order_830_2

This commit is contained in:
dengbw
2022-08-30 16:55:12 +08:00
parent 4c4250883b
commit b65a4e3068
+30 -30
View File
@@ -62,8 +62,8 @@ class order extends HD_Controller
$config['brand_id'] = 5;
$config['bizs'] = [
1 => ['biz_name' => '泉州零跑品牌店', 'ids' => '63', 'rowspan' => 1],
2 => ['biz_name' => '泉州渠道', 'not_ids' => '63', 'city_id' => '350500', 'show' => 'customer'],
3 => ['biz_name' => '厦门渠道', 'city_id' => '350200', 'show' => 'customer']];
2 => ['biz_name' => '泉州渠道', 'not_ids' => '63', 'city_id' => '350500', 'show' => 'order'],
3 => ['biz_name' => '厦门渠道', 'city_id' => '350200', 'show' => 'order']];
$res = $this->commonSelect($params, $config);
$this->data['info'] = $res['info'];
$this->data['params'] = $res['params'];
@@ -83,10 +83,10 @@ class order extends HD_Controller
$config['brand_id'] = 4;
$config['bizs'] = [
1 => ['biz_name' => '宁德哪吒品牌店', 'ids' => '70', 'rowspan' => 1],
2 => ['biz_name' => '宁德哪吒代理店', 'type' => 3, 'city_id' => '350900', 'show' => 'customer'],
3 => ['biz_name' => '厦门哪吒订单中心', 'city_id' => '350200', 'show' => 'customer'],
4 => ['biz_name' => '泉州哪吒订单中心', 'city_id' => '350500', 'show' => 'customer'],
5 => ['biz_name' => '福州哪吒订单中心', 'city_id' => '350100', 'show' => 'customer']];
2 => ['biz_name' => '宁德哪吒代理店', 'type' => 3, 'city_id' => '350900', 'show' => 'order'],
3 => ['biz_name' => '厦门哪吒订单中心', 'city_id' => '350200', 'show' => 'order'],
4 => ['biz_name' => '泉州哪吒订单中心', 'city_id' => '350500', 'show' => 'order'],
5 => ['biz_name' => '福州哪吒订单中心', 'city_id' => '350100', 'show' => 'order']];
$res = $this->commonSelect($params, $config);
$this->data['info'] = $res['info'];
$this->data['params'] = $res['params'];
@@ -414,7 +414,7 @@ class order extends HD_Controller
$where_o = ["biz_id in({$str_ids})" => null, 'brand_id' => $brand_id,
'status in(0,1)' => null, 'order_time>=' => $order_time['s_time'], 'order_time<=' => $order_time['e_time']];
$num = $this->mdOrders->count($where_o);
if ($num && $v['show'] == 'customer') {//按订单数来匹配
if ($num && $v['show'] == 'order') {//按订单数来匹配
$res_o = $this->mdOrders->select($where_o, 'id desc', 0, 0, 'customer_id');
$customer_ids[$k2] = implode(',', array_unique(array_column($res_o, 'customer_id')));
}
@@ -426,7 +426,7 @@ class order extends HD_Controller
->join('lc_receiver_customers as b', "b.id=a.customer_id", 'left')
->where($where_o)
->count_all_results();
if ($num && $v['show'] == 'customer') {//按订单数来匹配
if ($num && $v['show'] == 'order') {//按订单数来匹配
$res_o = $this->mdOrders->db->select('a.customer_id')
->from('lc_receiver_orders_v2 as a')
->join('lc_receiver_customers as b', "b.id=a.customer_id", 'left')
@@ -443,7 +443,7 @@ class order extends HD_Controller
$v['customer_ids'] = $customer_ids;
$bizs[$k] = $v;
}
//echo json_encode($bizs, JSON_UNESCAPED_UNICODE);
//echo json_encode($bizs,JSON_UNESCAPED_UNICODE);
$offlineSources = $this->mdCustomers->offlineSources();
$offlineSources_count = count($offlineSources);
//过程数据
@@ -455,14 +455,29 @@ class order extends HD_Controller
foreach ($days as $k3 => $v3) {
$order_time = $this->getTime($k3);
$c_time = $this->getTime($k3, 1);
//进店数
if ($params['type'] == 2) {
$num_ord = $this->mdOrders->db->select('a.id')
->from('lc_receiver_orders_v2 as a')
->join('lc_receiver_customers as b', "b.id=a.customer_id", 'left')
->where(["a.biz_id in({$v['ids']})" => null, 'a.brand_id' => $brand_id, 'a.status in(0,1)' => null, 'a.order_time>=' => $order_time['s_time']
, 'a.order_time<=' => $order_time['e_time'], 'b.of_id' => $k2])
->count_all_results();
} else {
$num_ord = $this->mdOrders->db->select('a.id')
->from('lc_receiver_orders_v2 as a')
->join('lc_receiver_customers as b', "b.id=a.customer_id", 'left')
->where(["a.biz_id in({$v['ids']})" => null, 'a.brand_id' => $brand_id, 'a.status in(0,1)' => null, 'a.order_time>=' => $order_time['s_time'], 'a.order_time<=' => $order_time['e_time']
, 'b.of_id' => $k2, 'b.c_time>=' => $c_time['s_time'], 'b.c_time<=' => $c_time['e_time']])
->count_all_results();
}
//线索数
$num_cus = 0;
if ($k2 != 1) {//不包括自然到店
$where_cus = ["biz_id in({$v['ids']})" => null, 'of_id' => $k2, 'status>=' => 0, 'c_time>=' => $c_time['s_time'], 'c_time<=' => $c_time['e_time']];
if ($v['show'] == 'customer') {
$v['customer_ids'][$k3] && $num_cus = $this->mdCustomers->count(array_merge($where_cus, ["id in({$v['customer_ids'][$k3]})" => null]));
if ($v['show'] == 'order') {
$num_cus = $num_ord;
} else {
$num_cus = $this->mdCustomers->count($where_cus);
$num_cus = $this->mdCustomers->count(["biz_id in({$v['ids']})" => null, 'of_id' => $k2, 'status>=' => 0, 'c_time>=' => $c_time['s_time'], 'c_time<=' => $c_time['e_time']]);
}
$cus_sum[$k3] += $num_cus;
$stats_cus[] = $num_cus;
@@ -473,7 +488,7 @@ class order extends HD_Controller
if ($params['type'] == 2) {
$where_into = ['a.type' => 4, 'a.log' => '客户到店', 'a.c_time>=' => $c_time['s_time'], 'a.c_time<=' => $c_time['e_time'],
'b.status>=' => 0, "b.biz_id in({$v['ids']})" => null, 'b.of_id' => $k2];
if ($v['show'] == 'customer') {
if ($v['show'] == 'order') {
if ($v['customer_ids'][$k3]) {
$num_into = $this->mdUsersLog->db->select('a.id')
->from('lc_receiver_customer_oplogs as a')
@@ -491,7 +506,7 @@ class order extends HD_Controller
} else {
$where_into = ['a.type' => 4, 'a.log' => '客户到店', 'a.c_time>=' => $c_time['s_time'], 'a.c_time<=' => $c_time['e_time'],
'b.status>=' => 0, "b.biz_id in({$v['ids']})" => null, 'b.of_id' => $k2, 'b.c_time>=' => $c_time['s_time'], 'b.c_time<=' => $c_time['e_time']];
if ($v['show'] == 'customer') {
if ($v['show'] == 'order') {
if ($v['customer_ids'][$k3]) {
$num_into = $this->mdUsersLog->db->select('a.id')
->from('lc_receiver_customer_oplogs as a')
@@ -515,21 +530,6 @@ class order extends HD_Controller
}
$stats_per_into[$k3] = $num_into_per;
//成交数
if ($params['type'] == 2) {
$num_ord = $this->mdOrders->db->select('a.id')
->from('lc_receiver_orders_v2 as a')
->join('lc_receiver_customers as b', "b.id=a.customer_id", 'left')
->where(["a.biz_id in({$v['ids']})" => null, 'a.brand_id' => $brand_id, 'a.status in(0,1)' => null, 'a.order_time>=' => $order_time['s_time']
, 'a.order_time<=' => $order_time['e_time'], 'b.of_id' => $k2])
->count_all_results();
} else {
$num_ord = $this->mdOrders->db->select('a.id')
->from('lc_receiver_orders_v2 as a')
->join('lc_receiver_customers as b', "b.id=a.customer_id", 'left')
->where(["a.biz_id in({$v['ids']})" => null, 'a.brand_id' => $brand_id, 'a.status in(0,1)' => null, 'a.order_time>=' => $order_time['s_time'], 'a.order_time<=' => $order_time['e_time']
, 'b.of_id' => $k2, 'b.c_time>=' => $c_time['s_time'], 'b.c_time<=' => $c_time['e_time']])
->count_all_results();
}
$ord_sum[$k3] += $num_ord;
$stats_ord[] = $num_ord;
//转化率=订单数/进店数