public function tool3() { if ($_POST) { $money = floatval($_POST['money']); $rate = floatval($_POST['interest_rate']); $month = $_POST['selDays'] == -1 ? intval($_POST['month']) : intval($_POST['selDays']); $fee = getFloatValue($rate / 12 * $month * $money / 100 + $money, 4); $this->assign('mmoney', $money); $this->assign('m', $month); $this->assign('fee', $fee); $parm['month_times'] = $month; $parm['account'] = $money; $parm['year_apr'] = $rate; $repay_detail = EqualSeason($parm); $parm['type'] = "all"; $repay_summary = EqualSeason($parm); $this->assign('repay_detail', $repay_detail); $this->assign('repay_summary', $repay_summary); $data['html_1'] = $this->fetch('tool3_res_1'); $data['html_2'] = $this->fetch('tool3_res_2'); exit(json_encode($data)); } $this->display(); }
function getBorrowInterest($type, $money, $duration, $rate) { //if(!in_array($type,C('REPAYMENT_TYPE'))) return $money; //echo $month_rate."|".$rate."|".$duration."|".$type; switch ($type) { case 1: //按天到期还款 $month_rate = $rate / 100; $interest = getFloatValue($money * $month_rate * $duration, 4); break; case 2: //按月分期还款 $parm['duration'] = $duration; $parm['money'] = $money; $parm['year_apr'] = $rate; $parm['type'] = "all"; $intre = EqualMonth($parm); $interest = $intre['repayment_money'] - $money; break; case 3: //按季分期还款 $parm['month_times'] = $duration; $parm['account'] = $money; $parm['year_apr'] = $rate; $parm['type'] = "all"; $intre = EqualSeason($parm); $interest = $intre['interest']; break; case 4: //每月还息到期还本 $parm['month_times'] = $duration; $parm['account'] = $money; $parm['year_apr'] = $rate; $parm['type'] = "all"; $intre = EqualEndMonth($parm); $interest = $intre['interest']; break; } return $interest; }
function getRepayDetail($repayment_type, $borrow_interest_rate, $borrow_duration) { $repay_detail = array(); if ($repayment_type == 2) { $money = 100; $rate = $borrow_interest_rate; $month = $borrow_duration; $monthData['money'] = $money; $monthData['year_apr'] = $rate; $monthData['duration'] = $month; $monthData['type'] = "all"; $repay_detail = EqualMonth($monthData); } elseif ($repayment_type == 3) { $money = 100; $rate = $borrow_interest_rate; $month = $borrow_duration; $monthData['account'] = $money; $monthData['year_apr'] = $rate; $monthData['month_times'] = $month; $monthData['type'] = "all"; $repay_detail = EqualSeason($monthData); } elseif ($repayment_type == 4) { $money = 100; $rate = $borrow_interest_rate; $month = $borrow_duration; $parm['month_times'] = $month; $parm['account'] = $money; $parm['year_apr'] = $rate; $parm['type'] = "all"; $repay_detail = EqualEndMonth($parm); } return $repay_detail; }
function investMoney($uid, $borrow_id, $money, $_is_auto = 0, $invest_info_id, $reqext = 0) { //2015-09-30 lj 红包最后一笔扣不了钱 // require_once('config/config.db.php'); $pre = DB_PREFIX; $done = false; $datag = get_global_setting(); //$fee_invest_manage = explode("|",$datag['fee_invest_manage']); /////////////////////////////锁表 zhang 2015-5-5//////////////////////////////////////////////// $bdb = new PDO('mysql:host=' . DB_HOST . ';dbname=' . DB_NAME, DB_USER, DB_PWD); $bdb->beginTransaction(); $bId = $borrow_id; $sql = "SELECT suo FROM lzh_borrow_info_lock WHERE id = ? FOR UPDATE"; $stmt1 = $bdb->prepare($sql); $stmt1->bindParam(1, $bId); //绑定第一个参数值 $stmt1->execute(); /////////////////////////////锁表 zhang 2015-5-5//////////////////////////////////////////////// $sqlbi = 'SELECT borrow_uid,borrow_money,borrow_interest_rate,borrow_type,borrow_duration,repayment_type,has_borrow,reward_money,money_collect,manage_rate,danbao FROM lzh_borrow_info WHERE id = ? limit 1'; $stmt2 = $bdb->prepare($sqlbi); $stmt2->bindParam(1, $borrow_id); $stmt2->execute(); while ($rowbi = $stmt2->fetch(PDO::FETCH_ASSOC)) { $binfo = $rowbi; } //新加入了奖金reward_money到资金总额里 $sql = "SELECT m.user_leve,m.time_limit,mm.account_money,mm.back_money,mm.money_collect FROM {$pre}members AS m LEFT JOIN {$pre}member_money mm ON mm.uid=m.id WHERE m.id= ? limit 1"; $stmt = $bdb->prepare($sql); $stmt->bindParam(1, $uid); //绑定第一个参数值 $stmt->execute(); // var_dump($stmt2->queryString); while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) { $vminfo = $row; } // $vminfo = getMinfo($uid,'m.user_leve,m.time_limit,mm.account_money,mm.back_money,mm.money_collect'); // if(($vminfo['account_money']+$vminfo['back_money']+$binfo['reward_money'])<$money) { // return "您当前的可用金额为:".($vminfo['account_money']+$vminfo['back_money']+$binfo['reward_money'])." 对不起,可用余额不足,不能投标"; // } // // ////////////新增投标时检测会员的待收金额是否大于标的设置的代收金额限制,大于就可投标,小于就不让投标 2013-08-26 fan////////////// // // if($binfo['money_collect']>0){//判断是否设置了投标待收金额限制 // if($vminfo['money_collect']<$binfo['money_collect']){ // return "对不起,此标设置有投标待收金额限制,您当前的待收金额为".$vminfo['money_collect']."元,小于该标设置的待收金额限制".$binfo['money_collect']."元。"; // } // } ////////////新增投标时检测会员的待收金额是否大于标的设置的代收金额限制,大于就可投标,小于就不让投标 2013-08-26 fan////////////// //不同会员级别的费率 //($vminfo['user_leve']==1 && $vminfo['time_limit']>time())?$fee_rate=($fee_invest_manage[1]/100):$fee_rate=($fee_invest_manage[0]/100); $fee_rate = $datag['fee_invest_manage'] / 100; //投入的钱 $havemoney = $binfo['has_borrow']; // if(($binfo['borrow_money'] - $havemoney -$money)<0) // { // return "对不起,此标还差".($binfo['borrow_money'] - $havemoney)."元满标,您最多投标".($binfo['borrow_money'] - $havemoney)."元"; // } $sql = "SELECT SUM(investor_capital) AS investor_capital FROM {$pre}borrow_investor WHERE borrow_id = ? LIMIT 1"; $stmt = $bdb->prepare($sql); $stmt->bindParam(1, $borrow_id); $stmt->execute(); while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) { $borrow_invest = $row; } // $borrow_invest = M("borrow_investor")->where('borrow_id = {$borrow_id}')->sum('investor_capital');//新加投资金额检测 /***获取积分比率****/ // $fee = M('members')->where("id=".$uid)->getField('integral'); $sql = "SELECT integral FROM {$pre}members WHERE id=? limit 1"; $stmt = $bdb->prepare($sql); $stmt->bindParam(1, $uid); $stmt->execute(); // // file_put_contents('/tmp/444',date('m-d H:i:s')."monthDataDetail".print_r($sql,true)."\n",FILE_APPEND); // while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) { $fee = $row; } $fs = $fs = (require_once 'config/config.leveinvestconfig.php'); foreach ($fs as $val) { if ($fee > $val['start'] && $fee < $val['end']) { $rate = floatval($val['rate']) / 100; break; } } /***获取积分比率结束****/ $investinfo['status'] = 1; //等待复审 $investinfo['borrow_id'] = $borrow_id; $investinfo['investor_uid'] = $uid; //投资者 $investinfo['borrow_uid'] = $binfo['borrow_uid']; //借款者 $investinfo['investor_fee'] = $binfo['manage_rate'] * $money; //管理费 if ($binfo['danbao'] != 0) { // $guarrate=M("member_guarrate")->field("guarrate")->where("uid={$binfo['danbao']}")->find();//担保费率 $sql = "SELECT guarrate FROM {$pre}member_guarrate WHERE uid=? limit 1"; $stmt = $bdb->prepare($sql); $stmt->bindParam(1, $binfo['danbao']); $stmt->execute(); while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) { $fee = $row; } $investinfo['guar_fee'] = $guarrate['guarrate'] * $money / 100; } /////////////////////////////////////新加投资金额检测///////////////////////////////////////////// if ($borrow_invest['investor_capital'] > $binfo['borrow_money']) { $investinfo['investor_capital'] = $binfo['borrow_money'] - $binfo['has_borrow']; } else { $investinfo['investor_capital'] = $money; } /////////////////////////////////////新加投资金额检测///////////////////////////////////////////// $investinfo['is_auto'] = $_is_auto; $investinfo['add_time'] = time(); //还款详细公共信息START $handler = mysql_connect(DB_HOST, DB_USER, DB_PWD); mysql_select_db(DB_NAME); mysql_query("SET AUTOCOMMIT=0"); //设置为不自动提交,因为MYSQL默认立即执行 mysql_query("START TRANSACTION"); //开始事务定义 //还款概要公共信息START $savedetail = array(); switch ($binfo['repayment_type']) { case 1: //按天到期还款 //还款概要START $investinfo['investor_interest'] = getFloatValue($binfo['borrow_interest_rate'] / 360 * $investinfo['investor_capital'] * $binfo['borrow_duration'] / 100, 4); $investinfo['invest_fee'] = getFloatValue($fee_rate * $investinfo['investor_interest'] * (1 - $rate), 4); //修改投资人的天标利息管理费2013-03-19 fan $investinfo['invest_fee_yh'] = getFloatValue($fee_rate * $investinfo['investor_interest'], 4); //修改投资人的天标利息管理费2013-03-19 fan //$invest_info_id = M('borrow_investor')->add($investinfo); // M('borrow_investor')->where("id=".$invest_info_id)->save($investinfo); foreach ($investinfo as $key => $val) { $upSql .= "{$key}={$val},"; } $upSql = rtrim($upSql, ","); $sql = sprintf("UPDATE %s SET {$upSql} where id=%s", "{$pre}borrow_investor", $invest_info_id); $rtype = mysql_query($sql); //还款概要END $investdetail['borrow_id'] = $borrow_id; $investdetail['invest_id'] = $invest_info_id; $investdetail['investor_uid'] = $uid; $investdetail['borrow_uid'] = $binfo['borrow_uid']; $investdetail['capital'] = $investinfo['investor_capital']; $investdetail['interest'] = $investinfo['investor_interest']; $investdetail['interest_fee'] = $fee_rate * $investinfo['invest_fee'] * (1 - $rate); $investdetail['interest_fee_yh'] = $fee_rate * $investinfo['invest_fee']; $investdetail['status'] = 0; $investdetail['sort_order'] = 1; $investdetail['total'] = 1; $savedetail[] = $investdetail; break; case 2: //每月还款 //还款概要START $monthData['type'] = "all"; $monthData['money'] = $investinfo['investor_capital']; $monthData['year_apr'] = $binfo['borrow_interest_rate']; $monthData['duration'] = $binfo['borrow_duration']; $repay_detail = EqualMonth($monthData); $investinfo['investor_interest'] = $repay_detail['repayment_money'] - $investinfo['investor_capital']; $investinfo['invest_fee'] = getFloatValue($fee_rate * $investinfo['investor_interest'] * (1 - $rate), 4); $investinfo['invest_fee_yh'] = getFloatValue($fee_rate * $investinfo['investor_interest'], 4); //$invest_info_id = M('borrow_investor')->add($investinfo); // M('borrow_investor')->where("id=".$invest_info_id)->save($investinfo); foreach ($investinfo as $key => $val) { $upSql .= "{$key}={$val},"; } $upSql = rtrim($upSql, ","); $sql = sprintf("UPDATE %s SET {$upSql} where id=%s", "{$pre}borrow_investor", $invest_info_id); $rtype = mysql_query($sql); //还款概要END $monthDataDetail['money'] = $investinfo['investor_capital']; $monthDataDetail['year_apr'] = $binfo['borrow_interest_rate']; $monthDataDetail['duration'] = $binfo['borrow_duration']; $repay_list = EqualMonth($monthDataDetail); $i = 1; //file_put_contents(C('WEB_ROOT').'a.txt', json_encode($repay_list));exit; foreach ($repay_list as $key => $v) { $investdetail['borrow_id'] = $borrow_id; $investdetail['invest_id'] = $invest_info_id; $investdetail['investor_uid'] = $uid; $investdetail['borrow_uid'] = $binfo['borrow_uid']; $investdetail['capital'] = $v['capital']; $investdetail['interest'] = $v['interest']; $investdetail['interest_fee'] = getFloatValue($fee_rate * $v['interest'] * (1 - $rate), 4); $investdetail['interest_fee_yh'] = getFloatValue($fee_rate * $v['interest'], 4); $investdetail['status'] = 0; $investdetail['sort_order'] = $i; $investdetail['total'] = $binfo['borrow_duration']; $i++; $savedetail[] = $investdetail; } break; case 3: //按季分期还款 //还款概要START $monthData['month_times'] = $binfo['borrow_duration']; $monthData['account'] = $investinfo['investor_capital']; $monthData['year_apr'] = $binfo['borrow_interest_rate']; $monthData['type'] = "all"; $repay_detail = EqualSeason($monthData); $investinfo['investor_interest'] = $repay_detail['repayment_money'] - $investinfo['investor_capital']; $investinfo['invest_fee'] = getFloatValue($fee_rate * $investinfo['investor_interest'] * (1 - $rate), 4); $investinfo['invest_fee_yh'] = getFloatValue($fee_rate * $investinfo['investor_interest'], 4); //$invest_info_id = M('borrow_investor')->add($investinfo); // M('borrow_investor')->where("id=".$invest_info_id)->save($investinfo); foreach ($investinfo as $key => $val) { $upSql .= "{$key}={$val},"; } $upSql = rtrim($upSql, ","); $sql = sprintf("UPDATE %s SET {$upSql} where id=%s", "{$pre}borrow_investor", $invest_info_id); $rtype = mysql_query($sql); //还款概要END $monthDataDetail['month_times'] = $binfo['borrow_duration']; $monthDataDetail['account'] = $investinfo['investor_capital']; $monthDataDetail['year_apr'] = $binfo['borrow_interest_rate']; $repay_list = EqualSeason($monthDataDetail); $i = 1; foreach ($repay_list as $key => $v) { $investdetail['borrow_id'] = $borrow_id; $investdetail['invest_id'] = $invest_info_id; $investdetail['investor_uid'] = $uid; $investdetail['borrow_uid'] = $binfo['borrow_uid']; $investdetail['capital'] = $v['capital']; $investdetail['interest'] = $v['interest']; $investdetail['interest_fee'] = getFloatValue($fee_rate * $v['interest'] * (1 - $rate), 4); $investdetail['interest_fee_yh'] = getFloatValue($fee_rate * $v['interest'], 4); $investdetail['status'] = 0; $investdetail['sort_order'] = $i; $investdetail['total'] = $binfo['borrow_duration']; $i++; $savedetail[] = $investdetail; } break; case 4: //每月还息到期还本 $monthData['month_times'] = $binfo['borrow_duration']; $monthData['account'] = $investinfo['investor_capital']; $monthData['year_apr'] = $binfo['borrow_interest_rate']; $monthData['type'] = "all"; $repay_detail = EqualEndMonth($monthData); $investinfo['investor_interest'] = $repay_detail['repayment_account'] - $investinfo['investor_capital']; $investinfo['invest_fee'] = getFloatValue($fee_rate * $investinfo['investor_interest'] * (1 - $rate), 4); $investinfo['invest_fee_yh'] = getFloatValue($fee_rate * $investinfo['investor_interest'], 4); //$invest_info_id = M('borrow_investor')->add($investinfo); foreach ($investinfo as $key => $val) { $upSql .= "{$key}={$val},"; } $upSql = rtrim($upSql, ","); $sql = sprintf("UPDATE %s SET {$upSql} where id=%s", "{$pre}borrow_investor", $invest_info_id); $rtype = mysql_query($sql); // M('borrow_investor')->where("id=".$invest_info_id)->save($investinfo); //还款概要END $monthDataDetail['month_times'] = $binfo['borrow_duration']; $monthDataDetail['account'] = $investinfo['investor_capital']; $monthDataDetail['year_apr'] = $binfo['borrow_interest_rate']; //file_put_contents('/tmp/abc',date('m-d H:i:s')."monthDataDetail".print_r($monthDataDetail,true)."\n",FILE_APPEND); $repay_list = EqualEndMonthBYWHH($monthDataDetail); //file_put_contents('/tmp/abc',date('m-d H:i:s')."repay_list".print_r($repay_list,true)."\n",FILE_APPEND); $i = 1; foreach ($repay_list as $key => $v) { $investdetail['borrow_id'] = $borrow_id; $investdetail['invest_id'] = $invest_info_id; $investdetail['investor_uid'] = $uid; $investdetail['borrow_uid'] = $binfo['borrow_uid']; $investdetail['capital'] = $v['capital']; $investdetail['interest'] = $v['interest']; $investdetail['interest_fee'] = getFloatValue($fee_rate * $v['interest'] * (1 - $rate), 4); $investdetail['interest_fee_yh'] = getFloatValue($fee_rate * $v['interest'], 4); $investdetail['status'] = 0; $investdetail['sort_order'] = $i; $investdetail['total'] = $binfo['borrow_duration']; $i++; $savedetail[] = $investdetail; } // file_put_contents('/tmp/abc',date('m-d H:i:s')."savedetail".print_r($savedetail,true)."\n",FILE_APPEND); break; case 5: //一次性还款 $monthData['month_times'] = $binfo['borrow_duration']; $monthData['account'] = $investinfo['investor_capital']; $monthData['year_apr'] = $binfo['borrow_interest_rate']; $monthData['type'] = "all"; $repay_detail = EqualEndMonthOnly($monthData); $investinfo['investor_interest'] = $repay_detail['repayment_account'] - $investinfo['investor_capital']; $investinfo['invest_fee'] = getFloatValue($fee_rate * $investinfo['investor_interest'] * (1 - $rate), 4); $investinfo['invest_fee_yh'] = getFloatValue($fee_rate * $investinfo['investor_interest'], 4); //$invest_info_id = M('borrow_investor')->add($investinfo); $sql = sprintf("UPDATE %s SET investor_interest =%s,invest_fee =%s,invest_fee_yh=%s where id=%s", "{$pre}borrow_investor", $investinfo['investor_interest'], $investinfo['invest_fee'], $investinfo['invest_fee_yh'], $invest_info_id); $rtype = mysql_query($sql); // M('borrow_investor')->where("id=".$invest_info_id)->save($investinfo); //还款概要END $monthDataDetail['month_times'] = $binfo['borrow_duration']; $monthDataDetail['account'] = $investinfo['investor_capital']; $monthDataDetail['year_apr'] = $binfo['borrow_interest_rate']; $monthDataDetail['type'] = "all"; $repay_list = EqualEndMonthOnly($monthDataDetail); $investdetail['borrow_id'] = $borrow_id; $investdetail['invest_id'] = $invest_info_id; $investdetail['investor_uid'] = $uid; $investdetail['borrow_uid'] = $binfo['borrow_uid']; $investdetail['capital'] = $repay_list['capital']; $investdetail['interest'] = $repay_list['interest']; $investdetail['interest_fee'] = getFloatValue($fee_rate * $repay_list['interest'] * (1 - $rate), 4); $investdetail['interest_fee_yh'] = getFloatValue($fee_rate * $repay_list['interest'], 4); $investdetail['status'] = 0; $investdetail['sort_order'] = 1; $investdetail['total'] = 1; $savedetail[] = $investdetail; break; } foreach ($savedetail as $key => $val) { // $invest_defail_id = M('investor_detail')->add($val);//保存还款详情 $vol = ' (' . implode(',', array_keys($val)) . ')'; $vlaue = ' (' . implode(',', $val) . ')'; $invest_defail_id = mysql_query("INSERT INTO {$pre}investor_detail {$vol} VALUES {$vlaue}"); } // $last_have_money = M("borrow_info")->getFieldById($borrow_id,"has_borrow"); $result = mysql_query("SELECT has_borrow FROM {$pre}borrow_info WHERE id = {$borrow_id} LIMIT 1"); while ($row = mysql_fetch_assoc($result)) { $last_have_money = $row['has_borrow']; } // $last_have_money = $last_have_money['has_borrow']; $lasthavemoney = $last_have_money + $money; $sql = "update {$pre}borrow_info set `has_borrow`= {$lasthavemoney},borrow_times=borrow_times+1 WHERE `id`={$borrow_id}"; $upborrow_res = mysql_query($sql); //更新投标进度 if ($invest_defail_id && $rtype && $upborrow_res) { //还款概要和详情投标进度都保存成功 $bdb->commit(); mysql_query("COMMIT"); //执行事务 // $investMoney->commit(); file_put_contents('/tmp/4.txt', date('m-d H:i:s') . " comminvest::" . print_r($reqext, true) . "\n", FILE_APPEND); $res = memberMoneyLog($uid, 6, -($money - $reqext), "对{$borrow_id}号标进行投标", $binfo['borrow_uid']); //($uid,$type,$amoney,$info="",$target_uid="",$target_uname="",$fee=0,$reqext=0){ $today_reward = explode("|", $datag['today_reward']); if ($binfo['repayment_type'] == '1') { //如果是天标,则执行1个月的续投奖励利率 $reward_rate = floatval($today_reward[0]); } else { if ($binfo['borrow_duration'] == 1) { $reward_rate = floatval($today_reward[0]); } else { if ($binfo['borrow_duration'] == 2) { $reward_rate = floatval($today_reward[1]); } else { $reward_rate = floatval($today_reward[2]); } } } ////////////////////////////////////////回款续投奖励规则 fan 2013-07-20//////////////////////////// //$reward_rate = floatval($datag['today_reward']);//floatval($datag['today_reward']);//当日回款续投奖励利率 if ($binfo['borrow_type'] != 3) { //如果是秒标(borrow_type==3),则没有续投奖励这一说 $vd['add_time'] = array("lt", time()); $vd['investor_uid'] = $uid; //$borrow_invest_count = M("borrow_investor")->where($vd)->count('id');//检测是否投过标且大于一次 $sqlbic = sprintf("SELECT count(id) AS total FROM %s WHERE investor_uid=%s AND add_time<%s", "{$pre}borrow_investor", $uid, time()); // $borrow_invest_count = mysql_query("SELECT count(id) FROM {$pre}borrow_investor WHERE investor_uid") $resultbic = mysql_query($sqlbic); while ($rowbic = mysql_fetch_assoc($resultbic)) { $borrow_invest_count = $rowbic['total']; } if ($reward_rate > 0 && $vminfo['back_money'] > 0 && $borrow_invest_count > 0) { //首次投标不给续投奖励 if ($money > $vminfo['back_money']) { //如果投标金额大于回款资金池金额,有效续投奖励以回款金额资金池总额为标准,否则以投标金额为准 $reward_money_s = $vminfo['back_money']; } else { $reward_money_s = $money; } $save_reward['borrow_id'] = $borrow_id; $save_reward['reward_uid'] = $uid; $save_reward['invest_money'] = $reward_money_s; //如果投标金额大于回款资金池金额,有效续投奖励以回款金额资金池总额为标准,否则以投标金额为准 $save_reward['reward_money'] = $reward_money_s * $reward_rate / 1000; //续投奖励 $save_reward['reward_status'] = 0; $save_reward['add_time'] = time(); $save_reward['add_ip'] = get_client_ip(); //$newidxt = M("today_reward")->add($save_reward); $vol = ' (' . implode(',', array_keys($save_reward)) . ')'; $vlaue = ' (' . implode(',', $save_reward) . ')'; $invest_defail_id = mysql_query("INSERT INTO {$pre}today_reward {$vol} VALUES {$vlaue}"); } else { $result = true; } } /////////////////////////回款续投奖励结束 2013-05-10 Dqsy/////////////////////////////// //////////////////////邀请奖励开始//////////////////////////////////////// $sqlm = sprintf("SELECT user_name,recommend_id,usrid FROM %s WHERE id = %s LIMIT 1", "{$pre}members", $uid); $result = mysql_query($sqlm); $vo = mysql_fetch_assoc($result); // $vo = M('members')->field('user_name,recommend_id,usrid')->find($uid); $sql = sprintf("SELECT usrid FROM %s WHERE id = %s LIMIT 1 ", "{$pre}members", $vo['recommend_id']); $result = mysql_query($sql); $recommend_usrid = mysql_fetch_assoc($result); // $recommend_usrid = M('members')->field("usrid")->where("id = {$vo['recommend_id']}")->find(); $_rate = $datag['award_invest'] / 1000; //推广奖励 $jiangli = getFloatValue($_rate * $investinfo['investor_capital'], 2); if ($vo['recommend_id'] != 0) { $obj = core::Singleton('huifu.huifu'); $obj->transfer($jiangli, $recommend_usrid['usrid']); memberMoneyLog($vo['recommend_id'], 13, $jiangli, $vo['user_name'] . "对{$borrow_id}号标投资成功,你获得推广奖励" . $jiangli . "元。", $uid); } /////////////////////邀请奖励结束///////////////////////////////////////// //$aaa = M('investor_detail')->where('invest_id =2629')->count(); //if($aaa !=3 ){ // exit('aaaaa'); //} if ($lasthavemoney == $binfo['borrow_money']) { borrowFull($borrow_id, $binfo['borrow_type']); //满标,标记为还款中,更新相关数据 } if (!$res) { //没有正常记录和扣除帐户余额的话手动回滚 // M('investor_detail')->where("invest_id={$invest_info_id}")->delete(); // M('borrow_investor')->where("id={$invest_info_id}")->delete(); //更新投标进度 // $upborrowsql = "update `{$pre}borrow_info` set "; // $upborrowsql .= "`has_borrow`=".$havemoney.",`borrow_times`=`borrow_times`-1"; // $upborrowsql .= " WHERE `id`={$borrow_id}"; // $upborrow_res = M()->execute($upborrowsql); //更新投标进度 $done = false; } else { $done = true; } } else { mysql_query("ROOLBACK"); } mysql_query("SET AUTOCOMMIT=1"); mysql_close($handler); return $done; }
public function detail() { $vminfo = M('members')->field("user_leve,time_limit")->find($this->uid); if (!($vminfo['user_leve'] > 0 && $vminfo['time_limit'] > time())) { $this->error("请先通过VIP审核再投资", __APP__ . "/member/vip/invest"); } if ($_GET['type'] == 'commentlist') { //评论 $cmap['tid'] = intval($_GET['id']); $clist = getCommentList($cmap, 5); $this->assign("commentlist", $clist['list']); $this->assign("commentpagebar", $clist['page']); $this->assign("commentcount", $clist['count']); $data['html'] = $this->fetch('commentlist'); exit(json_encode($data)); } $pre = C('DB_PREFIX'); $id = intval($_GET['id']); $Bconfig = (require C("APP_ROOT") . "Conf/borrow_config.php"); //合同ID if ($this->uid) { $invs = M('borrow_investor')->field('id')->where("borrow_id={$id} AND (investor_uid={$this->uid} OR borrow_uid={$this->uid})")->find(); if ($invs['id'] > 0) { $invsx = $invs['id']; } elseif (!is_array($invs)) { $invsx = 'no'; } } else { $invsx = 'login'; } $this->assign("invid", $invsx); //合同ID //borrowinfo $borrowinfo = M("borrow_info")->field(true)->find($id); if (!is_array($borrowinfo) || $borrowinfo['borrow_status'] == 0 && $this->uid != $borrowinfo['borrow_uid']) { $this->error("数据有误"); } $borrowinfo['biao'] = $borrowinfo['borrow_times']; $borrowinfo['need'] = $borrowinfo['borrow_money'] - $borrowinfo['has_borrow']; $borrowinfo['lefttime'] = $borrowinfo['collect_time'] - time(); $borrowinfo['progress'] = getFloatValue($borrowinfo['has_borrow'] / $borrowinfo['borrow_money'] * 100, 2); $borrowinfo['vouch_progress'] = getFloatValue($borrowinfo['has_vouch'] / $borrowinfo['borrow_money'] * 100, 2); $borrowinfo['vouch_need'] = $borrowinfo['borrow_money'] - $borrowinfo['has_vouch']; $this->assign("vo", $borrowinfo); //borrowinfo //此标借款利息还款相关情况 if ($borrowinfo['repayment_type'] == 2) { $money = 100; $rate = $borrowinfo['borrow_interest_rate']; $month = $borrowinfo['borrow_duration']; $monthData['money'] = $money; $monthData['year_apr'] = $rate; $monthData['duration'] = $month; $monthData['type'] = "all"; $repay_detail = EqualMonth($monthData); $this->assign('repay_detail', $repay_detail); } elseif ($borrowinfo['repayment_type'] == 3) { $money = 100; $rate = $borrowinfo['borrow_interest_rate']; $month = $borrowinfo['borrow_duration']; $monthData['account'] = $money; $monthData['year_apr'] = $rate; $monthData['month_times'] = $month; $monthData['type'] = "all"; $repay_detail = EqualSeason($monthData); $this->assign('repay_detail', $repay_detail); } elseif ($borrowinfo['repayment_type'] == 4) { $money = 100; $rate = $borrowinfo['borrow_interest_rate']; $month = $borrowinfo['borrow_duration']; $parm['month_times'] = $month; $parm['account'] = $money; $parm['year_apr'] = $rate; $parm['type'] = "all"; $repay_detail = EqualEndMonth($parm); $repay_detail['repayment_money'] = $repay_detail['repayment_account']; $this->assign("repay_detail", $repay_detail); } elseif ($borrowinfo['repayment_type'] == 1) { $repay_detail['repayment_money'] = getFloatValue(100 + 100 * $borrowinfo['borrow_interest_rate'] * $borrowinfo['borrow_duration'] / 100, 2); $this->assign('repay_detail', $repay_detail); } //此标借款利息还款相关情况 //memberinfo $memberinfo = M("members m")->field("m.id,m.customer_name,m.customer_id,m.user_name,m.reg_time,m.credits,fi.*,mi.*")->join("{$pre}member_financial_info fi ON fi.uid = m.id")->join("{$pre}member_info mi ON mi.uid = m.id")->where("m.id={$borrowinfo['borrow_uid']}")->find(); $areaList = getArea(); $memberinfo['location'] = $areaList[$memberinfo['province']] . $areaList[$memberinfo['city']]; $memberinfo['location_now'] = $areaList[$memberinfo['province_now']] . $areaList[$memberinfo['city_now']]; $this->assign("minfo", $memberinfo); //memberinfo //vouch_list $vouch_list = M("borrow_vouch")->field(true)->where("borrow_id={$id}")->select(); $this->assign("vouch_list", $vouch_list); $this->assign("Vstatus", array(0 => '担保中', 1 => "担保完成")); //vouch_list //data_list $data_list = M("member_data_info")->field('type,add_time,count(status) as num,sum(deal_credits) as credits')->where("uid={$borrowinfo['borrow_uid']} AND status=1")->group('type')->select(); $this->assign("data_list", $data_list); //data_list //paying_list $paying_list = getMemberBorrow($borrowinfo['borrow_uid']); $this->assign("paying_list", $paying_list); //paying_list //近期还款的投标 //$time1 = microtime(true)*1000; $history = getDurationCount($borrowinfo['borrow_uid']); $this->assign("history", $history); //$time2 = microtime(true)*1000; //echo $time2-$time1; //investinfo $fieldx = "bi.investor_capital,bi.add_time,m.user_name,bi.is_auto"; $investinfo = M("borrow_investor bi")->field($fieldx)->join("{$pre}members m ON bi.investor_uid = m.id")->where("bi.borrow_id={$id}")->order("bi.id DESC")->select(); $this->assign("investinfo", $investinfo); //investinfo //帐户资金情况 $this->assign("mainfo", getMinfo($borrowinfo['borrow_uid'], true)); $this->assign("capitalinfo", getMemberBorrowScan($borrowinfo['borrow_uid'])); //帐户资金情况 //评论 $cmap['tid'] = $id; $cmap['is_audit'] = 1; //审核通过的评论 $clist = getCommentList($cmap, 5); $this->assign("Bconfig", $Bconfig); $this->assign("commentlist", $clist['list']); $this->assign("commentpagebar", $clist['page']); $this->assign("commentcount", $clist['count']); $this->display(); }