This commit is contained in:
小鱼开发
2024-07-13 17:51:15 +08:00
parent 866529eeff
commit f7eb40cd94
2 changed files with 82 additions and 39 deletions
+73 -21
View File
@@ -18,6 +18,7 @@ class Statistics extends Wxapp{
$this->check_mobile = array();//需要手机号
$this->check_headimg = array();//授权微信信息
$this->load->model("biz/biz_model");
$this->load->model("biz/biz_model");
$this->load->model('receiver/receiver_customers_model','customers_model');
$this->load->model('receiver/order/receiver_orders_model','orders_model');
@@ -185,7 +186,6 @@ class Statistics extends Wxapp{
];
return $data;
}
//数据分析页面客户数据
protected function get_scust(){
$day = $this->input_param('day');
@@ -609,7 +609,6 @@ class Statistics extends Wxapp{
];
return $data;
}
/**
* 获取月份
*/
@@ -632,7 +631,6 @@ class Statistics extends Wxapp{
return $season_data;
}
protected function get_stats()
{
$s_time = $this->input_param('s_time');
@@ -644,10 +642,23 @@ class Statistics extends Wxapp{
$c_time = ['s_time' => strtotime($s_time), 'e_time' => strtotime(date('Y-m-d 23:59:59', strtotime($e_time)))];
$o_time = ['s_time' => $s_time . ' 00:00:00', 'e_time' => $e_time . ' 23:59:59'];
$biz_where = array('province_id' => $province_id, 'status' => 1, 'type' => 0);
$city_id && $biz_where['city_id'] = $city_id;
$bizs = $this->biz_model->select($biz_where);
$biz_id_arr = implode(',', array_unique(array_column($bizs, 'id')));
if($city_id){
$biz_where = array('province_id' => $province_id, 'city_id' => $city_id, 'status' => 1, 'type' => 0);
$bizs = $this->biz_model->select($biz_where);
$bizs = array_column($bizs, 'id');
$this->session['biz_id'] && $bizs = array_intersect($bizs, explode(',', $this->session['biz_id']));
$biz_id_arr = implode(',', array_unique($bizs));
}else{
if($this->session['biz_id']){
$biz_id_arr = $this->session['biz_id'];
}else{
$biz_where = array('province_id' => $province_id, 'status' => 1, 'type' => 0);
$bizs = $this->biz_model->select($biz_where);
$biz_id_arr = implode(',', array_unique(array_column($bizs, 'id')));
}
}
!$biz_id_arr && $biz_id_arr = 0;
//客户
$c_where = [
@@ -730,10 +741,25 @@ class Statistics extends Wxapp{
'c_time>=' => $c_time['s_time'],
'c_time<=' => $c_time['e_time'],
];
$biz_where = array('province_id' => $province_id, 'status' => 1, 'type' => 0);
$city_id && $biz_where['city_id'] = $city_id;
$bizs = $this->biz_model->select($biz_where);
$biz_id_arr = implode(',', array_unique(array_column($bizs, 'id')));
if($city_id){
$biz_where = array('province_id' => $province_id, 'city_id' => $city_id, 'status' => 1, 'type' => 0);
$bizs = $this->biz_model->select($biz_where);
$bizs = array_column($bizs, 'id');
$this->session['biz_id'] && $bizs = array_intersect($bizs, explode(',', $this->session['biz_id']));
$biz_id_arr = implode(',', array_unique($bizs));
}else{
if($this->session['biz_id']){
$biz_id_arr = $this->session['biz_id'];
}else{
$biz_where = array('province_id' => $province_id, 'status' => 1, 'type' => 0);
$bizs = $this->biz_model->select($biz_where);
$biz_id_arr = implode(',', array_unique(array_column($bizs, 'id')));
}
}
!$biz_id_arr && $biz_id_arr = 0;
$c_where["biz_id in ({$biz_id_arr})"] = null;
$customers[] = $this->customers_model->count($c_where);
$o_where = [
@@ -774,11 +800,25 @@ class Statistics extends Wxapp{
$pie1_level = $pie1_offline = $biz_customer = [];
$bottom2 = $bottom1 = '';
$biz_where = array('province_id' => $province_id, 'status' => 1, 'type' => 0);
$city_id && $biz_where['city_id'] = $city_id;
$bizs = $this->biz_model->select($biz_where);
if($bizs){
$biz_id_arr = implode(',', array_unique(array_column($bizs, 'id')));
if($city_id){
$biz_where = array('province_id' => $province_id, 'city_id' => $city_id, 'status' => 1, 'type' => 0);
$bizs = $this->biz_model->select($biz_where);
$bizs = array_column($bizs, 'id');
$this->session['biz_id'] && $bizs = array_intersect($bizs, explode(',', $this->session['biz_id']));
$biz_id_arr = implode(',', array_unique($bizs));
}else{
if($this->session['biz_id']){
$biz_id_arr = $this->session['biz_id'];
}else{
$biz_where = array('province_id' => $province_id, 'status' => 1, 'type' => 0);
$bizs = $this->biz_model->select($biz_where);
$biz_id_arr = implode(',', array_unique(array_column($bizs, 'id')));
}
}
if($biz_id_arr){
$biz_where = array('status' => 1, 'type' => 0, "id in ({$biz_id_arr})" => null);
$bizs = $this->biz_model->select($biz_where);
$sdata_level = $this->customers_model->get_sdata('level');
foreach ($sdata_level as $v) {
@@ -961,11 +1001,23 @@ class Statistics extends Wxapp{
$pie_offline = [];
$o_time = ['s_time' => $s_time . ' 00:00:00', 'e_time' => $e_time . ' 23:59:59'];
$biz_where = array('province_id' => $province_id, 'status' => 1, 'type' => 0);
$city_id && $biz_where['city_id'] = $city_id;
$bizs = $this->biz_model->select($biz_where);
if($bizs){
$biz_id_arr = implode(',', array_unique(array_column($bizs, 'id')));
if($city_id){
$biz_where = array('province_id' => $province_id, 'city_id' => $city_id, 'status' => 1, 'type' => 0);
$bizs = $this->biz_model->select($biz_where);
$bizs = array_column($bizs, 'id');
$this->session['biz_id'] && $bizs = array_intersect($bizs, explode(',', $this->session['biz_id']));
$biz_id_arr = implode(',', array_unique($bizs));
}else{
if($this->session['biz_id']){
$biz_id_arr = $this->session['biz_id'];
}else{
$biz_where = array('province_id' => $province_id, 'status' => 1, 'type' => 0);
$bizs = $this->biz_model->select($biz_where);
$biz_id_arr = implode(',', array_unique(array_column($bizs, 'id')));
}
}
if($biz_id_arr){
$offlineSources = $this->customers_model->offlineSources($id, 0);
foreach ($offlineSources["list"] as $k => $v) {