增加狸车宝统计二级数据

This commit is contained in:
lccsw
2023-06-14 14:22:30 +08:00
parent 4e0ab69a5d
commit 4efcce905c
2 changed files with 82 additions and 6 deletions
+80 -4
View File
@@ -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
+2 -2
View File
@@ -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']}<br>方可获得秒杀资格");
}
}
$act = $this->market_sylive_activity_model->get(['activityId'=>$a_id]);