order_830

This commit is contained in:
dengbw
2022-08-30 16:00:32 +08:00
parent 95e988aa1c
commit 4c4250883b
+68 -25
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'],
3 => ['biz_name' => '厦门渠道', 'city_id' => '350200']];
2 => ['biz_name' => '泉州渠道', 'not_ids' => '63', 'city_id' => '350500', 'show' => 'customer'],
3 => ['biz_name' => '厦门渠道', 'city_id' => '350200', 'show' => 'customer']];
$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'],
3 => ['biz_name' => '厦门哪吒订单中心', 'city_id' => '350200'],
4 => ['biz_name' => '泉州哪吒订单中心', 'city_id' => '350500'],
5 => ['biz_name' => '福州哪吒订单中心', 'city_id' => '350100']];
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']];
$res = $this->commonSelect($params, $config);
$this->data['info'] = $res['info'];
$this->data['params'] = $res['params'];
@@ -406,29 +406,44 @@ class order extends HD_Controller
$str_ids = $str_ids ? $str_ids : '-2';
}
}
$list = [];
$list = $customer_ids = [];
foreach ($days as $k2 => $v2) {
$order_time = $this->getTime($k2);
$c_time = $this->getTime($k2, 1);
if ($params['type'] == 2) {
$num = $this->mdOrders->count(["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']]);
$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') {//按订单数来匹配
$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')));
}
} else {
$where_o = ["a.biz_id in({$str_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.c_time>=' => $c_time['s_time'], 'b.c_time<=' => $c_time['e_time']];
$num = $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({$str_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.c_time>=' => $c_time['s_time'], 'b.c_time<=' => $c_time['e_time']])
->where($where_o)
->count_all_results();
if ($num && $v['show'] == 'customer') {//按订单数来匹配
$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')
->where($where_o)
->count_all_results();
$customer_ids[$k2] = implode(',', array_unique(array_column($res_o, 'customer_id')));
}
}
$list[$k2] = $num;
$days[$k2]['num'] = $v2['num'] + $num;
}
$v['list'] = $list;
$v['ids'] = $str_ids;
$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);
//过程数据
@@ -443,26 +458,54 @@ class order extends HD_Controller
//线索数
$num_cus = 0;
if ($k2 != 1) {//不包括自然到店
$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']]);
$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]));
} else {
$num_cus = $this->mdCustomers->count($where_cus);
}
$cus_sum[$k3] += $num_cus;
$stats_cus[] = $num_cus;
$stats_per_cus[$k3] = $num_cus;
}
//进店数
$num_into = 0;
if ($params['type'] == 2) {
$num_into = $this->mdUsersLog->db->select('a.id')
->from('lc_receiver_customer_oplogs as a')
->join('lc_receiver_customers as b', "b.id=a.customer_id", 'left')
->where(['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])
->count_all_results();
$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['customer_ids'][$k3]) {
$num_into = $this->mdUsersLog->db->select('a.id')
->from('lc_receiver_customer_oplogs as a')
->join('lc_receiver_customers as b', "b.id=a.customer_id", 'left')
->where(array_merge($where_into, ["b.id in({$v['customer_ids'][$k3]})" => null]))
->count_all_results();
}
} else {
$num_into = $this->mdUsersLog->db->select('a.id')
->from('lc_receiver_customer_oplogs as a')
->join('lc_receiver_customers as b', "b.id=a.customer_id", 'left')
->where($where_into)
->count_all_results();
}
} else {
$num_into = $this->mdUsersLog->db->select('a.id')
->from('lc_receiver_customer_oplogs as a')
->join('lc_receiver_customers as b', "b.id=a.customer_id", 'left')
->where(['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']])
->count_all_results();
$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['customer_ids'][$k3]) {
$num_into = $this->mdUsersLog->db->select('a.id')
->from('lc_receiver_customer_oplogs as a')
->join('lc_receiver_customers as b', "b.id=a.customer_id", 'left')
->where(array_merge($where_into, ["b.id in({$v['customer_ids'][$k3]})" => null]))
->count_all_results();
}
} else {
$num_into = $this->mdUsersLog->db->select('a.id')
->from('lc_receiver_customer_oplogs as a')
->join('lc_receiver_customers as b', "b.id=a.customer_id", 'left')
->where($where_into)
->count_all_results();
}
}
$into_sum[$k3] += $num_into;
$stats_into[] = $num_into;