|
@@ -1084,55 +1084,6 @@ class UserCenter extends Base
|
|
|
Db::rollback();
|
|
|
$this->error($e->getMessage());
|
|
|
}
|
|
|
-
|
|
|
- $v = getConfigValue('withdraw_switch');
|
|
|
- if (!$v) $this->error('维护中,暂时关闭');
|
|
|
- $redis = new Redis(['select'=>2]);
|
|
|
- $redis_value = $redis->get('withdraw'.$this->uid);
|
|
|
- if ($redis_value){
|
|
|
- $this->error('请求过快,请稍后重试');
|
|
|
- }else{
|
|
|
- $redis->set('withdraw'.$this->uid,1,3);
|
|
|
- }
|
|
|
- $money = input('money');
|
|
|
- $withdraw_type = input('withdraw_type','wx');
|
|
|
- if (!$money) $this->error('参数错误');
|
|
|
- $user = Db::name('store_member')->where('id',$this->uid)->find();
|
|
|
- if ($user['money'] < $money) $this->error('余额不足');
|
|
|
- $withdraw_min_price = getConfigValue('withdraw_min_price'); //最小提现金额
|
|
|
- $withdraw_max_price = getConfigValue('withdraw_max_price'); //最大提现金额
|
|
|
- $poundage_proportion = getConfigValue('poundage_proportion'); //手续费百分比
|
|
|
- $discount = getMemberServiceCharge($this->uid);// 折扣
|
|
|
- $poundage_proportion = bcmul($poundage_proportion,$discount);
|
|
|
- if ($money < $withdraw_min_price) $this->error('最低提现'.$withdraw_min_price.'元');
|
|
|
- if ($money > $withdraw_max_price) $this->error('最大提现'.$withdraw_min_price.'元');
|
|
|
-
|
|
|
- if ($withdraw_type=='zfb'){
|
|
|
- if (!$user['zfb_account'] || !$user['zfb_real_name']) $this->error('请先绑定支付宝');
|
|
|
- }
|
|
|
- if($withdraw_type == 'wx' && !$user['openid']) $this->error('请先绑定微信');
|
|
|
- Db::startTrans();
|
|
|
- try {
|
|
|
- $data['mid'] = $this->uid;
|
|
|
- $order_no = get_order_sn();
|
|
|
- $data['order_no'] = $order_no;
|
|
|
- $data['price'] = $money;
|
|
|
- $data['poundage_proportion'] = $poundage_proportion;
|
|
|
- $proportion = sprintf("%.2f", $money*($poundage_proportion/100)); //四舍五入保留两位小数点
|
|
|
- $data['proportion'] = $proportion;
|
|
|
- $real_money = $money-$proportion;
|
|
|
- $data['real_money'] = $real_money;
|
|
|
- $data['account_no'] = $withdraw_type == 'wx'? $user['openid'] : $user['zfb_account'];
|
|
|
- $data['account_name'] = $withdraw_type == 'wx' ? $user['name'] : $user['zfb_real_name'];
|
|
|
- $id =Db::name('store_member_withdraw')->insertGetId($data);
|
|
|
- $res = memberMoneyChange($money,3,$this->uid,'余额提现',0,$id,2);
|
|
|
- if(!$res) throw new Exception('提现失败');
|
|
|
- Db::commit();
|
|
|
- }catch (\Exception $e) {
|
|
|
- Db::rollback();
|
|
|
- DelRedisSetNx('withdraw'.$this->uid);
|
|
|
- $this->error($e->getMessage());
|
|
|
- }
|
|
|
DelRedisSetNx('withdraw'.$this->uid);
|
|
|
$this->success('提现申请成功,等待审核!');
|
|
|
}else{
|