diff --git a/admin/controllers/app/licheb/Member.php b/admin/controllers/app/licheb/Member.php index c8ed7d2a..7e22e657 100644 --- a/admin/controllers/app/licheb/Member.php +++ b/admin/controllers/app/licheb/Member.php @@ -120,15 +120,10 @@ class Member extends HD_Controller 'city_id1' => $row['city_id1'], ); if ($row['group_id'] == 4) { - $this->load->model('app/licheb/App_licheb_channel_biz_model', 'mdChannelBiz'); - $res_biz = $this->mdChannelBiz->select(['uid' => $id], 'id desc', 0, 0, 'biz_id'); - $res_biz && $biz_id_arr = array_unique(array_column($res_biz, 'biz_id')); - if ($res_biz) { - $biz_id_arr = array_unique(array_column($res_biz, 'biz_id')); - $ids = implode(',', $biz_id_arr); - $typeAry = $this->biz_model->type_ary(); - $type_ids = implode(',', array_keys($typeAry)); - $selectedBrands = $this->biz_model->select(["id in ($ids)" => null, "type in ($type_ids)" => null, 'status' => 1], '', 0, 0, 'id as biz_id,biz_name as name'); + $user = $this->userM->get(['id' => $id]); + if ($user['biz_id']) { + $ids = $user['biz_id']; + $selectedBrands = $this->biz_model->select(["id in ($ids)" => null, 'status' => 1], '', 0, 0, 'id as biz_id,biz_name as name'); } } else if ($row['biz_id']) { $re_biz = $this->biz_model->get(["id" => $row['biz_id'], 'status' => 1], 'id ,biz_name'); @@ -138,15 +133,11 @@ class Member extends HD_Controller } # group_id1 if ($row['group_id1'] == 4) { - $this->load->model('app/licheb/App_licheb_channel_biz1_model', 'mdChannelBiz1'); - $res_biz = $this->mdChannelBiz1->select(['uid' => $id], 'id desc', 0, 0, 'biz_id'); - $res_biz && $biz_id_arr = array_unique(array_column($res_biz, 'biz_id')); - if ($res_biz) { - $biz_id_arr = array_unique(array_column($res_biz, 'biz_id')); - $ids = implode(',', $biz_id_arr); - $typeAry = $this->biz_model->type_ary(); - $type_ids = implode(',', array_keys($typeAry)); - $selectedBrands1 = $this->biz_model->select(["id in ($ids)" => null, "type in ($type_ids)" => null, 'status' => 1], '', 0, 0, 'id as biz_id,biz_name as name'); + + $user = $this->userM->get(['id' => $id]); + if ($user['biz_id1']) { + $ids = $user['biz_id1']; + $selectedBrands1 = $this->biz_model->select(["id in ($ids)" => null, 'status' => 1], '', 0, 0, 'id as biz_id,biz_name as name'); } } else if ($row['biz_id1']) { $re_biz = $this->biz_model->get(["id" => $row['biz_id1'], 'status' => 1], 'id ,biz_name'); diff --git a/api/controllers/wxapp/licheb/Statistics.php b/api/controllers/wxapp/licheb/Statistics.php index 96253d74..21c1f2cb 100644 --- a/api/controllers/wxapp/licheb/Statistics.php +++ b/api/controllers/wxapp/licheb/Statistics.php @@ -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) {