Files
liche/admin/libraries/OrdersList.php
T
2021-11-15 14:30:51 +08:00

1599 lines
79 KiB
PHP

<?php
/**
* 订单管理列表
*/
class OrdersList
{
private $ci;
private $searchTpAry = array('name' => '客户姓名', 'mobile' => '客户手机号', 'sid' => '订单号');
private $paywayAry = array(0 => '贷款', 1 => '全款');
public function __construct()
{
$this->ci = &get_instance();
$this->ci->load->model('receiver/order/receiver_orders_model', 'mdOrders');
$this->ci->load->model('app/licheb/app_licheb_users_model', 'mdLichebUsers');
$this->ci->load->model('receiver/receiver_customers_model', 'mdCustomers');
$this->ci->load->model('receiver/receiver_clues_cfrom_model', 'mdCluesCfrom');
$this->ci->load->model("biz/biz_model");
$this->ci->load->model('auto/auto_series_model');
$this->ci->load->model('auto/auto_brand_model');
$this->ci->load->model('auto/auto_attr_model');
}
public function lists($status_pid, $params = array())
{
$result = $show_info = array();
!$params['qdjl_id'] && $params['qdjl_id'] = '';
!$params['cf_title'] && $params['cf_title'] = '';
!$params['cf_clues'] && $params['cf_clues'] = '';
!$params['payway'] && $params['payway'] = '';
!$params['biz_type'] && $params['biz_type'] = '';
$fieldAry = $this->get_fields($status_pid);
$show_info['cfTitleAry'] = $this->ci->mdCustomers->get_sdata('cfrom');//来源类型
$show_info['cfCluesAry'] = $this->ci->mdCustomers->get_sdata('cfrom_clues');//线下来源
$show_info['paywayAry'] = $this->paywayAry;//付款方式
$show_info['bizTypeAry'] = $this->ci->biz_model->type_ary();//门店类型
//渠道经理
$show_info['qdjl_lists'] = $this->ci->mdLichebUsers->select(array('group_id' => 4, 'status' => 1, 'biz_id<>' => '0')
, 'id desc', 0, 0, 'id,uname as name');
if (!strlen($status_pid) || $status_pid == 6 || $status_pid == 7) {
if ($status_pid) {
$params['status'] = $status_pid;
}
$result = $this->orders($params);
$result['show_info'] = $show_info;
$result['fieldAry'] = $fieldAry;
return $result;
}
if ($status_pid == 0) {
$this->ci->load->model('receiver/order/receiver_order_signs_model', 'order_signs_model');
$result = $this->sign($status_pid, $params);
} else if ($status_pid == 1) {
$this->ci->load->model('receiver/order/receiver_order_loans_model', 'order_loans_model');
$result = $this->loan($status_pid, $params);
} else if ($status_pid == 2) {
$this->ci->load->model('receiver/order/receiver_order_ckcars_model', 'order_ckcars_model');
$result = $this->ckcar($status_pid, $params);
} else if ($status_pid == 3) {
$this->ci->load->model('receiver/order/receiver_order_bills_model', 'order_bills_model');
$result = $this->bill($status_pid, $params);
} else if ($status_pid == 4) {
$this->ci->load->model('receiver/order/receiver_order_agents_model', 'order_agents_model');
$result = $this->agent($status_pid, $params);
} else if ($status_pid == 5) {
$this->ci->load->model('receiver/order/receiver_order_deliverys_model', 'order_deliverys_model');
$result = $this->delivery($status_pid, $params);
}
$result['show_info'] = $show_info;
$result['fieldAry'] = $fieldAry;
return $result;
}
/**
* Notes:全部订单
* Created on: 2021/9/18 15:13
* Created by: dengbw
* @param array $params
* @return array
*/
private function orders($params = array())
{
$page = $params['page'] = $params['page'] ? intval($params['page']) : 1;
$size = $params['size'] = $params['size'] ? intval($params['size']) : 20;
$status_arr = $this->ci->mdOrders->statusAry();
$view_type = 'orders';
if ($params['status']) {
$where = ["status" => $params['status']];
$_title = $status_arr[$params['status']]['name'];
$view = 'receiver/order/lists';
if ($params['status'] == 6) {
$view_type = 'deal';
} else if ($params['status'] == 7) {
$view_type = 'refund';
}
} else {
$where = ["status>=" => 0];
$_title = '全部订单';
$view = 'receiver/orders/lists';
}
$where['biz_id<>'] = 1;
if ($_SESSION['admin_info']['biz_id']) {
$biz_ids = implode(',', $_SESSION['admin_info']['biz_id']);
$where["biz_id in ($biz_ids)"] = null;
}
if ($params['biz_type']) {
$where['biz_id in (select id from lc_biz where type = ' . $params['biz_type'] . ' and status=1)'] = null;
}
if ($params['cf_title'] || $params['cf_clues'] || $params['cfrom_id'] || $params['cfrom_id2']) {
$where_c = 'status>=0';
if ($params['cfrom_id'] == 24) {
$where_c .= ' and cf_id = 24';
$params['cfrom_id2'] && $where_c .= ' and t_id = ' . $params['cfrom_id2'];
} else {
if ($params['cfrom_id2']) {
$where_c .= ' and cf_id = ' . $params['cfrom_id2'];
} else if ($params['cfrom_id']) {
$cf_rows = $this->ci->mdCluesCfrom->select(['pid' => $params['cfrom_id']], '', '', '', 'id');
$cf_ids = array_column($cf_rows, 'id');
$cf_ids[] = $params['cfrom_id'];
$cf_str_ids = implode(',', array_filter($cf_ids));
$cf_str_ids && $where_c .= " and cf_id in ({$cf_str_ids})";
}
}
$params['cf_title'] && $where_c .= ' and cf_title = "' . $params['cf_title'] . '"';
$params['cf_clues'] && $where_c .= ' and cf_clues = "' . $params['cf_clues'] . '"';
$where['rid in (select id from lc_receiver_customers where ' . $where_c . ')'] = null;
}
if (strlen($params['payway'])) {
$where["payway"] = $params['payway'];
}
if ($params['qdjl_id']) {//渠道经理
$re_bu = $this->ci->mdLichebUsers->get(array('id' => $params['qdjl_id']));
if ($re_bu['biz_id']) {
$where["biz_id in({$re_bu['biz_id']})"] = null;
} else {
$where['biz_id'] = -1;
}
}
if ($params['title']) {
$where["{$params['search_tp']} like '%{$params['title']}%'"] = null;
}
//创建时间
if ($params['c_time']) {
$c_time = explode(' ~ ', $params['c_time']);
if ($c_time[0]) {
$where["c_time >="] = strtotime($c_time[0] . ' 00:00:00');
}
if ($c_time[1]) {
$where["c_time <="] = strtotime($c_time[1] . ' 23:59:59');
}
}
//开票时间
if ($params['bill_time']) {
$bill_time = explode(' ~ ', $params['bill_time']);
if ($bill_time[0]) {
$where["bill_time >="] = $bill_time[0] . ' 00:00:00';
}
if ($bill_time[1]) {
$where["bill_time <="] = $bill_time[1] . ' 23:59:59';
}
}
if ($params['brand_id']) {//品牌
$where["brand_id"] = $params['brand_id'];
} else {
$where["brand_id<>3"] = null;//狸车品牌不显示
$params['brand_id'] = '';
}
if ($params['s_id']) {//车系
$where["s_id"] = $params['s_id'];
} else {
$params['s_id'] = '';
}
if ($params['v_id']) {//车型
$where["v_id"] = $params['v_id'];
} else {
$params['v_id'] = '';
}
if ($params['cor_id']) {//车身颜色
$where["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;
$rows_biz = $this->ci->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;
$rows_lcb = $this->ci->mdLichebUsers->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->ci->mdOrders->count($where);
$lists = [];
if ($count) {
$fileds = "id,rid,name,mobile,brand_id,s_id,v_id,cor_id,incor_id,price,deposit,payway,status,c_time,biz_id";
$rows = $this->ci->mdOrders->select($where, "c_time desc", $page, $size, $fileds);
//客户来源
$str_rids = implode(',', array_unique(array_column($rows, 'rid')));
!$str_rids && $str_rids = 0;
$customers = $this->ci->mdCustomers->map('id', '', array("id in({$str_rids})" => null),'','','','id,cf_title,cf_clues,cf_id');
$cfroms = [];
if($customers){
foreach($customers as $key=>$val){
$cf_id_arr[] = $val[0]['cf_id'];
}
//获取来源
$cfroms = $this->ci->mdCluesCfrom->get_map_by_ids($cf_id_arr, 'id,title');
}
//门店
$str_biz_ids = implode(',', array_unique(array_column($rows, 'biz_id')));
!$str_biz_ids && $str_biz_ids = 0;
$bizs = $this->ci->biz_model->map('id', 'biz_name', array("id in({$str_biz_ids})" => null));
//品牌车型
$brand_arr = array_unique(array_column($rows, 'brand_id'));
$brands = $this->ci->auto_brand_model->get_map_by_ids($brand_arr, 'id,name');
//车系车型
$series_arr = array_unique(array_column($rows, 's_id'));
$series = $this->ci->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->ci->auto_attr_model->get_map_by_ids($attr_arr, 'id,title');
foreach ($rows as $key => $val) {
$fields = array();
$brand_name = isset($brands[$val['brand_id']]) ? $brands[$val['brand_id']][0]['name'] : '';
$series_name = isset($series[$val['s_id']]) ? $series[$val['s_id']][0]['name'] : '';
$v_name = isset($attr[$val['v_id']]) ? $attr[$val['v_id']][0]['title'] : '';
$cor_name = isset($attr[$val['cor_id']]) ? $attr[$val['cor_id']][0]['title'] : '';
$fields['mobile'] = $val['mobile'];
$fields['name'] = $size > 1000 ? $val['name']
: '<a href="javascript:;" data-open="/receiver/orders/get?id=' . $val['id'] . '">' . $val['name'] . '<br>' . $val['mobile'] . '</a>';
$fields['car_name'] = "{$brand_name}-{$series_name}-{$v_name}-{$cor_name}";
$fields['price'] = number_format($val['price'], 2);
$fields['deposit'] = number_format($val['deposit'], 2);
$fields['payway_name'] = $this->paywayAry[$val['payway']];
$fields['incor_name'] = isset($attr[$val['incor_id']]) ? $attr[$val['incor_id']][0]['title'] : '';
$fields['status_name'] = $status_arr[$val['status']]['name'];
$fields['biz_name'] = $bizs[$val['biz_id']];
$fields['c_time'] = date('Y-m-d H:i:s', $val['c_time']);
$fields['cf_title'] = $customers[$val['rid']][0]['cf_title'];
$fields['cf_clues'] = $customers[$val['rid']][0]['cf_clues'];
$fields['cf_name'] = $cfroms[$customers[$val['rid']][0]['cf_id']][0]['title'];
$lists[] = $fields;
}
}
$pager = array('count' => ceil($count / $size), 'curr' => $page, 'totle' => $count);
$_title = $size > 1000 ? $_title : $_title . '列表';
$view_type != 'orders' && $status_arr = [];
return array('lists' => $lists, 'pager' => $pager, 'params' => $params, 'status_arr' => $status_arr
, 'searchTpAry' => $this->searchTpAry, 'view' => $view, 'view_type' => $view_type, '_title' => $_title);
}
/**
* Notes:合同签订列表
* Created on: 2021/9/17 13:44
* Created by: dengbw
* @param array $params
* @param array $status_pid
* @return array
*/
private function sign($status_pid, $params = array())
{
$page = $params['page'] = $params['page'] ? intval($params['page']) : 1;
$size = $params['size'] = $params['size'] ? intval($params['size']) : 20;
$t1 = 'lc_receiver_order_signs';
$t2 = 'lc_receiver_orders';
$where = [
"$t2.status>=" => 0,
"$t2.biz_id!=" => 1,
];
if ($_SESSION['admin_info']['biz_id']) {
$biz_ids = implode(',', $_SESSION['admin_info']['biz_id']);
$where["$t2.biz_id in ($biz_ids)"] = null;
}
$biz_type = $params['biz_type'];
if ($biz_type) {
$where["$t2.biz_id in (select id from lc_biz where type = $biz_type and status=1)"] = null;
}
if ($params['cf_title'] || $params['cf_clues'] || $params['cfrom_id'] || $params['cfrom_id2']) {
$where_c = 'status>=0';
if ($params['cfrom_id'] == 24) {
$where_c .= ' and cf_id = 24';
$params['cfrom_id2'] && $where_c .= ' and t_id = ' . $params['cfrom_id2'];
} else {
if ($params['cfrom_id2']) {
$where_c .= ' and cf_id = ' . $params['cfrom_id2'];
} else if ($params['cfrom_id']) {
$cf_rows = $this->ci->mdCluesCfrom->select(['pid' => $params['cfrom_id']], '', '', '', 'id');
$cf_ids = array_column($cf_rows, 'id');
$cf_ids[] = $params['cfrom_id'];
$cf_str_ids = implode(',', array_filter($cf_ids));
$cf_str_ids && $where_c .= " and cf_id in ({$cf_str_ids})";
}
}
$params['cf_title'] && $where_c .= ' and cf_title = "' . $params['cf_title'] . '"';
$params['cf_clues'] && $where_c .= ' and cf_clues = "' . $params['cf_clues'] . '"';
$where[$t2 . '.rid in (select id from lc_receiver_customers where ' . $where_c . ')'] = null;
}
if (strlen($params['payway'])) {
$where["{$t2}.payway"] = $params['payway'];
}
if ($params['qdjl_id']) {//渠道经理
$re_bu = $this->ci->mdLichebUsers->get(array('id' => $params['qdjl_id']));
if ($re_bu['biz_id']) {
$where["biz_id in({$re_bu['biz_id']})"] = null;
} else {
$where['biz_id'] = -1;
}
}
$statusAry = $this->ci->mdOrders->statusAry($status_pid);
if ($params['list_type'] == 'all') {
$status_arr = $statusAry['list'];
strlen($params['status']) && $where["$t1.status"] = $params['status'];
} else {
$status_arr = $statusAry['menu_list'];
if (!strlen($params['status'])) {
$params['status'] = $statusAry['menu_default'];
}
$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["{$t2}.c_time >="] = strtotime($c_time[0] . ' 00:00:00');
}
if ($c_time[1]) {
$where["{$t2}.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;
$rows_biz = $this->ci->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;
$rows_lcb = $this->ci->mdLichebUsers->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->ci->order_signs_model->count_order($where);
$lists = [];
if ($count) {
$fileds = "$t1.id,$t1.o_id,$t1.status,";
$fileds .= "$t2.rid,$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, {$t2}.admin_id";
$rows = $this->ci->order_signs_model->select_order($where, "$t2.c_time desc", $page, $size, $fileds);
$brand_arr = $series_arr = $v_arr = $cor_arr = $incor_arr = array();
$admin_ids = array();
if ($rows) {
foreach ($rows as $v) {
!in_array($v['brand_id'], $brand_arr) && $brand_arr[] = $v['brand_id'];
!in_array($v['s_id'], $series_arr) && $series_arr[] = $v['s_id'];
!in_array($v['v_id'], $v_arr) && $v_arr[] = $v['v_id'];
!in_array($v['cor_id'], $cor_arr) && $cor_arr[] = $v['cor_id'];
!in_array($v['incor_id'], $incor_arr) && $incor_arr[] = $v['incor_id'];
$v['admin_id'] && !in_array($v['admin_id'], $admin_ids) && $admin_ids[] = $v['admin_id'];
}
}
//客户来源
$str_rids = implode(',', array_unique(array_column($rows, 'rid')));
!$str_rids && $str_rids = 0;
$customers = $this->ci->mdCustomers->map('id', '', array("id in({$str_rids})" => null),'','','','id,cf_title,cf_clues,cf_id');
$cfroms = [];
if($customers){
foreach($customers as $key=>$val){
$cf_id_arr[] = $val[0]['cf_id'];
}
//获取来源
$cfroms = $this->ci->mdCluesCfrom->get_map_by_ids($cf_id_arr, 'id,title');
}
//品牌车型
$brands = $this->ci->auto_brand_model->get_map_by_ids($brand_arr, 'id,name');
//车系车型
$series = $this->ci->auto_series_model->get_map_by_ids($series_arr, 'id,name');
//获取属性
$attr_arr = array_merge($v_arr, $cor_arr, $incor_arr);
$attr = $this->ci->auto_attr_model->get_map_by_ids($attr_arr, 'id,title');
//获取销售
$map_admin = array();
$map_biz = array();
if ($admin_ids) {
$str_ids = implode(',', $admin_ids);
$where = array("id in({$str_ids})" => null);
$select = 'id, uname, biz_id';
$rows_admin = $this->ci->mdLichebUsers->select($where, 'id desc', 0, 0, $select);
if ($rows_admin) {
$biz_ids = array();
foreach ($rows_admin as $v) {
$map_admin[$v['id']] = $v;
!in_array($v['biz_id'], $biz_ids) && $biz_ids[] = $v['biz_id'];
}
if ($biz_ids) {
$str_ids = implode(',', $biz_ids);
$where = array("id in({$str_ids})" => null);
$map_biz = $this->ci->biz_model->map('id', 'biz_name', $where);
}
}
}
foreach ($rows as $key => $val) {
$fields = array();
$admin = $map_admin[$val['admin_id']];
$brand_name = isset($brands[$val['brand_id']]) ? $brands[$val['brand_id']][0]['name'] : '';
$series_name = isset($series[$val['s_id']]) ? $series[$val['s_id']][0]['name'] : '';
$v_name = isset($attr[$val['v_id']]) ? $attr[$val['v_id']][0]['title'] : '';
$cor_name = isset($attr[$val['cor_id']]) ? $attr[$val['cor_id']][0]['title'] : '';
$fields['mobile'] = $val['mobile'];
$fields['name'] = $size > 1000 ? $val['name']
: '<a href="javascript:;" data-open="/receiver/orders/get?id=' . $val['o_id'] . '">' . $val['name'] . '<br>' . $val['mobile'] . '</a>';
$fields['car_name'] = "{$brand_name}-{$series_name}-{$v_name}-{$cor_name}";
$fields['payway_name'] = $this->paywayAry[$val['payway']];
$fields['c_time'] = date('Y-m-d H:i:s', $val['c_time']);
$fields['incor_name'] = isset($attr[$val['incor_id']]) ? $attr[$val['incor_id']][0]['title'] : '';
$fields['status_name'] = $status_arr[$val['status']];
$fields['admin_name'] = $admin ? $admin['uname'] : '';
$fields['price'] = $val['price'] > 1 ? number_format($val['price']) : number_format($val['price'], 2);
$fields['deposit'] = $val['deposit'] > 1 ? number_format($val['deposit']) : number_format($val['deposit'], 2);
$fields['biz_name'] = $map_biz[$admin['biz_id']];
$fields['cf_title'] = $customers[$val['rid']][0]['cf_title'];
$cf_name = '';
$cfroms[$customers[$val['rid']][0]['cf_id']][0]['title'] && $cf_name = $cfroms[$customers[$val['rid']][0]['cf_id']][0]['title'].'(线上)<br>';
$customers[$val['rid']][0]['cf_clues'] && $cf_name .= $customers[$val['rid']][0]['cf_clues'].'(线下)';
$fields['cf_name'] = $cf_name;
$lists[] = $fields;
}
}
$pager = array('count' => ceil($count / $size), 'curr' => $page, 'totle' => $count);
$_title = $size > 1000 ? $statusAry['name'] : $statusAry['name'] . '列表';
return array('lists' => $lists, 'pager' => $pager, 'params' => $params, 'status_arr' => $status_arr
, 'searchTpAry' => $this->searchTpAry, 'view' => 'receiver/order/lists', 'view_type' => 'sign', '_title' => $_title);
}
/**
* Notes:分期办理列表
* Created on: 2021/9/17 15:37
* Created by: dengbw
* @param $status_pid
* @param array $params
* @return array
*/
private function loan($status_pid, $params = array())
{
$page = $params['page'] = $params['page'] ? intval($params['page']) : 1;
$size = $params['size'] = $params['size'] ? intval($params['size']) : 20;
$t1 = 'lc_receiver_order_loans';
$t2 = 'lc_receiver_orders';
$where = [
"$t2.status>=" => 0,
"$t2.biz_id!=" => 1,
];
if ($_SESSION['admin_info']['biz_id']) {
$biz_ids = implode(',', $_SESSION['admin_info']['biz_id']);
$where["$t2.biz_id in ($biz_ids)"] = null;
}
$biz_type = $params['biz_type'];
if ($biz_type) {
$where["$t2.biz_id in (select id from lc_biz where type = $biz_type and status=1)"] = null;
}
if ($params['cf_title'] || $params['cf_clues'] || $params['cfrom_id'] || $params['cfrom_id2']) {
$where_c = 'status>=0';
if ($params['cfrom_id'] == 24) {
$where_c .= ' and cf_id = 24';
$params['cfrom_id2'] && $where_c .= ' and t_id = ' . $params['cfrom_id2'];
} else {
if ($params['cfrom_id2']) {
$where_c .= ' and cf_id = ' . $params['cfrom_id2'];
} else if ($params['cfrom_id']) {
$cf_rows = $this->ci->mdCluesCfrom->select(['pid' => $params['cfrom_id']], '', '', '', 'id');
$cf_ids = array_column($cf_rows, 'id');
$cf_ids[] = $params['cfrom_id'];
$cf_str_ids = implode(',', array_filter($cf_ids));
$cf_str_ids && $where_c .= " and cf_id in ({$cf_str_ids})";
}
}
$params['cf_title'] && $where_c .= ' and cf_title = "' . $params['cf_title'] . '"';
$params['cf_clues'] && $where_c .= ' and cf_clues = "' . $params['cf_clues'] . '"';
$where[$t2 . '.rid in (select id from lc_receiver_customers where ' . $where_c . ')'] = null;
}
if (strlen($params['payway'])) {
$where["{$t2}.payway"] = $params['payway'];
}
if ($params['qdjl_id']) {//渠道经理
$re_bu = $this->ci->mdLichebUsers->get(array('id' => $params['qdjl_id']));
if ($re_bu['biz_id']) {
$where["biz_id in({$re_bu['biz_id']})"] = null;
} else {
$where['biz_id'] = -1;
}
}
$statusAry = $this->ci->mdOrders->statusAry($status_pid);
if ($params['list_type'] == 'all') {
$status_arr = $statusAry['list'];
strlen($params['status']) && $where["$t1.status"] = $params['status'];
} else {
$status_arr = $statusAry['menu_list'];
if (!strlen($params['status'])) {
$params['status'] = $statusAry['menu_default'];
}
$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;
$rows_biz = $this->ci->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;
$rows_lcb = $this->ci->mdLichebUsers->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->ci->order_loans_model->count_order($where, $t2);
$lists = [];
if ($count) {
$this->ci->load->model('sys/sys_finance_model');
$fileds = "$t1.o_id,$t1.title,$t1.year,$t1.first_price,$t1.status,$t1.c_time,";
$fileds .= "$t2.rid,$t2.id,$t2.name,$t2.mobile,$t2.sid,$t2.finance_id,$t2.money_json";
$rows = $this->ci->order_loans_model->select_order($where, "$t2.c_time desc", $page, $size, $fileds);
//客户来源
$str_rids = implode(',', array_unique(array_column($rows, 'rid')));
!$str_rids && $str_rids = 0;
$customers = $this->ci->mdCustomers->map('id', '', array("id in({$str_rids})" => null),'','','','id,cf_title,cf_clues,cf_id');
$cfroms = [];
if($customers){
foreach($customers as $key=>$val){
$cf_id_arr[] = $val[0]['cf_id'];
}
//获取来源
$cfroms = $this->ci->mdCluesCfrom->get_map_by_ids($cf_id_arr, 'id,title');
}
$finance_arr = array_column($rows, 'finance_id');
$finance_rows = $this->ci->sys_finance_model->get_map_by_ids($finance_arr, 'id,title');
foreach ($rows as $key => $val) {
$fields = array();
$money_json = json_decode($val['money_json'], true);
$price_loan = $money_json['price_loan'] ? $money_json['price_loan'] : 0;
$fields['mobile'] = $val['mobile'];
$fields['name'] = $size > 1000 ? $val['name']
: '<a href="javascript:;" data-open="/receiver/orders/get?id=' . $val['o_id'] . '">' . $val['name'] . '<br>' . $val['mobile'] . '</a>';
$fields['title'] = $finance_rows[$val['finance_id']] ? $finance_rows[$val['finance_id']][0]['title'] : '';
$fields['price_loan'] = number_format($price_loan, 2);
$fields['c_time'] = date('Y-m-d H:i:s', $val['c_time']);
$fields['status_name'] = $status_arr[$val['status']];
$fields['cf_title'] = $customers[$val['rid']][0]['cf_title'];
$cf_name = '';
$cfroms[$customers[$val['rid']][0]['cf_id']][0]['title'] && $cf_name = $cfroms[$customers[$val['rid']][0]['cf_id']][0]['title'].'(线上)<br>';
$customers[$val['rid']][0]['cf_clues'] && $cf_name .= $customers[$val['rid']][0]['cf_clues'].'(线下)';
$fields['cf_name'] = $cf_name;
$lists[] = $fields;
}
}
$pager = array('count' => ceil($count / $size), 'curr' => $page, 'totle' => $count);
$_title = $size > 1000 ? $statusAry['name'] : $statusAry['name'] . '列表';
return array('lists' => $lists, 'pager' => $pager, 'params' => $params, 'status_arr' => $status_arr
, 'searchTpAry' => $this->searchTpAry, 'view' => 'receiver/order/lists', 'view_type' => 'loan', '_title' => $_title);
}
/**
* Notes:车辆分配列表
* Created on: 2021/9/17 15:57
* Created by: dengbw
* @param $status_pid
* @param array $params
* @return array
*/
private function ckcar($status_pid, $params = array())
{
$page = $params['page'] = $params['page'] ? intval($params['page']) : 1;
$size = $params['size'] = $params['size'] ? intval($params['size']) : 20;
$t1 = 'lc_receiver_order_ckcars';
$t2 = 'lc_receiver_orders';
$where = [
"$t2.status>=" => 0,
"$t2.biz_id!=" => 1,
];
if ($_SESSION['admin_info']['biz_id']) {
$biz_ids = implode(',', $_SESSION['admin_info']['biz_id']);
$where["$t2.biz_id in ($biz_ids)"] = null;
}
$biz_type = $params['biz_type'];
if ($biz_type) {
$where["$t2.biz_id in (select id from lc_biz where type = $biz_type and status=1)"] = null;
}
if ($params['cf_title'] || $params['cf_clues'] || $params['cfrom_id'] || $params['cfrom_id2']) {
$where_c = 'status>=0';
if ($params['cfrom_id'] == 24) {
$where_c .= ' and cf_id = 24';
$params['cfrom_id2'] && $where_c .= ' and t_id = ' . $params['cfrom_id2'];
} else {
if ($params['cfrom_id2']) {
$where_c .= ' and cf_id = ' . $params['cfrom_id2'];
} else if ($params['cfrom_id']) {
$cf_rows = $this->ci->mdCluesCfrom->select(['pid' => $params['cfrom_id']], '', '', '', 'id');
$cf_ids = array_column($cf_rows, 'id');
$cf_ids[] = $params['cfrom_id'];
$cf_str_ids = implode(',', array_filter($cf_ids));
$cf_str_ids && $where_c .= " and cf_id in ({$cf_str_ids})";
}
}
$params['cf_title'] && $where_c .= ' and cf_title = "' . $params['cf_title'] . '"';
$params['cf_clues'] && $where_c .= ' and cf_clues = "' . $params['cf_clues'] . '"';
$where[$t2 . '.rid in (select id from lc_receiver_customers where ' . $where_c . ')'] = null;
}
if (strlen($params['payway'])) {
$where["{$t2}.payway"] = $params['payway'];
}
if ($params['qdjl_id']) {//渠道经理
$re_bu = $this->ci->mdLichebUsers->get(array('id' => $params['qdjl_id']));
if ($re_bu['biz_id']) {
$where["biz_id in({$re_bu['biz_id']})"] = null;
} else {
$where['biz_id'] = -1;
}
}
$statusAry = $this->ci->mdOrders->statusAry($status_pid);
if ($params['list_type'] == 'all') {
$status_arr = $statusAry['list'];
strlen($params['status']) && $where["$t1.status"] = $params['status'];
} else {
$status_arr = $statusAry['menu_list'];
if (!strlen($params['status'])) {
$params['status'] = $statusAry['menu_default'];
}
$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;
$rows_biz = $this->ci->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;
$rows_lcb = $this->ci->mdLichebUsers->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->ci->order_ckcars_model->count_order($where, $t2);
$lists = [];
if ($count) {
$fileds = "$t1.o_id,$t1.status,$t1.c_time,";
$fileds .= "$t2.rid,$t2.sid,$t2.name,$t2.mobile,$t2.brand_id,$t2.biz_id,$t2.s_id,$t2.v_id,$t2.cor_id,$t2.incor_id,$t2.price,$t2.deposit,$t2.payway,$t2.c_time";
$rows = $this->ci->order_ckcars_model->select_order($where, "$t2.c_time desc", $page, $size, $fileds);
//客户来源
$str_rids = implode(',', array_unique(array_column($rows, 'rid')));
!$str_rids && $str_rids = 0;
$customers = $this->ci->mdCustomers->map('id', '', array("id in({$str_rids})" => null),'','','','id,cf_title,cf_clues,cf_id');
$cfroms = [];
if($customers){
foreach($customers as $key=>$val){
$cf_id_arr[] = $val[0]['cf_id'];
}
//获取来源
$cfroms = $this->ci->mdCluesCfrom->get_map_by_ids($cf_id_arr, 'id,title');
}
//门店
$str_biz_ids = implode(',', array_unique(array_column($rows, 'biz_id')));
!$str_biz_ids && $str_biz_ids = 0;
$bizs = $this->ci->biz_model->map('id', 'biz_name', array("id in({$str_biz_ids})" => null));
//品牌车型
$brand_arr = array_unique(array_column($rows, 'brand_id'));
$brands = $this->ci->auto_brand_model->get_map_by_ids($brand_arr, 'id,name');
//车系车型
$series_arr = array_unique(array_column($rows, 's_id'));
$series = $this->ci->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->ci->auto_attr_model->get_map_by_ids($attr_arr, 'id,title');
foreach ($rows as $key => $val) {
$fields = array();
$brand_name = isset($brands[$val['brand_id']]) ? $brands[$val['brand_id']][0]['name'] : '';
$series_name = isset($series[$val['s_id']]) ? $series[$val['s_id']][0]['name'] : '';
$v_name = isset($attr[$val['v_id']]) ? $attr[$val['v_id']][0]['title'] : '';
$cor_name = isset($attr[$val['cor_id']]) ? $attr[$val['cor_id']][0]['title'] : '';
$fields['mobile'] = $val['mobile'];
$fields['name'] = $size > 1000 ? $val['name']
: '<a href="javascript:;" data-open="/receiver/orders/get?id=' . $val['o_id'] . '">' . $val['name'] . '<br>' . $val['mobile'] . '</a>';
$fields['car_name'] = "{$brand_name}-{$series_name}-{$v_name}-{$cor_name}";
$fields['price'] = number_format($val['price'], 2);
$fields['deposit'] = number_format($val['deposit'], 2);
$fields['payway_name'] = $this->paywayAry[$val['payway']];
$fields['incor_name'] = isset($attr[$val['incor_id']]) ? $attr[$val['incor_id']][0]['title'] : '';
$fields['status_name'] = $status_arr[$val['status']];
$fields['biz_name'] = $bizs[$val['biz_id']];
$fields['cf_title'] = $customers[$val['rid']][0]['cf_title'];
$cf_name = '';
$cfroms[$customers[$val['rid']][0]['cf_id']][0]['title'] && $cf_name = $cfroms[$customers[$val['rid']][0]['cf_id']][0]['title'].'(线上)<br>';
$customers[$val['rid']][0]['cf_clues'] && $cf_name .= $customers[$val['rid']][0]['cf_clues'].'(线下)';
$fields['cf_name'] = $cf_name;
$lists[] = $fields;
}
}
$pager = array('count' => ceil($count / $size), 'curr' => $page, 'totle' => $count);
$_title = $size > 1000 ? $statusAry['name'] : $statusAry['name'] . '列表';
return array('lists' => $lists, 'pager' => $pager, 'params' => $params, 'status_arr' => $status_arr
, 'searchTpAry' => $this->searchTpAry, 'view' => 'receiver/order/lists', 'view_type' => 'ckcar', '_title' => $_title);
}
/**
* Notes:开票相关列表
* Created on: 2021/9/17 16:14
* Created by: dengbw
* @param $status_pid
* @param array $params
* @return array
*/
private function bill($status_pid, $params = array())
{
$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.status>=" => 0,
"$t2.biz_id!=" => 1,
];
if ($_SESSION['admin_info']['biz_id']) {
$biz_ids = implode(',', $_SESSION['admin_info']['biz_id']);
$where["$t2.biz_id in ($biz_ids)"] = null;
}
$biz_type = $params['biz_type'];
if ($biz_type) {
$where["$t2.biz_id in (select id from lc_biz where type = $biz_type and status=1)"] = null;
}
if ($params['cf_title'] || $params['cf_clues'] || $params['cfrom_id'] || $params['cfrom_id2']) {
$where_c = 'status>=0';
if ($params['cfrom_id'] == 24) {
$where_c .= ' and cf_id = 24';
$params['cfrom_id2'] && $where_c .= ' and t_id = ' . $params['cfrom_id2'];
} else {
if ($params['cfrom_id2']) {
$where_c .= ' and cf_id = ' . $params['cfrom_id2'];
} else if ($params['cfrom_id']) {
$cf_rows = $this->ci->mdCluesCfrom->select(['pid' => $params['cfrom_id']], '', '', '', 'id');
$cf_ids = array_column($cf_rows, 'id');
$cf_ids[] = $params['cfrom_id'];
$cf_str_ids = implode(',', array_filter($cf_ids));
$cf_str_ids && $where_c .= " and cf_id in ({$cf_str_ids})";
}
}
$params['cf_title'] && $where_c .= ' and cf_title = "' . $params['cf_title'] . '"';
$params['cf_clues'] && $where_c .= ' and cf_clues = "' . $params['cf_clues'] . '"';
$where[$t2 . '.rid in (select id from lc_receiver_customers where ' . $where_c . ')'] = null;
}
if (strlen($params['payway'])) {
$where["{$t2}.payway"] = $params['payway'];
}
if ($params['qdjl_id']) {//渠道经理
$re_bu = $this->ci->mdLichebUsers->get(array('id' => $params['qdjl_id']));
if ($re_bu['biz_id']) {
$where["biz_id in({$re_bu['biz_id']})"] = null;
} else {
$where['biz_id'] = -1;
}
}
$statusAry = $this->ci->mdOrders->statusAry($status_pid);
if ($params['list_type'] == 'all') {
$status_arr = $statusAry['list'];
strlen($params['status']) && $where["$t1.status"] = $params['status'];
} else {
$status_arr = $statusAry['menu_list'];
if (!strlen($params['status'])) {
$params['status'] = $statusAry['menu_default'];
}
$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;
$rows_biz = $this->ci->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;
$rows_lcb = $this->ci->mdLichebUsers->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->ci->order_bills_model->count_order($where, $t2);
$lists = [];
if ($count) {
$fileds = "$t1.o_id,$t1.status,$t1.c_time,";
$fileds .= "$t2.rid,$t2.sid,$t2.name,$t2.mobile,$t2.brand_id,$t2.biz_id,$t2.s_id,$t2.v_id,$t2.cor_id,$t2.incor_id,$t2.price,$t2.deposit,$t2.payway,$t2.c_time";
$rows = $this->ci->order_bills_model->select_order($where, "$t2.c_time desc", $page, $size, $fileds);
//客户来源
$str_rids = implode(',', array_unique(array_column($rows, 'rid')));
!$str_rids && $str_rids = 0;
$customers = $this->ci->mdCustomers->map('id', '', array("id in({$str_rids})" => null),'','','','id,cf_title,cf_clues,cf_id');
$cfroms = [];
if($customers){
foreach($customers as $key=>$val){
$cf_id_arr[] = $val[0]['cf_id'];
}
//获取来源
$cfroms = $this->ci->mdCluesCfrom->get_map_by_ids($cf_id_arr, 'id,title');
}
//门店
$str_biz_ids = implode(',', array_unique(array_column($rows, 'biz_id')));
!$str_biz_ids && $str_biz_ids = 0;
$bizs = $this->ci->biz_model->map('id', 'biz_name', array("id in({$str_biz_ids})" => null));
//品牌车型
$brand_arr = array_unique(array_column($rows, 'brand_id'));
$brands = $this->ci->auto_brand_model->get_map_by_ids($brand_arr, 'id,name');
//车系车型
$series_arr = array_unique(array_column($rows, 's_id'));
$series = $this->ci->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->ci->auto_attr_model->get_map_by_ids($attr_arr, 'id,title');
foreach ($rows as $key => $val) {
$fields = array();
$brand_name = isset($brands[$val['brand_id']]) ? $brands[$val['brand_id']][0]['name'] : '';
$series_name = isset($series[$val['s_id']]) ? $series[$val['s_id']][0]['name'] : '';
$v_name = isset($attr[$val['v_id']]) ? $attr[$val['v_id']][0]['title'] : '';
$cor_name = isset($attr[$val['cor_id']]) ? $attr[$val['cor_id']][0]['title'] : '';
$fields['mobile'] = $val['mobile'];
$fields['name'] = $size > 1000 ? $val['name']
: '<a href="javascript:;" data-open="/receiver/orders/get?id=' . $val['o_id'] . '">' . $val['name'] . '<br>' . $val['mobile'] . '</a>';
$fields['car_name'] = "{$brand_name}-{$series_name}-{$v_name}-{$cor_name}";
$fields['price'] = number_format($val['price'], 2);
$fields['deposit'] = number_format($val['deposit'], 2);
$fields['payway_name'] = $this->paywayAry[$val['payway']];
$fields['incor_name'] = isset($attr[$val['incor_id']]) ? $attr[$val['incor_id']][0]['title'] : '';
$fields['status_name'] = $status_arr[$val['status']];
$fields['biz_name'] = $bizs[$val['biz_id']];
$fields['cf_title'] = $customers[$val['rid']];
$fields['cf_title'] = $customers[$val['rid']][0]['cf_title'];
$cf_name = '';
$cfroms[$customers[$val['rid']][0]['cf_id']][0]['title'] && $cf_name = $cfroms[$customers[$val['rid']][0]['cf_id']][0]['title'].'(线上)<br>';
$customers[$val['rid']][0]['cf_clues'] && $cf_name .= $customers[$val['rid']][0]['cf_clues'].'(线下)';
$fields['cf_name'] = $cf_name;
$lists[] = $fields;
}
}
$pager = array('count' => ceil($count / $size), 'curr' => $page, 'totle' => $count);
$_title = $size > 1000 ? $statusAry['name'] : $statusAry['name'] . '列表';
return array('lists' => $lists, 'pager' => $pager, 'params' => $params, 'status_arr' => $status_arr
, 'searchTpAry' => $this->searchTpAry, 'view' => 'receiver/order/lists', 'view_type' => 'bill', '_title' => $_title);
}
/**
* Notes:代办服务订列表
* Created on: 2021/9/17 16:26
* Created by: dengbw
* @param $status_pid
* @param array $params
* @return array
*/
private function agent($status_pid, $params = array())
{
$page = $params['page'] = $params['page'] ? intval($params['page']) : 1;
$size = $params['size'] = $params['size'] ? intval($params['size']) : 20;
$t1 = 'lc_receiver_order_agents';
$t2 = 'lc_receiver_orders';
$where = [
"$t2.status>=" => 0,
"$t2.biz_id!=" => 1,
];
if ($_SESSION['admin_info']['biz_id']) {
$biz_ids = implode(',', $_SESSION['admin_info']['biz_id']);
$where["$t2.biz_id in ($biz_ids)"] = null;
}
$biz_type = $params['biz_type'];
if ($biz_type) {
$where["$t2.biz_id in (select id from lc_biz where type = $biz_type and status=1)"] = null;
}
if ($params['cf_title'] || $params['cf_clues'] || $params['cfrom_id'] || $params['cfrom_id2']) {
$where_c = 'status>=0';
if ($params['cfrom_id'] == 24) {
$where_c .= ' and cf_id = 24';
$params['cfrom_id2'] && $where_c .= ' and t_id = ' . $params['cfrom_id2'];
} else {
if ($params['cfrom_id2']) {
$where_c .= ' and cf_id = ' . $params['cfrom_id2'];
} else if ($params['cfrom_id']) {
$cf_rows = $this->ci->mdCluesCfrom->select(['pid' => $params['cfrom_id']], '', '', '', 'id');
$cf_ids = array_column($cf_rows, 'id');
$cf_ids[] = $params['cfrom_id'];
$cf_str_ids = implode(',', array_filter($cf_ids));
$cf_str_ids && $where_c .= " and cf_id in ({$cf_str_ids})";
}
}
$params['cf_title'] && $where_c .= ' and cf_title = "' . $params['cf_title'] . '"';
$params['cf_clues'] && $where_c .= ' and cf_clues = "' . $params['cf_clues'] . '"';
$where[$t2 . '.rid in (select id from lc_receiver_customers where ' . $where_c . ')'] = null;
}
if (strlen($params['payway'])) {
$where["{$t2}.payway"] = $params['payway'];
}
if ($params['qdjl_id']) {//渠道经理
$re_bu = $this->ci->mdLichebUsers->get(array('id' => $params['qdjl_id']));
if ($re_bu['biz_id']) {
$where["biz_id in({$re_bu['biz_id']})"] = null;
} else {
$where['biz_id'] = -1;
}
}
$statusAry = $this->ci->mdOrders->statusAry($status_pid);
if ($params['list_type'] == 'all') {
$status_arr = $statusAry['list'];
strlen($params['status']) && $where["$t1.status"] = $params['status'];
} else {
$status_arr = $statusAry['menu_list'];
if (!strlen($params['status'])) {
$params['status'] = $statusAry['menu_default'];
}
$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;
$rows_biz = $this->ci->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;
$rows_lcb = $this->ci->mdLichebUsers->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->ci->order_agents_model->count_order($where, $t2);
$lists = [];
if ($count) {
$fileds = "$t1.o_id,$t1.status,$t1.c_time,";
$fileds .= "$t2.rid,$t2.sid,$t2.name,$t2.mobile,$t2.brand_id,$t2.biz_id,$t2.s_id,$t2.v_id,$t2.cor_id,$t2.incor_id,$t2.price,$t2.deposit,$t2.payway,$t2.c_time";
$rows = $this->ci->order_agents_model->select_order($where, "$t2.c_time desc", $page, $size, $fileds);
//客户来源
$str_rids = implode(',', array_unique(array_column($rows, 'rid')));
!$str_rids && $str_rids = 0;
$customers = $this->ci->mdCustomers->map('id', '', array("id in({$str_rids})" => null),'','','','id,cf_title,cf_clues,cf_id');
$cfroms = [];
if($customers){
foreach($customers as $key=>$val){
$cf_id_arr[] = $val[0]['cf_id'];
}
//获取来源
$cfroms = $this->ci->mdCluesCfrom->get_map_by_ids($cf_id_arr, 'id,title');
}
//门店
$str_biz_ids = implode(',', array_unique(array_column($rows, 'biz_id')));
!$str_biz_ids && $str_biz_ids = 0;
$bizs = $this->ci->biz_model->map('id', 'biz_name', array("id in({$str_biz_ids})" => null));
//品牌车型
$brand_arr = array_unique(array_column($rows, 'brand_id'));
$brands = $this->ci->auto_brand_model->get_map_by_ids($brand_arr, 'id,name');
//车系车型
$series_arr = array_unique(array_column($rows, 's_id'));
$series = $this->ci->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->ci->auto_attr_model->get_map_by_ids($attr_arr, 'id,title');
foreach ($rows as $key => $val) {
$fields = array();
$brand_name = isset($brands[$val['brand_id']]) ? $brands[$val['brand_id']][0]['name'] : '';
$series_name = isset($series[$val['s_id']]) ? $series[$val['s_id']][0]['name'] : '';
$v_name = isset($attr[$val['v_id']]) ? $attr[$val['v_id']][0]['title'] : '';
$cor_name = isset($attr[$val['cor_id']]) ? $attr[$val['cor_id']][0]['title'] : '';
$fields['mobile'] = $val['mobile'];
$fields['name'] = $size > 1000 ? $val['name']
: '<a href="javascript:;" data-open="/receiver/orders/get?id=' . $val['o_id'] . '">' . $val['name'] . '<br>' . $val['mobile'] . '</a>';
$fields['car_name'] = "{$brand_name}-{$series_name}-{$v_name}-{$cor_name}";
$fields['price'] = number_format($val['price'], 2);
$fields['deposit'] = number_format($val['deposit'], 2);
$fields['payway_name'] = $this->paywayAry[$val['payway']];
$fields['incor_name'] = isset($attr[$val['incor_id']]) ? $attr[$val['incor_id']][0]['title'] : '';
$fields['status_name'] = $status_arr[$val['status']];
$fields['biz_name'] = $bizs[$val['biz_id']];
$fields['cf_title'] = $customers[$val['rid']][0]['cf_title'];
$cf_name = '';
$cfroms[$customers[$val['rid']][0]['cf_id']][0]['title'] && $cf_name = $cfroms[$customers[$val['rid']][0]['cf_id']][0]['title'].'(线上)<br>';
$customers[$val['rid']][0]['cf_clues'] && $cf_name .= $customers[$val['rid']][0]['cf_clues'].'(线下)';
$fields['cf_name'] = $cf_name;
$lists[] = $fields;
}
}
$pager = array('count' => ceil($count / $size), 'curr' => $page, 'totle' => $count);
$_title = $size > 1000 ? $statusAry['name'] : $statusAry['name'] . '列表';
return array('lists' => $lists, 'pager' => $pager, 'params' => $params, 'status_arr' => $status_arr
, 'searchTpAry' => $this->searchTpAry, 'view' => 'receiver/order/lists', 'view_type' => 'agent', '_title' => $_title);
}
/**
* Notes:交付车辆列表
* Created on: 2021/9/19 22:53
* Created by: dengbw
* @param $status_pid
* @param array $params
* @return array
*/
private function delivery($status_pid, $params = array())
{
$page = $params['page'] = $params['page'] ? intval($params['page']) : 1;
$size = $params['size'] = $params['size'] ? intval($params['size']) : 20;
$t1 = 'lc_receiver_order_deliverys';
$t2 = 'lc_receiver_orders';
$where = [
"$t2.status>=" => 0,
"$t2.biz_id!=" => 1,
];
if ($_SESSION['admin_info']['biz_id']) {
$biz_ids = implode(',', $_SESSION['admin_info']['biz_id']);
$where["$t2.biz_id in ($biz_ids)"] = null;
}
$biz_type = $params['biz_type'];
if ($biz_type) {
$where["$t2.biz_id in (select id from lc_biz where type = $biz_type and status=1)"] = null;
}
if ($params['cf_title'] || $params['cf_clues'] || $params['cfrom_id'] || $params['cfrom_id2']) {
$where_c = 'status>=0';
if ($params['cfrom_id'] == 24) {
$where_c .= ' and cf_id = 24';
$params['cfrom_id2'] && $where_c .= ' and t_id = ' . $params['cfrom_id2'];
} else {
if ($params['cfrom_id2']) {
$where_c .= ' and cf_id = ' . $params['cfrom_id2'];
} else if ($params['cfrom_id']) {
$cf_rows = $this->ci->mdCluesCfrom->select(['pid' => $params['cfrom_id']], '', '', '', 'id');
$cf_ids = array_column($cf_rows, 'id');
$cf_ids[] = $params['cfrom_id'];
$cf_str_ids = implode(',', array_filter($cf_ids));
$cf_str_ids && $where_c .= " and cf_id in ({$cf_str_ids})";
}
}
$params['cf_title'] && $where_c .= ' and cf_title = "' . $params['cf_title'] . '"';
$params['cf_clues'] && $where_c .= ' and cf_clues = "' . $params['cf_clues'] . '"';
$where[$t2 . '.rid in (select id from lc_receiver_customers where ' . $where_c . ')'] = null;
}
if (strlen($params['payway'])) {
$where["{$t2}.payway"] = $params['payway'];
}
if ($params['qdjl_id']) {//渠道经理
$re_bu = $this->ci->mdLichebUsers->get(array('id' => $params['qdjl_id']));
if ($re_bu['biz_id']) {
$where["biz_id in({$re_bu['biz_id']})"] = null;
} else {
$where['biz_id'] = -1;
}
}
$statusAry = $this->ci->mdOrders->statusAry($status_pid);
if ($params['list_type'] == 'all') {
$status_arr = $statusAry['list'];
strlen($params['status']) && $where["$t1.status"] = $params['status'];
} else {
$status_arr = $statusAry['menu_list'];
if (!strlen($params['status'])) {
$params['status'] = $statusAry['menu_default'];
}
$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;
$rows_biz = $this->ci->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;
$rows_lcb = $this->ci->mdLichebUsers->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->ci->order_deliverys_model->count_order($where, $t2);
$lists = [];
if ($count) {
$fileds = "$t1.o_id,$t1.status,$t1.c_time,";
$fileds .= "$t2.rid,$t2.sid,$t2.name,$t2.mobile,$t2.brand_id,$t2.biz_id,$t2.s_id,$t2.v_id,$t2.cor_id,$t2.incor_id,$t2.price,$t2.deposit,$t2.payway,$t2.c_time";
$rows = $this->ci->order_deliverys_model->select_order($where, "$t2.c_time desc", $page, $size, $fileds);
//客户来源
$str_rids = implode(',', array_unique(array_column($rows, 'rid')));
!$str_rids && $str_rids = 0;
$customers = $this->ci->mdCustomers->map('id', '', array("id in({$str_rids})" => null),'','','','id,cf_title,cf_clues,cf_id');
$cfroms = [];
if($customers){
foreach($customers as $key=>$val){
$cf_id_arr[] = $val[0]['cf_id'];
}
//获取来源
$cfroms = $this->ci->mdCluesCfrom->get_map_by_ids($cf_id_arr, 'id,title');
}
//门店
$str_biz_ids = implode(',', array_unique(array_column($rows, 'biz_id')));
!$str_biz_ids && $str_biz_ids = 0;
$bizs = $this->ci->biz_model->map('id', 'biz_name', array("id in({$str_biz_ids})" => null));
//品牌车型
$brand_arr = array_unique(array_column($rows, 'brand_id'));
$brands = $this->ci->auto_brand_model->get_map_by_ids($brand_arr, 'id,name');
//车系车型
$series_arr = array_unique(array_column($rows, 's_id'));
$series = $this->ci->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->ci->auto_attr_model->get_map_by_ids($attr_arr, 'id,title');
foreach ($rows as $key => $val) {
$fields = array();
$brand_name = isset($brands[$val['brand_id']]) ? $brands[$val['brand_id']][0]['name'] : '';
$series_name = isset($series[$val['s_id']]) ? $series[$val['s_id']][0]['name'] : '';
$v_name = isset($attr[$val['v_id']]) ? $attr[$val['v_id']][0]['title'] : '';
$cor_name = isset($attr[$val['cor_id']]) ? $attr[$val['cor_id']][0]['title'] : '';
$fields['mobile'] = $val['mobile'];
$fields['name'] = $size > 1000 ? $val['name']
: '<a href="javascript:;" data-open="/receiver/orders/get?id=' . $val['o_id'] . '">' . $val['name'] . '<br>' . $val['mobile'] . '</a>';
$fields['car_name'] = "{$brand_name}-{$series_name}-{$v_name}-{$cor_name}";
$fields['price'] = number_format($val['price'], 2);
$fields['deposit'] = number_format($val['deposit'], 2);
$fields['payway_name'] = $this->paywayAry[$val['payway']];
$fields['incor_name'] = isset($attr[$val['incor_id']]) ? $attr[$val['incor_id']][0]['title'] : '';
$fields['status_name'] = $status_arr[$val['status']];
$fields['biz_name'] = $bizs[$val['biz_id']];
$fields['cf_title'] = $customers[$val['rid']][0]['cf_title'];
$cf_name = '';
$cfroms[$customers[$val['rid']][0]['cf_id']][0]['title'] && $cf_name = $cfroms[$customers[$val['rid']][0]['cf_id']][0]['title'].'(线上)<br>';
$customers[$val['rid']][0]['cf_clues'] && $cf_name .= $customers[$val['rid']][0]['cf_clues'].'(线下)';
$fields['cf_name'] = $cf_name;
$lists[] = $fields;
}
}
$pager = array('count' => ceil($count / $size), 'curr' => $page, 'totle' => $count);
$_title = $size > 1000 ? $statusAry['name'] : $statusAry['name'] . '列表';
return array('lists' => $lists, 'pager' => $pager, 'params' => $params, 'status_arr' => $status_arr
, 'searchTpAry' => $this->searchTpAry, 'view' => 'receiver/order/lists', 'view_type' => 'delivery', '_title' => $_title);
}
/**
* Notes:获取字段
* Created on: 2021/10/29 15:38
* Created by: dengbw
* @param $status_pid
* @param int $export
* @return array
*/
public function get_fields($status_pid, $export = 0)
{
$fields1 = $fields2 = [];
if ($export) {
$fields1['name'] = ['title' => '客户姓名'];
$fields1['mobile'] = ['title' => '客户电话'];
} else {
$fields1['name'] = ['title' => '客户', 'width' => '14%'];
}
if (strlen($status_pid) && $status_pid == 0) {
$fields2 = ['car_name' => ['title' => '车辆', 'width' => '22%'],
'biz_name' => ['title' => '门店', 'width' => '10%'], 'price' => ['title' => '合同价', 'width' => '7%'],
'payway_name' => ['title' => '付款', 'width' => '5%'],'admin_name' => ['title' => '销售员', 'width' => '7%'],
'cf_title' => ['title' => '来源类型', 'width' => '8%'],'cf_name' => ['title' => '来源','width' => '10%'],
'status_name' => ['title' => '合同状态', 'width' => '7%'], 'c_time' => ['title' => '订单时间', 'width' => '12%']];
$fields = array_merge($fields1, $fields2);
} else if ($status_pid == 1) {
$fields2 = ['title' => ['title' => '分期产品', 'width' => '15%'],
'price_loan' => ['title' => '贷款金额', 'width' => '10%'], 'c_time' => ['title' => '分期时间', 'width' => '7%'],
'cf_title' => ['title' => '来源类型', 'width' => '10%'], 'cf_name' => ['title' => '来源','width' => '10%'],
'status_name' => ['title' => '状态', 'width' => '10%']];
$fields = array_merge($fields1, $fields2);
} else if ($status_pid == 2 || $status_pid == 3 || $status_pid == 4 || $status_pid == 5) {
$fields2 = ['car_name' => ['title' => '车辆', 'width' => '27%'],
'biz_name' => ['title' => '门店', 'width' => '12%'], 'price' => ['title' => '车辆平台价', 'width' => '9%'],
'payway_name' => ['title' => '付款方式', 'width' => '8%'],
'cf_title' => ['title' => '来源类型', 'width' => '9%'], 'cf_name' => ['title' => '来源','width' => '10%'],
'status_name' => ['title' => '状态', 'width' => '9%']];
$fields = array_merge($fields1, $fields2);
} else {
$fields2 = ['car_name' => ['title' => '车辆', 'width' => '27%'],
'biz_name' => ['title' => '门店', 'width' => '12%'], 'price' => ['title' => '车辆平台价', 'width' => '9%'],
'payway_name' => ['title' => '付款方式', 'width' => '8%'],
'cf_title' => ['title' => '来源类型', 'width' => '9%'], 'cf_name' => ['title' => '来源','width' => '10%'],
'status_name' => ['title' => '状态', 'width' => '9%'],
'c_time' => ['title' => '订单时间', 'width' => '9%']];
$fields = array_merge($fields1, $fields2);
}
return $fields;
}
}
?>