修改:分销商佣金提现修改 - 银行卡修改为个人账户和企业账户

添加:分销商佣金提交添加手续费设置
This commit is contained in:
wuhui_zzw 2024-03-29 17:18:27 +08:00
parent 0186b6d6e0
commit 2e25d63673
4 changed files with 36 additions and 11 deletions

View File

@ -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(),
];
}
}

View File

@ -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)

View File

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

View File

@ -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;
}