From 3ad0b1e9acc0cf17258ff1951ed3a56c60655827 Mon Sep 17 00:00:00 2001 From: wuhui_zzw <1760308791@qq.com> Date: Tue, 2 Jul 2024 18:05:29 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=EF=BC=9A=E9=83=A8=E5=88=86?= =?UTF-8?q?=E7=B1=BB=E5=9E=8B=E8=AE=A2=E5=8D=95=E8=A7=A6=E5=8F=91=E6=94=AF?= =?UTF-8?q?=E4=BB=98=E8=B6=85=E6=97=B6=E8=87=AA=E5=8A=A8=E5=8F=96=E6=B6=88?= =?UTF-8?q?=E8=AE=A2=E5=8D=95=E5=A4=B1=E8=B4=A5=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dao/store/order/StoreGroupOrderDao.php | 4 +- app/common/dao/store/order/StoreOrderDao.php | 4 +- .../store/order/StoreGroupOrderRepository.php | 14 +++--- app/event.php | 10 ++-- .../exchangeQuota/OrderCancelEvent.php | 46 +++++++++++++++++++ crmeb/listens/AutoCancelGroupOrderListen.php | 2 +- 6 files changed, 63 insertions(+), 17 deletions(-) create mode 100644 app/listener/exchangeQuota/OrderCancelEvent.php diff --git a/app/common/dao/store/order/StoreGroupOrderDao.php b/app/common/dao/store/order/StoreGroupOrderDao.php index b77c845..792b33e 100644 --- a/app/common/dao/store/order/StoreGroupOrderDao.php +++ b/app/common/dao/store/order/StoreGroupOrderDao.php @@ -55,9 +55,9 @@ class StoreGroupOrderDao extends BaseDao $query->where('paid',$where['paid']); }) ->when($isWithGoods == 1,function($query) use ($where){ - $query->whereNotIn('activity_type',[30,31,32,33,34,36,37,38]); + $query->whereNotIn('activity_type',[30,31,32,33,34,37,38]); },function($query) use ($where){ - $query->whereNotIn('activity_type',[30,31,32,33,34,35,36,37,38]); + $query->whereNotIn('activity_type',[30,31,32,33,34,35,37,38]); }) ->when(isset($where['paid']) && $where['paid'] !== '',function($query) use ($where){ $query->where('paid',$where['paid']); diff --git a/app/common/dao/store/order/StoreOrderDao.php b/app/common/dao/store/order/StoreOrderDao.php index 05bbbad..bac7855 100644 --- a/app/common/dao/store/order/StoreOrderDao.php +++ b/app/common/dao/store/order/StoreOrderDao.php @@ -90,9 +90,9 @@ class StoreOrderDao extends BaseDao $isWithGoods = $where['is_with_goods'] ?? 0; $activityType = $where['activity_type'] ?? 0; if($isWithGoods == 1 || $activityType == 35){ - $query->whereNotIn('StoreOrder.activity_type',[20,30,31,32,33,34,36,37,38]); + $query->whereNotIn('StoreOrder.activity_type',[20,30,31,32,33,34,37,38]); }else if($activityType == 0){ - $query->whereNotIn('StoreOrder.activity_type',[20,30,31,32,33,34,35,36,37,38]); + $query->whereNotIn('StoreOrder.activity_type',[20,30,31,32,33,34,35,37,38]); } $query->when(($sysDel !== null), function ($query) use ($sysDel) { diff --git a/app/common/repositories/store/order/StoreGroupOrderRepository.php b/app/common/repositories/store/order/StoreGroupOrderRepository.php index cded97f..013a698 100644 --- a/app/common/repositories/store/order/StoreGroupOrderRepository.php +++ b/app/common/repositories/store/order/StoreGroupOrderRepository.php @@ -113,13 +113,13 @@ class StoreGroupOrderRepository extends BaseRepository * @author xaboy * @day 2020/6/10 */ - public function cancel($id, $uid = null) - { - $groupOrder = $this->search(['paid' => 0, 'uid' => $uid ?? ''])->where('group_order_id', $id)->with(['orderList'])->find(); - if (!$groupOrder) - throw new ValidateException('订单不存在'); - if ($groupOrder['paid'] != 0) - throw new ValidateException('订单状态错误,无法删除'); + public function cancel($id, $uid = null){ + $groupOrder = $this->getSearch(['paid' => 0, 'uid' => $uid ?? '']) + ->where('group_order_id', $id) + ->with(['orderList'])->find(); + + if (!$groupOrder) throw new ValidateException('订单不存在'); + if ($groupOrder['paid'] != 0) throw new ValidateException('订单状态错误,无法删除'); //TODO 关闭订单 Db::transaction(function () use ($groupOrder, $id, $uid) { $groupOrder->is_del = 1; diff --git a/app/event.php b/app/event.php index b6ebac6..dc0ae1c 100644 --- a/app/event.php +++ b/app/event.php @@ -60,29 +60,29 @@ return [ ], // 订单支付成功事件触发 'order.paySuccess' => [ - // 赠送酒卡额度 'app\listener\exchangeQuota\OrderPaySuccessEvent' ], + // 订单取消成功 + 'order.cancel' => [ + 'app\listener\exchangeQuota\OrderCancelEvent' + ], // 订单完成事件触发(进入待评价) 'order.take' => [ - // 酒卡额度解冻 'app\listener\exchangeQuota\OrderTakeEvent' ], // 订单核销成功事件触发 'order.verify' => [ - // 酒卡额度解冻 'app\listener\exchangeQuota\OrderVerifyEvent' ], // 订单退款事件 'refund.agree' => [ - // 酒卡额度相关处理 'app\listener\exchangeQuota\OrderAgreeRefundEvent' ], // 会员卡开通 支付成功 'user.vipPay' => [ // 酒卡额度相关处理 'app\listener\exchangeQuota\OrderVipPayEvent', - //开卡成功送优惠券 + // 开卡成功送优惠券 'app\listener\giveCoupon\CardOpeningEvent', ], ], diff --git a/app/listener/exchangeQuota/OrderCancelEvent.php b/app/listener/exchangeQuota/OrderCancelEvent.php new file mode 100644 index 0000000..3bb0f8b --- /dev/null +++ b/app/listener/exchangeQuota/OrderCancelEvent.php @@ -0,0 +1,46 @@ +groupOrder = $params['order'] ?? []; + try{ + // 根据订单类型进行对应的处理 + // switch((int)$this->groupOrder->activity_type){ + // // 酒道馆和小酒馆兑换订单 + // case 36:$this->quotaAndIntegralHandle();break; + // // 进货订单 + // case 35:$this->merQuotaHandle();break; + // } + + + }catch(\Exception $e){ + $data = [ + // 'uid' => $this->groupOrder->uid, + // 'group_order_id' => $this->groupOrder->group_order_id, + 'msg' => $e->getMessage() + ]; + Log::info('订单取消 - 错误: '.var_export($data,1)); + } + } + + + + + + + + +} \ No newline at end of file diff --git a/crmeb/listens/AutoCancelGroupOrderListen.php b/crmeb/listens/AutoCancelGroupOrderListen.php index 3da9c67..b49bc91 100644 --- a/crmeb/listens/AutoCancelGroupOrderListen.php +++ b/crmeb/listens/AutoCancelGroupOrderListen.php @@ -27,7 +27,7 @@ class AutoCancelGroupOrderListen extends TimerService implements ListenerInterfa try { $storeGroupOrderRepository->cancel($id); } catch (\Exception $e) { - // Log::info('自动关闭订单失败' . var_export($id, 1)); + // Log::info('自动关闭订单失败'.var_export(['id' => $id,'msg' => $e->getMessage()],1)); } } });