public function repayment() { $borrowid = intval($_POST['bid']); $sort_order = intval($_POST['sort_order']); $type = 2; borrowRepayment($borrowid, $sort_order, $type); }
public function repayment() { $pre = C('DB_PREFIX'); $borrow_id = intval($_POST['bid']); $sort_order = intval($_POST['sort_order']); //$vo = M("borrow_info")->field('id')->where("id={$borrow_id} AND borrow_uid={$this->uid}")->find(); //if(!is_array($vo)) ajaxmsg("数据有误",0); $vo = M("borrow_info")->field('borrow_uid,danbao')->where("id={$borrow_id}")->find(); if ($vo['borrow_uid'] == $this->uid && $vo['danbao'] == $this->uid) { ajaxmsg("担保公司不能为借款人", 0); } else { if ($vo['borrow_uid'] == $this->uid) { $type = 1; } else { if ($vo['danbao'] == $this->uid) { $type = 3; } else { ajaxmsg("数据有误", 0); } } } $res = borrowRepayment($borrow_id, $sort_order, $type); //$this->display("Public:_footer"); if (true === $res) { ajaxmsg(); } elseif (!empty($res)) { ajaxmsg($res, 0); } else { ajaxmsg("还款失败,请重试或联系客服", 0); } }
public function repayment() { $pre = C('DB_PREFIX'); $borrow_id = intval($_POST['bid']); $sort_order = intval($_POST['sort_order']); $vo = M("borrow_info")->field('*')->where("id={$borrow_id} AND borrow_uid={$this->uid}")->find(); /** $capitallist=M('borrow_investor')->where("borrow_id={$borrow_id}")->Field('*')->select(); foreach($capitallist as $val){ $repay_money = $val['investor_capital']+$val['investor_interest']; $arr = M("members")->field("user_phone,user_name,$repay_money as repay_money")->where("id = {$val['investor_uid']}")->find(); if($arr['user_phone']){ $vusernames[] = $arr; } } */ $borrowDetail = D('investor_detail'); $detailList = $borrowDetail->field('invest_id,investor_uid,capital,interest,interest_fee,borrow_id,total')->where("borrow_id={$borrow_id} AND sort_order={$sort_order}")->select(); foreach ($detailList as $val) { $repay_money = $val['capital'] + $val['interest']; $arr = M("members")->field("user_phone,user_name,{$repay_money} as repay_money")->where("id = {$val['investor_uid']}")->find(); if ($arr['user_phone']) { $vusernames[] = $arr; } } if (!is_array($vo)) { ajaxmsg("数据有误", 0); } $res = borrowRepayment($borrow_id, $sort_order); //$this->display("Public:_footer"); if (true === $res) { $smsTxt = (array) FS("Webconfig/smstxt"); if (false === empty($smsTxt['payback']['enable'])) { foreach ($vusernames as $val) { $txt = preg_replace(array("/#USERANEM#/", "/#ID#/", "/#ORDER#/", "/#MONEY#/"), array($val['user_name'], $borrow_id, $sort_order, $val['repay_money']), $smsTxt['payback']['content']); sendsms($val['user_phone'], $txt); } } ajaxmsg(); } elseif (!empty($res)) { ajaxmsg($res, 0); } else { ajaxmsg("还款失败,请重试或联系客服", 0); } }
function borrowFull($borrow_id, $btype = 0) { if ($btype == 3) { //秒还标 borrowApproved($borrow_id); borrowRepayment($borrow_id, 1); } else { $saveborrow['borrow_status'] = 4; $saveborrow['full_time'] = time(); $upborrow_res = M("borrow_info")->where("id={$borrow_id}")->save($saveborrow); } }
public function domiao() { $borrow_id = intval($_REQUEST['borrow_id']); $vm = M('borrow_info')->field('borrow_uid,borrow_money,has_borrow,borrow_type,borrow_status')->find($borrow_id); if ($vm['borrow_status'] == 7 || $vm['borrow_status'] == 9 || $vm['borrow_status'] == 10) { $this->error('该标已还款完成,请不要重复还款!'); exit; } //复审投标检测 $capital_sum1 = M('investor_detail')->where("borrow_id={$borrow_id}")->sum('capital'); $capital_sum2 = M('borrow_investor')->where("borrow_id={$borrow_id}")->sum('investor_capital'); if ($vm['borrow_money'] != $capital_sum2 || $capital_sum1 != $capital_sum2 || $vm['borrow_money'] != $vm['has_borrow']) { $this->error('投标金额不统一,请确认!'); exit; } else { //dump($borrow_id);exit; if ($vm['borrow_type'] == 3) { borrowApproved($borrow_id); $done = borrowRepayment($borrow_id, 1); if (!$done) { $this->error('还款失败,请确认!'); exit; } else { $this->success('还款成功,请确认!'); exit; } } else { $this->error('非秒标类型,不能执行此操作,请确认!'); exit; } } }
public function sRepayment() { $borrow_id = $_GET['id']; $binfo = M("borrow_info")->field("has_pay,total")->find($borrow_id); $from = $binfo['has_pay'] + 1; for ($i = $from; $i <= $binfo['total']; $i++) { $res = borrowRepayment($borrow_id, $i, 2); } if ($res === true) { $this->success("代还成功"); } elseif (!empty($res)) { $this->error($res); } else { $this->error("代还出错,请重试"); } }
/** * 代还款 **/ public function bDetail() { if ($_POST['ResultCode'] == '88') { import("ORG.Loan.Escrow"); $loan = new Escrow(); if ($loan->loanVerify($_POST)) { $str = ''; if (empty($_POST['Action'])) { //空为冻结 暂不处理 notifyMsg('代还冻结', $_POST, 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'], 'SUCCESS'); echo "SUCCESS"; exit; } elseif (intval($_POST['Action']) == 1) { $info = explode("_", $_POST['Remark1']); $expired = explode('/', $_POST['Remark2']); $vo = M('investor_detail')->where("borrow_id={$info[0]} AND sort_order={$info[1]} AND substitute_money>0")->find(); if (is_array($vo)) { $str = 'SUCCESS'; } elseif (borrowRepayment($info[0], $info[1], $expired, 2)) { $str = 'SUCCESS'; } } notifyMsg('代还', $_POST, 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'], $str); echo $str; exit; } } }
public function doexpired() { $borrow_id = intval($_POST['bid']); $sort_order = intval($_POST['sort_order']); $newid = borrowRepayment($borrow_id, $sort_order); if ($newid === true) { ajaxmsg(); } elseif ($newid === false) { ajaxmsg('还款失败,请重试', 0); } else { ajaxmsg($newid, 0); } }
/** * 3、在到还款期限时,以自动扣款方式进行还款。目前的系统只能由借款者手动触发还款操作 * 每天晚上11点55分自动还款 * add by zh 0319 */ public function autorepaymentCron() { $startDay = time(); $endDay = $startDay + 1.0 * 24 * 3600; //1 day ;endDay>deadline $pre = C('DB_PREFIX'); $field = "d.borrow_id,d.borrow_uid,d.sort_order,sum(d.capital+d.interest) as transamt,m.user_phone"; $list = M('investor_detail d')->distinct(true)->field($field)->join("{$pre}borrow_info b ON b.id=d.borrow_id")->join("{$pre}members m ON m.id=b.borrow_uid")->where("b.borrow_status=6 AND d.repayment_time=0 AND d.deadline>" . $startDay . " AND d.deadline<" . $endDay)->group('d.borrow_id,d.sort_order')->select(); $kefu = M('ausers')->distinct(true)->field('phone')->where('u_group_id=22')->find(); file_put_contents('/tmp/autorepaymentCron', date('m-d H:i:s') . "sql " . print_r(M('investor_detail d')->getLastSql(), true) . "\n", FILE_APPEND); file_put_contents('/tmp/autorepaymentCron', date('m-d H:i:s') . "list " . print_r($list, true) . "\n", FILE_APPEND); foreach ($list as $key => $v) { $transamt = $v['transamt']; //应还金额 $account = M('member_money')->field('account_money,back_money')->where("uid=" . $v['borrow_uid'])->find(); $accountamt = $account['account_money'] + $account['back_money']; //账户余额 if ($transamt > $accountamt) { $msg = '您今日将对标号为' . $v["borrow_id"] . '的第' . $v["sort_order"] . '期还款' . $transamt . '元。目前账户余额为' . $accountamt . '元' . ',余额不足无法自动还款,请充值!'; //echo text($v['user_phone']).$msg; sendsms(text($v['user_phone']), $msg); $msgKefu = '手机号' . $v['user_phone'] . '今日将对标号为' . $v['borrow_id'] . '第' . $v['sort_order'] . '期还款' . $transamt . '元。目前账户余额为' . $accountamt . '元' . ',余额不足无法自动还款!'; sendsms(text($kefu['phone']), $msgKefu); } else { file_put_contents('/tmp/autorepaymentCron', date('m-d H:i:s') . "v " . print_r($v, true) . "\n", FILE_APPEND); //自动还款 borrowRepayment($v['borrow_id'], $v['sort_order']); } sleep(2); } }
public function doexpired() { $borrow_id = intval($_GET['id']); $sort_order = intval($_GET['sort_order']); $vo = M('investor_detail')->where("borrow_id={$borrow_id} AND sort_order={$sort_order} AND substitute_money>0")->find(); if (is_array($vo)) { $this->error("已代还过了"); } else { $newid = borrowRepayment($borrow_id, $sort_order, 2); } if ($newid === true) { $this->success("代还成功"); } elseif ($newid) { $this->error($newid); } else { $this->error("代还失败,请重试"); } }
function borrowFull($borrow_id, $btype = 0) { $pre = DB_PREFIX; if ($btype == 3) { //秒还标 borrowApproved($borrow_id); sleep(3); borrowRepayment($borrow_id, 1); } else { $dd = new PDO('mysql:host=' . DB_HOST . ';dbname=' . DB_NAME, DB_USER, DB_PWD); $sql = "update %s set borrow_status='%s',full_time = '%s' where id= %s "; $sql = sprintf($sql, "{$pre}borrow_info", 4, time(), $borrow_id); $stmt1 = $dd->prepare($sql); $result = $stmt1->execute(); $dd = null; file_put_contents('/tmp/investmoney.txt', date('m-d H:i:s') . "{$result}" . print_r($sql, true) . "\n", FILE_APPEND); } }
/** * 还款后台通知地址 * */ public function detail() { if ($_POST['ResultCode'] == '88') { import("ORG.Loan.Escrow"); $loan = new Escrow(); if ($loan->loanVerify($_POST)) { $str = ''; if ($_POST['Action'] == 1) { $info = explode("_", $_POST['Remark1']); $expired = explode('/', $_POST['Remark2']); if (borrowRepayment($info[0], $info[1], $expired)) { $str = "SUCCESS"; } } elseif (empty($_POST['Action'])) { notifyMsg('还款冻结', $_POST, 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'], 'SUCCESS'); die("SUCCESS"); } notifyMsg('还款', $_POST, 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'], $str); echo $str; } } }