183 lines
6.9 KiB
PHP
183 lines
6.9 KiB
PHP
<?php
|
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
|
|
|
class Bill extends HD_Controller{
|
|
|
|
private $searchTpAry = array('mobile' => '客户手机号', 'name' => '客户姓名','sid' => '订单号');
|
|
|
|
public function __construct(){
|
|
parent::__construct();
|
|
$this->load->model('receiver/order/receiver_order_bills_model','order_bills_model');
|
|
$this->load->model('auto/auto_series_model');
|
|
$this->load->model('auto/auto_brand_model');
|
|
$this->load->model('auto/auto_attr_model');
|
|
}
|
|
|
|
public function index(){
|
|
$this->lists();
|
|
}
|
|
|
|
public function lists(){
|
|
$status_arr = $this->order_bills_model->get_status();
|
|
$params = $this->input->get();
|
|
|
|
$page = $params['page'] = $params['page'] ? intval($params['page']) : 1;
|
|
$size = $params['size'] = $params['size'] ? intval($params['size']) : 20;
|
|
|
|
$t1 = 'lc_receiver_order_bills';
|
|
$t2 = 'lc_receiver_orders';
|
|
$where = [
|
|
"$t2.id>" => 0,
|
|
];
|
|
|
|
strlen($params['status']) && $where["$t1.status"] = $params['status'];
|
|
|
|
if ($params['title']) {
|
|
$where["{$t2}.{$params['search_tp']} like '%{$params['title']}%'"] = null;
|
|
}
|
|
//创建时间
|
|
if ($params['c_time']) {
|
|
$c_time = explode(' ~ ', $params['c_time']);
|
|
if ($c_time[0]) {
|
|
$where["{$t1}.c_time >="] = strtotime($c_time[0] . ' 00:00:00');
|
|
}
|
|
if ($c_time[1]) {
|
|
$where["{$t1}.c_time <="] = strtotime($c_time[1] . ' 23:59:59');
|
|
}
|
|
}
|
|
|
|
if($params['brand_id']){//品牌
|
|
$where["{$t2}.brand_id"] = $params['brand_id'];
|
|
} else {
|
|
$where["{$t2}.brand_id<>3"] = null;//狸车品牌不显示
|
|
$params['brand_id'] = '';
|
|
}
|
|
if($params['s_id']){//车系
|
|
$where["{$t2}.s_id"] = $params['s_id'];
|
|
} else {
|
|
$params['s_id'] = '';
|
|
}
|
|
if($params['v_id']){//车型
|
|
$where["{$t2}.v_id"] = $params['v_id'];
|
|
} else {
|
|
$params['v_id'] = '';
|
|
}
|
|
if($params['cor_id']){//车身颜色
|
|
$where["{$t2}.cor_id"] = $params['cor_id'];
|
|
} else {
|
|
$params['cor_id'] = '';
|
|
}
|
|
|
|
//销售员筛选
|
|
if($params['admin_id']){
|
|
$where['admin_id'] = $params['admin_id'];
|
|
} else {
|
|
$where_lcb = array();
|
|
if($params['biz_id_admin']){//指定店铺所有销售员
|
|
$where_lcb['biz_id'] = $params['biz_id_admin'];
|
|
} else {
|
|
//指定城市的所有销售员
|
|
$where_biz = array();
|
|
if($params['county_id_admin']){
|
|
$where_biz['county_id'] = $params['county_id_admin'];
|
|
} else if($params['city_id_admin']){
|
|
$where_biz['city_id'] = $params['city_id_admin'];
|
|
}
|
|
if($where_biz){
|
|
$where_biz['status>-1'] = null;
|
|
$this->load->model("biz/biz_model");
|
|
$rows_biz = $this->biz_model->select($where_biz, 'id desc', 0, 0, 'id');
|
|
if($rows_biz){
|
|
$str_ids = implode(',', array_column($rows_biz, 'id'));
|
|
$where_lcb["biz_id in({$str_ids})"] = null;
|
|
} else {
|
|
$where_lcb['biz_id'] = -1;
|
|
}
|
|
}
|
|
}
|
|
//获取目标销售员列表
|
|
if($where_lcb){
|
|
$where_lcb['status>-1'] = null;
|
|
$this->load->model('app/licheb/App_licheb_users_model', 'licheb_user_model');
|
|
$rows_lcb = $this->licheb_user_model->select($where_lcb, 'id desc', 0, 0, 'id');
|
|
if($rows_lcb){
|
|
$str_ids = implode(',', array_column($rows_lcb, 'id'));
|
|
$where["admin_id in({$str_ids})"] = null;
|
|
} else {
|
|
$where['admin_id'] = -1;
|
|
}
|
|
}
|
|
|
|
!$params['city_id_admin'] && $params['city_id_admin'] = '';
|
|
!$params['county_id_admin'] && $params['county_id_admin'] = '';
|
|
!$params['biz_id_admin'] && $params['biz_id_admin'] = '';
|
|
$params['admin_id'] = '';
|
|
}
|
|
|
|
$count = $this->order_bills_model->count_order($where,$t2);
|
|
$lists = [];
|
|
if($count){
|
|
$fileds = "$t1.o_id,$t1.status,$t1.c_time,";
|
|
$fileds.= "$t2.sid,$t2.name,$t2.mobile,$t2.brand_id,$t2.s_id,$t2.v_id,$t2.cor_id,$t2.incor_id,$t2.price,$t2.deposit,$t2.payway,$t2.c_time";
|
|
$rows = $this->order_bills_model->select_order($where,"$t1.id desc",$page,$size,$fileds);
|
|
|
|
//品牌车型
|
|
$brand_arr = array_unique(array_column($rows,'brand_id'));
|
|
$brands = $this->auto_brand_model->get_map_by_ids($brand_arr,'id,name');
|
|
//车系车型
|
|
$series_arr = array_unique(array_column($rows,'s_id'));
|
|
$series = $this->auto_series_model->get_map_by_ids($series_arr,'id,name');
|
|
//获取属性
|
|
$v_arr = array_unique(array_column($rows,'v_id'));
|
|
$cor_arr = array_unique(array_column($rows,'cor_id'));
|
|
$incor_arr = array_unique(array_column($rows,'incor_id'));
|
|
$attr_arr = array_merge($v_arr,$cor_arr,$incor_arr);
|
|
$attr = $this->auto_attr_model->get_map_by_ids($attr_arr,'id,title');
|
|
|
|
foreach($rows as $key=>$val){
|
|
$val['brand_name'] = isset($brands[$val['brand_id']]) ? $brands[$val['brand_id']][0]['name'] : '';
|
|
$val['series_name'] = isset($series[$val['s_id']]) ? $series[$val['s_id']][0]['name'] : '';
|
|
$val['v_name'] = isset($attr[$val['v_id']]) ? $attr[$val['v_id']][0]['title'] : '';
|
|
$val['cor_name'] = isset($attr[$val['cor_id']]) ? $attr[$val['cor_id']][0]['title'] : '';
|
|
$val['incor_name'] = isset($attr[$val['incor_id']]) ? $attr[$val['incor_id']][0]['title'] : '';
|
|
$val['status_name'] = $status_arr[$val['status']];
|
|
$lists[] = $val;
|
|
}
|
|
}
|
|
$this->data['pager'] = array('count' => ceil($count / $size), 'curr' => $page, 'totle' => $count);
|
|
$this->data['lists'] = $lists;
|
|
$this->data['params'] = $params;
|
|
$this->data['searchTpAry'] = $this->searchTpAry;
|
|
$this->data['status_arr'] = $status_arr;
|
|
$this->data['_title'] = '合同签订列表';
|
|
return $this->show_view('receiver/order/bill/lists', true);
|
|
}
|
|
|
|
public function get(){
|
|
}
|
|
|
|
//添加单条数据
|
|
public function add(){
|
|
}
|
|
|
|
//编辑单条数据
|
|
public function edit(){
|
|
}
|
|
|
|
//删除单条数据
|
|
public function del(){
|
|
|
|
}
|
|
|
|
//批量操作(默认修改状态)
|
|
public function batch(){
|
|
|
|
}
|
|
|
|
//导出数据列表
|
|
public function export(){
|
|
|
|
}
|
|
|
|
}
|