示例#1
0
 /**
  * 手机普通标投资
  */
 public function Invest()
 {
     if (!$this->uid) {
         if ($this->isAjax()) {
             die("请先登录后投资");
         } else {
             $this->redirect('M/pub/login');
         }
     }
     if ($this->isAjax()) {
         // ajax提交投资信息
         $borrow_id = intval($this->_get('bid'));
         $invest_money = intval($this->_post('invest_money'));
         $paypass = $this->_post('paypass');
         $invest_pass = isset($_POST['invest_pass']) ? $_POST['invest_pass'] : '';
         $status = checkInvest($this->uid, $borrow_id, $invest_money, $paypass, $invest_pass);
         if ($status == 'TRUE') {
             $done = investMoney($this->uid, $borrow_id, $invest_money);
             if ($done === true) {
                 die('TRUE');
             } elseif ($done) {
                 die($done);
             } else {
                 die(L('investment_failure'));
             }
         } else {
             die($status);
         }
     } else {
         $borrow_id = $this->_get('bid');
         $borrow_info = M("borrow_info")->field('borrow_duration, borrow_money, borrow_interest, borrow_interest_rate, has_borrow,
                          borrow_min, borrow_max, password, repayment_type')->where("id='{$borrow_id}'")->find();
         $this->assign('borrow_info', $borrow_info);
         $user_info = M('member_money')->field("account_money+back_money as money ")->where("uid='{$this->uid}'")->find();
         $this->assign('user_info', $user_info);
         $paypass = M("members")->field('pin_pass')->where('id=' . $this->uid)->find();
         $this->assign('paypass', $paypass['pin_pass']);
         $this->display();
     }
 }
 public function Invest()
 {
     if (!$this->uid) {
         if ($this->isAjax()) {
             die("请先登录后投资");
         } else {
             $this->redirect('M/pub/login');
         }
     }
     $loanconfig = FS("Webconfig/loanconfig");
     if ($this->isAjax()) {
         // ajax提交投资信息
         $borrow_id = intval($this->_get('bid'));
         //$borrow_id ='22';
         $invest_money = intval($this->_post('invest_money'));
         //die($borrow_id);
         $paypass = $this->_post('paypass');
         $invest_pass = isset($_POST['invest_pass']) ? $_POST['invest_pass'] : '';
         $binfo = M("borrow_info")->field('borrow_money,borrow_max,has_borrow,has_vouch,borrow_type,borrow_min,money_collect, borrow_uid')->find($borrow_id);
         $status = checkInvest($this->uid, $borrow_id, $invest_money, $paypass, $invest_pass);
         if ($status == 'TRUE') {
             $invest_id = investMoney($this->uid, $borrow_id, $invest_money);
             if ($invest_id == true) {
                 $orders = date("YmdHi") . $invest_id;
                 $invest_qdd = M("escrow_account")->field('*')->where("uid={$this->uid}")->find();
                 $borrow_qdd = M("escrow_account")->field('*')->where("uid={$binfo['borrow_uid']}")->find();
                 $invest_info = M("borrow_investor")->field("reward_money, borrow_fee")->where("id={$invest_id}")->find();
                 $secodary = '';
                 import("ORG.Loan.Escrow");
                 $loan = new Escrow();
                 if ($invest_info['reward_money'] > 0.0) {
                     // 投标奖励
                     $secodary[] = $loan->secondaryJsonList($invest_qdd['qdd_marked'], $invest_info['reward_money'], '二次分配', '支付投标奖励');
                 }
                 if ($invest_info['borrow_fee'] > 0.0) {
                     // 借款管理费
                     $secodary[] = $loan->secondaryJsonList($loanconfig['pfmmm'], $invest_info['borrow_fee'], '二次分配', '支付平台借款管理费');
                 }
                 $secodary && ($secodary = json_encode($secodary));
                 // 投标奖励
                 $loanList[] = $loan->loanJsonList($invest_qdd['qdd_marked'], $borrow_qdd['qdd_marked'], $orders, $borrow_id, $invest_money, $binfo['borrow_money'], '投标', "对{$borrow_id}号投标", $secodary);
                 $loanJsonList = json_encode($loanList);
                 //$returnURL = C('WEB_URL').U("invest/investReturn");
                 $returnURL = 'http://' . $_SERVER['HTTP_HOST'] . U("/invest/wapinvestReturn");
                 $notifyURL = 'http://' . $_SERVER['HTTP_HOST'] . U("invest/notify");
                 //echo $returnURL."    notifyURL:".$notifyURL;die();
                 //var_dump($loanJsonList);die();
                 $data = $loan->transfer($loanJsonList, $returnURL, $notifyURL);
                 //var_dump($data);die();
                 $form = $loan->setForm($data, 'transfer');
                 echo $form . "正在跳转至乾多多。。。";
                 //die('TRUE');
                 exit;
                 //die('TURE');
             } elseif ($invest_id) {
                 die($invest_id);
             } else {
                 die(L('investment_failure'));
             }
         } else {
             die($status);
         }
     } else {
         $borrow_id = $this->_get('bid');
         $borrow_info = M("borrow_info")->field('borrow_duration, borrow_money, borrow_interest, borrow_interest_rate, has_borrow,
                          borrow_min, borrow_max, password, repayment_type')->where("id='{$borrow_id}'")->find();
         $this->assign('borrow_info', $borrow_info);
         $this->assign('borrow_pass', $borrow_info . password);
         $user_info = M('member_money')->field("account_money+back_money as money ")->where("uid='{$this->uid}'")->find();
         $this->assign('user_info', $user_info);
         $paypass = M("members")->field('pin_pass')->where('id=' . $this->uid)->find();
         $this->assign('paypass', $paypass['pin_pass']);
         $this->display();
     }
 }