其余文件

This commit is contained in:
2026-04-14 17:46:22 +08:00
parent 294b68fe37
commit 3691f4db22
1343 changed files with 189847 additions and 0 deletions

View File

@ -0,0 +1,168 @@
<?php
namespace app\admin\logic\setting;
use app\common\basics\Logic;
use app\common\server\ConfigServer;
use app\common\server\FileServer;
use app\common\server\UrlServer;
/**
* 网站基础设置
* Class BasicLogic
* @package app\admin\logic\setting
*/
class BasicLogic extends Logic
{
/**
* Notes: 网站设置
* @author 段誉(2021/6/10 23:52)
* @return array
*/
public static function getBasicConfig()
{
$config = [
'file_url' => UrlServer::getFileUrl('/'),
'name' => ConfigServer::get('website', 'name'),
'web_favicon' => ConfigServer::get('website', 'web_favicon'),
'client_login_logo' => ConfigServer::get('website', 'client_login_logo'),
'pc_client_login_logo' => ConfigServer::get('website', 'pc_client_login_logo'),
'user_image' => ConfigServer::get('website', 'user_image'),
'goods_image' => ConfigServer::get('website', 'goods_image'),
'platform_login_logo' => ConfigServer::get('website_platform', 'platform_login_logo'),
'platform_login_image' => ConfigServer::get('website_platform', 'platform_login_image'),
'platform_login_title' => ConfigServer::get('website_platform', 'platform_login_title'),
'platform_admin_logo' => ConfigServer::get('website_platform', 'platform_admin_logo'),
'platform_contact' => ConfigServer::get('website_platform', 'platform_contact'),
'platform_mobile' => ConfigServer::get('website_platform', 'platform_mobile'),
'shop_login_logo' => ConfigServer::get('website_shop', 'shop_login_logo'),
'shop_login_image' => ConfigServer::get('website_shop', 'shop_login_image'),
'shop_login_title' => ConfigServer::get('website_shop', 'shop_login_title'),
'shop_admin_logo' => ConfigServer::get('website_shop', 'shop_admin_logo'),
'shop_default_logo' => ConfigServer::get('website_shop', 'shop_default_logo'),
'shop_default_bg' => ConfigServer::get('website_shop', 'shop_default_bg'),
];
return $config;
}
/**
* Notes: 网站设置-商城设置
* @param $post
* @author 段誉(2021/6/10 23:53)
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public static function setWebsiteBasic($post)
{
ConfigServer::set('website', 'name', $post['name']);
ConfigServer::set('website', 'web_favicon', UrlServer::setFileUrl($post['web_favicon'] ?? ''));
ConfigServer::set('website', 'client_login_logo', UrlServer::setFileUrl($post['client_login_logo'] ?? ''));
ConfigServer::set('website', 'pc_client_login_logo', UrlServer::setFileUrl($post['pc_client_login_logo'] ?? ''));
ConfigServer::set('website', 'user_image', UrlServer::setFileUrl($post['user_image'] ?? ''));
ConfigServer::set('website', 'goods_image', UrlServer::setFileUrl($post['goods_image'] ?? ''));
}
/**
* Notes: 网站设置-平台设置
* @param $post
* @author 段誉(2021/6/10 23:53)
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public static function setPlatform($post)
{
ConfigServer::set('website_platform', 'platform_login_logo', UrlServer::setFileUrl($post['platform_login_logo'] ?? ''));
ConfigServer::set('website_platform', 'platform_login_image', UrlServer::setFileUrl($post['platform_login_image'] ?? ''));
ConfigServer::set('website_platform', 'platform_login_title', $post['platform_login_title']);
ConfigServer::set('website_platform', 'platform_admin_logo', UrlServer::setFileUrl($post['platform_admin_logo'] ?? ''));
ConfigServer::set('website_platform', 'platform_contact', $post['platform_contact']);
ConfigServer::set('website_platform', 'platform_mobile', $post['platform_mobile']);
}
/**
* Notes: 网站设置-商家设置
* @param $post
* @author 段誉(2021/6/10 23:53)
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public static function setShop($post)
{
ConfigServer::set('website_shop', 'shop_login_logo', UrlServer::setFileUrl($post['shop_login_logo'] ?? ''));
ConfigServer::set('website_shop', 'shop_login_image', UrlServer::setFileUrl($post['shop_login_image'] ?? ''));
ConfigServer::set('website_shop', 'shop_login_title', $post['shop_login_title']);
ConfigServer::set('website_shop', 'shop_admin_logo', UrlServer::setFileUrl($post['shop_admin_logo'] ?? ''));
ConfigServer::set('website_shop', 'shop_default_logo', UrlServer::setFileUrl($post['shop_default_logo'] ?? ''));
ConfigServer::set('website_shop', 'shop_default_bg', UrlServer::setFileUrl($post['shop_default_bg'] ?? ''));
}
/**
* @notes 获取版权资质
* @return array[]
* @author ljj
* @date 2022/2/22 9:30 上午
*/
public static function getCopyright()
{
$config = [
'company_name' => ConfigServer::get('copyright', 'company_name'),
'number' => ConfigServer::get('copyright', 'number'),
'link' => ConfigServer::get('copyright', 'link'),
'business_license' => ConfigServer::get('copyright', 'business_license'),
'other_qualifications' => ConfigServer::get('copyright', 'other_qualifications',[]),
];
$config['business_license'] = $config['business_license'] ? UrlServer::getFileUrl($config['business_license']) : '';
if (!empty($config['other_qualifications'])) {
foreach ($config['other_qualifications'] as &$val) {
$val = UrlServer::getFileUrl($val);
}
}
return ['config'=>$config];
}
/**
* @notes 设置版权资质
* @param $post
* @return bool
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author ljj
* @date 2022/2/22 9:37 上午
*/
public static function setCopyright($post)
{
$num = count($post['other_qualifications'] ?? []);
if ($num > 5) {
return '其他资质图片不能超过五张';
}
ConfigServer::set('copyright', 'company_name', $post['company_name']);
ConfigServer::set('copyright', 'number', $post['number']);
ConfigServer::set('copyright', 'link', $post['link']);
ConfigServer::set('copyright', 'business_license', UrlServer::setFileUrl($post['business_license'] ?? ''));
$other_qualifications = [];
if (!empty($post['other_qualifications'])) {
foreach ($post['other_qualifications'] as &$val) {
$val = UrlServer::setFileUrl($val);
}
$other_qualifications = json_encode($post['other_qualifications']);
}
ConfigServer::set('copyright', 'other_qualifications', $other_qualifications);
return true;
}
}

View File

@ -0,0 +1,28 @@
<?php
namespace app\admin\logic\setting;
use app\common\basics\Logic;
use app\common\server\ConfigServer;
class HotSearchLogic extends Logic
{
public static function info()
{
// 使用 [''] 目标,触发后台页面可正常显示一个空的添加项
$info = ConfigServer::get('hot_search','hot_keyword',['']);
$info = empty($info) ? [''] : $info;
return $info;
}
public static function set($post)
{
if ($post['hot_keyword'] == ['']){
return ConfigServer::set('hot_search','hot_keyword',[]);
}
$hotKeyword = array_filter($post['hot_keyword'], function($value) {
return !empty($value);
});
return ConfigServer::set('hot_search','hot_keyword', $hotKeyword);
}
}

View File

@ -0,0 +1,42 @@
<?php
namespace app\admin\logic\setting;
use app\common\basics\Logic;
use app\common\server\ConfigServer;
class MapLogic extends Logic
{
/**
* @notes 设置地图
* @return array
* @author 段誉
* @date 2022/1/17 10:31
*/
public static function getConfig()
{
$config = [
'tx_map_key' => ConfigServer::get('map', 'tx_map_key'),
'is_open_nearby' => ConfigServer::get('map', 'is_open_nearby',0),
];
return $config;
}
/**
* @notes 设置配置
* @param $post
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author 段誉
* @date 2022/1/17 10:31
*/
public static function setConfig($post)
{
ConfigServer::set('map', 'tx_map_key', $post['tx_map_key']);
ConfigServer::set('map', 'is_open_nearby', $post['is_open_nearby']);
}
}

View File

@ -0,0 +1,48 @@
<?php
namespace app\admin\logic\setting;
use app\common\basics\Logic;
use app\common\server\ConfigServer;
use think\facade\Validate;
/**
* 营销逻辑
* Class MarketingConfigLogic
* @package app\admin\logic\setting
*/
class MarketingConfigLogic extends Logic
{
/**
* @notes 设置消费奖励
* @param $post
* @throws \think\Exception
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author ljj
* @date 2022/2/18 4:22 下午
*/
public static function setOrderAward($post)
{
$open_award = isset($post['open_award']) && $post['open_award'] == 'on' ? 1 : 0;
$award_event = $post['award_event'] ?? 0;
$award_ratio = $post['award_ratio'] ?? '';
if ($open_award == 1) {
if (!isset($post['award_event']) || $post['award_event'] == '') {
return '开启消费送积分时,赠送积分事件不能为空';
}
if (!isset($post['award_ratio']) || $post['award_ratio'] == '') {
return '开启消费送积分时,赠送积分比例不能为空';
}
if (!Validate::isNumber($award_ratio)) {
return '赠送积分比率必须为纯数字';
}
}
ConfigServer::set('order_award','open_award',$open_award);
ConfigServer::set('order_award','award_event',$award_event);
ConfigServer::set('order_award','award_ratio',$award_ratio);
return true;
}
}

View File

@ -0,0 +1,216 @@
<?php
// +----------------------------------------------------------------------
// | likeshop开源商城系统
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | gitee下载https://gitee.com/likeshop_gitee
// | github下载https://github.com/likeshop-github
// | 访问官网https://www.likeshop.cn
// | 访问社区https://home.likeshop.cn
// | 访问手册http://doc.likeshop.cn
// | 微信公众号likeshop技术社区
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用未经许可不能去除前后端官方版权标识
// | likeshop系列产品收费版本务必购买商业授权购买去版权授权后方可去除前后端官方版权标识
// | 禁止对系统程序代码以任何目的,任何形式的再发布
// | likeshop团队版权所有并拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeshop.cn.team
// +----------------------------------------------------------------------
namespace app\admin\logic\setting;
use app\common\basics\Logic;
use app\common\enum\NoticeEnum;
use app\common\model\SmsConfig;
use app\common\model\SmsLog;
use app\common\server\ConfigServer;
class SmsLogic extends Logic
{
/**
* Notes: 短信配置列表
* @author 段誉(2021/6/7 15:54)
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public static function configLists()
{
$default = ConfigServer::get('sms_driver', 'default', '');
$lists = [
[
'name' => '阿里云短信',
'path' => '存储在本地服务器',
'engine' => 'ali',
'status' => $default == 'ali' ? 1 : 0
],
[
'name' => '腾讯云短信',
'path' => '存储在七牛云,请前往七牛云开通存储服务',
'engine' => 'tc',
'status' => $default == 'tc' ? 1 : 0
]
];
return ['count' => count($lists), 'lists' => $lists];
}
/**
* Notes: 设置短信配置
* @param $post
* @author 段誉(2021/6/21 23:33)
* @return bool
*/
public static function setConfig($post)
{
$engine = $post['engine'] ?? '';
try{
if ($engine == 'ali') {
ConfigServer::set('sms_engine', 'ali', [
'sign' => $post['sign'],
'app_key' => $post['app_key'],
'secret_key' => $post['secret_key'],
]);
} elseif ($engine == 'tc') {
ConfigServer::set('sms_engine', 'tc', [
'sign' => $post['sign'],
'app_id' => $post['app_id'],
'app_key' => $post['app_key'],
'secret_key' => $post['secret_key'],
]);
} else {
throw new \Exception('设置短信渠道不存在');
}
self::setDefaultByStatus($post['status'] ?? 'off', $engine);
return true;
} catch (\Exception $e) {
self::$error = $e->getMessage();
return false;
}
}
/**
* Notes: 根据原来的短信引擎更新短信默认
* @param $status
* @param $now_engine
* @author 段誉(2021/6/22 0:22)
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public static function setDefaultByStatus($status, $now_engine)
{
$last_engine = ConfigServer::get('sms_driver', 'default', '');
if ($status == 'on') {
ConfigServer::set('sms_driver', 'default', $now_engine);
}
if ($status != 'on' && $last_engine == $now_engine) {
ConfigServer::set('sms_driver', 'default', '');
}
}
/**
* Notes: 获取短信配置
* @param $engine
* @author 段誉(2021/6/22 0:10)
* @return array|bool|mixed|null
*/
public static function getConfigInfo($engine)
{
switch ($engine) {
case 'ali':
$info = ConfigServer::get('sms_engine', 'ali', [
'sign' => '',
'app_key' => '',
'secret_key' => '',
]);
break;
case 'tc':
$info = ConfigServer::get('sms_engine', 'tc', [
'sign' => '',
'app_id' => '',
'app_key' => '',
'secret_key' => '',
]);
break;
default:
$info = [];
}
if (empty($info)) {
return false;
}
$info['default_engine'] = ConfigServer::get('sms_driver', 'default', '');
return $info;
}
//************************************************短信发送记录*************************************************************
/**
* Notes: 日志列表
* @param $get
* @author 段誉(2021/6/7 15:54)
* @return array
* @throws \think\db\exception\DbException
*/
public static function logLists($get)
{
$where = [
['message_key', 'in', NoticeEnum::SMS_SCENE]
];
if (isset($get['name']) && $get['name']) {
$where[] = ['d.name', 'like', '%' . $get['name'] . '%'];
}
if (isset($get['mobile']) && $get['mobile']) {
$where[] = ['mobile', 'like', '%' . $get['mobile'] . '%'];
}
if (isset($get['send_status']) && $get['send_status'] != '') {
$where[] = ['send_status', '=', $get['send_status']];
}
if (isset($get['start_time']) && $get['start_time']) {
$where[] = ['create_time', '>=', strtotime($get['start_time'])];
}
if (isset($get['end_time']) && $get['end_time']) {
$where[] = ['create_time', '<=', strtotime($get['end_time'])];
}
$lists = SmsLog::where($where)
->order('id desc')
->paginate([
'page' => $get['page'],
'list_rows' => $get['limit'],
'var_page' => 'page'
])->toArray();
return ['count' => $lists['total'], 'lists' => $lists['data']];
}
/**
* Notes: 短信详情
* @param $id
* @author 段誉(2021/6/7 15:53)
* @return array|\think\Model|null
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public static function detail($id)
{
$log = SmsLog::where([
['message_key', 'in',NoticeEnum::SMS_SCENE],
['id', '=', $id]
])->withAttr('name', function ($value, $data){
return NoticeEnum::getSceneDesc($data['message_key']);
})->find();
return $log;
}
}

View File

@ -0,0 +1,131 @@
<?php
// +----------------------------------------------------------------------
// | likeshop开源商城系统
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | gitee下载https://gitee.com/likeshop_gitee
// | github下载https://github.com/likeshop-github
// | 访问官网https://www.likeshop.cn
// | 访问社区https://home.likeshop.cn
// | 访问手册http://doc.likeshop.cn
// | 微信公众号likeshop技术社区
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用未经许可不能去除前后端官方版权标识
// | likeshop系列产品收费版本务必购买商业授权购买去版权授权后方可去除前后端官方版权标识
// | 禁止对系统程序代码以任何目的,任何形式的再发布
// | likeshop团队版权所有并拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeshop.cn.team
// +----------------------------------------------------------------------
namespace app\admin\logic\setting;
use app\common\basics\Logic;
use app\common\server\ConfigServer;
use app\common\server\FileServer;
use app\common\server\UrlServer;
use think\facade\Db;
/**
* 用户设置逻辑层
* Class UserLogic
* @package app\admin\logic\setting
*/
class UserLogic extends Logic
{
/**
* @notes 获取用户配置
* @return array
* @author Tab
* @date 2021/9/1 10:07
*/
public static function getConfig()
{
$config = [
// 邀请下级 0-关闭 1-开启(默认)
'is_open' => ConfigServer::get('invite', 'is_open', 1),
// 邀请下级资格 1-全部用户(默认) 2-分销会员
'qualifications' => ConfigServer::get('invite', 'qualifications', [1]),
// 成为下级条件 1-邀请码(默认)
'condition' => ConfigServer::get('invite', 'condition', 1),
// 自定义邀请海报
'poster' => ConfigServer::get('invite', 'poster', '/images/share/share_user_bg.png'),
//指定会员
'invite_appoint_user' => ConfigServer::get('invite', 'invite_appoint_user', []),
];
$config['poster'] = empty($config['poster']) ? $config['poster'] : UrlServer::getFileUrl($config['poster']);
return $config;
}
/**
* @notes 用户设置
* @param $params
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author Tab
* @date 2021/9/1 10:33
*/
public static function set($params)
{
try {
if(!isset($params['poster'])) {
throw new \Exception('请选择自定义海报');
}
if(!isset($params['qualifications'])) {
throw new \Exception('请至少选择一种分销资格');
}
//兼容以前版本,保存数据格式
$params['qualifications'] = [$params['qualifications']];
if(count($params['qualifications']) >= 2){
throw new \Exception('分销资格只能选择一种');
}
$allowFields = ['is_open', 'qualifications', 'condition', 'poster','invite_appoint_user'];
if(in_array(2,$params['qualifications'])){
if(!isset($params['invite_appoint_user']) || empty($params['invite_appoint_user'])){
throw new \Exception('请选择指定会员等级');
}
$user_level = self::getUserLevel();
$user_level = array_column($user_level,'id');
$ids = [];
foreach ($params['invite_appoint_user'] as $id =>$val) {
if(!in_array($id,$user_level)){
throw new \Exception('用户等级错误,请刷新页面');
}
$ids[] = $id;
}
$params['invite_appoint_user'] = $ids;
}else{
$params['invite_appoint_user'] = [];
}
foreach ($allowFields as $field) {
if(isset($params[$field])) {
$params[$field] = is_array($params[$field]) ? json_encode($params[$field], JSON_UNESCAPED_UNICODE) : $params[$field];
$params[$field] = $field == 'poster' ? UrlServer::setFileUrl($params[$field]) : $params[$field];
ConfigServer::set('invite', $field, $params[$field]);
}
}
return true;
} catch (\Exception $e) {
self::$error = $e->getMessage();
return false;
}
}
/**
* @notes
* @return \think\Collection
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author cjhao
* @date 2022/2/28 10:34
*/
public static function getUserLevel(){
$user_level = Db::name('user_level')
->where(['del'=>0])
->field('id,name')
->select()->toArray();
return $user_level;
}
}