提现:提现添加手续费
This commit is contained in:
parent
c82b023545
commit
63d87aeb53
|
|
@ -93,6 +93,7 @@ class UserExtractRepository extends BaseRepository
|
||||||
public function create($user,$data)
|
public function create($user,$data)
|
||||||
{
|
{
|
||||||
event('user.extract.before',compact('user','data'));
|
event('user.extract.before',compact('user','data'));
|
||||||
|
$data['extract_price'] = abs($data['extract_price']);
|
||||||
$userExtract = Db::transaction(function()use($user,$data){
|
$userExtract = Db::transaction(function()use($user,$data){
|
||||||
if($user['brokerage_price'] < (systemConfig('user_extract_min')))
|
if($user['brokerage_price'] < (systemConfig('user_extract_min')))
|
||||||
throw new ValidateException('可提现金额不足');
|
throw new ValidateException('可提现金额不足');
|
||||||
|
|
@ -108,11 +109,18 @@ class UserExtractRepository extends BaseRepository
|
||||||
if(!$openid) throw new ValidateException('openID获取失败,请确认是微信用户');
|
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']);
|
$PlatformCommissionMoney = app()->make(UserBillRepository::class)->getPlatformCommissionMoney($user['uid']);
|
||||||
$brokeragePrice = bcsub($user['brokerage_price'],$PlatformCommissionMoney,2);
|
$brokeragePrice = bcsub($user['brokerage_price'],$PlatformCommissionMoney,2);
|
||||||
$brokerage_price = bcsub($brokeragePrice,$data['extract_price'],2);
|
$brokerage_price = bcsub($brokeragePrice,$data['total_extract_money'],2);
|
||||||
// debug($brokerage_price);
|
|
||||||
$user->brokerage_price = $brokerage_price;
|
$user->brokerage_price = $brokerage_price;
|
||||||
$user->save();
|
$user->save();
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue