order_822
This commit is contained in:
+167
-135
@@ -20,6 +20,27 @@ class order extends HD_Controller
|
||||
return $this->get_dfmc();
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes:零跑
|
||||
* Created on: 2022/8/22 14:19
|
||||
* Created by: dengbw
|
||||
*/
|
||||
public function get_leapmotor()
|
||||
{
|
||||
$params = $this->input->get();
|
||||
$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']];
|
||||
$res = $this->commonSelect($params, $config);
|
||||
$this->data['info'] = $res['info'];
|
||||
$this->data['params'] = $res['params'];
|
||||
$this->data['url'] = '/stats/order/get_leapmotor';
|
||||
$this->data['_title'] = '零跑';
|
||||
return $this->show_view('stats/order/common', true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes:哪吒
|
||||
* Created on: 2022/8/17 14:19
|
||||
@@ -27,144 +48,22 @@ class order extends HD_Controller
|
||||
*/
|
||||
public function get_hozonauto()
|
||||
{
|
||||
$brand_id = 4;//品牌id
|
||||
$params = $this->input->get();
|
||||
!$params['type'] && $params['type'] = 1;
|
||||
$start_date = date('Y-m', strtotime("-2 month"));//取最近3个月
|
||||
$end_date = date('Y-m');
|
||||
if ($params['time']) {
|
||||
$time = explode(' ~ ', $params['time']);
|
||||
$time[0] && $start_date = $time[0];
|
||||
$time[1] && $end_date = $time[1];
|
||||
} else {
|
||||
$params['time'] = $start_date . ' ~ ' . $end_date;
|
||||
}
|
||||
$date_months = $this->dateMonths($start_date, $end_date);
|
||||
rsort($date_months);
|
||||
$days = [];
|
||||
foreach ($date_months as $k => $v) {
|
||||
$month = date('n', strtotime($v . '-01'));
|
||||
$days[$v] = ['month' => $month, 'num' => 0];
|
||||
}
|
||||
$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']];
|
||||
foreach ($bizs as $k => $v) {
|
||||
$str_ids = $v['ids'] ? $v['ids'] : '';
|
||||
if (!$str_ids) {
|
||||
$where_b = ['status' => 1, 'city_id' => $v['city_id']];
|
||||
$v['type'] && $where_b['type'] = $v['type'];
|
||||
$res = $this->mdBiz->select($where_b, 'id desc', 0, 0, 'id');
|
||||
if ($res) {
|
||||
$str_ids = implode(',', array_unique(array_column($res, 'id')));
|
||||
$str_ids = $str_ids ? $str_ids : '-1';
|
||||
}
|
||||
}
|
||||
$list = [];
|
||||
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>=' => 0, 'order_time>=' => $order_time['s_time'], 'order_time<=' => $order_time['e_time']]);
|
||||
} else {
|
||||
$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>=' => 0, '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']])
|
||||
->count_all_results();
|
||||
}
|
||||
$list[$k2] = $num;
|
||||
$days[$k2]['num'] = $v2['num'] + $num;
|
||||
}
|
||||
$v['list'] = $list;
|
||||
$v['ids'] = $str_ids;
|
||||
$bizs[$k] = $v;
|
||||
}
|
||||
$offlineSources = $this->mdCustomers->offlineSources();
|
||||
$offlineSources_count = count($offlineSources);
|
||||
//过程数据
|
||||
$process_cus = $process_into = $process_ord = [];
|
||||
foreach ($bizs as $k => $v) {
|
||||
$list_cus = $cus_sum = $list_into = $ord_into = $into_sum = $list_ord = $ord_sum = [];
|
||||
foreach ($offlineSources as $k2 => $v2) {
|
||||
$stats_per_cus = $stats_cus = $stats_per_into = $stats_into = $stats_per_ord = $stats_ord = [];
|
||||
foreach ($days as $k3 => $v3) {
|
||||
$order_time = $this->getTime($k3);
|
||||
$c_time = $this->getTime($k3, 1);
|
||||
//线索数
|
||||
$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']]);
|
||||
$cus_sum[$k3] += $num_cus;
|
||||
$stats_cus[] = $num_cus;
|
||||
$stats_per_cus[$k3] = $num_cus;
|
||||
}
|
||||
//进店数
|
||||
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();
|
||||
} 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();
|
||||
}
|
||||
$into_sum[$k3] += $num_into;
|
||||
$stats_into[] = $num_into;
|
||||
$num_into_per = '';
|
||||
if ($k2 != 1) {//转化率=进店数/客户数
|
||||
$num_into_per = $this->getPercentage(['num' => $num_into, 'sum' => $num_cus]);
|
||||
}
|
||||
$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>=' => 0, '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>=' => 0, '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;
|
||||
//转化率=订单数/进店数
|
||||
$stats_per_ord[$k3] = $this->getPercentage(['num' => $num_ord, 'sum' => $num_into]);
|
||||
}
|
||||
if ($k2 != 1) {//不包括自然到店
|
||||
$list_cus[] = ['name' => $v2['name'], 'stats_per' => $stats_per_cus, 'stats' => $stats_cus];
|
||||
}
|
||||
$list_into[] = ['name' => $v2['name'], 'stats_per' => $stats_per_into, 'stats' => $stats_into];
|
||||
$list_ord[] = ['name' => $v2['name'], 'stats_per' => $stats_per_ord, 'stats' => $stats_ord];
|
||||
}
|
||||
$process_cus[] = ['biz_name' => $v['biz_name'], 'num_sum' => $cus_sum, 'list' => $list_cus];
|
||||
$process_into[] = ['biz_name' => $v['biz_name'], 'num_sum' => $into_sum, 'list' => $list_into];
|
||||
$process_ord[] = ['biz_name' => $v['biz_name'], 'num_sum' => $ord_sum, 'list' => $list_ord];
|
||||
}
|
||||
$process = ['customers' => $process_cus, 'into_shop' => $process_into, 'orders' => $process_ord];
|
||||
$this->data['info'] = ['days' => $days, 'bizs' => $bizs, 'bizs_count' => count($bizs), 'days_count' => count($days)
|
||||
, 'brands_count' => 1, 'offlineSources_count' => $offlineSources_count, 'process' => $process,
|
||||
'type_ary' => [1 => '月销售模型(当月线索)', 2 => '月销售模型']];
|
||||
$this->data['params'] = $params;
|
||||
$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']];
|
||||
$res = $this->commonSelect($params, $config);
|
||||
$this->data['info'] = $res['info'];
|
||||
$this->data['params'] = $res['params'];
|
||||
$this->data['url'] = '/stats/order/get_hozonauto';
|
||||
$this->data['_title'] = '哪吒';
|
||||
return $this->show_view('stats/order/hozonauto', true);
|
||||
return $this->show_view('stats/order/common', true);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Notes:东风品牌店群
|
||||
* Created on: 2022/8/17 14:17
|
||||
@@ -369,8 +268,141 @@ class order extends HD_Controller
|
||||
return $this->show_view('stats/order/dfmc', true);
|
||||
}
|
||||
|
||||
private function dataSelect($params)
|
||||
private function commonSelect($params, $config)
|
||||
{
|
||||
$brand_id = $config['brand_id'];//品牌id
|
||||
!$params['type'] && $params['type'] = 1;
|
||||
$start_date = date('Y-m', strtotime("-2 month"));//取最近3个月
|
||||
$end_date = date('Y-m');
|
||||
if ($params['time']) {
|
||||
$time = explode(' ~ ', $params['time']);
|
||||
$time[0] && $start_date = $time[0];
|
||||
$time[1] && $end_date = $time[1];
|
||||
} else {
|
||||
$params['time'] = $start_date . ' ~ ' . $end_date;
|
||||
}
|
||||
$date_months = $this->dateMonths($start_date, $end_date);
|
||||
rsort($date_months);
|
||||
$days = [];
|
||||
foreach ($date_months as $k => $v) {
|
||||
$month = date('n', strtotime($v . '-01'));
|
||||
$days[$v] = ['month' => $month, 'num' => 0];
|
||||
}
|
||||
$bizs = $config['bizs'];
|
||||
foreach ($bizs as $k => $v) {
|
||||
$str_ids = $v['ids'] ? $v['ids'] : '';
|
||||
if (!$str_ids) {
|
||||
$where_b = ['status' => 1, 'city_id' => $v['city_id']];
|
||||
$v['type'] && $where_b['type'] = $v['type'];
|
||||
$v['not_ids'] && $where_b["id not in({$v['not_ids']})"] = null;
|
||||
$res = $this->mdBiz->select($where_b, 'id desc', 0, 0, 'id');
|
||||
if ($res) {
|
||||
$str_ids = implode(',', array_unique(array_column($res, 'id')));
|
||||
$str_ids = $str_ids ? $str_ids : '-2';
|
||||
}
|
||||
}
|
||||
$list = [];
|
||||
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>=' => 0, 'order_time>=' => $order_time['s_time'], 'order_time<=' => $order_time['e_time']]);
|
||||
} else {
|
||||
$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>=' => 0, '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']])
|
||||
->count_all_results();
|
||||
}
|
||||
$list[$k2] = $num;
|
||||
$days[$k2]['num'] = $v2['num'] + $num;
|
||||
}
|
||||
$v['list'] = $list;
|
||||
$v['ids'] = $str_ids;
|
||||
$bizs[$k] = $v;
|
||||
}
|
||||
//echo json_encode($bizs,JSON_UNESCAPED_UNICODE);
|
||||
$offlineSources = $this->mdCustomers->offlineSources();
|
||||
$offlineSources_count = count($offlineSources);
|
||||
//过程数据
|
||||
$process_cus = $process_into = $process_ord = [];
|
||||
foreach ($bizs as $k => $v) {
|
||||
$list_cus = $cus_sum = $list_into = $ord_into = $into_sum = $list_ord = $ord_sum = [];
|
||||
foreach ($offlineSources as $k2 => $v2) {
|
||||
$stats_per_cus = $stats_cus = $stats_per_into = $stats_into = $stats_per_ord = $stats_ord = [];
|
||||
foreach ($days as $k3 => $v3) {
|
||||
$order_time = $this->getTime($k3);
|
||||
$c_time = $this->getTime($k3, 1);
|
||||
//线索数
|
||||
$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']]);
|
||||
$cus_sum[$k3] += $num_cus;
|
||||
$stats_cus[] = $num_cus;
|
||||
$stats_per_cus[$k3] = $num_cus;
|
||||
}
|
||||
//进店数
|
||||
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();
|
||||
} 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();
|
||||
}
|
||||
$into_sum[$k3] += $num_into;
|
||||
$stats_into[] = $num_into;
|
||||
$num_into_per = '';
|
||||
if ($k2 != 1) {//转化率=进店数/客户数
|
||||
$num_into_per = $this->getPercentage(['num' => $num_into, 'sum' => $num_cus]);
|
||||
}
|
||||
$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>=' => 0, '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>=' => 0, '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;
|
||||
//转化率=订单数/进店数
|
||||
$stats_per_ord[$k3] = $this->getPercentage(['num' => $num_ord, 'sum' => $num_into]);
|
||||
}
|
||||
if ($k2 != 1) {//不包括自然到店
|
||||
$list_cus[] = ['name' => $v2['name'], 'stats_per' => $stats_per_cus, 'stats' => $stats_cus];
|
||||
}
|
||||
$list_into[] = ['name' => $v2['name'], 'stats_per' => $stats_per_into, 'stats' => $stats_into];
|
||||
$list_ord[] = ['name' => $v2['name'], 'stats_per' => $stats_per_ord, 'stats' => $stats_ord];
|
||||
}
|
||||
$process_cus[] = ['biz_name' => $v['biz_name'], 'num_sum' => $cus_sum, 'list' => $list_cus];
|
||||
$process_into[] = ['biz_name' => $v['biz_name'], 'num_sum' => $into_sum, 'list' => $list_into];
|
||||
$process_ord[] = ['biz_name' => $v['biz_name'], 'num_sum' => $ord_sum, 'list' => $list_ord];
|
||||
}
|
||||
$process = ['customers' => $process_cus, 'into_shop' => $process_into, 'orders' => $process_ord];
|
||||
$data['info'] = ['days' => $days, 'bizs' => $bizs, 'bizs_count' => count($bizs), 'days_count' => count($days)
|
||||
, 'brands_count' => 1, 'offlineSources_count' => $offlineSources_count, 'process' => $process,
|
||||
'type_ary' => [1 => '月销售模型(当月线索)', 2 => '月销售模型']];
|
||||
$data['params'] = $params;
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<div class="coms-table-wrap mt10">
|
||||
<form id="vue-app" class=" form-search coms-table-hd clearfix no-border" onsubmit="return false"
|
||||
action="/stats/order/get_hozonauto">
|
||||
action="<?= $url ?>">
|
||||
<input name="type" value="<?= $params['type'] ?>" type="hidden">
|
||||
<div class="am-form am-form-horizontal">
|
||||
<div class="am-form-group fl">
|
||||
@@ -24,7 +24,7 @@
|
||||
<li role="presentation"
|
||||
class="<?= $params['type'] == $key ? 'active' : '' ?>">
|
||||
<a href="javascript:void (0);"
|
||||
data-open="/stats/order/get_hozonauto?type=<?= $key ?>&time=<?= $params['time'] ?>">
|
||||
data-open="<?= $url ?>?type=<?= $key ?>&time=<?= $params['time'] ?>">
|
||||
<?= $val ?>
|
||||
</a>
|
||||
</li>
|
||||
Reference in New Issue
Block a user