From 4efcce905ceb35c77f3fd4dde69c4f3c8bd8d67a Mon Sep 17 00:00:00 2001 From: lccsw <805383944@qq.com> Date: Wed, 14 Jun 2023 14:22:30 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=8B=B8=E8=BD=A6=E5=AE=9D?= =?UTF-8?q?=E7=BB=9F=E8=AE=A1=E4=BA=8C=E7=BA=A7=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/controllers/wxapp/licheb/Biz.php | 84 ++++++++++++++++++++- home/controllers/h5/market/sylive2/Item.php | 4 +- 2 files changed, 82 insertions(+), 6 deletions(-) diff --git a/api/controllers/wxapp/licheb/Biz.php b/api/controllers/wxapp/licheb/Biz.php index 4a5aedc7..4f1863bd 100644 --- a/api/controllers/wxapp/licheb/Biz.php +++ b/api/controllers/wxapp/licheb/Biz.php @@ -134,15 +134,16 @@ class Biz extends Wxapp } $offlineSources = $this->mdCustomers->offlineSources(); foreach ($offlineSources as $k => $v) { + $id = count($v["list"])>0 ? $k : 0; $value_1 = $this->mdCustomers->count(array_merge($where, ['of_id' => $k])); - $value_1 && $pie1_offline[] = ['name' => $v['name'], 'value' => $value_1]; + $value_1 && $pie1_offline[] = ['id' => $id,'name' => $v['name'], 'value' => $value_1]; $value_2 = $this->mdCustomers->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' => $this->biz_id, 'b.of_id' => $k]) ->count_all_results(); - $value_2 && $pie2_offline[] = ['name' => $v['name'], 'value' => $value_2]; + $value_2 && $pie2_offline[] = ['id' => $id,'name' => $v['name'], 'value' => $value_2]; } $res_user = $this->app_user_model->select(['status' => 1, 'biz_id' => $this->biz_id], 'id desc', 0, 0, 'id,uname'); foreach ($res_user as $k => $v) { @@ -155,6 +156,51 @@ class Biz extends Wxapp $data['title'] = '客户数据'; return $data; } + //客户数据 + protected function get_stats_customer_pid() + { + $id = $this->input_param('id'); + $type = $this->input_param('type'); + $s_time = $this->input_param('s_time'); + $e_time = $this->input_param('e_time'); + !$s_time && $s_time = date('Y-m-d'); + !$e_time && $e_time = date('Y-m-d'); + $c_time = ['s_time' => strtotime($s_time), 'e_time' => strtotime(date('Y-m-d 23:59:59', strtotime($e_time)))]; + $pie_offline = []; + $where = ['biz_id' => $this->biz_id, 'status>=' => 0, 'c_time>=' => $c_time['s_time'], 'c_time<=' => $c_time['e_time']]; + $o_time = ['s_time' => $s_time . ' 00:00:00', 'e_time' => $e_time . ' 23:59:59']; + $offlineSources = $this->mdCustomers->offlineSources($id); + foreach ($offlineSources["list"] as $k => $v) { + if($type==1){ + $value_1 = $this->mdCustomers->count(array_merge($where, ['of_id'=>$id,'of2_id' => $k])); + $value_1 && $pie_offline[] = ['name' => $v, 'value' => $value_1]; + }else if($type==2){ + $value_1 = $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' => $this->biz_id, 'a.status>=' => 0, 'a.order_time>=' => $o_time['s_time'], 'a.order_time<=' => $o_time['e_time'] + , 'b.of_id' => $id, 'b.of2_id' => $k]) + ->count_all_results(); + $value_1 && $pie_offline[] = ['name' => $v, 'value' => $value_1]; + }else{ + $value_1 = $this->mdCustomers->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' => $this->biz_id, 'b.of_id' => $id, 'of2_id' => $k]) + ->count_all_results(); + $value_1 && $pie_offline[] = ['id' => $id,'name' => $v['name'], 'value' => $value_1]; + } + } + if($type==1){ + $title = "客户来源(录入)"; + }else if($type==2){ + $title = "订单来源"; + }else{ + $title = "客户来源(进店)"; + } + return ['title' => $title, 'series_data' => $pie_offline]; + } /** * Notes:企微数据 @@ -208,6 +254,7 @@ class Biz extends Wxapp $pie1_bottom = 0; $offlineSources = $this->mdCustomers->offlineSources(); foreach ($offlineSources as $k => $v) { + $id = count($v["list"])>0 ? $k : 0; $value = $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') @@ -215,7 +262,7 @@ class Biz extends Wxapp , 'b.of_id' => $k]) ->count_all_results(); if ($value) { - $pie1_series_data[] = ['name' => $v['name'], 'value' => $value]; + $pie1_series_data[] = ['id'=> $id, 'name' => $v['name'], 'value' => $value]; $pie1_bottom += $value; } } @@ -244,7 +291,8 @@ class Biz extends Wxapp if ($v['brand_id']) { $value = $this->mdOrders->count(array_merge($where_o, ['brand_id' => $v['brand_id']])); } - $value && $series_data_1[] = ['name' => $name, 'value' => $value]; + $brand_id = $v['brand_id']; + $value && $series_data_1[] = ['id' => $brand_id,'name' => $name, 'value' => $value]; } } //退定 @@ -269,6 +317,34 @@ class Biz extends Wxapp return $data; } + //订单数据 + protected function get_stats_order_series(){ + $id = $this->input_param('id'); + $s_time = $this->input_param('s_time'); + $e_time = $this->input_param('e_time'); + !$s_time && $s_time = date('Y-m-d'); + !$e_time && $e_time = date('Y-m-d'); + $o_time = ['s_time' => $s_time . ' 00:00:00', 'e_time' => $e_time . ' 23:59:59']; + $this->load->model('auto/auto_series_model', 'mdAutoSeries'); + $series_data_1 = []; + $where_o = ['biz_id' => $this->biz_id, 'status>=' => 0, 'order_time>=' => $o_time['s_time'], 'order_time<=' => $o_time['e_time'],'brand_id'=>$id]; + //成交 + $res_o = $this->mdOrders->select($where_o, 'id desc', 0, 0, 'distinct(s_id) as s_id'); + if ($res_o) { + $str_ids = implode(",", array_unique(array_column($res_o, 's_id'))); + $map_series = $this->mdAutoSeries->map('id', 'name', ["id in({$str_ids})" => null]); + foreach ($res_o as $k => $v) { + $name = $map_series[$v['s_id']] ? $map_series[$v['s_id']] : '-'; + $value = 0; + if ($v['s_id']) { + $value = $this->mdOrders->count(array_merge($where_o, ['s_id' => $v['s_id']])); + } + $value && $series_data_1[] = ['name' => $name, 'value' => $value]; + } + } + return ['title' => '品牌分布', 'series_data' => $series_data_1]; + } + /** * Notes:店铺概况_tab diff --git a/home/controllers/h5/market/sylive2/Item.php b/home/controllers/h5/market/sylive2/Item.php index a74a7158..790263c9 100644 --- a/home/controllers/h5/market/sylive2/Item.php +++ b/home/controllers/h5/market/sylive2/Item.php @@ -247,10 +247,10 @@ class Item extends Wx{ } $item_row = $this->market_sylive_items_model->get(['itemId'=>$item_id,'activityId'=>$a_id]); if($item_row['needItemId']){ //特殊处理需要先购买权益商品 - $where = ['itemId'=>$item_row['needItemId'],'userId'=>$this->uid]; + $where = ['itemId'=>$item_row['needItemId'],'userId'=>$this->uid,'status>'=>0]; if(!$this->market_sylive_order_model->count($where)){ $need_item_row = $this->market_sylive_items_model->get(['itemId'=>$item_row['needItemId']],'title'); - $this->show_json('',400,"购买{$need_item_row['title']}方可获得秒杀资格"); + $this->show_json('',400,"购买{$need_item_row['title']}
方可获得秒杀资格"); } } $act = $this->market_sylive_activity_model->get(['activityId'=>$a_id]);