first commit
This commit is contained in:
65
app/adminapi/logic/setting/CustomerServiceLogic.php
Normal file
65
app/adminapi/logic/setting/CustomerServiceLogic.php
Normal file
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\adminapi\logic\setting;
|
||||
|
||||
use app\common\logic\BaseLogic;
|
||||
use app\common\service\ConfigService;
|
||||
use app\common\service\FileService;
|
||||
|
||||
/**
|
||||
* 客服设置逻辑
|
||||
* Class CustomerServiceLogic
|
||||
* @package app\adminapi\logic\setting
|
||||
*/
|
||||
class CustomerServiceLogic extends BaseLogic
|
||||
{
|
||||
/**
|
||||
* @notes 获取客服设置
|
||||
* @return array
|
||||
* @author ljj
|
||||
* @date 2022/2/15 12:05 下午
|
||||
*/
|
||||
public static function getConfig()
|
||||
{
|
||||
$qrCode = ConfigService::get('customer_service', 'qr_code');
|
||||
$qrCode = empty($qrCode) ? '' : FileService::getFileUrl($qrCode);
|
||||
$config = [
|
||||
'qr_code' => $qrCode,
|
||||
'wechat' => ConfigService::get('customer_service', 'wechat', ''),
|
||||
'phone' => ConfigService::get('customer_service', 'phone', ''),
|
||||
'service_time' => ConfigService::get('customer_service', 'service_time', ''),
|
||||
];
|
||||
return $config;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 设置客服设置
|
||||
* @param $params
|
||||
* @author ljj
|
||||
* @date 2022/2/15 12:11 下午
|
||||
*/
|
||||
public static function setConfig($params)
|
||||
{
|
||||
$allowField = ['qr_code','wechat','phone','service_time'];
|
||||
foreach($params as $key => $value) {
|
||||
if(in_array($key, $allowField)) {
|
||||
if ($key == 'qr_code') {
|
||||
$value = FileService::setFileUrl($value);
|
||||
}
|
||||
ConfigService::set('customer_service', $key, $value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
157
app/adminapi/logic/setting/LanguageLogic.php
Normal file
157
app/adminapi/logic/setting/LanguageLogic.php
Normal file
@@ -0,0 +1,157 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\adminapi\logic\setting;
|
||||
|
||||
use app\common\enum\YesNoEnum;
|
||||
use app\common\model\setting\Language;
|
||||
use app\common\logic\BaseLogic;
|
||||
use think\facade\Db;
|
||||
|
||||
|
||||
/**
|
||||
* 语言包逻辑
|
||||
* Class LanguageLogic
|
||||
* @package app\adminapi\logic\setting
|
||||
*/
|
||||
class LanguageLogic extends BaseLogic
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加语言包
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author likeadmin
|
||||
* @date 2023/11/30 13:59
|
||||
*/
|
||||
public static function add(array $params): bool
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
Language::create([
|
||||
'name' => $params['name'],
|
||||
'name_loc' => $params['name_loc'],
|
||||
'symbol' => $params['symbol'],
|
||||
'trans_symbol' => $params['trans_symbol'],
|
||||
'logo' => $params['logo'],
|
||||
'precision' => $params['precision'],
|
||||
'time_format' => $params['time_format'],
|
||||
'is_show' => $params['is_show'],
|
||||
'sort' => $params['sort']
|
||||
]);
|
||||
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
self::setError($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑语言包
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author likeadmin
|
||||
* @date 2023/11/30 13:59
|
||||
*/
|
||||
public static function edit(array $params): bool
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
Language::where('id', $params['id'])->update([
|
||||
'name' => $params['name'],
|
||||
'name_loc' => $params['name_loc'],
|
||||
'symbol' => $params['symbol'],
|
||||
'trans_symbol' => $params['trans_symbol'],
|
||||
'logo' => $params['logo'],
|
||||
'precision' => $params['precision'],
|
||||
'time_format' => $params['time_format'],
|
||||
'is_show' => $params['is_show'],
|
||||
'sort' => $params['sort']
|
||||
]);
|
||||
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
self::setError($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除语言包
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author likeadmin
|
||||
* @date 2023/11/30 13:59
|
||||
*/
|
||||
public static function delete(array $params): bool
|
||||
{
|
||||
return Language::destroy($params['id']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取语言包详情
|
||||
* @param $params
|
||||
* @return array
|
||||
* @author likeadmin
|
||||
* @date 2023/11/30 13:59
|
||||
*/
|
||||
public static function detail($params): array
|
||||
{
|
||||
return Language::findOrEmpty($params['id'])->toArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 更改状态
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author heshihu
|
||||
* @date 2022/2/22 10:18
|
||||
*/
|
||||
public static function updateStatus(array $params)
|
||||
{
|
||||
Language::update([
|
||||
'id' => $params['id'],
|
||||
'is_show' => $params['is_show']
|
||||
]);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 语言包数据
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author 段誉
|
||||
* @date 2022/10/13 10:53
|
||||
*/
|
||||
public static function getAllData()
|
||||
{
|
||||
return Language::where(['is_show' => YesNoEnum::YES])
|
||||
->order(['sort' => 'desc', 'id' => 'desc'])
|
||||
->select()
|
||||
->toArray();
|
||||
}
|
||||
|
||||
}
|
||||
236
app/adminapi/logic/setting/LanguagePagLogic.php
Normal file
236
app/adminapi/logic/setting/LanguagePagLogic.php
Normal file
@@ -0,0 +1,236 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\adminapi\logic\setting;
|
||||
|
||||
use app\common\service\{UtilsService};
|
||||
use app\common\model\setting\{LanguagePag,Language};
|
||||
use app\common\logic\BaseLogic;
|
||||
use think\facade\Db;
|
||||
|
||||
|
||||
/**
|
||||
* 语言包逻辑
|
||||
* Class LanguagePagLogic
|
||||
* @package app\adminapi\logic\setting
|
||||
*/
|
||||
class LanguagePagLogic extends BaseLogic
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加语言包
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author likeadmin
|
||||
* @date 2024/01/14 13:50
|
||||
*/
|
||||
public static function add(array $params): bool
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
//查询是否存在
|
||||
$pag = LanguagePag::where(['lang' => $params['lang'],'type' => $params['type'],'name' => $params['name']])->findOrEmpty();
|
||||
if (!$pag->isEmpty()) {
|
||||
throw new \Exception('语言包已存在');
|
||||
}
|
||||
|
||||
LanguagePag::create([
|
||||
'lang' => $params['lang'],
|
||||
'type' => $params['type'],
|
||||
'name' => $params['name'],
|
||||
'value' => $params['value']
|
||||
]);
|
||||
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
self::setError($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑语言包
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author likeadmin
|
||||
* @date 2024/01/14 13:50
|
||||
*/
|
||||
public static function edit(array $params): bool
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
LanguagePag::where('id', $params['id'])->update([
|
||||
'lang' => $params['lang'],
|
||||
'type' => $params['type'],
|
||||
'name' => $params['name'],
|
||||
'value' => $params['value']
|
||||
]);
|
||||
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
self::setError($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除语言包
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author likeadmin
|
||||
* @date 2024/01/14 13:50
|
||||
*/
|
||||
public static function delete(array $params): bool
|
||||
{
|
||||
return LanguagePag::destroy($params['id']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取语言包详情
|
||||
* @param $params
|
||||
* @return array
|
||||
* @author likeadmin
|
||||
* @date 2024/01/14 13:50
|
||||
*/
|
||||
public static function detail($params): array
|
||||
{
|
||||
return LanguagePag::findOrEmpty($params['id'])->toArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 同步语言包
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author likeadmin
|
||||
* @date 2024/01/14 13:50
|
||||
*/
|
||||
public static function sync(array $params): bool
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
//获取源语言
|
||||
$from = Language::find($params['from_id']);
|
||||
if ($from->isEmpty()) {
|
||||
throw new \Exception('源语言不存在');
|
||||
}
|
||||
|
||||
//获取目标语言
|
||||
$to = Language::find($params['to_id']);
|
||||
if ($to->isEmpty()) {
|
||||
throw new \Exception('目标语言不存在');
|
||||
}
|
||||
|
||||
//获取源语言
|
||||
$pags = LanguagePag::where(['lang' => $from['symbol']])
|
||||
->order(['type' => 'desc','name' => 'desc'])
|
||||
->select()
|
||||
->toArray();
|
||||
|
||||
foreach ($pags as &$pag) {
|
||||
//查询是否存在
|
||||
$to_pag = LanguagePag::where(['lang' => $to['symbol'],'type' => $pag['type'],'name' => $pag['name']])->findOrEmpty();
|
||||
if ($to_pag->isEmpty()) {
|
||||
LanguagePag::create([
|
||||
'lang' => $to['symbol'],
|
||||
'type' => $pag['type'],
|
||||
'name' => $pag['name'],
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
self::setError($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 翻译语言包
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author likeadmin
|
||||
* @date 2024/01/14 13:50
|
||||
*/
|
||||
public static function trans(array $params): bool
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
//获取源语言
|
||||
$from = Language::find($params['from_id']);
|
||||
if ($from->isEmpty()) {
|
||||
throw new \Exception('源语言不存在');
|
||||
}
|
||||
|
||||
//获取目标语言
|
||||
$to = Language::find($params['to_id']);
|
||||
if ($to->isEmpty()) {
|
||||
throw new \Exception('目标语言不存在');
|
||||
}
|
||||
|
||||
|
||||
//获取待翻译目标语言
|
||||
$pags = LanguagePag::where(['lang' => $to['symbol']])
|
||||
->where(" value IS NULL OR value='' ")
|
||||
->order(['type' => 'desc','name' => 'desc'])
|
||||
->select()
|
||||
->toArray();
|
||||
|
||||
$qArray = array();
|
||||
|
||||
$idArray = array();
|
||||
foreach ($pags as &$pag) {
|
||||
//查询源语言
|
||||
$from_pag = LanguagePag::where(['lang' => $from['symbol'],'type' => $pag['type'],'name' => $pag['name']])->where(" value IS NOT NULL OR value='' ")->findOrEmpty();
|
||||
if($from_pag->isEmpty()){
|
||||
continue;
|
||||
}else{
|
||||
array_push($qArray, $from_pag['value']);
|
||||
array_push($idArray, $pag['id']);
|
||||
}
|
||||
}
|
||||
|
||||
if(count($qArray) == 0) throw new \Exception('不存在待翻译的内容');
|
||||
|
||||
$ret = UtilsService::do_translate($qArray,$from['trans_symbol'],$to['trans_symbol']);
|
||||
$ret = json_decode($ret, true);
|
||||
if($ret['errorCode'] != 0){
|
||||
throw new \Exception('错误代码:'.$ret['errorCode'].',请核对错误代码列表');
|
||||
}
|
||||
foreach ($idArray as $key=>$id) {
|
||||
LanguagePag::update([
|
||||
'id' => $id,
|
||||
'value' => $ret['translateResults'][$key]['translation'],
|
||||
]);
|
||||
}
|
||||
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
self::setError($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
184
app/adminapi/logic/setting/RechargeMethodLogic.php
Normal file
184
app/adminapi/logic/setting/RechargeMethodLogic.php
Normal file
@@ -0,0 +1,184 @@
|
||||
<?php
|
||||
namespace app\adminapi\logic\setting;
|
||||
|
||||
|
||||
use app\common\model\setting\RechargeMethod;
|
||||
use app\common\logic\BaseLogic;
|
||||
use think\facade\Db;
|
||||
use app\common\service\{ConfigService, FileService};
|
||||
use app\common\model\setting\Language;
|
||||
use app\common\enum\YesNoEnum;
|
||||
|
||||
|
||||
/**
|
||||
* 充值方式逻辑
|
||||
* Class RechargeMethodLogic
|
||||
* @package app\adminapi\logic\setting
|
||||
*/
|
||||
class RechargeMethodLogic extends BaseLogic
|
||||
{
|
||||
/**
|
||||
* @notes 添加充值方式
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author BD
|
||||
* @date 2023/11/30 15:22
|
||||
*/
|
||||
public static function add(array $params): bool
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
RechargeMethod::create([
|
||||
'lang_id' => $params['lang_id'],
|
||||
'type' => $params['type'],
|
||||
'name' => $params['name'],
|
||||
'logo' => $params['logo'] ? FileService::setFileUrl($params['logo']) : '',
|
||||
'account' => $params['account'],
|
||||
'img' => $params['img'] ? FileService::setFileUrl($params['img']) : '',
|
||||
'bank_name' => $params['bank_name'],
|
||||
'bank_username' => $params['bank_username'],
|
||||
'main_coin_type' => $params['main_coin_type'],
|
||||
'coin_type' => $params['coin_type'],
|
||||
'protocol' => $params['protocol'],
|
||||
'address' => $params['address'],
|
||||
'member_id' => $params['member_id'],
|
||||
'avail_num' => $params['avail_num'],
|
||||
'rate' => $params['rate'],
|
||||
'symbol_rate' => $params['symbol_rate'],
|
||||
'precision' => $params['precision'],
|
||||
'symbol' => $params['symbol'],
|
||||
'is_show' => $params['is_show'],
|
||||
'is_voucher' => $params['is_voucher'],
|
||||
'sort' => $params['sort']
|
||||
]);
|
||||
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
self::setError($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑充值方式
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author BD
|
||||
* @date 2023/11/30 15:22
|
||||
*/
|
||||
public static function edit(array $params): bool
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
RechargeMethod::where('id', $params['id'])->update([
|
||||
'lang_id' => $params['lang_id'],
|
||||
'type' => $params['type'],
|
||||
'name' => $params['name'],
|
||||
'logo' => $params['logo'] ? FileService::setFileUrl($params['logo']) : '',
|
||||
'account' => $params['account'],
|
||||
'img' => $params['img'] ? FileService::setFileUrl($params['img']) : '',
|
||||
'bank_name' => $params['bank_name'],
|
||||
'bank_username' => $params['bank_username'],
|
||||
'main_coin_type' => $params['main_coin_type'],
|
||||
'coin_type' => $params['coin_type'],
|
||||
'protocol' => $params['protocol'],
|
||||
'address' => $params['address'],
|
||||
'member_id' => $params['member_id'],
|
||||
'avail_num' => $params['avail_num'],
|
||||
'rate' => $params['rate'],
|
||||
'symbol_rate' => $params['symbol_rate'],
|
||||
'precision' => $params['precision'],
|
||||
'symbol' => $params['symbol'],
|
||||
'is_show' => $params['is_show'],
|
||||
'is_voucher' => $params['is_voucher'],
|
||||
'sort' => $params['sort']
|
||||
]);
|
||||
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
self::setError($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除充值方式
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author BD
|
||||
* @date 2023/11/30 15:22
|
||||
*/
|
||||
public static function delete(array $params): bool
|
||||
{
|
||||
return RechargeMethod::destroy($params['id']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取充值方式详情
|
||||
* @param $params
|
||||
* @return array
|
||||
* @author BD
|
||||
* @date 2023/11/30 15:22
|
||||
*/
|
||||
public static function detail($params): array
|
||||
{
|
||||
$method = RechargeMethod::findOrEmpty($params['id'])->toArray();
|
||||
$method['logo'] = FileService::getFileUrl($method['logo']);
|
||||
$method['img'] = FileService::getFileUrl($method['img']);
|
||||
return $method;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 更改状态
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author heshihu
|
||||
* @date 2022/2/22 10:18
|
||||
*/
|
||||
public static function updateStatus(array $params)
|
||||
{
|
||||
RechargeMethod::update([
|
||||
'id' => $params['id'],
|
||||
'is_show' => $params['is_show']
|
||||
]);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 充值方式数据
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author 段誉
|
||||
* @date 2022/10/13 10:53
|
||||
*/
|
||||
public static function getAllData()
|
||||
{
|
||||
$field = 'id,name,lang_id';
|
||||
|
||||
$methods = RechargeMethod::field($field)
|
||||
->where(['is_show' => YesNoEnum::YES])
|
||||
->order(['sort' => 'desc', 'id' => 'desc'])
|
||||
->select()
|
||||
->toArray();
|
||||
|
||||
foreach ($methods as &$method) {
|
||||
$method['lang_name'] = '通用';
|
||||
if($method['lang_id'] != 0){
|
||||
$language = Language::where(['id' => $method['lang_id']])->findOrEmpty();
|
||||
if(!$language->isEmpty()){
|
||||
$method['lang_name'] = $language['name'];
|
||||
}
|
||||
}
|
||||
}
|
||||
return $methods;
|
||||
}
|
||||
}
|
||||
203
app/adminapi/logic/setting/StorageLogic.php
Normal file
203
app/adminapi/logic/setting/StorageLogic.php
Normal file
@@ -0,0 +1,203 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\adminapi\logic\setting;
|
||||
|
||||
|
||||
use app\common\logic\BaseLogic;
|
||||
use app\common\service\ConfigService;
|
||||
use think\facade\Cache;
|
||||
|
||||
|
||||
/**
|
||||
* 存储设置逻辑层
|
||||
* Class ShopStorageLogic
|
||||
* @package app\adminapi\logic\setting\
|
||||
*/
|
||||
class StorageLogic extends BaseLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @notes 存储引擎列表
|
||||
* @return array[]
|
||||
* @author 段誉
|
||||
* @date 2022/4/20 16:14
|
||||
*/
|
||||
public static function lists()
|
||||
{
|
||||
|
||||
$default = ConfigService::get('storage', 'default', 'local');
|
||||
|
||||
$data = [
|
||||
[
|
||||
'name' => '本地存储',
|
||||
'path' => '存储在本地服务器',
|
||||
'engine' => 'local',
|
||||
'status' => $default == 'local' ? 1 : 0
|
||||
],
|
||||
[
|
||||
'name' => '七牛云存储',
|
||||
'path' => '存储在七牛云,请前往七牛云开通存储服务',
|
||||
'engine' => 'qiniu',
|
||||
'status' => $default == 'qiniu' ? 1 : 0
|
||||
],
|
||||
[
|
||||
'name' => '阿里云OSS',
|
||||
'path' => '存储在阿里云,请前往阿里云开通存储服务',
|
||||
'engine' => 'aliyun',
|
||||
'status' => $default == 'aliyun' ? 1 : 0
|
||||
],
|
||||
[
|
||||
'name' => '腾讯云COS',
|
||||
'path' => '存储在腾讯云,请前往腾讯云开通存储服务',
|
||||
'engine' => 'qcloud',
|
||||
'status' => $default == 'qcloud' ? 1 : 0
|
||||
]
|
||||
];
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 存储设置详情
|
||||
* @param $param
|
||||
* @return mixed
|
||||
* @author 段誉
|
||||
* @date 2022/4/20 16:15
|
||||
*/
|
||||
public static function detail($param)
|
||||
{
|
||||
|
||||
$default = ConfigService::get('storage', 'default', '');
|
||||
|
||||
// 本地存储
|
||||
$local = ['status' => $default == 'local' ? 1 : 0];
|
||||
// 七牛云存储
|
||||
$qiniu = ConfigService::get('storage', 'qiniu', [
|
||||
'bucket' => '',
|
||||
'access_key' => '',
|
||||
'secret_key' => '',
|
||||
'domain' => '',
|
||||
'status' => $default == 'qiniu' ? 1 : 0
|
||||
]);
|
||||
|
||||
// 阿里云存储
|
||||
$aliyun = ConfigService::get('storage', 'aliyun', [
|
||||
'bucket' => '',
|
||||
'access_key' => '',
|
||||
'secret_key' => '',
|
||||
'domain' => '',
|
||||
'status' => $default == 'aliyun' ? 1 : 0
|
||||
]);
|
||||
|
||||
// 腾讯云存储
|
||||
$qcloud = ConfigService::get('storage', 'qcloud', [
|
||||
'bucket' => '',
|
||||
'region' => '',
|
||||
'access_key' => '',
|
||||
'secret_key' => '',
|
||||
'domain' => '',
|
||||
'status' => $default == 'qcloud' ? 1 : 0
|
||||
]);
|
||||
|
||||
$data = [
|
||||
'local' => $local,
|
||||
'qiniu' => $qiniu,
|
||||
'aliyun' => $aliyun,
|
||||
'qcloud' => $qcloud
|
||||
];
|
||||
$result = $data[$param['engine']];
|
||||
if ($param['engine'] == $default) {
|
||||
$result['status'] = 1;
|
||||
} else {
|
||||
$result['status'] = 0;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 设置存储参数
|
||||
* @param $params
|
||||
* @return bool|string
|
||||
* @author 段誉
|
||||
* @date 2022/4/20 16:16
|
||||
*/
|
||||
public static function setup($params)
|
||||
{
|
||||
if ($params['status'] == 1) { //状态为开启
|
||||
ConfigService::set('storage', 'default', $params['engine']);
|
||||
} else {
|
||||
ConfigService::set('storage', 'default', 'local');
|
||||
}
|
||||
|
||||
switch ($params['engine']) {
|
||||
case 'local':
|
||||
ConfigService::set('storage', 'local', []);
|
||||
break;
|
||||
case 'qiniu':
|
||||
ConfigService::set('storage', 'qiniu', [
|
||||
'bucket' => $params['bucket'] ?? '',
|
||||
'access_key' => $params['access_key'] ?? '',
|
||||
'secret_key' => $params['secret_key'] ?? '',
|
||||
'domain' => $params['domain'] ?? ''
|
||||
]);
|
||||
break;
|
||||
case 'aliyun':
|
||||
ConfigService::set('storage', 'aliyun', [
|
||||
'bucket' => $params['bucket'] ?? '',
|
||||
'access_key' => $params['access_key'] ?? '',
|
||||
'secret_key' => $params['secret_key'] ?? '',
|
||||
'domain' => $params['domain'] ?? ''
|
||||
]);
|
||||
break;
|
||||
case 'qcloud':
|
||||
ConfigService::set('storage', 'qcloud', [
|
||||
'bucket' => $params['bucket'] ?? '',
|
||||
'region' => $params['region'] ?? '',
|
||||
'access_key' => $params['access_key'] ?? '',
|
||||
'secret_key' => $params['secret_key'] ?? '',
|
||||
'domain' => $params['domain'] ?? '',
|
||||
]);
|
||||
break;
|
||||
}
|
||||
|
||||
Cache::delete('STORAGE_DEFAULT');
|
||||
Cache::delete('STORAGE_ENGINE');
|
||||
if ($params['engine'] == 'local' && $params['status'] == 0) {
|
||||
return '默认开启本地存储';
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 切换状态
|
||||
* @param $params
|
||||
* @author 段誉
|
||||
* @date 2022/4/20 16:17
|
||||
*/
|
||||
public static function change($params)
|
||||
{
|
||||
$default = ConfigService::get('storage', 'default', '');
|
||||
if ($default == $params['engine']) {
|
||||
ConfigService::set('storage', 'default', 'local');
|
||||
} else {
|
||||
ConfigService::set('storage', 'default', $params['engine']);
|
||||
}
|
||||
Cache::delete('STORAGE_DEFAULT');
|
||||
Cache::delete('STORAGE_ENGINE');
|
||||
}
|
||||
}
|
||||
64
app/adminapi/logic/setting/TransactionSettingsLogic.php
Normal file
64
app/adminapi/logic/setting/TransactionSettingsLogic.php
Normal file
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\adminapi\logic\setting;
|
||||
|
||||
use app\common\logic\BaseLogic;
|
||||
use app\common\service\ConfigService;
|
||||
|
||||
/**
|
||||
* 交易设置逻辑
|
||||
* Class TransactionSettingsLogic
|
||||
* @package app\adminapi\logic\setting
|
||||
*/
|
||||
class TransactionSettingsLogic extends BaseLogic
|
||||
{
|
||||
/**
|
||||
* @notes 获取交易设置
|
||||
* @return array
|
||||
* @author ljj
|
||||
* @date 2022/2/15 11:40 上午
|
||||
*/
|
||||
public static function getConfig()
|
||||
{
|
||||
$config = [
|
||||
'cancel_unpaid_orders' => ConfigService::get('transaction', 'cancel_unpaid_orders', 1),
|
||||
'cancel_unpaid_orders_times' => ConfigService::get('transaction', 'cancel_unpaid_orders_times', 30),
|
||||
'verification_orders' => ConfigService::get('transaction', 'verification_orders', 1),
|
||||
'verification_orders_times' => ConfigService::get('transaction', 'verification_orders_times', 24),
|
||||
];
|
||||
|
||||
return $config;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 设置交易设置
|
||||
* @param $params
|
||||
* @author ljj
|
||||
* @date 2022/2/15 11:49 上午
|
||||
*/
|
||||
public static function setConfig($params)
|
||||
{
|
||||
ConfigService::set('transaction', 'cancel_unpaid_orders', $params['cancel_unpaid_orders']);
|
||||
ConfigService::set('transaction', 'verification_orders', $params['verification_orders']);
|
||||
|
||||
if (isset($params['cancel_unpaid_orders_times'])) {
|
||||
ConfigService::set('transaction', 'cancel_unpaid_orders_times', $params['cancel_unpaid_orders_times']);
|
||||
}
|
||||
|
||||
if (isset($params['verification_orders_times'])) {
|
||||
ConfigService::set('transaction', 'verification_orders_times', $params['verification_orders_times']);
|
||||
}
|
||||
}
|
||||
}
|
||||
84
app/adminapi/logic/setting/dict/DictDataLogic.php
Normal file
84
app/adminapi/logic/setting/dict/DictDataLogic.php
Normal file
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\adminapi\logic\setting\dict;
|
||||
|
||||
use app\common\logic\BaseLogic;
|
||||
use app\common\model\dict\DictData;
|
||||
use app\common\model\dict\DictType;
|
||||
|
||||
|
||||
/**
|
||||
* 字典数据逻辑
|
||||
* Class DictDataLogic
|
||||
* @package app\adminapi\logic\DictData
|
||||
*/
|
||||
class DictDataLogic extends BaseLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @notes 添加编辑
|
||||
* @param array $params
|
||||
* @return DictData|\think\Model
|
||||
* @author 段誉
|
||||
* @date 2022/6/20 17:13
|
||||
*/
|
||||
public static function save(array $params)
|
||||
{
|
||||
$data = [
|
||||
'name' => $params['name'],
|
||||
'value' => $params['value'],
|
||||
'sort' => $params['sort'] ?? 0,
|
||||
'status' => $params['status'],
|
||||
'remark' => $params['remark'] ?? '',
|
||||
];
|
||||
|
||||
if (!empty($params['id'])) {
|
||||
return DictData::where(['id' => $params['id']])->update($data);
|
||||
} else {
|
||||
$dictType = DictType::findOrEmpty($params['type_id']);
|
||||
$data['type_id'] = $params['type_id'];
|
||||
$data['type_value'] = $dictType['type'];
|
||||
return DictData::create($data);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除字典数据
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author 段誉
|
||||
* @date 2022/6/20 17:01
|
||||
*/
|
||||
public static function delete(array $params)
|
||||
{
|
||||
return DictData::destroy($params['id']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取字典数据详情
|
||||
* @param $params
|
||||
* @return array
|
||||
* @author 段誉
|
||||
* @date 2022/6/20 17:01
|
||||
*/
|
||||
public static function detail($params): array
|
||||
{
|
||||
return DictData::findOrEmpty($params['id'])->toArray();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
111
app/adminapi/logic/setting/dict/DictTypeLogic.php
Normal file
111
app/adminapi/logic/setting/dict/DictTypeLogic.php
Normal file
@@ -0,0 +1,111 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\adminapi\logic\setting\dict;
|
||||
|
||||
use app\common\enum\YesNoEnum;
|
||||
use app\common\logic\BaseLogic;
|
||||
use app\common\model\dict\DictData;
|
||||
use app\common\model\dict\DictType;
|
||||
|
||||
|
||||
/**
|
||||
* 字典类型逻辑
|
||||
* Class DictTypeLogic
|
||||
* @package app\adminapi\logic\dict
|
||||
*/
|
||||
class DictTypeLogic extends BaseLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @notes 添加字典类型
|
||||
* @param array $params
|
||||
* @return DictType|\think\Model
|
||||
* @author 段誉
|
||||
* @date 2022/6/20 16:08
|
||||
*/
|
||||
public static function add(array $params)
|
||||
{
|
||||
return DictType::create([
|
||||
'name' => $params['name'],
|
||||
'type' => $params['type'],
|
||||
'status' => $params['status'],
|
||||
'remark' => $params['remark'] ?? '',
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑字典类型
|
||||
* @param array $params
|
||||
* @author 段誉
|
||||
* @date 2022/6/20 16:10
|
||||
*/
|
||||
public static function edit(array $params)
|
||||
{
|
||||
DictType::update([
|
||||
'id' => $params['id'],
|
||||
'name' => $params['name'],
|
||||
'type' => $params['type'],
|
||||
'status' => $params['status'],
|
||||
'remark' => $params['remark'] ?? '',
|
||||
]);
|
||||
|
||||
DictData::where(['type_id' => $params['id']])
|
||||
->update(['type_value' => $params['type']]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除字典类型
|
||||
* @param array $params
|
||||
* @author 段誉
|
||||
* @date 2022/6/20 16:23
|
||||
*/
|
||||
public static function delete(array $params)
|
||||
{
|
||||
DictType::destroy($params['id']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取字典详情
|
||||
* @param $params
|
||||
* @return array
|
||||
* @author 段誉
|
||||
* @date 2022/6/20 16:23
|
||||
*/
|
||||
public static function detail($params): array
|
||||
{
|
||||
return DictType::findOrEmpty($params['id'])->toArray();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 角色数据
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author 段誉
|
||||
* @date 2022/10/13 10:44
|
||||
*/
|
||||
public static function getAllData()
|
||||
{
|
||||
return DictType::where(['status' => YesNoEnum::YES])
|
||||
->order(['id' => 'desc'])
|
||||
->select()
|
||||
->toArray();
|
||||
}
|
||||
}
|
||||
37
app/adminapi/logic/setting/system/CacheLogic.php
Normal file
37
app/adminapi/logic/setting/system/CacheLogic.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\adminapi\logic\setting\system;
|
||||
|
||||
use app\common\logic\BaseLogic;
|
||||
use think\facade\Cache;
|
||||
|
||||
/**
|
||||
* 系统缓存逻辑
|
||||
* Class CacheLogic
|
||||
* @package app\adminapi\logic\setting\system
|
||||
*/
|
||||
class CacheLogic extends BaseLogic
|
||||
{
|
||||
/**
|
||||
* @notes 清楚系统缓存
|
||||
* @author 段誉
|
||||
* @date 2022/4/8 16:29
|
||||
*/
|
||||
public static function clear()
|
||||
{
|
||||
Cache::clear();
|
||||
del_target_dir(app()->getRootPath().'runtime/file',true);
|
||||
}
|
||||
}
|
||||
71
app/adminapi/logic/setting/system/OperationLogLogic.php
Normal file
71
app/adminapi/logic/setting/system/OperationLogLogic.php
Normal file
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\adminapi\logic\setting\system;
|
||||
|
||||
use app\common\logic\BaseLogic;
|
||||
use app\common\model\setting\OperationLog;
|
||||
use think\facade\Db;
|
||||
|
||||
|
||||
/**
|
||||
* 生成器逻辑
|
||||
* Class OperationLogLogic
|
||||
* @package app\adminapi\logic\setting\system
|
||||
*/
|
||||
class OperationLogLogic extends BaseLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @notes 删除表相关信息
|
||||
* @param $params
|
||||
* @return bool
|
||||
* @author 段誉
|
||||
* @date 2022/6/16 9:30
|
||||
*/
|
||||
public static function deleteTable($params)
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
OperationLog::whereIn('id', $params['id'])->delete();
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
self::$error = $e->getMessage();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 删除日志
|
||||
* @param $params
|
||||
* @return bool
|
||||
* @author 段誉
|
||||
* @date 2022/6/16 9:30
|
||||
*/
|
||||
public static function deleteAll()
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
OperationLog::where('create_time > 0')->delete();
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
self::$error = $e->getMessage();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
65
app/adminapi/logic/setting/system/SystemLogic.php
Normal file
65
app/adminapi/logic/setting/system/SystemLogic.php
Normal file
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\adminapi\logic\setting\system;
|
||||
|
||||
|
||||
use app\common\logic\BaseLogic;
|
||||
|
||||
/**
|
||||
* Class SystemLogic
|
||||
* @package app\adminapi\logic\setting\system
|
||||
*/
|
||||
class SystemLogic extends BaseLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @notes 系统环境信息
|
||||
* @return \array[][]
|
||||
* @author 段誉
|
||||
* @date 2021/12/28 18:35
|
||||
*/
|
||||
public static function getInfo() : array
|
||||
{
|
||||
$server = [
|
||||
['param' => '服务器操作系统', 'value' => PHP_OS],
|
||||
['param' => 'web服务器环境', 'value' => $_SERVER['SERVER_SOFTWARE']],
|
||||
['param' => 'PHP版本', 'value' => PHP_VERSION],
|
||||
];
|
||||
|
||||
$env = [
|
||||
[ 'option' => 'PHP版本',
|
||||
'require' => '8.0版本以上',
|
||||
'status' => (int)compare_php('8.0.0'),
|
||||
'remark' => ''
|
||||
]
|
||||
];
|
||||
|
||||
$auth = [
|
||||
[
|
||||
'dir' => '/runtime',
|
||||
'require' => 'runtime目录可写',
|
||||
'status' => (int)check_dir_write('runtime'),
|
||||
'remark' => ''
|
||||
],
|
||||
];
|
||||
|
||||
return [
|
||||
'server' => $server,
|
||||
'env' => $env,
|
||||
'auth' => $auth,
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
120
app/adminapi/logic/setting/user/UserLogic.php
Normal file
120
app/adminapi/logic/setting/user/UserLogic.php
Normal file
@@ -0,0 +1,120 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\adminapi\logic\setting\user;
|
||||
|
||||
use app\common\service\{ConfigService, FileService};
|
||||
|
||||
/**
|
||||
* 设置-用户设置逻辑层
|
||||
* Class UserLogic
|
||||
* @package app\adminapi\logic\config
|
||||
*/
|
||||
class UserLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @notes 获取用户设置
|
||||
* @return array
|
||||
* @author 段誉
|
||||
* @date 2022/3/29 10:09
|
||||
*/
|
||||
public static function getConfig(): array
|
||||
{
|
||||
$defaultAvatar = FileService::getFileUrl(config('project.default_image.user_avatar'));
|
||||
$config = [
|
||||
//默认头像
|
||||
'default_avatar' => FileService::getFileUrl(ConfigService::get('default_image', 'user_avatar', $defaultAvatar)),
|
||||
];
|
||||
return $config;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 设置用户设置
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author 段誉
|
||||
* @date 2022/3/29 10:09
|
||||
*/
|
||||
public function setConfig(array $params): bool
|
||||
{
|
||||
$avatar = FileService::setFileUrl($params['default_avatar']);
|
||||
ConfigService::set('default_image', 'user_avatar', $avatar);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取注册配置
|
||||
* @return array
|
||||
* @author 段誉
|
||||
* @date 2022/3/29 10:10
|
||||
*/
|
||||
public function getRegisterConfig(): array
|
||||
{
|
||||
$config = [
|
||||
// 登录方式
|
||||
'login_way' => ConfigService::get('login', 'login_way', config('project.login.login_way')),
|
||||
// 注册强制绑定手机
|
||||
'coerce_mobile' => ConfigService::get('login', 'coerce_mobile', config('project.login.coerce_mobile')),
|
||||
// 政策协议
|
||||
'login_agreement' => ConfigService::get('login', 'login_agreement', config('project.login.login_agreement')),
|
||||
// 第三方登录 开关
|
||||
'third_auth' => ConfigService::get('login', 'third_auth', config('project.login.third_auth')),
|
||||
// 微信授权登录
|
||||
'wechat_auth' => ConfigService::get('login', 'wechat_auth', config('project.login.wechat_auth')),
|
||||
// qq授权登录
|
||||
'qq_auth' => ConfigService::get('login', 'qq_auth', config('project.login.qq_auth')),
|
||||
// 国家区号
|
||||
'country_code' => ConfigService::get('login', 'country_code', config('project.login.country_code')),
|
||||
// 初始支付密码
|
||||
'password_pay' => ConfigService::get('login', 'password_pay', config('project.login.password_pay')),
|
||||
// 邀请码
|
||||
'invite_code' => ConfigService::get('login', 'invite_code', config('project.login.invite_code')),
|
||||
];
|
||||
return $config;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 设置登录注册
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author 段誉
|
||||
* @date 2022/3/29 10:10
|
||||
*/
|
||||
public static function setRegisterConfig(array $params): bool
|
||||
{
|
||||
// 登录方式:1-账号密码登录;2-手机短信验证码登录
|
||||
ConfigService::set('login', 'login_way', $params['login_way']);
|
||||
// 注册强制绑定手机
|
||||
ConfigService::set('login', 'coerce_mobile', $params['coerce_mobile']);
|
||||
// 政策协议
|
||||
ConfigService::set('login', 'login_agreement', $params['login_agreement']);
|
||||
// 第三方授权登录
|
||||
ConfigService::set('login', 'third_auth', $params['third_auth']);
|
||||
// 微信授权登录
|
||||
ConfigService::set('login', 'wechat_auth', $params['wechat_auth']);
|
||||
// qq登录
|
||||
ConfigService::set('login', 'qq_auth', $params['qq_auth']);
|
||||
// 国家区号
|
||||
ConfigService::set('login', 'country_code', $params['country_code']);
|
||||
// 初始支付密码
|
||||
ConfigService::set('login', 'password_pay', $params['password_pay']);
|
||||
// 邀请码
|
||||
ConfigService::set('login', 'invite_code', $params['invite_code']);
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
357
app/adminapi/logic/setting/web/WebSettingLogic.php
Normal file
357
app/adminapi/logic/setting/web/WebSettingLogic.php
Normal file
@@ -0,0 +1,357 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\adminapi\logic\setting\web;
|
||||
|
||||
|
||||
use app\common\logic\BaseLogic;
|
||||
use app\common\service\ConfigService;
|
||||
use app\common\service\FileService;
|
||||
use app\common\model\withdraw\WithdrawMethod;
|
||||
use think\facade\Config;
|
||||
|
||||
|
||||
/**
|
||||
* 网站设置
|
||||
* Class WebSettingLogic
|
||||
* @package app\adminapi\logic\setting
|
||||
*/
|
||||
class WebSettingLogic extends BaseLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @notes 获取网站信息
|
||||
* @return array
|
||||
* @author BD
|
||||
* @date 2023/12/28 15:43
|
||||
*/
|
||||
public static function getWebsiteInfo(): array
|
||||
{
|
||||
$defaultAvatar = FileService::getFileUrl(config('project.default_image.user_avatar'));
|
||||
|
||||
return [
|
||||
'name' => ConfigService::get('website', 'name'),
|
||||
'log_way' => ConfigService::get('website', 'log_way'),
|
||||
'web_favicon' => FileService::getFileUrl(ConfigService::get('website', 'web_favicon')),
|
||||
'web_logo' => FileService::getFileUrl(ConfigService::get('website', 'web_logo')),
|
||||
'login_image' => FileService::getFileUrl(ConfigService::get('website', 'login_image')),
|
||||
// 订单提醒
|
||||
'warm' => ConfigService::get('website', 'warm', config('project.website.warm')),
|
||||
'shop_name' => ConfigService::get('website', 'shop_name'),
|
||||
'shop_logo' => FileService::getFileUrl(ConfigService::get('website', 'shop_logo')),
|
||||
'shop_logo2' => FileService::getFileUrl(ConfigService::get('website', 'shop_logo2')),
|
||||
'google_auth' => ConfigService::get('website', 'google_auth'),
|
||||
|
||||
'pc_logo' => FileService::getFileUrl(ConfigService::get('website', 'pc_logo')),
|
||||
'pc_title' => ConfigService::get('website', 'pc_title', ''),
|
||||
'pc_ico' => FileService::getFileUrl(ConfigService::get('website', 'pc_ico')),
|
||||
'pc_desc' => ConfigService::get('website', 'pc_desc', ''),
|
||||
'pc_keywords' => ConfigService::get('website', 'pc_keywords', ''),
|
||||
|
||||
'currency' => ConfigService::get('website', 'currency', ''),
|
||||
'currency2' => ConfigService::get('website', 'currency2', ''),
|
||||
'precision' => ConfigService::get('website', 'precision', ''),
|
||||
//默认头像
|
||||
'default_avatar' => FileService::getFileUrl(ConfigService::get('default_image', 'user_avatar', $defaultAvatar)),
|
||||
// 登录方式
|
||||
'login_way' => ConfigService::get('login', 'login_way', config('project.login.login_way')),
|
||||
// 注册强制绑定手机
|
||||
'coerce_mobile' => ConfigService::get('login', 'coerce_mobile', config('project.login.coerce_mobile')),
|
||||
// 国家区号
|
||||
// 'country_code' => ConfigService::get('login', 'country_code', config('project.login.country_code')),
|
||||
// 初始支付密码
|
||||
'password_pay' => ConfigService::get('login', 'password_pay', config('project.login.password_pay')),
|
||||
// 邀请码
|
||||
'invite_code' => ConfigService::get('login', 'invite_code', config('project.login.invite_code')),
|
||||
// 多处登录
|
||||
'multipoint_login' => ConfigService::get('login', 'multipoint_login', config('project.login.multipoint_login')),
|
||||
// app下载地址
|
||||
'down_link' => ConfigService::get('website', 'down_link'),
|
||||
// app下载状态
|
||||
'is_down' => ConfigService::get('website', 'is_down'),
|
||||
// IP可注册数量
|
||||
'ip_num' => ConfigService::get('login', 'ip_num'),
|
||||
// 前台链接
|
||||
'front_link' => ConfigService::get('website', 'front_link'),
|
||||
|
||||
'agent_name' => ConfigService::get('website', 'agent_name'),
|
||||
'agent_web_favicon' => FileService::getFileUrl(ConfigService::get('website', 'agent_web_favicon')),
|
||||
'agent_web_logo' => FileService::getFileUrl(ConfigService::get('website', 'agent_web_logo')),
|
||||
'agent_login_image' => FileService::getFileUrl(ConfigService::get('website', 'agent_login_image')),
|
||||
'agent_google_auth' => ConfigService::get('website', 'agent_google_auth'),
|
||||
|
||||
'kefu_logo' => FileService::getFileUrl(ConfigService::get('website', 'kefu_logo')),
|
||||
'show_kefu' => ConfigService::get('website', 'show_kefu'),
|
||||
'kefu_link' => ConfigService::get('website', 'kefu_link'),
|
||||
|
||||
'contract_y_logo' => FileService::getFileUrl(ConfigService::get('contract', 'contract_y_logo')),
|
||||
'contract_b_logo' => FileService::getFileUrl(ConfigService::get('contract', 'contract_b_logo')),
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 设置网站信息
|
||||
* @param array $params
|
||||
* @author BD
|
||||
* @date 2023/12/28 15:43
|
||||
*/
|
||||
public static function setWebsiteInfo(array $params)
|
||||
{
|
||||
$favicon = FileService::setFileUrl($params['web_favicon']);
|
||||
$logo = FileService::setFileUrl($params['web_logo']);
|
||||
$login = FileService::setFileUrl($params['login_image']);
|
||||
$shopLogo = FileService::setFileUrl($params['shop_logo']);
|
||||
$shopLogo2 = FileService::setFileUrl($params['shop_logo2']);
|
||||
$pcLogo = FileService::setFileUrl($params['pc_logo']);
|
||||
$pcIco = FileService::setFileUrl($params['pc_ico'] ?? '');
|
||||
$avatar = FileService::setFileUrl($params['default_avatar']);
|
||||
|
||||
ConfigService::set('website', 'name', $params['name']);
|
||||
ConfigService::set('website', 'log_way', $params['log_way']);
|
||||
ConfigService::set('website', 'web_favicon', $favicon);
|
||||
ConfigService::set('website', 'web_logo', $logo);
|
||||
ConfigService::set('website', 'login_image', $login);
|
||||
ConfigService::set('website', 'shop_name', $params['shop_name']);
|
||||
ConfigService::set('website', 'shop_logo', $shopLogo);
|
||||
ConfigService::set('website', 'shop_logo2', $shopLogo2);
|
||||
// 订单提醒
|
||||
ConfigService::set('website', 'warm', $params['warm']);
|
||||
ConfigService::set('website', 'google_auth', $params['google_auth']);
|
||||
|
||||
ConfigService::set('website', 'pc_logo', $pcLogo);
|
||||
ConfigService::set('website', 'pc_title', $params['pc_title']);
|
||||
ConfigService::set('website', 'pc_ico', $pcIco);
|
||||
ConfigService::set('website', 'pc_desc', $params['pc_desc'] ?? '');
|
||||
ConfigService::set('website', 'pc_keywords', $params['pc_keywords'] ?? '');
|
||||
|
||||
ConfigService::set('website', 'currency', $params['currency'] ?? '');
|
||||
ConfigService::set('website', 'currency2', $params['currency2'] ?? '');
|
||||
ConfigService::set('website', 'precision', $params['precision'] ?? '');
|
||||
|
||||
ConfigService::set('default_image', 'user_avatar', $avatar);
|
||||
|
||||
// 登录方式:1-账号密码登录;2-手机短信验证码登录
|
||||
ConfigService::set('login', 'login_way', $params['login_way']);
|
||||
// 注册强制绑定手机
|
||||
ConfigService::set('login', 'coerce_mobile', $params['coerce_mobile']);
|
||||
// 国家区号
|
||||
// ConfigService::set('login', 'country_code', $params['country_code']);
|
||||
// 初始支付密码
|
||||
ConfigService::set('login', 'password_pay', $params['password_pay']);
|
||||
// 邀请码
|
||||
ConfigService::set('login', 'invite_code', $params['invite_code']);
|
||||
// 多处登录
|
||||
ConfigService::set('login', 'multipoint_login', $params['multipoint_login']);
|
||||
// app下载地址
|
||||
ConfigService::set('website', 'down_link', $params['down_link']);
|
||||
// app下载状态
|
||||
ConfigService::set('website', 'is_down', $params['is_down']);
|
||||
// IP可注册数量
|
||||
ConfigService::set('login', 'ip_num', $params['ip_num']);
|
||||
// 前台链接
|
||||
ConfigService::set('website', 'front_link', $params['front_link']);
|
||||
|
||||
ConfigService::set('website', 'agent_name', $params['agent_name']);
|
||||
ConfigService::set('website', 'agent_web_favicon', FileService::setFileUrl($params['agent_web_favicon']));
|
||||
ConfigService::set('website', 'agent_web_logo', FileService::setFileUrl($params['agent_web_logo']));
|
||||
ConfigService::set('website', 'agent_login_image', FileService::setFileUrl($params['agent_login_image']));
|
||||
ConfigService::set('website', 'agent_google_auth', $params['agent_google_auth']);
|
||||
|
||||
ConfigService::set('website', 'kefu_logo', FileService::setFileUrl($params['kefu_logo']));
|
||||
ConfigService::set('website', 'show_kefu', $params['show_kefu']);
|
||||
ConfigService::set('website', 'kefu_link', $params['kefu_link']);
|
||||
|
||||
ConfigService::set('contract', 'contract_y_logo', FileService::setFileUrl($params['contract_y_logo']));
|
||||
ConfigService::set('contract', 'contract_b_logo', FileService::setFileUrl($params['contract_b_logo']));
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 获取网站配置
|
||||
* @param array $params
|
||||
* @return array
|
||||
* @author BD
|
||||
* @date 2023/12/28 15:43
|
||||
*/
|
||||
public static function getWebsiteProject(array $params)
|
||||
{
|
||||
try {
|
||||
$element = $params['name'];
|
||||
$array = ['distribute','reward','udun','email','trade','market','translation','kefu','tron','regioncode','mine'];
|
||||
if (!in_array($element, $array)) {
|
||||
throw new \Exception('参数异常');
|
||||
}
|
||||
$data = ConfigService::get('website', $params['name']);
|
||||
//有logo,替换域名
|
||||
if($element == 'market' || $element == 'kefu' || $element == 'regioncode'){
|
||||
if(!empty($data)){
|
||||
foreach ($data as &$item) {
|
||||
$item['logo'] = FileService::getFileUrl($item['logo']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Udun提现方式
|
||||
if($element == 'udun'){
|
||||
$field = 'id,name,is_open_df,main_coin_type,coin_type';
|
||||
|
||||
$methods = WithdrawMethod::field($field)
|
||||
->where(['is_show' => 1,'type' => 1])
|
||||
->order(['sort' => 'desc', 'id' => 'desc'])
|
||||
->select()
|
||||
->toArray();
|
||||
|
||||
$data['methods'] = $methods;
|
||||
|
||||
}
|
||||
|
||||
return ['data' => $data];
|
||||
} catch (\Exception $e) {
|
||||
self::$error = $e->getMessage();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 设置网站配置
|
||||
* @param array $params
|
||||
* @author BD
|
||||
* @date 2023/12/28 15:43
|
||||
*/
|
||||
public static function setWebsiteProject(array $params)
|
||||
{
|
||||
try {
|
||||
$element = $params['name'];
|
||||
$array = ['distribute','reward','udun','email','trade','market','translation','kefu','tron','regioncode','mine'];
|
||||
|
||||
if (!in_array($element, $array)) {
|
||||
throw new \Exception('参数异常');
|
||||
}
|
||||
$content = $params['content'];
|
||||
|
||||
//有logo,替换域名
|
||||
if($element == 'market' || $element == 'kefu' || $element == 'regioncode'){
|
||||
foreach ($content as &$item) {
|
||||
$item['logo'] = FileService::setFileUrl($item['logo']);
|
||||
}
|
||||
}
|
||||
|
||||
//Udun提现方式
|
||||
if($element == 'udun'){
|
||||
|
||||
$methods = $content['methods'];
|
||||
foreach ($methods as &$method) {
|
||||
WithdrawMethod::update([
|
||||
'id' => $method['id'],
|
||||
'is_open_df' => $method['is_open_df'],
|
||||
'main_coin_type' => $method['main_coin_type'],
|
||||
'coin_type' => $method['coin_type'],
|
||||
]);
|
||||
}
|
||||
|
||||
unset($content['methods']);
|
||||
}
|
||||
|
||||
ConfigService::set('website', $params['name'], $content);
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
self::$error = $e->getMessage();
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 获取国际区号
|
||||
* @return array
|
||||
* @author BD
|
||||
* @date 2023/12/28 16:09
|
||||
*/
|
||||
public static function getRegioncodeAll() : array
|
||||
{
|
||||
return ConfigService::get('website', 'regioncode');
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 获取版权备案
|
||||
* @return array
|
||||
* @author BD
|
||||
* @date 2023/12/28 16:09
|
||||
*/
|
||||
public static function getCopyright() : array
|
||||
{
|
||||
return ConfigService::get('copyright', 'config', []);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 设置版权备案
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author BD
|
||||
* @date 2022/8/8 16:33
|
||||
*/
|
||||
public static function setCopyright(array $params)
|
||||
{
|
||||
try {
|
||||
if (!is_array($params['config'])) {
|
||||
throw new \Exception('参数异常');
|
||||
}
|
||||
ConfigService::set('copyright', 'config', $params['config'] ?? []);
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
self::$error = $e->getMessage();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 设置政策协议
|
||||
* @param array $params
|
||||
* @author ljj
|
||||
* @date 2022/2/15 10:59 上午
|
||||
*/
|
||||
public static function setAgreement(array $params)
|
||||
{
|
||||
$serviceContent = clear_file_domain($params['service_content'] ?? '');
|
||||
$privacyContent = clear_file_domain($params['privacy_content'] ?? '');
|
||||
ConfigService::set('agreement', 'service_title', $params['service_title'] ?? '');
|
||||
ConfigService::set('agreement', 'service_content', $serviceContent);
|
||||
ConfigService::set('agreement', 'privacy_title', $params['privacy_title'] ?? '');
|
||||
ConfigService::set('agreement', 'privacy_content', $privacyContent);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取政策协议
|
||||
* @return array
|
||||
* @author ljj
|
||||
* @date 2022/2/15 11:15 上午
|
||||
*/
|
||||
public static function getAgreement() : array
|
||||
{
|
||||
$config = [
|
||||
'service_title' => ConfigService::get('agreement', 'service_title'),
|
||||
'service_content' => ConfigService::get('agreement', 'service_content'),
|
||||
'privacy_title' => ConfigService::get('agreement', 'privacy_title'),
|
||||
'privacy_content' => ConfigService::get('agreement', 'privacy_content'),
|
||||
];
|
||||
|
||||
$config['service_content'] = get_file_domain($config['service_content']);
|
||||
$config['privacy_content'] = get_file_domain($config['privacy_content']);
|
||||
|
||||
return $config;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user