first commit
This commit is contained in:
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