/** * 精选标 */ public function _homeAct() { core::Singleton('comm.remote.remote'); $data['sname'] = 'topborrow.get'; $data = transferAPI($data); if ($data['code'] == 0) { if ($data['ratio']) { core::Singleton('comm.remote.remote'); $data['sname'] = 'topborrow.get'; $data = transferAPI($data); } $this->view->assign('bondname', $data["data"]["bname"]); $this->view->assign('rate', sprintf('%.1f', $data["data"]["interest_rate"])); $this->view->assign('deadline', $data['data']["borrow_duration"]); $this->view->assign('ratio', $data['data']["ratio"]); $this->view->assign('min', str2val_money($data['data']["borrow_min"])); $monery = $data['data']["borrow_money"] / 10000; $this->view->assign('money', '<i>' . $monery . '</i>'); $this->view->assign('bid', $data['data']['id']); } $data['sname'] = 'banner.get'; $data['latest_time'] = time(); $data = transferAPI($data); $a = $img = ''; if ($data['code'] == 0) { foreach ($data['data'] as $k => $d) { $img = $img . ',' . '"' . $d['pic_url'] . '"'; $a = $a . ',' . '"' . $d['link'] . '"'; } $this->view->assign('img', trim($img, ',')); $this->view->assign('a', trim($a, ',')); $this->view->assign('BENNERTIME', BENNERTIME); } }
public function userinfo() { //自动对帐 $usr = M("members")->field("usrid")->where("id=" . $this->uid)->find(); $usrid = $usr['usrid']; import("ORG.Huifu.Huifu"); $huifu = new Huifu(); $result = $huifu->queryBalanceBg($usrid); if (strcmp($result['RespCode'], "000") == 0) { $accountval = $result['AvlBal']; $freezeval = $result['FrzBal']; $moneyinfo = M("member_money")->where("uid=" . $this->uid)->find(); $account_money = str2val_money($accountval) - str2val_money($moneyinfo['back_money']); $freeze_money = str2val_money($freezeval); $data['money_freeze'] = $freeze_money; $data['account_money'] = $account_money; M("member_money")->where("uid=" . $this->uid)->save($data); } else { header("Content-type: text/html; charset=utf-8"); echo $_POST['RespDesc']; } //结束 $mess = array(); $mess['uid'] = intval(session("u_id")); $vo = M('members')->field('id,user_name,user_email,user_pass,is_ban')->where("id={$mess['uid']}")->find(); $mess['username'] = $vo['user_name']; $mess['phone'] = intval(session("u_user_phone")); $mess['head'] = get_avatar($mess['uid']); //头像 $minfo = getMinfo($mess['uid'], true); $mess['credits'] = getLeveIco($minfo['credits'], 3); //会员等级 $membermoney = M("member_money")->field(true)->where("uid={$mess['uid']}")->find(); if (is_array($membermoney)) { $mess['mayuse'] = $membermoney['account_money'] + $membermoney['back_money']; //可用 $mess['freeze'] = $membermoney['money_freeze']; //冻结 $mess['collect'] = $membermoney['money_collect']; //代收 $mess['total'] = $mess['mayuse'] + $mess['freeze'] + $mess['collect']; //总额 } else { $mess['total'] = 0; $mess['mayuse'] = 0; $mess['freeze'] = 0; $mess['collect'] = 0; } ajaxmsg($mess); }
public function duizhang() { $usr = M("members")->field("usrid")->where("id=" . $this->uid)->find(); $usrid = $usr['usrid']; import("ORG.Huifu.Huifu"); $huifu = new Huifu(); $result = $huifu->queryBalanceBg($usrid); if (strcmp($result['RespCode'], "000") == 0) { $accountval = $result['AvlBal']; $freezeval = $result['FrzBal']; $moneyinfo = M("member_money")->where("uid=" . $this->uid)->find(); $account_money = str2val_money($accountval) - str2val_money($moneyinfo['back_money']); $freeze_money = str2val_money($freezeval); $data['money_freeze'] = $freeze_money; $data['account_money'] = $account_money; M("member_money")->where("uid=" . $this->uid)->save($data); } else { header("Content-type: text/html; charset=utf-8"); echo $_POST['RespDesc']; } }
public function _initiativetenderreturnAct() { file_put_contents('/tmp/4.txt', date('m-d H:i:s') . " returnplant异步:" . print_r($_POST, true) . "\n", FILE_APPEND); $is_avail = $this->is_avail($_POST); if ($is_avail) { $usrid = $_POST['UsrCustId']; $db = core::Singleton('comm.db.activeRecord'); $db->connect('CAILAI'); $info = $db->get_one($where = array('usrid' => $usrid), '', 'lzh_huifulog'); // file_get_contents('/tmp/3',json_encode($_POST)); //$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['UsrCustId']; //用户客户号 $data['ordid'] = $_POST['OrdId']; //订单号 $data['orddate'] = $_POST['OrdDate']; //订单日期 $data['trxid'] = $_POST['TrxId']; //交易流水号 $data['merpriv'] = $_POST['MerPriv']; $data['addtime'] = time(); //记录时间 //防止钱投完使用红包不扣款的bug出现 $reqext = $_POST['RespExt']; //代金券的内容json字符串 $reqext = urldecode($reqext); $reqext = json_decode($reqext, 1); $reqext = $reqext['Vocher']['VocherAmt']; file_put_contents('/tmp/4.txt', date('m-d H:i:s') . " returnplant异步红包:" . print_r($reqext, true) . "\n", FILE_APPEND); sleep(1); //防止与前台回调同步到达 $condition['uid'] = $data['uid']; $condition['ordid'] = $data['ordid']; $num = $db->count_all($condition, 'lzh_huifulog'); if ($num === 0) { // $db = core::Singleton('comm.db.activeRecord'); // $db->connect('CAILAI'); $db->insert($data, 'lzh_huifulog'); 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); // file_put_contents('/tmp/4.txt',date('m-d H:i:s')." return ".print_r($merpriv,true)."\n",FILE_APPEND); $borrow_id = $merpriv['borrowid']; //标ID $money = str2val_money($_POST['TransAmt']); //交易金额 $info = array(); $info['ordid'] = $data['ordid']; //订单号 $info['orddate'] = $data['orddate']; //订单日期 $info['freezeordid'] = $_POST['FreezeOrdId']; //冻结订单号 $info['freezetrxid'] = $_POST['FreezeTrxId']; //冻结流水号 // $db = core::Singleton('comm.db.activeRecord'); $db->connect('CAILAI'); $invest_info_id = $db->insert($info, 'lzh_borrow_investor'); // $invest_info_id = M('borrow_investor')->add($info); //剪去红包的钱 才是真正扣掉的钱 //$money=$money-$reqext; file_put_contents('/tmp/4.txt', date('m-d H:i:s') . " returnplant真钱:" . print_r($money, true) . "\n", FILE_APPEND); $l = investMoney($data['uid'], $borrow_id, $money, 0, $invest_info_id, $reqext); $borrowName = getBorrowName($borrow_id); $realName = getRealName($data['uid']); $content = "尊敬的财来网投资人" . $realName['real_name'] . ",您于" . date("Y") . "年" . date("m") . "月" . date("d") . "日" . date("H") . ":" . date("i") . "分向" . $borrowName['borrow_name'] . "标的投资" . $money . "元,资金已冻结,将于满标复审后计息,详情请咨询客户经理,或致电400-079-8558"; sendsms(trim($data['username']), $content); } } echo "RECV_ORD_ID_" . $_POST['OrdId']; } exit; }
public function usrtransferret() { $usrid = $_POST['UsrCustId']; $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['UsrCustId']; //用户客户号 $data['ordid'] = $_POST['OrdId']; //订单号 $data['orddate'] = ''; $data['trxid'] = ''; $data['merpriv'] = ''; $data['addtime'] = time(); //记录时间 $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) { //还款人 $out = M('members')->field("user_name")->where("id=" . $data['uid'])->find(); //收款人 $in = M('members')->field("id,user_name")->where("usrid='" . $_POST['InUsrCustId'] . "'")->find(); //还款人帐户 $accountMoney_z = M('member_money')->field('money_freeze,money_collect,account_money,back_money')->find($data['uid']); $datamoney_z['uid'] = $data['uid']; $datamoney_z['type'] = 51; $datamoney_z['affect_money'] = -str2val_money($_POST['TransAmt']); //偿还金额 $datamoney_z['collect_money'] = $accountMoney_z['money_collect']; $datamoney_z['freeze_money'] = $accountMoney_z['money_freeze']; if ($accountMoney_z['back_money'] + $datamoney_z['affect_money'] < 0) { $datamoney_z['back_money'] = 0; $datamoney_z['account_money'] = $accountMoney_z['account_money'] + $accountMoney_z['back_money'] + $datamoney_z['affect_money']; } else { $datamoney_z['account_money'] = $accountMoney_z['account_money']; $datamoney_z['back_money'] = $accountMoney_z['back_money'] + $datamoney_z['affect_money']; } //还款人帐户 $mmoney_z['money_freeze'] = $datamoney_z['freeze_money']; $mmoney_z['money_collect'] = $datamoney_z['collect_money']; $mmoney_z['account_money'] = $datamoney_z['account_money']; $mmoney_z['back_money'] = $datamoney_z['back_money']; //还款人帐户 $datamoney_z['info'] = "偿还担保公司(帐号:" . $in['user_name'] . ")代还金额" . str2val_money($_POST['TransAmt']) . "元"; $datamoney_z['add_time'] = time(); $datamoney_z['add_ip'] = get_client_ip(); $datamoney_z['target_uid'] = $in['id']; $datamoney_z['target_uname'] = $in['user_name']; $moneynewid_z = M('member_moneylog')->add($datamoney_z); if ($moneynewid_z) { M('member_money')->where("uid={$datamoney_z['uid']}")->save($mmoney_z); } //收款人帐户 $accountMoney_y = M('member_money')->field('money_freeze,money_collect,account_money,back_money')->find($in['id']); $datamoney_y['uid'] = $in['id']; $datamoney_y['type'] = 52; $datamoney_y['affect_money'] = str2val_money($_POST['TransAmt']); //接收偿还金额 $datamoney_y['collect_money'] = $accountMoney_y['money_collect']; $datamoney_y['freeze_money'] = $accountMoney_y['money_freeze']; $datamoney_y['account_money'] = $accountMoney_y['account_money']; //充值账户不变 $datamoney_y['back_money'] = $accountMoney_y['back_money'] + $datamoney_y['affect_money']; //回款账户增加 //收款人帐户 $mmoney_y['money_freeze'] = $datamoney_y['freeze_money']; $mmoney_y['money_collect'] = $datamoney_y['collect_money']; $mmoney_y['account_money'] = $datamoney_y['account_money']; $mmoney_y['back_money'] = $datamoney_y['back_money']; //收款人帐户 $datamoney_y['info'] = "接收偿还金额" . str2val_money($_POST['TransAmt']) . "元(还款人帐号:" . $out['user_name'] . ")"; $datamoney_y['add_time'] = time(); $datamoney_y['add_ip'] = get_client_ip(); $datamoney_y['target_uid'] = $data['uid']; $datamoney_y['target_uname'] = $out['user_name']; $moneynewid_y = M('member_moneylog')->add($datamoney_y); if ($moneynewid_y) { M('member_money')->where("uid={$datamoney_y['uid']}")->save($mmoney_y); } } } echo "RECV_ORD_ID_" . $_POST['OrdId']; }
/** * 取现复核 * @param unknown_type $post */ public function cash_audit($post) { $usrid = $post['UsrCustId']; //$info = M("huifulog")->distinct(true)->field("uid,username")->where("usrid=".$usrid)->find(); $db = core::Singleton('comm.db.activeRecord'); $db->connect('CAILAI'); $info = $db->get_one(array('usrid' => $usrid), '', 'lzh_huifulog'); $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'] = ''; $data['trxid'] = ''; $data['addtime'] = time(); //记录时间 $condition['uid'] = $data['uid']; $condition['ordid'] = $data['ordid']; $condition['cmdid'] = $data['cmdid']; //$num = M("huifulog")->where($condition)->count(); $num = $db->count_all($condition, 'lzh_huifulog'); if ($num == 0) { //M("huifulog")->add($data); $db->insert($data, 'lzh_huifulog'); //请求正在处理中,就当作可以了 by whh 2015-03-05 汇付的技术反馈的 if (strcmp($post['RespCode'], "000") == 0 || strcmp($post['RespCode'], "999") == 0) { $map['uid'] = $info['uid']; $s['status'] = 1; //$result =M('member_withdrawlog')->where("ordid=".$data['ordid'])->save($s); $result = $db->update(array('ordid' => $data['ordid']), $s, 'lzh_member_withdrawlog'); //$servfee = M('member_withdrawlog')->where("ordid=".$data['ordid'])->find(); $servfee = $db->get_one(array('ordid' => $data['ordid']), '', 'lzh_member_withdrawlog'); //$money = M('member_money')->where($map)->find();//会员资金 $money = $db->get_one($map, '', 'lzh_member_money'); file_put_contents('/tmp/money', '$money:' . print_r($money, true) . "\n", FILE_APPEND); $out_money = str2val_money($post['TransAmt']); //提现资金总金额 $fees = str2val_money($servfee['servfee']); //总手续费 $width_money = $out_money + $fees; unset($data); if ($money['back_money'] + $money['account_money'] <= $width_money) { //如果提现金额小于等于总金额 $deduct = $out_money; //用户减少资金 } else { $deduct = $width_money; //用户减少资金 } if ($money["back_money"] > $width_money) { $data['back_money'] = $money["back_money"] - $deduct; $data['account_money'] = $money["account_money"]; } else { $data['back_money'] = 0; $data['account_money'] = $money["account_money"] - $deduct + $money["back_money"]; } //M("member_money")->where($map)->save($data); file_put_contents('/tmp/money', '$map:' . print_r($map, true) . "\n", FILE_APPEND); file_put_contents('/tmp/money', '$$data:' . print_r($data, true) . "\n", FILE_APPEND); $db->update($map, $data, 'lzh_member_money'); $log_data = array(); $log_data['uid'] = $info['uid']; $log_data['type'] = 29; $log_data['back_money'] = $data['back_money']; $log_data['account_money'] = $data['account_money']; $log_data['affect_money'] = -$deduct; $log_data['collect_money'] = $money['money_collect']; $log_data['freeze_money'] = $money['money_freeze']; $fee = str2val_money($post['FeeAmt']) + str2val_money($servfee['servfee']); if ($money['back_money'] + $money['account_money'] <= $width_money) { //如果提现金额小于等于总金额 $log_data['info'] = "提现申请已通过,扣除实际手续费" . $fees . "元,到帐金额" . ($out_money - $fees) . "元"; } else { $log_data['info'] = "提现申请已通过,扣除实际手续费" . $fees . "元,到帐金额" . $out_money . "元"; } $log_data['add_time'] = time(); $log_data['add_ip'] = get_client_ip(); $log_data['target_uid'] = 0; $log_data['target_uname'] = "@网站管理员@"; //M("member_moneylog")->add($log_data); $db->insert($log_data, 'lzh_member_moneylog'); $mwhere = $info['uid']; $bdb = new PDO('mysql:host=' . DB_HOST . ';dbname=' . DB_NAME, DB_USER, DB_PWD); $sql = "SELECT real_name FROM lzh_member_info WHERE uid = ? limit 1 "; $stmt1 = $bdb->prepare($sql); $stmt1->bindParam(1, $mwhere); //绑定第一个参数值 $stmt1->execute(); while ($memberd = $stmt1->fetch(PDO::FETCH_ASSOC)) { $memberInfo = $memberd; } $bdb = null; $timeT = date('Y-m-d H:i'); $sendms = "尊敬的财来网投资人{$memberInfo['real_name']},您于{$timeT}分,在财来网汇付宝账号提现{$out_money}元,根据银行情况,将于1-2个工作日到账,敬请关注。详情请咨询客户经理,或致电400-079-8558"; //取现成功发送短信 sendsms($info['username'], $sendms); file_put_contents('/tmp/zw11.txt', "{$info['username']}:" . print_r($sendms, true) . "\n", FILE_APPEND); } } }
public function autorepayment() { $token = $_GET['key']; $config = file_get_contents($this->updir . 'config.txt'); list($startime, $condition, $key) = explode('|', $config, 3); if ($key != $token) { exit('服务器拒绝响应'); } $glodata = get_global_setting(); $pre = C("DB_PREFIX"); $strOut = "<br/>-----------正在执行企业直投自动还款程序:服务器当前时间" . date("Y-m-d H:i:s", time()) . "---------------<br/>"; $transfer_investor_detail = M('transfer_investor_detail'); $map = array(); //$map['deadline'] = array("lt",time()+86400); $map['status'] = 7; $field = 'id,invest_id,interest,investor_uid,borrow_uid,borrow_id,capital,interest_fee,sort_order'; $lists = $transfer_investor_detail->field($field)->where($map)->select(); //$this->pre($lists); if (empty($lists)) { return -1; } import("ORG.Huifu.Huifu"); $Huifu = new Huifu(); $Updateb = M('transfer_investor_detail'); $transfer_investor_detail->startTrans(); foreach ($lists as $rows) { $usrid = M('members')->getFieldById($rows['borrow_uid'], 'Usrid'); $respose = $Huifu->queryBalanceBg($usrid); $acctBal = str2val_money($respose['AcctBal']); $this->pre($acctBal); $accountMoney_borrower = M('member_money')->field('money_freeze,money_collect,account_money,back_money')->find($v['borrow_uid']); if ($accountMoney_borrower['account_money'] + $accountMoney_borrower['back_money'] < $v['capital'] + $v['interest']) { return "帐户可用余额不足,本期还款共需" . ($v['capital'] + $v['interest']) . "元,请先充值!"; } //借款者减少 $datamoney_x['uid'] = $v['borrow_uid']; $datamoney_x['type'] = 11; $datamoney_x['affect_money'] = -($v['capital'] + $v['interest']); if ($datamoney_x['affect_money'] + $accountMoney_borrower['back_money'] < 0) { //如果需要还款的金额大于回款资金池资金总额 $datamoney_x['account_money'] = floatval($accountMoney_borrower['account_money'] + $accountMoney_borrower['back_money'] + $datamoney_x['affect_money']); $datamoney_x['back_money'] = 0; } else { $datamoney_x['account_money'] = $accountMoney_borrower['account_money']; $datamoney_x['back_money'] = floatval($accountMoney_borrower['back_money']) + $datamoney_x['affect_money']; //回款资金注入回款资金池 } $datamoney_x['collect_money'] = $accountMoney_borrower['money_collect']; $datamoney_x['freeze_money'] = $accountMoney_borrower['money_freeze']; //会员帐户 $mmoney_x['money_freeze'] = $datamoney_x['freeze_money']; $mmoney_x['money_collect'] = $datamoney_x['collect_money']; $mmoney_x['account_money'] = $datamoney_x['account_money']; $mmoney_x['back_money'] = $datamoney_x['back_money']; //会员帐户 $datamoney_x['info'] = "对{$v['borrow_id']}号企业直投进行还款"; $datamoney_x['add_time'] = time(); $datamoney_x['add_ip'] = get_client_ip(); $datamoney_x['target_uid'] = 0; $datamoney_x['target_uname'] = '@网站管理员@'; $moneynewid_x = M('member_moneylog')->add($datamoney_x); if ($moneynewid_x) { $bxid = M('member_money')->where("uid={$datamoney_x['uid']}")->save($mmoney_x); } //借款者减少 $vo = M("transfer_borrow_investor")->field("transfer_month,transfer_num")->where("id={$v['invest_id']}")->find(); $update_investor = array(); $update_investor['id'] = $v['invest_id']; $update_investor['status'] = 2; //还款完成 $update_investor['receive_capital'] = array("exp", "`receive_capital`+{$v['capital']}"); $update_investor['receive_interest'] = array("exp", "`receive_interest`+{$v['interest']}-{$v['interest_fee']}"); $update_investor['back_time'] = time(); $investor = M("transfer_borrow_investor")->save($update_investor); $update_borrow = array(); $update_borrow['id'] = $v['borrow_id']; $update_borrow['transfer_back'] = array("exp", "`transfer_back`+{$vo['transfer_num']}"); $update_borrow['borrow_status'] = 7; //还款完成 $summary = M("transfer_borrow_info")->save($update_borrow); $mapdetail['id'] = $v['id']; $updetail['status'] = 1; //还款完成 $updetail['receive_capital'] = array("exp", "`receive_capital`+{$v['capital']}"); $updetail['receive_interest'] = array("exp", "`receive_interest`+{$v['interest']}-{$v['interest_fee']}"); $updetail['repayment_time'] = time(); $detail = M("transfer_investor_detail")->where($mapdetail)->save($updetail); //$strOut .= "成功还款第{$v['borrow_id']}号企业直投<br/>"; ////////////////////////////////////////////////////对投资帐户进行增加 开始////////////////////////////////////////////////// if ($investor && $summary && $detail) { $accountMoney = M('member_money')->field('money_freeze,money_collect,account_money,back_money')->find($v['investor_uid']); $datamoney['uid'] = $v['investor_uid']; $datamoney['type'] = "44"; $datamoney['affect_money'] = $v['capital'] + $v['interest'] - $v['interest_fee']; //收利息加本金,并且扣管理费 $datamoney['account_money'] = $accountMoney['account_money']; $datamoney['back_money'] = $accountMoney['back_money'] + $datamoney['affect_money']; $datamoney['collect_money'] = $accountMoney['money_collect'] - $datamoney['affect_money']; $datamoney['freeze_money'] = $accountMoney['money_freeze']; //会员帐户 $mmoney['money_freeze'] = $datamoney['freeze_money']; $mmoney['money_collect'] = $datamoney['collect_money']; $mmoney['account_money'] = $datamoney['account_money']; $mmoney['back_money'] = $datamoney['back_money']; //会员帐户 $datamoney['info'] = "收到借款人对{$v['borrow_id']}号企业直投的还款"; $datamoney['add_time'] = time(); $datamoney['add_ip'] = get_client_ip(); $datamoney['target_uid'] = $binfo['borrow_uid']; $datamoney['target_uname'] = $b_member['user_name']; $moneynewid = M('member_moneylog')->add($datamoney); if ($moneynewid) { $xid = M('member_money')->where("uid={$datamoney['uid']}")->save($mmoney); } } ////////////////////////////////////////////////////对投资帐户进行增加 结束////////////////////////////////////////////////// } if ($investor && $summary && $detail && $moneynewid && $xid) { $Updateb->commit(); $strOut .= "成功还款第{$v['borrow_id']}号企业直投<br/>"; } else { $strOut .= "第{$v['borrow_id']}号企业直投还款失败<br/>"; $Updateb->rollback(); } $data = $strOut . "\r\n" . date("Y-m-d H:i:s", time()); //服务器时间 echo $data; }