mirror of
https://github.com/crmeb/CRMEB.git
synced 2026-03-19 04:04:08 +00:00
【程序目录】更新v4.7.0
This commit is contained in:
parent
c963fd6531
commit
20346a1ecc
33
README.md
33
README.md
@ -75,6 +75,24 @@ Redis
|
|||||||
|
|
||||||
> 温馨提示:虚拟空间不支持,推荐使用bt宝塔面板,服务器推荐阿里云ecs或腾讯云cvm 云服务器:<a href="https://promotion.aliyun.com/ntms/yunparter/invite.html?userCode=dligum2z" target="_blank"> 查看 </a>
|
> 温馨提示:虚拟空间不支持,推荐使用bt宝塔面板,服务器推荐阿里云ecs或腾讯云cvm 云服务器:<a href="https://promotion.aliyun.com/ntms/yunparter/invite.html?userCode=dligum2z" target="_blank"> 查看 </a>
|
||||||
|
|
||||||
|
### 官方论坛
|
||||||
|
|
||||||
|
|
||||||
|
[](https://www.crmeb.com/ask/thread/list/147)
|
||||||
|
|
||||||
|
产品BUG、优化建议,欢迎社区反馈:https://www.crmeb.com/ask/thread/list?id=147
|
||||||
|
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
#### 体验云部署
|
||||||
|
不懂服务器?不懂技术?无法解决高并发?想数据私有化?还想后期定制开发?
|
||||||
|
|
||||||
|
推荐云部署版一键超低价格低至 :collision: 9.9元/年,解决以上所有问题<a href='https://saas.crmeb.com/saas-home-software-detail-50043-s-y.html' target='_blank'>点击了解 </a>
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### 系统演示
|
### 系统演示
|
||||||
|
|
||||||
@ -88,21 +106,6 @@ PC端:http://v4.crmeb.net/(电脑端打开)
|
|||||||
|
|
||||||
APP下载:http://app.crmeb.cn/bzv (苹果手机直接在APP Store里搜索CRMEB下载)
|
APP下载:http://app.crmeb.cn/bzv (苹果手机直接在APP Store里搜索CRMEB下载)
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
#### 体验云部署
|
|
||||||
不懂服务器?不懂技术?无法解决高并发?想数据私有化?还想后期定制开发?
|
|
||||||
|
|
||||||
推荐云部署版一键超低价格低至 :collision: 9.9元/年,解决以上所有问题<a href='https://saas.crmeb.com/saas-home-software-detail-50043-s-y.html' target='_blank'>点击了解 </a>
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
### 官方论坛
|
|
||||||
|
|
||||||
|
|
||||||
产品BUG、优化建议,欢迎社区反馈:https://www.crmeb.com/ask/thread/list?id=147
|
|
||||||
|
|
||||||
|
|
||||||
### 页面展示
|
### 页面展示
|
||||||
(页面仅展示部分UI)
|
(页面仅展示部分UI)
|
||||||

|

|
||||||
|
|||||||
@ -346,6 +346,7 @@ class Common extends AuthController
|
|||||||
$pid = $item->getData('pid');
|
$pid = $item->getData('pid');
|
||||||
$data[$key] = json_decode($item, true);
|
$data[$key] = json_decode($item, true);
|
||||||
$data[$key]['pid'] = $pid;
|
$data[$key]['pid'] = $pid;
|
||||||
|
$data[$key]['menu_path'] = '/' . config('app.admin_prefix', 'admin') . $item['menu_path'];
|
||||||
if (in_array($item->id, $counts)) {
|
if (in_array($item->id, $counts)) {
|
||||||
$data[$key]['type'] = 1;
|
$data[$key]['type'] = 1;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@ -95,6 +95,7 @@ class ExportExcel extends AuthController
|
|||||||
['pay_type', ''],
|
['pay_type', ''],
|
||||||
['order', ''],
|
['order', ''],
|
||||||
['field_key', ''],
|
['field_key', ''],
|
||||||
|
['ids', []],
|
||||||
]);
|
]);
|
||||||
$where['is_system_del'] = 0;
|
$where['is_system_del'] = 0;
|
||||||
$where['pid'] = 0;
|
$where['pid'] = 0;
|
||||||
@ -110,7 +111,8 @@ class ExportExcel extends AuthController
|
|||||||
$where = $this->request->getMore([
|
$where = $this->request->getMore([
|
||||||
['store_name', ''],
|
['store_name', ''],
|
||||||
['cate_id', ''],
|
['cate_id', ''],
|
||||||
['type', 1]
|
['type', 1],
|
||||||
|
['ids', []]
|
||||||
]);
|
]);
|
||||||
return app('json')->success($this->service->exportProductList($where));
|
return app('json')->success($this->service->exportProductList($where));
|
||||||
}
|
}
|
||||||
@ -206,6 +208,7 @@ class ExportExcel extends AuthController
|
|||||||
['price_max', ''],
|
['price_max', ''],
|
||||||
['price_min', ''],
|
['price_min', ''],
|
||||||
['excel', '1'],
|
['excel', '1'],
|
||||||
|
['time', ''],
|
||||||
]);
|
]);
|
||||||
$data = $services->getCommissionList($where, false);
|
$data = $services->getCommissionList($where, false);
|
||||||
return app('json')->success($this->service->userCommission($data['list'] ?? []));
|
return app('json')->success($this->service->userCommission($data['list'] ?? []));
|
||||||
|
|||||||
@ -62,6 +62,7 @@ class StoreService extends AuthController
|
|||||||
['data', '', '', 'time'],
|
['data', '', '', 'time'],
|
||||||
['type', '', '', 'user_type'],
|
['type', '', '', 'user_type'],
|
||||||
]);
|
]);
|
||||||
|
$where['is_del'] = 0;
|
||||||
[$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');
|
[$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'));
|
return app('json')->success(compact('list', 'count'));
|
||||||
}
|
}
|
||||||
|
|||||||
@ -106,10 +106,7 @@ class StoreSeckill extends AuthController
|
|||||||
$storeProductAttrValueServices = app()->make(StoreProductAttrValueServices::class);
|
$storeProductAttrValueServices = app()->make(StoreProductAttrValueServices::class);
|
||||||
$unique = $storeProductAttrValueServices->value(['product_id' => $id, 'type' => 1], 'unique');
|
$unique = $storeProductAttrValueServices->value(['product_id' => $id, 'type' => 1], 'unique');
|
||||||
if ($unique) {
|
if ($unique) {
|
||||||
$name = 'seckill_' . $unique . '_1';
|
CacheService::delete('seckill_' . $unique . '_1');
|
||||||
/** @var CacheService $cache */
|
|
||||||
$cache = app()->make(CacheService::class);
|
|
||||||
$cache->del($name);
|
|
||||||
}
|
}
|
||||||
return app('json')->success(100002);
|
return app('json')->success(100002);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -78,6 +78,9 @@ class LiveRoom extends AuthController
|
|||||||
['replay_status', 1],
|
['replay_status', 1],
|
||||||
['sort', 0]
|
['sort', 0]
|
||||||
]);
|
]);
|
||||||
|
if (mb_strlen($data['name']) < 6 || mb_strlen($data['name']) > 17) {
|
||||||
|
return app('json')->fail(500030);
|
||||||
|
}
|
||||||
$this->validate($data, \app\adminapi\validate\marketing\LiveRoomValidate::class, 'save');
|
$this->validate($data, \app\adminapi\validate\marketing\LiveRoomValidate::class, 'save');
|
||||||
$this->services->add($data);
|
$this->services->add($data);
|
||||||
return app('json')->success(100000);
|
return app('json')->success(100000);
|
||||||
|
|||||||
@ -103,14 +103,10 @@ class SmsConfig extends AuthController
|
|||||||
*/
|
*/
|
||||||
public function logout()
|
public function logout()
|
||||||
{
|
{
|
||||||
$res = CacheService::delete('sms_account');
|
CacheService::delete('sms_account');
|
||||||
if ($res) {
|
$this->services->updateSmsConfig('', '');
|
||||||
$this->services->updateSmsConfig('', '');
|
CacheService::clear();
|
||||||
CacheService::clear();
|
return app('json')->success(100042);
|
||||||
return app('json')->success(100042);
|
|
||||||
} else {
|
|
||||||
return app('json')->fail(100043);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -57,7 +57,13 @@ class RefundOrder extends AuthController
|
|||||||
/**
|
/**
|
||||||
* 订单详情
|
* 订单详情
|
||||||
* @param $uni
|
* @param $uni
|
||||||
* @return mixed
|
* @return \think\Response
|
||||||
|
* @throws \think\db\exception\DataNotFoundException
|
||||||
|
* @throws \think\db\exception\DbException
|
||||||
|
* @throws \think\db\exception\ModelNotFoundException
|
||||||
|
* @author 吴汐
|
||||||
|
* @email 442384644@qq.com
|
||||||
|
* @date 2023/03/02
|
||||||
*/
|
*/
|
||||||
public function getRefundInfo($uni)
|
public function getRefundInfo($uni)
|
||||||
{
|
{
|
||||||
@ -163,12 +169,12 @@ class RefundOrder extends AuthController
|
|||||||
return app('json')->fail(400147);
|
return app('json')->fail(400147);
|
||||||
}
|
}
|
||||||
$refund_price = $data['refund_price'];
|
$refund_price = $data['refund_price'];
|
||||||
|
}
|
||||||
|
|
||||||
$data['refunded_price'] = bcadd($data['refund_price'], $orderRefund['refunded_price'], 2);
|
$data['refunded_price'] = bcadd($data['refund_price'], $orderRefund['refunded_price'], 2);
|
||||||
$bj = bccomp((string)$orderRefund['refund_price'], (string)$data['refunded_price'], 2);
|
$bj = bccomp((string)$orderRefund['refund_price'], (string)$data['refunded_price'], 2);
|
||||||
if ($bj < 0) {
|
if ($bj < 0) {
|
||||||
return app('json')->fail(400148);
|
return app('json')->fail(400148);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
unset($data['type']);
|
unset($data['type']);
|
||||||
@ -184,7 +190,7 @@ class RefundOrder extends AuthController
|
|||||||
$refund_data['open_id'] = $wechatUserServices->uidToOpenid((int)$order['uid'], 'routine') ?? '';
|
$refund_data['open_id'] = $wechatUserServices->uidToOpenid((int)$order['uid'], 'routine') ?? '';
|
||||||
$refund_data['refund_no'] = $orderRefund['order_id'];
|
$refund_data['refund_no'] = $orderRefund['order_id'];
|
||||||
//修改订单退款状态
|
//修改订单退款状态
|
||||||
unset($data['refund_price']);
|
$data['refund_price'] = $data['refunded_price'];
|
||||||
if ($this->services->agreeRefund($id, $refund_data)) {
|
if ($this->services->agreeRefund($id, $refund_data)) {
|
||||||
$this->services->update($id, $data);
|
$this->services->update($id, $data);
|
||||||
return app('json')->success(400149);
|
return app('json')->success(400149);
|
||||||
|
|||||||
@ -591,7 +591,7 @@ class StoreOrder extends AuthController
|
|||||||
}
|
}
|
||||||
$services->storeProductOrderRefundNo((int)$id, $refund_reason);
|
$services->storeProductOrderRefundNo((int)$id, $refund_reason);
|
||||||
//提醒推送
|
//提醒推送
|
||||||
event('notice.notice', [['orderInfo' => $orderInfo], 'send_order_refund_no_status']);
|
event('NoticeListener', [['orderInfo' => $orderInfo], 'send_order_refund_no_status']);
|
||||||
return app('json')->success(100010);
|
return app('json')->success(100010);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -307,6 +307,9 @@ class SystemConfig extends AuthController
|
|||||||
return app('json')->fail(400763);
|
return app('json')->fail(400763);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (isset($post['uni_brokerage_price']) && preg_match('/\.[0-9]{2,}[1-9][0-9]*$/', (string)$post['uni_brokerage_price']) > 0) {
|
||||||
|
return app('json')->fail(500029);
|
||||||
|
}
|
||||||
|
|
||||||
//支付接口类型选择,如果有订单就不能再进行切换
|
//支付接口类型选择,如果有订单就不能再进行切换
|
||||||
// if (isset($post['pay_wechat_type'])) {
|
// if (isset($post['pay_wechat_type'])) {
|
||||||
|
|||||||
@ -136,7 +136,7 @@ class SystemClearData extends AuthController
|
|||||||
//删除商品收藏记录
|
//删除商品收藏记录
|
||||||
/** @var StoreProductReplyServices $productRelation */
|
/** @var StoreProductReplyServices $productRelation */
|
||||||
$productRelation = app()->make(StoreProductReplyServices::class);
|
$productRelation = app()->make(StoreProductReplyServices::class);
|
||||||
$productRelation->delete([['product_id', 'in', $ids], ['category', '=', 'product']]);
|
$productRelation->delete([['product_id', 'in', $ids], ['reply_type', '=', 'product']]);
|
||||||
|
|
||||||
//删除商品的评论
|
//删除商品的评论
|
||||||
/** @var StoreProductReplyServices $productReply */
|
/** @var StoreProductReplyServices $productReply */
|
||||||
|
|||||||
@ -3,12 +3,12 @@
|
|||||||
namespace app\adminapi\controller\v1\system;
|
namespace app\adminapi\controller\v1\system;
|
||||||
|
|
||||||
use app\adminapi\controller\AuthController;
|
use app\adminapi\controller\AuthController;
|
||||||
use app\services\system\timer\SystemTimerServices;
|
use app\services\system\crontab\SystemCrontabServices;
|
||||||
use think\facade\App;
|
use think\facade\App;
|
||||||
|
|
||||||
class SystemTimer extends AuthController
|
class SystemCrontab extends AuthController
|
||||||
{
|
{
|
||||||
public function __construct(App $app, SystemTimerServices $services)
|
public function __construct(App $app, SystemCrontabServices $services)
|
||||||
{
|
{
|
||||||
parent::__construct($app);
|
parent::__construct($app);
|
||||||
$this->services = $services;
|
$this->services = $services;
|
||||||
@ -123,20 +123,19 @@ class User extends AuthController
|
|||||||
if ($data['card_id']) {
|
if ($data['card_id']) {
|
||||||
if (!check_card($data['card_id'])) return app('json')->fail(400315);
|
if (!check_card($data['card_id'])) return app('json')->fail(400315);
|
||||||
}
|
}
|
||||||
if ($data['pwd']) {
|
if (!$data['pwd']) {
|
||||||
if (!$data['true_pwd']) {
|
return app('json')->fail(400256);
|
||||||
return app('json')->fail(400263);
|
|
||||||
}
|
|
||||||
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']);
|
|
||||||
}
|
}
|
||||||
|
if (!$data['true_pwd']) {
|
||||||
|
return app('json')->fail(400263);
|
||||||
|
}
|
||||||
|
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']);
|
||||||
unset($data['true_pwd']);
|
unset($data['true_pwd']);
|
||||||
$data['avatar'] = sys_config('h5_avatar');
|
$data['avatar'] = sys_config('h5_avatar');
|
||||||
$data['adminId'] = $this->adminId;
|
$data['adminId'] = $this->adminId;
|
||||||
@ -379,6 +378,12 @@ class User extends AuthController
|
|||||||
['spread_open', 1]
|
['spread_open', 1]
|
||||||
]);
|
]);
|
||||||
if (!$id) return app('json')->fail(100100);
|
if (!$id) return app('json')->fail(100100);
|
||||||
|
if (!$data['real_name']) {
|
||||||
|
return app('json')->fail(410245);
|
||||||
|
}
|
||||||
|
if (!$data['phone']) {
|
||||||
|
return app('json')->fail(410245);
|
||||||
|
}
|
||||||
if ($data['phone']) {
|
if ($data['phone']) {
|
||||||
if (!preg_match("/^1[3456789]\d{9}$/", $data['phone'])) return app('json')->fail(400252);
|
if (!preg_match("/^1[3456789]\d{9}$/", $data['phone'])) return app('json')->fail(400252);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -36,7 +36,6 @@ Route::group(function () {
|
|||||||
Route::get('get_workerman_url', 'PublicController/getWorkerManUrl')->option(['real_name' => '获取客服数据']);
|
Route::get('get_workerman_url', 'PublicController/getWorkerManUrl')->option(['real_name' => '获取客服数据']);
|
||||||
//测试
|
//测试
|
||||||
Route::get('index', 'Test/index')->option(['real_name' => '测试地址']);
|
Route::get('index', 'Test/index')->option(['real_name' => '测试地址']);
|
||||||
Route::get('h5', 'Test/h5pay')->option(['real_name' => '测试地址2']);
|
|
||||||
})->middleware(AllowOriginMiddleware::class);
|
})->middleware(AllowOriginMiddleware::class);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -99,17 +99,17 @@ Route::group('system', function () {
|
|||||||
|
|
||||||
/** 定时任务 */
|
/** 定时任务 */
|
||||||
//定时任务列表
|
//定时任务列表
|
||||||
Route::get('timer/list', 'v1.system.SystemTimer/getTimerList')->option(['real_name' => '定时任务列表']);
|
Route::get('crontab/list', 'v1.system.SystemCrontab/getTimerList')->option(['real_name' => '定时任务列表']);
|
||||||
//定时任务类型
|
//定时任务类型
|
||||||
Route::get('timer/mark', 'v1.system.SystemTimer/getMarkList')->option(['real_name' => '定时任务类型']);
|
Route::get('crontab/mark', 'v1.system.SystemCrontab/getMarkList')->option(['real_name' => '定时任务类型']);
|
||||||
//定时任务详情
|
//定时任务详情
|
||||||
Route::get('timer/info/:id', 'v1.system.SystemTimer/getTimerInfo')->option(['real_name' => '定时任务详情']);
|
Route::get('crontab/info/:id', 'v1.system.SystemCrontab/getTimerInfo')->option(['real_name' => '定时任务详情']);
|
||||||
//定时任务添加编辑
|
//定时任务添加编辑
|
||||||
Route::post('timer/save', 'v1.system.SystemTimer/saveTimer')->option(['real_name' => '定时任务添加编辑']);
|
Route::post('crontab/save', 'v1.system.SystemCrontab/saveTimer')->option(['real_name' => '定时任务添加编辑']);
|
||||||
//删除定时任务
|
//删除定时任务
|
||||||
Route::delete('timer/del/:id', 'v1.system.SystemTimer/delTimer')->option(['real_name' => '删除定时任务']);
|
Route::delete('crontab/del/:id', 'v1.system.SystemCrontab/delTimer')->option(['real_name' => '删除定时任务']);
|
||||||
//定时任务是否开启开关
|
//定时任务是否开启开关
|
||||||
Route::get('timer/set_open/:id/:is_open', 'v1.system.SystemTimer/setTimerStatus')->option(['real_name' => '定时任务是否开启开关']);
|
Route::get('crontab/set_open/:id/:is_open', 'v1.system.SystemCrontab/setTimerStatus')->option(['real_name' => '定时任务是否开启开关']);
|
||||||
|
|
||||||
})->middleware([
|
})->middleware([
|
||||||
\app\http\middleware\AllowOriginMiddleware::class,
|
\app\http\middleware\AllowOriginMiddleware::class,
|
||||||
|
|||||||
@ -14,6 +14,7 @@ namespace app\api;
|
|||||||
|
|
||||||
use crmeb\exceptions\AdminException;
|
use crmeb\exceptions\AdminException;
|
||||||
use crmeb\exceptions\ApiException;
|
use crmeb\exceptions\ApiException;
|
||||||
|
use crmeb\exceptions\ApiStatusException;
|
||||||
use crmeb\exceptions\AuthException;
|
use crmeb\exceptions\AuthException;
|
||||||
use think\db\exception\DbException;
|
use think\db\exception\DbException;
|
||||||
use think\exception\Handle;
|
use think\exception\Handle;
|
||||||
@ -86,11 +87,13 @@ class ApiExceptionHandle extends Handle
|
|||||||
] : [];
|
] : [];
|
||||||
$message = Env::get('app_debug', false) ? $e->getMessage() : '很抱歉,系统开小差了';
|
$message = Env::get('app_debug', false) ? $e->getMessage() : '很抱歉,系统开小差了';
|
||||||
// 添加自定义异常处理机制
|
// 添加自定义异常处理机制
|
||||||
|
if ($e instanceof ApiStatusException) {
|
||||||
|
return app('json')->status($e->getApiStatus(), $message, $e->getApiData());
|
||||||
|
}
|
||||||
if ($e instanceof AuthException || $e instanceof AdminException || $e instanceof ApiException || $e instanceof ValidateException) {
|
if ($e instanceof AuthException || $e instanceof AdminException || $e instanceof ApiException || $e instanceof ValidateException) {
|
||||||
return app('json')->make($e->getCode() ?: 400, $message, $massageData);
|
return app('json')->make($e->getCode() ?: 400, $message, $massageData);
|
||||||
} else {
|
|
||||||
return app('json')->fail($message, $massageData);
|
|
||||||
}
|
}
|
||||||
|
return app('json')->fail($message, $massageData);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -9,35 +9,3 @@
|
|||||||
// | Author: CRMEB Team <admin@crmeb.com>
|
// | Author: CRMEB Team <admin@crmeb.com>
|
||||||
// +----------------------------------------------------------------------
|
// +----------------------------------------------------------------------
|
||||||
|
|
||||||
/**
|
|
||||||
* 设置浏览信息
|
|
||||||
* @param $uid
|
|
||||||
* @param int $product_id
|
|
||||||
* @param int $cate
|
|
||||||
* @param string $type
|
|
||||||
* @param string $content
|
|
||||||
* @param int $min
|
|
||||||
*/
|
|
||||||
function set_view($uid, $product_id = 0, $cate = 0, $type = '', $content = '', $min = 20)
|
|
||||||
{
|
|
||||||
//TODO 待优化
|
|
||||||
$Db = new \app\models\store\StoreVisit;
|
|
||||||
$view = $Db->where('uid', $uid)->where('product_id', $product_id)->field('count,add_time,id')->find();
|
|
||||||
if ($view && $type != 'search') {
|
|
||||||
$time = time();
|
|
||||||
if (($view['add_time'] + $min) < $time) {
|
|
||||||
$Db->where(['id' => $view['id']])->update(['count' => $view['count'] + 1, 'add_time' => time()]);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$cate = explode(',', $cate)[0];
|
|
||||||
$Db->insert([
|
|
||||||
'add_time' => time(),
|
|
||||||
'count' => 1,
|
|
||||||
'product_id' => $product_id,
|
|
||||||
'cate_id' => $cate,
|
|
||||||
'type' => $type,
|
|
||||||
'uid' => $uid,
|
|
||||||
'content' => $content
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@ -10,15 +10,33 @@ use app\services\order\StoreOrderServices;
|
|||||||
use app\services\order\StoreOrderTakeServices;
|
use app\services\order\StoreOrderTakeServices;
|
||||||
use app\services\product\product\StoreProductServices;
|
use app\services\product\product\StoreProductServices;
|
||||||
use app\services\system\attachment\SystemAttachmentServices;
|
use app\services\system\attachment\SystemAttachmentServices;
|
||||||
|
use app\services\system\crontab\SystemCrontabServices;
|
||||||
|
|
||||||
class TimerController
|
/**
|
||||||
|
* 定时任务控制器
|
||||||
|
* @author 吴汐
|
||||||
|
* @email 442384644@qq.com
|
||||||
|
* @date 2023/02/21
|
||||||
|
*/
|
||||||
|
class CrontabController
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* 定时任务调用接口
|
||||||
|
* @author 吴汐
|
||||||
|
* @email 442384644@qq.com
|
||||||
|
* @date 2023/02/17
|
||||||
|
*/
|
||||||
|
public function crontabRun()
|
||||||
|
{
|
||||||
|
app()->make(SystemCrontabServices::class)->crontabRun();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 检测定时任务是否正常,必须6秒执行一次
|
* 检测定时任务是否正常,必须6秒执行一次
|
||||||
*/
|
*/
|
||||||
public function timerCheck()
|
public function crontabCheck()
|
||||||
{
|
{
|
||||||
file_put_contents(runtime_path() . '.timer', time());
|
file_put_contents(root_path() . 'runtime/.timer', time());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -13,6 +13,7 @@ namespace app\api\controller\v1;
|
|||||||
|
|
||||||
|
|
||||||
use app\Request;
|
use app\Request;
|
||||||
|
use crmeb\services\app\MiniProgramService;
|
||||||
use crmeb\services\pay\Pay;
|
use crmeb\services\pay\Pay;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -36,8 +37,11 @@ class PayController
|
|||||||
/** @var Pay $pay */
|
/** @var Pay $pay */
|
||||||
$pay = app()->make(Pay::class, ['ali_pay']);
|
$pay = app()->make(Pay::class, ['ali_pay']);
|
||||||
return $pay->handleNotify();
|
return $pay->handleNotify();
|
||||||
case 'wechat':
|
case 'v3wechat':
|
||||||
|
return app()->make(Pay::class, ['v3_wechat_pay'])->handleNotify()->getContent();
|
||||||
case 'routine':
|
case 'routine':
|
||||||
|
return MiniProgramService::handleNotify();
|
||||||
|
case 'wechat':
|
||||||
if (sys_config('pay_wechat_type')) {
|
if (sys_config('pay_wechat_type')) {
|
||||||
/** @var Pay $pay */
|
/** @var Pay $pay */
|
||||||
$pay = app()->make(Pay::class, ['v3_wechat_pay']);
|
$pay = app()->make(Pay::class, ['v3_wechat_pay']);
|
||||||
|
|||||||
@ -645,4 +645,16 @@ class PublicController
|
|||||||
{
|
{
|
||||||
return app('json')->success(['version' => get_crmeb_version()]);
|
return app('json')->success(['version' => get_crmeb_version()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取多语言缓存
|
||||||
|
* @return \think\Response
|
||||||
|
* @author 吴汐
|
||||||
|
* @email 442384644@qq.com
|
||||||
|
* @date 2023/03/06
|
||||||
|
*/
|
||||||
|
public function getLangVersion()
|
||||||
|
{
|
||||||
|
return app('json')->success(app()->make(LangCodeServices::class)->getLangVersion());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -56,7 +56,7 @@ class OtherOrderController
|
|||||||
$uid = $request->uid();
|
$uid = $request->uid();
|
||||||
/** @var UserServices $userService */
|
/** @var UserServices $userService */
|
||||||
$userService = app()->make(UserServices::class);
|
$userService = app()->make(UserServices::class);
|
||||||
$user_info = $userService->get($uid);
|
$user_info = $userService->get($uid, ['is_money_level']);
|
||||||
//会员线下享受折扣
|
//会员线下享受折扣
|
||||||
if ($user_info->is_money_level > 0) {
|
if ($user_info->is_money_level > 0) {
|
||||||
//看是否开启线下享受折扣
|
//看是否开启线下享受折扣
|
||||||
@ -115,30 +115,20 @@ class OtherOrderController
|
|||||||
|
|
||||||
$info = compact('order_id');
|
$info = compact('order_id');
|
||||||
|
|
||||||
$payType = get_pay_type($payType);
|
$payType = app()->make(OrderPayServices::class)->getPayType($payType);
|
||||||
|
|
||||||
|
//支付金额为0
|
||||||
|
if (bcsub((string)$orderInfo['pay_price'], '0', 2) <= 0) {
|
||||||
|
//创建订单jspay支付
|
||||||
|
$payPriceStatus = $OtherOrderServices->zeroYuanPayment($orderInfo);
|
||||||
|
if ($payPriceStatus)//0元支付成功
|
||||||
|
return app('json')->status('success', 410199, $info);
|
||||||
|
else
|
||||||
|
return app('json')->status('pay_error');
|
||||||
|
}
|
||||||
|
|
||||||
if ($order_id) {
|
if ($order_id) {
|
||||||
switch ($payType) {
|
switch ($payType) {
|
||||||
case PayServices::WEIXIN_PAY:
|
|
||||||
if ($orderInfo['paid']) return app('json')->fail(410174);
|
|
||||||
//支付金额为0
|
|
||||||
if (bcsub((string)$orderInfo['pay_price'], '0', 2) <= 0) {
|
|
||||||
//创建订单jspay支付
|
|
||||||
$payPriceStatus = $OtherOrderServices->zeroYuanPayment($orderInfo, $uid);
|
|
||||||
if ($payPriceStatus)//0元支付成功
|
|
||||||
return app('json')->status('success', 410195, $info);
|
|
||||||
else
|
|
||||||
return app('json')->status('pay_error');
|
|
||||||
} else {
|
|
||||||
/** @var OrderPayServices $payServices */
|
|
||||||
$payServices = app()->make(OrderPayServices::class);
|
|
||||||
$info['jsConfig'] = $payServices->orderPay($orderInfo, $from);
|
|
||||||
if ($from == 'weixinh5') {
|
|
||||||
return app('json')->status('wechat_h5_pay', 410196, $info);
|
|
||||||
} else {
|
|
||||||
return app('json')->status('wechat_pay', 410196, $info);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
case PayServices::YUE_PAY:
|
case PayServices::YUE_PAY:
|
||||||
/** @var YuePayServices $yueServices */
|
/** @var YuePayServices $yueServices */
|
||||||
$yueServices = app()->make(YuePayServices::class);
|
$yueServices = app()->make(YuePayServices::class);
|
||||||
@ -151,39 +141,12 @@ class OtherOrderController
|
|||||||
else
|
else
|
||||||
return app('json')->status('pay_error', $pay);
|
return app('json')->status('pay_error', $pay);
|
||||||
}
|
}
|
||||||
case PayServices::ALIAPY_PAY:
|
|
||||||
if (!$quitUrl && $from != 'routine' && !request()->isApp()) {
|
|
||||||
return app('json')->status('pay_error', 410198, $info);
|
|
||||||
}
|
|
||||||
//支付金额为0
|
|
||||||
if (bcsub((string)$orderInfo['pay_price'], '0', 2) <= 0) {
|
|
||||||
//创建订单jspay支付
|
|
||||||
$payPriceStatus = $OtherOrderServices->zeroYuanPayment($orderInfo);
|
|
||||||
if ($payPriceStatus)//0元支付成功
|
|
||||||
return app('json')->status('success', 410199, $info);
|
|
||||||
else
|
|
||||||
return app('json')->status('pay_error');
|
|
||||||
} else {
|
|
||||||
/** @var OrderPayServices $payServices */
|
|
||||||
$payServices = app()->make(OrderPayServices::class);
|
|
||||||
$info['jsConfig'] = $payServices->alipayOrder($orderInfo, $quitUrl, $from == 'routine');
|
|
||||||
$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);
|
|
||||||
}
|
|
||||||
case PayServices::OFFLINE_PAY:
|
case PayServices::OFFLINE_PAY:
|
||||||
return app('json')->status('success', 410196, $info);
|
return app('json')->status('success', 410196, $info);
|
||||||
case PayServices::ALLIN_PAY:
|
default:
|
||||||
/** @var OrderPayServices $payServices */
|
|
||||||
$payServices = app()->make(OrderPayServices::class);
|
$payServices = app()->make(OrderPayServices::class);
|
||||||
$info['jsConfig'] = $payServices->orderPay($orderInfo, $payType, [
|
$payInfo = $payServices->beforePay($order->toArray(), $payType, ['quitUrl' => $quitUrl]);
|
||||||
'returl' => sys_config('site_url') . '/pages/index/index',
|
return app('json')->status($payInfo['status'], $payInfo['payInfo']);
|
||||||
]);
|
|
||||||
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);
|
} else return app('json')->fail(410200);
|
||||||
}
|
}
|
||||||
@ -194,8 +157,8 @@ class OtherOrderController
|
|||||||
*/
|
*/
|
||||||
public function pay_type(Request $request)
|
public function pay_type(Request $request)
|
||||||
{
|
{
|
||||||
$payType['ali_pay_status'] = is_ali_pay();
|
$payType['ali_pay_status'] = sys_config('ali_pay_status', '0') != '0';
|
||||||
$payType['pay_weixin_open'] = is_wecaht_pay();
|
$payType['pay_weixin_open'] = sys_config('pay_weixin_open', '0') != '0';
|
||||||
$payType['site_name'] = sys_config('site_name');
|
$payType['site_name'] = sys_config('site_name');
|
||||||
$payType['now_money'] = $request->user('now_money');
|
$payType['now_money'] = $request->user('now_money');
|
||||||
$payType['offline_pay_status'] = true;
|
$payType['offline_pay_status'] = true;
|
||||||
|
|||||||
@ -65,18 +65,8 @@ class StoreIntegralOrderController
|
|||||||
|
|
||||||
$num = (int)$num;
|
$num = (int)$num;
|
||||||
//判断积分商品限量
|
//判断积分商品限量
|
||||||
$unique = $storeIntegralServices->checkoutProductStock($uid, $productInfo['product_id'], $num, $unique);
|
$storeIntegralServices->checkoutProductStock($uid, $productInfo['product_id'], $num, $unique);
|
||||||
try {
|
$order = $this->services->createOrder($uid, $addressId, $mark, $request->user()->toArray(), $num, $productInfo);
|
||||||
//弹出队列
|
|
||||||
if (!CacheService::popStock($unique, $num, 4)) {
|
|
||||||
return app('json')->fail(410296);
|
|
||||||
}
|
|
||||||
$order = $this->services->createOrder($uid, $addressId, $mark, $request->user()->toArray(), $num, $productInfo);
|
|
||||||
} catch (\Throwable $e) {
|
|
||||||
//生成失败归还库存
|
|
||||||
CacheService::setStock($unique, $num, 4, false);
|
|
||||||
return app('json')->fail($e->getMessage());
|
|
||||||
}
|
|
||||||
return app('json')->status('success', 410203, ['orderId' => $order['order_id']]);
|
return app('json')->status('success', 410203, ['orderId' => $order['order_id']]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -15,6 +15,8 @@ use app\services\pay\PayServices;
|
|||||||
use app\services\shipping\ExpressServices;
|
use app\services\shipping\ExpressServices;
|
||||||
use app\services\system\admin\SystemAdminServices;
|
use app\services\system\admin\SystemAdminServices;
|
||||||
use app\services\user\UserInvoiceServices;
|
use app\services\user\UserInvoiceServices;
|
||||||
|
use crmeb\exceptions\ApiException;
|
||||||
|
use crmeb\exceptions\ApiStatusException;
|
||||||
use crmeb\services\pay\extend\allinpay\AllinPay;
|
use crmeb\services\pay\extend\allinpay\AllinPay;
|
||||||
use app\services\activity\{lottery\LuckLotteryServices,
|
use app\services\activity\{lottery\LuckLotteryServices,
|
||||||
bargain\StoreBargainServices,
|
bargain\StoreBargainServices,
|
||||||
@ -125,7 +127,7 @@ class StoreOrderController
|
|||||||
if ($this->services->be(['order_id|unique' => $key, 'uid' => $uid, 'is_del' => 0]))
|
if ($this->services->be(['order_id|unique' => $key, 'uid' => $uid, 'is_del' => 0]))
|
||||||
return app('json')->status('extend_order', 410173, ['orderId' => $key, 'key' => $key]);
|
return app('json')->status('extend_order', 410173, ['orderId' => $key, 'key' => $key]);
|
||||||
list($addressId, $couponId, $payType, $useIntegral, $mark, $combinationId, $pinkId, $seckill_id, $bargainId, $shipping_type) = $request->postMore([
|
list($addressId, $couponId, $payType, $useIntegral, $mark, $combinationId, $pinkId, $seckill_id, $bargainId, $shipping_type) = $request->postMore([
|
||||||
'addressId', 'couponId', ['payType', 'yue'], ['useIntegral', 0], 'mark', ['combinationId', 0], ['pinkId', 0], ['seckill_id', 0], ['bargainId', ''],
|
'addressId', 'couponId', ['payType', ''], ['useIntegral', 0], 'mark', ['combinationId', 0], ['pinkId', 0], ['seckill_id', 0], ['bargainId', ''],
|
||||||
['shipping_type', 1],
|
['shipping_type', 1],
|
||||||
], true);
|
], true);
|
||||||
$payType = strtolower($payType);
|
$payType = strtolower($payType);
|
||||||
@ -154,8 +156,8 @@ class StoreOrderController
|
|||||||
* @param StoreOrderInvoiceServices $storeOrderInvoiceServices
|
* @param StoreOrderInvoiceServices $storeOrderInvoiceServices
|
||||||
* @param StoreCombinationServices $combinationServices
|
* @param StoreCombinationServices $combinationServices
|
||||||
* @param $key
|
* @param $key
|
||||||
|
* @return \think\Response
|
||||||
* @throws \Psr\SimpleCache\InvalidArgumentException
|
* @throws \Psr\SimpleCache\InvalidArgumentException
|
||||||
* @throws \think\Exception
|
|
||||||
* @throws \think\db\exception\DataNotFoundException
|
* @throws \think\db\exception\DataNotFoundException
|
||||||
* @throws \think\db\exception\DbException
|
* @throws \think\db\exception\DbException
|
||||||
* @throws \think\db\exception\ModelNotFoundException
|
* @throws \think\db\exception\ModelNotFoundException
|
||||||
@ -163,10 +165,10 @@ class StoreOrderController
|
|||||||
public function create(Request $request, StoreBargainServices $bargainServices, StorePinkServices $pinkServices, StoreOrderCreateServices $createServices, StoreSeckillServices $seckillServices, UserInvoiceServices $userInvoiceServices, StoreOrderInvoiceServices $storeOrderInvoiceServices, StoreCombinationServices $combinationServices, $key)
|
public function create(Request $request, StoreBargainServices $bargainServices, StorePinkServices $pinkServices, StoreOrderCreateServices $createServices, StoreSeckillServices $seckillServices, UserInvoiceServices $userInvoiceServices, StoreOrderInvoiceServices $storeOrderInvoiceServices, StoreCombinationServices $combinationServices, $key)
|
||||||
{
|
{
|
||||||
if (!$key) return app('json')->fail(100100);
|
if (!$key) return app('json')->fail(100100);
|
||||||
$uid = (int)$request->uid();
|
$userInfo = $request->user()->toArray();
|
||||||
if ($checkOrder = $this->services->getOne(['order_id|unique' => $key, 'uid' => $uid, 'is_del' => 0]))
|
if ($checkOrder = $this->services->getOne(['order_id|unique' => $key, 'uid' => $userInfo['uid'], 'is_del' => 0]))
|
||||||
return app('json')->status('extend_order', 410209, ['orderId' => $checkOrder['order_id'], 'key' => $key]);
|
return app('json')->status('extend_order', 410209, ['orderId' => $checkOrder['order_id'], 'key' => $key]);
|
||||||
[$addressId, $couponId, $payType, $useIntegral, $mark, $combinationId, $pinkId, $seckill_id, $bargainId, $from, $shipping_type, $real_name, $phone, $storeId, $news, $invoice_id, $quitUrl, $advanceId, $virtual_type, $customForm] = $request->postMore([
|
[$addressId, $couponId, $payType, $useIntegral, $mark, $combinationId, $pinkId, $seckillId, $bargainId, $shipping_type, $real_name, $phone, $storeId, $news, $invoice_id, $quitUrl, $advanceId, $virtual_type, $customForm] = $request->postMore([
|
||||||
[['addressId', 'd'], 0],
|
[['addressId', 'd'], 0],
|
||||||
[['couponId', 'd'], 0],
|
[['couponId', 'd'], 0],
|
||||||
['payType', ''],
|
['payType', ''],
|
||||||
@ -176,7 +178,6 @@ class StoreOrderController
|
|||||||
[['pinkId', 'd'], 0],
|
[['pinkId', 'd'], 0],
|
||||||
[['seckill_id', 'd'], 0],
|
[['seckill_id', 'd'], 0],
|
||||||
[['bargainId', 'd'], ''],
|
[['bargainId', 'd'], ''],
|
||||||
['from', 'weixin'],
|
|
||||||
[['shipping_type', 'd'], 1],
|
[['shipping_type', 'd'], 1],
|
||||||
['real_name', ''],
|
['real_name', ''],
|
||||||
['phone', ''],
|
['phone', ''],
|
||||||
@ -189,172 +190,11 @@ class StoreOrderController
|
|||||||
['custom_form', []],
|
['custom_form', []],
|
||||||
], true);
|
], true);
|
||||||
$payType = strtolower($payType);
|
$payType = strtolower($payType);
|
||||||
$cartGroup = $this->services->getCacheOrderInfo($uid, $key);
|
$order = CacheService::lock('orderCreat' . $key, function () use ($createServices, $userInfo, $key, $addressId, $payType, $useIntegral, $couponId, $mark, $combinationId, $pinkId, $seckillId, $bargainId, $shipping_type, $real_name, $phone, $storeId, $news, $advanceId, $customForm, $invoice_id) {
|
||||||
if (!$cartGroup) {
|
return $createServices->createOrder($userInfo['uid'], $key, $userInfo, $addressId, $payType, !!$useIntegral, $couponId, $mark, $combinationId, $pinkId, $seckillId, $bargainId, $shipping_type, $real_name, $phone, $storeId, !!$news, $advanceId, $customForm, $invoice_id);
|
||||||
return app('json')->fail(410208);
|
});
|
||||||
}
|
|
||||||
//下单前砍价验证
|
|
||||||
if ($bargainId) {
|
|
||||||
$bargainServices->checkBargainUser((int)$bargainId, $uid);
|
|
||||||
}
|
|
||||||
//下单前发票验证
|
|
||||||
if ($invoice_id) {
|
|
||||||
$userInvoiceServices->checkInvoice((int)$invoice_id, $uid);
|
|
||||||
}
|
|
||||||
if ($pinkId) {
|
|
||||||
$pinkId = (int)$pinkId;
|
|
||||||
/** @var StorePinkServices $pinkServices */
|
|
||||||
$pinkServices = app()->make(StorePinkServices::class);
|
|
||||||
if ($pinkServices->isPink($pinkId, $uid))
|
|
||||||
return app('json')->status('ORDER_EXIST', 410210, ['orderId' => $this->services->getStoreIdPink($pinkId, $uid)]);
|
|
||||||
if ($this->services->getIsOrderPink($pinkId, $uid))
|
|
||||||
return app('json')->status('ORDER_EXIST', 410211, ['orderId' => $this->services->getStoreIdPink($pinkId, $uid)]);
|
|
||||||
if (!CacheService::checkStock(md5($pinkId), 1, 3) || !CacheService::popStock(md5($pinkId), 1, 3)) {
|
|
||||||
return app('json')->fail(410212);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ($from != 'pc') {
|
|
||||||
if (!$this->services->checkPaytype(get_pay_type($payType))) {
|
|
||||||
return app('json')->fail(410213);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$payType = 'pc';
|
|
||||||
}
|
|
||||||
$isChannel = $this->getChennel[$from] ?? ($request->isApp() ? 0 : 1);
|
|
||||||
$cartInfo = null;
|
|
||||||
if ($seckill_id || $combinationId || $bargainId || $advanceId) {
|
|
||||||
$cartInfo = $cartGroup['cartInfo'];
|
|
||||||
foreach ($cartInfo as $item) {
|
|
||||||
$type = 0;
|
|
||||||
if (!isset($item['product_attr_unique']) || !$item['product_attr_unique']) continue;
|
|
||||||
if ($item['seckill_id']) {
|
|
||||||
$type = 1;
|
|
||||||
} elseif ($item['bargain_id']) {
|
|
||||||
$type = 2;
|
|
||||||
} elseif ($item['combination_id']) {
|
|
||||||
$type = 3;
|
|
||||||
} elseif ($item['advance_id']) {
|
|
||||||
$type = 6;
|
|
||||||
}
|
|
||||||
if ($type && (!CacheService::checkStock($item['product_attr_unique'], (int)$item['cart_num'], $type) || !CacheService::popStock($item['product_attr_unique'], (int)$item['cart_num'], $type))) {
|
|
||||||
return app('json')->fail(410214, null, ['cart_num' => $item['cart_num'], 'unit_name' => $item['productInfo']['unit_name']]);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$virtual_type = $cartGroup['cartInfo'][0]['productInfo']['virtual_type'] ?? 0;
|
|
||||||
$order = $createServices->createOrder($uid, $key, $cartGroup, $request->user()->toArray(), $addressId, $payType, !!$useIntegral, $couponId, $mark, $combinationId, $pinkId, $seckill_id, $bargainId, $isChannel, $shipping_type, $real_name, $phone, $storeId, !!$news, $advanceId, $virtual_type, $customForm);
|
|
||||||
if ($order === false) {
|
|
||||||
if ($seckill_id || $combinationId || $advanceId || $bargainId) {
|
|
||||||
foreach ($cartInfo as $item) {
|
|
||||||
$value = $item['cart_info'];
|
|
||||||
$type = 0;
|
|
||||||
if (!isset($value['product_attr_unique']) || $value['product_attr_unique']) continue;
|
|
||||||
if ($value['seckill_id']) {
|
|
||||||
$type = 1;
|
|
||||||
} elseif ($value['bargain_id']) {
|
|
||||||
$type = 2;
|
|
||||||
} elseif ($value['combination_id']) {
|
|
||||||
$type = 3;
|
|
||||||
} elseif ($value['advance_id']) {
|
|
||||||
$type = 6;
|
|
||||||
}
|
|
||||||
if ($type) CacheService::setStock($value['product_attr_unique'], (int)$value['cart_num'], $type, false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return app('json')->fail(410200);
|
|
||||||
}
|
|
||||||
$orderId = $order['order_id'];
|
$orderId = $order['order_id'];
|
||||||
$orderInfo = $this->services->getOne(['order_id' => $orderId]);
|
return app('json')->status('success', 410203, compact('orderId', 'key'));
|
||||||
if (!$orderInfo || !isset($orderInfo['paid'])) {
|
|
||||||
return app('json')->fail(410194);
|
|
||||||
}
|
|
||||||
//创建开票数据
|
|
||||||
if ($invoice_id) {
|
|
||||||
$storeOrderInvoiceServices->makeUp($uid, $orderId, (int)$invoice_id);
|
|
||||||
}
|
|
||||||
$orderInfo = $orderInfo->toArray();
|
|
||||||
$info = compact('orderId', 'key');
|
|
||||||
if ($orderId) {
|
|
||||||
switch ($payType) {
|
|
||||||
case PayServices::WEIXIN_PAY:
|
|
||||||
if ($orderInfo['paid']) return app('json')->fail(410174);
|
|
||||||
//支付金额为0
|
|
||||||
if (bcsub((string)$orderInfo['pay_price'], '0', 2) <= 0) {
|
|
||||||
//创建订单jspay支付
|
|
||||||
/** @var StoreOrderSuccessServices $success */
|
|
||||||
$success = app()->make(StoreOrderSuccessServices::class);
|
|
||||||
$payPriceStatus = $success->zeroYuanPayment($orderInfo, $uid, PayServices::WEIXIN_PAY);
|
|
||||||
if ($payPriceStatus)//0元支付成功
|
|
||||||
return app('json')->status('success', 410195, $info);
|
|
||||||
else
|
|
||||||
return app('json')->status('pay_error');
|
|
||||||
} else {
|
|
||||||
/** @var OrderPayServices $payServices */
|
|
||||||
$payServices = app()->make(OrderPayServices::class);
|
|
||||||
if ($from == 'app' && $request->isApp()) {
|
|
||||||
$from = 'weixin';
|
|
||||||
}
|
|
||||||
$info['jsConfig'] = $payServices->orderPay($orderInfo, $from);
|
|
||||||
if ($from == 'weixinh5') {
|
|
||||||
return app('json')->status('wechat_h5_pay', 410203, $info);
|
|
||||||
} else {
|
|
||||||
return app('json')->status('wechat_pay', 410203, $info);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
case PayServices::YUE_PAY:
|
|
||||||
/** @var YuePayServices $yueServices */
|
|
||||||
$yueServices = app()->make(YuePayServices::class);
|
|
||||||
$pay = $yueServices->yueOrderPay($orderInfo, $uid);
|
|
||||||
if ($pay['status'] === true)
|
|
||||||
return app('json')->status('success', 410197, $info);
|
|
||||||
else {
|
|
||||||
if (is_array($pay))
|
|
||||||
return app('json')->status($pay['status'], $pay['msg'], $info);
|
|
||||||
else
|
|
||||||
return app('json')->status('pay_error', $pay);
|
|
||||||
}
|
|
||||||
case PayServices::ALIAPY_PAY:
|
|
||||||
if (!$quitUrl && ($request->isH5() || $request->isWechat())) {
|
|
||||||
return app('json')->status('pay_error', 410198, $info);
|
|
||||||
}
|
|
||||||
[$url, $param] = explode('?', $quitUrl);
|
|
||||||
$quitUrl = $url . '?order_id=' . $orderInfo['order_id'];
|
|
||||||
//支付金额为0
|
|
||||||
if (bcsub((string)$orderInfo['pay_price'], '0', 2) <= 0) {
|
|
||||||
//创建订单jspay支付
|
|
||||||
/** @var StoreOrderSuccessServices $success */
|
|
||||||
$success = app()->make(StoreOrderSuccessServices::class);
|
|
||||||
$payPriceStatus = $success->zeroYuanPayment($orderInfo, $uid, PayServices::ALIAPY_PAY);
|
|
||||||
if ($payPriceStatus)//0元支付成功
|
|
||||||
return app('json')->status('success', 410199, $info);
|
|
||||||
else
|
|
||||||
return app('json')->status('pay_error');
|
|
||||||
} else {
|
|
||||||
/** @var OrderPayServices $payServices */
|
|
||||||
$payServices = app()->make(OrderPayServices::class);
|
|
||||||
$info['jsConfig'] = $payServices->alipayOrder($orderInfo, $quitUrl, $from == 'routine');
|
|
||||||
$payKey = md5($orderInfo['order_id']);
|
|
||||||
CacheService::set($payKey, ['order_id' => $orderInfo['order_id'], 'other_pay_type' => false], 300);
|
|
||||||
$info['pay_key'] = $payKey;
|
|
||||||
return app('json')->status(PayServices::ALIAPY_PAY . '_pay', 410203, $info);
|
|
||||||
}
|
|
||||||
case PayServices::OFFLINE_PAY:
|
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -372,6 +212,23 @@ class StoreOrderController
|
|||||||
return app('json')->success(['cateId' => implode(',', $cateId)]);
|
return app('json')->success(['cateId' => implode(',', $cateId)]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $orderId
|
||||||
|
* @param string $type
|
||||||
|
* @return \think\Response
|
||||||
|
* @author 等风来
|
||||||
|
* @email 136327134@qq.com
|
||||||
|
* @date 2023/2/13
|
||||||
|
*/
|
||||||
|
public function cashier(Request $request, $orderId, $type = 'order')
|
||||||
|
{
|
||||||
|
if (!$orderId) {
|
||||||
|
return app('json')->fail(100100);
|
||||||
|
}
|
||||||
|
|
||||||
|
return app('json')->success($this->services->getCashierInfo((int)$request->uid(), $orderId, $type));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 订单支付
|
* 订单支付
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
@ -383,10 +240,9 @@ class StoreOrderController
|
|||||||
*/
|
*/
|
||||||
public function pay(Request $request, StorePinkServices $services, OrderPayServices $payServices, YuePayServices $yuePayServices)
|
public function pay(Request $request, StorePinkServices $services, OrderPayServices $payServices, YuePayServices $yuePayServices)
|
||||||
{
|
{
|
||||||
[$uni, $paytype, $from, $quitUrl, $type] = $request->postMore([
|
[$uni, $paytype, $quitUrl, $type] = $request->postMore([
|
||||||
['uni', ''],
|
['uni', ''],
|
||||||
['paytype', 'weixin'],
|
['paytype', ''],
|
||||||
['from', 'weixin'],
|
|
||||||
['quitUrl', ''],
|
['quitUrl', ''],
|
||||||
['type', 0]
|
['type', 0]
|
||||||
], true);
|
], true);
|
||||||
@ -395,6 +251,7 @@ class StoreOrderController
|
|||||||
$uid = $type == 1 ? (int)$request->uid() : $orderInfo->uid;
|
$uid = $type == 1 ? (int)$request->uid() : $orderInfo->uid;
|
||||||
$orderInfo->pay_uid = $uid;
|
$orderInfo->pay_uid = $uid;
|
||||||
$orderInfo->save();
|
$orderInfo->save();
|
||||||
|
$orderInfo = $orderInfo->toArray();
|
||||||
$order = $this->services->get(['order_id' => $uni]);
|
$order = $this->services->get(['order_id' => $uni]);
|
||||||
if (!$order)
|
if (!$order)
|
||||||
return app('json')->fail(410173);
|
return app('json')->fail(410173);
|
||||||
@ -403,58 +260,23 @@ class StoreOrderController
|
|||||||
if ($order['pink_id'] && $services->isPinkStatus($order['pink_id'])) {
|
if ($order['pink_id'] && $services->isPinkStatus($order['pink_id'])) {
|
||||||
return app('json')->fail(410215);
|
return app('json')->fail(410215);
|
||||||
}
|
}
|
||||||
$isChannel = $this->getChennel[$from];
|
|
||||||
//缓存不存在 || 切换另一端支付
|
//重新生成订单号去支付
|
||||||
if (!Cache::get('pay_' . $order['order_id']) || $isChannel != $order['is_channel']) {
|
$order['order_id'] = mt_rand(100, 999) . '_' . $order['order_id'];
|
||||||
switch ($from) {
|
|
||||||
case 'weixin':
|
//0元支付
|
||||||
if ($type == 1 || in_array($order['is_channel'], [1, 2, 3, 4])) {//0
|
if (bcsub((string)$orderInfo['pay_price'], '0', 2) <= 0) {
|
||||||
$order['order_id'] = mt_rand(100, 999) . '_' . $order['order_id'];
|
//创建订单jspay支付
|
||||||
}
|
/** @var StoreOrderSuccessServices $success */
|
||||||
break;
|
$success = app()->make(StoreOrderSuccessServices::class);
|
||||||
case 'weixinh5':
|
$payPriceStatus = $success->zeroYuanPayment($orderInfo, $uid, $paytype);
|
||||||
if ($type == 1 || in_array($order['is_channel'], [0, 1, 3, 4])) {
|
if ($payPriceStatus)//0元支付成功
|
||||||
$order['order_id'] = mt_rand(100, 999) . '_' . $order['order_id'];
|
return app('json')->status('success', 410195, ['order_id' => $orderInfo['order_id'], 'key' => $orderInfo['unique']]);
|
||||||
}
|
else
|
||||||
break;
|
return app('json')->status('pay_error', 410216);
|
||||||
case 'routine':
|
|
||||||
if ($type == 1 || in_array($order['is_channel'], [0, 2, 3, 4])) {
|
|
||||||
$order['order_id'] = mt_rand(100, 999) . '_' . $order['order_id'];
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 'app':
|
|
||||||
if ($type == 1 || in_array($order['is_channel'], [0, 1, 2, 3])) {
|
|
||||||
$order['order_id'] = mt_rand(100, 999) . '_' . $order['order_id'];
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 'pc':
|
|
||||||
case 'aliapy':
|
|
||||||
$order['order_id'] = mt_rand(100, 999) . '_' . $order['order_id'];
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
$order['pay_type'] = get_pay_type($paytype); //重新支付选择支付方式
|
|
||||||
switch ($order['pay_type']) {
|
switch ($paytype) {
|
||||||
case PayServices::WEIXIN_PAY:
|
|
||||||
$jsConfig = $payServices->orderPay($order->toArray(), $from);
|
|
||||||
if ($from == 'weixinh5') {
|
|
||||||
return app('json')->status('wechat_h5_pay', ['jsConfig' => $jsConfig, 'order_id' => $order['order_id']]);
|
|
||||||
} elseif ($from == 'weixin' || $from == 'routine') {
|
|
||||||
return app('json')->status('wechat_pay', ['jsConfig' => $jsConfig, 'order_id' => $order['order_id']]);
|
|
||||||
} elseif ($from == 'pc') {
|
|
||||||
return app('json')->status('wechat_pc_pay', ['jsConfig' => $jsConfig, 'order_id' => $order['order_id']]);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case PayServices::ALIAPY_PAY:
|
|
||||||
if (!$quitUrl && $from != 'routine') {
|
|
||||||
return app('json')->fail(410198);
|
|
||||||
}
|
|
||||||
$isCode = $from == 'routine' || $from == 'pc';
|
|
||||||
$jsConfig = $payServices->alipayOrder($order->toArray(), $quitUrl, $isCode);
|
|
||||||
if ($isCode && !($jsConfig->invalid ?? false)) $jsConfig->invalid = time() + 60;
|
|
||||||
$payKey = md5($order['order_id']);
|
|
||||||
CacheService::set($payKey, ['order_id' => $order['order_id'], 'other_pay_type' => false], 300);
|
|
||||||
return app('json')->status(PayServices::ALIAPY_PAY . '_pay', 410203, ['jsConfig' => $jsConfig, 'order_id' => $order['order_id'], 'pay_key' => $payKey]);
|
|
||||||
case PayServices::YUE_PAY:
|
case PayServices::YUE_PAY:
|
||||||
$pay = $yuePayServices->yueOrderPay($order->toArray(), $request->uid());
|
$pay = $yuePayServices->yueOrderPay($order->toArray(), $request->uid());
|
||||||
if ($pay['status'] === true)
|
if ($pay['status'] === true)
|
||||||
@ -470,22 +292,14 @@ class StoreOrderController
|
|||||||
return app('json')->status('success', 410203);
|
return app('json')->status('success', 410203);
|
||||||
else
|
else
|
||||||
return app('json')->status('success', 410216);
|
return app('json')->status('success', 410216);
|
||||||
case PayServices::ALLIN_PAY:
|
default:
|
||||||
/** @var OrderPayServices $payServices */
|
$payInfo = $payServices->beforePay($order->toArray(), $paytype, ['quitUrl' => $quitUrl]);
|
||||||
$payServices = app()->make(OrderPayServices::class);
|
return app('json')->status($payInfo['status'], $payInfo['payInfo']);
|
||||||
$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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 支付宝单独支付
|
* TODO 支付宝单独支付 弃用
|
||||||
* @param OrderPayServices $payServices
|
* @param OrderPayServices $payServices
|
||||||
* @param OtherOrderServices $services
|
* @param OtherOrderServices $services
|
||||||
* @param string $key
|
* @param string $key
|
||||||
@ -495,11 +309,11 @@ class StoreOrderController
|
|||||||
* @throws \think\db\exception\DbException
|
* @throws \think\db\exception\DbException
|
||||||
* @throws \think\db\exception\ModelNotFoundException
|
* @throws \think\db\exception\ModelNotFoundException
|
||||||
*/
|
*/
|
||||||
public function aliPay(OrderPayServices $payServices, OtherOrderServices $services, string $key, string $quitUrl)
|
// public function aliPay(OrderPayServices $payServices, OtherOrderServices $services, string $key, string $quitUrl)
|
||||||
{
|
// {
|
||||||
$payInfo = $this->services->aliPayOrder($payServices, $services, $key, $quitUrl);
|
// $payInfo = $this->services->aliPayOrder($payServices, $services, $key, $quitUrl);
|
||||||
return app('json')->success(['pay_content' => $payInfo]);
|
// return app('json')->success(['pay_content' => $payInfo]);
|
||||||
}
|
// }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 订单列表
|
* 订单列表
|
||||||
|
|||||||
@ -34,8 +34,13 @@ class ArticleController
|
|||||||
*/
|
*/
|
||||||
public function lst($cid)
|
public function lst($cid)
|
||||||
{
|
{
|
||||||
|
if ($cid == 0) {
|
||||||
|
$where = ['is_hot' => 1];
|
||||||
|
} else {
|
||||||
|
$where = ['cid' => $cid];
|
||||||
|
}
|
||||||
[$page, $limit] = $this->services->getPageValue();
|
[$page, $limit] = $this->services->getPageValue();
|
||||||
$list = $this->services->cidByArticleList(['cid' => $cid], $page, $limit, "id,title,image_input,visit,from_unixtime(add_time,'%Y-%m-%d %H:%i') as add_time,synopsis,url");
|
$list = $this->services->cidByArticleList($where, $page, $limit, "id,title,image_input,visit,from_unixtime(add_time,'%Y-%m-%d %H:%i') as add_time,synopsis,url");
|
||||||
return app('json')->success($list);
|
return app('json')->success($list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -40,13 +40,14 @@ class CategoryController
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @return mixed
|
||||||
* @author 等风来
|
* @author 等风来
|
||||||
* @email 136327134@qq.com
|
* @email 136327134@qq.com
|
||||||
* @date 2022/11/11
|
* @date 2022/11/11
|
||||||
* @return mixed
|
|
||||||
*/
|
*/
|
||||||
public function getCategoryVersion()
|
public function getCategoryVersion()
|
||||||
{
|
{
|
||||||
return app('json')->success(['version' => $this->services->getCategoryVersion()]);
|
$data = $this->services->getCategoryVersion();
|
||||||
|
return app('json')->success(['version' => $data['version'], 'is_diy' => $data['is_diy']]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -42,6 +42,7 @@ class DivisionController
|
|||||||
]);
|
]);
|
||||||
$verifyCode = CacheService::get('code_' . $data['phone']);
|
$verifyCode = CacheService::get('code_' . $data['phone']);
|
||||||
if ($verifyCode != $data['code']) return app('json')->fail(410010);
|
if ($verifyCode != $data['code']) return app('json')->fail(410010);
|
||||||
|
if ($data['division_invite'] == 0) return app('json')->fail(500028);
|
||||||
$this->services->applyAgent($data, $id);
|
$this->services->applyAgent($data, $id);
|
||||||
return app('json')->success(100017);
|
return app('json')->success(100017);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -49,18 +49,19 @@ class UserRechargeController
|
|||||||
if (!in_array($type, [0, 1])) return app('json')->fail(410123);
|
if (!in_array($type, [0, 1])) return app('json')->fail(410123);
|
||||||
if (!in_array($from, [PayServices::WEIXIN_PAY, 'weixinh5', 'routine', PayServices::ALIAPY_PAY])) return app('json')->fail(410123);
|
if (!in_array($from, [PayServices::WEIXIN_PAY, 'weixinh5', 'routine', PayServices::ALIAPY_PAY])) return app('json')->fail(410123);
|
||||||
$storeMinRecharge = sys_config('store_user_min_recharge');
|
$storeMinRecharge = sys_config('store_user_min_recharge');
|
||||||
if ($price < $storeMinRecharge) return app('json')->fail(410124, null, ['money' => $storeMinRecharge]);
|
if (!$recharId && $price < $storeMinRecharge) return app('json')->fail(410124, null, ['money' => $storeMinRecharge]);
|
||||||
$uid = (int)$request->uid();
|
$uid = (int)$request->uid();
|
||||||
$re = $this->services->recharge($uid, $price, $recharId, $type, $from);
|
$re = $this->services->recharge($uid, $price, $recharId, $type, $from, true);
|
||||||
if ($re) {
|
if ($re) {
|
||||||
unset($re['msg']);
|
$payType = $re['pay_type'];
|
||||||
return app('json')->success(410125, $re);
|
unset($re['pay_type']);
|
||||||
|
return app('json')->status($payType, 410125, $re);
|
||||||
}
|
}
|
||||||
return app('json')->fail(410126);
|
return app('json')->fail(410126);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 小程序充值
|
* TODO 小程序充值 弃用
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
@ -81,7 +82,7 @@ class UserRechargeController
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 公众号充值
|
* TODO 公众号充值 弃用
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -37,7 +37,12 @@ class AuthController
|
|||||||
/**
|
/**
|
||||||
* 小程序授权登录
|
* 小程序授权登录
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
* @return mixed
|
* @return \think\Response
|
||||||
|
* @throws \think\db\exception\DataNotFoundException
|
||||||
|
* @throws \think\db\exception\ModelNotFoundException
|
||||||
|
* @author 吴汐
|
||||||
|
* @email 442384644@qq.com
|
||||||
|
* @date 2023/02/24
|
||||||
*/
|
*/
|
||||||
public function mp_auth(Request $request)
|
public function mp_auth(Request $request)
|
||||||
{
|
{
|
||||||
@ -79,7 +84,7 @@ class AuthController
|
|||||||
*/
|
*/
|
||||||
public function notify()
|
public function notify()
|
||||||
{
|
{
|
||||||
$this->services->notify();
|
return $this->services->notify();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -85,8 +85,8 @@ class PublicController
|
|||||||
{
|
{
|
||||||
/** @var DiyServices $diyService */
|
/** @var DiyServices $diyService */
|
||||||
$diyService = app()->make(DiyServices::class);
|
$diyService = app()->make(DiyServices::class);
|
||||||
$version = $diyService->getDiyVersion((int)$id);
|
$data = $diyService->getDiyVersion((int)$id);
|
||||||
return app('json')->success(['version' => $version ?: '']);
|
return app('json')->success(['version' => $data['version'] ?: '', 'is_diy' => $data['is_diy']]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -79,6 +79,23 @@ class AuthController
|
|||||||
return app('json')->fail(410019);
|
return app('json')->fail(410019);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 小程序绑定手机号
|
||||||
|
* @param string $code
|
||||||
|
* @param string $iv
|
||||||
|
* @param string $encryptedData
|
||||||
|
* @return \think\Response
|
||||||
|
* @author 吴汐
|
||||||
|
* @email 442384644@qq.com
|
||||||
|
* @date 2023/02/24
|
||||||
|
*/
|
||||||
|
public function bindingPhone($code = '', $iv = '', $encryptedData = '')
|
||||||
|
{
|
||||||
|
if (!$code || !$iv || !$encryptedData) return app('json')->fail(100100);
|
||||||
|
$this->services->bindingPhone($code, $iv, $encryptedData);
|
||||||
|
return app('json')->success(410016);
|
||||||
|
}
|
||||||
|
|
||||||
/** 以下方法该版本暂未使用 */
|
/** 以下方法该版本暂未使用 */
|
||||||
/**
|
/**
|
||||||
* 小程序授权登录
|
* 小程序授权登录
|
||||||
|
|||||||
@ -17,8 +17,6 @@ return [
|
|||||||
'HttpEnd' => [],
|
'HttpEnd' => [],
|
||||||
'LogLevel' => [],
|
'LogLevel' => [],
|
||||||
'LogWrite' => [],
|
'LogWrite' => [],
|
||||||
'UserLogin'=>[
|
'UserLogin'=> []
|
||||||
// \crmeb\listeners\user\UserLogin::class
|
|
||||||
]
|
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
|
|||||||
@ -15,9 +15,6 @@ use think\facade\Config;
|
|||||||
use think\Response;
|
use think\Response;
|
||||||
|
|
||||||
Route::any('wechat/serve', 'v1.wechat.WechatController/serve');//公众号服务
|
Route::any('wechat/serve', 'v1.wechat.WechatController/serve');//公众号服务
|
||||||
Route::any('wechat/notify', 'v1.wechat.WechatController/notify');//公众号支付回调
|
|
||||||
Route::any('wechat/v3notify', 'v1.wechat.WechatController/v3notify');//公众号支付回调
|
|
||||||
Route::any('routine/notify', 'v1.wechat.AuthController/notify');//小程序支付回调
|
|
||||||
Route::any('pay/notify/:type', 'v1.PayController/notify');//支付回调
|
Route::any('pay/notify/:type', 'v1.PayController/notify');//支付回调
|
||||||
Route::get('get_script', 'v1.PublicController/getScript');//获取统计代码
|
Route::get('get_script', 'v1.PublicController/getScript');//获取统计代码
|
||||||
Route::get('version', 'v1.PublicController/getVersion');//获取统计代码
|
Route::get('version', 'v1.PublicController/getVersion');//获取统计代码
|
||||||
@ -45,8 +42,8 @@ Route::group(function () {
|
|||||||
Route::post('register/reset', 'v1.LoginController/reset')->name('registerReset');
|
Route::post('register/reset', 'v1.LoginController/reset')->name('registerReset');
|
||||||
// 绑定手机号(静默授权 还未有用户信息)
|
// 绑定手机号(静默授权 还未有用户信息)
|
||||||
Route::post('binding', 'v1.LoginController/binding_phone')->name('bindingPhone');
|
Route::post('binding', 'v1.LoginController/binding_phone')->name('bindingPhone');
|
||||||
// 支付宝复制链接支付
|
// 支付宝复制链接支付 弃用
|
||||||
Route::get('ali_pay', 'v1.order.StoreOrderController/aliPay')->name('aliPay');
|
// Route::get('ali_pay', 'v1.order.StoreOrderController/aliPay')->name('aliPay');
|
||||||
//查询版权
|
//查询版权
|
||||||
Route::get('copyright', 'v1.PublicController/copyright')->option(['real_name' => '申请版权']);
|
Route::get('copyright', 'v1.PublicController/copyright')->option(['real_name' => '申请版权']);
|
||||||
|
|
||||||
@ -166,6 +163,7 @@ Route::group(function () {
|
|||||||
Route::post('order/pay', 'v1.order.StoreOrderController/pay')->name('orderPay'); //订单支付
|
Route::post('order/pay', 'v1.order.StoreOrderController/pay')->name('orderPay'); //订单支付
|
||||||
Route::post('order/product', 'v1.order.StoreOrderController/product')->name('orderProduct'); //订单商品信息
|
Route::post('order/product', 'v1.order.StoreOrderController/product')->name('orderProduct'); //订单商品信息
|
||||||
Route::post('order/comment', 'v1.order.StoreOrderController/comment')->name('orderComment'); //订单评价
|
Route::post('order/comment', 'v1.order.StoreOrderController/comment')->name('orderComment'); //订单评价
|
||||||
|
Route::get('order/cashier/:orderId/[:type]', 'v1.order.StoreOrderController/cashier')->name('orderCashier'); //订单收银台
|
||||||
//活动---砍价
|
//活动---砍价
|
||||||
Route::get('bargain/detail/:id', 'v1.activity.StoreBargainController/detail')->name('bargainDetail');//砍价商品详情
|
Route::get('bargain/detail/:id', 'v1.activity.StoreBargainController/detail')->name('bargainDetail');//砍价商品详情
|
||||||
Route::post('bargain/start', 'v1.activity.StoreBargainController/start')->name('bargainStart');//砍价开启
|
Route::post('bargain/start', 'v1.activity.StoreBargainController/start')->name('bargainStart');//砍价开启
|
||||||
@ -390,28 +388,32 @@ Route::group(function () {
|
|||||||
Route::get('get_lang_json', 'v1.PublicController/getLangJson')->name('getLangJson');
|
Route::get('get_lang_json', 'v1.PublicController/getLangJson')->name('getLangJson');
|
||||||
//获取当前后台设置的默认语言类型
|
//获取当前后台设置的默认语言类型
|
||||||
Route::get('get_default_lang_type', 'v1.PublicController/getDefaultLangType')->name('getLangJson');
|
Route::get('get_default_lang_type', 'v1.PublicController/getDefaultLangType')->name('getLangJson');
|
||||||
|
//获取当前后台设置的默认语言类型
|
||||||
|
Route::get('lang_version', 'v1.PublicController/getLangVersion')->name('getLangVersion');
|
||||||
|
|
||||||
/** 定时任务接口 */
|
/** 定时任务接口 */
|
||||||
|
//定时任务调用接口
|
||||||
|
Route::get('crontab/run', 'v1.CrontabController/crontabRun')->name('crontabRun');
|
||||||
//检测定时任务接口
|
//检测定时任务接口
|
||||||
Route::get('timer/check', 'v1.TimerController/timerCheck')->name('timerCheck');
|
Route::get('crontab/check', 'v1.CrontabController/crontabCheck')->name('crontabCheck');
|
||||||
//未支付自动取消订单
|
//未支付自动取消订单
|
||||||
Route::get('timer/order_cancel', 'v1.TimerController/orderUnpaidCancel')->name('orderUnpaidCancel');
|
Route::get('crontab/order_cancel', 'v1.CrontabController/orderUnpaidCancel')->name('orderUnpaidCancel');
|
||||||
//拼团到期订单处理
|
//拼团到期订单处理
|
||||||
Route::get('timer/pink_expiration', 'v1.TimerController/pinkExpiration')->name('pinkExpiration');
|
Route::get('crontab/pink_expiration', 'v1.CrontabController/pinkExpiration')->name('pinkExpiration');
|
||||||
//自动解绑上级绑定
|
//自动解绑上级绑定
|
||||||
Route::get('timer/agent_unbind', 'v1.TimerController/agentUnbind')->name('agentUnbind');
|
Route::get('crontab/agent_unbind', 'v1.CrontabController/agentUnbind')->name('agentUnbind');
|
||||||
//更新直播商品状态
|
//更新直播商品状态
|
||||||
Route::get('timer/live_product_status', 'v1.TimerController/syncGoodStatus')->name('syncGoodStatus');
|
Route::get('crontab/live_product_status', 'v1.CrontabController/syncGoodStatus')->name('syncGoodStatus');
|
||||||
//更新直播间状态
|
//更新直播间状态
|
||||||
Route::get('timer/live_room_status', 'v1.TimerController/syncRoomStatus')->name('syncRoomStatus');
|
Route::get('crontab/live_room_status', 'v1.CrontabController/syncRoomStatus')->name('syncRoomStatus');
|
||||||
//自动收货
|
//自动收货
|
||||||
Route::get('timer/take_delivery', 'v1.TimerController/autoTakeOrder')->name('autoTakeOrder');
|
Route::get('crontab/take_delivery', 'v1.CrontabController/autoTakeOrder')->name('autoTakeOrder');
|
||||||
//查询预售到期商品自动下架
|
//查询预售到期商品自动下架
|
||||||
Route::get('timer/advance_off', 'v1.TimerController/downAdvance')->name('downAdvance');
|
Route::get('crontab/advance_off', 'v1.CrontabController/downAdvance')->name('downAdvance');
|
||||||
//自动好评
|
//自动好评
|
||||||
Route::get('timer/product_replay', 'v1.TimerController/autoComment')->name('autoComment');
|
Route::get('crontab/product_replay', 'v1.CrontabController/autoComment')->name('autoComment');
|
||||||
//清除昨日海报
|
//清除昨日海报
|
||||||
Route::get('timer/clear_poster', 'v1.TimerController/emptyYesterdayAttachment')->name('emptyYesterdayAttachment');
|
Route::get('crontab/clear_poster', 'v1.CrontabController/emptyYesterdayAttachment')->name('emptyYesterdayAttachment');
|
||||||
|
|
||||||
|
|
||||||
})->middleware(\app\http\middleware\AllowOriginMiddleware::class)->middleware(\app\api\middleware\StationOpenMiddleware::class)->middleware(\app\api\middleware\AuthTokenMiddleware::class, false);
|
})->middleware(\app\http\middleware\AllowOriginMiddleware::class)->middleware(\app\api\middleware\StationOpenMiddleware::class)->middleware(\app\api\middleware\AuthTokenMiddleware::class, false);
|
||||||
|
|||||||
@ -36,6 +36,8 @@ Route::group('v2', function () {
|
|||||||
Route::get('bind_status', 'v2.PublicController/bindPhoneStatus');
|
Route::get('bind_status', 'v2.PublicController/bindPhoneStatus');
|
||||||
//小程序授权绑定手机号
|
//小程序授权绑定手机号
|
||||||
Route::post('auth_bindind_phone', 'v2.wechat.AuthController/authBindingPhone');
|
Route::post('auth_bindind_phone', 'v2.wechat.AuthController/authBindingPhone');
|
||||||
|
//小程序授权后绑定手机号
|
||||||
|
Route::post('routine/binding_phone', 'v2.wechat.AuthController/BindingPhone');
|
||||||
//小程序手机号登录直接绑定
|
//小程序手机号登录直接绑定
|
||||||
Route::post('phone_silence_auth', 'v2.wechat.AuthController/silenceAuthBindingPhone');
|
Route::post('phone_silence_auth', 'v2.wechat.AuthController/silenceAuthBindingPhone');
|
||||||
//微信手机号登录直接绑定
|
//微信手机号登录直接绑定
|
||||||
|
|||||||
@ -22,63 +22,19 @@ use app\services\system\lang\LangTypeServices;
|
|||||||
use app\services\system\lang\LangCodeServices;
|
use app\services\system\lang\LangCodeServices;
|
||||||
use app\services\system\lang\LangCountryServices;
|
use app\services\system\lang\LangCountryServices;
|
||||||
use think\facade\Config;
|
use think\facade\Config;
|
||||||
|
use think\facade\Log;
|
||||||
|
|
||||||
if (!function_exists('get_pay_type')) {
|
if (!function_exists('crmebLog')) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $payType
|
* CRMEB Log 日志
|
||||||
* @return string
|
* @param $msg
|
||||||
* @author 等风来
|
* @author 吴汐
|
||||||
* @email 136327134@qq.com
|
* @email 442384644@qq.com
|
||||||
* @date 2023/2/9
|
* @date 2023/03/03
|
||||||
*/
|
*/
|
||||||
function get_pay_type(string $payType)
|
function crmebLog($msg)
|
||||||
{
|
{
|
||||||
// $allinPay = (int)sys_config('allin_pay_status') == 1;
|
Log::write($msg, 'crmeb');
|
||||||
//
|
|
||||||
// //微信支付没有开启,通联支付开启,用户访问端在小程序或者公众号的时候,使用通联微信H5支付
|
|
||||||
// if ($payType == PayServices::WEIXIN_PAY) {
|
|
||||||
// $wechat_pay_type = (int)sys_config('wechat_pay_type', 0);
|
|
||||||
// if ($wechat_pay_type == 1 && $allinPay && (request()->isRoutine() || request()->isWechat())) {
|
|
||||||
// $payType = PayServices::ALLIN_PAY;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// //支付宝没有开启,通联支付开了,用户使用支付宝支付,并且在app端访问的时候,使用通联app支付宝支付
|
|
||||||
// if ($payType == PayServices::ALIAPY_PAY) {
|
|
||||||
// $alipay_pay_type = (int)sys_config('alipay_pay_type', 0);
|
|
||||||
// if ($alipay_pay_type == 1 && $allinPay && 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()
|
|
||||||
{
|
|
||||||
return (int)sys_config('pay_weixin_open') == 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!function_exists('is_ali_pay')) {
|
|
||||||
/**
|
|
||||||
* @return bool
|
|
||||||
* @author 等风来
|
|
||||||
* @email 136327134@qq.com
|
|
||||||
* @date 2023/2/8
|
|
||||||
*/
|
|
||||||
function is_ali_pay()
|
|
||||||
{
|
|
||||||
return (int)sys_config('ali_pay_status') == 1;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -981,61 +937,72 @@ if (!function_exists('getLang')) {
|
|||||||
*/
|
*/
|
||||||
function getLang($code, array $replace = [])
|
function getLang($code, array $replace = [])
|
||||||
{
|
{
|
||||||
/** @var LangCountryServices $langCountryServices */
|
//确保获取语言的时候不会报错
|
||||||
$langCountryServices = app()->make(LangCountryServices::class);
|
try {
|
||||||
/** @var LangTypeServices $langTypeServices */
|
|
||||||
$langTypeServices = app()->make(LangTypeServices::class);
|
|
||||||
/** @var LangCodeServices $langCodeServices */
|
|
||||||
$langCodeServices = app()->make(LangCodeServices::class);
|
|
||||||
|
|
||||||
$request = app()->request;
|
/** @var LangCountryServices $langCountryServices */
|
||||||
//获取接口传入的语言类型
|
$langCountryServices = app()->make(LangCountryServices::class);
|
||||||
if (!$range = $request->header('cb-lang')) {
|
/** @var LangTypeServices $langTypeServices */
|
||||||
//没有传入则使用系统默认语言显示
|
$langTypeServices = app()->make(LangTypeServices::class);
|
||||||
$range = $langTypeServices->cacheDriver()->remember('range_name', function () use ($langTypeServices) {
|
/** @var LangCodeServices $langCodeServices */
|
||||||
return $langTypeServices->value(['is_default' => 1], 'file_name');
|
$langCodeServices = app()->make(LangCodeServices::class);
|
||||||
});
|
|
||||||
if (!$range) {
|
$request = app()->request;
|
||||||
//系统没有设置默认语言的话,根据浏览器语言显示,如果浏览器语言在库中找不到,则使用简体中文
|
//获取接口传入的语言类型
|
||||||
if ($request->header('accept-language') !== null) {
|
if (!$range = $request->header('cb-lang')) {
|
||||||
$range = explode(',', $request->header('accept-language'))[0];
|
//没有传入则使用系统默认语言显示
|
||||||
} else {
|
$range = $langTypeServices->cacheDriver()->remember('range_name', function () use ($langTypeServices) {
|
||||||
$range = 'zh-CN';
|
return $langTypeServices->value(['is_default' => 1], 'file_name');
|
||||||
|
});
|
||||||
|
if (!$range) {
|
||||||
|
//系统没有设置默认语言的话,根据浏览器语言显示,如果浏览器语言在库中找不到,则使用简体中文
|
||||||
|
if ($request->header('accept-language') !== null) {
|
||||||
|
$range = explode(',', $request->header('accept-language'))[0];
|
||||||
|
} else {
|
||||||
|
$range = 'zh-CN';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// 获取type_id
|
// 获取type_id
|
||||||
$typeId = $langCountryServices->cacheDriver()->remember('type_id_' . $range, function () use ($langCountryServices, $range) {
|
$typeId = $langCountryServices->cacheDriver()->remember('type_id_' . $range, function () use ($langCountryServices, $range) {
|
||||||
return $langCountryServices->value(['code' => $range], 'type_id') ?: 1;
|
return $langCountryServices->value(['code' => $range], 'type_id') ?: 1;
|
||||||
}, 3600);
|
}, 3600);
|
||||||
|
|
||||||
// 获取类型
|
// 获取类型
|
||||||
$langData = CacheService::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');
|
return $langTypeServices->getColumn(['status' => 1, 'is_del' => 0], 'file_name', 'id');
|
||||||
}, 3600);
|
}, 3600);
|
||||||
|
|
||||||
// 获取缓存key
|
// 获取缓存key
|
||||||
$langStr = 'lang_' . str_replace('-', '_', $langData[$typeId]);
|
$langStr = 'lang_' . str_replace('-', '_', $langData[$typeId]);
|
||||||
|
|
||||||
//读取当前语言的语言包
|
//读取当前语言的语言包
|
||||||
$lang = CacheService::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');
|
return $langCodeServices->getColumn(['type_id' => $typeId, 'is_admin' => 1], 'lang_explain', 'code');
|
||||||
}, 3600);
|
}, 3600);
|
||||||
//获取返回文字
|
//获取返回文字
|
||||||
$message = (string)($lang[$code] ?? 'Code Error');
|
$message = (string)($lang[$code] ?? 'Code Error');
|
||||||
|
|
||||||
//替换变量
|
//替换变量
|
||||||
if (!empty($replace) && is_array($replace)) {
|
if (!empty($replace) && is_array($replace)) {
|
||||||
// 关联索引解析
|
// 关联索引解析
|
||||||
$key = array_keys($replace);
|
$key = array_keys($replace);
|
||||||
foreach ($key as &$v) {
|
foreach ($key as &$v) {
|
||||||
$v = "{:{$v}}";
|
$v = "{:{$v}}";
|
||||||
|
}
|
||||||
|
$message = str_replace($key, $replace, $message);
|
||||||
}
|
}
|
||||||
$message = str_replace($key, $replace, $message);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $message;
|
return $message;
|
||||||
|
} catch (\Throwable $e) {
|
||||||
|
Log::error('获取语言code:' . $code . '发成错误,错误原因是:' . json_encode([
|
||||||
|
'file' => $e->getFile(),
|
||||||
|
'message' => $e->getMessage(),
|
||||||
|
'line' => $e->getLine()
|
||||||
|
]));
|
||||||
|
return $code;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -43,7 +43,7 @@ class StoreIntegralOrderStatusDao extends BaseDao
|
|||||||
*/
|
*/
|
||||||
public function getStatusList(array $where, int $page, int $limit)
|
public function getStatusList(array $where, int $page, int $limit)
|
||||||
{
|
{
|
||||||
return $this->search($where)->page($page, $limit)->select()->toArray();
|
return $this->search($where)->page($page, $limit)->order('change_time desc')->select()->toArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -150,4 +150,25 @@ class StoreOrderRefundDao extends BaseDao
|
|||||||
})
|
})
|
||||||
->order('add_time ASC')->select()->toArray();
|
->order('add_time ASC')->select()->toArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $time
|
||||||
|
* @param $timeType
|
||||||
|
* @param $field
|
||||||
|
* @param $str
|
||||||
|
* @return mixed
|
||||||
|
* @author 吴汐
|
||||||
|
* @email 442384644@qq.com
|
||||||
|
* @date 2023/03/06
|
||||||
|
*/
|
||||||
|
public function getProductTrend($time, $timeType, $field, $str)
|
||||||
|
{
|
||||||
|
return $this->getModel()->where(function ($query) use ($time, $field) {
|
||||||
|
if ($time[0] == $time[1]) {
|
||||||
|
$query->whereDay($field, $time[0]);
|
||||||
|
} else {
|
||||||
|
$query->whereTime($field, 'between', $time);
|
||||||
|
}
|
||||||
|
})->field("FROM_UNIXTIME($field,'$timeType') as days,$str as num")->group('days')->select()->toArray();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -81,6 +81,12 @@ class StoreOrderStoreOrderStatusDao extends BaseDao
|
|||||||
* @param array $where
|
* @param array $where
|
||||||
* @param int $limit
|
* @param int $limit
|
||||||
* @return array
|
* @return array
|
||||||
|
* @throws \think\db\exception\DataNotFoundException
|
||||||
|
* @throws \think\db\exception\DbException
|
||||||
|
* @throws \think\db\exception\ModelNotFoundException
|
||||||
|
* @author 吴汐
|
||||||
|
* @email 442384644@qq.com
|
||||||
|
* @date 2023/03/01
|
||||||
*/
|
*/
|
||||||
public function getTakeOrderIds(array $where, int $limit = 0)
|
public function getTakeOrderIds(array $where, int $limit = 0)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -47,7 +47,7 @@ class SystemAdminDao extends BaseDao
|
|||||||
*/
|
*/
|
||||||
public function accountByAdmin(string $account)
|
public function accountByAdmin(string $account)
|
||||||
{
|
{
|
||||||
return $this->search(['account' => $account, 'is_del' => 0, 'status' => 1])->find();
|
return $this->search(['account' => $account, 'is_del' => 0])->find();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -14,7 +14,6 @@ namespace app\dao\system\config;
|
|||||||
|
|
||||||
use app\dao\BaseDao;
|
use app\dao\BaseDao;
|
||||||
use app\model\system\config\SystemStorage;
|
use app\model\system\config\SystemStorage;
|
||||||
use crmeb\traits\SearchDaoTrait;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class SystemStorageDao
|
* Class SystemStorageDao
|
||||||
@ -23,8 +22,6 @@ use crmeb\traits\SearchDaoTrait;
|
|||||||
class SystemStorageDao extends BaseDao
|
class SystemStorageDao extends BaseDao
|
||||||
{
|
{
|
||||||
|
|
||||||
use SearchDaoTrait;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
@ -33,6 +30,38 @@ class SystemStorageDao extends BaseDao
|
|||||||
return SystemStorage::class;
|
return SystemStorage::class;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取列表
|
||||||
|
* @param array $where
|
||||||
|
* @param array|string[] $field
|
||||||
|
* @param int $page
|
||||||
|
* @param int $limit
|
||||||
|
* @param null $sort
|
||||||
|
* @param array $with
|
||||||
|
* @return array
|
||||||
|
* @throws \think\db\exception\DataNotFoundException
|
||||||
|
* @throws \think\db\exception\DbException
|
||||||
|
* @throws \think\db\exception\ModelNotFoundException
|
||||||
|
*/
|
||||||
|
public function getList(array $where = [], array $field = ['*'], int $page = 0, int $limit = 0, $sort = null, array $with = [])
|
||||||
|
{
|
||||||
|
return $this->search($where)->field($field)->when($page && $limit, function ($query) use ($page, $limit) {
|
||||||
|
$query->page($page, $limit);
|
||||||
|
})->when($sort, function ($query) use ($sort) {
|
||||||
|
if (is_array($sort)) {
|
||||||
|
foreach ($sort as $v => $k) {
|
||||||
|
if (is_numeric($v)) {
|
||||||
|
$query->order($k, 'desc');
|
||||||
|
} else {
|
||||||
|
$query->order($v, $k);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$query->order($sort, 'desc');
|
||||||
|
}
|
||||||
|
})->with($with)->select()->toArray();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array $where
|
* @param array $where
|
||||||
* @return \crmeb\basic\BaseModel|mixed|\think\Model
|
* @return \crmeb\basic\BaseModel|mixed|\think\Model
|
||||||
|
|||||||
18
crmeb/app/dao/system/crontab/SystemCrontabDao.php
Normal file
18
crmeb/app/dao/system/crontab/SystemCrontabDao.php
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\dao\system\crontab;
|
||||||
|
|
||||||
|
use app\dao\BaseDao;
|
||||||
|
use app\model\system\crontab\SystemCrontab;
|
||||||
|
|
||||||
|
class SystemCrontabDao extends BaseDao
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 设置模型
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
protected function setModel(): string
|
||||||
|
{
|
||||||
|
return SystemCrontab::class;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,18 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace app\dao\system\timer;
|
|
||||||
|
|
||||||
use app\dao\BaseDao;
|
|
||||||
use app\model\system\timer\SystemTimer;
|
|
||||||
|
|
||||||
class SystemTimerDao extends BaseDao
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* 设置模型
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
protected function setModel(): string
|
|
||||||
{
|
|
||||||
return SystemTimer::class;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -240,6 +240,10 @@ class UserWechatUserDao extends BaseDao
|
|||||||
if (isset($where['time'])) {
|
if (isset($where['time'])) {
|
||||||
$model->withSearch(['time'], ['time' => $where['time'], 'timeKey' => 'u.add_time']);
|
$model->withSearch(['time'], ['time' => $where['time'], 'timeKey' => 'u.add_time']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isset($where['is_del'])) {
|
||||||
|
$model->where($userAlias . 'is_del', $where['is_del']);
|
||||||
|
}
|
||||||
return $field ? $model->field($field) : $model;
|
return $field ? $model->field($field) : $model;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -19,26 +19,26 @@ return [
|
|||||||
'listen' => [
|
'listen' => [
|
||||||
'AppInit' => [],
|
'AppInit' => [],
|
||||||
'HttpRun' => [],
|
'HttpRun' => [],
|
||||||
'HttpEnd' => [\app\listener\http\HttpEnd::class], //HTTP请求结束回调事件
|
'HttpEnd' => [\app\listener\http\HttpEndListener::class], //HTTP请求结束回调事件
|
||||||
'LogLevel' => [],
|
'LogLevel' => [],
|
||||||
'LogWrite' => [],
|
'LogWrite' => [],
|
||||||
'queue.start' => [\app\listener\queue\QueueStart::class],
|
'QueueStartListener' => [\app\listener\queue\QueueStartListener::class],
|
||||||
'user.login' => [\app\listener\user\Login::class],
|
'UserLoginListener' => [\app\listener\user\LoginListener::class],
|
||||||
'admin.login' => [\app\listener\admin\AdminLogin::class],//管理员登录
|
'AdminLoginListener' => [\app\listener\admin\AdminLoginListener::class],//管理员登录
|
||||||
'user.register' => [\app\listener\user\Register::class], //用户注册后置事件
|
'UserRegisterListener' => [\app\listener\user\RegisterListener::class], //用户注册后置事件
|
||||||
'wechat.auth' => [\app\listener\wechat\Auth::class], //用户授权后置事件
|
'WechatAuthListener' => [\app\listener\wechat\AuthListener::class], //用户授权后置事件
|
||||||
'order.orderCreateAfter' => [\app\listener\order\OrderCreateAfter::class], //订单创建后置事件
|
'OrderCreateAfterListener' => [\app\listener\order\OrderCreateAfterListener::class], //订单创建后置事件
|
||||||
'order.orderPaySuccess' => [\app\listener\order\OrderPaySuccess::class], //订单支付成功后置事件
|
'OrderPaySuccessListener' => [\app\listener\order\OrderPaySuccessListener::class], //订单支付成功后置事件
|
||||||
'order.orderDelivery' => [\app\listener\order\OrderDelivery::class], //订单发货后置事件
|
'OrderDeliveryListener' => [\app\listener\order\OrderDeliveryListener::class], //订单发货后置事件
|
||||||
'order.orderTake' => [\app\listener\order\OrderTake::class], //订单收货后置事件
|
'OrderTakeListener' => [\app\listener\order\OrderTakeListener::class], //订单收货后置事件
|
||||||
'order.orderRefundCreateAfter' => [\app\listener\order\OrderRefundCreateAfter::class], //售后单生成后置事件
|
'OrderRefundCreateAfterListener' => [\app\listener\order\OrderRefundCreateAfterListener::class], //售后单生成后置事件
|
||||||
'order.orderRefundCancelAfter' => [\app\listener\order\OrderRefundCancelAfter::class], //售后单取消后置事件
|
'OrderRefundCancelAfterListener' => [\app\listener\order\OrderRefundCancelAfterListener::class], //售后单取消后置事件
|
||||||
'out.outPush' => [\app\listener\out\OutPush::class], //对外推送事件
|
'OutPushListener' => [\app\listener\out\OutPushListener::class], //对外推送事件
|
||||||
'user.userLevel' => [\app\listener\user\UserLevel::class], //用户升级事件
|
'UserLevelListener' => [\app\listener\user\UserLevelListener::class], //用户升级事件
|
||||||
'user.userVisit' => [\app\listener\user\UserVisit::class], //用户访问事件
|
'UserVisitListener' => [\app\listener\user\UserVisitListener::class], //用户访问事件
|
||||||
'notice.notice' => [\app\listener\notice\Notice::class], //通知->消息事件
|
'NoticeListener' => [\app\listener\notice\NoticeListener::class], //通知->消息事件
|
||||||
'pay.notify' => [\app\listener\pay\Notify::class],//支付异步回调
|
'NotifyListener' => [\app\listener\pay\NotifyListener::class],//支付异步回调
|
||||||
'SystemTimer' => [\app\listener\timer\SystemTimer::class],//定时任务事件
|
'CrontabListener' => [\app\listener\crontab\SystemCrontabListener::class],//定时任务事件
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|||||||
@ -65,13 +65,6 @@ class UnpaidOrderCancelJob extends BaseJobs
|
|||||||
$orderInfo->is_del = 1;
|
$orderInfo->is_del = 1;
|
||||||
$orderInfo->mark = '订单未支付已超过系统预设时间';
|
$orderInfo->mark = '订单未支付已超过系统预设时间';
|
||||||
$orderInfo->save();
|
$orderInfo->save();
|
||||||
try {
|
|
||||||
/** @var StoreSeckillServices $seckiiServices */
|
|
||||||
$seckiiServices = app()->make(StoreSeckillServices::class);
|
|
||||||
$seckiiServices->cancelOccupySeckillStock($cartInfo, $orderInfo['unique']);
|
|
||||||
$seckiiServices->rollBackStock($cartInfo);
|
|
||||||
} catch (\Throwable $e) {
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return $res;
|
return $res;
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
|
|||||||
@ -40,7 +40,7 @@ class UnpaidOrderSend extends BaseJobs
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
//收货给用户发送消息
|
//收货给用户发送消息
|
||||||
event('notice.notice', [['order' => $orderInfo], 'order_pay_false']);
|
event('NoticeListener', [['order' => $orderInfo], 'order_pay_false']);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -17,7 +17,7 @@ namespace app\listener\admin;
|
|||||||
* Class AdminLogin
|
* Class AdminLogin
|
||||||
* @package app\listener\admin
|
* @package app\listener\admin
|
||||||
*/
|
*/
|
||||||
class AdminLogin
|
class AdminLoginListener
|
||||||
{
|
{
|
||||||
|
|
||||||
public function handle($event)
|
public function handle($event)
|
||||||
@ -35,13 +35,11 @@ class AdminLogin
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
$timerPath = root_path('runtime') . '.timer';
|
$timerPath = root_path('runtime') . '.timer';
|
||||||
$timer = file_get_contents($timerPath);
|
$timer = file_get_contents($timerPath);
|
||||||
if ($timer && $timer <= time() && $timer > (time() - 10)) {
|
if ($timer && $timer <= time() && $timer > (time() - 70)) {
|
||||||
$res1 = true;
|
$res1 = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
}
|
}
|
||||||
|
|
||||||
79
crmeb/app/listener/crontab/SystemCrontabListener.php
Normal file
79
crmeb/app/listener/crontab/SystemCrontabListener.php
Normal file
@ -0,0 +1,79 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\listener\crontab;
|
||||||
|
|
||||||
|
use app\services\system\crontab\CrontabRunServices;
|
||||||
|
use app\services\system\crontab\SystemCrontabServices;
|
||||||
|
use crmeb\interfaces\ListenerInterface;
|
||||||
|
use think\helper\Str;
|
||||||
|
use Workerman\Crontab\Crontab;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 系统定时任务
|
||||||
|
*/
|
||||||
|
class SystemCrontabListener implements ListenerInterface
|
||||||
|
{
|
||||||
|
public function handle($event): void
|
||||||
|
{
|
||||||
|
$systemCrontabServices = app()->make(SystemCrontabServices::class);
|
||||||
|
$crontabRunServices = app()->make(CrontabRunServices::class);
|
||||||
|
|
||||||
|
//自动写入文件方便检测是否启动定时任务命令
|
||||||
|
new Crontab('*/6 * * * * *', function () {
|
||||||
|
file_put_contents(root_path() . 'runtime/.timer', time());
|
||||||
|
});
|
||||||
|
|
||||||
|
$list = $systemCrontabServices->selectList(['is_del' => 0, 'is_open' => 1])->toArray();
|
||||||
|
foreach ($list as &$item) {
|
||||||
|
//转化小驼峰
|
||||||
|
$functionName = Str::camel($item['mark']);
|
||||||
|
//获取定时任务时间字符串
|
||||||
|
$timeStr = $this->getTimerStr($item);
|
||||||
|
new Crontab($timeStr, function () use ($crontabRunServices, $functionName) {
|
||||||
|
$crontabRunServices->$functionName();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取定时任务时间表达式
|
||||||
|
* 0 1 2 3 4 5
|
||||||
|
* | | | | | |
|
||||||
|
* | | | | | +------ day of week (0 - 6) (Sunday=0)
|
||||||
|
* | | | | +------ month (1 - 12)
|
||||||
|
* | | | +-------- day of month (1 - 31)
|
||||||
|
* | | +---------- hour (0 - 23)
|
||||||
|
* | +------------ min (0 - 59)
|
||||||
|
* +-------------- sec (0-59)[可省略,如果没有0位,则最小时间粒度是分钟]
|
||||||
|
* @param $data
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getTimerStr($data): string
|
||||||
|
{
|
||||||
|
$timeStr = '';
|
||||||
|
switch ($data['type']) {
|
||||||
|
case 1:// 每隔几秒
|
||||||
|
$timeStr = '*/' . $data['second'] . ' * * * * *';
|
||||||
|
break;
|
||||||
|
case 2:// 每隔几分
|
||||||
|
$timeStr = '0 */' . $data['minute'] . ' * * * *';
|
||||||
|
break;
|
||||||
|
case 3:// 每隔几时第几分钟执行
|
||||||
|
$timeStr = '0 ' . $data['minute'] . ' */' . $data['hour'] . ' * * *';
|
||||||
|
break;
|
||||||
|
case 4:// 每隔几日第几小时第几分钟执行
|
||||||
|
$timeStr = '0 ' . $data['minute'] . ' ' . $data['hour'] . ' */' . $data['day'] . ' * *';
|
||||||
|
break;
|
||||||
|
case 5:// 每日几时几分几秒
|
||||||
|
$timeStr = $data['second'] . ' ' . $data['minute'] . ' ' . $data['hour'] . ' * * *';
|
||||||
|
break;
|
||||||
|
case 6:// 每周周几几时几分几秒
|
||||||
|
$timeStr = $data['second'] . ' ' . $data['minute'] . ' ' . $data['hour'] . ' * * ' . ($data['week'] == 7 ? 0 : $data['week']);
|
||||||
|
break;
|
||||||
|
case 7:// 每月几日几时几分几秒
|
||||||
|
$timeStr = $data['second'] . ' ' . $data['minute'] . ' ' . $data['hour'] . ' ' . $data['day'] . ' * *';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return $timeStr;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -19,7 +19,7 @@ use think\Response;
|
|||||||
* Class Create
|
* Class Create
|
||||||
* @package app\listener\http
|
* @package app\listener\http
|
||||||
*/
|
*/
|
||||||
class HttpEnd
|
class HttpEndListener
|
||||||
{
|
{
|
||||||
public function handle(Response $response):void
|
public function handle(Response $response):void
|
||||||
{
|
{
|
||||||
@ -31,7 +31,7 @@ use crmeb\utils\Str;
|
|||||||
* Class Create
|
* Class Create
|
||||||
* @package app\listener\order
|
* @package app\listener\order
|
||||||
*/
|
*/
|
||||||
class Notice implements ListenerInterface
|
class NoticeListener implements ListenerInterface
|
||||||
{
|
{
|
||||||
public function handle($event): void
|
public function handle($event): void
|
||||||
{
|
{
|
||||||
@ -18,10 +18,10 @@ use crmeb\utils\Arr;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 订单创建后置事件
|
* 订单创建后置事件
|
||||||
* Class OrderCreateAfter
|
* Class OrderCreateAfterListener
|
||||||
* @package app\listener\order
|
* @package app\listener\order
|
||||||
*/
|
*/
|
||||||
class OrderCreateAfter implements ListenerInterface
|
class OrderCreateAfterListener implements ListenerInterface
|
||||||
{
|
{
|
||||||
public function handle($event): void
|
public function handle($event): void
|
||||||
{
|
{
|
||||||
@ -9,10 +9,10 @@ use crmeb\interfaces\ListenerInterface;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 订单到期自动收货
|
* 订单到期自动收货
|
||||||
* Class OrderDelivery
|
* Class OrderDeliveryListener
|
||||||
* @package app\listener\order
|
* @package app\listener\order
|
||||||
*/
|
*/
|
||||||
class OrderDelivery implements ListenerInterface
|
class OrderDeliveryListener implements ListenerInterface
|
||||||
{
|
{
|
||||||
public function handle($event): void
|
public function handle($event): void
|
||||||
{
|
{
|
||||||
@ -14,6 +14,7 @@ use app\services\order\StoreOrderDeliveryServices;
|
|||||||
use app\services\order\StoreOrderInvoiceServices;
|
use app\services\order\StoreOrderInvoiceServices;
|
||||||
use app\services\order\StoreOrderServices;
|
use app\services\order\StoreOrderServices;
|
||||||
use app\services\order\StoreOrderStatusServices;
|
use app\services\order\StoreOrderStatusServices;
|
||||||
|
use app\services\pay\PayServices;
|
||||||
use app\services\product\product\StoreProductCouponServices;
|
use app\services\product\product\StoreProductCouponServices;
|
||||||
use app\services\product\sku\StoreProductAttrValueServices;
|
use app\services\product\sku\StoreProductAttrValueServices;
|
||||||
use app\services\product\sku\StoreProductVirtualServices;
|
use app\services\product\sku\StoreProductVirtualServices;
|
||||||
@ -26,10 +27,10 @@ use think\facade\Log;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 订单支付成功后
|
* 订单支付成功后
|
||||||
* Class OrderPaySuccess
|
* Class OrderPaySuccessListener
|
||||||
* @package app\listener\order
|
* @package app\listener\order
|
||||||
*/
|
*/
|
||||||
class OrderPaySuccess implements ListenerInterface
|
class OrderPaySuccessListener implements ListenerInterface
|
||||||
{
|
{
|
||||||
public function handle($event): void
|
public function handle($event): void
|
||||||
{
|
{
|
||||||
@ -45,14 +46,6 @@ class OrderPaySuccess implements ListenerInterface
|
|||||||
'change_time' => time()
|
'change_time' => time()
|
||||||
]);
|
]);
|
||||||
|
|
||||||
//回退秒杀库存占用
|
|
||||||
/** @var StoreOrderCartInfoServices $cartServices */
|
|
||||||
$cartServices = app()->make(StoreOrderCartInfoServices::class);
|
|
||||||
$cartInfo = $cartServices->getOrderCartInfo($orderInfo['id']);
|
|
||||||
/** @var StoreSeckillServices $seckiiServices */
|
|
||||||
$seckiiServices = app()->make(StoreSeckillServices::class);
|
|
||||||
$seckiiServices->cancelOccupySeckillStock($cartInfo, $orderInfo['unique']);
|
|
||||||
|
|
||||||
//赠送购买商品优惠券
|
//赠送购买商品优惠券
|
||||||
/** @var StoreProductCouponServices $storeProductCouponServices */
|
/** @var StoreProductCouponServices $storeProductCouponServices */
|
||||||
$storeProductCouponServices = app()->make(StoreProductCouponServices::class);
|
$storeProductCouponServices = app()->make(StoreProductCouponServices::class);
|
||||||
@ -63,14 +56,14 @@ class OrderPaySuccess implements ListenerInterface
|
|||||||
$orderInvoiceServices->update(['order_id' => $orderInfo['id']], ['is_pay' => 1]);
|
$orderInvoiceServices->update(['order_id' => $orderInfo['id']], ['is_pay' => 1]);
|
||||||
|
|
||||||
//虚拟商品自动发货
|
//虚拟商品自动发货
|
||||||
if($orderInfo['virtual_type'] > 0){
|
if ($orderInfo['virtual_type'] > 0) {
|
||||||
/** @var StoreOrderDeliveryServices $orderDeliveryServices */
|
/** @var StoreOrderDeliveryServices $orderDeliveryServices */
|
||||||
$orderDeliveryServices = app()->make(StoreOrderDeliveryServices::class);
|
$orderDeliveryServices = app()->make(StoreOrderDeliveryServices::class);
|
||||||
$orderDeliveryServices->virtualSend($orderInfo);
|
$orderDeliveryServices->virtualSend($orderInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 写入资金流水
|
// 写入资金流水
|
||||||
if ($orderInfo['pay_type'] == 'weixin' || $orderInfo['pay_type'] == 'alipay') {
|
if ($orderInfo['pay_type'] == 'weixin' || $orderInfo['pay_type'] == 'alipay' || $orderInfo['pay_type'] == PayServices::ALLIN_PAY) {
|
||||||
/** @var UserServices $userServices */
|
/** @var UserServices $userServices */
|
||||||
$userServices = app()->make(UserServices::class);
|
$userServices = app()->make(UserServices::class);
|
||||||
$userInfo = $userServices->get($orderInfo['uid']);
|
$userInfo = $userServices->get($orderInfo['uid']);
|
||||||
@ -7,10 +7,10 @@ use crmeb\interfaces\ListenerInterface;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 售后单取消
|
* 售后单取消
|
||||||
* Class OrderRefundCancelAfter
|
* Class OrderRefundCancelAfterListener
|
||||||
* @package app\listener\order
|
* @package app\listener\order
|
||||||
*/
|
*/
|
||||||
class OrderRefundCancelAfter implements ListenerInterface
|
class OrderRefundCancelAfterListener implements ListenerInterface
|
||||||
{
|
{
|
||||||
public function handle($event): void
|
public function handle($event): void
|
||||||
{
|
{
|
||||||
@ -11,7 +11,7 @@ use crmeb\interfaces\ListenerInterface;
|
|||||||
* Class orderRefundCreateAfter
|
* Class orderRefundCreateAfter
|
||||||
* @package app\listener\order
|
* @package app\listener\order
|
||||||
*/
|
*/
|
||||||
class OrderRefundCreateAfter implements ListenerInterface
|
class OrderRefundCreateAfterListener implements ListenerInterface
|
||||||
{
|
{
|
||||||
public function handle($event): void
|
public function handle($event): void
|
||||||
{
|
{
|
||||||
@ -11,10 +11,10 @@ use think\facade\Log;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 订单确认收货
|
* 订单确认收货
|
||||||
* Class OrderTake
|
* Class OrderTakeListener
|
||||||
* @package app\listener\order
|
* @package app\listener\order
|
||||||
*/
|
*/
|
||||||
class OrderTake implements ListenerInterface
|
class OrderTakeListener implements ListenerInterface
|
||||||
{
|
{
|
||||||
public function handle($event): void
|
public function handle($event): void
|
||||||
{
|
{
|
||||||
@ -9,7 +9,7 @@ use crmeb\services\CacheService;
|
|||||||
use crmeb\services\HttpService;
|
use crmeb\services\HttpService;
|
||||||
use think\facade\Log;
|
use think\facade\Log;
|
||||||
|
|
||||||
class OutPush implements ListenerInterface
|
class OutPushListener implements ListenerInterface
|
||||||
{
|
{
|
||||||
public function handle($event): void
|
public function handle($event): void
|
||||||
{
|
{
|
||||||
@ -18,10 +18,10 @@ use crmeb\utils\Hook;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 支付异步回调
|
* 支付异步回调
|
||||||
* Class Notify
|
* Class NotifyListener
|
||||||
* @package app\listener\pay
|
* @package app\listener\pay
|
||||||
*/
|
*/
|
||||||
class Notify
|
class NotifyListener
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @param $event
|
* @param $event
|
||||||
@ -30,17 +30,16 @@ class Notify
|
|||||||
*/
|
*/
|
||||||
public function handle($event)
|
public function handle($event)
|
||||||
{
|
{
|
||||||
[$notify] = $event;
|
[$notify, $payType] = $event;
|
||||||
|
|
||||||
if (isset($notify['attach']) && $notify['attach']) {
|
if (isset($notify['attach']) && $notify['attach']) {
|
||||||
if (($count = strpos($notify['out_trade_no'], '_')) !== false) {
|
if (($count = strpos($notify['out_trade_no'], '_')) !== false) {
|
||||||
$notify['out_trade_no'] = substr($notify['out_trade_no'], $count + 1);
|
$notify['out_trade_no'] = substr($notify['out_trade_no'], $count + 1);
|
||||||
}
|
}
|
||||||
return (new Hook(PayNotifyServices::class, 'wechat'))->listen($notify['attach'], $notify['out_trade_no'], $notify['transaction_id']);
|
return (new Hook(PayNotifyServices::class, 'wechat'))->listen($notify['attach'], $notify['out_trade_no'], $notify['transaction_id'], $payType);
|
||||||
}
|
}
|
||||||
|
|
||||||
if($notify['attach'] === 'wechat' && isset($notify['out_trade_no']))
|
if ($notify['attach'] === 'wechat' && isset($notify['out_trade_no'])) {
|
||||||
{
|
|
||||||
/** @var WechatMessageServices $wechatMessageService */
|
/** @var WechatMessageServices $wechatMessageService */
|
||||||
$wechatMessageService = app()->make(WechatMessageServices::class);
|
$wechatMessageService = app()->make(WechatMessageServices::class);
|
||||||
$wechatMessageService->setOnceMessage($notify, $notify['openid'], 'payment_success', $notify['out_trade_no']);
|
$wechatMessageService->setOnceMessage($notify, $notify['openid'], 'payment_success', $notify['out_trade_no']);
|
||||||
@ -16,7 +16,7 @@ namespace app\listener\queue;
|
|||||||
|
|
||||||
use think\console\Output;
|
use think\console\Output;
|
||||||
|
|
||||||
class QueueStart
|
class QueueStartListener
|
||||||
{
|
{
|
||||||
|
|
||||||
public function handle(Output $output)
|
public function handle(Output $output)
|
||||||
@ -1,192 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace app\listener\timer;
|
|
||||||
|
|
||||||
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;
|
|
||||||
use app\services\system\timer\SystemTimerServices;
|
|
||||||
use crmeb\interfaces\ListenerInterface;
|
|
||||||
use think\facade\Log;
|
|
||||||
use Workerman\Crontab\Crontab;
|
|
||||||
|
|
||||||
class SystemTimer implements ListenerInterface
|
|
||||||
{
|
|
||||||
public function handle($event): void
|
|
||||||
{
|
|
||||||
|
|
||||||
new Crontab('*/6 * * * * *', function () {
|
|
||||||
file_put_contents(runtime_path() . '.timer', time());
|
|
||||||
});
|
|
||||||
|
|
||||||
/** @var SystemTimerServices $systemTimerServices */
|
|
||||||
$systemTimerServices = app()->make(SystemTimerServices::class);
|
|
||||||
$list = $systemTimerServices->selectList(['is_del' => 0, 'is_open' => 1])->toArray();
|
|
||||||
foreach ($list as &$item) {
|
|
||||||
//获取定时任务时间字符串
|
|
||||||
$timeStr = $this->getTimerStr($item);
|
|
||||||
// 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'));
|
|
||||||
//未支付自动取消订单
|
|
||||||
try {
|
|
||||||
/** @var StoreOrderServices $orderServices */
|
|
||||||
$orderServices = app()->make(StoreOrderServices::class);
|
|
||||||
$orderServices->orderUnpaidCancel();
|
|
||||||
} catch (\Throwable $e) {
|
|
||||||
Log::error('自动取消订单失败,失败原因:' . $e->getMessage());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($item['mark'] == 'pink_expiration') {
|
|
||||||
new Crontab($timeStr, function () {
|
|
||||||
// Log::error('每隔1分钟执行一次拼团到期订单处理 '.date('Y-m-d H:i:s'));
|
|
||||||
//拼团到期订单处理
|
|
||||||
try {
|
|
||||||
/** @var StorePinkServices $storePinkServices */
|
|
||||||
$storePinkServices = app()->make(StorePinkServices::class);
|
|
||||||
$storePinkServices->statusPink();
|
|
||||||
} catch (\Throwable $e) {
|
|
||||||
Log::error('拼团到期订单处理失败,失败原因:' . $e->getMessage());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($item['mark'] == 'agent_unbind') {
|
|
||||||
new Crontab($timeStr, function () {
|
|
||||||
// Log::error('每隔1分钟执行一次自动解除上级绑定 '.date('Y-m-d H:i:s'));
|
|
||||||
//自动解绑上级绑定
|
|
||||||
try {
|
|
||||||
/** @var AgentManageServices $agentManage */
|
|
||||||
$agentManage = app()->make(AgentManageServices::class);
|
|
||||||
$agentManage->removeSpread();
|
|
||||||
} catch (\Throwable $e) {
|
|
||||||
Log::error('自动解除上级绑定失败,失败原因:' . $e->getMessage());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($item['mark'] == 'live_product_status') {
|
|
||||||
new Crontab($timeStr, function () {
|
|
||||||
// Log::error('每隔3分钟执行一次更新直播商品状态 '.date('Y-m-d H:i:s'));
|
|
||||||
//更新直播商品状态
|
|
||||||
try {
|
|
||||||
/** @var LiveGoodsServices $liveGoods */
|
|
||||||
$liveGoods = app()->make(LiveGoodsServices::class);
|
|
||||||
$liveGoods->syncGoodStatus();
|
|
||||||
} catch (\Throwable $e) {
|
|
||||||
Log::error('更新直播商品状态失败,失败原因:' . $e->getMessage());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($item['mark'] == 'live_room_status') {
|
|
||||||
new Crontab($timeStr, function () {
|
|
||||||
// Log::error('每隔3分钟执行一次更新直播间状态 '.date('Y-m-d H:i:s'));
|
|
||||||
//更新直播间状态
|
|
||||||
try {
|
|
||||||
/** @var LiveRoomServices $liveRoom */
|
|
||||||
$liveRoom = app()->make(LiveRoomServices::class);
|
|
||||||
$liveRoom->syncRoomStatus();
|
|
||||||
} catch (\Throwable $e) {
|
|
||||||
Log::error('更新直播间状态失败,失败原因:' . $e->getMessage());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($item['mark'] == 'take_delivery') {
|
|
||||||
new Crontab($timeStr, function () {
|
|
||||||
// Log::error('每隔5分钟执行一次自动收货 '.date('Y-m-d H:i:s'));
|
|
||||||
//自动收货
|
|
||||||
try {
|
|
||||||
/** @var StoreOrderTakeServices $services */
|
|
||||||
$services = app()->make(StoreOrderTakeServices::class);
|
|
||||||
$services->autoTakeOrder();
|
|
||||||
} catch (\Throwable $e) {
|
|
||||||
Log::error('自动收货失败,失败原因:' . $e->getMessage());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($item['mark'] == 'advance_off') {
|
|
||||||
new Crontab($timeStr, function () {
|
|
||||||
// Log::error('每隔5分钟执行一次查询预售到期商品自动下架 '.date('Y-m-d H:i:s'));
|
|
||||||
//查询预售到期商品自动下架
|
|
||||||
try {
|
|
||||||
/** @var StoreProductServices $product */
|
|
||||||
$product = app()->make(StoreProductServices::class);
|
|
||||||
$product->downAdvance();
|
|
||||||
} catch (\Throwable $e) {
|
|
||||||
Log::error('预售到期商品自动下架失败,失败原因:' . $e->getMessage());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($item['mark'] == 'product_replay') {
|
|
||||||
new Crontab($timeStr, function () {
|
|
||||||
// Log::error('每隔5分钟执行一次自动好评 '.date('Y-m-d H:i:s'));
|
|
||||||
//自动好评
|
|
||||||
try {
|
|
||||||
/** @var StoreOrderServices $orderServices */
|
|
||||||
$orderServices = app()->make(StoreOrderServices::class);
|
|
||||||
$orderServices->autoComment();
|
|
||||||
} catch (\Throwable $e) {
|
|
||||||
Log::error('自动好评失败,失败原因:' . $e->getMessage());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($item['mark'] == 'clear_poster') {
|
|
||||||
new Crontab($timeStr, function () {
|
|
||||||
// Log::error('每天0时30分0秒执行一次清除昨日海报 '.date('Y-m-d H:i:s'));
|
|
||||||
//清除昨日海报
|
|
||||||
try {
|
|
||||||
/** @var SystemAttachmentServices $attach */
|
|
||||||
$attach = app()->make(SystemAttachmentServices::class);
|
|
||||||
$attach->emptyYesterdayAttachment();
|
|
||||||
} catch (\Throwable $e) {
|
|
||||||
Log::error('清除昨日海报失败,失败原因:' . $e->getMessage());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getTimerStr($data): string
|
|
||||||
{
|
|
||||||
$timeStr = '';
|
|
||||||
switch ($data['type']) {
|
|
||||||
case 1:
|
|
||||||
$timeStr = '*/' . $data['second'] . ' * * * * *';
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
$timeStr = '0 */' . $data['minute'] . ' * * * *';
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
$timeStr = '0 0 */' . $data['hour'] . ' * * *';
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
$timeStr = '0 0 0 */' . $data['day'] . ' * *';
|
|
||||||
break;
|
|
||||||
case 5:
|
|
||||||
$timeStr = $data['second'] . ' ' . $data['minute'] . ' ' . $data['hour'] . ' * * *';
|
|
||||||
break;
|
|
||||||
case 6:
|
|
||||||
$timeStr = $data['second'] . ' ' . $data['minute'] . ' ' . $data['hour'] . ' * * ' . ($data['week'] == 7 ? 0 : $data['week']);
|
|
||||||
break;
|
|
||||||
case 7:
|
|
||||||
$timeStr = $data['second'] . ' ' . $data['minute'] . ' ' . $data['hour'] . ' ' . $data['day'] . ' * *';
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return $timeStr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -8,10 +8,10 @@ use crmeb\interfaces\ListenerInterface;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户登录后置事件
|
* 用户登录后置事件
|
||||||
* Class Login
|
* Class LoginListener
|
||||||
* @package app\listener\user
|
* @package app\listener\user
|
||||||
*/
|
*/
|
||||||
class Login implements ListenerInterface
|
class LoginListener implements ListenerInterface
|
||||||
{
|
{
|
||||||
public function handle($event): void
|
public function handle($event): void
|
||||||
{
|
{
|
||||||
@ -13,10 +13,10 @@ use crmeb\interfaces\ListenerInterface;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 注册完成后置事件
|
* 注册完成后置事件
|
||||||
* Class Register
|
* Class RegisterListener
|
||||||
* @package app\listener\user
|
* @package app\listener\user
|
||||||
*/
|
*/
|
||||||
class Register implements ListenerInterface
|
class RegisterListener implements ListenerInterface
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* 注册完成后置事件
|
* 注册完成后置事件
|
||||||
@ -9,10 +9,10 @@ use crmeb\interfaces\ListenerInterface;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户升级事件
|
* 用户升级事件
|
||||||
* Class UserLevel
|
* Class UserLevelListener
|
||||||
* @package app\listener\user
|
* @package app\listener\user
|
||||||
*/
|
*/
|
||||||
class UserLevel implements ListenerInterface
|
class UserLevelListener implements ListenerInterface
|
||||||
{
|
{
|
||||||
public function handle($event): void
|
public function handle($event): void
|
||||||
{
|
{
|
||||||
@ -9,10 +9,10 @@ use crmeb\interfaces\ListenerInterface;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 写入用户访问
|
* 写入用户访问
|
||||||
* Class UserVisit
|
* Class UserVisitListener
|
||||||
* @package app\listener\user
|
* @package app\listener\user
|
||||||
*/
|
*/
|
||||||
class UserVisit implements ListenerInterface
|
class UserVisitListener implements ListenerInterface
|
||||||
{
|
{
|
||||||
public function handle($event): void
|
public function handle($event): void
|
||||||
{
|
{
|
||||||
@ -8,10 +8,10 @@ use crmeb\interfaces\ListenerInterface;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户授权后置事件
|
* 用户授权后置事件
|
||||||
* Class Auth
|
* Class AuthListener
|
||||||
* @package app\listener\wechat
|
* @package app\listener\wechat
|
||||||
*/
|
*/
|
||||||
class Auth implements ListenerInterface
|
class AuthListener implements ListenerInterface
|
||||||
{
|
{
|
||||||
public function handle($event): void
|
public function handle($event): void
|
||||||
{
|
{
|
||||||
@ -589,4 +589,14 @@ class StoreOrder extends BaseModel
|
|||||||
{
|
{
|
||||||
if ($value !== '') $query->where('agent_id', $value);
|
if ($value !== '') $query->where('agent_id', $value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $query
|
||||||
|
* @param $value
|
||||||
|
*/
|
||||||
|
public function searchIdsAttr($query, $value)
|
||||||
|
{
|
||||||
|
if (is_string($value)) $value = explode(',', $value);
|
||||||
|
if (count($value)) $query->whereIn('id', $value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -338,6 +338,17 @@ class StoreProduct extends BaseModel
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 在当前id中查询
|
||||||
|
* @param $query
|
||||||
|
* @param $value
|
||||||
|
*/
|
||||||
|
public function searchIdsAttr($query, $value)
|
||||||
|
{
|
||||||
|
if (is_string($value)) $value = explode(',', $value);
|
||||||
|
if (count($value)) $query->whereIn('id', $value);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 不在当前id中查询
|
* 不在当前id中查询
|
||||||
* @param $query
|
* @param $query
|
||||||
|
|||||||
@ -1,11 +1,11 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace app\model\system\timer;
|
namespace app\model\system\crontab;
|
||||||
|
|
||||||
use crmeb\basic\BaseModel;
|
use crmeb\basic\BaseModel;
|
||||||
use crmeb\traits\ModelTrait;
|
use crmeb\traits\ModelTrait;
|
||||||
|
|
||||||
class SystemTimer extends BaseModel
|
class SystemCrontab extends BaseModel
|
||||||
{
|
{
|
||||||
use ModelTrait;
|
use ModelTrait;
|
||||||
|
|
||||||
@ -127,4 +127,18 @@ class WechatUser extends BaseModel
|
|||||||
return $query->where('user_type', $value);
|
return $query->where('user_type', $value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* is_del 搜索器
|
||||||
|
* @param $query
|
||||||
|
* @param $value
|
||||||
|
* @return void
|
||||||
|
* @author 吴汐
|
||||||
|
* @email 442384644@qq.com
|
||||||
|
* @date 2023/03/03
|
||||||
|
*/
|
||||||
|
public function searchIsDelAttr($query, $value)
|
||||||
|
{
|
||||||
|
if($value !== '') return $query->where('is_del', $value);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -11,27 +11,53 @@
|
|||||||
|
|
||||||
namespace app\services;
|
namespace app\services;
|
||||||
|
|
||||||
use crmeb\traits\ServicesTrait;
|
|
||||||
use crmeb\utils\JwtAuth;
|
use crmeb\utils\JwtAuth;
|
||||||
use think\facade\Db;
|
use think\facade\Db;
|
||||||
use think\facade\Config;
|
use think\facade\Config;
|
||||||
use think\facade\Route as Url;
|
use think\facade\Route as Url;
|
||||||
|
use think\Model;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class BaseServices
|
* Class BaseServices
|
||||||
* @package app\services
|
* @package app\services
|
||||||
|
* @method array|Model|null get($id, ?array $field = []) 获取一条数据
|
||||||
|
* @method array|Model|null getOne(array $where, ?string $field = '*') 获取一条数据(不走搜素器)
|
||||||
|
* @method string|null batchUpdate(array $ids, array $data, ?string $key = null) 批量修改
|
||||||
|
* @method float sum(array $where, string $field, bool $search = false) 求和
|
||||||
|
* @method mixed update($id, array $data, ?string $field = '') 修改数据
|
||||||
|
* @method bool be($map, string $field = '') 查询一条数据是否存在
|
||||||
|
* @method mixed value(array $where, string $field) 获取指定条件下的数据
|
||||||
|
* @method int count(array $where = []) 读取数据条数
|
||||||
|
* @method int getCount(array $where = []) 获取某些条件总数(不走搜素器)
|
||||||
|
* @method array getColumn(array $where, string $field, string $key = '') 获取某个字段数组(不走搜素器)
|
||||||
|
* @method mixed delete($id, ?string $key = null) 删除
|
||||||
|
* @method mixed save(array $data) 保存数据
|
||||||
|
* @method mixed saveAll(array $data) 批量保存数据
|
||||||
|
* @method bool bcInc($key, string $incField, string $inc, string $keyField = null, int $acc = 2) 高精度加法
|
||||||
|
* @method bool bcDec($key, string $decField, string $dec, string $keyField = null, int $acc = 2) 高精度 减法
|
||||||
|
* @method mixed decStockIncSales(array $where, int $num, string $stock = 'stock', string $sales = 'sales') 减库存加销量
|
||||||
|
* @method mixed incStockDecSales(array $where, int $num, string $stock = 'stock', string $sales = 'sales') 加库存减销量
|
||||||
*/
|
*/
|
||||||
abstract class BaseServices
|
abstract class BaseServices
|
||||||
{
|
{
|
||||||
|
|
||||||
use ServicesTrait;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 模型注入
|
* 模型注入
|
||||||
* @var object
|
* @var object
|
||||||
*/
|
*/
|
||||||
protected $dao;
|
protected $dao;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return \crmeb\utils\Cache
|
||||||
|
* @author 等风来
|
||||||
|
* @email 136327134@qq.com
|
||||||
|
* @date 2023/2/8
|
||||||
|
*/
|
||||||
|
public function cacheDriver()
|
||||||
|
{
|
||||||
|
return new \crmeb\utils\Cache($this->dao->getTableName());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取分页配置
|
* 获取分页配置
|
||||||
* @param bool $isPage
|
* @param bool $isPage
|
||||||
|
|||||||
@ -115,13 +115,6 @@ class StoreAdvanceServices extends BaseServices
|
|||||||
$valueGroup = $storeProductAttrServices->saveProductAttr($skuList, (int)$res->id, 6);
|
$valueGroup = $storeProductAttrServices->saveProductAttr($skuList, (int)$res->id, 6);
|
||||||
if (!$res) throw new AdminException(100022);
|
if (!$res) throw new AdminException(100022);
|
||||||
}
|
}
|
||||||
$res = true;
|
|
||||||
foreach ($valueGroup->toArray() as $item) {
|
|
||||||
$res = $res && CacheService::setStock($item['unique'], (int)$item['quota_show'], 6);
|
|
||||||
}
|
|
||||||
if (!$res) {
|
|
||||||
throw new AdminException(400092);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -319,7 +312,7 @@ class StoreAdvanceServices extends BaseServices
|
|||||||
$data['productValue'] = $productValue;
|
$data['productValue'] = $productValue;
|
||||||
$data['routine_contact_type'] = sys_config('routine_contact_type', 0);
|
$data['routine_contact_type'] = sys_config('routine_contact_type', 0);
|
||||||
//用户访问事件
|
//用户访问事件
|
||||||
event('user.userVisit', [$uid, $id, 'advance', $storeInfo['product_id'], 'view']);
|
event('UserVisitListener', [$uid, $id, 'advance', $storeInfo['product_id'], 'view']);
|
||||||
//浏览记录
|
//浏览记录
|
||||||
ProductLogJob::dispatch(['visit', ['uid' => $uid, 'product_id' => $storeInfo['product_id']]]);
|
ProductLogJob::dispatch(['visit', ['uid' => $uid, 'product_id' => $storeInfo['product_id']]]);
|
||||||
return $data;
|
return $data;
|
||||||
|
|||||||
@ -171,13 +171,6 @@ class StoreBargainServices extends BaseServices
|
|||||||
$valueGroup = $storeProductAttrServices->saveProductAttr($skuList, (int)$res->id, 2);
|
$valueGroup = $storeProductAttrServices->saveProductAttr($skuList, (int)$res->id, 2);
|
||||||
if (!$res) throw new AdminException(100022);
|
if (!$res) throw new AdminException(100022);
|
||||||
}
|
}
|
||||||
$res = true;
|
|
||||||
foreach ($valueGroup->toArray() as $item) {
|
|
||||||
$res = $res && CacheService::setStock($item['unique'], (int)$item['quota_show'], 2);
|
|
||||||
}
|
|
||||||
if (!$res) {
|
|
||||||
throw new AdminException(400092);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -505,7 +498,7 @@ class StoreBargainServices extends BaseServices
|
|||||||
$data['bargain']['price'] = bcsub($data['bargain']['price'], (string)$userBargainInfo['alreadyPrice'], 2);
|
$data['bargain']['price'] = bcsub($data['bargain']['price'], (string)$userBargainInfo['alreadyPrice'], 2);
|
||||||
|
|
||||||
//用户访问事件
|
//用户访问事件
|
||||||
event('user.userVisit', [$user['uid'], $id, 'bargain', $bargain['product_id'], 'view']);
|
event('UserVisitListener', [$user['uid'], $id, 'bargain', $bargain['product_id'], 'view']);
|
||||||
|
|
||||||
//浏览记录
|
//浏览记录
|
||||||
ProductLogJob::dispatch(['visit', ['uid' => $user['uid'], 'product_id' => $bargain['product_id']]]);
|
ProductLogJob::dispatch(['visit', ['uid' => $user['uid'], 'product_id' => $bargain['product_id']]]);
|
||||||
@ -646,7 +639,7 @@ class StoreBargainServices extends BaseServices
|
|||||||
$price = $userHelpService->setBargainRecord($uid, $bargainUserInfo, $bargainInfo);
|
$price = $userHelpService->setBargainRecord($uid, $bargainUserInfo, $bargainInfo);
|
||||||
if ($price) {
|
if ($price) {
|
||||||
if (!$bargainUserService->getSurplusPrice($bargainUserTableId, 1)) {
|
if (!$bargainUserService->getSurplusPrice($bargainUserTableId, 1)) {
|
||||||
event('notice.notice', [['uid' => $bargainUserUid, 'bargainInfo' => $bargainInfo, 'bargainUserInfo' => $bargainUserInfo,], 'bargain_success']);
|
event('NoticeListener', [['uid' => $bargainUserUid, 'bargainInfo' => $bargainInfo, 'bargainUserInfo' => $bargainUserInfo,], 'bargain_success']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ['bargainUserInfo' => $bargainUserInfo, 'price' => $price];
|
return ['bargainUserInfo' => $bargainUserInfo, 'price' => $price];
|
||||||
|
|||||||
@ -187,8 +187,14 @@ class StoreBargainUserServices extends BaseServices
|
|||||||
if (!$bargainUserUid) return [];
|
if (!$bargainUserUid) return [];
|
||||||
[$page, $limit] = $this->getPageValue();
|
[$page, $limit] = $this->getPageValue();
|
||||||
$list = $this->dao->userAll($bargainUserUid, $page, $limit);
|
$list = $this->dao->userAll($bargainUserUid, $page, $limit);
|
||||||
|
$bargainHelpServices = app()->make(StoreBargainUserHelpServices::class);
|
||||||
foreach ($list as &$item) {
|
foreach ($list as &$item) {
|
||||||
$item['residue_price'] = bcsub((string)$item['bargain_price'], (string)$item['price'], 2);
|
$item['residue_price'] = bcsub((string)$item['bargain_price'], (string)$item['price'], 2);
|
||||||
|
if ($item['status'] == 3) {
|
||||||
|
$item['success_time'] = date('Y-m-d H:i:s', (int)$bargainHelpServices->getMax(['bargain_user_id' => $item['id']], 'add_time'));
|
||||||
|
} else {
|
||||||
|
$item['success_time'] = '';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return $list;
|
return $list;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -118,13 +118,6 @@ class StoreCombinationServices extends BaseServices
|
|||||||
$valueGroup = $storeProductAttrServices->saveProductAttr($skuList, (int)$res->id, 3);
|
$valueGroup = $storeProductAttrServices->saveProductAttr($skuList, (int)$res->id, 3);
|
||||||
if (!$res) throw new AdminException(100022);
|
if (!$res) throw new AdminException(100022);
|
||||||
}
|
}
|
||||||
$res = true;
|
|
||||||
foreach ($valueGroup->toArray() as $item) {
|
|
||||||
$res = $res && CacheService::setStock($item['unique'], (int)$item['quota_show'], 3);
|
|
||||||
}
|
|
||||||
if (!$res) {
|
|
||||||
throw new AdminException(400092);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -425,7 +418,7 @@ class StoreCombinationServices extends BaseServices
|
|||||||
$data['routine_contact_type'] = sys_config('routine_contact_type', 0);
|
$data['routine_contact_type'] = sys_config('routine_contact_type', 0);
|
||||||
|
|
||||||
//用户访问事件
|
//用户访问事件
|
||||||
event('user.userVisit', [$uid, $id, 'combination', $storeInfo['product_id'], 'view']);
|
event('UserVisitListener', [$uid, $id, 'combination', $storeInfo['product_id'], 'view']);
|
||||||
//浏览记录
|
//浏览记录
|
||||||
ProductLogJob::dispatch(['visit', ['uid' => $uid, 'product_id' => $storeInfo['product_id']]]);
|
ProductLogJob::dispatch(['visit', ['uid' => $uid, 'product_id' => $storeInfo['product_id']]]);
|
||||||
return $data;
|
return $data;
|
||||||
|
|||||||
@ -131,9 +131,6 @@ class StorePinkServices extends BaseServices
|
|||||||
} else if ($countY) {//团员
|
} else if ($countY) {//团员
|
||||||
$res = $this->dao->update($countY['id'], ['stop_time' => time() - 1, 'k_id' => 0, 'is_refund' => $id, 'status' => 3]);
|
$res = $this->dao->update($countY['id'], ['stop_time' => time() - 1, 'k_id' => 0, 'is_refund' => $id, 'status' => 3]);
|
||||||
}
|
}
|
||||||
if ($res) {
|
|
||||||
CacheService::setStock(md5((string)$id), 1, 3, false);
|
|
||||||
}
|
|
||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -151,8 +148,23 @@ class StorePinkServices extends BaseServices
|
|||||||
$where['cid'] = $id;
|
$where['cid'] = $id;
|
||||||
$where['k_id'] = 0;
|
$where['k_id'] = 0;
|
||||||
$where['is_refund'] = 0;
|
$where['is_refund'] = 0;
|
||||||
$list = $this->dao->pinkList($where);
|
$pinkList = $this->dao->pinkList($where);
|
||||||
$ids = array_column($list, 'id');
|
$ids = array_column($pinkList, 'id');
|
||||||
|
$orderIdKey = array_column($pinkList, 'order_id_key');
|
||||||
|
$refunList = [];
|
||||||
|
if ($orderIdKey) {
|
||||||
|
$refunList = app()->make(StoreOrderRefundServices::class)->getColumn([['store_order_id', 'in', $orderIdKey]], 'id', 'store_order_id');
|
||||||
|
}
|
||||||
|
if ($refunList) {
|
||||||
|
$list = [];
|
||||||
|
foreach ($pinkList as $item) {
|
||||||
|
if (!isset($refunList[$item['order_id_key']])) {
|
||||||
|
$list[] = $item;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$list = $pinkList;
|
||||||
|
}
|
||||||
$counts = $this->dao->getPinkPeopleCount($ids);
|
$counts = $this->dao->getPinkPeopleCount($ids);
|
||||||
if ($type) {
|
if ($type) {
|
||||||
$pinkAll = [];
|
$pinkAll = [];
|
||||||
@ -285,9 +297,9 @@ class StorePinkServices extends BaseServices
|
|||||||
{
|
{
|
||||||
$pink = $this->dao->getOne([['id|k_id', '=', $pid], ['uid', '=', $uid]], '*', ['getProduct']);
|
$pink = $this->dao->getOne([['id|k_id', '=', $pid], ['uid', '=', $uid]], '*', ['getProduct']);
|
||||||
if ($isRemove) {
|
if ($isRemove) {
|
||||||
event('notice.notice', [['uid' => $uid, 'pink' => $pink, 'user_type' => $channel], 'send_order_pink_clone']);
|
event('NoticeListener', [['uid' => $uid, 'pink' => $pink, 'user_type' => $channel], 'send_order_pink_clone']);
|
||||||
} else {
|
} else {
|
||||||
event('notice.notice', [['uid' => $uid, 'pink' => $pink, 'user_type' => $channel], 'send_order_pink_fial']);
|
event('NoticeListener', [['uid' => $uid, 'pink' => $pink, 'user_type' => $channel], 'send_order_pink_fial']);
|
||||||
}
|
}
|
||||||
$this->dao->update([['id|k_id', '=', $pid]], ['status' => 3, 'stop_time' => time()]);
|
$this->dao->update([['id|k_id', '=', $pid]], ['status' => 3, 'stop_time' => time()]);
|
||||||
}
|
}
|
||||||
@ -375,7 +387,7 @@ class StorePinkServices extends BaseServices
|
|||||||
foreach ($pinkList as $item) {
|
foreach ($pinkList as $item) {
|
||||||
$item['nickname'] = $pinkT_name;
|
$item['nickname'] = $pinkT_name;
|
||||||
//用户发送消息
|
//用户发送消息
|
||||||
event('notice.notice', [
|
event('NoticeListener', [
|
||||||
[
|
[
|
||||||
'list' => $item,
|
'list' => $item,
|
||||||
'title' => $title,
|
'title' => $title,
|
||||||
@ -424,7 +436,7 @@ class StorePinkServices extends BaseServices
|
|||||||
$res = $this->save($pink);
|
$res = $this->save($pink);
|
||||||
}
|
}
|
||||||
// 拼团团成功发送模板消息
|
// 拼团团成功发送模板消息
|
||||||
event('notice.notice', [['orderInfo' => $orderInfo, 'title' => $product['title'], 'pink' => $pink], 'can_pink_success']);
|
event('NoticeListener', [['orderInfo' => $orderInfo, 'title' => $product['title'], 'pink' => $pink], 'can_pink_success']);
|
||||||
|
|
||||||
//处理拼团完成
|
//处理拼团完成
|
||||||
list($pinkAll, $pinkT, $count, $idAll, $uidAll) = $this->getPinkMemberAndPinkK($pink);
|
list($pinkAll, $pinkT, $count, $idAll, $uidAll) = $this->getPinkMemberAndPinkK($pink);
|
||||||
@ -463,12 +475,9 @@ class StorePinkServices extends BaseServices
|
|||||||
$pink['id'] = $res1['id'];
|
$pink['id'] = $res1['id'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$number = (int)bcsub((string)$pink['people'], '1', 0);
|
|
||||||
if ($number) CacheService::setStock(md5($pink['id']), $number, 3);
|
|
||||||
|
|
||||||
PinkJob::dispatchSecs((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']);
|
event('NoticeListener', [['orderInfo' => $orderInfo, 'title' => $product['title'], 'pink' => $pink], 'open_pink_success']);
|
||||||
|
|
||||||
if ($res) return true;
|
if ($res) return true;
|
||||||
else return false;
|
else return false;
|
||||||
|
|||||||
@ -87,7 +87,7 @@ class StoreIntegralServices extends BaseServices
|
|||||||
$res = $this->dao->update($id, $data);
|
$res = $this->dao->update($id, $data);
|
||||||
$storeDescriptionServices->saveDescription((int)$id, $description, 4);
|
$storeDescriptionServices->saveDescription((int)$id, $description, 4);
|
||||||
$skuList = $storeProductServices->validateProductAttr($items, $detail, (int)$id, 4);
|
$skuList = $storeProductServices->validateProductAttr($items, $detail, (int)$id, 4);
|
||||||
$valueGroup = $storeProductAttrServices->saveProductAttr($skuList, (int)$id, 4);
|
$storeProductAttrServices->saveProductAttr($skuList, (int)$id, 4);
|
||||||
if (!$res) throw new AdminException(100007);
|
if (!$res) throw new AdminException(100007);
|
||||||
} else {
|
} else {
|
||||||
if (!$storeProductServices->getOne(['is_show' => 1, 'is_del' => 0, 'id' => $data['product_id']])) {
|
if (!$storeProductServices->getOne(['is_show' => 1, 'is_del' => 0, 'id' => $data['product_id']])) {
|
||||||
@ -97,16 +97,9 @@ class StoreIntegralServices extends BaseServices
|
|||||||
$res = $this->dao->save($data);
|
$res = $this->dao->save($data);
|
||||||
$storeDescriptionServices->saveDescription((int)$res->id, $description, 4);
|
$storeDescriptionServices->saveDescription((int)$res->id, $description, 4);
|
||||||
$skuList = $storeProductServices->validateProductAttr($items, $detail, (int)$res->id, 4);
|
$skuList = $storeProductServices->validateProductAttr($items, $detail, (int)$res->id, 4);
|
||||||
$valueGroup = $storeProductAttrServices->saveProductAttr($skuList, (int)$res->id, 4);
|
$storeProductAttrServices->saveProductAttr($skuList, (int)$res->id, 4);
|
||||||
if (!$res) throw new AdminException(100022);
|
if (!$res) throw new AdminException(100022);
|
||||||
}
|
}
|
||||||
$res = true;
|
|
||||||
foreach ($valueGroup->toArray() as $item) {
|
|
||||||
$res = $res && CacheService::setStock($item['unique'], (int)$item['quota_show'], 4);
|
|
||||||
}
|
|
||||||
if (!$res) {
|
|
||||||
throw new AdminException(400092);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -393,9 +386,6 @@ class StoreIntegralServices extends BaseServices
|
|||||||
if ($product_stock < $num) {
|
if ($product_stock < $num) {
|
||||||
throw new ApiException(410297, ['num' => $num]);
|
throw new ApiException(410297, ['num' => $num]);
|
||||||
}
|
}
|
||||||
if (!CacheService::checkStock($unique, $num, 4)) {
|
|
||||||
throw new ApiException(410297, ['num' => $num]);
|
|
||||||
}
|
|
||||||
return $unique;
|
return $unique;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -190,7 +190,7 @@ class StorePointRecordServices extends BaseServices
|
|||||||
$list[] = [
|
$list[] = [
|
||||||
'name' => $item['name'],
|
'name' => $item['name'],
|
||||||
'value' => $item['value'],
|
'value' => $item['value'],
|
||||||
'percent' => $count != 0 ? bcmul((string)bcdiv((string)$item['value'], (string)$count, 4), '100', 1) : 0,
|
'percent' => $count != 0 ? bcmul((string)bcdiv((string)$item['value'], (string)$count, 4), '100', 2) : 0,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
array_multisort(array_column($list, 'value'), SORT_DESC, $list);
|
array_multisort(array_column($list, 'value'), SORT_DESC, $list);
|
||||||
@ -222,7 +222,7 @@ class StorePointRecordServices extends BaseServices
|
|||||||
$list[] = [
|
$list[] = [
|
||||||
'name' => $item['name'],
|
'name' => $item['name'],
|
||||||
'value' => $item['value'],
|
'value' => $item['value'],
|
||||||
'percent' => $count != 0 ? bcmul((string)bcdiv((string)$item['value'], (string)$count, 4), '100', 1) : 0,
|
'percent' => $count != 0 ? bcmul((string)bcdiv((string)$item['value'], (string)$count, 4), '100', 2) : 0,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
array_multisort(array_column($list, 'value'), SORT_DESC, $list);
|
array_multisort(array_column($list, 'value'), SORT_DESC, $list);
|
||||||
|
|||||||
@ -190,13 +190,6 @@ class StoreSeckillServices extends BaseServices
|
|||||||
$valueGroup = $storeProductAttrServices->saveProductAttr($skuList, (int)$res->id, 1);
|
$valueGroup = $storeProductAttrServices->saveProductAttr($skuList, (int)$res->id, 1);
|
||||||
if (!$res) throw new AdminException(100022);
|
if (!$res) throw new AdminException(100022);
|
||||||
}
|
}
|
||||||
$res = true;
|
|
||||||
foreach ($valueGroup->toArray() as $item) {
|
|
||||||
$res = $res && CacheService::setStock($item['unique'], (int)$item['quota_show'], 1);
|
|
||||||
}
|
|
||||||
if (!$res) {
|
|
||||||
throw new AdminException(400092);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -569,7 +562,7 @@ class StoreSeckillServices extends BaseServices
|
|||||||
$data['routine_contact_type'] = sys_config('routine_contact_type', 0);
|
$data['routine_contact_type'] = sys_config('routine_contact_type', 0);
|
||||||
|
|
||||||
//用户访问事件
|
//用户访问事件
|
||||||
event('user.userVisit', [$uid, $id, 'seckill', $storeInfo['product_id'], 'view']);
|
event('UserVisitListener', [$uid, $id, 'seckill', $storeInfo['product_id'], 'view']);
|
||||||
//浏览记录
|
//浏览记录
|
||||||
ProductLogJob::dispatch(['visit', ['uid' => $uid, 'product_id' => $storeInfo['product_id']]]);
|
ProductLogJob::dispatch(['visit', ['uid' => $uid, 'product_id' => $storeInfo['product_id']]]);
|
||||||
return $data;
|
return $data;
|
||||||
@ -602,33 +595,18 @@ class StoreSeckillServices extends BaseServices
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 秒杀库存添加入redis的队列中
|
* 检查秒杀库存
|
||||||
* @param string $unique sku唯一值
|
* @param int $uid
|
||||||
* @param int $type 类型
|
* @param int $seckillId
|
||||||
* @param int $number 库存个数
|
|
||||||
* @param bool $isPush 是否放入之前删除当前队列
|
|
||||||
* @return bool|int
|
|
||||||
*/
|
|
||||||
public function pushSeckillStock(string $unique, int $type, int $number, bool $isPush = false)
|
|
||||||
{
|
|
||||||
$name = 'seckill_' . $unique . '_' . $type;
|
|
||||||
/** @var CacheService $cache */
|
|
||||||
$cache = app()->make(CacheService::class);
|
|
||||||
$res = true;
|
|
||||||
if (!$isPush) {
|
|
||||||
$cache->delete($name);
|
|
||||||
}
|
|
||||||
for ($i = 1; $i <= $number; $i++) {
|
|
||||||
$res = $res && $cache->lPush($name, $i);
|
|
||||||
}
|
|
||||||
return $res;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param int $productId
|
|
||||||
* @param string $unique
|
|
||||||
* @param int $cartNum
|
* @param int $cartNum
|
||||||
* @param string $value
|
* @param string $unique
|
||||||
|
* @return array
|
||||||
|
* @throws \think\db\exception\DataNotFoundException
|
||||||
|
* @throws \think\db\exception\DbException
|
||||||
|
* @throws \think\db\exception\ModelNotFoundException
|
||||||
|
* @author 吴汐
|
||||||
|
* @email 442384644@qq.com
|
||||||
|
* @date 2023/03/01
|
||||||
*/
|
*/
|
||||||
public function checkSeckillStock(int $uid, int $seckillId, int $cartNum = 1, string $unique = '')
|
public function checkSeckillStock(int $uid, int $seckillId, int $cartNum = 1, string $unique = '')
|
||||||
{
|
{
|
||||||
@ -661,139 +639,18 @@ class StoreSeckillServices extends BaseServices
|
|||||||
return [$attrInfo, $unique, $StoreSeckillinfo];
|
return [$attrInfo, $unique, $StoreSeckillinfo];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 弹出redis队列中的库存条数
|
|
||||||
* @param string $unique
|
|
||||||
* @param int $type
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public function popSeckillStock(string $unique, int $type, int $number = 1)
|
|
||||||
{
|
|
||||||
$name = 'seckill_' . $unique . '_' . $type;
|
|
||||||
/** @var CacheService $cache */
|
|
||||||
$cache = app()->make(CacheService::class);
|
|
||||||
if ($number > $cache->lLen($name)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
$res = true;
|
|
||||||
for ($i = 1; $i <= $number; $i++) {
|
|
||||||
$res = $res && $cache->lPop($name);
|
|
||||||
}
|
|
||||||
return $res;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 是否有库存
|
|
||||||
* @param string $unique
|
|
||||||
* @param int $type
|
|
||||||
* @return mixed
|
|
||||||
* @throws \Psr\SimpleCache\InvalidArgumentException
|
|
||||||
*/
|
|
||||||
public function isSeckillStock(string $unique, int $type, int $number)
|
|
||||||
{
|
|
||||||
/** @var CacheService $cache */
|
|
||||||
$cache = app()->make(CacheService::class);
|
|
||||||
return $cache->lLen('seckill_' . $unique . '_' . $type) >= $number;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 回滚库存
|
|
||||||
* @param array $cartInfo
|
|
||||||
* @param int $number
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
public function rollBackStock(array $cartInfo)
|
|
||||||
{
|
|
||||||
$res = true;
|
|
||||||
foreach ($cartInfo as $item) {
|
|
||||||
$value = $item['cart_info'];
|
|
||||||
if ($value['seckill_id']) {
|
|
||||||
$res = $res && $this->pushSeckillStock($value['product_attr_unique'], 1, (int)$value['cart_num'], true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return $res;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 占用库存
|
|
||||||
* @param $cartInfo
|
|
||||||
*/
|
|
||||||
public function occupySeckillStock($cartInfo, $key, $time = 0)
|
|
||||||
{
|
|
||||||
//占用库存
|
|
||||||
if ($cartInfo) {
|
|
||||||
if (!$time) {
|
|
||||||
$time = time() + 600;
|
|
||||||
}
|
|
||||||
foreach ($cartInfo as $val) {
|
|
||||||
if ($val['seckill_id']) {
|
|
||||||
$this->setSeckillStock($val['product_id'], $val['product_attr_unique'], $time, $key, (int)$val['cart_num']);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 取消秒杀占用的库存
|
|
||||||
* @param array $cartInfo
|
|
||||||
* @param string $key
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
public function cancelOccupySeckillStock(array $cartInfo, string $key)
|
|
||||||
{
|
|
||||||
if ($cartInfo) {
|
|
||||||
foreach ($cartInfo as $val) {
|
|
||||||
if (isset($val['seckill_id']) && $val['seckill_id']) {
|
|
||||||
$this->backSeckillStock((int)$val['product_id'], $val['product_attr_unique'], $key, (int)$val['cart_num']);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 存入当前秒杀商品属性有序集合
|
|
||||||
* @param $product_id
|
|
||||||
* @param $unique
|
|
||||||
* @param $score
|
|
||||||
* @param $value
|
|
||||||
* @param int $cart_num
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
public function setSeckillStock($product_id, $unique, $score, $value, $cart_num = 1)
|
|
||||||
{
|
|
||||||
$set_key = md5('seckill_set_attr_stock_' . $product_id . '_' . $unique);
|
|
||||||
$i = 0;
|
|
||||||
for ($i; $i < $cart_num; $i++) {
|
|
||||||
CacheService::zAdd($set_key, $score, $value . $i);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 取消集合中的秒杀商品
|
|
||||||
* @param int $product_id
|
|
||||||
* @param string $unique
|
|
||||||
* @param $value
|
|
||||||
* @param int $cart_num
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
public function backSeckillStock(int $product_id, string $unique, $value, int $cart_num = 1)
|
|
||||||
{
|
|
||||||
$set_key = md5('seckill_set_attr_stock_' . $product_id . '_' . $unique);
|
|
||||||
$i = 0;
|
|
||||||
for ($i; $i < $cart_num; $i++) {
|
|
||||||
CacheService::zRem($set_key, $value . $i);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改秒杀库存
|
* 修改秒杀库存
|
||||||
* @param int $num
|
* @param int $num
|
||||||
* @param int $seckillId
|
* @param int $seckillId
|
||||||
|
* @param string $unique
|
||||||
* @return bool
|
* @return bool
|
||||||
|
* @throws \think\db\exception\DataNotFoundException
|
||||||
|
* @throws \think\db\exception\DbException
|
||||||
|
* @throws \think\db\exception\ModelNotFoundException
|
||||||
|
* @author 吴汐
|
||||||
|
* @email 442384644@qq.com
|
||||||
|
* @date 2023/03/01
|
||||||
*/
|
*/
|
||||||
public function decSeckillStock(int $num, int $seckillId, string $unique = '')
|
public function decSeckillStock(int $num, int $seckillId, string $unique = '')
|
||||||
{
|
{
|
||||||
|
|||||||
@ -66,6 +66,10 @@ class AgentLevelServices extends BaseServices
|
|||||||
$query->field('count(*) as sum');
|
$query->field('count(*) as sum');
|
||||||
}], $page, $limit);
|
}], $page, $limit);
|
||||||
$count = $this->dao->count($where);
|
$count = $this->dao->count($where);
|
||||||
|
foreach ($list as &$item) {
|
||||||
|
$item['one_brokerage_ratio'] = bcdiv(bcmul((string)sys_config('store_brokerage_ratio'), bcadd('100', (string)$item['one_brokerage'], 2), 2), '100', 2);
|
||||||
|
$item['two_brokerage_ratio'] = bcdiv(bcmul((string)sys_config('store_brokerage_two'), bcadd('100', (string)$item['two_brokerage'], 2), 2), '100', 2);
|
||||||
|
}
|
||||||
return compact('count', 'list');
|
return compact('count', 'list');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -90,6 +94,9 @@ class AgentLevelServices extends BaseServices
|
|||||||
$this->checkUserLevelFinish($uid);
|
$this->checkUserLevelFinish($uid);
|
||||||
|
|
||||||
$list = $this->dao->getList(['is_del' => 0, 'status' => 1]);
|
$list = $this->dao->getList(['is_del' => 0, 'status' => 1]);
|
||||||
|
foreach ($list as &$item) {
|
||||||
|
$item['image'] = set_file_url($item['image']);
|
||||||
|
}
|
||||||
$agent_level = $user['agent_level'] ?? 0;
|
$agent_level = $user['agent_level'] ?? 0;
|
||||||
//没等级默认最低等级
|
//没等级默认最低等级
|
||||||
if (!$agent_level) {
|
if (!$agent_level) {
|
||||||
@ -253,11 +260,19 @@ class AgentLevelServices extends BaseServices
|
|||||||
*/
|
*/
|
||||||
public function createForm()
|
public function createForm()
|
||||||
{
|
{
|
||||||
$field[] = Form::input('name', '等级名称')->col(24);
|
$field[] = Form::input('name', '等级名称')->maxlength(8)->col(24);
|
||||||
$field[] = Form::number('grade', '等级', 0)->min(0)->precision(0);
|
$field[] = Form::number('grade', '等级', 0)->min(0)->precision(0);
|
||||||
$field[] = Form::frameImage('image', '背景图', Url::buildUrl('admin/widget.images/index', array('fodder' => 'image')))->icon('ios-add')->width('950px')->height('505px')->modal(['footer-hide' => true]);
|
$field[] = Form::frameImage('image', '背景图', Url::buildUrl('admin/widget.images/index', array('fodder' => 'image')))->icon('ios-add')->width('950px')->height('505px')->modal(['footer-hide' => true]);
|
||||||
$field[] = Form::number('one_brokerage', '一级上浮', 0)->info('在分销一级佣金基础上浮(0-1000之间整数)百分比')->min(0)->max(1000)->precision(0);
|
$field[] = Form::number('one_brokerage', '一级上浮', 0)->appendRule('suffix', [
|
||||||
$field[] = Form::number('two_brokerage', '二级上浮', 0)->info('在分销二级佣金基础上浮(0-1000之间整数)百分比')->min(0)->max(1000)->precision(0);
|
'type' => 'div',
|
||||||
|
'class' => 'tips-info',
|
||||||
|
'domProps' => ['innerHTML' => '在分销一级佣金基础上浮(0-1000之间整数)百分比,目前一级返佣比率:10%,上浮5%,则返佣比率:一级返佣比率 * (1 + 一级上浮比率) = 10.50%']
|
||||||
|
])->max(1000)->precision(0);
|
||||||
|
$field[] = Form::number('two_brokerage', '二级上浮', 0)->appendRule('suffix', [
|
||||||
|
'type' => 'div',
|
||||||
|
'class' => 'tips-info',
|
||||||
|
'domProps' => ['innerHTML' => '在分销二级佣金基础上浮(0-1000之间整数)百分比,目前二级返佣比率:10%,上浮2%,则返佣比率:二级返佣比率 * (1 + 二级上浮比率) = 5.10%']
|
||||||
|
])->min(0)->max(1000)->precision(0);
|
||||||
$field[] = Form::radio('status', '是否显示', 1)->options([['value' => 1, 'label' => '显示'], ['value' => 0, 'label' => '隐藏']]);
|
$field[] = Form::radio('status', '是否显示', 1)->options([['value' => 1, 'label' => '显示'], ['value' => 0, 'label' => '隐藏']]);
|
||||||
return create_form('添加分销员等级', $field, Url::buildUrl('/agent/level'), 'POST');
|
return create_form('添加分销员等级', $field, Url::buildUrl('/agent/level'), 'POST');
|
||||||
}
|
}
|
||||||
@ -275,11 +290,19 @@ class AgentLevelServices extends BaseServices
|
|||||||
throw new AdminException(100026);
|
throw new AdminException(100026);
|
||||||
$field = [];
|
$field = [];
|
||||||
$field[] = Form::hidden('id', $id);
|
$field[] = Form::hidden('id', $id);
|
||||||
$field[] = Form::input('name', '等级名称', $levelInfo['name'])->col(24);
|
$field[] = Form::input('name', '等级名称', $levelInfo['name'])->maxlength(8)->col(24);
|
||||||
$field[] = Form::number('grade', '等级', $levelInfo['grade'])->min(0)->precision(0);
|
$field[] = Form::number('grade', '等级', $levelInfo['grade'])->min(0)->precision(0);
|
||||||
$field[] = Form::frameImage('image', '背景图', Url::buildUrl('admin/widget.images/index', array('fodder' => 'image')), $levelInfo['image'])->icon('ios-add')->width('950px')->height('505px')->modal(['footer-hide' => true]);
|
$field[] = Form::frameImage('image', '背景图', Url::buildUrl('admin/widget.images/index', array('fodder' => 'image')), $levelInfo['image'])->icon('ios-add')->width('950px')->height('505px')->modal(['footer-hide' => true]);
|
||||||
$field[] = Form::number('one_brokerage', '一级上浮', $levelInfo['one_brokerage'])->info('在分销一级佣金基础上浮(0-1000之间整数)百分比')->min(0)->max(1000)->precision(0);
|
$field[] = Form::number('one_brokerage', '一级上浮', $levelInfo['one_brokerage'])->appendRule('suffix', [
|
||||||
$field[] = Form::number('two_brokerage', '二级上浮', $levelInfo['two_brokerage'])->info('在分销二级佣金基础上浮(0-1000之间整数)百分比')->min(0)->max(1000)->precision(0);
|
'type' => 'div',
|
||||||
|
'class' => 'tips-info',
|
||||||
|
'domProps' => ['innerHTML' => '在分销一级佣金基础上浮(0-1000之间整数)百分比,目前一级返佣比率:10%,上浮5%,则返佣比率:一级返佣比率 * (1 + 一级上浮比率) = 10.50%']
|
||||||
|
])->min(0)->max(1000)->precision(0);
|
||||||
|
$field[] = Form::number('two_brokerage', '二级上浮', $levelInfo['two_brokerage'])->appendRule('suffix', [
|
||||||
|
'type' => 'div',
|
||||||
|
'class' => 'tips-info',
|
||||||
|
'domProps' => ['innerHTML' => '在分销二级佣金基础上浮(0-1000之间整数)百分比,目前二级返佣比率:10%,上浮2%,则返佣比率:二级返佣比率 * (1 + 二级上浮比率) = 5.10%']
|
||||||
|
])->min(0)->max(1000)->precision(0);
|
||||||
$field[] = Form::radio('status', '是否显示', $levelInfo['status'])->options([['value' => 1, 'label' => '显示'], ['value' => 0, 'label' => '隐藏']]);
|
$field[] = Form::radio('status', '是否显示', $levelInfo['status'])->options([['value' => 1, 'label' => '显示'], ['value' => 0, 'label' => '隐藏']]);
|
||||||
|
|
||||||
return create_form('编辑分销员等级', $field, Url::buildUrl('/agent/level/' . $id), 'PUT');
|
return create_form('编辑分销员等级', $field, Url::buildUrl('/agent/level/' . $id), 'PUT');
|
||||||
@ -328,11 +351,11 @@ class AgentLevelServices extends BaseServices
|
|||||||
{
|
{
|
||||||
/** @var UserServices $userServices */
|
/** @var UserServices $userServices */
|
||||||
$userServices = app()->make(UserServices::class);
|
$userServices = app()->make(UserServices::class);
|
||||||
$userInfo = $userServices->getUserInfo($uid);
|
$userInfo = $userServices->getUserInfo($uid, 'uid');
|
||||||
if (!$userInfo) {
|
if (!$userInfo) {
|
||||||
throw new AdminException(400214);
|
throw new AdminException(400214);
|
||||||
}
|
}
|
||||||
$levelInfo = $this->getLevelInfo($id);
|
$levelInfo = $this->getLevelInfo($id, 'id');
|
||||||
if (!$levelInfo) {
|
if (!$levelInfo) {
|
||||||
throw new AdminException(400442);
|
throw new AdminException(400442);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -373,7 +373,7 @@ class AgentManageServices extends BaseServices
|
|||||||
{
|
{
|
||||||
/** @var UserServices $userServices */
|
/** @var UserServices $userServices */
|
||||||
$userServices = app()->make(UserServices::class);
|
$userServices = app()->make(UserServices::class);
|
||||||
if (!$userServices->getUserInfo($uid)) {
|
if (!$userServices->getUserInfo($uid, 'uid')) {
|
||||||
throw new AdminException(100026);
|
throw new AdminException(100026);
|
||||||
}
|
}
|
||||||
if ($userServices->update($uid, ['spread_open' => 0]) !== false)
|
if ($userServices->update($uid, ['spread_open' => 0]) !== false)
|
||||||
|
|||||||
@ -147,11 +147,11 @@ class DiyServices extends BaseServices
|
|||||||
{
|
{
|
||||||
if ($id) {
|
if ($id) {
|
||||||
return $this->cacheDriver()->remember('index_diy_' . $id, function () use ($id) {
|
return $this->cacheDriver()->remember('index_diy_' . $id, function () use ($id) {
|
||||||
return $this->dao->value(['id' => $id], 'version');
|
return $this->dao->getOne(['id' => $id], 'version,is_diy');
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
return $this->cacheDriver()->remember('index_diy_default', function () {
|
return $this->cacheDriver()->remember('index_diy_default', function () {
|
||||||
return $this->dao->value(['status' => 1, 'is_del' => 0], 'version');
|
return $this->dao->getOne(['status' => 1, 'is_del' => 0], 'version,is_diy');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -86,14 +86,12 @@ class SystemNotificationServices extends BaseServices
|
|||||||
$info['content'] = $info['sms_text'];
|
$info['content'] = $info['sms_text'];
|
||||||
break;
|
break;
|
||||||
case 'is_wechat':
|
case 'is_wechat':
|
||||||
$wechat = $TemplateMessageServices->getOne(['id' => $info['wechat_id'], 'type' => 1]);
|
|
||||||
$info['templage_message_id'] = $wechat['id'] ?? '';
|
|
||||||
$info['tempkey'] = $wechat['tempkey'] ?? '';
|
|
||||||
$info['tempid'] = $wechat['tempid'] ?? '';
|
|
||||||
$info['content'] = $wechat['content'] ?? '';
|
|
||||||
break;
|
|
||||||
case 'is_routine':
|
case 'is_routine':
|
||||||
$wechat = $TemplateMessageServices->getOne(['id' => $info['routine_id'], 'type' => 0]);
|
if ('is_wechat' === $type) {
|
||||||
|
$wechat = $TemplateMessageServices->getOne(['id' => $info['wechat_id'], 'type' => 1]);
|
||||||
|
} else {
|
||||||
|
$wechat = $TemplateMessageServices->getOne(['id' => $info['routine_id'], 'type' => 0]);
|
||||||
|
}
|
||||||
$info['templage_message_id'] = $wechat['id'] ?? '';
|
$info['templage_message_id'] = $wechat['id'] ?? '';
|
||||||
$info['tempkey'] = $wechat['tempkey'] ?? '';
|
$info['tempkey'] = $wechat['tempkey'] ?? '';
|
||||||
$info['tempid'] = $wechat['tempid'] ?? '';
|
$info['tempid'] = $wechat['tempid'] ?? '';
|
||||||
|
|||||||
@ -29,10 +29,17 @@ use think\facade\Log;
|
|||||||
|
|
||||||
class MessageServices extends BaseServices
|
class MessageServices extends BaseServices
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 扫码
|
* 扫码
|
||||||
* @param $message
|
* @param $message
|
||||||
* @return array|\EasyWeChat\Message\Image|\EasyWeChat\Message\News|\EasyWeChat\Message\Text|\EasyWeChat\Message\Voice|string
|
* @return array|\EasyWeChat\Message\Image|\EasyWeChat\Message\News|\EasyWeChat\Message\Text|\EasyWeChat\Message\Transfer|\EasyWeChat\Message\Voice|mixed|string
|
||||||
|
* @throws \think\db\exception\DataNotFoundException
|
||||||
|
* @throws \think\db\exception\DbException
|
||||||
|
* @throws \think\db\exception\ModelNotFoundException
|
||||||
|
* @author 吴汐
|
||||||
|
* @email 442384644@qq.com
|
||||||
|
* @date 2023/02/24
|
||||||
*/
|
*/
|
||||||
public function wechatEventScan($message)
|
public function wechatEventScan($message)
|
||||||
{
|
{
|
||||||
@ -59,150 +66,131 @@ class MessageServices extends BaseServices
|
|||||||
$is_new = $wechatUser->saveUser($message->FromUserName);
|
$is_new = $wechatUser->saveUser($message->FromUserName);
|
||||||
$uid = $wechatUser->getFieldValue($message->FromUserName, 'openid', 'uid', ['user_type', '<>', 'h5']);
|
$uid = $wechatUser->getFieldValue($message->FromUserName, 'openid', 'uid', ['user_type', '<>', 'h5']);
|
||||||
$userInfo = $userService->get($uid);
|
$userInfo = $userService->get($uid);
|
||||||
if (strtolower($thirdType[0]) == 'spread') {
|
try {
|
||||||
try {
|
switch (strtolower($thirdType[0])) {
|
||||||
if ($spreadUid == $uid) {
|
case 'spread':
|
||||||
$response = '自己不能推荐自己';
|
if ($spreadUid == $uid) {
|
||||||
} else if (!$userInfo) {
|
$response = '自己不能推荐自己';
|
||||||
$response = '用户不存在';
|
} else if (!$userInfo) {
|
||||||
} else if (!$spreadInfo) {
|
$response = '用户不存在';
|
||||||
$response = '上级用户不存在';
|
} else if (!$spreadInfo) {
|
||||||
} else if ($userInfo['spread_uid']) {
|
$response = '上级用户不存在';
|
||||||
$response = '已有推荐人!';
|
} else if ($userInfo['spread_uid']) {
|
||||||
} else if (!$loginService->updateUserInfo(['code' => $spreadUid], $userInfo, $is_new)) {
|
$response = '已有推荐人!';
|
||||||
$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['title'] = sys_config('site_name');
|
||||||
$wechatNews['url'] = $baseUrl . '/pages/index/index';
|
$wechatNews['image'] = sys_config('wap_login_logo');
|
||||||
$loginService->updateUserInfo(['code' => $spreadUid], $userInfo, $is_new);
|
$wechatNews['url'] = $baseUrl . '/pages/index/index';
|
||||||
$messages = WechatService::newsMessage($wechatNews);
|
$loginService->updateUserInfo(['code' => $spreadUid], $userInfo, $is_new);
|
||||||
WechatService::staffService()->message($messages)->to($message->FromUserName)->send();
|
$messages = WechatService::newsMessage($wechatNews);
|
||||||
} catch (\Exception $e) {
|
WechatService::staffService()->message($messages)->to($message->FromUserName)->send();
|
||||||
$response = $e->getMessage();
|
break;
|
||||||
}
|
case 'agent':
|
||||||
} elseif (strtolower($thirdType[0]) == 'agent') {
|
if ($spreadUid == $uid) {
|
||||||
try {
|
$response = '自己不能推荐自己';
|
||||||
if ($spreadUid == $uid) {
|
} else if (!$userInfo) {
|
||||||
$response = '自己不能推荐自己';
|
$response = '用户不存在';
|
||||||
} else if (!$userInfo) {
|
} else if (!$spreadInfo) {
|
||||||
$response = '用户不存在';
|
$response = '上级用户不存在';
|
||||||
} else if (!$spreadInfo) {
|
} else if ($userInfo->is_division) {
|
||||||
$response = '上级用户不存在';
|
$response = '您是事业部,不能绑定成为别人的员工';
|
||||||
} else if ($userInfo->is_division) {
|
} else if ($userInfo->is_agent) {
|
||||||
$response = '您是事业部,不能绑定成为别人的员工';
|
$response = '您是代理商,不能绑定成为别人的员工';
|
||||||
} else if ($userInfo->is_agent) {
|
} else if ($loginService->updateUserInfo(['code' => $spreadUid, 'is_staff' => 1], $userInfo, $is_new)) {
|
||||||
$response = '您是代理商,不能绑定成为别人的员工';
|
$response = '绑定店员成功!';
|
||||||
} else if ($loginService->updateUserInfo(['code' => $spreadUid, 'is_staff' => 1], $userInfo, $is_new)) {
|
}
|
||||||
$response = '绑定店员成功!';
|
break;
|
||||||
}
|
case 'wechatqrcode':
|
||||||
} catch (\Exception $e) {
|
/** @var WechatQrcodeServices $wechatQrcodeService */
|
||||||
$response = $e->getMessage();
|
$wechatQrcodeService = app()->make(WechatQrcodeServices::class);
|
||||||
}
|
//wechatqrcode类型的二维码数据中,third_id为渠道码的id
|
||||||
} elseif (strtolower($thirdType[0]) == 'wechatqrcode') {
|
$qrcodeInfo = $wechatQrcodeService->qrcodeInfo($qrInfo['third_id']);
|
||||||
/** @var WechatQrcodeServices $wechatQrcodeService */
|
$spreadUid = $qrcodeInfo['uid'];
|
||||||
$wechatQrcodeService = app()->make(WechatQrcodeServices::class);
|
$spreadInfo = $userService->get($spreadUid);
|
||||||
try {
|
$is_new = $wechatUser->saveUser($message->FromUserName);
|
||||||
//wechatqrcode类型的二维码数据中,third_id为渠道码的id
|
$uid = $wechatUser->getFieldValue($message->FromUserName, 'openid', 'uid', ['user_type', '<>', 'h5']);
|
||||||
$qrcodeInfo = $wechatQrcodeService->qrcodeInfo($qrInfo['third_id']);
|
$userInfo = $userService->get($uid);
|
||||||
$spreadUid = $qrcodeInfo['uid'];
|
if ($qrcodeInfo['status'] == 0 || $qrcodeInfo['is_del'] == 1 || ($qrcodeInfo['end_time'] < time() && $qrcodeInfo['end_time'] > 0)) {
|
||||||
$spreadInfo = $userService->get($spreadUid);
|
$response = '二维码已失效';
|
||||||
$is_new = $wechatUser->saveUser($message->FromUserName);
|
} else if ($spreadUid == $uid) {
|
||||||
$uid = $wechatUser->getFieldValue($message->FromUserName, 'openid', 'uid', ['user_type', '<>', 'h5']);
|
$response = '自己不能推荐自己';
|
||||||
$userInfo = $userService->get($uid);
|
} else if (!$userInfo) {
|
||||||
if ($qrcodeInfo['status'] == 0 || $qrcodeInfo['is_del'] == 1 || ($qrcodeInfo['end_time'] < time() && $qrcodeInfo['end_time'] > 0)) {
|
$response = '用户不存在';
|
||||||
$response = '二维码已失效';
|
} else if (!$spreadInfo) {
|
||||||
} else if ($spreadUid == $uid) {
|
$response = '上级用户不存在';
|
||||||
$response = '自己不能推荐自己';
|
} else if ($loginService->updateUserInfo(['code' => $spreadUid], $userInfo, $is_new)) {
|
||||||
} else if (!$userInfo) {
|
//写入扫码记录,返回内容
|
||||||
$response = '用户不存在';
|
$response = $wechatQrcodeService->wechatQrcodeRecord($qrcodeInfo, $userInfo, $spreadInfo);
|
||||||
} else if (!$spreadInfo) {
|
}
|
||||||
$response = '上级用户不存在';
|
break;
|
||||||
} else if ($loginService->updateUserInfo(['code' => $spreadUid], $userInfo, $is_new)) {
|
case 'product':
|
||||||
//写入扫码记录,返回内容
|
/** @var StoreProductServices $productService */
|
||||||
$response = $wechatQrcodeService->wechatQrcodeRecord($qrcodeInfo, $userInfo, $spreadInfo);
|
$productService = app()->make(StoreProductServices::class);
|
||||||
}
|
$productInfo = $productService->get($thirdType[1] ?? 0);
|
||||||
} catch (\Exception $e) {
|
$wechatNews['title'] = $productInfo->store_name;
|
||||||
$response = $e->getMessage();
|
$wechatNews['image'] = $productInfo->image;
|
||||||
}
|
$wechatNews['description'] = $productInfo->store_info;
|
||||||
} elseif (strtolower($thirdType[0]) == 'product') {
|
$wechatNews['url'] = $baseUrl . '/pages/goods_details/index?id=' . $thirdType[1];
|
||||||
try {
|
$loginService->updateUserInfo(['code' => $spreadUid], $userInfo, $is_new);
|
||||||
/** @var StoreProductServices $productService */
|
$messages = WechatService::newsMessage($wechatNews);
|
||||||
$productService = app()->make(StoreProductServices::class);
|
WechatService::staffService()->message($messages)->to($message->FromUserName)->send();
|
||||||
$productInfo = $productService->get($thirdType[1] ?? 0);
|
break;
|
||||||
$wechatNews['title'] = $productInfo->store_name;
|
case 'combination':
|
||||||
$wechatNews['image'] = $productInfo->image;
|
/** @var StoreCombinationServices $combinationService */
|
||||||
$wechatNews['description'] = $productInfo->store_info;
|
$combinationService = app()->make(StoreCombinationServices::class);
|
||||||
$wechatNews['url'] = $baseUrl . '/pages/goods_details/index?id=' . $thirdType[1];
|
$productInfo = $combinationService->get($thirdType[1] ?? 0);
|
||||||
$loginService->updateUserInfo(['code' => $spreadUid], $userInfo, $is_new);
|
$wechatNews['title'] = $productInfo->title;
|
||||||
$messages = WechatService::newsMessage($wechatNews);
|
$wechatNews['image'] = $productInfo->image;
|
||||||
WechatService::staffService()->message($messages)->to($message->FromUserName)->send();
|
$wechatNews['description'] = $productInfo->info;
|
||||||
} catch (\Exception $e) {
|
$wechatNews['url'] = $baseUrl . '/pages/activity/goods_combination_details/index?id=' . $thirdType[1];
|
||||||
$response = $e->getMessage();
|
$loginService->updateUserInfo(['code' => $spreadUid], $userInfo, $is_new);
|
||||||
}
|
$messages = WechatService::newsMessage($wechatNews);
|
||||||
} elseif (strtolower($thirdType[0]) == 'combination') {
|
WechatService::staffService()->message($messages)->to($message->FromUserName)->send();
|
||||||
try {
|
break;
|
||||||
/** @var StoreCombinationServices $combinationService */
|
case 'seckill':
|
||||||
$combinationService = app()->make(StoreCombinationServices::class);
|
/** @var StoreSeckillServices $seckillService */
|
||||||
$productInfo = $combinationService->get($thirdType[1] ?? 0);
|
$seckillService = app()->make(StoreSeckillServices::class);
|
||||||
$wechatNews['title'] = $productInfo->title;
|
$productInfo = $seckillService->get($thirdType[1] ?? 0);
|
||||||
$wechatNews['image'] = $productInfo->image;
|
$wechatNews['title'] = $productInfo->title;
|
||||||
$wechatNews['description'] = $productInfo->info;
|
$wechatNews['image'] = $productInfo->image;
|
||||||
$wechatNews['url'] = $baseUrl . '/pages/activity/goods_combination_details/index?id=' . $thirdType[1];
|
$wechatNews['description'] = $productInfo->info;
|
||||||
$loginService->updateUserInfo(['code' => $spreadUid], $userInfo, $is_new);
|
$wechatNews['url'] = $baseUrl . '/pages/activity/goods_seckill_details/index?id=' . $thirdType[1];
|
||||||
$messages = WechatService::newsMessage($wechatNews);
|
$loginService->updateUserInfo(['code' => $spreadUid], $userInfo, $is_new);
|
||||||
WechatService::staffService()->message($messages)->to($message->FromUserName)->send();
|
$messages = WechatService::newsMessage($wechatNews);
|
||||||
} catch (\Exception $e) {
|
WechatService::staffService()->message($messages)->to($message->FromUserName)->send();
|
||||||
$response = $e->getMessage();
|
break;
|
||||||
}
|
case 'bargain':
|
||||||
} elseif (strtolower($thirdType[0]) == 'seckill') {
|
/** @var StoreBargainServices $bargainService */
|
||||||
try {
|
$bargainService = app()->make(StoreBargainServices::class);
|
||||||
/** @var StoreSeckillServices $seckillService */
|
$productInfo = $bargainService->get($thirdType[1] ?? 0);
|
||||||
$seckillService = app()->make(StoreSeckillServices::class);
|
$wechatNews['title'] = $productInfo->title;
|
||||||
$productInfo = $seckillService->get($thirdType[1] ?? 0);
|
$wechatNews['image'] = $productInfo->image;
|
||||||
$wechatNews['title'] = $productInfo->title;
|
$wechatNews['description'] = $productInfo->info;
|
||||||
$wechatNews['image'] = $productInfo->image;
|
$wechatNews['url'] = $baseUrl . '/pages/activity/goods_bargain_details/index?id=' . $thirdType[1] . '&bargain=' . $thirdType[2];
|
||||||
$wechatNews['description'] = $productInfo->info;
|
$loginService->updateUserInfo(['code' => $spreadUid], $userInfo, $is_new);
|
||||||
$wechatNews['url'] = $baseUrl . '/pages/activity/goods_seckill_details/index?id=' . $thirdType[1];
|
$messages = WechatService::newsMessage($wechatNews);
|
||||||
$loginService->updateUserInfo(['code' => $spreadUid], $userInfo, $is_new);
|
WechatService::staffService()->message($messages)->to($message->FromUserName)->send();
|
||||||
$messages = WechatService::newsMessage($wechatNews);
|
break;
|
||||||
WechatService::staffService()->message($messages)->to($message->FromUserName)->send();
|
case 'pink':
|
||||||
} catch (\Exception $e) {
|
/** @var StorePinkServices $pinkService */
|
||||||
$response = $e->getMessage();
|
$pinkService = app()->make(StorePinkServices::class);
|
||||||
}
|
/** @var StoreCombinationServices $combinationService */
|
||||||
} elseif (strtolower($thirdType[0]) == 'bargain') {
|
$combinationService = app()->make(StoreCombinationServices::class);
|
||||||
try {
|
$pinktInfo = $pinkService->get($thirdType[1]);
|
||||||
/** @var StoreBargainServices $bargainService */
|
$productInfo = $combinationService->get($pinktInfo->cid);
|
||||||
$bargainService = app()->make(StoreBargainServices::class);
|
$wechatNews['title'] = $productInfo->title;
|
||||||
$productInfo = $bargainService->get($thirdType[1] ?? 0);
|
$wechatNews['image'] = $productInfo->image;
|
||||||
$wechatNews['title'] = $productInfo->title;
|
$wechatNews['description'] = $productInfo->info;
|
||||||
$wechatNews['image'] = $productInfo->image;
|
$wechatNews['url'] = $baseUrl . '/pages/activity/goods_combination_status/index?id=' . $thirdType[1];
|
||||||
$wechatNews['description'] = $productInfo->info;
|
$loginService->updateUserInfo(['code' => $spreadUid], $userInfo, $is_new);
|
||||||
$wechatNews['url'] = $baseUrl . '/pages/activity/goods_bargain_details/index?id=' . $thirdType[1] . '&bargain=' . $thirdType[2];
|
$messages = WechatService::newsMessage($wechatNews);
|
||||||
$loginService->updateUserInfo(['code' => $spreadUid], $userInfo, $is_new);
|
WechatService::staffService()->message($messages)->to($message->FromUserName)->send();
|
||||||
$messages = WechatService::newsMessage($wechatNews);
|
break;
|
||||||
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 (\Throwable $e) {
|
||||||
|
$response = $e->getMessage();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
//扫码不生成用户流程
|
//扫码不生成用户流程
|
||||||
@ -222,98 +210,170 @@ class MessageServices extends BaseServices
|
|||||||
$wechatUser->unSubscribe($message->FromUserName);
|
$wechatUser->unSubscribe($message->FromUserName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 公众号关注
|
* 公众号关注
|
||||||
* @param $message
|
* @param $message
|
||||||
* @return array|\EasyWeChat\Message\Image|\EasyWeChat\Message\News|\EasyWeChat\Message\Text|\EasyWeChat\Message\Voice|string
|
* @return array|\EasyWeChat\Message\Image|\EasyWeChat\Message\News|\EasyWeChat\Message\Text|\EasyWeChat\Message\Transfer|\EasyWeChat\Message\Voice|mixed|string
|
||||||
|
* @throws \think\db\exception\DataNotFoundException
|
||||||
|
* @throws \think\db\exception\DbException
|
||||||
|
* @throws \think\db\exception\ModelNotFoundException
|
||||||
|
* @author 吴汐
|
||||||
|
* @email 442384644@qq.com
|
||||||
|
* @date 2023/02/24
|
||||||
*/
|
*/
|
||||||
public function wechatEventSubscribe($message)
|
public function wechatEventSubscribe($message)
|
||||||
{
|
{
|
||||||
|
/** @var QrcodeServices $qrcodeService */
|
||||||
|
$qrcodeService = app()->make(QrcodeServices::class);
|
||||||
/** @var WechatReplyServices $wechatReplyService */
|
/** @var WechatReplyServices $wechatReplyService */
|
||||||
$wechatReplyService = app()->make(WechatReplyServices::class);
|
$wechatReplyService = app()->make(WechatReplyServices::class);
|
||||||
/** @var WechatUserServices $wechatUser */
|
/** @var WechatUserServices $wechatUser */
|
||||||
$wechatUser = app()->make(WechatUserServices::class);
|
$wechatUser = app()->make(WechatUserServices::class);
|
||||||
/** @var UserServices $userService */
|
|
||||||
$userService = app()->make(UserServices::class);
|
|
||||||
/** @var LoginServices $loginService */
|
/** @var LoginServices $loginService */
|
||||||
$loginService = app()->make(LoginServices::class);
|
$loginService = app()->make(LoginServices::class);
|
||||||
|
/** @var UserServices $userService */
|
||||||
|
$userService = app()->make(UserServices::class);
|
||||||
|
|
||||||
$response = $wechatReplyService->reply('subscribe');
|
$response = $wechatReplyService->reply('subscribe');
|
||||||
if (isset($message->EventKey)) {
|
if ($message->EventKey && ($qrInfo = $qrcodeService->getQrcode($message->Ticket, 'ticket'))) {
|
||||||
/** @var QrcodeServices $qrcodeService */
|
$qrcodeService->scanQrcode($message->Ticket, 'ticket');
|
||||||
$qrcodeService = app()->make(QrcodeServices::class);
|
$thirdType = explode('-', $qrInfo['third_type']);
|
||||||
if ($message->EventKey && ($qrInfo = $qrcodeService->getQrcode($message->Ticket, 'ticket'))) {
|
$baseUrl = sys_config('site_url');
|
||||||
$qrcodeService->scanQrcode($message->Ticket, 'ticket');
|
if (in_array(strtolower($thirdType[0]), ['spread', 'agent', 'wechatqrcode', 'product', 'combination', 'seckill', 'bargain', 'pink'])) {
|
||||||
if (strtolower($qrInfo['third_type']) == 'spread') {
|
//扫码需要生成用户流程
|
||||||
try {
|
$spreadUid = $qrInfo['third_id'];
|
||||||
$spreadUid = $qrInfo['third_id'];
|
$spreadInfo = $userService->get($spreadUid);
|
||||||
$wechatUser->saveUser($message->FromUserName);
|
$is_new = $wechatUser->saveUser($message->FromUserName);
|
||||||
$uid = $wechatUser->getFieldValue($message->FromUserName, 'openid', 'uid', ['user_type', '<>', 'h5']);
|
$uid = $wechatUser->getFieldValue($message->FromUserName, 'openid', 'uid', ['user_type', '<>', 'h5']);
|
||||||
if ($spreadUid == $uid) return '自己不能推荐自己';
|
$userInfo = $userService->get($uid);
|
||||||
$userInfo = $userService->get($uid);
|
|
||||||
if ($userInfo['spread_uid']) return '已有推荐人!';
|
|
||||||
$userInfo->spread_uid = $spreadUid;
|
|
||||||
$userInfo->spread_time = time();
|
|
||||||
if (!$userInfo->save()) {
|
|
||||||
return '绑定推荐人失败!';
|
|
||||||
}
|
|
||||||
} catch (\Exception $e) {
|
|
||||||
$response = $e->getMessage();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (strtolower($qrInfo['third_type']) == 'agent') {
|
|
||||||
try {
|
try {
|
||||||
$spreadUid = $qrInfo['third_id'];
|
switch (strtolower($thirdType[0])) {
|
||||||
$spreadInfo = $userService->get($spreadUid);
|
case 'spread':
|
||||||
$is_new = $wechatUser->saveUser($message->FromUserName);
|
if ($spreadUid == $uid) {
|
||||||
$uid = $wechatUser->getFieldValue($message->FromUserName, 'openid', 'uid', ['user_type', '<>', 'h5']);
|
$response = '自己不能推荐自己';
|
||||||
$userInfo = $userService->get($uid);
|
} else if (!$userInfo) {
|
||||||
if ($spreadUid == $uid) {
|
$response = '用户不存在';
|
||||||
$response = '自己不能推荐自己';
|
} else if (!$spreadInfo) {
|
||||||
} else if (!$userInfo) {
|
$response = '上级用户不存在';
|
||||||
$response = '用户不存在';
|
} else if ($userInfo['spread_uid']) {
|
||||||
} else if (!$spreadInfo) {
|
$response = '已有推荐人!';
|
||||||
$response = '上级用户不存在';
|
} else if (!$loginService->updateUserInfo(['code' => $spreadUid], $userInfo, $is_new)) {
|
||||||
} else if ($userInfo->is_division) {
|
$response = '绑定推荐人失败!';
|
||||||
$response = '您是事业部,不能绑定成为别人的员工';
|
}
|
||||||
} else if ($userInfo->is_agent) {
|
$wechatNews['title'] = sys_config('site_name');
|
||||||
$response = '您是代理商,不能绑定成为别人的员工';
|
$wechatNews['image'] = sys_config('wap_login_logo');
|
||||||
} else if ($loginService->updateUserInfo(['code' => $spreadUid, 'is_staff' => 1], $userInfo, $is_new)) {
|
$wechatNews['url'] = $baseUrl . '/pages/index/index';
|
||||||
$response = '绑定店员成功!';
|
$loginService->updateUserInfo(['code' => $spreadUid], $userInfo, $is_new);
|
||||||
|
$messages = WechatService::newsMessage($wechatNews);
|
||||||
|
WechatService::staffService()->message($messages)->to($message->FromUserName)->send();
|
||||||
|
break;
|
||||||
|
case 'agent':
|
||||||
|
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 = '绑定店员成功!';
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'wechatqrcode':
|
||||||
|
/** @var WechatQrcodeServices $wechatQrcodeService */
|
||||||
|
$wechatQrcodeService = app()->make(WechatQrcodeServices::class);
|
||||||
|
//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);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'product':
|
||||||
|
/** @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();
|
||||||
|
break;
|
||||||
|
case 'combination':
|
||||||
|
/** @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();
|
||||||
|
break;
|
||||||
|
case 'seckill':
|
||||||
|
/** @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();
|
||||||
|
break;
|
||||||
|
case 'bargain':
|
||||||
|
/** @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();
|
||||||
|
break;
|
||||||
|
case 'pink':
|
||||||
|
/** @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();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
} catch (\Exception $e) {
|
} catch (\Throwable $e) {
|
||||||
$response = $e->getMessage();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (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, 1);
|
|
||||||
}
|
|
||||||
} catch (\Exception $e) {
|
|
||||||
$response = $e->getMessage();
|
$response = $e->getMessage();
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
//扫码不生成用户流程
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -158,7 +158,7 @@ class DeliveryServiceServices extends BaseServices
|
|||||||
*/
|
*/
|
||||||
public function saveDeliveryService(array $data)
|
public function saveDeliveryService(array $data)
|
||||||
{
|
{
|
||||||
if ($data['image'] == '') throw new AdminException(400466);
|
if ($data['image'] == '') throw new AdminException(400250);
|
||||||
$data['uid'] = $data['image']['uid'];
|
$data['uid'] = $data['image']['uid'];
|
||||||
/** @var UserServices $userService */
|
/** @var UserServices $userService */
|
||||||
$userService = app()->make(UserServices::class);
|
$userService = app()->make(UserServices::class);
|
||||||
|
|||||||
@ -336,15 +336,14 @@ class OtherOrderServices extends BaseServices
|
|||||||
$capitalFlowServices->setFlow($orderInfo, $type);
|
$capitalFlowServices->setFlow($orderInfo, $type);
|
||||||
}
|
}
|
||||||
$res = $res1 && $res2 && $res3 && $res4;
|
$res = $res1 && $res2 && $res3 && $res4;
|
||||||
|
|
||||||
//购买付费会员返佣设置
|
//购买付费会员返佣设置
|
||||||
if (sys_config('member_brokerage', 0) == 1 && sys_config('brokerage_func_status', 0) == 1) {
|
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_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_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_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);
|
$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_one && $spread_one_price > 0) $this->memberBrokerage($spread_one, $spread_one_price, sys_config('is_self_brokerage') ? 'get_self_member_brokerage' : 'get_member_brokerage', $orderInfo);
|
||||||
if ($spread_two && $spread_two_price > 0) $this->memberBrokerage($spread_two, $spread_two_price, 'get_two_brokerage', $orderInfo);
|
if ($spread_two && $spread_two_price > 0) $this->memberBrokerage($spread_two, $spread_two_price, 'get_two_member_brokerage', $orderInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
return false !== $res;
|
return false !== $res;
|
||||||
@ -375,8 +374,8 @@ class OtherOrderServices extends BaseServices
|
|||||||
$userBrokerageServices = app()->make(UserBrokerageServices::class);
|
$userBrokerageServices = app()->make(UserBrokerageServices::class);
|
||||||
$userBrokerageServices->income($type, $uid, [
|
$userBrokerageServices->income($type, $uid, [
|
||||||
'nickname' => $userInfo['nickname'],
|
'nickname' => $userInfo['nickname'],
|
||||||
'pay_price' => floatval($price),
|
'pay_price' => floatval($orderInfo['pay_price']),
|
||||||
'number' => floatval($userInfo['brokerage_price']),
|
'number' => floatval($price),
|
||||||
'frozen_time' => $frozen_time
|
'frozen_time' => $frozen_time
|
||||||
], $balance, $orderInfo['id']);
|
], $balance, $orderInfo['id']);
|
||||||
}
|
}
|
||||||
@ -563,6 +562,9 @@ class OtherOrderServices extends BaseServices
|
|||||||
case "alipay" :
|
case "alipay" :
|
||||||
$v['pay_type'] = "支付宝";
|
$v['pay_type'] = "支付宝";
|
||||||
break;
|
break;
|
||||||
|
case 'allinpay':
|
||||||
|
$v['pay_type'] = "通联支付";
|
||||||
|
break;
|
||||||
case "admin" :
|
case "admin" :
|
||||||
$v['pay_type'] = "后台赠送";
|
$v['pay_type'] = "后台赠送";
|
||||||
break;
|
break;
|
||||||
|
|||||||
@ -208,9 +208,6 @@ class StoreCartServices extends BaseServices
|
|||||||
if ($product_stock < $cartNum) {
|
if ($product_stock < $cartNum) {
|
||||||
throw new ApiException(410297, ['num' => $cartNum]);
|
throw new ApiException(410297, ['num' => $cartNum]);
|
||||||
}
|
}
|
||||||
if ($type != 5 && !CacheService::checkStock($unique, (int)$cartNum, $type)) {
|
|
||||||
throw new ApiException(410297, ['num' => $cartNum]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return [$attrInfo, $unique, $bargainUserInfo['bargain_price_min'] ?? 0, $cartNum, $productInfo];
|
return [$attrInfo, $unique, $bargainUserInfo['bargain_price_min'] ?? 0, $cartNum, $productInfo];
|
||||||
}
|
}
|
||||||
@ -435,6 +432,9 @@ class StoreCartServices extends BaseServices
|
|||||||
*/
|
*/
|
||||||
public function setCartNum($uid, $productId, $num, $unique, $type)
|
public function setCartNum($uid, $productId, $num, $unique, $type)
|
||||||
{
|
{
|
||||||
|
//检查限购
|
||||||
|
$this->checkLimit($uid, $productId, $num, 0);
|
||||||
|
|
||||||
/** @var StoreProductAttrValueServices $attrValueServices */
|
/** @var StoreProductAttrValueServices $attrValueServices */
|
||||||
$attrValueServices = app()->make(StoreProductAttrValueServices::class);
|
$attrValueServices = app()->make(StoreProductAttrValueServices::class);
|
||||||
|
|
||||||
@ -444,7 +444,7 @@ class StoreCartServices extends BaseServices
|
|||||||
/** @var StoreProductServices $productServices */
|
/** @var StoreProductServices $productServices */
|
||||||
$productServices = app()->make(StoreProductServices::class);
|
$productServices = app()->make(StoreProductServices::class);
|
||||||
|
|
||||||
if (!$productServices->isValidProduct((int)$productId)) {
|
if (!$productServices->isValidProduct((int)$productId, 'id')) {
|
||||||
throw new ApiException(410295);
|
throw new ApiException(410295);
|
||||||
}
|
}
|
||||||
if (!($unique && $attrValueServices->getAttrvalueCount($productId, $unique, 0))) {
|
if (!($unique && $attrValueServices->getAttrvalueCount($productId, $unique, 0))) {
|
||||||
@ -540,7 +540,14 @@ class StoreCartServices extends BaseServices
|
|||||||
* @param int $uid
|
* @param int $uid
|
||||||
* @param array $cartList
|
* @param array $cartList
|
||||||
* @param array $addr
|
* @param array $addr
|
||||||
|
* @param int $shipping_type
|
||||||
* @return array
|
* @return array
|
||||||
|
* @throws \think\db\exception\DataNotFoundException
|
||||||
|
* @throws \think\db\exception\DbException
|
||||||
|
* @throws \think\db\exception\ModelNotFoundException
|
||||||
|
* @author 吴汐
|
||||||
|
* @email 442384644@qq.com
|
||||||
|
* @date 2023/02/16
|
||||||
*/
|
*/
|
||||||
public function handleCartList(int $uid, array $cartList, array $addr = [], int $shipping_type = 1)
|
public function handleCartList(int $uid, array $cartList, array $addr = [], int $shipping_type = 1)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -82,11 +82,6 @@ class StoreOrderComputedServices extends BaseServices
|
|||||||
$offlinePayStatus = (int)sys_config('offline_pay_status') ?? (int)2;
|
$offlinePayStatus = (int)sys_config('offline_pay_status') ?? (int)2;
|
||||||
$systemPayType = PayServices::PAY_TYPE;
|
$systemPayType = PayServices::PAY_TYPE;
|
||||||
if ($offlinePayStatus == 2) unset($systemPayType['offline']);
|
if ($offlinePayStatus == 2) unset($systemPayType['offline']);
|
||||||
if (strtolower($payType) != 'pc' && strtolower($payType) != 'friend') {
|
|
||||||
if (!array_key_exists($payType, $systemPayType)) {
|
|
||||||
throw new ApiException(410241);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!$userInfo) {
|
if (!$userInfo) {
|
||||||
/** @var UserServices $userServices */
|
/** @var UserServices $userServices */
|
||||||
$userServices = app()->make(UserServices::class);
|
$userServices = app()->make(UserServices::class);
|
||||||
@ -453,7 +448,7 @@ class StoreOrderComputedServices extends BaseServices
|
|||||||
}
|
}
|
||||||
//会员邮费享受折扣
|
//会员邮费享受折扣
|
||||||
if ($storePostage) {
|
if ($storePostage) {
|
||||||
$express_rule_number = 0;
|
$express_rule_number = 100;
|
||||||
if (!$userInfo) {
|
if (!$userInfo) {
|
||||||
/** @var UserServices $userService */
|
/** @var UserServices $userService */
|
||||||
$userService = app()->make(UserServices::class);
|
$userService = app()->make(UserServices::class);
|
||||||
@ -487,25 +482,27 @@ class StoreOrderComputedServices extends BaseServices
|
|||||||
$tempNumber = $temp_num[$tempId]['number'] ?? 0;
|
$tempNumber = $temp_num[$tempId]['number'] ?? 0;
|
||||||
if (!$tempId || !$tempPostage || !$tempNumber) continue;
|
if (!$tempId || !$tempPostage || !$tempNumber) continue;
|
||||||
$type = $temp_num[$tempId]['type'];
|
$type = $temp_num[$tempId]['type'];
|
||||||
$cartNumber = $item['cart_num'];
|
|
||||||
if ((($cartAlready[$tempId]['number'] ?? 0) + $cartNumber) >= $tempNumber) {
|
|
||||||
|
if ($type == 1) {
|
||||||
|
$num = $item['cart_num'];
|
||||||
|
} elseif ($type == 2) {
|
||||||
|
$num = $item['cart_num'] * $item['productInfo']['attrInfo']['weight'];
|
||||||
|
} else {
|
||||||
|
$num = $item['cart_num'] * $item['productInfo']['attrInfo']['volume'];
|
||||||
|
}
|
||||||
|
if ((($cartAlready[$tempId]['number'] ?? 0) + $num) >= $tempNumber) {
|
||||||
$price = isset($cartAlready[$tempId]['price']) ? bcsub((string)$tempPostage, (string)$cartAlready[$tempId]['price'], 6) : $tempPostage;
|
$price = isset($cartAlready[$tempId]['price']) ? bcsub((string)$tempPostage, (string)$cartAlready[$tempId]['price'], 6) : $tempPostage;
|
||||||
} else {
|
} else {
|
||||||
$price = bcmul((string)$tempPostage, bcdiv((string)$cartNumber, (string)$tempNumber, 6), 6);
|
$price = bcmul((string)$tempPostage, bcdiv((string)$num, (string)$tempNumber, 6), 6);
|
||||||
}
|
}
|
||||||
$cartAlready[$tempId]['number'] = bcadd((string)($cartNumber[$tempId]['number'] ?? 0), (string)$cartNumber, 4);
|
$cartAlready[$tempId]['number'] = bcadd((string)($cartAlready[$tempId]['number'] ?? 0), (string)$num, 4);
|
||||||
$cartAlready[$tempId]['price'] = bcadd((string)($cartNumber[$tempId]['price'] ?? 0.00), (string)$price, 4);
|
$cartAlready[$tempId]['price'] = bcadd((string)($cartAlready[$tempId]['price'] ?? 0.00), (string)$price, 4);
|
||||||
|
|
||||||
if ($express_rule_number && $express_rule_number < 100) {
|
if ($express_rule_number && $express_rule_number < 100) {
|
||||||
$price = bcmul($price, $discountRate, 4);
|
$price = bcmul($price, $discountRate, 4);
|
||||||
}
|
}
|
||||||
if ($type == 2) {
|
$item['postage_price'] = sprintf("%.2f", $price);
|
||||||
$price = bcmul($price, $item['productInfo']['attrInfo']['weight'], 6);
|
|
||||||
} elseif ($type == 3) {
|
|
||||||
$price = bcmul($price, $item['productInfo']['attrInfo']['volume'], 6);
|
|
||||||
}
|
|
||||||
$price = sprintf("%.2f", $price);
|
|
||||||
$item['postage_price'] = $price;
|
|
||||||
}
|
}
|
||||||
if ($express_rule_number && $express_rule_number < 100) {
|
if ($express_rule_number && $express_rule_number < 100) {
|
||||||
$storePostageDiscount = $storePostage;
|
$storePostageDiscount = $storePostage;
|
||||||
|
|||||||
@ -13,17 +13,21 @@ namespace app\services\order;
|
|||||||
|
|
||||||
|
|
||||||
use app\services\activity\advance\StoreAdvanceServices;
|
use app\services\activity\advance\StoreAdvanceServices;
|
||||||
|
use app\services\activity\combination\StorePinkServices;
|
||||||
use app\services\agent\AgentLevelServices;
|
use app\services\agent\AgentLevelServices;
|
||||||
use app\services\activity\coupon\StoreCouponUserServices;
|
use app\services\activity\coupon\StoreCouponUserServices;
|
||||||
use app\services\agent\DivisionServices;
|
use app\services\agent\DivisionServices;
|
||||||
use app\services\pay\PayServices;
|
use app\services\pay\PayServices;
|
||||||
|
use app\services\pc\OrderServices;
|
||||||
use app\services\product\product\StoreCategoryServices;
|
use app\services\product\product\StoreCategoryServices;
|
||||||
use app\services\shipping\ShippingTemplatesFreeServices;
|
use app\services\shipping\ShippingTemplatesFreeServices;
|
||||||
use app\services\shipping\ShippingTemplatesRegionServices;
|
use app\services\shipping\ShippingTemplatesRegionServices;
|
||||||
use app\services\shipping\ShippingTemplatesServices;
|
use app\services\shipping\ShippingTemplatesServices;
|
||||||
|
use app\services\user\UserInvoiceServices;
|
||||||
use app\services\wechat\WechatUserServices;
|
use app\services\wechat\WechatUserServices;
|
||||||
use app\services\BaseServices;
|
use app\services\BaseServices;
|
||||||
use crmeb\exceptions\ApiException;
|
use crmeb\exceptions\ApiException;
|
||||||
|
use crmeb\exceptions\ApiStatusException;
|
||||||
use crmeb\services\CacheService;
|
use crmeb\services\CacheService;
|
||||||
use app\dao\order\StoreOrderDao;
|
use app\dao\order\StoreOrderDao;
|
||||||
use app\services\user\UserServices;
|
use app\services\user\UserServices;
|
||||||
@ -64,12 +68,18 @@ class StoreOrderCreateServices extends BaseServices
|
|||||||
$snowflake = new \Godruoyi\Snowflake\Snowflake();
|
$snowflake = new \Godruoyi\Snowflake\Snowflake();
|
||||||
|
|
||||||
if (Config::get('cache.default') == 'file') {
|
if (Config::get('cache.default') == 'file') {
|
||||||
//32位
|
//32位
|
||||||
if (PHP_INT_SIZE == 4) {
|
if (PHP_INT_SIZE == 4) {
|
||||||
$id = abs($snowflake->id());
|
$id = abs($snowflake->id());
|
||||||
} else {
|
} else {
|
||||||
$id = $snowflake->setStartTimeStamp(strtotime('2022-01-01') * 1000)->id();
|
$id = $snowflake->setStartTimeStamp(strtotime('2022-01-01') * 1000)->id();
|
||||||
}
|
}
|
||||||
|
$replace = '';
|
||||||
|
$chars = 'abcdefghijklmnopqrstuvwxyz0123456789';
|
||||||
|
for ($i = 0; $i < 3; $i++) {
|
||||||
|
$replace .= $chars[mt_rand(0, strlen($chars) - 1)];
|
||||||
|
}
|
||||||
|
$id = substr_replace($id, $replace, -3);
|
||||||
} else {
|
} else {
|
||||||
$is_callable = function ($currentTime) {
|
$is_callable = function ($currentTime) {
|
||||||
$redis = Cache::store('redis');
|
$redis = Cache::store('redis');
|
||||||
@ -109,31 +119,62 @@ class StoreOrderCreateServices extends BaseServices
|
|||||||
* 创建订单
|
* 创建订单
|
||||||
* @param $uid
|
* @param $uid
|
||||||
* @param $key
|
* @param $key
|
||||||
* @param $cartGroup
|
|
||||||
* @param $userInfo
|
* @param $userInfo
|
||||||
* @param $addressId
|
* @param $addressId
|
||||||
* @param $payType
|
* @param $payType
|
||||||
* @param bool $useIntegral
|
* @param false $useIntegral
|
||||||
* @param int $couponId
|
* @param int $couponId
|
||||||
* @param string $mark
|
* @param string $mark
|
||||||
* @param int $combinationId
|
* @param int $combinationId
|
||||||
* @param int $pinkId
|
* @param int $pinkId
|
||||||
* @param int $seckillId
|
* @param int $seckillId
|
||||||
* @param int $bargainId
|
* @param int $bargainId
|
||||||
* @param int $isChannel
|
|
||||||
* @param int $shippingType
|
* @param int $shippingType
|
||||||
* @param string $real_name
|
* @param string $real_name
|
||||||
* @param string $phone
|
* @param string $phone
|
||||||
* @param int $storeId
|
* @param int $storeId
|
||||||
* @param bool $news
|
* @param false $news
|
||||||
|
* @param int $advanceId
|
||||||
|
* @param array $customForm
|
||||||
|
* @param int $invoice_id
|
||||||
* @return mixed
|
* @return mixed
|
||||||
* @throws \Psr\SimpleCache\InvalidArgumentException
|
|
||||||
* @throws \think\db\exception\DataNotFoundException
|
* @throws \think\db\exception\DataNotFoundException
|
||||||
* @throws \think\db\exception\DbException
|
* @throws \think\db\exception\DbException
|
||||||
* @throws \think\db\exception\ModelNotFoundException
|
* @throws \think\db\exception\ModelNotFoundException
|
||||||
|
* @author 吴汐
|
||||||
|
* @email 442384644@qq.com
|
||||||
|
* @date 2023/03/01
|
||||||
*/
|
*/
|
||||||
public function createOrder($uid, $key, $cartGroup, $userInfo, $addressId, $payType, $useIntegral = false, $couponId = 0, $mark = '', $combinationId = 0, $pinkId = 0, $seckillId = 0, $bargainId = 0, $isChannel = 0, $shippingType = 1, $real_name = '', $phone = '', $storeId = 0, $news = false, $advanceId = 0, $virtual_type = 0, $customForm = [])
|
public function createOrder($uid, $key, $userInfo, $addressId, $payType, $useIntegral = false, $couponId = 0, $mark = '', $combinationId = 0, $pinkId = 0, $seckillId = 0, $bargainId = 0, $shippingType = 1, $real_name = '', $phone = '', $storeId = 0, $news = false, $advanceId = 0, $customForm = [], $invoice_id = 0)
|
||||||
{
|
{
|
||||||
|
/** @var StoreOrderServices $orderService */
|
||||||
|
$storeOrderServices = app()->make(StoreOrderServices::class);
|
||||||
|
$bargainServices = app()->make(StoreBargainServices::class);
|
||||||
|
$cartGroup = $storeOrderServices->getCacheOrderInfo($uid, $key);
|
||||||
|
if (!$cartGroup) {
|
||||||
|
throw new ApiException(410208);
|
||||||
|
}
|
||||||
|
//下单前砍价验证
|
||||||
|
if ($bargainId) {
|
||||||
|
$bargainServices->checkBargainUser((int)$bargainId, $uid);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($pinkId) {
|
||||||
|
$pinkId = (int)$pinkId;
|
||||||
|
/** @var StorePinkServices $pinkServices */
|
||||||
|
$pinkServices = app()->make(StorePinkServices::class);
|
||||||
|
if ($pinkServices->isPink($pinkId, $uid))
|
||||||
|
throw new ApiStatusException('ORDER_EXIST', 410210, ['orderId' => $storeOrderServices->getStoreIdPink($pinkId, $uid)]);
|
||||||
|
if ($storeOrderServices->getIsOrderPink($pinkId, $uid))
|
||||||
|
throw new ApiStatusException('ORDER_EXIST', 410211, ['orderId' => $storeOrderServices->getStoreIdPink($pinkId, $uid)]);
|
||||||
|
}
|
||||||
|
$virtual_type = $cartGroup['cartInfo'][0]['productInfo']['virtual_type'] ?? 0;
|
||||||
|
|
||||||
|
//下单前发票验证
|
||||||
|
if ($invoice_id) {
|
||||||
|
app()->make(UserInvoiceServices::class)->checkInvoice((int)$invoice_id, $uid);
|
||||||
|
}
|
||||||
|
|
||||||
/** @var StoreOrderComputedServices $computedServices */
|
/** @var StoreOrderComputedServices $computedServices */
|
||||||
$computedServices = app()->make(StoreOrderComputedServices::class);
|
$computedServices = app()->make(StoreOrderComputedServices::class);
|
||||||
$priceData = $computedServices->computedOrder($uid, $userInfo, $cartGroup, $addressId, $payType, $useIntegral, $couponId, true, $shippingType);
|
$priceData = $computedServices->computedOrder($uid, $userInfo, $cartGroup, $addressId, $payType, $useIntegral, $couponId, true, $shippingType);
|
||||||
@ -183,11 +224,6 @@ class StoreOrderCreateServices extends BaseServices
|
|||||||
if ($deduction) {
|
if ($deduction) {
|
||||||
$couponId = 0;
|
$couponId = 0;
|
||||||
$useIntegral = false;
|
$useIntegral = false;
|
||||||
$systemPayType = PayServices::PAY_TYPE;
|
|
||||||
unset($systemPayType['offline']);
|
|
||||||
if ($payType != 'pc' && !array_key_exists($payType, $systemPayType)) {
|
|
||||||
throw new ApiException(410246);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
//$shipping_type = 1 快递发货 $shipping_type = 2 门店自提
|
//$shipping_type = 1 快递发货 $shipping_type = 2 门店自提
|
||||||
$storeSelfMention = sys_config('store_self_mention') ?? 0;
|
$storeSelfMention = sys_config('store_self_mention') ?? 0;
|
||||||
@ -219,7 +255,6 @@ class StoreOrderCreateServices extends BaseServices
|
|||||||
'bargain_id' => $bargainId,
|
'bargain_id' => $bargainId,
|
||||||
'advance_id' => $advance_id,
|
'advance_id' => $advance_id,
|
||||||
'cost' => $priceGroup['costPrice'],
|
'cost' => $priceGroup['costPrice'],
|
||||||
'is_channel' => $isChannel,
|
|
||||||
'add_time' => time(),
|
'add_time' => time(),
|
||||||
'unique' => $key,
|
'unique' => $key,
|
||||||
'shipping_type' => $shippingType,
|
'shipping_type' => $shippingType,
|
||||||
@ -259,8 +294,6 @@ class StoreOrderCreateServices extends BaseServices
|
|||||||
/** @var UserServices $userService */
|
/** @var UserServices $userService */
|
||||||
$userService = app()->make(UserServices::class);
|
$userService = app()->make(UserServices::class);
|
||||||
$userService->update(['uid' => $uid], ['real_name' => $orderInfo['real_name'], 'record_phone' => $orderInfo['user_phone']]);
|
$userService->update(['uid' => $uid], ['real_name' => $orderInfo['real_name'], 'record_phone' => $orderInfo['user_phone']]);
|
||||||
//占用库存
|
|
||||||
$seckillServices->occupySeckillStock($cartInfo, $key);
|
|
||||||
//积分抵扣
|
//积分抵扣
|
||||||
if ($priceData['usedIntegral'] > 0) {
|
if ($priceData['usedIntegral'] > 0) {
|
||||||
$this->deductIntegral($userInfo, $useIntegral, $priceData, (int)$userInfo['uid'], $order['id']);
|
$this->deductIntegral($userInfo, $useIntegral, $priceData, (int)$userInfo['uid'], $order['id']);
|
||||||
@ -272,10 +305,15 @@ class StoreOrderCreateServices extends BaseServices
|
|||||||
return $order;
|
return $order;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
//创建开票数据
|
||||||
|
if ($invoice_id) {
|
||||||
|
app()->make(StoreOrderInvoiceServices::class)->makeUp($uid, $order['order_id'], (int)$invoice_id);
|
||||||
|
}
|
||||||
|
|
||||||
// 订单创建成功后置事件
|
// 订单创建成功后置事件
|
||||||
event('order.orderCreateAfter', [$order, compact('cartInfo', 'priceData', 'addressId', 'cartIds', 'news'), $uid, $key, $combinationId, $seckillId, $bargainId]);
|
event('OrderCreateAfterListener', [$order, compact('cartInfo', 'priceData', 'addressId', 'cartIds', 'news'), $uid, $key, $combinationId, $seckillId, $bargainId]);
|
||||||
// 推送订单
|
// 推送订单
|
||||||
event('out.outPush', ['order_create_push', ['order_id' => (int)$order['id']]]);
|
event('OutPushListener', ['order_create_push', ['order_id' => (int)$order['id']]]);
|
||||||
return $order;
|
return $order;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -450,10 +488,8 @@ class StoreOrderCreateServices extends BaseServices
|
|||||||
$cart['coupon_price'] = 0.00;
|
$cart['coupon_price'] = 0.00;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
[$cartInfo, $spread_ids] = $this->computeOrderProductBrokerage($uid, $cartInfo, $orderInfo);
|
|
||||||
$cartInfo = $this->computeOrderProductCoupon($cartInfo, $priceData);
|
$cartInfo = $this->computeOrderProductCoupon($cartInfo, $priceData);
|
||||||
$cartInfo = $this->computeOrderProductIntegral($cartInfo, $priceData);
|
$cartInfo = $this->computeOrderProductIntegral($cartInfo, $priceData);
|
||||||
// $cartInfo = $this->computeOrderProductPostage($cartInfo, $priceData, $addressId);
|
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
Log::error('订单商品结算失败,File:' . $e->getFile() . ',Line:' . $e->getLine() . ',Message:' . $e->getMessage());
|
Log::error('订单商品结算失败,File:' . $e->getFile() . ',Line:' . $e->getLine() . ',Message:' . $e->getMessage());
|
||||||
throw new ApiException(410248);
|
throw new ApiException(410248);
|
||||||
@ -475,6 +511,12 @@ class StoreOrderCreateServices extends BaseServices
|
|||||||
$cart['truePrice'] = $cart['truePrice'] > $uni_integral_price ? bcsub((string)$cart['truePrice'], $uni_integral_price, 2) : 0;
|
$cart['truePrice'] = $cart['truePrice'] > $uni_integral_price ? bcsub((string)$cart['truePrice'], $uni_integral_price, 2) : 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
try {
|
||||||
|
[$cartInfo, $spread_ids] = $this->computeOrderProductBrokerage($uid, $cartInfo, $orderInfo);
|
||||||
|
} catch (\Throwable $e) {
|
||||||
|
Log::error('订单商品结算失败,File:' . $e->getFile() . ',Line:' . $e->getLine() . ',Message:' . $e->getMessage());
|
||||||
|
throw new ApiException(410248);
|
||||||
|
}
|
||||||
return [$cartInfo, $spread_ids];
|
return [$cartInfo, $spread_ids];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -756,20 +798,27 @@ class StoreOrderCreateServices extends BaseServices
|
|||||||
$productInfo = $cart['productInfo'];
|
$productInfo = $cart['productInfo'];
|
||||||
|
|
||||||
//计算商品金额
|
//计算商品金额
|
||||||
if (isset($productInfo['attrInfo'])) {
|
if (sys_config('user_brokerage_type') == 1) {
|
||||||
$price = bcmul((string)($productInfo['attrInfo']['price'] ?? '0'), $cartNum, 4);
|
//按照实际支付价格返佣
|
||||||
|
$price = bcmul((string)$cart['truePrice'], $cartNum, 4);
|
||||||
} else {
|
} else {
|
||||||
$price = bcmul((string)($productInfo['price'] ?? '0'), $cartNum, 4);
|
//按照商品价格返佣
|
||||||
|
if (isset($productInfo['attrInfo'])) {
|
||||||
|
$price = bcmul((string)($productInfo['attrInfo']['price'] ?? '0'), $cartNum, 4);
|
||||||
|
} else {
|
||||||
|
$price = bcmul((string)($productInfo['price'] ?? '0'), $cartNum, 4);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$staffBrokerage = bcmul((string)$price, (string)bcdiv($staffPercent, 100, 4), 2);
|
$staffBrokerage = bcmul((string)$price, (string)bcdiv($staffPercent, 100, 4), 2);
|
||||||
$agentBrokerage = bcmul((string)$price, (string)bcdiv($agentPercent, 100, 4), 2);
|
$agentBrokerage = bcmul((string)$price, (string)bcdiv($agentPercent, 100, 4), 2);
|
||||||
$divisionBrokerage = bcmul((string)$price, (string)bcdiv($divisionPercent, 100, 4), 2);
|
$divisionBrokerage = bcmul((string)$price, (string)bcdiv($divisionPercent, 100, 4), 2);
|
||||||
|
|
||||||
//指定返佣金额
|
//指定返佣金额
|
||||||
if (isset($productInfo['is_sub']) && $productInfo['is_sub'] == 1) {
|
if (isset($productInfo['is_sub']) && $productInfo['is_sub'] == 1) {
|
||||||
$oneBrokerage = $storeBrokerageRatio > 0 ? bcmul((string)($productInfo['attrInfo']['brokerage'] ?? '0'), $cartNum, 2) : 0;
|
$oneBrokerage = bcmul((string)($productInfo['attrInfo']['brokerage'] ?? '0'), $cartNum, 2);
|
||||||
$twoBrokerage = $storeBrokerageTwo > 0 ? bcmul((string)($productInfo['attrInfo']['brokerage_two'] ?? '0'), $cartNum, 2) : 0;
|
$twoBrokerage = bcmul((string)($productInfo['attrInfo']['brokerage_two'] ?? '0'), $cartNum, 2);
|
||||||
} else {
|
} else {
|
||||||
if ($price) {
|
if ($price) {
|
||||||
//一级返佣比例 小于等于零时直接返回 不返佣
|
//一级返佣比例 小于等于零时直接返回 不返佣
|
||||||
@ -794,6 +843,7 @@ class StoreOrderCreateServices extends BaseServices
|
|||||||
$cart['agent_brokerage'] = $agentBrokerage;
|
$cart['agent_brokerage'] = $agentBrokerage;
|
||||||
$cart['division_brokerage'] = $divisionBrokerage;
|
$cart['division_brokerage'] = $divisionBrokerage;
|
||||||
}
|
}
|
||||||
|
|
||||||
return [$cartInfo, [$spread_one_uid, $spread_two_uid]];
|
return [$cartInfo, [$spread_one_uid, $spread_two_uid]];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -364,6 +364,12 @@ class StoreOrderDeliveryServices extends BaseServices
|
|||||||
* @param int $id
|
* @param int $id
|
||||||
* @param array $data
|
* @param array $data
|
||||||
* @return bool
|
* @return bool
|
||||||
|
* @throws \think\db\exception\DataNotFoundException
|
||||||
|
* @throws \think\db\exception\DbException
|
||||||
|
* @throws \think\db\exception\ModelNotFoundException
|
||||||
|
* @author 吴汐
|
||||||
|
* @email 442384644@qq.com
|
||||||
|
* @date 2023/02/21
|
||||||
*/
|
*/
|
||||||
public function splitDelivery(int $id, array $data)
|
public function splitDelivery(int $id, array $data)
|
||||||
{
|
{
|
||||||
@ -396,10 +402,8 @@ class StoreOrderDeliveryServices extends BaseServices
|
|||||||
}
|
}
|
||||||
|
|
||||||
$cart_ids = $data['cart_ids'];
|
$cart_ids = $data['cart_ids'];
|
||||||
/** @var StoreOrderCartInfoServices $storeOrderCartInfoServices */
|
|
||||||
$storeOrderCartInfoServices = app()->make(StoreOrderCartInfoServices::class);
|
|
||||||
unset($data['cart_ids']);
|
unset($data['cart_ids']);
|
||||||
$this->transaction(function () use ($id, $cart_ids, $orderInfo, $data, $storeOrderCartInfoServices) {
|
$this->transaction(function () use ($id, $cart_ids, $orderInfo, $data) {
|
||||||
/** @var StoreOrderSplitServices $storeOrderSplitServices */
|
/** @var StoreOrderSplitServices $storeOrderSplitServices */
|
||||||
$storeOrderSplitServices = app()->make(StoreOrderSplitServices::class);
|
$storeOrderSplitServices = app()->make(StoreOrderSplitServices::class);
|
||||||
//订单拆单
|
//订单拆单
|
||||||
@ -440,11 +444,11 @@ class StoreOrderDeliveryServices extends BaseServices
|
|||||||
switch ($type) {
|
switch ($type) {
|
||||||
case 1://快递发货
|
case 1://快递发货
|
||||||
$this->orderDeliverGoods($id, $data, $orderInfo, $storeName);
|
$this->orderDeliverGoods($id, $data, $orderInfo, $storeName);
|
||||||
event('notice.notice', [['orderInfo' => $orderInfo, 'storeName' => $storeName, 'data' => $data], 'order_postage_success']);
|
event('NoticeListener', [['orderInfo' => $orderInfo, 'storeName' => $storeName, 'data' => $data], 'order_postage_success']);
|
||||||
break;
|
break;
|
||||||
case 2://配送
|
case 2://配送
|
||||||
$this->orderDelivery($id, $data, $orderInfo, $storeName);
|
$this->orderDelivery($id, $data, $orderInfo, $storeName);
|
||||||
event('notice.notice', [['orderInfo' => $orderInfo, 'storeName' => $storeName, 'data' => $data], 'order_deliver_success']);
|
event('NoticeListener', [['orderInfo' => $orderInfo, 'storeName' => $storeName, 'data' => $data], 'order_deliver_success']);
|
||||||
break;
|
break;
|
||||||
case 3://虚拟发货
|
case 3://虚拟发货
|
||||||
$this->orderVirtualDelivery($id, $data, $orderInfo, $storeName);
|
$this->orderVirtualDelivery($id, $data, $orderInfo, $storeName);
|
||||||
@ -453,7 +457,7 @@ class StoreOrderDeliveryServices extends BaseServices
|
|||||||
throw new AdminException(400522);
|
throw new AdminException(400522);
|
||||||
}
|
}
|
||||||
//到期自动收货
|
//到期自动收货
|
||||||
event('order.orderDelivery', [$orderInfo, $storeName, $data, $type]);
|
event('OrderDeliveryListener', [$orderInfo, $storeName, $data, $type]);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -278,7 +278,7 @@ class StoreOrderRefundServices extends BaseServices
|
|||||||
app()->make(StoreOrderInvoiceServices::class)->update(['order_id' => $order['id']], ['is_refund' => 1]);
|
app()->make(StoreOrderInvoiceServices::class)->update(['order_id' => $order['id']], ['is_refund' => 1]);
|
||||||
//订单退款记录
|
//订单退款记录
|
||||||
ProductLogJob::dispatch(['refund', ['uid' => $order['uid'], 'order_id' => $order['id']]]);
|
ProductLogJob::dispatch(['refund', ['uid' => $order['uid'], 'order_id' => $order['id']]]);
|
||||||
event('notice.notice', [['data' => $refundData, 'order' => $order], 'order_refund']);
|
event('NoticeListener', [['data' => $refundData, 'order' => $order], 'order_refund']);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -286,6 +286,12 @@ class StoreOrderRefundServices extends BaseServices
|
|||||||
* 商家同意用户退货
|
* 商家同意用户退货
|
||||||
* @param $id
|
* @param $id
|
||||||
* @return bool
|
* @return bool
|
||||||
|
* @throws \think\db\exception\DataNotFoundException
|
||||||
|
* @throws \think\db\exception\DbException
|
||||||
|
* @throws \think\db\exception\ModelNotFoundException
|
||||||
|
* @author 吴汐
|
||||||
|
* @email 442384644@qq.com
|
||||||
|
* @date 2023/02/16
|
||||||
*/
|
*/
|
||||||
public function agreeExpress($id)
|
public function agreeExpress($id)
|
||||||
{
|
{
|
||||||
@ -424,17 +430,23 @@ class StoreOrderRefundServices extends BaseServices
|
|||||||
*/
|
*/
|
||||||
public function integralAndCouponBack($order)
|
public function integralAndCouponBack($order)
|
||||||
{
|
{
|
||||||
|
/** @var StoreOrderStatusServices $statusService */
|
||||||
|
$statusService = app()->make(StoreOrderStatusServices::class);
|
||||||
$res = true;
|
$res = true;
|
||||||
//回退优惠卷 拆分子订单不退优惠券
|
//回退优惠卷 拆分子订单不退优惠券
|
||||||
if (!$order['pid'] && $order['coupon_id'] && $order['coupon_price']) {
|
if (!$order['pid'] && $order['coupon_id'] && $order['coupon_price']) {
|
||||||
/** @var StoreCouponUserServices $coumonUserServices */
|
/** @var StoreCouponUserServices $coumonUserServices */
|
||||||
$coumonUserServices = app()->make(StoreCouponUserServices::class);
|
$coumonUserServices = app()->make(StoreCouponUserServices::class);
|
||||||
$res = $res && $coumonUserServices->recoverCoupon((int)$order['coupon_id']);
|
$res = $res && $coumonUserServices->recoverCoupon((int)$order['coupon_id']);
|
||||||
|
$statusService->save([
|
||||||
|
'oid' => $order['id'],
|
||||||
|
'change_type' => 'coupon_back',
|
||||||
|
'change_message' => '商品退优惠券',
|
||||||
|
'change_time' => time()
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
//回退积分
|
//回退积分
|
||||||
$order = $this->regressionIntegral($order);
|
$order = $this->regressionIntegral($order);
|
||||||
/** @var StoreOrderStatusServices $statusService */
|
|
||||||
$statusService = app()->make(StoreOrderStatusServices::class);
|
|
||||||
$statusService->save([
|
$statusService->save([
|
||||||
'oid' => $order['id'],
|
'oid' => $order['id'],
|
||||||
'change_type' => 'integral_back',
|
'change_type' => 'integral_back',
|
||||||
@ -490,6 +502,8 @@ class StoreOrderRefundServices extends BaseServices
|
|||||||
//记录赠送积分收回
|
//记录赠送积分收回
|
||||||
$integral = $integral - $give_integral;
|
$integral = $integral - $give_integral;
|
||||||
$res2 = $userBillServices->income('integral_refund', $order['uid'], $give_integral, $integral, $order['id']);
|
$res2 = $userBillServices->income('integral_refund', $order['uid'], $give_integral, $integral, $order['id']);
|
||||||
|
//清除积分冻结
|
||||||
|
$userBillServices->update(['link_id' => $order['id']], ['frozen_time' => 0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//返还下单使用积分
|
//返还下单使用积分
|
||||||
@ -512,6 +526,10 @@ class StoreOrderRefundServices extends BaseServices
|
|||||||
* 回退库存
|
* 回退库存
|
||||||
* @param $order
|
* @param $order
|
||||||
* @return bool
|
* @return bool
|
||||||
|
* @throws \Psr\SimpleCache\InvalidArgumentException
|
||||||
|
* @author 吴汐
|
||||||
|
* @email 442384644@qq.com
|
||||||
|
* @date 2023/03/01
|
||||||
*/
|
*/
|
||||||
public function regressionStock($order)
|
public function regressionStock($order)
|
||||||
{
|
{
|
||||||
@ -519,7 +537,6 @@ class StoreOrderRefundServices extends BaseServices
|
|||||||
$combination_id = $order['combination_id'];
|
$combination_id = $order['combination_id'];
|
||||||
$seckill_id = $order['seckill_id'];
|
$seckill_id = $order['seckill_id'];
|
||||||
$bargain_id = $order['bargain_id'];
|
$bargain_id = $order['bargain_id'];
|
||||||
$advance_id = $order['advance_id'];
|
|
||||||
$res5 = true;
|
$res5 = true;
|
||||||
/** @var StoreOrderCartInfoServices $cartServices */
|
/** @var StoreOrderCartInfoServices $cartServices */
|
||||||
$cartServices = app()->make(StoreOrderCartInfoServices::class);
|
$cartServices = app()->make(StoreOrderCartInfoServices::class);
|
||||||
@ -539,20 +556,15 @@ class StoreOrderRefundServices extends BaseServices
|
|||||||
//增库存减销量
|
//增库存减销量
|
||||||
$unique = isset($cart['cart_info']['productInfo']['attrInfo']) ? $cart['cart_info']['productInfo']['attrInfo']['unique'] : '';
|
$unique = isset($cart['cart_info']['productInfo']['attrInfo']) ? $cart['cart_info']['productInfo']['attrInfo']['unique'] : '';
|
||||||
$cart_num = (int)$cart['cart_info']['cart_num'];
|
$cart_num = (int)$cart['cart_info']['cart_num'];
|
||||||
$type = 0;
|
|
||||||
if ($combination_id) {
|
if ($combination_id) {
|
||||||
$type = 3;
|
|
||||||
$res5 = $res5 && $pinkServices->incCombinationStock($cart_num, (int)$combination_id, $unique);
|
$res5 = $res5 && $pinkServices->incCombinationStock($cart_num, (int)$combination_id, $unique);
|
||||||
} else if ($seckill_id) {
|
} else if ($seckill_id) {
|
||||||
$type = 1;
|
|
||||||
$res5 = $res5 && $seckillServices->incSeckillStock($cart_num, (int)$seckill_id, $unique);
|
$res5 = $res5 && $seckillServices->incSeckillStock($cart_num, (int)$seckill_id, $unique);
|
||||||
} else if ($bargain_id) {
|
} else if ($bargain_id) {
|
||||||
$type = 2;
|
|
||||||
$res5 = $res5 && $bargainServices->incBargainStock($cart_num, (int)$bargain_id, $unique);
|
$res5 = $res5 && $bargainServices->incBargainStock($cart_num, (int)$bargain_id, $unique);
|
||||||
} else {
|
} else {
|
||||||
$res5 = $res5 && $services->incProductStock($cart_num, (int)$cart['cart_info']['productInfo']['id'], $unique);
|
$res5 = $res5 && $services->incProductStock($cart_num, (int)$cart['cart_info']['productInfo']['id'], $unique);
|
||||||
}
|
}
|
||||||
if ($type) CacheService::setStock($unique, $cart_num, $type, false);
|
|
||||||
}
|
}
|
||||||
return $res5;
|
return $res5;
|
||||||
}
|
}
|
||||||
@ -587,7 +599,7 @@ class StoreOrderRefundServices extends BaseServices
|
|||||||
$capitalFlowServices->setFlow($order, 'refund');
|
$capitalFlowServices->setFlow($order, 'refund');
|
||||||
}
|
}
|
||||||
|
|
||||||
event('notice.notice', [['data' => $data, 'order' => $order], 'order_refund']);
|
event('NoticeListener', [['data' => $data, 'order' => $order], 'order_refund']);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -681,7 +693,7 @@ class StoreOrderRefundServices extends BaseServices
|
|||||||
'change_time' => time()
|
'change_time' => time()
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
event('notice.notice', [['orderInfo' => $orderRefundInfo], 'send_order_refund_no_status']);
|
event('NoticeListener', [['orderInfo' => $orderRefundInfo], 'send_order_refund_no_status']);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -838,7 +850,7 @@ class StoreOrderRefundServices extends BaseServices
|
|||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
}
|
}
|
||||||
//提醒推送
|
//提醒推送
|
||||||
event('notice.notice', [['order' => $order], 'send_order_apply_refund']);
|
event('NoticeListener', [['order' => $order], 'send_order_apply_refund']);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
@ -992,8 +1004,6 @@ class StoreOrderRefundServices extends BaseServices
|
|||||||
$res4 = $res4 && $storeOrderCartInfoServices->update(['oid' => $id, 'cart_id' => $cart['cart_id']], ['refund_num' => (($cartInfo[$cart['cart_id']]['refund_num'] ?? 0) + $cart['cart_num'])]);
|
$res4 = $res4 && $storeOrderCartInfoServices->update(['oid' => $id, 'cart_id' => $cart['cart_id']], ['refund_num' => (($cartInfo[$cart['cart_id']]['refund_num'] ?? 0) + $cart['cart_num'])]);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
//修改原订单状态
|
|
||||||
$res2 = false !== $orderServices->update(['id' => $order['id']], ['refund_status' => 1]);
|
|
||||||
foreach ($cartInfos as $cart) {
|
foreach ($cartInfos as $cart) {
|
||||||
$res4 = $res4 && $storeOrderCartInfoServices->update(['oid' => $id, 'cart_id' => $cart['cart_id']], ['refund_num' => $cart['cart_num']]);
|
$res4 = $res4 && $storeOrderCartInfoServices->update(['oid' => $id, 'cart_id' => $cart['cart_id']], ['refund_num' => $cart['cart_num']]);
|
||||||
}
|
}
|
||||||
@ -1002,11 +1012,11 @@ class StoreOrderRefundServices extends BaseServices
|
|||||||
});
|
});
|
||||||
$storeOrderCartInfoServices->clearOrderCartInfo($order['id']);
|
$storeOrderCartInfoServices->clearOrderCartInfo($order['id']);
|
||||||
//申请退款事件
|
//申请退款事件
|
||||||
event('order.orderRefundCreateAfter', [$order]);
|
event('OrderRefundCreateAfterListener', [$order]);
|
||||||
//提醒推送
|
//提醒推送
|
||||||
event('notice.notice', [['order' => $order], 'send_order_apply_refund']);
|
event('NoticeListener', [['order' => $order], 'send_order_apply_refund']);
|
||||||
//推送订单
|
//推送订单
|
||||||
event('out.outPush', ['refund_create_push', ['order_id' => (int)$order['id']]]);
|
event('OutPushListener', ['refund_create_push', ['order_id' => (int)$order['id']]]);
|
||||||
try {
|
try {
|
||||||
ChannelService::instance()->send('NEW_REFUND_ORDER', ['order_id' => $order['order_id']]);
|
ChannelService::instance()->send('NEW_REFUND_ORDER', ['order_id' => $order['order_id']]);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
@ -1027,7 +1037,13 @@ class StoreOrderRefundServices extends BaseServices
|
|||||||
foreach ($cartInfo as $cart) {
|
foreach ($cartInfo as $cart) {
|
||||||
if (isset($cart['cart_info'])) $cart = $cart['cart_info'];
|
if (isset($cart['cart_info'])) $cart = $cart['cart_info'];
|
||||||
if ($is_unit) {
|
if ($is_unit) {
|
||||||
$SumPrice = bcadd($SumPrice, bcmul($cart['cart_num'] ?? 1, $cart[$key] ?? 0, 2), 2);
|
if ($key == 'level' || $key == 'member') {
|
||||||
|
if ($cart['price_type'] == $key) {
|
||||||
|
$SumPrice = bcadd($SumPrice, bcmul($cart['cart_num'] ?? 1, $cart['vip_truePrice'], 2), 2);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$SumPrice = bcadd($SumPrice, bcmul($cart['cart_num'] ?? 1, $cart[$key] ?? 0, 2), 2);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
$SumPrice = bcadd($SumPrice, $cart[$key] ?? 0, 2);
|
$SumPrice = bcadd($SumPrice, $cart[$key] ?? 0, 2);
|
||||||
}
|
}
|
||||||
@ -1048,7 +1064,7 @@ class StoreOrderRefundServices extends BaseServices
|
|||||||
if ($list) {
|
if ($list) {
|
||||||
foreach ($list as &$item) {
|
foreach ($list as &$item) {
|
||||||
$item['paid'] = 1;
|
$item['paid'] = 1;
|
||||||
$item['add_time'] = isset($item['add_time']) ? date('Y-m-d H:i', (int)$item['add_time']) : '';
|
$item['add_time'] = $item['_add_time'] = isset($item['add_time']) ? date('Y-m-d H:i', (int)$item['add_time']) : '';
|
||||||
$item['cartInfo'] = $item['cart_info'];
|
$item['cartInfo'] = $item['cart_info'];
|
||||||
if (in_array($item['refund_type'], [1, 2, 4, 5])) {
|
if (in_array($item['refund_type'], [1, 2, 4, 5])) {
|
||||||
$item['refund_status'] = 1;
|
$item['refund_status'] = 1;
|
||||||
@ -1098,7 +1114,13 @@ class StoreOrderRefundServices extends BaseServices
|
|||||||
/**
|
/**
|
||||||
* 退款订单详情
|
* 退款订单详情
|
||||||
* @param $uni
|
* @param $uni
|
||||||
* @return mixed
|
* @return array
|
||||||
|
* @throws \think\db\exception\DataNotFoundException
|
||||||
|
* @throws \think\db\exception\DbException
|
||||||
|
* @throws \think\db\exception\ModelNotFoundException
|
||||||
|
* @author 吴汐
|
||||||
|
* @email 442384644@qq.com
|
||||||
|
* @date 2023/02/17
|
||||||
*/
|
*/
|
||||||
public function refundDetail($uni)
|
public function refundDetail($uni)
|
||||||
{
|
{
|
||||||
@ -1123,6 +1145,12 @@ class StoreOrderRefundServices extends BaseServices
|
|||||||
$orderData['store_order_sn'] = $orderInfo['order_id'];
|
$orderData['store_order_sn'] = $orderInfo['order_id'];
|
||||||
$orderData['cartInfo'] = $orderData['cart_info'];
|
$orderData['cartInfo'] = $orderData['cart_info'];
|
||||||
$orderData['_pay_time'] = date('Y-m-d H:i:s', $orderInfo['pay_time']);
|
$orderData['_pay_time'] = date('Y-m-d H:i:s', $orderInfo['pay_time']);
|
||||||
|
$orderData['type'] = 0;
|
||||||
|
if ($orderInfo['seckill_id'] || $orderInfo['bargain_id'] || $orderInfo['combination_id']) {
|
||||||
|
if ($orderInfo['seckill_id']) $orderData['type'] = 1;
|
||||||
|
if ($orderInfo['bargain_id']) $orderData['type'] = 2;
|
||||||
|
if ($orderInfo['combination_id']) $orderData['type'] = 3;
|
||||||
|
}
|
||||||
//核算优惠金额
|
//核算优惠金额
|
||||||
$vipTruePrice = 0;
|
$vipTruePrice = 0;
|
||||||
$total_price = 0;
|
$total_price = 0;
|
||||||
@ -1149,6 +1177,8 @@ class StoreOrderRefundServices extends BaseServices
|
|||||||
$orderData['pay_postage'] = $this->getOrderSumPrice($orderData['cart_info'], 'origin_postage_price', false);
|
$orderData['pay_postage'] = $this->getOrderSumPrice($orderData['cart_info'], 'origin_postage_price', false);
|
||||||
$orderData['member_price'] = 0;
|
$orderData['member_price'] = 0;
|
||||||
$orderData['routine_contact_type'] = sys_config('routine_contact_type', 0);
|
$orderData['routine_contact_type'] = sys_config('routine_contact_type', 0);
|
||||||
|
$orderData['levelPrice'] = $this->getOrderSumPrice($orderData['cart_info'], 'level');//获取会员等级优惠
|
||||||
|
$orderData['memberPrice'] = $this->getOrderSumPrice($orderData['cart_info'], 'member');//获取付费会员优惠
|
||||||
|
|
||||||
switch ($orderInfo['pay_type']) {
|
switch ($orderInfo['pay_type']) {
|
||||||
case PayServices::WEIXIN_PAY:
|
case PayServices::WEIXIN_PAY:
|
||||||
@ -1163,6 +1193,9 @@ class StoreOrderRefundServices extends BaseServices
|
|||||||
case PayServices::ALIAPY_PAY:
|
case PayServices::ALIAPY_PAY:
|
||||||
$pay_type_name = '支付宝支付';
|
$pay_type_name = '支付宝支付';
|
||||||
break;
|
break;
|
||||||
|
case PayServices::ALLIN_PAY:
|
||||||
|
$pay_type_name = '通联支付';
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
$pay_type_name = '其他支付';
|
$pay_type_name = '其他支付';
|
||||||
break;
|
break;
|
||||||
@ -1272,9 +1305,9 @@ class StoreOrderRefundServices extends BaseServices
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
//售后订单取消后置事件
|
//售后订单取消后置事件
|
||||||
event('order.orderRefundCancelAfter', [$orderRefundInfo]);
|
event('OrderRefundCancelAfterListener', [$orderRefundInfo]);
|
||||||
// 推送订单
|
// 推送订单
|
||||||
event('out.outPush', ['refund_cancel_push', ['order_id' => (int)$orderRefundInfo['id']]]);
|
event('OutPushListener', ['refund_cancel_push', ['order_id' => (int)$orderRefundInfo['id']]]);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -23,6 +23,7 @@ use app\services\product\product\StoreProductLogServices;
|
|||||||
use app\services\system\attachment\SystemAttachmentServices;
|
use app\services\system\attachment\SystemAttachmentServices;
|
||||||
use app\services\system\store\SystemStoreServices;
|
use app\services\system\store\SystemStoreServices;
|
||||||
use app\services\user\UserInvoiceServices;
|
use app\services\user\UserInvoiceServices;
|
||||||
|
use app\services\user\UserRechargeServices;
|
||||||
use app\services\user\UserServices;
|
use app\services\user\UserServices;
|
||||||
use app\services\product\product\StoreProductReplyServices;
|
use app\services\product\product\StoreProductReplyServices;
|
||||||
use app\services\user\UserAddressServices;
|
use app\services\user\UserAddressServices;
|
||||||
@ -31,6 +32,7 @@ use app\services\user\UserLevelServices;
|
|||||||
use app\services\wechat\WechatUserServices;
|
use app\services\wechat\WechatUserServices;
|
||||||
use crmeb\exceptions\AdminException;
|
use crmeb\exceptions\AdminException;
|
||||||
use crmeb\exceptions\ApiException;
|
use crmeb\exceptions\ApiException;
|
||||||
|
use crmeb\exceptions\PayException;
|
||||||
use crmeb\services\CacheService;
|
use crmeb\services\CacheService;
|
||||||
use crmeb\services\FormBuilder as Form;
|
use crmeb\services\FormBuilder as Form;
|
||||||
use crmeb\services\printer\Printer;
|
use crmeb\services\printer\Printer;
|
||||||
@ -51,6 +53,7 @@ use think\facade\Log;
|
|||||||
* @method getTrendData($time, $type, $timeType, $str) 用户趋势
|
* @method getTrendData($time, $type, $timeType, $str) 用户趋势
|
||||||
* @method getRegion($time, $channelType) 地域统计
|
* @method getRegion($time, $channelType) 地域统计
|
||||||
* @method getProductTrend($time, $timeType, $field, $str) 商品趋势
|
* @method getProductTrend($time, $timeType, $field, $str) 商品趋势
|
||||||
|
* @method getList(array $where, array $field, int $page = 0, int $limit = 0, array $with = [])
|
||||||
*/
|
*/
|
||||||
class StoreOrderServices extends BaseServices
|
class StoreOrderServices extends BaseServices
|
||||||
{
|
{
|
||||||
@ -168,8 +171,9 @@ class StoreOrderServices extends BaseServices
|
|||||||
$data['refunded_count'] = (string)$storeOrderRefundServices->count($refund_where + ['refund_type' => 6]);
|
$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['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['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'] = is_wecaht_pay();//微信支付 1 开启 0 关闭
|
$data['pc_order_count'] = $data['order_count'] + $data['refunding_count'] + $data['refunded_count'];
|
||||||
$data['ali_pay_status'] = is_ali_pay();//支付包支付 1 开启 0 关闭
|
$data['pay_weixin_open'] = sys_config('pay_weixin_open', '0') != '0';//微信支付 1 开启 0 关闭
|
||||||
|
$data['ali_pay_status'] = sys_config('ali_pay_status', '0') != '0';//支付包支付 1 开启 0 关闭
|
||||||
$data['friend_pay_status'] = (int)sys_config('friend_pay_status') ?? 0;//好友代付 1 开启 0 关闭
|
$data['friend_pay_status'] = (int)sys_config('friend_pay_status') ?? 0;//好友代付 1 开启 0 关闭
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
@ -497,6 +501,9 @@ class StoreOrderServices extends BaseServices
|
|||||||
case PayServices::ALIAPY_PAY:
|
case PayServices::ALIAPY_PAY:
|
||||||
$item['pay_type_name'] = '支付宝支付';
|
$item['pay_type_name'] = '支付宝支付';
|
||||||
break;
|
break;
|
||||||
|
case PayServices::ALLIN_PAY:
|
||||||
|
$item['pay_type_name'] = '通联支付';
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
$item['pay_type_name'] = '其他支付';
|
$item['pay_type_name'] = '其他支付';
|
||||||
break;
|
break;
|
||||||
@ -775,7 +782,7 @@ HTML;
|
|||||||
if ($res) {
|
if ($res) {
|
||||||
$order = $this->dao->getOne(['id' => $id, 'is_del' => 0]);
|
$order = $this->dao->getOne(['id' => $id, 'is_del' => 0]);
|
||||||
//改价短信提醒
|
//改价短信提醒
|
||||||
event('notice.notice', [['order' => $order, 'pay_price' => $data['pay_price']], 'price_revision']);
|
event('NoticeListener', [['order' => $order, 'pay_price' => $data['pay_price']], 'price_revision']);
|
||||||
return $data['order_id'];
|
return $data['order_id'];
|
||||||
} else {
|
} else {
|
||||||
throw new AdminException(100007);
|
throw new AdminException(100007);
|
||||||
@ -981,10 +988,46 @@ HTML;
|
|||||||
]
|
]
|
||||||
]]
|
]]
|
||||||
];
|
];
|
||||||
|
$series3 = ['normal' => ['color' => [
|
||||||
|
'x' => 0, 'y' => 0, 'x2' => 0, 'y2' => 1,
|
||||||
|
'colorStops' => [
|
||||||
|
[
|
||||||
|
'offset' => 0,
|
||||||
|
'color' => '#69cdff'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'offset' => 0.5,
|
||||||
|
'color' => '#3eb3f7'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'offset' => 1,
|
||||||
|
'color' => '#1495eb'
|
||||||
|
]
|
||||||
|
]
|
||||||
|
]]
|
||||||
|
];
|
||||||
|
$series4 = ['normal' => ['color' => [
|
||||||
|
'x' => 0, 'y' => 0, 'x2' => 0, 'y2' => 1,
|
||||||
|
'colorStops' => [
|
||||||
|
[
|
||||||
|
'offset' => 0,
|
||||||
|
'color' => '#6fdeab'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'offset' => 0.5,
|
||||||
|
'color' => '#44d693'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'offset' => 1,
|
||||||
|
'color' => '#2cc981'
|
||||||
|
]
|
||||||
|
]
|
||||||
|
]]
|
||||||
|
];
|
||||||
$chartdata['series'][] = ['name' => $chartdata['legend'][0], 'type' => 'bar', 'itemStyle' => $series1, 'data' => $data['pre']['price']];//分类1值
|
$chartdata['series'][] = ['name' => $chartdata['legend'][0], 'type' => 'bar', 'itemStyle' => $series1, 'data' => $data['pre']['price']];//分类1值
|
||||||
$chartdata['series'][] = ['name' => $chartdata['legend'][1], 'type' => 'bar', 'itemStyle' => $series1, 'data' => $data['now']['price']];//分类1值
|
$chartdata['series'][] = ['name' => $chartdata['legend'][1], 'type' => 'bar', 'itemStyle' => $series2, 'data' => $data['now']['price']];//分类1值
|
||||||
$chartdata['series'][] = ['name' => $chartdata['legend'][2], 'type' => 'line', 'itemStyle' => $series2, 'data' => $data['pre']['count'], 'yAxisIndex' => 1];//分类2值
|
$chartdata['series'][] = ['name' => $chartdata['legend'][2], 'type' => 'line', 'itemStyle' => $series3, 'data' => $data['pre']['count'], 'yAxisIndex' => 1];//分类2值
|
||||||
$chartdata['series'][] = ['name' => $chartdata['legend'][3], 'type' => 'line', 'itemStyle' => $series2, 'data' => $data['now']['count'], 'yAxisIndex' => 1];//分类2值
|
$chartdata['series'][] = ['name' => $chartdata['legend'][3], 'type' => 'line', 'itemStyle' => $series4, 'data' => $data['now']['count'], 'yAxisIndex' => 1];//分类2值
|
||||||
|
|
||||||
//统计总数上期
|
//统计总数上期
|
||||||
$pre_total = $this->dao->preTotalFind($datebefor, $dateafter);
|
$pre_total = $this->dao->preTotalFind($datebefor, $dateafter);
|
||||||
@ -1102,10 +1145,46 @@ HTML;
|
|||||||
]
|
]
|
||||||
]]
|
]]
|
||||||
];
|
];
|
||||||
|
$series3 = ['normal' => ['color' => [
|
||||||
|
'x' => 0, 'y' => 0, 'x2' => 0, 'y2' => 1,
|
||||||
|
'colorStops' => [
|
||||||
|
[
|
||||||
|
'offset' => 0,
|
||||||
|
'color' => '#69cdff'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'offset' => 0.5,
|
||||||
|
'color' => '#3eb3f7'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'offset' => 1,
|
||||||
|
'color' => '#1495eb'
|
||||||
|
]
|
||||||
|
]
|
||||||
|
]]
|
||||||
|
];
|
||||||
|
$series4 = ['normal' => ['color' => [
|
||||||
|
'x' => 0, 'y' => 0, 'x2' => 0, 'y2' => 1,
|
||||||
|
'colorStops' => [
|
||||||
|
[
|
||||||
|
'offset' => 0,
|
||||||
|
'color' => '#6fdeab'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'offset' => 0.5,
|
||||||
|
'color' => '#44d693'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'offset' => 1,
|
||||||
|
'color' => '#2cc981'
|
||||||
|
]
|
||||||
|
]
|
||||||
|
]]
|
||||||
|
];
|
||||||
$chartdata['series'][] = ['name' => $chartdata['legend'][0], 'type' => 'bar', 'itemStyle' => $series1, 'data' => $data['pre']['price']];//分类1值
|
$chartdata['series'][] = ['name' => $chartdata['legend'][0], 'type' => 'bar', 'itemStyle' => $series1, 'data' => $data['pre']['price']];//分类1值
|
||||||
$chartdata['series'][] = ['name' => $chartdata['legend'][1], 'type' => 'bar', 'itemStyle' => $series1, 'data' => $data['now']['price']];//分类1值
|
$chartdata['series'][] = ['name' => $chartdata['legend'][1], 'type' => 'bar', 'itemStyle' => $series2, 'data' => $data['now']['price']];//分类1值
|
||||||
$chartdata['series'][] = ['name' => $chartdata['legend'][2], 'type' => 'line', 'itemStyle' => $series2, 'data' => $data['pre']['count'], 'yAxisIndex' => 1];//分类2值
|
$chartdata['series'][] = ['name' => $chartdata['legend'][2], 'type' => 'line', 'itemStyle' => $series3, 'data' => $data['pre']['count'], 'yAxisIndex' => 1];//分类2值
|
||||||
$chartdata['series'][] = ['name' => $chartdata['legend'][3], 'type' => 'line', 'itemStyle' => $series2, 'data' => $data['now']['count'], 'yAxisIndex' => 1];//分类2值
|
$chartdata['series'][] = ['name' => $chartdata['legend'][3], 'type' => 'line', 'itemStyle' => $series4, 'data' => $data['now']['count'], 'yAxisIndex' => 1];//分类2值
|
||||||
|
|
||||||
//统计总数上期
|
//统计总数上期
|
||||||
$pre_total = $this->dao->preTotalFind($datebefor, $dateafter);
|
$pre_total = $this->dao->preTotalFind($datebefor, $dateafter);
|
||||||
@ -1221,10 +1300,46 @@ HTML;
|
|||||||
]
|
]
|
||||||
]]
|
]]
|
||||||
];
|
];
|
||||||
|
$series3 = ['normal' => ['color' => [
|
||||||
|
'x' => 0, 'y' => 0, 'x2' => 0, 'y2' => 1,
|
||||||
|
'colorStops' => [
|
||||||
|
[
|
||||||
|
'offset' => 0,
|
||||||
|
'color' => '#69cdff'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'offset' => 0.5,
|
||||||
|
'color' => '#3eb3f7'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'offset' => 1,
|
||||||
|
'color' => '#1495eb'
|
||||||
|
]
|
||||||
|
]
|
||||||
|
]]
|
||||||
|
];
|
||||||
|
$series4 = ['normal' => ['color' => [
|
||||||
|
'x' => 0, 'y' => 0, 'x2' => 0, 'y2' => 1,
|
||||||
|
'colorStops' => [
|
||||||
|
[
|
||||||
|
'offset' => 0,
|
||||||
|
'color' => '#6fdeab'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'offset' => 0.5,
|
||||||
|
'color' => '#44d693'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'offset' => 1,
|
||||||
|
'color' => '#2cc981'
|
||||||
|
]
|
||||||
|
]
|
||||||
|
]]
|
||||||
|
];
|
||||||
$chartdata['series'][] = ['name' => $chartdata['legend'][0], 'type' => 'bar', 'itemStyle' => $series1, 'data' => $data['pre']['price']];//分类1值
|
$chartdata['series'][] = ['name' => $chartdata['legend'][0], 'type' => 'bar', 'itemStyle' => $series1, 'data' => $data['pre']['price']];//分类1值
|
||||||
$chartdata['series'][] = ['name' => $chartdata['legend'][1], 'type' => 'bar', 'itemStyle' => $series1, 'data' => $data['now']['price']];//分类1值
|
$chartdata['series'][] = ['name' => $chartdata['legend'][1], 'type' => 'bar', 'itemStyle' => $series2, 'data' => $data['now']['price']];//分类1值
|
||||||
$chartdata['series'][] = ['name' => $chartdata['legend'][2], 'type' => 'line', 'itemStyle' => $series2, 'data' => $data['pre']['count'], 'yAxisIndex' => 1];//分类2值
|
$chartdata['series'][] = ['name' => $chartdata['legend'][2], 'type' => 'line', 'itemStyle' => $series3, 'data' => $data['pre']['count'], 'yAxisIndex' => 1];//分类2值
|
||||||
$chartdata['series'][] = ['name' => $chartdata['legend'][3], 'type' => 'line', 'itemStyle' => $series2, 'data' => $data['now']['count'], 'yAxisIndex' => 1];//分类2值
|
$chartdata['series'][] = ['name' => $chartdata['legend'][3], 'type' => 'line', 'itemStyle' => $series4, 'data' => $data['now']['count'], 'yAxisIndex' => 1];//分类2值
|
||||||
|
|
||||||
//统计总数上期
|
//统计总数上期
|
||||||
$pre_total = $this->dao->preTotalFind($datebefor, $dateafter);
|
$pre_total = $this->dao->preTotalFind($datebefor, $dateafter);
|
||||||
@ -1316,24 +1431,24 @@ HTML;
|
|||||||
$yesterday_sales = $this->dao->todaySales('yesterday');
|
$yesterday_sales = $this->dao->todaySales('yesterday');
|
||||||
//日同比
|
//日同比
|
||||||
$sales_today_ratio = $this->growth($today_sales, $yesterday_sales);
|
$sales_today_ratio = $this->growth($today_sales, $yesterday_sales);
|
||||||
//周销售额
|
// //周销售额
|
||||||
//本周
|
// //本周
|
||||||
$this_week_sales = $this->dao->thisWeekSales('week');
|
// $this_week_sales = $this->dao->thisWeekSales('week');
|
||||||
//上周
|
// //上周
|
||||||
$last_week_sales = $this->dao->thisWeekSales('last week');
|
// $last_week_sales = $this->dao->thisWeekSales('last week');
|
||||||
//周同比
|
// //周同比
|
||||||
$sales_week_ratio = $this->growth($this_week_sales, $last_week_sales);
|
// $sales_week_ratio = $this->growth($this_week_sales, $last_week_sales);
|
||||||
//总销售额
|
//总销售额
|
||||||
$total_sales = $this->dao->totalSales('month');
|
$total_sales = $this->dao->totalSales('month');
|
||||||
$sales = [
|
$sales = [
|
||||||
'today' => $today_sales,
|
'today' => $today_sales,
|
||||||
'yesterday' => $yesterday_sales,
|
'yesterday' => $yesterday_sales,
|
||||||
'today_ratio' => $sales_today_ratio,
|
'today_ratio' => $sales_today_ratio,
|
||||||
'week' => $this_week_sales,
|
// 'week' => $this_week_sales,
|
||||||
'last_week' => $last_week_sales,
|
// 'last_week' => $last_week_sales,
|
||||||
'week_ratio' => $sales_week_ratio,
|
// 'week_ratio' => $sales_week_ratio,
|
||||||
'total' => $total_sales . '元',
|
'total' => $total_sales . '元',
|
||||||
'date' => '昨日'
|
'date' => '今日'
|
||||||
];
|
];
|
||||||
//TODO:用户访问量
|
//TODO:用户访问量
|
||||||
//今日访问量
|
//今日访问量
|
||||||
@ -1342,23 +1457,23 @@ HTML;
|
|||||||
$yesterday_visits = $productLogServices->count(['time' => 'yesterday', 'type' => 'visit']);
|
$yesterday_visits = $productLogServices->count(['time' => 'yesterday', 'type' => 'visit']);
|
||||||
//日同比
|
//日同比
|
||||||
$visits_today_ratio = $this->growth($today_visits, $yesterday_visits);
|
$visits_today_ratio = $this->growth($today_visits, $yesterday_visits);
|
||||||
//本周访问量
|
// //本周访问量
|
||||||
$this_week_visits = $productLogServices->count(['time' => 'week', 'type' => 'visit']);
|
// $this_week_visits = $productLogServices->count(['time' => 'week', 'type' => 'visit']);
|
||||||
//上周访问量
|
// //上周访问量
|
||||||
$last_week_visits = $productLogServices->count(['time' => 'last week', 'type' => 'visit']);
|
// $last_week_visits = $productLogServices->count(['time' => 'last week', 'type' => 'visit']);
|
||||||
//周同比
|
// //周同比
|
||||||
$visits_week_ratio = $this->growth($this_week_visits, $last_week_visits);
|
// $visits_week_ratio = $this->growth($this_week_visits, $last_week_visits);
|
||||||
//总访问量
|
//总访问量
|
||||||
$total_visits = $productLogServices->count(['time' => 'month', 'type' => 'visit']);
|
$total_visits = $productLogServices->count(['time' => 'month', 'type' => 'visit']);
|
||||||
$visits = [
|
$visits = [
|
||||||
'today' => $today_visits,
|
'today' => $today_visits,
|
||||||
'yesterday' => $yesterday_visits,
|
'yesterday' => $yesterday_visits,
|
||||||
'today_ratio' => $visits_today_ratio,
|
'today_ratio' => $visits_today_ratio,
|
||||||
'week' => $this_week_visits,
|
// 'week' => $this_week_visits,
|
||||||
'last_week' => $last_week_visits,
|
// 'last_week' => $last_week_visits,
|
||||||
'week_ratio' => $visits_week_ratio,
|
// 'week_ratio' => $visits_week_ratio,
|
||||||
'total' => $total_visits . 'Pv',
|
'total' => $total_visits . 'Pv',
|
||||||
'date' => '昨日'
|
'date' => '今日'
|
||||||
];
|
];
|
||||||
//TODO 订单量
|
//TODO 订单量
|
||||||
//今日订单量
|
//今日订单量
|
||||||
@ -1367,23 +1482,23 @@ HTML;
|
|||||||
$yesterday_order = $this->dao->todayOrderVisit('yesterday', 1);
|
$yesterday_order = $this->dao->todayOrderVisit('yesterday', 1);
|
||||||
//订单日同比
|
//订单日同比
|
||||||
$order_today_ratio = $this->growth($today_order, $yesterday_order);
|
$order_today_ratio = $this->growth($today_order, $yesterday_order);
|
||||||
//本周订单量
|
// //本周订单量
|
||||||
$this_week_order = $this->dao->todayOrderVisit('week', 2);
|
// $this_week_order = $this->dao->todayOrderVisit('week', 2);
|
||||||
//上周订单量
|
// //上周订单量
|
||||||
$last_week_order = $this->dao->todayOrderVisit('last week', 2);
|
// $last_week_order = $this->dao->todayOrderVisit('last week', 2);
|
||||||
//订单周同比
|
// //订单周同比
|
||||||
$order_week_ratio = $this->growth($this_week_order, $last_week_order);
|
// $order_week_ratio = $this->growth($this_week_order, $last_week_order);
|
||||||
//总订单量
|
//总订单量
|
||||||
$total_order = $this->dao->count(['time' => 'month', 'paid' => 1, 'refund_status' => 0, 'pid' => 0]);
|
$total_order = $this->dao->count(['time' => 'month', 'paid' => 1, 'refund_status' => 0, 'pid' => 0]);
|
||||||
$order = [
|
$order = [
|
||||||
'today' => $today_order,
|
'today' => $today_order,
|
||||||
'yesterday' => $yesterday_order,
|
'yesterday' => $yesterday_order,
|
||||||
'today_ratio' => $order_today_ratio,
|
'today_ratio' => $order_today_ratio,
|
||||||
'week' => $this_week_order,
|
// 'week' => $this_week_order,
|
||||||
'last_week' => $last_week_order,
|
// 'last_week' => $last_week_order,
|
||||||
'week_ratio' => $order_week_ratio,
|
// 'week_ratio' => $order_week_ratio,
|
||||||
'total' => $total_order . '单',
|
'total' => $total_order . '单',
|
||||||
'date' => '昨日'
|
'date' => '今日'
|
||||||
];
|
];
|
||||||
//TODO 用户
|
//TODO 用户
|
||||||
//今日新增用户
|
//今日新增用户
|
||||||
@ -1392,23 +1507,23 @@ HTML;
|
|||||||
$yesterday_user = $uSercice->todayAddVisits('yesterday', 1);
|
$yesterday_user = $uSercice->todayAddVisits('yesterday', 1);
|
||||||
//新增用户日同比
|
//新增用户日同比
|
||||||
$user_today_ratio = $this->growth($today_user, $yesterday_user);
|
$user_today_ratio = $this->growth($today_user, $yesterday_user);
|
||||||
//本周新增用户
|
// //本周新增用户
|
||||||
$this_week_user = $uSercice->todayAddVisits('week', 2);
|
// $this_week_user = $uSercice->todayAddVisits('week', 2);
|
||||||
//上周新增用户
|
// //上周新增用户
|
||||||
$last_week_user = $uSercice->todayAddVisits('last week', 2);
|
// $last_week_user = $uSercice->todayAddVisits('last week', 2);
|
||||||
//新增用户周同比
|
// //新增用户周同比
|
||||||
$user_week_ratio = $this->growth($this_week_user, $last_week_user);
|
// $user_week_ratio = $this->growth($this_week_user, $last_week_user);
|
||||||
//所有用户
|
//所有用户
|
||||||
$total_user = $uSercice->count(['time' => 'month']);
|
$total_user = $uSercice->count(['time' => 'month']);
|
||||||
$user = [
|
$user = [
|
||||||
'today' => $today_user,
|
'today' => $today_user,
|
||||||
'yesterday' => $yesterday_user,
|
'yesterday' => $yesterday_user,
|
||||||
'today_ratio' => $user_today_ratio,
|
'today_ratio' => $user_today_ratio,
|
||||||
'week' => $this_week_user,
|
// 'week' => $this_week_user,
|
||||||
'last_week' => $last_week_user,
|
// 'last_week' => $last_week_user,
|
||||||
'week_ratio' => $user_week_ratio,
|
// 'week_ratio' => $user_week_ratio,
|
||||||
'total' => $total_user . '人',
|
'total' => $total_user . '人',
|
||||||
'date' => '昨日'
|
'date' => '今日'
|
||||||
];
|
];
|
||||||
$info = array_values(compact('sales', 'visits', 'order', 'user'));
|
$info = array_values(compact('sales', 'visits', 'order', 'user'));
|
||||||
$info[0]['title'] = '销售额';
|
$info[0]['title'] = '销售额';
|
||||||
@ -1577,7 +1692,7 @@ HTML;
|
|||||||
$data['integralRatio'] = $other['integralRatio'];
|
$data['integralRatio'] = $other['integralRatio'];
|
||||||
$data['offline_pay_status'] = (int)sys_config('offline_pay_status') ?? (int)2;
|
$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['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'] = is_wecaht_pay();//微信支付 1 开启 0 关闭
|
$data['pay_weixin_open'] = sys_config('pay_weixin_open', '0') != '0';//微信支付 1 开启 0 关闭
|
||||||
$data['friend_pay_status'] = (int)sys_config('friend_pay_status') ?? 0;//好友代付 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;//门店自提是否开启
|
$data['store_self_mention'] = (int)sys_config('store_self_mention') ?? 0;//门店自提是否开启
|
||||||
/** @var SystemStoreServices $systemStoreServices */
|
/** @var SystemStoreServices $systemStoreServices */
|
||||||
@ -1585,7 +1700,7 @@ HTML;
|
|||||||
$store_count = $systemStoreServices->count(['type' => 0]);
|
$store_count = $systemStoreServices->count(['type' => 0]);
|
||||||
$data['store_self_mention'] = $data['store_self_mention'] && $store_count;
|
$data['store_self_mention'] = $data['store_self_mention'] && $store_count;
|
||||||
|
|
||||||
$data['ali_pay_status'] = is_ali_pay();//支付包支付 1 开启 0 关闭
|
$data['ali_pay_status'] = sys_config('ali_pay_status', '0') != '0';//支付包支付 1 开启 0 关闭
|
||||||
$data['system_store'] = [];//门店信息
|
$data['system_store'] = [];//门店信息
|
||||||
/** @var UserInvoiceServices $userInvoice */
|
/** @var UserInvoiceServices $userInvoice */
|
||||||
$userInvoice = app()->make(UserInvoiceServices::class);
|
$userInvoice = app()->make(UserInvoiceServices::class);
|
||||||
@ -1689,7 +1804,7 @@ HTML;
|
|||||||
$res = false;
|
$res = false;
|
||||||
switch ($payType) {
|
switch ($payType) {
|
||||||
case PayServices::WEIXIN_PAY:
|
case PayServices::WEIXIN_PAY:
|
||||||
$res = (bool)sys_config('pay_weixin_open');
|
$res = sys_config('pay_weixin_open', '0') != '0';
|
||||||
break;
|
break;
|
||||||
case PayServices::YUE_PAY:
|
case PayServices::YUE_PAY:
|
||||||
$res = sys_config('balance_func_status') && sys_config('yue_pay_status') == 1;
|
$res = sys_config('balance_func_status') && sys_config('yue_pay_status') == 1;
|
||||||
@ -1698,7 +1813,7 @@ HTML;
|
|||||||
$res = sys_config('offline_pay_status') == 1;
|
$res = sys_config('offline_pay_status') == 1;
|
||||||
break;
|
break;
|
||||||
case PayServices::ALIAPY_PAY:
|
case PayServices::ALIAPY_PAY:
|
||||||
$res = sys_config('ali_pay_status') == 1;
|
$res = sys_config('ali_pay_status', '0') != '0';
|
||||||
break;
|
break;
|
||||||
case PayServices::FRIEND:
|
case PayServices::FRIEND:
|
||||||
$res = sys_config('friend_pay_status', 1) == 1;
|
$res = sys_config('friend_pay_status', 1) == 1;
|
||||||
@ -1717,6 +1832,24 @@ HTML;
|
|||||||
*/
|
*/
|
||||||
public function setOrderTypePayOffline(string $orderId)
|
public function setOrderTypePayOffline(string $orderId)
|
||||||
{
|
{
|
||||||
|
if (($count = strpos($orderId, '_')) !== false) {
|
||||||
|
$orderId = substr($orderId, $count + 1);
|
||||||
|
}
|
||||||
|
if (sys_config('offline_postage', 0) == 1) {
|
||||||
|
$orderInfo = $this->dao->get(['order_id' => $orderId]);
|
||||||
|
$cartInfoService = app()->make(StoreOrderCartInfoServices::class);
|
||||||
|
$cartInfo = $cartInfoService->getColumn(['oid' => $orderInfo['id']], 'cart_info', 'id');
|
||||||
|
foreach ($cartInfo as $key => &$item) {
|
||||||
|
$item_arr = json_decode($item, true);
|
||||||
|
$item_arr['postage_price'] = $item_arr['origin_postage_price'] = 0;
|
||||||
|
$cartInfoService->update(['id' => $key], ['cart_info' => json_encode($item_arr)]);
|
||||||
|
}
|
||||||
|
return $this->dao->update($orderId, [
|
||||||
|
'pay_type' => 'offline',
|
||||||
|
'pay_price' => bcsub((string)$orderInfo['pay_price'], (string)$orderInfo['pay_postage'], 2),
|
||||||
|
'pay_postage' => 0
|
||||||
|
], 'order_id');
|
||||||
|
}
|
||||||
return $this->dao->update($orderId, ['pay_type' => 'offline'], 'order_id');
|
return $this->dao->update($orderId, ['pay_type' => 'offline'], 'order_id');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1797,10 +1930,6 @@ HTML;
|
|||||||
throw new ApiException(100020);
|
throw new ApiException(100020);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
/** @var StoreSeckillServices $seckiiServices */
|
|
||||||
$seckiiServices = app()->make(StoreSeckillServices::class);
|
|
||||||
$seckiiServices->cancelOccupySeckillStock($cartInfo, $order['unique']);
|
|
||||||
$seckiiServices->rollBackStock($cartInfo);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1856,7 +1985,7 @@ HTML;
|
|||||||
{
|
{
|
||||||
/** @var UserServices $userServices */
|
/** @var UserServices $userServices */
|
||||||
$userServices = app()->make(UserServices::class);
|
$userServices = app()->make(UserServices::class);
|
||||||
$user = $userServices->getUserInfo($uid);
|
$user = $userServices->getUserInfo($uid, 'uid');
|
||||||
if (!$user) {
|
if (!$user) {
|
||||||
throw new AdminException(100026);
|
throw new AdminException(100026);
|
||||||
}
|
}
|
||||||
@ -2021,10 +2150,6 @@ HTML;
|
|||||||
/** @var StoreOrderCartInfoServices $cartServices */
|
/** @var StoreOrderCartInfoServices $cartServices */
|
||||||
$cartServices = app()->make(StoreOrderCartInfoServices::class);
|
$cartServices = app()->make(StoreOrderCartInfoServices::class);
|
||||||
$cartInfo = $cartServices->getOrderCartInfo((int)$order['id']);
|
$cartInfo = $cartServices->getOrderCartInfo((int)$order['id']);
|
||||||
/** @var StoreSeckillServices $seckiiServices */
|
|
||||||
$seckiiServices = app()->make(StoreSeckillServices::class);
|
|
||||||
$seckiiServices->cancelOccupySeckillStock($cartInfo, $order['unique']);
|
|
||||||
$seckiiServices->rollBackStock($cartInfo);
|
|
||||||
|
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
Log::error('自动取消订单失败,失败原因:' . $e->getMessage(), $e->getTrace());
|
Log::error('自动取消订单失败,失败原因:' . $e->getMessage(), $e->getTrace());
|
||||||
@ -2290,7 +2415,7 @@ HTML;
|
|||||||
if (!$orderInfo) {
|
if (!$orderInfo) {
|
||||||
throw new ApiException(410264);
|
throw new ApiException(410264);
|
||||||
}
|
}
|
||||||
return $payServices->alipayOrder($orderInfo->toArray(), $quitUrl);
|
return $payServices->beforePay($orderInfo->toArray(), PayServices::ALIAPY_PAY, ['quitUrl' => $quitUrl]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -2347,8 +2472,8 @@ HTML;
|
|||||||
}
|
}
|
||||||
$order['mapKey'] = sys_config('tengxun_map_key');
|
$order['mapKey'] = sys_config('tengxun_map_key');
|
||||||
$order['yue_pay_status'] = (int)sys_config('balance_func_status') && (int)sys_config('yue_pay_status') == 1 ? (int)1 : (int)2;//余额支付 1 开启 2 关闭
|
$order['yue_pay_status'] = (int)sys_config('balance_func_status') && (int)sys_config('yue_pay_status') == 1 ? (int)1 : (int)2;//余额支付 1 开启 2 关闭
|
||||||
$order['pay_weixin_open'] = (int)sys_config('pay_weixin_open') ?? 0;//微信支付 1 开启 0 关闭
|
$order['pay_weixin_open'] = sys_config('pay_weixin_open') != '0';//微信支付 1 开启 0 关闭
|
||||||
$order['ali_pay_status'] = (bool)sys_config('ali_pay_status');//支付包支付 1 开启 0 关闭
|
$order['ali_pay_status'] = sys_config('ali_pay_status', '0') != '0';//支付包支付 1 开启 0 关闭
|
||||||
$order['friend_pay_status'] = (int)sys_config('friend_pay_status') ?? 0;//好友代付 1 开启 0 关闭
|
$order['friend_pay_status'] = (int)sys_config('friend_pay_status') ?? 0;//好友代付 1 开启 0 关闭
|
||||||
$orderData = $this->tidyOrder($order, true, true);
|
$orderData = $this->tidyOrder($order, true, true);
|
||||||
$vipTruePrice = $memberPrice = $levelPrice = 0;
|
$vipTruePrice = $memberPrice = $levelPrice = 0;
|
||||||
@ -2392,7 +2517,7 @@ HTML;
|
|||||||
if ($orderData['uid'] != $orderData['pay_uid']) {
|
if ($orderData['uid'] != $orderData['pay_uid']) {
|
||||||
/** @var UserServices $userServices */
|
/** @var UserServices $userServices */
|
||||||
$userServices = app()->make(UserServices::class);
|
$userServices = app()->make(UserServices::class);
|
||||||
$payUser = $userServices->get($orderData['pay_uid']);
|
$payUser = $userServices->get($orderData['pay_uid'], ['nickname', 'avatar']);
|
||||||
$orderData['help_info'] = [
|
$orderData['help_info'] = [
|
||||||
'pay_uid' => $orderData['pay_uid'],
|
'pay_uid' => $orderData['pay_uid'],
|
||||||
'pay_nickname' => $payUser['nickname'],
|
'pay_nickname' => $payUser['nickname'],
|
||||||
@ -2472,4 +2597,81 @@ HTML;
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $orderId
|
||||||
|
* @param string $type
|
||||||
|
* @return array
|
||||||
|
* @throws \think\db\exception\DataNotFoundException
|
||||||
|
* @throws \think\db\exception\DbException
|
||||||
|
* @throws \think\db\exception\ModelNotFoundException
|
||||||
|
* @author 等风来
|
||||||
|
* @email 136327134@qq.com
|
||||||
|
* @date 2023/2/13
|
||||||
|
*/
|
||||||
|
public function getCashierInfo(int $uid, string $orderId, string $type)
|
||||||
|
{
|
||||||
|
//支付类型开关
|
||||||
|
$data = [
|
||||||
|
'ali_pay_status' => sys_config('ali_pay_status', '0') != '0',
|
||||||
|
'wechat_pay_status' => sys_config('pay_weixin_open', '0') != '0',
|
||||||
|
'offline_pay_status' => (int)sys_config('offline_pay_status') == 1,
|
||||||
|
'friend_pay_status' => (int)sys_config('friend_pay_status') == 1,
|
||||||
|
'yue_pay_status' => (int)sys_config('balance_func_status') && (int)sys_config('yue_pay_status') == 1,
|
||||||
|
];
|
||||||
|
|
||||||
|
$data['order_id'] = $orderId;
|
||||||
|
$data['pay_price'] = '0';
|
||||||
|
$data['now_money'] = app()->make(UserServices::class)->value(['uid' => $uid], 'now_money');
|
||||||
|
|
||||||
|
switch ($type) {
|
||||||
|
case 'order':
|
||||||
|
$info = $this->dao->get(['order_id' => $orderId], ['pay_price', 'add_time', 'combination_id', 'seckill_id', 'bargain_id', 'pay_postage']);
|
||||||
|
if (!$info) {
|
||||||
|
throw new PayException('您支付的订单不存在');
|
||||||
|
}
|
||||||
|
$orderCancelTime = (int)sys_config('order_cancel_time', 0);
|
||||||
|
$orderActivityTime = (int)sys_config('order_activity_time', 0);
|
||||||
|
if ($info->combination_id) {
|
||||||
|
$time = ((int)sys_config('order_pink_time', 0) ?: $orderActivityTime) * 60 * 60 + ((int)$info->add_time);
|
||||||
|
} else if ($info->seckill_id) {
|
||||||
|
$time = ((int)sys_config('order_seckill_time', 0) ?: $orderActivityTime) * 60 * 60 + ((int)$info->add_time);
|
||||||
|
} else if ($info->bargain_id) {
|
||||||
|
$time = ((int)sys_config('order_bargain_time', 0) ?: $orderActivityTime) * 60 * 60 + ((int)$info->add_time);
|
||||||
|
} else {
|
||||||
|
$time = $orderCancelTime * 60 * 60 + ((int)$info->add_time);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($time < 0) {
|
||||||
|
$time = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
$data['pay_price'] = $info['pay_price'];
|
||||||
|
$data['pay_postage'] = $info['pay_postage'];
|
||||||
|
$data['offline_postage'] = sys_config('offline_postage', 0);
|
||||||
|
$data['invalid_time'] = $time;
|
||||||
|
|
||||||
|
break;
|
||||||
|
case 'svip':
|
||||||
|
$info = app()->make(OtherOrderServices::class)->get(['order_id' => $orderId], ['pay_price', 'add_time']);
|
||||||
|
if (!$info) {
|
||||||
|
throw new PayException('您支付的订单不存在');
|
||||||
|
}
|
||||||
|
$data['pay_price'] = $info['pay_price'];
|
||||||
|
$data['invalid_time'] = $info->add_time + 86400;
|
||||||
|
break;
|
||||||
|
case 'recharge':
|
||||||
|
$info = app()->make(UserRechargeServices::class)->get(['order_id' => $orderId], ['price', 'add_time']);
|
||||||
|
if (!$info) {
|
||||||
|
throw new PayException('您支付的订单不存在');
|
||||||
|
}
|
||||||
|
$data['pay_price'] = $info['price'];
|
||||||
|
$data['invalid_time'] = $info->add_time + 86400;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new PayException('暂不支持其他类型订单支付');
|
||||||
|
}
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -85,7 +85,7 @@ class StoreOrderSplitServices extends BaseServices
|
|||||||
if (empty($cart_ids_arr['other'])) return [$old_order, ['id' => 0]];
|
if (empty($cart_ids_arr['other'])) return [$old_order, ['id' => 0]];
|
||||||
return $this->transaction(function () use ($id, $cart_ids_arr, $orderInfo, $orderInfoOld, $cartInfo, $storeOrderCreateServices, $storeOrderCartInfoServices, $statusService) {
|
return $this->transaction(function () use ($id, $cart_ids_arr, $orderInfo, $orderInfoOld, $cartInfo, $storeOrderCreateServices, $storeOrderCartInfoServices, $statusService) {
|
||||||
$order = $otherOrder = [];
|
$order = $otherOrder = [];
|
||||||
$statusData = $statusService->getColumn(['oid' => $id], '*');
|
$statusData = $statusService->selectList(['oid' => $id])->toArray();
|
||||||
//订单实际支付金额
|
//订单实际支付金额
|
||||||
$order_pay_price = bcsub((string)bcadd((string)$orderInfo['total_price'], (string)$orderInfo['pay_postage'], 2), (string)bcadd((string)$orderInfo['deduction_price'], (string)$orderInfo['coupon_price'], 2), 2);
|
$order_pay_price = bcsub((string)bcadd((string)$orderInfo['total_price'], (string)$orderInfo['pay_postage'], 2), (string)bcadd((string)$orderInfo['deduction_price'], (string)$orderInfo['coupon_price'], 2), 2);
|
||||||
//有改价
|
//有改价
|
||||||
@ -106,6 +106,7 @@ class StoreOrderSplitServices extends BaseServices
|
|||||||
$allData = [];
|
$allData = [];
|
||||||
foreach ($statusData as $data) {
|
foreach ($statusData as $data) {
|
||||||
$data['oid'] = $new_id;
|
$data['oid'] = $new_id;
|
||||||
|
$data['change_time'] = strtotime($data['change_time']);
|
||||||
$allData[] = $data;
|
$allData[] = $data;
|
||||||
}
|
}
|
||||||
if ($allData) {
|
if ($allData) {
|
||||||
|
|||||||
@ -69,6 +69,7 @@ class StoreOrderSuccessServices extends BaseServices
|
|||||||
{
|
{
|
||||||
$updata = ['paid' => 1, 'pay_type' => $paytype, 'pay_time' => time()];
|
$updata = ['paid' => 1, 'pay_type' => $paytype, 'pay_time' => time()];
|
||||||
$orderInfo['pay_time'] = $updata['pay_time'];
|
$orderInfo['pay_time'] = $updata['pay_time'];
|
||||||
|
$orderInfo['pay_type'] = $paytype;
|
||||||
if ($other && isset($other['trade_no'])) {
|
if ($other && isset($other['trade_no'])) {
|
||||||
$updata['trade_no'] = $other['trade_no'];
|
$updata['trade_no'] = $other['trade_no'];
|
||||||
}
|
}
|
||||||
@ -92,13 +93,13 @@ class StoreOrderSuccessServices extends BaseServices
|
|||||||
}
|
}
|
||||||
$orderInfo['send_name'] = $orderInfo['real_name'];
|
$orderInfo['send_name'] = $orderInfo['real_name'];
|
||||||
//订单支付成功后置事件
|
//订单支付成功后置事件
|
||||||
event('order.orderPaySuccess', [$orderInfo]);
|
event('OrderPaySuccessListener', [$orderInfo]);
|
||||||
//用户推送消息事件
|
//用户推送消息事件
|
||||||
event('notice.notice', [$orderInfo, 'order_pay_success']);
|
event('NoticeListener', [$orderInfo, 'order_pay_success']);
|
||||||
//支付成功给客服发送消息
|
//支付成功给客服发送消息
|
||||||
event('notice.notice', [$orderInfo, 'admin_pay_success_code']);
|
event('NoticeListener', [$orderInfo, 'admin_pay_success_code']);
|
||||||
// 推送订单
|
// 推送订单
|
||||||
event('out.outPush', ['order_pay_push', ['order_id' => (int)$orderInfo['id']]]);
|
event('OutPushListener', ['order_pay_push', ['order_id' => (int)$orderInfo['id']]]);
|
||||||
$res = $res1 && $resPink;
|
$res = $res1 && $resPink;
|
||||||
return false !== $res;
|
return false !== $res;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -65,15 +65,7 @@ class StoreOrderTakeServices extends BaseServices
|
|||||||
throw new ApiException(410266);
|
throw new ApiException(410266);
|
||||||
}
|
}
|
||||||
$order->status = 2;
|
$order->status = 2;
|
||||||
/** @var StoreOrderStatusServices $statusService */
|
$res = $order->save() && $this->storeProductOrderUserTakeDelivery($order);
|
||||||
$statusService = app()->make(StoreOrderStatusServices::class);
|
|
||||||
$res = $order->save() && $statusService->save([
|
|
||||||
'oid' => $order['id'],
|
|
||||||
'change_type' => 'user_take_delivery',
|
|
||||||
'change_message' => '用户已收货',
|
|
||||||
'change_time' => time()
|
|
||||||
]);
|
|
||||||
$res = $res && $this->storeProductOrderUserTakeDelivery($order);
|
|
||||||
if (!$res) {
|
if (!$res) {
|
||||||
throw new ApiException(410205);
|
throw new ApiException(410205);
|
||||||
}
|
}
|
||||||
@ -114,11 +106,11 @@ class StoreOrderTakeServices extends BaseServices
|
|||||||
if ($res) {
|
if ($res) {
|
||||||
try {
|
try {
|
||||||
// 收货成功后置队列
|
// 收货成功后置队列
|
||||||
event('order.orderTake', [$order, $userInfo, $storeTitle]);
|
event('OrderTakeListener', [$order, $userInfo, $storeTitle]);
|
||||||
//收货给用户发送消息
|
//收货给用户发送消息
|
||||||
event('notice.notice', [['order' => $order, 'storeTitle' => $storeTitle], 'order_take']);
|
event('NoticeListener', [['order' => $order, 'storeTitle' => $storeTitle], 'order_take']);
|
||||||
//收货给客服发送消息
|
//收货给客服发送消息
|
||||||
event('notice.notice', [['order' => $order, 'storeTitle' => $storeTitle], 'send_admin_confirm_take_over']);
|
event('NoticeListener', [['order' => $order, 'storeTitle' => $storeTitle], 'send_admin_confirm_take_over']);
|
||||||
} catch (\Throwable $exception) {
|
} catch (\Throwable $exception) {
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -190,7 +182,7 @@ class StoreOrderTakeServices extends BaseServices
|
|||||||
/** @var StoreOrderServices $orderServices */
|
/** @var StoreOrderServices $orderServices */
|
||||||
$orderServices = app()->make(StoreOrderServices::class);
|
$orderServices = app()->make(StoreOrderServices::class);
|
||||||
$orderServices->update($order['id'], ['gain_integral' => $give_integral], 'id');
|
$orderServices->update($order['id'], ['gain_integral' => $give_integral], 'id');
|
||||||
event('notice.notice', [['order' => $order, 'storeTitle' => $storeTitle, 'give_integral' => $give_integral, 'integral' => $integral], 'integral_accout']);
|
event('NoticeListener', [['order' => $order, 'storeTitle' => $storeTitle, 'give_integral' => $give_integral, 'integral' => $integral], 'integral_accout']);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@ -481,7 +473,7 @@ class StoreOrderTakeServices extends BaseServices
|
|||||||
$goodsPrice = $brokeragePrice;
|
$goodsPrice = $brokeragePrice;
|
||||||
}
|
}
|
||||||
//提醒推送
|
//提醒推送
|
||||||
event('notice.notice', [['spread_uid' => $spread_uid, 'userType' => $userType, 'brokeragePrice' => $brokeragePrice, 'goodsName' => $goodsName, 'goodsPrice' => $goodsPrice, 'add_time' => $orderInfo['add_time'] ?? time()], 'order_brokerage']);
|
event('NoticeListener', [['spread_uid' => $spread_uid, 'userType' => $userType, 'brokeragePrice' => $brokeragePrice, 'goodsName' => $goodsName, 'goodsPrice' => $goodsPrice, 'add_time' => $orderInfo['add_time'] ?? time()], 'order_brokerage']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -518,7 +510,7 @@ class StoreOrderTakeServices extends BaseServices
|
|||||||
}
|
}
|
||||||
|
|
||||||
//用户升级事件
|
//用户升级事件
|
||||||
event('user.userLevel', [$order['uid']]);
|
event('UserLevelListener', [$order['uid']]);
|
||||||
|
|
||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -33,7 +33,7 @@ class ExportServices extends BaseServices
|
|||||||
/** @var UserServices $userServices */
|
/** @var UserServices $userServices */
|
||||||
$userServices = app()->make(UserServices::class);
|
$userServices = app()->make(UserServices::class);
|
||||||
$data = $userServices->index($where)['list'];
|
$data = $userServices->index($where)['list'];
|
||||||
$header = ['用户ID', '昵称', '真实姓名', '性别', '电话', '用户等级', '用户分组', '用户标签', '用户类型', '用户余额', '最后登录时间', '注册时间'];
|
$header = ['用户ID', '昵称', '真实姓名', '性别', '电话', '用户等级', '用户分组', '用户标签', '用户类型', '用户余额', '最后登录时间', '注册时间', '是否注销'];
|
||||||
$filename = '用户列表_' . date('YmdHis', time());
|
$filename = '用户列表_' . date('YmdHis', time());
|
||||||
$export = $fileKey = [];
|
$export = $fileKey = [];
|
||||||
if (!empty($data)) {
|
if (!empty($data)) {
|
||||||
@ -51,7 +51,8 @@ class ExportServices extends BaseServices
|
|||||||
'user_type' => $item['user_type'],
|
'user_type' => $item['user_type'],
|
||||||
'now_money' => $item['now_money'],
|
'now_money' => $item['now_money'],
|
||||||
'last_time' => date('Y-m-d H:i:s', $item['last_time']),
|
'last_time' => date('Y-m-d H:i:s', $item['last_time']),
|
||||||
'add_time' => date('Y-m-d H:i:s', $item['add_time'])
|
'add_time' => date('Y-m-d H:i:s', $item['add_time']),
|
||||||
|
'is_del' => $item['is_del'] ? '已注销' : '正常'
|
||||||
];
|
];
|
||||||
$export[] = $one_data;
|
$export[] = $one_data;
|
||||||
if ($i == 0) {
|
if ($i == 0) {
|
||||||
@ -481,23 +482,13 @@ class ExportServices extends BaseServices
|
|||||||
$export = [];
|
$export = [];
|
||||||
if (!empty($data)) {
|
if (!empty($data)) {
|
||||||
foreach ($data as $item) {
|
foreach ($data as $item) {
|
||||||
switch ($item['recharge_type']) {
|
|
||||||
case 'routine':
|
|
||||||
$item['_recharge_type'] = '小程序充值';
|
|
||||||
break;
|
|
||||||
case 'weixin':
|
|
||||||
$item['_recharge_type'] = '公众号充值';
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
$item['_recharge_type'] = '其他充值';
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
$item['_pay_time'] = $item['pay_time'] ? date('Y-m-d H:i:s', $item['pay_time']) : '暂无';
|
$item['_pay_time'] = $item['pay_time'] ? date('Y-m-d H:i:s', $item['pay_time']) : '暂无';
|
||||||
$item['_add_time'] = $item['add_time'] ? date('Y-m-d H:i:s', $item['add_time']) : '暂无';
|
$item['_add_time'] = $item['add_time'] ? date('Y-m-d H:i:s', $item['add_time']) : '暂无';
|
||||||
$item['paid_type'] = $item['paid'] ? '已支付' : '未支付';
|
$item['paid_type'] = $item['paid'] ? '已支付' : '未支付';
|
||||||
|
|
||||||
$export[] = [
|
$export[] = [
|
||||||
$item['nickname'],
|
$item['nickname'],
|
||||||
|
$item['order_id'],
|
||||||
$item['price'],
|
$item['price'],
|
||||||
$item['paid_type'],
|
$item['paid_type'],
|
||||||
$item['_recharge_type'],
|
$item['_recharge_type'],
|
||||||
@ -507,7 +498,7 @@ class ExportServices extends BaseServices
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$header = ['昵称/姓名', '充值金额', '是否支付', '充值类型', '支付时间', '是否退款', '添加时间'];
|
$header = ['昵称/姓名', '订单号', '充值金额', '是否支付', '充值类型', '支付时间', '是否退款', '添加时间'];
|
||||||
$title = ['充值记录', '充值记录' . time(), ' 生成时间:' . date('Y-m-d H:i:s', time())];
|
$title = ['充值记录', '充值记录' . time(), ' 生成时间:' . date('Y-m-d H:i:s', time())];
|
||||||
$filename = '充值记录_' . date('YmdHis', time());
|
$filename = '充值记录_' . date('YmdHis', time());
|
||||||
$suffix = 'xlsx';
|
$suffix = 'xlsx';
|
||||||
|
|||||||
@ -17,7 +17,10 @@ use app\services\order\StoreOrderCartInfoServices;
|
|||||||
use app\services\order\StoreOrderServices;
|
use app\services\order\StoreOrderServices;
|
||||||
use app\services\wechat\WechatUserServices;
|
use app\services\wechat\WechatUserServices;
|
||||||
use crmeb\exceptions\ApiException;
|
use crmeb\exceptions\ApiException;
|
||||||
|
use crmeb\services\CacheService;
|
||||||
|
use crmeb\services\pay\extend\allinpay\AllinPay;
|
||||||
use crmeb\utils\Str;
|
use crmeb\utils\Str;
|
||||||
|
use think\exception\ValidateException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 订单发起支付
|
* 订单发起支付
|
||||||
@ -38,16 +41,75 @@ class OrderPayServices
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 订单发起支付
|
* 获取支付方式
|
||||||
|
* @param string $payType
|
||||||
|
* @return string
|
||||||
|
* @author 等风来
|
||||||
|
* @email 136327134@qq.com
|
||||||
|
* @date 2023/2/15
|
||||||
|
*/
|
||||||
|
public function getPayType(string $payType)
|
||||||
|
{
|
||||||
|
//微信支付没有开启,通联支付开启,用户访问端在小程序或者公众号的时候,使用通联微信H5支付
|
||||||
|
if ($payType == PayServices::WEIXIN_PAY && !request()->isH5() && !request()->isApp()) {
|
||||||
|
$payType = sys_config('pay_weixin_open', 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
//支付宝没有开启,通联支付开了,用户使用支付宝支付,并且在app端访问的时候,使用通联app支付宝支付
|
||||||
|
if ($payType == PayServices::ALIAPY_PAY && request()->isApp()) {
|
||||||
|
$payType = sys_config('ali_pay_status', 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $payType;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取返回类型
|
||||||
|
* @param string $payType
|
||||||
|
* @return string
|
||||||
|
* @author 等风来
|
||||||
|
* @email 136327134@qq.com
|
||||||
|
* @date 2023/2/15
|
||||||
|
*/
|
||||||
|
public function payStatus(string $payType)
|
||||||
|
{
|
||||||
|
if ($payType == PayServices::WEIXIN_PAY) {
|
||||||
|
if (request()->isH5()) {
|
||||||
|
$payStstus = 'wechat_h5_pay';
|
||||||
|
} else if (request()->isPc()) {
|
||||||
|
$payStstus = 'wechat_pc_pay';
|
||||||
|
} else {
|
||||||
|
$payStstus = 'wechat_pay';
|
||||||
|
}
|
||||||
|
} else if ($payType == PayServices::ALIAPY_PAY) {
|
||||||
|
$payStstus = 'alipay_pay';
|
||||||
|
} else if ($payType == PayServices::ALLIN_PAY) {
|
||||||
|
$payStstus = 'allinpay_pay';
|
||||||
|
} else {
|
||||||
|
throw new ValidateException('获取支付返回类型失败');
|
||||||
|
}
|
||||||
|
return $payStstus;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发起支付前
|
||||||
* @param array $orderInfo
|
* @param array $orderInfo
|
||||||
* @param string $payType
|
* @param string $payType
|
||||||
* @return array|string
|
* @param array $options
|
||||||
|
* @return array
|
||||||
* @throws \think\db\exception\DataNotFoundException
|
* @throws \think\db\exception\DataNotFoundException
|
||||||
* @throws \think\db\exception\DbException
|
* @throws \think\db\exception\DbException
|
||||||
* @throws \think\db\exception\ModelNotFoundException
|
* @throws \think\db\exception\ModelNotFoundException
|
||||||
|
* @author 等风来
|
||||||
|
* @email 136327134@qq.com
|
||||||
|
* @date 2023/2/15
|
||||||
*/
|
*/
|
||||||
public function orderPay(array $orderInfo, string $payType, array $options = [])
|
public function beforePay(array $orderInfo, string $payType, array $options = [])
|
||||||
{
|
{
|
||||||
|
$wehcat = $payType == PayServices::WEIXIN_PAY;
|
||||||
|
|
||||||
|
$payType = $this->getPayType($payType);
|
||||||
|
|
||||||
if ($orderInfo['paid']) {
|
if ($orderInfo['paid']) {
|
||||||
throw new ApiException(410174);
|
throw new ApiException(410174);
|
||||||
}
|
}
|
||||||
@ -55,27 +117,39 @@ class OrderPayServices
|
|||||||
throw new ApiException(410274);
|
throw new ApiException(410274);
|
||||||
}
|
}
|
||||||
|
|
||||||
$openid = '';
|
switch ($payType) {
|
||||||
if (!in_array($payType, ['weixinh5', 'pc', 'allinpay']) && !request()->isApp()) {
|
case PayServices::WEIXIN_PAY:
|
||||||
if ($payType === 'weixin') {
|
$openid = '';
|
||||||
$userType = 'wechat';
|
if (request()->isWechat() || request()->isRoutine()) {
|
||||||
} else {
|
if (request()->isWechat()) {
|
||||||
$userType = $payType;
|
$userType = 'wechat';
|
||||||
}
|
} else {
|
||||||
/** @var WechatUserServices $services */
|
$userType = 'routine';
|
||||||
$services = app()->make(WechatUserServices::class);
|
}
|
||||||
$openid = $services->uidToOpenid($orderInfo['pay_uid'] ?? $orderInfo['uid'], $userType);
|
/** @var WechatUserServices $services */
|
||||||
if (!$openid) {
|
$services = app()->make(WechatUserServices::class);
|
||||||
throw new ApiException(410275);
|
$openid = $services->uidToOpenid($orderInfo['pay_uid'] ?? $orderInfo['uid'], $userType);
|
||||||
}
|
if (!$openid) {
|
||||||
|
throw new ApiException(410275);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$options['openid'] = $openid;
|
||||||
|
break;
|
||||||
|
case PayServices::ALLIN_PAY:
|
||||||
|
if ($wehcat) {
|
||||||
|
$options['wechat'] = $wehcat;
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$site_name = sys_config('site_name');
|
$site_name = sys_config('site_name');
|
||||||
if (isset($orderInfo['member_type'])) {
|
if (isset($orderInfo['member_type'])) {
|
||||||
$body = Str::substrUTf8($site_name . '--' . $orderInfo['member_type'], 20);
|
$body = Str::substrUTf8($site_name . '--' . $orderInfo['member_type'], 20);
|
||||||
$successAction = "member";
|
$successAction = "member";
|
||||||
/** @var OtherOrderServices $otherOrderServices */
|
/** @var OtherOrderServices $otherOrderServices */
|
||||||
$otherOrderServices = app()->make(OtherOrderServices::class);
|
$otherOrderServices = app()->make(OtherOrderServices::class);
|
||||||
$otherOrderServices->update($orderInfo['id'], ['pay_type' => 'alipay']);
|
$otherOrderServices->update($orderInfo['id'], ['pay_type' => $payType]);
|
||||||
} else {
|
} else {
|
||||||
/** @var StoreOrderCartInfoServices $orderInfoServices */
|
/** @var StoreOrderCartInfoServices $orderInfoServices */
|
||||||
$orderInfoServices = app()->make(StoreOrderCartInfoServices::class);
|
$orderInfoServices = app()->make(StoreOrderCartInfoServices::class);
|
||||||
@ -84,52 +158,55 @@ class OrderPayServices
|
|||||||
$successAction = "product";
|
$successAction = "product";
|
||||||
/** @var StoreOrderServices $orderServices */
|
/** @var StoreOrderServices $orderServices */
|
||||||
$orderServices = app()->make(StoreOrderServices::class);
|
$orderServices = app()->make(StoreOrderServices::class);
|
||||||
$orderServices->update($orderInfo['id'], ['pay_type' => 'weixin']);
|
$orderServices->update($orderInfo['id'], ['pay_type' => $payType]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$body) {
|
if (!$body) {
|
||||||
throw new ApiException(410276);
|
throw new ApiException(410276);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->payServices->setOptions($options)->pay($payType, $openid, $orderInfo['order_id'], $orderInfo['pay_price'], $successAction, $body);
|
//发起支付
|
||||||
|
$jsConfig = $this->payServices->pay($payType, $orderInfo['order_id'], $orderInfo['pay_price'], $successAction, $body, $options);
|
||||||
|
|
||||||
|
//发起支付后处理返回参数
|
||||||
|
$payInfo = $this->afterPay($orderInfo, $jsConfig, $payType);
|
||||||
|
$statusType = $this->payStatus($payType);
|
||||||
|
|
||||||
|
return [
|
||||||
|
'status' => $statusType,
|
||||||
|
'payInfo' => $payInfo,
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 支付宝支付
|
* 支付发起后处理返回参数
|
||||||
* @param array $orderInfo
|
* @param $order
|
||||||
* @param string $quitUrl
|
* @param $jsConfig
|
||||||
* @return array|string
|
* @param string $payType
|
||||||
|
* @return array
|
||||||
|
* @author 等风来
|
||||||
|
* @email 136327134@qq.com
|
||||||
|
* @date 2023/2/15
|
||||||
*/
|
*/
|
||||||
public function alipayOrder(array $orderInfo, string $quitUrl, bool $isCode = false)
|
public function afterPay($order, $jsConfig, string $payType)
|
||||||
{
|
{
|
||||||
if ($orderInfo['paid']) {
|
$payKey = md5($order['order_id']);
|
||||||
throw new ApiException(410174);
|
switch ($payType) {
|
||||||
}
|
case PayServices::ALIAPY_PAY:
|
||||||
if ($orderInfo['pay_price'] <= 0) {
|
if (request()->isPc()) $jsConfig->invalid = time() + 60;
|
||||||
throw new ApiException(410274);
|
CacheService::set($payKey, ['order_id' => $order['order_id'], 'other_pay_type' => false], 300);
|
||||||
}
|
break;
|
||||||
$site_name = sys_config('site_name');
|
case PayServices::ALLIN_PAY:
|
||||||
if (isset($orderInfo['member_type'])) {
|
if (request()->isWechat()) {
|
||||||
$body = Str::substrUTf8($site_name . '--' . $orderInfo['member_type'], 30);
|
$payUrl = AllinPay::UNITODER_H5UNIONPAY;
|
||||||
$successAction = "member";
|
}
|
||||||
/** @var OtherOrderServices $otherOrderServices */
|
break;
|
||||||
$otherOrderServices = app()->make(OtherOrderServices::class);
|
case PayServices::WEIXIN_PAY:
|
||||||
$otherOrderServices->update($orderInfo['id'], ['pay_type' => 'alipay']);
|
if (isset($jsConfig['mweb_url'])) {
|
||||||
} else {
|
$jsConfig['h5_url'] = $jsConfig['mweb_url'];
|
||||||
/** @var StoreOrderCartInfoServices $orderInfoServices */
|
}
|
||||||
$orderInfoServices = app()->make(StoreOrderCartInfoServices::class);
|
|
||||||
$body = $orderInfoServices->getCarIdByProductTitle((int)$orderInfo['id']);
|
|
||||||
$body = Str::substrUTf8($site_name . '--' . $body, 30);
|
|
||||||
$successAction = "product";
|
|
||||||
/** @var StoreOrderServices $orderServices */
|
|
||||||
$orderServices = app()->make(StoreOrderServices::class);
|
|
||||||
$orderServices->update($orderInfo['id'], ['pay_type' => 'alipay']);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$body) {
|
return ['jsConfig' => $jsConfig, 'order_id' => $order['order_id'], 'pay_key' => $payKey, 'pay_url' => $payUrl ?? ''];
|
||||||
throw new ApiException(410276);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->payServices->pay('alipay', $quitUrl, $orderInfo['order_id'], $orderInfo['pay_price'], $successAction, $body, $isCode);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -16,7 +16,7 @@ use app\services\order\StoreOrderSuccessServices;
|
|||||||
use app\services\user\UserRechargeServices;
|
use app\services\user\UserRechargeServices;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 支付成功回调
|
* 支付成功回调 所有的异步通知回调都会走下面的三个方法,不在取分微信/支付宝支付回调
|
||||||
* Class PayNotifyServices
|
* Class PayNotifyServices
|
||||||
* @package app\services\pay
|
* @package app\services\pay
|
||||||
*/
|
*/
|
||||||
@ -24,11 +24,11 @@ class PayNotifyServices
|
|||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 微信支付-订单支付成功之后
|
* 订单支付成功之后
|
||||||
* @param string|null $order_id 订单id
|
* @param string|null $order_id 订单id
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function wechatProduct(string $order_id = null, string $trade_no = null)
|
public function wechatProduct(string $order_id = null, string $trade_no = null, string $payType = PayServices::WEIXIN_PAY)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
/** @var StoreOrderSuccessServices $services */
|
/** @var StoreOrderSuccessServices $services */
|
||||||
@ -36,35 +36,35 @@ class PayNotifyServices
|
|||||||
$orderInfo = $services->getOne(['order_id' => $order_id]);
|
$orderInfo = $services->getOne(['order_id' => $order_id]);
|
||||||
if (!$orderInfo) return true;
|
if (!$orderInfo) return true;
|
||||||
if ($orderInfo->paid) return true;
|
if ($orderInfo->paid) return true;
|
||||||
return $services->paySuccess($orderInfo->toArray(), PayServices::WEIXIN_PAY, ['trade_no' => $trade_no]);
|
return $services->paySuccess($orderInfo->toArray(), $payType, ['trade_no' => $trade_no]);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 微信支付-充值成功后
|
* 充值成功后
|
||||||
* @param string|null $order_id 订单id
|
* @param string|null $order_id 订单id
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function wechatUserRecharge(string $order_id = null, string $trade_no = null)
|
public function wechatUserRecharge(string $order_id = null, string $trade_no = null, string $payType = PayServices::WEIXIN_PAY)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
/** @var UserRechargeServices $userRecharge */
|
/** @var UserRechargeServices $userRecharge */
|
||||||
$userRecharge = app()->make(UserRechargeServices::class);
|
$userRecharge = app()->make(UserRechargeServices::class);
|
||||||
if ($userRecharge->be(['order_id' => $order_id, 'paid' => 1])) return true;
|
if ($userRecharge->be(['order_id' => $order_id, 'paid' => 1])) return true;
|
||||||
return $userRecharge->rechargeSuccess($order_id, ['trade_no' => $trade_no]);
|
return $userRecharge->rechargeSuccess($order_id, ['trade_no' => $trade_no, 'pay_type' => $payType]);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 微信支付-购买会员
|
* 购买会员
|
||||||
* @param string|null $order_id
|
* @param string|null $order_id
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function wechatMember(string $order_id = null, string $trade_no = null)
|
public function wechatMember(string $order_id = null, string $trade_no = null, string $payType = PayServices::WEIXIN_PAY)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
/** @var OtherOrderServices $services */
|
/** @var OtherOrderServices $services */
|
||||||
@ -72,110 +72,10 @@ class PayNotifyServices
|
|||||||
$orderInfo = $services->getOne(['order_id' => $order_id]);
|
$orderInfo = $services->getOne(['order_id' => $order_id]);
|
||||||
if (!$orderInfo) return true;
|
if (!$orderInfo) return true;
|
||||||
if ($orderInfo->paid) return true;
|
if ($orderInfo->paid) return true;
|
||||||
return $services->paySuccess($orderInfo->toArray());
|
return $services->paySuccess($orderInfo->toArray(), $payType, ['trade_no' => $trade_no]);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 支付宝支付-异步回调处理事件
|
|
||||||
* @param string|null $order_id
|
|
||||||
* @param string|null $trade_no
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
public function aliyunProduct(string $order_id = null, string $trade_no = null)
|
|
||||||
{
|
|
||||||
if (!$order_id || !$trade_no) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
/** @var StoreOrderSuccessServices $services */
|
|
||||||
$services = app()->make(StoreOrderSuccessServices::class);
|
|
||||||
$orderInfo = $services->getOne(['order_id' => $order_id]);
|
|
||||||
if (!$orderInfo) return true;
|
|
||||||
if ($orderInfo->paid) return true;
|
|
||||||
return $services->paySuccess($orderInfo->toArray(), PayServices::ALIAPY_PAY, ['trade_no' => $trade_no]);
|
|
||||||
} catch (\Throwable $e) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 支付宝支付-购买会员卡
|
|
||||||
* @param string|null $order_id
|
|
||||||
* @param string|null $trade_no
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
public function aliyunMember(string $order_id = null, string $trade_no = null)
|
|
||||||
{
|
|
||||||
if (!$order_id || !$trade_no) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
/** @var OtherOrderServices $services */
|
|
||||||
$services = app()->make(OtherOrderServices::class);
|
|
||||||
$orderInfo = $services->getOne(['order_id' => $order_id]);
|
|
||||||
if (!$orderInfo) return true;
|
|
||||||
if ($orderInfo->paid) return true;
|
|
||||||
return $services->paySuccess($orderInfo->toArray(), PayServices::ALIAPY_PAY, ['trade_no' => $trade_no]);
|
|
||||||
} catch (\Throwable $e) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 通联支付-订单支付成功之后
|
|
||||||
* @param string|null $order_id 订单id
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
public function allinProduct(string $order_id = null, string $trade_no = null)
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
/** @var StoreOrderSuccessServices $services */
|
|
||||||
$services = app()->make(StoreOrderSuccessServices::class);
|
|
||||||
$orderInfo = $services->getOne(['order_id' => $order_id]);
|
|
||||||
if (!$orderInfo) return true;
|
|
||||||
if ($orderInfo->paid) return true;
|
|
||||||
return $services->paySuccess($orderInfo->toArray(), PayServices::ALLIN_PAY, ['trade_no' => $trade_no]);
|
|
||||||
} catch (\Exception $e) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 通联支付-充值成功后
|
|
||||||
* @param string|null $order_id 订单id
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
public function allinUserRecharge(string $order_id = null, string $trade_no = null)
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
/** @var UserRechargeServices $userRecharge */
|
|
||||||
$userRecharge = app()->make(UserRechargeServices::class);
|
|
||||||
if ($userRecharge->be(['order_id' => $order_id, 'paid' => 1])) return true;
|
|
||||||
return $userRecharge->rechargeSuccess($order_id, ['trade_no' => $trade_no]);
|
|
||||||
} catch (\Exception $e) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 通联支付-购买会员
|
|
||||||
* @param string|null $order_id
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
public function allinMember(string $order_id = null, string $trade_no = null)
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
/** @var OtherOrderServices $services */
|
|
||||||
$services = app()->make(OtherOrderServices::class);
|
|
||||||
$orderInfo = $services->getOne(['order_id' => $order_id]);
|
|
||||||
if (!$orderInfo) return true;
|
|
||||||
if ($orderInfo->paid) return true;
|
|
||||||
return $services->paySuccess($orderInfo->toArray(), PayServices::ALLIN_PAY);
|
|
||||||
} catch (\Exception $e) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -105,7 +105,7 @@ class PayServices
|
|||||||
* @param string $body
|
* @param string $body
|
||||||
* @return array|string
|
* @return array|string
|
||||||
*/
|
*/
|
||||||
public function pay(string $payType, string $openid, string $orderId, string $price, string $successAction, string $body, bool $isCode = false)
|
public function pay(string $payType, string $orderId, string $price, string $successAction, string $body, array $options = [])
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
|
|
||||||
@ -116,29 +116,19 @@ class PayServices
|
|||||||
if (sys_config('pay_wechat_type') == 1) {
|
if (sys_config('pay_wechat_type') == 1) {
|
||||||
$payType = 'v3_wechat_pay';
|
$payType = 'v3_wechat_pay';
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
|
if ($payType == 'alipay') {
|
||||||
if ($payType == 'alipay') {
|
$payType = 'ali_pay';
|
||||||
$payType = 'ali_pay';
|
} elseif ($payType == 'allinpay') {
|
||||||
}
|
$payType = 'allin_pay';
|
||||||
|
|
||||||
|
|
||||||
$options = [];
|
|
||||||
if (self::ALLIN_PAY === $payType) {
|
|
||||||
$options['returl'] = $this->getOption('returl');
|
|
||||||
if ($options['returl']) {
|
|
||||||
$options['returl'] = str_replace('http://', 'https://', $options['returl']);
|
|
||||||
}
|
}
|
||||||
$options['is_wechat'] = $this->getOption('is_wechat', false);
|
|
||||||
$options['appid'] = sys_config('routine_appId');
|
|
||||||
$payType = 'allin_pay';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @var Pay $pay */
|
/** @var Pay $pay */
|
||||||
$pay = app()->make(Pay::class, [$payType]);
|
$pay = app()->make(Pay::class, [$payType]);
|
||||||
|
|
||||||
|
|
||||||
return $pay->create($orderId, $price, $successAction, $body, '', ['openid' => $openid, 'isCode' => $isCode, 'pay_new_weixin_open' => (bool)sys_config('pay_new_weixin_open')] + $options);
|
return $pay->create($orderId, $price, $successAction, $body, '', ['pay_new_weixin_open' => (bool)sys_config('pay_new_weixin_open')] + $options);
|
||||||
|
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
if (strpos($e->getMessage(), 'api unauthorized rid') !== false) {
|
if (strpos($e->getMessage(), 'api unauthorized rid') !== false) {
|
||||||
@ -147,4 +137,57 @@ class PayServices
|
|||||||
throw new ApiException($e->getMessage());
|
throw new ApiException($e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TODO 发起支付 弃用
|
||||||
|
* @param string $payType
|
||||||
|
* @param string $openid
|
||||||
|
* @param string $orderId
|
||||||
|
* @param string $price
|
||||||
|
* @param string $successAction
|
||||||
|
* @param string $body
|
||||||
|
* @return array|string
|
||||||
|
*/
|
||||||
|
// public function pay(string $payType, string $openid, string $orderId, string $price, string $successAction, string $body, bool $isCode = false)
|
||||||
|
// {
|
||||||
|
// try {
|
||||||
|
//
|
||||||
|
// //这些全都是微信支付
|
||||||
|
// if (in_array($payType, ['routine', 'weixinh5', 'weixin', 'pc', 'store'])) {
|
||||||
|
// $payType = 'wechat_pay';
|
||||||
|
// //判断是否使用v3
|
||||||
|
// if (sys_config('pay_wechat_type') == 1) {
|
||||||
|
// $payType = 'v3_wechat_pay';
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// if ($payType == 'alipay') {
|
||||||
|
// $payType = 'ali_pay';
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// $options = [];
|
||||||
|
// if (self::ALLIN_PAY === $payType) {
|
||||||
|
// $options['returl'] = $this->getOption('returl');
|
||||||
|
// if ($options['returl']) {
|
||||||
|
// $options['returl'] = str_replace('http://', 'https://', $options['returl']);
|
||||||
|
// }
|
||||||
|
// $options['is_wechat'] = $this->getOption('is_wechat', false);
|
||||||
|
// $options['appid'] = sys_config('routine_appId');
|
||||||
|
// $payType = 'allin_pay';
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// /** @var Pay $pay */
|
||||||
|
// $pay = app()->make(Pay::class, [$payType]);
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// return $pay->create($orderId, $price, $successAction, $body, '', ['openid' => $openid, 'isCode' => $isCode, 'pay_new_weixin_open' => (bool)sys_config('pay_new_weixin_open')] + $options);
|
||||||
|
//
|
||||||
|
// } catch (\Exception $e) {
|
||||||
|
// if (strpos($e->getMessage(), 'api unauthorized rid') !== false) {
|
||||||
|
// throw new ApiException('请在微信支付配置中将小程序商户号选择改为商户号绑定');
|
||||||
|
// }
|
||||||
|
// throw new ApiException($e->getMessage());
|
||||||
|
// }
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|||||||
@ -14,9 +14,9 @@ namespace app\services\pay;
|
|||||||
|
|
||||||
|
|
||||||
use app\model\user\UserRecharge;
|
use app\model\user\UserRecharge;
|
||||||
use app\services\user\UserRechargeServices;
|
|
||||||
use app\services\wechat\WechatUserServices;
|
use app\services\wechat\WechatUserServices;
|
||||||
use crmeb\exceptions\ApiException;
|
use crmeb\exceptions\ApiException;
|
||||||
|
use crmeb\services\pay\extend\allinpay\AllinPay;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -44,29 +44,40 @@ class RechargeServices
|
|||||||
if ($recharge['paid'] == 1) {
|
if ($recharge['paid'] == 1) {
|
||||||
throw new ApiException(410174);
|
throw new ApiException(410174);
|
||||||
}
|
}
|
||||||
$userType = '';
|
$payType = '';
|
||||||
switch ($recharge['recharge_type']) {
|
switch ($recharge['recharge_type']) {
|
||||||
case 'weixin':
|
case 'weixin':
|
||||||
case 'weixinh5':
|
case 'weixinh5':
|
||||||
$userType = 'wechat';
|
|
||||||
break;
|
|
||||||
case 'routine':
|
case 'routine':
|
||||||
$userType = 'routine';
|
$payType = PayServices::WEIXIN_PAY;
|
||||||
break;
|
break;
|
||||||
case PayServices::ALIAPY_PAY:
|
case PayServices::ALIAPY_PAY:
|
||||||
$userType = PayServices::ALIAPY_PAY;
|
$payType = PayServices::ALIAPY_PAY;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
$userType = get_pay_type($userType);
|
$payType = app()->make(OrderPayServices::class)->getPayType($payType);
|
||||||
|
|
||||||
if (!$userType) {
|
if (!$payType) {
|
||||||
throw new ApiException(410278);
|
throw new ApiException(410278);
|
||||||
}
|
}
|
||||||
/** @var WechatUserServices $wechatUser */
|
|
||||||
$wechatUser = app()->make(WechatUserServices::class);
|
if ($recharge['recharge_type'] == PayServices::WEIXIN_PAY && !request()->isH5()) {
|
||||||
$openid = $wechatUser->uidToOpenid((int)$recharge['uid'], $userType);
|
|
||||||
if (in_array($recharge['recharge_type'], ['weixin', 'routine']) && !request()->isApp()) {
|
/** @var WechatUserServices $wechatUser */
|
||||||
|
$wechatUser = app()->make(WechatUserServices::class);
|
||||||
|
if (request()->isApp()) {
|
||||||
|
$userType = 'app';
|
||||||
|
} else if (request()->isRoutine()) {
|
||||||
|
$userType = 'routine';
|
||||||
|
} else if (request()->isWechat()) {
|
||||||
|
$userType = 'wechat';
|
||||||
|
} else {
|
||||||
|
throw new ApiException(410275);
|
||||||
|
}
|
||||||
|
|
||||||
|
$openid = $wechatUser->uidToOpenid((int)$recharge['uid'], $userType);
|
||||||
|
|
||||||
if (!$openid) {
|
if (!$openid) {
|
||||||
throw new ApiException(410275);
|
throw new ApiException(410275);
|
||||||
}
|
}
|
||||||
@ -74,13 +85,21 @@ class RechargeServices
|
|||||||
$openid = '';
|
$openid = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
$res = $this->pay->pay($recharge['recharge_type'], $openid, $recharge['order_id'], $recharge['price'], 'user_recharge', '用户充值');
|
$res = $this->pay->pay($payType, $recharge['order_id'], $recharge['price'], 'user_recharge', '用户充值', ['openid' => $openid]);
|
||||||
|
|
||||||
if ($userType === PayServices::ALLIN_PAY) {
|
if ($payType == PayServices::WEIXIN_PAY) {
|
||||||
$res['pay_type'] = $userType;
|
if (request()->isH5()) {
|
||||||
|
$payStstus = 'wechat_h5_pay';
|
||||||
|
} else {
|
||||||
|
$payStstus = 'wechat_pay';
|
||||||
|
}
|
||||||
|
} else if ($payType == PayServices::ALIAPY_PAY) {
|
||||||
|
$payStstus = 'alipay_pay';
|
||||||
|
} else if ($payType == PayServices::ALLIN_PAY) {
|
||||||
|
$payStstus = 'allinpay_pay';
|
||||||
}
|
}
|
||||||
|
|
||||||
return $res;
|
return ['pay_url' => AllinPay::UNITODER_H5UNIONPAY, 'jsConfig' => $res, 'pay_key' => md5($recharge['order_id']), 'order_id' => $recharge['order_id'], 'pay_type' => strtoupper($payStstus)];
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -14,6 +14,7 @@ namespace app\services\product\product;
|
|||||||
|
|
||||||
use app\dao\product\product\StoreCategoryDao;
|
use app\dao\product\product\StoreCategoryDao;
|
||||||
use app\services\BaseServices;
|
use app\services\BaseServices;
|
||||||
|
use app\services\diy\DiyServices;
|
||||||
use crmeb\exceptions\AdminException;
|
use crmeb\exceptions\AdminException;
|
||||||
use crmeb\services\CacheService;
|
use crmeb\services\CacheService;
|
||||||
use crmeb\services\FormBuilder as Form;
|
use crmeb\services\FormBuilder as Form;
|
||||||
@ -95,7 +96,7 @@ class StoreCategoryServices extends BaseServices
|
|||||||
$where = [];
|
$where = [];
|
||||||
if ($show !== '') $where['is_show'] = $show;
|
if ($show !== '') $where['is_show'] = $show;
|
||||||
if (!$type) $where['pid'] = 0;
|
if (!$type) $where['pid'] = 0;
|
||||||
$data = get_tree_children($this->dao->getTierList($where, ['id as value', 'cate_name as label', 'pid']), 'children', 'value');
|
$data = get_tree_children($this->dao->getTierList($where, ['id', 'id as value', 'cate_name as label', 'cate_name as title', 'pid']), 'children', 'id');
|
||||||
foreach ($data as &$item) {
|
foreach ($data as &$item) {
|
||||||
if (!isset($item['children'])) {
|
if (!isset($item['children'])) {
|
||||||
$item['disabled'] = true;
|
$item['disabled'] = true;
|
||||||
@ -117,7 +118,6 @@ class StoreCategoryServices extends BaseServices
|
|||||||
throw new AdminException(100005);
|
throw new AdminException(100005);
|
||||||
} else {
|
} else {
|
||||||
$this->cacheDriver()->clear();
|
$this->cacheDriver()->clear();
|
||||||
$this->cacheDriver()->set('category_version', uniqid());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -205,7 +205,6 @@ class StoreCategoryServices extends BaseServices
|
|||||||
if (!$res) throw new AdminException(100006);
|
if (!$res) throw new AdminException(100006);
|
||||||
|
|
||||||
$this->cacheDriver()->clear();
|
$this->cacheDriver()->clear();
|
||||||
$this->cacheDriver()->set('category_version', uniqid());
|
|
||||||
|
|
||||||
return (int)$res->id;
|
return (int)$res->id;
|
||||||
}
|
}
|
||||||
@ -214,6 +213,12 @@ class StoreCategoryServices extends BaseServices
|
|||||||
* 保存修改数据
|
* 保存修改数据
|
||||||
* @param $id
|
* @param $id
|
||||||
* @param $data
|
* @param $data
|
||||||
|
* @throws \think\db\exception\DataNotFoundException
|
||||||
|
* @throws \think\db\exception\DbException
|
||||||
|
* @throws \think\db\exception\ModelNotFoundException
|
||||||
|
* @author 吴汐
|
||||||
|
* @email 442384644@qq.com
|
||||||
|
* @date 2023/02/23
|
||||||
*/
|
*/
|
||||||
public function editData($id, $data)
|
public function editData($id, $data)
|
||||||
{
|
{
|
||||||
@ -239,7 +244,6 @@ class StoreCategoryServices extends BaseServices
|
|||||||
});
|
});
|
||||||
|
|
||||||
$this->cacheDriver()->clear();
|
$this->cacheDriver()->clear();
|
||||||
$this->cacheDriver()->set('category_version', uniqid());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -255,7 +259,6 @@ class StoreCategoryServices extends BaseServices
|
|||||||
if (!$res) throw new AdminException(100008);
|
if (!$res) throw new AdminException(100008);
|
||||||
|
|
||||||
$this->cacheDriver()->clear();
|
$this->cacheDriver()->clear();
|
||||||
$this->cacheDriver()->set('category_version', uniqid());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -267,7 +270,10 @@ class StoreCategoryServices extends BaseServices
|
|||||||
public function getCategoryVersion()
|
public function getCategoryVersion()
|
||||||
{
|
{
|
||||||
return $this->cacheDriver()->remember('category_version', function () {
|
return $this->cacheDriver()->remember('category_version', function () {
|
||||||
return uniqid();
|
return [
|
||||||
|
'is_diy' => app()->make(DiyServices::class)->value(['status' => 1], 'is_diy'),
|
||||||
|
'version' => uniqid()
|
||||||
|
];
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -275,6 +281,12 @@ class StoreCategoryServices extends BaseServices
|
|||||||
* 获取指定id下的分类,一=以数组形式返回
|
* 获取指定id下的分类,一=以数组形式返回
|
||||||
* @param string $cateIds
|
* @param string $cateIds
|
||||||
* @return array
|
* @return array
|
||||||
|
* @throws \think\db\exception\DataNotFoundException
|
||||||
|
* @throws \think\db\exception\DbException
|
||||||
|
* @throws \think\db\exception\ModelNotFoundException
|
||||||
|
* @author 吴汐
|
||||||
|
* @email 442384644@qq.com
|
||||||
|
* @date 2023/02/23
|
||||||
*/
|
*/
|
||||||
public function getCateArray(string $cateIds)
|
public function getCateArray(string $cateIds)
|
||||||
{
|
{
|
||||||
@ -283,7 +295,14 @@ class StoreCategoryServices extends BaseServices
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 前台分类列表
|
* 前台分类列表
|
||||||
* @return bool|mixed|null
|
* @param array $where
|
||||||
|
* @return array|mixed
|
||||||
|
* @throws \think\db\exception\DataNotFoundException
|
||||||
|
* @throws \think\db\exception\DbException
|
||||||
|
* @throws \think\db\exception\ModelNotFoundException
|
||||||
|
* @author 吴汐
|
||||||
|
* @email 442384644@qq.com
|
||||||
|
* @date 2023/02/23
|
||||||
*/
|
*/
|
||||||
public function getCategory(array $where)
|
public function getCategory(array $where)
|
||||||
{
|
{
|
||||||
|
|||||||
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