|
@@ -201,17 +201,23 @@ class Userwallet extends Api
|
|
|
|
|
|
//提现
|
|
|
public function withdrawal() {
|
|
|
- if ($this->auth->idcard_status != 1) {
|
|
|
- $this->error('请先完成实名认证~');
|
|
|
- }
|
|
|
|
|
|
- $id = input('id', 0, 'intval');
|
|
|
- $type = input('type', 0, 'intval'); //账户类型:1=支付宝,2=银行卡
|
|
|
- $freemoney = input_post('freemoney', 0, 'intval'); //自定义金额
|
|
|
+ $id = input('id', 0, 'intval');
|
|
|
+ $type = input('type', 0, 'intval'); //账户类型:1=支付宝,2=银行卡
|
|
|
+ $freemoney = input('freemoney', 0, 'intval'); //自定义金额
|
|
|
|
|
|
if (!$id && !$freemoney) {
|
|
|
$this->error('请选择或填写提现金额');
|
|
|
}
|
|
|
+
|
|
|
+ if (!in_array($type, [1, 2])) {
|
|
|
+ $this->error('请选择提现账户~');
|
|
|
+ }
|
|
|
+
|
|
|
+ if ($this->auth->idcard_status != 1) {
|
|
|
+ $this->error('请先完成实名认证~');
|
|
|
+ }
|
|
|
+
|
|
|
if ($id > 0) {
|
|
|
$withdrawal_config = Db::name('withdrawal_config')->find($id);
|
|
|
if (!$withdrawal_config) {
|
|
@@ -225,35 +231,31 @@ class Userwallet extends Api
|
|
|
}
|
|
|
|
|
|
//扣除金额
|
|
|
- $money = floatval($withdrawal_config['money']);
|
|
|
+ $money = $withdrawal_config['money'];
|
|
|
//实际获得金额
|
|
|
$real_money = $withdrawal_config['real_money'];
|
|
|
}
|
|
|
if ($freemoney > 0) {
|
|
|
//扣除金额
|
|
|
$money = $freemoney;
|
|
|
- //实际获得金额
|
|
|
+ //平台手续费
|
|
|
$bili = config('site.withdrawal_rate') >= 0 ? config('site.withdrawal_rate') : 10;
|
|
|
- $real_money = number_format($money * (100 - $bili) / 100, 2, '.', '');
|
|
|
+ $plat_money = bcdiv(bcmul($money,$bili,2),100,2);
|
|
|
+
|
|
|
+ //减去手续费,得实得金额
|
|
|
+ $real_money = bcsub($money,$plat_money,2);
|
|
|
}
|
|
|
|
|
|
- if ($money <= 0) {
|
|
|
+ if ($money <= 0 || $real_money <= 0) {
|
|
|
$this->error('提现金额异常');
|
|
|
}
|
|
|
|
|
|
- if (!in_array($type, [1, 2])) {
|
|
|
- $this->error('请选择提现账户~');
|
|
|
- }
|
|
|
+
|
|
|
|
|
|
$check = Db::name('take_cash')->where(['user_id'=>$this->auth->id,'status'=>0])->find();
|
|
|
if($check){
|
|
|
$this->error('您有一笔提现在审核中,待审核通过后再申请提现。');
|
|
|
}
|
|
|
- $time = strtotime(date('Y-m-d'));
|
|
|
- $check = Db::name('take_cash')->where(['user_id'=>$this->auth->id, 'wallet_id'=>$id, 'createtime' => ['egt', $time]])->find();
|
|
|
- if($check){
|
|
|
- $this->error('您今日已经提现过该额度');
|
|
|
- }
|
|
|
|
|
|
$user_money = model('wallet')->getwallet($this->auth->id,'money');
|
|
|
if($money > $user_money){
|
|
@@ -281,19 +283,6 @@ class Userwallet extends Api
|
|
|
'type' => $type,
|
|
|
'realname' => $realname
|
|
|
];
|
|
|
- //计算上级可获得金额
|
|
|
- /*if ($this->auth->intro_uid) {
|
|
|
- $data['intro_uid'] = $this->auth->intro_uid;
|
|
|
- //获取返利比率
|
|
|
- $intro_withdrawal_rebate_rate = (int)config('site.intro_withdrawal_rebate_rate');
|
|
|
- if ($intro_withdrawal_rebate_rate > 0 && $intro_withdrawal_rebate_rate <= 100) {
|
|
|
- //上级获得金额数量
|
|
|
- $intro_uid_money = number_format($money * $intro_withdrawal_rebate_rate / 100, 2, '.', '');
|
|
|
- if ($intro_uid_money > 0) {
|
|
|
- $data['intro_money'] = $intro_uid_money;
|
|
|
- }
|
|
|
- }
|
|
|
- }*/
|
|
|
|
|
|
$msg = '申请成功请等待审核';
|
|
|
|
|
@@ -305,8 +294,16 @@ class Userwallet extends Api
|
|
|
$this->error('您的网络开小差啦~');
|
|
|
}
|
|
|
|
|
|
+ //扣除money
|
|
|
+ $rs_wallet = model('Wallet')->lockChangeAccountRemain($this->auth->id,0,'money',-$data['number'],15,'提现(审核中)','take_cash',$log_id);
|
|
|
+ if($rs_wallet['status']===false)
|
|
|
+ {
|
|
|
+ Db::rollback();
|
|
|
+ $this->error($rs_wallet['msg']);
|
|
|
+ }
|
|
|
+
|
|
|
Db::commit();
|
|
|
- //审核时候再扣,或者这里先扣,等需求方确认
|
|
|
+
|
|
|
$this->success($msg);
|
|
|
}
|
|
|
|