diff --git a/app/common/dao/store/order/StoreOrderDao.php b/app/common/dao/store/order/StoreOrderDao.php index dba1cab..e5dc8d7 100644 --- a/app/common/dao/store/order/StoreOrderDao.php +++ b/app/common/dao/store/order/StoreOrderDao.php @@ -291,7 +291,7 @@ class StoreOrderDao extends BaseDao ->when(isset($where['uid']) && $where['uid'] !== '', function ($query) use ($where) { $query->where('uid', $where['uid']); }) - ->when($where['activity_type'] == 20, function ($query) use ($where) { + ->when(!empty($where['activity_type']) && $where['activity_type'] == 20, function ($query) use ($where) { $query->where('mer_id', $where['mer_id'] ?? 0); }) ->when(isset($where['is_user']) && $where['is_user'] !== '', function ($query) use ($where) { diff --git a/app/common/repositories/store/order/StoreOrderRepository.php b/app/common/repositories/store/order/StoreOrderRepository.php index 57a8b4a..c32e5d8 100644 --- a/app/common/repositories/store/order/StoreOrderRepository.php +++ b/app/common/repositories/store/order/StoreOrderRepository.php @@ -773,11 +773,12 @@ class StoreOrderRepository extends BaseRepository */ public function takeOrder($id, ?User $user = null) { - $order = $this->dao->searchAll(!$user ? [] : ['uid' => $user->uid])->where('order_id', $id)->where('StoreOrder.is_del', '<>',1)->find(); - if (!$order) - throw new ValidateException('订单不存在'); - if ($order['status'] != 1 || ($order['order_type'] && $order['order_type'] != 20)) - throw new ValidateException('订单状态有误'); + $order = $this->dao->searchAll(!$user ? [] : ['uid' => $user->uid]) + ->where('order_id', $id) + ->where('StoreOrder.is_del', '<>',1) + ->find(); + if (!$order) throw new ValidateException('订单不存在'); + if ($order['status'] != 1 || ($order['order_type'] && $order['order_type'] != 20)) throw new ValidateException('订单状态有误'); $func = 'createUserLog'; if (!$user){ $func = 'createSysLog'; @@ -1377,6 +1378,8 @@ class StoreOrderRepository extends BaseRepository if (isset($temp_code)) Queue::push(SendSmsJob::class, ['tempId' => $temp_code, 'id' => $order->order_id]); event('order.delivery', compact('order', 'data')); + + if($data['status'] == 2) event('order.take', compact('order')); return $data; } diff --git a/app/common/repositories/store/platformCommission/LegumesLogRepository.php b/app/common/repositories/store/platformCommission/LegumesLogRepository.php index f665ae6..aef1b0e 100644 --- a/app/common/repositories/store/platformCommission/LegumesLogRepository.php +++ b/app/common/repositories/store/platformCommission/LegumesLogRepository.php @@ -30,6 +30,9 @@ class LegumesLogRepository extends BaseRepository{ ->when((int)$params['uid'] > 0,function($query) use ($params){ $query->where('uid', (int)$params['uid']); }) + ->when(isset($where['status']) && $where['status'] !== '',function($query) use($params){ + $query->where('status',$params['status']); + }) ->when((int)$params['legumes_id'] > 0,function($query) use ($params){ $query->where('legumes_id', (int)$params['legumes_id']); }) diff --git a/app/controller/admin/store/marketing/PlatformCommission.php b/app/controller/admin/store/marketing/PlatformCommission.php index 4f3e55f..a367b41 100644 --- a/app/controller/admin/store/marketing/PlatformCommission.php +++ b/app/controller/admin/store/marketing/PlatformCommission.php @@ -147,7 +147,7 @@ class PlatformCommission extends BaseController{ ['className' => 'el-icon-coin','count' => $legumesLogModel->sum('order_money'),'name' => '订单总金额(积分上限)'], ['className' => 'el-icon-coin','count' => $legumesLogModel->sum('get_integral'),'name' => '已产生积分'], ['className' => 'el-icon-coin','count' => $legumesLogModel->sum('use_integral'),'name' => '已使用积分'], - ['className' => 'el-icon-coin','count' => $legumesLogModel->where('status',0)->sum('use_integral'),'name' => '冻结中积分'], + ['className' => 'el-icon-coin','count' => $legumesLogModel->where('status',0)->sum('get_integral'),'name' => '冻结中积分'], ]); } /** @@ -170,7 +170,7 @@ class PlatformCommission extends BaseController{ */ public function legumesList(){ [$page, $limit] = $this->getPage(); - $params = $this->request->params(['uid','legumes_id']); + $params = $this->request->params(['uid','legumes_id','status']); $data = app()->make(LegumesLogRepository::class)->getRecordList((array)$params,(int)$page,(int)$limit); return app('json')->success($data); diff --git a/app/event.php b/app/event.php index 1a6c072..bf11ede 100644 --- a/app/event.php +++ b/app/event.php @@ -57,6 +57,11 @@ return [ // 支付成功处理平台抽成 'app\listener\platformCommission\OrderPaySuccessEvent' ], + // 订单完成事件触发(进入待评价) + 'order.take' => [ + // 订单完成 - 平台抽成相关冻结内容解冻 + 'app\listener\platformCommission\OrderTakeEvent' + ], ], 'subscribe' => [], ]; diff --git a/app/listener/platformCommission/OrderPaySuccessEvent.php b/app/listener/platformCommission/OrderPaySuccessEvent.php index 2b83c5b..116c00b 100644 --- a/app/listener/platformCommission/OrderPaySuccessEvent.php +++ b/app/listener/platformCommission/OrderPaySuccessEvent.php @@ -16,22 +16,25 @@ class OrderPaySuccessEvent{ public $groupOrder; public function handle($groupOrder){ - $groupOrder = $groupOrder['groupOrder']; - Log::info('支付成功 - 平台抽成处理 - 开始: '.var_export(['uid'=>$groupOrder->uid,'group_order_id'=>$groupOrder->group_order_id],1)); - $this->orderPaySuccessHandle($groupOrder); - // 订单支付成功 触发购买商品升级 - Queue::push(UserBrokerageLevelJob::class,[ - 'uid' => $groupOrder->uid, - 'type' => 'many_goods', - 'inc' => 0, - 'group_order_id' => $groupOrder->group_order_id - ]); - // 订单支付成功 触发购买商品赠送上级权重值 - Queue::push(GiveWeightValueJob::class,[ - 'uid' => $groupOrder->uid, - 'group_order_id' => $groupOrder->group_order_id - ]); - + try{ + $groupOrder = $groupOrder['groupOrder']; + Log::info('支付成功 - 平台抽成处理 - 开始: '.var_export(['uid'=>$groupOrder->uid,'group_order_id'=>$groupOrder->group_order_id],1)); + $this->orderPaySuccessHandle($groupOrder); + // 订单支付成功 触发购买商品升级 + Queue::push(UserBrokerageLevelJob::class,[ + 'uid' => $groupOrder->uid, + 'type' => 'many_goods', + 'inc' => 0, + 'group_order_id' => $groupOrder->group_order_id + ]); + // 订单支付成功 触发购买商品赠送上级权重值 + Queue::push(GiveWeightValueJob::class,[ + 'uid' => $groupOrder->uid, + 'group_order_id' => $groupOrder->group_order_id + ]); + }catch(\Exception $e){ + Log::info('支付成功 - 平台抽成处理 - 错误: '.$e->getMessage()); + } } /** * Common: 支付成功 - 平台抽成处理 diff --git a/app/listener/platformCommission/OrderTakeEvent.php b/app/listener/platformCommission/OrderTakeEvent.php new file mode 100644 index 0000000..e66e45e --- /dev/null +++ b/app/listener/platformCommission/OrderTakeEvent.php @@ -0,0 +1,36 @@ + $order->order_id, + 'uid' => $order->uid + ],1)); + // 分配豆豆解冻 + LegumesLog::update(['status'=>1],['order_id'=>$order->order_id]); + }catch(\Exception $e){ + Log::info('订单进入待评价 - 平台抽成相关处理 - 错误: '.$e->getMessage()); + } + + } + + + +} \ No newline at end of file