コード例 #1
0
 public function withdraw()
 {
     $pre = C('DB_PREFIX');
     $money_info = M("member_money")->field("account_money, back_money")->where("uid={$this->uid}")->find();
     $amount = floatval($_POST['Amount']);
     // if($amount > $money_info['account_money']){
     // $this->error('可用余额资金余额不足!');
     // }
     $amount > $money_info['account_money'] + $money_info['back_money'] && $this->error('提现金额超过了可用资金金额!');
     $tx['uid'] = $this->uid;
     $tx['add_ip'] = get_client_ip();
     $tx['add_time'] = time();
     $tx['withdraw_money'] = $amount;
     $nid = M('member_withdraw')->add($tx);
     $field = "m.user_name,m.user_phone,(mm.account_money+mm.back_money) all_money,mm.account_money,mm.back_money,i.real_name,b.bank_num,b.bank_name,b.bank_address,b.bank_province,b.bank_city";
     $vo = M('members m')->field($field)->join("{$pre}member_info i on i.uid = m.id")->join("{$pre}member_money mm on mm.uid = m.id")->join("{$pre}member_banks b on b.uid = m.id")->where("m.id={$this->uid}")->find();
     if (empty($vo['bank_num'])) {
         $data['html'] = '<script type="text/javascript">alert("您还未绑定银行帐户,请先绑定");window.location.href="' . __APP__ . '/M/Capital/index";</script>';
     } else {
         $tqfee = explode("|", $this->glo['fee_tqtx']);
         $fee[0] = explode("-", $tqfee[0]);
         $fee[1] = explode("-", $tqfee[1]);
         $fee[2] = explode("-", $tqfee[2]);
         $this->assign("fee", $fee);
         $borrow_info = M("borrow_info")->field("sum(borrow_money+borrow_interest+borrow_fee) as borrow, sum(repayment_money+repayment_interest) as also")->where("borrow_uid = {$this->uid} and borrow_type=4 and borrow_status in (0,2,4,6,8,9,10)")->find();
         $vo['all_money'] -= $borrow_info['borrow'] + $borrow_info['also'];
         $vo['OrderNo'] = $nid;
     }
     //dump($vo);die;
     $va = M('escrow_account')->where("uid={$this->uid}")->find();
     $submitdata['WithdrawMoneymoremore'] = $va['qdd_marked'];
     if ($nid) {
         $submitdata['OrderNo'] = date("YmdHi") . $nid;
     }
     $submitdata['CardNo'] = $vo['bank_num'];
     $submitdata['CardType'] = 0;
     //(0.借记卡 1.信用卡)
     $submitdata['BankCode'] = $vo['bank_name'];
     //银行代码
     $submitdata['BranchBankName'] = '';
     //auto_charset($vo['bank_name']);//
     $submitdata['Province'] = $vo['bank_province'];
     $submitdata['City'] = $vo['bank_city'];
     $submitdata['FeePercent'] = 0;
     //$vo[''];
     $submitdata['Amount'] = $amount;
     //$submitdata['txtPassword']=$vo[''];//提现密码
     $submitdata['PlatformMoneymoremore'] = $va['platform_marked'];
     $submitdata['Remark1'] = '';
     //dump($submitdata);exit;
     import("ORG.Loan.Escrow");
     $loan = new Escrow();
     //dump($submitdata);die;
     $data = $loan->wapwithdraw($submitdata);
     //dump($data);die;
     $form = $loan->setForm($data, 'withdraw');
     echo $form;
     exit;
 }