示例#1
0
 public function index()
 {
     $root = array();
     $id = intval($GLOBALS['request']['id']);
     $deal = get_deal($id);
     //send_deal_contract_email($id,$deal,$deal['user_id']);  //发送电子协议邮件
     $root['deal'] = $deal;
     //借款列表
     $load_list = $GLOBALS['db']->getAll("SELECT deal_id,user_id,user_name,money,is_auto,create_time FROM " . DB_PREFIX . "deal_load WHERE deal_id = " . $id);
     $u_info = get_user("*", $deal['user_id']);
     //可用额度
     $can_use_quota = get_can_use_quota($deal['user_id']);
     $root['can_use_quota'] = $can_use_quota;
     $credit_file = get_user_credit_file($deal['user_id']);
     $deal['is_faved'] = 0;
     /*
     		if($GLOBALS['user_info']){
     			$deal['is_faved'] = $GLOBALS['db']->getOne("SELECT count(*) FROM ".DB_PREFIX."deal_collect WHERE deal_id = ".$id." AND user_id=".intval($GLOBALS['user_info']['id']));
     				
     			if($deal['deal_status'] >=4){
     				//还款列表
     				$loan_repay_list = get_deal_load_list($deal);
     				
     				$root['loan_repay_list']= $loan_repay_list;
     				
     				
     				foreach($load_list as $k=>$v){
     					$load_list[$k]['remain_money'] = $v['money'] - $GLOBALS['db']->getOne("SELECT sum(self_money) FROM ".DB_PREFIX."deal_load_repay WHERE user_id=".$v['user_id']." AND deal_id=".$id);
     					if($load_list[$k]['remain_money'] <=0){
     						$load_list[$k]['remain_money'] = 0;
     						$load_list[$k]['status'] = 1;
     					}
     				}
     			}
     			
     		}*/
     $user_statics = sys_user_status($deal['user_id'], true);
     $root['user_statics'] = $user_statics;
     //借款笔数
     $root['load_list'] = $load_list;
     $root['credit_file'] = $credit_file;
     $root['u_info'] = $u_info;
     //工作认证是否过期
     $root['expire'] = user_info_expire($u_info);
     //留言
     $message_list = $GLOBALS['db']->getAll("SELECT title,content,a.create_time,rel_id,a.user_id,a.is_effect,b.user_name FROM " . DB_PREFIX . "message as a left join " . DB_PREFIX . "user as b on  a.user_id = b.id WHERE rel_id = " . $id);
     $root['message'] = $message_list;
     //seo
     if ($deal['type_match_row']) {
         $seo_title = $deal['seo_title'] != '' ? $deal['seo_title'] : $deal['type_match_row'] . " - " . $deal['name'];
     } else {
         $seo_title = $deal['seo_title'] != '' ? $deal['seo_title'] : $deal['name'];
     }
     $root['page_title'] = $seo_title;
     $seo_keyword = $deal['seo_keyword'] != '' ? $deal['seo_keyword'] : $deal['type_match_row'] . "," . $deal['name'];
     $root['page_keyword'] = $seo_keyword;
     $seo_description = $deal['seo_description'] != '' ? $deal['seo_description'] : $deal['name'];
     $root['seo_description'] = $seo_description;
     output($root);
 }
 public function index()
 {
     $GLOBALS['tmpl']->assign("page_title", $GLOBALS['lang']['UC_CREDIT']);
     $list = load_auto_cache("level");
     $GLOBALS['tmpl']->assign("list", $list['list']);
     foreach ($list["list"] as $k => $v) {
         if ($v['id'] == $GLOBALS['user_info']['level_id']) {
             $user_point_level = $v['name'];
         }
     }
     //可用额度
     $can_use_quota = get_can_use_quota($GLOBALS['user_info']['id']);
     $GLOBALS['tmpl']->assign('can_use_quota', $can_use_quota);
     $credit_file = get_user_credit_file($GLOBALS['user_info']['id'], $GLOBALS['user_info']);
     //必要信用认证
     $level_point['need_other_point'] = 0;
     $must_credit_count = 0;
     $other_credit_count = 0;
     foreach ($credit_file as $k => $v) {
         if ($v['passed'] == 1) {
             $level_point['need_other_point'] += (int) trim($v['point']);
         }
         if ($v['must'] == 1) {
             $must_credit_count++;
         } else {
             $other_credit_count++;
         }
     }
     //还清
     $level_point['repay_success'] = $GLOBALS['db']->getRow("SELECT sum(point) as total_point,count(*) AS total_count FROM " . DB_PREFIX . "user_log WHERE log_info like '%还清借款%' AND user_id=" . $GLOBALS['user_info']['id']);
     //逾期
     $level_point['impose_repay'] = $GLOBALS['db']->getRow("SELECT sum(point) as total_point,count(*) AS total_count FROM " . DB_PREFIX . "user_log WHERE log_info like '%逾期还款%' and log_info not like '%严重逾期还款%' AND user_id=" . $GLOBALS['user_info']['id']);
     //严重逾期
     $level_point['yz_impose_repay'] = $GLOBALS['db']->getRow("SELECT sum(point) as total_point,count(*) AS total_count FROM " . DB_PREFIX . "user_log WHERE log_info like '%严重逾期还款%' AND user_id=" . $GLOBALS['user_info']['id']);
     $GLOBALS['tmpl']->assign('level_point', $level_point);
     $GLOBALS['tmpl']->assign("credit_file", $credit_file);
     $GLOBALS['tmpl']->assign("must_credit_count", $must_credit_count);
     $GLOBALS['tmpl']->assign("other_credit_count", $other_credit_count);
     $GLOBALS['tmpl']->assign("user_point_level", $user_point_level);
     $GLOBALS['tmpl']->assign("inc_file", "inc/uc/uc_credit.html");
     $GLOBALS['tmpl']->display("page/uc.html");
 }
示例#3
0
 public function index()
 {
     $root = array();
     $id = intval($GLOBALS['request']['id']);
     $deal = get_deal($id);
     //send_deal_contract_email($id,$deal,$deal['user_id']);  //发送电子协议邮件
     $root['deal'] = $deal;
     //借款列表
     $load_list = $GLOBALS['db']->getAll("SELECT deal_id,user_id,user_name,money,is_auto,create_time FROM " . DB_PREFIX . "deal_load WHERE deal_id = " . $id);
     $u_info = get_user("*", $deal['user_id']);
     //可用额度
     $can_use_quota = get_can_use_quota($deal['user_id']);
     $root['can_use_quota'] = $can_use_quota;
     $credit_file = get_user_credit_file($deal['user_id']);
     $deal['is_faved'] = 0;
     $user_statics = sys_user_status($deal['user_id'], true);
     $root['user_statics'] = $user_statics;
     //借款笔数
     $root['load_list'] = $load_list;
     $root['credit_file'] = $credit_file;
     $root['u_info'] = $u_info;
     //工作认证是否过期
     $root['expire'] = user_info_expire($u_info);
     //留言
     $message_list = $GLOBALS['db']->getAll("SELECT a.title,a.content,a.create_time,a.rel_id,a.user_id,a.is_effect,b.user_name FROM " . DB_PREFIX . "message as a left join " . DB_PREFIX . "user as b on  a.user_id = b.id WHERE a.rel_id = " . $id);
     $root['message'] = $message_list;
     //seo
     if ($deal['type_match_row']) {
         $seo_title = $deal['seo_title'] != '' ? $deal['seo_title'] : $deal['type_match_row'] . " - " . $deal['name'];
     } else {
         $seo_title = $deal['seo_title'] != '' ? $deal['seo_title'] : $deal['name'];
     }
     $root['page_title'] = $seo_title;
     $seo_keyword = $deal['seo_keyword'] != '' ? $deal['seo_keyword'] : $deal['type_match_row'] . "," . $deal['name'];
     $root['page_keyword'] = $seo_keyword;
     $seo_description = $deal['seo_description'] != '' ? $deal['seo_description'] : $deal['name'];
     $root['seo_description'] = $seo_description;
     $root['program_title'] = "详细信息";
     output($root);
 }
示例#4
0
 public function creditswitch()
 {
     $info['title'] = "信用审核";
     $GLOBALS['tmpl']->assign("info", $info);
     $list = load_auto_cache("level");
     $GLOBALS['tmpl']->assign("list", $list['list']);
     foreach ($list["list"] as $k => $v) {
         if ($v['id'] == $GLOBALS['user_info']['level_id']) {
             $user_point_level = $v['name'];
         }
     }
     $GLOBALS['tmpl']->assign("user_point_level", $user_point_level);
     //可用额度
     $can_use_quota = get_can_use_quota($GLOBALS['user_info']['id']);
     $GLOBALS['tmpl']->assign('can_use_quota', $can_use_quota);
     $credit_file = get_user_credit_file($GLOBALS['user_info']['id'], $GLOBALS['user_info']);
     //必要信用认证
     $level_point['need_other_point'] = 0;
     $must_credit_count = 0;
     $other_credit_count = 0;
     foreach ($credit_file as $k => $v) {
         if ($v['passed'] == 1) {
             $level_point['need_other_point'] += (int) trim($v['point']);
         }
         if ($v['must'] == 1) {
             $must_credit_count++;
         } else {
             $other_credit_count++;
         }
     }
     $GLOBALS['tmpl']->assign('credit_file', $credit_file);
     $GLOBALS['tmpl']->assign("must_credit_count", $must_credit_count);
     $GLOBALS['tmpl']->assign("other_credit_count", $other_credit_count);
     //还清
     $level_point['repay_success'] = $GLOBALS['db']->getRow("SELECT sum(point) as total_point,count(*) AS total_count FROM " . DB_PREFIX . "user_log WHERE log_info like '%还清借款%' AND user_id=" . $GLOBALS['user_info']['id']);
     //逾期
     $level_point['impose_repay'] = $GLOBALS['db']->getRow("SELECT sum(point) as total_point,count(*) AS total_count FROM " . DB_PREFIX . "user_log WHERE log_info like '%逾期还款%' and log_info not like '%严重逾期还款%' AND user_id=" . $GLOBALS['user_info']['id']);
     //严重逾期
     $level_point['yz_impose_repay'] = $GLOBALS['db']->getRow("SELECT sum(point) as total_point,count(*) AS total_count FROM " . DB_PREFIX . "user_log WHERE log_info like '%严重逾期还款%' AND user_id=" . $GLOBALS['user_info']['id']);
     $GLOBALS['tmpl']->assign('level_point', $level_point);
     $seo_title = $info['seo_title'] != '' ? $info['seo_title'] : $info['title'];
     $GLOBALS['tmpl']->assign("page_title", $seo_title);
     $seo_keyword = $info['seo_keyword'] != '' ? $info['seo_keyword'] : $info['title'];
     $GLOBALS['tmpl']->assign("page_keyword", $seo_keyword . ",");
     $seo_description = $info['seo_description'] != '' ? $info['seo_description'] : $info['title'];
     $GLOBALS['tmpl']->assign("page_description", $seo_description . ",");
     $GLOBALS['tmpl']->display("page/borrow_creditswitch.html");
 }
 function preview()
 {
     $deal['id'] = 'XXX';
     $deal_loan_type_list = load_auto_cache("deal_loan_type_list");
     if (intval($_REQUEST['quota']) == 1) {
         $deal = $GLOBALS['db']->getRow("SELECT * FROM " . DB_PREFIX . "deal_quota_submit WHERE status=1 and user_id = " . $GLOBALS['user_info']['id'] . " ORDER BY id DESC");
         $type_id = intval($deal['type_id']);
         $deal['rate_foramt'] = number_format($deal['rate'], 2);
         $data['view_info'] = unserialize($deal['view_info']);
         if ($deal['cate_id'] > 0) {
             $deal['cate_info'] = $GLOBALS['db']->getRowCached("select id,name,brief,uname,icon from " . DB_PREFIX . "deal_cate where id = " . $deal['cate_id'] . " and is_effect = 1 and is_delete = 0");
         }
         $deal['repay_time'] = strim($_REQUEST['repay_time']);
         $deal['repay_time_type'] = 1;
     } else {
         $deal['name'] = strim($_REQUEST['borrowtitle']);
         $type_id = intval($_REQUEST['borrowtype']);
         $deal['repay_time_type'] = intval($_REQUEST['repaytime_type']);
         $deal['rate_foramt'] = number_format(strim($_REQUEST['apr']), 2);
         $deal['repay_time'] = strim($_REQUEST['repaytime']);
         $icon_type = strim($_REQUEST['imgtype']);
         $icon_type_arr = array('upload' => 1, 'userImg' => 2, 'systemImg' => 3);
         $data['icon_type'] = $icon_type_arr[$icon_type];
         switch ($data['icon_type']) {
             case 1:
                 $deal['icon'] = replace_public(strim($_REQUEST['icon']));
                 break;
             case 2:
                 $deal['icon'] = replace_public(get_user_avatar($GLOBALS['user_info']['id'], 'big'));
                 break;
             case 3:
                 $deal['icon'] = $GLOBALS['db']->getOneCached("SELECT icon FROM " . DB_PREFIX . "deal_loan_type WHERE id=" . intval($_REQUEST['systemimgpath']));
         }
         $deal['description'] = replace_public(valid_str(bstrim($_REQUEST['borrowdesc'])));
         $user_view_info = $GLOBALS['user_info']['view_info'];
         $user_view_info = unserialize($user_view_info);
         $new_view_info_arr = array();
         for ($i = 1; $i <= intval($_REQUEST['file_upload_count']); $i++) {
             $img_info = array();
             $img = replace_public(strim($_REQUEST['file_' . $i]));
             if ($img != "") {
                 $img_info['name'] = strim($_REQUEST['file_name_' . $i]);
                 $img_info['img'] = $img;
                 $img_info['is_user'] = 1;
                 $user_view_info[] = $img_info;
                 $ss = $user_view_info;
                 end($ss);
                 $key = key($ss);
                 $new_view_info_arr[$key] = $img_info;
             }
         }
         $data['view_info'] = array();
         foreach ($_REQUEST['file_key'] as $k => $v) {
             if (isset($user_view_info[$v])) {
                 $data['view_info'][$v] = $user_view_info[$v];
             }
         }
         foreach ($new_view_info_arr as $k => $v) {
             $data['view_info'][$k] = $v;
         }
         if ($deal['cate_id'] > 0) {
             $deal['cate_info']['name'] = "借款预览标";
         }
     }
     $deal['borrow_amount'] = strim($_REQUEST['borrowamount']);
     $deal['borrow_amount_format'] = format_price($deal['borrow_amount'] / 10000) . "万";
     $GLOBALS['tmpl']->assign('view_info_list', $data['view_info']);
     unset($data['view_info']);
     foreach ($deal_loan_type_list as $k => $v) {
         if ($v['id'] == $type_id) {
             $deal['type_info'] = $v;
         }
     }
     $deal['min_loan_money'] = 50;
     $deal['need_money'] = $deal['borrow_amount_format'];
     //本息还款金额
     $deal['month_repay_money'] = format_price(pl_it_formula($deal['borrow_amount'], strim($deal['rate']) / 12 / 100, $deal['repay_time']));
     if ($deal['agency_id'] > 0) {
         $deal['agency_info'] = $GLOBALS['db']->getRowCached("select * from " . DB_PREFIX . "deal_agency where id = " . $deal['agency_id'] . " and is_effect = 1");
     }
     $deal['progress_point'] = 0;
     $deal['buy_count'] = 0;
     $deal['voffice'] = 1;
     $deal['vjobtype'] = 1;
     $deal['is_delete'] = 2;
     $u_info = get_user("*", $GLOBALS['user_info']['id']);
     $GLOBALS['tmpl']->assign("u_info", $u_info);
     $can_use_quota = get_can_use_quota($GLOBALS['user_info']['id']);
     $GLOBALS['tmpl']->assign('can_use_quota', $can_use_quota);
     $credit_file = get_user_credit_file($GLOBALS['user_info']['id'], $u_info);
     $GLOBALS['tmpl']->assign("credit_file", $credit_file);
     $user_statics = sys_user_status($GLOBALS['user_info']['id'], true);
     $GLOBALS['tmpl']->assign("user_statics", $user_statics);
     $seo_title = $deal['seo_title'] != '' ? $deal['seo_title'] : $deal['type_match_row'] . " - " . $deal['name'];
     $GLOBALS['tmpl']->assign("page_title", $seo_title);
     $seo_keyword = $deal['seo_keyword'] != '' ? $deal['seo_keyword'] : $deal['type_match_row'] . "," . $deal['name'];
     $GLOBALS['tmpl']->assign("page_keyword", $seo_keyword . ",");
     $seo_description = $deal['seo_description'] != '' ? $deal['seo_description'] : $deal['name'];
     $GLOBALS['tmpl']->assign("seo_description", $seo_description . ",");
     $GLOBALS['tmpl']->assign("deal", $deal);
     $GLOBALS['tmpl']->display("page/deal.html");
 }
 public function detail()
 {
     /*if(!$GLOBALS['user_info']){
     			
     			app_redirect(url("index","user#login")); 
     		}*/
     set_gopreview();
     $id = intval($_REQUEST['id']);
     $deal_id = $GLOBALS['db']->getOne("SELECT deal_id FROM " . DB_PREFIX . "deal_load_transfer WHERE id=" . $id);
     if ($deal_id == 0) {
         echo "不存在的债权";
         die;
     }
     $deal = get_deal($deal_id);
     syn_transfer_status($id);
     $deal['yq_count'] = $GLOBALS['db']->getOne("SELECT count(*) FROM " . DB_PREFIX . "deal_repay WHERE has_repay = 1 and deal_id=" . $deal_id . " AND status >= 2");
     $GLOBALS['tmpl']->assign('deal', $deal);
     //借款列表
     $load_list = $GLOBALS['db']->getAll("SELECT deal_id,user_id,user_name,money,is_auto,create_time FROM " . DB_PREFIX . "deal_load WHERE deal_id = " . $deal_id);
     $u_info = get_user("*", $deal['user_id']);
     if ($deal['view_info'] != "") {
         $view_info_list = unserialize($deal['view_info']);
         $GLOBALS['tmpl']->assign('view_info_list', $view_info_list);
     }
     //可用额度
     $can_use_quota = get_can_use_quota($deal['user_id']);
     $GLOBALS['tmpl']->assign('can_use_quota', $can_use_quota);
     $credit_file = get_user_credit_file($deal['user_id']);
     $deal['is_faved'] = 0;
     if ($GLOBALS['user_info']) {
         if ($u_info['user_type'] == 1) {
             $company = $GLOBALS['db']->getRowCached("SELECT * FROM " . DB_PREFIX . "user_company WHERE user_id=" . $u_info['id']);
         }
         if ($deal['deal_status'] >= 4) {
             //还款列表
             $loan_repay_list = get_deal_load_list($deal);
             $GLOBALS['tmpl']->assign("loan_repay_list", $loan_repay_list);
             if ($loan_repay_list) {
                 $temp_self_money_list = $GLOBALS['db']->getAllCached("SELECT sum(self_money) as total_money,u_key FROM " . DB_PREFIX . "deal_load_repay WHERE has_repay=1 AND deal_id=" . $id . " group by u_key ");
                 $self_money_list = array();
                 foreach ($temp_self_money_list as $k => $v) {
                     $self_money_list[$v['u_key']] = $v['total_money'];
                 }
                 foreach ($load_list as $k => $v) {
                     $load_list[$k]['remain_money'] = $v['money'] - $self_money_list[$k];
                     if ($load_list[$k]['remain_money'] <= 0) {
                         $load_list[$k]['remain_money'] = 0;
                         $load_list[$k]['status'] = 1;
                     }
                 }
             }
         }
         $user_statics = sys_user_status($deal['user_id'], true);
         $GLOBALS['tmpl']->assign("user_statics", $user_statics);
         $GLOBALS['tmpl']->assign("company", $company);
     }
     $GLOBALS['tmpl']->assign("load_list", $load_list);
     $GLOBALS['tmpl']->assign("credit_file", $credit_file);
     $GLOBALS['tmpl']->assign("u_info", $u_info);
     //工作认证是否过期
     $GLOBALS['tmpl']->assign('expire', user_info_expire($u_info));
     //留言
     require APP_ROOT_PATH . 'app/Lib/message.php';
     require APP_ROOT_PATH . 'app/Lib/page.php';
     $rel_table = 'transfer';
     $message_type = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "message_type where type_name='" . $rel_table . "'");
     $condition = "rel_table = '" . $rel_table . "' and rel_id = " . $id;
     if (app_conf("USER_MESSAGE_AUTO_EFFECT") == 0) {
         $condition .= " and user_id = " . intval($GLOBALS['user_info']['id']);
     } else {
         if ($message_type['is_effect'] == 0) {
             $condition .= " and user_id = " . intval($GLOBALS['user_info']['id']);
         }
     }
     //message_form 变量输出
     $GLOBALS['tmpl']->assign('rel_id', $id);
     $GLOBALS['tmpl']->assign('rel_table', $rel_table);
     //分页
     $page = intval($_REQUEST['p']);
     if ($page == 0) {
         $page = 1;
     }
     $limit = ($page - 1) * app_conf("PAGE_SIZE") . "," . app_conf("PAGE_SIZE");
     $msg_condition = $condition . " AND is_effect = 1 ";
     $message = get_message_list($limit, $msg_condition);
     $page = new Page($message['count'], app_conf("PAGE_SIZE"));
     //初始化分页对象
     $p = $page->show();
     $GLOBALS['tmpl']->assign('pages', $p);
     foreach ($message['list'] as $k => $v) {
         $msg_sub = get_message_list("", "pid=" . $v['id'], false);
         $message['list'][$k]["sub"] = $msg_sub["list"];
     }
     $GLOBALS['tmpl']->assign("message_list", $message['list']);
     //==================================================
     $condition = ' AND dlt.id=' . $id . ' AND d.deal_status >= 4 and d.is_effect=1 and d.is_delete=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 ";
     $transfer = get_transfer($union_sql, $condition);
     $GLOBALS['tmpl']->assign('transfer', $transfer);
     if ($deal['type_match_row']) {
         $seo_title = $deal['seo_title'] != '' ? $deal['seo_title'] : $deal['type_match_row'] . " - " . $deal['name'];
     } else {
         $seo_title = $deal['seo_title'] != '' ? $deal['seo_title'] : $deal['name'];
     }
     $GLOBALS['tmpl']->assign("page_title", $GLOBALS['lang']['TRANSFER'] . " - " . $seo_title);
     $seo_keyword = $deal['seo_keyword'] != '' ? $deal['seo_keyword'] : $deal['type_match_row'] . "," . $deal['name'];
     $GLOBALS['tmpl']->assign("page_keyword", $GLOBALS['lang']['TRANSFER'] . "," . $seo_keyword . ",");
     $seo_description = $deal['seo_description'] != '' ? $deal['seo_description'] : $deal['name'];
     $GLOBALS['tmpl']->assign("seo_description", $GLOBALS['lang']['TRANSFER'] . "," . $seo_description . ",");
     $GLOBALS['tmpl']->assign("deal", $deal);
     $GLOBALS['tmpl']->display("page/transfer.html");
 }
示例#7
0
 public function level()
 {
     $GLOBALS['tmpl']->caching = true;
     $GLOBALS['tmpl']->cache_lifetime = 600;
     $cache_id = md5(MODULE_NAME . ACTION_NAME . trim($_REQUEST['id']));
     if (!$GLOBALS['tmpl']->is_cached('page/space_credit.html', $cache_id)) {
         $this->init();
         $title = sprintf($GLOBALS['lang']['WHOS_SPACE'], $this->space_user['user_name']);
         $site_nav[] = array('name' => $GLOBALS['lang']['HOME_PAGE'], 'url' => APP_ROOT . "/");
         $site_nav[] = array('name' => $title, 'url' => url("index", "space#deal", array("id" => $this->space_user['id'])));
         $site_nav[] = array('name' => $GLOBALS['lang']['SPACE_DEAL'], 'url' => url("index", "space#deal", array("id" => $this->space_user['id'])));
         $GLOBALS['tmpl']->assign("site_nav", $site_nav);
         $list = load_auto_cache("level");
         $GLOBALS['tmpl']->assign("list", $list['list']);
         foreach ($list["list"] as $k => $v) {
             if ($v['id'] == $this->space_user['level_id']) {
                 $user_point_level = $v['name'];
             }
         }
         $GLOBALS['tmpl']->assign("user_point_level", $user_point_level);
         $credit_file = get_user_credit_file($GLOBALS['user_info']['id'], $this->space_user);
         //必要信用认证
         $level_point['need_other_point'] = 0;
         $must_credit_count = 0;
         $other_credit_count = 0;
         foreach ($credit_file as $k => $v) {
             if ($v['passed'] == 1) {
                 $level_point['need_other_point'] += (int) trim($v['point']);
             }
             if ($v['must'] == 1) {
                 $must_credit_count++;
             } else {
                 $other_credit_count++;
             }
         }
         //工作认证是否过期
         $GLOBALS['tmpl']->assign('expire', $this->space_user);
         //还清
         $level_point['repay_success'] = $GLOBALS['db']->getRow("SELECT sum(point) as total_point,count(*) AS total_count FROM " . DB_PREFIX . "user_log WHERE log_info like '%还清借款%' AND user_id=" . $this->space_user['id']);
         //逾期
         $level_point['impose_repay'] = $GLOBALS['db']->getRow("SELECT sum(point) as total_point,count(*) AS total_count FROM " . DB_PREFIX . "user_log WHERE log_info like '%逾期还款%' and log_info not like '%严重逾期还款%' AND user_id=" . $this->space_user['id']);
         //严重逾期
         $level_point['yz_impose_repay'] = $GLOBALS['db']->getRow("SELECT sum(point) as total_point,count(*) AS total_count FROM " . DB_PREFIX . "user_log WHERE log_info like '%严重逾期还款%' AND user_id=" . $this->space_user['id']);
         $GLOBALS['tmpl']->assign('level_point', $level_point);
         $GLOBALS['tmpl']->assign("credit_file", $credit_file);
         $GLOBALS['tmpl']->assign("must_credit_count", $must_credit_count);
         $GLOBALS['tmpl']->assign("other_credit_count", $other_credit_count);
         //可用额度
         $can_use_quota = get_can_use_quota($this->space_user['id']);
         $GLOBALS['tmpl']->assign('can_use_quota', $can_use_quota);
         $GLOBALS['tmpl']->assign("page_title", $title);
         $GLOBALS['tmpl']->assign("page_keyword", $title . ",");
         $GLOBALS['tmpl']->assign("page_description", $title . ",");
     }
     $GLOBALS['tmpl']->display("page/space_credit.html", $cache_id);
 }
 function savedebit()
 {
     $view["type"] = intval($_REQUEST["type"]);
     $view["debit_money"] = strim($_REQUEST["debit_money"]);
     $view["repay_time"] = intval($_REQUEST["repaytime"]);
     $view["university"] = strim($_REQUEST["university"]);
     $view["address"] = strim($_REQUEST["address"]);
     $view["mobile"] = strim($_REQUEST["mobile"]);
     $is_ajax = intval($_REQUEST["is_ajax"]);
     if (strim($GLOBALS["user_info"]["u_alipay"]) == "") {
         showErr("请先绑定支付宝", $is_ajax);
     }
     if ($view["university"] == "") {
         showErr("请填写学校信息", $is_ajax);
     }
     if ($view["address"] == "") {
         showErr("请填写地址", $is_ajax);
     }
     if ($view["mobile"] == "") {
         showErr("请填写联系电话", $is_ajax);
     }
     if ($view["type"] == "" || $view["debit_money"] == "" || $view["repay_time"] == "") {
         showErr("请返回重新提交", $is_ajax);
     }
     $is_ajax = intval($_REQUEST['is_ajax']);
     if (!$GLOBALS['user_info']) {
         showErr($GLOBALS['lang']['PLEASE_LOGIN_FIRST'], $is_ajax);
     }
     $t = trim($_REQUEST['t']);
     if (!in_array($t, array("save", "publish"))) {
         showErr($GLOBALS['lang']['ERROR_TITLE'], $is_ajax);
     }
     /*读取白条配置*/
     $debit_conf = $GLOBALS["db"]->getRow("select * from " . DB_PREFIX . "debit_conf");
     /*读取标类别作为商品名*/
     $view["deal_loan_type"] = $GLOBALS["db"]->getOne("select name from " . DB_PREFIX . "deal_loan_type");
     if ($t == "save") {
         $data['is_delete'] = 2;
     } else {
         $data['is_delete'] = 0;
     }
     $data['name'] = $view["deal_loan_type"] . $view["debit_money"] . "元";
     if (empty($data['name'])) {
         showErr("请输入借款标题", $is_ajax);
     }
     $data['publish_wait'] = 1;
     $icon_type = "systemImg";
     if ($icon_type == "") {
         showErr("请选择借款图片类型", $is_ajax);
     }
     $icon_type_arr = array('upload' => 1, 'userImg' => 2, 'systemImg' => 3);
     $data['icon_type'] = $icon_type_arr[$icon_type];
     if (intval($data['icon_type']) == 0) {
         showErr("请选择借款图片类型", $is_ajax);
     }
     $_REQUEST['systemimgpath'] = $view["type"];
     switch ($data['icon_type']) {
         case 1:
             if (strim($_REQUEST['icon']) == '') {
                 showErr("请上传图片", $is_ajax);
             } else {
                 $data['icon'] = replace_public(strim($_REQUEST['icon']));
             }
             break;
         case 2:
             $data['icon'] = replace_public(get_user_avatar($GLOBALS['user_info']['id'], 'big'));
             break;
         case 3:
             if (intval($_REQUEST['systemimgpath']) == 0) {
                 showErr("请选择系统图片", $is_ajax);
             } else {
                 $data['icon'] = $GLOBALS['db']->getOne("SELECT icon FROM " . DB_PREFIX . "deal_loan_type WHERE id=" . intval($_REQUEST['systemimgpath']));
             }
             break;
     }
     //$data['cate_id'] = $data['type_id'] = intval($view["type"]);
     $data['type_id'] = intval($view["type"]);
     if ($data['type_id'] == 0) {
         showErr("请选择借款用途", $is_ajax);
     }
     $data['borrow_amount'] = floatval($view["debit_money"]);
     /*if($data['borrow_amount'] < (int)trim(app_conf('MIN_BORROW_QUOTA')) || $data['borrow_amount'] > (int)trim(app_conf('MAX_BORROW_QUOTA')) || $data['borrow_amount'] %50 != 0){
      		showErr("请正确选择借款金额",$is_ajax);
      	}*/
     //判断是否需要额度
     if ($GLOBALS['db']->getOne("SELECT is_quota FROM " . DB_PREFIX . "deal_loan_type WHERE id=" . $data['type_id']) == 1) {
         if (intval($GLOBALS['user_info']['quota']) != 0) {
             $can_use_quota = get_can_use_quota($GLOBALS['user_info']['id']);
             if ($data['borrow_amount'] > intval($can_use_quota)) {
                 showErr("输入借款的借款金额超过您的可用额度<br>您当前可用额度为:" . $can_use_quota, $is_ajax);
             }
         }
     }
     $data['repay_time'] = intval($_REQUEST['repaytime']);
     if ($data['repay_time'] == 0) {
         showErr("借款期限", $is_ajax);
     }
     $data['rate'] = floatval($view["rate"]);
     //
     $data['repay_time_type'] = 1;
     //按月
     $min_rate = 0;
     $max_rate = 0;
     $is_rate_lock = false;
     $level_list = load_auto_cache("level");
     $level_list_info = reset($level_list["repaytime_list"]);
     foreach ($level_list_info as $k => $v) {
         if ($v[1] != 0 && $v[0] == $view["repay_time"]) {
             $min_rate = $v[2];
             $max_rate = $v[3];
             break;
         }
     }
     if ($debit_conf["rate_cfg"] == 0) {
         $data["rate"] = $min_rate;
     } elseif ($debit_conf["rate_cfg"] == 1) {
         $data["rate"] = floatval(($min_rate + $max_rate) / 2);
     } elseif ($debit_conf["rate_cfg"] == 2) {
         $data["rate"] = $max_rate;
     }
     if (floatval($data['rate']) <= 0 || floatval($data['rate']) > $max_rate || floatval($data['rate']) < $min_rate) {
         showErr("请正确输入借款利率", $is_ajax);
     }
     $data['enddate'] = intval($debit_conf['enddate']);
     //筹标期限
     $data['description'] = $GLOBALS["user_info"]["user_name"] . "的白条:" . $view["deal_loan_type"] . $view["debit_money"] . "元";
     if (trim($data['description']) == '') {
         showErr("请输入项目描述", $is_ajax);
     }
     $datas["university"] = $view["university"];
     $datas["address"] = $view["address"];
     $datas["mobile"] = $view["mobile"];
     //$datas['view_info'] = serialize($user_view_info);
     $GLOBALS['db']->autoExecute(DB_PREFIX . "user", $datas, "UPDATE", "id=" . $GLOBALS['user_info']['id']);
     $data["services_fee"] = $debit_conf["services_fee"];
     $data["manage_fee"] = $debit_conf["manage_fee"];
     $data["manage_impose_fee_day1"] = $debit_conf["manage_impose_fee_day1"];
     $data["manage_impose_fee_day2"] = $debit_conf["manage_impose_fee_day2"];
     $data["impose_fee_day1"] = $debit_conf["impose_fee_day1"];
     $data["impose_fee_day2"] = $debit_conf["impose_fee_day2"];
     $data['voffice'] = 1;
     $data['vposition'] = 1;
     $data['is_effect'] = 1;
     $data['deal_status'] = 0;
     $data['agency_id'] = 0;
     //担保机构
     $data['agency_status'] = 1;
     $data['warrant'] = 0;
     //担保类型
     $data['guarantor_margin_amt'] = 0;
     //担保保证金
     $data['guarantor_pro_fit_amt'] = 0;
     //担保收益
     $data['user_id'] = intval($GLOBALS['user_info']['id']);
     $data['loantype'] = intval($view['loantype']);
     if ($data['repay_time_type'] == 0) {
         $data['loantype'] = 2;
     }
     //当为天的时候
     if ($data['repay_time_type'] == 0) {
         $true_repay_time = 1;
     } else {
         $true_repay_time = $data['repay_time'];
     }
     //本金担保
     if ($data['warrant'] == 1) {
         $data['guarantor_amt'] = $data['borrow_amount'];
     } elseif ($data['warrant'] == 2) {
         //等额本息
         if ($data['loantype'] == 0) {
             $data['guarantor_amt'] = pl_it_formula($data['borrow_amount'], $data['rate'] / 12 / 100, $true_repay_time) * $true_repay_time;
         }
     }
     $data['is_hidden'] = 1;
     $data['create_time'] = TIME_UTC;
     //推荐人
     $work_id = strim($_REQUEST["work_id"]);
     if ($work_id) {
         $data["admin_id"] = $GLOBALS['db']->getOne("select id from " . DB_PREFIX . "admin where work_id = '" . $work_id . "'");
     }
     $module = "INSERT";
     $jumpurl = url("debit", "debit_uc_center#order");
     $condition = "";
     $deal_id = $GLOBALS['db']->getOne("SELECT id FROM " . DB_PREFIX . "deal WHERE ((is_delete=2 or is_delete=3) or (is_delete=0 and publish_wait=1)) AND user_id=" . $GLOBALS['user_info']['id']);
     if ($deal_id > 0) {
         $module = "UPDATE";
         if ($t == "save") {
             $jumpurl = url("debit", "debit_uc_center#order");
         }
         $condition = "id = {$deal_id}";
     } else {
         if ($t == "save") {
             $jumpurl = url("debit", "debit_uc_center#order");
         }
     }
     $GLOBALS['db']->autoExecute(DB_PREFIX . "deal", $data, $module, $condition);
     if ($module == "INSERT") {
         $deal_id = $GLOBALS['db']->insert_id();
     }
     require_once APP_ROOT_PATH . 'app/Lib/deal.php';
     $deal = get_deal($deal_id);
     //发送验证通知
     if ($t != "save" && trim(app_conf('CUSTOM_SERVICE')) != '' && ($GLOBALS['user_info']['idcardpassed'] == 0 || $GLOBALS['user_info']['incomepassed'] == 0 || $GLOBALS['user_info']['creditpassed'] == 0 || $GLOBALS['user_info']['workpassed'] == 0)) {
         $ulist = explode(",", trim(app_conf('CUSTOM_SERVICE')));
         $ulist = array_filter($ulist);
         if ($ulist) {
             $uuid = $ulist[array_rand($ulist)];
             if ($uuid > 0) {
                 $content = app_conf("SHOP_TITLE") . "用户您好,请尽快上传必要信用认证材料(包括身份证认证、工作认证、收入认证、信用报告认证)。另外,多上传一些可选信用认证,有助于您提高借款额度,也有利于出借人更多的了解您的情况,以便让您更快的筹集到所需的资金。请您点击'我要贷款',之后点击相应的审核项目,进入后,可先阅读该项信用认证所需材料及要求,然后按要求上传资料即可。 如果您有任何问题请您拨打客服电话 " . app_conf('SHOP_TEL') . " 或给客服邮箱发邮件 " . app_conf("REPLY_ADDRESS") . " 我们会及时给您回复。";
                 require_once APP_ROOT_PATH . 'app/Lib/message.php';
                 //添加留言
                 $message['title'] = $content;
                 $message['content'] = htmlspecialchars(addslashes(valid_str($content)));
                 $message['title'] = valid_str($message['title']);
                 $message['create_time'] = TIME_UTC;
                 $message['rel_table'] = "deal";
                 $message['rel_id'] = $deal_id;
                 $message['user_id'] = $uuid;
                 $message['is_effect'] = 1;
                 $GLOBALS['db']->autoExecute(DB_PREFIX . "message", $message);
                 //添加到动态
                 insert_topic("message", $message['rel_id'], $message['user_id'], get_user_name($message['user_id'], false), $GLOBALS['user_info']['id']);
                 //自己给自己留言不执行操作
                 if ($deal['user_id'] != $message['user_id']) {
                     $msg_conf = get_user_msg_conf($deal['user_id']);
                     //站内信
                     if ($msg_conf['sms_asked'] == 1) {
                         $notices['shop_title'] = app_conf("SHOP_TITLE");
                         $notices['shop_tel'] = app_conf('SHOP_TEL');
                         $notices['shop_address'] = app_conf("REPLY_ADDRESS");
                         /*{$notice.shop_title}用户您好,请尽快上传必要信用认证材料(包括身份证认证、工作认证、收入认证、信用报告认证)。另外,多上传一些可选信用认证,有助于您提高借款额度,也有利于出借人更多的了解您的情况,以便让您更快的筹集到所需的资金。请您点击'我要贷款',之后点击相应的审核项目,进入后,可先阅读该项信用认证所需材料及要求,然后按要求上传资料即可。 如果您有任何问题请您拨打客服电话{$notice.shop_tel}或给客服邮箱发邮件{$notice.shop_address}我们会及时给您回复。*/
                         $notices['url'] = "“<a href=\"" . $deal_info['url'] . "\">" . $deal_info['name'] . "</a>”";
                         $notices['user_name'] = get_user_name($message['user_id']);
                         $notices['money'] = $user_load_data['true_repay_money'] + $user_load_data['impose_money'];
                         $tmpl_content = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "msg_template where name = 'TPL_WORDS_MSG'", false);
                         $GLOBALS['tmpl']->assign("notice", $notices);
                         $contents = $GLOBALS['tmpl']->fetch("str:" . $tmpl_content['content']);
                         send_user_msg("", $contents, 0, $deal['user_id'], TIME_UTC, 0, true, 13, $message['rel_id']);
                     }
                     //邮件
                     if ($msg_conf['mail_asked'] == 1 && app_conf('MAIL_ON') == 1) {
                         $tmpl = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "msg_template where name = 'TPL_MAIL_DEAL_MSG'");
                         $tmpl_content = $tmpl['content'];
                         $notice['user_name'] = $GLOBALS['user_info']['user_name'];
                         $notice['msg_user_name'] = get_user_name($message['user_id'], false);
                         $notice['deal_name'] = $deal['name'];
                         $notice['deal_url'] = SITE_DOMAIN . url("index", "deal", array("id" => $deal['id']));
                         $notice['message'] = $message['content'];
                         $notice['site_name'] = app_conf("SHOP_TITLE");
                         $notice['site_url'] = SITE_DOMAIN . APP_ROOT;
                         $notice['help_url'] = SITE_DOMAIN . url("index", "helpcenter");
                         $GLOBALS['tmpl']->assign("notice", $notice);
                         $msg = $GLOBALS['tmpl']->fetch("str:" . $tmpl_content);
                         $msg_data['dest'] = $GLOBALS['user_info']['email'];
                         $msg_data['send_type'] = 1;
                         $msg_data['title'] = get_user_name($message['user_id'], false) . "给您的标留言!";
                         $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'] = $GLOBALS['user_info']['id'];
                         $msg_data['is_html'] = $tmpl['is_html'];
                         $GLOBALS['db']->autoExecute(DB_PREFIX . "deal_msg_list", $msg_data);
                         //插入
                     }
                 }
             }
         }
     }
     if ($is_ajax == 1) {
         showSuccess("提交成功,请等待管理员审核", $is_ajax, $jumpurl);
     } else {
         app_redirect($jumpurl);
     }
 }
 public function index()
 {
     $root = array();
     //set_gopreview();
     $deal_id = intval($GLOBALS['request']['id']);
     $root['deal_id'] = $deal_id;
     if ($deal_id == 0) {
         echo "不存在的债权";
         die;
     }
     $deal = get_deal($deal_id);
     //syn_transfer_status($id);
     $deal['yq_count'] = $GLOBALS['db']->getOne("SELECT count(*) FROM " . DB_PREFIX . "deal_repay WHERE has_repay = 1 and deal_id=" . $deal_id . " AND status >= 2");
     $root['deal'] = $deal;
     //借款列表
     $load_list = $GLOBALS['db']->getAll("SELECT deal_id,user_id,user_name,money,is_auto,create_time FROM " . DB_PREFIX . "deal_load WHERE deal_id = " . $deal_id);
     $u_info = get_user("*", $deal['user_id']);
     //可用额度
     $can_use_quota = get_can_use_quota($deal['user_id']);
     $root['can_use_quota'] = $can_use_quota;
     $credit_file = get_user_credit_file($deal['user_id']);
     $deal['is_faved'] = 0;
     $user_statics = sys_user_status($deal['user_id'], true);
     $root['user_statics'] = $user_statics;
     $root['load_list'] = $load_list;
     $root['credit_file'] = $credit_file;
     $root['u_info'] = $u_info;
     //工作认证是否过期
     $root['expire'] = user_info_expire($u_info);
     //留言
     $message_list = $GLOBALS['db']->getAll("SELECT title,content,a.create_time,rel_id,a.user_id,a.is_effect,b.user_name FROM " . DB_PREFIX . "message as a left join " . DB_PREFIX . "user as b on  a.user_id = b.id WHERE rel_id = " . $id);
     $root['message'] = $message_list;
     /*
     //分页
     $page = intval($_REQUEST['p']);
     if($page==0)
     	$page = 1;
     $limit = (($page-1)*app_conf("PAGE_SIZE")).",".app_conf("PAGE_SIZE");
     $msg_condition = $condition." AND is_effect = 1 ";
     $message = get_message_list($limit,$msg_condition);
     $page = new Page($message['count'],app_conf("PAGE_SIZE"));   //初始化分页对象
     $p  =  $page->show();
     $root['pages']= $p;
     */
     foreach ($message['list'] as $k => $v) {
         $msg_sub = get_message_list("", "pid=" . $v['id'], false);
         $message['list'][$k]["sub"] = $msg_sub["list"];
     }
     $root['message_list'] = $message['list'];
     $condition = ' AND dlt.id=' . $id . ' AND d.deal_status >= 4 and d.is_effect=1 and d.is_delete=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 ";
     $transfer = get_transfer($union_sql, $condition);
     $root['transfer'] = $transfer;
     if ($deal['type_match_row']) {
         $seo_title = $deal['seo_title'] != '' ? $deal['seo_title'] : $deal['type_match_row'] . " - " . $deal['name'];
     } else {
         $seo_title = $deal['seo_title'] != '' ? $deal['seo_title'] : $deal['name'];
     }
     $root['page_title'] = $seo_title;
     $seo_keyword = $deal['seo_keyword'] != '' ? $deal['seo_keyword'] : $deal['type_match_row'] . "," . $deal['name'];
     $root['page_keyword'] = $seo_keyword;
     $seo_description = $deal['seo_description'] != '' ? $deal['seo_description'] : $deal['name'];
     $root['seo_description'] = $seo_description;
     output($root);
 }