parent
0186b6d6e0
commit
2e25d63673
|
|
@ -94,12 +94,9 @@ class UserExtractRepository extends BaseRepository
|
|||
{
|
||||
event('user.extract.before',compact('user','data'));
|
||||
$userExtract = Db::transaction(function()use($user,$data){
|
||||
if($user['brokerage_price'] < (systemConfig('user_extract_min')))
|
||||
throw new ValidateException('可提现金额不足');
|
||||
if($data['extract_price'] < (systemConfig('user_extract_min')))
|
||||
throw new ValidateException('提现金额不得小于最低额度');
|
||||
if($user['brokerage_price'] < $data['extract_price'])
|
||||
throw new ValidateException('提现金额不足');
|
||||
if($user['brokerage_price'] < (systemConfig('user_extract_min'))) throw new ValidateException('可提现金额不足');
|
||||
if($data['extract_price'] < (systemConfig('user_extract_min'))) throw new ValidateException('提现金额不得小于最低额度');
|
||||
if($user['brokerage_price'] < $data['extract_price']) throw new ValidateException('提现金额不足');
|
||||
if($data['extract_type'] == 3) {
|
||||
$make = app()->make(WechatUserRepository::class);
|
||||
$openid = $make->idByOpenId((int)$user['wechat_user_id']);
|
||||
|
|
@ -116,6 +113,14 @@ class UserExtractRepository extends BaseRepository
|
|||
$data['uid'] = $user['uid'];
|
||||
$data['balance'] = $brokerage_price;
|
||||
|
||||
// 手续费计算
|
||||
$commissionRate = (float)systemConfig('withdraw_commission');
|
||||
if($commissionRate > 0){
|
||||
$data['withdraw_commission'] = (float)sprintf("%.2f", $data['extract_price'] * $commissionRate / 100);
|
||||
$data['extract_price'] = (float)sprintf("%.2f", $data['extract_price'] - $data['withdraw_commission']);
|
||||
}
|
||||
|
||||
|
||||
return $this->dao->create($data);
|
||||
});
|
||||
event('user.extract',compact('userExtract'));
|
||||
|
|
@ -180,8 +185,14 @@ class UserExtractRepository extends BaseRepository
|
|||
return $sn;
|
||||
}
|
||||
|
||||
public function getHistoryBank($uid)
|
||||
{
|
||||
return $this->dao->getSearch(['uid' => $uid,'extract_type' => 0])->order('create_time DESC')->field('real_name,bank_code,bank_address,bank_name')->find();
|
||||
public function getHistoryBank($uid){
|
||||
// 获取最新的记录 银行卡类型:0=个人账户,1=企业账户
|
||||
$one = (int)$this->dao->getSearch(['uid' => $uid,'extract_type' => 0,'bank_type'=>0])->max('extract_id');
|
||||
$two = (int)$this->dao->getSearch(['uid' => $uid,'extract_type' => 0,'bank_type'=>1])->max('extract_id');
|
||||
|
||||
return [
|
||||
0 => $this->dao->getSearch(['extract_id' => $one])->field('real_name,bank_code,bank_address,bank_name,bank_type')->findOrEmpty()->toArray(),
|
||||
1 => $this->dao->getSearch(['extract_id' => $two])->field('real_name,bank_code,bank_address,bank_name,bank_type')->findOrEmpty()->toArray(),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,7 +44,8 @@ class ConfigOthers extends BaseController
|
|||
'max_bag_number',
|
||||
'promoter_explain',
|
||||
'user_extract_min',
|
||||
'withdraw_type'
|
||||
'withdraw_type',
|
||||
'withdraw_commission'
|
||||
]);
|
||||
|
||||
if ($data['extension_two_rate'] < 0 || $data['extension_one_rate'] < 0)
|
||||
|
|
|
|||
|
|
@ -97,6 +97,8 @@ class User extends BaseController
|
|||
];
|
||||
// 获取用户分销商 申请转正信息
|
||||
$data['is_formal'] = (int)UserBrokerageApplyFormal::where('uid', $user->uid)->value('status');
|
||||
// 提现手续费
|
||||
$data['withdraw_commission'] = (float)systemConfig('withdraw_commission');
|
||||
|
||||
|
||||
return app('json')->success($data);
|
||||
|
|
|
|||
|
|
@ -49,7 +49,18 @@ class UserExtract extends BaseController
|
|||
|
||||
public function checkParams(validate $validate)
|
||||
{
|
||||
$data = $this->request->params(['extract_type','bank_code','bank_address','alipay_code','wechat','extract_pic','extract_price','real_name','bank_name']);
|
||||
$data = $this->request->params([
|
||||
'extract_type',
|
||||
'bank_code',
|
||||
'bank_address',
|
||||
'alipay_code',
|
||||
'wechat',
|
||||
'extract_pic',
|
||||
'extract_price',
|
||||
'real_name',
|
||||
'bank_name',
|
||||
'bank_type'
|
||||
]);
|
||||
$validate->check($data);
|
||||
return $data;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue