/** * 新手标后台回调 20150914 bylj */ public function ininewbietenderreturn() { file_put_contents('/tmp/debugs', date('m-d H:i:s') . "\$新手标同步回调post" . print_r($_POST, true) . "\n", FILE_APPEND); $usrid = $_POST['UsrCustId']; //借款人的userid $info = M("huifulog")->distinct(true)->field("uid,username")->where("usrid=" . $usrid)->find(); $yonghu_id = $info['uid']; $jiner = $_POST['TransAmt']; $shoujihao = $info['username']; $data = array(); $data['uid'] = $info['uid']; //用户UID $data['username'] = $info['username']; //用户名 $data['rescode'] = $_POST['RespCode']; //返回码 $data['cmdid'] = $_POST['CmdId']; //消息类型 $data['usrid'] = $_POST['UsrCustId']; //用户客户号 $data['ordid'] = $_POST['OrdId']; //订单号 $data['orddate'] = $_POST['OrdDate']; //订单日期 $data['trxid'] = $_POST['TrxId']; //交易流水号 $data['merpriv'] = $_POST['MerPriv']; $data['addtime'] = time(); //记录时间 $reqext = $_POST['RespExt']; //代金券的内容json字符串 $reqext = urldecode($reqext); $reqext = json_decode($reqext, 1); $reqext = $reqext['Vocher']['VocherAmt']; if ($reqext) { /*根据订单号修改现金券的使用状态*/ $save['is_success'] = 1; M('active_redpacket')->where('orderno=' . $data['ordid'])->save($save); //把代金券修改为成功 } $condition['uid'] = $data['uid']; $condition['ordid'] = $data['ordid']; $num = M("huifulog")->where($condition)->count(); if ($num == 0) { M("huifulog")->add($data); $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); $borrow_id = $merpriv['borrowid']; //标ID $money = str2val_money($_POST['TransAmt']); //交易金额 //查询标的利率和周期 2015-09-16 $bininfo = M("newbie_bid")->field('borrow_uid,rate,bidtime')->where("id=" . $borrow_id)->find(); $info = array(); $info['ordid'] = $data['ordid']; //订单号 $info['orddate'] = $data['orddate']; //订单日期 $info['freezeordid'] = $_POST['FreezeOrdId']; //冻结订单号 $info['freezetrxid'] = $_POST['FreezeTrxId']; //冻结流水号 $info['investid'] = $data['uid']; $info['invest_money'] = $jiner; $info['interest'] = number_format($jiner * $bininfo['bidtime'] * ($bininfo['rate'] / 100) / 365, 2); //* 利息多少 金额*时间*利率/365天 $info['borrow_uid'] = $bininfo['borrow_uid']; //2015-09-16添加一个借款人uid $info['invest_uid'] = $data['uid']; $info['invest_time'] = strtotime(date("Y-m-d H:i", time())); //逾期时刻 //根据标号 查询借款人 $borrow_uid = $bininfo['borrow_uid']; //1093行 //根据借款人id 查询借款人的usrid $invest_usrid = M("members")->field('usrid,user_name')->where("id=" . $borrow_uid)->find(); $touzier = M("members")->field('usrid,user_name')->where("id=" . $data['uid'])->find(); //插入投资人电话(也就是用户名) //2015-09-22 插入之前首先查询是否有此人投资过 以防止异步也同时插入 $ishas = M("newbie_record")->getFieldByInvest_id($data['uid'], 'id'); $info['username'] = $touzier['user_name']; //要把投资者id插入 投资id 插入 投资时间 if (!$ishas) { $invest_info_id = M('newbie_record')->add($info); //换成新手标的表 } //根据订单号查询投资人 $invest = M('newbie_record')->field('invest_uid,ordid,orddate')->where('ordid=' . $data['ordid'])->find(); //通知投资人 2015-09-15 最后的1为借款人id memberMoneyLog($invest['invest_uid'], 6, -($money - $reqext), "对{$borrow_id}号新手标进行投标", $borrow_uid); // //开始放款 2015-09-15 lj import("ORG.Huifu.Huifu"); $huifu = new Huifu(); //每次是单笔的复审 所以用loans方法 20150914 $borrowercustid = $invest_usrid['usrid']; //600856564542 应该为借款人 的投资urid $transamt = $jiner; $Fee = 0.0; $subordid = $invest['ordid']; $suborddate = $invest['orddate']; //商户号 $tuoguan = FS("Webconfig/tuoguanconfig"); $merCustId = $tuoguan['huifu']['MerCustId']; $divdetails = ''; //[{"DivCustId":"'.$merCustId.'","DivAcctId":"MDT000001","DivAmt":"'.$Fee.'"}] $freezetrxid = $_POST['FreezeTrxId']; $borrowid = $borrow_id; //标号 $investid = $data['uid']; //为投资者id // loans 调用的问题 这里的loans 就相当于 点击复审之后 给每一笔解冻,把钱打到借款人账号。就是所谓的放款 $huifu->loans($usrid, $transamt, $borrowercustid, $Fee, $subordid, $suborddate, $divdetails, $freezetrxid, $borrowid, $investid, $reqext); //放款成功后继续回调 以后台回调为准 unset($content, $touziren_info, $touziren_info, $shijian, $biaodi_info); } echo "RECV_ORD_ID_" . $_POST['OrdId']; }