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