Ejemplo n.º 1
0
 private function getlist($mode = "index")
 {
     $result = getInvestList($mode, intval($GLOBALS['user_info']['id']), intval($_REQUEST['p']));
     $list = $result['list'];
     foreach ($list as $k => $v) {
         //当为天的时候
         if ($v['repay_time_type'] == 0) {
             $true_repay_time = 1;
         } else {
             $true_repay_time = $v['repay_time'];
         }
         //本息还款金额
         if ($v['loantype'] == 0) {
             $v['interest_amount'] = pl_it_formula($v['u_load_money'], $v['rate'] / 12 / 100, $true_repay_time) * $true_repay_time - $v['u_load_money'];
         } elseif ($v['loantype'] == 1) {
             $v['interest_amount'] = av_it_formula($v['u_load_money'], $v['rate'] / 12 / 100) * $true_repay_time - $v['u_load_money'];
         } elseif ($v['loantype'] == 2) {
             $v['interest_amount'] = $v['u_load_money'] * $v['rate'] / 12 / 100 * $true_repay_time - $v['u_load_money'];
         }
         $list[$k] = $v;
     }
     $count = $result['count'];
     $GLOBALS['tmpl']->assign("list", $list);
     $page = new Page($count, app_conf("PAGE_SIZE"));
     //初始化分页对象
     $p = $page->show();
     $GLOBALS['tmpl']->assign('pages', $p);
     $GLOBALS['tmpl']->assign("page_title", $GLOBALS['lang']['UC_INVEST']);
     $GLOBALS['tmpl']->assign("inc_file", "inc/uc/uc_invest.html");
     $GLOBALS['tmpl']->display("page/uc.html");
 }
Ejemplo n.º 2
0
 function savedeal()
 {
     $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);
     }
     if ($t == "save") {
         $data['is_delete'] = 2;
     } else {
         $data['is_delete'] = 0;
     }
     $data['name'] = strim($_REQUEST['borrowtitle']);
     if (empty($data['name'])) {
         showErr("请输入借款标题", $is_ajax);
     }
     $data['publish_wait'] = 1;
     $icon_type = strim($_REQUEST['imgtype']);
     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);
     }
     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['type_id'] = intval($_REQUEST['borrowtype']);
     if ($data['type_id'] == 0) {
         showErr("请选择借款用途", $is_ajax);
     }
     $data['borrow_amount'] = floatval($_REQUEST['borrowamount']);
     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($_REQUEST['apr']);
     $data['repay_time_type'] = intval($_REQUEST['repaytime_type']);
     $level_list = load_auto_cache("level");
     $min_rate = 0;
     $max_rate = 0;
     $is_rate_lock = false;
     foreach ($level_list['repaytime_list'][$GLOBALS['user_info']['level_id']] as $kkk => $vvv) {
         if ($data['repay_time_type'] == 1) {
             if ($data['repay_time'] == intval($vvv[0]) && $vvv[1] == $data['repay_time_type']) {
                 $min_rate = $vvv[2];
                 $max_rate = $vvv[3];
             }
         } else {
             if ($data['repay_time'] <= intval($vvv[0]) && intval($vvv[1]) == $data['repay_time_type'] && $is_rate_lock == false) {
                 $min_rate = $vvv[2];
                 $max_rate = $vvv[3];
                 $is_rate_lock = true;
             } elseif ($data['repay_time'] > intval($vvv[0]) && intval($vvv[1]) == $data['repay_time_type']) {
                 $min_rate = $vvv[2];
                 $max_rate = $vvv[3];
             }
         }
     }
     if (floatval($data['rate']) <= 0 || floatval($data['rate']) > $max_rate || floatval($data['rate']) < $min_rate) {
         showErr("请正确输入借款利率", $is_ajax);
     }
     $data['enddate'] = intval($_REQUEST['enddate']);
     $data['description'] = replace_public(btrim($_REQUEST['borrowdesc']));
     $data['description'] = valid_tag($data['description']);
     if (trim($data['description']) == '') {
         showErr("请输入项目描述", $is_ajax);
     }
     $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;
         }
     }
     $datas['view_info'] = serialize($user_view_info);
     $GLOBALS['db']->autoExecute(DB_PREFIX . "user", $datas, "UPDATE", "id=" . $GLOBALS['user_info']['id']);
     $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;
     }
     $data['view_info'] = serialize($data['view_info']);
     //资金运转
     $data['remark_1'] = strim(replace_public($_REQUEST['remark_1']));
     $data['remark_1'] = valid_tag($data['remark_1']);
     //风险控制措施
     $data['remark_2'] = strim(replace_public($_REQUEST['remark_2']));
     $data['remark_2'] = valid_tag($data['remark_2']);
     //政策及市场分析
     $data['remark_3'] = strim(replace_public($_REQUEST['remark_3']));
     $data['remark_3'] = valid_tag($data['remark_3']);
     //企业背景
     $data['remark_4'] = strim(replace_public($_REQUEST['remark_4']));
     $data['remark_4'] = valid_tag($data['remark_4']);
     //企业信息
     $data['remark_5'] = strim(replace_public($_REQUEST['remark_5']));
     $data['remark_5'] = valid_tag($data['remark_5']);
     //项目相关资料
     $data['remark_6'] = strim(replace_public($_REQUEST['remark_6']));
     $data['remark_6'] = valid_tag($data['remark_6']);
     //$data['voffice'] = intval($_REQUEST['voffice']);
     //$data['vposition'] = intval($_REQUEST['vposition']);
     $data['voffice'] = 1;
     $data['vposition'] = 1;
     $data['is_effect'] = 1;
     $data['deal_status'] = 0;
     $data['agency_id'] = intval($_REQUEST['agency_id']);
     $data['agency_status'] = 1;
     $data['warrant'] = intval($_REQUEST['warrant']);
     $data['guarantor_margin_amt'] = floatval($_REQUEST['guarantor_margin_amt']);
     $data['guarantor_pro_fit_amt'] = floatval($_REQUEST['guarantor_pro_fit_amt']);
     $data['user_id'] = intval($GLOBALS['user_info']['id']);
     $data['loantype'] = intval($_REQUEST['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;
         } elseif ($data['loantype'] == 1) {
             $data['guarantor_amt'] = av_it_formula($data['borrow_amount'], $data['rate'] / 12 / 100) * $true_repay_time + $data['borrow_amount'];
         } elseif ($data['loantype'] == 2) {
             $data['guarantor_amt'] = $data['borrow_amount'] * $data['rate'] / 12 / 100 * $true_repay_time + $data['borrow_amount'];
         }
     }
     $data['create_time'] = TIME_UTC;
     $module = "INSERT";
     $jumpurl = url("index", "borrow#steptwo");
     $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("index", "borrow#stepone");
         }
         $condition = "id = {$deal_id}";
     } else {
         if ($t == "save") {
             $jumpurl = url("index", "borrow#stepone");
         }
     }
     $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($GLOBALS['lang']['SUCCESS_TITLE'], $is_ajax, $jumpurl);
     } else {
         app_redirect($jumpurl);
     }
 }
Ejemplo n.º 3
0
 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");
 }
 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");
 }
Ejemplo n.º 5
0
 public function dcontract()
 {
     $id = intval($_REQUEST['id']);
     if ($id == 0) {
         showErr("操作失败!");
     }
     $deal = get_deal($id);
     if (!$deal) {
         showErr("操作失败!");
     }
     $load_user_id = $GLOBALS['db']->getOne("select user_id FROM " . DB_PREFIX . "deal_load WHERE deal_id=" . $id . " and user_id=" . $GLOBALS['user_info']['id'] . " ORDER BY create_time ASC");
     if ($load_user_id == 0 && $deal['user_id'] != $GLOBALS['user_info']['id']) {
         showErr("操作失败!");
     }
     if ($deal['agency_id'] > 0) {
         $agency = $GLOBALS['db']->getRow("select * FROM " . DB_PREFIX . "deal_agency WHERE id=" . $deal['agency_id'] . " ");
         $deal['agency_name'] = $agency['name'];
         $deal['agency_address'] = $agency['address'];
     }
     $GLOBALS['tmpl']->assign('deal', $deal);
     $loan_list = $GLOBALS['db']->getAll("select * FROM " . DB_PREFIX . "deal_load WHERE deal_id=" . $id . " ORDER BY create_time ASC");
     foreach ($loan_list as $k => $v) {
         if ($deal['loantype'] == 0) {
             $loan_list[$k]['get_repay_money'] = pl_it_formula($v['money'], $deal['rate'] / 12 / 100, $deal['repay_time']);
         } elseif ($deal['loantype'] == 1) {
             $loan_list[$k]['get_repay_money'] = av_it_formula($v['money'], $deal['rate'] / 12 / 100);
         } elseif ($deal['loantype'] == 2) {
             $loan_list[$k]['get_repay_money'] = $v['money'] * $deal['rate'] / 12 / 100 * $deal['repay_time'] + $v['money'];
         }
         if ($deal['repay_time_type'] == 0) {
             $loan_list[$k]['get_repay_money'] = $v['money'] * $deal['rate'] / 12 / 100 + $v['money'];
         }
     }
     $GLOBALS['tmpl']->assign('loan_list', $loan_list);
     $u_info = get_user("*", $deal['user_id']);
     $GLOBALS['tmpl']->assign('user_info', $u_info);
     if ($u_info['sealpassed'] == 1) {
         $credit_file = get_user_credit_file($deal['user_id']);
         $GLOBALS['tmpl']->assign('user_seal_url', $credit_file['credit_seal']['file_list'][0]);
     }
     if ($deal['agency_id'] > 0) {
         $contract = $GLOBALS['tmpl']->fetch("str:" . app_conf("CONTRACT_1"));
     } else {
         $contract = $GLOBALS['tmpl']->fetch("str:" . app_conf("CONTRACT_0"));
     }
     $GLOBALS['tmpl']->assign('contract', $contract);
     header("Content-type:text/html;charset=utf-8");
     header("Content-Disposition: attachment; filename=借款协议.html");
     echo "<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>";
     echo '<html>';
     echo '<head>';
     echo '<title>借款协议</title>';
     echo '<meta http-equiv="Content-Type" content="text/html; charset=utf-8">';
     echo '<meta http-equiv="X-UA-Compatible" content="IE=7" />';
     echo $GLOBALS['tmpl']->fetch("inc/uc/uc_deal_contract.html");
     echo '</body>';
     echo '</html>';
 }
Ejemplo n.º 6
0
function getInvestList($mode = "index", $user_id = 0, $page = 0, $user_name = '', $user_pwd = '')
{
    if ($user_id > 0) {
        $condtion = "   AND d.deal_status in(1,2,3,4,5)  ";
        switch ($mode) {
            case "index":
                $condtion = "   AND d.deal_status in(1,2,3,4,5)  ";
                break;
            case "invite":
                $condtion = "   AND d.deal_status in(1,2)  ";
                break;
            case "in":
                $condtion = "   AND d.deal_status =1  ";
                break;
            case "full":
                $condtion = "   AND d.deal_status =2  ";
                break;
            case "flow":
                $condtion = "   AND d.deal_status =3  ";
                break;
            case "ing":
                $condtion = "   AND d.deal_status =4  ";
                break;
            case "over":
                $condtion = "   AND d.deal_status =5  ";
                break;
            case "bad":
                $condtion = "   AND d.deal_status = 4 AND (" . TIME_UTC . " - d.last_repay_time)/24/3600 >=" . trim(app_conf("YZ_IMPSE_DAY")) . " and d.last_repay_time > 0 ";
                break;
        }
        if ($page == 0) {
            $page = 1;
        }
        $limit = ($page - 1) * app_conf("PAGE_SIZE") . "," . app_conf("PAGE_SIZE");
        //$sql = "select d.*,u.user_name,dl.money as u_load_money,u.level_id,u.province_id,u.city_id,dl.id as load_id from ".DB_PREFIX."deal d left join ".DB_PREFIX."deal_load as dl on d.id = dl.deal_id LEFT JOIN ".DB_PREFIX."user u ON u.id=d.user_id where dl.user_id = ".$user_id." $condtion group by dl.id order by dl.create_time desc limit ".$limit;
        //$sql_count = "select count(DISTINCT dl.id) from ".DB_PREFIX."deal d left join ".DB_PREFIX."deal_load as dl on d.id = dl.deal_id where d.is_delete=0 and d.publish_wait = 0 and dl.user_id = ".$user_id." $condtion ";
        $sql = "select dlt.t_user_id,d.*,u.user_name,dl.money as u_load_money,u.level_id,u.province_id,u.city_id,dl.id as load_id,dl.rebate_money from " . DB_PREFIX . "deal d left join " . DB_PREFIX . "deal_load as dl on d.id = dl.deal_id LEFT JOIN " . DB_PREFIX . "deal_load_transfer dlt on dlt.load_id = dl.id LEFT JOIN " . DB_PREFIX . "user u ON u.id=d.user_id where (dl.user_id = " . $user_id . " or dlt.t_user_id =" . $user_id . ")  {$condtion} group by dl.id order by dl.create_time desc limit " . $limit;
        $sql_count = "select count(DISTINCT dl.id) from " . DB_PREFIX . "deal d left join " . DB_PREFIX . "deal_load as dl on d.id = dl.deal_id LEFT JOIN " . DB_PREFIX . "deal_load_transfer dlt on dlt.load_id = dl.id where d.is_delete=0 and d.publish_wait = 0 and (dl.user_id = " . $user_id . " or dlt.t_user_id =" . $user_id . ")  {$condtion} ";
        $count = $GLOBALS['db']->getOne($sql_count);
        $list = array();
        if ($count > 0) {
            $list = $GLOBALS['db']->getAll($sql);
            $load_ids = array();
            foreach ($list as $k => $v) {
                $list[$k]['borrow_amount_format'] = format_price($v['borrow_amount'] / 10000) . "万";
                //format_price($deal['borrow_amount']);
                $list[$k]['rate_foramt_w'] = number_format($v['rate'], 2) . "%";
                //$list[$k]['borrow_amount_format'] = format_price($v['borrow_amount']);
                $list[$k]['rate_foramt'] = number_format($v['rate'], 2);
                //本息还款金额
                $list[$k]['month_repay_money'] = pl_it_formula($v['borrow_amount'], $v['rate'] / 12 / 100, $v['repay_time']);
                $list[$k]['month_repay_money_format'] = format_price($list[$k]['month_repay_money']);
                if ($list[$k]['create_time'] != "") {
                    $list[$k]['create_time_format'] = to_date($list[$k]['create_time'], "Y-m-d");
                }
                if ($v['deal_status'] == 1) {
                    //还需多少钱
                    $list[$k]['need_money'] = format_price($v['borrow_amount'] - $v['load_money']);
                    //百分比
                    $list[$k]['progress_point'] = $v['load_money'] / $v['borrow_amount'] * 100;
                } elseif ($v['deal_status'] == 2 || $v['deal_status'] == 5) {
                    $list[$k]['progress_point'] = 100;
                } elseif ($v['deal_status'] == 4) {
                    //百分比
                    $list[$k]['remain_repay_money'] = $list[$k]['month_repay_money'] * $v['repay_time'];
                    //还有多少需要还
                    $list[$k]['need_remain_repay_money'] = $list[$k]['remain_repay_money'] - $v['repay_money'];
                    //还款进度条
                    $list[$k]['progress_point'] = round($v['repay_money'] / $list[$k]['remain_repay_money'] * 100, 2);
                }
                $user_location = $GLOBALS['db']->getOne("select name from " . DB_PREFIX . "region_conf where id = " . intval($v['city_id']), false);
                if ($user_location == '') {
                    $user_location = $GLOBALS['db']->getOne("select name from " . DB_PREFIX . "region_conf where id = " . intval($v['province_id']), false);
                }
                $list[$k]['user_location'] = $user_location;
                $list[$k]['point_level'] = $GLOBALS['db']->getOne("select name from " . DB_PREFIX . "user_level where id = " . intval($v['level_id']));
                //$durl = url("index","deal",array("id"=>$list[$k]['id']));
                //$deal['url'] = $durl;
                if ($v['deal_status'] == 4 || $v['deal_status'] == 5) {
                    $durl = "/index.php?ctl=uc_invest&act=mrefdetail&is_sj=1&id=" . $v['id'] . "&load_id=" . $v['load_id'] . "&user_name=" . $user_name . "&user_pwd=" . $user_pwd;
                    $list[$k]['app_url'] = str_replace("/mapi", "", SITE_DOMAIN . $durl);
                } else {
                    $durl = "/index.php?ctl=deal&act=mobile&is_sj=1&id=" . $v['id'];
                    $list[$k]['app_url'] = str_replace("/mapi", "", SITE_DOMAIN . $durl);
                }
                $load_ids[] = $v['load_id'];
            }
            //判断是否已经转让
            if (count($load_ids) > 0) {
                $tmptransfer_list = $GLOBALS['db']->getAll("SELECT * FROM " . DB_PREFIX . "deal_load_transfer where load_id in(" . implode(",", $load_ids) . ") and t_user_id > 0 and user_id=" . $user_id);
                $transfer_list = array();
                foreach ($tmptransfer_list as $k => $v) {
                    $transfer_list[$v['load_id']] = $v;
                }
                unset($tmptransfer_list);
                foreach ($list as $k => $v) {
                    if (isset($transfer_list[$v['load_id']])) {
                        $list[$k]['has_transfer'] = 1;
                    }
                }
            }
        }
        return array('list' => $list, 'count' => $count);
    } else {
        return array();
    }
}
Ejemplo n.º 7
0
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);
    }
}
Ejemplo n.º 8
0
 /**
  * 债券转让计算
  */
 function transfer($transfer)
 {
     $return['month_repay_money'] = pl_it_formula($transfer['load_money'], $transfer['rate'] / 12 / 100, $transfer['repay_time']);
     //剩余多少钱未回
     $return['all_must_repay_money'] = $return['month_repay_money'] * $transfer['how_much_month'];
     //剩余多少本金未回
     if ($transfer['repay_time'] == $transfer['how_much_month']) {
         $return['left_benjin'] = $transfer['load_money'];
     } else {
         $return['left_benjin'] = get_benjin($transfer['repay_time'] - $transfer['how_much_month'], $transfer['repay_time'], $transfer['load_money'], $return['month_repay_money'], $transfer['rate']);
     }
     return $return;
 }
Ejemplo n.º 9
0
function get_transfer_list($limit, $condition = '', $extfield, $union_sql, $orderby = '')
{
    //获取转让列表
    $count_sql = 'SELECT count(dlt.id) FROM ' . DB_PREFIX . 'deal_load_transfer dlt LEFT JOIN ' . DB_PREFIX . 'deal d ON d.id =dlt.deal_id WHERE dlt.status=1 and d.is_effect=1 AND d.is_delete = 0 ' . $condition;
    $rs_count = $GLOBALS['db']->getOne($count_sql);
    if ($rs_count > 0) {
        $list_sql = 'SELECT dlt.*,d.loantype,d.name,d.icon,d.cate_id,d.user_id as duser_id,d.rate,d.repay_time,d.repay_time_type ' . $extfield . '  FROM ' . DB_PREFIX . 'deal_load_transfer dlt LEFT JOIN ' . DB_PREFIX . 'deal d ON d.id =dlt.deal_id ' . $union_sql . ' WHERE dlt.status=1 and d.is_effect=1 AND d.is_delete = 0 ' . $condition;
        $list_sql .= ' ORDER BY ' . $orderby;
        $list_sql .= ' LIMIT ' . $limit;
        $list = $GLOBALS['db']->getAll($list_sql);
        foreach ($list as $k => $v) {
            $list[$k]['duser'] = get_user("user_name,level_id,province_id,city_id", $v['duser_id']);
            $list[$k]['user'] = get_user("user_name,level_id,province_id,city_id", $v['user_id']);
            if ($v['t_user_id'] > 0) {
                $list[$k]['tuser'] = get_user("user_name,level_id,province_id,city_id", $v['t_user_id']);
            } else {
                $list[$k]['tuser'] = null;
            }
            if ($list[$k]['tuser'] === false) {
                $list[$k]['tuser'] = null;
            }
            if ($list[$k]['duser'] === false) {
                $list[$k]['duser'] = null;
            }
            if ($list[$k]['user'] === false) {
                $list[$k]['user'] = null;
                //new ArrayObject(); {}
            }
            $list[$k]['url'] = url("index", "transfer#detail", array("id" => $v['id']));
            //$deal['url'] = $durl;
            //x	$durl = "/index.php?ctl=deal&act=mobile&id=".$v['deal_id'];
            $durl = APP_ROOT . "/wap/index.php?ctl=transfer_mobile&is_sj=1&id=" . $v['deal_id'];
            $list[$k]['app_url'] = str_replace("/mapi", "", SITE_DOMAIN . $durl);
            //剩余期数
            $list[$k]['how_much_month'] = how_much_month($v['near_repay_time'], $v['last_repay_time']) + 1;
            if ($v['cate_id'] > 0) {
                $list[$k]['cate_info'] = $GLOBALS['db']->getRowCached("select id,name,brief,uname,icon from " . DB_PREFIX . "deal_cate where id = " . $v['cate_id'] . " and is_effect = 1 and is_delete = 0");
            }
            //本息还款金额
            if ($v['loantype'] == 0) {
                $list[$k]['month_repay_money'] = pl_it_formula($v['load_money'], $v['rate'] / 12 / 100, $v['repay_time']);
                //剩余多少钱未回
                $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]['month_repay_money'] = av_it_formula($v['load_money'], $v['rate'] / 12 / 100);
                //剩余多少钱未回
                $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]['month_repay_money'] = 0;
                //剩余多少钱未回
                $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']);
            $list[$k]['remain_time'] = $v['near_repay_time'] - TIME_UTC + 24 * 3600 - 1;
            $list[$k]['remain_time_format'] = remain_time($list[$k]['remain_time']);
            $list[$k]['near_repay_time_format'] = to_date($v['near_repay_time'], "Y-m-d");
            $list[$k]['transfer_amount_format'] = format_price($v['transfer_amount'] / 10000) . "万";
            //转让收益
            $list[$k]['transfer_income'] = $list[$k]['all_must_repay_money'] - $list[$k]['transfer_amount'];
            $list[$k]['transfer_income_format'] = format_price($list[$k]['transfer_income']);
            //
            $list[$k]['transfer_time_format'] = to_date($v['transfer_time'], "Y-m-d");
        }
        $result["list"] = $list;
    }
    $result["rs_count"] = $rs_count;
    return $result;
}
Ejemplo n.º 10
0
 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);
     }
 }
Ejemplo n.º 11
0
 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("发送成功");
 }
Ejemplo n.º 12
0
 public function invest()
 {
     $authorized_info = $this->checkLogin();
     $page = intval($_REQUEST['p']);
     if ($page == 0) {
         $page = 1;
     }
     $limit = ($page - 1) * app_conf("PAGE_SIZE") . "," . app_conf("PAGE_SIZE");
     if ($limit) {
         $limit = " limit " . $limit;
     }
     $user_id = intval($_REQUEST['u_id']);
     if ($user_id) {
         $sql = "select f_u.id as f_u_id,t_u.id as t_u_id,dlt.t_user_id,d.*,f_u.user_name as f_user_name,t_u.user_name as t_user_name,dl.money as u_load_money,u.level_id,u.province_id,u.city_id,dl.id as load_id from " . DB_PREFIX . "deal d left join " . DB_PREFIX . "deal_load as dl on d.id = dl.deal_id LEFT JOIN " . DB_PREFIX . "deal_load_transfer dlt on dlt.load_id = dl.id LEFT JOIN " . DB_PREFIX . "user u ON u.id=d.user_id \r\nLEFT JOIN " . DB_PREFIX . "user t_u ON t_u.id = t_user_id LEFT JOIN " . DB_PREFIX . "user f_u ON f_u.id = dl.user_id where d.deal_status in(4,5) and (f_u.pid='" . $authorized_info["id"] . "' or t_u.pid = '" . $authorized_info["id"] . "') and ((f_u.id = '" . $user_id . "' and (t_u.id is null or t_u.id = 0)) or t_u.id = '" . $user_id . "') group by dl.id order by dl.create_time desc " . $limit;
         $sql_count = "select count(DISTINCT dl.id) from " . DB_PREFIX . "deal d left join " . DB_PREFIX . "deal_load as dl on d.id = dl.deal_id LEFT JOIN " . DB_PREFIX . "deal_load_transfer dlt on dlt.load_id = dl.id LEFT JOIN " . DB_PREFIX . "user u ON u.id=d.user_id \r\nLEFT JOIN " . DB_PREFIX . "user t_u ON t_u.id = t_user_id LEFT JOIN " . DB_PREFIX . "user f_u ON f_u.id = dl.user_id where d.is_delete=0 and d.publish_wait = 0 AND d.deal_status in(4,5) and (f_u.pid='" . $authorized_info["id"] . "' or t_u.pid = '" . $authorized_info["id"] . "') and ((f_u.id = '" . $user_id . "' and (t_u.id is null or t_u.id = 0)) or t_u.id = '" . $user_id . "')";
     } else {
         $sql = "select t_u.id as t_u_id,f_u.id as f_u_id,dlt.t_user_id,d.*,f_u.user_name as f_user_name,t_u.user_name as t_user_name,dl.money as u_load_money,u.level_id,u.province_id,u.city_id,dl.id as load_id from " . DB_PREFIX . "deal d left join " . DB_PREFIX . "deal_load as dl on d.id = dl.deal_id LEFT JOIN " . DB_PREFIX . "deal_load_transfer dlt on dlt.load_id = dl.id LEFT JOIN " . DB_PREFIX . "user u ON u.id=d.user_id \r\nLEFT JOIN " . DB_PREFIX . "user t_u ON t_u.id = t_user_id LEFT JOIN " . DB_PREFIX . "user f_u ON f_u.id = dl.user_id where d.deal_status in(4,5) and (f_u.pid='" . $authorized_info["id"] . "' or t_u.pid = '" . $authorized_info["id"] . "') group by dl.id order by dl.create_time desc " . $limit;
         $sql_count = "select count(DISTINCT dl.id) from " . DB_PREFIX . "deal d left join " . DB_PREFIX . "deal_load as dl on d.id = dl.deal_id LEFT JOIN " . DB_PREFIX . "deal_load_transfer dlt on dlt.load_id = dl.id LEFT JOIN " . DB_PREFIX . "user u ON u.id=d.user_id \r\nLEFT JOIN " . DB_PREFIX . "user t_u ON t_u.id = t_user_id LEFT JOIN " . DB_PREFIX . "user f_u ON f_u.id = dl.user_id where d.is_delete=0 and d.publish_wait = 0 AND d.deal_status in(4,5) and (f_u.pid='" . $authorized_info["id"] . "' or t_u.pid = '" . $authorized_info["id"] . "')";
     }
     $count = $GLOBALS['db']->getOne($sql_count);
     $list = array();
     if ($count > 0) {
         $list = $GLOBALS['db']->getAll($sql);
         $load_ids = array();
         foreach ($list as $k => $v) {
             $list[$k]["u_id"] = $v["t_u_id"] ? $v["t_u_id"] : $v["f_u_id"];
             $list[$k]['borrow_amount_format'] = format_price($v['borrow_amount'] / 10000) . "万";
             //format_price($deal['borrow_amount']);
             $list[$k]['rate_foramt_w'] = number_format($v['rate'], 2) . "%";
             $list[$k]['user_name'] = $v["t_user_name"] != "" ? $v["t_user_name"] : $v["f_user_name"];
             //$list[$k]['borrow_amount_format'] = format_price($v['borrow_amount']);
             $list[$k]['rate_foramt'] = number_format($v['rate'], 2);
             //本息还款金额
             $list[$k]['month_repay_money'] = pl_it_formula($v['borrow_amount'], $v['rate'] / 12 / 100, $v['repay_time']);
             $list[$k]['month_repay_money_format'] = format_price($list[$k]['month_repay_money']);
             switch ($v['deal_status']) {
                 //case "1":$list[$k]['status_format'] = ; break;
                 //case "2":$list[$k]['status_format'] = ; break;
                 //case "3":$list[$k]['status_format'] = ""; break;
                 case "4":
                     $list[$k]['status_format'] = "还款中";
                     break;
                 case "5":
                     $list[$k]['status_format'] = "已还清";
                     break;
                 default:
                     break;
             }
             /*if($v['deal_status'] == 1){
             				//还需多少钱
             				$list[$k]['need_money'] = format_price($v['borrow_amount'] - $v['load_money']);
             	
             				//百分比
             				$list[$k]['progress_point'] = $v['load_money']/$v['borrow_amount']*100;
             	
             			}
             			/*elseif($v['deal_status'] == 2 || $v['deal_status'] == 5)
             			{
             				$list[$k]['progress_point'] = 100;
             			}
             			elseif($v['deal_status'] == 4){
             				//百分比
             				$list[$k]['remain_repay_money'] = $list[$k]['month_repay_money'] * $v['repay_time'];
             				//还有多少需要还
             				$list[$k]['need_remain_repay_money'] = $list[$k]['remain_repay_money'] - $v['repay_money'];
             				//还款进度条
             				$list[$k]['progress_point'] =  round($v['repay_money']/$list[$k]['remain_repay_money']*100,2);
             			}*/
             $user_location = $GLOBALS['db']->getOne("select name from " . DB_PREFIX . "region_conf where id = " . intval($v['city_id']));
             if ($user_location == '') {
                 $user_location = $GLOBALS['db']->getOne("select name from " . DB_PREFIX . "region_conf where id = " . intval($v['province_id']));
             }
             $list[$k]['user_location'] = $user_location;
             $list[$k]['point_level'] = $GLOBALS['db']->getOne("select name from " . DB_PREFIX . "user_level where id = " . intval($v['level_id']));
             //$durl = url("index","deal",array("id"=>$list[$k]['id']));
             //$deal['url'] = $durl;
             /*if($v['deal_status'] == 4 || $v['deal_status'] == 5){
             			$durl = "/index.php?ctl=uc_invest&act=mrefdetail&is_sj=1&id=".$v['id']."&load_id=".$v['load_id']."&user_name=".$user_name."&user_pwd=".$user_pwd;					
             			$list[$k]['app_url'] = str_replace("/mapi", "", SITE_DOMAIN.$durl);
             		}else{
             			$durl = "/index.php?ctl=deal&act=mobile&is_sj=1&id=".$v['id'];
             			$list[$k]['app_url'] = str_replace("/mapi", "", SITE_DOMAIN.$durl);
             		}*/
             $load_ids[] = $v['load_id'];
         }
         //判断是否已经转让
         if (count($load_ids) > 0) {
             $tmptransfer_list = $GLOBALS['db']->getAll("SELECT * FROM " . DB_PREFIX . "deal_load_transfer where load_id in(" . implode(",", $load_ids) . ") and t_user_id > 0 and user_id=" . $user_id);
             $transfer_list = array();
             foreach ($tmptransfer_list as $k => $v) {
                 $transfer_list[$v['load_id']] = $v;
             }
             unset($tmptransfer_list);
             foreach ($list as $k => $v) {
                 if (isset($transfer_list[$v['load_id']])) {
                     $list[$k]['has_transfer'] = 1;
                 }
             }
         }
     }
     $GLOBALS['tmpl']->assign("list", $list);
     require APP_ROOT_PATH . "app/Lib/deal_func.php";
     require APP_ROOT_PATH . "app/Lib/page.php";
     $page = new Page($count, app_conf("PAGE_SIZE"));
     //初始化分页对象
     $p = $page->show();
     $GLOBALS['tmpl']->assign('pages', $p);
     $GLOBALS['tmpl']->assign("page_title", "客户投资列表");
     $GLOBALS['tmpl']->assign("inc_file", "authorized/authorized_invest.html");
     $GLOBALS['tmpl']->display("authorized/a_m.html");
 }
Ejemplo n.º 13
0
 function ajax_calculate()
 {
     $rate = $_REQUEST['apr'] / 12;
     $borrowpay = intval($_REQUEST['borrowpay']);
     $borrowamount = intval($_REQUEST['borrowamount']);
     $repaytime = intval($_REQUEST['repaytime']);
     $apr = trim($_REQUEST['apr']);
     $GLOBALS['tmpl']->assign("borrowpay", $borrowpay);
     $lixi = 0;
     //等额本息
     if ($borrowpay == 0) {
         $repayamount = pl_it_formula($borrowamount, $rate / 100, $repaytime);
     } elseif ($borrowpay == 1) {
         $lixi = av_it_formula($borrowamount, $rate / 100);
         $lixi = round($lixi, 2);
         $repayamount = 0;
         $GLOBALS['tmpl']->assign("lixi", $lixi);
     } elseif ($borrowpay == 2) {
         $lixi = $borrowamount * $rate / 100 * $repaytime;
         $lixi = round($lixi, 2);
         $repayamount = $lixi + $borrowamount;
         $GLOBALS['tmpl']->assign("lixi", $lixi);
     }
     $GLOBALS['tmpl']->assign("borrowamount", $borrowamount);
     $GLOBALS['tmpl']->assign("apr", $apr);
     $GLOBALS['tmpl']->assign("rate", $rate);
     $GLOBALS['tmpl']->assign("repaytime", $repaytime);
     $GLOBALS['tmpl']->assign("repayamount", $repayamount);
     //等额本息
     if ($borrowpay == 0) {
         $repayallamount = $repayamount * $repaytime;
     } elseif ($borrowpay == 1) {
         $repayallamount = $borrowamount + $lixi * $repaytime;
     } elseif ($borrowpay == 2) {
         $repayallamount = $borrowamount + $lixi;
     }
     $GLOBALS['tmpl']->assign("repayallamount", $repayallamount);
     if (isset($_REQUEST['isshow']) && intval($_REQUEST['isshow']) == 1) {
         //=======================================本息还款计算开始=================================
         if ($borrowpay == 0) {
             //月还本金
             $r_smoney = 0;
             //月还本息
             $r_rmoney = 0;
             //借款管理费
             $r_mmoney = $borrowamount * trim(app_conf('MANAGE_FEE')) / 100;
             //本金余额
             $l_money = $borrowamount;
             //本息余额
             $r_money = $repayallamount;
             $list = null;
             //$had_repay_money = 0;
             for ($i = 1; $i <= $repaytime; $i++) {
                 $l_money = $l_money - $r_smoney;
                 //月还利息
                 $list[$i]['r_rmoney'] = $l_money * $rate / 100;
                 //本息余额
                 if ($i == $repaytime) {
                     $after_money = round($repayamount, 2);
                     $after_month = $i - 1;
                     $list[$i]['repayamount'] = $repayallamount - $after_month * $after_money;
                     //月还本金
                     $list[$i]['r_smoney'] = $list[$i]['repayamount'] - $list[$i]['r_rmoney'];
                     $list[$i]['r_money'] = 0;
                 } else {
                     //月还本息
                     $list[$i]['repayamount'] = $repayamount;
                     //月还本金
                     $r_smoney = $list[$i]['r_smoney'] = $repayamount - $list[$i]['r_rmoney'];
                     //本息余额
                     if ($i + 1 == $repaytime) {
                         $r_money = $r_money - $list[$i]['r_rmoney'] - $list[$i]['r_smoney'];
                         $after_money = round($repayamount, 2);
                         $after_month = $i;
                         $list[$i]['r_money'] = $repayallamount - $after_month * $after_money;
                     } else {
                         $r_money = $list[$i]['r_money'] = $r_money - $list[$i]['r_rmoney'] - $list[$i]['r_smoney'];
                     }
                 }
             }
             $GLOBALS['tmpl']->assign("list", $list);
             $GLOBALS['tmpl']->assign("r_mmoney", $r_mmoney);
         } elseif ($borrowpay == 1) {
             //借款管理费
             $r_mmoney = $borrowamount * trim(app_conf('MANAGE_FEE')) / 100;
             //本金余额
             $l_money = $borrowamount;
             //本息余额
             $r_money = $repayallamount;
             $list = null;
             $r_smoney = 0;
             for ($i = 1; $i <= $repaytime; $i++) {
                 //月还利息
                 $list[$i]['r_rmoney'] = $lixi;
                 if ($i == $repaytime) {
                     $list[$i]['repayamount'] = $l_money + $lixi;
                     //月还本金
                     $list[$i]['r_smoney'] = $borrowamount;
                     $list[$i]['r_money'] = 0;
                 } else {
                     $list[$i]['repayamount'] = $lixi;
                     //月还本金
                     $r_smoney = $list[$i]['r_smoney'] = 0;
                     //本息余额
                     $r_money = $list[$i]['r_money'] = $r_money - $list[$i]['r_rmoney'] - $list[$i]['r_smoney'];
                 }
             }
             $GLOBALS['tmpl']->assign("list", $list);
             $GLOBALS['tmpl']->assign("r_mmoney", $r_mmoney);
         } elseif ($borrowpay == 2) {
             //借款管理费
             $r_mmoney = $borrowamount * trim(app_conf('MANAGE_FEE')) / 100 * $repaytime;
             //本金余额
             $l_money = $borrowamount;
             //本息余额
             $r_money = $repayallamount;
             $list = null;
             $list[1]['r_rmoney'] = $lixi;
             $list[1]['repayamount'] = $l_money + $lixi;
             //月还本金
             $list[1]['r_smoney'] = $borrowamount;
             $list[1]['r_money'] = 0;
             $GLOBALS['tmpl']->assign("list", $list);
             $GLOBALS['tmpl']->assign("r_mmoney", $r_mmoney);
         }
         //=================================到期还本息结束=================================
     }
     $GLOBALS['tmpl']->display("inc/tool/calculate_result.html");
 }