【程序目录】更新5.2

This commit is contained in:
evoxwht 2023-09-19 14:56:53 +08:00
parent 87809fce93
commit 9ea5d9d11a
2138 changed files with 8593 additions and 35610 deletions

View File

@ -1,5 +1,5 @@
version=CRMEB-KY v5.1.0
version_code=510
version=CRMEB-KY v5.2.0
version_code=520
platform=gitee
app_id=ze7x9rxsv09l6pvsyo
app_key=fuF7U9zaybLa5gageVQzxtxQMFnvU2OI

View File

@ -60,7 +60,12 @@ class Request extends \think\Request
$name = is_array($param[1]) ? $param[0] . '/a' : $param[0];
$keyName = $param[0];
}
$p[$suffix == true ? $i++ : ($param[3] ?? $keyName)] = $this->filterWord(is_string($this->param($name, $param[1], $param[2])) ? trim($this->param($name, $param[1], $param[2])) : $this->param($name, $param[1], $param[2]), $filter && !in_array($keyName, $this->except));
$p[$suffix == true ? $i++ : ($param[3] ?? $keyName)] = $this->filterWord(
is_string($this->param($name, $param[1], $param[2])) ?
trim($this->param($name, $param[1], $param[2])) :
$this->param($name, $param[1], $param[2]),
$filter && !in_array($keyName, $this->except));
}
}
return $p;
@ -86,12 +91,34 @@ class Request extends \think\Request
foreach ($str as &$v) {
if (is_array($v)) {
foreach ($v as &$vv) {
if (!is_array($vv)) $vv = preg_replace($farr, '', $vv);
if (!is_array($vv)) {
$vv = $this->replaceWord($farr, $vv);
}
}
} else {
$v = preg_replace($farr, '', $v);
$v = $this->replaceWord($farr, $v);
}
}
} else {
$str = $this->replaceWord($farr, $str);
}
return $str;
}
/**
* 替换
* @param $farr
* @param $str
* @return array|string|string[]|null
* @author: 吴汐
* @email: 442384644@qq.com
* @date: 2023/9/19
*/
public function replaceWord($farr, $str)
{
if (parse_url($str, PHP_URL_HOST)) {
$url = parse_url($str);
$str = $url['scheme'] . '://' . $url['host'] . preg_replace($farr, '', $url['path']);
} else {
$str = preg_replace($farr, '', $str);
}

View File

@ -20,8 +20,8 @@ use app\services\user\UserExtractServices;
use app\services\product\sku\StoreProductAttrValueServices;
use app\services\system\SystemMenusServices;
use app\services\user\UserServices;
use crmeb\services\CacheService;
use crmeb\services\HttpService;
use think\facade\Cache;
/**
* 公共接口基类 主要存放公共接口
@ -402,7 +402,7 @@ class Common extends AuthController
'info' => ''
]);
}
$services->cacheDriver()->clear();
CacheService::clear();
return app('json')->success(100000);
}

View File

@ -14,6 +14,7 @@ namespace app\adminapi\controller;
use app\Request;
use app\services\system\attachment\SystemAttachmentServices;
use app\services\system\SystemRouteServices;
use crmeb\services\CacheService;
use think\Response;
@ -65,10 +66,20 @@ class PublicController
['pid', 0]
], true);
$service = app()->make(SystemAttachmentServices::class);
if ($service->cacheDriver()->get('scan_upload') != $uploadToken) {
if (CacheService::get('scan_upload') != $uploadToken) {
return app('json')->fail(410086);
}
$service->upload((int)$pid, $file, $upload_type, $type, '', $uploadToken);
return app('json')->success(100032);
}
public function import(Request $request)
{
$filePath = $request->param('file_path', '');
if (empty($filePath)) {
return app('json')->fail(12894);
}
app()->make(SystemRouteServices::class)->import($filePath);
return app('json')->success(100010);
}
}

View File

@ -6,14 +6,11 @@
namespace app\adminapi\controller;
use app\services\user\OutUserServices;
class Test
{
public function index()
{
$data = app()->make(OutUserServices::class)->userInfo(1);
return app('json')->success(compact('data'));
}
}

File diff suppressed because one or more lines are too long

View File

@ -11,8 +11,8 @@
namespace app\adminapi\controller\v1\application\routine;
use app\jobs\notice\SyncMessageJob;
use app\services\message\SystemNotificationServices;
use app\services\other\QrcodeServices;
use app\services\message\TemplateMessageServices;
use app\services\system\attachment\SystemAttachmentServices;
use crmeb\exceptions\AdminException;
use think\exception\ValidateException;
@ -34,9 +34,9 @@ class RoutineTemplate extends AuthController
* 构造方法
* WechatTemplate constructor.
* @param App $app
* @param TemplateMessageServices $services
* @param SystemNotificationServices $services
*/
public function __construct(App $app, TemplateMessageServices $services)
public function __construct(App $app, SystemNotificationServices $services)
{
parent::__construct($app);
$this->services = $services;
@ -54,16 +54,17 @@ class RoutineTemplate extends AuthController
if (!sys_config('routine_appId') || !sys_config('routine_appsecret')) {
throw new AdminException(400236);
}
$all = $this->services->getTemplateList(['status' => 1, 'type' => 0]);
$list = MiniProgramService::getSubscribeTemplateList();
foreach ($list->data as $v) {
MiniProgramService::delSubscribeTemplate($v['priTmplId']);
}
if ($all['list']) {
foreach ($all['list'] as $template) {
SyncMessageJob::dispatch('SyncSubscribe', [$template]);
}
$tempKeys = $this->services->getTempKey('routine');
foreach ($tempKeys as $key => $content) {
SyncMessageJob::dispatch('SyncSubscribe', [$key, $content]);
}
return app('json')->success(100038);
}

View File

@ -63,6 +63,7 @@ class Reply extends AuthController
['key', ''],
['type', ''],
]);
$where['key_type'] = 0;
$list = $this->services->getKeyAll($where);
return app('json')->success($list);
}

View File

@ -12,8 +12,8 @@ namespace app\adminapi\controller\v1\application\wechat;
use app\adminapi\controller\AuthController;
use app\jobs\notice\SyncMessageJob;
use app\services\message\SystemNotificationServices;
use crmeb\exceptions\AdminException;
use app\services\message\TemplateMessageServices;
use crmeb\services\app\WechatService;
use think\facade\App;
@ -28,9 +28,9 @@ class WechatTemplate extends AuthController
* 构造方法
* WechatTemplate constructor.
* @param App $app
* @param TemplateMessageServices $services
* @param SystemNotificationServices $services
*/
public function __construct(App $app, TemplateMessageServices $services)
public function __construct(App $app, SystemNotificationServices $services)
{
parent::__construct($app);
$this->services = $services;
@ -48,13 +48,16 @@ class WechatTemplate extends AuthController
if (!sys_config('wechat_appid') || !sys_config('wechat_appsecret')) {
throw new AdminException(400248);
}
$all = $this->services->getTemplateList(['status' => 1, 'type' => 1]);
$list = WechatService::getPrivateTemplates();
foreach ($list->template_list as $v) {
WechatService::deleleTemplate($v['template_id']);
$tempIds = $this->services->getTempId('wechat');
foreach ($tempIds as $v) {
WechatService::deleleTemplate($v);
}
foreach ($all['list'] as $template) {
SyncMessageJob::dispatch('SyncWechat', [$template]);
$tempKeys = $this->services->getTempKey('wechat');
foreach ($tempKeys as $key => $content) {
SyncMessageJob::dispatch('SyncWechat', [$key, $content['wechat_content']]);
}
return app('json')->success(100038);
}

View File

@ -170,9 +170,6 @@ class ArticleCategory extends AuthController
public function getTreeList()
{
$list = $this->service->getTreeList();
foreach ($list as &$item) {
$item['disabled'] = !$item['status'] || $item['is_del'];
}
return app('json')->success($list);
}
}

View File

@ -103,6 +103,18 @@ class ExportExcel extends AuthController
return app('json')->success($this->service->exportOrderList($where));
}
/**
* 发货订单列表导出
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function orderDeliveryList()
{
return app('json')->success($this->service->exportOrderDeliveryList());
}
/**
* 商品列表导出
* @return mixed

View File

@ -12,6 +12,7 @@ namespace app\adminapi\controller\v1\file;
use app\adminapi\controller\AuthController;
use app\services\system\attachment\SystemAttachmentServices;
use crmeb\services\CacheService;
use think\facade\App;
/**
@ -150,7 +151,7 @@ class SystemAttachment extends AuthController
['pid', 0]
], true);
$uploadToken = md5(time());
$this->service->cacheDriver()->set('scan_upload', $uploadToken, 600);
CacheService::set('scan_upload', $uploadToken, 600);
$url = sys_config('site_url') . '/app/upload?pid=' . $pid . '&token=' . $uploadToken;
return app('json')->success(['url' => $url]);
}
@ -164,7 +165,7 @@ class SystemAttachment extends AuthController
*/
public function removeUploadQrcode()
{
$this->service->cacheDriver()->delete('scan_upload');
CacheService::delete('scan_upload');
return app('json')->success();
}

View File

@ -104,6 +104,7 @@ class SystemAttachmentCategory extends AuthController
['pid', 0],
['name', '']
]);
if (is_array($data['pid'])) $data['pid'] = end($data['pid']);
if (!$data['name']) {
return app('json')->fail(400100);
}

View File

@ -0,0 +1,82 @@
<?php
/**
* @author: 吴汐
* @email: 442384644@qq.com
* @date: 2023/8/3
*/
namespace app\adminapi\controller\v1\kefu;
use app\adminapi\controller\AuthController;
use app\services\wechat\WechatReplyServices;
class StoreServiceAutoReply extends AuthController
{
/**
* @return \think\Response
* @author: 吴汐
* @email: 442384644@qq.com
* @date: 2023/8/3
*/
public function autoReplyList()
{
$where = $this->request->getMore([
['key', ''],
['type', ''],
]);
$where['key_type'] = 1;
$list = app()->make(WechatReplyServices::class)->getKeyAll($where);
return app('json')->success($list);
}
/**
* 获取自动回复表单
* @param int $id
* @return \think\Response
* @throws \FormBuilder\Exception\FormBuilderException
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author: 吴汐
* @email: 442384644@qq.com
* @date: 2023/8/3
*/
public function autoReplyForm($id = 0)
{
return app('json')->success(app()->make(WechatReplyServices::class)->autoReplyForm($id));
}
/**
* 保存自动回复
* @param int $id
* @return \think\Response
* @author: 吴汐
* @email: 442384644@qq.com
* @date: 2023/8/3
*/
public function autoReplySave($id = 0)
{
$data = $this->request->postMore([
['keys', ''],
['type', ''],
['data', ''],
['status', 1],
]);
app()->make(WechatReplyServices::class)->autoReplySave($id, $data);
return app('json')->success(100000);
}
/**
* 删除自动回复
* @param $id
* @return \think\Response
* @author: 吴汐
* @email: 442384644@qq.com
* @date: 2023/8/3
*/
public function autoReplyDel($id)
{
app()->make(WechatReplyServices::class)->autoReplyDel($id);
return app('json')->success(100002);
}
}

View File

@ -0,0 +1,117 @@
<?php
/**
* @author: 吴汐
* @email: 442384644@qq.com
* @date: 2023/7/31
*/
namespace app\adminapi\controller\v1\marketing;
use app\adminapi\controller\AuthController;
use app\services\system\SystemSignRewardServices;
use think\facade\App;
class SignRewards extends AuthController
{
/**
* @param App $app
* @param SystemSignRewardServices $services
*/
public function __construct(App $app, SystemSignRewardServices $services)
{
parent::__construct($app);
$this->services = $services;
}
/**
* 签到奖励列表
* @return \think\Response
* @throws \ReflectionException
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author: 吴汐
* @email: 442384644@qq.com
* @date: 2023/7/31
*/
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
* @author: 吴汐
* @email: 442384644@qq.com
* @date: 2023/7/31
*/
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 \FormBuilder\Exception\FormBuilderException
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author: 吴汐
* @email: 442384644@qq.com
* @date: 2023/7/31
*/
public function editRewards($id)
{
$data = $this->services->rewardsForm($id);
return app('json')->success($data);
}
/**
* 保存签到奖励
* @param $id
* @return \think\Response
* @author: 吴汐
* @email: 442384644@qq.com
* @date: 2023/7/31
*/
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(100000);
}
/**
* 删除签到奖励
* @param $id
* @return \think\Response
* @author: 吴汐
* @email: 442384644@qq.com
* @date: 2023/7/31
*/
public function delRewards($id)
{
$this->services->delete($id);
return app('json')->success(100002);
}
}

View File

@ -14,6 +14,7 @@ use app\services\system\config\SystemConfigServices;
use app\services\yihaotong\SmsAdminServices;
use app\services\serve\ServeServices;
use app\adminapi\controller\AuthController;
use crmeb\services\CacheService;
use think\facade\App;
/**
@ -65,7 +66,7 @@ class SmsConfig extends AuthController
public function is_login(ServeServices $services)
{
$configServices = app()->make(SystemConfigServices::class);
$sms_info = $configServices->cacheDriver()->get('sms_account');
$sms_info = CacheService::get('sms_account');
$data = ['status' => false, 'info' => ''];
if ($sms_info) {
try {
@ -81,14 +82,14 @@ class SmsConfig extends AuthController
}
return app('json')->success($data);
} else {
$configServices->cacheDriver()->clear();
CacheService::clear();
$account = sys_config('sms_account');
$password = sys_config('sms_token');
//没有退出登录 清空这两个数据 自动登录
if ($account && $password) {
$res = $services->user()->login($account, $password);
if ($res) {
$configServices->cacheDriver()->set('sms_account', $account);
CacheService::set('sms_account', $account);
$data['status'] = true;
$data['info'] = $account;
}
@ -104,10 +105,9 @@ class SmsConfig extends AuthController
*/
public function logout()
{
$configServices = app()->make(SystemConfigServices::class);
$configServices->cacheDriver()->delete('sms_account');
CacheService::delete('sms_account');
$this->services->updateSmsConfig('', '');
$configServices->cacheDriver()->clear();
CacheService::clear();
return app('json')->success(100042);
}

View File

@ -12,7 +12,9 @@ namespace app\adminapi\controller\v1\order;
use app\adminapi\controller\AuthController;
use app\adminapi\validate\order\StoreOrderValidate;
use app\jobs\OrderExpressJob;
use app\services\serve\ServeServices;
use crmeb\services\FileService;
use app\services\order\{StoreOrderCartInfoServices,
StoreOrderDeliveryServices,
StoreOrderRefundServices,
@ -862,4 +864,23 @@ class StoreOrder extends AuthController
return app('json')->fail('取消失败');
}
}
/**
* 导入批量发货
* @return \think\Response|void
* @throws \PhpOffice\PhpSpreadsheet\Reader\Exception
*/
public function importExpress()
{
[$file] = $this->request->getMore([
['file', '']
], true);
if (!$file) return app('json')->fail(400168);
$file = public_path() . substr($file, 1);
$expressData = app()->make(FileService::class)->readExcel($file, 'express', 2);
foreach ($expressData as $item) {
OrderExpressJob::dispatch([$item]);
}
return app('json')->success('批量发货成功');
}
}

View File

@ -41,7 +41,11 @@ class StoreProduct extends AuthController
*/
public function type_header()
{
$list = $this->service->getHeader();
$where = $this->request->getMore([
['store_name', ''],
['cate_id', ''],
]);
$list = $this->service->getHeader($where);
return app('json')->success(compact('list'));
}
@ -238,7 +242,8 @@ class StoreProduct extends AuthController
['is_copy', 0],//是否是复制商品
['is_limit', 0],//是否限购
['limit_type', 0],//限购类型
['limit_num', 0]//限购数量
['limit_num', 0],//限购数量
['min_qty', 1],//起购数量
]);
$this->service->save((int)$id, $data);
return app('json')->success(100000);
@ -385,7 +390,7 @@ class StoreProduct extends AuthController
$file = public_path() . substr($data['file'], 1);
/** @var FileService $readExcelService */
$readExcelService = app()->make(FileService::class);
$cardData = $readExcelService->readExcel($file);
$cardData = $readExcelService->readExcel($file, 'card');
return app('json')->success($cardData);
}

View File

@ -92,4 +92,4 @@ class LangType extends AuthController
CacheService::delete('lang_type_data');
return app('json')->success(100002);
}
}
}

View File

@ -14,6 +14,7 @@ use app\adminapi\controller\AuthController;
use app\Request;
use app\services\system\config\SystemConfigServices;
use app\services\system\config\SystemConfigTabServices;
use crmeb\services\CacheService;
use crmeb\services\easywechat\orderShipping\MiniOrderService;
use think\facade\App;
@ -97,6 +98,7 @@ class SystemConfig extends AuthController
['sort', 0],
['status', 0]
]);
if (is_array($data['config_tab_id'])) $data['config_tab_id'] = end($data['config_tab_id']);
if (!$data['info']) return app('json')->fail(400274);
if (!$data['menu_name']) return app('json')->fail(400275);
if (!$data['desc']) return app('json')->fail(400276);
@ -124,7 +126,7 @@ class SystemConfig extends AuthController
} else {
$this->services->save($data);
}
$this->services->cacheDriver()->clear();
CacheService::clear();
return app('json')->success(400284);
}
@ -185,12 +187,13 @@ class SystemConfig extends AuthController
['sort', 0],
['status', 0]
]);
if (is_array($data['config_tab_id'])) $data['config_tab_id'] = end($data['config_tab_id']);
if (!$this->services->get($id)) {
return app('json')->fail(100026);
}
$data['value'] = json_encode($data['value']);
$this->services->update($id, $data);
$this->services->cacheDriver()->clear();
CacheService::clear();
return app('json')->success(100001);
}
@ -204,7 +207,7 @@ class SystemConfig extends AuthController
if (!$this->services->delete($id))
return app('json')->fail(100008);
else {
$this->services->cacheDriver()->clear();
CacheService::clear();
return app('json')->success(100002);
}
}
@ -221,7 +224,7 @@ class SystemConfig extends AuthController
return app('json')->fail(100100);
}
$this->services->update($id, ['status' => $status]);
$this->services->cacheDriver()->clear();
CacheService::clear();
return app('json')->success(100014);
}
@ -329,12 +332,33 @@ class SystemConfig extends AuthController
@copy($from, $toPublic);
}
if (isset($post['reward_integral']) || isset($post['reward_money'])) {
if ($post['reward_integral'] < 0 || $post['reward_money'] < 0) return app('json')->fail(400558);
if ($post['reward_money'] < 0) return app('json')->fail('赠送余额不能小于0元');
if ($post['reward_integral'] < 0) return app('json')->fail('赠送积分不能小于0');
}
if (isset($post['sign_give_point'])) {
if (!is_int($post['sign_give_point']) || $post['sign_give_point'] < 0) return app('json')->fail('签到赠送积分请填写大于等于0的整数');
}
if (isset($post['sign_give_exp'])) {
if (!is_int($post['sign_give_exp']) || $post['sign_give_exp'] < 0) return app('json')->fail('签到赠送经验请填写大于等于0的整数');
}
if (isset($post['integral_frozen'])) {
if (!ctype_digit($post['integral_frozen']) || $post['integral_frozen'] < 0) return app('json')->fail('积分冻结天数请填写大于等于0的整数');
}
if (isset($post['store_free_postage'])) {
if (!is_int($post['store_free_postage']) || $post['store_free_postage'] < 0) return app('json')->fail('满额包邮请填写大于等于0的整数');
}
if (isset($post['withdrawal_fee'])) {
if ($post['withdrawal_fee'] < 0 || $post['withdrawal_fee'] > 100) return app('json')->fail('提现手续费范围在0-100之间');
}
if (isset($post['routine_auth_type']) && count($post['routine_auth_type']) == 0) return app('json')->fail('微信和手机号登录开关至少开启一个');
if (isset($post['integral_max_num'])) {
if (!ctype_digit($post['integral_max_num']) || $post['integral_max_num'] < 0) return app('json')->fail('积分抵扣上限请填写大于等于0的整数');
}
if (isset($post['customer_phone'])) {
if (!ctype_digit($post['customer_phone']) || strlen($post['customer_phone']) > 11) return app('json')->fail('客服手机号为11位数字');
}
// if (isset($post['order_shipping_open']) && $post['order_shipping_open'] == 1 && isset($post['order_shipping_url'])) {
// MiniOrderService::setMesJumpPathAndCheck($post['order_shipping_url']);
// }
foreach ($post as $k => $v) {
$config_one = $this->services->getOne(['menu_name' => $k]);
if ($config_one) {
@ -343,7 +367,7 @@ class SystemConfig extends AuthController
$this->services->update($k, ['value' => json_encode($v)], 'menu_name');
}
}
$this->services->cacheDriver()->clear();
CacheService::clear();
return app('json')->success(100001);
}
@ -366,6 +390,7 @@ class SystemConfig extends AuthController
$config_tab = [];
} else {
$config_tab = $services->getConfigTab($pid);
if (empty($config_tab)) $config_tab[] = $services->get($pid, ['id', 'id as value', 'title as label', 'pid', 'icon', 'type']);
}
return app('json')->success(compact('config_tab'));
}

View File

@ -75,6 +75,7 @@ class SystemConfigTab extends AuthController
['sort', 0],
['pid', 0],
]);
if (is_array($data['pid'])) $data['pid'] = end($data['pid']);
if (!$data['title']) return app('json')->fail(400291);
$this->services->save($data);
return app('json')->success(400292);
@ -119,6 +120,7 @@ class SystemConfigTab extends AuthController
['sort', 0],
['pid', 0],
]);
if (is_array($data['pid'])) $data['pid'] = end($data['pid']);
if (!$data['title']) return app('json')->fail(400291);
if (!$data['eng_title']) return app('json')->fail(400275);
$this->services->update($id, $data);

View File

@ -17,12 +17,14 @@ namespace app\adminapi\controller\v1\setting;
use app\adminapi\controller\AuthController;
use app\Request;
use app\services\system\log\SystemFileServices;
use app\services\system\SystemCrudDataService;
use app\services\system\SystemCrudServices;
use app\services\system\SystemMenusServices;
use crmeb\services\CacheService;
use crmeb\services\crud\enum\FormTypeEnum;
use crmeb\services\crud\Make;
use crmeb\services\crud\Service;
use crmeb\services\FileService;
use crmeb\utils\Terminal;
use think\facade\App;
use think\helper\Str;
use think\Response;
@ -49,7 +51,7 @@ class SystemCrud extends AuthController
}
/**
* @return \think\Response
* @return Response
* @author 等风来
* @email 136327134@qq.com
* @date 2023/4/11
@ -60,12 +62,12 @@ class SystemCrud extends AuthController
}
/**
* @return \think\Response
* @return Response
* @author 等风来
* @email 136327134@qq.com
* @date 2023/4/11
*/
public function save($id = 0)
public function save(SystemCrudDataService $service, $id = 0)
{
$data = $this->request->postMore([
['pid', 0],//上级菜单id
@ -80,30 +82,44 @@ class SystemCrud extends AuthController
['deleteField', []],//删除的表字段
]);
$fromField = $columnField = [];
$fromField = $searchField = $hasOneField = $columnField = $tableIndex = [];
$dictionaryids = array_column($data['tableField'], 'dictionary_id');
if ($dictionaryids) {
$dictionaryList = $service->getColumn([['id', 'in', $dictionaryids]], 'value', 'id');
foreach ($dictionaryList as &$value) {
$value = is_string($value) ? json_decode($value, true) : $value;
}
} else {
$dictionaryList = [];
}
foreach ($data['tableField'] as $item) {
//判断字段长度
if (in_array($item['field_type'], ['datetime', 'timestamp', 'time', 'date', 'year']) && $item['limit'] > 6) {
if (in_array($item['field_type'], [FormTypeEnum::DATE_TIME, 'timestamp', 'time', 'date', 'year']) && $item['limit'] > 6) {
return app('json')->fail('字段' . $item['field'] . '长度不能大于6');
}
if ($item['field_type'] == 'enum' && !is_array($item['limit'])) {
return app('json')->fail('数据类型为枚举时,长度为数组类型');
}
//收集列表展示数据
if ($item['is_table'] && !in_array($item['field_type'], ['primaryKey', 'addSoftDelete', 'addSoftDelete'])) {
if ($item['is_table'] && !in_array($item['field_type'], ['primaryKey', 'addSoftDelete'])) {
if (isset($item['primaryKey']) && !$item['primaryKey']) {
$columnField[] = [
'field' => $item['field'],
'name' => $item['table_name'],
'name' => $item['table_name'] ?: $item['comment'],
'type' => $item['from_type'],
];
}
}
$name = $item['table_name'] ?: $item['comment'];
$option = $item['options'] ?? (isset($item['dictionary_id']) ? ($dictionaryList[$item['dictionary_id']] ?? []) : []);
//收集表单展示数据
if ($item['from_type']) {
$name = $item['table_name'] ?: $item['comment'];
$option = $item['options'] ?? [];
if (!$name) {
return app('json')->fail(500048, [], ['field' => $item['field']]);
}
if (!$option && in_array($item['from_type'], ['radio', 'select'])) {
if (!$option && in_array($item['from_type'], [FormTypeEnum::RADIO, FormTypeEnum::SELECT])) {
return app('json')->fail('表单类型为radio或select时,options字段不能为空');
}
$fromField[] = [
@ -111,9 +127,34 @@ class SystemCrud extends AuthController
'type' => $item['from_type'],
'name' => $name,
'required' => $item['required'],
'option' => $option,
'option' => $option
];
}
//搜索
if (!empty($item['search'])) {
$searchField[] = [
'field' => $item['field'],
'type' => $item['from_type'],
'name' => $name,
'search' => $item['search'],
'options' => $option
];
}
//关联
if (!empty($item['hasOne'])) {
$hasOneField[] = [
'field' => $item['field'],
'hasOne' => $item['hasOne'] ?? '',
'name' => $name,
];
}
//索引
if (!empty($item['index'])) {
$tableIndex[] = $item['field'];
}
}
if (!$fromField) {
return app('json')->fail(500046);
@ -122,7 +163,10 @@ class SystemCrud extends AuthController
return app('json')->fail(500047);
}
$data['fromField'] = $fromField;
$data['tableIndex'] = $tableIndex;
$data['columnField'] = $columnField;
$data['searchField'] = $searchField;
$data['hasOneField'] = $hasOneField;
if (!$data['tableName']) {
return app('json')->fail(500042);
}
@ -134,7 +178,7 @@ class SystemCrud extends AuthController
/**
* 获取创建文件的目录存放位置
* @return \think\Response
* @return Response
* @author 等风来
* @email 136327134@qq.com
* @date 2023/4/11
@ -194,7 +238,7 @@ class SystemCrud extends AuthController
/**
* @param $id
* @return \think\Response
* @return Response
* @author 等风来
* @email 136327134@qq.com
* @date 2023/4/12
@ -233,10 +277,13 @@ class SystemCrud extends AuthController
$make = $this->services->makeFile($info->table_name, $routeName, false, [
'menuName' => $info->name,
'modelName' => $info->model_name,
'tableField' => $info->field['tableField'] ?? [],
'key' => $key,
'softDelete' => $softDelete,
'fromField' => $info->field['fromField'] ?? [],
'columnField' => $info->field['columnField'] ?? [],
'searchField' => $info->field['searchField'] ?? [],
'hasOneField' => $info->field['hasOneField'] ?? [],
]);
$data = [];
@ -284,9 +331,15 @@ class SystemCrud extends AuthController
$item['default_field_type'] = $item['field_type'];
$item['default_comment'] = $item['comment'];
$item['default_default'] = $item['default'];
$item['default_default_type'] = $item['default_type'] ?? '1';
$item['default_type'] = $item['default_type'] ?? '1';
$item['is_table'] = !!$item['is_table'];
$item['required'] = !!$item['required'];
$item['index'] = isset($item['index']) && !!$item['index'];
$item['primaryKey'] = isset($item['primaryKey']) ? (int)$item['primaryKey'] : 0;
if (!isset($item['dictionary_id'])) {
$item['dictionary_id'] = 0;
}
$info['field']['tableField'][$key] = $item;
}
//对比数据库,是否有新增字段
@ -412,7 +465,7 @@ class SystemCrud extends AuthController
/**
* 获取tree菜单
* @return \think\Response
* @return Response
* @author 等风来
* @email 136327134@qq.com
* @date 2023/4/11
@ -423,9 +476,50 @@ class SystemCrud extends AuthController
->getList(['auth_type' => 1, 'is_show' => 1], ['auth_type', 'pid', 'id', 'menu_name as label', 'id as value']));
}
/**
* 获取可以进行关联的表名
* @return Response
* @author 等风来
* @email 136327134@qq.com
* @date 2023/8/2
*/
public function getAssociationTable()
{
return app('json')->success($this->services->getTableAll());
}
/**
* 获取表的详细信息
* @param string $tableName
* @return Response
* @author 等风来
* @email 136327134@qq.com
* @date 2023/8/2
*/
public function getAssociationTableInfo(string $tableName)
{
if (!$tableName) {
return app('json')->fail('缺少表名');
}
// if (in_array($tableName, SystemCrudServices::NOT_CRUD_TABANAME)) {
// return app('json')->fail('不允许查看当前表明细');
// }
$tableInfo = $this->services->getColumnNamesList($tableName);
$data = [];
foreach ($tableInfo as $key => $item) {
$data[] = [
'label' => $item['comment'] ?: $key,
'value' => $key,
'leaf' => true
];
}
return app('json')->success($data);
}
/**
* 获取创建表数据类型
* @return \think\Response
* @return Response
* @author 等风来
* @email 136327134@qq.com
* @date 2023/4/11
@ -438,7 +532,7 @@ class SystemCrud extends AuthController
/**
* @param SystemMenusServices $services
* @param $id
* @return \think\Response
* @return Response
* @author 等风来
* @email 136327134@qq.com
* @date 2023/4/11
@ -511,11 +605,12 @@ class SystemCrud extends AuthController
unlink($zipName);
}
$makePath = $info->make_path ?? [];
foreach ($makePath as $key => $item) {
if (in_array($key, ['pages', 'router', 'api'])) {
$item = $zipPath . str_replace(dirname(app()->getRootPath()), '', Make::adminTemplatePath()) . $item;
} else {
$item = $zipPath . DS . $item;
$item = $zipPath . DS . 'crmeb' . DS . $item;
}
$makePath[$key] = $item;
}
@ -542,10 +637,13 @@ class SystemCrud extends AuthController
$this->services->makeFile($info->table_name, $routeName, true, [
'menuName' => $info->name,
'tableFields' => $info->field['tableField'] ?? [],
'key' => $key,
'softDelete' => $softDelete,
'fromField' => $info->field['fromField'] ?? [],
'columnField' => $info->field['columnField'] ?? [],
'searchField' => $info->field['searchField'] ?? [],
'hasOneField' => $info->field['hasOneField'] ?? [],
], $makePath, $zipPath);
if (!extension_loaded('zip')) {
@ -590,11 +688,19 @@ class SystemCrud extends AuthController
$newRoute['create'] = $item['api_url'];
} else if (strstr($item['api_url'], 'edit')) {
$newRoute['edit'] = $item['api_url'];
} else if (strstr($item['api_url'], 'status')) {
$newRoute['status'] = $item['api_url'];
} else {
$newRoute['index'] = $item['api_url'];
if (strstr($item['api_url'], '<id>')) {
$newRoute['read'] = $item['api_url'];
} else {
$newRoute['index'] = $item['api_url'];
}
}
} else if ($item['methods'] == 'DELETE') {
$newRoute['delete'] = $item['api_url'];
} else if ($item['methods'] == 'PUT' && strstr($item['api_url'], 'status')) {
$newRoute['status'] = $item['api_url'];
}
}
@ -614,16 +720,39 @@ class SystemCrud extends AuthController
'from_type' => '',
]
];
$readFields = [
'name' => $info->field['modelName'] ?: $info->field['menuName'],
'all' => [],
];
foreach ((array)$info->field['tableField'] as $item) {
if (isset($item['primaryKey']) && $item['primaryKey']) {
continue;
}
$prefix = app()->make(Service::class)->getAttrPrefix();
$readFields['all'][] = [
'field' => in_array($item['from_type'], [FormTypeEnum::FRAME_IMAGES,
FormTypeEnum::DATE_TIME_RANGE,
FormTypeEnum::RADIO,
FormTypeEnum::SELECT,
FormTypeEnum::CHECKBOX]) ? $item['field'] . $prefix : $item['field'],
'comment' => $item['comment'],
'from_type' => $item['from_type'],
];
if (isset($item['is_table']) && $item['is_table']) {
$label = '';
if (in_array($item['from_type'], ['frameImageOne', 'frameImages'])) {
if (in_array($item['from_type'], [FormTypeEnum::SWITCH, FormTypeEnum::DATE_TIME_RANGE, FormTypeEnum::FRAME_IMAGE_ONE, FormTypeEnum::FRAME_IMAGES])) {
$keyName = 'slot';
} elseif (in_array($item['from_type'], ['radio', 'select', 'checkbox'])) {
$label = app()->make(Make::class)->getAttrPrefix();
if ($item['from_type'] == FormTypeEnum::FRAME_IMAGES) {
$label = $prefix;
} else if ($item['from_type'] == FormTypeEnum::DATE_TIME_RANGE) {
$label = $prefix;
}
} elseif (in_array($item['from_type'], [FormTypeEnum::RADIO, FormTypeEnum::SELECT, FormTypeEnum::CHECKBOX])) {
$label = $prefix;
$keyName = 'key';
} else {
$keyName = 'key';
}
@ -635,45 +764,127 @@ class SystemCrud extends AuthController
];
}
}
$searchField = $info->field['searchField'] ?? [];
$search = [];
foreach ((array)$searchField as $item) {
if (!$item['type']) {
$item['type'] = FormTypeEnum::INPUT;
}
if ($item['search'] == 'BETWEEN') {
$item['type'] = 'date-picker';
} else {
if (in_array($item['type'], [FormTypeEnum::CHECKBOX, FormTypeEnum::RADIO, FormTypeEnum::SELECT])) {
$item['type'] = FormTypeEnum::SELECT;
} else {
$item['type'] = FormTypeEnum::INPUT;
}
}
$search[] = [
'field' => $item['field'],
'type' => $item['type'],
'name' => $item['name'],
'option' => $item['options'] ?? [],
];
}
$route = $newRoute;
return app('json')->success(compact('key', 'route', 'columns'));
return app('json')->success(compact('key', 'route', 'columns', 'readFields', 'search'));
}
/**
* @return string
* 修改或者保存字典数据
* @param SystemCrudDataService $service
* @param int $id
* @return Response
* @author 等风来
* @email 136327134@qq.com
* @date 2023/4/14
* @date 2023/8/1
*/
public function npm()
public function saveDataDictionary(SystemCrudDataService $service, $id = 0)
{
$terminal = new Terminal();
$data = $this->request->postMore([
['name', ''],
['value', []],
]);
$adminPath = $terminal->adminTemplatePath();
$adminPath = dirname($adminPath);
try {
$dir = $adminPath . DS . 'node_modules';
if (!is_dir($dir)) {
// $terminal->run('npm-install');
}
// $res = $terminal->run('npm-build');
} catch (\Throwable $e) {
$terminal->echoOutputFlag($e->getMessage());
if (!$data['name']) {
return app('json')->fail('数据字段名不能为空');
}
if (!$data['value']) {
return app('json')->fail('数据字段内容不能为空');
}
$data['value'] = json_encode($data['value']);
if ($id) {
$service->update($id, $data);
} else {
$service->save($data);
}
if (!is_dir($adminPath . DS . 'dist')) {
echo Response::create([
'message' => '打包失败',
], 'json')->getContent();
return app('json')->success($id ? '修改成功' : '添加成功');
}
/**
* 查看数据字典
* @param SystemCrudDataService $service
* @param $id
* @return Response
* @author 等风来
* @email 136327134@qq.com
* @date 2023/8/7
*/
public function getDataDictionaryOne(SystemCrudDataService $service, $id)
{
if (!$id) {
return app('json')->fail('缺少参数');
}
$info = $service->get($id);
if (!$info) {
return app('json')->fail('没有查询到数据');
}
return app('json')->success($info->toArray());
}
/**
* 获取数据字典列表
* @param SystemCrudDataService $service
* @return Response
* @throws \ReflectionException
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author 等风来
* @email 136327134@qq.com
* @date 2023/8/1
*/
public function getDataDictionary(SystemCrudDataService $service)
{
$name = $this->request->get('name', '');
$data = $service->getlistAll($name);
return app('json')->success($data);
}
/**
* 删除数据字典
* @param SystemCrudDataService $service
* @param $id
* @return Response
* @author 等风来
* @email 136327134@qq.com
* @date 2023/8/4
*/
public function deleteDataDictionary(SystemCrudDataService $service, $id)
{
if (!$id) {
return app('json')->fail('缺少参数');
}
if ($service->delete($id)) {
return app('json')->success('删除成功');
} else {
return app('json')->fail('删除失败');
}
$build = public_path() . config('app.admin_prefix');
// $this->app->make(FileService::class)->copyDir($adminPath . DS . 'dist', $build);
// echo $res;
}
}

View File

@ -109,6 +109,10 @@ class SystemGroupData extends AuthController
}
}
}
if ($group && $group['config_name'] == 'user_recharge_quota') {
if ($params['price'] <= 0) return app('json')->fail('售价必须大于0');
if ($params['give_money'] < 0) return app('json')->fail('赠送不能小于0');
}
$this->services->checkSeckillTime($services, $gid, $params);
$this->checkSign($services, $gid, $params);
$fields = json_decode($group['fields'], true) ?? [];
@ -175,6 +179,11 @@ class SystemGroupData extends AuthController
$groupData = $this->services->get($id);
$fields = $services->getValueFields((int)$groupData["gid"]);
$params = request()->post();
$group = $services->getOne(['id' => $params['gid']], 'id,config_name,fields');
if ($group && $group['config_name'] == 'user_recharge_quota') {
if ($params['price'] <= 0) return app('json')->fail('售价必须大于0');
if ($params['give_money'] < 0) return app('json')->fail('赠送不能小于0');
}
$this->services->checkSeckillTime($services, $groupData["gid"], $params, $id);
$this->checkSign($services, $groupData["gid"], $params);
$value = [];
@ -231,7 +240,6 @@ class SystemGroupData extends AuthController
}
/**
* 检查签到配置
* @param SystemGroupServices $services

View File

@ -81,12 +81,12 @@ class SystemRole extends AuthController
$data['rules'] = implode(',', $data['rules']);
if ($id) {
if (!$this->services->update($id, $data)) return app('json')->fail(100007);
$this->services->cacheDriver()->clear();
CacheService::clear();
return app('json')->success(100001);
} else {
$data['level'] = $this->adminInfo['level'] + 1;
if (!$this->services->save($data)) return app('json')->fail(400223);
$this->services->cacheDriver()->clear();
CacheService::clear();
return app('json')->success(400222);
}
}
@ -124,7 +124,7 @@ class SystemRole extends AuthController
if (!$this->services->delete($id))
return app('json')->fail(100008);
else {
$this->services->cacheDriver()->clear();
CacheService::clear();
return app('json')->success(100002);
}
}
@ -146,7 +146,7 @@ class SystemRole extends AuthController
}
$role->status = $status;
if ($role->save()) {
$this->services->cacheDriver()->clear();
CacheService::clear();
return app('json')->success(100001);
} else {
return app('json')->fail(100007);

View File

@ -16,6 +16,7 @@ namespace app\adminapi\controller\v1\setting;
use app\adminapi\controller\AuthController;
use app\services\system\SystemRouteServices;
use crmeb\services\CacheService;
use think\facade\App;
/**
@ -104,6 +105,8 @@ class SystemRoute extends AuthController
['method', ''],
['type', 0],
['app_name', ''],
['query', []],
['header', []],
['request', []],
['response', []],
['request_example', []],
@ -129,7 +132,7 @@ class SystemRoute extends AuthController
$data['add_time'] = date('Y-m-d H:i:s');
$this->services->save($data);
}
$this->services->cacheDriver()->clear();
CacheService::clear();
return app('json')->success($id ? 100001 : 100021);
}
@ -163,6 +166,4 @@ class SystemRoute extends AuthController
return app('json')->success(100002);
}
}

View File

@ -89,6 +89,7 @@ class SystemStorage extends AuthController
['accessKey', ''],
['secretKey', ''],
['appid', ''],
['storageRegion', ''],
]);
$this->services->saveConfig((int)$type, $data);

View File

@ -115,7 +115,7 @@ class SystemFile extends AuthController
$comment = $this->request->param('comment');
$filepath = $this->request->param('filepath');
if (empty($filepath)) {
return app('json')->fail(410087);
return app('json')->fail('文件路径不存在');
}
$res = $this->services->savefile($filepath, $comment);
if ($res) {

View File

@ -43,7 +43,7 @@ class UserLabel extends AuthController
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function index($label_cate = 0)
public function index($label_cate = '')
{
return app('json')->success($this->services->getList(['label_cate' => $label_cate]));
}

View File

@ -129,6 +129,18 @@ Route::group('app', function () {
Route::get('wechat/kefu/record/:id', 'v1.kefu.StoreService/chat_user')->option(['real_name' => '聊天记录']);
//查看对话
Route::get('wechat/kefu/chat_list', 'v1.kefu.StoreService/chat_list')->option(['real_name' => '查看对话']);
//客服自动回复列表
Route::get('kefu/auto_reply/list', 'v1.kefu.StoreServiceAutoReply/autoReplyList')->option(['real_name' => '客服自动回复列表']);
//客服自动回复添加修改表单
Route::get('kefu/auto_reply/form/:id', 'v1.kefu.StoreServiceAutoReply/autoReplyForm')->option(['real_name' => '客服自动回复添加修改表单']);
//客服自动回复添加修改保存
Route::post('kefu/auto_reply/save/:id', 'v1.kefu.StoreServiceAutoReply/autoReplySave')->option(['real_name' => '客服自动回复添加修改保存']);
//客服自动回复修改状态
Route::put('kefu/auto_reply/status/:id/:status', 'v1.kefu.StoreServiceAutoReply/autoReplyStatus')->option(['real_name' => '客服自动回复修改状态']);
//客服自动回复删除
Route::delete('kefu/auto_reply/del/:id', 'v1.kefu.StoreServiceAutoReply/autoReplyDel')->option(['real_name' => '客服自动回复删除']);
})->option(['parent' => 'app', 'cate_name' => '客服相关']);
})->middleware([

View File

@ -32,4 +32,4 @@ Route::group(function () {
\app\adminapi\middleware\AdminAuthTokenMiddleware::class,
\app\adminapi\middleware\AdminCheckRoleMiddleware::class,
\app\adminapi\middleware\AdminLogMiddleware::class
])->option(['mark' => 'crud', 'mark_name' => '代码生成']);
])->option(['mark' => 'crud', 'mark_name' => '生成代码路由']);

View File

@ -18,6 +18,8 @@ Route::group('export', function () {
Route::get('user_list', 'v1.export.ExportExcel/userList')->option(['real_name' => '用户列表导出']);
//订单列表
Route::get('order_list', 'v1.export.ExportExcel/orderList')->option(['real_name' => '订单列表导出']);
//发货订单列表
Route::get('order_delivery_list', 'v1.export.ExportExcel/orderDeliveryList')->option(['real_name' => '发货订单列表导出']);
//商品列表
Route::get('product_list', 'v1.export.ExportExcel/productList')->option(['real_name' => '商品列表导出']);
//砍价列表

View File

@ -198,6 +198,20 @@ Route::group('marketing', function () {
Route::post('lottery/record/deliver', 'v1.marketing.lottery.LuckLotteryRecord/deliver')->option(['real_name' => '抽奖中奖发货、备注处理']);
})->option(['parent' => 'marketing', 'cate_name' => '抽奖活动']);
/** 每日签到 */
Route::group(function () {
//签到奖励列表
Route::get('sign/rewards', 'v1.marketing.SignRewards/index')->option(['real_name' => '签到奖励列表']);
//添加签到奖励
Route::get('sign/add_rewards', 'v1.marketing.SignRewards/addRewards')->option(['real_name' => '添加签到奖励']);
//编辑签到奖励
Route::get('sign/edit_rewards/:id', 'v1.marketing.SignRewards/editRewards')->option(['real_name' => '保存签到奖励']);
//保存签到奖励
Route::post('sign/save_rewards/:id', 'v1.marketing.SignRewards/saveRewards')->option(['real_name' => '保存签到奖励']);
//删除签到奖励
Route::delete('sign/del_rewards/:id', 'v1.marketing.SignRewards/delRewards')->option(['real_name' => '删除签到奖励']);
})->option(['parent' => 'marketing', 'cate_name' => '每日签到']);
})->middleware([
\app\http\middleware\AllowOriginMiddleware::class,
\app\adminapi\middleware\AdminAuthTokenMiddleware::class,

View File

@ -34,6 +34,8 @@ Route::group('order', function () {
Route::put('update/:id', 'v1.order.StoreOrder/update')->name('StoreOrderUpdate')->option(['real_name' => '修改订单']);
//确认收货
Route::put('take/:id', 'v1.order.StoreOrder/take_delivery')->name('StoreOrderTakeDelivery')->option(['real_name' => '确认收货']);
//批量发货
Route::get('delivery/import_express', 'v1.order.StoreOrder/importExpress')->name('importExpress')->option(['real_name' => '批量发货']);
//发送货
Route::put('delivery/:id', 'v1.order.StoreOrder/update_delivery')->name('StoreOrderUpdateDelivery')->option(['real_name' => '订单发送货']);
//获取商家寄件金额

View File

@ -39,6 +39,8 @@ Route::group(function () {
//扫码上传图片
Route::post('image/scan_upload', 'PublicController/scanUpload')->option(['real_name' => '扫码上传图片']);
//路由导入
Route::get('route/import_api', 'PublicController/import')->option(['real_name' => '路由导入']);
})->middleware(AllowOriginMiddleware::class)->option(['mark' => 'login', 'mark_name' => '登录相关']);

View File

@ -174,6 +174,18 @@ Route::group('system', function () {
Route::get('crud/menus', 'v1.setting.SystemCrud/getMenus')->option(['real_name' => '获取菜单TREE形数据']);
//获取CRUD文件存放
Route::post('crud/file_path', 'v1.setting.SystemCrud/getFilePath')->option(['real_name' => '获取CRUD文件存放']);
//获取数据字典列表
Route::get('crud/data_dictionary', 'v1.setting.SystemCrud/getDataDictionary')->option(['real_name' => '获取数据字典列表']);
//查看数据字典
Route::get('crud/data_dictionary/:id', 'v1.setting.SystemCrud/getDataDictionaryOne')->option(['real_name' => '查看数据字典']);
//修改或者保存字典数据
Route::post('crud/data_dictionary/[:id]', 'v1.setting.SystemCrud/saveDataDictionary')->option(['real_name' => '修改或者保存字典数据']);
//删除数据字典
Route::delete('crud/data_dictionary/:id', 'v1.setting.SystemCrud/deleteDataDictionary')->option(['real_name' => '删除数据字典']);
//获取可以进行关联的表名
Route::get('crud/association_table', 'v1.setting.SystemCrud/getAssociationTable')->option(['real_name' => '获取可以进行关联的表名']);
//获取表的详细信息
Route::get('crud/association_table/:tableName', 'v1.setting.SystemCrud/getAssociationTableInfo')->option(['real_name' => '获取表的详细信息']);
//删除CRUD
Route::delete('crud/:id', 'v1.setting.SystemCrud/delete')->option(['real_name' => '删除CRUD']);
//查看CRUD

View File

@ -38,7 +38,6 @@ class SystemConfigValidata extends Validate
'store_stock' => 'number',
'store_brokerage_price' => 'float',
'integral_ratio' => 'float|egt:0|elt:1000|regex:float_two',
'integral_max_num' => 'number|egt:0',
'order_give_integral' => 'float|egt:0|elt:1000',
'order_cancel_time' => 'float',
'order_activity_time' => 'float',
@ -52,7 +51,6 @@ class SystemConfigValidata extends Validate
'sign_rule_number' => 'number|gt:0',
'offline_rule_number' => 'number|gt:0',
'order_give_exp' => 'number|egt:0',
'sign_give_exp' => 'number|egt:0',
'invite_user_exp' => 'number|egt:0',
'config_export_to_name' => 'chs|length:2,10',
'config_export_to_tel' => 'mobile|number',
@ -100,8 +98,6 @@ class SystemConfigValidata extends Validate
'integral_ratio.regex' => '400055',
'integral_ratio.egt' => '400056',
'integral_ratio.elt' => '400056',
'integral_max_num.number' => '400057',
'integral_max_num.egt' => '400058',
'order_give_integral.float' => '400059',
'order_give_integral.egt' => '400060',
'order_give_integral.elt' => '400060',
@ -117,8 +113,6 @@ class SystemConfigValidata extends Validate
'offline_rule_number.number' => '400070',
'order_give_exp.number' => '400071',
'order_give_exp.egt' => '400072',
'sign_give_exp.number' => '400073',
'sign_give_exp.egt' => '400074',
'invite_user_exp.number' => '400075',
'invite_user_exp.egt' => '400076',
'config_export_to_name.chs' => '400077',

View File

@ -51,6 +51,8 @@ class PublicController
$data['site_keywords'] = sys_config('site_keywords');
$data['site_description'] = sys_config('site_description');
$data['network_security'] = sys_config('network_security');
$data['network_security_url'] = sys_config('network_security_url');
$data['icp_url'] = sys_config('icp_url');
$logoUrl = sys_config('pc_logo');
if (strstr($logoUrl, 'http') === false && $logoUrl) {
$logoUrl = sys_config('site_url') . $logoUrl;

View File

@ -14,8 +14,6 @@ namespace app\api\controller\v1;
use app\Request;
use app\services\message\notice\SmsService;
use app\services\wechat\WechatServices;
use think\facade\Cache;
use app\jobs\TaskJob;
use think\facade\Config;
use crmeb\services\CacheService;
use app\services\user\LoginServices;
@ -81,7 +79,7 @@ class LoginController
public function verifyCode()
{
$unique = password_hash(uniqid(true), PASSWORD_BCRYPT);
Cache::set('sms.key.' . $unique, 0, 300);
CacheService::set('sms.key.' . $unique, 0, 300);
$time = sys_config('verify_expire_time', 1);
return app('json')->success(['key' => $unique, 'expire_time' => $time]);
}
@ -98,7 +96,7 @@ class LoginController
$key = app('session')->get('captcha.key');
$uni = $request->get('key');
if ($uni) {
Cache::set('sms.key.cap.' . $uni, $key, 300);
CacheService::set('sms.key.cap.' . $uni, $key, 300);
}
return $rep;
}
@ -113,14 +111,14 @@ class LoginController
protected function checkCaptcha($uni, string $code): bool
{
$cacheName = 'sms.key.cap.' . $uni;
if (!Cache::has($cacheName)) {
if (!CacheService::has($cacheName)) {
return false;
}
$key = Cache::get($cacheName);
$key = CacheService::get($cacheName);
$code = mb_strtolower($code, 'UTF-8');
$res = password_verify($code, $key);
if ($res) {
Cache::delete($cacheName);
CacheService::delete($cacheName);
}
return $res;
}
@ -144,13 +142,13 @@ class LoginController
$keyName = 'sms.key.' . $key;
$nowKey = 'sms.' . date('YmdHi');
if (!Cache::has($keyName)) {
if (!CacheService::has($keyName)) {
return app('json')->fail(410003);
}
$total = 1;
if (Cache::has($nowKey)) {
$total = Cache::get($nowKey);
if (CacheService::has($nowKey)) {
$total = CacheService::get($nowKey);
if ($total > Config::get('sms.maxMinuteCount', 20))
return app('json')->success(410006);
}
@ -171,7 +169,7 @@ class LoginController
$smsCode = $this->services->verify($services, $phone, $type, $time, app()->request->ip());
if ($smsCode) {
CacheService::set('code_' . $phone, $smsCode, $time * 60);
Cache::set($nowKey, $total, 61);
CacheService::set($nowKey, $total, 61);
return app('json')->success(410007);
} else {
return app('json')->fail(410008);

View File

@ -37,7 +37,6 @@ use app\Request;
use crmeb\services\CacheService;
use app\services\other\UploadService;
use crmeb\services\workerman\ChannelService;
use think\facade\Cache;
/**
* 公共类
@ -117,6 +116,9 @@ class PublicController
public function getSiteConfig()
{
$data['record_No'] = sys_config('record_No');
$data['icp_url'] = sys_config('icp_url');
$data['network_security'] = sys_config('network_security');
$data['network_security_url'] = sys_config('network_security_url');
return app('json')->success($data);
}
@ -226,7 +228,7 @@ class PublicController
['filename', 'file'],
]);
if (!$data['filename']) return app('json')->fail(100100);
if (Cache::has('start_uploads_' . $request->uid()) && Cache::get('start_uploads_' . $request->uid()) >= 100) return app('json')->fail(100101);
if (CacheService::has('start_uploads_' . $request->uid()) && CacheService::get('start_uploads_' . $request->uid()) >= 100) return app('json')->fail(100101);
$upload = UploadService::init();
$info = $upload->to('store/comment')->validate()->move($data['filename']);
if ($info === false) {
@ -234,12 +236,12 @@ class PublicController
}
$res = $upload->getUploadInfo();
$services->attachmentAdd($res['name'], $res['size'], $res['type'], $res['dir'], $res['thumb_path'], 1, (int)sys_config('upload_type', 1), $res['time'], 3);
if (Cache::has('start_uploads_' . $request->uid()))
$start_uploads = (int)Cache::get('start_uploads_' . $request->uid());
if (CacheService::has('start_uploads_' . $request->uid()))
$start_uploads = (int)CacheService::get('start_uploads_' . $request->uid());
else
$start_uploads = 0;
$start_uploads++;
Cache::set('start_uploads_' . $request->uid(), $start_uploads, 86400);
CacheService::set('start_uploads_' . $request->uid(), $start_uploads, 86400);
$res['dir'] = path_to_url($res['dir']);
if (strpos($res['dir'], 'http') === false) $res['dir'] = $request->domain() . $res['dir'];
return app('json')->success(100009, ['name' => $res['name'], 'url' => $res['dir']]);
@ -686,6 +688,9 @@ class PublicController
$data['yue_pay_status'] = sys_config('yue_pay_status') == 1 && sys_config('balance_func_status') != 0;//余额是否启用
$data['offline_pay_status'] = sys_config('offline_pay_status') == 1;//线下是否启用
$data['friend_pay_status'] = sys_config('friend_pay_status') == 1;//好友是否启用
$data['wechat_auth_switch'] = (int)in_array(1, sys_config('routine_auth_type'));//微信登录开关
$data['phone_auth_switch'] = (int)in_array(2, sys_config('routine_auth_type'));//手机号登录开关
$data['wechat_status'] = sys_config('wechat_appid') != '' && sys_config('wechat_appsecret') != '';//公众号是否配置
return app('json')->success($data);
}
}

View File

@ -18,8 +18,6 @@ use app\services\pay\PayServices;
use app\services\pay\YuePayServices;
use app\services\user\member\MemberCardServices;
use app\services\user\UserServices;
use crmeb\services\CacheService;
use crmeb\services\pay\extend\allinpay\AllinPay;
use app\Request;
/**

View File

@ -9,7 +9,6 @@ use app\services\activity\integral\StoreIntegralOrderServices;
use app\services\activity\integral\StoreIntegralServices;
use app\services\product\sku\StoreProductAttrValueServices;
use app\services\shipping\ExpressServices;
use crmeb\services\CacheService;
class StoreIntegralOrderController
{

View File

@ -14,24 +14,16 @@ use app\Request;
use app\services\pay\PayServices;
use app\services\shipping\ExpressServices;
use app\services\system\admin\SystemAdminServices;
use app\services\user\UserInvoiceServices;
use crmeb\exceptions\ApiException;
use crmeb\exceptions\ApiStatusException;
use crmeb\services\pay\extend\allinpay\AllinPay;
use app\services\activity\{lottery\LuckLotteryServices,
bargain\StoreBargainServices,
combination\StoreCombinationServices,
combination\StorePinkServices,
seckill\StoreSeckillServices
combination\StorePinkServices
};
use app\services\activity\coupon\StoreCouponIssueServices;
use app\services\order\{OtherOrderServices,
use app\services\order\{
StoreCartServices,
StoreOrderCartInfoServices,
StoreOrderComputedServices,
StoreOrderCreateServices,
StoreOrderEconomizeServices,
StoreOrderInvoiceServices,
StoreOrderRefundServices,
StoreOrderServices,
StoreOrderStatusServices,
@ -43,8 +35,12 @@ use app\services\pay\YuePayServices;
use app\services\product\product\StoreProductReplyServices;
use app\services\shipping\ShippingTemplatesServices;
use crmeb\services\CacheService;
use think\facade\Cache;
use Psr\SimpleCache\InvalidArgumentException;
use think\db\exception\DataNotFoundException;
use think\db\exception\DbException;
use think\db\exception\ModelNotFoundException;
use think\facade\Log;
use think\Response;
/**
* 订单控制器
@ -83,7 +79,7 @@ class StoreOrderController
* 获取确认订单页面是否展示快递配送和到店自提
* @param Request $request
* @return mixed
* @throws \Psr\SimpleCache\InvalidArgumentException
* @throws InvalidArgumentException
*/
public function checkShipping(Request $request)
{
@ -96,10 +92,10 @@ class StoreOrderController
* @param Request $request
* @param ShippingTemplatesServices $services
* @return mixed
* @throws \Psr\SimpleCache\InvalidArgumentException
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @throws InvalidArgumentException
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
*/
public function confirm(Request $request, ShippingTemplatesServices $services)
{
@ -154,21 +150,14 @@ class StoreOrderController
/**
* 订单创建
* @param Request $request
* @param StoreBargainServices $bargainServices
* @param StorePinkServices $pinkServices
* @param StoreOrderCreateServices $createServices
* @param StoreSeckillServices $seckillServices
* @param UserInvoiceServices $userInvoiceServices
* @param StoreOrderInvoiceServices $storeOrderInvoiceServices
* @param StoreCombinationServices $combinationServices
* @param $key
* @return \think\Response
* @throws \Psr\SimpleCache\InvalidArgumentException
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @return Response
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
*/
public function create(Request $request, StoreBargainServices $bargainServices, StorePinkServices $pinkServices, StoreOrderCreateServices $createServices, StoreSeckillServices $seckillServices, UserInvoiceServices $userInvoiceServices, StoreOrderInvoiceServices $storeOrderInvoiceServices, StoreCombinationServices $combinationServices, $key)
public function create(Request $request, StoreOrderCreateServices $createServices, $key)
{
if (!$key) return app('json')->fail(100100);
$userInfo = $request->user()->toArray();
@ -220,10 +209,10 @@ class StoreOrderController
* @param Request $request
* @param $orderId
* @param string $type
* @return \think\Response
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @return Response
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
* @author 等风来
* @email 136327134@qq.com
* @date 2023/2/13
@ -243,7 +232,6 @@ class StoreOrderController
* @param OrderPayServices $payServices
* @param YuePayServices $yuePayServices
* @return mixed
* @throws \Psr\SimpleCache\InvalidArgumentException
*/
public function pay(Request $request, StorePinkServices $services, OrderPayServices $payServices, YuePayServices $yuePayServices)
{
@ -310,9 +298,9 @@ class StoreOrderController
* 订单列表
* @param Request $request
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
*/
public function lst(Request $request)
{
@ -339,9 +327,9 @@ class StoreOrderController
* @param StoreOrderEconomizeServices $services
* @param $uni
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
*/
public function detail(Request $request, StoreOrderEconomizeServices $services, $uni)
{
@ -354,9 +342,9 @@ class StoreOrderController
* 代付订单详情
* @param Request $request
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
*/
public function friendDetail(Request $request)
{
@ -419,7 +407,7 @@ class StoreOrderController
* 订单删除
* @param Request $request
* @return mixed
* @throws \Psr\SimpleCache\InvalidArgumentException
* @throws InvalidArgumentException
*/
public function del(Request $request)
{
@ -464,9 +452,9 @@ class StoreOrderController
* @param $uni
* @param string $type
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
*/
public function express(Request $request, StoreOrderCartInfoServices $services, ExpressServices $expressServices, $uni, $type = '')
{
@ -502,7 +490,7 @@ class StoreOrderController
$cartInfo = $services->getCartColunm(['oid' => $order['id']], 'cart_info', 'unique');
$info = [];
$cartNew = [];
foreach ($cartInfo as $k => $cart) {
foreach ($cartInfo as $cart) {
$cart = json_decode($cart, true);
$cartNew['cart_num'] = $cart['cart_num'];
$cartNew['truePrice'] = $cart['truePrice'];
@ -535,8 +523,8 @@ class StoreOrderController
* @param Request $request
* @param StoreOrderCartInfoServices $cartInfoServices
* @param StoreProductReplyServices $replyServices
* @return \think\Response|void
* @throws \Psr\SimpleCache\InvalidArgumentException
* @return Response|void
* @throws InvalidArgumentException
*/
public function comment(Request $request, StoreOrderCartInfoServices $cartInfoServices, StoreProductReplyServices $replyServices)
{
@ -663,9 +651,9 @@ class StoreOrderController
* 获取退货商品列表
* @param Request $request
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
*/
public function refundCartInfoList(Request $request)
{
@ -686,10 +674,10 @@ class StoreOrderController
* @param StoreOrderServices $storeOrderServices
* @param $id
* @return mixed
* @throws \Psr\SimpleCache\InvalidArgumentException
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @throws InvalidArgumentException
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
*/
public function applyRefund(Request $request, StoreOrderRefundServices $services, StoreOrderServices $storeOrderServices, $id)
{
@ -755,9 +743,9 @@ class StoreOrderController
* 订单取消 未支付的订单回退积分,回退优惠券,回退库存
* @param Request $request
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
*/
public function cancel(Request $request)
{
@ -801,7 +789,7 @@ class StoreOrderController
/**
* 商家寄件回调
* @param Request $request
* @return \think\Response
* @return Response
* @author 等风来
* @email 136327134@qq.com
* @date 2023/6/12
@ -809,19 +797,10 @@ class StoreOrderController
public function callBack(Request $request)
{
$data = $request->postMore([
['t', ''],
['sign', ''],
['type', ''],
['data', ''],
]);
\think\facade\Log::error('回调:' . json_encode($data));
$data['data']['id'] = (int)$data['data']['id'];
if (md5(json_encode($data['data']) . $data['t']) != $data['sign']) {
return app('json')->fail('验签失败');
}
$data['data'] = $this->decrypt($data['data'], sys_config('sms_token'));
switch ($data['type']) {
case 'order_success'://下单成功
$update = [
@ -894,4 +873,23 @@ class StoreOrderController
return app('json')->success();
}
/**
* 解密商家寄件回调
* @param string $encryptedData
* @param string $key
* @return false|string
* @author: 吴汐
* @email: 442384644@qq.com
* @date: 2023/8/31
*/
function decrypt(string $encryptedData, string $key)
{
$key = substr($key, 0, 32);
$decodedData = base64_decode($encryptedData);
$iv = substr($decodedData, 0, 16);
$encrypted = substr($decodedData, 16);
$decrypted = openssl_decrypt($encrypted, 'AES-256-CBC', $key, OPENSSL_RAW_DATA, $iv);
return $decrypted;
}
}

View File

@ -5,6 +5,9 @@ namespace app\api\controller\v1\order;
use app\Request;
use app\services\order\StoreOrderRefundServices;
use app\services\order\StoreOrderServices;
use think\db\exception\DataNotFoundException;
use think\db\exception\DbException;
use think\db\exception\ModelNotFoundException;
class StoreOrderRefundController
{
@ -56,9 +59,9 @@ class StoreOrderRefundController
* @param Request $request
* @param $uni
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
*/
public function cancelApply(Request $request, $uni)
{

View File

@ -10,7 +10,6 @@
// +----------------------------------------------------------------------
namespace app\api\controller\v1\publics;
use app\Request;
use app\services\article\ArticleServices;
/**

View File

@ -15,6 +15,9 @@ use app\services\product\product\StoreCategoryServices;
use app\services\product\product\StoreProductReplyServices;
use app\services\product\product\StoreProductServices;
use app\services\user\UserServices;
use think\db\exception\DataNotFoundException;
use think\db\exception\DbException;
use think\db\exception\ModelNotFoundException;
/**
* 商品类
@ -39,9 +42,9 @@ class StoreProductController
* @param Request $request
* @param StoreCategoryServices $services
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
*/
public function lst(Request $request, StoreCategoryServices $services)
{
@ -99,9 +102,9 @@ class StoreProductController
* @param $id
* @param int $type
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
*/
public function detail(Request $request, $id, $type = 0)
{
@ -113,9 +116,9 @@ class StoreProductController
* 为你推荐
* @param Request $request
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
*/
public function product_hot(Request $request)
{
@ -129,9 +132,9 @@ class StoreProductController
* @param Request $request
* @param $type
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
*/
public function groom_list(Request $request, $type)
{
@ -173,9 +176,9 @@ class StoreProductController
* @param Request $request
* @param $id
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
*/
public function reply_list(Request $request, $id)
{

View File

@ -9,6 +9,9 @@ use app\services\agent\DivisionAgentApplyServices;
use app\services\other\AgreementServices;
use app\services\user\UserServices;
use crmeb\services\CacheService;
use think\db\exception\DataNotFoundException;
use think\db\exception\DbException;
use think\db\exception\ModelNotFoundException;
class DivisionController
{
@ -51,9 +54,9 @@ class DivisionController
* 申请详情
* @param Request $request
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
*/
public function applyInfo(Request $request)
{
@ -66,9 +69,9 @@ class DivisionController
* 移动端获取规则
* @param AgreementServices $agreementServices
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
*/
public function getAgentAgreement(AgreementServices $agreementServices)
{
@ -80,9 +83,9 @@ class DivisionController
* 员工列表
* @param Request $request
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
*/
public function getStaffList(Request $request)
{

View File

@ -16,6 +16,9 @@ use app\services\activity\coupon\StoreCouponUserServices;
use app\services\order\OtherOrderServices;
use app\services\other\AgreementServices;
use app\services\user\member\MemberCardServices;
use think\db\exception\DataNotFoundException;
use think\db\exception\DbException;
use think\db\exception\ModelNotFoundException;
/** 会员卡
* Class MemberCardController
@ -40,9 +43,9 @@ class MemberCardController
* 会员卡主页数据接口
* @param Request $request
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
*/
public function index(Request $request)
{
@ -91,9 +94,9 @@ class MemberCardController
* 会员券接口
* @param Request $request
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
*/
public function memberCouponList(Request $request)
{

View File

@ -11,8 +11,6 @@
namespace app\api\controller\v1\user;
use app\Request;
use app\services\user\member\MemberCardServices;
use app\services\user\UserServices;
use app\services\user\UserSignServices;
/**
@ -35,31 +33,15 @@ class UserSignController
/**
* 签到 配置
* @param Request $request
* @param UserServices $userServices
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function sign_config(Request $request, UserServices $userServices)
public function sign_config(Request $request)
{
$signConfig = sys_data('sign_day_num') ?? [];
// $uid = (int)$request->uid();
// $user = $userServices->getUserInfo($uid);
// //是否是付费会员
// if ($user['is_money_level'] > 0) {
// //看是否开启签到积分翻倍奖励
// /** @var MemberCardServices $memberCardService */
// $memberCardService = app()->make(MemberCardServices::class);
// $sign_rule_number = $memberCardService->isOpenMemberCard('sign');
// if ($sign_rule_number) {
// foreach ($signConfig as &$value) {
// $value['sign_num'] = (int)$sign_rule_number * $value['sign_num'];
// }
// }
// }
return app('json')->success($signConfig);
$uid = (int)$request->uid();
return app('json')->success($this->services->signConfig($uid));
}
/**
@ -125,4 +107,20 @@ class UserSignController
return app('json')->success($this->services->getSignMonthList($uid));
}
/**
* 用户设置签到提醒
* @param Request $request
* @param $status
* @return \think\Response
* @author: 吴汐
* @email: 442384644@qq.com
* @date: 2023/8/9
*/
public function sign_remind(Request $request, $status)
{
$uid = (int)$request->uid();
$this->services->setSignRemind($uid, $status);
return app('json')->success(100014);
}
}

View File

@ -42,6 +42,7 @@ class WechatController
{
return $this->services->serve();
}
/**
* 微信小程序公众号服务
* @return \think\Response
@ -74,28 +75,6 @@ class WechatController
return app('json')->success($this->services->config($request->get('url')));
}
/**
* 公众号授权登陆
* @param Request $request
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
*/
public function auth(Request $request)
{
[$spreadId, $login_type] = $request->getMore([
[['spread', 'd'], 0],
['login_type', ''],
], true);
$token = $this->services->auth($spreadId, $login_type);
if ($token && isset($token['key'])) {
return app('json')->success(410022, $token);
} else if ($token) {
return app('json')->success(410001, ['userInfo' => $token['userInfo']]);
} else
return app('json')->fail(410019);
}
/**
* App微信登陆
* @param Request $request

View File

@ -66,7 +66,7 @@ class StoreCartController
{
list($product_id, $num, $unique, $type) = $request->postMore([
['product_id', 0],
['num', 0],
['num', 1],
['unique', ''],
['type', -1]
], true);

View File

@ -35,24 +35,37 @@ class AuthController
}
/**
* 静默授权
* 返回用户信息的缓存key,返回是否强制绑定手机号
* @param $code
* @param string $spread_code
* @param string $spread_spid
* @return mixed
* @return \think\Response
* @author: 吴汐
* @email: 442384644@qq.com
* @date: 2023/8/12
*/
public function authType($code, $spread_code = '', $spread_spid = '')
{
$data = $this->services->authType($code, $spread_code, $spread_spid);
return app('json')->success($data);
}
/**
* 根据缓存获取token
* @param $key
* @return \think\Response
* @throws \Psr\SimpleCache\InvalidArgumentException
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author: 吴汐
* @email: 442384644@qq.com
* @date: 2023/8/12
*/
public function silenceAuth($code, $spread_code = '', $spread_spid = '')
public function authLogin($key)
{
$token = $this->services->silenceAuth($code, $spread_code, $spread_spid);
if ($token && isset($token['key'])) {
return app('json')->success(410022, $token);
} else if ($token) {
return app('json')->success(410001, ['token' => $token['token'], 'expires_time' => $token['params']['exp'], 'new_user' => $token['new_user']]);
} else
return app('json')->fail(410019);
$data = $this->services->authLogin($key);
return app('json')->success($data);
}
/**
@ -72,13 +85,46 @@ class AuthController
{
if (!$code || !$iv || !$encryptedData)
return app('json')->fail(100100);
$token = $this->services->authBindingPhone($code, $iv, $encryptedData, $spread_code, $spread_spid, $key);
if ($token) {
return app('json')->success(410001, $token);
$data = $this->services->authBindingPhone($code, $iv, $encryptedData, $spread_code, $spread_spid, $key);
if ($data) {
return app('json')->success(410001, $data);
} else
return app('json')->fail(410019);
}
/**
* 小程序手机号登录
* @param string $key
* @param string $phone
* @param string $captcha
* @param string $spread_code
* @param string $spread_spid
* @param string $code
* @return \think\Response
* @throws \Psr\SimpleCache\InvalidArgumentException
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author: 吴汐
* @email: 442384644@qq.com
* @date: 2023/8/12
*/
public function phoneLogin($key = '', $phone = '', $captcha = '', $spread_code = '', $spread_spid = '', $code = '')
{
//验证验证码
$verifyCode = CacheService::get('code_' . $phone);
if (!$verifyCode)
return app('json')->fail(410009);
$verifyCode = substr($verifyCode, 0, 6);
if ($verifyCode != $captcha) {
CacheService::delete('code_' . $phone);
return app('json')->fail(410010);
}
CacheService::delete('code_' . $phone);
$data = $this->services->phoneLogin($key, $phone, $spread_code, $spread_spid, $code);
return app('json')->success($data);
}
/**
* 小程序绑定手机号
* @param string $code
@ -95,103 +141,4 @@ class AuthController
$this->services->bindingPhone($code, $iv, $encryptedData);
return app('json')->success(410016);
}
/** 以下方法该版本暂未使用 */
/**
* 小程序授权登录
* @param Request $request
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
*/
public function auth(Request $request)
{
[$code, $spid, $spread, $iv, $encryptedData] = $request->postMore([
['code', ''],
['spread_spid', 0],
['spread_code', ''],
['iv', ''],
['encryptedData', ''],
], true);
$token = $this->services->newAuth($code, $spid, $spread, $iv, $encryptedData);
if ($token) {
if (isset($token['key']) && $token['key']) {
return app('json')->success(410022, $token);
} else {
return app('json')->success(410001, ['token' => $token['token'], 'userInfo' => $token['userInfo'], 'expires_time' => $token['params']['exp']]);
}
} else
return app('json')->fail(410019);
}
/**
* 静默授权 不登录
* @param $code
* @param string $spread_code
* @param string $spread_spid
* @return mixed
* @throws \Psr\SimpleCache\InvalidArgumentException
*/
public function silenceAuthNoLogin($code, $spread_code = '', $spread_spid = '')
{
$token = $this->services->silenceAuthNoLogin($code, $spread_code, $spread_spid);
if ($token && isset($token['auth_login'])) {
return app('json')->success(410023);
} else if ($token) {
return app('json')->success(410001, ['token' => $token['token'], 'userInfo' => $token['userInfo'], 'expires_time' => $token['params']['exp']]);
} else
return app('json')->fail(410019);
}
/**
* 静默授权
* @param string $code
* @param string $spread_code
* @param string $spread_spid
* @param string $phone
* @param string $captcha
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
*/
public function silenceAuthBindingPhone($code = '', $spread_code = '', $spread_spid = '', $phone = '', $captcha = '')
{
//验证验证码
$verifyCode = CacheService::get('code_' . $phone);
if (!$verifyCode)
return app('json')->fail(410009);
$verifyCode = substr($verifyCode, 0, 6);
if ($verifyCode != $captcha) {
CacheService::delete('code_' . $phone);
return app('json')->fail(410010);
}
CacheService::delete('code_' . $phone);
$token = $this->services->silenceAuthBindingPhone($code, $spread_code, $spread_spid, $phone);
if ($token) {
return app('json')->success(410001, ['token' => $token['token'], 'expires_time' => $token['params']['exp'], 'new_user' => $token['new_user']]);
} else
return app('json')->fail(410019);
}
/**
* 更新用户信息
* @param Request $request
* @param $userInfo
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function updateInfo(Request $request, $userInfo)
{
if (!$userInfo) {
return app('json')->fail(100100);
}
$uid = (int)$request->uid();
$re = $this->services->updateUserInfo($uid, $userInfo);
if ($re) {
return app('json')->success(100012);
} else
return app('json')->fail(100013);
}
}

View File

@ -32,75 +32,38 @@ class WechatController
}
/**
* 公众号授权登陆
* @param Request $request
* @return mixed
* 公众号授权登录,返回token
* @param $spread
* @return \think\Response
* @throws \Psr\SimpleCache\InvalidArgumentException
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
* @author: 吴汐
* @email: 442384644@qq.com
* @date: 2023/8/12
*/
public function auth(Request $request)
public function authLogin($spread = '')
{
[$spreadId, $login_type] = $request->getMore([
[['spread', 'd'], 0],
['login_type', 'wechat'],
], true);
$token = $this->services->newAuth($spreadId, $login_type);
if ($token && isset($token['key'])) {
return app('json')->success(410022, $token);
} else if ($token) {
return app('json')->success(410001, ['token' => $token['token'], 'userInfo' => $token['userInfo'], 'expires_time' => $token['params']['exp']]);
} else
return app('json')->fail(410019);
$data = $this->services->authLogin($spread);
return app('json')->success($data);
}
/**
* 微信公众号静默授权
* @param string $spread
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
*/
public function silenceAuth($spread = '')
{
$token = $this->services->silenceAuth($spread);
if ($token && isset($token['key'])) {
return app('json')->success(410022, $token);
} else if ($token) {
return app('json')->success(410001, ['token' => $token['token'], 'expires_time' => $token['params']['exp']]);
} else
return app('json')->fail(410019);
}
/**
* 微信公众号静默授权
* @param string $spread
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
*/
public function silenceAuthNoLogin($spread = '')
{
$token = $this->services->silenceAuthNoLogin($spread);
if ($token && isset($token['auth_login'])) {
return app('json')->success(410023, $token);
} else if ($token) {
return app('json')->success(410001, ['token' => $token['token'], 'userInfo' => $token['userInfo'], 'expires_time' => $token['params']['exp']]);
} else
return app('json')->fail(410019);
}
/**
* 静默授权 手机号直接注册登录
* 公众号授权绑定手机号
* @param string $key
* @param string $phone
* @param string $captcha
* @return mixed
* @return \think\Response
* @throws \Psr\SimpleCache\InvalidArgumentException
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author: 吴汐
* @email: 442384644@qq.com
* @date: 2023/8/12
*/
public function silenceAuthBindingPhone($key = '', $phone = '', $captcha = '')
public function authBindingPhone($key = '', $phone = '', $captcha = '')
{
//验证验证码
$verifyCode = CacheService::get('code_' . $phone);
@ -112,10 +75,7 @@ class WechatController
return app('json')->fail(410010);
}
CacheService::delete('code_' . $phone);
$token = $this->services->silenceAuthBindingPhone($key, $phone);
if ($token) {
return app('json')->success(410001, $token);
} else
return app('json')->fail(410019);
$data = $this->services->authBindingPhone($key, $phone);
return app('json')->success($data);
}
}

View File

@ -157,6 +157,7 @@ Route::group(function () {
Route::get('sign/config', 'v1.user.UserSignController/sign_config')->name('signConfig')->option(['real_name' => '签到配置']);//签到配置
Route::get('sign/list', 'v1.user.UserSignController/sign_list')->name('signList')->option(['real_name' => '签到列表']);//签到列表
Route::get('sign/month', 'v1.user.UserSignController/sign_month')->name('signIntegral')->option(['real_name' => '签到列表(年月)']);//签到列表(年月)
Route::get('sign/remind/:status', 'v1.user.UserSignController/sign_remind')->name('signRemind')->option(['real_name' => '签到提醒开关']);//签到列表(年月)
Route::post('sign/user', 'v1.user.UserSignController/sign_user')->name('signUser')->option(['real_name' => '签到用户信息']);//签到用户信息
Route::post('sign/integral', 'v1.user.UserSignController/sign_integral')->name('signIntegral')->option(['real_name' => '公众号授权登录'])->middleware(BlockerMiddleware::class);//签到
})->option(['mark' => 'sign', 'mark_name' => '签到']);

View File

@ -18,30 +18,22 @@ Route::group('v2', function () {
//无需授权接口
Route::group(function () {
Route::group(function () {
//公众号授权登录
Route::get('wechat/auth', 'v2.wechat.WechatController/auth')->option(['real_name' => '公众号授权登录']);
//小程序授权
Route::get('wechat/routine_auth', 'v2.wechat.AuthController/auth')->option(['real_name' => '小程序授权']);
//小程序静默授权
Route::get('wechat/silence_auth', 'v2.wechat.AuthController/silenceAuthNoLogin')->option(['real_name' => '小程序静默授权']);
//小程序静默授权登陆
Route::get('wechat/silence_auth_login', 'v2.wechat.AuthController/silenceAuth')->option(['real_name' => '小程序静默授权登陆']);
//公众号静默授权
Route::get('wechat/wx_silence_auth', 'v2.wechat.WechatController/silenceAuthNoLogin')->option(['real_name' => '公众号静默授权']);
//公众号静默授权登陆
Route::get('wechat/wx_silence_auth_login', 'v2.wechat.WechatController/silenceAuth')->option(['real_name' => '公众号静默授权登陆']);
//是否强制绑定手机号
Route::get('bind_status', 'v2.PublicController/bindPhoneStatus')->option(['real_name' => '是否强制绑定手机号']);
//小程序登录页面自动加载,返回用户信息的缓存key,返回是否强制绑定手机号
Route::get('routine/auth_type', 'v2.wechat.AuthController/authType')->option(['real_name' => '小程序页面登录类型']);
//小程序授权登录,返回token
Route::get('routine/auth_login', 'v2.wechat.AuthController/authLogin')->option(['real_name' => '小程序授权登录']);
//小程序授权绑定手机号
Route::post('auth_bindind_phone', 'v2.wechat.AuthController/authBindingPhone')->option(['real_name' => '小程序授权绑定手机号']);
Route::post('routine/auth_binding_phone', 'v2.wechat.AuthController/authBindingPhone')->option(['real_name' => '小程序授权绑定手机号']);
//小程序手机号直接登录
Route::post('routine/phone_login', 'v2.wechat.AuthController/phoneLogin')->option(['real_name' => '手机号直接登录']);
//小程序授权后绑定手机号
Route::post('routine/binding_phone', 'v2.wechat.AuthController/BindingPhone')->option(['real_name' => '小程序授权后绑定手机号']);
//小程序手机号登录直接绑定
Route::post('phone_silence_auth', 'v2.wechat.AuthController/silenceAuthBindingPhone')->option(['real_name' => '小程序手机号登录直接绑定']);
//微信手机号登录直接绑定
Route::post('phone_wx_silence_auth', 'v2.wechat.WechatController/silenceAuthBindingPhone')->option(['real_name' => '微信手机号登录直接绑定']);
//公众号授权登录,返回token
Route::get('wechat/auth_login', 'v2.wechat.WechatController/authLogin')->option(['real_name' => '公众号授权登录']);
//公众号授权绑定手机号
Route::post('wechat/auth_binding_phone', 'v2.wechat.WechatController/authBindingPhone')->option(['real_name' => '小程序授权绑定手机号']);
})->option(['mark' => 'wechat_auto', 'mark_name' => '微信授权']);
Route::group(function () {
@ -59,8 +51,6 @@ Route::group('v2', function () {
Route::post('reset_cart', 'v2.store.StoreCartController/resetCart')->name('resetCart')->option(['real_name' => '清除购物车', 'mark' => 'cart', 'mark_name' => '购物车']);
Route::get('new_coupon', 'v2.store.StoreCouponsController/getNewCoupon')->name('getNewCoupon')->option(['real_name' => '获取新人券', 'mark' => 'coupons', 'mark_name' => '优惠券']);//获取新人券
// Route::get('get_today_coupon', 'v2.store.StoreCouponsController/getTodayCoupon');//新优惠券弹窗接口
Route::post('user/user_update', 'v2.wechat.AuthController/updateInfo')->option(['real_name' => '修改用户信息', 'mark' => 'user', 'mark_name' => '用户']);
Route::post('order/product_coupon/:orderId', 'v2.store.StoreCouponsController/getOrderProductCoupon')->option(['real_name' => '获取订单下管理的优惠券', 'mark' => 'coupons', 'mark_name' => '优惠券']);
Route::get('user/service/record', 'v2.user.StoreService/record')->name('userServiceRecord')->option(['real_name' => '客服聊天记录', 'parent' => 'user', 'cate_name' => '客服']);//客服聊天记录
Route::get('cart_list', 'v2.store.StoreCartController/getCartList')->option(['real_name' => '获取购物车列表', 'mark' => 'cart', 'mark_name' => '购物车']);

View File

@ -507,6 +507,9 @@ if (!function_exists('image_to_base64')) {
$avatar = str_replace('https', 'http', $avatar);
try {
$url = parse_url($avatar);
if ($url['scheme'] . '://' . $url['host'] == sys_config('site_url')) {
return "data:image/jpeg;base64," . base64_encode(file_get_contents(public_path() . substr($url['path'], 1)));
}
$url = $url['host'];
$header = [
'User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:45.0) Gecko/20100101 Firefox/45.0',
@ -953,7 +956,7 @@ if (!function_exists('getLang')) {
//获取接口传入的语言类型
if (!$range = $request->header('cb-lang')) {
//没有传入则使用系统默认语言显示
$range = $langTypeServices->cacheDriver()->remember('range_name', function () use ($langTypeServices) {
$range = CacheService::remember('range_name', function () use ($langTypeServices) {
return $langTypeServices->value(['is_default' => 1], 'file_name');
});
if (!$range) {
@ -967,7 +970,7 @@ if (!function_exists('getLang')) {
}
// 获取type_id
$typeId = $langCountryServices->cacheDriver()->remember('type_id_' . $range, function () use ($langCountryServices, $range) {
$typeId = CacheService::remember('type_id_' . $range, function () use ($langCountryServices, $range) {
return $langCountryServices->value(['code' => $range], 'type_id') ?: 1;
}, 3600);

View File

@ -92,4 +92,22 @@ class ArticleCategoryDao extends BaseDao
{
return $this->search($where)->order('sort desc,id desc')->column('title,pid,id,is_del,status');
}
/**
* 树形列表
* @param array $where
* @param array $field
* @return array
* @throws \ReflectionException
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author: 吴汐
* @email: 442384644@qq.com
* @date: 2023/9/7
*/
public function getTreeList(array $where, array $field)
{
return $this->search($where)->field($field)->order('sort desc,id desc')->select()->toArray();
}
}

View File

@ -940,6 +940,21 @@ class StoreOrderDao extends BaseDao
})->field(['order_id', 'real_name', 'status', 'pay_price', 'total_num', 'add_time', 'pay_time', 'paid'])->order('add_time desc')->select()->toArray();
}
/**
* 秒杀订单统计总数
* @param $id
* @param $where
* @return int
* @throws \ReflectionException
* @author: 吴汐
* @email: 442384644@qq.com
* @date: 2023/8/31
*/
public function seckillCount($id, $where)
{
return $this->search($where)->where('seckill_id', $id)->count();
}
/**
* 砍价订单统计
* @param $id
@ -959,6 +974,21 @@ class StoreOrderDao extends BaseDao
})->field(['uid', 'order_id', 'real_name', 'status', 'pay_price', 'total_num', 'add_time', 'pay_time', 'paid'])->order('add_time desc')->select()->toArray();
}
/**
* 砍价订单统计数量
* @param $id
* @param $where
* @return int
* @throws \ReflectionException
* @author: 吴汐
* @email: 442384644@qq.com
* @date: 2023/8/31
*/
public function bargainStatisticsOrderCount($id, $where)
{
return $this->search($where)->where('bargain_id', $id)->count();
}
/**
* 拼团订单统计
* @param $id
@ -978,16 +1008,62 @@ class StoreOrderDao extends BaseDao
})->field(['uid', 'order_id', 'real_name', 'status', 'pay_price', 'total_num', 'add_time', 'pay_time', 'paid'])->order('add_time desc')->select()->toArray();
}
/**
* 拼团订单统计数量
* @param $id
* @param $where
* @param int $page
* @param int $limit
* @return int
* @throws \ReflectionException
* @author: 吴汐
* @email: 442384644@qq.com
* @date: 2023/8/31
*/
public function combinationStatisticsCount($id, $where)
{
return $this->search($where)->where('combination_id', $id)->count();
}
/**
* 查找待收货的子订单
* @param int $pid
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author: 吴汐
* @email: 442384644@qq.com
* @date: 2023/8/31
*/
public function getSubOrderNotSendList(int $pid)
{
return $this->getModel()->where('pid', $pid)->where('status', 1)->select()->toArray();
}
/**
* 判断订单是否全部发货
* @param int $pid
* @param int $order_id
* @return int
* @author: 吴汐
* @email: 442384644@qq.com
* @date: 2023/8/31
*/
public function getSubOrderNotSend(int $pid, int $order_id)
{
return $this->getModel()->where('pid', $pid)->where('status', 0)->where('id', '<>', $order_id)->count();
}
/**
* 判断是否存在子未收货子订单
* @param int $pid
* @param int $order_id
* @return int
* @author: 吴汐
* @email: 442384644@qq.com
* @date: 2023/8/31
*/
public function getSubOrderNotTake(int $pid, int $order_id)
{
return $this->getModel()->where('pid', $pid)->where('status', 1)->where('id', '<>', $order_id)->count();

View File

@ -0,0 +1,40 @@
<?php
/**
* +----------------------------------------------------------------------
* | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
* +----------------------------------------------------------------------
* | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
* +----------------------------------------------------------------------
* | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
* +----------------------------------------------------------------------
* | Author: CRMEB Team <admin@crmeb.com>
* +----------------------------------------------------------------------
*/
namespace app\dao\system;
use app\dao\BaseDao;
use app\model\system\SystemCrudData;
/**
* Class SystemCrudDataDao
* @author 等风来
* @email 136327134@qq.com
* @date 2023/7/28
* @package app\dao\system
*/
class SystemCrudDataDao extends BaseDao
{
/**
* @return string
* @author 等风来
* @email 136327134@qq.com
* @date 2023/7/28
*/
protected function setModel(): string
{
return SystemCrudData::class;
}
}

View File

@ -36,10 +36,15 @@ class SystemNotificationDao extends BaseDao
* 获取列表
* @param array $where
* @param string $field
* @param int $page
* @param int $limit
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author: 吴汐
* @email: 442384644@qq.com
* @date: 2023/8/16
*/
public function getList(array $where, string $field = '*', int $page = 0, $limit = 0)
{
@ -48,5 +53,38 @@ class SystemNotificationDao extends BaseDao
})->order('id asc')->select()->toArray();
}
/**
* 获取tempid
* @param $type
* @return array
* @author: 吴汐
* @email: 442384644@qq.com
* @date: 2023/8/16
*/
public function getTempId($type)
{
$whereField = 'is_' . $type;
$field = $type . '_tempid';
return array_unique($this->getModel()->where($whereField, 1)->where($field, '<>', '')->column($field));
}
/**
* 获取tempkey
* @param $type
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author: 吴汐
* @email: 442384644@qq.com
* @date: 2023/8/16
*/
public function getTempKey($type)
{
$whereField = 'is_' . $type;
$field = $type . '_tempkey';
$content = $type . '_content,name';
return $this->getModel()->where($whereField, 1)->column($content, $field);
}
}

View File

@ -0,0 +1,26 @@
<?php
namespace app\dao\system;
use app\dao\BaseDao;
use app\model\system\SystemSignReward;
/**
* @author: 吴汐
* @email: 442384644@qq.com
* @date: 2023/7/28
*/
class SystemSignRewardDao extends BaseDao
{
/**
* 设置模型
* @return string
* @author: 吴汐
* @email: 442384644@qq.com
* @date: 2023/7/28
*/
protected function setModel(): string
{
return SystemSignReward::class;
}
}

View File

@ -68,7 +68,7 @@ class SystemConfigDao extends BaseDao
*/
public function getConfigList(array $where, int $page, int $limit)
{
return $this->search($where)->page($page, $limit)->order('sort desc,id desc')->select()->toArray();
return $this->search($where)->page($page, $limit)->order('sort desc,id asc')->select()->toArray();
}
/**

View File

@ -63,4 +63,47 @@ class UserSignDao extends BaseDao
{
return $this->search($where)->field($field)->order('id desc')->group($group)->page($page, $limit)->select()->toArray();
}
/**
* 获取周或者月的累积签到次数
* @param $type
* @param $uid
* @return int
* @author: 吴汐
* @email: 442384644@qq.com
* @date: 2023/8/1
*/
public function getCumulativeDays($type, $uid)
{
return $this->getModel()->where('uid', $uid)->where(function ($query) use ($type) {
if ($type == 1) {
$query->whereWeek('add_time');
} elseif($type == 0) {
$query->whereMonth('add_time');
}
})->count();
}
/**
* 获取本周或者本月的签到列表
* @param $type
* @param $uid
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author: 吴汐
* @email: 442384644@qq.com
* @date: 2023/8/8
*/
public function getUserSignList($type, $uid): array
{
return $this->getModel()->where('uid', $uid)->where(function ($query) use ($type) {
if ($type == 1) {
$query->whereWeek('add_time');
} else {
$query->whereMonth('add_time');
}
})->order('id asc')->select()->toArray();
}
}

View File

@ -42,11 +42,11 @@ class WechatReplyDao extends BaseDao
public function getKey($key)
{
$res = $this->getModel()->whereIn('id', function ($query) use ($key) {
$query->name('wechat_key')->where('keys', $key)->field(['reply_id'])->select();
$query->name('wechat_key')->where('keys', $key)->where('key_type', 0)->field(['reply_id'])->select();
})->where('status', '1')->find();
if (empty($res)) {
$res = $this->getModel()->whereIn('id', function ($query) use ($key) {
$query->name('wechat_key')->where('keys', 'default')->field(['reply_id'])->select();
$query->name('wechat_key')->where('keys', 'default')->where('key_type', 0)->field(['reply_id'])->select();
})->where('status', '1')->find();
}
return $res;

View File

@ -80,6 +80,8 @@ class WechatReplyKeyDao extends BaseDao
$query->where($this->joinAlis . '.keys', 'LIKE', "%$where[key]%");
})->when(isset($where['type']) && $where['type'], function ($query) use ($where) {
$query->where($this->alias . '.type', $where['type']);
})->when(isset($where['key_type']) && $where['key_type'] !== '', function ($query) use ($where) {
$query->where($this->joinAlis . '.key_type', $where['key_type']);
})->where($this->joinAlis . '.keys', '<>', 'subscribe')
->where($this->joinAlis . '.keys', '<>', 'default');
}

View File

@ -9,7 +9,13 @@
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
// 事件定义文件
/** 事件定义文件
* 调用事件示例:
* @param mixed $event 事件名(或者类名)
* @param mixed $args 参数
* event($event,$args);
* event('OrderCreateAfterListener',$order);
*/
return [
'bind' => [

View File

@ -0,0 +1,43 @@
<?php
namespace app\jobs;
use app\services\order\StoreOrderDeliveryServices;
use crmeb\basic\BaseJobs;
use crmeb\traits\QueueTrait;
use think\facade\Log;
class OrderExpressJob extends BaseJobs
{
use QueueTrait;
public function doJob($expressInfo)
{
$id = $expressInfo['id'];
$data = [
'type' => 1,
'delivery_name' => $expressInfo['delivery_name'],
'delivery_code' => $expressInfo['delivery_code'],
'delivery_id' => $expressInfo['delivery_id'],
'express_record_type' => 1,
'express_temp_id' => '',
'to_name' => '',
'to_tel' => '',
'to_addr' => '',
'sh_delivery_name' => '',
'sh_delivery_id' => '',
'sh_delivery_uid' => '',
'fictitious_content' => '',
'cart_ids' => [],
'day_type' => 0,
'pickup_time' => [],
'service_type' => '',
];
try {
app()->make(StoreOrderDeliveryServices::class)->splitDelivery($id, $data, false);
} catch (\Throwable $e) {
Log::error('订单ID' . $id . '发货失败,失败原因:' . $e->getMessage());
}
return true;
}
}

View File

@ -37,7 +37,7 @@ class TemplateJob extends BaseJobs
* @param $color
* @return bool|mixed
*/
public function doJob($type, $openid, $tempCode, $data, $link, $color)
public function doJob($type, $openid, $tempId, $data, $link, $color)
{
try {
if (!$openid) return true;
@ -56,15 +56,7 @@ class TemplateJob extends BaseJobs
}
$template->url($link);
}
//判断小程序还是公众号,获取数据id
$is_type = $type == 'wechat' ? 'is_wechat' : 'is_routine';
$key = $is_type == 'is_wechat' ? 'wechat_' . $tempCode : 'routine_' . $tempCode;
$tempid = CacheService::remember($key, function () use ($type, $tempCode, $is_type) {
/** @var SystemNotificationServices $notifyServices */
$notifyServices = app()->make(SystemNotificationServices::class);
return $notifyServices->getNotInfo(['type' => $is_type, 'mark' => $tempCode])['tempid'];
});
return $template->send($tempid, $data);
return $template->send($tempId, $data);
} catch (\Exception $e) {
Log::error($e->getMessage());
return true;

View File

@ -2,9 +2,8 @@
namespace app\jobs\notice;
use app\services\message\TemplateMessageServices;
use app\services\message\SystemNotificationServices;
use crmeb\basic\BaseJobs;
use crmeb\exceptions\AdminException;
use crmeb\services\app\MiniProgramService;
use crmeb\services\app\WechatService;
use crmeb\traits\QueueTrait;
@ -19,95 +18,57 @@ class SyncMessageJob extends BaseJobs
* @param $template
* @return bool
*/
public function syncSubscribe($template)
public function syncSubscribe($key, $data)
{
$errCode = [-1, 40001, 40002, 40013, 40125, 41002, 41004, 43104, 45009, 200011, 200012, 200014];
/** @var TemplateMessageServices $templateMessageServices */
$templateMessageServices = app()->make(TemplateMessageServices::class);
if ($template['tempkey']) {
if ($template['tempid']) {
try {
MiniProgramService::delSubscribeTemplate($template['tempid']);
} catch (\Throwable $e) {
$wechatErr = $e->getMessage();
if (is_string($wechatErr)) {
Log::error('删除旧订阅消息模版失败:' . $wechatErr);
return true;
}
if (in_array($wechatErr->getCode(), $errCode)) {
Log::error('删除旧订阅消息模版失败:' . $wechatErr->getCode());
return true;
}
Log::error('删除旧订阅消息模版失败:' . $wechatErr->getMessage());
return true;
$works = MiniProgramService::getSubscribeTemplateKeyWords($key);
$kid = [];
if ($works) {
$works = array_combine(array_column($works, 'name'), $works);
$content = is_array($data['routine_content']) ? $data['routine_content'] : explode("\n", $data['routine_content']);
foreach ($content as $c) {
$name = explode('{{', $c)[0] ?? '';
if ($name && isset($works[$name])) {
$kid[] = $works[$name]['kid'];
}
}
}
if ($kid) {
try {
$works = MiniProgramService::getSubscribeTemplateKeyWords($template['tempkey']);
$tempid = MiniProgramService::addSubscribeTemplate($key, $kid, $data['name']);
} catch (\Throwable $e) {
$wechatErr = $e->getMessage();
if (is_string($wechatErr)) {
Log::error('获取关键词列表失败:' . $wechatErr);
return true;
}
if (in_array($wechatErr->getCode(), $errCode)) {
Log::error('获取关键词列表失败:' . $wechatErr->getCode());
return true;
}
Log::error('获取关键词列表失败:' . $wechatErr->getMessage());
return true;
}
$kid = [];
if ($works) {
$works = array_combine(array_column($works, 'name'), $works);
$content = is_array($template['content']) ? $template['content'] : explode("\n", $template['content']);
foreach ($content as $c) {
$name = explode('{{', $c)[0] ?? '';
if ($name && isset($works[$name])) {
$kid[] = $works[$name]['kid'];
}
}
}
if ($kid) {
try {
$tempid = MiniProgramService::addSubscribeTemplate($template['tempkey'], $kid, $template['name']);
} catch (\Throwable $e) {
$wechatErr = $e->getMessage();
if (is_string($wechatErr)) {
Log::error('添加订阅消息模版失败:' . $wechatErr);
return true;
}
if (in_array($wechatErr->getCode(), $errCode)) {
Log::error('添加订阅消息模版失败:' . $wechatErr->getCode());
return true;
}
Log::error('添加订阅消息模版失败:' . $wechatErr->getMessage());
return true;
}
$templateMessageServices->update($template['id'], ['tempid' => $tempid, 'kid' => json_encode($kid), 'add_time' => time()], 'id');
Log::error('同步订阅消息失败:' . $e->getMessage());
return true;
}
app()->make(SystemNotificationServices::class)->update(['routine_tempkey' => $key], ['routine_tempid' => $tempid, 'routine_kid' => json_encode($kid)]);
return true;
}
return true;
}
/**
* 同步公众号模版消息
* @param $template
* @param $key
* @param $content
* @return bool
* @author: 吴汐
* @email: 442384644@qq.com
* @date: 2023/8/16
*/
public function syncWechat($template)
public function syncWechat($key, $content)
{
/** @var TemplateMessageServices $templateMessageServices */
$templateMessageServices = app()->make(TemplateMessageServices::class);
$content = is_array($content) ? $content : explode("\n", $content);
$name = [];
foreach ($content as $c) {
$name[] = explode('{{', $c)[0] ?? '';
}
try {
$res = WechatService::addTemplateId($template['tempkey']);
$res = WechatService::addTemplateId($key, $name);
} catch (\Throwable $e) {
Log::error('同步模版消息失败:' . $e->getMessage());
return true;
}
if(!$res->errcode && $res->template_id){
$templateMessageServices->update($template['id'],['tempid'=>$res->template_id]);
if (!$res->errcode && $res->template_id) {
app()->make(SystemNotificationServices::class)->update(['wechat_tempkey' => $key], ['wechat_tempid' => $res->template_id]);
}
return true;
}

View File

@ -27,9 +27,9 @@ use app\api\validate\user\StoreServiceFeedbackValidate;
use app\services\kefu\service\StoreServiceFeedbackServices;
use crmeb\exceptions\AuthException;
use app\services\other\UploadService;
use crmeb\services\CacheService;
use crmeb\utils\Arr;
use crmeb\utils\JwtAuth;
use think\facade\Cache;
class Common extends BaseController
{
@ -225,7 +225,7 @@ class Common extends BaseController
}
$uid = $authInfo['user']['uid'];
if (!$data['filename']) return app('json')->fail(100100);
if (Cache::has('start_uploads_' . $uid) && Cache::get('start_uploads_' . $uid) >= 100) return app('json')->fail('非法操作');
if (CacheService::has('start_uploads_' . $uid) && CacheService::get('start_uploads_' . $uid) >= 100) return app('json')->fail('非法操作');
$upload = UploadService::init();
$info = $upload->to('store/comment')->validate()->move($data['filename']);
if ($info === false) {
@ -233,12 +233,12 @@ class Common extends BaseController
}
$res = $upload->getUploadInfo();
$services->attachmentAdd($res['name'], $res['size'], $res['type'], $res['dir'], $res['thumb_path'], 1, (int)sys_config('upload_type', 1), $res['time'], 2);
if (Cache::has('start_uploads_' . $uid))
$start_uploads = (int)Cache::get('start_uploads_' . $uid);
if (CacheService::has('start_uploads_' . $uid))
$start_uploads = (int)CacheService::get('start_uploads_' . $uid);
else
$start_uploads = 0;
$start_uploads++;
Cache::set('start_uploads_' . $uid, $start_uploads, 86400);
CacheService::set('start_uploads_' . $uid, $start_uploads, 86400);
$res['dir'] = path_to_url($res['dir']);
if (strpos($res['dir'], 'http') === false) $res['dir'] = $request->domain() . $res['dir'];
return app('json')->success(410091, ['name' => $res['name'], 'url' => $res['dir']]);

View File

@ -23,7 +23,6 @@ use app\services\user\UserLabelCateServices;
use app\services\user\UserLabelRelationServices;
use app\services\kefu\service\StoreServiceRecordServices;
use think\facade\Config;
use think\facade\Cache;
/**
* Class User
@ -163,7 +162,7 @@ class User extends AuthController
['filename', 'file'],
]);
if (!$data['filename']) return app('json')->fail(100100);
if (Cache::has('start_uploads_' . $request->kefuId()) && Cache::get('start_uploads_' . $request->kefuId()) >= 100) return app('json')->fail('非法操作');
if (CacheService::has('start_uploads_' . $request->kefuId()) && CacheService::get('start_uploads_' . $request->kefuId()) >= 100) return app('json')->fail('非法操作');
$upload = UploadService::init();
$info = $upload->to('store/comment')->validate()->move($data['filename']);
if ($info === false) {
@ -171,12 +170,12 @@ class User extends AuthController
}
$res = $upload->getUploadInfo();
$services->attachmentAdd($res['name'], $res['size'], $res['type'], $res['dir'], $res['thumb_path'], 1, (int)sys_config('upload_type', 1), $res['time'], 2);
if (Cache::has('start_uploads_' . $request->kefuId()))
$start_uploads = (int)Cache::get('start_uploads_' . $request->kefuId());
if (CacheService::has('start_uploads_' . $request->kefuId()))
$start_uploads = (int)CacheService::get('start_uploads_' . $request->kefuId());
else
$start_uploads = 0;
$start_uploads++;
Cache::set('start_uploads_' . $request->kefuId(), $start_uploads, 86400);
CacheService::set('start_uploads_' . $request->kefuId(), $start_uploads, 86400);
$res['dir'] = path_to_url($res['dir']);
if (strpos($res['dir'], 'http') === false) $res['dir'] = $request->domain() . $res['dir'];
return app('json')->success(410091, ['name' => $res['name'], 'url' => $res['dir']]);

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,56 @@
<?php
/**
* +----------------------------------------------------------------------
* | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
* +----------------------------------------------------------------------
* | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
* +----------------------------------------------------------------------
* | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
* +----------------------------------------------------------------------
* | Author: CRMEB Team <admin@crmeb.com>
* +----------------------------------------------------------------------
*/
namespace app\model\system;
use crmeb\basic\BaseModel;
/**
* Class SystemCrudData
* @author 等风来
* @email 136327134@qq.com
* @date 2023/7/28
* @package app\model\system
*/
class SystemCrudData extends BaseModel
{
/**
* @var string
*/
protected $name = 'system_crud_data';
/**
* @var string
*/
protected $pk = 'id';
public function getValueAttr($value)
{
return json_decode($value, true);
}
/**
* @param $query
* @param $value
* @author 等风来
* @email 136327134@qq.com
* @date 2023/8/10
*/
public function searchNameAttr($query, $value)
{
if ($value != '') {
$query->where('name', 'like', '%' . $value . '%');
}
}
}

View File

@ -46,6 +46,26 @@ class SystemRoute extends BaseModel
}
}
public function setQueryAttr($value)
{
return json_encode($value);
}
public function getQueryAttr($value)
{
return json_decode($value, true);
}
public function setHeaderAttr($value)
{
return json_encode($value);
}
public function getHeaderAttr($value)
{
return json_decode($value, true);
}
public function setRequestAttr($value)
{
return json_encode($value);

View File

@ -0,0 +1,41 @@
<?php
namespace app\model\system;
use crmeb\basic\BaseModel;
use crmeb\traits\ModelTrait;
/**
* @author: 吴汐
* @email: 442384644@qq.com
* @date: 2023/7/28
*/
class SystemSignReward extends BaseModel
{
use ModelTrait;
/**
* 数据表主键
* @var string
*/
protected $pk = 'id';
/**
* 模型名称
* @var string
*/
protected $name = 'system_sign_reward';
/**
* 类型搜索器
* @param $query
* @param $value
* @author: 吴汐
* @email: 442384644@qq.com
* @date: 2023/7/28
*/
public function searchTypeAttr($query, $value)
{
if ($value !== '') $query->where('type', $value);
}
}

View File

@ -53,8 +53,8 @@ class SystemRole extends BaseModel
*/
public function searchStatusAttr($query, $value)
{
if ($value != '') {
$query->where('status', $value ?: 1);
if ($value !== '') {
$query->where('status', $value);
}
}

View File

@ -223,7 +223,7 @@ class User extends BaseModel
*/
public function searchLikeAttr($query, $value)
{
$query->where('account|nickname|phone|real_name|uid', 'LIKE', "%$value%");
$query->where('account|nickname|phone|real_name|uid', 'like', '%' . $value . '%');
}
/**

View File

@ -35,4 +35,14 @@ class WechatKey extends BaseModel
* @var string
*/
protected $name = 'wechat_key';
public function searchKeysAttr($query, $value)
{
if ($value) $query->where('keys', $value);
}
public function searchKeysLikeAttr($query, $value)
{
if ($value) $query->where('keys', 'like', '%' . $value . '%');
}
}

View File

@ -41,9 +41,27 @@ class WechatReply extends BaseModel
*/
public static $replyType = ['text', 'image', 'news', 'voice'];
/**
* 公众号自动回复关联
* @return \think\model\relation\HasMany
* @author: 吴汐
* @email: 442384644@qq.com
* @date: 2023/8/3
*/
public function wechatKeys()
{
return $this->hasMany(WechatKey::class, 'reply_id', 'id');
}
/**
* 客服自动回复关联
* @return \think\model\relation\HasOne
* @author: 吴汐
* @email: 442384644@qq.com
* @date: 2023/8/3
*/
public function kefuKey()
{
return $this->hasOne(WechatKey::class, 'reply_id', 'id')->bind(['keys']);
}
}

View File

@ -11,6 +11,8 @@
namespace app\services;
use app\services\user\UserServices;
use crmeb\exceptions\ApiException;
use crmeb\utils\JwtAuth;
use think\facade\Db;
use think\facade\Config;
@ -48,17 +50,6 @@ abstract class BaseServices
*/
protected $dao;
/**
* @return \crmeb\utils\Cache
* @author 等风来
* @email 136327134@qq.com
* @date 2023/2/8
*/
public function cacheDriver()
{
return new \crmeb\utils\Cache($this->dao->getTableName());
}
/**
* 获取分页配置
* @param bool $isPage
@ -103,6 +94,9 @@ abstract class BaseServices
{
/** @var JwtAuth $jwtAuth */
$jwtAuth = app()->make(JwtAuth::class);
if ($type == 'api' && !app()->make(UserServices::class)->value(['uid' => $id], 'status')) {
throw new ApiException(410027);
}
return $jwtAuth->createToken($id, $type, ['pwd' => md5($pwd)]);
}

View File

@ -1029,8 +1029,7 @@ class StoreBargainServices extends BaseServices
[$page, $limit] = $this->getPageValue();
$where = $where + ['paid' => 1, 'refund_status' => 0, 'is_del' => 0];
$list = $orderServices->bargainStatisticsOrder($id, $where, $page, $limit);
$where['bargain_id'] = $id;
$count = $orderServices->count($where);
$count = $orderServices->bargainStatisticsOrderCount($where);
foreach ($list as &$item) {
if ($item['status'] == 0) {
if ($item['paid'] == 0) {

View File

@ -224,7 +224,7 @@ class StoreCombinationServices extends BaseServices
$header[] = ['title' => '成本价', 'key' => 'cost', 'align' => 'center', 'minWidth' => 80];
$header[] = ['title' => '日常售价', 'key' => 'r_price', 'align' => 'center', 'minWidth' => 80];
$header[] = ['title' => '库存', 'key' => 'stock', 'align' => 'center', 'minWidth' => 80];
$header[] = ['title' => '限量', 'key' => 'quota', 'type' => 1, 'align' => 'center', 'minWidth' => 80];
$header[] = ['title' => '限量', 'slot' => 'quota', 'type' => 1, 'align' => 'center', 'minWidth' => 80];
$header[] = ['title' => '重量(KG)', 'key' => 'weight', 'align' => 'center', 'minWidth' => 80];
$header[] = ['title' => '体积(m³)', 'key' => 'volume', 'align' => 'center', 'minWidth' => 80];
$header[] = ['title' => '商品编号', 'key' => 'bar_code', 'align' => 'center', 'minWidth' => 80];
@ -662,8 +662,7 @@ class StoreCombinationServices extends BaseServices
[$page, $limit] = $this->getPageValue();
$where = $where + ['paid' => 1, 'refund_status' => 0, 'is_del' => 0];
$list = $orderServices->combinationStatisticsOrder($id, $where, $page, $limit);
$where['combination_id'] = $id;
$count = $orderServices->count($where);
$count = $orderServices->combinationStatisticsCount($where);
foreach ($list as &$item) {
if ($item['status'] == 0) {
if ($item['paid'] == 0) {

View File

@ -131,12 +131,13 @@ class StorePinkServices extends BaseServices
$res12 = $this->dao->update($kCount['id'], ['stop_time' => $count['add_time'] + 86400, 'k_id' => 0]);
$res1 = $res11 && $res12;
$res2 = $this->dao->update($id, ['stop_time' => time() - 1, 'k_id' => $kCount['id'], 'is_refund' => $kCount['id'], 'status' => 3]);
$res3 = app()->make(StoreOrderServices::class)->update(['pink_id' => $id], ['pink_id' => $kCount['id']]);
} else {
$res1 = true;
$res1 = $res3 = true;
$res2 = $this->dao->update($id, ['stop_time' => time() - 1, 'is_refund' => $id, 'status' => 3]);
}
//修改结束时间为前一秒 团长ID为0
$res = $res1 && $res2;
$res = $res1 && $res2 && $res3;
} else if ($countY) {//团员
$res = $this->dao->update($countY['id'], ['stop_time' => time() - 1, 'is_refund' => $id, 'status' => 3]);
}

View File

@ -383,7 +383,7 @@ class StoreCouponIssueServices extends BaseServices
$couponUserService = app()->make(StoreCouponUserServices::class);
$this->transaction(function () use ($issueUserService, $uid, $id, $couponUserService, $issueCouponInfo, $is_receive) {
$issueUserService->save(['uid' => $uid, 'issue_coupon_id' => $id, 'add_time' => time()]);
$couponUserService->addUserCoupon($uid, $issueCouponInfo, "send");
$couponUserService->addUserCoupon($uid, $issueCouponInfo, $is_receive ? 'get' : 'send');
if ($issueCouponInfo['total_count'] > 0 && $is_receive) {
$issueCouponInfo['remain_count'] -= 1;
$issueCouponInfo->save();

View File

@ -71,7 +71,7 @@ class StoreCouponService extends BaseServices
$f[] = Form::select('category_id', '选择品类')->setOptions(Form::setOptions($options))->filterable(1)->col(12);
break;
case 2://商品券
$f[] = Form::frameImages('image', '商品', Url::buildUrl(config('app.admin_prefix', 'admin') . '/store.StoreProduct/index', array('fodder' => 'image', 'type' => 'many')))->icon('ios-add')->width('950px')->height('560px')->modal(['footer-hide' => true])->props(['srcKey' => 'image']);
$f[] = Form::frameImages('image', '商品', Url::buildUrl(config('app.admin_prefix', 'admin') . '/store.StoreProduct/index', array('fodder' => 'image', 'type' => 'many')))->icon('el-icon-picture-outline')->width('950px')->height('560px')->props(['srcKey' => 'image', 'footer' => false]);
$f[] = Form::hidden('product_id', '');
break;
}

View File

@ -212,9 +212,9 @@ class StoreIntegralServices extends BaseServices
$header[] = ['title' => $item['value'], 'key' => 'value' . ($key + 1), 'align' => 'center', 'minWidth' => 80];
}
$header[] = ['title' => '图片', 'slot' => 'pic', 'align' => 'center', 'minWidth' => 120];
$header[] = ['title' => '兑换积分', 'key' => 'price', 'type' => 1, 'align' => 'center', 'minWidth' => 80];
$header[] = ['title' => '兑换积分', 'slot' => 'price', 'type' => 1, 'align' => 'center', 'minWidth' => 80];
$header[] = ['title' => '库存', 'key' => 'stock', 'align' => 'center', 'minWidth' => 80];
$header[] = ['title' => '兑换次数', 'key' => 'quota', 'type' => 1, 'align' => 'center', 'minWidth' => 80];
$header[] = ['title' => '兑换次数', 'slot' => 'quota', 'type' => 1, 'align' => 'center', 'minWidth' => 80];
$header[] = ['title' => '重量(KG)', 'key' => 'weight', 'align' => 'center', 'minWidth' => 80];
$header[] = ['title' => '体积(m³)', 'key' => 'volume', 'align' => 'center', 'minWidth' => 80];
$header[] = ['title' => '商品编号', 'key' => 'bar_code', 'align' => 'center', 'minWidth' => 80];

View File

@ -75,14 +75,14 @@ class LiveAnchorServices extends BaseServices
$field[] = Form::input('name', '主播名称', '')->maxlength(20)->required('请填写名称');
$field[] = Form::input('wechat', '主播微信号', '')->maxlength(32)->required('请填写微信号');
$field[] = Form::input('phone', '主播手机号', '')->maxlength(20)->required('请填写手机号');
$field[] = Form::frameImage('cover_img', '主播图像', Url::buildUrl(config('app.admin_prefix', 'admin') . '/widget.images/index', array('fodder' => 'cover_img')), '')->icon('ios-add')->width('950px')->height('560px')->modal(['footer-hide' => true])->appendValidate(Validate::str()->required('请选择图像'));
$field[] = Form::frameImage('cover_img', '主播图像', Url::buildUrl(config('app.admin_prefix', 'admin') . '/widget.images/index', array('fodder' => 'cover_img')), '')->icon('el-icon-picture-outline')->width('950px')->height('560px')->Props(['footer' => false])->appendValidate(Validate::str()->required('请选择图像'));
} else {
$title = '修改主播';
$field[] = Form::hidden('id', $anchor->getData('id'));
$field[] = Form::input('name', '主播名称', $anchor->getData('name'))->maxlength(20)->required('请填写名称');
$field[] = Form::input('wechat', '主播微信号', $anchor->getData('wechat'))->maxlength(32)->required('请填写微信号');
$field[] = Form::input('phone', '主播手机号', $anchor->getData('phone'))->maxlength(20)->required('请填写手机号');
$field[] = Form::frameImage('cover_img', '主播图像', Url::buildUrl(config('app.admin_prefix', 'admin') . '/widget.images/index', array('fodder' => 'cover_img')), $anchor->getData('cover_img'))->icon('ios-add')->width('950px')->height('560px')->modal(['footer-hide' => true])->appendValidate(Validate::str()->required('请选择图像'));
$field[] = Form::frameImage('cover_img', '主播图像', Url::buildUrl(config('app.admin_prefix', 'admin') . '/widget.images/index', array('fodder' => 'cover_img')), $anchor->getData('cover_img'))->icon('el-icon-picture-outline')->width('950px')->height('560px')->Props(['footer' => false])->appendValidate(Validate::str()->required('请选择图像'));
}
return create_form($title, $field, $this->url('/live/anchor/save'), 'POST');
}

View File

@ -96,6 +96,7 @@ class LiveGoodsServices extends BaseServices
@unlink($path);
} catch (\Throwable $e) {
Log::error('添加直播商品图片错误,原因:' . $e->getMessage());
@unlink($path);
$coverImgUrl = $data['cover_img'];
}
$res = MiniProgramService::addGoods($coverImgUrl, $data['name'], $data['price_type'], $data['url'], floatval($data['price']));

View File

@ -362,11 +362,11 @@ class StoreSeckillServices extends BaseServices
$header[] = ['title' => $item['value'], 'key' => 'value' . ($key + 1), 'align' => 'center', 'minWidth' => 80];
}
$header[] = ['title' => '图片', 'slot' => 'pic', 'align' => 'center', 'minWidth' => 120];
$header[] = ['title' => '秒杀价', 'type' => 1, 'key' => 'price', 'align' => 'center', 'minWidth' => 80];
$header[] = ['title' => '秒杀价', 'slot' => 'price', 'align' => 'center', 'minWidth' => 80];
$header[] = ['title' => '成本价', 'key' => 'cost', 'align' => 'center', 'minWidth' => 80];
$header[] = ['title' => '原价', 'key' => 'ot_price', 'align' => 'center', 'minWidth' => 80];
$header[] = ['title' => '库存', 'key' => 'stock', 'align' => 'center', 'minWidth' => 80];
$header[] = ['title' => '限量', 'key' => 'quota', 'type' => 1, 'align' => 'center', 'minWidth' => 80];
$header[] = ['title' => '限量', 'slot' => 'quota', 'type' => 1, 'align' => 'center', 'minWidth' => 80];
$header[] = ['title' => '重量(KG)', 'key' => 'weight', 'align' => 'center', 'minWidth' => 80];
$header[] = ['title' => '体积(m³)', 'key' => 'volume', 'align' => 'center', 'minWidth' => 80];
$header[] = ['title' => '商品编号', 'key' => 'bar_code', 'align' => 'center', 'minWidth' => 80];
@ -777,8 +777,7 @@ class StoreSeckillServices extends BaseServices
[$page, $limit] = $this->getPageValue();
$where = $where + ['paid' => 1, 'refund_status' => 0, 'is_del' => 0];
$list = $orderServices->seckillOrder($id, $where, $page, $limit);
$where['seckill_id'] = $id;
$count = $orderServices->count($where);
$count = $orderServices->seckillCount($id, $where);
foreach ($list as &$item) {
if ($item['status'] == 0) {
if ($item['paid'] == 0) {

View File

@ -262,7 +262,7 @@ class AgentLevelServices extends BaseServices
{
$field[] = Form::input('name', '等级名称')->maxlength(8)->col(24);
$field[] = Form::number('grade', '等级', 0)->min(0)->precision(0);
$field[] = Form::frameImage('image', '背景图', Url::buildUrl(config('app.admin_prefix', 'admin') . '/widget.images/index', array('fodder' => 'image')))->icon('ios-add')->width('950px')->height('560px')->modal(['footer-hide' => true]);
$field[] = Form::frameImage('image', '背景图', Url::buildUrl(config('app.admin_prefix', 'admin') . '/widget.images/index', array('fodder' => 'image')))->icon('el-icon-picture-outline')->width('950px')->height('560px')->props(['footer' => false]);
$field[] = Form::number('one_brokerage', '一级上浮', 0)->appendRule('suffix', [
'type' => 'div',
'class' => 'tips-info',
@ -292,7 +292,7 @@ class AgentLevelServices extends BaseServices
$field[] = Form::hidden('id', $id);
$field[] = Form::input('name', '等级名称', $levelInfo['name'])->maxlength(8)->col(24);
$field[] = Form::number('grade', '等级', $levelInfo['grade'])->min(0)->precision(0);
$field[] = Form::frameImage('image', '背景图', Url::buildUrl(config('app.admin_prefix', 'admin') . '/widget.images/index', array('fodder' => 'image')), $levelInfo['image'])->icon('ios-add')->width('950px')->height('560px')->modal(['footer-hide' => true]);
$field[] = Form::frameImage('image', '背景图', Url::buildUrl(config('app.admin_prefix', 'admin') . '/widget.images/index', array('fodder' => 'image')), $levelInfo['image'])->icon('el-icon-picture-outline')->width('950px')->height('560px')->props(['footer' => false]);
$field[] = Form::number('one_brokerage', '一级上浮', $levelInfo['one_brokerage'])->appendRule('suffix', [
'type' => 'div',
'class' => 'tips-info',
@ -334,8 +334,8 @@ class AgentLevelServices extends BaseServices
return $menus;
};
$field[] = Form::hidden('uid', $uid);
$field[] = Form::select('id', '分销等级', $userInfo['agent_level'] ?? 0)->setOptions(Form::setOptions($setOptionLabel))->filterable(true);
return create_form('赠送分销等级', $field, Url::buildUrl('/agent/give_level'), 'post');
$field[] = Form::select('id', '分销等级', $userInfo['agent_level'] != 0 ? $userInfo['agent_level'] : '')->setOptions(Form::setOptions($setOptionLabel))->filterable(true);
return create_form('修改分销等级', $field, Url::buildUrl('/agent/give_level'), 'post');
}
/**

View File

@ -88,9 +88,12 @@ class AgentManageServices extends BaseServices
/** @var UserServices $userServices */
$userServices = app()->make(UserServices::class);
$uids = $userServices->getAgentUserIds($where);
//分销员人数
$data['uids'] = $uids;
$data['sum_count'] = count($uids);
//发展会员人数以及用户的可提现金额
$data['spread_sum'] = 0;
$data['extract_price'] = 0;
if ($data['sum_count']) {
@ -101,10 +104,10 @@ class AgentManageServices extends BaseServices
$frozenPrices = app()->make(UserBrokerageFrozenServices::class);
$data['extract_price'] = bcsub((string)$userServices->getSumBrokerage(['uid' => $uids]), $frozenPrices->getSumFrozenBrokerage($uids), 2);
}
//分销员人数
//订单总数,订单金额,提现次数
$data['order_count'] = 0;
$data['pay_price'] = 0;
$data['pay_price'] = 0;
$data['extract_count'] = 0;
if ($data['sum_count']) {
/** @var StoreOrderServices $storeOrder */
@ -116,42 +119,43 @@ class AgentManageServices extends BaseServices
//提现次数
$data['extract_count'] = app()->make(UserExtractServices::class)->getCount([['uid', 'in', $uids], ['status', '=', 1]]);
}
return [
[
'name' => '分销员人数(人)',
'count' => $data['sum_count'],
'className' => 'md-contacts',
'col' => 6,
'className' => 'iconfaqirenshu',
'col' => 4,
],
[
'name' => '推广用户数量(人)',
'count' => $data['spread_sum'],
'className' => 'md-contact',
'col' => 6,
'className' => 'icontuiguangrenshu',
'col' => 4,
],
[
'name' => '订单数(单)',
'count' => $data['order_count'],
'className' => 'md-cart',
'col' => 6,
'className' => 'icondingdanliang',
'col' => 4,
],
[
'name' => '订单金额(元)',
'count' => $data['pay_price'],
'className' => 'md-bug',
'col' => 6,
'className' => 'icondingdanjine',
'col' => 4,
],
[
'name' => '提现次数(次)',
'count' => $data['extract_count'],
'className' => 'md-basket',
'col' => 6,
'className' => 'iconzhichujine',
'col' => 4,
],
[
'name' => '未提现金额(元)',
'count' => $data['extract_price'],
'className' => 'ios-at-outline',
'col' => 6,
'className' => 'iconjiaoyijine',
'col' => 4,
],
];
}

View File

@ -121,7 +121,7 @@ class DivisionAgentApplyServices extends BaseServices
$field[] = Form::hidden('id', $id);
if ($type) {
$field[] = Form::number('division_percent', '佣金比例', '')->placeholder('代理商佣金比例1-100')->info('填写1-100,如填写50代表返佣50%,但是不能高于上级事业部的比例')->style(['width' => '173px'])->min(0)->max(100)->required();
$field[] = Form::date('division_end_time', '到期时间', '')->placeholder('代理商代理到期时间')->required();
$field[] = Form::date('division_end_time', '到期时间', '')->placeholder('代理商代理到期时间');
$field[] = Form::radio('division_status', '代理状态', 1)->options([['label' => '开通', 'value' => 1], ['label' => '关闭', 'value' => 0]]);
$title = '同意申请';
} else {

View File

@ -98,7 +98,7 @@ class DivisionServices extends BaseServices
}
$field[] = Form::hidden('aid', $adminInfo['id'] ?? 0);
$field[] = Form::number('division_percent', '佣金比例', $userInfo['division_percent'] ?? '')->placeholder('区域代理佣金比例1-100')->info('填写1-100,如填写50代表返佣50%')->style(['width' => '173px'])->min(0)->max(100)->required();
$field[] = Form::date('division_end_time', '到期时间', ($userInfo['division_end_time'] ?? '') != 0 ? date('Y-m-d H:i:s', $userInfo['division_end_time']) : '')->placeholder('区域代理到期时间')->required();
$field[] = Form::date('division_end_time', '到期时间', ($userInfo['division_end_time'] ?? '') != 0 ? date('Y-m-d H:i:s', $userInfo['division_end_time']) : '')->placeholder('区域代理到期时间');
$field[] = Form::radio('division_status', '代理状态', $userInfo['division_status'] ?? 1)->options([['label' => '开通', 'value' => 1], ['label' => '关闭', 'value' => 0]]);
$field[] = Form::input('account', '管理账号', $adminInfo['account'] ?? '')->required('请填写管理员账号');
$field[] = Form::input('pwd', '管理密码')->type('password')->placeholder('请填写管理员密码');
@ -231,7 +231,7 @@ class DivisionServices extends BaseServices
$field[] = Form::hidden('edit', 0);
}
$field[] = Form::number('division_percent', '佣金比例', $userInfo['division_percent'] ?? '')->placeholder('代理商佣金比例1-100')->info('填写1-100,如填写50代表返佣50%,但是不能高于上级事业部的比例')->style(['width' => '173px'])->min(0)->max(100)->required();
$field[] = Form::date('division_end_time', '到期时间', ($userInfo['division_end_time'] ?? '') != 0 ? date('Y-m-d H:i:s', $userInfo['division_end_time']) : '')->placeholder('代理商代理到期时间')->required();
$field[] = Form::date('division_end_time', '到期时间', ($userInfo['division_end_time'] ?? '') != 0 ? date('Y-m-d H:i:s', $userInfo['division_end_time']) : '')->placeholder('代理商代理到期时间');
$field[] = Form::radio('division_status', '代理状态', $userInfo['division_status'] ?? 1)->options([['label' => '开通', 'value' => 1], ['label' => '关闭', 'value' => 0]]);
return create_form('代理商', $field, Route::buildUrl('/agent/division/agent/save'), 'POST');
}
@ -256,6 +256,8 @@ class DivisionServices extends BaseServices
'division_change_time' => time(),
'division_end_time' => strtotime($data['division_end_time']),
'division_type' => 2,
'is_agent' => 1,
'agent_id' => $uid
];
$division_info = $userServices->getUserInfo($data['division_id'], 'division_end_time,division_percent');
if ($division_info) {

View File

@ -75,7 +75,7 @@ class ArticleCategoryServices extends BaseServices
$f[] = Form::select('pid', '上级分类', (int)($info['pid'] ?? ''))->setOptions($this->menus($pid))->filterable(1);
$f[] = Form::input('title', '分类名称', $info['title'] ?? '')->maxlength(20)->required();
$f[] = Form::input('intr', '分类简介', $info['intr'] ?? '')->type('textarea')->required();
$f[] = Form::frameImage('image', '分类图片', Url::buildUrl(config('app.admin_prefix', 'admin') . '/widget.images/index', array('fodder' => 'image')), $info['image'] ?? '')->icon('ios-add')->width('950px')->height('560px')->modal(['footer-hide' => true]);
$f[] = Form::frameImage('image', '分类图片', Url::buildUrl(config('app.admin_prefix', 'admin') . '/widget.images/index', array('fodder' => 'image')), $info['image'] ?? '')->icon('el-icon-picture-outline')->width('950px')->height('560px')->props(['footer' => false]);
$f[] = Form::number('sort', '排序', (int)($info['sort'] ?? 0))->precision(0);
$f[] = Form::radio('status', '状态', $info['status'] ?? 1)->options([['value' => 1, 'label' => '显示'], ['value' => 0, 'label' => '隐藏']]);
return create_form('添加分类', $f, Url::buildUrl($url), $method);
@ -111,7 +111,7 @@ class ArticleCategoryServices extends BaseServices
/** @var ArticleServices $articleService */
$articleService = app()->make(ArticleServices::class);
$pidCount = $this->dao->count(['pid' => $id]);
if($pidCount > 0) throw new AdminException(400454);
if ($pidCount > 0) throw new AdminException(400454);
$count = $articleService->count(['cid' => $id]);
if ($count > 0) {
throw new AdminException(400455);
@ -152,9 +152,16 @@ class ArticleCategoryServices extends BaseServices
* 树形列表
* @return array
* @throws \ReflectionException
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author: 吴汐
* @email: 442384644@qq.com
* @date: 2023/9/7
*/
public function getTreeList()
{
return sort_list_tier($this->dao->getMenus([]));
return get_tree_children($this->dao->getTreeList(['is_del' => 0, 'status' => 1, 'hidden' => 0], ['id', 'id as value', 'title as label', 'title', 'pid']), 'children', 'id');
// return sort_list_tier($this->dao->getMenus([]));
}
}

View File

@ -22,6 +22,7 @@ use app\services\product\product\StoreProductServices;
use app\services\system\config\SystemGroupDataServices;
use app\services\system\config\SystemGroupServices;
use crmeb\exceptions\AdminException;
use crmeb\services\CacheService;
use crmeb\services\FormBuilder as Form;
use crmeb\services\SystemConfigService;
use think\facade\Route as Url;
@ -82,8 +83,8 @@ class DiyServices extends BaseServices
$id = $res->id;
}
$this->cacheDriver()->clear();
$this->cacheDriver()->set('index_diy_' . $id, $data['version']);
CacheService::clear();
CacheService::set('index_diy_' . $id, $data['version']);
$this->updateCacheDiyVersion();
return $id;
@ -101,7 +102,7 @@ class DiyServices extends BaseServices
$res = $this->dao->update($id, ['is_del' => 1]);
if (!$res) throw new AdminException(100008);
$this->cacheDriver()->clear();
CacheService::clear();
}
/**
@ -114,7 +115,7 @@ class DiyServices extends BaseServices
$this->dao->update([['id', '<>', $id]], ['status' => 0]);
$this->dao->update($id, ['status' => 1, 'update_time' => time()]);
$this->cacheDriver()->clear();
CacheService::clear();
$this->updateCacheDiyVersion();
}
@ -130,9 +131,9 @@ class DiyServices extends BaseServices
{
$diyInfo = $this->dao->get(['status' => 1, 'is_del' => 0], ['id', 'version']);
if (!$diyInfo) {
$this->cacheDriver()->delete('index_diy_default');
CacheService::delete('index_diy_default');
} else {
$this->cacheDriver()->set('index_diy_default', $diyInfo['version']);
CacheService::set('index_diy_default', $diyInfo['version']);
}
}
@ -155,7 +156,7 @@ class DiyServices extends BaseServices
$cacheKey = 'index_diy_default';
$where = ['status' => 1, 'is_del' => 0];
}
$data = $this->cacheDriver()->remember($cacheKey, function () use ($where) {
$data = CacheService::remember($cacheKey, function () use ($where) {
return $this->dao->getOne($where, 'version,is_diy');
});
if (isset($data['version']) && isset($data['is_diy'])) {
@ -177,7 +178,7 @@ class DiyServices extends BaseServices
{
$field = 'name,value,is_show,is_bg_color,color_picker,bg_pic,bg_tab_val,is_bg_pic,order_status,is_diy,title';
$info = $this->cacheDriver()->remember('diy_info_' . $id, function () use ($field, $id) {
$info = CacheService::remember('diy_info_' . $id, function () use ($field, $id) {
if ($id) {
$info = $this->dao->getOne(['id' => $id], $field);
} else {
@ -406,7 +407,7 @@ class DiyServices extends BaseServices
*/
public function getNavigation(string $template_name)
{
$value = $this->cacheDriver()->remember('navigation', function () {
$value = CacheService::remember('navigation', function () {
$value = $this->dao->value(['status' => 1], 'value');
if (!$value) {
$value = $this->dao->value(['template_name' => 'default'], 'value');

View File

@ -15,12 +15,9 @@ namespace app\services\kefu;
use crmeb\exceptions\AuthException;
use crmeb\services\oauth\OAuth;
use crmeb\utils\JwtAuth;
use Firebase\JWT\ExpiredException;
use think\facade\Cache;
use app\services\BaseServices;
use crmeb\services\CacheService;
use app\dao\service\StoreServiceDao;
use crmeb\services\app\WechatOpenService;
use app\services\wechat\WechatUserServices;
/**
@ -85,11 +82,9 @@ class LoginServices extends BaseServices
public function parseToken(string $token)
{
$noCli = !request()->isCli();
/** @var CacheService $cacheService */
$cacheService = app()->make(CacheService::class);
//检测token是否过期
$md5Token = md5($token);
if (!$token || !$cacheService->has($md5Token) || !($cacheService->get($md5Token, '', NULL, 'kefu'))) {
if (!$token || !CacheService::has($md5Token) || !(CacheService::get($md5Token, '', NULL, 'kefu'))) {
throw new AuthException(110005);
}
if ($token === 'undefined') {
@ -105,14 +100,14 @@ class LoginServices extends BaseServices
try {
$jwtAuth->verifyToken();
} catch (\Throwable $e) {
$noCli && $cacheService->delete($md5Token);
$noCli && CacheService::delete($md5Token);
throw new AuthException(110006);
}
//获取管理员信息
$adminInfo = $this->dao->get($id);
if (!$adminInfo || !$adminInfo->id) {
$noCli && $cacheService->delete($md5Token);
$noCli && CacheService::delete($md5Token);
throw new AuthException(110007);
}
@ -169,7 +164,7 @@ class LoginServices extends BaseServices
*/
public function scanLogin(string $key)
{
$hasKey = Cache::has($key);
$hasKey = CacheService::has($key);
if ($hasKey === false) {
$status = 0;//不存在需要刷新二维码
} else {

View File

@ -91,9 +91,9 @@ class StoreServiceServices extends BaseServices
public function createServiceForm(array $formData = [])
{
if ($formData) {
$field[] = $this->builder->frameImage('avatar', '客服头像', $this->url(config('app.admin_prefix', 'admin') . '/widget.images/index', ['fodder' => 'avatar'], true), $formData['avatar'] ?? '')->icon('ios-add')->width('950px')->height('560px')->modal(['footer-hide' => true]);
$field[] = $this->builder->frameImage('avatar', '客服头像', $this->url(config('app.admin_prefix', 'admin') . '/widget.images/index', ['fodder' => 'avatar'], true), $formData['avatar'] ?? '')->icon('el-icon-user')->width('950px')->height('560px')->props(['footer' => false]);
} else {
$field[] = $this->builder->frameImage('image', '选择用户', $this->url(config('app.admin_prefix', 'admin') . '/system.user/list', ['fodder' => 'image'], true))->icon('ios-add')->width('950px')->height('560px')->modal(['footer-hide' => true])->Props(['srcKey' => 'image']);
$field[] = $this->builder->frameImage('image', '选择用户', $this->url(config('app.admin_prefix', 'admin') . '/system.user/list', ['fodder' => 'image'], true))->icon('el-icon-user')->width('950px')->height('560px')->Props(['srcKey' => 'image', 'footer' => false]);
$field[] = $this->builder->hidden('uid', 0);
$field[] = $this->builder->hidden('avatar', '');
}
@ -108,10 +108,10 @@ class StoreServiceServices extends BaseServices
$field[] = $this->builder->input('password', '登录密码')->type('password')->col(24)->required();
$field[] = $this->builder->input('true_password', '确认密码')->type('password')->col(24)->required();
}
$field[] = $this->builder->switches('status', '客服状态', (int)($formData['status'] ?? 1))->appendControl(1, [
$this->builder->switches('customer', '手机订单管理', $formData['customer'] ?? 0)->falseValue(0)->trueValue(1)->openStr('打开')->closeStr('关闭')->size('large'),
$this->builder->switches('notify', '订单通知', $formData['notify'] ?? 0)->falseValue(0)->trueValue(1)->openStr('打开')->closeStr('关闭')->size('large'),
])->falseValue(0)->trueValue(1)->openStr('开启')->closeStr('关闭')->size('large');
$field[] = $this->builder->switches('status', '客服状态', (string)($formData['status'] ?? 1))->appendControl('1', [
$this->builder->switches('customer', '手机订单管理', (string)($formData['customer'] ?? 0)),
$this->builder->switches('notify', '订单通知', (string)($formData['notify'] ?? 0)),
])->activeValue('1')->inactiveValue('0');
return $field;
}

View File

@ -70,9 +70,6 @@ class SystemNotificationServices extends BaseServices
*/
public function getNotInfo(array $where)
{
/** @var TemplateMessageServices $TemplateMessageServices */
$TemplateMessageServices = app()->make(TemplateMessageServices::class);
$type = $where['type'];
unset($where['type']);
$info = $this->dao->getOne($where);
@ -86,16 +83,14 @@ class SystemNotificationServices extends BaseServices
$info['content'] = $info['sms_text'];
break;
case 'is_wechat':
$info['tempkey'] = $info['wechat_tempkey'] ?? '';
$info['tempid'] = $info['wechat_tempid'] ?? '';
$info['content'] = $info['wechat_content'] ?? '';
break;
case 'is_routine':
if ('is_wechat' === $type) {
$wechat = $TemplateMessageServices->getOne(['id' => $info['wechat_id'], 'type' => 1]);
} else {
$wechat = $TemplateMessageServices->getOne(['id' => $info['routine_id'], 'type' => 0]);
}
$info['templage_message_id'] = $wechat['id'] ?? '';
$info['tempkey'] = $wechat['tempkey'] ?? '';
$info['tempid'] = $wechat['tempid'] ?? '';
$info['content'] = $wechat['content'] ?? '';
$info['tempkey'] = $info['routine_tempkey'] ?? '';
$info['tempid'] = $info['routine_tempid'] ?? '';
$info['content'] = $info['routine_content'] ?? '';
break;
}
return $info;
@ -117,8 +112,6 @@ class SystemNotificationServices extends BaseServices
if (!$info) {
throw new AdminException(100026);
}
/** @var TemplateMessageServices $TemplateMessageServices */
$TemplateMessageServices = app()->make(TemplateMessageServices::class);
$res = null;
switch ($type) {
case 'is_system':
@ -140,20 +133,14 @@ class SystemNotificationServices extends BaseServices
$res = $this->dao->update((int)$id, $update);
break;
case 'is_wechat':
$update['name'] = $data['name'];
$update['title'] = $data['title'];
$update['is_wechat'] = $data['is_wechat'];
$res1 = $this->dao->update((int)$id, $update);
$res2 = $TemplateMessageServices->update(['notification_id' => $id, 'type' => 1], ['tempid' => $data['tempid']]);
$res = $res1 && $res2;
$update['wechat_tempid'] = $data['tempid'];
$res = $this->dao->update((int)$id, $update);
break;
case 'is_routine':
$update['name'] = $data['name'];
$update['title'] = $data['title'];
$update['is_routine'] = $data['is_routine'];
$res1 = $this->dao->update((int)$id, $update);
$res2 = $TemplateMessageServices->update(['notification_id' => $id, 'type' => 0], ['tempid' => $data['tempid']]);
$res = $res1 && $res2;
$update['routine_tempid'] = $data['tempid'];
$res = $this->dao->update((int)$id, $update);
break;
case 'is_ent_wechat':
$update['name'] = $data['name'];
@ -166,4 +153,33 @@ class SystemNotificationServices extends BaseServices
}
return $res;
}
/**
* 获取tempid
* @param $type
* @return array
* @author: 吴汐
* @email: 442384644@qq.com
* @date: 2023/8/16
*/
public function getTempId($type)
{
return $this->dao->getTempId($type);
}
/**
* 获取tempkey
* @param $type
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author: 吴汐
* @email: 442384644@qq.com
* @date: 2023/8/16
*/
public function getTempKey($type)
{
return $this->dao->getTempKey($type);
}
}

View File

@ -13,6 +13,7 @@ namespace app\services\message\notice;
use app\jobs\TemplateJob;
use app\services\message\NoticeService;
use app\services\user\UserServices;
use app\services\wechat\WechatUserServices;
use think\facade\Log;
@ -24,25 +25,6 @@ use think\facade\Log;
*/
class RoutineTemplateListService extends NoticeService
{
/**
* 判断是否开启权限
* @var bool
*/
private $isOpen = true;
/**
* 是否开启权限
* @param string $mark
* @return $this
*/
public function isOpen(string $mark)
{
$this->isOpen = $this->noticeInfo['is_routine'] === 1;
return $this;
}
/**
* 根据UID获取openid
* @param int $uid
@ -50,9 +32,13 @@ class RoutineTemplateListService extends NoticeService
*/
public function getOpenidByUid(int $uid)
{
/** @var WechatUserServices $wechatServices */
$wechatServices = app()->make(WechatUserServices::class);
return $wechatServices->uidToOpenid($uid, 'routine');
$isDel = app()->make(UserServices::class)->value(['uid' => $uid], 'is_del');
if ($isDel) {
$openid = '';
} else {
$openid = app()->make(WechatUserServices::class)->uidToOpenid($uid, 'routine');
}
return $openid;
}
/**
@ -66,11 +52,10 @@ class RoutineTemplateListService extends NoticeService
public function sendTemplate(int $uid, array $data, string $link = null, string $color = null)
{
try {
$this->isOpen = $this->noticeInfo['is_routine'] === 1;
if ($this->isOpen) {
if ($this->noticeInfo['is_routine'] == 1) {
$openid = $this->getOpenidByUid($uid);
//放入队列执行
TemplateJob::dispatch('doJob', ['subscribe', $openid, $this->noticeInfo['mark'], $data, $link, $color]);
TemplateJob::dispatch('doJob', ['subscribe', $openid, $this->noticeInfo['routine_tempid'], $data, $link, $color]);
}
} catch (\Exception $e) {
Log::error($e->getMessage());

View File

@ -30,30 +30,12 @@ use think\facade\Log;
*/
class SmsService extends NoticeService
{
/**
* 判断是否开启权限
* @var bool
*/
private $isOpen = true;
/**
* 短信类型
* @var string[]
*/
private $smsType = ['yihaotong', 'aliyun', 'tencent'];
/**
* 是否开启权限
* @param string $mark
* @return $this
*/
public function isOpen(string $mark)
{
$this->isOpen = $this->noticeInfo['is_sms'] === 1;
return $this;
}
/**
* 发送短信消息
* @param $phone
@ -63,18 +45,13 @@ class SmsService extends NoticeService
public function sendSms($phone, array $data)
{
try {
$this->isOpen = $this->noticeInfo['is_sms'] === 1;
$mark = $this->noticeInfo['mark'];
if ($this->isOpen) {
if ($this->noticeInfo['is_sms'] == 1) {
try {
/** @var SmsService $smsServices */
$smsServices = app()->make(SmsService::class);
$smsServices->send(true, $phone, $data, $mark);
$this->send(true, $phone, $data, $this->noticeInfo['mark']);
return true;
} catch (\Throwable $e) {
Log::error('发送短信失败,失败原因:' . $e->getMessage());
}
//SmsJob::dispatch('doJob', [$phone, $data, $mark]);
}
} catch (\Exception $e) {
Log::error($e->getMessage());
@ -93,25 +70,15 @@ class SmsService extends NoticeService
public function send(bool $switch, $phone, array $data, string $mark)
{
if ($switch && $phone) {
/** @var ServeServices $services */
$services = app()->make(ServeServices::class);
//获取短信ID
$templateId = CacheService::get('NOTICE_SMS_' . $mark);
if (!$templateId) {
/** @var SystemNotificationServices $notifyServices */
$notifyServices = app()->make(SystemNotificationServices::class);
$templateId = $notifyServices->value(['mark' => $mark], 'sms_id') ?? 0;
CacheService::set('NOTICE_SMS_' . $mark, $templateId);
}
//获取发送短信驱动类型
$type = $this->smsType[sys_config('sms_type', 0)];
if ($type == 'tencent') {
$data = $this->handleTencent($mark, $data);
}
$smsMake = $services->sms($type);
$smsMake = app()->make(ServeServices::class)->sms($type);
$smsId = $mark == 'verify_code' ? app()->make(SystemNotificationServices::class)->value(['mark' => 'verify_code'], 'sms_id') : $this->noticeInfo['sms_id'];
//发送短信
$res = $smsMake->send($phone, $templateId, $data);
$res = $smsMake->send($phone, $smsId, $data);
if ($res === false) {
throw new ApiException($smsMake->getError());
}
@ -128,13 +95,15 @@ class SmsService extends NoticeService
*/
public function sendAdminRefund($order)
{
/** @var StoreServiceServices $StoreServiceServices */
$StoreServiceServices = app()->make(StoreServiceServices::class);
$adminList = $StoreServiceServices->getStoreServiceOrderNotice();
if ($this->noticeInfo['is_sms'] == 1) {
/** @var StoreServiceServices $StoreServiceServices */
$StoreServiceServices = app()->make(StoreServiceServices::class);
$adminList = $StoreServiceServices->getStoreServiceOrderNotice();
foreach ($adminList as $item) {
$data = ['order_id' => $order['order_id'], 'admin_name' => $item['nickname']];
$this->sendSms($item['phone'], $data, 'send_order_apply_refund');
foreach ($adminList as $item) {
$data = ['order_id' => $order['order_id'], 'admin_name' => $item['nickname']];
$this->sendSms($item['phone'], $data);
}
}
return true;
}
@ -148,12 +117,14 @@ class SmsService extends NoticeService
*/
public function sendAdminConfirmTakeOver($order)
{
/** @var StoreServiceServices $StoreServiceServices */
$StoreServiceServices = app()->make(StoreServiceServices::class);
$adminList = $StoreServiceServices->getStoreServiceOrderNotice();
foreach ($adminList as $item) {
$data = ['order_id' => $order['order_id'], 'admin_name' => $item['nickname']];
$this->sendSms($item['phone'], $data, 'send_admin_confirm_take_over');
if ($this->noticeInfo['is_sms'] == 1) {
/** @var StoreServiceServices $StoreServiceServices */
$StoreServiceServices = app()->make(StoreServiceServices::class);
$adminList = $StoreServiceServices->getStoreServiceOrderNotice();
foreach ($adminList as $item) {
$data = ['order_id' => $order['order_id'], 'admin_name' => $item['nickname']];
$this->sendSms($item['phone'], $data);
}
}
return true;
}
@ -167,13 +138,14 @@ class SmsService extends NoticeService
*/
public function sendAdminPaySuccess($order)
{
/** @var StoreServiceServices $StoreServiceServices */
$StoreServiceServices = app()->make(StoreServiceServices::class);
$adminList = $StoreServiceServices->getStoreServiceOrderNotice();
foreach ($adminList as $item) {
$data = ['order_id' => $order['order_id'], 'admin_name' => $item['nickname']];
$this->sendSms($item['phone'], $data, 'admin_pay_success_code');
if ($this->noticeInfo['is_sms'] == 1) {
/** @var StoreServiceServices $StoreServiceServices */
$StoreServiceServices = app()->make(StoreServiceServices::class);
$adminList = $StoreServiceServices->getStoreServiceOrderNotice();
foreach ($adminList as $item) {
$data = ['order_id' => $order['order_id'], 'admin_name' => $item['nickname']];
$this->sendSms($item['phone'], $data);
}
}
return true;
}
@ -191,6 +163,7 @@ class SmsService extends NoticeService
case 'verify_code':
$result = [(string)$data['code'], (string)$data['time']];
break;
case 'send_order_refund_no_status':
case 'order_pay_false':
$result = [$data['order_id']];
break;
@ -212,6 +185,13 @@ class SmsService extends NoticeService
case 'order_postage_success':
$result = [$data['nickname'], $data['store_name'], $data['order_id']];
break;
case 'order_refund':
$result = [$data['order_id'], $data['refund_price']];
break;
case 'recharge_success':
$result = [$data['price'], $data['now_money']];
break;
}
return $result;
}

View File

@ -24,25 +24,6 @@ use think\facade\Log;
*/
class SystemMsgService extends NoticeService
{
/**
* 判断是否开启权限
* @var bool
*/
private $isOpen = true;
/**
* 是否开启权限
* @param string $mark
* @return $this
*/
public function isOpen(string $mark)
{
$this->isOpen = $this->noticeInfo['is_system'] === 1;
return $this;
}
/**
* 发送消息
* @param int $uid
@ -51,9 +32,8 @@ class SystemMsgService extends NoticeService
*/
public function sendMsg(int $uid, $data)
{
$this->isOpen = $this->noticeInfo['is_system'] === 1;
try {
if ($this->isOpen) {
if ($this->noticeInfo['is_system'] == 1) {
$title = $this->noticeInfo['system_title'];
$str = $this->noticeInfo['system_text'];
foreach ($data as $key => $item) {
@ -91,7 +71,7 @@ class SystemMsgService extends NoticeService
$StoreServiceServices = app()->make(StoreServiceServices::class);
$adminList = $StoreServiceServices->getStoreServiceOrderNotice();
try {
if ($this->isOpen) {
if ($this->noticeInfo['is_system'] == 1) {
$save = [];
$title = $this->noticeInfo['system_title'];
$str = $this->noticeInfo['system_text'];

Some files were not shown because too many files have changed in this diff Show More