Esempio n. 1
0
 /**
  * 确认购买
  * 流程: 检测购买条件
  * 购买
  */
 public function buy()
 {
     $paypass = strval($_REQUEST['paypass']);
     $invest_id = intval($_REQUEST['invest_id']);
     D("DebtBehavior");
     $Debt = new DebtBehavior($this->uid);
     // 检测是否可以购买  密码是否正确,余额是否充足
     $result = $Debt->buy($paypass, $invest_id);
     if ($result === 'TRUE') {
         ajaxmsg('购买成功');
     } else {
         ajaxmsg($result, 1);
     }
 }
Esempio n. 2
0
 public function creditassignret()
 {
     $usrid = $_POST['BuyCustId'];
     $info = M("huifulog")->distinct(true)->field("uid,username")->where("usrid=" . $usrid)->find();
     $data = array();
     $data['uid'] = $info['uid'];
     //用户UID
     $data['username'] = $info['username'];
     //用户名
     $data['rescode'] = $_POST['RespCode'];
     //返回码
     $data['cmdid'] = $_POST['CmdId'];
     //消息类型
     $data['usrid'] = $_POST['BuyCustId'];
     //用户客户号
     $data['ordid'] = $_POST['OrdId'];
     //订单号
     $data['orddate'] = $_POST['OrdDate'];
     //订单日期
     $data['trxid'] = "";
     $data['merpriv'] = $_POST['MerPriv'];
     $data['addtime'] = time();
     //记录时间
     sleep(1);
     //防止与前台回调同步到达
     $condition['uid'] = $data['uid'];
     $condition['ordid'] = $data['ordid'];
     $num = M("huifulog")->where($condition)->count();
     if ($num == 0) {
         M("huifulog")->add($data);
         if (strcmp($_POST['RespCode'], "000") == 0) {
             $temp = base64_decode($data['merpriv']);
             $pos1 = strpos($temp, '{');
             $pos2 = strpos($temp, '}');
             $len = $pos2 - $pos1 + 1;
             $merpriv = substr($temp, $pos1, $len);
             $merpriv = json_decode($merpriv, true);
             $investid = $merpriv['investid'];
             //投资ID
             D("DebtBehavior");
             $Debt = new DebtBehavior($data['uid']);
             $Debt->buy($investid);
             $assign['investor'] = $data['uid'];
             $assign['ordid'] = $data['ordid'];
             $assign['orddate'] = $data['orddate'];
             M("borrow_investor")->where("id=" . $investid)->save($assign);
         }
     }
     echo "RECV_ORD_ID_" . $_POST['OrdId'];
 }