chore: 添加静态资源文件和版本配置文件

添加大量图片、字体、音频等静态资源文件,包括用户界面图片、模板文件和安装界面素材
添加系统版本配置文件(.version)和常量定义文件(.constant)
更新供应商依赖文件,包括Symfony VarDumper组件和相关许可证文件
添加验证码配置文件(captcha.php)和.gitignore规则
This commit is contained in:
2026-03-06 20:14:23 +08:00
commit c9a98f342c
4485 changed files with 490986 additions and 0 deletions

View File

@@ -0,0 +1,29 @@
<?php
namespace app\controller\admin\v1\system;
use app\controller\admin\AuthController;
use app\services\system\AiServices;
use think\annotation\Inject;
class Ai extends AuthController
{
/**
* @var AiServices
*/
#[Inject]
protected AiServices $services;
public function chatAi()
{
$data = $this->request->postMore([
['message', ''],
['store_name', ''],
['product_id', 0],
['unique', ''],
['type', '']
]);
$result = $this->services->AiType($data);
return $this->success($result);
}
}

View File

@@ -0,0 +1,83 @@
<?php
namespace app\controller\admin\v1\system;
use app\controller\admin\AuthController;
use app\services\system\AppVersionServices;
use think\annotation\Inject;
class AppVersion extends AuthController
{
/**
* @var AppVersionServices
*/
#[Inject]
protected AppVersionServices $services;
/**
* 版本列表
* @return \think\Response
* @author wuhaotian
* @email 442384644@qq.com
* @date 2024/4/2
*/
public function list()
{
$where = $this->request->getMore([
['platform', '']
]);
return $this->success($this->services->versionList($where));
}
/**
* 新增版本表单
* @param $id
* @return \think\Response
* @throws \FormBuilder\Exception\FormBuilderException
* @author wuhaotian
* @email 442384644@qq.com
* @date 2024/4/2
*/
public function crate($id)
{
return $this->success($this->services->createForm($id));
}
/**
* 保存数据
* @return \think\Response
* @author wuhaotian
* @email 442384644@qq.com
* @date 2024/4/2
*/
public function save()
{
$data = $this->request->postMore([
['id', 0],
['version', ''],
['platform', 1],
['info', ''],
['is_force', 1],
['url', ''],
['is_new', 1],
]);
$id = $data['id'];
unset($data['id']);
$this->services->versionSave($id, $data);
return $this->success(100021);
}
/**
* 删除App版本
* @param $id
* @return \think\Response
* @author wuhaotian
* @email 442384644@qq.com
* @date 2024/4/2
*/
public function del($id)
{
$this->services->delete($id);
return $this->success('删除成功');
}
}

View File

@@ -0,0 +1,65 @@
<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
namespace app\controller\admin\v1\system;
use think\exception\ValidateException;
use app\services\system\log\ClearServices;
use app\controller\admin\AuthController;
/**
* 清除数据控制器
* Class Clear
* @package app\controller\admin\v1\system
*/
class Out extends AuthController
{
/**
* @var ClearServices
*/
protected ClearServices $services;
/**
* Out constructor.
* @param ClearServices $services
*/
public function __construct(ClearServices $services)
{
parent::__construct();
$this->services = $services;
//生产模式下不允许清除数据
if (!env('APP_DEBUG', false)) {
throw new ValidateException('生产模式下,禁止操作');
}
}
/**
* 刷新数据缓存
*/
public function refresh_cache()
{
$this->services->refresCache();
return $this->success('数据缓存刷新成功!');
}
/**
* 删除日志
*/
public function delete_log()
{
$this->services->deleteLog();
return $this->success('数据缓存刷新成功!');
}
}

View File

@@ -0,0 +1,136 @@
<?php
namespace app\controller\admin\v1\system;
use app\controller\admin\AuthController;
use app\services\system\PrintDocumentServices;
use think\annotation\Inject;
class PrintDocument extends AuthController
{
/**
* @var PrintDocumentServices
*/
#[Inject]
protected PrintDocumentServices $services;
/**
* 打印机列表
* @return \think\Response
* @author wuhaotian
* @email 442384644@qq.com
* @date 2024/8/21
*/
public function printList()
{
$where = $this->request->getMore([
['type', 0],
['keyword', ''],
]);
$where['supplier_id'] = $this->supplierId ?: 0;
return $this->success($this->services->printList($where));
}
/**
* 打印机添加表单
* @param $id
* @return \think\Response
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author wuhaotian
* @email 442384644@qq.com
* @date 2024/8/21
*/
public function printForm($id)
{
return $this->success($this->services->printForm($id));
}
/**
* 保存打印机
* @param $id
* @return \think\Response
* @author wuhaotian
* @email 442384644@qq.com
* @date 2024/8/21
*/
public function printSave($id)
{
$data = $this->request->postMore([
['print_name', ''],
['type', 0],
['yly_user_id', ''],
['yly_app_id', ''],
['yly_app_secret', ''],
['yly_sn', ''],
['fey_user', ''],
['fey_ukey', ''],
['fey_sn', ''],
['times', 1],
['print_type', 1],
['status', 1],
]);
if (!$id) {
$data['supplier_id'] = $this->supplierId ?: 0;
}
$this->services->printSave($id, $data);
return $this->success('保存成功');
}
/**
* 打印机状态修改
* @param $id
* @param $status
* @return \think\Response
* @author wuhaotian
* @email 442384644@qq.com
* @date 2024/8/21
*/
public function printSetStatus($id, $status)
{
$this->services->printSetStatus($id, $status);
return $this->success('修改成功');
}
/**
* 删除打印机
* @param $id
* @return \think\Response
* @author wuhaotian
* @email 442384644@qq.com
* @date 2024/8/21
*/
public function printDel($id)
{
$this->services->printDel($id);
return $this->success('删除成功');
}
public function getPrintContent($id)
{
return $this->success($this->services->getPrintContent($id));
}
public function savePrintContent($id)
{
$data = $this->request->postMore([
['header', 0],
['delivery', 0],
['buyer_remarks', 0],
['goods', []],
['freight', 0],
['preferential', 0],
['pay', []],
['custom', 0],
['order', []],
['code', 0],
['code_url', ''],
['show_notice', 0],
['notice_content', '']
]);
$this->services->savePrintContent($id, $data);
return $this->success('保存成功');
}
}

View File

@@ -0,0 +1,290 @@
<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
namespace app\controller\admin\v1\system;
use app\services\community\CommunityRelevanceServices;
use app\services\other\HotDataServices;
use app\services\product\product\StoreDescriptionServices;
use app\services\product\product\StoreProductCouponServices;
use app\services\product\product\StoreProductRelationServices;
use app\services\user\UserRelationServices;
use app\services\product\product\StoreProductReplyServices;
use app\services\product\sku\StoreProductAttrResultServices;
use app\services\product\sku\StoreProductAttrServices;
use app\services\product\sku\StoreProductAttrValueServices;
use crmeb\exceptions\AdminException;
use crmeb\services\CacheService;
use think\annotation\Inject;
use think\exception\ValidateException;
use app\controller\admin\AuthController;
use app\services\system\SystemClearServices;
use app\services\product\product\StoreProductServices;
use app\services\system\attachment\SystemAttachmentServices;
/**
* 清除默认数据理控制器
* Class SystemClearData
* @package app\controller\admin\v1\system
*/
class SystemClearData extends AuthController
{
/**
* @var SystemClearServices
*/
#[Inject]
protected SystemClearServices $services;
/**
* 构造方法
* SystemClearData constructor.
* @param SystemClearServices $services
*/
public function __construct(SystemClearServices $services)
{
parent::__construct();
$this->services = $services;
//生产模式下不允许清除数据
if (!env('APP_DEBUG', false)) {
throw new ValidateException('生产模式下,禁止操作');
}
}
/**
* 清除方法入口
* @param $type
* @return mixed
*/
public function index($type)
{
switch ($type) {
case 'temp':
return $this->userTemp();
break;
case 'recycle':
return $this->recycleProduct();
break;
case 'store':
return $this->storeData();
break;
case 'order':
return $this->orderData();
break;
case 'kefu':
return $this->kefuData();
break;
case 'wechat':
return $this->wechatData();
break;
case 'attachment':
return $this->attachmentData();
break;
case 'article':
return $this->articledata();
break;
case 'system':
return $this->systemdata();
break;
case 'user':
return $this->userRelevantData();
break;
default:
return $this->fail('参数有误');
}
}
/**
* 清除用户生成的临时文件
* @return mixed
*/
public function userTemp()
{
/** @var SystemAttachmentServices $services */
$services = app()->make(SystemAttachmentServices::class);
$ids = implode(',', $services->getColumn(['module_type' => 2], 'att_id'));
$services->del($ids);
$services->delete(2, 'module_type');
return $this->success('清除数据成功!');
}
/**
* 清除回收站商品
* @return mixed
*/
public function recycleProduct(array $ids = [])
{
/** @var StoreProductServices $product */
$product = app()->make(StoreProductServices::class);
if (!$ids) {
$ids = $product->getColumn(['is_del' => 1], 'id');
} else {
if ($product->search(['id' => $ids, 'is_del' => 0])->find()) {
return $this->fail('只能删除回收站商品');
}
}
$this->services->recycleProduct($ids);
return $this->success('清除数据成功!');
}
/**
* 清除用户数据
* @return mixed
*/
public function userRelevantData()
{
$this->services->clearData([
'wechat_user', 'wechat_message', 'user_search', 'user_visit', 'user_sign', 'user_recharge', 'user_notice_see', 'user_notice',
'user_level', 'user_label_relation', 'user_label', 'user_invoice', 'user_group', 'user_friends', 'user_extract', 'user_enter',
'user_brokerage_frozen', 'user_bill', 'user_address', 'user', 'system_store_staff', 'store_visit', 'store_service_record',
'store_service_speechcraft', 'store_service_record', 'store_service_log', 'store_service_feedback', 'store_service',
'store_product_reply', 'user_relation', 'store_product_log', 'store_pink', 'store_order_status', 'store_order_invoice',
'store_order_economize', 'store_order_cart_info', 'store_order', 'store_coupon_user', 'store_coupon_issue_user', 'store_cart',
'store_bargain_user_help', 'store_bargain_user', 'sms_record', 'qrcode', 'other_order_status', 'other_order', 'member_card',
'member_card_batch', 'delivery_service', 'queue_auxiliary', 'queue_list', 'luck_lottery_record', 'agent_level_task_record',
'user_brokerage', 'user_money', 'system_message'
], true);
$this->services->delDirAndFile('./public/uploads/store/comment');
return $this->success('清除数据成功!');
}
/**
* 清除商城数据
* @return mixed
*/
public function storeData()
{
$this->services->clearData([
'store_product_category', 'live_anchor', 'live_goods', 'live_room', 'live_room_goods', 'store_bargain', 'store_bargain_user',
'store_bargain_user_help', 'store_cart', 'store_combination', 'store_coupon_issue', 'store_coupon_issue_user',
'store_coupon_product', 'store_coupon_user', 'store_product', 'store_product_attr', 'store_product_attr_result',
'store_product_attr_value', 'store_product_cate', 'store_product_coupon', 'store_product_description', 'store_product_log',
'user_relation', 'store_product_reply', 'store_product_rule', 'store_seckill', 'store_visit', 'store_integral'
], true);
return $this->success('清除数据成功!');
}
/**
* 清除订单数据
* @return mixed
*/
public function orderData()
{
$this->services->clearData([
'queue_list', 'queue_auxiliary', 'other_order_status', 'store_order', 'store_order_cart_info', 'store_order_economize', 'store_order_invoice', 'store_order_refund',
'store_order_status', 'store_pink', 'other_order', 'store_integral_order', 'store_integral_order_status'
], true);
return $this->success('清除数据成功!');
}
/**
* 清除客服数据
* @return mixed
*/
public function kefuData()
{
$this->services->clearData([
'queue_auxiliary', 'store_service', 'store_service_feedback', 'store_service_log', 'store_service_record', 'store_service_speechcraft'
], true);
$this->services->delDirAndFile('./public/uploads/store/service');
return $this->success('清除数据成功!');
}
/**
* 清除微信管理数据
* @return mixed
*/
public function wechatData()
{
$this->services->clearData([
'wechat_key', 'wechat_media', 'wechat_message', 'wechat_news_category', 'wechat_reply'
], true);
$this->services->delDirAndFile('./public/uploads/wechat');
return $this->success('清除数据成功!');
}
/**
* 清除所有附件
* @return mixed
*/
public function attachmentData()
{
$this->services->clearData([
'system_attachment', 'system_attachment_category'
], true);
$this->services->delDirAndFile('./public/uploads/');
return $this->success('清除上传文件成功!');
}
/**
* 清楚内容数据
* @return mixed
*/
public function articledata()
{
$this->services->clearData([
'article_category', 'article', 'article_content'
], true);
return $this->success('清除数据成功!');
}
/**
* 清楚系统记录
* @return mixed
*/
public function systemdata()
{
$this->services->clearData([
'system_notice_admin', 'system_log'
], true);
return $this->success('清除数据成功!');
}
/**
* 替换域名方法
* @return mixed
*/
public function replaceSiteUrl()
{
[$url] = $this->request->postMore([
['url', '']
], true);
if (!$url)
return $this->fail('请输入需要更换的域名');
if (!verify_domain($url))
return $this->fail('域名不合法');
$this->services->replaceSiteUrl($url);
return $this->success('替换成功!');
}
/**
* 预热营销商品库存
* @param HotDataServices $hotDataServices
* @return mixed
*/
public function hotProductStock(HotDataServices $hotDataServices)
{
$key = 'hot_product_stock';
$re = CacheService::get($key);
if (!$re) {
$f = [1, 2, 3, 4, 5];
try {
foreach ($f as $type) {
$hotDataServices->hot($type);
}
} catch (\Throwable $e) {
}
CacheService::set($key, time(), 86400);
}
return $this->success('预热成功!');
}
}

View File

@@ -0,0 +1,172 @@
<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
namespace app\controller\admin\v1\system;
use think\facade\Session;
use think\annotation\Inject;
use think\exception\ValidateException;
use app\controller\admin\AuthController;
use app\services\system\SystemDatabackupServices;
/**
* 数据备份
* Class SystemDatabackup
* @package app\admin\controller\system
*
*/
class SystemDatabackup extends AuthController
{
/**
* @var SystemDatabackupServices
*/
#[Inject]
protected SystemDatabackupServices $services;
/**
* 构造方法
* SystemDatabackup constructor.
* @param SystemDatabackupServices $services
*/
public function __construct(SystemDatabackupServices $services)
{
parent::__construct();
$this->services = $services;
//生产模式下不允许清除数据
if (!env('APP_DEBUG', false)) {
throw new ValidateException('生产模式下,禁止操作');
}
}
/**
* 获取数据库表
*/
public function index()
{
return $this->success($this->services->getDataList());
}
/**
* 查看表结构 详情
*/
public function read()
{
[$tablename] = $this->request->getMore(['tablename', ''],true);
return $this->success($this->services->getRead($tablename));
}
/**
* 优化表
*/
public function optimize()
{
[$tables] = $this->request->postMore(['tables', ''],true);
$res = $this->services->getDbBackup()->optimize($tables);
return $this->success($res ? '优化成功' : '优化失败');
}
/**
* 修复表
*/
public function repair()
{
[$tables] = $this->request->postMore(['tables', ''],true);
$res = $this->services->getDbBackup()->repair($tables);
return $this->success($res ? '修复成功' : '修复失败');
}
/**
* 备份表
*/
public function backup()
{
[$tables] = $this->request->postMore(['tables', ''],true);
$data = $this->services->backup($tables);
return $this->success($data ? '备份失败' . $data : '备份成功');
}
/**
* 获取备份记录表
*/
public function fileList()
{
return $this->success($this->services->getBackup());
}
/**
* 删除备份记录表
*/
public function delFile()
{
$filename = intval(request()->post('filename'));
$files = $this->services->getDbBackup()->delFile($filename);
return $this->success('删除成功');
}
/**
* 导入备份记录表
*/
public function import()
{
[$part, $start, $time] = $this->request->postMore([
[['part', 'd'], 0],
[['start', 'd'], 0],
[['time', 'd'], 0],
], true);
$db = $this->services->getDbBackup();
if (is_numeric($time) && !$start) {
$list = $db->getFile('timeverif', $time);
if (is_array($list)) {
session::set('backup_list', $list);
return $this->success('初始化完成!', array('part' => 1, 'start' => 0));
} else {
return $this->fail('备份文件可能已经损坏,请检查!');
}
} else if (is_numeric($part) && is_numeric($start) && $part && $start) {
$list = session::get('backup_list');
$start = $db->setFile($list)->import($start);
if (false === $start) {
return $this->fail('还原数据出错!');
} elseif (0 === $start) {
if (isset($list[++$part])) {
$data = array('part' => $part, 'start' => 0);
return $this->success("正在还原...#{$part}", $data);
} else {
session::delete('backup_list');
return $this->success('还原完成!');
}
} else {
$data = array('part' => $part, 'start' => $start[0]);
if ($start[1]) {
$rate = floor(100 * ($start[0] / $start[1]));
return $this->success("正在还原...#{$part}({$rate}%)", $data);
} else {
$data['gz'] = 1;
return $this->success("正在还原...#{$part}", $data);
}
return $this->success("正在还原...#{$part}");
}
} else {
return $this->fail('参数错误!');
}
}
/**
* 下载备份记录表
*/
public function downloadFile()
{
$time = intval(request()->param('time'));
return $this->success(['key' => $this->services->getDbBackup()->downloadFile($time, 0, true)]);
}
}

View File

@@ -0,0 +1,335 @@
<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
namespace app\controller\admin\v1\system;
use app\controller\admin\AuthController;
use app\services\system\SystemMenusRelevanceServices;
use app\services\system\SystemMenusServices;
use crmeb\services\CacheService;
use think\annotation\Inject;
use think\helper\Str;
/**
* 菜单权限
* Class SystemMenus
* @package app\controller\admin\v1\setting
*/
class SystemMenus extends AuthController
{
/**
* @var SystemMenusServices
*/
#[Inject]
protected SystemMenusServices $services;
/**
* 菜单展示列表
* @return \think\Response
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function index()
{
$where = $this->request->getMore([
['type', 1],
['is_show', ''],
['keyword', ''],
]);
return $this->success($this->services->getList($where));
}
/**
* 显示创建资源表单页.
*
* @return \think\Response
*/
public function create()
{
[$type] = $this->request->getMore([
['type', 1]
], true);
return $this->success($this->services->createMenus($type));
}
/**
* 保存菜单权限
* @return mixed
*/
public function save()
{
$data = $this->request->getMore([
['menu_name', ''],
['controller', ''],
['module', 'admin'],
['action', ''],
['icon', ''],
['params', ''],
['path', []],
['menu_path', ''],
['api_url', ''],
['methods', ''],
['unique_auth', ''],
['header', ''],
['is_header', 0],
['pid', 0],
['type', 1],
['sort', 0],
['auth_type', 0],
['access', 1],
['is_show', 1],
['is_show_path', 0],
]);
if (!$data['menu_name'])
return $this->fail('请填写按钮名称');
$data['path'] = implode('/', $data['path']);
$data['is_show'] = $data['auth_type'] == 2 ? 1 : $data['is_show'];
if ($this->services->save($data)) {
CacheService::redisHandler('system_menus')->clear();
return $this->success('添加成功');
} else {
return $this->fail('添加失败');
}
}
/**
* 获取一条菜单权限信息
* @param int $id
* @return \think\Response
*/
public function read($id)
{
if (!$id) {
return $this->fail('数据不存在');
}
return $this->success($this->services->find((int)$id));
}
/**
* 修改菜单权限表单获取
* @param int $id
* @return \think\Response
*/
public function edit($id)
{
if (!$id) {
return $this->fail('缺少修改参数');
}
return $this->success($this->services->updateMenus((int)$id));
}
/**
* 修改菜单
* @param $id
* @return mixed
*/
public function update($id)
{
if (!$id || !($menu = $this->services->get($id)))
return $this->fail('数据不存在');
$data = $this->request->postMore([
['type', 1],
'menu_name',
'controller',
['module', 'admin'],
'action',
'params',
['icon', ''],
['menu_path', ''],
['api_url', ''],
['methods', ''],
['unique_auth', ''],
['path', []],
['sort', 0],
['pid', 0],
['is_header', 0],
['header', ''],
['auth_type', 0],
['access', 1],
['is_show', 1],
['is_show_path', 0],
]);
if (!$data['menu_name'])
return $this->fail('请输入按钮名称');
$data['path'] = implode('/', $data['path']);
$data['is_show'] = $data['auth_type'] == 2 ? 1 : $data['is_show'];
if ($this->services->update($id, $data)) {
CacheService::redisHandler('system_menus')->clear();
return $this->success('修改成功');
} else
return $this->fail('修改失败');
}
/**
* 删除指定资源
*
* @param int $id
* @return \think\Response
*/
public function delete($id)
{
if (!$id) {
return $this->fail('参数错误,请重新打开');
}
if (!$this->services->delete((int)$id)) {
CacheService::redisHandler('system_menus')->clear();
return $this->fail('删除失败,请稍候再试!');
} else {
return $this->success('删除成功!');
}
}
/**
* 显示和隐藏
* @param $id
* @return mixed
*/
public function show($id)
{
if (!$id) {
return $this->fail('参数错误,请重新打开');
}
[$show] = $this->request->postMore([['is_show', 0]], true);
if ($this->services->update($id, ['is_show' => $show])) {
CacheService::redisHandler('system_menus')->clear();
return $this->success('修改成功');
} else {
return $this->fail('修改失败');
}
}
/**
* 获取菜单数据
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function menus()
{
[$type] = $this->request->getMore([
['type', 1]
], true);
[$menus, $unique] = $this->services->getMenusList($this->adminInfo['roles'], (int)$this->adminInfo['level']);
return app('json')->success(['menus' => $menus, 'unique' => $unique]);
}
/**
* 获取接口列表
* @return array
*/
public function ruleList($type = 1)
{
$this->app = app();
$rule = $type == 1 ? 'adminapi/' : 'storeapi/';
$this->app->route->setTestMode(true);
$this->app->route->clear();
$path = $this->app->getRootPath() . 'route' . DIRECTORY_SEPARATOR;
$files = is_dir($path) ? scandir($path) : [];
foreach ($files as $file) {
if (strpos($file, '.php')) {
include $path . $file;
}
}
$ruleList = $this->app->route->getRuleList();
$ruleNewList = [];
foreach ($ruleList as $item) {
if (Str::contains($item['rule'], $rule)) {
$ruleNewList[] = $item;
}
}
foreach ($ruleNewList as $key => &$value) {
$only = $value['option']['only'] ?? [];
$route = is_string($value['route']) ? explode('/', $value['route']) : [];
$value['route'] = is_string($value['route']) ? $value['route'] : '';
$action = $route[count($route) - 1] ?? null;
if ($only && $action && !in_array($action, $only)) {
unset($ruleNewList[$key]);
}
$except = $value['option']['except'] ?? [];
if ($except && $action && in_array($action, $except)) {
unset($ruleNewList[$key]);
}
}
$ruleList = $ruleNewList;
//获取所有的路由
// $ruleList = Route::getRuleList();
$menuApiList = $this->services->getColumn(['auth_type' => 2, 'is_del' => 0, 'type' => $type], "concat(`api_url`,'_',lower(`methods`)) as rule");
if ($menuApiList) $menuApiList = array_column($menuApiList, 'rule');
$list = [];
$action_arr = ['index', 'read', 'create', 'save', 'edit', 'update', 'delete'];
$middleware = $type == 1 ? 'app\http\middleware\admin\AdminCkeckRoleMiddleware' : 'app\http\middleware\store\StoreCkeckRoleMiddleware';
foreach ($ruleList as $item) {
$item['rule'] = str_replace($type == 1 ? 'adminapi/' : 'storeapi/', '', $item['rule']);
if (!in_array($item['rule'] . '_' . $item['method'], $menuApiList) && isset($item['option']['middleware']) && in_array($middleware, $item['option']['middleware'])) {
$real_name = $item['option']['real_name'] ?? '';
if (is_array($real_name)) {
foreach ($action_arr as $action) {
if (Str::contains($item['route'], $action)) {
$real_name = $real_name[$action] ?? '';
}
}
}
$item['real_name'] = $real_name;
unset($item['option']);
$item['method'] = strtoupper($item['method']);
$list[] = $item;
}
}
return app('json')->success($list);
}
/**
* 获取关键词
* @param $id
* @param SystemMenusRelevanceServices $services
* @return \think\Response
* @throws \ReflectionException
* User: liusl
* DateTime: 2024/12/25 上午10:07
*/
public function getKeyword($id, SystemMenusRelevanceServices $services)
{
if (!$id) {
return app('json')->fail('参数错误');
}
return app('json')->success($services->getKeyword($id));
}
/**
* 修改关键词
* @param $id
* @param SystemMenusRelevanceServices $services
* @return \think\Response
* @throws \ReflectionException
* User: liusl
* DateTime: 2024/12/25 上午10:08
*/
public function setKeyword($id, SystemMenusRelevanceServices $services)
{
[$keyword] = $this->request->getMore([
['keyword', []]
], true);
if (!$id) {
return app('json')->fail('参数错误');
}
$res = $services->updateData($id, $keyword);
return app('json')->success('操作成功');
}
public function searchMenus()
{
}
}

View File

@@ -0,0 +1,87 @@
<?php
namespace app\controller\admin\v1\system;
use app\controller\admin\AuthController;
use app\services\system\SystemRecommendServices;
use think\annotation\Inject;
class SystemRecommend extends AuthController
{
/**
* @var SystemRecommendServices
*/
#[Inject]
protected SystemRecommendServices $services;
/**
* 获取推荐列表
* @return mixed
*/
public function getRecommendList()
{
return $this->success($this->services->getRecommendList());
}
/**
* 获取推荐详情
* @param int $id 推荐ID
* @return mixed
*/
public function getRecommendInfo($id)
{
return $this->success($this->services->getRecommendInfo($id));
}
/**
* 编辑推荐标题
* @return mixed
*/
public function editRecommendTitle()
{
[$id, $title] = $this->request->postMore([
['id', 0],
['title', ''],
], true);
$this->services->editRecommendTitle($id, $title);
return $this->success('保存成功');
}
/**
* 保存推荐配置
* @return mixed
*/
public function saveRecommend()
{
$data = $this->request->postMore([
['id', 0], // id 0新增,非0编辑
['name', ''], //名称
['title', ''], //推荐标题
['pic', ''], //图标
['type', 0], //推荐类型
['specify_recommend_status', 0], //指定推荐状态
['specify_recommend_content', ''], //指定推荐内容
['personality_recommend_status', 0], //个性推荐状态
['personality_recommend_content', ''], //个性推荐内容
['sort_recommend_status', 0], //排序推荐状态
['sort_recommend_content', ''], //排序推荐内容
['status', 1] //状态
]);
$id = $data['id'];
unset($data['id']);
$result = $this->services->saveRecommend($id, $data);
return $this->success('保存成功');
}
/**
* 设置推荐状态
* @param int $id 推荐ID
* @param int $status 状态
* @return mixed
*/
public function setRecommendStatus($id, $status)
{
$this->services->setRecommendStatus($id, $status);
return $this->success('修改成功');
}
}

View File

@@ -0,0 +1,142 @@
<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
namespace app\controller\admin\v1\system;
use app\controller\admin\AuthController;
use app\services\system\SystemRoleServices;
use app\services\system\SystemMenusServices;
use crmeb\services\CacheService;
use think\annotation\Inject;
/**
* Class SystemRole
* @package app\controller\admin\v1\setting
*/
class SystemRole extends AuthController
{
/**
* @var SystemRoleServices
*/
#[Inject]
protected SystemRoleServices $services;
/**
* 显示资源列表
*
* @return \think\Response
*/
public function index()
{
$where = $this->request->getMore([
['status', ''],
['role_name', ''],
]);
$where['type'] = 0;
$where['level'] = $this->adminInfo['level'] + 1;
return $this->success($this->services->getRoleList($where));
}
/**
* 显示创建资源表单页.
*
* @return \think\Response
*/
public function create(SystemMenusServices $services)
{
$menus = $services->getmenus($this->adminInfo['level'] == 0 ? [] : $this->adminInfo['roles'], 1, 0);
return $this->success(compact('menus'));
}
/**
* 保存新建的资源
*
* @return \think\Response
*/
public function save($id)
{
$data = $this->request->postMore([
'role_name',
['status', 0],
['checked_menus', [], '', 'rules']
]);
if (!$data['role_name']) return $this->fail('请输入身份名称');
if (!is_array($data['rules']) || !count($data['rules']))
return $this->fail('请选择最少一个权限');
$data['rules'] = implode(',', $data['rules']);
if ($id) {
if (!$this->services->update($id, $data)) return $this->fail('修改失败!');
CacheService::redisHandler('system_menus')->clear();
return $this->success('修改成功!');
} else {
$data['level'] = $this->adminInfo['level'] + 1;
if (!$this->services->save($data)) return $this->fail('添加身份失败!');
CacheService::redisHandler('system_menus')->clear();
return $this->success('添加身份成功!');
}
}
/**
* 显示编辑资源表单页.
*
* @param int $id
* @return \think\Response
*/
public function edit(SystemMenusServices $services, $id)
{
$role = $this->services->get($id);
if (!$role) {
return $this->fail('修改的角色不存在');
}
$menus = $services->getMenus($this->adminInfo['level'] == 0 ? [] : $this->adminInfo['roles'], 1, 0);
return $this->success(['role' => $role->toArray(), 'menus' => $menus]);
}
/**
* 删除指定资源
*
* @param int $id
* @return \think\Response
*/
public function delete($id)
{
if (!$this->services->delete($id))
return $this->fail('删除失败,请稍候再试!');
else {
CacheService::redisHandler('system_menus')->clear();
return $this->success('删除成功!');
}
}
/**
* 修改状态
* @param $id
* @param $status
* @return mixed
*/
public function set_status($id, $status)
{
if (!$id) {
return $this->fail('缺少参数');
}
$role = $this->services->get($id);
if (!$role) {
return $this->fail('没有查到此身份');
}
$role->status = $status;
if ($role->save()) {
CacheService::redisHandler('system_menus')->clear();
return $this->success('修改成功');
} else {
return $this->fail('修改失败');
}
}
}

View File

@@ -0,0 +1,104 @@
<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
namespace app\controller\admin\v1\system;
use app\controller\admin\AuthController;
use app\services\system\SystemSignRewardServices;
use think\annotation\Inject;
/**
* 签到奖励
* Class SystemSignReward
* @package app\controller\admin\v1\system
*/
class SystemSignReward extends AuthController
{
/**
* @var SystemSignRewardServices
*/
#[Inject]
protected SystemSignRewardServices $services;
/**
* 签到奖励列表
* @return \think\Response
*/
public function index()
{
[$type] = $this->request->getMore([
['type', 0]
], true);
$data = $this->services->getList($type);
return app('json')->success($data);
}
/**
* 新增签到奖励
* @return \think\Response
* @throws \FormBuilder\Exception\FormBuilderException
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function addRewards()
{
[$type] = $this->request->getMore([
['type', 0]
], true);
$data = $this->services->rewardsForm(0, $type);
return app('json')->success($data);
}
/**
* 修改签到奖励
* @param $id
* @return \think\Response
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function editRewards($id)
{
$data = $this->services->rewardsForm($id);
return app('json')->success($data);
}
/**
* 保存签到奖励
* @param $id
* @return \think\Response
* @throws \think\db\exception\DbException
*/
public function saveRewards($id)
{
$data = $this->request->postMore([
['type', 0],
['days', 0],
['point', 0],
['exp', 0]
]);
$this->services->saveRewards($id, $data);
return app('json')->success('保存成功');
}
/**
* 删除签到奖励
* @param $id
* @return \think\Response
*/
public function delRewards($id)
{
$this->services->delete($id);
return app('json')->success('删除成功');
}
}

View File

@@ -0,0 +1,135 @@
<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
namespace app\controller\admin\v1\system;
use app\controller\admin\AuthController;
use app\services\system\timer\SystemTimerServices;
use think\annotation\Inject;
/**
* 定时任务表控制器
* Class SystemTimer
* @package app\controller\admin\v1\system
*/
class SystemTimer extends AuthController
{
/**
* @var SystemTimerServices
*/
#[Inject]
protected SystemTimerServices $services;
/**
* 定时任务名称及标识
* @return mixed
*/
public function task_name()
{
return $this->success($this->services->getTasKName());
}
/**
* 显示列表
* @return mixed
*/
public function index()
{
$where['is_del'] = 0;
return $this->success($this->services->getTimerList($where));
}
/**
* 删除指定资源
* @param string $id
* @return \think\Response
*/
public function delete($id)
{
$this->services->del($id);
$this->services->delOneTimerCache($id);
return $this->success('删除成功');
}
/**
* 修改状态
* @param string $is_show
* @param string $id
*/
public function set_show($id = '', $is_show = '')
{
if ($is_show == '' || $id == '') return $this->fail('缺少参数');
$this->services->setShow($id, $is_show);
$this->services->updateOneTimerCache($id);
return $this->success($is_show == 1 ? '显示成功' : '隐藏成功');
}
/**获取单条定时器数据
* @param $id
* @return void
*/
public function get_timer_one($id)
{
return $this->success($this->services->getOneTimer($id));
}
/**
* 保存定时任务
* @return mixed
*/
public function save()
{
$data = $this->request->postMore([
['name', ''],
['mark', ''],
['type', 0],
['title', ''],
['is_open', 0],
['cycle', '']
]);
if (!$data['name']) {
return $this->fail('请输入定时任务名称');
}
if (!$data['mark']) {
return $this->fail('请输入定时任务标识');
}
$this->services->createData($data);
$this->services->setAllTimerCache();
return $this->success('添加定时器成功!');
}
/**
* 更新定时任务
* @param $id
* @return mixed
*/
public function update($id)
{
$data = $this->request->postMore([
['name', ''],
['mark', ''],
['type', 0],
['title', ''],
['is_open', 0],
['cycle', '']
]);
if (!$data['name']) {
return $this->fail('请输入定时任务名称');
}
if (!$data['mark']) {
return $this->fail('请输入定时任务标识');
}
$this->services->editData($id, $data);
$this->services->updateOneTimerCache($id);
return $this->success('修改成功!');
}
}

View File

@@ -0,0 +1,23 @@
<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
namespace app\controller\admin\v1\system;
use app\controller\admin\AuthController;
/**
* 在线升级控制器
* Class SystemUpgradeClient
* @package app\controller\admin\v1\system
*/
class SystemUpgradeClient extends AuthController
{
}

View File

@@ -0,0 +1,201 @@
<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
namespace app\controller\admin\v1\system\admin;
use app\controller\admin\AuthController;
use app\services\system\admin\LoginAuthServices;
use app\services\system\admin\SystemAdminServices;
use crmeb\services\CacheService;
use think\facade\Config;
use think\annotation\Inject;
/**
* Class SystemAdmin
* @package app\controller\admin\v1\setting
*/
class SystemAdmin extends AuthController
{
/**
* @var SystemAdminServices
*/
#[Inject]
protected SystemAdminServices $services;
/**
* 显示管理员资源列表
*
* @return \think\Response
*/
public function index()
{
$where = $this->request->getMore([
['name', '', '', 'account_like'],
['roles', ''],
['is_del', 1],
['status', '']
]);
$where['level'] = $this->adminInfo['level'] + 1;
$where['admin_type'] = 1;
return $this->success($this->services->getAdminList($where));
}
/**
* 创建表单
* @return mixed
* @throws \FormBuilder\Exception\FormBuilderException
*/
public function create()
{
return $this->success($this->services->createForm($this->adminInfo['level'] + 1));
}
/**
* 添加管理员信息
* @param LoginAuthServices $loginAuthServices
* @return \think\Response
* User: liusl
* DateTime: 2024/7/31 10:06
*/
public function save(LoginAuthServices $loginAuthServices)
{
$data = $this->request->postMore([
['account', ''],
['conf_pwd', ''],
['pwd', ''],
['real_name', ''],
['phone', ''],
['roles', []],
['status', 0],
]);
$this->validate($data, \app\validate\admin\setting\SystemAdminValidate::class);
//验证密码
$loginAuthServices->validatePassword((string)$data['pwd']);
$data['level'] = $this->adminInfo['level'] + 1;
$this->services->create($data);
return $this->success('添加成功');
}
/**
* 显示编辑资源表单页.
*
* @param int $id
* @return \think\Response
*/
public function edit($id)
{
if (!$id) {
return $this->fail('管理员信息读取失败');
}
return $this->success($this->services->updateForm($this->adminInfo['level'] + 1, (int)$id));
}
/**
* 修改管理员信息
* @param LoginAuthServices $loginAuthServices
* @param $id
* @return \think\Response
* User: liusl
* DateTime: 2024/7/31 10:08
*/
public function update(LoginAuthServices $loginAuthServices, $id)
{
$data = $this->request->postMore([
['account', ''],
['conf_pwd', ''],
['pwd', ''],
['real_name', ''],
['phone', ''],
['roles', []],
['status', 0],
]);
if ($data['pwd']) {
$loginAuthServices->validatePassword((string)$data['pwd']);
}
$this->validate($data, \app\validate\admin\setting\SystemAdminValidate::class, 'update');
if ($this->services->save((int)$id, $data)) {
return $this->success('修改成功');
} else {
return $this->fail('修改失败');
}
}
/**
* 删除管理员
* @param $id
* @return mixed
*/
public function delete($id)
{
if (!$id) return $this->fail('删除失败,缺少参数');
if ($this->services->update((int)$id, ['is_del' => 1, 'status' => 0]))
return $this->success('删除成功!');
else
return $this->fail('删除失败');
}
/**
* 修改状态
* @param $id
* @param $status
* @return mixed
*/
public function set_status($id, $status)
{
$this->services->update((int)$id, ['status' => $status]);
return $this->success($status == 0 ? '关闭成功' : '开启成功');
}
/**
* 获取当前登陆管理员的信息
* @return mixed
*/
public function info()
{
return $this->success($this->adminInfo);
}
/**
* 修改当前登陆admin信息
* @return mixed
*/
public function update_admin()
{
$data = $this->request->postMore([
['real_name', ''],
['head_pic', ''],
['pwd', ''],
['new_pwd', ''],
['conf_pwd', ''],
['phone', ''],
['code', '']
]);
if ($this->services->updateAdmin($this->adminId, $data))
return $this->success('修改成功');
else
return $this->fail('修改失败');
}
/**
* 退出登陆
* @return mixed
*/
public function logout()
{
$key = trim(ltrim($this->request->header(Config::get('cookie.token_name')), 'Bearer'));
CacheService::redisHandler()->delete(md5($key));
return $this->success();
}
}

View File

@@ -0,0 +1,238 @@
<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
namespace app\controller\admin\v1\system\attachment;
use app\controller\admin\AuthController;
use app\services\other\CacheServices;
use app\services\system\admin\SystemAdminServices;
use app\services\system\attachment\SystemAttachmentServices;
use think\annotation\Inject;
/**
* 图片管理类
* Class SystemAttachment
* @package app\controller\admin\v1\file
*/
class SystemAttachment extends AuthController
{
/**
* @var SystemAttachmentServices
*/
#[Inject]
protected SystemAttachmentServices $service;
/**
* 显示列表
* @return mixed
*/
public function index()
{
$where = $this->request->getMore([
['pid', 0],
['file_type', 1],
['name', '', '', 'real_name']
]);
$where['type'] = 1;
if($this->supplierId){
$where['type'] = 4;
$where['relation_id'] = $this->supplierId;
}
return $this->success($this->service->getImageList($where));
}
/**
* 删除指定资源
*
* @param string $ids
* @return \think\Response
*/
public function delete()
{
[$ids] = $this->request->postMore([
['ids', '']
], true);
$this->service->del($ids);
return $this->success('删除成功');
}
/**
* 图片上传
* @param int $upload_type
* @param int $type
* @return mixed
*/
public function upload($upload_type = 0, $type = 0)
{
[$pid, $file] = $this->request->postMore([
['pid', 0],
['file', 'file'],
], true);
if($this->supplierId){
$res = $this->service->storeUpload((int)$pid, $file, (int)$this->supplierId, 4, $upload_type);
}else{
$res = $this->service->upload((int)$pid, $file, (int)$upload_type, (int)$type);
}
return $this->success('上传成功', $res);
}
/**
* 移动图片
* @return mixed
*/
public function moveImageCate()
{
$data = $this->request->postMore([
['pid', 0],
['images', '']
]);
$this->service->move($data);
return $this->success('移动成功');
}
/**
* 修改文件名
* @param $id
* @return mixed
*/
public function update($id)
{
$realName = $this->request->post('real_name', '');
if (!$realName) {
return $this->fail('文件名称不能为空');
}
$this->service->update($id, ['real_name' => $realName]);
return $this->success('修改成功');
}
/**
* 获取上传类型
* @return mixed
*/
public function uploadType()
{
$data['upload_type'] = (string)sys_config('upload_type', 1);
return app('json')->success($data);
}
/**
* 视频分片上传
* @return mixed
*/
public function videoUpload()
{
$data = $this->request->postMore([
['chunkNumber', 0],//第几分片
['currentChunkSize', 0],//分片大小
['chunkSize', 0],//总大小
['totalChunks', 0],//分片总数
['file', 'file'],//文件
['md5', ''],//MD5
['filename', ''],//文件名称
['pid', 0],//分类ID
]);
$fileHandle = $this->request->file($data['file']);
if (!$fileHandle) return $this->fail('上传信息为空');
$res = $this->service->videoUpload($data, $fileHandle);
return app('json')->success($res);
}
/**
* 保存云端视频记录
* @return mixed
*/
public function saveVideoAttachment()
{
$data = $this->request->postMore([
['path', ''],//视频地址
['cover_image', ''],//封面地址
['pid', 0],//分类ID
['upload_type', 1],//上传类型
]);
$res = $this->service->saveOssVideoAttachment($data, 1, 0, (int)$data['upload_type']);
return app('json')->success($res);
}
/**
* 获取扫码上传页面链接以及参数
* @return \think\Response
*/
public function scanUploadQrcode(CacheServices $services)
{
[$pid] = $this->request->getMore([
['pid', 0]
], true);
$uploadToken = md5(time());
$upload_file_size_max = config('upload.filesize');//文件上传大小kb
$services->setDbCache('scan_upload', $uploadToken, 68400);
$url = sys_config('site_url') . '/app/upload?pid=' . $pid . '&cache=scan_upload&type=1&relation_id=0&upload_file_size_max=' . $upload_file_size_max . '&token=' . $uploadToken;
return app('json')->success(['url' => $url]);
}
/**删除二维码
* @return \think\Response
*/
public function removeUploadQrcode(CacheServices $services)
{
$services->delectDbCache('scan_upload');
return app('json')->success();
}
/**获取扫码上传的图片数据
* @param $scan_token
* @return \think\Response
*/
public function scanUploadImage($scan_token)
{
return app('json')->success($this->service->scanUploadImage($scan_token));
}
/**网络图片上传
* @return \think\Response
*/
public function onlineUpload()
{
$data = $this->request->postMore([
['pid', 0],
['images', []]
]);
$this->service->onlineUpload($data);
return app('json')->success('上传完成');
}
/**获取上传信息
* @return \think\Response
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function getAdminsData()
{
/** @var SystemAdminServices $adminServices */
$adminServices = app()->make(SystemAdminServices::class);
$data['is_way'] = $adminServices->value(['id' => $this->adminId], 'is_way');
$data['upload_file_size_max'] = config('upload.filesize');//文件上传大小kb
return app('json')->success($data);
}
/**保存上传信息
* @param int $is_way
* @return \think\Response
*/
public function setAdminsData(int $is_way = 0)
{
/** @var SystemAdminServices $adminServices */
$adminServices = app()->make(SystemAdminServices::class);
if (!in_array($is_way, [0, 1, 2])) return app('json')->fail('参数有误!');
$res = $adminServices->update($this->adminId, ['is_way' => $is_way]);
if ($res) return app('json')->success('ok');
else return app('json')->fail('保存失败!');
}
}

View File

@@ -0,0 +1,155 @@
<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
namespace app\controller\admin\v1\system\attachment;
use app\controller\admin\AuthController;
use app\services\system\attachment\SystemAttachmentCategoryServices;
use think\annotation\Inject;
use think\facade\App;
/**
* 图片分类管理类
* Class SystemAttachmentCategory
* @package app\controller\admin\v1\file
*/
class SystemAttachmentCategory extends AuthController
{
/**
* @var SystemAttachmentCategoryServices
*/
#[Inject]
protected SystemAttachmentCategoryServices $service;
/**
* 显示资源列表
*
* @return \think\Response
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function index()
{
$where = $this->request->getMore([
['name', ''],
['pid', 0],
['file_type', 1]
]);
$where['type'] = 1;
if ($this->supplierId) {
$where['type'] = 4;
$where['relation_id'] = $this->supplierId;
}
if ($where['name'] != '') $where['pid'] = '';
return $this->success($this->service->getAll($where));
}
/**
* 新增表单
* @return mixed
* @throws \FormBuilder\Exception\FormBuilderException
*/
public function create($id)
{
[$file_type] = $this->request->postMore([
['file_type', 1]
], true);
$type = 1;
$relation_id = 0;
if ($this->supplierId) {
$type = 4;
$relation_id = $this->supplierId;
}
return $this->success($this->service->createForm($id, $type, $relation_id, $file_type));
}
/**
* 保存新增
* @return mixed
*/
public function save()
{
$data = $this->request->postMore([
['pid', 0],
['name', ''],
['file_type', 1]
]);
if (!$data['name']) {
return $this->fail('请输入分类名称');
}
$data['type'] = 1;
if ($this->supplierId) {
$data['type'] = 4;
$data['relation_id'] = $this->supplierId;
}
$this->service->save($data);
return $this->success('添加成功');
}
/**
* 编辑表单
* @param $id
* @return mixed
* @throws \FormBuilder\Exception\FormBuilderException
*/
public function edit($id)
{
[$file_type] = $this->request->postMore([
['file_type', 1]
], true);
$type = 1;
$relation_id = 0;
if ($this->supplierId) {
$type = 4;
$relation_id = $this->supplierId;
}
return $this->success($this->service->editForm($id, $type, $relation_id, $file_type));
}
/**
* 保存更新的资源
*
* @param \think\Request $request
* @param int $id
* @return \think\Response
*/
public function update($id)
{
$data = $this->request->postMore([
['pid', 0],
['name', ''],
['file_type', 1]
]);
if (!$data['name']) {
return $this->fail('请输入分类名称');
}
$info = $this->service->get($id);
$count = $this->service->count(['pid' => $id]);
if ($count && $info['pid'] != $data['pid']) return $this->fail('该分类有下级分类,无法修改上级');
$this->service->update($id, $data);
return $this->success('分类编辑成功!');
}
/**
* 删除指定资源
*
* @param int $id
* @return \think\Response
*/
public function delete($id)
{
$this->service->del($id);
return $this->success('删除成功!');
}
}

View File

@@ -0,0 +1,496 @@
<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
namespace app\controller\admin\v1\system\config;
use app\controller\admin\AuthController;
use app\Request;
use app\services\product\product\StoreProductServices;
use app\services\store\SystemStoreServices;
use app\services\system\config\SystemConfigServices;
use app\services\system\config\SystemConfigTabServices;
use crmeb\services\CacheService;
use think\annotation\Inject;
use think\facade\Cache;
/**
* 系统配置
* Class SystemConfig
* @package app\controller\admin\v1\setting
*/
class SystemConfig extends AuthController
{
/**
* @var SystemConfigServices
*/
#[Inject]
protected SystemConfigServices $services;
/**
* 显示资源列表
*
* @return \think\Response
*/
public function index()
{
$where = $this->request->getMore([
['tab_id', 0],
['status', -1]
]);
if (!$where['tab_id']) {
return $this->fail('参数错误');
}
if ($where['status'] == -1) {
unset($where['status']);
}
$where['is_store'] = 0;
return $this->success($this->services->getConfigList($where));
}
/**
* 显示创建资源表单页.
* @param $type
* @return \think\Response
*/
public function create()
{
[$type, $tabId] = $this->request->getMore([
[['type', 'd'], ''],
[['tab_id', 'd'], 1]
], true);
return $this->success($this->services->createFormRule($type, $tabId));
}
/**
* 保存新建的资源
*
* @return \think\Response
*/
public function save()
{
$data = $this->request->postMore([
['menu_name', ''],
['type', ''],
['input_type', ''],
['config_tab_id', []],
['parameter', ''],
['upload_type', 1],
['required', ''],
['width', 0],
['high', 0],
['value', ''],
['info', ''],
['desc', ''],
['sort', 0],
['status', 0],
['is_store', 0],
]);
if ($data['config_tab_id']) $data['config_tab_id'] = end($data['config_tab_id']);
if (!$data['info']) return $this->fail('请输入配置名称');
if (!$data['menu_name']) return $this->fail('请输入字段名称');
if (!$data['desc']) return $this->fail('请输入配置简介');
if ($data['sort'] < 0) {
$data['sort'] = 0;
}
if ($data['type'] == 'text') {
if (!$data['width']) return $this->fail('请输入文本框的宽度');
if ($data['width'] <= 0) return $this->fail('请输入正确的文本框的宽度');
}
if ($data['type'] == 'textarea') {
if (!$data['width']) return $this->fail('请输入多行文本框的宽度');
if (!$data['high']) return $this->fail('请输入多行文本框的高度');
if ($data['width'] < 0) return $this->fail('请输入正确的多行文本框的宽度');
if ($data['high'] < 0) return $this->fail('请输入正确的多行文本框的宽度');
}
if ($data['type'] == 'radio' || $data['type'] == 'checkbox') {
if (!$data['parameter']) return $this->fail('请输入配置参数');
$this->services->valiDateRadioAndCheckbox($data);
}
$data['value'] = json_encode($data['value']);
$config = $this->services->getOne(['menu_name' => $data['menu_name']]);
if ($config) {
$this->services->update($config['id'], $data, 'id');
} else {
$this->services->save($data);
}
event('config.create', [$data]);
return $this->success('添加配置成功!');
}
/**
* 显示指定的资源
*
* @param int $id
* @return \think\Response
*/
public function read($id)
{
if (!$id) {
return $this->fail('参数错误,请重新打开');
}
$info = $this->services->getReadList((int)$id);
return $this->success(compact('info'));
}
/**
* 显示编辑资源表单页.
*
* @param int $id
* @return \think\Response
*/
public function edit($id)
{
return $this->success($this->services->editConfigForm((int)$id));
}
/**
* 保存更新的资源
*
* @param int $id
* @return \think\Response
*/
public function update($id)
{
$type = request()->post('type');
if ($type == 'text' || $type == 'textarea' || $type == 'radio' || ($type == 'upload' && (request()->post('upload_type') == 1 || request()->post('upload_type') == 3))) {
$value = request()->post('value');
} else {
$value = request()->post('value/a');
}
if (!$value) $value = request()->post(request()->post('menu_name'));
$data = $this->request->postMore([
['type', ''],
['input_type', ''],
['config_tab_id', []],
['parameter', ''],
['upload_type', 1],
['required', ''],
['width', 0],
['high', 0],
['value', ''],
['info', ''],
['desc', ''],
['sort', 0],
['status', 0],
['is_store', 0],
]);
$data['config_tab_id'] = end($data['config_tab_id']);
if (!$this->services->get($id)) {
return $this->fail('编辑的记录不存在!');
}
$data['value'] = json_encode($data['value']);
$this->services->update($id, $data);
\crmeb\services\SystemConfigService::clear();
return $this->success('修改成功!');
}
/**
* 删除指定资源
*
* @param int $id
* @return \think\Response
*/
public function delete($id)
{
if (!$this->services->delete($id))
return $this->fail('删除失败,请稍候再试!');
else {
event('config.delete', [$id]);
return $this->success('删除成功!');
}
}
/**
* 修改状态
* @param $id
* @param $status
* @return mixed
*/
public function set_status($id, $status)
{
if ($status == '' || $id == 0) {
return $this->fail('参数错误');
}
$this->services->update($id, ['status' => $status]);
event('config.status', [$id, $status]);
return $this->success($status == 0 ? '隐藏成功' : '显示成功');
}
/**
* 基础配置
* */
public function edit_basics(Request $request)
{
$tabId = $this->request->param('tab_id', 1);
if (!$tabId) {
return $this->fail('参数错误');
}
$url = $request->baseUrl();
return $this->success($this->services->getConfigForm($url, $tabId));
}
/**
* @param string $type
* @return mixed
*/
public function getNewFormBuild(string $type)
{
return $this->success($this->services->getNewFormBuildRule($type));
}
/**
* 获取用户配置
* @return mixed
*/
public function getUserConfig($type)
{
return $this->success($this->services->getUserConfig($type));
}
/**
* 保存用户配置
* @param $type
* @return mixed
*/
public function saveUserConfig($type)
{
$post = $this->request->post();
$this->validate($post, \app\validate\admin\setting\SystemConfigValidate::class);
$this->services->saveUserConfig($type, $post);
return $this->success('保存成功');
}
/**
* 获取缩略图配置
* @return mixed
*/
public function getImageConfig()
{
return $this->success($this->services->getImageConfig());
}
/**
* 保存数据 true
* */
public function save_basics(Request $request)
{
$isStore = $this->request->get('is_store', false);
$post = $this->request->post();
if ($isStore && isset($post['store_self_mention'])) {//门店配置
$baseData = [
'name' => '',
'phone' => '',
'address' => '',
'detailed_address' => '',
'day_time' => '',
'latlng' => '',
];
foreach ($baseData as $key => $value) {
unset($post[$key]);
}
}
foreach ($post as $k => $v) {
if (is_array($v)) {
$res = $this->services->getUploadTypeList($k);
foreach ($res as $kk => $vv) {
if ($kk == 'upload') {
if ($vv == 1 || $vv == 3) {
$post[$k] = $v[0];
}
}
}
}
}
if (!empty($post['links_list'])) {
foreach ($post['links_list'] as $item) {
foreach ($item as $v => $k) {
if ('' === $item[$v]) {
return $this->fail('友情链接内容不能为空');
}
}
}
}
// if (!empty($post['filing_list'])) {
// foreach ($post['filing_list'] as $item) {
// foreach ($item as $v => $k) {
// if ('' === $item[$v]) {
// return $this->fail('PC底部自定义展示内容不能为空');
// }
// }
// }
// }
$this->validate($post, \app\validate\admin\setting\SystemConfigValidate::class);
if (isset($post['upload_type'])) {
$this->services->checkThumbParam($post);
}
if (isset($post['store_brokerage_binding_status'])) {
$this->services->checkBrokerageBinding($post);
}
if (isset($post['store_brokerage_ratio']) && isset($post['store_brokerage_two'])) {
$num = $post['store_brokerage_ratio'] + $post['store_brokerage_two'];
if ($num > 100) {
return $this->fail('一二级返佣比例不能大于100%');
}
}
if (isset($post['spread_banner'])) {
$num = count($post['spread_banner']);
if ($num > 5) {
return $this->fail('分销海报不能多于5张');
}
}
if (isset($post['user_extract_min_price'])) {
if (!preg_match('/[0-9]$/', $post['user_extract_min_price'])) {
return $this->fail('提现最低金额只能为数字!');
}
}
if (isset($post['user_extract_max_price'])) {
if (!preg_match('/[0-9]$/', $post['user_extract_max_price'])) {
return $this->fail('提现最高金额只能为数字!');
}
}
if (isset($post['store_extract_max_price']) && isset($post['store_extract_min_price'])) {
if ($post['store_extract_max_price'] < $post['store_extract_min_price']) {
return $this->fail('门店提现最低金额不能大于最高金额');
}
}
//小程序支付
if (isset($post['pay_routine_open']) && $post['pay_routine_open']) {
if (empty($post['pay_routine_mchid'])) {
return $this->fail('小程序商户号不能为空');
}
}
if (isset($post['routine_auth_type'])) {
if (empty($post['routine_auth_type']) || count($post['routine_auth_type']) == 0) {
return app('json')->fail('手机号获取方式至少选择一个');
}
}
//全场包邮开关
// if (isset($post['whole_free_shipping'])) {
// $wholeFreeShipping = (int)$post['whole_free_shipping'];
// if (!$wholeFreeShipping) {
// $post['store_free_postage'] = 0;
// }
// unset($post['whole_free_shipping']);
// }
if (isset($post['ico_path'])) {
$from = public_path() . $post['ico_path'];
$toHome = public_path('home') . 'favicon.ico';
$toAdmin = public_path('admin') . 'favicon.ico';
$toSupplier = public_path('supplier') . 'favicon.ico';
$toPublic = public_path() . 'favicon.ico';
@copy($from, $toHome);
@copy($from, $toAdmin);
@copy($from, $toSupplier);
@copy($from, $toPublic);
}
//分销提现
if (isset($post['user_extract_alipay_status'])) {
if (!$post['user_extract_bank_status'] && !$post['user_extract_alipay_status'] && !$post['user_extract_wechat_status'] && !$post['user_extract_balance_status']) {
return app('json')->fail('分销提现方式至少请开启一个');
}
}
//社区设置
if (isset($post['community_exp']) && $post['community_exp'] == 1 && $post['community_exp_restrict'] && $post['community_exp_num'] > $post['community_exp_restrict']) {
return app('json')->fail('社区单次经验值不能大于每天经验值上限');
}
if (isset($post['community_integral']) && $post['community_integral'] == 1 && $post['community_integral_restrict'] && $post['community_integral_num'] > $post['community_integral_restrict']) {
return app('json')->fail('社区单次积分值不能大于每天积分值上限');
}
//系统参数过滤
if (isset($post['param_filter_data'])) {
$post['param_filter_data'] = base64_encode($post['param_filter_data']);
}
// 余额功能启用状态跟随余额支付开关
if (isset($post['yue_pay_status'])) {
$post['balance_func_status'] = $post['yue_pay_status'];
}
$is_store_stock = isset($post['store_stock']) && $post['store_stock'] != sys_config('store_stock');
foreach ($post as $k => $v) {
$config_one = $this->services->getOne(['menu_name' => $k]);
if ($config_one) {
$config_one['value'] = $v;
$this->services->valiDateValue($config_one);
$this->services->update($k, ['value' => json_encode($v)], 'menu_name');
}
}
//记录缓存时间
if (!empty($post['cache_config'])) {
Cache::store('redis')->set(CacheService::CACHE_EXPIRE_NAME, $post['cache_config']);
}
//修改警戒库存
if ($is_store_stock) {
/** @var StoreProductServices $storeProductServices */
$storeProductServices = app()->make(StoreProductServices::class);
$storeProductServices->productStockTips();
}
\crmeb\services\SystemConfigService::clear();
return $this->success('修改成功');
}
/**
* 获取系统设置头部分类
* @param SystemConfigTabServices $services
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function header_basics(SystemConfigTabServices $services)
{
[$type, $pid] = $this->request->getMore([
[['type', 'd'], 0],
[['pid', 'd'], 0]
], true);
if ($type == 3) {//其它分类
$config_tab = [];
} else {
$config_tab = $services->getConfigTab($pid);
}
return $this->success(compact('config_tab'));
}
/**
* 获取单个配置的值
* @param $name
* @return mixed
*/
public function get_system($name)
{
$value = sys_config($name);
return $this->success(compact('value'));
}
/**
* @return mixed
*/
public function getVersion()
{
$version = get_crmeb_version();
return $this->success([
'version' => $version,
'label' => strripos($version, 'min') === false ? 3 : 2
]);
}
}

View File

@@ -0,0 +1,161 @@
<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
namespace app\controller\admin\v1\system\config;
use app\controller\admin\AuthController;
use app\services\system\config\SystemConfigServices;
use app\services\system\config\SystemConfigTabServices;
use think\annotation\Inject;
/**
* 配置分类
* Class SystemConfigTab
* @package app\controller\admin\v1\setting
*/
class SystemConfigTab extends AuthController
{
/**
* @var SystemConfigTabServices
*/
#[Inject]
protected SystemConfigTabServices $services;
/**
* 显示资源列表
*
* @return \think\Response
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function index()
{
$where = $this->request->getMore([
['status', ''],
['title', ''],
['is_store', '']
]);
return $this->success($this->services->getConfgTabList($where));
}
/**
* 显示创建资源表单页.
*
* @return \think\Response
*/
public function create()
{
return $this->success($this->services->createForm());
}
/**
* 保存新建的资源
*
* @return \think\Response
*/
public function save()
{
$data = $this->request->postMore([
'eng_title',
'status',
'title',
'icon',
['type', 0],
['sort', 0],
['pid', []],
['is_store', 0],
]);
$data['pid'] = end($data['pid']);
if (!$data['title']) return $this->fail('请输入按钮名称');
$this->services->save($data);
return $this->success('添加配置分类成功!');
}
/**
* 显示指定的资源
*
* @param int $id
* @return \think\Response
*/
public function read($id)
{
//
}
/**
* 显示编辑资源表单页.
*
* @param int $id
* @return \think\Response
*/
public function edit($id)
{
return $this->success($this->services->updateForm((int)$id));
}
/**
* 保存更新的资源
*
* @param int $id
* @return \think\Response
*/
public function update($id)
{
$data = $this->request->postMore([
'title',
'status',
'eng_title',
'icon',
['type', 0],
['sort', 0],
['pid', []],
['is_store', 0],
]);
$data['pid'] = end($data['pid']);
if (!$data['title']) return $this->fail('请输入分类昵称');
if (!$data['eng_title']) return $this->fail('请输入分类字段');
$this->services->update($id, $data);
return $this->success('修改成功!');
}
/**
* 删除指定资源
*
* @param int $id
* @return \think\Response
*/
public function delete(SystemConfigServices $services, $id)
{
if ($services->count(['tab_id' => $id])) {
return $this->fail('存在下级配置,无法删除!');
}
if (!$this->services->delete($id))
return $this->fail('删除失败,请稍候再试!');
else
return $this->success('删除成功!');
}
/**
* 修改状态
* @param $id
* @param $status
* @return mixed
*/
public function set_status($id, $status)
{
if ($status == '' || $id == 0) {
return $this->fail('参数错误');
}
$this->services->update($id, ['status' => $status]);
return $this->success($status == 0 ? '隐藏成功' : '显示成功');
}
}

View File

@@ -0,0 +1,210 @@
<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
namespace app\controller\admin\v1\system\config;
use app\services\system\config\SystemGroupDataServices;
use think\annotation\Inject;
use app\controller\admin\AuthController;
use app\services\system\config\SystemGroupServices;
/**
* 组合数据
* Class SystemGroup
* @package app\controller\admin\v1\setting
*/
class SystemGroup extends AuthController
{
/**
* @var SystemGroupServices
*/
#[Inject]
protected SystemGroupServices $services;
/**
* 显示资源列表
*
* @return \think\Response
*/
public function index()
{
$where = $this->request->getMore([
['title', '']
]);
return $this->success($this->services->getGroupList($where));
}
/**
* 显示创建资源表单页.
*
* @return \think\Response
*/
public function create()
{
//
}
/**
* 保存新建的资源
*
* @return \think\Response
*/
public function save()
{
$params = $this->request->postMore([
['name', ''],
['config_name', ''],
[['cate_id', 'd'], 0],
['info', ''],
['typelist', []],
]);
//数据组名称判断
if (!$params['name']) {
return $this->fail('请输入数据组名称!');
}
if (!$params['config_name']) {
return $this->fail('请输入配置名称!');
}
$data["name"] = $params['name'];
$data["config_name"] = $params['config_name'];
$data["info"] = $params['info'];
$data["cate_id"] = $params['cate_id'];
//字段信息判断
if (!count($params['typelist']))
return $this->fail('字段至少存在一个!');
else {
$validate = ["name", "type", "title", "description"];
foreach ($params["typelist"] as $key => $value) {
foreach ($value as $name => $field) {
if (empty($field["value"]) && in_array($name, $validate))
return $this->fail("字段" . ($key + 1) . ":" . $field["placeholder"] . "不能为空!");
else
$data["fields"][$key][$name] = $field["value"];
}
}
}
$data["fields"] = json_encode($data["fields"]);
$this->services->save($data);
\crmeb\services\GroupDataService::clear();
return $this->success('添加数据组成功!');
}
/**
* 显示指定的资源
*
* @param int $id
* @return \think\Response
*/
public function read($id)
{
$info = $this->services->get($id);
$fields = json_decode($info['fields'], true);
$type_list = [];
foreach ($fields as $key => $v) {
$type_list[$key]['name']['value'] = $v['name'];
$type_list[$key]['title']['value'] = $v['title'];
$type_list[$key]['type']['value'] = $v['type'];
$type_list[$key]['param']['value'] = $v['param'];
}
$info['typelist'] = $type_list;
unset($info['fields']);
return $this->success(compact('info'));
}
/**
* 显示编辑资源表单页.
*
* @param int $id
* @return \think\Response
*/
public function edit($id)
{
//
}
/**
* 保存更新的资源
*
* @param int $id
* @return \think\Response
*/
public function update($id)
{
$params = $this->request->postMore([
['name', ''],
['config_name', ''],
[['cate_id', 'd'], 0],
['info', ''],
['typelist', []],
]);
//数据组名称判断
if (!$params['name']) return $this->fail('请输入数据组名称!');
if (!$params['config_name']) return $this->fail('请输入配置名称!');
//判断ID是否存在,存在就是编辑,不存在就是添加
if (!$id) {
if ($this->services->count(['config_name' => $params['config_name']])) {
return $this->fail('数据关键字已存在!');
}
}
$data["name"] = $params['name'];
$data["config_name"] = $params['config_name'];
$data["info"] = $params['info'];
$data["cate_id"] = $params['cate_id'];
//字段信息判断
if (!count($params['typelist']))
return $this->fail('字段至少存在一个!');
else {
$validate = ["name", "type", "title", "description"];
foreach ($params["typelist"] as $key => $value) {
foreach ($value as $name => $field) {
if (empty($field["value"]) && in_array($name, $validate))
return $this->fail("字段" . ($key + 1) . ":" . $field["placeholder"] . "不能为空!");
else
$data["fields"][$key][$name] = $field["value"];
}
}
}
$data["fields"] = json_encode($data["fields"]);
$this->services->update($id, $data);
\crmeb\services\GroupDataService::clear();
return $this->success('编辑数据组成功!');
}
/**
* 删除指定资源
*
* @param int $id
* @return \think\Response
*/
public function delete($id, SystemGroupDataServices $services)
{
if (!$this->services->delete($id))
return $this->fail('删除失败,请稍候再试!');
else {
$services->delete($id, 'gid');
return $this->success('删除成功!');
}
}
/**
* 获取组合数据
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function getGroup()
{
return $this->success($this->services->getGroupList(['cate_id' => 1], ['id', 'name', 'config_name'])['list']);
}
}

View File

@@ -0,0 +1,436 @@
<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
namespace app\controller\admin\v1\system\config;
use app\services\activity\seckill\StoreSeckillServices;
use crmeb\exceptions\AdminException;
use app\services\other\CacheServices;
use think\annotation\Inject;
use think\exception\ValidateException;
use app\controller\admin\AuthController;
use app\services\system\config\SystemGroupDataServices;
use app\services\system\config\SystemGroupServices;
/**
* 数据管理
* Class SystemGroupData
* @package app\controller\admin\v1\setting
*/
class SystemGroupData extends AuthController
{
/**
* @var SystemGroupDataServices
*/
#[Inject]
protected SystemGroupDataServices $services;
/**
* 获取数据列表头
* @return mixed
*/
public function header(SystemGroupServices $services)
{
[$gid, $config_name] = $this->request->getMore([
['gid', 0],
['config_name', '']
], true);
if (!$gid && !$config_name) return $this->fail('参数错误');
if (!$gid) {
$gid = $services->value(['config_name' => $config_name], 'id');
}
return $this->success($services->getGroupDataTabHeader($gid));
}
/**
* 显示资源列表
*
* @param SystemGroupServices $group
* @return \think\Response
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function index(SystemGroupServices $group)
{
$where = $this->request->getMore([
['gid', 0],
['status', ''],
['config_name', '']
]);
if (!$where['gid'] && !$where['config_name']) return $this->fail('参数错误');
if (!$where['gid']) {
$where['gid'] = $group->value(['config_name' => $where['config_name']], 'id');
}
unset($where['config_name']);
return $this->success($this->services->getGroupDataList($where));
}
/**
* 显示创建资源表单页.
*
* @return \think\Response
* @throws \FormBuilder\Exception\FormBuilderException
*/
public function create()
{
$gid = $this->request->param('gid/d');
if ($this->services->isGroupGidSave($gid, 4, 'index_categy_images')) {
return $this->fail('不能大于四个!');
}
if ($this->services->isGroupGidSave($gid, 7, 'sign_day_num')) {
return $this->fail('签到天数配置不能大于7天');
}
return $this->success($this->services->createForm($gid));
}
/**
* 保存新建的资源
*
* @param SystemGroupServices $services
* @return \think\Response
*/
public function save(SystemGroupServices $services)
{
$params = request()->post();
$gid = (int)$params['gid'];
$group = $services->getOne(['id' => $gid], 'id,config_name,fields');
if ($group && $group['config_name'] == 'order_details_images') {
$groupDatas = $this->services->getColumn(['gid' => $gid], 'value', 'id');
foreach ($groupDatas as $groupData) {
$groupData = json_decode($groupData, true);
if (isset($groupData['order_status']['value']) && $groupData['order_status']['value'] == $params['order_status']) {
return $this->fail('已存在请不要重复添加');
}
}
}
$this->checkSeckillTime($services, $gid, $params);
$this->checkSign($services, $gid, $params);
$this->checkRecharge($services, $gid, $params);
$fields = json_decode($group['fields'], true) ?? [];
$value = [];
foreach ($params as $key => $param) {
foreach ($fields as $index => $field) {
if ($key == $field["title"]) {
if ($key != 'give_money' && $param == "")
return $this->fail($field["name"] . "不能为空!");
else {
$value[$key]["type"] = $field["type"];
$value[$key]["value"] = $key == 'give_money' && $param == "" ? 0 : $param;
}
}
}
}
$data = [
"gid" => $params['gid'],
"add_time" => time(),
"value" => json_encode($value),
"sort" => $params["sort"] ?: 0,
"status" => $params["status"]
];
$res = $this->services->save($data);
$data['id'] = $res->id;
$this->services->cacheUpdate($data);
\crmeb\services\GroupDataService::clear();
return $this->success('添加数据成功!');
}
/**
* 显示指定的资源
*
* @param int $id
* @return \think\Response
*/
public function read($id)
{
//
}
/**
* 显示编辑资源表单页.
*
* @param int $id
* @return \think\Response
*/
public function edit($id)
{
$gid = $this->request->param('gid/d');
if (!$gid) {
return $this->fail('缺少参数');
}
return $this->success($this->services->updateForm((int)$gid, (int)$id));
}
public function saveAll()
{
$params = request()->post();
if (!isset($params['config_name']) || !isset($params['data'])) {
return $this->fail('缺少参数');
}
$this->services->saveAllData($params['data'], $params['config_name']);
return $this->success('添加数据成功!');
}
/**
* 保存更新的资源
*
* @param \think\Request $request
* @param int $id
* @return \think\Response
*/
public function update(SystemGroupServices $services, $id)
{
$groupData = $this->services->get($id);
$fields = $services->getValueFields((int)$groupData["gid"]);
$params = request()->post();
$this->checkSeckillTime($services, $groupData["gid"], $params, $id);
$this->checkSign($services, $groupData["gid"], $params);
$this->checkRecharge($services, $groupData["gid"], $params);
foreach ($params as $key => $param) {
foreach ($fields as $index => $field) {
if ($key == $field["title"]) {
if ($key != 'give_money' && $param == '')
return $this->fail($field["name"] . "不能为空!");
else {
$value[$key]["type"] = $field["type"];
$value[$key]["value"] = $key == 'give_money' && $param == "" ? 0 : $param;
}
}
}
}
$data = [
"value" => json_encode($value),
"sort" => $params["sort"],
"status" => $params["status"]
];
$this->services->update($id, $data);
$this->services->cacheSaveValue($id, $data);
\crmeb\services\GroupDataService::clear();
return $this->success('修改成功!');
}
/**
* 删除指定资源
* @param SystemGroupServices $services
* @param StoreSeckillServices $seckillServices
* @param $id
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function delete(SystemGroupServices $services, StoreSeckillServices $seckillServices, $id)
{
$groupData = $this->services->get((int)$id);
if ($groupData) {
$gid = $groupData['gid'];
$group = $services->getOne(['id' => $gid], 'id,config_name,fields');
if ($group['config_name'] == 'routine_seckill_time') {//验证时间段下是否有商品
if ($seckillServices->getTimeCount((int)$id)) {
return $this->fail('有正在进行秒杀商品不能删除!');
}
}
if (!$this->services->delete($id))
return $this->fail('删除失败,请稍候再试!');
}
\crmeb\services\GroupDataService::clear();
$this->services->cacheDelById($id);
return $this->success('删除成功!');
}
/**
* 修改状态
* @param $id
* @param $status
* @return mixed
*/
public function set_status($id, $status)
{
if ($status == '' || $id == 0) return $this->fail('参数错误');
$this->services->update($id, ['status' => $status]);
if ($status) {
$this->services->cacheSaveValue($id, 'status', $status);
} else {
$this->services->cacheDelById($id);
}
\crmeb\services\GroupDataService::clear();
return $this->success($status == 0 ? '隐藏成功' : '显示成功');
}
/**
* 检查秒杀时间段
* @param SystemGroupServices $services
* @param $gid
* @param $params
* @param int $id
* @return mixed
*/
public function checkSeckillTime(SystemGroupServices $services, $gid, $params, $id = 0)
{
$name = $services->value(['id' => $gid], 'config_name');
if ($name == 'routine_seckill_time') {
if ($params['time'] == '') {
throw new AdminException('请输入开始时间');
}
if (!$params['continued']) {
throw new AdminException('请输入持续时间');
}
if (!preg_match('/^(\d|1\d|2[0-3])$/', $params['time'])) {
throw new AdminException('请输入0-23点之前的整点数');
}
if (!preg_match('/^([1-9]|1\d|2[0-4])$/', $params['continued'])) {
throw new AdminException('请输入1-24点之前的持续时间');
}
if (($params['time'] + $params['continued']) > 24) throw new AdminException('开始时间+持续时间不能大于24小时');
$list = $this->services->getColumn(['gid' => $gid], 'value', 'id');
if ($id) unset($list[$id]);
$times = $time = [];
foreach ($list as $item) {
$info = json_decode($item, true);
for ($i = 0; $i < $info['continued']['value']; $i++) {
$times[] = $info['time']['value'] + $i;
}
}
for ($i = 0; $i < $params['continued']; $i++) {
$time[] = $params['time'] + $i;
}
foreach ($time as $v) {
if (in_array($v, $times)) throw new AdminException('时段已占用');
}
}
}
/**
* 检查签到配置
* @param SystemGroupServices $services
* @param $gid
* @param $params
* @param int $id
* @return mixed
*/
public function checkSign(SystemGroupServices $services, $gid, $params, $id = 0)
{
$name = $services->value(['id' => $gid], 'config_name');
if ($name == 'sign_day_num') {
if (!$params['sign_num']) {
throw new AdminException('请输入签到赠送积分');
}
if (!preg_match('/^\+?[1-9]\d*$/', $params['sign_num'])) {
throw new AdminException('请输入大于等于0的整数');
}
}
}
/**
* 检查充值金额配置
* @param SystemGroupServices $services
* @param $gid
* @param $params
* @param int $id
* @return mixed
*/
public function checkRecharge(SystemGroupServices $services, $gid, $params, $id = 0)
{
$name = $services->value(['id' => $gid], 'config_name');
if ($name == 'user_recharge_quota') {
if (!$params['price']) {
throw new AdminException('请输入售价');
}
if (!preg_match('/^[0-9]{0,8}+(.[0-9]{1,2})?$/', $params['price'])) {
throw new AdminException('售价限制最大10位浮点型且最多两位小数');
}
if ($params['give_money'] && !preg_match('/^[0-9]{0,8}+(.[0-9]{1,2})?$/', $params['give_money'])) {
throw new AdminException('赠送金额限制最大10位浮点型且最多两位小数');
}
if ($this->services->count(['gid' => $gid]) >= 20) {
throw new AdminException('充值优惠条数最多添加20个');
}
}
}
/**
* 获取客服页面广告内容
* @return mixed
*/
public function getKfAdv()
{
/** @var CacheServices $cache */
$cache = app()->make(CacheServices::class);
$content = $cache->getDbCache('kf_adv', '');
return $this->success(compact('content'));
}
/**
* 设置客服页面广告内容
* @return mixed
*/
public function setKfAdv()
{
$content = $this->request->post('content');
/** @var CacheServices $cache */
$cache = app()->make(CacheServices::class);
$cache->setDbCache('kf_adv', $content);
return $this->success('设置成功');
}
/**
* 获取用户协议内容
* @return mixed
*/
public function getUserAgreement($type)
{
/** @var CacheServices $cache */
$cache = app()->make(CacheServices::class);
$content = $cache->getDbCache($type, '');
return $this->success(compact('content'));
}
/**
* 设置用户协议内容
* @return mixed
*/
public function setUserAgreement($type)
{
$content = $this->request->post('content');
/** @var CacheServices $cache */
$cache = app()->make(CacheServices::class);
$cache->setDbCache($type, $content);
if ('privacy' === $type) {
$html = <<<HTML
<!doctype html>
<html class="x-admin-sm">
<head>
<meta charset="UTF-8">
<title>隐私协议</title>
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
</head>
<body class="index">
$content
</body>
</html>
HTML;
$file_path = public_path() . 'protocol.html';
if (!file_exists($file_path)) {
try {
touch(str_replace('\\', '/', $file_path));
} catch (\Throwable $e) {
throw new ValidateException('请手动在:'. public_path() . '创建空文件:protocol.html,注意检查文件权限');
}
}
file_put_contents(public_path() . 'protocol.html', $html);
}
return $this->success('设置成功');
}
}

View File

@@ -0,0 +1,255 @@
<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
namespace app\controller\admin\v1\system\config;
use app\controller\admin\AuthController;
use app\services\system\config\SystemConfigServices;
use app\services\system\config\SystemStorageServices;
use crmeb\services\UploadService;
use think\annotation\Inject;
/**
* Class SystemStorage
* @package app\adminapi\controller\v1\setting
*/
class SystemStorage extends AuthController
{
/**
* @var SystemStorageServices
*/
#[Inject]
protected SystemStorageServices $services;
/**
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function index()
{
return app('json')->success($this->services->getList(['type' => $this->request->get('type')]));
}
/**
* 获取创建数据表单
* @param $type
* @return mixed
* @throws \FormBuilder\Exception\FormBuilderException
*/
public function create($type)
{
if (!$type) {
return app('json')->fail('缺少参数');
}
return app('json')->success($this->services->getFormStorage((int)$type));
}
/**
* 获取配置表单
* @param $type
* @return mixed
* @throws \FormBuilder\Exception\FormBuilderException
*/
public function getConfigForm($type)
{
return app('json')->success($this->services->getFormStorageConfig((int)$type));
}
/**
* 获取配置类型
* @return mixed
*/
public function getConfig()
{
return app('json')->success(['type' => (int)sys_config('upload_type', 1)]);
}
/**
* @param SystemConfigServices $services
* @return mixed
*/
public function saveConfig(SystemConfigServices $services)
{
$type = (int)$this->request->post('type', 0);
$services->update('upload_type', ['value' => json_encode($type)], 'menu_name');
if (1 === $type) {
$this->services->transaction(function () {
$this->services->update(['status' => 1, 'is_delete' => 0], ['status' => 0]);
});
}
$data = $this->request->postMore([
['accessKey', ''],
['secretKey', ''],
['appid', ''],
['storageRegion', '']
]);
$this->services->saveConfig((int)$type, $data);
return app('json')->success('保存成功');
}
/**
* @param $type
* @return mixed
*/
public function synch($type)
{
try {
$this->services->synchronization((int)$type);
return app('json')->success('同步成功');
} catch (\Throwable $e) {
return app('json')->fail('同步失败,失败原因:' . $e->getMessage());
}
}
/**
* 保存类型
* @param $type
* @return mixed
*/
public function save($type)
{
$data = $this->request->postMore([
['accessKey', ''],
['secretKey', ''],
['appid', ''],
['name', ''],
['region', ''],
['acl', ''],
]);
$type = (int)$type;
if ($type === 4) {
if (!$data['appid'] && !sys_config('tengxun_appid')) {
return app('json')->fail('缺少APPID');
}
}
if (!$data['accessKey']) {
unset($data['accessKey'], $data['secretKey'], $data['appid']);
}
$this->services->saveStorage((int)$type, $data);
return app('json')->success('添加成功');
}
/**
* 修改状态
* @param $id
* @return mixed
*/
public function status($id)
{
if (!$id) {
return app('json')->fail('缺少参数');
}
$info = $this->services->get($id);
$info->status = 1;
if (!$info->domain) {
return app('json')->fail('请先设置空间域名');
}
//设置跨域规则
try {
$upload = UploadService::init($info->type);
$upload->setBucketCors($info->name, $info->region);
} catch (\Throwable $e) {
}
//修改状态
$this->services->transaction(function () use ($id, $info) {
$this->services->update(['type' => $info->type, 'status' => 1, 'is_delete' => 0], ['status' => 0]);
$info->save();
});
return app('json')->success('修改成功');
}
/**
* @param $id
* @return mixed
* @throws \FormBuilder\Exception\FormBuilderException
*/
public function getUpdateDomainForm($id)
{
return app('json')->success($this->services->getUpdateDomainForm((int)$id));
}
/**
* @param $id
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function updateDomain($id)
{
$domain = $this->request->post('domain', '');
$data = $this->request->postMore([
['pri', ''],
['ca', '']
]);
if (!$domain) {
return app('json')->fail('缺少参数');
}
if (strstr($domain, 'https://') === false && strstr($domain, 'http://') === false) {
return app('json')->fail('格式错误,请输入格式为:http://域名');
}
// if (strstr($domain, 'https://') !== false && !$data['pri']) {
// return app('json')->fail('域名为HTTPS访问时,必须填写证书');
// }
$this->services->updateDomain($id, $domain);
return app('json')->success('修改成功');
}
/**
* 删除
* @param $id
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function delete($id)
{
if (!$id) {
return app('json')->fail('缺少参数');
}
if ($this->services->deleteStorage($id)) {
return app('json')->success('删除成功');
} else {
return app('json')->fail('删除失败');
}
}
/**
* 切换存储类型
* @param SystemConfigServices $services
* @param $type
* @return mixed
*/
public function uploadType(SystemConfigServices $services, $type)
{
$status = $this->services->count(['type' => $type, 'status' => 1]);
if (!$status && $type != 1) {
return app('json')->fail('未有正在使用的存储空间');
}
$services->update('upload_type', ['value' => json_encode($type)], 'menu_name');
\crmeb\services\SystemConfigService::clear();
return app('json')->success('切换成功');
}
}

View File

@@ -0,0 +1,242 @@
<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
namespace app\controller\admin\v1\system\form;
use app\controller\admin\AuthController;
use app\services\system\form\SystemFormDataServices;
use app\services\system\form\SystemFormServices;
use think\annotation\Inject;
use think\facade\App;
/**
*
* Class SystemForm
* @package app\controller\admin\v1\system\form
*/
class SystemForm extends AuthController
{
/**
* @var SystemFormServices
*/
#[Inject]
protected SystemFormServices $services;
/**
* 系统表单列表
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function index()
{
$where = $this->request->getMore([
['status', ''],
['name', ''],
]);
return $this->success($this->services->getFormList($where));
}
/*
* 所有系统表单
*/
public function allSystemForm()
{
$data = $this->services->getFormList([], ['id', 'name']);
return $this->success($data['list'] ?? []);
}
/**
* 获取一条数据
* @param int $id
* @return mixed
*/
public function getInfo(int $id)
{
if (!$id) return $this->fail('数据不存在');
[$type] = $this->request->postMore([
['type', 0],
], true);
$info = $this->services->get($id);
if ($info) {
$info = $info->toArray();
} else {
return $this->fail('数据不存在');
}
$info['value'] = json_decode($info['value'], true);
if ($type == 1) {//处理表单数据
$value = $info['value'] ?? [];
$info = $this->services->handleForm($value);
}
return $this->success(compact('info'));
}
/**
* 保存资源
* @param int $id
* @return mixed
*/
public function save(int $id = 0)
{
$data = $this->request->postMore([
['name', ''],
]);
$data['value'] = $this->request->param('value', '');
if (!$data['name']) {
return $this->fail('请输入表单模版名称');
}
if (!$data['value']) {
return $this->fail('请添加表单组件');
}
foreach ($data['value'] as $item) {
$defaultValue = $item['defaultValConfig']['value'] ?? '';
if ($item['name'] == 'texts' && $defaultValue) {//文本类型,验证手机号 身份证 邮箱 数字
$tableList = $item['valConfig']['tabList'] ?? [];
$tableValue = $item['valConfig']['tabVal'] ?? 0;
if ($tableList) {
foreach ($tableList as $type => $verify) {
switch ($tableValue) {
case 0:
break;
case 1://手机号
if (!check_phone($defaultValue)) {
return $this->fail('请输入正确的手机号');
}
break;
case 2://身份证
try {
if (!check_card($defaultValue)) return app('json')->fail('请输入正确的身份证');
} catch (\Throwable $e) {
// return app('json')->fail('请输入正确的身份证');
}
break;
case 3://邮箱
if (!check_mail($defaultValue)) {
return $this->fail('请填写正确的邮箱');
}
break;
case 4://数字
if (!preg_match('/^[0-9]+$/', $defaultValue)) {
return $this->fail('请输入数字');
}
break;
}
}
}
}
}
$value = is_array($data['value']) ? json_encode($data['value']) : $data['value'];
$data['value'] = $value;
$one = $this->services->getOne(['name' => $data['name'], 'is_del' => 0]);
if ($one && (($id && $one['id'] != $id) || !$id)) {
return $this->fail('模版名称已经存在');
}
if ($id) {
$info = $this->services->get((int)$id, ['id', 'is_del']);
if (!$info) {
return $this->fail('数据不存在');
}
$data['update_time'] = time();
$res = $this->services->update($id, $data);
if (!$res) $this->fail('修改失败');
} else {
$data['add_time'] = time();
$data['update_time'] = time();
$res = $this->services->save($data);
if (!$res) $this->fail('保存失败');
$id = $res->id;
}
return $this->success($id ? '修改成功' : '保存成功', ['id' => $id]);
}
/**
* 删除模板
* @param $id
* @return mixed
*/
public function del($id)
{
$info = $this->services->get((int)$id, ['id', 'is_del']);
if ($info && $info['is_del'] == 0) {
$this->services->update($id, ['is_del' => 1]);
}
return $this->success('删除成功');
}
/**
* 上下架
* @param $id
* @return mixed
*/
public function set_show($id, $is_show)
{
$info = $this->services->get((int)$id, ['id']);
if (!$info) {
return $this->fail('数据不存在');
}
$this->services->update($id, ['status' => $is_show, 'update_time' => time()]);
return $this->success('设置成功');
}
/**
* 表单收集数据列表
* @param SystemFormDataServices $systemFormDataServices
* @param $id
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function formData(SystemFormDataServices $systemFormDataServices, $id)
{
$where = $this->request->postMore([
['data', '', '', 'time']
]);
return $this->success($systemFormDataServices->getFormDataList((int)$id, $where));
}
/**
* 修改表单模板名称
* @param $id
* @return bool|object
*/
public function updateName($id)
{
// 获取请求数据中的名称字段
[$name] = $this->request->postMore([
['name', '']
], true);
if (!$name) {
return $this->fail('请输入表单模版名称');
}
$info = $this->services->getOne(['id' => $id, 'is_del' => 0]);
if (!$info) {
return $this->fail('数据不存在');
}
if ($info['name'] == $name) {
return $this->fail('模版名称未修改');
}
$one = $this->services->getOne(['name' => $name, 'is_del' => 0]);
if ($one) {
return $this->fail('模版名称已经存在');
}
$info->name = $name;
$info->save();
return $this->success('修改成功');
}
}

View File

@@ -0,0 +1,63 @@
<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
namespace app\controller\admin\v1\system\log;
use think\exception\ValidateException;
use app\services\system\log\ClearServices;
use app\controller\admin\AuthController;
/**
* 清除数据控制器
* Class Clear
* @package app\controller\admin\v1\system
*/
class Clear extends AuthController
{
/**
* @var ClearServices
*/
protected ClearServices $services;
/**
* Clear constructor.
* @param ClearServices $services
*/
public function __construct(ClearServices $services)
{
parent::__construct();
$this->services = $services;
//生产模式下不允许清除数据
if (!env('APP_DEBUG', false)) {
throw new ValidateException('生产模式下,禁止操作');
}
}
/**
* 刷新数据缓存
*/
public function refresh_cache()
{
$this->services->refresCache();
return $this->success('数据缓存刷新成功!');
}
/**
* 删除日志
*/
public function delete_log()
{
$this->services->deleteLog();
return $this->success('数据缓存刷新成功!');
}
}

View File

@@ -0,0 +1,89 @@
<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
namespace app\controller\admin\v1\system\log;
use think\annotation\Inject;
use think\exception\ValidateException;
use app\controller\admin\AuthController;
use app\services\system\log\SystemFileServices;
/**
* 文件校验控制器
* Class SystemFile
* @package app\admin\controller\system
*
*/
class SystemFile extends AuthController
{
/**
* @var SystemFileServices
*/
#[Inject]
protected SystemFileServices $services;
/**
* 构造方法
* SystemFile constructor.
* @param SystemFileServices $services
*/
public function __construct(SystemFileServices $services)
{
parent::__construct();
$this->services = $services;
//生产模式下不允许清除数据
if (!env('APP_DEBUG', false)) {
throw new ValidateException('生产模式下,禁止操作');
}
}
/**
* 文件校验记录
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function index()
{
return $this->success(['list' => $this->services->getFileList()]);
}
//打开目录
public function opendir()
{
// return $this->success($this->services->opendir());
}
//读取文件
public function openfile()
{
// $file = $this->request->param('filepath');
// if (empty($file)) return $this->fail('出现错误');
// return $this->success($this->services->openfile($file));
}
//保存文件
public function savefile()
{
// $comment = $this->request->param('comment');
// $filepath = $this->request->param('filepath');
// if(empty($comment) || empty($filepath)){
// return $this->fail('出现错误');
// }
// $res = $this->services->savefile($filepath,$comment);
// if ($res) {
return $this->success('保存成功!');
// } else {
// return $this->fail('保存失败');
// }
}
}

View File

@@ -0,0 +1,66 @@
<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
namespace app\controller\admin\v1\system\log;
use app\services\system\admin\SystemAdminServices;
use app\controller\admin\AuthController;
use app\services\system\log\SystemLogServices;
/**
* 管理员操作记录表控制器
* Class SystemLog
* @package app\controller\admin\v1\system
*/
class SystemLog extends AuthController
{
/**
* @var SystemLogServices
*/
protected SystemLogServices $services;
/**
* 构造方法
* SystemLog constructor.
* @param SystemLogServices $services
* @throws \Exception
*/
public function __construct(SystemLogServices $services)
{
parent::__construct();
$this->services = $services;
$this->services->deleteLog();
}
/**
* 显示操作记录
*/
public function index()
{
$where = $this->request->getMore([
['pages', ''],
['path', ''],
['ip', ''],
['admin_id', ''],
['data', '', '', 'time'],
]);
return $this->success($this->services->getLogList($where, (int)$this->adminInfo['level']));
}
public function search_admin(SystemAdminServices $services)
{
$info = $services->getOrdAdmin('id,real_name', $this->adminInfo['level']);
return $this->success(compact('info'));
}
}