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();