diff --git a/admin/controllers/receiver/Orders.php b/admin/controllers/receiver/Orders.php
index 38f9d8dd..ccf6ed57 100644
--- a/admin/controllers/receiver/Orders.php
+++ b/admin/controllers/receiver/Orders.php
@@ -102,11 +102,17 @@ class Orders extends HD_Controller
$id = $this->input->get('id');
$row = $this->orders_model->get(['id' => $id]);
- $sign = $this->order_signs_model->get(['o_id' => $row['id']], 'status');
- $customers = $this->customers_model->get(['id' => $row['rid']], 'cf_title');
+ //$sign = $this->order_signs_model->get(['o_id' => $row['id']], 'status');
+ $customers = $this->customers_model->get(['id' => $row['rid']]);
if (!$row) {
return $this->show_json(SYS_CODE_FAIL, '订单不存在!');
}
+ if ($customers['of_id']) {//客户来源
+ $of_ary = $this->customers_model->offlineSources($customers['of_id']);
+ $of_title = $of_ary['name'];
+ $customers['of2_id'] && $of_title .= '-' . $of_ary['list'][$customers['of2_id']];
+ $row['of_title'] = $of_title;
+ }
$sub_status_cn = $this->orderslist->sub_status_cn($row['id'],$row['status']);
$sub_status_cn && $sub_status_cn = "-".$sub_status_cn;
$money_json = json_decode($row['money_json'], true);
@@ -121,7 +127,6 @@ class Orders extends HD_Controller
$row['deposit'] = number_format($deposit, 2);
$row['c_time'] = date('Y-m-d', $row['c_time']);
$row['sign_status_name'] = $status_arr[$row['status']]['name'].$sub_status_cn;
- $row['cf_title'] = $customers['cf_title'];
$row['payway'] = intval($row['payway']);
$row['item_id'] = intval($row['item_id']);
$row['cardid'] = $row['info_json']['cardid'] ? $row['info_json']['cardid'] : $row['info_json']['c_cardid'];
diff --git a/admin/controllers/receiver/orderv2/Orders.php b/admin/controllers/receiver/orderv2/Orders.php
index b467d695..0c7a83dd 100644
--- a/admin/controllers/receiver/orderv2/Orders.php
+++ b/admin/controllers/receiver/orderv2/Orders.php
@@ -115,10 +115,16 @@ class Orders extends HD_Controller
$id = $this->input->get('id');
$row = $this->receiver_orders_v2_model->get(['id' => $id]);
- $customers = $this->customers_model->get(['id' => $row['customer_id']], 'cf_title');
+ $customers = $this->customers_model->get(['id' => $row['customer_id']]);
if (!$row) {
return $this->show_json(SYS_CODE_FAIL, '订单不存在!');
}
+ if ($customers['of_id']) {//客户来源
+ $of_ary = $this->customers_model->offlineSources($customers['of_id']);
+ $of_title = $of_ary['name'];
+ $customers['of2_id'] && $of_title .= '-' . $of_ary['list'][$customers['of2_id']];
+ $row['of_title'] = $of_title;
+ }
$money_json = json_decode($row['money_json'], true);
$deposit = $money_json['price_book'];
$jsondata = $row['jsondata'] ? json_decode($row['jsondata'], true) : array();
@@ -136,7 +142,6 @@ class Orders extends HD_Controller
$row['price'] = number_format($money_json['price_car'], 2);
$row['deposit'] = number_format($deposit, 2);
$row['c_time'] = date('Y-m-d', $row['c_time']);
- $row['cf_title'] = $customers['cf_title'];
$row['payway'] = intval($row['payway']);
$row['item_id'] = intval($row['item_id']);
$row['cardid'] = $row['info_json']['c_cardid'] ? $row['info_json']['c_cardid'] :'';
diff --git a/admin/libraries/OrdersList.php b/admin/libraries/OrdersList.php
index 21186a90..38e80e4c 100644
--- a/admin/libraries/OrdersList.php
+++ b/admin/libraries/OrdersList.php
@@ -28,13 +28,12 @@ class OrdersList
{
$result = $show_info = array();
!$params['qdjl_id'] && $params['qdjl_id'] = '';
- !$params['cf_title'] && $params['cf_title'] = '';
- !$params['cf_clues'] && $params['cf_clues'] = '';
+ !$params['of_id'] && $params['of_id'] = '';
+ !$params['of2_id'] && $params['of2_id'] = '';
!strlen($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['offlineSourcesAry'] = $this->ci->mdCustomers->offlineSources();//客户来源
$show_info['paywayAry'] = $this->paywayAry;//付款方式
$show_info['bizTypeAry'] = $this->ci->biz_model->type_ary();//门店类型
//渠道经理
@@ -108,25 +107,11 @@ class OrdersList
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']) {
+ if ($params['of_id'] || $params['of2_id']) {
$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;
+ $params['of_id'] && $where_c .= ' and of_id = ' . $params['of_id'];
+ $params['of2_id'] && $where_c .= ' and of2_id = ' . $params['of2_id'];
+ $where["rid in (select id from lc_receiver_customers where " . $where_c . ')'] = null;
}
if (strlen($params['payway'])) {
$where["payway"] = $params['payway'];
@@ -220,15 +205,8 @@ class OrdersList
//客户来源
$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');
- }
+ $customers = $this->ci->mdCustomers->map('id', 'of_id,of2_id', array("id in({$str_rids})" => null));
+ $offlineSources = $this->ci->mdCustomers->offlineSources();
//获取销售
$str_admin_ids = implode(',', array_unique(array_column($rows, 'admin_id')));
!$str_admin_ids && $str_admin_ids = 0;
@@ -255,6 +233,15 @@ class OrdersList
$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'] : '';
+ $of_title = '-';
+ $of_id = $customers[$val['rid']]['of_id'];
+ if ($of_id) {
+ $of_ary = $offlineSources[$of_id];
+ $of_title = $of_ary['name'];
+ $of2_id = $customers[$val['rid']]['of2_id'];
+ $of2_id && $of_title .= '-' . $of_ary['list'][$of2_id];
+ }
+ $fields['of_title'] = $of_title;
$fields['o_id'] = $val['id'];
$fields['bill_time'] = $val['bill_time'];
$fields['mobile'] = $val['mobile'];
@@ -268,9 +255,6 @@ class OrdersList
$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'];
$fields['admin_name'] = $map_admin[$val['admin_id']] ? $map_admin[$val['admin_id']] : '';
$lists[] = $fields;
}
@@ -308,24 +292,10 @@ class OrdersList
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']) {
+ if ($params['of_id'] || $params['of2_id']) {
$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'] . '"';
+ $params['of_id'] && $where_c .= ' and of_id = ' . $params['of_id'];
+ $params['of2_id'] && $where_c .= ' and of2_id = ' . $params['of2_id'];
$where[$t2 . '.rid in (select id from lc_receiver_customers where ' . $where_c . ')'] = null;
}
if (strlen($params['payway'])) {
@@ -440,15 +410,8 @@ class OrdersList
//客户来源
$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');
- }
+ $customers = $this->ci->mdCustomers->map('id', 'of_id,of2_id', array("id in({$str_rids})" => null));
+ $offlineSources = $this->ci->mdCustomers->offlineSources();
//品牌车型
$brands = $this->ci->auto_brand_model->get_map_by_ids($brand_arr, 'id,name');
//车系车型
@@ -484,6 +447,15 @@ class OrdersList
$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'] : '';
+ $of_title = '-';
+ $of_id = $customers[$val['rid']]['of_id'];
+ if ($of_id) {
+ $of_ary = $offlineSources[$of_id];
+ $of_title = $of_ary['name'];
+ $of2_id = $customers[$val['rid']]['of2_id'];
+ $of2_id && $of_title .= '-' . $of_ary['list'][$of2_id];
+ }
+ $fields['of_title'] = $of_title;
$fields['o_id'] = $val['o_id'];
$fields['bill_time'] = $val['bill_time'];
$fields['mobile'] = $val['mobile'];
@@ -498,11 +470,6 @@ class OrdersList
$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[$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'] . '(线上)
';
- $customers[$val['rid']][0]['cf_clues'] && $cf_name .= $customers[$val['rid']][0]['cf_clues'] . '(线下)';
- $fields['cf_name'] = $cf_name;
$fields['order_time'] = $val['order_time'] != '0000-00-00 00:00:00' ? $val['order_time'] : '';
$lists[] = $fields;
}
@@ -539,24 +506,10 @@ class OrdersList
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']) {
+ if ($params['of_id'] || $params['of2_id']) {
$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'] . '"';
+ $params['of_id'] && $where_c .= ' and of_id = ' . $params['of_id'];
+ $params['of2_id'] && $where_c .= ' and of2_id = ' . $params['of2_id'];
$where[$t2 . '.rid in (select id from lc_receiver_customers where ' . $where_c . ')'] = null;
}
if (strlen($params['payway'])) {
@@ -650,15 +603,8 @@ class OrdersList
//客户来源
$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');
- }
+ $customers = $this->ci->mdCustomers->map('id', 'of_id,of2_id', array("id in({$str_rids})" => null));
+ $offlineSources = $this->ci->mdCustomers->offlineSources();
$finance_arr = array_column($rows, 'finance_id');
$finance_rows = $this->ci->sys_finance_model->get_map_by_ids($finance_arr, 'id,title');
//获取销售
@@ -669,6 +615,15 @@ class OrdersList
$fields = array();
$money_json = json_decode($val['money_json'], true);
$price_loan = $money_json['price_loan'] ? $money_json['price_loan'] : 0;
+ $of_title = '-';
+ $of_id = $customers[$val['rid']]['of_id'];
+ if ($of_id) {
+ $of_ary = $offlineSources[$of_id];
+ $of_title = $of_ary['name'];
+ $of2_id = $customers[$val['rid']]['of2_id'];
+ $of2_id && $of_title .= '-' . $of_ary['list'][$of2_id];
+ }
+ $fields['of_title'] = $of_title;
$fields['o_id'] = $val['o_id'];
$fields['bill_time'] = $val['bill_time'];
$fields['mobile'] = $val['mobile'];
@@ -678,11 +633,6 @@ class OrdersList
$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'] . '(线上)
';
- $customers[$val['rid']][0]['cf_clues'] && $cf_name .= $customers[$val['rid']][0]['cf_clues'] . '(线下)';
- $fields['cf_name'] = $cf_name;
$fields['admin_name'] = $map_admin[$val['admin_id']] ? $map_admin[$val['admin_id']] : '';
$lists[] = $fields;
}
@@ -719,24 +669,10 @@ class OrdersList
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']) {
+ if ($params['of_id'] || $params['of2_id']) {
$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'] . '"';
+ $params['of_id'] && $where_c .= ' and of_id = ' . $params['of_id'];
+ $params['of2_id'] && $where_c .= ' and of2_id = ' . $params['of2_id'];
$where[$t2 . '.rid in (select id from lc_receiver_customers where ' . $where_c . ')'] = null;
}
if (strlen($params['payway'])) {
@@ -829,15 +765,8 @@ class OrdersList
//客户来源
$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');
- }
+ $customers = $this->ci->mdCustomers->map('id', 'of_id,of2_id', array("id in({$str_rids})" => null));
+ $offlineSources = $this->ci->mdCustomers->offlineSources();
//获取销售
$str_admin_ids = implode(',', array_unique(array_column($rows, 'admin_id')));
!$str_admin_ids && $str_admin_ids = 0;
@@ -864,6 +793,15 @@ class OrdersList
$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'] : '';
+ $of_title = '-';
+ $of_id = $customers[$val['rid']]['of_id'];
+ if ($of_id) {
+ $of_ary = $offlineSources[$of_id];
+ $of_title = $of_ary['name'];
+ $of2_id = $customers[$val['rid']]['of2_id'];
+ $of2_id && $of_title .= '-' . $of_ary['list'][$of2_id];
+ }
+ $fields['of_title'] = $of_title;
$fields['o_id'] = $val['o_id'];
$fields['bill_time'] = $val['bill_time'];
$fields['mobile'] = $val['mobile'];
@@ -876,11 +814,6 @@ class OrdersList
$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'] . '(线上)
';
- $customers[$val['rid']][0]['cf_clues'] && $cf_name .= $customers[$val['rid']][0]['cf_clues'] . '(线下)';
- $fields['cf_name'] = $cf_name;
$fields['admin_name'] = $map_admin[$val['admin_id']] ? $map_admin[$val['admin_id']] : '';
$lists[] = $fields;
}
@@ -917,24 +850,10 @@ class OrdersList
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']) {
+ if ($params['of_id'] || $params['of2_id']) {
$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'] . '"';
+ $params['of_id'] && $where_c .= ' and of_id = ' . $params['of_id'];
+ $params['of2_id'] && $where_c .= ' and of2_id = ' . $params['of2_id'];
$where[$t2 . '.rid in (select id from lc_receiver_customers where ' . $where_c . ')'] = null;
}
if (strlen($params['payway'])) {
@@ -1042,15 +961,8 @@ class OrdersList
//客户来源
$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');
- }
+ $customers = $this->ci->mdCustomers->map('id', 'of_id,of2_id', array("id in({$str_rids})" => null));
+ $offlineSources = $this->ci->mdCustomers->offlineSources();
//获取销售
$str_admin_ids = implode(',', array_unique(array_column($rows, 'admin_id')));
!$str_admin_ids && $str_admin_ids = 0;
@@ -1077,6 +989,15 @@ class OrdersList
$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'] : '';
+ $of_title = '-';
+ $of_id = $customers[$val['rid']]['of_id'];
+ if ($of_id) {
+ $of_ary = $offlineSources[$of_id];
+ $of_title = $of_ary['name'];
+ $of2_id = $customers[$val['rid']]['of2_id'];
+ $of2_id && $of_title .= '-' . $of_ary['list'][$of2_id];
+ }
+ $fields['of_title'] = $of_title;
$fields['o_id'] = $val['o_id'];
$fields['bill_time'] = $val['bill_time'];
$fields['mobile'] = $val['mobile'];
@@ -1090,12 +1011,6 @@ class OrdersList
$jsondata = json_decode($val['jsondata'], true);
$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'] . '(线上)
';
- $customers[$val['rid']][0]['cf_clues'] && $cf_name .= $customers[$val['rid']][0]['cf_clues'] . '(线下)';
- $fields['cf_name'] = $cf_name;
$fields['item_id'] = $val['item_id'];
$fields['admin_name'] = $map_admin[$val['admin_id']] ? $map_admin[$val['admin_id']] : '';
$fields['vin'] = $items[$val['item_id']] ? $items[$val['item_id']] : '';
@@ -1134,24 +1049,10 @@ class OrdersList
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']) {
+ if ($params['of_id'] || $params['of2_id']) {
$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'] . '"';
+ $params['of_id'] && $where_c .= ' and of_id = ' . $params['of_id'];
+ $params['of2_id'] && $where_c .= ' and of2_id = ' . $params['of2_id'];
$where[$t2 . '.rid in (select id from lc_receiver_customers where ' . $where_c . ')'] = null;
}
if (strlen($params['payway'])) {
@@ -1244,15 +1145,8 @@ class OrdersList
//客户来源
$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');
- }
+ $customers = $this->ci->mdCustomers->map('id', 'of_id,of2_id', array("id in({$str_rids})" => null));
+ $offlineSources = $this->ci->mdCustomers->offlineSources();
//获取销售
$str_admin_ids = implode(',', array_unique(array_column($rows, 'admin_id')));
!$str_admin_ids && $str_admin_ids = 0;
@@ -1279,6 +1173,15 @@ class OrdersList
$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'] : '';
+ $of_title = '-';
+ $of_id = $customers[$val['rid']]['of_id'];
+ if ($of_id) {
+ $of_ary = $offlineSources[$of_id];
+ $of_title = $of_ary['name'];
+ $of2_id = $customers[$val['rid']]['of2_id'];
+ $of2_id && $of_title .= '-' . $of_ary['list'][$of2_id];
+ }
+ $fields['of_title'] = $of_title;
$fields['o_id'] = $val['o_id'];
$fields['bill_time'] = $val['bill_time'];
$fields['mobile'] = $val['mobile'];
@@ -1296,11 +1199,6 @@ class OrdersList
}
$fields['status_name'] = $status_arr[$val['status']] . $complete;
$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'] . '(线上)
';
- $customers[$val['rid']][0]['cf_clues'] && $cf_name .= $customers[$val['rid']][0]['cf_clues'] . '(线下)';
- $fields['cf_name'] = $cf_name;
$fields['u_time'] = date('Y-m-d H:i', strtotime($val['u_time']));
$fields['admin_name'] = $map_admin[$val['admin_id']] ? $map_admin[$val['admin_id']] : '';
$lists[] = $fields;
@@ -1338,24 +1236,10 @@ class OrdersList
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']) {
+ if ($params['of_id'] || $params['of2_id']) {
$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'] . '"';
+ $params['of_id'] && $where_c .= ' and of_id = ' . $params['of_id'];
+ $params['of2_id'] && $where_c .= ' and of2_id = ' . $params['of2_id'];
$where[$t2 . '.rid in (select id from lc_receiver_customers where ' . $where_c . ')'] = null;
}
if (strlen($params['payway'])) {
@@ -1448,15 +1332,8 @@ class OrdersList
//客户来源
$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');
- }
+ $customers = $this->ci->mdCustomers->map('id', 'of_id,of2_id', array("id in({$str_rids})" => null));
+ $offlineSources = $this->ci->mdCustomers->offlineSources();
//获取销售
$str_admin_ids = implode(',', array_unique(array_column($rows, 'admin_id')));
!$str_admin_ids && $str_admin_ids = 0;
@@ -1483,6 +1360,15 @@ class OrdersList
$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'] : '';
+ $of_title = '-';
+ $of_id = $customers[$val['rid']]['of_id'];
+ if ($of_id) {
+ $of_ary = $offlineSources[$of_id];
+ $of_title = $of_ary['name'];
+ $of2_id = $customers[$val['rid']]['of2_id'];
+ $of2_id && $of_title .= '-' . $of_ary['list'][$of2_id];
+ }
+ $fields['of_title'] = $of_title;
$fields['o_id'] = $val['o_id'];
$fields['bill_time'] = $val['bill_time'];
$fields['mobile'] = $val['mobile'];
@@ -1495,11 +1381,6 @@ class OrdersList
$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'] . '(线上)
';
- $customers[$val['rid']][0]['cf_clues'] && $cf_name .= $customers[$val['rid']][0]['cf_clues'] . '(线下)';
- $fields['cf_name'] = $cf_name;
$fields['admin_name'] = $map_admin[$val['admin_id']] ? $map_admin[$val['admin_id']] : '';
$lists[] = $fields;
}
@@ -1531,13 +1412,13 @@ class OrdersList
$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%'],
+ 'of_title' => ['title' => '客户来源', 'width' => '10%'],
'status_name' => ['title' => '合同状态', 'width' => '7%'], 'order_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%'],
+ 'of_title' => ['title' => '客户来源', 'width' => '10%'],
'status_name' => ['title' => '状态', 'width' => '10%']];
$fields = array_merge($fields1, $fields2);
} else if ($status_pid == 3) {
@@ -1545,14 +1426,14 @@ class OrdersList
'vin' => ['title' => '车架号', 'width' => '12%'], 'biz_name' => ['title' => '门店', 'width' => '12%'],
'price' => ['title' => '车辆平台价', 'width' => '9%'], 'admin_name' => ['title' => '销售员', 'width' => '8%'],
'payway_name' => ['title' => '付款方式', 'width' => '8%'],
- 'cf_title' => ['title' => '来源类型', 'width' => '9%'], 'cf_name' => ['title' => '来源', 'width' => '10%'],
+ 'of_title' => ['title' => '客户来源', 'width' => '10%'],
'status_name' => ['title' => '状态', 'width' => '8%']];
$fields = array_merge($fields1, $fields2);
} else if ($status_pid == 2 || $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%'],
+ 'of_title' => ['title' => '客户来源', 'width' => '10%'],
'status_name' => ['title' => '状态', 'width' => '9%']];
$status_pid == 4 && $fields2['u_time'] = ['title' => '更新时间', 'width' => '9%'];
$fields = array_merge($fields1, $fields2);
@@ -1560,7 +1441,7 @@ class OrdersList
$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%'],
+ 'of_title' => ['title' => '客户来源', 'width' => '10%'],
'status_name' => ['title' => '状态', 'width' => '9%'],
'c_time' => ['title' => '订单时间', 'width' => '9%']];
$fields = array_merge($fields1, $fields2);
diff --git a/admin/libraries/Ordersv2List.php b/admin/libraries/Ordersv2List.php
index 958cd297..aa4c4dbe 100644
--- a/admin/libraries/Ordersv2List.php
+++ b/admin/libraries/Ordersv2List.php
@@ -6,7 +6,7 @@
class Ordersv2List
{
private $ci;
- private $searchTpAry = array('owner_name'=>'车主姓名','owner_mobile'=>'车主手机号','name' => '客户姓名', 'mobile' => '客户手机号', 'sid' => '订单号');
+ private $searchTpAry = array('owner_name' => '车主姓名', 'owner_mobile' => '车主手机号', 'name' => '客户姓名', 'mobile' => '客户手机号', 'sid' => '订单号');
private $paywayAry = array(0 => '贷款', 1 => '全款');
private $t1 = 'lc_receiver_orders_v2';
private $t2 = 'lc_receiver_order_status';
@@ -34,15 +34,14 @@ class Ordersv2List
{
// $result = $show_info = array();
!$params['qdjl_id'] && $params['qdjl_id'] = '';
- !$params['cf_title'] && $params['cf_title'] = '';
- !$params['cf_clues'] && $params['cf_clues'] = '';
+ !$params['of_id'] && $params['of_id'] = '';
+ !$params['of2_id'] && $params['of2_id'] = '';
!strlen($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['offlineSourcesAry'] = $this->ci->mdCustomers->offlineSources();//客户来源
$show_info['paywayAry'] = $this->paywayAry;//付款方式
- $show_info['bizTypeAry'] = $this->ci->biz_model->type_ary();//门店类型
+ $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');
@@ -69,8 +68,8 @@ class Ordersv2List
$where = ["{$this->t1}.status>=" => 0];
$_title = '全部订单';
$view = 'receiver/orderv2/lists';
- $params['status_pid']==1 && $where["{$this->t1}.payway"] = 0;
- if(is_product()){
+ $params['status_pid'] == 1 && $where["{$this->t1}.payway"] = 0;
+ if (is_product()) {
$where["{$this->t1}.biz_id<>"] = 1;
}
if ($_SESSION['admin_info']['biz_id']) {
@@ -80,24 +79,10 @@ class Ordersv2List
if ($params['biz_type']) {
$where["{$this->t1}.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']) {
+ if ($params['of_id'] || $params['of2_id']) {
$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'] . '"';
+ $params['of_id'] && $where_c .= ' and of_id = ' . $params['of_id'];
+ $params['of2_id'] && $where_c .= ' and of2_id = ' . $params['of2_id'];
$where["{$this->t1}.customer_id in (select id from lc_receiver_customers where " . $where_c . ')'] = null;
}
if (strlen($params['payway'])) {
@@ -142,10 +127,10 @@ class Ordersv2List
if ($params['brand_id']) {//品牌
$where["{$this->t1}.brand_id"] = $params['brand_id'];
} else {
- if(is_product()){
- $where["{$this->t1}.brand_id<>"] = 3;//狸车品牌不显示
- }
- $params['brand_id'] = '';
+ if (is_product()) {
+ $where["{$this->t1}.brand_id<>"] = 3;//狸车品牌不显示
+ }
+ $params['brand_id'] = '';
}
if ($params['s_id']) {//车系
$where["{$this->t1}.s_id"] = $params['s_id'];
@@ -192,7 +177,7 @@ class Ordersv2List
!$params['biz_id_admin'] && $params['biz_id_admin'] = '';
$params['admin_id'] = '';
}
- if($params['vin']){
+ if ($params['vin']) {
$where = ["{$this->t1}.status>=" => 0];
$where["{$this->t1}.item_id in(select id from lc_items where vin like '%{$params['vin']}%')"] = null;
}
@@ -200,46 +185,46 @@ class Ordersv2List
{$this->t1}.cor_id,{$this->t1}.incor_id,{$this->t1}.money_json,{$this->t1}.payway,{$this->t1}.status,{$this->t1}.c_time,
{$this->t1}.biz_id,{$this->t1}.bill_time,{$this->t1}.customer_id,{$this->t1}.owner_name,{$this->t1}.owner_mobile,{$this->t1}.main_type,{$this->t1}.info_json,
{$this->t1}.order_time,{$this->t1}.bill_time,{$this->t1}.item_id";
- if($params['status_pid']==3 && strlen($params['status'])){ //开票
+ if ($params['status_pid'] == 3 && strlen($params['status'])) { //开票
}
- if($params['status_pid']==4){ //交付需要开票后才显示
+ if ($params['status_pid'] == 4) { //交付需要开票后才显示
$where["{$this->t1}.id in (select o_id from lc_receiver_order_status where pid_status=3 and status=1)"] = null;
}
- if(strlen($params['status_pid'])){
+ if (strlen($params['status_pid'])) {
$where["{$this->t1}.id>="] = Orders_v2_entity::V2_START_ID;
}
- if(strlen($params['status_pid']) && !$params['status_pid']){ //付款列表 下定时间排序
+ if (strlen($params['status_pid']) && !$params['status_pid']) { //付款列表 下定时间排序
$orderby = "{$this->t1}.order_time desc";
- }elseif ($params['status_pid']==3){ // 开票列表 开票时间排序
+ } elseif ($params['status_pid'] == 3) { // 开票列表 开票时间排序
$orderby = "{$this->t1}.bill_time desc";
- }else{
+ } else {
$orderby = "{$this->t1}.c_time desc";
}
- if(strlen($params['status_pid']) && $params['status']){
+ if (strlen($params['status_pid']) && $params['status']) {
$where["{$this->t2}.pid_status"] = $params['status_pid'];
- $up_key = $params['status']+1;
+ $up_key = $params['status'] + 1;
$where["{$this->t2}.status in ({$params['status']},{$up_key})"] = null;
$having = "total = 1";
- if($params['status_pid']==0 && $params['status']==1){
+ if ($params['status_pid'] == 0 && $params['status'] == 1) {
$having = "total >= 1";
}
- $count = $this->ci->mdOrders->selectOrders($where,'', '', '', 1,'',$having);
- $rows = $this->ci->mdOrders->selectOrders($where, $orderby, $page, $size, '',$fileds,$having);
- }else{
- if(strlen($params['status'])){
+ $count = $this->ci->mdOrders->selectOrders($where, '', '', '', 1, '', $having);
+ $rows = $this->ci->mdOrders->selectOrders($where, $orderby, $page, $size, '', $fileds, $having);
+ } else {
+ if (strlen($params['status'])) {
$where["id not in (select o_id from lc_receiver_order_status where pid_status={$params['status_pid']} and status=1)"] = null;
}
- if($params['status_pid']==3){ //开票
- if(strlen($params['status'])){ //待开票
+ if ($params['status_pid'] == 3) { //开票
+ if (strlen($params['status'])) { //待开票
$where['id in (select o_id from lc_receiver_order_status where pid_status=0 and status=2)'] = null;
- }else{ //全部
+ } else { //全部
$where['id in (select o_id from lc_receiver_order_status where (pid_status=0 and status=2) or (pid_status=3 and status=1))'] = null;
}
}
$count = $this->ci->mdOrders->count($where);
- $rows = $this->ci->mdOrders->select($where, $orderby, $page, $size,$fileds);
+ $rows = $this->ci->mdOrders->select($where, $orderby, $page, $size, $fileds);
}
$lists = [];
if ($count) {
@@ -250,15 +235,8 @@ class Ordersv2List
//客户来源
$str_rids = implode(',', array_unique(array_column($rows, 'customer_id')));
!$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');
- }
+ $customers = $this->ci->mdCustomers->map('id', 'of_id,of2_id', array("id in({$str_rids})" => null));
+ $offlineSources = $this->ci->mdCustomers->offlineSources();
//门店
$str_biz_ids = implode(',', array_unique(array_column($rows, 'biz_id')));
!$str_biz_ids && $str_biz_ids = 0;
@@ -276,8 +254,8 @@ class Ordersv2List
$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) {
- $money_json = json_decode($val['money_json'],true);
- $info_json = json_decode($val['info_json'],true);
+ $money_json = json_decode($val['money_json'], true);
+ $info_json = json_decode($val['info_json'], true);
$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'] : '';
@@ -285,42 +263,45 @@ class Ordersv2List
$cor_name = isset($attr[$val['cor_id']]) ? $attr[$val['cor_id']][0]['title'] : '';
$fields['o_id'] = $val['id'];
$fields['bill_time'] = $val['bill_time'];
- if(Orders_v2_entity::V2_START_ID<$val['id']){
- if($val['main_type']){
+ if (Orders_v2_entity::V2_START_ID < $val['id']) {
+ if ($val['main_type']) {
$name = $info_json['c_company'];
$mobile = $val['mobile'];
- }else{
+ } else {
$name = $val['owner_name'];
$mobile = $val['owner_mobile'];
}
$open_url = '/receiver/orderv2/orders/get?id=';
$fields['name'] = $size > 1000 ? $name
- : '' . $name . '
' . $mobile . '';
- }else{
+ : '' . $name . '
' . $mobile . '';
+ } else {
$open_url = '/receiver/orders/get?id=';
$mobile = $val['mobile'];
- $o_tp = '(旧订单)';
+ $o_tp = '(旧订单)';
$fields['name'] = $size > 1000 ? $val['name']
- : '' . $val['name']. $o_tp . '
' . $val['mobile'] . '';
+ : '' . $val['name'] . $o_tp . '
' . $val['mobile'] . '';
}
$fields['mobile'] = $mobile;
$fields['car_name'] = "{$brand_name}-{$series_name}-{$v_name}-{$cor_name}";
$fields['price'] = number_format($money_json['price_car'], 2);
$fields['payway_name'] = $this->paywayAry[$val['payway']];
$fields['incor_name'] = isset($attr[$val['incor_id']]) ? $attr[$val['incor_id']][0]['title'] : '';
- if(strlen($params['status_pid']) && $params['status_pid']!=5 && $val['status']!=2){
- $fields['status_name'] = $this->ci->orders_status_entity->last_status_cn($val['id'],$params['status_pid']);
- }else{
+ if (strlen($params['status_pid']) && $params['status_pid'] != 5 && $val['status'] != 2) {
+ $fields['status_name'] = $this->ci->orders_status_entity->last_status_cn($val['id'], $params['status_pid']);
+ } else {
$fields['status_name'] = $order_status_cn[$val['status']];
}
$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['customer_id']][0]['cf_title'];
- $cf_name = $cfroms[$customers[$val['customer_id']][0]['cf_id']][0]['title'];
- $cf_clues = $customers[$val['customer_id']][0]['cf_clues'];
- $fields['cf_name'] = '';
- $cf_name && $fields['cf_name'] = $cf_name.'(线上)
';
- $cf_clues && $fields['cf_name'] .= $cf_clues.'(线下)';
+ $of_title = '-';
+ $of_id = $customers[$val['customer_id']]['of_id'];
+ if ($of_id) {
+ $of_ary = $offlineSources[$of_id];
+ $of_title = $of_ary['name'];
+ $of2_id = $customers[$val['customer_id']]['of2_id'];
+ $of2_id && $of_title .= '-' . $of_ary['list'][$of2_id];
+ }
+ $fields['of_title'] = $of_title;
$fields['order_time'] = $val['order_time'] != '0000-00-00 00:00:00' ? $val['order_time'] : '';
$fields['bill_time'] = $val['bill_time'] != '0000-00-00 00:00:00' ? $val['bill_time'] : '';
$fields['vin'] = $items[$val['item_id']] ? $items[$val['item_id']] : '';
@@ -351,31 +332,26 @@ class Ordersv2List
} else {
$fields1['name'] = ['title' => '客户', 'width' => '14%'];
}
- if(strlen($status_pid) && $status_pid==0){
+ if (strlen($status_pid) && $status_pid == 0) {
$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%'],
- 'order_time' => ['title' => '下定时间', 'width' => '9%']];
- }elseif($status_pid==3){
+ 'payway_name' => ['title' => '付款方式', 'width' => '8%'], 'of_title' => ['title' => '客户来源', 'width' => '10%'],
+ 'status_name' => ['title' => '状态', 'width' => '9%'], 'order_time' => ['title' => '下定时间', 'width' => '9%']];
+ } elseif ($status_pid == 3) {
$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%'],
- 'bill_time' => ['title' => '开票时间', 'width' => '9%']];
- }else{
+ 'payway_name' => ['title' => '付款方式', 'width' => '8%'], 'of_title' => ['title' => '客户来源', 'width' => '10%'],
+ 'status_name' => ['title' => '状态', 'width' => '9%'], 'bill_time' => ['title' => '开票时间', 'width' => '9%']];
+ } 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%'],
+ 'payway_name' => ['title' => '付款方式', 'width' => '8%'], 'of_title' => ['title' => '客户来源', 'width' => '10%'],
'status_name' => ['title' => '状态', 'width' => '9%'],
'c_time' => ['title' => '订单时间', 'width' => '9%']];
}
$fields = array_merge($fields1, $fields2);
- if($export){
- $fields['vin'] = ['title'=>'vin码'];
+ if ($export) {
+ $fields['vin'] = ['title' => 'vin码'];
}
return $fields;
}
diff --git a/admin/views/receiver/order/lists.php b/admin/views/receiver/order/lists.php
index b68ab6d3..55863192 100644
--- a/admin/views/receiver/order/lists.php
+++ b/admin/views/receiver/order/lists.php
@@ -89,7 +89,7 @@
-