From 52d6cb27ad10f93c07bb2d6363f9c694532442e5 Mon Sep 17 00:00:00 2001 From: luofei <604446095@qq.com> Date: Wed, 28 Feb 2024 18:00:11 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E5=95=86=E6=88=B7=E9=87=87?= =?UTF-8?q?=E8=B4=AD=E9=87=91=E9=A2=9D=E5=86=99=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../store/order/StoreOrderRepository.php | 12 ++++++++++++ .../system/merchant/MerchantRepository.php | 9 +-------- crmeb/listens/SendSubsidyCouponListen.php | 3 ++- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/app/common/repositories/store/order/StoreOrderRepository.php b/app/common/repositories/store/order/StoreOrderRepository.php index bb0eae75..947db40d 100755 --- a/app/common/repositories/store/order/StoreOrderRepository.php +++ b/app/common/repositories/store/order/StoreOrderRepository.php @@ -786,6 +786,18 @@ class StoreOrderRepository extends BaseRepository $order->interest->save(); } $order->save(); + + if ($order->uid != $order->merchant->uid) { + $refundPrice = StoreRefundOrder::where('order_id', $order['order_id'])->where('status', '<>', -1)->sum('refund_price'); + $money = bcsub($order->pay_price, $refundPrice, 2); + //订单确认收货,增加商户销售金额 + Merchant::where('mer_id', $order->mer_id)->update(['sale_amount' => Db::raw('sale_amount+' . $money)]); + //订单确认收货,增加商户采购金额 + $merId = Merchant::where('uid', $order->uid)->value('mer_id'); + if (!empty($merId)) { + Merchant::where('mer_id', $merId)->update(['purchase_amount' => Db::raw('purchase_amount+' . $money)]); + } + } }); } diff --git a/app/common/repositories/system/merchant/MerchantRepository.php b/app/common/repositories/system/merchant/MerchantRepository.php index 64f48c67..3953ea26 100755 --- a/app/common/repositories/system/merchant/MerchantRepository.php +++ b/app/common/repositories/system/merchant/MerchantRepository.php @@ -270,7 +270,7 @@ class MerchantRepository extends BaseRepository $margin = app()->make(MerchantTypeRepository::class)->get($data['type_id']); $data['is_margin'] = $margin['is_margin'] ?? -1; $data['margin'] = $margin['margin'] ?? 0; - + return Db::transaction(function () use ($data, $make) { $account = $data['mer_account']; $password = $data['mer_password']; @@ -589,13 +589,6 @@ class MerchantRepository extends BaseRepository $bill->save(); } if ($money > 0) { - //订单确认收货,增加商户销售金额 - Merchant::where('mer_id', $bill->mer_id)->update(['sale_amount' => Db::raw('sale_amount+' . $money)]); - //订单确认收货,增加商户采购金额 - $merId = Merchant::where('uid', $bill->uid)->value('mer_id'); - if (!empty($merId)) { - Merchant::where('mer_id', $merId)->update(['purchase_amount' => Db::raw('purchase_amount+' . $money)]); - } app()->make(UserBillRepository::class)->incBill($bill->uid, 'mer_computed_money', 'order', [ 'link_id' => $order->order_id, 'mer_id' => $bill->mer_id, diff --git a/crmeb/listens/SendSubsidyCouponListen.php b/crmeb/listens/SendSubsidyCouponListen.php index 63375971..94724c01 100644 --- a/crmeb/listens/SendSubsidyCouponListen.php +++ b/crmeb/listens/SendSubsidyCouponListen.php @@ -15,7 +15,8 @@ class SendSubsidyCouponListen extends TimerService implements ListenerInterface public function handle($event): void { - $this->tick(1000 * 60 * 20, function () { + //TODO 上线后改成30分钟 + $this->tick(1000 * 60 * 1, function () { Log::info('定时任务:发放商户采购补贴券'); try { $consumption = StoreConsumption::where('type', StoreConsumption::TYPE_SALE_SUBSIDY)->find();