mirror of
https://github.com/crmeb/CRMEB.git
synced 2026-10-28 21:40:50 +00:00
【程序目录】更新开源
This commit is contained in:
parent
bae7aefa6b
commit
f7e87bf0d3
@ -1 +0,0 @@
|
||||
APP_DEBUG = false
[APP]
DEFAULT_TIMEZONE = Asia/Shanghai
[DATABASE]
TYPE = mysql
HOSTNAME =
HOSTPORT = 3306
USERNAME =
PASSWORD = ''
DATABASE =
PREFIX = eb_
CHARSET = utf8
DEBUG = true
[LANG]
default_lang = zh-cn
[REDIS]
REDIS_HOSTNAME =
PORT = 6379
REDIS_PASSWORD =
SELECT = 0
[QUEUE]
QUEUE_NAME =
|
||||
@ -1 +0,0 @@
|
||||
APP_DEBUG = false
[APP]
DEFAULT_TIMEZONE = Asia/Shanghai
[DATABASE]
TYPE = mysql
HOSTNAME =
HOSTPORT = 3306
USERNAME =
PASSWORD =
DATABASE =
PREFIX = eb_
CHARSET = utf8
DEBUG = true
[LANG]
default_lang = zh-cn
[REDIS]
REDIS_HOSTNAME =
PORT = 6379
REDIS_PASSWORD =
SELECT = 0
[QUEUE]
QUEUE_NAME =
|
||||
22
crmeb/.phpstorm.meta.php
Normal file
22
crmeb/.phpstorm.meta.php
Normal file
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace PHPSTORM_META {
|
||||
|
||||
use think\Container;
|
||||
use function \app;
|
||||
|
||||
override(
|
||||
\app(),
|
||||
map([
|
||||
'json' => \crmeb\utils\Json::class
|
||||
])
|
||||
);
|
||||
|
||||
override(
|
||||
\think\Container::make(),
|
||||
map([
|
||||
'' => '@'
|
||||
])
|
||||
);
|
||||
|
||||
}
|
||||
@ -1,5 +1,4 @@
|
||||
version=CRMEB-KY v4.6.0
|
||||
version_code=460
|
||||
version=CRMEB-KY v4.7.0
|
||||
version_code=470
|
||||
platform=gitee
|
||||
app_id=ze7x9rxsv09l6pvsyo
|
||||
app_key=fuF7U9zaybLa5gageVQzxtxQMFnvU2OI
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
# 软件使用许可协议
|
||||
本协议是您因使用CRMEB开源商城系统软件与西安众邦网络科技有限公司所订立的有效合约。
|
||||
CRMEB是国内最稳定、最强大、最先进的互联网电商平台解决方案之一,CRMEB基于 PHP + MySQL 的技术,采用ThinkPHP框架开发。
|
||||
CRMEB是国内稳定、强大、先进的互联网电商平台解决方案之一,CRMEB基于 PHP + MySQL 的技术,采用ThinkPHP框架开发。
|
||||
CRMEB开源商城系统(以下简称“CRMEB”或“许可软件”或“本软件”),由西安众邦网络科技有限公司(以下称“众邦科技”)自主独创开发,CRMEB官方网站:http://www.crmeb.com,您在使用CRMEB客户管理+电商系统(以下称“许可软件”或“本软件”)之前,请您仔细阅读本协议,特别是法律适用和争议解决条款,您需要重点阅读。如您对协议有任何疑问,可咨询CRMEB官方客服。如果您安装或以其他任何方式使用本软件,则视为已经接受本协议。如果您不接受本协议的全部或部分条款,您将无权使用本软件,请立即终止安装、或以其他方式使用该软件,删除您已经安装或保留的该软件的任何组件。
|
||||
|
||||
一、定义
|
||||
|
||||
@ -84,9 +84,9 @@ class AdminApiExceptionHandle extends Handle
|
||||
'trace' => $e->getTrace(),
|
||||
'previous' => $e->getPrevious(),
|
||||
] : [];
|
||||
$message = Env::get('app_debug', false) ? '接口报错:' . $e->getMessage() : '很抱歉,系统开小差了';
|
||||
$message = Env::get('app_debug', false) ? $e->getMessage() : '很抱歉,系统开小差了';
|
||||
// 添加自定义异常处理机制
|
||||
if ($e instanceof AuthException || $e instanceof AdminException || $e instanceof ApiException) {
|
||||
if ($e instanceof AuthException || $e instanceof AdminException || $e instanceof ApiException || $e instanceof ValidateException) {
|
||||
return app('json')->make($e->getCode() ?: 400, $message, $massageData);
|
||||
} else {
|
||||
return app('json')->fail($message, $massageData);
|
||||
|
||||
@ -104,14 +104,14 @@ class Login extends AuthController
|
||||
$this->validate(['account' => $account, 'pwd' => $password], \app\adminapi\validate\setting\SystemAdminValidata::class, 'get');
|
||||
$result = $this->services->login($account, $password, 'admin', $key);
|
||||
if (!$result) {
|
||||
$num = CacheService::redisHandler()->get('login_captcha',1);
|
||||
$num = CacheService::get('login_captcha',1);
|
||||
if ($num > 1) {
|
||||
return app('json')->fail(400140, ['login_captcha' => 1]);
|
||||
}
|
||||
CacheService::redisHandler()->set('login_captcha', $num + 1, 60);
|
||||
CacheService::set('login_captcha', $num + 1, 60);
|
||||
return app('json')->fail(400140, ['login_captcha' => 0]);
|
||||
}
|
||||
CacheService::redisHandler()->delete('login_captcha');
|
||||
CacheService::delete('login_captcha');
|
||||
return app('json')->success($result);
|
||||
}
|
||||
|
||||
|
||||
@ -61,7 +61,7 @@ class RoutineTemplate extends AuthController
|
||||
}
|
||||
if ($all['list']) {
|
||||
foreach ($all['list'] as $template) {
|
||||
SyncMessageJob::dispatchDo('SyncSubscribe', [$template]);
|
||||
SyncMessageJob::dispatch('SyncSubscribe', [$template]);
|
||||
}
|
||||
}
|
||||
return app('json')->success(100038);
|
||||
|
||||
@ -54,7 +54,7 @@ class WechatTemplate extends AuthController
|
||||
WechatService::deleleTemplate($v['template_id']);
|
||||
}
|
||||
foreach ($all['list'] as $template) {
|
||||
SyncMessageJob::dispatchDo('SyncWechat', [$template]);
|
||||
SyncMessageJob::dispatch('SyncWechat', [$template]);
|
||||
}
|
||||
return app('json')->success(100038);
|
||||
}
|
||||
|
||||
@ -89,6 +89,7 @@ class Diy extends AuthController
|
||||
}
|
||||
}
|
||||
$data['value'] = json_encode($value);
|
||||
$data['version'] = uniqid();
|
||||
$this->services->saveData($id, $data);
|
||||
return app('json')->success(100000);
|
||||
}
|
||||
@ -169,6 +170,7 @@ class Diy extends AuthController
|
||||
$data['version'] = '1.0';
|
||||
$data['type'] = 2;
|
||||
$data['is_diy'] = 1;
|
||||
$data['version'] = uniqid();
|
||||
return app('json')->success($id ? 100001 : 100000, ['id' => $this->services->saveData($id, $data)]);
|
||||
}
|
||||
|
||||
|
||||
@ -49,6 +49,132 @@ class ExportExcel extends AuthController
|
||||
$this->service = $services;
|
||||
}
|
||||
|
||||
public function userList()
|
||||
{
|
||||
$where = $this->request->getMore([
|
||||
['page', 1],
|
||||
['limit', 20],
|
||||
['nickname', ''],
|
||||
['status', ''],
|
||||
['pay_count', ''],
|
||||
['is_promoter', ''],
|
||||
['order', ''],
|
||||
['data', ''],
|
||||
['user_type', ''],
|
||||
['country', ''],
|
||||
['province', ''],
|
||||
['city', ''],
|
||||
['user_time_type', ''],
|
||||
['user_time', ''],
|
||||
['sex', ''],
|
||||
[['level', 0], 0],
|
||||
[['group_id', 'd'], 0],
|
||||
['label_id', ''],
|
||||
['now_money', 'normal'],
|
||||
['field_key', ''],
|
||||
['isMember', '']
|
||||
]);
|
||||
return app('json')->success($this->service->exportUserList($where));
|
||||
}
|
||||
|
||||
/**
|
||||
* 订单导出
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function orderList()
|
||||
{
|
||||
$where = $this->request->getMore([
|
||||
['status', ''],
|
||||
['real_name', ''],
|
||||
['is_del', ''],
|
||||
['data', '', '', 'time'],
|
||||
['type', ''],
|
||||
['pay_type', ''],
|
||||
['order', ''],
|
||||
['field_key', ''],
|
||||
]);
|
||||
$where['is_system_del'] = 0;
|
||||
$where['pid'] = 0;
|
||||
return app('json')->success($this->service->exportOrderList($where));
|
||||
}
|
||||
|
||||
/**
|
||||
* 商品列表导出
|
||||
* @return mixed
|
||||
*/
|
||||
public function productList()
|
||||
{
|
||||
$where = $this->request->getMore([
|
||||
['store_name', ''],
|
||||
['cate_id', ''],
|
||||
['type', 1]
|
||||
]);
|
||||
return app('json')->success($this->service->exportProductList($where));
|
||||
}
|
||||
|
||||
/**
|
||||
* 砍价商品列表导出
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function bargainList()
|
||||
{
|
||||
$where = $this->request->getMore([
|
||||
['status', ''],
|
||||
['store_name', ''],
|
||||
]);
|
||||
$where['is_del'] = 0;
|
||||
return app('json')->success($this->service->exportBargainList($where));
|
||||
}
|
||||
|
||||
/**
|
||||
* 拼团商品导出
|
||||
* @return mixed
|
||||
*/
|
||||
public function combinationList()
|
||||
{
|
||||
$where = $this->request->getMore([
|
||||
['is_show', ''],
|
||||
['store_name', '']
|
||||
]);
|
||||
$where['is_del'] = 0;
|
||||
return app('json')->success($this->service->exportCombinationList($where));
|
||||
}
|
||||
|
||||
/**
|
||||
* 秒杀商品导出
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function seckillList()
|
||||
{
|
||||
$where = $this->request->getMore([
|
||||
[['status', 's'], ''],
|
||||
[['store_name', 's'], '']
|
||||
]);
|
||||
return app('json')->success($this->service->exportSeckillList($where));
|
||||
}
|
||||
|
||||
/**
|
||||
* 会员卡导出
|
||||
* @param $id
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function memberCardList($id)
|
||||
{
|
||||
return app('json')->success($this->service->exportMemberCard($id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存用户资金监控的excel表格
|
||||
* @param UserBillServices $services
|
||||
@ -239,7 +365,7 @@ class ExportExcel extends AuthController
|
||||
}
|
||||
|
||||
/**
|
||||
* 产品导出
|
||||
* 商品导出
|
||||
* @param StoreProductServices $services
|
||||
* @return mixed
|
||||
*/
|
||||
|
||||
@ -62,7 +62,7 @@ class StoreService extends AuthController
|
||||
['data', '', '', 'time'],
|
||||
['type', '', '', 'user_type'],
|
||||
]);
|
||||
[$list, $count] = $services->getWhereUserList($where, 'u.nickname,u.uid,u.avatar as headimgurl,w.subscribe,w.province,w.country,w.city,w.sex,w.user_type,u.is_del');
|
||||
[$list, $count] = $services->getWhereUserList($where, 'u.nickname,u.uid,u.avatar as headimgurl,w.subscribe,w.province,w.country,w.city,w.sex,u.user_type,u.is_del');
|
||||
return app('json')->success(compact('list', 'count'));
|
||||
}
|
||||
|
||||
|
||||
@ -64,7 +64,7 @@ class SmsConfig extends AuthController
|
||||
*/
|
||||
public function is_login(ServeServices $services)
|
||||
{
|
||||
$sms_info = CacheService::redisHandler()->get('sms_account');
|
||||
$sms_info = CacheService::get('sms_account');
|
||||
$data = ['status' => false, 'info' => ''];
|
||||
if ($sms_info) {
|
||||
try {
|
||||
@ -87,7 +87,7 @@ class SmsConfig extends AuthController
|
||||
if ($account && $password) {
|
||||
$res = $services->user()->login($account, $password);
|
||||
if ($res) {
|
||||
CacheService::redisHandler()->set('sms_account', $account);
|
||||
CacheService::set('sms_account', $account);
|
||||
$data['status'] = true;
|
||||
$data['info'] = $account;
|
||||
}
|
||||
@ -103,7 +103,7 @@ class SmsConfig extends AuthController
|
||||
*/
|
||||
public function logout()
|
||||
{
|
||||
$res = CacheService::redisHandler()->delete('sms_account');
|
||||
$res = CacheService::delete('sms_account');
|
||||
if ($res) {
|
||||
$this->services->updateSmsConfig('', '');
|
||||
CacheService::clear();
|
||||
|
||||
@ -693,15 +693,17 @@ class StoreOrder extends AuthController
|
||||
}
|
||||
|
||||
/**
|
||||
* 易联云打印机打印
|
||||
* 小票打印机打印
|
||||
* @param $id
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function order_print($id)
|
||||
{
|
||||
if (!$id) return app('json')->fail(100100);
|
||||
|
||||
$res = $this->services->orderPrint($id);
|
||||
$res = $this->services->orderPrintTicket($id, true);
|
||||
if ($res) {
|
||||
return app('json')->success(100010);
|
||||
} else {
|
||||
|
||||
@ -107,7 +107,7 @@ class Login extends AuthController
|
||||
$res = $this->services->user()->login($account, $password);
|
||||
if ($res) {
|
||||
CacheService::clear();
|
||||
CacheService::redisHandler()->set('sms_account', $account);
|
||||
CacheService::set('sms_account', $account);
|
||||
$services->updateSmsConfig($account, $password);
|
||||
return app('json')->success(400139, $res);
|
||||
} else {
|
||||
|
||||
@ -44,7 +44,7 @@ class Serve extends AuthController
|
||||
*/
|
||||
public function is_login()
|
||||
{
|
||||
$sms_info = CacheService::redisHandler()->get('sms_account');
|
||||
$sms_info = CacheService::get('sms_account');
|
||||
if ($sms_info) {
|
||||
return app('json')->success(['status' => true, 'info' => $sms_info]);
|
||||
} else {
|
||||
@ -188,7 +188,7 @@ class Serve extends AuthController
|
||||
|
||||
$data['password'] = md5($data['password']);
|
||||
$this->services->user()->modify($data);
|
||||
CacheService::redisHandler()->delete('sms_account');
|
||||
CacheService::delete('sms_account');
|
||||
return app('json')->success(100001);
|
||||
}
|
||||
|
||||
@ -207,7 +207,7 @@ class Serve extends AuthController
|
||||
$this->validate($data, ServeValidata::class, 'phone');
|
||||
|
||||
$this->services->user()->modifyPhone($data);
|
||||
CacheService::redisHandler()->delete('sms_account');
|
||||
CacheService::delete('sms_account');
|
||||
return app('json')->success(100001);
|
||||
}
|
||||
}
|
||||
|
||||
@ -65,7 +65,7 @@ class LangType extends AuthController
|
||||
['status', 0]
|
||||
]);
|
||||
$this->services->langTypeSave($data);
|
||||
CacheService::redisHandler()->delete('lang_type_data');
|
||||
CacheService::delete('lang_type_data');
|
||||
return app('json')->success(100000);
|
||||
}
|
||||
|
||||
@ -89,7 +89,7 @@ class LangType extends AuthController
|
||||
public function langTypeDel(int $id = 0)
|
||||
{
|
||||
$this->services->langTypeDel($id);
|
||||
CacheService::redisHandler()->delete('lang_type_data');
|
||||
CacheService::delete('lang_type_data');
|
||||
return app('json')->success(100002);
|
||||
}
|
||||
}
|
||||
@ -169,7 +169,7 @@ class SystemAdmin extends AuthController
|
||||
['new_pwd', ''],
|
||||
['conf_pwd', ''],
|
||||
]);
|
||||
if(!preg_match('/^(?![^a-zA-Z]+$)(?!\D+$).{6,}$/',$data['new_pwd'])){
|
||||
if (!preg_match('/^(?![^a-zA-Z]+$)(?!\D+$).{6,}$/', $data['new_pwd'])) {
|
||||
return app('json')->fail(400183);
|
||||
}
|
||||
if ($this->services->updateAdmin($this->adminId, $data))
|
||||
@ -177,6 +177,7 @@ class SystemAdmin extends AuthController
|
||||
else
|
||||
return app('json')->fail(100007);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改当前登陆admin的文件管理密码
|
||||
* @return mixed
|
||||
@ -187,7 +188,7 @@ class SystemAdmin extends AuthController
|
||||
['file_pwd', ''],
|
||||
['conf_file_pwd', ''],
|
||||
]);
|
||||
if(!preg_match('/^(?![^a-zA-Z]+$)(?!\D+$).{6,}$/',$data['file_pwd'])){
|
||||
if (!preg_match('/^(?![^a-zA-Z]+$)(?!\D+$).{6,}$/', $data['file_pwd'])) {
|
||||
return app('json')->fail(400183);
|
||||
}
|
||||
if ($this->services->setFilePassword($this->adminId, $data))
|
||||
@ -203,7 +204,7 @@ class SystemAdmin extends AuthController
|
||||
public function logout()
|
||||
{
|
||||
$key = trim(ltrim($this->request->header(Config::get('cookie.token_name')), 'Bearer'));
|
||||
CacheService::redisHandler()->delete($key);
|
||||
CacheService::delete(md5($key));
|
||||
return app('json')->success();
|
||||
}
|
||||
}
|
||||
|
||||
@ -107,19 +107,19 @@ class User extends AuthController
|
||||
['is_promoter', 0],
|
||||
['status', 0]
|
||||
]);
|
||||
if ($data['phone']) {
|
||||
if (!check_phone($data['phone'])) {
|
||||
return app('json')->fail(400252);
|
||||
}
|
||||
if ($this->services->count(['phone' => $data['phone'], 'is_del' => 0])) {
|
||||
return app('json')->fail(400314);
|
||||
}
|
||||
if (trim($data['real_name']) != '') {
|
||||
$data['nickname'] = $data['real_name'];
|
||||
} else {
|
||||
$data['nickname'] = substr_replace($data['phone'], '****', 3, 4);
|
||||
}
|
||||
if (!$data['real_name']) {
|
||||
return app('json')->fail(410245);
|
||||
}
|
||||
if (!$data['phone']) {
|
||||
return app('json')->fail(410245);
|
||||
}
|
||||
if (!check_phone($data['phone'])) {
|
||||
return app('json')->fail(400252);
|
||||
}
|
||||
if ($this->services->count(['phone' => $data['phone'], 'is_del' => 0])) {
|
||||
return app('json')->fail(400314);
|
||||
}
|
||||
$data['nickname'] = $data['real_name'];
|
||||
if ($data['card_id']) {
|
||||
if (!check_card($data['card_id'])) return app('json')->fail(400315);
|
||||
}
|
||||
@ -130,6 +130,9 @@ class User extends AuthController
|
||||
if ($data['pwd'] != $data['true_pwd']) {
|
||||
return app('json')->fail(400264);
|
||||
}
|
||||
if (strlen($data['pwd']) < 6 || strlen($data['pwd']) > 32) {
|
||||
return app('json')->fail(400762);
|
||||
}
|
||||
$data['pwd'] = md5($data['pwd']);
|
||||
} else {
|
||||
unset($data['pwd']);
|
||||
@ -389,6 +392,9 @@ class User extends AuthController
|
||||
if ($data['pwd'] != $data['true_pwd']) {
|
||||
return app('json')->fail(400264);
|
||||
}
|
||||
if (strlen($data['pwd']) < 6 || strlen($data['pwd']) > 32) {
|
||||
return app('json')->fail(400762);
|
||||
}
|
||||
$data['pwd'] = md5($data['pwd']);
|
||||
} else {
|
||||
unset($data['pwd']);
|
||||
|
||||
@ -14,6 +14,21 @@ use think\facade\Route;
|
||||
* 导出excel相关路由
|
||||
*/
|
||||
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('product_list', 'v1.export.ExportExcel/productList')->option(['real_name' => '商品列表导出']);
|
||||
//砍价列表
|
||||
Route::get('bargain_list', 'v1.export.ExportExcel/bargainList')->option(['real_name' => '砍价商品列表导出']);
|
||||
//拼团列表
|
||||
Route::get('combination_list', 'v1.export.ExportExcel/combinationList')->option(['real_name' => '拼团商品列表导出']);
|
||||
//秒杀列表
|
||||
Route::get('seckill_list', 'v1.export.ExportExcel/seckillList')->option(['real_name' => '秒杀商品列表导出']);
|
||||
//导出会员卡
|
||||
Route::get('member_card/:id', 'v1.export.ExportExcel/memberCardList')->option(['real_name' => '会员卡导出']);
|
||||
|
||||
//用户资金监控
|
||||
Route::get('userFinance', 'v1.export.ExportExcel/userFinance')->option(['real_name' => '用户资金导出']);
|
||||
//用户佣金
|
||||
|
||||
@ -36,6 +36,7 @@ Route::group(function () {
|
||||
Route::get('get_workerman_url', 'PublicController/getWorkerManUrl')->option(['real_name' => '获取客服数据']);
|
||||
//测试
|
||||
Route::get('index', 'Test/index')->option(['real_name' => '测试地址']);
|
||||
Route::get('h5', 'Test/h5pay')->option(['real_name' => '测试地址2']);
|
||||
})->middleware(AllowOriginMiddleware::class);
|
||||
|
||||
/**
|
||||
|
||||
@ -84,9 +84,9 @@ class ApiExceptionHandle extends Handle
|
||||
'trace' => $e->getTrace(),
|
||||
'previous' => $e->getPrevious(),
|
||||
] : [];
|
||||
$message = Env::get('app_debug', false) ? '接口报错:' . $e->getMessage() : '很抱歉,系统开小差了';
|
||||
$message = Env::get('app_debug', false) ? $e->getMessage() : '很抱歉,系统开小差了';
|
||||
// 添加自定义异常处理机制
|
||||
if ($e instanceof AuthException || $e instanceof AdminException || $e instanceof ApiException) {
|
||||
if ($e instanceof AuthException || $e instanceof AdminException || $e instanceof ApiException || $e instanceof ValidateException) {
|
||||
return app('json')->make($e->getCode() ?: 400, $message, $massageData);
|
||||
} else {
|
||||
return app('json')->fail($message, $massageData);
|
||||
|
||||
@ -68,10 +68,11 @@ class ProductController
|
||||
*/
|
||||
public function getProductRoutineCode(Request $request)
|
||||
{
|
||||
list($product_id) = $request->getMore([
|
||||
list($product_id, $type) = $request->getMore([
|
||||
['product_id', 0],
|
||||
['type', 'product'],
|
||||
], true);
|
||||
$routineCode = $this->services->getProductRoutineCode((int)$product_id);
|
||||
$routineCode = $this->services->getProductRoutineCode((int)$product_id, $type);
|
||||
return app('json')->success(['routineCode' => $routineCode]);
|
||||
}
|
||||
|
||||
|
||||
@ -53,7 +53,7 @@ class LoginController
|
||||
[$account, $password, $spread] = $request->postMore([
|
||||
'account', 'password', 'spread'
|
||||
], true);
|
||||
TaskJob::dispatchDo('emptyYesterdayAttachment');
|
||||
TaskJob::dispatch('emptyYesterdayAttachment');
|
||||
if (!$account || !$password) {
|
||||
return app('json')->fail(410000);
|
||||
}
|
||||
@ -68,7 +68,7 @@ class LoginController
|
||||
public function logout(Request $request)
|
||||
{
|
||||
$key = trim(ltrim($request->header(Config::get('cookie.token_name')), 'Bearer'));
|
||||
CacheService::redisHandler()->delete($key);
|
||||
CacheService::delete(md5($key));
|
||||
return app('json')->success(410002);
|
||||
}
|
||||
|
||||
|
||||
@ -46,6 +46,12 @@ class PayController
|
||||
$pay = app()->make(Pay::class);
|
||||
}
|
||||
return $pay->handleNotify()->getContent();
|
||||
default:
|
||||
if (strstr($type, 'allin') !== false) {
|
||||
/** @var Pay $pay */
|
||||
$pay = app()->make(Pay::class, ['allin_pay']);
|
||||
return $pay->handleNotify($type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -284,12 +284,14 @@ class PublicController
|
||||
/**
|
||||
* 记录用户分享
|
||||
* @param Request $request
|
||||
* @param UserBillServices $services
|
||||
* @return mixed
|
||||
*/
|
||||
public function user_share(Request $request, UserBillServices $services)
|
||||
{
|
||||
$uid = (int)$request->uid();
|
||||
return app('json')->success($services->setUserShare($uid));
|
||||
$services->setUserShare($uid);
|
||||
return app('json')->success(100012);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -306,11 +308,11 @@ class PublicController
|
||||
if ($imageUrl !== '' && !preg_match('/.*(\.png|\.jpg|\.jpeg|\.gif)$/', $imageUrl)) {
|
||||
return app('json')->success(['code' => false, 'image' => false]);
|
||||
}
|
||||
if ($codeUrl !== '' && !preg_match('/.*(\.png|\.jpg|\.jpeg|\.gif)$/', $codeUrl)) {
|
||||
if ($codeUrl !== '' && !(preg_match('/.*(\.png|\.jpg|\.jpeg|\.gif)$/', $codeUrl) || strpos($codeUrl, 'https://mp.weixin.qq.com/cgi-bin/showqrcode') !== false)) {
|
||||
return app('json')->success(['code' => false, 'image' => false]);
|
||||
}
|
||||
try {
|
||||
$code = CacheService::get($codeUrl, function () use ($codeUrl) {
|
||||
$code = CacheService::remember($codeUrl, function () use ($codeUrl) {
|
||||
$codeTmp = $code = $codeUrl ? image_to_base64($codeUrl) : false;
|
||||
if (!$codeTmp) {
|
||||
$putCodeUrl = put_image($codeUrl);
|
||||
@ -319,7 +321,7 @@ class PublicController
|
||||
}
|
||||
return $code;
|
||||
});
|
||||
$image = CacheService::get($imageUrl, function () use ($imageUrl) {
|
||||
$image = CacheService::remember($imageUrl, function () use ($imageUrl) {
|
||||
$imageTmp = $image = $imageUrl ? image_to_base64($imageUrl) : false;
|
||||
if (!$imageTmp) {
|
||||
$putImageUrl = put_image($imageUrl);
|
||||
@ -615,7 +617,7 @@ class PublicController
|
||||
$langStr = 'api_lang_' . str_replace('-', '_', $langData[$typeId]);
|
||||
|
||||
//读取当前语言的语言包
|
||||
$lang = CacheService::redisHandler()->remember($langStr, function () use ($typeId, $range) {
|
||||
$lang = CacheService::remember($langStr, function () use ($typeId, $range) {
|
||||
/** @var LangCodeServices $langCodeServices */
|
||||
$langCodeServices = app()->make(LangCodeServices::class);
|
||||
return $langCodeServices->getColumn(['type_id' => $typeId, 'is_admin' => 0], 'lang_explain', 'code');
|
||||
|
||||
119
crmeb/app/api/controller/v1/TimerController.php
Normal file
119
crmeb/app/api/controller/v1/TimerController.php
Normal file
@ -0,0 +1,119 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\controller\v1;
|
||||
|
||||
use app\services\activity\combination\StorePinkServices;
|
||||
use app\services\activity\live\LiveGoodsServices;
|
||||
use app\services\activity\live\LiveRoomServices;
|
||||
use app\services\agent\AgentManageServices;
|
||||
use app\services\order\StoreOrderServices;
|
||||
use app\services\order\StoreOrderTakeServices;
|
||||
use app\services\product\product\StoreProductServices;
|
||||
use app\services\system\attachment\SystemAttachmentServices;
|
||||
|
||||
class TimerController
|
||||
{
|
||||
/**
|
||||
* 检测定时任务是否正常,必须6秒执行一次
|
||||
*/
|
||||
public function timerCheck()
|
||||
{
|
||||
file_put_contents(runtime_path() . '.timer', time());
|
||||
}
|
||||
|
||||
/**
|
||||
* 未支付自动取消订单
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function orderUnpaidCancel()
|
||||
{
|
||||
/** @var StoreOrderServices $orderServices */
|
||||
$orderServices = app()->make(StoreOrderServices::class);
|
||||
$orderServices->orderUnpaidCancel();
|
||||
}
|
||||
|
||||
/**
|
||||
* 拼团到期订单处理
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function pinkExpiration()
|
||||
{
|
||||
/** @var StorePinkServices $storePinkServices */
|
||||
$storePinkServices = app()->make(StorePinkServices::class);
|
||||
$storePinkServices->statusPink();
|
||||
}
|
||||
|
||||
/**
|
||||
* 自动解绑上级绑定
|
||||
*/
|
||||
public function agentUnbind()
|
||||
{
|
||||
/** @var AgentManageServices $agentManage */
|
||||
$agentManage = app()->make(AgentManageServices::class);
|
||||
$agentManage->removeSpread();
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新直播商品状态
|
||||
*/
|
||||
public function syncGoodStatus()
|
||||
{
|
||||
/** @var LiveGoodsServices $liveGoods */
|
||||
$liveGoods = app()->make(LiveGoodsServices::class);
|
||||
$liveGoods->syncGoodStatus();
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新直播间状态
|
||||
*/
|
||||
public function syncRoomStatus()
|
||||
{
|
||||
/** @var LiveRoomServices $liveRoom */
|
||||
$liveRoom = app()->make(LiveRoomServices::class);
|
||||
$liveRoom->syncRoomStatus();
|
||||
}
|
||||
|
||||
/**
|
||||
* 自动收货
|
||||
*/
|
||||
public function autoTakeOrder()
|
||||
{
|
||||
/** @var StoreOrderTakeServices $services */
|
||||
$services = app()->make(StoreOrderTakeServices::class);
|
||||
$services->autoTakeOrder();
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询预售到期商品自动下架
|
||||
*/
|
||||
public function downAdvance()
|
||||
{
|
||||
/** @var StoreProductServices $product */
|
||||
$product = app()->make(StoreProductServices::class);
|
||||
$product->downAdvance();
|
||||
}
|
||||
|
||||
/**
|
||||
* 自动好评
|
||||
*/
|
||||
public function autoComment()
|
||||
{
|
||||
/** @var StoreOrderServices $orderServices */
|
||||
$orderServices = app()->make(StoreOrderServices::class);
|
||||
$orderServices->autoComment();
|
||||
}
|
||||
|
||||
/**
|
||||
* 清除昨日海报
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function emptyYesterdayAttachment()
|
||||
{
|
||||
/** @var SystemAttachmentServices $attach */
|
||||
$attach = app()->make(SystemAttachmentServices::class);
|
||||
$attach->emptyYesterdayAttachment();
|
||||
}
|
||||
}
|
||||
@ -39,7 +39,8 @@ class StoreSeckillController
|
||||
//秒杀时间段
|
||||
$seckillTime = GroupDataService::getData('routine_seckill_time') ?? [];
|
||||
$seckillTimeIndex = -1;
|
||||
$timeCount = count($seckillTime);
|
||||
$timeCount = count($seckillTime);//总数
|
||||
$unTimeCunt = 0;//即将开始
|
||||
if ($timeCount) {
|
||||
$today = strtotime(date('Y-m-d'));
|
||||
$currentHour = date('H');
|
||||
@ -62,6 +63,7 @@ class StoreSeckillController
|
||||
$value['state'] = '即将开始';
|
||||
$value['status'] = 2;
|
||||
$value['stop'] = (int)bcadd($today, bcmul($activityEndHour, 3600, 0));
|
||||
$unTimeCunt += 1;
|
||||
} else if ($currentHour >= $activityEndHour) {
|
||||
$value['time'] = strlen((int)$value['time']) == 2 ? (int)$value['time'] . ':00' : '0' . (int)$value['time'] . ':00';
|
||||
$value['state'] = '已结束';
|
||||
@ -71,9 +73,16 @@ class StoreSeckillController
|
||||
}
|
||||
}
|
||||
//有时间段但是都不在抢购中
|
||||
if ($seckillTimeIndex == -1) {
|
||||
if ($currentHour < (int)$seckillTime[0]['time'] ?? 0) {
|
||||
if ($seckillTimeIndex == -1 && $currentHour <= (int)$seckillTime[$timeCount - 1]['time'] ?? 0) {
|
||||
if ($currentHour < (int)$seckillTime[0]['time'] ?? 0) {//当前时间
|
||||
$seckillTimeIndex = 0;
|
||||
} elseif ($unTimeCunt) {//存在未开始的
|
||||
foreach ($seckillTime as $key => $item) {
|
||||
if ($item['status'] == 2) {
|
||||
$seckillTimeIndex = $key;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$seckillTimeIndex = $timeCount - 1;
|
||||
}
|
||||
@ -123,11 +132,11 @@ class StoreSeckillController
|
||||
* @param $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function code(Request $request, $id, $stop_time = '')
|
||||
public function code(Request $request, $id)
|
||||
{
|
||||
/** @var QrcodeServices $qrcodeService */
|
||||
$qrcodeService = app()->make(QrcodeServices::class);
|
||||
$url = $qrcodeService->getRoutineQrcodePath($id, $request->uid(), 2, compact('stop_time'));
|
||||
$url = $qrcodeService->getRoutineQrcodePath($id, $request->uid(), 2);
|
||||
if ($url) {
|
||||
return app('json')->success(['code' => $url]);
|
||||
} else {
|
||||
|
||||
@ -130,6 +130,7 @@ class StoreOrderController
|
||||
if (!$order) return app('json')->fail(410173);
|
||||
if ($order['paid']) {
|
||||
$order['nickname'] = $userServices->value(['uid' => $order['uid']], 'nickname');
|
||||
$order['config_export_open'] = (bool)((int)sys_config('config_export_open'));
|
||||
$order = $order->hidden(['uid', 'status', 'paid'])->toArray();
|
||||
return app('json')->success($order);
|
||||
}
|
||||
|
||||
@ -19,7 +19,7 @@ use app\services\pay\YuePayServices;
|
||||
use app\services\user\member\MemberCardServices;
|
||||
use app\services\user\UserServices;
|
||||
use crmeb\services\CacheService;
|
||||
use crmeb\services\SystemConfigService;
|
||||
use crmeb\services\pay\extend\allinpay\AllinPay;
|
||||
use app\Request;
|
||||
|
||||
/**
|
||||
@ -115,6 +115,8 @@ class OtherOrderController
|
||||
|
||||
$info = compact('order_id');
|
||||
|
||||
$payType = get_pay_type($payType);
|
||||
|
||||
if ($order_id) {
|
||||
switch ($payType) {
|
||||
case PayServices::WEIXIN_PAY:
|
||||
@ -168,10 +170,20 @@ class OtherOrderController
|
||||
$payKey = md5($orderInfo['order_id']);
|
||||
CacheService::set($payKey, ['order_id' => $orderInfo['order_id'], 'other_pay_type' => true], 300);
|
||||
$info['pay_key'] = $payKey;
|
||||
return app('json')->status(PayServices::ALIAPY_PAY . '_pay', 410196, $info);
|
||||
return app('json')->status(PayServices::ALIAPY_PAY . '_pay', 410196, $info);
|
||||
}
|
||||
case PayServices::OFFLINE_PAY:
|
||||
return app('json')->status('success', 410196, $info);
|
||||
case PayServices::ALLIN_PAY:
|
||||
/** @var OrderPayServices $payServices */
|
||||
$payServices = app()->make(OrderPayServices::class);
|
||||
$info['jsConfig'] = $payServices->orderPay($orderInfo, $payType, [
|
||||
'returl' => sys_config('site_url') . '/pages/index/index',
|
||||
]);
|
||||
if ($request->isWechat()) {
|
||||
$info['pay_url'] = AllinPay::UNITODER_H5UNIONPAY;
|
||||
}
|
||||
return app('json')->status(PayServices::ALLIN_PAY . '_pay', 410196, $info);
|
||||
}
|
||||
} else return app('json')->fail(410200);
|
||||
}
|
||||
@ -182,9 +194,8 @@ class OtherOrderController
|
||||
*/
|
||||
public function pay_type(Request $request)
|
||||
{
|
||||
/** @var SystemConfigService $systemConfigService */
|
||||
$systemConfigService = app()->make(SystemConfigService::class);
|
||||
$payType = $systemConfigService->more(['ali_pay_status', 'pay_weixin_open']);
|
||||
$payType['ali_pay_status'] = is_ali_pay();
|
||||
$payType['pay_weixin_open'] = is_wecaht_pay();
|
||||
$payType['site_name'] = sys_config('site_name');
|
||||
$payType['now_money'] = $request->user('now_money');
|
||||
$payType['offline_pay_status'] = true;
|
||||
|
||||
@ -15,6 +15,7 @@ use app\services\pay\PayServices;
|
||||
use app\services\shipping\ExpressServices;
|
||||
use app\services\system\admin\SystemAdminServices;
|
||||
use app\services\user\UserInvoiceServices;
|
||||
use crmeb\services\pay\extend\allinpay\AllinPay;
|
||||
use app\services\activity\{lottery\LuckLotteryServices,
|
||||
bargain\StoreBargainServices,
|
||||
combination\StoreCombinationServices,
|
||||
@ -213,7 +214,7 @@ class StoreOrderController
|
||||
}
|
||||
}
|
||||
if ($from != 'pc') {
|
||||
if (!$this->services->checkPaytype($payType)) {
|
||||
if (!$this->services->checkPaytype(get_pay_type($payType))) {
|
||||
return app('json')->fail(410213);
|
||||
}
|
||||
} else {
|
||||
@ -342,6 +343,16 @@ class StoreOrderController
|
||||
case 'pc':
|
||||
case 'friend':
|
||||
return app('json')->status('success', 410203, $info);
|
||||
case PayServices::ALLIN_PAY:
|
||||
/** @var OrderPayServices $payServices */
|
||||
$payServices = app()->make(OrderPayServices::class);
|
||||
$info['jsConfig'] = $payServices->orderPay($orderInfo, $payType, [
|
||||
'returl' => sys_config('site_url') . '/pages/index/index',
|
||||
]);
|
||||
if ($request->isWechat()) {
|
||||
$info['pay_url'] = AllinPay::UNITODER_H5UNIONPAY;
|
||||
}
|
||||
return app('json')->status(PayServices::ALLIN_PAY . '_pay', 410203, $info);
|
||||
}
|
||||
} else return app('json')->fail(410200);
|
||||
}
|
||||
@ -408,8 +419,7 @@ class StoreOrderController
|
||||
break;
|
||||
case 'routine':
|
||||
if ($type == 1 || in_array($order['is_channel'], [0, 2, 3, 4])) {
|
||||
$order['order_id'] = app()->make(StoreOrderCreateServices::class)->getNewOrderId('cp');
|
||||
$this->services->update($order['id'], ['order_id' => $order['order_id']], 'id');
|
||||
$order['order_id'] = mt_rand(100, 999) . '_' . $order['order_id'];
|
||||
}
|
||||
break;
|
||||
case 'app':
|
||||
@ -423,7 +433,7 @@ class StoreOrderController
|
||||
break;
|
||||
}
|
||||
}
|
||||
$order['pay_type'] = $paytype; //重新支付选择支付方式
|
||||
$order['pay_type'] = get_pay_type($paytype); //重新支付选择支付方式
|
||||
switch ($order['pay_type']) {
|
||||
case PayServices::WEIXIN_PAY:
|
||||
$jsConfig = $payServices->orderPay($order->toArray(), $from);
|
||||
@ -460,6 +470,16 @@ class StoreOrderController
|
||||
return app('json')->status('success', 410203);
|
||||
else
|
||||
return app('json')->status('success', 410216);
|
||||
case PayServices::ALLIN_PAY:
|
||||
/** @var OrderPayServices $payServices */
|
||||
$payServices = app()->make(OrderPayServices::class);
|
||||
$info['jsConfig'] = $payServices->orderPay($order->toArray(), $order['pay_type'], [
|
||||
'returl' => sys_config('site_url') . '/pages/index/index',
|
||||
]);
|
||||
if ($request->isWechat()) {
|
||||
$info['pay_url'] = AllinPay::UNITODER_H5UNIONPAY;
|
||||
}
|
||||
return app('json')->status(PayServices::ALLIN_PAY . '_pay', 410203, $info);
|
||||
}
|
||||
return app('json')->fail(410218);
|
||||
}
|
||||
@ -501,7 +521,7 @@ class StoreOrderController
|
||||
$where['is_system_del'] = 0;
|
||||
if (in_array($where['status'], [-1, -2, -3])) {
|
||||
$where['not_pid'] = 1;
|
||||
} elseif (in_array($where['status'], [0, 1, 2, 3, 4])) {
|
||||
} elseif (in_array($where['status'], [0, 1, 2, 3, 4, 9])) {
|
||||
$where['pid'] = 0;
|
||||
}
|
||||
$list = $this->services->getOrderApiList($where);
|
||||
@ -778,7 +798,7 @@ class StoreOrderController
|
||||
*/
|
||||
public function data(Request $request)
|
||||
{
|
||||
return app('json')->success($this->services->getOrderData((int)$request->uid(), true));
|
||||
return app('json')->success($this->services->getOrderData((int)$request->uid()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -33,7 +33,7 @@ class ArticleCategoryController
|
||||
*/
|
||||
public function lst()
|
||||
{
|
||||
$cateInfo = CacheService::get('ARTICLE_CATEGORY', function () {
|
||||
$cateInfo = CacheService::remember('ARTICLE_CATEGORY', function () {
|
||||
$cateInfo = $this->services->getArticleCategory();
|
||||
array_unshift($cateInfo, ['id' => 0, 'title' => '热门']);
|
||||
return $cateInfo;
|
||||
|
||||
@ -38,4 +38,15 @@ class CategoryController
|
||||
$category = $this->services->getCategory($where);
|
||||
return app('json')->success($category);
|
||||
}
|
||||
|
||||
/**
|
||||
* @author 等风来
|
||||
* @email 136327134@qq.com
|
||||
* @date 2022/11/11
|
||||
* @return mixed
|
||||
*/
|
||||
public function getCategoryVersion()
|
||||
{
|
||||
return app('json')->success(['version' => $this->services->getCategoryVersion()]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -388,7 +388,11 @@ class UserBillController
|
||||
|
||||
/**
|
||||
* 获取海报详细信息
|
||||
* @param Request $request
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function getSpreadInfo(Request $request)
|
||||
{
|
||||
@ -402,8 +406,18 @@ class UserBillController
|
||||
$routineSpreadBanner[] = ['pic' => $item];
|
||||
}
|
||||
}
|
||||
|
||||
if (sys_config('share_qrcode', 0) && request()->isWechat()) {
|
||||
/** @var QrcodeServices $qrcodeService */
|
||||
$qrcodeService = app()->make(QrcodeServices::class);
|
||||
$qrcode = $qrcodeService->getTemporaryQrcode('spread', $request->uid())->url;
|
||||
} else {
|
||||
$qrcode = '';
|
||||
}
|
||||
|
||||
return app('json')->success([
|
||||
'spread' => $routineSpreadBanner,
|
||||
'qrcode' => $qrcode,
|
||||
'nickname' => $request->user('nickname'),
|
||||
'site_name' => sys_config('site_name')
|
||||
]);
|
||||
@ -413,6 +427,9 @@ class UserBillController
|
||||
* 积分记录
|
||||
* @param Request $request
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function integral_list(Request $request)
|
||||
{
|
||||
|
||||
@ -93,9 +93,9 @@ class UserController
|
||||
}
|
||||
$uid = (int)$request->uid();
|
||||
if ($this->services->eidtNickname($uid, ['avatar' => $avatar, 'nickname' => $nickname])) {
|
||||
return app('json')->success(100001);
|
||||
return app('json')->success(100014);
|
||||
}
|
||||
return app('json')->fail(100007);
|
||||
return app('json')->fail(100015);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -74,6 +74,21 @@ class PublicController
|
||||
return app('json')->success($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $id
|
||||
* @return mixed
|
||||
* @author 等风来
|
||||
* @email 136327134@qq.com
|
||||
* @date 2023/2/8
|
||||
*/
|
||||
public function getVersion($id = 0)
|
||||
{
|
||||
/** @var DiyServices $diyService */
|
||||
$diyService = app()->make(DiyServices::class);
|
||||
$version = $diyService->getDiyVersion((int)$id);
|
||||
return app('json')->success(['version' => $version ?: '']);
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否强制绑定手机号
|
||||
* @return mixed
|
||||
|
||||
@ -75,10 +75,10 @@ class LuckLotteryController
|
||||
|
||||
$uid = (int)$request->uid();
|
||||
$key = 'lucklotter_limit_' . $uid;
|
||||
if (CacheService::redisHandler()->get($key)) {
|
||||
if (CacheService::get($key)) {
|
||||
return app('json')->fail('您求的频率太过频繁,请稍后请求!');
|
||||
}
|
||||
CacheService::redisHandler()->set('lucklotter_limit_' . $uid, $uid, 1);
|
||||
CacheService::set('lucklotter_limit_' . $uid, $uid, 1);
|
||||
|
||||
if ($type == 5 && request()->isWechat()) {
|
||||
/** @var WechatServices $wechat */
|
||||
|
||||
@ -35,13 +35,57 @@ class AuthController
|
||||
}
|
||||
|
||||
/**
|
||||
* 小程序授权登录
|
||||
* @param Request $request
|
||||
* 静默授权
|
||||
* @param $code
|
||||
* @param string $spread_code
|
||||
* @param string $spread_spid
|
||||
* @return mixed
|
||||
* @throws \Psr\SimpleCache\InvalidArgumentException
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws \think\exception\DbException
|
||||
*/
|
||||
public function silenceAuth($code, $spread_code = '', $spread_spid = '')
|
||||
{
|
||||
$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);
|
||||
}
|
||||
|
||||
/**
|
||||
* 授权获取小程序用户手机号 直接绑定
|
||||
* @param string $code
|
||||
* @param string $iv
|
||||
* @param string $encryptedData
|
||||
* @param string $spread_code
|
||||
* @param string $spread_spid
|
||||
* @param string $key
|
||||
* @return mixed
|
||||
* @throws \Psr\SimpleCache\InvalidArgumentException
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function authBindingPhone($code = '', $iv = '', $encryptedData = '', $spread_code = '', $spread_spid = '', $key = '')
|
||||
{
|
||||
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);
|
||||
} else
|
||||
return app('json')->fail(410019);
|
||||
}
|
||||
|
||||
/** 以下方法该版本暂未使用 */
|
||||
/**
|
||||
* 小程序授权登录
|
||||
* @param Request $request
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function auth(Request $request)
|
||||
{
|
||||
@ -63,30 +107,13 @@ class AuthController
|
||||
return app('json')->fail(410019);
|
||||
}
|
||||
|
||||
/**
|
||||
* 静默授权
|
||||
* @param $code
|
||||
* @param string $spread_code
|
||||
* @param string $spread_spid
|
||||
* @return mixed
|
||||
*/
|
||||
public function silenceAuth($code, $spread_code = '', $spread_spid = '')
|
||||
{
|
||||
$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);
|
||||
}
|
||||
|
||||
/**
|
||||
* 静默授权 不登录
|
||||
* @param $code
|
||||
* @param string $spread_code
|
||||
* @param string $spread_spid
|
||||
* @return mixed
|
||||
* @throws \Psr\SimpleCache\InvalidArgumentException
|
||||
*/
|
||||
public function silenceAuthNoLogin($code, $spread_code = '', $spread_spid = '')
|
||||
{
|
||||
@ -107,7 +134,8 @@ class AuthController
|
||||
* @param string $phone
|
||||
* @param string $captcha
|
||||
* @return mixed
|
||||
* @throws \Psr\SimpleCache\InvalidArgumentException
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function silenceAuthBindingPhone($code = '', $spread_code = '', $spread_spid = '', $phone = '', $captcha = '')
|
||||
{
|
||||
@ -129,31 +157,13 @@ class AuthController
|
||||
}
|
||||
|
||||
/**
|
||||
* 授权获取小程序用户手机号 直接绑定
|
||||
* @param string $code
|
||||
* @param string $iv
|
||||
* @param string $encryptedData
|
||||
* @param string $spread_code
|
||||
* @param string $spread_spid
|
||||
* @param string $key
|
||||
* @return mixed
|
||||
*/
|
||||
public function authBindingPhone($code = '', $iv = '', $encryptedData = '', $spread_code = '', $spread_spid = '', $key = '')
|
||||
{
|
||||
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);
|
||||
} 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)
|
||||
{
|
||||
|
||||
70
crmeb/app/api/middleware/BlockerMiddleware.php
Normal file
70
crmeb/app/api/middleware/BlockerMiddleware.php
Normal file
@ -0,0 +1,70 @@
|
||||
<?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\api\middleware;
|
||||
|
||||
|
||||
use app\Request;
|
||||
use crmeb\exceptions\ApiException;
|
||||
use crmeb\interfaces\MiddlewareInterface;
|
||||
use crmeb\services\CacheService;
|
||||
use think\facade\Config;
|
||||
|
||||
/**
|
||||
* Redis锁
|
||||
* Class BlockerMiddleware
|
||||
* @author 等风来
|
||||
* @email 136327134@qq.com
|
||||
* @date 2023/2/8
|
||||
* @package app\api\middleware
|
||||
*/
|
||||
class BlockerMiddleware implements MiddlewareInterface
|
||||
{
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param \Closure $next
|
||||
* @author 等风来
|
||||
* @email 136327134@qq.com
|
||||
* @date 2022/11/21
|
||||
*/
|
||||
public function handle(Request $request, \Closure $next)
|
||||
{
|
||||
if (Config::get('cache.default') == 'file') {
|
||||
return $next($request);
|
||||
}
|
||||
|
||||
$uid = $request->uid();
|
||||
$key = md5($request->rule()->getRule() . $uid);
|
||||
if (!CacheService::setMutex($key)) {
|
||||
throw new ApiException('请求太过频繁,请稍后再试');
|
||||
}
|
||||
|
||||
$response = $next($request);
|
||||
|
||||
$this->after($response, $key);
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $response
|
||||
* @param $key
|
||||
* @author 等风来
|
||||
* @email 136327134@qq.com
|
||||
* @date 2022/11/22
|
||||
*/
|
||||
public function after($response, $key)
|
||||
{
|
||||
CacheService::delMutex($key);
|
||||
}
|
||||
}
|
||||
@ -28,7 +28,7 @@ Route::group('pc', function () {
|
||||
Route::get('get_banner', 'pc.HomeController/getBanner')->name('getBanner');//PC首页轮播图
|
||||
Route::get('get_category_product', 'pc.HomeController/getCategoryProduct')->name('getCategoryProduct');//首页分类尚品
|
||||
Route::get('get_products', 'pc.ProductController/getProductList')->name('getProductList');//商品列表
|
||||
Route::get('get_product_code/:product_id', 'pc.ProductController/getProductRoutineCode')->name('getProductRoutineCode');//商品详情小程序二维码
|
||||
Route::get('get_product_code/:product_id/[:type]', 'pc.ProductController/getProductRoutineCode')->name('getProductRoutineCode');//商品详情小程序二维码
|
||||
Route::get('get_city/:pid', 'pc.PublicController/getCity')->name('getCity');//获取城市数据
|
||||
Route::get('check_order_status/:order_id/:end_time', 'pc.OrderController/checkOrderStatus')->name('checkOrderStatus');//轮询订单状态接口
|
||||
Route::get('get_company_info', 'pc.PublicController/getCompanyInfo')->name('getCompanyInfo');//获取公司信息
|
||||
|
||||
@ -9,6 +9,7 @@
|
||||
// | Author: CRMEB Team <admin@crmeb.com>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
use app\api\middleware\BlockerMiddleware;
|
||||
use think\facade\Route;
|
||||
use think\facade\Config;
|
||||
use think\Response;
|
||||
@ -134,7 +135,7 @@ Route::group(function () {
|
||||
Route::get('sign/list', 'v1.user.UserSignController/sign_list')->name('signList');//签到列表
|
||||
Route::get('sign/month', 'v1.user.UserSignController/sign_month')->name('signIntegral');//签到列表(年月)
|
||||
Route::post('sign/user', 'v1.user.UserSignController/sign_user')->name('signUser');//签到用户信息
|
||||
Route::post('sign/integral', 'v1.user.UserSignController/sign_integral')->name('signIntegral');//签到
|
||||
Route::post('sign/integral', 'v1.user.UserSignController/sign_integral')->name('signIntegral')->middleware(BlockerMiddleware::class);//签到
|
||||
//优惠券类
|
||||
Route::post('coupon/receive', 'v1.store.StoreCouponsController/receive')->name('couponReceive'); //领取优惠券
|
||||
Route::post('coupon/receive/batch', 'v1.store.StoreCouponsController/receive_batch')->name('couponReceiveBatch'); //批量领取优惠券
|
||||
@ -151,14 +152,14 @@ Route::group(function () {
|
||||
Route::post('order/check_shipping', 'v1.order.StoreOrderController/checkShipping')->name('checkShipping'); //检测是否显示快递和自提标签
|
||||
Route::post('order/confirm', 'v1.order.StoreOrderController/confirm')->name('orderConfirm'); //订单确认
|
||||
Route::post('order/computed/:key', 'v1.order.StoreOrderController/computedOrder')->name('computedOrder'); //计算订单金额
|
||||
Route::post('order/create/:key', 'v1.order.StoreOrderController/create')->name('orderCreate'); //订单创建
|
||||
Route::post('order/create/:key', 'v1.order.StoreOrderController/create')->name('orderCreate')->middleware(BlockerMiddleware::class); //订单创建
|
||||
Route::get('order/data', 'v1.order.StoreOrderController/data')->name('orderData'); //订单统计数据
|
||||
Route::get('order/list', 'v1.order.StoreOrderController/lst')->name('orderList'); //订单列表
|
||||
Route::get('order/detail/:uni/[:cartId]', 'v1.order.StoreOrderController/detail')->name('orderDetail'); //订单详情
|
||||
Route::get('order/refund_detail/:uni/[:cartId]', 'v1.order.StoreOrderController/refund_detail')->name('refundDetail'); //退款订单详情
|
||||
Route::get('order/refund/reason', 'v1.order.StoreOrderController/refund_reason')->name('orderRefundReason'); //订单退款理由
|
||||
Route::post('order/refund/verify', 'v1.order.StoreOrderController/refund_verify')->name('orderRefundVerify'); //订单退款审核
|
||||
Route::post('order/take', 'v1.order.StoreOrderController/take')->name('orderTake'); //订单收货
|
||||
Route::get('order/refund/reason', 'v1.order.StoreOrderController/refund_reason')->name('orderRefundReason')->middleware(BlockerMiddleware::class); //订单退款理由
|
||||
Route::post('order/refund/verify', 'v1.order.StoreOrderController/refund_verify')->name('orderRefundVerify')->middleware(BlockerMiddleware::class); //订单退款审核
|
||||
Route::post('order/take', 'v1.order.StoreOrderController/take')->name('orderTake')->middleware(BlockerMiddleware::class); //订单收货
|
||||
Route::get('order/express/:uni/[:type]', 'v1.order.StoreOrderController/express')->name('orderExpress'); //订单查看物流
|
||||
Route::post('order/del', 'v1.order.StoreOrderController/del')->name('orderDel'); //订单删除
|
||||
Route::post('order/again', 'v1.order.StoreOrderController/again')->name('orderAgain'); //订单 再次下单
|
||||
@ -287,6 +288,7 @@ Route::group(function () {
|
||||
Route::get('search/keyword', 'v1.PublicController/search')->name('searchKeyword');//热门搜索关键字获取
|
||||
//商品分类类
|
||||
Route::get('category', 'v1.store.CategoryController/category')->name('category');
|
||||
Route::get('category_version', 'v1.store.CategoryController/getCategoryVersion')->name('getCategoryVersion');//商品分类类版本
|
||||
//商品类
|
||||
Route::post('image_base64', 'v1.PublicController/get_image_base64')->name('getImageBase64');// 获取图片base64
|
||||
Route::get('product/detail/:id/[:type]', 'v1.store.StoreProductController/detail')->name('detail');//商品详情
|
||||
@ -388,6 +390,30 @@ Route::group(function () {
|
||||
Route::get('get_lang_json', 'v1.PublicController/getLangJson')->name('getLangJson');
|
||||
//获取当前后台设置的默认语言类型
|
||||
Route::get('get_default_lang_type', 'v1.PublicController/getDefaultLangType')->name('getLangJson');
|
||||
|
||||
/** 定时任务接口 */
|
||||
//检测定时任务接口
|
||||
Route::get('timer/check', 'v1.TimerController/timerCheck')->name('timerCheck');
|
||||
//未支付自动取消订单
|
||||
Route::get('timer/order_cancel', 'v1.TimerController/orderUnpaidCancel')->name('orderUnpaidCancel');
|
||||
//拼团到期订单处理
|
||||
Route::get('timer/pink_expiration', 'v1.TimerController/pinkExpiration')->name('pinkExpiration');
|
||||
//自动解绑上级绑定
|
||||
Route::get('timer/agent_unbind', 'v1.TimerController/agentUnbind')->name('agentUnbind');
|
||||
//更新直播商品状态
|
||||
Route::get('timer/live_product_status', 'v1.TimerController/syncGoodStatus')->name('syncGoodStatus');
|
||||
//更新直播间状态
|
||||
Route::get('timer/live_room_status', 'v1.TimerController/syncRoomStatus')->name('syncRoomStatus');
|
||||
//自动收货
|
||||
Route::get('timer/take_delivery', 'v1.TimerController/autoTakeOrder')->name('autoTakeOrder');
|
||||
//查询预售到期商品自动下架
|
||||
Route::get('timer/advance_off', 'v1.TimerController/downAdvance')->name('downAdvance');
|
||||
//自动好评
|
||||
Route::get('timer/product_replay', 'v1.TimerController/autoComment')->name('autoComment');
|
||||
//清除昨日海报
|
||||
Route::get('timer/clear_poster', 'v1.TimerController/emptyYesterdayAttachment')->name('emptyYesterdayAttachment');
|
||||
|
||||
|
||||
})->middleware(\app\http\middleware\AllowOriginMiddleware::class)->middleware(\app\api\middleware\StationOpenMiddleware::class)->middleware(\app\api\middleware\AuthTokenMiddleware::class, false);
|
||||
|
||||
Route::miss(function () {
|
||||
|
||||
@ -8,6 +8,7 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: CRMEB Team <admin@crmeb.com>
|
||||
// +----------------------------------------------------------------------
|
||||
use app\api\middleware\BlockerMiddleware;
|
||||
use think\facade\Route;
|
||||
|
||||
/**
|
||||
@ -30,6 +31,7 @@ Route::group('v2', function () {
|
||||
Route::get('wechat/wx_silence_auth_login', 'v2.wechat.WechatController/silenceAuth');
|
||||
//DIY接口
|
||||
Route::get('diy/get_diy/[:name]', 'v2.PublicController/getDiy');
|
||||
Route::get('diy/get_version/[:name]', 'v2.PublicController/getVersion');
|
||||
//是否强制绑定手机号
|
||||
Route::get('bind_status', 'v2.PublicController/bindPhoneStatus');
|
||||
//小程序授权绑定手机号
|
||||
@ -79,9 +81,9 @@ Route::group('v2', function () {
|
||||
//抽奖活动详情
|
||||
Route::get('lottery/info/:factor', 'v2.activity.LuckLotteryController/lotteryInfo')->mame('lotteryInfo');
|
||||
//参与抽奖
|
||||
Route::post('lottery', 'v2.activity.LuckLotteryController/luckLottery')->mame('luckLottery');
|
||||
Route::post('lottery', 'v2.activity.LuckLotteryController/luckLottery')->mame('luckLottery')->middleware(BlockerMiddleware::class);
|
||||
//领取奖品
|
||||
Route::post('lottery/receive', 'v2.activity.LuckLotteryController/lotteryReceive')->mame('lotteryReceive');
|
||||
Route::post('lottery/receive', 'v2.activity.LuckLotteryController/lotteryReceive')->mame('lotteryReceive')->middleware(BlockerMiddleware::class);
|
||||
//抽奖记录
|
||||
Route::get('lottery/record', 'v2.activity.LuckLotteryController/lotteryRecord')->mame('lotteryRecord');
|
||||
|
||||
|
||||
@ -10,6 +10,7 @@
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
// 应用公共文件
|
||||
use app\services\pay\PayServices;
|
||||
use crmeb\services\CacheService;
|
||||
use crmeb\services\HttpService;
|
||||
use Fastknife\Service\ClickWordCaptchaService;
|
||||
@ -22,6 +23,80 @@ use app\services\system\lang\LangCodeServices;
|
||||
use app\services\system\lang\LangCountryServices;
|
||||
use think\facade\Config;
|
||||
|
||||
if (!function_exists('get_pay_type')) {
|
||||
|
||||
/**
|
||||
* @author 等风来
|
||||
* @email 136327134@qq.com
|
||||
* @date 2023/2/9
|
||||
* @param string $paytype
|
||||
* @return string
|
||||
*/
|
||||
function get_pay_type(string $paytype)
|
||||
{
|
||||
$wechatPay = (int)sys_config('pay_weixin_open') == 1;
|
||||
$allinPay = (int)sys_config('allin_pay_status') == 1;
|
||||
//微信支付没有开启,通联支付开启,用户访问端在小程序或者公众号的时候,使用通联微信H5支付
|
||||
if ($paytype == PayServices::WEIXIN_PAY && !$wechatPay && $allinPay && (request()->isRoutine() || request()->isWechat())) {
|
||||
$paytype = PayServices::ALLIN_PAY;
|
||||
}
|
||||
|
||||
$aliPay = (bool)sys_config('ali_pay_status');
|
||||
//支付宝没有开启,通联支付开了,用户使用支付宝支付,并且在app端访问的时候,使用通联app支付宝支付
|
||||
if (!$aliPay && $paytype == PayServices::ALIAPY_PAY && request()->isApp()) {
|
||||
$paytype = PayServices::ALLIN_PAY;
|
||||
}
|
||||
return $paytype;
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('is_wechat_pay')) {
|
||||
/**
|
||||
* @return bool
|
||||
* @author 等风来
|
||||
* @email 136327134@qq.com
|
||||
* @date 2023/2/8
|
||||
*/
|
||||
function is_wecaht_pay()
|
||||
{
|
||||
$wechatPay = (int)sys_config('pay_weixin_open') == 1;
|
||||
$allinPay = (int)sys_config('allin_pay_status') == 1;
|
||||
|
||||
if ($wechatPay) {
|
||||
return true;
|
||||
} else {
|
||||
if ((request()->isRoutine() || request()->isWechat()) && $allinPay) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('is_ali_pay')) {
|
||||
/**
|
||||
* @return bool
|
||||
* @author 等风来
|
||||
* @email 136327134@qq.com
|
||||
* @date 2023/2/8
|
||||
*/
|
||||
function is_ali_pay()
|
||||
{
|
||||
$aliPay = (bool)sys_config('ali_pay_status');
|
||||
$allinPay = (int)sys_config('allin_pay_status') == 1;
|
||||
|
||||
if ($aliPay) {
|
||||
return true;
|
||||
} else {
|
||||
if (request()->isApp() && $allinPay) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('getWorkerManUrl')) {
|
||||
|
||||
/**
|
||||
@ -946,7 +1021,7 @@ if (!function_exists('getLang')) {
|
||||
$typeId = $langCountryServices->value(['code' => $range], 'type_id') ?: 1;
|
||||
|
||||
// 获取类型
|
||||
$langData = CacheService::redisHandler()->remember('lang_type_data', function () use ($langTypeServices) {
|
||||
$langData = CacheService::remember('lang_type_data', function () use ($langTypeServices) {
|
||||
return $langTypeServices->getColumn(['status' => 1, 'is_del' => 0], 'file_name', 'id');
|
||||
}, 3600);
|
||||
|
||||
@ -954,7 +1029,7 @@ if (!function_exists('getLang')) {
|
||||
$langStr = 'lang_' . str_replace('-', '_', $langData[$typeId]);
|
||||
|
||||
//读取当前语言的语言包
|
||||
$lang = CacheService::redisHandler()->remember($langStr, function () use ($typeId, $range, $langCodeServices) {
|
||||
$lang = CacheService::remember($langStr, function () use ($typeId, $range, $langCodeServices) {
|
||||
return $langCodeServices->getColumn(['type_id' => $typeId, 'is_admin' => 1], 'lang_explain', 'code');
|
||||
}, 3600);
|
||||
//获取返回文字
|
||||
|
||||
@ -126,6 +126,17 @@ abstract class BaseDao
|
||||
return $this->getModel()->getPk();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
* @author 等风来
|
||||
* @email 136327134@qq.com
|
||||
* @date 2023/2/8
|
||||
*/
|
||||
public function getTableName()
|
||||
{
|
||||
return $this->getModel()->getName();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取一条数据
|
||||
* @param $id
|
||||
|
||||
@ -23,8 +23,7 @@ return [
|
||||
'LogLevel' => [],
|
||||
'LogWrite' => [],
|
||||
'queue.start' => [\app\listener\queue\QueueStart::class],
|
||||
'user.login' => [\app\listener\user\Login::class], //
|
||||
'admin.info' => [\app\listener\admin\AdminInfo::class],//管理员登录前获取登录信息事件
|
||||
'user.login' => [\app\listener\user\Login::class],
|
||||
'admin.login' => [\app\listener\admin\AdminLogin::class],//管理员登录
|
||||
'user.register' => [\app\listener\user\Register::class], //用户注册后置事件
|
||||
'wechat.auth' => [\app\listener\wechat\Auth::class], //用户授权后置事件
|
||||
|
||||
@ -26,8 +26,7 @@ class CheckQueueJob extends BaseJobs
|
||||
{
|
||||
use QueueTrait;
|
||||
|
||||
|
||||
public function handle($key)
|
||||
public function doJob($key)
|
||||
{
|
||||
$path = root_path('runtime') . '.queue';
|
||||
file_put_contents($path, $key);
|
||||
|
||||
@ -31,11 +31,11 @@ class OutPushJob extends BaseJobs
|
||||
/** @var OutStoreOrderServices $services */
|
||||
$services = app()->make(OutStoreOrderServices::class);
|
||||
if (!$services->orderCreatePush($oid, $pushUrl)) {
|
||||
OutPushJob::dispatchSece(($step + 1) * 5, 'orderCreate', [$oid, $pushUrl, $step + 1]);
|
||||
OutPushJob::dispatchSecs(($step + 1) * 5, 'orderCreate', [$oid, $pushUrl, $step + 1]);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
Log::error('订单' . $oid . '推送失败,失败原因:' . $e->getMessage());
|
||||
OutPushJob::dispatchSece(($step + 1) * 5, 'orderCreate', [$oid, $pushUrl, $step + 1]);
|
||||
OutPushJob::dispatchSecs(($step + 1) * 5, 'orderCreate', [$oid, $pushUrl, $step + 1]);
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -59,11 +59,11 @@ class OutPushJob extends BaseJobs
|
||||
/** @var OutStoreOrderServices $services */
|
||||
$services = app()->make(OutStoreOrderServices::class);
|
||||
if (!$services->paySuccessPush($oid, $pushUrl)) {
|
||||
OutPushJob::dispatchSece(($step + 1) * 5, 'paySuccess', [$oid, $pushUrl, $step + 1]);
|
||||
OutPushJob::dispatchSecs(($step + 1) * 5, 'paySuccess', [$oid, $pushUrl, $step + 1]);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
Log::error('订单支付' . $oid . '推送失败,失败原因:' . $e->getMessage());
|
||||
OutPushJob::dispatchSece(($step + 1) * 5, 'paySuccess', [$oid, $pushUrl, $step + 1]);
|
||||
OutPushJob::dispatchSecs(($step + 1) * 5, 'paySuccess', [$oid, $pushUrl, $step + 1]);
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -87,11 +87,11 @@ class OutPushJob extends BaseJobs
|
||||
/** @var OutStoreOrderRefundServices $services */
|
||||
$services = app()->make(OutStoreOrderRefundServices::class);
|
||||
if (!$services->refundCreatePush($oid, $pushUrl)) {
|
||||
OutPushJob::dispatchSece(($step + 1) * 5, 'refundCreate', [$oid, $pushUrl, $step + 1]);
|
||||
OutPushJob::dispatchSecs(($step + 1) * 5, 'refundCreate', [$oid, $pushUrl, $step + 1]);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
Log::error('售后单' . $oid . '推送失败,失败原因:' . $e->getMessage());
|
||||
OutPushJob::dispatchSece(($step + 1) * 5, 'refundCreate', [$oid, $pushUrl, $step + 1]);
|
||||
OutPushJob::dispatchSecs(($step + 1) * 5, 'refundCreate', [$oid, $pushUrl, $step + 1]);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -114,11 +114,11 @@ class OutPushJob extends BaseJobs
|
||||
/** @var OutStoreOrderRefundServices $services */
|
||||
$services = app()->make(OutStoreOrderRefundServices::class);
|
||||
if (!$services->cancelApplyPush($oid, $pushUrl)) {
|
||||
OutPushJob::dispatchSece(($step + 1) * 5, 'refundCancel', [$oid, $pushUrl, $step + 1]);
|
||||
OutPushJob::dispatchSecs(($step + 1) * 5, 'refundCancel', [$oid, $pushUrl, $step + 1]);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
Log::error('取消售后单' . $oid . '推送失败,失败原因:' . $e->getMessage());
|
||||
OutPushJob::dispatchSece(($step + 1) * 5, 'refundCancel', [$oid, $pushUrl, $step + 1]);
|
||||
OutPushJob::dispatchSecs(($step + 1) * 5, 'refundCancel', [$oid, $pushUrl, $step + 1]);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -141,10 +141,10 @@ class OutPushJob extends BaseJobs
|
||||
/** @var UserServices $services */
|
||||
$services = app()->make(UserServices::class);
|
||||
if (!$services->userUpdate($data, $pushUrl)) {
|
||||
OutPushJob::dispatchSece(($step + 1) * 5, 'userUpdate', [$data, $pushUrl, $step + 1]);
|
||||
OutPushJob::dispatchSecs(($step + 1) * 5, 'userUpdate', [$data, $pushUrl, $step + 1]);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
OutPushJob::dispatchSece(($step + 1) * 5, 'userUpdate', [$data, $pushUrl, $step + 1]);
|
||||
OutPushJob::dispatchSecs(($step + 1) * 5, 'userUpdate', [$data, $pushUrl, $step + 1]);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -47,21 +47,21 @@ class ProductCopyJob extends BaseJobs
|
||||
} else {
|
||||
$d_image = 'http://' . ltrim($image, '\//');
|
||||
}
|
||||
$description_cache = CacheService::getTokenBucket('desc_images_' . $id);
|
||||
$description_cache = CacheService::get('desc_images_' . $id);
|
||||
if ($description_cache === null) {
|
||||
$description_cache = $description;
|
||||
CacheService::setTokenBucket('desc_images_count' . $id, 0);
|
||||
CacheService::set('desc_images_count' . $id, 0);
|
||||
}
|
||||
$res = $copyTaobao->downloadCopyImage($d_image);
|
||||
$description_cache = str_replace($image, $res, $description_cache);
|
||||
$desc_count = CacheService::getTokenBucket('desc_images_count' . $id) + 1;
|
||||
$desc_count = CacheService::get('desc_images_count' . $id) + 1;
|
||||
if ($desc_count == $count) {
|
||||
CacheService::clearToken('desc_images_' . $id);
|
||||
CacheService::clearToken('desc_images_count' . $id);
|
||||
CacheService::delete('desc_images_' . $id);
|
||||
CacheService::delete('desc_images_count' . $id);
|
||||
$storeDescriptionServices->saveDescription((int)$id, $description_cache);
|
||||
} else {
|
||||
CacheService::setTokenBucket('desc_images_' . $id, $description_cache);
|
||||
CacheService::setTokenBucket('desc_images_count' . $id, $desc_count);
|
||||
CacheService::set('desc_images_' . $id, $description_cache);
|
||||
CacheService::set('desc_images_count' . $id, $desc_count);
|
||||
}
|
||||
} catch (\Throwable $e) {
|
||||
Log::error('下载商品详情图片失败,失败原因:' . $e->getMessage());
|
||||
@ -86,20 +86,20 @@ class ProductCopyJob extends BaseJobs
|
||||
//下载图片
|
||||
$res = $copyTaobao->downloadCopyImage($image);
|
||||
//获取缓存中的轮播图
|
||||
$slider_images = CacheService::getTokenBucket('slider_images_' . $id);
|
||||
$slider_images = CacheService::get('slider_images_' . $id);
|
||||
//缓存为null则赋值[]
|
||||
if ($slider_images === null) $slider_images = [];
|
||||
//将下载的图片插入数组
|
||||
array_push($slider_images, $res);
|
||||
//如果$slider_images中图片数量和传入的$count相等,说明已经下载完成,写入商品表,如果不等则继续插入缓存
|
||||
if (count($slider_images) == $count) {
|
||||
CacheService::clearToken('slider_images_' . $id);
|
||||
CacheService::delete('slider_images_' . $id);
|
||||
$image = $slider_images[0];
|
||||
$slider_images = $slider_images ? json_encode($slider_images) : '';
|
||||
$StoreProductServices->update($id, ['slider_image' => $slider_images, 'image' => $image]);
|
||||
$StoreProductAttrValueServices->update(['product_id' => $id], ['image' => $image]);
|
||||
} else {
|
||||
CacheService::setTokenBucket('slider_images_' . $id, $slider_images);
|
||||
CacheService::set('slider_images_' . $id, $slider_images);
|
||||
}
|
||||
} catch (\Throwable $e) {
|
||||
Log::error('下载商品轮播图片失败,失败原因:' . $e->getMessage());
|
||||
|
||||
@ -29,7 +29,7 @@ class ProductStockJob extends BaseJobs
|
||||
{
|
||||
try {
|
||||
foreach ($data as $key => $item) {
|
||||
ProductStockJob::dispatchDo('calcValueStock', [$key]);
|
||||
ProductStockJob::dispatch('calcValueStock', [$key]);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
Log::error(['msg' => '拆分计算失败,错误原因:' . $e->getMessage(), 'data' => $data]);
|
||||
|
||||
@ -25,25 +25,16 @@ class TaskJob extends BaseJobs
|
||||
{
|
||||
use QueueTrait;
|
||||
|
||||
/**
|
||||
* 修改短信发送记录短信状态
|
||||
*/
|
||||
public function modifyResultCode()
|
||||
{
|
||||
/** @var SmsRecordServices $smsRecord */
|
||||
$smsRecord = app()->make(SmsRecordServices::class);
|
||||
return $smsRecord->modifyResultCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* 清除昨日海报
|
||||
* @return bool
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function emptyYesterdayAttachment()
|
||||
public function emptyYesterdayAttachment(): bool
|
||||
{
|
||||
/** @var SystemAttachmentServices $attach */
|
||||
$attach = app()->make(SystemAttachmentServices::class);
|
||||
return $attach->emptyYesterdayAttachment();
|
||||
$attach->emptyYesterdayAttachment();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -59,7 +59,7 @@ class TemplateJob extends BaseJobs
|
||||
//判断小程序还是公众号,获取数据id
|
||||
$is_type = $type == 'wechat' ? 'is_wechat' : 'is_routine';
|
||||
$key = $is_type == 'is_wechat' ? 'wechat_' . $tempCode : 'routine_' . $tempCode;
|
||||
$tempid = CacheService::get($key, function () use ($type, $tempCode, $is_type) {
|
||||
$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'];
|
||||
|
||||
@ -11,8 +11,8 @@
|
||||
|
||||
namespace app\jobs\notice;
|
||||
|
||||
use app\services\message\notice\EnterpriseWechatService;
|
||||
use crmeb\basic\BaseJobs;
|
||||
use crmeb\services\HttpService;
|
||||
use crmeb\traits\QueueTrait;
|
||||
use think\facade\Log;
|
||||
|
||||
@ -20,45 +20,20 @@ class EnterpriseWechatJob extends BaseJobs
|
||||
{
|
||||
use QueueTrait;
|
||||
|
||||
|
||||
/**
|
||||
* 给企业微信群发送消息
|
||||
* @param $data
|
||||
* @return bool
|
||||
*/
|
||||
public function doJob($data, $url, $ent_wechat_text)
|
||||
public function doJob($data): bool
|
||||
{
|
||||
try {
|
||||
$str = $ent_wechat_text;
|
||||
foreach ($data as $key => $item) {
|
||||
$str = str_replace('{' . $key . '}', $item, $str);
|
||||
}
|
||||
$s = explode('\n', $str);
|
||||
$d = '';
|
||||
foreach ($s as $item) {
|
||||
$d .= $item . "\n>";
|
||||
}
|
||||
$d = substr($d, 0, strlen($d) - 2);
|
||||
$datas = [
|
||||
'msgtype' => 'markdown',
|
||||
'markdown' => ['content' => $d]
|
||||
];
|
||||
HttpService::postRequest($url, json_encode($datas));
|
||||
/** @var EnterpriseWechatService $enterpriseWechatService */
|
||||
$enterpriseWechatService = app()->make(EnterpriseWechatService::class);
|
||||
$enterpriseWechatService->weComSend($data);
|
||||
return true;
|
||||
} catch (\Throwable $e) {
|
||||
} catch (\Exception $e) {
|
||||
Log::error('发送企业群消息失败,失败原因:' . $e->getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
/**
|
||||
* 给企业微信群发送消息
|
||||
*/
|
||||
public function ceshi($data,$url, $ent_wechat_text = '')
|
||||
{
|
||||
$wdata = [
|
||||
'msgtype' => 'markdown',
|
||||
'markdown' => ['content' => '你好啊,测试队列消息'.$url.$ent_wechat_text]
|
||||
];
|
||||
HttpService::postRequest('https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=4d92900f-dc4a-4b2b-8d37-5ce2784dd618', json_encode($wdata));
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -11,13 +11,11 @@
|
||||
|
||||
namespace app\jobs\notice;
|
||||
|
||||
|
||||
use app\services\order\StoreOrderServices;
|
||||
use crmeb\basic\BaseJobs;
|
||||
use crmeb\services\printer\Printer;
|
||||
use crmeb\traits\QueueTrait;
|
||||
use think\facade\Log;
|
||||
|
||||
|
||||
/**
|
||||
* 小票打印
|
||||
* Class PrintJob
|
||||
@ -29,28 +27,18 @@ class PrintJob extends BaseJobs
|
||||
|
||||
/**
|
||||
* 小票打印
|
||||
* @param $type
|
||||
* @param $configData
|
||||
* @param $order
|
||||
* @param $product
|
||||
* @param $id
|
||||
* @return bool|void
|
||||
*/
|
||||
public function doJob($type, $configData, $order, $product)
|
||||
public function doJob($id)
|
||||
{
|
||||
|
||||
try {
|
||||
$printer = new Printer($type, $configData);
|
||||
$printer->setPrinterContent([
|
||||
'name' => sys_config('site_name'),
|
||||
'url' => sys_config('site_url'),
|
||||
'orderInfo' => is_object($order) ? $order->toArray() : $order,
|
||||
'product' => $product
|
||||
])->startPrinter();
|
||||
/** @var StoreOrderServices $orderServices */
|
||||
$orderServices = app()->make(StoreOrderServices::class);
|
||||
$orderServices->orderPrintTicket((int)$id);
|
||||
return true;
|
||||
} catch (\Throwable $e) {
|
||||
Log::error('小票打印失败失败,失败原因:' . $e->getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -37,7 +37,7 @@ class SmsJob extends BaseJobs
|
||||
$smsServices->send(true, $phone, $data, $template);
|
||||
return true;
|
||||
}catch (\Throwable $e) {
|
||||
Log::error('发送企业群消息失败,失败原因:' . $e->getMessage());
|
||||
Log::error('发送短信失败,失败原因:' . $e->getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -94,6 +94,7 @@ class SyncMessageJob extends BaseJobs
|
||||
/**
|
||||
* 同步公众号模版消息
|
||||
* @param $template
|
||||
* @return bool
|
||||
*/
|
||||
public function syncWechat($template)
|
||||
{
|
||||
|
||||
@ -84,9 +84,9 @@ class KefuApiExceptionHandle extends Handle
|
||||
'trace' => $e->getTrace(),
|
||||
'previous' => $e->getPrevious(),
|
||||
] : [];
|
||||
$message = Env::get('app_debug', false) ? '接口报错:' . $e->getMessage() : '很抱歉,系统开小差了';
|
||||
$message = Env::get('app_debug', false) ? $e->getMessage() : '很抱歉,系统开小差了';
|
||||
// 添加自定义异常处理机制
|
||||
if ($e instanceof AuthException || $e instanceof AdminException || $e instanceof ApiException) {
|
||||
if ($e instanceof AuthException || $e instanceof AdminException || $e instanceof ApiException || $e instanceof ValidateException) {
|
||||
return app('json')->make($e->getCode() ?: 400, $message, $massageData);
|
||||
} else {
|
||||
return app('json')->fail($message, $massageData);
|
||||
|
||||
@ -147,7 +147,7 @@ class User extends AuthController
|
||||
public function logout()
|
||||
{
|
||||
$key = trim(ltrim($this->request->header(Config::get('cookie.token_name')), 'Bearer'));
|
||||
CacheService::redisHandler()->delete(md5($key));
|
||||
CacheService::delete(md5($key));
|
||||
return app('json')->success();
|
||||
}
|
||||
|
||||
|
||||
@ -1,32 +0,0 @@
|
||||
<?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\listener\admin;
|
||||
|
||||
|
||||
use app\jobs\CheckQueueJob;
|
||||
use crmeb\interfaces\ListenerInterface;
|
||||
|
||||
/**
|
||||
* 登录前获取信息
|
||||
* Class AdminInfo
|
||||
* @package app\listener\admin
|
||||
*/
|
||||
class AdminInfo implements ListenerInterface
|
||||
{
|
||||
|
||||
public function handle($event): void
|
||||
{
|
||||
CheckQueueJob::dispatch($event);
|
||||
}
|
||||
}
|
||||
@ -11,6 +11,9 @@
|
||||
|
||||
namespace app\listener\notice;
|
||||
|
||||
use app\jobs\notice\EnterpriseWechatJob;
|
||||
use app\jobs\notice\PrintJob;
|
||||
use app\services\order\StoreOrderServices;
|
||||
use app\services\message\notice\{
|
||||
EnterpriseWechatService,
|
||||
RoutineTemplateListService,
|
||||
@ -18,7 +21,6 @@ use app\services\message\notice\{
|
||||
SystemMsgService,
|
||||
WechatTemplateListService
|
||||
};
|
||||
use app\services\message\NoticeService;
|
||||
use app\services\order\StoreOrderCartInfoServices;
|
||||
use app\services\user\UserServices;
|
||||
use crmeb\interfaces\ListenerInterface;
|
||||
@ -36,9 +38,6 @@ class Notice implements ListenerInterface
|
||||
try {
|
||||
[$data, $mark] = $event;
|
||||
|
||||
/** @var NoticeService $NoticeService */
|
||||
$NoticeService = app()->make(NoticeService::class);
|
||||
|
||||
/** @var WechatTemplateListService $WechatTemplateList */
|
||||
$WechatTemplateList = app()->make(WechatTemplateListService::class);
|
||||
|
||||
@ -51,7 +50,7 @@ class Notice implements ListenerInterface
|
||||
/** @var EnterpriseWechatService $EnterpriseWechat */
|
||||
$EnterpriseWechat = app()->make(EnterpriseWechatService::class);
|
||||
|
||||
/** @var SmsService $NoticeSms */
|
||||
/** @var SmsService $NoticeSms */
|
||||
$NoticeSms = app()->make(SmsService::class);
|
||||
|
||||
/** @var StoreOrderCartInfoServices $orderInfoServices */
|
||||
@ -93,7 +92,7 @@ class Notice implements ListenerInterface
|
||||
$RoutineTemplateList->sendOrderSuccess($data['uid'], $data['pay_price'], $data['order_id']);
|
||||
//小票打印
|
||||
if (isset($data['cart_id']) && $data['cart_id']) {
|
||||
$NoticeService->orderPrint($data);
|
||||
PrintJob::dispatch([$data['id']]);
|
||||
}
|
||||
break;
|
||||
//发货给用户
|
||||
@ -355,7 +354,7 @@ class Notice implements ListenerInterface
|
||||
$link = '/pages/admin/orderDetail/index?id=' . $order['order_id'];
|
||||
$WechatTemplateList->sendAdminOrder($order['order_id'], $storeName, $title, $status, $link);
|
||||
//企业微信通知
|
||||
$EnterpriseWechat->sendMsg(['order_id' => $order['order_id']]);
|
||||
EnterpriseWechatJob::dispatch(['order_id' => $order['order_id']]);
|
||||
break;
|
||||
//确认收货给客服
|
||||
case 'send_admin_confirm_take_over':
|
||||
@ -372,7 +371,7 @@ class Notice implements ListenerInterface
|
||||
$link = '/pages/admin/orderDetail/index?id=' . $order['order_id'];
|
||||
$WechatTemplateList->sendAdminOrder($order['order_id'], $storeName, $title, $status, $link);
|
||||
//企业微信通知
|
||||
$EnterpriseWechat->sendMsg(['storeTitle' => $storeTitle, 'order_id' => $order['order_id']]);
|
||||
EnterpriseWechatJob::dispatch(['storeTitle' => $storeTitle, 'order_id' => $order['order_id']]);
|
||||
break;
|
||||
//申请退款给客服发消息
|
||||
case 'send_order_apply_refund':
|
||||
@ -382,7 +381,7 @@ class Notice implements ListenerInterface
|
||||
//短信
|
||||
$NoticeSms->sendAdminRefund($order);
|
||||
//企业微信通知
|
||||
$EnterpriseWechat->sendMsg(['order_id' => $order['order_id']]);
|
||||
EnterpriseWechatJob::dispatch(['order_id' => $order['order_id']]);
|
||||
//公众号
|
||||
$storeName = $orderInfoServices->getCarIdByProductTitle((int)$order['id']);
|
||||
$title = '亲,您有个退款订单待处理!';
|
||||
@ -395,7 +394,7 @@ class Notice implements ListenerInterface
|
||||
//站内信
|
||||
$SystemMsg->kefuSystemSend($data);
|
||||
//企业微信通知
|
||||
$EnterpriseWechat->sendMsg($data);
|
||||
EnterpriseWechatJob::dispatch($data);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@ -33,7 +33,7 @@ class OrderCreateAfter implements ListenerInterface
|
||||
$orderCreate->orderCreateAfter($order, $group, $combinationId || $seckillId || $bargainId);
|
||||
|
||||
//清除订单缓存
|
||||
CacheService::redisHandler()->delete('user_order_' . $uid . $key);
|
||||
CacheService::delete('user_order_' . $uid . $key);
|
||||
|
||||
//写入订单记录表
|
||||
/** @var StoreOrderStatusServices $statusService */
|
||||
@ -81,8 +81,8 @@ class OrderCreateAfter implements ListenerInterface
|
||||
$secs = $systemValue['order_cancel_time'];
|
||||
}
|
||||
//未支付10分钟后发送短信
|
||||
UnpaidOrderSend::dispatchSece(600, [$orderId]);
|
||||
UnpaidOrderSend::dispatchSecs(600, [$orderId]);
|
||||
//未支付根据系统设置事件取消订单
|
||||
UnpaidOrderCancelJob::dispatchSece((int)($secs * 3600), [$orderId]);
|
||||
UnpaidOrderCancelJob::dispatchSecs((int)($secs * 3600), [$orderId]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -22,7 +22,7 @@ class OrderDelivery implements ListenerInterface
|
||||
$time = sys_config('system_delivery_time') ?? 0;
|
||||
if ($time != 0) {
|
||||
$sevenDay = 24 * 3600 * $time;
|
||||
TakeOrderJob::dispatchSece((int)$sevenDay, [$orderInfo->id]);
|
||||
TakeOrderJob::dispatchSecs((int)$sevenDay, [$orderInfo->id]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -21,15 +21,15 @@ class OutPush implements ListenerInterface
|
||||
if ($item['push_open'] == 1) {
|
||||
$token = $this->getPushToken($item);
|
||||
if ($type == 'order_create_push') {
|
||||
OutPushJob::dispatchDo('orderCreate', [$data['order_id'], $item['order_create_push'] . '?pushToken=' . $token]);
|
||||
OutPushJob::dispatch('orderCreate', [$data['order_id'], $item['order_create_push'] . '?pushToken=' . $token]);
|
||||
} elseif ($type == 'order_pay_push') {
|
||||
OutPushJob::dispatchDo('paySuccess', [$data['order_id'], $item['order_pay_push'] . '?pushToken=' . $token]);
|
||||
OutPushJob::dispatch('paySuccess', [$data['order_id'], $item['order_pay_push'] . '?pushToken=' . $token]);
|
||||
} elseif ($type == 'refund_create_push') {
|
||||
OutPushJob::dispatchDo('refundCreate', [$data['order_id'], $item['refund_create_push'] . '?pushToken=' . $token]);
|
||||
OutPushJob::dispatch('refundCreate', [$data['order_id'], $item['refund_create_push'] . '?pushToken=' . $token]);
|
||||
} elseif ($type == 'refund_cancel_push') {
|
||||
OutPushJob::dispatchDo('refundCancel', [$data['order_id'], $item['refund_cancel_push'] . '?pushToken=' . $token]);
|
||||
OutPushJob::dispatch('refundCancel', [$data['order_id'], $item['refund_cancel_push'] . '?pushToken=' . $token]);
|
||||
} elseif ($type == 'user_update_push') {
|
||||
OutPushJob::dispatchDo('userUpdate', [$data, $item['user_update_push'] . '?pushToken=' . $token]);
|
||||
OutPushJob::dispatch('userUpdate', [$data, $item['user_update_push'] . '?pushToken=' . $token]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -42,7 +42,7 @@ class OutPush implements ListenerInterface
|
||||
*/
|
||||
public function getPushToken(array $info)
|
||||
{
|
||||
$token = CacheService::redisHandler()->get('pushToken' . $info['id']);
|
||||
$token = CacheService::get('pushToken' . $info['id']);
|
||||
if (!$token) {
|
||||
$param = json_encode(['push_account' => $info['push_account'], 'push_password' => $info['push_password']], JSON_UNESCAPED_UNICODE);
|
||||
$res = HttpService::postRequest($info['push_token_url'], $param, ['Content-Type:application/json', 'Content-Length:' . strlen($param)]);
|
||||
@ -51,7 +51,7 @@ class OutPush implements ListenerInterface
|
||||
Log::error(['msg' => $info['title'] . ',获取token失败']);
|
||||
return false;
|
||||
}
|
||||
CacheService::redisHandler()->set('pushToken' . $info['id'], $res['token'], $res['time']);
|
||||
CacheService::set('pushToken' . $info['id'], $res['token'], $res['time']);
|
||||
return $res['token'];
|
||||
} else {
|
||||
return $token;
|
||||
|
||||
@ -30,12 +30,12 @@ class SystemTimer implements ListenerInterface
|
||||
foreach ($list as &$item) {
|
||||
//获取定时任务时间字符串
|
||||
$timeStr = $this->getTimerStr($item);
|
||||
Log::error('mark:'.$item['mark']);
|
||||
Log::error($timeStr);
|
||||
// Log::error('mark:'.$item['mark']);
|
||||
// Log::error($timeStr);
|
||||
|
||||
if ($item['mark'] == 'order_cancel') {
|
||||
new Crontab($timeStr, function () {
|
||||
Log::error('每隔30秒执行一次自动取消订单 '.date('Y-m-d H:i:s'));
|
||||
// Log::error('每隔30秒执行一次自动取消订单 '.date('Y-m-d H:i:s'));
|
||||
//未支付自动取消订单
|
||||
try {
|
||||
/** @var StoreOrderServices $orderServices */
|
||||
@ -49,7 +49,7 @@ class SystemTimer implements ListenerInterface
|
||||
|
||||
if ($item['mark'] == 'pink_expiration') {
|
||||
new Crontab($timeStr, function () {
|
||||
Log::error('每隔1分钟执行一次拼团到期订单处理 '.date('Y-m-d H:i:s'));
|
||||
// Log::error('每隔1分钟执行一次拼团到期订单处理 '.date('Y-m-d H:i:s'));
|
||||
//拼团到期订单处理
|
||||
try {
|
||||
/** @var StorePinkServices $storePinkServices */
|
||||
@ -63,7 +63,7 @@ class SystemTimer implements ListenerInterface
|
||||
|
||||
if ($item['mark'] == 'agent_unbind') {
|
||||
new Crontab($timeStr, function () {
|
||||
Log::error('每隔1分钟执行一次自动解除上级绑定 '.date('Y-m-d H:i:s'));
|
||||
// Log::error('每隔1分钟执行一次自动解除上级绑定 '.date('Y-m-d H:i:s'));
|
||||
//自动解绑上级绑定
|
||||
try {
|
||||
/** @var AgentManageServices $agentManage */
|
||||
@ -77,7 +77,7 @@ class SystemTimer implements ListenerInterface
|
||||
|
||||
if ($item['mark'] == 'live_product_status') {
|
||||
new Crontab($timeStr, function () {
|
||||
Log::error('每隔3分钟执行一次更新直播商品状态 '.date('Y-m-d H:i:s'));
|
||||
// Log::error('每隔3分钟执行一次更新直播商品状态 '.date('Y-m-d H:i:s'));
|
||||
//更新直播商品状态
|
||||
try {
|
||||
/** @var LiveGoodsServices $liveGoods */
|
||||
@ -91,7 +91,7 @@ class SystemTimer implements ListenerInterface
|
||||
|
||||
if ($item['mark'] == 'live_room_status') {
|
||||
new Crontab($timeStr, function () {
|
||||
Log::error('每隔3分钟执行一次更新直播间状态 '.date('Y-m-d H:i:s'));
|
||||
// Log::error('每隔3分钟执行一次更新直播间状态 '.date('Y-m-d H:i:s'));
|
||||
//更新直播间状态
|
||||
try {
|
||||
/** @var LiveRoomServices $liveRoom */
|
||||
@ -105,7 +105,7 @@ class SystemTimer implements ListenerInterface
|
||||
|
||||
if ($item['mark'] == 'take_delivery') {
|
||||
new Crontab($timeStr, function () {
|
||||
Log::error('每隔5分钟执行一次自动收货 '.date('Y-m-d H:i:s'));
|
||||
// Log::error('每隔5分钟执行一次自动收货 '.date('Y-m-d H:i:s'));
|
||||
//自动收货
|
||||
try {
|
||||
/** @var StoreOrderTakeServices $services */
|
||||
@ -119,7 +119,7 @@ class SystemTimer implements ListenerInterface
|
||||
|
||||
if ($item['mark'] == 'advance_off') {
|
||||
new Crontab($timeStr, function () {
|
||||
Log::error('每隔5分钟执行一次查询预售到期商品自动下架 '.date('Y-m-d H:i:s'));
|
||||
// Log::error('每隔5分钟执行一次查询预售到期商品自动下架 '.date('Y-m-d H:i:s'));
|
||||
//查询预售到期商品自动下架
|
||||
try {
|
||||
/** @var StoreProductServices $product */
|
||||
@ -133,7 +133,7 @@ class SystemTimer implements ListenerInterface
|
||||
|
||||
if ($item['mark'] == 'product_replay') {
|
||||
new Crontab($timeStr, function () {
|
||||
Log::error('每隔5分钟执行一次自动好评 '.date('Y-m-d H:i:s'));
|
||||
// Log::error('每隔5分钟执行一次自动好评 '.date('Y-m-d H:i:s'));
|
||||
//自动好评
|
||||
try {
|
||||
/** @var StoreOrderServices $orderServices */
|
||||
@ -145,9 +145,9 @@ class SystemTimer implements ListenerInterface
|
||||
});
|
||||
}
|
||||
|
||||
if ($item['mark'] == 'product_replay') {
|
||||
if ($item['mark'] == 'clear_poster') {
|
||||
new Crontab($timeStr, function () {
|
||||
Log::error('每天0时30分0秒执行一次清除昨日海报 '.date('Y-m-d H:i:s'));
|
||||
// Log::error('每天0时30分0秒执行一次清除昨日海报 '.date('Y-m-d H:i:s'));
|
||||
//清除昨日海报
|
||||
try {
|
||||
/** @var SystemAttachmentServices $attach */
|
||||
|
||||
@ -84,9 +84,9 @@ class OutApiExceptionHandle extends Handle
|
||||
'trace' => $e->getTrace(),
|
||||
'previous' => $e->getPrevious(),
|
||||
] : [];
|
||||
$message = Env::get('app_debug', false) ? '接口报错:' . $e->getMessage() : '很抱歉,系统开小差了';
|
||||
$message = Env::get('app_debug', false) ? $e->getMessage() : '很抱歉,系统开小差了';
|
||||
// 添加自定义异常处理机制
|
||||
if ($e instanceof AuthException || $e instanceof AdminException || $e instanceof ApiException) {
|
||||
if ($e instanceof AuthException || $e instanceof AdminException || $e instanceof ApiException || $e instanceof ValidateException) {
|
||||
return app('json')->make($e->getCode() ?: 400, $message, $massageData);
|
||||
} else {
|
||||
return app('json')->fail($message, $massageData);
|
||||
|
||||
@ -67,7 +67,7 @@ class StoreOrder extends AuthController
|
||||
], true);
|
||||
if ($status != '') $data['status'] = $status;
|
||||
$data['is_show'] = 1;
|
||||
$list = CacheService::get('EXPRESS_LIST', function () use ($services, $data) {
|
||||
$list = CacheService::remember('EXPRESS_LIST', function () use ($services, $data) {
|
||||
return $services->express($data);
|
||||
}, 86400);
|
||||
return app('json')->success($list);
|
||||
|
||||
@ -11,6 +11,7 @@
|
||||
|
||||
namespace app\services;
|
||||
|
||||
use crmeb\traits\ServicesTrait;
|
||||
use crmeb\utils\JwtAuth;
|
||||
use think\facade\Db;
|
||||
use think\facade\Config;
|
||||
@ -22,6 +23,9 @@ use think\facade\Route as Url;
|
||||
*/
|
||||
abstract class BaseServices
|
||||
{
|
||||
|
||||
use ServicesTrait;
|
||||
|
||||
/**
|
||||
* 模型注入
|
||||
* @var object
|
||||
@ -64,7 +68,9 @@ abstract class BaseServices
|
||||
* 创建token
|
||||
* @param int $id
|
||||
* @param $type
|
||||
* @param string $pwd
|
||||
* @return array
|
||||
* @throws \Psr\SimpleCache\InvalidArgumentException
|
||||
*/
|
||||
public function createToken(int $id, $type, $pwd = '')
|
||||
{
|
||||
|
||||
@ -18,6 +18,7 @@ use app\Request;
|
||||
use app\services\BaseServices;
|
||||
use app\services\order\StoreOrderServices;
|
||||
use app\services\other\PosterServices;
|
||||
use app\services\other\QrcodeServices;
|
||||
use app\services\product\product\StoreCategoryServices;
|
||||
use app\services\product\product\StoreDescriptionServices;
|
||||
use app\services\product\product\StoreProductServices;
|
||||
@ -864,6 +865,7 @@ class StoreBargainServices extends BaseServices
|
||||
* 获取砍价海报信息
|
||||
* @param int $bargainId
|
||||
* @param $user
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
@ -938,6 +940,12 @@ class StoreBargainServices extends BaseServices
|
||||
}
|
||||
} catch (\Throwable $e) {
|
||||
}
|
||||
} else {
|
||||
if (sys_config('share_qrcode', 0) && request()->isWechat()) {
|
||||
/** @var QrcodeServices $qrcodeService */
|
||||
$qrcodeService = app()->make(QrcodeServices::class);
|
||||
$data['url'] = $qrcodeService->getTemporaryQrcode('bargain-' . $bargainId . '-' . $user['uid'], $user['uid'])->url;
|
||||
}
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
@ -17,7 +17,6 @@ use app\dao\activity\bargain\StoreBargainUserHelpDao;
|
||||
use app\services\user\UserServices;
|
||||
use crmeb\exceptions\AdminException;
|
||||
use crmeb\exceptions\ApiException;
|
||||
use crmeb\traits\ServicesTrait;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -29,8 +28,6 @@ use crmeb\traits\ServicesTrait;
|
||||
class StoreBargainUserHelpServices extends BaseServices
|
||||
{
|
||||
|
||||
use ServicesTrait;
|
||||
|
||||
/**
|
||||
* StoreBargainUserHelpServices constructor.
|
||||
* @param StoreBargainUserHelpDao $dao
|
||||
|
||||
@ -386,9 +386,14 @@ class StoreCombinationServices extends BaseServices
|
||||
$storeInfo['userLike'] = false;
|
||||
$storeInfo['store_name'] = $storeInfo['title'];
|
||||
|
||||
/** @var QrcodeServices $qrcodeService */
|
||||
$qrcodeService = app()->make(QrcodeServices::class);
|
||||
$storeInfo['code_base'] = $qrcodeService->getWechatQrcodePath($id . '_product_combination_detail_wap.jpg', '/pages/activity/goods_combination_details/index?id=' . $id);
|
||||
if (sys_config('share_qrcode', 0) && request()->isWechat()) {
|
||||
/** @var QrcodeServices $qrcodeService */
|
||||
$qrcodeService = app()->make(QrcodeServices::class);
|
||||
$storeInfo['wechat_code'] = $qrcodeService->getTemporaryQrcode('combination-' . $id, $uid)->url;
|
||||
} else {
|
||||
$storeInfo['wechat_code'] = '';
|
||||
}
|
||||
|
||||
$data['storeInfo'] = get_thumb_water($storeInfo, 'big', ['image', 'images']);
|
||||
$storeInfoNew = get_thumb_water($storeInfo, 'small');
|
||||
$data['storeInfo']['small_image'] = $storeInfoNew['image'];
|
||||
|
||||
@ -18,6 +18,7 @@ use app\services\BaseServices;
|
||||
use app\services\order\StoreOrderRefundServices;
|
||||
use app\services\order\StoreOrderServices;
|
||||
use app\services\other\PosterServices;
|
||||
use app\services\other\QrcodeServices;
|
||||
use app\services\system\attachment\SystemAttachmentServices;
|
||||
use app\services\user\UserServices;
|
||||
use crmeb\exceptions\ApiException;
|
||||
@ -465,7 +466,7 @@ class StorePinkServices extends BaseServices
|
||||
$number = (int)bcsub((string)$pink['people'], '1', 0);
|
||||
if ($number) CacheService::setStock(md5($pink['id']), $number, 3);
|
||||
|
||||
PinkJob::dispatchSece((int)(($product->effective_time * 3600) + 60), [$pink['id']]);
|
||||
PinkJob::dispatchSecs((int)(($product->effective_time * 3600) + 60), [$pink['id']]);
|
||||
// 开团成功发送模板消息
|
||||
event('notice.notice', [['orderInfo' => $orderInfo, 'title' => $product['title'], 'pink' => $pink], 'open_pink_success']);
|
||||
|
||||
@ -883,6 +884,12 @@ class StorePinkServices extends BaseServices
|
||||
$data['url'] = $url;
|
||||
if ($imageInfo['image_type'] == 1)
|
||||
$data['url'] = $siteUrl . $url;
|
||||
} else {
|
||||
if (sys_config('share_qrcode', 0) && request()->isWechat()) {
|
||||
/** @var QrcodeServices $qrcodeService */
|
||||
$qrcodeService = app()->make(QrcodeServices::class);
|
||||
$data['url'] = $qrcodeService->getTemporaryQrcode('pink-' . $id, $user['uid'])->url;
|
||||
}
|
||||
}
|
||||
} catch (\Throwable $e) {
|
||||
}
|
||||
|
||||
@ -23,7 +23,6 @@ use crmeb\exceptions\AdminException;
|
||||
use crmeb\exceptions\ApiException;
|
||||
use crmeb\services\FormBuilder as Form;
|
||||
use crmeb\services\printer\Printer;
|
||||
use crmeb\traits\ServicesTrait;
|
||||
|
||||
/**
|
||||
* Class StoreIntegralOrderServices
|
||||
@ -35,8 +34,6 @@ use crmeb\traits\ServicesTrait;
|
||||
class StoreIntegralOrderServices extends BaseServices
|
||||
{
|
||||
|
||||
use ServicesTrait;
|
||||
|
||||
/**
|
||||
* 发货类型
|
||||
* @var string[]
|
||||
|
||||
@ -14,7 +14,6 @@ namespace app\services\activity\integral;
|
||||
|
||||
use app\dao\activity\integral\StoreIntegralOrderStatusDao;
|
||||
use app\services\BaseServices;
|
||||
use crmeb\traits\ServicesTrait;
|
||||
|
||||
/**
|
||||
* 订单状态
|
||||
@ -23,7 +22,6 @@ use crmeb\traits\ServicesTrait;
|
||||
*/
|
||||
class StoreIntegralOrderStatusServices extends BaseServices
|
||||
{
|
||||
use ServicesTrait;
|
||||
|
||||
/**
|
||||
* 构造方法
|
||||
|
||||
@ -162,7 +162,7 @@ class LiveAnchorServices extends BaseServices
|
||||
public function syncAnchor($is_job = false)
|
||||
{
|
||||
$key = md5('Live_sync_status');
|
||||
$res = CacheService::redisHandler()->get($key);
|
||||
$res = CacheService::get($key);
|
||||
if (!$res || $is_job) {
|
||||
$start = 0;
|
||||
$limit = 30;
|
||||
@ -187,8 +187,8 @@ class LiveAnchorServices extends BaseServices
|
||||
$this->dao->saveAll($dataAll);
|
||||
}
|
||||
//支付成功后发送消息
|
||||
if (!$is_job) LiveJob::dispatchSece(120);
|
||||
CacheService::redisHandler()->set($key, 1, 0);
|
||||
if (!$is_job) LiveJob::dispatchSecs(120);
|
||||
CacheService::set($key, 1, 0);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -589,8 +589,7 @@ class LuckLotteryServices extends BaseServices
|
||||
return true;
|
||||
}
|
||||
$key = 'user_' . $type . '_luck_lottery_' . $uid;
|
||||
$cache = CacheService::redisHandler();
|
||||
return $cache->set($key, $lottery['factor_num'], 120);
|
||||
return CacheService::set($key, $lottery['factor_num'], 120);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -603,7 +602,7 @@ class LuckLotteryServices extends BaseServices
|
||||
public function getCacheLotteryNum(int $uid, string $type = 'order')
|
||||
{
|
||||
$key = 'user_' . $type . '_luck_lottery_' . $uid;
|
||||
$num = CacheService::redisHandler()->get($key);
|
||||
$num = CacheService::get($key);
|
||||
return empty($num) ? 0 : $num;
|
||||
}
|
||||
|
||||
@ -618,11 +617,10 @@ class LuckLotteryServices extends BaseServices
|
||||
{
|
||||
$key = 'user_' . $type . '_luck_lottery_' . $uid;
|
||||
$num = $this->getCacheLotteryNum($uid, $type);
|
||||
$cache = CacheService::redisHandler();
|
||||
if ($num > 1) {
|
||||
$cache->set($key, $num - 1, 120);
|
||||
CacheService::set($key, $num - 1, 120);
|
||||
} else {
|
||||
$cache->delete($key);
|
||||
CacheService::delete($key);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -478,9 +478,13 @@ class StoreSeckillServices extends BaseServices
|
||||
$productInfo = $storeProductService->get($storeInfo['product_id']);
|
||||
$storeInfo['total'] = $productInfo['sales'] + $productInfo['ficti'];
|
||||
|
||||
/** @var QrcodeServices $qrcodeService */
|
||||
$qrcodeService = app()->make(QrcodeServices::class);
|
||||
$storeInfo['code_base'] = $qrcodeService->getWechatQrcodePath($id . '_' . $uid . '_product_seckill_detail_wap.jpg', '/pages/activity/goods_seckill_details/index?id=' . $id . '&spread=' . $uid);
|
||||
if (sys_config('share_qrcode', 0) && request()->isWechat()) {
|
||||
/** @var QrcodeServices $qrcodeService */
|
||||
$qrcodeService = app()->make(QrcodeServices::class);
|
||||
$storeInfo['wechat_code'] = $qrcodeService->getTemporaryQrcode('seckill-' . $id, $uid)->url;
|
||||
} else {
|
||||
$storeInfo['wechat_code'] = '';
|
||||
}
|
||||
|
||||
/** @var StoreOrderServices $storeOrderServices */
|
||||
$storeOrderServices = app()->make(StoreOrderServices::class);
|
||||
@ -513,7 +517,7 @@ class StoreSeckillServices extends BaseServices
|
||||
if ($storeInfo['status'] == 1) {
|
||||
if ($storeInfo['start_time'] > time()) {
|
||||
$storeInfo['status'] = 2;
|
||||
} elseif ($storeInfo['stop_time'] < time()) {
|
||||
} elseif (($storeInfo['stop_time'] + 86400) < time()) {
|
||||
$storeInfo['status'] = 0;
|
||||
} else {
|
||||
/** @var SystemGroupDataServices $systemGroupDataService */
|
||||
@ -612,7 +616,7 @@ class StoreSeckillServices extends BaseServices
|
||||
$cache = app()->make(CacheService::class);
|
||||
$res = true;
|
||||
if (!$isPush) {
|
||||
$cache->del($name);
|
||||
$cache->delete($name);
|
||||
}
|
||||
for ($i = 1; $i <= $number; $i++) {
|
||||
$res = $res && $cache->lPush($name, $i);
|
||||
@ -689,7 +693,7 @@ class StoreSeckillServices extends BaseServices
|
||||
{
|
||||
/** @var CacheService $cache */
|
||||
$cache = app()->make(CacheService::class);
|
||||
return $cache->redisHandler()->lLen('seckill_' . $unique . '_' . $type) >= $number;
|
||||
return $cache->lLen('seckill_' . $unique . '_' . $type) >= $number;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -14,6 +14,7 @@ use crmeb\exceptions\AdminException;
|
||||
use crmeb\exceptions\ApiException;
|
||||
use crmeb\services\FormBuilder as Form;
|
||||
use app\services\other\UploadService;
|
||||
use think\facade\Log;
|
||||
use think\facade\Route;
|
||||
|
||||
class DivisionAgentApplyServices extends BaseServices
|
||||
@ -202,26 +203,32 @@ class DivisionAgentApplyServices extends BaseServices
|
||||
$item['orderCount'] = $item['pay_count'];
|
||||
$item['numberCount'] = $orderService->sum(['uid' => $item['uid']], 'pay_price');
|
||||
}
|
||||
/** @var SystemAttachmentServices $systemAttachment */
|
||||
$systemAttachment = app()->make(SystemAttachmentServices::class);
|
||||
$name = 'agent_' . $where['agent_id'] . '.jpg';
|
||||
$siteUrl = sys_config('site_url', '');
|
||||
$imageInfo = $systemAttachment->getInfo(['name' => $name]);
|
||||
if (!$imageInfo) {
|
||||
/** @var QrcodeServices $qrCode */
|
||||
$qrCode = app()->make(QrcodeServices::class);
|
||||
//公众号
|
||||
$resCode = $qrCode->getForeverQrcode('agent', $where['agent_id']);
|
||||
if ($resCode) {
|
||||
$res = ['res' => $resCode, 'id' => $resCode['id']];
|
||||
} else {
|
||||
$res = false;
|
||||
$codeUrl = '';
|
||||
try {
|
||||
/** @var SystemAttachmentServices $systemAttachment */
|
||||
$systemAttachment = app()->make(SystemAttachmentServices::class);
|
||||
$name = 'agent_' . $where['agent_id'] . '.jpg';
|
||||
$siteUrl = sys_config('site_url', '');
|
||||
$imageInfo = $systemAttachment->getInfo(['name' => $name]);
|
||||
if (!$imageInfo) {
|
||||
/** @var QrcodeServices $qrCode */
|
||||
$qrCode = app()->make(QrcodeServices::class);
|
||||
//公众号
|
||||
$resCode = $qrCode->getForeverQrcode('agent', $where['agent_id']);
|
||||
if ($resCode) {
|
||||
$res = ['res' => $resCode, 'id' => $resCode['id']];
|
||||
} else {
|
||||
$res = false;
|
||||
}
|
||||
if (!$res) throw new ApiException(410167);
|
||||
$imageInfo = $this->downloadImage($resCode['url'], $name);
|
||||
$systemAttachment->attachmentAdd($name, $imageInfo['size'], $imageInfo['type'], $imageInfo['att_dir'], $imageInfo['att_dir'], 1, $imageInfo['image_type'], time(), 2);
|
||||
}
|
||||
if (!$res) throw new ApiException(410167);
|
||||
$imageInfo = $this->downloadImage($resCode['url'], $name);
|
||||
$systemAttachment->attachmentAdd($name, $imageInfo['size'], $imageInfo['type'], $imageInfo['att_dir'], $imageInfo['att_dir'], 1, $imageInfo['image_type'], time(), 2);
|
||||
$codeUrl = strpos($imageInfo['att_dir'], 'http') === false ? $siteUrl . $imageInfo['att_dir'] : $imageInfo['att_dir'];
|
||||
} catch (\Exception $e) {
|
||||
Log::error('邀请员工二维码生成失败,失败原因' . $e->getMessage());
|
||||
}
|
||||
$codeUrl = strpos($imageInfo['att_dir'], 'http') === false ? $siteUrl . $imageInfo['att_dir'] : $imageInfo['att_dir'];
|
||||
|
||||
return compact('list', 'count', 'codeUrl');
|
||||
}
|
||||
|
||||
|
||||
@ -68,7 +68,7 @@ class DiyServices extends BaseServices
|
||||
* @param int $id
|
||||
* @param array $data
|
||||
*/
|
||||
public function saveData(int $id = 0, array $data)
|
||||
public function saveData(int $id = 0, array $data = [])
|
||||
{
|
||||
if ($id) {
|
||||
$data['update_time'] = time();
|
||||
@ -81,6 +81,11 @@ class DiyServices extends BaseServices
|
||||
if (!$res) throw new AdminException(100006);
|
||||
$id = $res->id;
|
||||
}
|
||||
|
||||
$this->cacheDriver()->clear();
|
||||
$this->cacheDriver()->set('index_diy_' . $id, $data['version']);
|
||||
$this->updateCacheDiyVersion();
|
||||
|
||||
return $id;
|
||||
}
|
||||
|
||||
@ -95,6 +100,8 @@ class DiyServices extends BaseServices
|
||||
if ($count) throw new AdminException(400458);
|
||||
$res = $this->dao->update($id, ['is_del' => 1]);
|
||||
if (!$res) throw new AdminException(100008);
|
||||
|
||||
$this->cacheDriver()->clear();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -106,6 +113,47 @@ class DiyServices extends BaseServices
|
||||
$this->dao->update(['is_diy' => 1], ['is_show' => 1, 'type' => 2]);
|
||||
$this->dao->update([['id', '<>', $id]], ['status' => 0]);
|
||||
$this->dao->update($id, ['status' => 1, 'update_time' => time()]);
|
||||
|
||||
$this->cacheDriver()->clear();
|
||||
$this->updateCacheDiyVersion();
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author 等风来
|
||||
* @email 136327134@qq.com
|
||||
* @date 2023/2/8
|
||||
*/
|
||||
public function updateCacheDiyVersion()
|
||||
{
|
||||
$diyInfo = $this->dao->get(['status' => 1, 'is_del' => 0], ['id', 'version']);
|
||||
if (!$diyInfo) {
|
||||
$this->cacheDriver()->delete('index_diy_default');
|
||||
} else {
|
||||
$this->cacheDriver()->set('index_diy_default', $diyInfo['version']);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $id
|
||||
* @return mixed|string|null
|
||||
* @author 等风来
|
||||
* @email 136327134@qq.com
|
||||
* @date 2023/2/8
|
||||
*/
|
||||
public function getDiyVersion(int $id)
|
||||
{
|
||||
if ($id) {
|
||||
return $this->cacheDriver()->remember('index_diy_' . $id, function () use ($id) {
|
||||
return $this->dao->value(['id' => $id], 'version');
|
||||
});
|
||||
} else {
|
||||
return $this->cacheDriver()->remember('index_diy_default', function () {
|
||||
return $this->dao->value(['status' => 1, 'is_del' => 0], 'version');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -119,13 +167,17 @@ class DiyServices extends BaseServices
|
||||
public function getDiy($id = 0)
|
||||
{
|
||||
$field = 'name,value,is_show,is_bg_color,color_picker,bg_pic,bg_tab_val,is_bg_pic,order_status,is_diy,title';
|
||||
if ($id) {
|
||||
$info = $this->dao->getOne(['id' => $id], $field);
|
||||
} else {
|
||||
$info = $this->dao->getOne(['status' => 1, 'is_del' => 0], $field);
|
||||
}
|
||||
|
||||
$info = $this->cacheDriver()->remember('diy_info_' . $id, function () use ($field, $id) {
|
||||
if ($id) {
|
||||
$info = $this->dao->getOne(['id' => $id], $field);
|
||||
} else {
|
||||
$info = $this->dao->getOne(['status' => 1, 'is_del' => 0], $field);
|
||||
}
|
||||
return $info ? $info->toArray() : [];
|
||||
});
|
||||
|
||||
if ($info) {
|
||||
$info = $info->toArray();
|
||||
if ($info['value']) {
|
||||
$info['value'] = json_decode($info['value'], true);
|
||||
if ($info['is_diy']) {
|
||||
@ -345,10 +397,14 @@ class DiyServices extends BaseServices
|
||||
*/
|
||||
public function getNavigation(string $template_name)
|
||||
{
|
||||
$value = $this->dao->value(['status' => 1], 'value');
|
||||
if (!$value) {
|
||||
$value = $this->dao->value(['template_name' => 'default'], 'value');
|
||||
}
|
||||
$value = $this->cacheDriver()->remember('navigation', function () {
|
||||
$value = $this->dao->value(['status' => 1], 'value');
|
||||
if (!$value) {
|
||||
$value = $this->dao->value(['template_name' => 'default'], 'value');
|
||||
}
|
||||
return $value;
|
||||
});
|
||||
|
||||
$navigation = [];
|
||||
if ($value) {
|
||||
$value = json_decode($value, true);
|
||||
|
||||
@ -41,7 +41,7 @@ class PageCategoryServices extends BaseServices
|
||||
*/
|
||||
public function getCategroyList()
|
||||
{
|
||||
return CacheService::get($this->tree_page_category_key, function () {
|
||||
return CacheService::remember($this->tree_page_category_key, function () {
|
||||
return $this->getSonCategoryList();
|
||||
}, 86400);
|
||||
}
|
||||
|
||||
@ -88,17 +88,12 @@ class LoginServices extends BaseServices
|
||||
$cacheService = app()->make(CacheService::class);
|
||||
//检测token是否过期
|
||||
$md5Token = md5($token);
|
||||
if (!$token || !$cacheService->hasToken($md5Token) || !($cacheToken = $cacheService->getTokenBucket($md5Token))) {
|
||||
if (!$token || !$cacheService->has($md5Token) || !($cacheService->get($md5Token, '', NULL, 'kefu'))) {
|
||||
throw new AuthException(110005);
|
||||
}
|
||||
if ($token === 'undefined') {
|
||||
throw new AuthException(110005);
|
||||
}
|
||||
//是否超出有效次数
|
||||
if (isset($cacheToken['invalidNum']) && $cacheToken['invalidNum'] >= 3) {
|
||||
$cacheService->clearToken($md5Token);
|
||||
throw new AuthException(110006);
|
||||
}
|
||||
|
||||
/** @var JwtAuth $jwtAuth */
|
||||
$jwtAuth = app()->make(JwtAuth::class);
|
||||
@ -108,19 +103,15 @@ class LoginServices extends BaseServices
|
||||
//验证token
|
||||
try {
|
||||
$jwtAuth->verifyToken();
|
||||
$cacheService->setTokenBucket($md5Token, $cacheToken, $cacheToken['exp']);
|
||||
} catch (ExpiredException $e) {
|
||||
$cacheToken['invalidNum'] = isset($cacheToken['invalidNum']) ? $cacheToken['invalidNum']++ : 1;
|
||||
$cacheService->setTokenBucket($md5Token, $cacheToken, $cacheToken['exp']);
|
||||
} catch (\Throwable $e) {
|
||||
$noCli && $cacheService->clearToken($md5Token);
|
||||
$noCli && $cacheService->delete($md5Token);
|
||||
throw new AuthException(110006);
|
||||
}
|
||||
|
||||
//获取管理员信息
|
||||
$adminInfo = $this->dao->get($id);
|
||||
if (!$adminInfo || !$adminInfo->id) {
|
||||
$noCli && $cacheService->clearToken($md5Token);
|
||||
$noCli && $cacheService->delete($md5Token);
|
||||
throw new AuthException(110007);
|
||||
}
|
||||
|
||||
|
||||
@ -15,7 +15,6 @@ namespace app\services\kefu;
|
||||
use app\dao\user\UserDao;
|
||||
use app\services\BaseServices;
|
||||
use crmeb\exceptions\ApiException;
|
||||
use crmeb\traits\ServicesTrait;
|
||||
use app\services\user\UserLabelServices;
|
||||
use app\services\system\SystemUserLevelServices;
|
||||
use app\services\user\UserLabelRelationServices;
|
||||
@ -27,7 +26,6 @@ use app\services\kefu\service\StoreServiceRecordServices;
|
||||
*/
|
||||
class UserServices extends BaseServices
|
||||
{
|
||||
use ServicesTrait;
|
||||
|
||||
/**
|
||||
* UserServices constructor.
|
||||
|
||||
@ -16,7 +16,6 @@ use app\dao\service\StoreServiceFeedbackDao;
|
||||
use app\services\BaseServices;
|
||||
use crmeb\exceptions\AdminException;
|
||||
use crmeb\services\FormBuilder;
|
||||
use crmeb\traits\ServicesTrait;
|
||||
|
||||
/**
|
||||
* 客服反馈
|
||||
@ -26,8 +25,6 @@ use crmeb\traits\ServicesTrait;
|
||||
class StoreServiceFeedbackServices extends BaseServices
|
||||
{
|
||||
|
||||
use ServicesTrait;
|
||||
|
||||
/**
|
||||
* StoreServiceFeedbackServices constructor.
|
||||
* @param StoreServiceFeedbackDao $dao
|
||||
|
||||
@ -14,7 +14,6 @@ namespace app\services\kefu\service;
|
||||
|
||||
use app\dao\service\StoreServiceRecordDao;
|
||||
use app\services\BaseServices;
|
||||
use crmeb\traits\ServicesTrait;
|
||||
use crmeb\utils\Str;
|
||||
use think\Model;
|
||||
|
||||
@ -26,8 +25,6 @@ use think\Model;
|
||||
class StoreServiceRecordServices extends BaseServices
|
||||
{
|
||||
|
||||
use ServicesTrait;
|
||||
|
||||
/**
|
||||
* StoreServiceRecordServices constructor.
|
||||
* @param StoreServiceRecordDao $dao
|
||||
|
||||
@ -17,7 +17,6 @@ use app\services\user\UserServices;
|
||||
use crmeb\exceptions\AdminException;
|
||||
use crmeb\exceptions\ApiException;
|
||||
use crmeb\services\FormBuilder;
|
||||
use crmeb\traits\ServicesTrait;
|
||||
|
||||
/**
|
||||
* 客服
|
||||
@ -27,7 +26,6 @@ use crmeb\traits\ServicesTrait;
|
||||
*/
|
||||
class StoreServiceServices extends BaseServices
|
||||
{
|
||||
use ServicesTrait;
|
||||
|
||||
/**
|
||||
* 创建form表单
|
||||
|
||||
@ -11,12 +11,7 @@
|
||||
|
||||
namespace app\services\message;
|
||||
|
||||
|
||||
use app\jobs\notice\EnterpriseWechatJob;
|
||||
use app\jobs\notice\PrintJob;
|
||||
use app\services\BaseServices;
|
||||
use app\services\order\StoreOrderCartInfoServices;
|
||||
use crmeb\exceptions\AdminException;
|
||||
use crmeb\services\CacheService;
|
||||
|
||||
/**
|
||||
@ -25,31 +20,13 @@ use crmeb\services\CacheService;
|
||||
*/
|
||||
class NoticeService extends BaseServices
|
||||
{
|
||||
|
||||
/**
|
||||
* 发送消息类型
|
||||
* @var array
|
||||
*/
|
||||
// protected $type = [
|
||||
// 'is_sms' => SmsService::class,
|
||||
// 'is_system' => SystemSendServices::class,
|
||||
// 'is_wechat' => WechatTemplateService::class,
|
||||
// 'is_routine' => RoutineTemplateServices::class,
|
||||
// 'is_ent_wechat' => EntWechatServices::class,
|
||||
// ];
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $notceinfo;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $noticeInfo;
|
||||
protected $event;
|
||||
|
||||
/**
|
||||
* 设置
|
||||
* @param string $event
|
||||
* @return $this
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
@ -57,58 +34,16 @@ class NoticeService extends BaseServices
|
||||
public function setEvent(string $event)
|
||||
{
|
||||
if ($this->event != $event) {
|
||||
$this->notceinfo = CacheService::get('NOTCE_' . $event);
|
||||
if (!$this->notceinfo) {
|
||||
$this->noticeInfo = CacheService::get('NOTICE_' . $event);
|
||||
if (!$this->noticeInfo) {
|
||||
/** @var SystemNotificationServices $services */
|
||||
$services = app()->make(SystemNotificationServices::class);
|
||||
$notceinfo = $services->getOneNotce(['mark' => $event]);
|
||||
$this->notceinfo = $notceinfo ? $notceinfo->toArray() : [];
|
||||
CacheService::set('NOTCE_' . $event, $this->notceinfo);
|
||||
$noticeInfo = $services->getOneNotce(['mark' => $event]);
|
||||
$this->noticeInfo = $noticeInfo ? $noticeInfo->toArray() : [];
|
||||
CacheService::set('NOTICE_' . $event, $this->noticeInfo);
|
||||
}
|
||||
$this->event = $event;
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 打印订单
|
||||
* @param $order
|
||||
* @param array $cartId
|
||||
*/
|
||||
public function orderPrint($order)
|
||||
{
|
||||
/** @var StoreOrderCartInfoServices $cartServices */
|
||||
$cartServices = app()->make(StoreOrderCartInfoServices::class);
|
||||
$product = $cartServices->getCartInfoPrintProduct($order['id']);
|
||||
if (!$product) {
|
||||
throw new AdminException(400463);
|
||||
}
|
||||
$switch = (bool)sys_config('pay_success_printing_switch');
|
||||
if (!$switch) {
|
||||
throw new AdminException(400464);
|
||||
}
|
||||
if (sys_config('print_type', 1) == 1) {
|
||||
$name = 'yi_lian_yun';
|
||||
$configData = [
|
||||
'clientId' => sys_config('printing_client_id', ''),
|
||||
'apiKey' => sys_config('printing_api_key', ''),
|
||||
'partner' => sys_config('develop_id', ''),
|
||||
'terminal' => sys_config('terminal_number', '')
|
||||
];
|
||||
if (!$configData['clientId'] || !$configData['apiKey'] || !$configData['partner'] || !$configData['terminal']) {
|
||||
throw new AdminException(400465);
|
||||
}
|
||||
} else {
|
||||
$name = 'fei_e_yun';
|
||||
$configData = [
|
||||
'feyUser' => sys_config('fey_user', ''),
|
||||
'feyUkey' => sys_config('fey_ukey', ''),
|
||||
'feySn' => sys_config('fey_sn', '')
|
||||
];
|
||||
if (!$configData['feyUser'] || !$configData['feyUkey'] || !$configData['feySn']) {
|
||||
throw new AdminException(400465);
|
||||
}
|
||||
}
|
||||
PrintJob::dispatch('doJob', [$name, $configData, $order, $product]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -11,11 +11,11 @@
|
||||
|
||||
namespace app\services\message\notice;
|
||||
|
||||
use app\services\message\NoticeService;
|
||||
use app\jobs\notice\EnterpriseWechatJob;
|
||||
use app\services\message\NoticeService;
|
||||
use crmeb\services\HttpService;
|
||||
use think\facade\Log;
|
||||
|
||||
|
||||
/**
|
||||
* 企业微信发送消息
|
||||
* Created by PhpStorm.
|
||||
@ -24,12 +24,11 @@ use think\facade\Log;
|
||||
*/
|
||||
class EnterpriseWechatService extends NoticeService
|
||||
{
|
||||
|
||||
/**
|
||||
* 判断是否开启权限
|
||||
* @var bool
|
||||
*/
|
||||
private $isopend = true;
|
||||
private $isOpen = true;
|
||||
|
||||
/**
|
||||
* 是否开启权限
|
||||
@ -38,30 +37,39 @@ class EnterpriseWechatService extends NoticeService
|
||||
*/
|
||||
public function isOpen(string $mark)
|
||||
{
|
||||
$this->isopend = $this->notceinfo['is_ent_wechat'] == 1 && $this->notceinfo['url'] !== '';
|
||||
$this->isOpen = $this->noticeInfo['is_ent_wechat'] == 1 && $this->noticeInfo['url'] !== '';
|
||||
return $this;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 发送消息
|
||||
* @param $uid uid
|
||||
* @param array $data 模板内容
|
||||
* 发送企业微信客服消息
|
||||
* @param $data
|
||||
*/
|
||||
public function sendMsg($data)
|
||||
public function weComSend($data)
|
||||
{
|
||||
try {
|
||||
if ($this->isopend) {
|
||||
$url = $this->notceinfo['url'];
|
||||
$ent_wechat_text = $this->notceinfo['ent_wechat_text'];
|
||||
EnterpriseWechatJob::dispatchDo('doJob', [$data, $url, $ent_wechat_text]);
|
||||
if ($this->isOpen) {
|
||||
$url = $this->noticeInfo['url'];
|
||||
$ent_wechat_text = $this->noticeInfo['ent_wechat_text'];
|
||||
try {
|
||||
$str = $ent_wechat_text;
|
||||
foreach ($data as $key => $item) {
|
||||
$str = str_replace('{' . $key . '}', $item, $str);
|
||||
}
|
||||
$s = explode('\n', $str);
|
||||
$d = '';
|
||||
foreach ($s as $item) {
|
||||
$d .= $item . "\n>";
|
||||
}
|
||||
$d = substr($d, 0, strlen($d) - 2);
|
||||
HttpService::postRequest($url, json_encode([
|
||||
'msgtype' => 'markdown',
|
||||
'markdown' => ['content' => $d]
|
||||
]));
|
||||
} catch (\Throwable $e) {
|
||||
Log::error('发送企业群消息失败,失败原因:' . $e->getMessage());
|
||||
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
Log::error($e->getMessage());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -29,7 +29,7 @@ class RoutineTemplateListService extends NoticeService
|
||||
* 判断是否开启权限
|
||||
* @var bool
|
||||
*/
|
||||
private $isopend = true;
|
||||
private $isOpen = true;
|
||||
|
||||
/**
|
||||
* 是否开启权限
|
||||
@ -38,7 +38,7 @@ class RoutineTemplateListService extends NoticeService
|
||||
*/
|
||||
public function isOpen(string $mark)
|
||||
{
|
||||
$this->isopend = $this->notceinfo['is_routine'] === 1;
|
||||
$this->isOpen = $this->noticeInfo['is_routine'] === 1;
|
||||
return $this;
|
||||
|
||||
}
|
||||
@ -66,11 +66,11 @@ class RoutineTemplateListService extends NoticeService
|
||||
public function sendTemplate(int $uid, array $data, string $link = null, string $color = null)
|
||||
{
|
||||
try {
|
||||
$this->isopend = $this->notceinfo['is_routine'] === 1;
|
||||
if ($this->isopend) {
|
||||
$this->isOpen = $this->noticeInfo['is_routine'] === 1;
|
||||
if ($this->isOpen) {
|
||||
$openid = $this->getOpenidByUid($uid);
|
||||
//放入队列执行
|
||||
TemplateJob::dispatchDo('doJob', ['subscribe', $openid, $this->notceinfo['mark'], $data, $link, $color]);
|
||||
TemplateJob::dispatch('doJob', ['subscribe', $openid, $this->noticeInfo['mark'], $data, $link, $color]);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
Log::error($e->getMessage());
|
||||
|
||||
@ -34,7 +34,7 @@ class SmsService extends NoticeService
|
||||
* 判断是否开启权限
|
||||
* @var bool
|
||||
*/
|
||||
private $isopend = true;
|
||||
private $isOpen = true;
|
||||
|
||||
/**
|
||||
* 短信类型
|
||||
@ -49,7 +49,7 @@ class SmsService extends NoticeService
|
||||
*/
|
||||
public function isOpen(string $mark)
|
||||
{
|
||||
$this->isopend = $this->notceinfo['is_sms'] === 1;
|
||||
$this->isOpen = $this->noticeInfo['is_sms'] === 1;
|
||||
return $this;
|
||||
|
||||
}
|
||||
@ -63,10 +63,18 @@ class SmsService extends NoticeService
|
||||
public function sendSms($phone, array $data)
|
||||
{
|
||||
try {
|
||||
$this->isopend = $this->notceinfo['is_sms'] === 1;
|
||||
$mark = $this->notceinfo['mark'];
|
||||
if ($this->isopend) {
|
||||
SmsJob::dispatch('doJob', [$phone, $data, $mark]);
|
||||
$this->isOpen = $this->noticeInfo['is_sms'] === 1;
|
||||
$mark = $this->noticeInfo['mark'];
|
||||
if ($this->isOpen) {
|
||||
try{
|
||||
/** @var SmsService $smsServices */
|
||||
$smsServices = app()->make(SmsService::class);
|
||||
$smsServices->send(true, $phone, $data, $mark);
|
||||
return true;
|
||||
}catch (\Throwable $e) {
|
||||
Log::error('发送短信失败,失败原因:' . $e->getMessage());
|
||||
}
|
||||
//SmsJob::dispatch('doJob', [$phone, $data, $mark]);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
Log::error($e->getMessage());
|
||||
@ -107,7 +115,6 @@ class SmsService extends NoticeService
|
||||
if ($res === false) {
|
||||
throw new ApiException($smsMake->getError());
|
||||
}
|
||||
TaskJob::dispatchDo('modifyResultCode');
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
|
||||
@ -29,7 +29,7 @@ class SystemMsgService extends NoticeService
|
||||
* 判断是否开启权限
|
||||
* @var bool
|
||||
*/
|
||||
private $isopend = true;
|
||||
private $isOpen = true;
|
||||
|
||||
/**
|
||||
* 是否开启权限
|
||||
@ -38,7 +38,7 @@ class SystemMsgService extends NoticeService
|
||||
*/
|
||||
public function isOpen(string $mark)
|
||||
{
|
||||
$this->isopend = $this->notceinfo['is_system'] === 1;
|
||||
$this->isOpen = $this->noticeInfo['is_system'] === 1;
|
||||
return $this;
|
||||
|
||||
}
|
||||
@ -51,17 +51,17 @@ class SystemMsgService extends NoticeService
|
||||
*/
|
||||
public function sendMsg(int $uid, $data)
|
||||
{
|
||||
$this->isopend = $this->notceinfo['is_system'] === 1;
|
||||
$this->isOpen = $this->noticeInfo['is_system'] === 1;
|
||||
try {
|
||||
if ($this->isopend) {
|
||||
$title = $this->notceinfo['system_title'];
|
||||
$str = $this->notceinfo['system_text'];
|
||||
if ($this->isOpen) {
|
||||
$title = $this->noticeInfo['system_title'];
|
||||
$str = $this->noticeInfo['system_text'];
|
||||
foreach ($data as $key => $item) {
|
||||
$str = str_replace('{' . $key . '}', $item, $str);
|
||||
$title = str_replace('{' . $key . '}', $item, $title);
|
||||
}
|
||||
$sdata = [];
|
||||
$sdata['mark'] = $this->notceinfo['mark'];
|
||||
$sdata['mark'] = $this->noticeInfo['mark'];
|
||||
$sdata['uid'] = $uid;
|
||||
$sdata['content'] = $str;
|
||||
$sdata['title'] = $title;
|
||||
@ -91,16 +91,16 @@ class SystemMsgService extends NoticeService
|
||||
$StoreServiceServices = app()->make(StoreServiceServices::class);
|
||||
$adminList = $StoreServiceServices->getStoreServiceOrderNotice();
|
||||
try {
|
||||
if ($this->isopend) {
|
||||
if ($this->isOpen) {
|
||||
$save = [];
|
||||
$title = $this->notceinfo['system_title'];
|
||||
$str = $this->notceinfo['system_text'];
|
||||
$title = $this->noticeInfo['system_title'];
|
||||
$str = $this->noticeInfo['system_text'];
|
||||
foreach ($data as $k => $val) {
|
||||
$str = str_replace('{' . $k . '}', $val, $str);
|
||||
$title = str_replace('{' . $k . '}', $val, $title);
|
||||
}
|
||||
foreach ($adminList as $key => $item) {
|
||||
$save[$key]['mark'] = $this->notceinfo['mark'];
|
||||
$save[$key]['mark'] = $this->noticeInfo['mark'];
|
||||
$save[$key]['uid'] = $item['uid'];
|
||||
$save[$key]['content'] = $str;
|
||||
$save[$key]['title'] = $title;
|
||||
|
||||
@ -31,7 +31,7 @@ class WechatTemplateListService extends NoticeService
|
||||
* 判断是否开启权限
|
||||
* @var bool
|
||||
*/
|
||||
private $isopend = true;
|
||||
private $isOpen = true;
|
||||
|
||||
/**
|
||||
* 是否开启权限
|
||||
@ -40,7 +40,7 @@ class WechatTemplateListService extends NoticeService
|
||||
*/
|
||||
public function isOpen(string $mark)
|
||||
{
|
||||
$this->isopend = $this->notceinfo['is_wechat'] === 1;
|
||||
$this->isOpen = $this->noticeInfo['is_wechat'] === 1;
|
||||
return $this;
|
||||
|
||||
}
|
||||
@ -68,11 +68,11 @@ class WechatTemplateListService extends NoticeService
|
||||
public function sendTemplate(int $uid, array $data, string $link = null, string $color = null)
|
||||
{
|
||||
try {
|
||||
$this->isopend = $this->notceinfo['is_wechat'] === 1;
|
||||
if ($this->isopend) {
|
||||
$this->isOpen = $this->noticeInfo['is_wechat'] === 1;
|
||||
if ($this->isOpen) {
|
||||
$openid = $this->getOpenidByUid($uid);
|
||||
//放入队列执行
|
||||
TemplateJob::dispatchDo('doJob', ['wechat', $openid, $this->notceinfo['mark'], $data, $link, $color]);
|
||||
TemplateJob::dispatch('doJob', ['wechat', $openid, $this->noticeInfo['mark'], $data, $link, $color]);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
Log::error($e->getMessage());
|
||||
|
||||
@ -12,13 +12,19 @@
|
||||
namespace app\services\message\wechat;
|
||||
|
||||
|
||||
use app\services\activity\bargain\StoreBargainServices;
|
||||
use app\services\activity\combination\StoreCombinationServices;
|
||||
use app\services\activity\combination\StorePinkServices;
|
||||
use app\services\activity\seckill\StoreSeckillServices;
|
||||
use app\services\BaseServices;
|
||||
use app\services\other\QrcodeServices;
|
||||
use app\services\product\product\StoreProductServices;
|
||||
use app\services\user\LoginServices;
|
||||
use app\services\user\UserServices;
|
||||
use app\services\wechat\WechatQrcodeServices;
|
||||
use app\services\wechat\WechatReplyServices;
|
||||
use app\services\wechat\WechatUserServices;
|
||||
use crmeb\services\app\WechatService;
|
||||
use think\facade\Log;
|
||||
|
||||
class MessageServices extends BaseServices
|
||||
@ -44,73 +50,162 @@ class MessageServices extends BaseServices
|
||||
$response = $wechatReplyService->reply('subscribe');
|
||||
if ($message->EventKey && ($qrInfo = $qrcodeService->getQrcode($message->Ticket, 'ticket'))) {
|
||||
$qrcodeService->scanQrcode($message->Ticket, 'ticket');
|
||||
if (strtolower($qrInfo['third_type']) == 'spread') {
|
||||
try {
|
||||
$spreadUid = $qrInfo['third_id'];
|
||||
$is_new = $wechatUser->saveUser($message->FromUserName);
|
||||
$uid = $wechatUser->getFieldValue($message->FromUserName, 'openid', 'uid', ['user_type', '<>', 'h5']);
|
||||
$userInfo = $userService->get($uid);
|
||||
if ($spreadUid == $uid) {
|
||||
$response = '自己不能推荐自己';
|
||||
} else if (!$userInfo) {
|
||||
$response = '用户不存在';
|
||||
} else if ($userInfo['spread_uid']) {
|
||||
$response = '已有推荐人!';
|
||||
} else if (!$loginService->updateUserInfo(['code' => $spreadUid], $userInfo, $is_new)) {
|
||||
$response = '绑定推荐人失败!';
|
||||
$thirdType = explode('-', $qrInfo['third_type']);
|
||||
$baseUrl = sys_config('site_url');
|
||||
if (in_array(strtolower($thirdType[0]), ['spread', 'agent', 'wechatqrcode', 'product', 'combination', 'seckill', 'bargain', 'pink'])) {
|
||||
//扫码需要生成用户流程
|
||||
$spreadUid = $qrInfo['third_id'];
|
||||
$spreadInfo = $userService->get($spreadUid);
|
||||
$is_new = $wechatUser->saveUser($message->FromUserName);
|
||||
$uid = $wechatUser->getFieldValue($message->FromUserName, 'openid', 'uid', ['user_type', '<>', 'h5']);
|
||||
$userInfo = $userService->get($uid);
|
||||
if (strtolower($thirdType[0]) == 'spread') {
|
||||
try {
|
||||
if ($spreadUid == $uid) {
|
||||
$response = '自己不能推荐自己';
|
||||
} else if (!$userInfo) {
|
||||
$response = '用户不存在';
|
||||
} else if (!$spreadInfo) {
|
||||
$response = '上级用户不存在';
|
||||
} else if ($userInfo['spread_uid']) {
|
||||
$response = '已有推荐人!';
|
||||
} else if (!$loginService->updateUserInfo(['code' => $spreadUid], $userInfo, $is_new)) {
|
||||
$response = '绑定推荐人失败!';
|
||||
}
|
||||
$wechatNews['title'] = sys_config('site_name');
|
||||
$wechatNews['image'] = sys_config('wap_login_logo');
|
||||
$wechatNews['url'] = $baseUrl . '/pages/index/index';
|
||||
$loginService->updateUserInfo(['code' => $spreadUid], $userInfo, $is_new);
|
||||
$messages = WechatService::newsMessage($wechatNews);
|
||||
WechatService::staffService()->message($messages)->to($message->FromUserName)->send();
|
||||
} catch (\Exception $e) {
|
||||
$response = $e->getMessage();
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
$response = $e->getMessage();
|
||||
}
|
||||
} elseif (strtolower($qrInfo['third_type']) == 'agent') {
|
||||
try {
|
||||
$spreadUid = $qrInfo['third_id'];
|
||||
$spreadInfo = $userService->get($spreadUid);
|
||||
$is_new = $wechatUser->saveUser($message->FromUserName);
|
||||
$uid = $wechatUser->getFieldValue($message->FromUserName, 'openid', 'uid', ['user_type', '<>', 'h5']);
|
||||
$userInfo = $userService->get($uid);
|
||||
if ($spreadUid == $uid) {
|
||||
$response = '自己不能推荐自己';
|
||||
} else if (!$userInfo) {
|
||||
$response = '用户不存在';
|
||||
} else if (!$spreadInfo) {
|
||||
$response = '上级用户不存在';
|
||||
} else if ($userInfo->is_division) {
|
||||
$response = '您是事业部,不能绑定成为别人的员工';
|
||||
} else if ($userInfo->is_agent) {
|
||||
$response = '您是代理商,不能绑定成为别人的员工';
|
||||
} else if ($loginService->updateUserInfo(['code' => $spreadUid, 'is_staff' => 1], $userInfo, $is_new)) {
|
||||
$response = '绑定店员成功!';
|
||||
} elseif (strtolower($thirdType[0]) == 'agent') {
|
||||
try {
|
||||
if ($spreadUid == $uid) {
|
||||
$response = '自己不能推荐自己';
|
||||
} else if (!$userInfo) {
|
||||
$response = '用户不存在';
|
||||
} else if (!$spreadInfo) {
|
||||
$response = '上级用户不存在';
|
||||
} else if ($userInfo->is_division) {
|
||||
$response = '您是事业部,不能绑定成为别人的员工';
|
||||
} else if ($userInfo->is_agent) {
|
||||
$response = '您是代理商,不能绑定成为别人的员工';
|
||||
} else if ($loginService->updateUserInfo(['code' => $spreadUid, 'is_staff' => 1], $userInfo, $is_new)) {
|
||||
$response = '绑定店员成功!';
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
$response = $e->getMessage();
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
$response = $e->getMessage();
|
||||
}
|
||||
} elseif (strtolower($qrInfo['third_type']) == 'wechatqrcode') {
|
||||
/** @var WechatQrcodeServices $wechatQrcodeService */
|
||||
$wechatQrcodeService = app()->make(WechatQrcodeServices::class);
|
||||
try {
|
||||
//wechatqrcode类型的二维码数据中,third_id为渠道码的id
|
||||
$qrcodeInfo = $wechatQrcodeService->qrcodeInfo($qrInfo['third_id']);
|
||||
$spreadUid = $qrcodeInfo['uid'];
|
||||
$spreadInfo = $userService->get($spreadUid);
|
||||
$is_new = $wechatUser->saveUser($message->FromUserName);
|
||||
$uid = $wechatUser->getFieldValue($message->FromUserName, 'openid', 'uid', ['user_type', '<>', 'h5']);
|
||||
$userInfo = $userService->get($uid);
|
||||
if ($qrcodeInfo['status'] == 0 || $qrcodeInfo['is_del'] == 1 || ($qrcodeInfo['end_time'] < time() && $qrcodeInfo['end_time'] > 0)) {
|
||||
$response = '二维码已失效';
|
||||
} else if ($spreadUid == $uid) {
|
||||
$response = '自己不能推荐自己';
|
||||
} else if (!$userInfo) {
|
||||
$response = '用户不存在';
|
||||
} else if (!$spreadInfo) {
|
||||
$response = '上级用户不存在';
|
||||
} else if ($loginService->updateUserInfo(['code' => $spreadUid], $userInfo, $is_new)) {
|
||||
//写入扫码记录,返回内容
|
||||
$response = $wechatQrcodeService->wechatQrcodeRecord($qrcodeInfo, $userInfo, $spreadInfo);
|
||||
} elseif (strtolower($thirdType[0]) == 'wechatqrcode') {
|
||||
/** @var WechatQrcodeServices $wechatQrcodeService */
|
||||
$wechatQrcodeService = app()->make(WechatQrcodeServices::class);
|
||||
try {
|
||||
//wechatqrcode类型的二维码数据中,third_id为渠道码的id
|
||||
$qrcodeInfo = $wechatQrcodeService->qrcodeInfo($qrInfo['third_id']);
|
||||
$spreadUid = $qrcodeInfo['uid'];
|
||||
$spreadInfo = $userService->get($spreadUid);
|
||||
$is_new = $wechatUser->saveUser($message->FromUserName);
|
||||
$uid = $wechatUser->getFieldValue($message->FromUserName, 'openid', 'uid', ['user_type', '<>', 'h5']);
|
||||
$userInfo = $userService->get($uid);
|
||||
if ($qrcodeInfo['status'] == 0 || $qrcodeInfo['is_del'] == 1 || ($qrcodeInfo['end_time'] < time() && $qrcodeInfo['end_time'] > 0)) {
|
||||
$response = '二维码已失效';
|
||||
} else if ($spreadUid == $uid) {
|
||||
$response = '自己不能推荐自己';
|
||||
} else if (!$userInfo) {
|
||||
$response = '用户不存在';
|
||||
} else if (!$spreadInfo) {
|
||||
$response = '上级用户不存在';
|
||||
} else if ($loginService->updateUserInfo(['code' => $spreadUid], $userInfo, $is_new)) {
|
||||
//写入扫码记录,返回内容
|
||||
$response = $wechatQrcodeService->wechatQrcodeRecord($qrcodeInfo, $userInfo, $spreadInfo);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
$response = $e->getMessage();
|
||||
}
|
||||
} elseif (strtolower($thirdType[0]) == 'product') {
|
||||
try {
|
||||
/** @var StoreProductServices $productService */
|
||||
$productService = app()->make(StoreProductServices::class);
|
||||
$productInfo = $productService->get($thirdType[1] ?? 0);
|
||||
$wechatNews['title'] = $productInfo->store_name;
|
||||
$wechatNews['image'] = $productInfo->image;
|
||||
$wechatNews['description'] = $productInfo->store_info;
|
||||
$wechatNews['url'] = $baseUrl . '/pages/goods_details/index?id=' . $thirdType[1];
|
||||
$loginService->updateUserInfo(['code' => $spreadUid], $userInfo, $is_new);
|
||||
$messages = WechatService::newsMessage($wechatNews);
|
||||
WechatService::staffService()->message($messages)->to($message->FromUserName)->send();
|
||||
} catch (\Exception $e) {
|
||||
$response = $e->getMessage();
|
||||
}
|
||||
} elseif (strtolower($thirdType[0]) == 'combination') {
|
||||
try {
|
||||
/** @var StoreCombinationServices $combinationService */
|
||||
$combinationService = app()->make(StoreCombinationServices::class);
|
||||
$productInfo = $combinationService->get($thirdType[1] ?? 0);
|
||||
$wechatNews['title'] = $productInfo->title;
|
||||
$wechatNews['image'] = $productInfo->image;
|
||||
$wechatNews['description'] = $productInfo->info;
|
||||
$wechatNews['url'] = $baseUrl . '/pages/activity/goods_combination_details/index?id=' . $thirdType[1];
|
||||
$loginService->updateUserInfo(['code' => $spreadUid], $userInfo, $is_new);
|
||||
$messages = WechatService::newsMessage($wechatNews);
|
||||
WechatService::staffService()->message($messages)->to($message->FromUserName)->send();
|
||||
} catch (\Exception $e) {
|
||||
$response = $e->getMessage();
|
||||
}
|
||||
} elseif (strtolower($thirdType[0]) == 'seckill') {
|
||||
try {
|
||||
/** @var StoreSeckillServices $seckillService */
|
||||
$seckillService = app()->make(StoreSeckillServices::class);
|
||||
$productInfo = $seckillService->get($thirdType[1] ?? 0);
|
||||
$wechatNews['title'] = $productInfo->title;
|
||||
$wechatNews['image'] = $productInfo->image;
|
||||
$wechatNews['description'] = $productInfo->info;
|
||||
$wechatNews['url'] = $baseUrl . '/pages/activity/goods_seckill_details/index?id=' . $thirdType[1];
|
||||
$loginService->updateUserInfo(['code' => $spreadUid], $userInfo, $is_new);
|
||||
$messages = WechatService::newsMessage($wechatNews);
|
||||
WechatService::staffService()->message($messages)->to($message->FromUserName)->send();
|
||||
} catch (\Exception $e) {
|
||||
$response = $e->getMessage();
|
||||
}
|
||||
} elseif (strtolower($thirdType[0]) == 'bargain') {
|
||||
try {
|
||||
/** @var StoreBargainServices $bargainService */
|
||||
$bargainService = app()->make(StoreBargainServices::class);
|
||||
$productInfo = $bargainService->get($thirdType[1] ?? 0);
|
||||
$wechatNews['title'] = $productInfo->title;
|
||||
$wechatNews['image'] = $productInfo->image;
|
||||
$wechatNews['description'] = $productInfo->info;
|
||||
$wechatNews['url'] = $baseUrl . '/pages/activity/goods_bargain_details/index?id=' . $thirdType[1] . '&bargain=' . $thirdType[2];
|
||||
$loginService->updateUserInfo(['code' => $spreadUid], $userInfo, $is_new);
|
||||
$messages = WechatService::newsMessage($wechatNews);
|
||||
WechatService::staffService()->message($messages)->to($message->FromUserName)->send();
|
||||
} catch (\Exception $e) {
|
||||
$response = $e->getMessage();
|
||||
}
|
||||
} elseif (strtolower($thirdType[0]) == 'pink') {
|
||||
try {
|
||||
/** @var StorePinkServices $pinkService */
|
||||
$pinkService = app()->make(StorePinkServices::class);
|
||||
/** @var StoreCombinationServices $combinationService */
|
||||
$combinationService = app()->make(StoreCombinationServices::class);
|
||||
$pinktInfo = $pinkService->get($thirdType[1]);
|
||||
$productInfo = $combinationService->get($pinktInfo->cid);
|
||||
$wechatNews['title'] = $productInfo->title;
|
||||
$wechatNews['image'] = $productInfo->image;
|
||||
$wechatNews['description'] = $productInfo->info;
|
||||
$wechatNews['url'] = $baseUrl . '/pages/activity/goods_combination_status/index?id=' . $thirdType[1];
|
||||
$loginService->updateUserInfo(['code' => $spreadUid], $userInfo, $is_new);
|
||||
$messages = WechatService::newsMessage($wechatNews);
|
||||
WechatService::staffService()->message($messages)->to($message->FromUserName)->send();
|
||||
} catch (\Exception $e) {
|
||||
$response = $e->getMessage();
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
$response = $e->getMessage();
|
||||
}
|
||||
} else {
|
||||
//扫码不生成用户流程
|
||||
}
|
||||
}
|
||||
return $response;
|
||||
@ -185,7 +280,7 @@ class MessageServices extends BaseServices
|
||||
$response = '您是事业部,不能绑定成为别人的员工';
|
||||
} else if ($userInfo->is_agent) {
|
||||
$response = '您是代理商,不能绑定成为别人的员工';
|
||||
} else if ($loginService->updateUserInfo(['code' => $spreadUid, 'is_staff' => 1, ], $userInfo, $is_new)) {
|
||||
} else if ($loginService->updateUserInfo(['code' => $spreadUid, 'is_staff' => 1], $userInfo, $is_new)) {
|
||||
$response = '绑定店员成功!';
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
|
||||
@ -18,6 +18,7 @@ use app\services\pay\PayServices;
|
||||
use app\services\statistic\CapitalFlowServices;
|
||||
use app\services\user\member\MemberShipServices;
|
||||
use app\services\user\UserBillServices;
|
||||
use app\services\user\UserBrokerageServices;
|
||||
use app\services\user\UserServices;
|
||||
use app\services\user\member\MemberCardServices;
|
||||
use crmeb\exceptions\ApiException;
|
||||
@ -335,9 +336,52 @@ class OtherOrderServices extends BaseServices
|
||||
$capitalFlowServices->setFlow($orderInfo, $type);
|
||||
}
|
||||
$res = $res1 && $res2 && $res3 && $res4;
|
||||
|
||||
//购买付费会员返佣设置
|
||||
if (sys_config('member_brokerage', 0) == 1 && sys_config('brokerage_func_status', 0) == 1) {
|
||||
$spread_one = sys_config('is_self_brokerage') ? $orderInfo['uid'] : $userServices->getSpreadUid($orderInfo['uid']);
|
||||
$spread_two = sys_config('brokerage_level', 2) == 2 ? $userServices->getSpreadUid($spread_one) : 0;
|
||||
$spread_one_price = bcmul((string)$orderInfo['pay_price'], (string)bcdiv((string)sys_config('store_brokerage_ratio', 0), '100', 4), 2);
|
||||
$spread_two_price = bcmul((string)$orderInfo['pay_price'], (string)bcdiv((string)sys_config('store_brokerage_two', 0), '100', 4), 2);
|
||||
if ($spread_one && $spread_one_price > 0) $this->memberBrokerage($spread_one, $spread_one_price, sys_config('is_self_brokerage') ? 'get_self_brokerage' : 'get_brokerage', $orderInfo);
|
||||
if ($spread_two && $spread_two_price > 0) $this->memberBrokerage($spread_two, $spread_two_price, 'get_two_brokerage', $orderInfo);
|
||||
}
|
||||
|
||||
return false !== $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 购买付费会员返佣
|
||||
* @param $uid
|
||||
* @param $price
|
||||
* @param $type
|
||||
* @param $orderInfo
|
||||
*/
|
||||
public function memberBrokerage($uid, $price, $type, $orderInfo)
|
||||
{
|
||||
/** @var UserServices $userServices */
|
||||
$userServices = app()->make(UserServices::class);
|
||||
$userInfo = $userServices->get($uid);
|
||||
// 上级推广员返佣之后的金额
|
||||
$balance = bcadd($userInfo['brokerage_price'], $price, 2);
|
||||
// 添加用户佣金
|
||||
$res1 = $userServices->bcInc($uid, 'brokerage_price', $price, 'uid');
|
||||
if ($res1) {
|
||||
//冻结时间
|
||||
$broken_time = intval(sys_config('extract_time'));
|
||||
$frozen_time = time() + $broken_time * 86400;
|
||||
// 添加佣金记录
|
||||
/** @var UserBrokerageServices $userBrokerageServices */
|
||||
$userBrokerageServices = app()->make(UserBrokerageServices::class);
|
||||
$userBrokerageServices->income($type, $uid, [
|
||||
'nickname' => $userInfo['nickname'],
|
||||
'pay_price' => floatval($price),
|
||||
'number' => floatval($userInfo['brokerage_price']),
|
||||
'frozen_time' => $frozen_time
|
||||
], $balance, $orderInfo['id']);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
* @param $where
|
||||
@ -372,7 +416,7 @@ class OtherOrderServices extends BaseServices
|
||||
$newMemberRight = $memberCardService->getMemberTypeValue();
|
||||
if (!array_key_exists($mcId, $newMemberRight)) throw new ApiException(410230);
|
||||
$price = $newMemberRight[$mcId]['pre_price'];
|
||||
if ($payPrice != $price || ($memberType != 'free' && $payPrice <= 0))throw new ApiException(100100);
|
||||
if ($payPrice != $price || ($memberType != 'free' && $payPrice <= 0)) throw new ApiException(100100);
|
||||
if ($memberType == 'free' && $newMemberRight[$mcId]['vip_day'] <= 0) throw new ApiException(100100);
|
||||
switch ($memberType) {
|
||||
case "free"://免费会员
|
||||
|
||||
@ -17,10 +17,6 @@ use app\services\BaseServices;
|
||||
use app\services\pay\PayServices;
|
||||
use crmeb\exceptions\AdminException;
|
||||
use crmeb\exceptions\ApiException;
|
||||
use crmeb\services\HttpService;
|
||||
use crmeb\services\UtilService;
|
||||
use crmeb\traits\ServicesTrait;
|
||||
use think\facade\Log;
|
||||
|
||||
/**
|
||||
* Class OutStoreOrderServices
|
||||
@ -39,8 +35,6 @@ use think\facade\Log;
|
||||
class OutStoreOrderServices extends BaseServices
|
||||
{
|
||||
|
||||
use ServicesTrait;
|
||||
|
||||
/**
|
||||
* 发货类型
|
||||
* @var string[]
|
||||
|
||||
@ -87,9 +87,8 @@ class StoreCartServices extends BaseServices
|
||||
if ($new) {
|
||||
$cartIds = explode(',', $cartIds);
|
||||
$cartInfo = [];
|
||||
$redis = CacheService::redisHandler();
|
||||
foreach ($cartIds as $key) {
|
||||
$info = $redis->get($key);
|
||||
$info = CacheService::get($key);
|
||||
if ($info) {
|
||||
$cartInfo[] = $info;
|
||||
}
|
||||
@ -272,7 +271,7 @@ class StoreCartServices extends BaseServices
|
||||
$info['trueStock'] = $info['productInfo']['attrInfo']['stock'];
|
||||
$info['costPrice'] = $info['productInfo']['attrInfo']['cost'];
|
||||
try {
|
||||
CacheService::redisHandler()->set($key, $info, 3600);
|
||||
CacheService::set($key, $info, 3600);
|
||||
} catch (\Throwable $e) {
|
||||
throw new ApiException($e->getMessage());
|
||||
}
|
||||
|
||||
@ -355,7 +355,7 @@ class StoreOrderCreateServices extends BaseServices
|
||||
//删除购物车
|
||||
if ($group['news']) {
|
||||
array_map(function ($key) {
|
||||
CacheService::redisHandler()->delete($key);
|
||||
CacheService::delete($key);
|
||||
}, $group['cartIds']);
|
||||
} else {
|
||||
/** @var StoreCartServices $cartServices */
|
||||
|
||||
@ -220,6 +220,17 @@ class StoreOrderRefundServices extends BaseServices
|
||||
//支付宝退款
|
||||
AliPayService::instance()->refund(strpos($refundOrder['trade_no'], '_') !== false ? $refundOrder['trade_no'] : $refundOrder['order_id'], floatval($refundData['refund_price']), $refund_id);
|
||||
break;
|
||||
case PayServices::ALLIN_PAY:
|
||||
/** @var Pay $pay */
|
||||
$pay = app()->make(Pay::class, ['allin_pay']);
|
||||
/** @var StoreOrderServices $orderServices */
|
||||
$orderServices = app()->make(StoreOrderServices::class);
|
||||
$trade_no = $orderServices->value(['id' => $orderRefundInfo['store_order_id']], 'trade_no');
|
||||
$pay->refund($trade_no, [
|
||||
'order_id' => $refundOrder['order_id'],
|
||||
'refund_price' => $refundData['refund_price']
|
||||
]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
//订单记录
|
||||
@ -1249,6 +1260,17 @@ class StoreOrderRefundServices extends BaseServices
|
||||
$storeOrderCartInfoServices->update(['oid' => $oid, 'cart_id' => $cart['id']], ['refund_num' => $refund_num]);
|
||||
}
|
||||
$storeOrderCartInfoServices->clearOrderCartInfo($oid);
|
||||
|
||||
//写入订单记录表
|
||||
/** @var StoreOrderStatusServices $statusService */
|
||||
$statusService = app()->make(StoreOrderStatusServices::class);
|
||||
$statusService->save([
|
||||
'oid' => $oid,
|
||||
'change_type' => 'cancel_refund_order',
|
||||
'change_message' => '取消退款',
|
||||
'change_time' => time()
|
||||
]);
|
||||
|
||||
//售后订单取消后置事件
|
||||
event('order.orderRefundCancelAfter', [$orderRefundInfo]);
|
||||
// 推送订单
|
||||
|
||||
@ -35,7 +35,6 @@ use crmeb\services\CacheService;
|
||||
use crmeb\services\FormBuilder as Form;
|
||||
use crmeb\services\printer\Printer;
|
||||
use crmeb\services\SystemConfigService;
|
||||
use crmeb\traits\ServicesTrait;
|
||||
use crmeb\utils\Arr;
|
||||
use think\facade\Log;
|
||||
|
||||
@ -56,8 +55,6 @@ use think\facade\Log;
|
||||
class StoreOrderServices extends BaseServices
|
||||
{
|
||||
|
||||
use ServicesTrait;
|
||||
|
||||
/**
|
||||
* 发货类型
|
||||
* @var string[]
|
||||
@ -140,13 +137,12 @@ class StoreOrderServices extends BaseServices
|
||||
/**
|
||||
* 获取订单数量
|
||||
* @param int $uid
|
||||
* @return mixed
|
||||
* @return array
|
||||
* @throws \ReflectionException
|
||||
*/
|
||||
public function getOrderData(int $uid = 0, $del = true, $isPid = false)
|
||||
public function getOrderData(int $uid = 0)
|
||||
{
|
||||
$where = ['uid' => $uid, 'paid' => 1, 'refund_status' => [0, 3], 'pid' => 0];
|
||||
if (!$del) $where = $where + ['is_del' => 0, 'is_system_del' => 0];
|
||||
$data['order_count'] = (string)$this->dao->count($where);
|
||||
$data['order_count'] = (string)$this->dao->count(['uid' => $uid, 'refund_status' => [0, 3], 'pid' => 0, 'is_del' => 0, 'is_system_del' => 0]);
|
||||
$data['sum_price'] = (string)$this->dao->sum([
|
||||
['uid', '=', $uid],
|
||||
['paid', '=', 1],
|
||||
@ -162,7 +158,6 @@ class StoreOrderServices extends BaseServices
|
||||
$data['received_count'] = (string)$this->dao->count(['status' => 2] + $countWhere + ['pid' => 0]);
|
||||
$data['evaluated_count'] = (string)$this->dao->count(['status' => 3] + $countWhere + ['pid' => 0]);
|
||||
$data['complete_count'] = (string)$this->dao->count(['status' => 4] + $countWhere + ['pid' => 0]);
|
||||
if (!$isPid) $countWhere = $countWhere + ['pid' => 0];
|
||||
|
||||
/** @var StoreOrderRefundServices $storeOrderRefundServices */
|
||||
$storeOrderRefundServices = app()->make(StoreOrderRefundServices::class);
|
||||
@ -173,8 +168,8 @@ class StoreOrderServices extends BaseServices
|
||||
$data['refunded_count'] = (string)$storeOrderRefundServices->count($refund_where + ['refund_type' => 6]);
|
||||
$data['refund_count'] = bcadd(bcadd($data['refunding_count'], $data['refunded_count'], 0), $data['no_refund_count'], 0);
|
||||
$data['yue_pay_status'] = (int)sys_config('balance_func_status') && (int)sys_config('yue_pay_status') == 1 ? (int)1 : (int)2;//余额支付 1 开启 2 关闭
|
||||
$data['pay_weixin_open'] = (int)sys_config('pay_weixin_open') ?? 0;//微信支付 1 开启 0 关闭
|
||||
$data['ali_pay_status'] = (bool)sys_config('ali_pay_status');//支付包支付 1 开启 0 关闭
|
||||
$data['pay_weixin_open'] = is_wecaht_pay();//微信支付 1 开启 0 关闭
|
||||
$data['ali_pay_status'] = is_ali_pay();//支付包支付 1 开启 0 关闭
|
||||
$data['friend_pay_status'] = (int)sys_config('friend_pay_status') ?? 0;//好友代付 1 开启 0 关闭
|
||||
return $data;
|
||||
}
|
||||
@ -508,18 +503,12 @@ class StoreOrderServices extends BaseServices
|
||||
}
|
||||
} else {
|
||||
switch ($item['pay_type']) {
|
||||
case PayServices::WEIXIN_PAY:
|
||||
$item['pay_type_name'] = '微信未支付';
|
||||
break;
|
||||
case PayServices::ALIAPY_PAY:
|
||||
$item['pay_type_name'] = '支付宝未支付';
|
||||
break;
|
||||
case 'offline':
|
||||
$item['pay_type_name'] = '线下支付';
|
||||
$item['pay_type_info'] = 1;
|
||||
break;
|
||||
default:
|
||||
$item['pay_type_name'] = '未支付';
|
||||
$item['pay_type_name'] = '';
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -1432,27 +1421,32 @@ HTML;
|
||||
$info[3]['total_name'] = '本月新增用户';
|
||||
return $info;
|
||||
}
|
||||
//TODO
|
||||
|
||||
/**
|
||||
* 打印订单
|
||||
* 订单小票打印
|
||||
* @param int $id
|
||||
* @param bool $start
|
||||
* @return bool|void
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function orderPrint(int $id)
|
||||
public function orderPrintTicket(int $id)
|
||||
{
|
||||
$order = $this->get($id);
|
||||
if (!$order) {
|
||||
throw new AdminException(400118);
|
||||
}
|
||||
|
||||
/** @var StoreOrderCartInfoServices $cartServices */
|
||||
$cartServices = app()->make(StoreOrderCartInfoServices::class);
|
||||
$product = $cartServices->getCartInfoPrintProduct($order->id);
|
||||
$product = $cartServices->getCartInfoPrintProduct($order['id']);
|
||||
if (!$product) {
|
||||
throw new AdminException(400533);
|
||||
throw new AdminException(400463);
|
||||
}
|
||||
$switch = (bool)sys_config('pay_success_printing_switch');
|
||||
if (!$switch) {
|
||||
throw new AdminException(400464);
|
||||
}
|
||||
if (sys_config('print_type', 1) == 1) {
|
||||
$name = 'yi_lian_yun';
|
||||
@ -1479,20 +1473,28 @@ HTML;
|
||||
$printer = new Printer($name, $configData);
|
||||
$res = $printer->setPrinterContent([
|
||||
'name' => sys_config('site_name'),
|
||||
'url' => sys_config('site_url'),
|
||||
'orderInfo' => is_object($order) ? $order->toArray() : $order,
|
||||
'product' => $product
|
||||
])->startPrinter();
|
||||
if (!$res) {
|
||||
throw new AdminException($printer->getError());
|
||||
}
|
||||
return $res;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取订单确认数据
|
||||
* @param array $user
|
||||
* @param $cartId
|
||||
* @return mixed
|
||||
* @param bool $new
|
||||
* @param int $addressId
|
||||
* @param int $shipping_type
|
||||
* @return array
|
||||
* @throws \Psr\SimpleCache\InvalidArgumentException
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function getOrderConfirmData(array $user, $cartId, bool $new, int $addressId, int $shipping_type = 1)
|
||||
{
|
||||
@ -1575,7 +1577,7 @@ HTML;
|
||||
$data['integralRatio'] = $other['integralRatio'];
|
||||
$data['offline_pay_status'] = (int)sys_config('offline_pay_status') ?? (int)2;
|
||||
$data['yue_pay_status'] = (int)sys_config('balance_func_status') && (int)sys_config('yue_pay_status') == 1 ? (int)1 : (int)2;//余额支付 1 开启 2 关闭
|
||||
$data['pay_weixin_open'] = (int)sys_config('pay_weixin_open') ?? 0;//微信支付 1 开启 0 关闭
|
||||
$data['pay_weixin_open'] = is_wecaht_pay();//微信支付 1 开启 0 关闭
|
||||
$data['friend_pay_status'] = (int)sys_config('friend_pay_status') ?? 0;//好友代付 1 开启 0 关闭
|
||||
$data['store_self_mention'] = (int)sys_config('store_self_mention') ?? 0;//门店自提是否开启
|
||||
/** @var SystemStoreServices $systemStoreServices */
|
||||
@ -1583,7 +1585,7 @@ HTML;
|
||||
$store_count = $systemStoreServices->count(['type' => 0]);
|
||||
$data['store_self_mention'] = $data['store_self_mention'] && $store_count;
|
||||
|
||||
$data['ali_pay_status'] = (bool)sys_config('ali_pay_status');//支付包支付 1 开启 0 关闭
|
||||
$data['ali_pay_status'] = is_ali_pay();//支付包支付 1 开启 0 关闭
|
||||
$data['system_store'] = [];//门店信息
|
||||
/** @var UserInvoiceServices $userInvoice */
|
||||
$userInvoice = app()->make(UserInvoiceServices::class);
|
||||
@ -1611,7 +1613,7 @@ HTML;
|
||||
public function cacheOrderInfo($uid, $cartInfo, $priceGroup, $other = [], $cacheTime = 600)
|
||||
{
|
||||
$key = $this->getCacheKey();
|
||||
CacheService::redisHandler()->set('user_order_' . $uid . $key, compact('cartInfo', 'priceGroup', 'other'), $cacheTime);
|
||||
CacheService::set('user_order_' . $uid . $key, compact('cartInfo', 'priceGroup', 'other'), $cacheTime);
|
||||
return $key;
|
||||
}
|
||||
|
||||
@ -1651,8 +1653,8 @@ HTML;
|
||||
public function getCacheOrderInfo(int $uid, string $key)
|
||||
{
|
||||
$cacheName = 'user_order_' . $uid . $key;
|
||||
if (!CacheService::redisHandler()->has($cacheName)) return null;
|
||||
return CacheService::redisHandler()->get($cacheName);
|
||||
if (!CacheService::has($cacheName)) return null;
|
||||
return CacheService::get($cacheName);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1701,6 +1703,8 @@ HTML;
|
||||
case PayServices::FRIEND:
|
||||
$res = sys_config('friend_pay_status', 1) == 1;
|
||||
break;
|
||||
case PayServices::ALLIN_PAY:
|
||||
$res = sys_config('allin_pay_status') == 1;
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
@ -2412,9 +2416,8 @@ HTML;
|
||||
if ($new) {
|
||||
$cartIds = explode(',', $cartIds);
|
||||
$cartInfo = [];
|
||||
$redis = CacheService::redisHandler();
|
||||
foreach ($cartIds as $key) {
|
||||
$info = $redis->get($key);
|
||||
$info = CacheService::get($key);
|
||||
if ($info) {
|
||||
$cartInfo[] = $info;
|
||||
}
|
||||
|
||||
@ -14,7 +14,6 @@ namespace app\services\order;
|
||||
|
||||
use app\dao\order\StoreOrderStatusDao;
|
||||
use app\services\BaseServices;
|
||||
use crmeb\traits\ServicesTrait;
|
||||
|
||||
/**
|
||||
* 订单状态
|
||||
@ -23,7 +22,6 @@ use crmeb\traits\ServicesTrait;
|
||||
*/
|
||||
class StoreOrderStatusServices extends BaseServices
|
||||
{
|
||||
use ServicesTrait;
|
||||
|
||||
/**
|
||||
* 构造方法
|
||||
|
||||
@ -14,7 +14,6 @@ namespace app\services\other;
|
||||
|
||||
use app\dao\other\CategoryDao;
|
||||
use app\services\BaseServices;
|
||||
use crmeb\traits\ServicesTrait;
|
||||
|
||||
/**
|
||||
* Class CategoryServices
|
||||
@ -23,8 +22,6 @@ use crmeb\traits\ServicesTrait;
|
||||
class CategoryServices extends BaseServices
|
||||
{
|
||||
|
||||
use ServicesTrait;
|
||||
|
||||
protected $cacheName = 'crmeb_cate';
|
||||
|
||||
/**
|
||||
|
||||
@ -223,10 +223,12 @@ class QrcodeServices extends BaseServices
|
||||
* 获取小程序分享二维码
|
||||
* @param int $id
|
||||
* @param int $uid
|
||||
* @param int $type 1 = 拼团,2 = 秒杀
|
||||
* @return bool|string
|
||||
* @param int $type
|
||||
* @param array $param
|
||||
* @param bool $isSaveAttach
|
||||
* @return false|mixed|string
|
||||
*/
|
||||
public function getRoutineQrcodePath(int $id, int $uid, int $type, array $parame = [], bool $isSaveAttach = true)
|
||||
public function getRoutineQrcodePath(int $id, int $uid, int $type, array $param = [], bool $isSaveAttach = true)
|
||||
{
|
||||
/** @var SystemAttachmentServices $systemAttachmentService */
|
||||
$systemAttachmentService = app()->make(SystemAttachmentServices::class);
|
||||
@ -236,7 +238,7 @@ class QrcodeServices extends BaseServices
|
||||
switch ($type) {
|
||||
case 0:
|
||||
$page = 'pages/goods_details/index';
|
||||
$namePath = $id . '_' . $uid . '_' . $parame['is_promoter'] . '_product.jpg';
|
||||
$namePath = $id . '_' . $uid . '_' . $param['is_promoter'] . '_product.jpg';
|
||||
break;
|
||||
case 1:
|
||||
$page = 'pages/activity/goods_combination_details/index';
|
||||
@ -245,10 +247,6 @@ class QrcodeServices extends BaseServices
|
||||
case 2:
|
||||
$page = 'pages/activity/goods_seckill_details/index';
|
||||
$namePath = 'seckill_' . $id . '_' . $uid . '.jpg';
|
||||
if (isset($parame['stop_time']) && $parame['stop_time']) {
|
||||
$data .= '&time=' . $parame['stop_time'];
|
||||
$namePath = $parame['stop_time'] . $namePath;
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
$page = 'pages/annex/offline_pay/index';
|
||||
|
||||
@ -11,12 +11,350 @@
|
||||
|
||||
namespace app\services\other\export;
|
||||
|
||||
|
||||
use app\services\activity\bargain\StoreBargainServices;
|
||||
use app\services\activity\combination\StoreCombinationServices;
|
||||
use app\services\activity\seckill\StoreSeckillServices;
|
||||
use app\services\BaseServices;
|
||||
use app\services\order\StoreOrderServices;
|
||||
use app\services\product\product\StoreProductServices;
|
||||
use app\services\user\member\MemberCardServices;
|
||||
use app\services\user\UserServices;
|
||||
use crmeb\services\SpreadsheetExcelService;
|
||||
|
||||
class ExportServices extends BaseServices
|
||||
{
|
||||
/**
|
||||
* 用户导出
|
||||
* @param $where
|
||||
* @return array
|
||||
*/
|
||||
public function exportUserList($where)
|
||||
{
|
||||
/** @var UserServices $userServices */
|
||||
$userServices = app()->make(UserServices::class);
|
||||
$data = $userServices->index($where)['list'];
|
||||
$header = ['用户ID', '昵称', '真实姓名', '性别', '电话', '用户等级', '用户分组', '用户标签', '用户类型', '用户余额', '最后登录时间', '注册时间'];
|
||||
$filename = '用户列表_' . date('YmdHis', time());
|
||||
$export = $fileKey = [];
|
||||
if (!empty($data)) {
|
||||
$i = 0;
|
||||
foreach ($data as $item) {
|
||||
$one_data = [
|
||||
'uid' => $item['uid'],
|
||||
'nickname' => $item['nickname'],
|
||||
'real_name' => $item['real_name'],
|
||||
'sex' => $item['sex'],
|
||||
'phone' => $item['phone'],
|
||||
'level' => $item['level'],
|
||||
'group_id' => $item['group_id'],
|
||||
'labels' => $item['labels'],
|
||||
'user_type' => $item['user_type'],
|
||||
'now_money' => $item['now_money'],
|
||||
'last_time' => date('Y-m-d H:i:s', $item['last_time']),
|
||||
'add_time' => date('Y-m-d H:i:s', $item['add_time'])
|
||||
];
|
||||
$export[] = $one_data;
|
||||
if ($i == 0) {
|
||||
$fileKey = array_keys($one_data);
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
return compact('header', 'fileKey', 'export', 'filename');
|
||||
}
|
||||
|
||||
/**
|
||||
* 订单导出
|
||||
* @param $where
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function exportOrderList($where)
|
||||
{
|
||||
$header = ['订单号', '收货人姓名', '收货人电话', '收货地址', '商品信息', '总价格', '实际支付', '支付状态', '支付时间', '订单状态', '下单时间', '用户备注'];
|
||||
$filename = '订单列表_' . date('YmdHis', time());
|
||||
$export = $fileKey = [];
|
||||
/** @var StoreOrderServices $orderServices */
|
||||
$orderServices = app()->make(StoreOrderServices::class);
|
||||
$data = $orderServices->getOrderList($where)['data'];
|
||||
if (!empty($data)) {
|
||||
$i = 0;
|
||||
foreach ($data as $item) {
|
||||
if ($item['paid'] == 1) {
|
||||
switch ($item['pay_type']) {
|
||||
case 'weixin':
|
||||
$item['pay_type_name'] = '微信支付';
|
||||
break;
|
||||
case 'yue':
|
||||
$item['pay_type_name'] = '余额支付';
|
||||
break;
|
||||
case 'offline':
|
||||
$item['pay_type_name'] = '线下支付';
|
||||
break;
|
||||
default:
|
||||
$item['pay_type_name'] = '其他支付';
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
switch ($item['pay_type']) {
|
||||
default:
|
||||
$item['pay_type_name'] = '未支付';
|
||||
break;
|
||||
case 'offline':
|
||||
$item['pay_type_name'] = '线下支付';
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ($item['paid'] == 0 && $item['status'] == 0) {
|
||||
$item['status_name'] = '未支付';
|
||||
} else if ($item['paid'] == 1 && $item['status'] == 0 && $item['shipping_type'] == 1 && $item['refund_status'] == 0) {
|
||||
$item['status_name'] = '未发货';
|
||||
} else if ($item['paid'] == 1 && $item['status'] == 0 && $item['shipping_type'] == 2 && $item['refund_status'] == 0) {
|
||||
$item['status_name'] = '未核销';
|
||||
} else if ($item['paid'] == 1 && $item['status'] == 1 && $item['shipping_type'] == 1 && $item['refund_status'] == 0) {
|
||||
$item['status_name'] = '待收货';
|
||||
} else if ($item['paid'] == 1 && $item['status'] == 1 && $item['shipping_type'] == 2 && $item['refund_status'] == 0) {
|
||||
$item['status_name'] = '未核销';
|
||||
} else if ($item['paid'] == 1 && $item['status'] == 2 && $item['refund_status'] == 0) {
|
||||
$item['status_name'] = '待评价';
|
||||
} else if ($item['paid'] == 1 && $item['status'] == 3 && $item['refund_status'] == 0) {
|
||||
$item['status_name'] = '已完成';
|
||||
} else if ($item['paid'] == 1 && $item['refund_status'] == 1) {
|
||||
$item['status_name'] = '正在退款';
|
||||
} else if ($item['paid'] == 1 && $item['refund_status'] == 2) {
|
||||
$item['status_name'] = '已退款';
|
||||
}
|
||||
$goodsName = [];
|
||||
foreach ($item['_info'] as $value) {
|
||||
$_info = $value['cart_info'];
|
||||
$sku = '';
|
||||
if (isset($_info['productInfo']['attrInfo'])) {
|
||||
if (isset($_info['productInfo']['attrInfo']['suk'])) {
|
||||
$sku = '(' . $_info['productInfo']['attrInfo']['suk'] . ')';
|
||||
}
|
||||
}
|
||||
if (isset($_info['productInfo']['store_name'])) {
|
||||
$goodsName[] = implode(' ',
|
||||
[$_info['productInfo']['store_name'],
|
||||
$sku,
|
||||
"[{$_info['cart_num']} * {$_info['truePrice']}]"
|
||||
]);
|
||||
}
|
||||
}
|
||||
$one_data = [
|
||||
'order_id' => $item['order_id'],
|
||||
'real_name' => $item['real_name'],
|
||||
'user_phone' => $item['user_phone'],
|
||||
'user_address' => $item['user_address'],
|
||||
'goods_name' => $goodsName ? implode("\n", $goodsName) : '',
|
||||
'total_price' => $item['total_price'],
|
||||
'pay_price' => $item['pay_price'],
|
||||
'pay_type_name' => $item['pay_type_name'],
|
||||
'pay_time' => $item['pay_time'] > 0 ? date('Y-m-d H:i', (int)$item['pay_time']) : '暂无',
|
||||
'status_name' => $item['status_name'] ?? '未知状态',
|
||||
'add_time' => $item['add_time'],
|
||||
'mark' => $item['mark'],
|
||||
];
|
||||
$export[] = $one_data;
|
||||
if ($i == 0) {
|
||||
$fileKey = array_keys($one_data);
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
return compact('header', 'fileKey', 'export', 'filename');
|
||||
}
|
||||
|
||||
/**
|
||||
* 商品导出
|
||||
* @param $where
|
||||
* @return array
|
||||
*/
|
||||
public function exportProductList($where)
|
||||
{
|
||||
$header = ['商品名称', '商品类型', '商品分类', '售价', '销量', '库存', '添加时间'];
|
||||
$filename = '商品列表_' . date('YmdHis', time());
|
||||
$export = $fileKey = [];
|
||||
/** @var StoreProductServices $productServices */
|
||||
$productServices = app()->make(StoreProductServices::class);
|
||||
$data = $productServices->getList($where)['list'];
|
||||
if (!empty($data)) {
|
||||
$i = 0;
|
||||
foreach ($data as $item) {
|
||||
$one_data = [
|
||||
'store_name' => $item['store_name'],
|
||||
'product_type' => $item['product_type'],
|
||||
'cate_name' => $item['cate_name'],
|
||||
'price' => $item['price'],
|
||||
'sales' => $item['sales'],
|
||||
'stock' => $item['stock'],
|
||||
'add_time' => date('Y-m-d H:i:s', $item['add_time'])
|
||||
];
|
||||
$export[] = $one_data;
|
||||
if ($i == 0) {
|
||||
$fileKey = array_keys($one_data);
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
return compact('header', 'fileKey', 'export', 'filename');
|
||||
}
|
||||
|
||||
/**
|
||||
* 砍价商品导出
|
||||
* @param $where
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function exportBargainList($where)
|
||||
{
|
||||
$header = ['砍价名称', '起始价格', '最低价', '参与人数', '成功人数', '剩余库存', '活动状态', '活动时间', '添加时间'];
|
||||
$filename = '砍价列表_' . date('YmdHis', time());
|
||||
$export = $fileKey = [];
|
||||
/** @var StoreBargainServices $bargainServices */
|
||||
$bargainServices = app()->make(StoreBargainServices::class);
|
||||
$data = $bargainServices->getStoreBargainList($where)['list'];
|
||||
if (!empty($data)) {
|
||||
$i = 0;
|
||||
foreach ($data as $item) {
|
||||
$one_data = [
|
||||
'title' => $item['title'],
|
||||
'price' => $item['price'],
|
||||
'min_price' => $item['min_price'],
|
||||
'count_people_all' => $item['count_people_all'],
|
||||
'count_people_success' => $item['count_people_success'],
|
||||
'quota' => $item['quota'],
|
||||
'start_name' => $item['start_name'],
|
||||
'activity_time' => date('Y-m-d H:i:s', $item['start_time']) . '至' . date('Y-m-d H:i:s', $item['stop_time']),
|
||||
'add_time' => $item['add_time']
|
||||
];
|
||||
$export[] = $one_data;
|
||||
if ($i == 0) {
|
||||
$fileKey = array_keys($one_data);
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
return compact('header', 'fileKey', 'export', 'filename');
|
||||
}
|
||||
|
||||
/**
|
||||
* 拼团商品导出
|
||||
* @param $where
|
||||
* @return array
|
||||
*/
|
||||
public function exportCombinationList($where)
|
||||
{
|
||||
$header = ['拼团名称', '拼团价', '原价', '拼团人数', '参与人数', '成团数量', '剩余库存', '活动状态', '活动时间', '添加时间'];
|
||||
$filename = '拼团列表_' . date('YmdHis', time());
|
||||
$export = $fileKey = [];
|
||||
/** @var StoreCombinationServices $combinationServices */
|
||||
$combinationServices = app()->make(StoreCombinationServices::class);
|
||||
$data = $combinationServices->systemPage($where)['list'];
|
||||
if (!empty($data)) {
|
||||
$i = 0;
|
||||
foreach ($data as $item) {
|
||||
$one_data = [
|
||||
'title' => $item['title'],
|
||||
'price' => $item['price'],
|
||||
'ot_price' => $item['ot_price'],
|
||||
'count_people' => $item['count_people'],
|
||||
'count_people_all' => $item['count_people_all'],
|
||||
'count_people_pink' => $item['count_people_pink'],
|
||||
'quota' => $item['quota'],
|
||||
'start_name' => $item['start_name'],
|
||||
'activity_time' => date('Y-m-d H:i:s', $item['start_time']) . '至' . date('Y-m-d H:i:s', $item['stop_time']),
|
||||
'add_time' => $item['add_time']
|
||||
];
|
||||
$export[] = $one_data;
|
||||
if ($i == 0) {
|
||||
$fileKey = array_keys($one_data);
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
return compact('header', 'fileKey', 'export', 'filename');
|
||||
}
|
||||
|
||||
/**
|
||||
* 秒杀导出
|
||||
* @param $where
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function exportSeckillList($where)
|
||||
{
|
||||
$header = ['秒杀名称', '秒杀价', '原价', '剩余库存', '活动状态', '活动时间', '添加时间'];
|
||||
$filename = '秒杀列表_' . date('YmdHis', time());
|
||||
$export = $fileKey = [];
|
||||
/** @var StoreSeckillServices $seckillServices */
|
||||
$seckillServices = app()->make(StoreSeckillServices::class);
|
||||
$data = $seckillServices->systemPage($where)['list'];
|
||||
if (!empty($data)) {
|
||||
$i = 0;
|
||||
foreach ($data as $item) {
|
||||
$one_data = [
|
||||
'title' => $item['title'],
|
||||
'price' => $item['price'],
|
||||
'ot_price' => $item['ot_price'],
|
||||
'quota' => $item['quota'],
|
||||
'start_name' => $item['start_name'],
|
||||
'activity_time' => date('Y-m-d H:i:s', $item['start_time']) . '至' . date('Y-m-d H:i:s', $item['stop_time']),
|
||||
'add_time' => $item['add_time']
|
||||
];
|
||||
$export[] = $one_data;
|
||||
if ($i == 0) {
|
||||
$fileKey = array_keys($one_data);
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
return compact('header', 'fileKey', 'export', 'filename');
|
||||
}
|
||||
|
||||
/**
|
||||
* 会员卡导出
|
||||
* @param $id
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function exportMemberCard($id)
|
||||
{
|
||||
/** @var MemberCardServices $memberCardServices */
|
||||
$memberCardServices = app()->make(MemberCardServices::class);
|
||||
$data = $memberCardServices->getExportData(['batch_card_id' => $id]);
|
||||
$header = ['会员卡号', '密码', '领取人', '领取人手机号', '领取时间', '是否使用'];
|
||||
$filename = $data['title'] . '批次列表_' . date('YmdHis', time());
|
||||
$export = $fileKey = [];
|
||||
if (!empty($data['data'])) {
|
||||
$i = 0;
|
||||
foreach ($data['data'] as $item) {
|
||||
$one_data = [
|
||||
'card_number' => $item['card_number'],
|
||||
'card_password' => $item['card_password'],
|
||||
'user_name' => $item['user_name'],
|
||||
'user_phone' => $item['user_phone'],
|
||||
'use_time' => $item['use_time'],
|
||||
'use_uid' => $item['use_uid'] ? '已领取' : '未领取'
|
||||
];
|
||||
$export[] = $one_data;
|
||||
if ($i == 0) {
|
||||
$fileKey = array_keys($one_data);
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
return compact('header', 'fileKey', 'export', 'filename');
|
||||
}
|
||||
|
||||
/**
|
||||
* 真实请求导出
|
||||
* @param $header excel表头
|
||||
@ -52,6 +390,7 @@ class ExportServices extends BaseServices
|
||||
return $protocol . $domainName;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 用户资金导出
|
||||
* @param $data 导出数据
|
||||
@ -392,126 +731,6 @@ class ExportServices extends BaseServices
|
||||
return $this->export($header, $title, $export, $filename, $suffix, $is_save);
|
||||
}
|
||||
|
||||
/**
|
||||
* 商铺订单导出
|
||||
* @param $data 导出数据
|
||||
*/
|
||||
public function storeOrder($data = [])
|
||||
{
|
||||
$export = [];
|
||||
if (!empty($data)) {
|
||||
foreach ($data as $item) {
|
||||
if ($item['paid'] == 1) {
|
||||
switch ($item['pay_type']) {
|
||||
case 'weixin':
|
||||
$item['pay_type_name'] = '微信支付';
|
||||
break;
|
||||
case 'yue':
|
||||
$item['pay_type_name'] = '余额支付';
|
||||
break;
|
||||
case 'offline':
|
||||
$item['pay_type_name'] = '线下支付';
|
||||
break;
|
||||
default:
|
||||
$item['pay_type_name'] = '其他支付';
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
switch ($item['pay_type']) {
|
||||
default:
|
||||
$item['pay_type_name'] = '未支付';
|
||||
break;
|
||||
case 'offline':
|
||||
$item['pay_type_name'] = '线下支付';
|
||||
$item['pay_type_info'] = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ($item['paid'] == 0 && $item['status'] == 0) {
|
||||
$item['status_name'] = '未支付';
|
||||
} else if ($item['paid'] == 1 && $item['status'] == 0 && $item['shipping_type'] == 1 && $item['refund_status'] == 0) {
|
||||
$item['status_name'] = '未发货';
|
||||
} else if ($item['paid'] == 1 && $item['status'] == 0 && $item['shipping_type'] == 2 && $item['refund_status'] == 0) {
|
||||
$item['status_name'] = '未核销';
|
||||
} else if ($item['paid'] == 1 && $item['status'] == 1 && $item['shipping_type'] == 1 && $item['refund_status'] == 0) {
|
||||
$item['status_name'] = '待收货';
|
||||
} else if ($item['paid'] == 1 && $item['status'] == 1 && $item['shipping_type'] == 2 && $item['refund_status'] == 0) {
|
||||
$item['status_name'] = '未核销';
|
||||
} else if ($item['paid'] == 1 && $item['status'] == 2 && $item['refund_status'] == 0) {
|
||||
$item['status_name'] = '待评价';
|
||||
} else if ($item['paid'] == 1 && $item['status'] == 3 && $item['refund_status'] == 0) {
|
||||
$item['status_name'] = '已完成';
|
||||
} else if ($item['paid'] == 1 && $item['refund_status'] == 1) {
|
||||
$refundReasonTime = date('Y-m-d H:i', $item['refund_reason_time']);
|
||||
$refundReasonWapImg = json_decode($item['refund_reason_wap_img'], true);
|
||||
$refundReasonWapImg = $refundReasonWapImg ?: [];
|
||||
$img = '';
|
||||
if (count($refundReasonWapImg)) {
|
||||
foreach ($refundReasonWapImg as $itemImg) {
|
||||
if (strlen(trim($itemImg)))
|
||||
$img .= '<img style="height:50px;" src="' . $itemImg . '" />';
|
||||
}
|
||||
}
|
||||
if (!strlen(trim($img))) $img = '无';
|
||||
$item['status_name'] = <<<HTML
|
||||
<b style="color:#f124c7">申请退款</b><br/>
|
||||
<span>退款原因:{$item['refund_reason_wap']}</span><br/>
|
||||
<span>备注说明:{$item['refund_reason_wap_explain']}</span><br/>
|
||||
<span>退款时间:{$refundReasonTime}</span><br/>
|
||||
<span>退款凭证:{$img}</span>
|
||||
HTML;
|
||||
} else if ($item['paid'] == 1 && $item['refund_status'] == 2) {
|
||||
$item['status_name'] = '已退款';
|
||||
}
|
||||
|
||||
$goodsName = [];
|
||||
foreach ($item['_info'] as $k => $v) {
|
||||
|
||||
$suk = '';
|
||||
if (isset($v['productInfo']['attrInfo'])) {
|
||||
if (isset($v['productInfo']['attrInfo']['suk'])) {
|
||||
$suk = '(' . $v['productInfo']['attrInfo']['suk'] . ')';
|
||||
}
|
||||
}
|
||||
if (isset($v['productInfo']['store_name'])) {
|
||||
$goodsName[] = implode(' ',
|
||||
[$v['productInfo']['store_name'],
|
||||
$suk,
|
||||
"[{$v['cart_num']} * {$v['truePrice']}]"
|
||||
]);
|
||||
}
|
||||
}
|
||||
if ($item['sex'] == 1) $sex_name = '男';
|
||||
else if ($item['sex'] == 2) $sex_name = '女';
|
||||
else $sex_name = '未知';
|
||||
$export[] = [
|
||||
$item['order_id'],
|
||||
$sex_name,
|
||||
$item['user_phone'],
|
||||
$item['real_name'],
|
||||
$item['user_phone'],
|
||||
$item['user_address'],
|
||||
$goodsName ? implode("\n", $goodsName) : '',
|
||||
$item['total_price'],
|
||||
$item['pay_price'],
|
||||
$item['pay_postage'],
|
||||
$item['coupon_price'],
|
||||
$item['pay_type_name'],
|
||||
$item['pay_time'] > 0 ? date('Y/m-d H:i', (int)$item['pay_time']) : '暂无',
|
||||
$item['status_name'] ?? '未知状态',
|
||||
empty($item['add_time']) ? 0 : date('Y-m-d H:i:s', (int)$item['add_time']),
|
||||
$item['mark']
|
||||
];
|
||||
}
|
||||
}
|
||||
$header = ['订单号', '性别', '电话', '收货人姓名', '收货人电话', '收货地址', '商品信息',
|
||||
'总价格', '实际支付', '邮费', '优惠金额', '支付状态', '支付时间', '订单状态', '下单时间', '用户备注'];
|
||||
$title = ['订单导出', '订单信息' . time(), ' 生成时间:' . date('Y-m-d H:i:s', time())];
|
||||
$filename = '订单导出_' . date('YmdHis', time());
|
||||
$suffix = 'xlsx';
|
||||
$is_save = true;
|
||||
return $this->export($header, $title, $export, $filename, $suffix, $is_save);
|
||||
}
|
||||
|
||||
/**
|
||||
* 商铺自提点导出
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user