add-licheb-city-filter

This commit is contained in:
lccsw
2021-09-18 11:54:39 +08:00
parent 199c260bbf
commit bee2a2491c
4 changed files with 93 additions and 11 deletions
+63
View File
@@ -0,0 +1,63 @@
<?php
defined('WXAPP_APP') OR exit('No direct script access allowed');
/**
* Created by vim
* User: lcc
* Desc: 城市
* Date: 2021/07/27
* Time: 10:22
*/
require_once APPPATH . 'controllers/wxapp/Wxapp.php';
class City extends Wxapp{
function __construct($inputs, $app_key){
parent::__construct($inputs, $app_key);
$this->login_white = array('get');//登录白名单
$this->check_status = array();//用户状态校验
$this->check_mobile = array();//需要手机号
$this->check_headimg =array();//授权微信信息
$this->load->model("sys/sys_city_model");
$this->load->model("biz/biz_model");
}
protected function get(){
$page = $this->input_param('page');
$size = $this->input_param('size');
!$page && $page = 1;
!$size && $size = 20;
$default_city = 350200;
$where = [
'status' => 1
];
if($this->app_id==2 && $this->session['group_id']==4){
$biz_id_arr = explode(',',$this->session['biz_id']);
$biz_where = ['city_id>'=>0,'status'=>1];
if($this->session['biz_id'] && $biz_id_arr){
$biz_ids = implode(',',$biz_id_arr);
$biz_where["id in ({$biz_ids})"] = null;
}
$biz_rows = $this->biz_model->select_groupby('city_id',$biz_where,'','','','id,city_id');
$city_ids = implode(',',array_column($biz_rows,'city_id'));
$city_ids && $where["city_id in ($city_ids)"] = null;
}
$count = $this->sys_city_model->count($where);
$lists = [];
if($count){
$rows = $this->sys_city_model->select($where,'id desc',$page,$size,'id,city_id,name');
$city_id_arr = array_column($rows,'city_id');
$default_city = in_array($city_id_arr,$default_city) ? $default_city : $city_id_arr[0];
foreach($rows as $key=>$val){
$lists = $val;
}
$lists = $rows;
}
$data = [
'list' => $lists,
'total' => $count,
'default' => $default_city
];
return $data;
}
}
+19 -4
View File
@@ -24,6 +24,7 @@ class Statistics extends Wxapp{
//统计客户
protected function get_cust(){
$season = $this->input_param('season');
$city_id = $this->input_param('city_id');
//!strlen($season) && $season = ceil((date('n'))/3)-1;//当月是第几季度
//$season_data = $this->season_data($season+1);
//$days = getMonth($season+1);
@@ -45,9 +46,15 @@ class Statistics extends Wxapp{
's_time' => date("Y-{$month}-01 00:00:00"),
'e_time' => date("Y-{$month}-t 23:59:59"),
];
$fileds = 'id,biz_name';
$biz_id_arr = explode(',',$this->session['biz_id']);
if($biz_id_arr){
$bizs_lists = $this->biz_model->get_by_id_arr($biz_id_arr,'id,biz_name',true);
if($this->session['biz_id'] && $biz_id_arr){
$city_id && $o_where = ['city_id'=>$city_id];
$bizs_lists = $this->biz_model->get_by_id_arr($biz_id_arr,$o_where,$fileds);
}else{
$bizs_lists = $this->biz_model->select(['status'=>0,'city_id'=>$city_id],'id desc','','',$fileds);
}
if($bizs_lists){
$bizs = array_column($bizs_lists,'biz_name');
foreach($bizs_lists as $key=>$val){
$count_data = [];
@@ -104,6 +111,7 @@ class Statistics extends Wxapp{
//统计订单
protected function get_orders(){
$season = $this->input_param('season');
$city_id = $this->input_param('city_id');
!strlen($season) && $season = ceil((date('n'))/3)-1;//当月是第几季度
$season_data = $this->season_data($season+1);
$days = getMonth($season+1);
@@ -117,9 +125,15 @@ class Statistics extends Wxapp{
'e_time' => date('Y-m-t 23:59:59',strtotime($val)),
];
}
$fileds = 'id,biz_name';
$biz_id_arr = explode(',',$this->session['biz_id']);
if($biz_id_arr){
$bizs_lists = $this->biz_model->get_by_id_arr($biz_id_arr,'id,biz_name',true);
if($this->session['biz_id'] && $biz_id_arr){
$city_id && $o_where = ['city_id'=>$city_id];
$bizs_lists = $this->biz_model->get_by_id_arr($biz_id_arr,$o_where,$fileds);
}else{
$bizs_lists = $this->biz_model->select(['status'=>0,'city_id'=>$city_id],'id desc','','',$fileds);
}
if($bizs_lists){
$bizs = array_column($bizs_lists,'biz_name');
foreach($bizs_lists as $key=>$val){
$count_data = [];
@@ -140,6 +154,7 @@ class Statistics extends Wxapp{
'smooth' => true
];
}
}
$stat_data = [
'tooltip' => ['trigger' => 'axis'],
+9 -2
View File
@@ -234,11 +234,18 @@ class User extends Wxapp{
* @return array
*/
protected function get_bizs(){
$city_id = $this->input_param('city_id');
$lists = [];
$biz_id_arr = explode(',',$this->session['biz_id']);
if($biz_id_arr){
$bizs = $this->biz_model->get_by_id_arr($biz_id_arr,'id,biz_name,jsondata');
$fileds = 'id,biz_name,jsondata';
if($this->session['biz_id'] && $biz_id_arr){
$city_id && $o_where = ['city_id'=>$city_id];
$bizs = $this->biz_model->get_by_id_arr($biz_id_arr,$o_where,$fileds);
}else{
$bizs = $this->biz_model->select(['status'=>0,'city_id'=>$city_id],'id desc','','',$fileds);
}
if($bizs){
foreach($bizs as $key => $val){
$auto_brands = [];
$jsondata = json_decode($val['jsondata'],true);
+2 -5
View File
@@ -38,10 +38,9 @@ class Biz_model extends HD_Model
* id数组获取门店
* @param array() $ids
* @param string $fileds
* @param boolean $del_test //是否删除测试门店
* @return array()
*/
public function get_by_id_arr($ids_arr,$fileds='id,biz_name',$del_test=false){
public function get_by_id_arr($ids_arr,$o_where,$fileds='id,biz_name'){
$bizs = [];
$ids = implode(',',$ids_arr);
if($ids){
@@ -49,9 +48,7 @@ class Biz_model extends HD_Model
"id in ($ids)" => null,
"status" => 1
];
if($del_test){
$where["id!="] = 1;
}
is_array($o_where) && $where = array_merge($where,$o_where);
$bizs = $this->biz_model->select($where,'',0,0,$fileds);
}
return $bizs;