function RepaymentNewTradeCallBack($pMerCode, $pErrCode, $pErrMsg, $str3Req) { //print_r($str3Req); $pMerBillNo = $str3Req["pMerBillNo"]; $where = " pMerBillNo = '" . $pMerBillNo . "'"; $data = array(); $data['pErrCode'] = $pErrCode; //MG00008F IPS受理中 $data['pErrMsg'] = $pErrMsg; $data['pIpsBillNo'] = $str3Req["pIpsBillNo"]; //IPS还款订单号 否 由 IPS 系统生成的唯一流水号, 此次还款的批次号 $data['pIpsDate'] = $str3Req["pIpsDate"]; //IPS受理日期 否 yyyyMMdd if ($data['pErrCode'] == 'MG00008F') { $data['pOutIpsFee'] = $str3Req["pOutIpsFee"]; } //收取转出方手 续费 此手续费由平台商户垫付给 IPS 的手续费 //echo $where;exit; $GLOBALS['db']->autoExecute(DB_PREFIX . "ips_repayment_new_trade", $data, 'UPDATE', $where); if ($data['pErrCode'] == 'MG00008F') { $ipsdata = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "ips_repayment_new_trade where " . $where); //has_repay 0未还,1已还 2部分还款3IPS受理中 //,lock_time = ".get_gmtime()." $sql = "update " . DB_PREFIX . "deal_repay set has_repay = 3 where has_repay in (0,2) and id = " . $ipsdata['deal_repay_id']; $GLOBALS['db']->query($sql); } //MG00000F操作成功 if ($data['pErrCode'] == 'MG00000F') { $sql = "update " . DB_PREFIX . "ips_repayment_new_trade set is_callback = 1 where is_callback = 0 and " . $where; $GLOBALS['db']->query($sql); if ($GLOBALS['db']->affected_rows()) { $ipsdata = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "ips_repayment_new_trade where " . $where); //require_once(APP_ROOT_PATH.'system/collocation/ips/xml.php'); //$pDetails = @XML_unserialize($pDetails); //print_r($pDetails); //$pDetails = getXmlNodeValue($str3XmlParaInfo, "pDetails"); $guarantor_real_fit_amt = 0; $attr = array(); if (isset($str3Req["pDetails"]["pRow"][0])) { $attr = $str3Req["pDetails"]["pRow"]; } else { $attr[] = $str3Req["pDetails"]["pRow"]; } foreach ($attr as $k => $v) { $pCreMerBillNo = $v["pCreMerBillNo"]; $where = " pid = " . $ipsdata['id'] . " and pCreMerBillNo = '" . $pCreMerBillNo . "'"; $ips_detail = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "ips_repayment_new_trade_detail where " . $where); $detail = array(); $detail['pStatus'] = $v["pStatus"]; //Y#转账成功;N#转账失败 $detail['pMessage'] = $v["pMessage"]; //转账备注 否 转账失败的原因 $GLOBALS['db']->autoExecute(DB_PREFIX . "ips_repayment_new_trade_detail", $detail, 'UPDATE', " id = " . intval($ips_detail['id'])); if ($v["pStatus"] == 'Y') { $load_repay = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "deal_load_repay where id = " . $ips_detail['deal_load_repay_id']); $detail = array(); $detail['repay_manage_impose_money'] = $ips_detail["repay_manage_impose_money"]; //平台收取 借款者 的管理费逾期罚息 $detail['impose_money'] = $ips_detail["impose_money"]; //投资者收取 借款者 的逾期罚息 $detail['status'] = $ips_detail["repay_status"]; //还款状态 $detail['true_repay_time'] = $ips_detail["true_repay_time"]; //还款时间 $detail['true_repay_date'] = to_date($ips_detail["true_repay_time"]); $detail['has_repay'] = 1; //0未收到还款,1已收到还款 $detail['true_manage_money'] = $load_repay['manage_money']; $detail['true_manage_interest_money'] = $load_repay["manage_interest_money"]; $detail['true_repay_manage_money'] = $load_repay["repay_manage_money"]; $detail['true_repay_money'] = $load_repay["repay_money"]; $detail['true_self_money'] = $load_repay['self_money']; $detail['true_interest_money'] = $load_repay['interest_money']; /* $detail = array(); $detail['repay_manage_impose_money'] = $ips_detail["repay_manage_impose_money"]; $detail['true_manage_money'] = floatval($ips_detail["pInFee"]) - floatval($ips_detail["manage_interest_money"]); $detail['true_manage_interest_money'] = $ips_detail["manage_interest_money"]; $detail['true_repay_manage_money'] = floatval($ips_detail["pOutInfoFee"]) - floatval($detail['repay_manage_impose_money']); $detail['true_repay_money'] = $ips_detail['pInAmt'] - $ips_detail["impose_money"]; $detail['true_self_money'] = $ips_detail['self_money']; $detail['true_interest_money'] = floatval($detail['true_repay_money']) - floatval($ips_detail['self_money']); $detail['impose_money'] = $ips_detail["impose_money"]; $detail['has_repay'] = 1;//0未收到还款,1已收到还款 $detail['status'] = $ips_detail["repay_status"]; $detail['true_repay_time'] = $ips_detail["true_repay_time"]; $detail['true_repay_date'] = to_date($ips_detail["true_repay_time"]); */ $GLOBALS['db']->autoExecute(DB_PREFIX . "deal_load_repay", $detail, 'UPDATE', " has_repay = 0 and id = " . intval($ips_detail['deal_load_repay_id'])); //普通会员邀请返利 get_referrals($ips_detail['deal_load_repay_id']); } } //更新用户回款计划 require_once APP_ROOT_PATH . "app/Lib/deal.php"; syn_deal_repay_status($ipsdata['deal_id'], $ipsdata['deal_repay_id']); } } return $ipsdata; }
function RepaymentRepayCallBack($str3Req) { if ($str3Req["code"] == '1') { $requestNo = $str3Req["requestNo"]; $platformNo = $str3Req["platformNo"]; $where = " requestNo = '" . $requestNo . "'"; $sql = "update " . DB_PREFIX . "yeepay_cp_transaction set is_complete_transaction = 1 where is_callback = 1 and " . $where; $GLOBALS['db']->query($sql); $yee_data = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "yeepay_cp_transaction where requestNo = " . $requestNo); $sql = "select * from " . DB_PREFIX . "yeepay_cp_transaction_detail where deal_load_repay_id > 0 and pid = " . $yee_data['id']; $list = $GLOBALS['db']->getAll($sql); foreach ($list as $k => $v) { $load_repay = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "deal_load_repay where id = " . $v['deal_load_repay_id']); $detail = array(); $detail['repay_manage_impose_money'] = $v["repay_manage_impose_money"]; //平台收取 借款者 的管理费逾期罚息 $detail['impose_money'] = $v["impose_money"]; //投资者收取 借款者 的逾期罚息 $detail['status'] = $v["repay_status"]; //还款状态 $detail['true_repay_time'] = $v["true_repay_time"]; //还款时间 $detail['true_repay_date'] = to_date($v["true_repay_time"]); $detail['has_repay'] = 1; //0未收到还款,1已收到还款 $detail['true_manage_money'] = $load_repay['manage_money']; $detail['true_manage_interest_money'] = $load_repay["manage_interest_money"]; $detail['true_repay_manage_money'] = $load_repay["repay_manage_money"]; $detail['true_repay_money'] = $load_repay["repay_money"]; $detail['true_self_money'] = $load_repay['self_money']; $detail['true_interest_money'] = $load_repay['interest_money']; $GLOBALS['db']->autoExecute(DB_PREFIX . "deal_load_repay", $detail, 'UPDATE', " has_repay = 0 and id = " . intval($v['deal_load_repay_id'])); //普通会员邀请返利 get_referrals($v['deal_load_repay_id']); } require_once APP_ROOT_PATH . "app/Lib/deal_func.php"; //更新用户回款计划 syn_deal_repay_status($yee_data["tenderOrderNo"], $yee_data["deal_repay_id"]); $result["deal_id"] = $yee_data["tenderOrderNo"]; return $result; } return 1; }
/** * 还款 * @param deal $deal 标的数据 * @param array $repaylist 还款列表 * @param int $deal_repay_id 还款计划ID * @param int $MerCode 商户ID * @param string $cert_md5 * @param string $post_url * @return string */ function RepaymentNewTrade($cfg, $deal, $repaylist, $deal_repay_id, $post_url) { $merchant_id = $cfg['merchant_id']; $terminal_id = $cfg['terminal_id']; $key = $cfg['key']; $iv = $cfg['iv']; //$deal = $GLOBALS['db']->getRow("select * from ".DB_PREFIX."deal where id = ".$deal_id); //$user = $GLOBALS['db']->getRow("select * from ".DB_PREFIX."user where id = ".$user_id); $data = array(); $data['merchant_id'] = $merchant_id; //商户号 $data['terminal_id'] = $terminal_id; //终端号 $data['action_type'] = 4; //请求类型,投标为1,满标为2,流标为3,还标为4 $data['order_id'] = 0; $data['user_id'] = $deal['user_id']; //借款人 $data['special'] = 1; $data['cus_id'] = $deal['id']; $data['cus_name'] = $deal['sub_name']; //项目名称 $data['brw_id'] = $deal['user_id']; //借款人 $data['req_time'] = microtime_float(); // get_gmtime();//请求时间 例如 1405668253874 (当前时间转换毫秒) $data['fee'] = 0; //手续费(涉及到满标、还款接口) $data['repay_start_time'] = 0; // 开始还款日期 $data['load_amount'] = 0; // 记录投标金额 $data['bids_msg'] = ''; //流标原因 $data['deal_repay_id'] = $deal_repay_id; //还款计划ID $GLOBALS['db']->autoExecute(DB_PREFIX . "baofoo_business", $data, 'INSERT'); $id = $GLOBALS['db']->insert_id(); $fee = 0; foreach ($repaylist as $k => $v) { //平台收取:借款者 的管理费 + 管理逾期罚息 $fee = $fee + $v['repay_manage_money'] + $v['repay_manage_impose_money']; //==============================投资者获取的,费用=================================== $detail = array(); $detail['pid'] = $id; $detail['deal_load_repay_id'] = $v['id']; $detail['repay_manage_impose_money'] = $v['repay_manage_impose_money']; //平台收取 借款者 的管理费逾期罚息 $detail['impose_money'] = $v['impose_money']; //投资者收取 借款者 的逾期罚息 $detail['repay_status'] = intval($v['status']) - 1; //还款状态 $detail['true_repay_time'] = TIME_UTC; //还款时间 //投资人会员编号 if ($v['t_user_id']) { //债权转让后,还款时,转给:承接者, 在债权转让后需要更新 fanwe_deal_load_repay.t_user_id 数据值 $detail['user_id'] = $v['t_user_id']; } else { $detail['user_id'] = $v['user_id']; } //投资者获取的,费用 [宝付会自动扣除 $detail['fee'] 部分,所以最终获得的收入为:$v['month_repay_money'] + $v['impose_money'] - $v['manage_money'] - $v['manage_interest_money'] $detail['amount'] = round($v['month_repay_money'] + $v['impose_money'], 2); //平台收取:投资者 的投资金额管理费 + 利息管理费 $detail['fee'] = round($v['manage_money'] + $v['manage_interest_money'], 2); $GLOBALS['db']->autoExecute(DB_PREFIX . "baofoo_business_detail", $detail, 'INSERT'); $details[] = $detail; } $data_update = array(); $data_update['order_id'] = $id; $data['order_id'] = $id; $data['fee'] = round($fee, 2); //手续费(涉及到满标、还款接口) $GLOBALS['db']->autoExecute(DB_PREFIX . "baofoo_business", $data_update, 'UPDATE', 'id=' . $id); $actions = "<actions>"; foreach ($details as $k => $v) { $actions .= "<action><user_id>" . intval($v['user_id']) . "</user_id><amount>" . $v['amount'] . "</amount><fee>" . $v['fee'] . "</fee></action>"; } $actions .= "<action><user_id>" . intval($deal['user_id']) . "</user_id><special>1</special><fee>" . round($fee, 2) . "</fee></action>"; $actions .= "</actions>"; $strxml = RepaymentNewTradeXml($data, $actions); $pSign = md5($strxml . "~|~" . $key); /* $pWebUrl= SITE_DOMAIN.APP_ROOT."/index.php?ctl=collocation&act=response&class_name=Baofoo&class_act=RepaymentNewTrade&from=".$_REQUEST['from']."&order_id=".$id;//web方式返回 $pS2SUrl= SITE_DOMAIN.APP_ROOT."/index.php?ctl=collocation&act=notify&class_name=Baofoo&class_act=RepaymentNewTrade&from=".$_REQUEST['from']."&order_id=".$id;//s2s方式返回 $html = '<html><head><meta http-equiv="content-type" content="text/html; charset=UTF-8" /></head><body> <form name="form1" id="form1" method="post" action="'.$post_url.'custody/businessPage.do" target="_self"> merchant_id:<input type="text" name="merchant_id" value="'.$merchant_id.'" /><br> terminal_id:<input type="text" name="terminal_id" value="'.$terminal_id.'" /><br> sign:<input type="text" name="sign" value="'.$pSign.'" /><br> requestParams:<textarea name="requestParams" cols="100" rows="5">'.$strxml.'</textarea> <br> page_url:<input type="text" name="page_url" value="'.$pWebUrl.'" /><br> service_url:<input type="text" name="service_url" value="'.$pS2SUrl.'" /><br> <input type="submit" value="提交"></input> </form> </body></html> ';//<script language="javascript">document.form1.submit();</script>'; //echo $html; exit; */ $post_data = array("merchant_id" => $merchant_id, "terminal_id" => $terminal_id, "sign" => $pSign, "requestParams" => $strxml); $baofoo_log = array(); $baofoo_log['code'] = 'business_4'; $baofoo_log['create_date'] = to_date(TIME_UTC, 'Y-m-d H:i:s'); $baofoo_log['strxml'] = $strxml; $baofoo_log['html'] = print_r($post_data, true); $GLOBALS['db']->autoExecute(DB_PREFIX . "baofoo_log", $baofoo_log); $resultStr = httpRequestPOST($post_url . "custody/p2pRequest.do", $post_data); $baofoo_log = array(); $baofoo_log['code'] = 'p2pRequest_4'; $baofoo_log['create_date'] = to_date(TIME_UTC, 'Y-m-d H:i:s'); $baofoo_log['strxml'] = print_r($resultStr, true); $baofoo_log['html'] = ''; $GLOBALS['db']->autoExecute(DB_PREFIX . "baofoo_log", $baofoo_log); //还款 require_once APP_ROOT_PATH . 'system/collocation/ips/xml.php'; $str3ParaInfo = @XML_unserialize($resultStr); $str3Req = $str3ParaInfo['crs']; $sign = $str3Req["sign"]; $Md5sign = Md5($str3Req["code"] . '~|~' . $str3Req["msg"] . '~|~' . $key); if ($sign == $Md5sign) { $order_id = $id; $where = " order_id = '" . $order_id . "'"; $sql = "update " . DB_PREFIX . "baofoo_business set is_callback = 1 where is_callback = 0 and " . $where; $GLOBALS['db']->query($sql); if ($GLOBALS['db']->affected_rows()) { //操作成功 $GLOBALS['db']->autoExecute(DB_PREFIX . "baofoo_business", $str3Req, 'UPDATE', $where); $ipsdata = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "baofoo_business where " . $where); $deal_id = intval($ipsdata['cus_id']); $deal_repay_id = intval($ipsdata['deal_repay_id']); if ($str3Req['code'] == 'CSD000') { $sql = "select * from " . DB_PREFIX . "baofoo_business_detail where deal_load_repay_id > 0 and pid = " . $ipsdata['id']; $list = $GLOBALS['db']->getAll($sql); foreach ($list as $k => $v) { $load_repay = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "deal_load_repay where id = " . $v['deal_load_repay_id']); //repay_status,repay_manage_impose_money $detail = array(); $detail['repay_manage_impose_money'] = $v["repay_manage_impose_money"]; //平台收取 借款者 的管理费逾期罚息 $detail['impose_money'] = $v["impose_money"]; //投资者收取 借款者 的逾期罚息 $detail['status'] = $v["repay_status"]; //还款状态 $detail['true_repay_time'] = $v["true_repay_time"]; //还款时间 $detail['true_repay_date'] = to_date($v["true_repay_time"]); $detail['has_repay'] = 1; //0未收到还款,1已收到还款 $detail['true_manage_money'] = $load_repay['manage_money']; $detail['true_manage_interest_money'] = $load_repay["manage_interest_money"]; $detail['true_repay_manage_money'] = $load_repay["repay_manage_money"]; $detail['true_repay_money'] = $load_repay["repay_money"]; $detail['true_self_money'] = $load_repay['self_money']; $detail['true_interest_money'] = $load_repay['interest_money']; $GLOBALS['db']->autoExecute(DB_PREFIX . "deal_load_repay", $detail, 'UPDATE', " has_repay = 0 and id = " . intval($v['deal_load_repay_id'])); //普通会员邀请返利 get_referrals($v['deal_load_repay_id']); } //更新用户回款计划 require_once APP_ROOT_PATH . "app/Lib/deal.php"; syn_deal_repay_status($deal_id, $deal_repay_id); return '已还款'; } else { return 'code:' . $str3Req['code'] . ';msg:' . $str3Req['msg']; } } else { return '重复调用'; } } else { return '验证不通过'; } }
/** * 代还款 */ function do_site_repay($page = 1) { require_once APP_ROOT_PATH . "app/Lib/common.php"; require_once APP_ROOT_PATH . "app/Lib/deal.php"; $id = intval($_REQUEST['id']); $l_key = intval($_REQUEST['l_key']); $this->assign("jumpUrl", U("Deal/repay_plan", array("id" => $id))); if ($id == 0) { $this->success("数据错误"); } $deal_info = get_deal($id); if (!$deal_info) { $this->success("借款不存在"); } if ($deal_info['ips_bill_no'] != "") { $this->success("第三方同步暂无法代还款"); } $user_id = $deal_info['user_id']; if ($page == 0) { $page = 1; } $page_size = 10; $limit = ($page - 1) * $page_size . "," . $page_size; $user_loan_list = get_deal_user_load_list($deal_info, 0, $l_key, -1, 0, 0, 1, $limit); $rs_count = $user_loan_list['count']; $page_all = ceil($rs_count / $page_size); require_once APP_ROOT_PATH . "system/libs/user.php"; foreach ($user_loan_list['item'] as $kk => $vv) { if ($vv['has_repay'] == 0) { //借入者已还款,但是没打款到借出用户中心 $user_load_data = array(); $user_load_data['true_repay_time'] = TIME_UTC; $user_load_data['true_repay_date'] = to_date(TIME_UTC); $user_load_data['is_site_repay'] = 1; $user_load_data['status'] = 0; $user_load_data['true_repay_money'] = (double) $vv['month_repay_money']; $user_load_data['true_self_money'] = (double) $vv['self_money']; $user_load_data['true_interest_money'] = (double) $vv['interest_money']; $user_load_data['true_manage_money'] = (double) $vv['manage_money']; $user_load_data['true_manage_interest_money'] = (double) $vv['manage_interest_money']; $user_load_data['true_repay_manage_money'] = (double) $vv['repay_manage_money']; $user_load_data['true_manage_interest_money_rebate'] = (double) $vv['manage_interest_money_rebate']; $user_load_data['impose_money'] = (double) $vv['impose_money']; $user_load_data['repay_manage_impose_money'] = (double) $vv['repay_manage_impose_money']; $user_load_data['true_reward_money'] = (double) $vv['reward_money']; if ($vv['status'] > 0) { $user_load_data['status'] = $vv['status'] - 1; } $user_load_data['has_repay'] = 1; $GLOBALS['db']->autoExecute(DB_PREFIX . "deal_load_repay", $user_load_data, "UPDATE", "id=" . $vv['id'] . " AND has_repay = 0 ", "SILENT"); if ($GLOBALS['db']->affected_rows() > 0) { //$content = "您好,您在".app_conf("SHOP_TITLE")."的投标 “<a href=\"".$deal_info['url']."\">".$deal_info['name']."</a>”成功还款".($user_load_data['true_repay_money']+$user_load_data['impose_money'])."元,"; $unext_loan = $user_loan_list[$vv['u_key']][$kk + 1]; if ($unext_loan) { //$content .= "本笔投标的下个还款日为".to_date($unext_loan['repay_day'],"Y年m月d日").",需还本息".number_format($unext_loan['month_repay_money'],2)."元。"; $notices['content'] = ",本笔投标的下个还款日为" . to_date($unext_loan['repay_day'], "Y年m月d日") . ",需还本息" . number_format($unext_loan['month_repay_money'], 2) . "元。"; } else { $load_repay_rs = $GLOBALS['db']->getOne("SELECT (sum(true_interest_money) + sum(impose_money)) as shouyi,sum(impose_money) as total_impose_money FROM " . DB_PREFIX . "deal_load_repay WHERE deal_id=" . $deal_info['id'] . " AND user_id=" . $vv['user_id']); $all_shouyi_money = number_format($load_repay_rs['shouyi'], 2); $all_impose_money = number_format($load_repay_rs['total_impose_money'], 2); //$content .= "本次投标共获得收益:".$all_shouyi_money."元,其中违约金为:".$all_impose_money."元,本次投标已回款完毕!"; $notices['content'] = ",本次投标共获得收益:" . $all_shouyi_money . "元,其中违约金为:" . $all_impose_money . "元,本次投标已回款完毕!"; } if ($user_load_data['impose_money'] != 0 || $user_load_data['true_manage_money'] != 0 || $user_load_data['true_repay_money'] != 0) { $in_user_id = $vv['user_id']; //如果是转让债权那么将回款打入转让者的账户 if ((int) $vv['t_user_id'] == 0) { $loan_user_info['user_name'] = $vv['user_name']; $loan_user_info['email'] = $vv['email']; $loan_user_info['mobile'] = $vv['mobile']; } else { $in_user_id = $vv['t_user_id']; $loan_user_info['user_name'] = $vv['t_user_name']; $loan_user_info['email'] = $vv['t_email']; $loan_user_info['mobile'] = $vv['t_mobile']; } //更新用户账户资金记录 modify_account(array("money" => $user_load_data['true_repay_money']), $in_user_id, "[<a href='" . $deal_info['url'] . "' target='_blank'>" . $deal_info['name'] . "</a>],第" . ($kk + 1) . "期,回报本息", 5); if ($user_load_data['true_manage_money'] > 0) { modify_account(array("money" => -$user_load_data['true_manage_money']), $in_user_id, "[<a href='" . $deal_info['url'] . "' target='_blank'>" . $deal_info['name'] . "</a>],第" . ($kk + 1) . "期,投标管理费", 20); } //利息管理费 modify_account(array("money" => -$user_load_data['true_manage_interest_money']), $in_user_id, "[<a href='" . $deal_info['url'] . "' target='_blank'>" . $deal_info['name'] . "</a>],第" . ($kk + 1) . "期,投标利息管理费", 20); if ($user_load_data['impose_money'] != 0) { modify_account(array("money" => $user_load_data['impose_money']), $in_user_id, "[<a href='" . $deal_info['url'] . "' target='_blank'>" . $deal_info['name'] . "</a>],第" . ($kk + 1) . "期,逾期罚息", 21); } //普通会员邀请返利 get_referrals($vv['id']); //投资者返佣金 if ($user_load_data['true_manage_interest_money_rebate'] != 0) { /*ok*/ $reback_memo = sprintf($GLOBALS['lang']["INVEST_REBATE_LOG"], $deal_info["url"], $deal_info["name"], $loan_user_info["user_name"], intval($vv["l_key"]) + 1); reback_rebate_money($in_user_id, $user_load_data['true_manage_interest_money_rebate'], "invest", $reback_memo); } $msg_conf = get_user_msg_conf($in_user_id); //短信通知 if (app_conf("SMS_ON") == 1 && app_conf('SMS_REPAY_TOUSER_ON') == 1) { $tmpl = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "msg_template where name = 'TPL_DEAL_LOAD_REPAY_SMS'"); $tmpl_content = $tmpl['content']; $notice['user_name'] = $loan_user_info['user_name']; $notice['deal_name'] = $deal_info['sub_name']; $notice['deal_url'] = $deal_info['url']; $notice['site_name'] = app_conf("SHOP_TITLE"); $notice['repay_money'] = number_format($user_load_data['true_repay_money'] + $user_load_data['impose_money'], 2); if ($unext_loan) { $notice['need_next_repay'] = $unext_loan; $notice['next_repay_time'] = to_date($unext_loan['repay_day'], "Y年m月d日"); $notice['next_repay_money'] = number_format($unext_loan['month_repay_money'], 2); } else { $notice['all_repay_money'] = $all_shouyi_money; $notice['impose_money'] = $all_impose_money; } $GLOBALS['tmpl']->assign("notice", $notice); $sms_content = $GLOBALS['tmpl']->fetch("str:" . $tmpl_content); $msg_data['dest'] = $loan_user_info['mobile']; $msg_data['send_type'] = 0; $msg_data['title'] = $msg_data['content'] = addslashes($sms_content); $msg_data['send_time'] = 0; $msg_data['is_send'] = 0; $msg_data['create_time'] = TIME_UTC; $msg_data['user_id'] = $in_user_id; $msg_data['is_html'] = 0; $GLOBALS['db']->autoExecute(DB_PREFIX . "deal_msg_list", $msg_data); //插入 } //站内信 $notices['shop_title'] = app_conf("SHOP_TITLE"); $notices['url'] = "“<a href=\"" . $deal_info['url'] . "\">" . $deal_info['name'] . "</a>”"; $notices['money'] = $user_load_data['true_repay_money'] + $user_load_data['impose_money']; $tmpl_content = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "msg_template where name = 'TPL_SITE_REPAY'", false); $GLOBALS['tmpl']->assign("notice", $notices); $content = $GLOBALS['tmpl']->fetch("str:" . $tmpl_content['content']); if ($msg_conf['sms_bidrepaid'] == 1) { send_user_msg("", $content, 0, $in_user_id, TIME_UTC, 0, true, 9); } //邮件 if ($msg_conf['mail_bidrepaid'] == 1 && app_conf('MAIL_ON') == 1) { $tmpl = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "msg_template where name = 'TPL_DEAL_LOAD_REPAY_EMAIL'", false); $tmpl_content = $tmpl['content']; $notice['user_name'] = $loan_user_info['user_name']; $notice['deal_name'] = $deal_info['sub_name']; $notice['deal_url'] = $deal_info['url']; $notice['site_name'] = app_conf("SHOP_TITLE"); $notice['site_url'] = SITE_DOMAIN . APP_ROOT; $notice['help_url'] = SITE_DOMAIN . url("index", "helpcenter"); $notice['msg_cof_setting_url'] = SITE_DOMAIN . url("index", "uc_msg#setting"); $notice['repay_money'] = number_format($vv['month_repay_money'] + $vv['impose_money'], 2); if ($unext_loan) { $notice['need_next_repay'] = $unext_loan; $notice['next_repay_time'] = to_date($unext_loan['repay_day'], "Y年m月d日"); $notice['next_repay_money'] = number_format($unext_loan['month_repay_money'], 2); } else { $notice['all_repay_money'] = $all_shouyi_money; $notice['impose_money'] = $all_impose_money; } $GLOBALS['tmpl']->assign("notice", $notice); $msg = $GLOBALS['tmpl']->fetch("str:" . $tmpl_content); $msg_data['dest'] = $loan_user_info['email']; $msg_data['send_type'] = 1; $msg_data['title'] = "“" . $deal_info['name'] . "”回款通知"; $msg_data['content'] = addslashes($msg); $msg_data['send_time'] = 0; $msg_data['is_send'] = 0; $msg_data['create_time'] = TIME_UTC; $msg_data['user_id'] = $in_user_id; $msg_data['is_html'] = $tmpl['is_html']; $GLOBALS['db']->autoExecute(DB_PREFIX . "deal_msg_list", $msg_data); //插入 } } } } } if ($page >= $page_all) { $s_count = $GLOBALS['db']->getOne("SELECT count(*) FROM " . DB_PREFIX . "deal_load_repay where deal_id=" . $id . " AND l_key=" . $l_key . " and has_repay = 0"); $adm_session = es_session::get(md5(conf("AUTH_KEY"))); if ($s_count == 0) { $rs_sum = $GLOBALS['db']->getRow("SELECT sum(true_repay_money) as total_repay_money,sum(true_self_money) as total_self_money,sum(true_interest_money) as total_interest_money,sum(true_repay_manage_money) as total_manage_money,sum(impose_money) as total_impose_money,sum(repay_manage_impose_money) as total_repay_manage_impose_money FROM " . DB_PREFIX . "deal_load_repay where deal_id=" . $id . " AND l_key=" . $l_key . " and has_repay = 1"); $deal_load_list = get_deal_load_list($deal_info); //统计网站代还款 $rs_site_sum = $GLOBALS['db']->getRow("SELECT sum(true_repay_money) as total_repay_money,sum(true_self_money) as total_self_money,sum(true_repay_manage_money) as total_manage_money,sum(impose_money) as total_impose_money,sum(repay_manage_impose_money) as total_repay_manage_impose_money FROM " . DB_PREFIX . "deal_load_repay where deal_id=" . $id . " AND l_key=" . $l_key . " and is_site_repay=1 and has_repay = 1"); $repay_data['status'] = (int) $GLOBALS['db']->getOne("SELECT `status` FROM " . DB_PREFIX . "deal_load_repay where deal_id=" . $id . " AND l_key=" . $l_key . " and has_repay = 1 AND is_site_repay=1 ORDER BY l_key DESC"); $repay_data['true_repay_time'] = TIME_UTC; $repay_data['true_repay_date'] = to_date(TIME_UTC); $repay_data['has_repay'] = 1; $repay_data['impose_money'] = floatval($rs_sum['total_impose_money']); $repay_data['true_self_money'] = floatval($rs_sum['total_self_money']); $repay_data['true_repay_money'] = floatval($rs_sum['total_repay_money']); $repay_data['true_manage_money'] = floatval($rs_sum['total_manage_money']); $repay_data['true_interest_money'] = floatval($rs_sum['total_interest_money']); $repay_data['manage_impose_money'] = floatval($rs_sum['total_repay_manage_impose_money']); $rebate_rs = get_rebate_fee($user_id, "borrow"); $repay_data['true_manage_money_rebate'] = $repay_data['true_manage_money'] * floatval($rebate_rs['rebate']) / 100; //借款者返佣 if ($repay_data['true_manage_money_rebate'] != 0) { /*ok*/ $reback_memo = sprintf(L("BORROW_REBATE_LOG"), $deal_info["url"], $deal_info["name"], $deal_info["user"]["user_name"], intval($l_key) + 1); reback_rebate_money($user_id, $repay_data['true_manage_money_rebate'], "borrow", $reback_memo); } $GLOBALS['db']->autoExecute(DB_PREFIX . "deal_repay", $repay_data, "UPDATE", " deal_id=" . $id . " AND l_key=" . $l_key . " and has_repay = 0 "); $impose_day = ceil((to_timespan(to_date(TIME_UTC, "Y-m-d"), "Y-m-d") - $deal_load_list[$l_key]['repay_day']) / 24 / 3600); if ($impose_day > 0) { //VIP 逾期还款降级 $type = 2; $type_info = 5; $resultdate = syn_user_vip($user_id, $type, $type_info); if ($impose_day < app_conf('YZ_IMPSE_DAY')) { modify_account(array("point" => trim(app_conf('IMPOSE_POINT'))), $deal_info['user_id'], "[<a href='" . $deal_info['url'] . "' target='_blank'>" . $deal_info['name'] . "</a>],第" . ($kk + 1) . "期,逾期还款", 11); } else { modify_account(array("point" => trim(app_conf('YZ_IMPOSE_POINT'))), $deal_info['user_id'], "[<a href='" . $deal_info['url'] . "' target='_blank'>" . $deal_info['name'] . "</a>],第" . ($kk + 1) . "期,严重逾期", 11); } } else { //VIP 代还款降级 $type = 2; $type_info = 6; $resultdate = syn_user_vip($user_id, $type, $type_info); } if ($rs_site_sum) { $r_msg = "网站代还款"; if ($rs_site_sum['total_repay_money'] > 0) { $r_msg .= ",本息:" . format_price($rs_site_sum['total_repay_money']); } if ($rs_site_sum['total_impose_money'] > 0) { $r_msg .= ",逾期费用:" . format_price($rs_site_sum['total_impose_money']); } if ($rs_site_sum['total_manage_money'] > 0) { $r_msg .= ",管理费:" . format_price($rs_site_sum['total_manage_money']); } if ($rs_site_sum['total_repay_manage_impose_money'] > 0) { $r_msg .= ",逾期管理费:" . format_price($rs_site_sum['total_repay_manage_impose_money']); } repay_log($deal_load_list[$l_key]['repay_id'], $r_msg, 0, $adm_session['adm_id']); } if ($GLOBALS['db']->getOne("SELECT count(*) FROM " . DB_PREFIX . "generation_repay WHERE deal_id=" . $id . " AND repay_id=" . $deal_load_list[$l_key]['repay_id'] . "") == 0) { $generation_repay['deal_id'] = $id; $generation_repay['repay_id'] = $deal_load_list[$l_key]['repay_id']; $generation_repay['admin_id'] = $adm_session['adm_id']; $generation_repay['agency_id'] = $deal_info['agency_id']; $generation_repay['repay_money'] = $rs_site_sum['total_repay_money']; $generation_repay['self_money'] = $rs_site_sum['total_self_money']; $generation_repay['impose_money'] = $rs_site_sum['total_impose_money']; $generation_repay['manage_money'] = $rs_site_sum['total_manage_money']; $generation_repay['manage_impose_money'] = $rs_site_sum['total_repay_manage_impose_money']; $generation_repay['create_time'] = TIME_UTC; $generation_repay['create_date'] = to_date(TIME_UTC, "Y-m-d"); $GLOBALS['db']->autoExecute(DB_PREFIX . "generation_repay", $generation_repay); $site_money_data['user_id'] = $user_id; $site_money_data['create_time'] = TIME_UTC; $site_money_data['create_time_ymd'] = to_date(TIME_UTC, "Y-m-d"); $site_money_data['create_time_ym'] = to_date(TIME_UTC, "Ym"); $site_money_data['create_time_y'] = to_date(TIME_UTC, "Y"); if ($rs_sum['total_manage_money'] != 0) { $site_money_data['memo'] = "[<a href='" . $deal_info['url'] . "' target='_blank'>" . $deal_info['name'] . "</a>],第" . $l_key . "期,借款管理费"; $site_money_data['type'] = 10; $site_money_data['money'] = $rs_sum['total_manage_money']; $GLOBALS['db']->autoExecute(DB_PREFIX . "site_money_log", $site_money_data, "INSERT"); } if ($rs_sum['total_repay_manage_impose_money'] != 0) { $site_money_data['memo'] = "[<a href='" . $deal_info['url'] . "' target='_blank'>" . $deal_info['name'] . "</a>],第" . $l_key . "期,逾期管理费"; $site_money_data['type'] = 12; $site_money_data['money'] = $rs_sum['total_repay_manage_impose_money']; $GLOBALS['db']->autoExecute(DB_PREFIX . "site_money_log", $site_money_data, "INSERT"); } } } syn_deal_status($deal_info['id']); syn_transfer_status(0, $deal_info['id']); $this->success("代还款执行完毕!"); } else { register_shutdown_function(array(&$this, 'do_site_repay'), $page + 1); } }
$b .= "<center>\n <form action=index.php?lev=" . $_SESSION[$_CONF['sess_name'] . '_lev'] . "&cat=" . $_SESSION[$_CONF['sess_name'] . '_cat'] . " method=POST name=students>" . make_selection_list($los, $sid, 'student_id', 'students', 'Student', 'on') . "\n <input type=hidden name=\"new_referral\" value=\"New\" />\n </form></center>"; } else { $sql = "SELECT users.first_name, users.last_name, schools.school_name\n FROM users, schools\n WHERE schools.school_id=users.school_id\n AND users.user_id=" . $sid; $result = $db->query($sql); $row = $result->fetch_assoc(); $sfName = $row['first_name']; $slName = $row['last_name']; $sDistrict = $row['school_name']; include 'referral_form.php'; $b .= $form; } $main .= make_box($t, $b); } elseif (isset($_POST['incident_referral_id']) || isset($_POST['send_referral'])) { include 'referral_form.php'; $b .= $form; $main .= make_box($t, $b); } else { /** display a list of OPEN referrals for current teacher **/ $result = get_referrals('teacher_id=' . $_SESSION[$_CONF['sess_name'] . '_myUID'], 'N'); $t = "OPEN Referrals"; $b = display_referrals($result, $_SERVER['PHP_SELF'] . "?lev=" . $_GET['lev'] . "&cat=" . $_GET['cat'], 'N', 'Y'); $main .= make_box($t, $b); /** display a list of CLOSED referrals for current teacher **/ $result = get_referrals('teacher_id=' . $_SESSION[$_CONF['sess_name'] . '_myUID'], 'Y'); $t = "CLOSED Referrals"; $b = display_referrals($result, $_SERVER['PHP_SELF'] . "?lev=" . $_GET['lev'] . "&cat=" . $_GET['cat'], 'Y', 'N'); $main .= make_box($t, $b); } } else { $main .= login_error(); }
function getUCInrepayRepayBorrowMoney($id) { $id = intval($id); $root = array(); $root["status"] = 0; //0:出错;1:正确; if ($id == 0) { $root["show_err"] = "操作失败!"; return $root; } $deal = get_deal($id); if (!$deal) { $root["show_err"] = "借款不存在!"; return $root; } if ($deal['user_id'] != $GLOBALS['user_info']['id']) { $root["show_err"] = "不属于你的借款!"; return $root; } if ($deal['deal_status'] != 4) { $root["show_err"] = "借款不是还款状态!"; return $root; } $time = TIME_UTC; $impose_money = 0; //是否有部分还款的 $repay_count_ing = $GLOBALS['db']->getOne("SELECT count(*) FROM " . DB_PREFIX . "deal_repay WHERE has_repay=2 and deal_id=" . $id); if ($repay_count_ing) { $root["show_err"] = "请将部分还款的借款还完才可以进行此操作!"; return $root; } //计算罚息 $loan_list = get_deal_load_list($deal); $k_repay_key = -1; $k_repay_time = 0; foreach ($loan_list as $k => $v) { if ($v['has_repay'] == 0) { if ($k_repay_key == -1) { $k_repay_key = $v['l_key']; $k_repay_time = $v['repay_day']; } $impose_money += $v['impose_all_money']; } } if ($impose_money > 0) { $root["show_err"] = "请将逾期未还的借款还完才可以进行此操作!"; return $root; } if ($deal['ips_bill_no'] != "") { $root["status"] = 2; $root["jump"] = APP_ROOT . '/index.php?ctl=collocation&act=RepaymentNewTrade&deal_id=' . $deal['id'] . '&l_key=all&from=' . $GLOBALS['request']['from']; $root['jump'] = str_replace("/mapi", "", SITE_DOMAIN . $root['jump']); return $root; } //还了几期了 $has_repay_count = $GLOBALS['db']->getOne("SELECT count(*) FROM " . DB_PREFIX . "deal_repay WHERE has_repay=1 and deal_id=" . $id); $loaninfo['deal'] = $deal; $loaninfo['loanlist'] = $loan_list; //返佣 $rebate_rs = get_rebate_fee($GLOBALS['user_info']['id'], "borrow"); $loaninfo['deal']['rebate'] = $rebate_rs['rebate']; $inrepay_info = inrepay_repay($loaninfo, $has_repay_count); $true_repay_money = (double) $inrepay_info['true_repay_money']; $true_self_money = (double) $inrepay_info['true_self_money']; $impose_money = (double) $inrepay_info['impose_money']; $true_manage_money = (double) $inrepay_info['true_manage_money']; $true_manage_money_rebate = (double) $inrepay_info['true_manage_money_rebate']; $true_total_repay_money = $true_repay_money + $impose_money + $true_manage_money; if ($true_total_repay_money > $GLOBALS['user_info']['money']) { $root["show_err"] = "对不起,您的余额不足!"; return $root; } //录入到提前还款列表 $inrepay_data['deal_id'] = $id; $inrepay_data['user_id'] = $GLOBALS['user_info']['id']; $inrepay_data['repay_money'] = $true_repay_money; $inrepay_data['self_money'] = $true_self_money; $inrepay_data['impose_money'] = $impose_money; $inrepay_data['manage_money'] = $true_manage_money; $inrepay_data['repay_time'] = $k_repay_time; $inrepay_data['true_repay_time'] = $time; $GLOBALS['db']->autoExecute(DB_PREFIX . "deal_inrepay_repay", $inrepay_data, "INSERT"); $inrepay_id = $GLOBALS['db']->insert_id(); if ($inrepay_id == 0) { $root["show_err"] = "对不起,数据处理失败,请联系客服!"; return $root; } //录入还款列表 $wait_repay_list = $GLOBALS['db']->getAll("SELECT * FROM " . DB_PREFIX . "deal_repay WHERE deal_id=" . $id . " and has_repay=0 ORDER BY l_key ASC"); $temp_ids = array(); foreach ($wait_repay_list as $k => $v) { $repay_data = array(); $repay_data['has_repay'] = 1; $repay_data['true_repay_time'] = $time; $repay_data['true_repay_date'] = to_date($time); $repay_data['status'] = 0; if ($k_repay_key == $v['l_key']) { $repay_data['true_repay_money'] = $true_repay_money; $repay_data['impose_money'] = $impose_money; $repay_data['true_manage_money'] = $true_manage_money; $repay_data['true_self_money'] = $true_self_money; $repay_data['true_interest_money'] = $true_repay_money - $true_self_money; $repay_data['true_manage_money_rebate'] = $true_manage_money_rebate; } $GLOBALS['db']->autoExecute(DB_PREFIX . "deal_repay", $repay_data, "UPDATE", "id=" . $v['id']); //假如出错 删除掉原来的以插入的数据 if ($GLOBALS['db']->affected_rows() == 0) { if (count($temp_ids) > 0) { $GLOBALS['db']->query("UPDATE " . DB_PREFIX . "deal_repay SET has_repay=0 WHERE id in " . implode(",", $temp_ids) . ""); make_repay_plan($deal); } $root["show_err"] = "对不起,处理数据失败请联系客服!"; return $root; } else { $temp_ids[] = $v['id']; } } if (count($temp_ids) == 0) { $root["show_err"] = "对不起,处理数据失败请联系客服!"; return $root; } //更新用户账户资金记录 require APP_ROOT_PATH . 'system/libs/user.php'; modify_account(array("money" => -round($impose_money, 2)), $GLOBALS['user_info']['id'], "[<a href='" . $deal['url'] . "' target='_blank'>" . $deal['name'] . "</a>],提前还款违约金", 6); modify_account(array("money" => -round($true_manage_money, 2)), $GLOBALS['user_info']['id'], "[<a href='" . $deal['url'] . "' target='_blank'>" . $deal['name'] . "</a>],提前还款管理费", 10); modify_account(array("money" => -round($true_repay_money, 2)), $GLOBALS['user_info']['id'], "[<a href='" . $deal['url'] . "' target='_blank'>" . $deal['name'] . "</a>],提前还款本息", 6); //用户获得额度 modify_account(array("quota" => trim(app_conf('USER_REPAY_QUOTA'))), $GLOBALS['user_info']['id'], "[<a href='" . $deal['url'] . "' target='_blank'>" . $deal['name'] . "</a>],还清借款获得额度", 6); //借款者返佣金 if ($true_manage_money_rebate != 0) { /*ok*/ $reback_memo = '借款“<a href="' . $deal["url"] . '">' . $deal["name"] . '</a>”,借款者' . $deal["user"]["user_name"]; reback_rebate_money($GLOBALS['user_info']['id'], $true_manage_money_rebate, "borrow", $reback_memo); } //判断获取的信用是否超过限制 if ($GLOBALS['db']->getOne("SELECT sum(point) FROM " . DB_PREFIX . "user_point_log WHERE `type`=6 AND user_id=" . $GLOBALS['user_info']['id']) < (int) trim(app_conf('REPAY_SUCCESS_LIMIT'))) { //获取上一次还款时间 $befor_repay_time = $GLOBALS['db']->getOne("SELECT MAX(create_time) FROM " . DB_PREFIX . "user_point_log WHERE `type`=6 AND user_id=" . $GLOBALS['user_info']['id']); $day = ceil(($time - $befor_repay_time) / 24 / 3600); //当天数大于等于间隔时间 获得信用 if ($day >= (int) trim(app_conf('REPAY_SUCCESS_DAY'))) { modify_account(array("point" => trim(app_conf('REPAY_SUCCESS_POINT'))), $GLOBALS['user_info']['id'], "[<a href='" . $deal['url'] . "' target='_blank'>" . $deal['name'] . "</a>],还清借款", 6); } } //用户回款 /** * 获取某一期的用户还款列表 * array $deal_info 借款信息 * int $user_id 用户ID 为0代表全部 * int $lkey 第几期 -1 全部 * int $ukey 第几个投标人 -1 全部 * int $true_time 真实还款时间 * int $get_type 0 全部 1代表未还的 2 代表已还的 * int $r_type = 0; 返回类型; 1:只返回一个数组; $result['item'] * string $limit; 查询限制数量; 0,20 $result['count'] */ $user_loan_list = get_deal_user_load_list($deal, 0, -1, -1, $time, 1, 0, ''); foreach ($user_loan_list as $lllk => $lllv) { //循环用户 //本金 $user_self_money = 0; //本息 $user_repay_money = 0; //违约金 $user_impose_money = 0; //管理费 $user_manage_money = 0; //利息管理费 $user_manage_interest_money = 0; //返佣金 $manage_interest_money_rebate = 0; //奖励 $user_reward_money = 0; foreach ($lllv as $kk => $vv) { //循环期数 $in_user_id = $vv['user_id']; //判断是否转让了债权 if ((int) $vv['t_user_id'] == 0) { $loan_user_info['user_name'] = $vv['user_name']; $loan_user_info['email'] = $vv['email']; $loan_user_info['mobile'] = $vv['mobile']; } else { $in_user_id = $vv['t_user_id']; $loan_user_info['user_name'] = $vv['t_user_name']; $loan_user_info['email'] = $vv['t_email']; $loan_user_info['mobile'] = $vv['t_mobile']; } $user_load_data = array(); $user_load_data['true_repay_time'] = $time; $user_load_data['true_repay_date'] = to_date($time); $user_load_data['is_site_repay'] = 0; $user_load_data['status'] = 0; if ($k_repay_key == $vv['l_key']) { $loadinfo['deal']['rate'] = $deal['rate']; $loadinfo['deal']['loantype'] = $deal['loantype']; $loadinfo['deal']['repay_time'] = $deal['repay_time']; $loadinfo['deal']['borrow_amount'] = $vv['money']; $loadinfo['deal']['repay_start_time'] = $deal['repay_start_time']; $loadinfo['deal']['month_manage_money'] = $vv['manage_money']; $loadinfo['deal']['manage_interest_money'] = $vv['manage_interest_money']; $deal = get_user_load_fee($in_user_id, 0, $deal); $loadinfo['deal']['user_loan_interest_manage_fee'] = $deal['user_loan_interest_manage_fee']; $rebate_rs = get_rebate_fee($in_user_id, "invest"); $loadinfo['deal']['rebate'] = $rebate_rs['rebate']; $loadinfo['deal']['manage_interest_money_rebate'] = $vv['manage_interest_money_rebate']; $loadinfo['deal']['month_repay_money'] = $vv['month_repay_money']; $loadinfo['deal']['compensate_fee'] = $deal['compensate_fee']; if ($deal['repay_time_type'] == 1) { $loadinfo['deal']['all_manage_money'] = $vv['manage_money']; } else { $loadinfo['deal']['all_manage_money'] = $vv['manage_money'] * $deal['repay_time']; } $loadinfo['deal']['repay_time_type'] = $deal['repay_time_type']; $user_load_rs = inrepay_repay($loadinfo, $has_repay_count); $user_load_data['true_repay_money'] = $user_load_rs['true_repay_money']; $user_load_data['true_self_money'] = $user_load_rs['true_self_money']; $user_load_data['impose_money'] = $user_load_rs['impose_money']; $user_load_data['true_interest_money'] = $user_load_rs['true_repay_money'] - $user_load_rs['true_self_money']; $user_load_data['true_manage_money'] = $user_load_rs['true_manage_money']; $user_load_data['true_manage_interest_money'] = $user_load_rs['true_manage_interest_money']; $user_load_data['true_manage_interest_money_rebate'] = $user_load_rs['true_manage_interest_money_rebate']; $user_load_data['true_repay_manage_money'] = $true_manage_money / count($user_loan_list); $user_load_data['true_reward_money'] = 0; if ((int) $vv['is_winning'] == 1 && (int) $vv['income_type'] == 2 && (double) $vv['income_value'] != 0) { $user_load_data['true_reward_money'] = $user_load_data['true_interest_money'] * (double) $vv['income_value'] * 0.01; } $user_self_money = $user_load_data['true_self_money']; $user_repay_money = $user_load_data['true_repay_money']; $user_impose_money = $user_load_data['impose_money']; $user_manage_money = $user_load_data['true_manage_money']; $user_manage_interest_money = $user_load_data['true_manage_interest_money']; $manage_interest_money_rebate = $user_load_data['true_manage_interest_money_rebate']; $user_reward_money = $user_load_data['true_reward_money']; } $user_load_data['has_repay'] = 1; $GLOBALS['db']->autoExecute(DB_PREFIX . "deal_load_repay", $user_load_data, "UPDATE", "id=" . $vv['id']); //普通会员邀请返利 get_referrals($vv['id']); } if ($user_repay_money > 0 || $user_impose_money > 0 || $user_manage_money > 0 || $user_manage_interest_money > 0 || $user_reward_money > 0) { $all_repay_money = number_format($GLOBALS['db']->getOne("SELECT (sum(repay_money)-sum(self_money) + sum(impose_money)) as shouyi FROM " . DB_PREFIX . "deal_load_repay WHERE has_repay = 1 and deal_id=" . $v['deal_id'] . " AND user_id=" . $v['user_id']), 2); $all_impose_money = number_format($GLOBALS['db']->getOne("SELECT sum(impose_money) FROM " . DB_PREFIX . "deal_load_repay WHERE has_repay = 1 and deal_id=" . $v['deal_id'] . " AND user_id=" . $v['user_id']), 2); //$content = "您好,您在".app_conf("SHOP_TITLE")."的投标 “<a href=\"".$deal['url']."\">".$deal['name']."</a>”提前还款,"; //$content .= "本次投标共获得收益:".$all_repay_money."元,其中违约金为:".$all_impose_money."元,本次投标已回款完毕!"; //更新用户账户资金记录 modify_account(array("money" => $user_repay_money), $in_user_id, "[<a href='" . $deal['url'] . "' target='_blank'>" . $deal['name'] . "</a>],回报本息", 5); modify_account(array("money" => $user_impose_money), $in_user_id, "[<a href='" . $deal['url'] . "' target='_blank'>" . $deal['name'] . "</a>],提前回收违约金", 7); if ($user_manage_money > 0) { modify_account(array("money" => -$user_manage_money), $in_user_id, "[<a href='" . $deal['url'] . "' target='_blank'>" . $deal['name'] . "</a>],投标管理费", 20); } if ($user_reward_money > 0) { modify_account(array("money" => -$user_reward_money), $in_user_id, "[<a href='" . $deal['url'] . "' target='_blank'>" . $deal['name'] . "</a>],投标奖励", 28); } modify_account(array("money" => -$user_manage_interest_money), $in_user_id, "[<a href='" . $deal['url'] . "' target='_blank'>" . $deal['name'] . "</a>],投标利息管理费", 20); //投资者返佣金 if ($manage_interest_money_rebate) { /*ok*/ $reback_memo = "借款“<a href'" . $deal['url'] . "'>" . $deal["name"] . "</a>”,投资者" . $loan_user_info["user_name"] . ",第" . (intval($k_repay_key) + 1) . "期,提前还款"; reback_rebate_money($in_user_id, $manage_interest_money_rebate, "invest", $reback_memo); } $msg_conf = get_user_msg_conf($in_user_id); //短信通知 if (app_conf("SMS_ON") == 1 && app_conf('SMS_REPAY_TOUSER_ON') == 1) { $tmpl = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "msg_template where name = 'TPL_DEAL_LOAD_REPAY_SMS'", false); $tmpl_content = $tmpl['content']; $notice['user_name'] = $loan_user_info['user_name']; $notice['deal_name'] = $deal['sub_name']; $notice['deal_url'] = $deal['url']; $notice['site_name'] = app_conf("SHOP_TITLE"); $notice['repay_money'] = $vv['month_repay_money'] + $vv['impose_money']; $notice['all_repay_money'] = $all_repay_money; $notice['impose_money'] = $all_impose_money; $GLOBALS['tmpl']->assign("notice", $notice); $sms_content = $GLOBALS['tmpl']->fetch("str:" . $tmpl_content); $msg_data['dest'] = $loan_user_info['mobile']; $msg_data['send_type'] = 0; $msg_data['title'] = $msg_data['content'] = addslashes($sms_content); $msg_data['send_time'] = 0; $msg_data['is_send'] = 0; $msg_data['create_time'] = $time; $msg_data['user_id'] = $in_user_id; $msg_data['is_html'] = 0; $GLOBALS['db']->autoExecute(DB_PREFIX . "deal_msg_list", $msg_data); //插入 } //站内信 $notices['shop_title'] = app_conf("SHOP_TITLE"); $notices['url'] = "“<a href=\"" . $deal['url'] . "\">" . $deal['name'] . "</a>”"; $notices['repay_money'] = $all_repay_money; $notices['impose_money'] = $all_impose_money; $tmpl_contents = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "msg_template where name = 'TPL_REPAY_MONEY_TQTB'", false); $GLOBALS['tmpl']->assign("notice", $notices); $content = $GLOBALS['tmpl']->fetch("str:" . $tmpl_contents['content']); if ($msg_conf['sms_bidrepaid'] == 1) { send_user_msg("", $content, 0, $in_user_id, $time, 0, true, 9); } //邮件 if ($msg_conf['mail_bidrepaid'] == 1 && app_conf('MAIL_ON') == 1) { $tmpl = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "msg_template where name = 'TPL_DEAL_LOAD_REPAY_EMAIL'", false); $tmpl_content = $tmpl['content']; $notice['user_name'] = $loan_user_info['user_name']; $notice['deal_name'] = $deal['sub_name']; $notice['deal_url'] = $deal['url']; $notice['site_name'] = app_conf("SHOP_TITLE"); $notice['site_url'] = SITE_DOMAIN . APP_ROOT; $notice['help_url'] = SITE_DOMAIN . url("index", "helpcenter"); $notice['msg_cof_setting_url'] = SITE_DOMAIN . url("index", "uc_msg#setting"); $notice['repay_money'] = $vv['month_repay_money'] + $vv['impose_money']; $notice['all_repay_money'] = $all_repay_money; $notice['impose_money'] = $all_impose_money; $GLOBALS['tmpl']->assign("notice", $notice); $msg = $GLOBALS['tmpl']->fetch("str:" . $tmpl_content); $msg_data['dest'] = $loan_user_info['email']; $msg_data['send_type'] = 1; $msg_data['title'] = "“" . $deal['name'] . "”回款通知"; $msg_data['content'] = addslashes($msg); $msg_data['send_time'] = 0; $msg_data['is_send'] = 0; $msg_data['create_time'] = $time; $msg_data['user_id'] = $in_user_id; $msg_data['is_html'] = $tmpl['is_html']; $GLOBALS['db']->autoExecute(DB_PREFIX . "deal_msg_list", $msg_data); //插入 } } } /* $content = "您好,您在".app_conf("SHOP_TITLE")."的借款 “<a href=\"".$deal['url']."\">".$deal['name']."</a>”成功提前还款".number_format($true_total_repay_money,2)."元,"; $content .= "其中违约金为:".number_format($impose_money,2)."元,本笔借款已还款完毕!"; */ $notices['shop_title'] = app_conf("SHOP_TITLE"); $notices['url'] = "“<a href=\"" . $deal['url'] . "\">" . $deal['name'] . "</a>”"; $notices['repay_money'] = number_format($true_total_repay_money, 2); $notices['impose_money'] = number_format($impose_money, 2); $tmpl_contents = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "msg_template where name = 'TPL_REPAY_MONEY_TQJK'", false); $GLOBALS['tmpl']->assign("notice", $notices); $content = $GLOBALS['tmpl']->fetch("str:" . $tmpl_contents['content']); //站内信 send_user_msg("", $content, 0, $GLOBALS['user_info']['id'], $time, 0, true, 8); //短信通知 if (app_conf("SMS_ON") == 1 && app_conf('SMS_SEND_REPAY') == 1) { //$sms_content = "尊敬的".app_conf("SHOP_TITLE")."用户".$GLOBALS['user_info']['user_name'].",您成功提前还款".number_format($true_total_repay_money,2)."元,其中违约金为:".number_format($impose_money,2)."元,感谢您的关注和支持。【".app_conf("SHOP_TITLE")."】"; $tmpl = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "msg_template where name = 'TPL_SMS_REPAY_SUCCESS_MSG'", false); $tmpl_content = $tmpl['content']; $notice['user_name'] = $GLOBALS['user_info']['user_name']; $notice['deal_name'] = $deal['sub_name']; $notice['site_name'] = app_conf("SHOP_TITLE"); $notice['index'] = $has_repay_count + 1; $notice['status'] = "成功提前"; $notice['all_money'] = number_format($true_total_repay_money, 2); $notice['repay_money'] = number_format($true_repay_money, 2); $notice['impose_money'] = number_format($impose_money, 2); $notice['manage_money'] = number_format($true_manage_money, 2); $notice['manage_impose_money'] = 0; $GLOBALS['tmpl']->assign("notice", $notice); $msg = $GLOBALS['tmpl']->fetch("str:" . $tmpl_content); $msg_data['dest'] = $GLOBALS['user_info']['mobile']; $msg_data['send_type'] = 0; $msg_data['title'] = "提前还款短信通知"; $msg_data['content'] = $msg; $msg_data['send_time'] = 0; $msg_data['is_send'] = 0; $msg_data['create_time'] = $time; $msg_data['user_id'] = $GLOBALS['user_info']['id']; $msg_data['is_html'] = 0; $GLOBALS['db']->autoExecute(DB_PREFIX . "deal_msg_list", $msg_data); //插入 } $GLOBALS['db']->query("UPDATE " . DB_PREFIX . "generation_repay_submit SET `memo`='因还款失效',`status`=2 WHERE deal_id=" . $deal['id']); //VIP升级 -提前还款 $type = 1; $type_info = 4; $resultdate = syn_user_vip($GLOBALS['user_info']['id'], $type, $type_info); syn_deal_status($id); sys_user_status($GLOBALS['user_info']['id'], false, true); syn_transfer_status(0, $id); $root["status"] = 1; //0:出错;1:正确; $root["show_err"] = "操作成功!"; return $root; }
$b .= "\n <th>\n <form action=index.php?lev=" . $_SESSION[$_CONF['sess_name'] . '_lev'] . "&cat=" . $_SESSION[$_CONF['sess_name'] . '_cat'] . " method=POST name=searchByTeacher>"; $b .= make_selection_list($lot, $tid, "teacher_id", "searchByTeacher", "Teacher", "on"); $b .= " \n <input type=hidden name=searchByTeacher />\n </form>\n </th>\n </tr>"; $b .= "\n </table></center>"; $main .= make_box($t, $b . $teacherReferrals); /** Search by Student **/ $t = "Search By Student"; $b = ""; $sid = -1; if (isset($_POST['student_id'])) { $sid = $_POST['student_id']; } $b .= "\n <center><table border=0 cellspacing=0 cellpadding=3>"; $b .= "\n <th>\n <form action=index.php?lev=" . $_SESSION[$_CONF['sess_name'] . '_lev'] . "&cat=" . $_SESSION[$_CONF['sess_name'] . '_cat'] . " method=POST name=searchByStudent>"; $b .= make_selection_list($los, $sid, "student_id", "searchByStudent", "Student", "on"); $b .= " \n <input type=hidden name=searchByStudent />\n </form>\n </th>\n </tr>"; $b .= "\n </table></center>"; $main .= make_box($t, $b . $studentReferrals); /** display a list of OPEN referrals **/ $result = get_referrals('', 'N'); $t = "OPEN Referrals"; $b = display_referrals($result, $_SERVER['PHP_SELF'] . "?lev=" . $_SESSION[$_CONF['sess_name'] . '_lev'] . "&cat=" . $_SESSION[$_CONF['sess_name'] . '_cat'], 'N', 'N'); $main .= make_box($t, $b); /** display a list of CLOSED referrals **/ $result = get_referrals('', 'Y'); $t = "CLOSED Referrals"; $b = display_referrals($result, $_SERVER['PHP_SELF'] . "?lev=" . $_SESSION[$_CONF['sess_name'] . '_lev'] . "&cat=" . $_SESSION[$_CONF['sess_name'] . '_cat'], 'Y', 'N'); $main .= make_box($t, $b); } else { $main .= login_error(); }