From 15f8c50b7405d98506dbe4b23fe29f9e44391e50 Mon Sep 17 00:00:00 2001 From: "home.fengxinyhyl" Date: Sun, 14 Apr 2024 20:58:31 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../user/UserAssetsLogRepository.php | 34 +++++++++++++++++++ app/event.php | 2 ++ crmeb/listens/pay/CustomizePaySuccess.php | 32 +++++++++++++++++ crmeb/listens/pay/CustomizeRefundAll.php | 32 +++++++++++++++++ 4 files changed, 100 insertions(+) create mode 100644 crmeb/listens/pay/CustomizePaySuccess.php create mode 100644 crmeb/listens/pay/CustomizeRefundAll.php diff --git a/app/common/repositories/user/UserAssetsLogRepository.php b/app/common/repositories/user/UserAssetsLogRepository.php index aaf731a..d820d7b 100644 --- a/app/common/repositories/user/UserAssetsLogRepository.php +++ b/app/common/repositories/user/UserAssetsLogRepository.php @@ -16,6 +16,7 @@ namespace app\common\repositories\user; use app\common\dao\user\UserAssetsLogDao; use app\common\model\store\StoreOrderHot; use app\common\repositories\BaseRepository; +use app\common\repositories\store\order\StoreOrderBaseRepository; use app\common\repositories\store\order\StoreOrderHotRepository; use app\common\repositories\store\order\StoreOrderRepository; use app\common\repositories\store\product\ProductRepository; @@ -135,6 +136,39 @@ class UserAssetsLogRepository extends BaseRepository } + public function userRefundEvent($orderItem) + { + // 更新该订单的所有数据为退款状态 + $this->dao->updateOrderStatus($orderItem['order_id'], self::STATUS_REFUND); + + $item = $this->dao->getWhere(array('id' => $orderItem)); + if($item){ + $item->status = self::STATUS_REFUND; + $item->save(); + } + $this->userAssetsRepository->updateAssets($orderItem['uid'], array('integral_buy' => -1 * $item['count'])); + } + + + public function userPayEvent($groupOrder){ + foreach ($groupOrder['orderList'] as $orderItem) { + + // 5. 本人使用的福利积分 + if ($orderItem['integral']) { + $log = array('uid' => $orderItem['uid'], + 'asset_type' => self::ASSET_INTEGRAL, + 'type' => self::INTEGRAL_BUY, + 'status' => self::STATUS_BUY, + 'order_id' => $orderItem['order_id'], + 'count' => -$orderItem['integral'], + ); + $this->addLog([$log]); + $this->userAssetsRepository->updateAssets($orderItem['uid'], array('integral_buy' => -$orderItem['integral'])); + } + } + } + + /** * notes 订单收货事件处理 * @param $orderItem diff --git a/app/event.php b/app/event.php index 9d9ac9b..df124eb 100755 --- a/app/event.php +++ b/app/event.php @@ -68,6 +68,8 @@ return [ 'create_operate_log' => [\crmeb\listens\CreateOperateLogListen::class], // 操作日志事件 'mini_order_shipping' => [\crmeb\listens\MiniOrderShippingListen::class], // 小程序发货管理事件 'order.take' => [\crmeb\listens\pay\CustomizeTake::class], + 'order.paySuccess' => [\crmeb\listens\pay\CustomizePaySuccess::class], + 'order.refundAll' => [\crmeb\listens\pay\CustomizeRefundAll::class], ], 'subscribe' => [], diff --git a/crmeb/listens/pay/CustomizePaySuccess.php b/crmeb/listens/pay/CustomizePaySuccess.php new file mode 100644 index 0000000..8795d5b --- /dev/null +++ b/crmeb/listens/pay/CustomizePaySuccess.php @@ -0,0 +1,32 @@ +make(UserAssetsLogRepository::class); + $repository->userPayEvent($data['groupOrder']); + } + } +} diff --git a/crmeb/listens/pay/CustomizeRefundAll.php b/crmeb/listens/pay/CustomizeRefundAll.php new file mode 100644 index 0000000..5993e9c --- /dev/null +++ b/crmeb/listens/pay/CustomizeRefundAll.php @@ -0,0 +1,32 @@ +make(UserAssetsLogRepository::class); + $repository->userRefundEvent($data['order']); + } + } +}