/** * 确认购买 * 流程: 检测购买条件 * 购买 */ public function buy() { //$paypass = strval($_REQUEST['paypass']); $invest_id = intval($_REQUEST['invest_id']); //echo $invest_id;exit; D("DebtBehavior"); $Debt = new DebtBehavior($this->uid); // 检测是否可以购买 密码是否正确,余额是否充足 //$result = $Debt->buy($paypass, $invest_id); $debt_info = M('invest_detb')->field("transfer_price,sell_uid,debt_fee,money")->where("invest_id={$invest_id}")->find(); $info = M("borrow_investor")->field("borrow_id,investor_uid,borrow_uid,investor_capital,investor_interest,ordid,orddate")->where("id=" . $invest_id)->find(); $info1 = M("members")->field("usrid")->where("id=" . $debt_info['sell_uid'])->find(); $info2 = M("members")->field("usrid")->where("id={$this->uid}")->find(); $info3 = M("members")->field("usrid")->where("id=" . $info['borrow_uid'])->find(); $sellcustid = $info1['usrid']; //转让人 $creditamt = $info['investor_capital']; //转让金额(必须是本金) $dealamt = $debt_info['transfer_price']; //承接金额(转让金额上下浮动10%) $Fee = $debt_info['debt_fee']; $biddetails = array(); $biddetails['BidOrdId'] = $info['ordid']; //原投标订单号 $biddetails['BidOrdDate'] = $info['orddate']; //原投标订单日期 $biddetails['BidCreditAmt'] = $info['investor_capital']; //从原投标订单中转出的本金 $details = array(); $details['BorrowerCustId'] = $info3['usrid']; //借款人 $details['BorrowerCreditAmt'] = $info['investor_capital']; // $details['PrinAmt'] = "0.00"; //已还本金 $biddetails['BorrowerDetails'] = $details; $biddetails = json_encode($biddetails); $str1 = array('{', '}'); $str2 = array('[{', '}]'); $biddetails = str_replace($str1, $str2, $biddetails); $biddetails = '{"BidDetails":' . $biddetails . '}'; $info2 = M("members")->field("usrid")->where("id={$this->uid}")->find(); $buycustid = $info2['usrid']; //承接人 import("ORG.Huifu.Huifu"); $huifu = new Huifu(); $huifu->creditAssign($sellcustid, $creditamt, $dealamt, $biddetails, $Fee, $buycustid, $invest_id); exit; //$result = $Debt->buy($invest_id); if ($result === 'TRUE') { ajaxmsg('购买成功'); } else { ajaxmsg($result, 1); } }