From 639bce66bda3c42ce02483b9893d0417a076a8f5 Mon Sep 17 00:00:00 2001 From: dengbw Date: Thu, 18 Aug 2022 14:55:58 +0800 Subject: [PATCH] order_818 --- admin/controllers/stats/Order.php | 157 ++++++++++++++- .../stats/order/{dashboards.php => dfmc.php} | 8 +- admin/views/stats/order/hozonauto.php | 184 ++++++++++++++++++ api/controllers/wxapp/licheb/Customers.php | 6 +- 4 files changed, 345 insertions(+), 10 deletions(-) rename admin/views/stats/order/{dashboards.php => dfmc.php} (97%) create mode 100644 admin/views/stats/order/hozonauto.php diff --git a/admin/controllers/stats/Order.php b/admin/controllers/stats/Order.php index 34f7941d..42e5eae8 100644 --- a/admin/controllers/stats/Order.php +++ b/admin/controllers/stats/Order.php @@ -16,10 +16,159 @@ class order extends HD_Controller //首页信息 public function index() { - return $this->get_dashboards(); + return $this->get_dfmc(); } - public function get_dashboards() + /** + * Notes:哪吒 + * Created on: 2022/8/17 14:19 + * Created by: dengbw + */ + public function get_hozonauto() + { + $this->load->model('biz/biz_model', 'mdBiz'); + $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' => '宁德哪吒代理店', 'city_id' => '350900'] + , 3 => ['biz_name' => '厦门哪吒订单中心', 'city_id' => '350200'], 4 => ['biz_name' => '泉州哪吒代理店', 'city_id' => '350500']]; + foreach ($bizs as $k => $v) { + $str_ids = $v['ids'] ? $v['ids'] : ''; + if (!$str_ids) { + $res = $this->mdBiz->select(['status' => 1, 'type' => 3, 'city_id' => $v['city_id']], '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; + $this->data['_title'] = '哪吒'; + return $this->show_view('stats/order/hozonauto', true); + } + + + /** + * Notes:东风品牌店群 + * Created on: 2022/8/17 14:17 + * Created by: dengbw + * @return bool|void + */ + public function get_dfmc() { $params = $this->input->get(); !$params['type'] && $params['type'] = 1; @@ -35,8 +184,6 @@ class order extends HD_Controller $date_months = $this->dateMonths($start_date, $end_date); rsort($date_months); $days = []; -// $days = ['2022-07' => ['month' => 7, 'num' => 0], '2022-06' => ['month' => 6, 'num' => 0], -// '2022-05' => ['month' => 5, 'num' => 0], '2022-04' => ['month' => 4, 'num' => 0]]; foreach ($date_months as $k => $v) { $month = date('n', strtotime($v . '-01')); $days[$v] = ['month' => $month, 'num' => 0]; @@ -216,7 +363,7 @@ class order extends HD_Controller , 'customers_stats' => $customers_stats, 'process' => $process, 'type_ary' => [1 => '月销售模型(当月线索)', 2 => '月销售模型']]; $this->data['params'] = $params; $this->data['_title'] = '东风品牌店群'; - return $this->show_view('stats/order/dashboards', true); + return $this->show_view('stats/order/dfmc', true); } /** diff --git a/admin/views/stats/order/dashboards.php b/admin/views/stats/order/dfmc.php similarity index 97% rename from admin/views/stats/order/dashboards.php rename to admin/views/stats/order/dfmc.php index ed0a115a..468d64ca 100644 --- a/admin/views/stats/order/dashboards.php +++ b/admin/views/stats/order/dfmc.php @@ -168,7 +168,7 @@ - 线索数 + 线索数 转化率 数据 @@ -201,7 +201,7 @@ 合计 - + @@ -229,7 +229,7 @@ 合计 - + @@ -257,7 +257,7 @@ 合计 - + diff --git a/admin/views/stats/order/hozonauto.php b/admin/views/stats/order/hozonauto.php new file mode 100644 index 00000000..a4d983cf --- /dev/null +++ b/admin/views/stats/order/hozonauto.php @@ -0,0 +1,184 @@ +
+ + +
+ +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
目标完成情况月完成
本期的完成情况(订单台数)
渠道
+ + + + + + + + + + + + + + + + + + + + + + + + + + + $v2) { ?> + ' : '' ?> + + $v3) { ?> + + + + + + ' : '' ?> + + + + + + + + + + + $v) { ?> + + + + + + $v2) { ?> + ' : '' ?> + + $v3) { ?> + + + + + + ' : '' ?> + + + + + + + + + + + $v) { ?> + + + + + + $v2) { ?> + ' : '' ?> + + $v3) { ?> + + + + + + ' : '' ?> + + + + + + + + + + + +
过程数据
线索数转化率数据
+
合计
进店数 +
合计
成交数 +
合计
+
+
+ + \ No newline at end of file diff --git a/api/controllers/wxapp/licheb/Customers.php b/api/controllers/wxapp/licheb/Customers.php index bc4f04ac..d89951ac 100644 --- a/api/controllers/wxapp/licheb/Customers.php +++ b/api/controllers/wxapp/licheb/Customers.php @@ -569,6 +569,7 @@ class Customers extends Wxapp $s_visit_time = $this->input_param('s_visit_time');//回访开始时间 $e_visit_time = $this->input_param('e_visit_time');//回访结束时间 $status_tp = intval($this->input_param('status_tp')); //状态类型 + $admin_ids = $this->input_param('admin_ids');//多选销售人员 !$page && $page = 1; !$size && $size = 10; @@ -603,7 +604,7 @@ class Customers extends Wxapp $where["admin_id"] = $uid; } if ($group_id == 4 && $this->biz_id != 1) { - $where['brand_id!='] = 3; //渠道经理过滤 + $where['brand_id<>'] = 3; //渠道经理过滤 } if ($s_time && $e_time) { $where['c_time >='] = strtotime($s_time); @@ -626,6 +627,9 @@ class Customers extends Wxapp } $unuse && $where['admin_id'] = 0; $admin_id && $where['admin_id'] = $admin_id; + if ($admin_ids) { + $where["admin_id in ({$admin_ids})"] = null; + } $id && $where['id'] = $id; strlen($istop) && $where['is_top'] = $istop; strlen($if_driver) && $where['if_driver'] = 1;