private function getlist($extwhere) { //分类 $cate_tree = M("DealCate")->where('is_delete = 0')->findAll(); $cate_tree = D("DealCate")->toFormatTree($cate_tree, 'name'); $this->assign("cate_tree", $cate_tree); $conditon = " 1=1 "; //开始加载搜索条件 if (intval($_REQUEST['deal_id']) > 0) { $conditon .= " and d.deal_id = " . intval($_REQUEST['deal_id']); } 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']); $conditon .= " and d.cate_id in (" . implode(",", $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); if ($ids) { $conditon .= " and dl.user_id in ({$ids}) "; } else { $conditon .= " and dl.user_id = 0 "; } } if (intval($_REQUEST['user_id']) > 0) { $sql = "select user_name from " . DB_PREFIX . "user where id='" . intval($_REQUEST['user_id']) . "'"; $_REQUEST['user_name'] = $GLOBALS['db']->getOne($sql); $conditon .= " and dl.user_id = " . intval($_REQUEST['user_id']); } $begin_time = trim($_REQUEST['begin_time']) == '' ? 0 : to_timespan($_REQUEST['begin_time']); $end_time = trim($_REQUEST['end_time']) == '' ? 0 : to_timespan($_REQUEST['end_time']); if ($begin_time > 0 || $end_time > 0) { if ($end_time == 0) { $conditon .= " and dl.create_time >= {$begin_time} "; } else { $conditon .= " and dl.create_time between {$begin_time} and {$end_time} "; } } $count = $GLOBALS['db']->getOne("SELECT count(*) FROM " . DB_PREFIX . "deal_load dl LEFT JOIN " . DB_PREFIX . "deal d ON d.id =dl.deal_id where {$conditon} {$extwhere} ORDER BY dl.id DESC "); if (!empty($_REQUEST['listRows'])) { $listRows = $_REQUEST['listRows']; } else { $listRows = ''; } $p = new Page($count, $listRows); if ($count > 0) { $list = $GLOBALS['db']->getAll("SELECT dl.*,d.name,d.repay_time,d.repay_time_type,d.loantype,d.rate,d.cate_id FROM " . DB_PREFIX . "deal_load dl LEFT JOIN " . DB_PREFIX . "deal d ON d.id =dl.deal_id where {$conditon} {$extwhere} ORDER BY dl.id DESC limit " . $p->firstRow . ',' . $p->listRows); $this->assign("list", $list); } $page = $p->show(); $this->assign("page", $page); }
public function shop() { //分类 $cate_tree = M("ShopCate")->where('is_delete = 0')->findAll(); $cate_tree = D("ShopCate")->toFormatTree($cate_tree, 'name'); $this->assign("cate_tree", $cate_tree); //输出团购城市 $city_list = M("DealCity")->where('is_delete = 0')->findAll(); $city_list = D("DealCity")->toFormatTree($city_list, 'name'); $this->assign("city_list", $city_list); //输出品牌 $brand_list = M("Brand")->findAll(); $this->assign("brand_list", $brand_list); //开始加载搜索条件 if (intval($_REQUEST['id']) > 0) { $map['id'] = intval($_REQUEST['id']); } $map['is_delete'] = 0; if (strim($_REQUEST['name']) != '') { $map['name'] = array('like', '%' . strim($_REQUEST['name']) . '%'); } if (intval($_REQUEST['city_id']) > 0) { require_once APP_ROOT_PATH . "system/utils/child.php"; $child = new Child("deal_city"); $city_ids = $child->getChildIds(intval($_REQUEST['city_id'])); $city_ids[] = intval($_REQUEST['city_id']); $map['city_id'] = array("in", $city_ids); } if (intval($_REQUEST['cate_id']) > 0) { require_once APP_ROOT_PATH . "system/utils/child.php"; $child = new Child("shop_cate"); $cate_ids = $child->getChildIds(intval($_REQUEST['cate_id'])); $cate_ids[] = intval($_REQUEST['cate_id']); $map['shop_cate_id'] = array("in", $cate_ids); } if (intval($_REQUEST['brand_id']) > 0) { $map['brand_id'] = intval($_REQUEST['brand_id']); } $map['publish_wait'] = 0; $map['is_shop'] = 1; if (method_exists($this, '_filter')) { $this->_filter($map); } $name = $this->getActionName(); $model = D($name); if (!empty($model)) { $this->_list($model, $map); } $this->display(); return; }
public function export_csv_generation($page = 1) { set_time_limit(0); $limit = ($page - 1) * intval(app_conf("BATCH_PAGE_SIZE")) . "," . intval(app_conf("BATCH_PAGE_SIZE")); if (isset($_REQUEST['_order'])) { $sorder = $_REQUEST['_order']; } else { $sorder = "id"; } switch ($sorder) { case "name": case "cate_id": $order = "d." . $sorder; break; case "site_bad_status": $order = "dr.is_site_bad"; break; case "is_has_send": $order = "d.send_three_msg_time"; break; case "l_key_index": $order = "dr.l_key"; break; default: $order = "gr." . $sorder; break; } //排序方式默认按照倒序排列 //接受 sost参数 0 表示倒序 非0都 表示正序 if (isset($_REQUEST['_sort'])) { $sort = $_REQUEST['_sort'] ? 'asc' : 'desc'; } else { $sort = "desc"; } $condition = " 1= 1 "; if (isset($_REQUEST['status'])) { $status = intval($_REQUEST['status']); if ($status > 0) { $condition .= " AND gr.status=" . ($status - 1); } } else { $condition .= " AND gr.status=0"; $_REQUEST['status'] = 1; } $begin_time = trim($_REQUEST['begin_time']) == "" ? 0 : to_timespan($_REQUEST['begin_time'], "Y-m-d"); $end_time = trim($_REQUEST['end_time']) == "" ? 0 : to_timespan($_REQUEST['end_time'], "Y-m-d"); if ($begin_time > 0 || $end_time > 0) { if ($end_time == 0) { $condition .= " and dr.repay_time >= {$begin_time} "; } else { $condition .= " and dr.repay_time between {$begin_time} and {$end_time} "; } } if ($begin_time > 0) { $_REQUEST['begin_time'] = to_date($begin_time, "Y-m-d"); } if ($end_time > 0) { $_REQUEST['end_time'] = to_date($end_time, "Y-m-d"); } $deal_status = intval($_REQUEST['deal_status']); if ($deal_status > 0) { $condition .= " AND dr.is_site_bad=" . ($deal_status - 1); } if (trim($_REQUEST['name']) != '') { $condition .= " and d.name like '%" . trim($_REQUEST['name']) . "%'"; } if (trim($_REQUEST['user_name']) != '') { $condition .= " and dr.user_id in (select id from " . DB_PREFIX . "user WHERE user_name='" . trim($_REQUEST['user_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']); $condition .= " and d.cate_id in (" . implode(",", $cate_ids) . ") "; } $list = array(); $sql_list = " SELECT gr.*,dr.l_key + 1 as l_key_index,dr.is_site_bad,dr.l_key,d.name,d.cate_id,d.send_three_msg_time,dr.user_id,dr.repay_time,agc.user_name as agency_name,u.user_name,u.mobile FROM " . DB_PREFIX . "generation_repay gr LEFT join " . DB_PREFIX . "deal_repay dr ON dr.id=gr.repay_id LEFT JOIN " . DB_PREFIX . "deal d ON d.id=gr.deal_id LEFT JOIN " . DB_PREFIX . "user agc ON agc.id=gr.agency_id left join " . DB_PREFIX . "user u on u.id=d.user_id WHERE {$condition} ORDER BY {$order} {$sort} LIMIT " . $limit; $list = $GLOBALS['db']->getAll($sql_list); foreach ($list as $k => $v) { $list[$k]['l_key_index'] = "第 " . $v['l_key_index'] . " 期"; $list[$k]['admin_id'] = $GLOBALS['db']->getOne("select adm_name from " . DB_PREFIX . "admin where id=" . $list[$k]['admin_id']); $list[$k]['cate_id'] = $GLOBALS['db']->getOne("select name from " . DB_PREFIX . "deal_cate where id=" . $list[$k]['cate_id']); if ($v['status'] == 0) { $list[$k]['status_format'] = "垫付待收款"; } else { $list[$k]['status_format'] = "垫付已收款"; } if ($v['is_site_bad'] == 1) { $list[$k]['site_bad_status'] = "坏账"; } else { $list[$k]['site_bad_status'] = "正常"; } $list[$k]['total_money'] = $v['repay_money'] + $v['manage_money'] + $v['impose_money'] + $v['manage_impose_money']; $list[$k]['create_time_format'] = to_date($v['create_time'], "Y-m-d H:i"); } if ($list) { register_shutdown_function(array(&$this, 'export_csv_generation'), $page + 1); $generation_value = array('id' => '""', 'name' => '""', 'l_key_index' => '""', 'cate_id' => '""', 'user_name' => '""', 'mobile' => '""', 'repay_money' => '""', 'manage_money' => '""', 'impose_money' => '""', 'manage_impose_money' => '""', 'total_money' => '""', 'repay_time' => '""', 'create_time_format' => '""', 'admin_id' => '""', 'agency_name' => '""', 'site_bad_status' => '""', 'status_format' => '""'); if ($page == 1) { $content = iconv("utf-8", "gbk", "编号,贷款名称,第几期,投标类型,借款人,电话号码,金额[垫],管理费[垫],逾期费[垫],逾期管理费[垫],总垫付,还款日,垫付时间,操作管理员,操作机构,账单状态,收款状态"); } if ($page == 1) { $content = $content . "\n"; } foreach ($list as $k => $v) { $generation_value = array(); $generation_value['id'] = iconv('utf-8', 'gbk', '"' . $v['id'] . '"'); $generation_value['name'] = iconv('utf-8', 'gbk', '"' . $v['name'] . '"'); $generation_value['l_key_index'] = iconv('utf-8', 'gbk', '"' . $v['l_key_index'] . '"'); $generation_value['cate_id'] = iconv('utf-8', 'gbk', '"' . $v['cate_id'] . '"'); $generation_value['user_name'] = iconv('utf-8', 'gbk', '"' . $v['user_name'] . '"'); $generation_value['mobile'] = iconv('utf-8', 'gbk', '"' . $v['mobile'] . '"'); $generation_value['repay_money'] = iconv('utf-8', 'gbk', '"' . format_price($v['repay_money']) . '"'); $generation_value['manage_money'] = iconv('utf-8', 'gbk', '"' . format_price($v['manage_money']) . '"'); $generation_value['impose_money'] = iconv('utf-8', 'gbk', '"' . format_price($v['impose_money']) . '"'); $generation_value['manage_impose_money'] = iconv('utf-8', 'gbk', '"' . format_price($v['manage_impose_money']) . '"'); $generation_value['total_money'] = iconv('utf-8', 'gbk', '"' . format_price($v['total_money']) . '"'); $generation_value['repay_time'] = iconv('utf-8', 'gbk', '"' . to_date($v['repay_time'], "Y-m-d") . '"'); $generation_value['create_time_format'] = iconv('utf-8', 'gbk', '"' . to_date($v['create_time_format'], "Y-m-d") . '"'); $generation_value['admin_id'] = iconv('utf-8', 'gbk', '"' . $v['admin_id'] . '"'); $generation_value['agency_name'] = iconv('utf-8', 'gbk', '"' . $v['agency_name'] . '"'); $generation_value['site_bad_status'] = iconv('utf-8', 'gbk', '"' . $v['site_bad_status'] . '"'); $generation_value['status_format'] = iconv('utf-8', 'gbk', '"' . $v['status_format'] . '"'); $content .= implode(",", $generation_value) . "\n"; } header("Content-Disposition: attachment; filename=generation_list.csv"); echo $content; } else { if ($page == 1) { $this->error(L("NO_RESULT")); } } }
public function all_loan() { if (isset($_REQUEST['_order'])) { $sorder = $_REQUEST['_order']; } else { $sorder = "id"; } switch ($sorder) { case "name": case "cate_id": $order = $sorder; break; default: $order = $sorder; break; } //排序方式默认按照倒序排列 //接受 sost参数 0 表示倒序 非0都 表示正序 if (isset($_REQUEST['_sort'])) { $sort = $_REQUEST['_sort'] ? 'asc' : 'desc'; } else { $sort = "desc"; } //开始加载搜索条件 $condition = " 1=1 "; if (trim($_REQUEST['name']) != '') { $condition .= " and d.name like '%" . trim($_REQUEST['name']) . "%'"; } if (trim($_REQUEST['user_name']) != '') { $condition .= " and u.user_name like '%" . trim($_REQUEST['user_name']) . "%' "; } //type 0所有 1已分配管理员 2已分配管理员或客服 $type = isset($_REQUEST['type']) ? intval($_REQUEST['type']) : 0; if ($type == 0) { } elseif ($type == 1) { $condition .= " AND d.admin_id != 0 "; } else { $condition .= " AND d.admin_id != 0 or d.customers_id != 0 "; } $this->assign('type', $type); //分类 $cate_tree = M("DealCate")->where('is_delete = 0')->findAll(); $cate_tree = D("DealCate")->toFormatTree($cate_tree, 'name'); $this->assign("cate_tree", $cate_tree); //管理员名 $admin_id = isset($_REQUEST['admin_id']) ? intval($_REQUEST['admin_id']) : 0; $this->assign('admin_id', $admin_id); if ($admin_id != 0) { $condition .= " AND d.admin_id = " . $admin_id; } $admin_list = M("Admin")->where('is_department = 0')->findAll(); $this->assign("admin_list", $admin_list); //客服名 $customer_id = isset($_REQUEST['customer_id']) ? intval($_REQUEST['customer_id']) : 0; $this->assign('customer_id', $customer_id); if ($customer_id != 0) { $condition .= " AND d.customers_id = " . $customer_id; } $customer_list = M("Customer")->where('is_delete = 0 and is_effect= 1')->findAll(); $this->assign("customer_list", $customer_list); 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']); $condition .= " and d.cate_id in (" . implode(",", $cate_ids) . ") "; } $sql_count = " SELECT count(*) FROM " . DB_PREFIX . "deal d left join " . DB_PREFIX . "user u on d.user_id = u.id WHERE {$condition} "; $rs_count = $GLOBALS['db']->getOne($sql_count); $list = array(); if ($rs_count > 0) { if (!empty($_REQUEST['listRows'])) { $listRows = $_REQUEST['listRows']; } else { $listRows = ''; } $p = new Page($rs_count, $listRows); $sql_list = " SELECT d.*,a.adm_name as admin_name,c.name as customer_name FROM " . DB_PREFIX . "deal d left join " . DB_PREFIX . "admin a on d.admin_id = a.id left join " . DB_PREFIX . "customer c on c.id = d.customers_id WHERE {$condition} ORDER BY {$order} {$sort} LIMIT " . $p->firstRow . ',' . $p->listRows; $list = $GLOBALS['db']->getAll($sql_list); $page = $p->show(); $this->assign("page", $page); } $sortImg = $sort; //排序图标 $sortAlt = $sort == 'desc' ? l("ASC_SORT") : l("DESC_SORT"); //排序提示 $sort = $sort == 'desc' ? 1 : 0; //排序方式 $this->assign('sort', $sort); $this->assign('order', $sorder); $this->assign('sortImg', $sortImg); $this->assign('sortType', $sortAlt); $this->assign("list", $list); $this->display(); return; }
public function yuqi() { $this->assign("main_title", L("DEAL_YUQI")); //分类 $cate_tree = M("DealCate")->where('is_delete = 0')->findAll(); $cate_tree = D("DealCate")->toFormatTree($cate_tree, 'name'); $this->assign("cate_tree", $cate_tree); //开始加载搜索条件 if (intval($_REQUEST['id']) > 0) { $map['id'] = intval($_REQUEST['id']); } $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; $yuqiday = 0; if (intval($_REQUEST['yuqi_day']) > 0) { $yuqiday = intval($_REQUEST['yuqi_day']); } $temp_ids = M("Deal")->where("publish_wait = 0 AND is_delete=0 AND deal_status = 4 AND (" . TIME_UTC . " - next_repay_time - 24*3600 + 1)/24/3600 > {$yuqiday} ")->Field('id')->findAll(); $deal_ids[] = 0; foreach ($temp_ids as $k => $v) { $deal_ids[] = $v['id']; } $map['id'] = array("in", implode(",", $deal_ids)); if (method_exists($this, '_filter')) { $this->_filter($map); } $name = $this->getActionName(); $model = D($name); if (!empty($model)) { $this->_list($model, $map); } $this->display(); return; }