初始版本

This commit is contained in:
贾祥聪
2025-08-19 14:16:51 +08:00
commit f937a1f9b9
4373 changed files with 359728 additions and 0 deletions

View File

@@ -0,0 +1,68 @@
<?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\adminapi\logic\setting;
use app\common\logic\BaseLogic;
use app\common\model\auth\Admin;
use think\facade\Config;
class AdminLogic extends BaseLogic
{
/**
* @notes 获取个人资料
* @param $admin_id
* @return array
* @author ljj
* @date 2022/4/18 2:36 下午
*/
public static function getAdmin($admin_id)
{
$admin = Admin::where('id',$admin_id)->field('id,name,avatar,account')->findOrEmpty()->toArray();
return $admin;
}
/**
* @notes 设置个人资料
* @param $params
* @return bool
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author ljj
* @date 2022/4/18 2:58 下午
*/
public static function setAdmin($params)
{
$admin = Admin::find($params['admin_id']);
$admin->name = $params['name'];
$admin->avatar = $params['avatar'];
$admin->account = $params['account'];
if (isset($params['password']) && $params['password'] != '') {
$passwordSalt = Config::get('project.unique_identification');
$password = create_password($params['new_password'], $passwordSalt);
$admin->password = $password;
}
$admin->save();
return true;
}
}

View File

@@ -0,0 +1,79 @@
<?php
namespace app\adminapi\logic\setting;
use app\common\service\ConfigService;
use app\common\service\FileService;
/**
* 基础设置
* Class BaseLogic
* @package app\adminapi\logic\setting
*/
class BaseLogic {
/**
* @notes 获取获取
* @return array[]
* @author cjhao
* @date 2024/11/1 13:07
*/
public function getConfig(){
return [
// 'platform' => [
'platform_name' => ConfigService::get('platform', 'platform_name',''),
'platform_logo' => FileService::getFileUrl(ConfigService::get('platform', 'platform_logo','')),
'poster' => FileService::getFileUrl(ConfigService::get('platform', 'poster','')),
'icon' => FileService::getFileUrl(ConfigService::get('platform', 'icon','')),
'safety_login' => ConfigService::get('platform', 'safety_login',1),
'safety_limit' => ConfigService::get('platform', 'safety_limit',3),
'safety_limit_time' => ConfigService::get('platform', 'safety_limit_time',5),
'doc_show' => ConfigService::get('platform', 'doc_show',1),
'contacts' => ConfigService::get('platform', 'contacts',''),
'mobile' => ConfigService::get('platform', 'mobile',''),
'service_mobile' => ConfigService::get('platform', 'service_mobile',''),
// ],
// 'user' => [
'user_name' => ConfigService::get('user', 'user_name',''),
'short_name' => ConfigService::get('user', 'short_name',''),
'user_logo' => FileService::getFileUrl(ConfigService::get('user', 'user_logo','')),
// ],
// 'coach' => [
'coach_name' => ConfigService::get('coach', 'coach_name',''),
'coach_logo' => FileService::getFileUrl(ConfigService::get('coach', 'coach_logo','')),
// ],
// 'shop' => [
'shop_name' => ConfigService::get('shop', 'shop_name',''),
'shop_logo' => FileService::getFileUrl(ConfigService::get('shop', 'shop_logo','')),
// ],
];
}
/**
* @notes 设置基础设置
* @param $params
* @return void
* @author cjhao
* @date 2024/11/1 13:18
*/
public function setConfig($params){
ConfigService::set('platform', 'platform_name',$params['platform_name']);
ConfigService::set('platform', 'platform_logo',FileService::setFileUrl($params['platform_logo']));
ConfigService::set('platform', 'poster',FileService::setFileUrl($params['poster']));
ConfigService::set('platform', 'icon',FileService::setFileUrl($params['icon']));
ConfigService::set('platform', 'safety_login',$params['safety_login']);
ConfigService::set('platform', 'safety_limit',$params['safety_limit']);
ConfigService::set('platform', 'doc_show',$params['doc_show']);
ConfigService::set('platform', 'safety_limit',$params['safety_limit']);
ConfigService::set('platform', 'contacts',$params['contacts']);
ConfigService::set('platform', 'mobile',$params['mobile']);
ConfigService::set('platform', 'service_mobile',$params['service_mobile']);
ConfigService::set('user', 'user_name',$params['user_name']);
ConfigService::set('user', 'short_name',$params['short_name']);
ConfigService::set('user', 'user_logo',FileService::setFileUrl($params['user_logo']));
ConfigService::set('coach', 'coach_name',$params['coach_name']);
ConfigService::set('coach', 'coach_logo',$params['coach_logo']);
ConfigService::set('shop', 'shop_name',$params['shop_name']);
ConfigService::set('shop', 'shop_logo',FileService::setFileUrl($params['shop_logo']));
}
}

View File

@@ -0,0 +1,226 @@
<?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\adminapi\logic\setting;
use app\common\logic\BaseLogic;
use app\common\model\city\City;
use app\common\model\goods\GoodsCategory;
use app\common\model\Region;
use app\common\model\skill\Skill;
class CityLogic extends BaseLogic
{
/**
* @notes 城市列表
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author cjhao
* @date 2024/10/6 17:27
*/
public function getCityLists()
{
$lists = City::where(['level'=>2])->select()->toArray();
$cityLists = [];
foreach ($lists as $city){
$parent = $cityLists[$city['parent_id']] ?? [];
if($parent){
$parent['sons'][] =[
'id' => $city['city_id'],
'name' => $city['name'],
];
}else{
$parent = [
'id' => $city['parent_id'],
'name' => $city['parent_name'],
'sons' => [
[
'id' => $city['city_id'],
'name' => $city['name'],
],
],
];
}
$cityLists[$city['parent_id']] = $parent;
}
return array_values($cityLists);
}
/**
* @notes 城市列表
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author cjhao
* @date 2024/10/6 17:27
*/
public function getRegionLists()
{
$lists = City::where(['level'=>2])->select()->toArray();
$cityLists = [];
foreach ($lists as $city){
$parent = $cityLists[$city['parent_id']] ?? [];
if($parent){
$parent['children'][] =[
'value' => $city['city_id'],
'label' => $city['name'],
'children' => [],
];
}else{
$parent = [
'value' => $city['parent_id'],
'label' => $city['parent_name'],
'children' => [
[
'value' => $city['city_id'],
'label' => $city['name'],
'children' => [],
],
],
];
}
$cityLists[$city['parent_id']] = $parent;
}
$cityIds = array_column($lists,'city_id');
$regionLists = Region::where(['parent_id'=>$cityIds,'level'=>3])->select()->toArray();
foreach ($cityLists as $key => $city){
foreach ($city['children'] as $sonsKey => $sons){
foreach ($regionLists as $regionList){
if($regionList['parent_id'] == $sons['value']){
$sons['children'][] = [
'value' => $regionList['id'],
'label' => $regionList['name'],
];
}
}
$cityLists[$key]['children'][$sonsKey] = $sons;
}
}
return array_values($cityLists);
}
/**
* @notes 添加
* @param $params
* @return bool
* @author ljj
* @date 2022/2/8 5:03 下午
*/
public function add($params)
{
$region = Region::where(['id'=>$params['city_id']])
->field('name,parent_id,level,gcj02_lng,gcj02_lat,db09_lng,db09_lat')
->findOrEmpty()
->toArray();
$parentName = Region::where(['id'=>$region['parent_id']])->value('name');
City::create([
'parent_id' => $region['parent_id'],
'parent_name' => $parentName,
'city_id' => $params['city_id'],
'level' => $region['level'],
'name' => $region['name'],
'taxi' => $params['taxi'],
'start_km' => $params['start_km'],
'start_price' => $params['start_price'],
'continue_price' => $params['continue_price'],
'gcj02_lng' => $region['gcj02_lng'],
'gcj02_lat' => $region['gcj02_lat'],
'db09_lng' => $region['db09_lng'],
'db09_lat' => $region['db09_lat'],
'bus' => $params['bus'],
'bus_start_time' => $params['bus_start_time'],
'bus_end_time' => $params['bus_end_time'],
'bus_fare' => $params['bus_fare'],
]);
return true;
}
/**
* @notes 查看服务分类详情
* @param $id
* @return array
* @author ljj
* @date 2022/2/8 5:21 下午
*/
public function detail($id)
{
$result = City::where('id',$id)->withoutField('update_time,delete_time')->findOrEmpty()->toArray();
return $result;
}
/**
* @notes 编辑服务分类
* @param $params
* @return bool
* @author ljj
* @date 2022/2/8 6:25 下午
*/
public function edit($params)
{
$region = Region::where(['id'=>$params['city_id']])
->field('name,parent_id,level,gcj02_lng,gcj02_lat,db09_lng,db09_lat')
->findOrEmpty()->toArray();
$parentName = Region::where(['id'=>$region['parent_id']])->value('name');
City::update([
'parent_id' => $region['parent_id'],
'parent_name' => $parentName,
'level' => $region['level'],
'city_id' => $params['city_id'],
'name' => $region['name'],
'taxi' => $params['taxi'],
'start_km' => $params['start_km'],
'start_price' => $params['start_price'],
'continue_price' => $params['continue_price'],
'bus' => $params['bus'],
'gcj02_lng' => $region['gcj02_lng'],
'gcj02_lat' => $region['gcj02_lat'],
'db09_lng' => $region['db09_lng'],
'db09_lat' => $region['db09_lat'],
'bus_start_time' => $params['bus_start_time'],
'bus_end_time' => $params['bus_end_time'],
'bus_fare' => $params['bus_fare'],
],['id'=>$params['id']]);
return true;
}
/**
* @notes 删除服务
* @param $id
* @return bool
* @author ljj
* @date 2022/2/8 6:34 下午
*/
public function del($id)
{
return City::destroy($id);
}
}

View File

@@ -0,0 +1,89 @@
<?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\adminapi\logic\setting;
use app\common\logic\BaseLogic;
use app\common\service\ConfigService;
use app\common\service\FileService;
use Exception;
use think\facade\Db;
class CustomerServiceLogic extends BaseLogic
{
/**
* @notes 获取
* @return array
* @author ljj
* @date 2024/8/27 下午5:17
*/
public static function getConfig()
{
$defaultData = [
'way' => '1',
'name' => '',
'remarks' => '',
'phone' => '',
'service_phone' => '',
'business_time' => '',
'qr_code' => '',
'enterprise_id' => '',
'kefu_link' => ''
];
$config = [
'mnp' => ConfigService::get('kefu_config', 'mnp', $defaultData),
'oa' => ConfigService::get('kefu_config', 'oa', $defaultData),
'h5' => ConfigService::get('kefu_config', 'h5', $defaultData),
];
if (!empty($config['mnp']['qr_code'])) $config['mnp']['qr_code'] = FileService::getFileUrl($config['mnp']['qr_code']);
if (!empty($config['oa']['qr_code'])) $config['oa']['qr_code'] = FileService::getFileUrl($config['oa']['qr_code']);
if (!empty($config['h5']['qr_code'])) $config['h5']['qr_code'] = FileService::getFileUrl($config['h5']['qr_code']);
return $config;
}
/**
* @notes 设置
* @param $params
* @return string|true
* @author ljj
* @date 2024/8/27 下午5:17
*/
public static function setConfig($params)
{
Db::startTrans();
try {
foreach($params as $key => $value) {
if(!in_array($key, ['mnp','oa','h5'])) {
throw new Exception('数据异常');
}
ConfigService::set('kefu_config', $key, $value);
}
// 提交事务
Db::commit();
return true;
} catch (Exception $e) {
// 回滚事务
Db::rollback();
return $e->getMessage();
}
}
}

View 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;
use app\common\logic\BaseLogic;
use app\common\model\HotSearch;
use app\common\service\ConfigService;
use app\common\service\FileService;
use think\facade\Validate;
/**
* 热门搜素逻辑
* Class HotSearchLogic
* @package app\adminapi\logic\setting
*/
class HotSearchLogic extends BaseLogic
{
/**
* @notes 获取配置
* @return array
* @author 段誉
* @date 2022/9/5 18:48
*/
public static function getConfig()
{
return [
// 功能状态 0-关闭 1-开启
'status' => ConfigService::get('hot_search', 'status', 0),
// 热门搜索数据
'data' => HotSearch::field(['name', 'sort'])->order(['sort' => 'desc', 'id' =>'desc'])->select()->toArray(),
];
}
/**
* @notes 设置热门搜搜
* @param $params
* @return bool
* @author 段誉
* @date 2022/9/5 18:58
*/
public static function setConfig($params)
{
try {
if (!empty($params['data'])) {
foreach ($params['data'] as $val) {
if (!isset($val['name']) || empty($val['name'])) {
throw new \think\Exception('关键词缺失', 10006);
}
if (!isset($val['sort']) || $val['sort'] < 0) {
throw new \think\Exception('排序值错误', 10006);
}
}
$model = (new HotSearch());
$model->where('id', '>', 0)->delete();
$model->saveAll($params['data']);
}
$status = empty($params['status']) ? 0 : $params['status'];
ConfigService::set('hot_search', 'status', $status);
return true;
} catch (\Exception $e) {
self::$error = $e->getMessage();
return false;
}
}
}

View File

@@ -0,0 +1,110 @@
<?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\adminapi\logic\setting;
use app\common\enum\DefaultEnum;
use app\common\enum\MapKeyEnum;
use app\common\logic\BaseLogic;
use app\common\model\MapKey;
use think\facade\Cache;
class MapKeyLogic extends BaseLogic
{
/**
* @notes 公共列表
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author ljj
* @date 2024/11/5 下午1:56
*/
public function commonLists()
{
$lists = (new MapKey())->order(['id'=>'desc'])->json(['error_info'],true)->select()->toArray();
return $lists;
}
/**
* @notes 新增key
* @param $params
* @return true
* @author ljj
* @date 2024/11/5 下午2:05
*/
public function add($params)
{
MapKey::create([
'key' => $params['key'],
'type' => $params['type']
]);
return true;
}
/**
* @notes 详情
* @param $id
* @return array
* @author ljj
* @date 2024/11/5 下午2:07
*/
public function detail($id)
{
$result = MapKey::where('id',$id)->json(['error_info'],true)->findOrEmpty()->toArray();
return $result;
}
/**
* @notes 编辑
* @param $params
* @return true
* @author ljj
* @date 2024/11/5 下午2:20
*/
public function edit($params)
{
$mapKey = MapKey::findOrEmpty($params['id']);
$mapKey->key = $params['key'];
$mapKey->type = $params['type'];
$mapKey->status = $mapKey->status == MapKeyEnum::STATUS_ABNORMAL ? MapKeyEnum::STATUS_WAIT : $mapKey->status;
$mapKey->save();
//删除缓存
Cache::delete('TENCENT_MAP_KEY');
return true;
}
/**
* @notes 删除
* @param $id
* @return bool
* @author ljj
* @date 2024/11/5 下午2:21
*/
public function del($id)
{
return MapKey::destroy($id);
}
}

View File

@@ -0,0 +1,201 @@
<?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\settings\shop
*/
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' => '腾讯云OSS',
'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']);
}
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');
}
}

View File

@@ -0,0 +1,62 @@
<?php
namespace app\adminapi\logic\setting;
use app\common\model\TextList;
class TextLogic
{
/**
* @notes 添加
* @param $params
* @return true
* @author cjhao
* @date 2024/11/1 10:14
*/
public function add($params)
{
TextList::create([
'title' => $params['title'],
'content' => $params['content'],
]);
return true;
}
/**
* @notes 编辑
* @param $params
* @return true
* @author cjhao
* @date 2024/11/1 10:15
*/
public function edit($params)
{
TextList::update([
'title' => $params['title'],
'content' => $params['content'],
],['id'=>$params['id']]);
return true;
}
/**
* @notes 删除
* @param $id
* @return bool
* @author cjhao
* @date 2024/11/1 10:16
*/
public function del($id)
{
$text = TextList::where(['id'=>$id])->findOrEmpty();
if($text->isEmpty()){
return '数据不存在';
}
if($text->is_default){
return '默认数据不允许删除';
}
$text->delete();
return true;
}
}

View File

@@ -0,0 +1,67 @@
<?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\adminapi\logic\setting;
use app\common\logic\BaseLogic;
use app\common\service\ConfigService;
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),
'is_auth_dispatch' => ConfigService::get('transaction', 'is_auth_dispatch',1),
];
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']);
ConfigService::set('transaction', 'is_auth_dispatch', $params['is_auth_dispatch']);
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']);
}
}
}

View 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();
}
}

View File

@@ -0,0 +1,88 @@
<?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\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)
{
return DictType::update([
'id' => $params['id'],
'name' => $params['name'],
'type' => $params['type'],
'status' => $params['status'],
'remark' => $params['remark'] ?? '',
]);
}
/**
* @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();
}
}

View File

@@ -0,0 +1,100 @@
<?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\adminapi\logic\setting\pay;
use app\common\enum\PayEnum;
use app\common\logic\BaseLogic;
use app\common\model\pay\PayConfig;
class PayConfigLogic extends BaseLogic
{
/**
* @notes 查看支付配置列表
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author ljj
* @date 2022/2/15 6:03 下午
*/
public function lists()
{
$lists = PayConfig::field('id,name,pay_way,image,sort')
->order(['sort'=>'asc','id'=>'desc'])
->append(['pay_way_desc'])
->select()
->toArray();
return $lists;
}
/**
* @notes 编辑支付配置
* @param $params
* @return bool
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author ljj
* @date 2022/2/15 6:13 下午
*/
public function edit($params)
{
$pay_config = PayConfig::find($params['id']);
$config = '';
if ($pay_config['pay_way'] == PayEnum::WECHAT_PAY) {
$config = [
'interface_version' => $params['interface_version'],
'merchant_type' => $params['merchant_type'],
'mch_id' => $params['mch_id'],
'pay_sign_key' => $params['pay_sign_key'],
'apiclient_cert' => $params['apiclient_cert'],
'apiclient_key' => $params['apiclient_key'],
];
}
if ($pay_config['pay_way'] == PayEnum::ALI_PAY) {
$config = [
'mode' => $params['mode'] ?? 'normal_mode',
'merchant_type' => $params['merchant_type'],
'app_id' => $params['app_id'],
'private_key' => $params['private_key'],
'ali_public_key' => $params['ali_public_key'],
];
}
$pay_config->name = $params['name'];
$pay_config->image = $params['image'];
$pay_config->sort = $params['sort'];
$pay_config->config = $config ? json_encode($config) : '';
return $pay_config->save();
}
/**
* @notes 支付配置详情
* @param $id
* @return array
* @author ljj
* @date 2022/2/15 6:28 下午
*/
public function detail($id)
{
return PayConfig::where('id',$id)->json(['config'])->append(['pay_way_desc'])->findOrEmpty()->toArray();
}
}

View File

@@ -0,0 +1,105 @@
<?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\adminapi\logic\setting\pay;
use app\common\enum\user\UserTerminalEnum;
use app\common\enum\YesNoEnum;
use app\common\logic\BaseLogic;
use app\common\model\pay\PayWay;
class PayWayLogic extends BaseLogic
{
/**
* @notes 获取支付方式
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author ljj
* @date 2022/2/15 6:51 下午
*/
public function getPayWay()
{
$pay_way = PayWay::select();
$pay_way = $pay_way->append(['pay_way_desc','icon'])->toArray();
if (empty($pay_way)) {
return [];
}
$lists = [];
for ($i=1;$i<=max(array_column($pay_way,'scene'));$i++) {
foreach ($pay_way as $val) {
if ($val['scene'] == $i) {
$lists[$i][] = $val;
}
}
}
return $lists;
}
/**
* @notes 设置支付方式
* @param $params
* @return bool|string
* @throws \Exception
* @author ljj
* @date 2022/2/15 7:02 下午
*/
public function setPayWay($params)
{
$pay_way = new PayWay;
$data = [];
foreach ($params as $key=>$value) {
$is_default = array_column($value,'is_default');
$is_default_num = array_count_values($is_default);
$status = array_column($value,'status');
$scene_name = UserTerminalEnum::getTermInalDesc($key);
if (!in_array(YesNoEnum::YES,$is_default)) {
return $scene_name.'支付场景缺少默认支付';
}
if ($is_default_num[YesNoEnum::YES] > 1) {
return $scene_name.'支付场景的默认值只能存在一个';
}
if (!in_array(YesNoEnum::YES,$status)) {
return $scene_name.'支付场景至少开启一个支付状态';
}
foreach ($value as $val) {
$result = PayWay::where('id',$val['id'])->findOrEmpty();
if ($result->isEmpty()) {
continue;
}
if ($val['is_default'] == YesNoEnum::YES && $val['status'] == YesNoEnum::NO) {
return $scene_name.'支付场景的默认支付未开启支付状态';
}
$data[] = [
'id' => $val['id'],
'is_default' => $val['is_default'],
'status' => $val['status'],
];
}
}
$pay_way->saveAll($data);
return true;
}
}

View 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);
}
}

View File

@@ -0,0 +1,128 @@
<?php
// +----------------------------------------------------------------------
// | likeshop100%开源免费商用商城系统
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | 商业版本务必购买商业授权,以免引起法律纠纷
// | 禁止对系统程序代码以任何目的,任何形式的再发布
// | 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团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeshopTeam
// +----------------------------------------------------------------------
namespace app\adminapi\logic\setting\system;
use app\common\logic\BaseLogic;
use app\common\service\ConfigService;
/**
* 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)comparePHP('8.0.0'), 'remark' => '']
];
$auth = [
['dir' => '/runtime', 'require' => 'runtime目录可写', 'status' => (int)checkDirWrite('runtime'), 'remark' => ''],
];
return [
'server' => $server,
'env' => $env,
'auth' => $auth,
];
}
/**
* @notes 获取通用配置
* @return array[]
* @author cjhao
* @date 2024/8/27 17:21
*/
public static function getGeneralSetting()
{
$orderSetting = [
'order_cancel_order' => ConfigService::get('order_setting', 'order_cancel_order'),
'order_cancel_time' => ConfigService::get('order_setting', 'order_cancel_time'),
'over_time_comment' => ConfigService::get('order_setting', 'over_time_comment'),
'over_time_comment_content' => ConfigService::get('order_setting', 'over_time_comment_content')
];
$settleSetting = [
//结算方式
'commission_settle' => ConfigService::get('settle_setting', 'commission_settle'),
//结算周期1-按状态2-周期
'commission_settle_cycle' => ConfigService::get('settle_setting', 'commission_settle_cycle'),
//1-每周、2-每月
'commission_settle_cycle_type' => ConfigService::get('settle_setting', 'commission_settle_cycle_type'),
//订单结束X天后结算,每周X每月X号
'commission_settle_cycle_day' => ConfigService::get('settle_setting', 'commission_settle_cycle_day'),
];
$serverSetting = [
'advance_appoint' => ConfigService::get('server_setting', 'advance_appoint'),
'coach_order_limit' => ConfigService::get('server_setting', 'coach_order_limit'),
'coach_server_scope' => ConfigService::get('server_setting', 'coach_server_scope'),
'shop_coach_limit' => ConfigService::get('server_setting', 'shop_coach_limit'),
'shop_order_limit' => ConfigService::get('server_setting', 'shop_order_limit'),
];
return [
'order_setting' => $orderSetting,
'settle_setting' => $settleSetting,
'server_setting' => $serverSetting,
];
}
/**
* @notes 设置通用设置
* @param array $params
* @return true
* @author cjhao
* @date 2024/8/27 17:11
*/
public static function setGeneralSetting(array $params)
{
ConfigService::set('order_setting', 'order_cancel_order',$params['order_setting']['order_cancel_order']);
ConfigService::set('order_setting', 'order_cancel_time',$params['order_setting']['order_cancel_time']);
ConfigService::set('order_setting', 'over_time_comment',$params['order_setting']['over_time_comment']);
ConfigService::set('order_setting', 'over_time_comment_content',$params['order_setting']['over_time_comment_content']);
ConfigService::set('settle_setting', 'commission_settle',$params['settle_setting']['commission_settle']);
ConfigService::set('settle_setting', 'commission_settle_cycle',$params['settle_setting']['commission_settle_cycle']);
ConfigService::set('settle_setting', 'commission_settle_cycle_type',$params['settle_setting']['commission_settle_cycle_type']);
ConfigService::set('settle_setting', 'commission_settle_cycle_day',$params['settle_setting']['commission_settle_cycle_day']);
ConfigService::set('server_setting', 'advance_appoint',$params['server_setting']['advance_appoint']);
ConfigService::set('server_setting', 'coach_order_limit',$params['server_setting']['coach_order_limit']);
ConfigService::set('server_setting', 'coach_server_scope',$params['server_setting']['coach_server_scope']);
ConfigService::set('server_setting', 'shop_coach_limit',$params['server_setting']['shop_coach_limit']);
ConfigService::set('server_setting', 'shop_order_limit',$params['server_setting']['shop_order_limit']);
return true;
}
}

View File

@@ -0,0 +1,493 @@
<?php
// +----------------------------------------------------------------------
// | likeshop100%开源免费商用商城系统
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | 商业版本务必购买商业授权,以免引起法律纠纷
// | 禁止对系统程序代码以任何目的,任何形式的再发布
// | 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团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeshopTeam
// +----------------------------------------------------------------------
namespace app\adminapi\logic\setting\system;
use app\common\logic\BaseLogic;
use think\facade\Cache;
use think\facade\Db;
use think\facade\Log;
use WpOrg\Requests\Requests;
/**
* 升级逻辑
* Class UpgradeLogic
* @package app\adminapi\logic\settings\system
*/
class UpgradeLogic extends BaseLogic
{
const BASE_URL = 'https://server.likeshop.cn';
/**
* @notes 格式化列表数据
* @param $lists
* @return array
* @author 段誉
* @date 2021/8/14 17:18
*/
public static function formatLists($lists, $pageNo)
{
$localData = local_version();
$localVersion = $localData['version'];
foreach ($lists as $k => $item) {
//版本描述
$lists[$k]['version_str'] = '';
$lists[$k]['able_update'] = 0;
if ($localVersion == $item['version_no']) {
$lists[$k]['version_str'] = '您的系统当前处于此版本';
}
if ($localVersion < $item['version_no']) {
$lists[$k]['version_str'] = '系统可更新至此版本';
$lists[$k]['able_update'] = 1;
}
//最新的版本号标志
$lists[$k]['new_version'] = 0;
//注意,是否需要重新发布描述
$lists[$k]['notice'] = [];
if ($item['uniapp_publish'] == 1) {
$lists[$k]['notice'][] = '更新至当前版本后需重新发布前端商城';
}
if ($item['pc_admin_publish'] == 1) {
$lists[$k]['notice'][] = '更新至当前版本后需重新发布PC管理后台';
}
if ($item['pc_shop_publish'] == 1) {
$lists[$k]['notice'][] = '更新至当前版本后需重新发布PC商城端';
}
//处理更新内容信息
$contents = $item['update_content'];
$add = [];
$optimize = [];
$repair = [];
$contentDesc = [];
if (!empty($contents)) {
foreach ($contents as $content) {
if ($content['type'] == 1) {
$add[] = '新增:' . $content['update_function'];
}
if ($content['type'] == 2) {
$optimize[] = '优化:' . $content['update_function'];
}
if ($content['type'] == 3) {
$repair[] = '修复:' . $content['update_function'];
}
}
$contentDesc = array_merge($add, $optimize, $repair);
}
$lists[$k]['add'] = $add;
$lists[$k]['optimize'] = $optimize;
$lists[$k]['repair'] = $repair;
$lists[$k]['content_desc'] = $contentDesc;
unset($lists[$k]['update_content']);
}
$lists[0]['new_version'] = ($pageNo == 1) ? 1 : 0;
return $lists;
}
/**
* @notes 更新操作
* @param $params
* @return bool|string
* @author 段誉
* @date 2021/8/14 17:19
*/
public static function upgrade($params)
{
$openBasedir = ini_get('open_basedir');
if(strpos($openBasedir, "server") !== false) {
self::$error = '请临时关闭服务器本站点的跨域攻击设置,并重启 nginx、PHP具体参考相关升级文档';
return false;
}
// 授权验证
$params['link'] = "package_link";
$result = self::verify($params);
if (!$result['has_permission']) {
self::$error = !empty($result['msg']) ? $result['msg'] : '请先联系客服获取授权';
// 写日志
self::addlog($params['id'], $params['update_type'], false);
return false;
}
// 本地更新包路径
$localUpgradeDir = ROOT_PATH . '/upgrade/';
// 本地更新临时文件
$tempDir = ROOT_PATH . '/upgrade/temp/';
// 更新成功或失败的标识
$flag = true;
Db::startTrans();
try {
// 远程下载链接
$remoteUrl = $result['link'];
if (!is_dir($localUpgradeDir)) {
mkdir(iconv("UTF-8", "GBK", $localUpgradeDir), 0777, true);
}
//下载更新压缩包保存到本地
$remoteData = self::downFile($remoteUrl, $localUpgradeDir);
if (false === $remoteData) {
throw new \Exception('获取文件错误');
}
//解压缩
if (false === unzip($remoteData['save_path'], $tempDir)) {
throw new \Exception('解压文件错误');
}
//更新sql->更新数据类型
if (false === self::upgradeSql($tempDir . 'sql/data/')) {
throw new \Exception('更新数据库数据失败');
}
//更新文件
if (false === self::upgradeFile($tempDir . 'project/server/', self::getProjectPath())) {
throw new \Exception('更新文件失败');
}
Db::commit();
} catch (\Exception $e) {
Db::rollback();
self::$error = $e->getMessage();
//错误日志
$params['error'] = $e->getMessage();
// 标识更新失败
$flag = false;
}
if ($flag) {
try {
//更新sql->更新数据结构
if (false === self::upgradeSql($tempDir . 'sql/structure/')) {
throw new \Exception('更新数据库结构失败');
}
} catch (\Exception $e) {
self::$error = $e->getMessage();
//错误日志
$params['error'] = $e->getMessage();
// 标识更新失败
$flag = false;
}
}
//删除临时文件(压缩包不删除,删除解压的文件)
if ($flag && false === del_target_dir($tempDir, true)) {
Log::write('删除系统更新临时文件失败');
}
// 增加日志
self::addlog($params['id'], $params['update_type'], $flag);
return $flag;
}
/**
* @notes 授权验证
* @param $params
* @author Tab
* @date 2021/10/26 17:12
*/
public static function verify($params)
{
$domain = $_SERVER['SERVER_NAME'];
$remoteUrl = self::BASE_URL . "/api/version/verify?domain=".$domain."&product_id=19&type=2&version_id=".$params['id']."&link=".$params['link'];
$result = Requests::get($remoteUrl);
$result = json_decode($result->body, true);
$result = $result['data'] ?? ['has_permission' => false, 'link' => '', 'msg' => ''];
return $result;
}
/**
* @notes 获取远程版本数据
* @param null $pageNo
* @param null $pageSize
* @return array|mixed
* @author 段誉
* @date 2021/8/14 17:20
*/
public static function getRemoteVersion($pageNo = null, $pageSize = null)
{
$cacheVersion = Cache::get('version_lists' . $pageNo);
if (!empty($cacheVersion)) {
return $cacheVersion;
}
if (empty($pageNo) || empty($pageSize)) {
$remoteUrl = self::BASE_URL . "/api/version/lists?product_id=19&type=2&page=1";
} else {
$remoteUrl = self::BASE_URL . "/api/version/lists?product_id=19&type=2&page_no=$pageNo&page_size=$pageSize&page=1";
}
$result = Requests::get($remoteUrl);
$result = json_decode($result->body, true);
$result = $result['data'] ?? [];
Cache::set('version_lists' . $pageNo, $result, 1800);
return $result;
}
/**
* @notes 更新包下载链接
* @param $params
* @return array|false
* @author 段誉
* @date 2022/3/25 17:50
*/
public static function getPkgLine($params)
{
$map = [
1 => 'package_link', //一键更新类型 : 服務端更新包
2 => 'package_link', //服務端更新包
3 => 'pc_package_link', //pc端更新包
4 => 'uniapp_package_link', //uniapp更新包
5 => 'web_package_link', //后台前端更新包
6 => 'integral_package_link', //完整包
8 => 'kefu_package_link', //客服更新包
];
$params['link'] = $map[$params['update_type']] ?? '未知类型';
// 授权验证
$result = self::verify($params);
if (!$result['has_permission']) {
self::$error = !empty($result['msg']) ? $result['msg'] : '请先联系客服获取授权';
// 写日志
self::addlog($params['id'], $params['update_type'], false);
return false;
}
//增加日志记录
self::addlog($params['id'], $params['update_type']);
//更新包下载链接
return ['line' => $result['link']];
}
/**
* @notes 添加日志
* @param $versionId //版本id
* @param $updateType //更新类型
* @param bool $status //更新状态
* @return bool|\Requests_Response
* @author 段誉
* @date 2021/10/9 14:48
*/
public static function addlog($versionId, $updateType, $status = true)
{
//版本信息
$versionData = self::getVersionDataById($versionId);
$domain = $_SERVER['SERVER_NAME'];
try {
$paramsData = [
'version_id' => $versionData['id'],
'version_no' => $versionData['version_no'],
'domain' => $domain,
'type' => 2,//付费版
'product_id' => 19,//上门按摩
'update_type' => $updateType,
'status' => $status ? 1 : 0,
'error' => empty(self::$error) ? '' : self::$error,
];
$requestUrl = self::BASE_URL . '/api/version/log';
$result = Requests::post($requestUrl, [], $paramsData);
return $result;
} catch (\Exception $e) {
Log::write('更新日志:' . '更新失败' . $e->getMessage());
return false;
}
}
/**
* @notes 通过版本记录id获取版本信息
* @param $id
* @return array
* @author 段誉
* @date 2021/10/9 11:40
*/
public static function getVersionDataById($id)
{
$cacheVersion = self::getRemoteVersion()['lists'] ?? [];
if (!empty($cacheVersion)) {
$versionColumn = array_column($cacheVersion, null, 'id');
if (!empty($versionColumn[$id])) {
return $versionColumn[$id];
}
}
return [];
}
/**
* @notes 下载远程文件
* @param $url
* @param string $savePath
* @return array|false
* @author 段誉
* @date 2021/8/14 17:20
*/
public static function downFile($url, $savePath = './upgrade/')
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, TRUE);
curl_setopt($ch, CURLOPT_NOBODY, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$response = curl_exec($ch);
$header = '';
$body = '';
if (curl_getinfo($ch, CURLINFO_HTTP_CODE) == '200') {
$headerSize = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
$header = substr($response, 0, $headerSize);
$body = substr($response, $headerSize);
}
curl_close($ch);
//文件名
$fullName = basename($url);
//文件保存完整路径
$savePath = $savePath . $fullName;
//创建目录并设置权限
$basePath = dirname($savePath);
if (!file_exists($basePath)) {
@mkdir($basePath, 0777, true);
@chmod($basePath, 0777);
}
if (file_put_contents($savePath, $body)) {
return [
'save_path' => $savePath,
'file_name' => $fullName,
];
}
return false;
}
/**
* @notes 获取项目路径
* @return string
* @author 段誉
* @date 2021/8/14 17:20
*/
public static function getProjectPath()
{
$path = dirname(ROOT_PATH);
if(substr($path, -1) != '/') {
$path = $path . '/';
}
return $path;
}
/**
* @notes 更新sql
* @param $dir
* @return bool
* @author 段誉
* @date 2021/8/14 17:20
*/
public static function upgradeSql($dir)
{
//没有sql文件时无需更新
if (!file_exists($dir)) {
return true;
}
//遍历指定目录下的指定后缀文件
$sqlFiles = get_scandir($dir, '', 'sql');
if (false === $sqlFiles) {
return false;
}
//当前数据库前缀
$sqlPrefix = config('database.connections.mysql.prefix');
foreach ($sqlFiles as $k => $item) {
if (get_extension($item) != 'sql') {
continue;
}
$sqlContent = file_get_contents($dir . $item);
if (empty($sqlContent)) {
continue;
}
$sqls = explode(';', $sqlContent);
//执行sql
foreach ($sqls as $sql) {
$sql = trim($sql);
if (!empty($sql)) {
$sql = str_replace('`ls_', '`' . $sqlPrefix, $sql) . ';';
Db::execute($sql);
}
}
}
return true;
}
/**
* @notes 更新文件
* @param $tempFile
* @param $oldFile
* @return bool
* @author 段誉
* @date 2021/8/14 17:21
*/
public static function upgradeFile($tempFile, $oldFile)
{
if (empty(trim($tempFile)) || empty(trim($oldFile))) {
return false;
}
// 目录不存在就新建
if (!is_dir($oldFile)) {
mkdir($oldFile, 0777, true);
}
foreach (glob($tempFile . '*') as $fileName) {
// 要处理的是目录时,递归处理文件目录。
if (is_dir($fileName)) {
self::upgradeFile($fileName . '/', $oldFile . basename($fileName) . '/');
}
// 要处理的是文件时,判断是否存在 或者 与原来文件不一致 则覆盖
if (is_file($fileName)) {
if (!file_exists($oldFile . basename($fileName))
|| md5(file_get_contents($fileName)) != md5(file_get_contents($oldFile . basename($fileName)))
) {
copy($fileName, $oldFile . basename($fileName));
}
}
}
return true;
}
}

View File

@@ -0,0 +1,153 @@
<?php
// +----------------------------------------------------------------------
// | likeshop100%开源免费商用商城系统
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | 商业版本务必购买商业授权,以免引起法律纠纷
// | 禁止对系统程序代码以任何目的,任何形式的再发布
// | 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团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeshopTeam
// +----------------------------------------------------------------------
namespace app\adminapi\logic\setting\user;
use app\common\{service\ConfigService, service\FileService};
/**
* 设置-用户设置逻辑层
* Class UserLogic
* @package app\adminapi\logic\config
*/
class UserLogic
{
/**
* @notes 获取用户设置
* @return array
* @author cjhao
* @date 2021/7/27 17:49
*/
public static function getConfig():array
{
$config = [
//默认头像
'default_avatar' => ConfigService::get('config', 'default_avatar', FileService::getFileUrl(config('project.default_image.default_avatar'))),
'default_coach_avatar' => ConfigService::get('config', 'default_coach_avatar', FileService::getFileUrl(config('project.default_image.default_coach_avatar'))),
'default_shop_avatar' => ConfigService::get('config', 'default_shop_avatar', FileService::getFileUrl(config('project.default_image.default_shop_avatar'))),
];
return $config;
}
/**
* @notes 设置用户设置
* @param array $postData
* @return bool
* @author cjhao
* @date 2021/7/27 17:58
*/
public function setConfig(array $params):bool
{
ConfigService::set('config', 'default_avatar', $params['default_avatar']);
ConfigService::set('config', 'default_coach_avatar', $params['default_coach_avatar']);
ConfigService::set('config', 'default_shop_avatar', $params['default_shop_avatar']);
return true;
}
/**
* @notes 获取注册配置
* @return array
* @author ljj
* @date 2022/2/17 3:32 下午
*/
public function getRegisterConfig():array
{
$config = [
// 'default_avatar' => ConfigService::get('login', 'default_avatar', FileService::getFileUrl(config('project.default_image.user_avatar'))),
// 登录方式
'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')),
];
return $config;
}
/**
* @notes 设置登录注册
* @param array $params
* @return bool
* @author cjhao
* @date 2021/9/14 17:20
*/
public static function setRegisterConfig(array $params):bool
{
// 登录方式1-账号密码登录2-手机短信验证码登录
// ConfigService::set('login', 'default_avatar', $params['default_avatar']);
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']);
return true;
}
/**
* @notes 提现配置
* @return array
* @author cjhao
* @date 2024/8/27 17:54
*/
public function getWithdrawConfig()
{
$config = [
'way_list' => ConfigService::get('withdraw', 'way_list'),
'min_money' => ConfigService::get('withdraw', 'min_money'),
'max_money' => ConfigService::get('withdraw', 'max_money'),
'service_charge' => ConfigService::get('withdraw', 'service_charge'),
'withdraw_cycle_type' => ConfigService::get('withdraw', 'withdraw_cycle_type'),
'withdraw_cycle_date' => ConfigService::get('withdraw', 'withdraw_cycle_date'),
];
return $config;
}
/**
* @notes 设置提现配置
* @return void
* @author cjhao
* @date 2024/8/27 17:54
*/
public function setWithdrawConfig($params)
{
ConfigService::set('withdraw', 'way_list',$params['way_list']);
ConfigService::set('withdraw', 'min_money',$params['min_money']);
ConfigService::set('withdraw', 'max_money',$params['max_money']);
ConfigService::set('withdraw', 'service_charge',$params['service_charge']);
ConfigService::set('withdraw', 'withdraw_cycle_type',$params['withdraw_cycle_type']);
ConfigService::set('withdraw', 'withdraw_cycle_date',$params['withdraw_cycle_date']);
}
}

View File

@@ -0,0 +1,174 @@
<?php
// +----------------------------------------------------------------------
// | likeshop100%开源免费商用商城系统
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | 商业版本务必购买商业授权,以免引起法律纠纷
// | 禁止对系统程序代码以任何目的,任何形式的再发布
// | 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团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeshopTeam
// +----------------------------------------------------------------------
namespace app\adminapi\logic\setting\web;
use app\common\logic\BaseLogic;
use app\common\service\ConfigService;
use app\common\service\FileService;
/**
* 网站设置
* Class WebSettingLogic
* @package app\adminapi\logic\setting
*/
class WebSettingLogic extends BaseLogic
{
/**
* @notes 获取网站信息
* @return array
* @author 段誉
* @date 2021/12/28 15:43
*/
public static function getWebsiteInfo(): array
{
return [
'name' => ConfigService::get('website', 'name'),
'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')),
'shop_name' => ConfigService::get('website', 'shop_name'),
'shop_logo' => FileService::getFileUrl(ConfigService::get('website', 'shop_logo')),
'mobile' => ConfigService::get('website', 'mobile'),
'contact' => ConfigService::get('website', 'contact'),
'document_status' => ConfigService::get('website','document_status',1),
];
}
/**
* @notes 设置网站信息
* @param array $params
* @author 段誉
* @date 2021/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']);
$shop_logo = FileService::setFileUrl($params['shop_logo']);
ConfigService::set('website', 'name', $params['name']);
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', $shop_logo);
ConfigService::set('website', 'mobile', $params['mobile']);
ConfigService::set('website', 'contact', $params['contact']);
//文档信息开关
ConfigService::set('website','document_status', $params['document_status']);
}
/**
* @notes 获取版权备案
* @return array
* @author 段誉
* @date 2021/12/28 16:09
*/
public static function getCopyright() : array
{
return ConfigService::get('copyright', 'config', []);
}
/**
* @notes 设置版权备案
* @param array $params
* @return bool
* @author 段誉
* @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)
{
ConfigService::set('agreement', 'service_title', $params['service_title'] ?? '');
ConfigService::set('agreement', 'service_content', $params['service_content'] ?? '');
ConfigService::set('agreement', 'privacy_title', $params['privacy_title'] ?? '');
ConfigService::set('agreement', 'privacy_content', $params['privacy_content'] ?? '');
}
/**
* @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'),
];
return $config;
}
/**
* @notes 设置地图钥匙
* @param array $params
* @return bool
* @author ljj
* @date 2022/3/10 5:11 下午
*/
public static function setMapKey(array $params)
{
ConfigService::set('map', 'tencent_map_key', $params['tencent_map_key'] ?? '');
return true;
}
/**
* @notes 获取地图钥匙
* @return array
* @author ljj
* @date 2022/3/10 5:12 下午
*/
public static function getMapKey(): array
{
return [
'tencent_map_key' => ConfigService::get('map', 'tencent_map_key',''),
];
}
}