From d6617700cc2b59ccd107efebed5e3bc2932140f5 Mon Sep 17 00:00:00 2001 From: luofei <604446095@qq.com> Date: Mon, 19 Feb 2024 17:00:08 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=B4=AD=E7=89=A9=E5=8D=A1?= =?UTF-8?q?=E5=8F=91=E8=B4=A7=E4=BA=8B=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../store/coupon/StoreCouponRepository.php | 3 +- .../store/order/StoreOrderRepository.php | 1 + app/controller/merchant/store/order/Order.php | 2 +- app/event.php | 1 + crmeb/listens/OrderDeliveryListen.php | 34 +++++++++++++++++++ 5 files changed, 39 insertions(+), 2 deletions(-) create mode 100644 crmeb/listens/OrderDeliveryListen.php diff --git a/app/common/repositories/store/coupon/StoreCouponRepository.php b/app/common/repositories/store/coupon/StoreCouponRepository.php index d77856ae..a4e7d6ce 100644 --- a/app/common/repositories/store/coupon/StoreCouponRepository.php +++ b/app/common/repositories/store/coupon/StoreCouponRepository.php @@ -335,6 +335,7 @@ class StoreCouponRepository extends BaseRepository 'uid' => $uid, 'coupon_title' => $coupon['title'], 'coupon_price' => $coupon['coupon_price'], + 'balance' => $coupon['coupon_price'], 'use_min_price' => $coupon['use_min_price'], 'type' => $type, 'coupon_id' => $coupon['coupon_id'], @@ -357,7 +358,7 @@ class StoreCouponRepository extends BaseRepository } /** - * TODO 优惠券发送费多用户 + * TODO 优惠券发送给多用户 * @param $uid * @param $id * @author Qinii diff --git a/app/common/repositories/store/order/StoreOrderRepository.php b/app/common/repositories/store/order/StoreOrderRepository.php index 2806e5be..aecffb77 100644 --- a/app/common/repositories/store/order/StoreOrderRepository.php +++ b/app/common/repositories/store/order/StoreOrderRepository.php @@ -1300,6 +1300,7 @@ class StoreOrderRepository extends BaseRepository if ($order['is_virtual'] == 1 && $data['delivery_type'] != 3) throw new ValidateException('虚拟商品只能虚拟发货'); //订单记录 + /** @var StoreOrderStatusRepository $statusRepository */ $statusRepository = app()->make(StoreOrderStatusRepository::class); switch ($data['delivery_type']) { case 1: diff --git a/app/controller/merchant/store/order/Order.php b/app/controller/merchant/store/order/Order.php index 344fc415..b5cf8610 100644 --- a/app/controller/merchant/store/order/Order.php +++ b/app/controller/merchant/store/order/Order.php @@ -225,7 +225,7 @@ class Order extends BaseController 'mer_id' => $this->request->merId(), 'data' => $params ]); - return app('json')->success('以开始批量发货,请稍后查看'); + return app('json')->success('已开始批量发货,请稍后查看'); } /** diff --git a/app/event.php b/app/event.php index bd64b441..9789e755 100644 --- a/app/event.php +++ b/app/event.php @@ -67,6 +67,7 @@ return [ //操作日志 'create_operate_log' => [\crmeb\listens\CreateOperateLogListen::class], // 操作日志事件 'mini_order_shipping' => [\crmeb\listens\MiniOrderShippingListen::class], // 小程序发货管理事件 + 'order.delivery' => [\crmeb\listens\OrderDeliveryListen::class], // 发货事件 ], 'subscribe' => [], diff --git a/crmeb/listens/OrderDeliveryListen.php b/crmeb/listens/OrderDeliveryListen.php new file mode 100644 index 00000000..2c021464 --- /dev/null +++ b/crmeb/listens/OrderDeliveryListen.php @@ -0,0 +1,34 @@ +orderProduct as $orderProduct) { + $merchantCate = $orderProduct->product->merCateId; + if (empty($merchantCate) || $merchantCate[0]['mer_cate_id']!= env('PLATFORM_CARD_TYPE_ID')) { + continue; + } + /** @var StoreCouponRepository $repo */ + $repo = app()->make(StoreCouponRepository::class); + $coupon = $repo->validCouponQuery(StoreCouponRepository::TYPE_PLATFORM_CARD, StoreCouponRepository::GET_COUPON_TYPE_BUY) + ->where('coupon_price', $orderProduct->product->price)->find(); + if (empty($coupon)) { + return; + } + $coupon->coupon_price = bcmul($orderProduct->product_num, $orderProduct->product->price); + $repo->sendCoupon($coupon, $order['uid'],StoreCouponUserRepository::SEND_TYPE_BUY); + } + } + +}