function make_repay_plan($deal) { $true_repay_time = $deal['repay_time']; $repay_day = $deal['repay_start_time']; $has_use_self_money = 0; $list = array(); for ($i = 0; $i < $true_repay_time; $i++) { $load_repay = array(); $load_repay['repay_time'] = $repay_day = next_replay_month($repay_day); $load_repay['repay_date'] = to_date($load_repay['repay_time']); if ($i + 1 == $true_repay_time) { $load_repay['repay_money'] = $deal['last_month_repay_money']; $load_repay['self_money'] = $deal['borrow_amount']; } else { $load_repay['repay_money'] = $deal['month_repay_money']; $load_repay['self_money'] = 0; } $load_repay['manage_money'] = $deal['month_manage_money']; $load_repay['interest_money'] = $load_repay['repay_money'] - $load_repay['self_money']; $load_repay['deal_id'] = $deal['id']; $load_repay['user_id'] = $deal['user_id']; $list[] = $load_repay; } return $list; }
function make_repay_plan($deal) { $true_repay_time = $deal['repay_time']; $repay_day = $deal['repay_start_time']; $has_use_self_money = 0; $list = array(); for ($i = 0; $i < $true_repay_time; $i++) { $load_repay = array(); $load_repay['repay_time'] = $repay_day = next_replay_month($repay_day); $load_repay['repay_date'] = to_date($load_repay['repay_time']); if ($i + 1 == $true_repay_time) { $load_repay['repay_money'] = $deal['last_month_repay_money']; $load_repay['self_money'] = $deal['borrow_amount'] - $has_use_self_money; } else { $load_repay['repay_money'] = $deal['month_repay_money']; $load_repay['self_money'] = get_self_money($i, $deal['borrow_amount'], $deal['month_repay_money'], $deal['rate']); $has_use_self_money += $load_repay['self_money']; } $load_repay['manage_money'] = $deal['month_manage_money']; $load_repay['interest_money'] = $load_repay['repay_money'] - $load_repay['self_money']; //借款者 授权服务机构获取的管理费抽成 $rebate_rs = get_rebate_fee($deal['user_id'], "borrow"); $load_repay['manage_money_rebate'] = $load_repay['manage_money'] * floatval($rebate_rs['rebate']) / 100; $load_repay['deal_id'] = $deal['id']; $load_repay['user_id'] = $deal['user_id']; $list[] = $load_repay; } return $list; }
public function index() { $GLOBALS['tmpl']->assign("page_title", "VIP等级特权"); $list = load_auto_cache("level"); $GLOBALS['tmpl']->assign("list", $list['list']); $userinfo = $GLOBALS['db']->getRow("SELECT * FROM " . DB_PREFIX . "user WHERE id='" . $GLOBALS['user_info']['id'] . "' and vip_state='1' "); $GLOBALS['tmpl']->assign('userinfo', $userinfo); $gradeinfo = $GLOBALS['db']->getRow("SELECT * FROM " . DB_PREFIX . "vip_type WHERE id='" . $userinfo['vip_id'] . "' and is_delete='0' "); $GLOBALS['tmpl']->assign('gradeinfo', $gradeinfo); $vip_type = $GLOBALS['db']->getAll("SELECT * FROM " . DB_PREFIX . "vip_type WHERE is_effect='1' and is_delete='0' "); $GLOBALS['tmpl']->assign('vip_type', $vip_type); $vip_setting = $GLOBALS['db']->getAll("SELECT * FROM " . DB_PREFIX . "vip_setting v LEFT JOIN " . DB_PREFIX . "vip_type vt ON v.vip_id=vt.id WHERE v.is_effect='1' and v.is_delete='0' "); $GLOBALS['tmpl']->assign('vip_setting', $vip_setting); $customerinfo = $GLOBALS['db']->getRow("SELECT * FROM " . DB_PREFIX . "customer WHERE id='" . $userinfo['customer_id'] . "' and is_effect='1' "); $GLOBALS['tmpl']->assign('customerinfo', $customerinfo); $today = to_date(TIME_UTC, "Y-m-d"); $start_time = to_date(next_replay_month(TIME_UTC, -24), "Y-m-d"); $begin_date = to_date(next_replay_month(TIME_UTC, -3), "Y-m-d"); $user_id = $GLOBALS['user_info']['id']; $borrow_total = $GLOBALS['db']->getOne("select sum(borrow_amount) FROM " . DB_PREFIX . "deal WHERE start_date>'{$start_time}' and user_id='{$user_id}' and deal_status > 3 "); $load_total = $GLOBALS['db']->getOne("select sum(dl.money) FROM " . DB_PREFIX . "deal_load dl LEFT JOIN " . DB_PREFIX . "deal d ON dl.deal_id=d.id WHERE dl.create_date>'{$start_time}' and dl.user_id='{$user_id}' and d.deal_status > 3 "); $t_u_load = $GLOBALS['db']->getRow("SELECT sum(dlr.repay_money) as load_money FROM " . DB_PREFIX . "deal_load_repay dlr LEFT JOIN " . DB_PREFIX . "deal d ON d.id=dlr.deal_id LEFT JOIN " . DB_PREFIX . "deal_load dl ON dl.id=dlr.load_id WHERE d.is_effect=1 and dl.is_repay= 0 and dlr.t_user_id = " . $user_id); $load_total = floatval($load_total) + floatval($t_u_load['load_money']); // $load_total = $GLOBALS['db']->getOne("select sum(money) FROM ".DB_PREFIX."deal_load WHERE create_date>'$start_time' and user_id='$user_id' "); $overdue_total = $GLOBALS['db']->getOne("select sum(repay_money) FROM " . DB_PREFIX . "deal_repay WHERE ((has_repay=1 and repay_date<true_repay_date) or (has_repay=0 and repay_date <'{$today}')) and user_id='{$user_id}' "); $bl_total = (int) $borrow_total + (int) $load_total; $yx_total = $bl_total - $overdue_total; $vipgradeinfo = $GLOBALS['db']->getRow("select * FROM " . DB_PREFIX . "vip_type WHERE lower_limit<='{$yx_total}' and upper_limit>='{$yx_total}' and is_effect='1' and is_delete='0' "); $grade_cz = $GLOBALS['db']->getRow("SELECT * FROM " . DB_PREFIX . "vip_type where is_effect='1' and is_delete='0' order by lower_limit asc limit 1 "); if ($grade_cz['lower_limit'] > $yx_total || $userinfo['vip_id'] == 0) { $chazhi = (int) $grade_cz['lower_limit'] - $yx_total; if ($chazhi > 0) { $chazhi = $chazhi; } else { $chazhi = 0; } $nextgrade = $grade_cz['vip_grade']; } else { $chazhi = $vipgradeinfo['upper_limit'] - $yx_total + 1; $nextgradeinfo = $GLOBALS['db']->getRow("select * FROM " . DB_PREFIX . "vip_type WHERE lower_limit >'" . $vipgradeinfo['upper_limit'] . "' and is_effect='1' and is_delete='0' order by lower_limit asc limit 1 "); $nextgrade = $nextgradeinfo['vip_grade']; } $chazhi = number_format($chazhi); $bl_total = number_format($bl_total); $vipgradeinfo = number_format($vipgradeinfo); $yx_total = number_format($yx_total); $overdue_total = number_format($overdue_total); $GLOBALS['tmpl']->assign('bl_total', $bl_total); $GLOBALS['tmpl']->assign('chazhi', $chazhi); $GLOBALS['tmpl']->assign('nextgrade', $nextgrade); $GLOBALS['tmpl']->assign('overdue_total', $overdue_total); $GLOBALS['tmpl']->assign('yx_total', $yx_total); $GLOBALS['tmpl']->assign('vipgradeinfo', $vipgradeinfo); $GLOBALS['tmpl']->assign("inc_file", "inc/uc/uc_vip_setting_index.html"); $GLOBALS['tmpl']->display("page/uc.html"); }
public function foreverdelete() { //彻底删除指定记录 $ajax = intval($_REQUEST['ajax']); $condition = array("log_time" => array("lt", next_replay_month(TIME_UTC, -6))); $list = M(MODULE_NAME)->where($condition)->delete(); if ($list !== false) { save_log("清除半年前的记录", 1); $this->success(l("FOREVER_DELETE_SUCCESS"), $ajax); } else { save_log("清除半年前的记录", 0); $this->error(l("FOREVER_DELETE_FAILED"), $ajax); } }
public function index() { $user_info = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "user where id = " . intval($GLOBALS['user_info']['id'])); $level_info = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "user_group where id = " . intval($user_info['group_id'])); $point_level = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "user_level where id = " . intval($user_info['level_id'])); $user_info['user_level'] = $level_info['name']; $user_info['point_level'] = $point_level['name']; $user_info['discount'] = $level_info['discount'] * 10; $GLOBALS['tmpl']->assign("user_data", $user_info); $type_title = isset($_REQUEST['type_title']) ? intval($_REQUEST['type_title']) : 100; $times = intval($_REQUEST['times']); $time_status = intval($_REQUEST['time_status']); $t = strim($_REQUEST['t']); //point 积分 为空为资金 $GLOBALS['tmpl']->assign("t", $t); $page = intval($_REQUEST['p']); if ($page == 0) { $page = 1; } $limit = ($page - 1) * app_conf("PAGE_SIZE") . "," . app_conf("PAGE_SIZE"); if ($t == "point") { $title_arrays = array("100" => "全部", "0" => "结存", "4" => "偿还本息", "5" => "回收本息", "6" => "提前还款", "7" => "提前回收", "8" => "申请认证", "11" => "逾期还款", "13" => "人工操作", "14" => "借款服务费", "18" => "开户奖励", "23" => "邀请返利", "24" => "投标返利", "25" => "签到成功"); } elseif ($t == "lock_money") { $title_arrays = array("100" => "全部", "0" => "结存", "1" => "充值", "2" => "投标成功", "8" => "申请提现", "9" => "提现手续费", "13" => "人工操作", "18" => "开户奖励", "19" => "流标还返"); } elseif ($t == "score") { $title_arrays = array("100" => "全部", "0" => "结存", "1" => "充值", "2" => "投标成功", "3" => "招标成功", "8" => "申请提现", "9" => "提现手续费", "13" => "人工操作", "18" => "开户奖励", "22" => "兑换", "25" => "签到成功", "28" => "投资奖励 ", "29" => "红包奖励 "); } elseif ($t == "nmc_amount") { $title_arrays = array("100" => "全部", "22" => "兑换", "28" => "投资奖励 ", "29" => "红包奖励 "); } else { $title_arrays = array("100" => "全部", "0" => "结存", "1" => "充值", "2" => "投标成功", "3" => "招标成功", "4" => "偿还本息", "5" => "回收本息", "6" => "提前还款", "7" => "提前回收", "8" => "申请提现", "9" => "提现手续费", "10" => "借款管理费", "11" => "逾期罚息", "12" => "逾期管理费", "13" => "人工充值", "14" => "借款服务费", "15" => "出售债权", "16" => "购买债权", "17" => "债权转让管理费", "18" => "开户奖励", "19" => "流标还返", "20" => "投标管理费", "21" => "投标逾期收入", "22" => "兑换", "23" => "邀请返利", "24" => "投标返利", "25" => "签到成功", "26" => "逾期罚金(垫付后)", "27" => "其他费用", "28" => "投资奖励 ", "29" => "红包奖励 "); } $GLOBALS['tmpl']->assign('title_array', $title_arrays); $times_array = array("0" => "全部", "1" => "三天以内", "2" => "一周以内", "3" => "一月以内", "4" => "三月以内", "5" => "一年以内"); $GLOBALS['tmpl']->assign('times_array', $times_array); $user_id = intval($GLOBALS['user_info']['id']); $condition = ""; if ($times == 1) { $condition .= " and create_time_ymd >= '" . to_date(TIME_UTC - 3600 * 24 * 3, "Y-m-d") . "' "; //三天以内 } elseif ($times == 2) { $condition .= "and create_time_ymd >= '" . to_date(TIME_UTC - to_date(TIME_UTC, "w") * 24 * 3600, "Y-m-d") . "'"; //一周以内 } elseif ($times == 3) { $condition .= " and create_time_ym = '" . to_date(TIME_UTC, "Ym") . "'"; //一月以内 } elseif ($times == 4) { $condition .= " and create_time_ym >= '" . to_date(next_replay_month(TIME_UTC, -2), "Ym") . "'"; //三月以内 } elseif ($times == 5) { $condition .= " and create_time_y = '" . to_date(TIME_UTC, "Y") . "'"; //一年以内 } if ($type_title == 100) { $type = -1; } else { $type = $type_title; } if ($time_status == 1) { $time = isset($_REQUEST['time']) ? strim($_REQUEST['time']) : ""; $time_f = to_date(to_timespan($time, "Ymd"), "Y-m-d"); $condition .= " and create_time_ymd = '" . $time_f . "'"; $GLOBALS['tmpl']->assign('time_normal', $time_f); $GLOBALS['tmpl']->assign('time', $time); } if (isset($t) && $t == "point") { $result = get_user_point_log($limit, $user_id, $type, $condition); //会员信用积分 } elseif (isset($t) && $t == "lock_money") { $result = get_user_lock_money_log($limit, $user_id, $type, $condition); //会员信用积分 } elseif (isset($t) && $t == "score") { $result = get_user_score_log($limit, $user_id, $type, $condition); //会员积分 } elseif (isset($t) && $t == "nmc_amount") { $result = get_user_nmc_amount_log($limit, $user_id, $type, $condition); //不可提现资金日志 } else { $result = get_user_money_log($limit, $user_id, $type, $condition); //会员资金日志 } foreach ($result['list'] as $k => $v) { $result['list'][$k]['title'] = $title_arrays[$v['type']]; } $GLOBALS['tmpl']->assign("type_title", $type_title); $GLOBALS['tmpl']->assign("times", $times); $GLOBALS['tmpl']->assign("carry_money", $GLOBALS['db']->getOne("SELECT sum(money) FROM " . DB_PREFIX . "user_carry WHERE user_id=" . $user_id . " AND `status`=1")); $GLOBALS['tmpl']->assign("incharge_money", $GLOBALS['db']->getOne("SELECT sum(money) FROM " . DB_PREFIX . "payment_notice WHERE user_id=" . $user_id . " AND `is_paid`=1")); $GLOBALS['tmpl']->assign('time_status', $time_status); $GLOBALS['tmpl']->assign("list", $result['list']); $page = new Page($result['count'], app_conf("PAGE_SIZE")); //初始化分页对象 $p = $page->show(); $GLOBALS['tmpl']->assign('pages', $p); $GLOBALS['tmpl']->assign("page_title", $GLOBALS['lang']['UC_MONEY']); $GLOBALS['tmpl']->assign("inc_file", "inc/uc/uc_money_index.html"); $GLOBALS['tmpl']->display("page/uc.html"); }
public function index() { $this->init_user(); $user_info = $this->user_data; $ajax = intval($_REQUEST['ajax']); if ($ajax == 0) { $this->init_main(); } $user_id = intval($GLOBALS['user_info']['id']); /***统计***/ $user_statics = $user_info['user_statics']; //债券转让统计 $list_sql = "select sum(CASE WHEN `has_repay`=1 THEN self_money ELSE 0 END ) AS `total_self_money` ,sum(CASE WHEN `has_repay`=1 THEN interest_money ELSE 0 END ) AS `total_interest_money`, " . "sum(CASE WHEN `has_repay`=0 THEN self_money ELSE 0 END ) AS `not_self_money` ,sum(CASE WHEN `has_repay`=0 THEN interest_money ELSE 0 END ) AS `not_interest_money`" . " from " . DB_PREFIX . "deal_load_repay dlr left join " . DB_PREFIX . "deal_load dl on dlr.load_id = dl.id where ((dlr.user_id = " . $user_id . " and dlr.t_user_id = 0) or dlr.t_user_id = " . $user_id . ") and (pP2PBillNo ='' or pP2PBillNo is null) "; //print_r($list_sql);die; $transfer_info = $GLOBALS['db']->getRow($list_sql); $user_statics["load_earnings"] = number_format(floatval($user_statics["load_earnings"]) + floatval($transfer_info["total_interest_money"]), 2); //$user_info["load_wait_repay_amount"] = 0; $user_statics["need_repay_amount"] = floatval($user_statics["need_repay_amount"]) + floatval($user_statics["need_manage_amount"]); //待收本金 $user_statics["load_wait_self_money"] = floatval($transfer_info["load_wait_self_money"]) + floatval($transfer_info["not_self_money"]); $user_statics["clear_total_money"] = number_format(round($user_statics["load_wait_self_money"], 2) + round($user_info["money"], 2) + round($user_info["lock_money"], 2) - round($user_statics["need_repay_amount"], 2), 2); $user_statics["load_wait_self_money"] = number_format($user_statics["load_wait_self_money"]); //待收收益 $user_statics["load_wait_earnings"] = number_format(floatval($transfer_info["load_wait_earnings"]) + floatval($transfer_info["not_interest_money"]), 2); $user_statics["ltotal_money"] = number_format(floatval($user_statics["load_wait_repay_money"]) + floatval($user_statics["load_repay_money"]), 2); $user_info["total_money"] = number_format(floatval($user_info["money"]) + floatval($user_info["lock_money"]), 2); $user_info["lock_money"] = number_format(floatval($user_info["lock_money"]), 2); $user_statics["money"] = number_format(floatval($user_info["money"]), 2); $user_statics["need_repay_amount"] = number_format(floatval($user_statics["need_repay_amount"]), 2); //投标中的 $invest_sql = "SELECT count(*) as l_count,sum(money) as l_money FROM " . DB_PREFIX . "deal_load dl LEFT JOIN " . DB_PREFIX . "deal d ON dl.deal_id = d.id WHERE dl.user_id=" . $user_id . " and d.deal_status in(1,2) group by dl.user_id"; $invest = $GLOBALS['db']->getRow($invest_sql); $user_statics["invest_count"] = $invest["l_count"]; $user_statics["invest_money"] = number_format($invest["l_money"], 2); $user_statics["total_money"] = number_format(round($invest_sql["money"], 2) + round($user_statics["load_wait_repay_money"], 2) + round($user_statics["load_repay_money"], 2), 2); $user_statics["load_wait_repay_money"] = number_format(floatval($user_statics["load_wait_repay_money"]), 2); $user_statics["load_repay_money"] = number_format(floatval($user_statics["load_repay_money"]) + floatval($transfer_info["total_self_money"]), 2); //本月 $this_wait_deals = $this->get_loadlist($user_id, " AND DATE_FORMAT(FROM_UNIXTIME(repay_time),'%Y年%m月') = date_format(curdate(),'%Y年%m月') "); $user_statics["this_month_money"] = 0.0; $user_statics["this_month_count"] = 0; foreach ($this_wait_deals as $k => $v) { $user_statics["this_month_money"] += $v["repay_money"]; $user_statics["this_month_count"]++; } //下月 $next_wait_deals = $this->get_loadlist($user_id, " AND DATE_FORMAT(FROM_UNIXTIME(repay_time),'%Y年%m月') = date_format(DATE_ADD(curdate(), INTERVAL 1 MONTH),'%Y年%m月')"); $user_statics["next_month_money"] = 0.0; $user_statics["next_month_count"] = 0; foreach ($next_wait_deals as $k => $v) { $user_statics["next_month_money"] += $v["repay_money"]; $user_statics["next_month_count"]++; } //本年 $year_wait_deals = $this->get_loadlist($user_id, " AND DATE_FORMAT(FROM_UNIXTIME(repay_time),'%Y') = DATE_FORMAT(curdate(),'%Y')"); $user_statics["year_money"] = 0.0; $user_statics["year_count"] = 0; foreach ($year_wait_deals as $k => $v) { $user_statics["year_money"] += $v["repay_money"]; $user_statics["year_count"]++; } $user_statics["year_money"] = number_format(round($user_statics["year_money"], 2), 2); $user_statics["this_month_money"] = number_format(round($user_statics["this_month_money"], 2), 2); $user_statics["next_month_money"] = number_format(round($user_statics["next_month_money"], 2), 2); //总计 $all_wait_deals = $this->get_loadlist($user_id, ''); $user_statics["total_invest_money"] = 0.0; $user_statics["total_invest_count"] = 0; foreach ($all_wait_deals as $k => $v) { $user_statics["total_invest_money"] += $v["repay_money"]; $user_statics["total_invest_count"]++; } $user_statics["total_invest_money"] = number_format($user_statics["total_invest_money"], 2); //$user_statics["total_invest_count"] = $user_statics["this_month_count"]+$user_statics["next_month_count"]+$user_statics["year_count"]; $load_list_sql = "SELECT * FROM " . DB_PREFIX . "deal_load WHERE user_id = " . $GLOBALS['user_info']['id'] . " ORDER BY id DESC limit 0,4"; //最近交易 $load_list = $GLOBALS['db']->getAllCached($load_list_sql); $GLOBALS['tmpl']->assign("load_list", $load_list); //$user_statics["total_money"] = number_format(floatval($user_info["load_wait_repay_money"]) - floatval($user_info["need_repay_amount"])); $GLOBALS['tmpl']->assign("user_statics", $user_statics); //最近六个月投资记录 $month = array(); //select month(FROM_UNIXTIME(time)) from table_name group by month(FROM_UNIXTIME(time)) $result['lend'] = $GLOBALS['db']->getAllCached("SELECT count(*) as l_count,sum(money) as l_money,DATE_FORMAT(FROM_UNIXTIME(dl.create_time),'%Y年%m月') as l_month FROM " . DB_PREFIX . "deal_load dl LEFT JOIN " . DB_PREFIX . "deal d ON dl.deal_id = d.id WHERE dl.is_repay = 0 AND dl.user_id=" . $user_id . " and d.deal_status in(1,2,4,5) group by DATE_FORMAT(FROM_UNIXTIME(dl.create_time),'%Y年%m月')"); $months[0]["time"] = to_date(next_replay_month(TIME_UTC, -5), 'Y年m月'); $months[1]["time"] = to_date(next_replay_month(TIME_UTC, -4), 'Y年m月'); $months[2]["time"] = to_date(next_replay_month(TIME_UTC, -3), 'Y年m月'); $months[3]["time"] = to_date(next_replay_month(TIME_UTC, -2), 'Y年m月'); $months[4]["time"] = to_date(next_replay_month(TIME_UTC, -1), 'Y年m月'); $months[5]["time"] = to_date(TIME_UTC, 'Y年m月'); $max_money = 100; foreach ($result['lend'] as $k => $v) { if (round($max_money) < round($v["l_money"])) { $max_money = $v["l_money"]; } foreach ($months as $kk => $vv) { if ($vv["time"] == $v["l_month"]) { $months[$kk]["l_money"] = $v["l_money"]; $months[$kk]["show_money"] = number_format(floatval($v["l_money"]), 2); } } } foreach ($months as $k => $v) { $months[$k]["height"] = $v["l_money"] / $max_money * 325; $months[$k]["bottom"] = $v["l_money"] / $max_money * 325 + 35; } $GLOBALS['tmpl']->assign("max_money", $max_money); $GLOBALS['tmpl']->assign("months", $months); /***右侧统计结束***/ $GLOBALS['tmpl']->assign("user_data", $user_info); if ($ajax == 0) { //近期待还款 $day_deal_repay = getUcDealRepay($user_id, 10, ""); //近期待收款 $day_repay_list = getUcRepayPlan($user_id, 3, 10, ""); //推荐的标 require APP_ROOT_PATH . "app/Lib/deal_func.php"; $where = " is_recommend = 1 and deal_status in (0,1,2)"; $deals_list = get_deal_list(10, 0, $where); foreach ($deals_list['list'] as $k => $v) { $deals_list['list'][$k]['repay_time_format'] = $v['repay_time'] . "个月"; $deals_list['list'][$k]['start_time_format'] = to_date($v['start_time'], "Y-m-d"); if ($deals_list['list'][$k]['deal_status'] == 0) { $deals_list['list'][$k]['deal_status_format'] = "待等材料"; } elseif ($deals_list['list'][$k]['deal_status'] == 1) { $deals_list['list'][$k]['deal_status_format'] = "进行中"; } elseif ($deals_list['list'][$k]['deal_status'] == 2) { $deals_list['list'][$k]['deal_status_format'] = "满标"; } } $GLOBALS['tmpl']->assign('day_deal_repay', $day_deal_repay['list']); $GLOBALS['tmpl']->assign('day_repay_list', $day_repay_list['list']); $GLOBALS['tmpl']->assign('deals_list', $deals_list['list']); $GLOBALS['tmpl']->assign("page_title", $GLOBALS['lang']['UC_CENTER_INDEX']); $GLOBALS['tmpl']->assign("post_title", $GLOBALS['lang']['UC_CENTER_INDEX']); $GLOBALS['tmpl']->assign("inc_file", "inc/uc/uc_center_index.html"); $GLOBALS['tmpl']->display("page/uc.html"); } else { header("Content-Type:text/html; charset=utf-8"); echo $GLOBALS['tmpl']->fetch("inc/topic_col_list.html"); } }
function getUcDealRepay($user_id, $limit, $condition = "") { $result = array("rs_count" => 0, "list" => array()); $extWhere = " 1=1 "; $extWhere .= " and has_repay=0 and user_id = " . $user_id . " and repay_time <=" . next_replay_month(TIME_UTC, 1) . " "; $sql_count = "SELECT count(*) FROM " . DB_PREFIX . "deal_repay where {$extWhere} {$condition} order by deal_id"; $result['rs_count'] = $GLOBALS['db']->getOne($sql_count); if ($result['rs_count'] > 0) { $result['list'] = $GLOBALS['db']->getAll("select *,l_key+1 as l_key_index from " . DB_PREFIX . "deal_repay where {$extWhere} {$condition} order by deal_id limit " . $limit); foreach ($result['list'] as $k => $v) { $result['list'][$k]['name'] = $GLOBALS['db']->getOne("select name from " . DB_PREFIX . "deal where id = " . $result['list'][$k]['deal_id']); //贷款名称 $result['list'][$k]['l_key_index'] = "第 " . $v['l_key_index'] . " 期"; if ($v['has_repay'] == 0) { $result['list'][$k]['status_format'] = '待还'; } elseif ($v['status'] == 0) { $result['list'][$k]['status_format'] = '提前还款'; } elseif ($v['status'] == 1) { $result['list'][$k]['status_format'] = '准时还款'; } elseif ($v['status'] == 2) { $result['list'][$k]['status_format'] = '逾期还款'; } elseif ($v['status'] == 3) { $result['list'][$k]['status_format'] = '严重逾期'; } $result['list'][$k]['repay_money_format'] = format_price($v['repay_money']); $result['list'][$k]['self_money_format'] = format_price($v['self_money']); $result['list'][$k]['interest_money_format'] = format_price($v['interest_money']); } } return $result; }
/** * 满标放款 * $type 0 普通 1代表 第三方 * $is_loan 0 不返款, 1 返款 */ function do_loans($id, $repay_start_time, $type = 0) { $return = array("status" => 0, "info" => ""); if ($id == 0) { $return['info'] = "放款失败,借款不存在"; return $return; } require_once APP_ROOT_PATH . "app/Lib/deal.php"; syn_deal_status($id); $deal_info = get_deal($id); if ($deal['cate_id'] == 6) { // 体验金 $is_ty = 1; } else { $is_ty = 0; } if (!$deal_info) { $return['info'] = "放款失败,借款不存在"; return $return; } if (!in_array($deal_info['deal_status'], array(2, 4, 5))) { $return['info'] = "放款失败,借款不是满标状态"; return $return; } if ($type == 0) { $loan_data['repay_start_time'] = $repay_start_time == '' ? 0 : to_timespan(to_date(to_timespan($repay_start_time), "Y-m-d"), "Y-m-d"); } else { $loan_data['repay_start_time'] = $repay_start_time; } if ($loan_data['repay_start_time'] == 0) { $return['info'] = "放款失败,时间没选择"; return $return; } if ($type == 0 && $deal_info['ips_bill_no'] != "") { $return['status'] = 2; $return['info'] = ""; $return['jump'] = APP_ROOT . "/index.php?ctl=collocation&act=Transfer&pTransferType=1&deal_id=" . $id . "&ref_data=" . $loan_data['repay_start_time']; return $return; } if ($loan_data['repay_start_time'] > 0) { $deal_info['next_repay_time'] = $loan_data['next_repay_time'] = next_replay_month($loan_data['repay_start_time']); } $deal_info['deal_status'] = $loan_data['deal_status'] = 4; $deal_info['is_has_loans'] = $loan_data['is_has_loans'] = 1; $deal_info['repay_start_time'] = $loan_data['repay_start_time']; format_deal_item($deal_info); //放款给用户 $GLOBALS['db']->autoExecute(DB_PREFIX . "deal", $loan_data, "UPDATE", "id=" . $id); if ($GLOBALS['db']->affected_rows() > 0) { require_once APP_ROOT_PATH . "system/libs/user.php"; if ($type == 0) { modify_account(array("money" => $deal_info['borrow_amount']), $deal_info['user_id'], "[<a href='" . $deal_info['url'] . "' target='_blank'>" . $deal_info['name'] . "</a>],招标成功", 3, $is_ty); //扣除服务费 $services_fee = $deal_info['borrow_amount'] * floatval(trim($deal_info['services_fee'])) / 100; modify_account(array("money" => -$services_fee), $deal_info['user_id'], "[<a href='" . $deal_info['url'] . "' target='_blank'>" . $deal_info['name'] . "</a>],服务费", 14, $is_ty); } $load_list = $GLOBALS['db']->getAll("SELECT id,user_id,`money`,`is_old_loan`,`rebate_money`,`rebid_money` FROM " . DB_PREFIX . "deal_load where deal_id=" . $id . " and is_rebate = 0 and is_rebid = 0 "); foreach ($load_list as $lk => $lv) { //扣除冻结资金 if ($lv['is_old_loan'] == 0 && $type == 0) { modify_account(array("lock_money" => -$lv['money']), $lv['user_id'], "[<a href='" . $deal_info['url'] . "' target='_blank'>" . $deal_info['name'] . "</a>],投标成功", 2, $is_ty); } //返利给用户 if (floatval($lv["rebate_money"]) != 0) { $GLOBALS['db']->query("UPDATE " . DB_PREFIX . "deal_load SET is_rebate =1 WHERE id=" . $lv['id'] . " AND is_rebate = 0 AND user_id=" . $lv['user_id'], $is_ty); if ($GLOBALS['db']->affected_rows()) { modify_account(array("money" => $lv['rebate_money']), $lv['user_id'], "[<a href='" . $deal_info['url'] . "' target='_blank'>" . $deal_info['name'] . "</a>],返利", 24, $is_ty); } } //续投奖励 if (floatval($lv["rebid_money"]) != 0) { $GLOBALS['db']->query("UPDATE " . DB_PREFIX . "deal_load SET is_rebid =1 WHERE id=" . $lv['id'] . " AND is_rebid = 0 AND user_id=" . $lv['user_id']); if ($GLOBALS['db']->affected_rows()) { modify_account(array("money" => $lv['rebid_money']), $lv['user_id'], "[<a href='" . $deal_info['url'] . "' target='_blank'>" . $deal_info['name'] . "</a>],续投奖励", 24, $is_ty); } } } $GLOBALS['db']->autoExecute(DB_PREFIX . "deal_load", array("is_has_loans" => 1), "UPDATE", "deal_id=" . $id); make_repay_plan($deal_info); //发借款成功邮件 send_deal_success_mail_sms($id, $deal_info); //发借款成功站内信 send_deal_success_site_sms($id, $deal_info); $return['status'] = 1; $return['info'] = "放款成功"; return $return; } else { $return['info'] = "放款失败"; return $return; } }
function getUcTransferBuys($page, $status) { if ($page == 0) { $page = 1; } $limit = ($page - 1) * app_conf("PAGE_SIZE") . "," . app_conf("PAGE_SIZE"); $page_args = array(); $condition = ' and d.is_effect=1 and d.is_delete=0 and d.repay_time_type =1 and d.publish_wait=0 and dlt.t_user_id=' . $GLOBALS['user_info']['id'] . " "; $union_sql = " LEFT JOIN " . DB_PREFIX . "deal_load_transfer dlt ON dlt.deal_id = dl.deal_id and dlt.load_id=dl.id "; switch ($status) { case 1: //回收中 $condition .= " AND d.deal_status = 4 "; break; case 2: //已回收 $condition .= " AND d.deal_status = 5 "; break; default: //默认 $condition .= " AND d.deal_status >= 4 "; break; } $count_sql = 'SELECT count(dl.id) FROM ' . DB_PREFIX . 'deal_load dl LEFT JOIN ' . DB_PREFIX . 'deal d ON d.id = dl.deal_id ' . $union_sql . ' WHERE 1=1 ' . $condition; $rs_count = $GLOBALS['db']->getOne($count_sql . " LIMIT {$limit} "); $list = array(); if ($rs_count > 0) { $list_sql = 'SELECT dl.id as dlid,d.*,dl.money as load_money,dlt.id as dltid,dlt.status as tras_status,dlt.t_user_id,dlt.transfer_amount,dlt.create_time as tras_create_time,dlt.transfer_time FROM ' . DB_PREFIX . 'deal_load dl LEFT JOIN ' . DB_PREFIX . 'deal d ON d.id = dl.deal_id ' . $union_sql . ' WHERE 1=1 ' . $condition; $list = $GLOBALS['db']->getAll($list_sql); foreach ($list as $k => $v) { //最后还款日 $list[$k]['final_repay_time'] = next_replay_month($v['repay_start_time'], $v['repay_time']); $list[$k]['final_repay_time_format'] = to_date($list[$k]['final_repay_time'], "Y-m-d"); //剩余期数 if ($v['deal_status'] == 4) { if (intval($v['last_repay_time']) > 0) { $list[$k]['how_much_month'] = how_much_month($v['last_repay_time'], $list[$k]['final_repay_time']); } else { $list[$k]['how_much_month'] = how_much_month($v['repay_start_time'], $list[$k]['final_repay_time']); } } else { $list[$k]['how_much_month'] = 0; } if ($v['loantype'] == 0) { $list[$k]['month_repay_money'] = pl_it_formula($v['load_money'], $v['rate'] / 12 / 100, $v['repay_time']); } elseif ($v['loantype'] == 1) { $list[$k]['month_repay_money'] = av_it_formula($v['load_money'], $v['rate'] / 12 / 100); } elseif ($v['loantype'] == 2) { $list[$k]['month_repay_money'] = 0; } if ($v['deal_status'] == 4) { if ($v['loantype'] == 0) { //剩余多少钱未回 $list[$k]['all_must_repay_money'] = $list[$k]['month_repay_money'] * $list[$k]['how_much_month']; //剩余多少本金未回 $list[$k]['left_benjin'] = get_benjin($v['repay_time'] - $list[$k]['how_much_month'] - 1, $v['repay_time'], $v['load_money'], $list[$k]['month_repay_money'], $v['rate']); } elseif ($v['loantype'] == 1) { //剩余多少钱未回 $list[$k]['all_must_repay_money'] = $list[$k]['month_repay_money'] * $list[$k]['how_much_month'] + $v['load_money']; //剩余多少本金未回 $list[$k]['left_benjin'] = $v['load_money']; } elseif ($v['loantype'] == 2) { //剩余多少钱未回 $list[$k]['all_must_repay_money'] = $v['load_money'] * $v['rate'] / 12 / 100 * $v['repay_time'] + $v['load_money']; //剩余多少本金未回 $list[$k]['left_benjin'] = $v['load_money']; } $list[$k]['left_benjin_format'] = format_price($list[$k]['left_benjin'] / 10000) . "万"; //剩多少利息 $list[$k]['left_lixi'] = $list[$k]['all_must_repay_money'] - $list[$k]['left_benjin']; $list[$k]['left_lixi_format'] = format_price($list[$k]['left_lixi']); } else { $list[$k]['left_benjin_format'] = format_price(0); $list[$k]['left_lixi_format'] = format_price(0); } //转让价格 $list[$k]['transfer_amount_format'] = format_price($v['transfer_amount'] / 10000) . "万"; if ($v['tras_create_time'] != "") { $list[$k]['tras_create_time_format'] = to_date($v['tras_create_time'], "Y-m-d"); } if (intval($v['transfer_time']) > 0) { $list[$k]['transfer_time_format'] = to_date($v['transfer_time'], "Y-m-d"); } $list[$k]['tras_status_op'] = 5; if ($v['deal_status'] == 4) { $list[$k]['tras_status_format'] = '回收中'; } elseif ($v['deal_status'] == 5) { $list[$k]['tras_status_format'] = '已回收'; } $durl = "/index.php?ctl=deal&act=mobile&id=" . $v['id']; $list[$k]['app_url'] = str_replace("/mapi", "", SITE_DOMAIN . $durl); } return array('list' => $list, 'count' => $rs_count); } else { return array('list' => null, 'count' => 0); } }
function apart() { require_once APP_ROOT_PATH . "app/Lib/common.php"; require_once APP_ROOT_PATH . "app/Lib/deal.php"; $id = intval($_REQUEST['id']); $deal = get_deal($id, 0); if (!$deal) { $this->error("借款不存在"); } if ($deal['is_effect'] == 1) { $this->error("请将借款设置为无效状态"); } if ($deal['ips_bill_no'] != "") { $this->error("第三方标无法拆分"); } if ($deal['deal_status'] != 1) { $this->error("该借款当前状态不是进行中"); } if ($deal['load_money'] == 0) { $this->error("该借款还没人投标无法拆标"); } $this->assign("deal", $deal); if (!in_array((int) to_date(TIME_UTC, "d"), array(29, 30, 31))) { $NOW_TIME = to_date(TIME_UTC, "Y-m-d"); } else { $NOW_TIME = to_date(next_replay_month(TIME_UTC), "Y-m") . "-01"; } $this->assign("NOW_TIME", $NOW_TIME); $html = $this->fetch(); $this->success($html); }
/** * 提前还款 */ function inrepay_repay($loaninfo, $k, $time_utc = 0) { $benjin = $loaninfo['deal']['borrow_amount']; $rate = $loaninfo['deal']['rate'] * 0.01 / 12; $all_repay_time = $loaninfo['deal']['repay_time']; $true_m = $true_k = 0; if ($time_utc == 0) { $time_utc = TIME_UTC; } //当为天的时候 if ($loaninfo['deal']['repay_time_type'] == 0) { $rate = $rate / 30; $left_time = intval(to_timespan(to_date($time_utc, "Y-m-d"), "Y-m-d")) - intval($loaninfo['deal']['repay_start_time']); if ($left_time > 0) { $true_k = ceil($left_time / 24 / 3600); } else { $true_k = 1; } $true_m = 1; $all_repay_time = 1; } else { for ($i = 0; $i < $all_repay_time; $i++) { if ($time_utc >= next_replay_month($loaninfo['deal']['repay_start_time'], $i) + 24 * 3600 - 1) { $true_k += 1; } } $true_m = $true_k; } $return["impose_money"] = $benjin * (double) trim($loaninfo['deal']['compensate_fee']) * 0.01; $return["true_self_money"] = $benjin; $return["true_repay_money"] = $benjin + $benjin * $rate * $true_k; $return["true_manage_money"] = $loaninfo['deal']['all_manage_money'] / $all_repay_time * $true_m; $return["true_manage_money_rebate"] = $return["true_manage_money"] * floatval($loaninfo['deal']['rebate']) / 100; $return["true_manage_interest_money"] = $benjin * $rate * $true_k * floatval($loaninfo['deal']["user_loan_interest_manage_fee"]) / 100; $return["true_manage_interest_money_rebate"] = $return["true_manage_interest_money"] * floatval($loaninfo['deal']['rebate_fee']) / 100; return $return; }
public function contact() { $id = intval($_REQUEST['id']); if ($id == 0) { echo "不存在的债权"; die; } //先执行更新借贷信息 $deal_id = $GLOBALS['db']->getOne("SELECT deal_id FROM " . DB_PREFIX . "deal_load WHERE id=" . $id); if ($deal_id == 0) { echo "不存在的债权"; die; } else { syn_deal_status($deal_id); } $condition = ' AND dlt.id=' . $id . ' AND d.deal_status >= 4 and d.is_effect=1 and d.is_delete=0 and d.loantype = 0 and d.repay_time_type =1 and d.publish_wait=0 and (dlt.user_id=' . $GLOBALS['user_info']['id'] . ' or dlt.t_user_id = ' . $GLOBALS['user_info']['id'] . ') '; $union_sql = " LEFT JOIN " . DB_PREFIX . "deal_load_transfer dlt ON dlt.deal_id = dl.deal_id "; $sql = 'SELECT dlt.id,dlt.deal_id,dlt.load_id,dlt.transfer_amount,dlt.near_repay_time,dlt.user_id,d.next_repay_time,d.last_repay_time,d.rate,d.repay_start_time,d.repay_time,dlt.load_money,dlt.id as dltid,dlt.status as tras_status,dlt.t_user_id,dlt.transfer_amount,dlt.create_time as tras_create_time,dlt.transfer_time,d.user_id as duser_id FROM ' . DB_PREFIX . 'deal_load dl LEFT JOIN ' . DB_PREFIX . 'deal d ON d.id = dl.deal_id ' . $union_sql . ' WHERE 1=1 ' . $condition; $transfer = $GLOBALS['db']->getRow($sql); if ($transfer) { //下个还款日 $transfer['next_repay_time_format'] = to_date($transfer['near_repay_time'], "Y 年 m 月 d 日"); $transfer['near_repay_time_format'] = to_date(next_replay_month($transfer['near_repay_time'], " -1 "), "Y 年 m 月 d 日"); //什么时候开始借 $transfer['repay_start_time_format'] = to_date($transfer['repay_start_time'], "Y 年 m 月 d 日"); //还款日 $transfer['final_repay_time'] = next_replay_month($transfer['repay_start_time'], $transfer['repay_time']); $transfer['final_repay_time_format'] = to_date($transfer['final_repay_time'], "Y 年 m 月 d 日"); //剩余期数 $transfer['how_much_month'] = how_much_month($transfer['near_repay_time'], $transfer['final_repay_time']) + 1; //本息还款金额 $transfer['month_repay_money'] = pl_it_formula($transfer['load_money'], $transfer['rate'] / 12 / 100, $transfer['repay_time']); $transfer['month_repay_money_format'] = format_price($transfer['month_repay_money']); //剩余多少钱未回 $transfer['all_must_repay_money'] = $transfer['month_repay_money'] * $transfer['how_much_month']; $transfer['all_must_repay_money_format'] = format_price($transfer['all_must_repay_money']); //剩余多少本金未回 $transfer['left_benjin'] = get_benjin($transfer['repay_time'] - $transfer['how_much_month'] - 1, $transfer['repay_time'], $transfer['load_money'], $transfer['month_repay_money'], $transfer['rate']); $transfer['left_benjin_format'] = format_price($transfer['left_benjin']); //剩多少利息 $transfer['left_lixi'] = $transfer['all_must_repay_money'] - $transfer['left_benjin']; $transfer['left_lixi_format'] = format_price($transfer['left_lixi']); //投标价格 $transfer['load_money_format'] = format_price($transfer['load_money']); //转让价格 $transfer['transfer_amount_format'] = format_price($transfer['transfer_amount']); //转让管理费 $transfer_fee = $transfer['transfer_amount'] * (double) app_conf("USER_LOAD_TRANSFER_FEE"); if ($transfer_fee != 0) { $transfer_fee = $transfer_fee / 100; } $transfer['transfer_fee_format'] = format_price($transfer_fee); //转让收益 $transfer['transfer_income_format'] = format_price($transfer['all_must_repay_money'] - $transfer['transfer_amount']); if ($transfer['tras_create_time'] != "") { $transfer['tras_create_time_format'] = to_date($transfer['tras_create_time'], "Y 年 m 月 d 日"); } $transfer['transfer_time_format'] = to_date($transfer['transfer_time'], "Y 年 m 月 d 日"); $transfer['user'] = get_user("user_name,real_name,idno,level_id", $transfer['user_id']); $transfer['tuser'] = get_user("user_name,real_name,idno,level_id", $transfer['t_user_id']); $transfer['duser'] = get_user("user_name,real_name,idno,level_id", $transfer['duser_id']); $GLOBALS['tmpl']->assign('transfer', $transfer); } else { echo "不存在的债权"; die; } $contract = $GLOBALS['tmpl']->fetch("str:" . app_conf("TCONTRACT")); $GLOBALS['tmpl']->assign('contract', $contract); $GLOBALS['tmpl']->display("inc/uc/transfer_contact.html"); }
/** * VIP 升降级 */ function syn_user_vip($user_id, $type, $type_info) { $vipdata = array(); //$type_info 1借款升级、2投标升级、3正常还款升级、4提前还款升级、5.逾期还款降级、6.代还款降级、7.坏账降级 switch ($type_info) { case "1": $vipdata['causes'] = "借款升级"; break; case "2": $vipdata['causes'] = "投标升级"; break; case "3": $vipdata['causes'] = "正常还款升级"; break; case "4": $vipdata['causes'] = "提前还款升级"; break; case "5": $vipdata['causes'] = "逾期还款降级"; break; case "6": $vipdata['causes'] = "代还款降级"; break; case "7": $vipdata['causes'] = "坏账降级"; break; default: $vipdata['causes'] = ""; break; } $vipdata['user_id'] = $user_id; $today = to_date(TIME_UTC, "Y-m-d"); $start_time = to_date(next_replay_month(TIME_UTC, -24), "Y-m-d"); $begin_date = to_date(next_replay_month(TIME_UTC, -3), "Y-m-d"); $user_info = $GLOBALS['db']->getRow("select * FROM " . DB_PREFIX . "user WHERE id='{$user_id}' "); $borrow_total = $GLOBALS['db']->getOne("select sum(borrow_amount) FROM " . DB_PREFIX . "deal WHERE start_date>'{$start_time}' and user_id='{$user_id}' and deal_status > 3 "); $overdue_total = $GLOBALS['db']->getOne("select sum(repay_money) FROM " . DB_PREFIX . "deal_repay WHERE ((has_repay=1 and repay_date<true_repay_date) or (has_repay=0 and repay_date <'{$today}')) and user_id='{$user_id}' "); $load_total = $GLOBALS['db']->getOne("select sum(dl.money) FROM " . DB_PREFIX . "deal_load dl LEFT JOIN " . DB_PREFIX . "deal d ON dl.deal_id=d.id WHERE dl.create_date>'{$start_time}' and dl.user_id='{$user_id}' and d.deal_status > 3 "); $t_u_load = $GLOBALS['db']->getRow("SELECT sum(dlr.repay_money) as load_money FROM " . DB_PREFIX . "deal_load_repay dlr LEFT JOIN " . DB_PREFIX . "deal d ON d.id=dlr.deal_id LEFT JOIN " . DB_PREFIX . "deal_load dl ON dl.id=dlr.load_id WHERE d.is_effect=1 and dl.is_repay= 0 and dlr.t_user_id = " . $user_id); $load_total = floatval($load_total) + floatval($t_u_load['load_money']); $bl_total = $borrow_total + $load_total - $overdue_total; $gradeinfo = $GLOBALS['db']->getRow("select * FROM " . DB_PREFIX . "vip_type WHERE lower_limit<='{$bl_total}' and upper_limit>='{$bl_total}' and is_effect='1' and is_delete='0' "); if ($type == 0) { } elseif ($type == 1) { //升级 $overdue_num = $GLOBALS['db']->getOne("select count(*) FROM " . DB_PREFIX . "deal_repay WHERE ((has_repay=1 and repay_date<true_repay_date and repay_date>'{$begin_date}') or (has_repay=0 and repay_date <'{$today}')) and user_id='{$user_id}' "); $demotion_num = $GLOBALS['db']->getOne("select count(*) FROM " . DB_PREFIX . "demotion_record WHERE status=0 and user_id='{$user_id}' and eresume_date>'{$today}' "); $rdemotion_num = $GLOBALS['db']->getOne("select count(*) FROM " . DB_PREFIX . "demotion_record WHERE status=0 and user_id='{$user_id}' and eresume_date<='{$today}' "); //三个月内无逾期还款且 超过了预计降级还原期 if ($overdue_num == 0 && $demotion_num == 0) { $vipdata['original_vip_id'] = $user_info['vip_id']; $vipdata['now_vip_id'] = $gradeinfo['id']; $vipdata['upgrade_date'] = to_date(TIME_UTC, "Y-m-d"); if ($gradeinfo['id'] != $user_info['vip_id'] && $gradeinfo['id'] != 0) { $GLOBALS['db']->autoExecute(DB_PREFIX . "vip_upgrade_record", $vipdata, "INSERT"); } $GLOBALS['db']->query("update " . DB_PREFIX . "user SET vip_id='" . $gradeinfo['id'] . "',vip_state='1' WHERE id=" . $user_id); if ($rdemotion_num > 0) { $GLOBALS['db']->query("update " . DB_PREFIX . "demotion_record SET status='1',arecovery_date='{$today}' WHERE status=0 and user_id='{$user_id}' and eresume_date<='{$today}' "); } } } elseif ($type == 2) { //降级 $now_grade = $GLOBALS['db']->getOne("select id FROM " . DB_PREFIX . "vip_type WHERE sort<'" . $gradeinfo['sort'] . "' and is_effect='1' and is_delete='0' order by sort desc limit 1 "); if ($gradeinfo['vip_grade'] != "普通VIP会员" && $user_info['vip_id'] != 0) { $GLOBALS['db']->query("update " . DB_PREFIX . "user SET vip_id='" . $now_grade . "' WHERE id=" . $user_id); } $vipdata['original_vip_id'] = $user_info['vip_id']; $vipdata['now_vip_id'] = $now_grade; $vipdata['start_date'] = to_date(TIME_UTC, "Y-m-d"); $vipdata['eresume_date'] = to_date(next_replay_month(TIME_UTC, 3), "Y-m-d"); $vipdata['status'] = 0; if ($demotion_num == 0 && $gradeinfo['vip_grade'] != "普通VIP会员" && $user_info['vip_id'] != 0) { $GLOBALS['db']->autoExecute(DB_PREFIX . "demotion_record", $vipdata, "INSERT"); } } return $vipdata; }
function check_trans($id, $paypassword) { $paypassword = strim($paypassword); $id = intval($id); $root = array(); $root["status"] = 0; //0:出错;1:正确; if (!$GLOBALS['user_info']) { $root["show_err"] = $GLOBALS['lang']['PLEASE_LOGIN_FIRST']; return $root; } if ($paypassword == "") { $root["show_err"] = $GLOBALS['lang']['PAYPASSWORD_EMPTY']; return $root; } if (md5($paypassword) != $GLOBALS['user_info']['paypassword']) { $root["show_err"] = $GLOBALS['lang']['PAYPASSWORD_ERROR']; //.$GLOBALS['user_info']['paypassword'].';'.md5($paypassword).';'.$paypassword; return $root; } $deal_id = $GLOBALS['db']->getOne("SELECT deal_id FROM " . DB_PREFIX . "deal_load_transfer WHERE id=" . $id); if ($deal_id == 0) { $root["show_err"] = "不存在的债权"; return $root; } else { syn_deal_status($deal_id); } $condition = ' AND dlt.id=' . $id . ' AND d.deal_status = 4 and d.is_effect=1 and d.is_delete=0 and d.loantype = 0 and d.repay_time_type =1 and d.publish_wait=0 '; $union_sql = " LEFT JOIN " . DB_PREFIX . "deal_load_transfer dlt ON dlt.deal_id = dl.deal_id "; $sql = 'SELECT dlt.load_id,dlt.id,dlt.t_user_id,dlt.transfer_amount,dlt.user_id,dlt.near_repay_time,d.next_repay_time,d.last_repay_time,d.rate,d.repay_start_time,d.repay_time,dlt.load_money,dlt.id as dltid,dlt.status as tras_status,dlt.t_user_id,dlt.transfer_amount,dlt.create_time as tras_create_time,d.user_id as duser_id,d.ips_bill_no FROM ' . DB_PREFIX . 'deal_load dl LEFT JOIN ' . DB_PREFIX . 'deal d ON d.id = dl.deal_id ' . $union_sql . ' WHERE 1=1 ' . $condition; $transfer = $GLOBALS['db']->getRow($sql); if ($transfer) { if ($transfer['user_id'] == $GLOBALS['user_info']['id']) { $root["show_err"] = "不能购买自己转让的债权"; return $root; } if ($transfer['duser_id'] == $GLOBALS['user_info']['id']) { $root["show_err"] = "不能购买自己的的借贷债权"; return $root; } if ($transfer['tras_status'] == 0) { $root["show_err"] = "债权已撤销"; return $root; } if (intval($transfer['t_user_id']) > 0) { $root["show_err"] = "债权已转让"; return $root; } //下个还款日 if (intval($transfer['next_repay_time']) == 0) { $transfer['next_repay_time'] = next_replay_month($transfer['repay_start_time']); } if ($transfer['next_repay_time'] - TIME_UTC + 24 * 3600 - 1 <= 0) { $root["show_err"] = "债权转让已过期"; return $root; } $root["transfer"] = $transfer; $root["deal_id"] = $deal_id; } else { $root["show_err"] = "债权转让不存在"; return $root; } if ($transfer['ips_bill_no'] != "") { $root["status"] = 2; } else { $root["status"] = 1; } //0:出错;1:正确; return $root; }
/** * 提前还款 */ function inrepay_repay($loaninfo, $k, $time_utc = 0) { $benjin = $loaninfo['deal']['borrow_amount']; $rate = $loaninfo['deal']['rate'] * 0.01 / 12; $all_repay_time = $loaninfo['deal']['repay_time']; $true_k = 0; if ($time_utc == 0) { $time_utc = TIME_UTC; } //当为天的时候 if ($loaninfo['deal']['repay_time_type'] == 0) { $rate = $rate / 30; $true_k = 1; $all_repay_time = 1; } else { for ($i = 0; $i < $all_repay_time; $i++) { if ($time_utc >= next_replay_month($loaninfo['deal']['repay_start_time'], $i) + 24 * 3600 - 1) { $true_k += 1; } } } $return["impose_money"] = $benjin * (double) trim($loaninfo['deal']['compensate_fee']) * 0.01; $return["true_self_money"] = $benjin; $return["true_repay_money"] = $benjin + $benjin * $rate * $true_k; $return["true_manage_money"] = $loaninfo['deal']['all_manage_money'] / $all_repay_time * $true_k; return $return; }
public function index() { $this->init_user(); $user_info = $this->user_data; $user_info["total_money"] = number_format(floatval($user_info["money"]) + floatval($user_info["lock_money"]), 2); $user_info["lock_money"] = number_format(floatval($user_info["lock_money"]), 2); $ajax = intval($_REQUEST['ajax']); if ($ajax == 0) { $this->init_main(); } $user_id = intval($GLOBALS['user_info']['id']); /***统计***/ $user_statics = sys_user_status($GLOBALS['user_info']['id'], true); $user_statics["load_earnings"] = number_format(floatval($user_statics["load_earnings"]), 2); //$user_info["load_wait_repay_amount"] = 0; $user_statics["need_repay_amount"] = floatval($user_statics["need_repay_amount"]) + floatval($user_statics["need_manage_amount"]); //待收本金 $user_statics["load_wait_self_money"] = number_format(floatval($user_statics["load_wait_self_money"]), 2); //待收收益 $user_statics["load_wait_earnings"] = number_format(floatval($user_statics["load_wait_earnings"]), 2); $user_statics["ltotal_money"] = number_format(floatval($user_statics["load_wait_repay_money"]) + floatval($user_statics["load_repay_money"]), 2); $user_statics["money"] = number_format(floatval($user_info["money"]), 2); $user_statics["load_repay_money"] = number_format(floatval($user_statics["load_repay_money"]), 2); $user_statics["load_wait_repay_money"] = number_format(floatval($user_statics["load_wait_repay_money"]), 2); $user_statics["need_repay_amount"] = number_format(floatval($user_statics["need_repay_amount"]), 2); //投标中的 $invest_sql = "SELECT count(*) as l_count,sum(money) as l_money FROM " . DB_PREFIX . "deal_load dl LEFT JOIN " . DB_PREFIX . "deal d ON dl.deal_id = d.id WHERE dl.user_id=" . $user_id . " and d.deal_status in(1,2) group by dl.user_id"; $invest = $GLOBALS['db']->getRowCached($invest_sql); $user_statics["invest_count"] = $invest["l_count"]; $user_statics["invest_money"] = number_format($invest["l_money"], 2); $user_statics["total_money"] = number_format(round($invest_sql["money"], 2) + round($user_statics["load_wait_repay_money"], 2) + round($user_statics["load_repay_money"], 2), 2); //本月 $this_wait_deals = $this->get_loadlist($user_id, " AND DATE_FORMAT(FROM_UNIXTIME(repay_time),'%Y年%m月') = date_format(curdate(),'%Y年%m月')"); $user_statics["this_month_money"] = 0.0; $user_statics["this_month_count"] = 0; foreach ($this_wait_deals as $k => $v) { $user_statics["this_month_money"] += $v["repay_money"]; $user_statics["this_month_count"]++; } //下月 $next_wait_deals = $this->get_loadlist($user_id, " AND DATE_FORMAT(FROM_UNIXTIME(repay_time),'%Y年%m月') = date_format(DATE_ADD(curdate(), INTERVAL 1 MONTH),'%Y年%m月')"); $user_statics["next_month_money"] = 0.0; $user_statics["next_month_count"] = 0; foreach ($next_wait_deals as $k => $v) { $user_statics["next_month_money"] += $v["repay_money"]; $user_statics["next_month_count"]++; } //本年 $year_wait_deals = $this->get_loadlist($user_id, " AND DATE_FORMAT(FROM_UNIXTIME(repay_time),'%Y') = DATE_FORMAT(curdate(),'%Y')"); $user_statics["year_money"] = 0.0; $user_statics["year_count"] = 0; foreach ($year_wait_deals as $k => $v) { $user_statics["year_money"] += $v["repay_money"]; $user_statics["year_count"]++; } //$user_statics["total_invest_money"] = number_format($user_statics["this_month_money"]+$user_statics["next_month_money"]+$user_statics["year_money"],2); $user_statics["year_money"] = number_format(round($user_statics["year_money"], 2), 2); $user_statics["this_month_money"] = number_format(round($user_statics["this_month_money"], 2), 2); $user_statics["next_month_money"] = number_format(round($user_statics["next_month_money"], 2), 2); //总计 $all_wait_deals = $this->get_loadlist($user_id, ''); $user_statics["total_invest_money"] = 0.0; $user_statics["total_invest_count"] = 0; foreach ($all_wait_deals as $k => $v) { $user_statics["total_invest_money"] += $v["repay_money"]; $user_statics["total_invest_count"]++; } $user_statics["total_invest_money"] = number_format($user_statics["total_invest_money"], 2); //$user_statics["total_invest_count"] = $user_statics["this_month_count"]+$user_statics["next_month_count"]+$user_statics["year_count"]; $load_list_sql = "SELECT * FROM " . DB_PREFIX . "deal_load WHERE user_id = " . $GLOBALS['user_info']['id'] . " ORDER BY id DESC limit 0,4"; //最近交易 $load_list = $GLOBALS['db']->getAllCached($load_list_sql); $GLOBALS['tmpl']->assign("load_list", $load_list); //$user_statics["total_money"] = number_format(floatval($user_info["load_wait_repay_money"]) - floatval($user_info["need_repay_amount"])); $GLOBALS['tmpl']->assign("user_statics", $user_statics); //最近六个月投资记录 $month = array(); //select month(FROM_UNIXTIME(time)) from table_name group by month(FROM_UNIXTIME(time)) $result['lend'] = $GLOBALS['db']->getAllCached("SELECT count(*) as l_count,sum(money) as l_money,DATE_FORMAT(FROM_UNIXTIME(dl.create_time),'%Y年%m月') as l_month FROM " . DB_PREFIX . "deal_load dl LEFT JOIN " . DB_PREFIX . "deal d ON dl.deal_id = d.id WHERE dl.is_repay = 0 AND dl.user_id=" . $user_id . " and d.deal_status in(1,2,4,5) group by DATE_FORMAT(FROM_UNIXTIME(dl.create_time),'%Y年%m月')"); $months[0]["time"] = to_date(next_replay_month(TIME_UTC, -5), 'Y年m月'); $months[1]["time"] = to_date(next_replay_month(TIME_UTC, -4), 'Y年m月'); $months[2]["time"] = to_date(next_replay_month(TIME_UTC, -3), 'Y年m月'); $months[3]["time"] = to_date(next_replay_month(TIME_UTC, -2), 'Y年m月'); $months[4]["time"] = to_date(next_replay_month(TIME_UTC, -1), 'Y年m月'); $months[5]["time"] = to_date(TIME_UTC, 'Y年m月'); $max_money = 100; foreach ($result['lend'] as $k => $v) { if (round($max_money) < round($v["l_money"])) { $max_money = $v["l_money"]; } foreach ($months as $kk => $vv) { if ($vv["time"] == $v["l_month"]) { $months[$kk]["l_money"] = $v["l_money"]; $months[$kk]["show_money"] = number_format(floatval($v["l_money"]), 2); } } } foreach ($months as $k => $v) { $months[$k]["height"] = $v["l_money"] / $max_money * 325; $months[$k]["bottom"] = $v["l_money"] / $max_money * 325 + 35; } $GLOBALS['tmpl']->assign("max_money", $max_money); $GLOBALS['tmpl']->assign("months", $months); /***右侧统计结束***/ $GLOBALS['tmpl']->assign("user_data", $user_info); if ($ajax == 0) { $GLOBALS['tmpl']->assign("page_title", $GLOBALS['lang']['UC_CENTER_INDEX']); $GLOBALS['tmpl']->assign("post_title", $GLOBALS['lang']['UC_CENTER_INDEX']); $GLOBALS['tmpl']->assign("inc_file", "inc/uc/uc_center_index.html"); $GLOBALS['tmpl']->display("page/uc.html"); } else { header("Content-Type:text/html; charset=utf-8"); echo $GLOBALS['tmpl']->fetch("inc/topic_col_list.html"); } }
public function three_msg() { $map['is_delete'] = 0; if (trim($_REQUEST['name']) != '') { $map['name'] = array('like', '%' . trim($_REQUEST['name']) . '%'); } if (intval($_REQUEST['cate_id']) > 0) { require_once APP_ROOT_PATH . "system/utils/child.php"; $child = new Child("deal_cate"); $cate_ids = $child->getChildIds(intval($_REQUEST['cate_id'])); $cate_ids[] = intval($_REQUEST['cate_id']); $map['cate_id'] = array("in", $cate_ids); } if (trim($_REQUEST['user_name']) != '') { $sql = "select group_concat(id) from " . DB_PREFIX . "user where user_name like '%" . trim($_REQUEST['user_name']) . "%'"; $ids = $GLOBALS['db']->getOne($sql); $map['user_id'] = array("in", $ids); } $map['publish_wait'] = 0; $map['is_effect'] = 1; //获取到期还本息的贷款 $temp_ids = M("Deal")->where("publish_wait = 0 and is_delete=0 AND deal_status = 4 AND ((next_repay_time - " . TIME_UTC . " + 24*3600 -1)/24/3600 between 0 AND 3)")->Field('id')->findAll(); $deal_ids[] = 0; foreach ($temp_ids as $k => $v) { $deal_ids[] = $v['id']; } $map['id'] = array("in", implode(",", $deal_ids)); $list = D("Deal")->where($map)->findAll(); //发送信息 foreach ($list as $k => $v) { $next_repay_time = 0; $true_repay_time = $v['repay_time']; if ($v['next_repay_time'] > 0) { $next_repay_time = $v['next_repay_time']; } else { if ($v['repay_time_type'] == 0) { $r_y = to_date($v['repay_start_time'], "Y"); $r_m = to_date($v['repay_start_time'], "m"); $r_d = to_date($v['repay_start_time'], "d"); if ($r_m - 1 <= 0) { $r_m = 12; $r_y = $r_y - 1; } else { $r_m = $r_m - 1; } $true_repay_time = 1; $v['repay_start_time'] = to_timespan($r_y . "-" . $r_m . "-" . $r_d, "Y-m-d") + $v['repay_time'] * 24 * 3600; } //到期还本息 if ($v['loantype'] == 2) { $y = to_date($v['repay_start_time'], "Y"); $m = to_date($v['repay_start_time'], "m"); $d = to_date($v['repay_start_time'], "d"); $y = $y + intval(($m + $true_repay_time) / 12); $m = ($m + $true_repay_time) % 12; $next_repay_time = to_timespan($y . "-" . $m . "-" . $d, "Y-m-d"); } else { $next_repay_time = next_replay_month($v['repay_start_time']); } } //计算最近一期该还多少 if ($v["loantype"] == 0) { $repay_money = pl_it_formula($v['borrow_amount'], $v['rate'] / 12 / 100, $true_repay_time); } elseif ($v['loantype'] == 1) { $repay_money = av_it_formula($v['borrow_amount'], $v['rate'] / 12 / 100); } elseif ($v['loantype'] == 2) { $repay_money = $v['borrow_amount'] * $v['rate'] / 12 / 100 * $true_repay_time; } if ($v['repay_time_type'] == 1) { $idx = ((int) to_date(TIME_UTC, "Y") - (int) to_date($v['repay_start_time'], "Y")) * 12 + ((int) to_date(TIME_UTC, "m") - (int) to_date($v['repay_start_time'], "m")); if ($true_repay_time == $idx) { if ($v['loantype'] == 0) { $repay_money = $repay_money * 12 - ($idx - 1) * round($repay_money, 2); } elseif ($v['loantype'] == 1) { $repay_money = $repay_money + $v['borrow_amount']; } elseif ($v['loantype'] == 2) { $repay_money = $repay_money + $v['borrow_amount']; } } } //站内信 $content = "您在" . app_conf("SHOP_TITLE") . "的借款 “<a href=\"" . url("index", "deal", array("id" => $v['id'])) . "\">" . $v['name'] . "</a>”," . "最近一期还款将于" . to_date($next_repay_time, "d") . "日到期,需还金额" . round($repay_money, 2) . "元。"; $group_arr = array(0, $v['user_id']); sort($group_arr); $group_arr[] = 4; $msg_data['content'] = $content; $msg_data['to_user_id'] = $v['user_id']; $msg_data['create_time'] = TIME_UTC; $msg_data['type'] = 0; $msg_data['group_key'] = implode("_", $group_arr); $msg_data['is_notice'] = 12; $msg_data['fav_id'] = $v['id']; $GLOBALS['db']->autoExecute(DB_PREFIX . "msg_box", $msg_data); $id = $GLOBALS['db']->insert_id(); $GLOBALS['db']->query("update " . DB_PREFIX . "msg_box set group_key = '" . $msg_data['group_key'] . "_" . $id . "' where id = " . $id); $user_info = D("User")->where("id=" . $v['user_id'])->find(); //邮件 if (app_conf("MAIL_ON") == 1) { $tmpl = $GLOBALS['db']->getRowCached("select * from " . DB_PREFIX . "msg_template where name = 'TPL_DEAL_THREE_EMAIL'"); $tmpl_content = $tmpl['content']; $notice['user_name'] = $user_info['user_name']; $notice['deal_name'] = $v['name']; $notice['deal_url'] = SITE_DOMAIN . url("index", "deal", array("id" => $v['id'])); $notice['repay_url'] = SITE_DOMAIN . url("index", "uc_deal#refund"); $notice['repay_time_y'] = to_date($next_repay_time, "Y"); $notice['repay_time_m'] = to_date($next_repay_time, "m"); $notice['repay_time_d'] = to_date($next_repay_time, "d"); $notice['site_name'] = app_conf("SHOP_TITLE"); $notice['repay_money'] = round($repay_money, 2); $notice['help_url'] = SITE_DOMAIN . url("index", "helpcenter"); $notice['msg_cof_setting_url'] = SITE_DOMAIN . url("index", "uc_msg#setting"); $GLOBALS['tmpl']->assign("notice", $notice); $msg = $GLOBALS['tmpl']->fetch("str:" . $tmpl_content); $msg_data['dest'] = $user_info['email']; $msg_data['send_type'] = 1; $msg_data['title'] = "三日内还款通知"; $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'] = $user_info['id']; $msg_data['is_html'] = $tmpl['is_html']; $GLOBALS['db']->autoExecute(DB_PREFIX . "deal_msg_list", $msg_data); //插入 } //短信 if (app_conf("SMS_ON") == 1) { $tmpl = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "msg_template where name = 'TPL_DEAL_THREE_SMS'"); $tmpl_content = $tmpl['content']; $notice['user_name'] = $user_info["user_name"]; $notice['deal_name'] = $v['name']; $notice['repay_time_y'] = to_date($next_repay_time, "Y"); $notice['repay_time_m'] = to_date($next_repay_time, "m"); $notice['repay_time_d'] = to_date($next_repay_time, "d"); $notice['site_name'] = app_conf("SHOP_TITLE"); $notice['repay_money'] = round($repay_money, 2); $GLOBALS['tmpl']->assign("notice", $notice); $msg = $GLOBALS['tmpl']->fetch("str:" . $tmpl_content); $msg_data['dest'] = $user_info['mobile']; $msg_data['send_type'] = 0; $msg_data['title'] = "三日内还款通知"; $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'] = $user_info['id']; $msg_data['is_html'] = $tmpl['is_html']; $GLOBALS['db']->autoExecute(DB_PREFIX . "deal_msg_list", $msg_data); //插入 } $GLOBALS['db']->autoExecute(DB_PREFIX . "deal", array("send_three_msg_time" => $next_repay_time), "UPDATE", "id=" . $v['id']); } //成功提示 if ($deal_ids) { save_log(implode(",", $deal_ids) . "发送三日内还款提示", 1); } $this->success("发送成功"); }
public function cash() { $user_info = $GLOBALS['authorized_info'] = $this->checkLogin(); //$level_info = $GLOBALS['db']->getRow("select * from ".DB_PREFIX."user_group where id = ".intval($authorized_info['group_id'])); //$point_level = $GLOBALS['db']->getRow("select * from ".DB_PREFIX."user_level where id = ".intval($authorized_info['level_id'])); //$authorized_info['user_level'] = $level_info['name']; //$authorized_info['point_level'] = $point_level['name']; //$authorized_info['discount'] = $level_info['discount']*10; $GLOBALS['tmpl']->assign("user_data", $user_info); require APP_ROOT_PATH . "app/Lib/uc_func.php"; require APP_ROOT_PATH . "app/Lib/page.php"; $type_title = isset($_REQUEST['type_title']) ? intval($_REQUEST['type_title']) : 100; $times = intval($_REQUEST['times']); $time_status = intval($_REQUEST['time_status']); $t = strim($_REQUEST['t']); //point 积分 为空为资金 $GLOBALS['tmpl']->assign("t", $t); $page = intval($_REQUEST['p']); if ($page == 0) { $page = 1; } $limit = ($page - 1) * app_conf("PAGE_SIZE") . "," . app_conf("PAGE_SIZE"); if ($t == "lock_money") { $title_arrays = array("100" => "全部", "8" => "申请提现", "9" => "提现手续费", "13" => "人工充值", "18" => "开户奖励", "23" => "邀请返利", "27" => "其他费用"); } else { $title_arrays = array("100" => "全部", "8" => "申请提现", "9" => "提现手续费", "13" => "人工充值", "18" => "开户奖励", "23" => "邀请返利", "27" => "其他费用"); } $GLOBALS['tmpl']->assign('title_array', $title_arrays); $times_array = array("0" => "全部", "1" => "三天以内", "2" => "一周以内", "3" => "一月以内", "4" => "三月以内", "5" => "一年以内"); $GLOBALS['tmpl']->assign('times_array', $times_array); $user_id = intval($GLOBALS['authorized_info']['id']); $condition = ""; if ($times == 1) { $condition .= " and create_time_ymd >= '" . to_date(TIME_UTC - 3600 * 24 * 3, "Y-m-d") . "' "; //三天以内 } elseif ($times == 2) { $condition .= "and create_time_ymd >= '" . to_date(TIME_UTC - to_date(TIME_UTC, "w") * 24 * 3600, "Y-m-d") . "'"; //一周以内 } elseif ($times == 3) { $condition .= " and create_time_ym = '" . to_date(TIME_UTC, "Ym") . "'"; //一月以内 } elseif ($times == 4) { $condition .= " and create_time_ym >= '" . to_date(next_replay_month(TIME_UTC, -2), "Ym") . "'"; //三月以内 } elseif ($times == 5) { $condition .= " and create_time_y = '" . to_date(TIME_UTC, "Y") . "'"; //一年以内 } if ($type_title == 100) { $type = -1; } else { $type = $type_title; } if ($time_status == 1) { $time = isset($_REQUEST['time']) ? strim($_REQUEST['time']) : ""; $time_f = to_date(to_timespan($time, "Ymd"), "Y-m-d"); $condition .= " and create_time_ymd = '" . $time_f . "'"; $GLOBALS['tmpl']->assign('time_normal', $time_f); $GLOBALS['tmpl']->assign('time', $time); } if (isset($t) && $t == "lock_money") { $result = get_user_lock_money_log($limit, $user_id, $type, $condition); //会员信用积分 } else { $result = get_user_money_log($limit, $user_id, $type, $condition); //会员资金日志 } foreach ($result['list'] as $k => $v) { $result['list'][$k]['title'] = $title_arrays[$v['type']]; } $GLOBALS['tmpl']->assign("type_title", $type_title); $GLOBALS['tmpl']->assign("times", $times); $GLOBALS['tmpl']->assign("carry_money", $GLOBALS['db']->getOne("SELECT sum(money) FROM " . DB_PREFIX . "user_carry WHERE user_id=" . $user_id . " AND `status`=1")); $GLOBALS['tmpl']->assign("incharge_money", $GLOBALS['db']->getOne("SELECT sum(money) FROM " . DB_PREFIX . "payment_notice WHERE user_id=" . $user_id . " AND `is_paid`=1")); $GLOBALS['tmpl']->assign('time_status', $time_status); $GLOBALS['tmpl']->assign("list", $result['list']); $page = new Page($result['count'], app_conf("PAGE_SIZE")); //初始化分页对象 $p = $page->show(); $GLOBALS['tmpl']->assign('pages', $p); $GLOBALS['tmpl']->assign("user_info", $GLOBALS['authorized_info']); $GLOBALS['tmpl']->assign("page_title", $GLOBALS['lang']['UC_MONEY']); $GLOBALS['tmpl']->assign("inc_file", "authorized/authorized_money_index.html"); $GLOBALS['tmpl']->display("authorized/a_m.html"); }
function ajax_calculate() { $deal['loantype'] = intval($_REQUEST['borrowpay']); $deal['borrow_amount'] = intval($_REQUEST['borrowamount']); $deal['repay_time'] = intval($_REQUEST['repaytime']); $deal['repay_time_type'] = intval($_REQUEST['repaytimetype']); $deal['rate'] = trim($_REQUEST['apr']); $deal['repay_start_time'] = to_timespan(to_date(TIME_UTC, "Y-m-d")); $deal_repay_rs = deal_repay_money($deal); $deal['month_repay_money'] = $deal_repay_rs['month_repay_money']; //总的必须还多少本息 $deal['remain_repay_money'] = $deal_repay_rs['remain_repay_money']; //最后一期还款 $deal['last_month_repay_money'] = $deal_repay_rs['last_month_repay_money']; $deal['month_manage_money'] = $deal['borrow_amount'] * (double) app_conf('MANAGE_FEE') / 100; //总的多少管理费 if ($deal['repay_time_type'] == 1) { $deal['all_manage_money'] = $deal['month_manage_money'] * $deal["repay_time"]; } else { $deal['all_manage_money'] = $deal['month_manage_money']; } $GLOBALS['tmpl']->assign("borrowpay", $deal['loantype']); $GLOBALS['tmpl']->assign("borrowamount", $deal['borrow_amount']); $GLOBALS['tmpl']->assign("apr", $deal['rate']); if ($deal['repay_time_type'] == 1) { $GLOBALS['tmpl']->assign("rate", $deal['rate'] / 12); } else { $GLOBALS['tmpl']->assign("rate", $deal['rate'] / 12 / 30); } $GLOBALS['tmpl']->assign("repaytime", $deal['repay_time']); $GLOBALS['tmpl']->assign("repaytimetype", $deal['repay_time_type']); $GLOBALS['tmpl']->assign("repayamount", $deal['month_repay_money']); $GLOBALS['tmpl']->assign("repayallamount", $deal['remain_repay_money']); $level = intval($_REQUEST['level']); $level_list = load_auto_cache("level"); $GLOBALS['tmpl']->assign("services_fee", $level_list['services_fee'][$level] / 100 * $deal['borrow_amount']); if ($deal['repay_time_type'] == 0) { $inrepayshow = 0; } else { $inrepayshow = intval($_REQUEST['inrepayshow']); } $impose_day = intval($_REQUEST['impose_day']); if (isset($_REQUEST['isshow']) && intval($_REQUEST['isshow']) == 1) { $loantype = $deal['loantype']; $LoanModule = LoadLoanModule($loantype); $list = $LoanModule->make_repay_plan($deal); if ($impose_day >= app_conf('YZ_IMPSE_DAY')) { $impose_fee = app_conf('IMPOSE_FEE_DAY2'); $manage_impose_fee = app_conf('MANAGE_IMPOSE_FEE_DAY2'); } else { $impose_fee = app_conf('IMPOSE_FEE_DAY1'); $manage_impose_fee = app_conf('MANAGE_IMPOSE_FEE_DAY1'); } $left_repay_money = $deal['remain_repay_money']; foreach ($list as $k => $v) { $list[$k]['impose_money'] = $v['repay_money'] * $impose_fee * $impose_day * 0.01; $list[$k]['manage_impose_money'] = $v['repay_money'] * $manage_impose_fee * $impose_day * 0.01; $list[$k]['left_repay_money'] = $left_repay_money = $left_repay_money - round($v['repay_money'], 2); } $GLOBALS['tmpl']->assign("list", $list); } //提前还款 if ($inrepayshow == 1) { $tq_list = array(); $deal['compensate_fee'] = app_conf('COMPENSATE_FEE'); for ($i = 0; $i < $deal['repay_time']; $i++) { $loaninfo['deal'] = $deal; if (is_last_repay($deal['loantype'])) { $loaninfo['deal']['month_manage_money'] = $deal['all_manage_money']; } $tq_list[$i] = inrepay_repay($loaninfo, $i, next_replay_month(TIME_UTC, $i + 1)); if (is_last_repay($deal['loantype'])) { $tq_list[$i]['month_repay_money'] = 0; $tq_list[$i]['month_repay_money'] = 0; if ($i + 1 == $deal['repay_time']) { $tq_list[$i]['manage_money'] = $deal['all_manage_money']; $tq_list[$i]['month_repay_money'] = $deal['last_month_repay_money']; } } else { $tq_list[$i]['manage_money'] = $deal['month_manage_money']; $tq_list[$i]['month_repay_money'] = $deal['month_repay_money']; if ($i + 1 == $deal['repay_time']) { $tq_list[$i]['month_repay_money'] = $deal['last_month_repay_money']; } } } $GLOBALS['tmpl']->assign("tq_list", $tq_list); } $GLOBALS['tmpl']->display("inc/tool/calculate_result.html"); }
public function record() { $user_info = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "user where id = " . intval($GLOBALS['user_info']['id'])); $level_info = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "user_group where id = " . intval($user_info['group_id'])); $point_level = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "user_level where id = " . intval($user_info['level_id'])); $user_info['user_level'] = $level_info['name']; $user_info['point_level'] = $point_level['name']; $user_info['discount'] = $level_info['discount'] * 10; $GLOBALS['tmpl']->assign("user_data", $user_info); $type_title = isset($_REQUEST['type_title']) ? intval($_REQUEST['type_title']) : 100; $times = intval($_REQUEST['times']); $time_status = intval($_REQUEST['time_status']); $t = "score"; $GLOBALS['tmpl']->assign("t", $t); $page = intval($_REQUEST['p']); if ($page == 0) { $page = 1; } $limit = ($page - 1) * app_conf("PAGE_SIZE") . "," . app_conf("PAGE_SIZE"); if ($t == "score") { $title_arrays = array("100" => "全部", "0" => "结存", "1" => "充值", "2" => "投标成功", "3" => "招标成功", "8" => "申请提现", "9" => "提现手续费", "13" => "人工操作", "18" => "开户奖励", "22" => "兑换", "25" => "签到成功", "28" => "投资奖励 ", "29" => "红包奖励 "); } $GLOBALS['tmpl']->assign('title_array', $title_arrays); $times_array = array("0" => "全部", "1" => "三天以内", "2" => "一周以内", "3" => "一月以内", "4" => "三月以内", "5" => "一年以内"); $GLOBALS['tmpl']->assign('times_array', $times_array); $user_id = intval($GLOBALS['user_info']['id']); $condition = ""; if ($times == 1) { $condition .= " and create_time_ymd >= '" . to_date(TIME_UTC - 3600 * 24 * 3, "Y-m-d") . "' "; //三天以内 } elseif ($times == 2) { $condition .= "and create_time_ymd >= '" . to_date(TIME_UTC - to_date(TIME_UTC, "w") * 24 * 3600, "Y-m-d") . "'"; //一周以内 } elseif ($times == 3) { $condition .= " and create_time_ym = '" . to_date(TIME_UTC, "Ym") . "'"; //一月以内 } elseif ($times == 4) { $condition .= " and create_time_ym >= '" . to_date(next_replay_month(TIME_UTC, -2), "Ym") . "'"; //三月以内 } elseif ($times == 5) { $condition .= " and create_time_y = '" . to_date(TIME_UTC, "Y") . "'"; //一年以内 } if ($type_title == 100) { $type = -1; } else { $type = $type_title; } if ($time_status == 1) { $time = isset($_REQUEST['time']) ? strim($_REQUEST['time']) : ""; $time_f = to_date(to_timespan($time, "Ymd"), "Y-m-d"); $condition .= " and create_time_ymd = '" . $time_f . "'"; $GLOBALS['tmpl']->assign('time_normal', $time_f); $GLOBALS['tmpl']->assign('time', $time); } if (isset($t) && $t == "score") { $result = get_user_score_log($limit, $user_id, $type, $condition); //会员积分 } foreach ($result['list'] as $k => $v) { $result['list'][$k]['title'] = $title_arrays[$v['type']]; } $GLOBALS['tmpl']->assign("type_title", $type_title); $GLOBALS['tmpl']->assign("times", $times); $GLOBALS['tmpl']->assign('time_status', $time_status); $GLOBALS['tmpl']->assign("list", $result['list']); $page = new Page($result['count'], app_conf("PAGE_SIZE")); //初始化分页对象 $p = $page->show(); $GLOBALS['tmpl']->assign('pages', $p); $GLOBALS['tmpl']->assign("page_title", "积分详情"); $GLOBALS['tmpl']->assign("inc_file", "inc/uc/uc_score_exchange_record.html"); $GLOBALS['tmpl']->display("page/uc.html"); }