From 63d87aeb5353d6b2967cf86f82f923b50826beaa Mon Sep 17 00:00:00 2001 From: wuhui_zzw <1760308791@qq.com> Date: Thu, 4 Jan 2024 18:24:39 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E7=8E=B0=EF=BC=9A=E6=8F=90=E7=8E=B0?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=89=8B=E7=BB=AD=E8=B4=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../repositories/user/UserExtractRepository.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/app/common/repositories/user/UserExtractRepository.php b/app/common/repositories/user/UserExtractRepository.php index d54f06c..bc3c8b1 100644 --- a/app/common/repositories/user/UserExtractRepository.php +++ b/app/common/repositories/user/UserExtractRepository.php @@ -93,6 +93,7 @@ class UserExtractRepository extends BaseRepository public function create($user,$data) { event('user.extract.before',compact('user','data')); + $data['extract_price'] = abs($data['extract_price']); $userExtract = Db::transaction(function()use($user,$data){ if($user['brokerage_price'] < (systemConfig('user_extract_min'))) throw new ValidateException('可提现金额不足'); @@ -108,11 +109,18 @@ class UserExtractRepository extends BaseRepository if(!$openid) throw new ValidateException('openID获取失败,请确认是微信用户'); } } + // 数据交换 总提现金额记录 + $data['total_extract_money'] = $data['extract_price']; + // 计算提现手续费 + $withdrawalFees = (float)systemConfig('withdrawal_fees'); + if($withdrawalFees > 0){ + $data['withdrawal_fees'] = (float)sprintf("%.2f",$data['total_extract_money'] * $withdrawalFees / 100); + $data['extract_price'] = (float)sprintf("%.2f",$data['total_extract_money'] - $data['withdrawal_fees']); + } // 由于 佣金包含平台抽成相关佣金 需要减去相关佣金,然后计算。否则会出现问题 $PlatformCommissionMoney = app()->make(UserBillRepository::class)->getPlatformCommissionMoney($user['uid']); $brokeragePrice = bcsub($user['brokerage_price'],$PlatformCommissionMoney,2); - $brokerage_price = bcsub($brokeragePrice,$data['extract_price'],2); - // debug($brokerage_price); + $brokerage_price = bcsub($brokeragePrice,$data['total_extract_money'],2); $user->brokerage_price = $brokerage_price; $user->save();