Пример #1
0
/**
 * 获取正在进行的投标列表
 */
function get_deal_list($limit = "", $cate_id = 0, $where = '', $orderby = '', $user_name = '', $user_pwd = '', $is_all = false)
{
    $time = TIME_UTC;
    $count_sql = "select count(*) from " . DB_PREFIX . "deal where 1=1 ";
    if ($is_all == false) {
        $count_sql .= " and is_effect = 1 and is_delete = 0 ";
    }
    if (es_cookie::get("shop_sort_field") == "ulevel") {
        $extfield = ",(SELECT u.level_id FROM fanwe_user u WHERE u.id=user_id ) as ulevel";
    }
    $sql = "select *,start_time as last_time,(load_money/borrow_amount*100) as progress_point,(start_time + enddate*24*3600 - " . $time . ") as remain_time {$extfield} from " . DB_PREFIX . "deal where 1 = 1 ";
    if ($is_all == false) {
        $sql .= " and is_effect = 1 and is_delete = 0 ";
    }
    if ($cate_id > 0) {
        $ids = load_auto_cache("deal_sub_parent_cate_ids", array("cate_id" => $cate_id));
        $sql .= " and cate_id in (" . implode(",", $ids) . ")";
        $count_sql .= " and cate_id in (" . implode(",", $ids) . ")";
    }
    if ($where != '') {
        $sql .= " and " . $where;
        $count_sql .= " and " . $where;
    }
    if ($orderby == '') {
        $sql .= " order by sort desc ";
    } else {
        $sql .= " order by " . $orderby;
    }
    if ($limit != "") {
        $sql .= " limit " . $limit;
    }
    $deals_count = $GLOBALS['db']->getOne($count_sql);
    if ($deals_count > 0) {
        $deals = $GLOBALS['db']->getAll($sql);
        //echo $sql;
        if ($deals) {
            foreach ($deals as $k => $deal) {
                format_deal_item($deal, $user_name, $user_pwd);
                $deals[$k] = $deal;
            }
        }
    } else {
        $deals = array();
    }
    return array('list' => $deals, 'count' => $deals_count);
}
Пример #2
0
/**
 * 满标放款
 * $type 0 普通 1代表 第三方
 * $is_loan 0 不返款, 1 返款
 */
function do_loans($id, $repay_start_time, $type = 0)
{
    $return = array("status" => 0, "info" => "");
    if ($id == 0) {
        $return['info'] = "放款失败,借款不存在";
        return $return;
    }
    require_once APP_ROOT_PATH . "app/Lib/deal.php";
    syn_deal_status($id);
    $deal_info = get_deal($id);
    if ($deal['cate_id'] == 6) {
        // 体验金
        $is_ty = 1;
    } else {
        $is_ty = 0;
    }
    if (!$deal_info) {
        $return['info'] = "放款失败,借款不存在";
        return $return;
    }
    if (!in_array($deal_info['deal_status'], array(2, 4, 5))) {
        $return['info'] = "放款失败,借款不是满标状态";
        return $return;
    }
    if ($type == 0) {
        $loan_data['repay_start_time'] = $repay_start_time == '' ? 0 : to_timespan(to_date(to_timespan($repay_start_time), "Y-m-d"), "Y-m-d");
    } else {
        $loan_data['repay_start_time'] = $repay_start_time;
    }
    if ($loan_data['repay_start_time'] == 0) {
        $return['info'] = "放款失败,时间没选择";
        return $return;
    }
    if ($type == 0 && $deal_info['ips_bill_no'] != "") {
        $return['status'] = 2;
        $return['info'] = "";
        $return['jump'] = APP_ROOT . "/index.php?ctl=collocation&act=Transfer&pTransferType=1&deal_id=" . $id . "&ref_data=" . $loan_data['repay_start_time'];
        return $return;
    }
    if ($loan_data['repay_start_time'] > 0) {
        $deal_info['next_repay_time'] = $loan_data['next_repay_time'] = next_replay_month($loan_data['repay_start_time']);
    }
    $deal_info['deal_status'] = $loan_data['deal_status'] = 4;
    $deal_info['is_has_loans'] = $loan_data['is_has_loans'] = 1;
    $deal_info['repay_start_time'] = $loan_data['repay_start_time'];
    format_deal_item($deal_info);
    //放款给用户
    $GLOBALS['db']->autoExecute(DB_PREFIX . "deal", $loan_data, "UPDATE", "id=" . $id);
    if ($GLOBALS['db']->affected_rows() > 0) {
        require_once APP_ROOT_PATH . "system/libs/user.php";
        if ($type == 0) {
            modify_account(array("money" => $deal_info['borrow_amount']), $deal_info['user_id'], "[<a href='" . $deal_info['url'] . "' target='_blank'>" . $deal_info['name'] . "</a>],招标成功", 3, $is_ty);
            //扣除服务费
            $services_fee = $deal_info['borrow_amount'] * floatval(trim($deal_info['services_fee'])) / 100;
            modify_account(array("money" => -$services_fee), $deal_info['user_id'], "[<a href='" . $deal_info['url'] . "' target='_blank'>" . $deal_info['name'] . "</a>],服务费", 14, $is_ty);
        }
        $load_list = $GLOBALS['db']->getAll("SELECT id,user_id,`money`,`is_old_loan`,`rebate_money`,`rebid_money` FROM " . DB_PREFIX . "deal_load where deal_id=" . $id . " and is_rebate = 0 and is_rebid = 0 ");
        foreach ($load_list as $lk => $lv) {
            //扣除冻结资金
            if ($lv['is_old_loan'] == 0 && $type == 0) {
                modify_account(array("lock_money" => -$lv['money']), $lv['user_id'], "[<a href='" . $deal_info['url'] . "' target='_blank'>" . $deal_info['name'] . "</a>],投标成功", 2, $is_ty);
            }
            //返利给用户
            if (floatval($lv["rebate_money"]) != 0) {
                $GLOBALS['db']->query("UPDATE " . DB_PREFIX . "deal_load SET is_rebate =1 WHERE id=" . $lv['id'] . " AND is_rebate = 0 AND user_id=" . $lv['user_id'], $is_ty);
                if ($GLOBALS['db']->affected_rows()) {
                    modify_account(array("money" => $lv['rebate_money']), $lv['user_id'], "[<a href='" . $deal_info['url'] . "' target='_blank'>" . $deal_info['name'] . "</a>],返利", 24, $is_ty);
                }
            }
            //续投奖励
            if (floatval($lv["rebid_money"]) != 0) {
                $GLOBALS['db']->query("UPDATE " . DB_PREFIX . "deal_load SET is_rebid =1 WHERE id=" . $lv['id'] . " AND is_rebid = 0 AND user_id=" . $lv['user_id']);
                if ($GLOBALS['db']->affected_rows()) {
                    modify_account(array("money" => $lv['rebid_money']), $lv['user_id'], "[<a href='" . $deal_info['url'] . "' target='_blank'>" . $deal_info['name'] . "</a>],续投奖励", 24, $is_ty);
                }
            }
        }
        $GLOBALS['db']->autoExecute(DB_PREFIX . "deal_load", array("is_has_loans" => 1), "UPDATE", "deal_id=" . $id);
        make_repay_plan($deal_info);
        //发借款成功邮件
        send_deal_success_mail_sms($id, $deal_info);
        //发借款成功站内信
        send_deal_success_site_sms($id, $deal_info);
        $return['status'] = 1;
        $return['info'] = "放款成功";
        return $return;
    } else {
        $return['info'] = "放款失败";
        return $return;
    }
}
Пример #3
0
/**
 * 满标放款
 * $type 0 普通 1代表 第三方
 * $is_loan 0 不返款, 1 返款
 */
function do_loans($id, $repay_start_time, $type = 0)
{
    $return = array("status" => 0, "info" => "");
    if ($id == 0) {
        $return['info'] = "放款失败,借款不存在";
        return $return;
    }
    require_once APP_ROOT_PATH . "app/Lib/deal.php";
    $deal_info = get_deal($id);
    if (!$deal_info) {
        $return['info'] = "放款失败,借款不存在";
        return $return;
    }
    if (!in_array($deal_info['deal_status'], array(2, 4, 5))) {
        $return['info'] = "放款失败,借款不是满标状态";
        return $return;
    }
    if ($type == 0) {
        $loan_data['repay_start_time'] = $repay_start_time == '' ? 0 : to_timespan(to_date(to_timespan($repay_start_time), "Y-m-d"), "Y-m-d");
    } else {
        $loan_data['repay_start_time'] = $repay_start_time;
    }
    if ($loan_data['repay_start_time'] == 0) {
        $return['info'] = "放款失败,时间没选择";
        return $return;
    }
    if ($type == 0 && $deal_info['ips_bill_no'] != "") {
        $return['status'] = 2;
        $return['info'] = "";
        $return['jump'] = APP_ROOT . "/index.php?ctl=collocation&act=Transfer&pTransferType=1&deal_id=" . $id . "&ref_data=" . $loan_data['repay_start_time'];
        return $return;
    }
    if ($loan_data['repay_start_time'] > 0) {
        $deal_info['next_repay_time'] = $loan_data['next_repay_time'] = next_replay_month($loan_data['repay_start_time']);
    }
    $deal_info['deal_status'] = $loan_data['deal_status'] = 4;
    $deal_info['is_has_loans'] = $loan_data['is_has_loans'] = 1;
    $loan_data['repay_start_date'] = to_date($loan_data['repay_start_time'], "Y-m-d");
    //放款给用户
    $GLOBALS['db']->autoExecute(DB_PREFIX . "deal", $loan_data, "UPDATE", "id=" . $id . " AND is_has_loans=0 ");
    $deal_info['repay_start_time'] = $loan_data['repay_start_time'];
    if ($GLOBALS['db']->affected_rows() > 0) {
        format_deal_item($deal_info);
        require_once APP_ROOT_PATH . "system/libs/user.php";
        if ($type == 0) {
            modify_account(array("money" => $deal_info['borrow_amount']), $deal_info['user_id'], "[<a href='" . $deal_info['url'] . "' target='_blank'>" . $deal_info['name'] . "</a>],招标成功", 3);
            //扣除服务费
            $services_fee = $deal_info['borrow_amount'] * floatval(trim($deal_info['services_fee'])) / 100;
            modify_account(array("money" => -$services_fee), $deal_info['user_id'], "[<a href='" . $deal_info['url'] . "' target='_blank'>" . $deal_info['name'] . "</a>],服务费", 14);
        }
        //积分
        if ($deal_info['score'] != 0) {
            modify_account(array("score" => $deal_info['score']), $deal_info['user_id'], "[<a href='" . $deal_info['url'] . "' target='_blank'>" . $deal_info['name'] . "</a>],招标成功", 3);
        }
        $load_list = $GLOBALS['db']->getAll("SELECT id,user_id,`money`,`is_old_loan`,`rebate_money`,`bid_score`,`is_winning`,`income_type`,`income_value` FROM " . DB_PREFIX . "deal_load where deal_id=" . $id . " and is_rebate = 0 ");
        foreach ($load_list as $lk => $lv) {
            //扣除冻结资金
            if ($type == 0) {
                $GLOBALS['db']->query("UPDATE " . DB_PREFIX . "deal_load SET is_has_loans =1 WHERE id=" . $lv['id'] . " AND is_has_loans = 0 AND user_id=" . $lv['user_id']);
                if ($GLOBALS['db']->affected_rows()) {
                    if ($lv['is_old_loan'] == 0) {
                        modify_account(array("lock_money" => -$lv['money']), $lv['user_id'], "[<a href='" . $deal_info['url'] . "' target='_blank'>" . $deal_info['name'] . "</a>],投标成功", 2);
                    }
                }
            }
            //返利给用户
            if (floatval($lv["rebate_money"]) != 0 || intval($lv["bid_score"]) != 0) {
                $GLOBALS['db']->query("UPDATE " . DB_PREFIX . "deal_load SET is_rebate =1 WHERE id=" . $lv['id'] . " AND is_rebate = 0 AND user_id=" . $lv['user_id']);
                if ($GLOBALS['db']->affected_rows()) {
                    //返利
                    if (floatval($lv["rebate_money"]) != 0) {
                        modify_account(array("money" => $lv['rebate_money']), $lv['user_id'], "[<a href='" . $deal_info['url'] . "' target='_blank'>" . $deal_info['name'] . "</a>],投资返利", 24);
                    }
                    //积分
                    if (intval($lv["bid_score"]) != 0) {
                        modify_account(array("score" => $lv['bid_score']), $lv['user_id'], "[<a href='" . $deal_info['url'] . "' target='_blank'>" . $deal_info['name'] . "</a>],投资返积分", 2);
                    }
                    //VIP奖励
                    if (((int) $lv['income_type'] == 1 || (int) $lv['income_type'] == 2 || (int) $lv['income_type'] == 3 || (int) $lv['income_type'] == 4) && $lv['is_winning'] == 1) {
                        $user_msg_conf = get_user_msg_conf($lv['user_id']);
                        //发放奖励
                        if ($lv['income_type'] == 1) {
                            //红包记录 增加用户金额与不可提现金额
                            $red_envelope_date['user_id'] = $lv['user_id'];
                            $red_envelope_date['deal_id'] = $id;
                            $red_envelope_date['load_id'] = $lv['id'];
                            $red_envelope_date['reward_name'] = "投标收益奖励";
                            $red_envelope_date['gift_type'] = 1;
                            $redmoney = $GLOBALS['db']->getOne("SELECT money FROM " . DB_PREFIX . "vip_red_envelope WHERE id='" . (int) $lv['income_value'] . "'");
                            $red_envelope_date['gift_value'] = $redmoney;
                            $red_envelope_date['status'] = 1;
                            $red_envelope_date['generation_date'] = to_date(TIME_UTC, "Y-m-d");
                            $red_envelope_date['release_date'] = to_date(TIME_UTC, "Y-m-d");
                            $is_send_mail = $user_msg_conf['mail_redenvelope'];
                            $is_send_sms = $user_msg_conf['sms_redenvelope'];
                            $TPL_MAIL_NAME = "TPL_MAIL_RED_ENVELOPE";
                            $TPL_SMS_NAME = "TPL_SMS_RED_ENVELOPE";
                            $gift_value = $redmoney;
                            if ($redmoney != 0 && $redmoney != "") {
                                $GLOBALS['db']->autoExecute(DB_PREFIX . "gift_record", $red_envelope_date);
                                //插入
                                modify_account(array('money' => $redmoney, 'nmc_amount' => $redmoney), $lv['user_id'], "[<a href='" . $deal_info['url'] . "' target='_blank'>" . $deal_info['name'] . "</a>],的投标收益奖励  红包现金", 28);
                            }
                        } elseif ($lv['income_type'] == 2) {
                            //收益率
                            $rate_date['user_id'] = $lv['user_id'];
                            $rate_date['deal_id'] = $id;
                            $rate_date['load_id'] = $lv['id'];
                            $rate_date['reward_name'] = "投标收益奖励";
                            $rate_date['gift_type'] = 2;
                            $loadinfo = $GLOBALS['db']->getRow("SELECT * FROM " . DB_PREFIX . "deal_load_repay WHERE load_id='" . $lv['id'] . "'");
                            $interest_money = $loadinfo['repay_money'] - $loadinfo['self_money'];
                            $gift_value = $interest_money * (double) $lv['income_value'] * 0.01;
                            $rate_date['reward_money'] = $gift_value;
                            $rate_date['gift_value'] = $lv['income_value'];
                            $rate_date['status'] = 1;
                            $rate_date['generation_date'] = to_date(TIME_UTC, "Y-m-d");
                            $rate_date['release_date'] = to_date(TIME_UTC, "Y-m-d");
                            $GLOBALS['db']->autoExecute(DB_PREFIX . "gift_record", $rate_date);
                            //插入
                        } elseif ($lv['income_type'] == 3) {
                            //积分
                            $score = (int) $lv['income_value'];
                            $score_date['user_id'] = $lv['user_id'];
                            $score_date['deal_id'] = $id;
                            $score_date['load_id'] = $lv['id'];
                            $score_date['reward_name'] = "投标收益奖励";
                            $score_date['gift_type'] = 3;
                            $score_date['gift_value'] = (int) $lv['income_value'];
                            $score_date['status'] = 1;
                            $score_date['generation_date'] = to_date(TIME_UTC, "Y-m-d");
                            $score_date['release_date'] = to_date(TIME_UTC, "Y-m-d");
                            $GLOBALS['db']->autoExecute(DB_PREFIX . "gift_record", $score_date);
                            //插入
                            $is_send_mail = $user_msg_conf['mail_integral'];
                            $is_send_sms = $user_msg_conf['sms_integral'];
                            $TPL_MAIL_NAME = "TPL_MAIL_INTEGRAL";
                            $TPL_SMS_NAME = "TPL_SMS_INTEGRAL";
                            $gift_value = (int) $lv['income_value'];
                            if ($score != 0) {
                                modify_account(array("score" => $score), $lv['user_id'], "[<a href='" . $deal_info['url'] . "' target='_blank'>" . $deal_info['name'] . "</a>],的投标收益奖励 积分", 28);
                            }
                        } elseif ($lv['income_type'] == 4) {
                            //礼品记录
                            $gift_date['user_id'] = $lv['user_id'];
                            $gift_date['deal_id'] = $id;
                            $gift_date['load_id'] = $lv['id'];
                            $gift_date['reward_name'] = "投标收益奖励";
                            $gift_date['gift_type'] = 4;
                            $gift_date['gift_value'] = (int) $lv['income_value'];
                            $gift_date['status'] = 1;
                            $gift_date['generation_date'] = to_date(TIME_UTC, "Y-m-d");
                            $gift_date['release_date'] = to_date(TIME_UTC, "Y-m-d");
                            $GLOBALS['db']->autoExecute(DB_PREFIX . "gift_record", $gift_date);
                            //插入
                            $is_send_mail = $user_msg_conf['mail_gift'];
                            $is_send_sms = $user_msg_conf['sms_gift'];
                            $TPL_MAIL_NAME = "TPL_MAIL_GIFT";
                            $TPL_SMS_NAME = "TPL_SMS_GIFT";
                            $gift_value = $GLOBALS['db']->getOne("select name from " . DB_PREFIX . "vip_gift where id = " . $gift_date['gift_value']);
                        }
                        $user_info = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "user where id = " . $lv['user_id']);
                        $deal_name = $GLOBALS['db']->getOne("select name from " . DB_PREFIX . "deal where id = " . $id);
                        //邮件
                        if ($is_send_mail == 1 && app_conf("MAIL_ON") == 1) {
                            $tmpl = $GLOBALS['db']->getRowCached("select * from " . DB_PREFIX . "msg_template where name = '" . $TPL_MAIL_NAME . "'");
                            $tmpl_content = $tmpl['content'];
                            $notice['user_name'] = $user_info['user_name'];
                            $notice['deal_name'] = $deal_name;
                            $notice['release_date'] = to_date(TIME_UTC, "Y-m-d");
                            $notice['site_name'] = app_conf("SHOP_TITLE");
                            $notice['gift_value'] = $gift_value;
                            $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 ($is_send_sms == 1 && app_conf("SMS_ON") == 1) {
                            $tmpl = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "msg_template where name = '" . $TPL_SMS_NAME . "'");
                            $tmpl_content = $tmpl['content'];
                            $notice['user_name'] = $user_info['user_name'];
                            $notice['deal_name'] = $deal_name;
                            $notice['release_date'] = to_date(TIME_UTC, "Y-m-d");
                            $notice['site_name'] = app_conf("SHOP_TITLE");
                            $notice['gift_value'] = $gift_value;
                            $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_load",array("is_has_loans"=>1),"UPDATE","deal_id=".$id);
        make_repay_plan($deal_info);
        //发借款成功邮件
        send_deal_success_mail_sms($id, $deal_info);
        //发借款成功站内信
        send_deal_success_site_sms($id, $deal_info);
        $return['status'] = 1;
        $return['info'] = "放款成功";
        return $return;
    } else {
        $return['info'] = "放款失败";
        return $return;
    }
}
Пример #4
0
 public function loan()
 {
     $authorized_info = $this->checkLogin();
     $user_id = intval($_REQUEST['u_id']);
     $auth = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "user where id = {$user_id} and pid = " . $authorized_info["id"]);
     if ($user_id && !$auth) {
         showErr("非法访问", 0);
     }
     require APP_ROOT_PATH . "app/Lib/deal_func.php";
     require APP_ROOT_PATH . "app/Lib/page.php";
     $status = intval($_REQUEST['status']);
     $GLOBALS['tmpl']->assign("status", $status);
     //输出借款记录
     $page = intval($_REQUEST['p']);
     if ($page == 0) {
         $page = 1;
     }
     $limit = ($page - 1) * app_conf("PAGE_SIZE") . "," . app_conf("PAGE_SIZE");
     $deal_status = 4;
     if ($status == 1) {
         $deal_status = 5;
     }
     $time = TIME_UTC;
     $count_sql = "select count(*) from " . DB_PREFIX . "deal d LEFT JOIN " . DB_PREFIX . "user u on d.user_id = u.id where deal_status in (4,5) and u.pid ='" . $authorized_info["id"] . "' ";
     if ($is_all == false) {
         $count_sql .= " and d.is_effect = 1 and d.is_delete = 0 ";
     }
     $sql = "select *,d.id as did,start_time as last_time,(load_money/borrow_amount*100) as progress_point,(start_time + enddate*24*3600 - " . $time . ") as remain_time {$extfield} from " . DB_PREFIX . "deal d left join " . DB_PREFIX . "user u on d.user_id = u.id where deal_status in (2,4,5) and u.pid ='" . $authorized_info["id"] . "' ";
     if ($is_all == false) {
         $sql .= " and d.is_effect = 1 and d.is_delete = 0 ";
     }
     if ($where != '') {
         $sql .= " and " . $where;
         $count_sql .= " and " . $where;
     }
     if ($user_id) {
         $sql .= " and user_id = " . $user_id;
         $count_sql .= " and user_id = " . $user_id;
     }
     if ($orderby == '') {
         $sql .= " order by d.id desc ";
     } else {
         $sql .= " order by " . $orderby;
     }
     if ($limit != "") {
         $sql .= " limit " . $limit;
     }
     $result["count"] = $GLOBALS['db']->getOne($count_sql);
     if ($result["count"] > 0) {
         $result["list"] = $GLOBALS['db']->getAll($sql);
         if ($result["list"]) {
             foreach ($result["list"] as $k => $deal) {
                 format_deal_item($deal, $user_name, $user_pwd);
                 $result["list"][$k] = $deal;
             }
         }
     } else {
         $result["list"] = array();
     }
     $deal_ids = array();
     foreach ($result['list'] as $k => $v) {
         if ($v['repay_progress_point'] >= $v['generation_position']) {
             $result['list'][$k]["can_generation"] = 1;
         }
         $deal_ids[] = $v['id'];
     }
     if ($deal_ids) {
         $temp_ids = $GLOBALS['db']->getAll("SELECT `deal_id`,`status` FROM " . DB_PREFIX . "generation_repay_submit WHERE deal_id in(" . implode(",", $deal_ids) . ") ");
         $deal_g_ids = array();
         foreach ($temp_ids as $k => $v) {
             $deal_g_ids[$v['deal_id']] = $v;
         }
         foreach ($result['list'] as $k => $v) {
             $result['list'][$k]["ll_key"] = $GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "deal_repay where user_id = " . $v["user_id"] . " and deal_id = " . $v["did"]);
             $result['list'][$k]["status_format"] = $v["deal_status"] == 5 ? "已还清" : "还款中";
         }
     }
     $GLOBALS['tmpl']->assign("deal_list", $result['list']);
     $page = new Page($result['count'], app_conf("PAGE_SIZE"));
     //初始化分页对象
     $p = $page->show();
     $GLOBALS['tmpl']->assign('pages', $p);
     $GLOBALS['tmpl']->assign("page_title", "客户借款列表");
     $GLOBALS['tmpl']->assign("inc_file", "authorized/authorized_borrowed.html");
     $GLOBALS['tmpl']->display("authorized/a_m.html");
 }