From 73bc09862a837e0d1f90e3bb1eeb89724249d03a Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Thu, 28 Sep 2023 14:52:27 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B7=9F=E6=96=B0=E4=BF=9D=E8=AF=81=E9=87=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../system/merchant/MerchantRepository.php | 16 ++++++++++------ app/controller/api/Auth.php | 7 +++++-- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/app/common/repositories/system/merchant/MerchantRepository.php b/app/common/repositories/system/merchant/MerchantRepository.php index e38ee0a0..d0b3af4b 100644 --- a/app/common/repositories/system/merchant/MerchantRepository.php +++ b/app/common/repositories/system/merchant/MerchantRepository.php @@ -689,14 +689,14 @@ class MerchantRepository extends BaseRepository public function autoMargin($income, $order, $finance, $financeSn, $index = 0) { $merchant = Merchant::find($this->merId); - $margin = Db::name('MerchantType')->where('mer_type_id', $merchant['type_id'])->value('margin'); + $margin_type = Db::name('MerchantType')->where('mer_type_id', $merchant['type_id'])->value('margin'); //商户保证金大于支付保证金 或者forceMargin==false 直接返回 不计算保证金 - if ($merchant['paid_margin']>= $margin|| ($this->forceMargin === false && $merchant['auto_margin_rate'] == 0)) { + if ($merchant['paid_margin']>= $margin_type|| ($this->forceMargin === false && $merchant['auto_margin_rate'] == 0)) { return [$income, $finance, false]; } $rate = $this->forceMargin ? 100 : $merchant['auto_margin_rate']; // //商户保证金未完全缴纳且设置了自动扣除比例 - $margin = bcmul($income, bcdiv($rate, 100,2), 2); + $margin= bcmul($income, bcdiv($rate, 100,2), 2); // $margin = min(bcsub($margin, $merchant['paid_margin'], 2), $margin); // $income = max(bcsub($income, $margin, 2), 0); // if ($margin <= 0) { @@ -714,10 +714,14 @@ class MerchantRepository extends BaseRepository 'mer_id' => $this->merId, 'financial_record_sn' => $financeSn . $index ]; - + if(bcadd($merchant['paid_margin'],$margin)>=$margin_type){ + $is_margin=10; + }else{ + $is_margin=1; + } $orderInfo = [ 'type_id' => $merchant['type_id'], - 'is_margin' => $merchant['is_margin'], + 'is_margin' => $is_margin, 'margin' => $margin, ]; $values = [ @@ -738,7 +742,7 @@ class MerchantRepository extends BaseRepository } $merchant->paid_margin = bcadd($margin, $merchant->paid_margin, 2); $merchant->ot_margin = $merchant->paid_margin; - $merchant->is_margin = MerchantRepository::PaidMargin; + $merchant->is_margin = $is_margin; if ($merchant->save() === false) { throw new \Exception('merchant 保存出错', 500); } diff --git a/app/controller/api/Auth.php b/app/controller/api/Auth.php index 34f8eeaa..832159d2 100644 --- a/app/controller/api/Auth.php +++ b/app/controller/api/Auth.php @@ -275,9 +275,12 @@ class Auth extends BaseController public function doMargin() { $user = $this->request->userInfo(); - $merchant = Db::name('merchant')->where('uid', $user['uid'])->where('status', 1)->where('is_margin', 1)->find(); + $merchant = Db::name('merchant')->where('uid', $user['uid'])->where('status', 1)->find(); if (!$merchant) { - return app('json')->fail('用户店铺异常'); + return app('json')->fail('没有店铺'); + } + if($merchant['is_margin'] == 10){ + return app('json')->fail('保证金已缴纳'); } if($merchant['margin'] == 0){ $margin = Db::name('MerchantType')->where('mer_type_id', $merchant['type_id'])->value('margin');