From b3fdae172bafff2209d1a408513c835ca3ef2112 Mon Sep 17 00:00:00 2001 From: luofei <604446095@qq.com> Date: Thu, 7 Mar 2024 12:25:41 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=98=A5=E8=80=95=E8=A1=A5?= =?UTF-8?q?=E8=B4=B4=E5=8F=91=E6=94=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- crmeb/listens/OrderDeliveryListen.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/crmeb/listens/OrderDeliveryListen.php b/crmeb/listens/OrderDeliveryListen.php index 31540949..db0857fb 100644 --- a/crmeb/listens/OrderDeliveryListen.php +++ b/crmeb/listens/OrderDeliveryListen.php @@ -15,22 +15,26 @@ class OrderDeliveryListen implements ListenerInterface public function handle($event): void { $order = $event['order']; + $consumptionTotal = 0; foreach ($order->orderProduct as $orderProduct) { if (!$orderProduct->product->isPlatformCard()) { continue; } + $consumptionTotal = bcadd($consumptionTotal, $orderProduct->total_price, 2); + } + if ($consumptionTotal > 0) { $consumption = StoreConsumption::where('type', StoreConsumption::TYPE_PULL_CONSUMPTION)->find(); /** @var StoreConsumptionUserDao $repo */ $repo = app()->make(StoreConsumptionUserDao::class); $repo->startTime = date('Y-m-d H:i:s'); $repo->endTime = '2025-07-01'; - $repo->send($consumption, 1, $order['uid'], $order['group_order_id'], $order->total_price, StoreConsumptionUser::STATUS_UNUSED); + $repo->send($consumption, 1, $order['uid'], $order['group_order_id'], $consumptionTotal, StoreConsumptionUser::STATUS_UNUSED); $consumption = StoreConsumption::where('type', StoreConsumption::TYPE_RECHARGE)->find(); $repo->startTime = date('Y-m-d H:i:s'); $repo->endTime = '2025-07-01'; - $rate = $this->getRate($order->total_price); - $repo->send($consumption, $rate, $order['uid'], $order['group_order_id'], $order->total_price, StoreConsumptionUser::STATUS_REPEAL, StoreConsumptionUser::TYPE_TWO); + $rate = $this->getRate($consumptionTotal); + $repo->send($consumption, $rate, $order['uid'], $order['group_order_id'], $consumptionTotal, StoreConsumptionUser::STATUS_REPEAL, StoreConsumptionUser::TYPE_TWO); } }