From cc2d406b31485575c60378b9e8ca7eccbe097435 Mon Sep 17 00:00:00 2001 From: luofei <604446095@qq.com> Date: Wed, 14 Jun 2023 14:06:29 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BD=A3=E9=87=91=E6=88=96=E4=BF=9D=E8=AF=81?= =?UTF-8?q?=E9=87=91=E4=B8=BA0=E6=97=B6=E4=B8=8D=E5=86=99=E5=85=A5?= =?UTF-8?q?=E8=AE=B0=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../system/merchant/MerchantRepository.php | 3 ++ app/listener/paySuccessOrder.php | 32 +++++++++++-------- 2 files changed, 22 insertions(+), 13 deletions(-) diff --git a/app/common/repositories/system/merchant/MerchantRepository.php b/app/common/repositories/system/merchant/MerchantRepository.php index 47209f08..ee2c065d 100644 --- a/app/common/repositories/system/merchant/MerchantRepository.php +++ b/app/common/repositories/system/merchant/MerchantRepository.php @@ -694,6 +694,9 @@ class MerchantRepository extends BaseRepository $margin = bcmul($income, $rate / 100, 2); $margin = min(bcsub($merchant['margin'], $merchant['paid_margin'], 2), $margin); $income = max(bcsub($income, $margin, 2), 0); + if ($margin <= 0) { + return [$income, $finance, false]; + } $finance[] = [ 'order_id' => $order->order_id, 'order_sn' => $order->order_sn, diff --git a/app/listener/paySuccessOrder.php b/app/listener/paySuccessOrder.php index 280c310d..fc1245f1 100644 --- a/app/listener/paySuccessOrder.php +++ b/app/listener/paySuccessOrder.php @@ -107,19 +107,21 @@ class paySuccessOrder $this->calculate(Merchant::TypeCloudWarehouse, 'commission_to_cloud_rate'); } - //平台佣金 - $this->finance[] = [ - 'order_id' => $this->event['order']['order_id'], - 'order_sn' => $this->event['order']['order_sn'], - 'user_info' => $this->event['order']->user->nickname, - 'user_id' => $this->event['order']['uid'], - 'financial_type' => 'commission_to_platform', - 'financial_pm' => 1, - 'type' => 1, - 'number' => $this->remain, - 'mer_id' => 0, - 'financial_record_sn' => $this->financeSn . $this->index - ]; + if ($this->remain > 0) { + //平台佣金 + $this->finance[] = [ + 'order_id' => $this->event['order']['order_id'], + 'order_sn' => $this->event['order']['order_sn'], + 'user_info' => $this->event['order']->user->nickname, + 'user_id' => $this->event['order']['uid'], + 'financial_type' => 'commission_to_platform', + 'financial_pm' => 1, + 'type' => 1, + 'number' => $this->remain, + 'mer_id' => 0, + 'financial_record_sn' => $this->financeSn . $this->index + ]; + } if (!$financialRecordRepository->insertAll($this->finance)) { throw new \Exception('财务流水保存出错'); @@ -156,6 +158,10 @@ class paySuccessOrder 'commission_to_cloud_rate' => 'cloud_warehouse', ]; $amount = bcmul($this->totalAmount, (string)($rate / 100), 2); + if ($amount <= 0) { + Log::info("订单分佣:$typeName 佣金为0"); + return false; + } $this->remain = bcsub($this->remain, $amount, 2); $this->finance[] = [ 'order_id' => $this->event['order']['order_id'],