From fb6aa84bfa042a8ed66caaca103906bf90bb67a1 Mon Sep 17 00:00:00 2001 From: luofei <604446095@qq.com> Date: Fri, 26 May 2023 11:01:44 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E8=AF=95=E5=B9=B3=E5=8F=B0=E6=89=8B?= =?UTF-8?q?=E7=BB=AD=E8=B4=B9=E5=88=86=E6=B6=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../store/order/StoreOrderRepository.php | 2 +- .../system/merchant/MerchantRepository.php | 4 ++-- app/listener/paySuccessOrder.php | 18 +++++++++++------- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/app/common/repositories/store/order/StoreOrderRepository.php b/app/common/repositories/store/order/StoreOrderRepository.php index 266c9eb2..68462931 100644 --- a/app/common/repositories/store/order/StoreOrderRepository.php +++ b/app/common/repositories/store/order/StoreOrderRepository.php @@ -351,7 +351,7 @@ class StoreOrderRepository extends BaseRepository $merchantRepo = app()->make(MerchantRepository::class); $merchantRepo->merId = $order->mer_id; $merchantRepo->forceMargin = false; - [$_payPrice, $finance] = $merchantRepo->autoMargin($_payPrice, $order, $finance, $financeSn, $i++); + [$_payPrice, $finance, $increase] = $merchantRepo->autoMargin($_payPrice, $order, $finance, $financeSn, $i++); } $finance[] = [ 'order_id' => $order->order_id, diff --git a/app/common/repositories/system/merchant/MerchantRepository.php b/app/common/repositories/system/merchant/MerchantRepository.php index b532d111..27492c7b 100644 --- a/app/common/repositories/system/merchant/MerchantRepository.php +++ b/app/common/repositories/system/merchant/MerchantRepository.php @@ -672,7 +672,7 @@ class MerchantRepository extends BaseRepository $merchant = Merchant::find($this->merId); //商户保证金未完全缴纳且设置了自动扣除比例 if ($merchant['margin'] <= $merchant['paid_margin'] || ($this->forceMargin === false && $merchant['auto_margin_rate'] <= 0 && $merchant['auto_margin_rate'] > 100)) { - return [$income, $finance]; + return [$income, $finance, false]; } $rate = $this->forceMargin ? 100 : $merchant['auto_margin_rate']; //商户保证金未完全缴纳且设置了自动扣除比例 @@ -692,7 +692,7 @@ class MerchantRepository extends BaseRepository 'financial_record_sn' => $financeSn . $index ]; Queue::push(AutoMarginJob::class, ['merId' => $this->merId, 'margin' => $margin]); - return [$income, $finance]; + return [$income, $finance, true]; } diff --git a/app/listener/paySuccessOrder.php b/app/listener/paySuccessOrder.php index afb5c0a2..c26a96fe 100644 --- a/app/listener/paySuccessOrder.php +++ b/app/listener/paySuccessOrder.php @@ -55,12 +55,6 @@ class paySuccessOrder if ($entryMerchant['type_id'] == Merchant::TypeStore) { $merchantRate = systemConfig('commission_to_merchant_rate'); $merchantAmount = bcmul($this->totalAmount, (string)($merchantRate / 100), 2); - /** @var MerchantRepository $merchantRepo */ - $merchantRepo = app()->make(MerchantRepository::class); - $merchantRepo->merId = $entryMerId; - $merchantRepo->forceMargin = true; - [$merchantAmount, $this->finance] = $merchantRepo->autoMargin($merchantAmount, $event['order'], $this->finance, $this->financeSn, $this->index); - $this->index++; if ($merchantAmount > 0) { $this->finance[] = [ 'order_id' => $this->event['order']['order_id'], @@ -75,7 +69,17 @@ class paySuccessOrder 'financial_record_sn' => $this->financeSn . $this->index ]; $this->index++; - app()->make(MerchantRepository::class)->addLockMoney($entryMerId, 'order', $event['order']['order_id'], (float)$merchantAmount); + /** @var MerchantRepository $merchantRepo */ + $merchantRepo = app()->make(MerchantRepository::class); + $merchantRepo->merId = $entryMerId; + $merchantRepo->forceMargin = true; + [$merchantAmount, $this->finance, $increase] = $merchantRepo->autoMargin($merchantAmount, $event['order'], $this->finance, $this->financeSn, $this->index); + if ($increase) { + $this->index++; + } + if ($merchantAmount > 0) { + app()->make(MerchantRepository::class)->addLockMoney($entryMerId, 'order', $event['order']['order_id'], (float)$merchantAmount); + } } }