diff --git a/api/controllers/plan/Licheb.php b/api/controllers/plan/Licheb.php index 6f466ba9..053c7044 100644 --- a/api/controllers/plan/Licheb.php +++ b/api/controllers/plan/Licheb.php @@ -236,18 +236,18 @@ class Licheb extends HD_Controller $city_id = intval($map_biz[$biz_id]['city_id']); $type = intval($map_biz[$biz_id]['type']); $c_num = $this->mdCustomerOpLogs->count(['uid' => $sale_id, 'type' => 4, 'log' => '客户到店', 'c_time>=' => $s_time, 'c_time<=' => $e_time, - "customer_id in(select id from lc_receiver_customers where admin_id={$sale_id} and biz_id={$biz_id})" => null], 'distinct(customer_id)'); + "customer_id in(select id from lc_receiver_customers where admin_id={$sale_id} and biz_id={$biz_id} and cs_biz_id!=-1)" => null], 'distinct(customer_id)'); $a_num = $this->mdCustomerOpLogs->count(['uid' => $sale_id, 'type' => 4, 'c_time>=' => $s_time, 'c_time<=' => $e_time, - "customer_id in(select id from lc_receiver_customers where admin_id={$sale_id} and biz_id={$biz_id})" => null] + "customer_id in(select id from lc_receiver_customers where admin_id={$sale_id} and biz_id={$biz_id} and cs_biz_id!=-1)" => null] ); $t_num = $this->mdCustomerOpLogs->count(['uid' => $sale_id, 'type' => 5, 'c_time>=' => $s_time, 'c_time<=' => $e_time, - "customer_id in(select id from lc_receiver_customers where admin_id={$sale_id} and biz_id={$biz_id})" => null] + "customer_id in(select id from lc_receiver_customers where admin_id={$sale_id} and biz_id={$biz_id} and cs_biz_id!=-1)" => null] ); $follows = $this->mdCustomerOpLogs->count(['uid' => $sale_id, 'type in(0,1,2)' => null, 'c_time>=' => $s_time, 'c_time<=' => $e_time, - "customer_id in(select id from lc_receiver_customers where admin_id={$sale_id} and biz_id={$biz_id})" => null], 'distinct(customer_id)' + "customer_id in(select id from lc_receiver_customers where admin_id={$sale_id} and biz_id={$biz_id} and cs_biz_id!=-1)" => null], 'distinct(customer_id)' ); $defeats = $this->mdCustomerOpLogs->count(['uid' => $sale_id, 'type' => 7, 'c_time>=' => $s_time, 'c_time<=' => $e_time, - "customer_id in(select id from lc_receiver_customers where admin_id={$sale_id} and biz_id={$biz_id})" => null] + "customer_id in(select id from lc_receiver_customers where admin_id={$sale_id} and biz_id={$biz_id} and cs_biz_id!=-1)" => null] ); $orders = $this->mdOrdersV2->count(['sale_id' => $sale_id, 'biz_id' => $biz_id, 'status>=' => 0, 'order_time>=' => "{$log_date} 00:00:00", 'order_time<=' => "{$log_date} 23:59:59"] @@ -266,12 +266,16 @@ class Licheb extends HD_Controller $qy_dels = $this->mdWechatqyLog->count(array_merge($qy_where, ["change_type in('del_external_contact','del_follow_user')" => null])); } } + //改派数 + $reassigns = $this->mdCustomers->count(['admin_id' => $sale_id, 'cs_biz_id' => -1, 'status>=' => 0, 'c_time>=' => $s_time, 'c_time<=' => $e_time]); + //接收数 + $receives = $this->mdCustomers->count(['admin_id' => $sale_id, 'cs_biz_id>' => 0, 'status>=' => 0, 'c_time>=' => $s_time, 'c_time<=' => $e_time]); $add_item = ['sale_id' => $sale_id, 'biz_id' => $biz_id, 'type' => $type, 'city_id' => $city_id, 'c_num' => $c_num , 'a_num' => $a_num, 't_num' => $t_num, 'orders' => $orders, 'bills' => $bills, 'follows' => $follows, 'defeats' => $defeats - , 'log_date' => $log_date, 'qy_adds' => $qy_adds, 'qy_dels' => $qy_dels, 'c_time' => time()]; + , 'log_date' => $log_date, 'qy_adds' => $qy_adds, 'qy_dels' => $qy_dels, 'reassigns' => $reassigns, 'receives' => $receives, 'c_time' => time()]; $customer_json = ''; foreach ($offlineSources as $key1 => $value1) { - $customer_num1 = $this->mdCustomers->count(['of_id' => $key1, 'admin_id' => $sale_id + $customer_num1 = $this->mdCustomers->count(['of_id' => $key1, 'admin_id' => $sale_id, 'cs_biz_id<>' => -1 , 'status>=' => 0, 'c_time>=' => $s_time, 'c_time<=' => $e_time]); if ($customer_num1) {//一级 $customers += $customer_num1; @@ -279,7 +283,7 @@ class Licheb extends HD_Controller $list = ''; foreach ($value1['list'] as $key2 => $value2) { $customer_num2 = $this->mdCustomers->count(['of_id' => $key1, 'of2_id' => $key2, 'admin_id' => $sale_id - , 'status>=' => 0, 'c_time>=' => $s_time, 'c_time<=' => $e_time]); + , 'status>=' => 0, 'c_time>=' => $s_time, 'c_time<=' => $e_time, 'cs_biz_id<>' => -1]); if ($customer_num2) {//二级 $list[$key2] = ['name' => $value2, 'num' => $customer_num2]; } diff --git a/api/controllers/wxapp/app/City.php b/api/controllers/wxapp/app/City.php index 58760847..b89aa294 100644 --- a/api/controllers/wxapp/app/City.php +++ b/api/controllers/wxapp/app/City.php @@ -6,22 +6,26 @@ defined('WXAPP_APP') OR exit('No direct script access allowed'); * Desc: 城市 * Date: 2021/07/27 * Time: 10:22 - */ + */ require_once APPPATH . 'controllers/wxapp/Wxapp.php'; -class City extends Wxapp{ - function __construct($inputs, $app_key){ + +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->check_headimg = array();//授权微信信息 $this->load->model("sys/sys_city_model"); $this->load->model("sys/sys_area_model"); $this->load->model("biz/biz_model"); } - protected function get(){ + protected function get() + { $page = $this->input_param('page'); $size = $this->input_param('size'); !$page && $page = 1; @@ -31,27 +35,27 @@ class City extends Wxapp{ $where = [ 'status' => 1 ]; - if($this->app_id==2 && $this->session['group_id']==4){ - $biz_id_arr = explode(',',$this->session['biz_id']); + 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,'type<>'=>4]; - if($this->session['biz_id'] && $biz_id_arr){ - $biz_ids = implode(',',$biz_id_arr); - $biz_where["id in ({$biz_ids})"] = null; + $biz_where = ['city_id>' => 0, 'status' => 1, 'type<>' => 4]; + 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')); + $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($default_city,$city_id_arr) ? $default_city : $city_id_arr[0]; - foreach($rows as $key=>$val){ + 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($default_city, $city_id_arr) ? $default_city : $city_id_arr[0]; + foreach ($rows as $key => $val) { $lists = $val; - } + } $lists = $rows; } $data = [ @@ -61,16 +65,64 @@ class City extends Wxapp{ ]; return $data; } + //上牌城市 - public function get_oncard(){ + public function get_oncard() + { $where = [ 'province_id' => 350, 'status' => 1 ]; - $lists = $this->sys_area_model->select_groupby('city_id',$where,'','','','city_id,city_name as name'); + $lists = $this->sys_area_model->select_groupby('city_id', $where, '', '', '', 'city_id,city_name as name'); $data = [ 'list' => $lists, ]; return $data; } -} + + /** + * Notes:获取省/市/区/街道 + * Created on: 2022/7/1 11:17 + * Created by: dengbw + * @return mixed + */ + public function get_area() + { + $this->load->model('area_model', 'mdArea'); + $type = $this->input->get('type'); + $pid = intval($this->input->get('pid')); + $lists = []; + switch ($type) { + case 'city': + !$pid && $pid = 350;//默认福建 + $res = $this->mdArea->select(['province_id' => $pid], null, null, null, 'distinct(city_id), city_name'); + foreach ($res as $v) { + $lists[] = ['id' => $v['city_id'], 'name' => $v['city_name']]; + } + break; + case 'county': + $res = $this->mdArea->select(['city_id' => $pid], null, null, null, 'distinct(county_id), county_name'); + foreach ($res as $v) { + $lists[] = ['id' => $v['county_id'], 'name' => $v['county_name']]; + } + break; + case 'street': + $this->load->model('sys/sys_street_model', 'mdStreet'); + $res = $this->mdStreet->select(['county_id' => $pid], 'id ASC', 0, 0, 'street_id,street_name'); + foreach ($res as $v) { + $lists[] = ['id' => $v['street_id'], 'name' => $v['street_name']]; + } + break; + default: + $res = $this->mdArea->select(null, null, null, null, 'distinct(province_id), province_name'); + foreach ($res as $v) { + $lists[] = ['id' => $v['province_id'], 'name' => $v['province_name']]; + } + break; + } + $data = [ + 'list' => $lists, + ]; + return $data; + } +} \ No newline at end of file diff --git a/api/controllers/wxapp/licheb/Customers.php b/api/controllers/wxapp/licheb/Customers.php index 1114ab42..1ad377b9 100644 --- a/api/controllers/wxapp/licheb/Customers.php +++ b/api/controllers/wxapp/licheb/Customers.php @@ -107,10 +107,17 @@ class Customers extends Wxapp { $id = intval($this->input_param('id')); $type = $this->input_param('type'); - $tags = $res_td = []; - if ($this->get_biz('type') == 5) {//异业店 - if ($type == 'detail') {//详情显示标签 - $re_cus = $this->customers_model->get(['id' => $id]); + $tags = $res_td = $re_cus = []; + $re_biz = $this->get_biz(); + $city_id = intval($re_biz['city_id']); + $county_id = intval($re_biz['county_id']); + if ($id) { + $re_cus = $this->customers_model->get(['id' => $id]); + $re_cus['city_id'] && $city_id = $re_cus['city_id']; + $re_cus['county_id'] && $county_id = $re_cus['county_id']; + } + if ($re_biz['type'] == 5) {//异业店 + if ($type == 'detail' && $re_cus) {//详情显示标签 if ($re_cus['cf_clues'] != '异业店') { $this->customers_model->update(['cf_clues' => '异业店'], ['id' => $re_cus['id']]); } @@ -144,7 +151,7 @@ class Customers extends Wxapp } } } - return ['tags' => $tags]; + return ['tags' => $tags, 'city_id' => $city_id, 'county_id' => $county_id]; } //修改基本信息 @@ -158,6 +165,8 @@ class Customers extends Wxapp $of2_id = $this->input_param('of2_id'); //线下来源一级 $buy_time = $this->input_param('buy_time'); //预计购车时间 $tag = $this->input_param('tag'); //客户标签 + $city_id = $this->input_param('city_id'); //城市id + $county_id = $this->input_param('county_id'); //区id $row = $this->customers_model->get(['id' => $id]); if (!$row) { throw new Exception('参数错误', ERR_PARAMS_ERROR); @@ -177,6 +186,8 @@ class Customers extends Wxapp $name && $update['name'] = $name; $of_id && $update['of_id'] = $of_id; $of2_id && $update['of2_id'] = $of2_id; + $city_id && $update['city_id'] = $city_id; + $county_id && $update['county_id'] = $county_id; if ($buy_time) { $this->load->library('receiver/customers_entity'); $update['level'] = $this->customers_entity->cal_level($buy_time); @@ -222,7 +233,12 @@ class Customers extends Wxapp $of2_id = $this->input_param('of2_id'); //线下来源一级 $status = intval($this->input_param('status')); //状态 $tag = $this->input_param('tag'); //客户标签 + $city_id = intval($this->input_param('city_id')); //城市id + $county_id = intval($this->input_param('county_id')); //区id if (!mobile_valid($mobile)) throw new Exception('请输入正确的手机号码', ERR_PARAMS_ERROR); + if (!$city_id || !$county_id) { + throw new Exception('请选择城市与行政区', API_CODE_FAIL); + } if ($this->customers_model->count(['biz_id' => $this->biz_id, 'mobile' => $mobile])) { throw new Exception('客户已存在', API_CODE_FAIL); } @@ -239,6 +255,8 @@ class Customers extends Wxapp 'cf_title' => '自有资源', 'cont_time' => $time, 'status' => $status, + 'city_id' => $city_id, + 'county_id' => $county_id, 'c_time' => time() ]; if ($biz_row['type'] == 5) {//异业店 @@ -430,6 +448,8 @@ class Customers extends Wxapp $where_vis = ['c_id' => $id, 'biz_id' => $biz_id, 'sales_id' => $sales_id, 't_day' => $visit_time]; $re_vis = $this->mdCustomerVisitData->get($where_vis); if (!$re_vis) { + //删除大于今天的回访记录 + $this->mdCustomerVisitData->delete(['c_id' => $id, 'biz_id' => $biz_id, 'sales_id' => $sales_id, 't_day>' => $visit_time]); $where_vis['level'] = $level; $where_vis['c_time'] = time(); $this->mdCustomerVisitData->add($where_vis); @@ -560,6 +580,7 @@ class Customers extends Wxapp } $where = [ 'biz_id' => $this->biz_id, + 'cs_biz_id<>' => -1, 'status>=' => 0 ]; if ($of_id) { @@ -612,7 +633,7 @@ class Customers extends Wxapp $lists = []; if ($count) { $fileds = 'id,name,admin_id,mobile,level,car_json,is_top,cf_title,brand_id,s_id,cont_time,c_time,if_defeat - ,of_id,of2_id,wxqy,status,biz_id'; + ,of_id,of2_id,wxqy,status,biz_id,cs_biz_id'; $rows = $this->customers_model->select($where, $orderby, $page, $size, $fileds); //获取管理员 $admin_arr = array_unique(array_column($rows, 'admin_id')); @@ -668,6 +689,7 @@ class Customers extends Wxapp 'allot' => $allot, 'tip' => $tip, 'level' => $val['level'], + 'reassign' => $val['cs_biz_id'] > 0 ? '他店改派' : '', ]; } } @@ -686,18 +708,77 @@ class Customers extends Wxapp $id_arr = $this->input_param('ids'); $admin_id = $this->input_param('admin_id'); $visit_time = $this->input_param('visit_time'); + $biz_id = intval($this->input_param('biz_id')); $allot = $this->get_allot(); if ($allot == 0) { throw new Hd_exception('无权限分配', API_CODE_INVILD_PARAM); } + if (!$id_arr) { + throw new Hd_exception('参数错误', API_CODE_INVILD_PARAM); + } + $this->load->library('receiver/customers_entity'); + if ($biz_id) {//改派 + $nums = count($id_arr); + foreach ($id_arr as $val) { + $id = $val; + $re = $this->customers_model->get(['id' => $id]); + if ($re['biz_id'] == $biz_id) {//同个门店跳出循环 + if ($nums == 1) { + throw new Hd_exception('不能分配给相同门店', API_CODE_INVILD_PARAM); + } + continue; + } + $re2 = $this->customers_model->get(['biz_id' => $biz_id, 'mobile' => $re['mobile']]); + if ($re2) {//客户已存在门店里 + if ($nums == 1) { + throw new Hd_exception('客户已在此门店', API_CODE_INVILD_PARAM); + } + continue; + } + $addData = ['rid' => $re['rid'], 'name' => $re['name'], 'mobile' => $re['mobile'], 'biz_id' => $biz_id + , 'cs_biz_id' => $re['biz_id'], 'level' => $re['level'], 'cf_title' => $re['cf_title'], 'cf_id' => $re['cf_id'] + , 'of_id' => $re['of_id'], 'of2_id' => $re['of2_id'], 'status' => 1, 'c_time' => time(), 'city_id' => $re['city_id'] + , 'county_id' => $re['county_id']]; + $re['jsondata'] && $addData['jsondata'] = $re['jsondata']; + $customer_id = $this->customers_model->add($addData); + if ($customer_id) { + //初始门店更改-1,狸车宝过滤 + $this->customers_model->update(['cs_biz_id' => -1], ["id" => $id]); + //删除未回访计划 + $this->mdCustomerVisitData->delete(['c_id' => $id, 'biz_id' => $re['biz_id'], 'status<>' => 2, 't_day >=' => date('Y-m-d')]); + //同步客户标签 + $res_tag = $this->mdCustomerTagdata->select(['c_id' => $id], 'id asc', 0, 0, 't_id,c_time'); + if ($res_tag) { + $add_tag = []; + foreach ($res_tag as $val2) { + $val2['c_id'] = $customer_id; + $add_tag[] = $val2; + } + $this->mdCustomerTagdata->add_batch($add_tag); + } + //同步跟进记录 + $res_oplogs = $this->customer_oplogs_model->select(['customer_id' => $id], 'id asc', 0, 0 + , 'uid,uname,type,log,imgs,cf_platform,c_time'); + if ($res_oplogs) { + $add_oplogs = []; + foreach ($res_oplogs as $val3) { + $val3['customer_id'] = $customer_id; + $add_oplogs[] = $val3; + } + $this->customer_oplogs_model->add_batch($add_oplogs); + } + $this->customers_entity->add_log($customer_id, $uid, $uname, "客户改派"); + } + } + throw new Exception('分配成功', API_CODE_SUCCESS); + } if (!$visit_time) { throw new Hd_exception('请选择回访时间', API_CODE_INVILD_PARAM); } $admin = $this->app_user_model->get(['id' => $admin_id, 'status' => 1]); - if (!$id_arr || !$admin) { + if (!$admin) { throw new Hd_exception('参数错误', API_CODE_INVILD_PARAM); } - $this->load->library('receiver/customers_entity'); foreach ($id_arr as $val) { $id = $val; $re = $this->customers_model->get(['id' => $id]); @@ -764,7 +845,7 @@ class Customers extends Wxapp !$page && $page = 1; !$size && $size = 10; $t_day = date('Y-m-d'); - $where = array('a.biz_id' => $this->biz_id, 'a.status in(0,1)' => null, 'b.t_day' => $t_day); + $where = array('a.biz_id' => $this->biz_id, 'a.cs_biz_id<>' => -1, 'a.status in(0,1)' => null, 'b.t_day' => $t_day); $params['level'] && $where['a.level'] = $params['level'];//等级 if ($status == 2) {//已跟进 $where['b.status'] = 2; @@ -850,7 +931,7 @@ class Customers extends Wxapp $size = $params['size']; !$page && $page = 1; !$size && $size = 10; - $where = array('biz_id' => $this->biz_id, 'if_defeat' => 1, 'status>' => -1); + $where = array('biz_id' => $this->biz_id, 'cs_biz_id<>' => 1, 'if_defeat' => 1, 'status>' => -1); $count = $this->customers_model->count($where); $lists = []; if ($count) { diff --git a/api/controllers/wxapp/licheb/Employees.php b/api/controllers/wxapp/licheb/Employees.php index e72e2dad..3eee2462 100644 --- a/api/controllers/wxapp/licheb/Employees.php +++ b/api/controllers/wxapp/licheb/Employees.php @@ -48,9 +48,18 @@ class Employees extends Wxapp{ $rows = $this->app_user_model->select($where,'id desc',$page,$size,$fileds); $lists = $rows; } + $this->load->model("biz/biz_model"); + $tabs = $bizs = []; + $re_biz = $this->biz_model->get(['id' => $biz_id, 'status' => 1]); + if ($re_biz['type'] == 1) {//品牌店 + $tabs = [['id' => 1, 'name' => '本店'], ['id' => 2, 'name' => '其它门店']]; + $bizs = $this->biz_model->select(['type' => 1, 'status' => 1], 'id desc', 0, 0, 'id, biz_name as name'); + } $data = [ 'list' => $lists, - 'total' => $count + 'total' => $count, + 'tabs' => $tabs, + 'bizs' => $bizs, ]; return $data; } diff --git a/api/controllers/wxapp/licheb/User.php b/api/controllers/wxapp/licheb/User.php index 85a2802f..1c8745e8 100644 --- a/api/controllers/wxapp/licheb/User.php +++ b/api/controllers/wxapp/licheb/User.php @@ -226,25 +226,15 @@ class User extends Wxapp $this->load->model('receiver/order/receiver_orders_v2_model'); $this->load->model('receiver/order/receiver_order_signs_model', 'order_signs_model'); $this->load->model('receiver/receiver_customers_visit_data_model', 'mdCustomerVisitData'); - $where = [ - 'status>' => -1, - 'is_top' => 1, - 'biz_id' => $biz_id - ]; + $where = ['status>' => -1, 'is_top' => 1, 'biz_id' => $biz_id, 'cs_biz_id<>' => -1]; $group_id == 1 && $where['admin_id'] = $uid; $group_id == 4 && $where['brand_id!='] = 3; //渠道经理过滤 $gz_count = $this->customers_model->count($where); - $where = [ - 'status' => 0, - 'biz_id' => $biz_id - ]; + $where = ['status' => 0, 'biz_id' => $biz_id]; $group_id == 1 && $where['admin_id'] = $uid; $group_id == 4 && $where['brand_id!='] = 3; //渠道经理过滤 $sign_count = $this->orders_model->count($where); - $where = [ - 'status' => 1, - 'biz_id' => $biz_id - ]; + $where = ['status' => 1, 'biz_id' => $biz_id]; $group_id == 1 && $where['admin_id'] = $uid; $group_id == 4 && $where['brand_id!='] = 3; //渠道经理过滤 $loan_count = $this->orders_model->count($where); @@ -254,56 +244,42 @@ class User extends Wxapp $customer_op_list = []; } else { //未派单客户 - $where = ['admin_id' => 0, 'biz_id' => $biz_id, 'status>=' => 0]; + $where = ['admin_id' => 0, 'biz_id' => $biz_id, 'cs_biz_id<>' => -1, 'status>=' => 0]; if ($group_id == 4 && $biz_id != 1) { $where['brand_id!='] = 3; //渠道经理过滤 } $unuse_count = $this->customers_model->count($where); - $defeat_count = $this->customers_model->count(array('biz_id' => $biz_id, 'if_defeat' => 1, 'status>' => -1)); + $defeat_count = $this->customers_model->count(['biz_id' => $biz_id, 'cs_biz_id<>' => -1, 'if_defeat' => 1, 'status>' => -1]); $customer_op_list = [ ['title' => '待分配客户(人)', 'icon' => 'icon-daifenpei', 'total' => $unuse_count, 'page' => '/pages/customer/allot/index'], ['title' => '战败申请(人)', 'icon' => 'icon-statistics-custom-5', 'total' => $defeat_count, 'page' => '/pages/customer/optDefeat/index'], ]; } - $where = [ - 'status>=' => 0, - 'payway' => 0, - 'id>=' => Orders_v2_entity::V2_START_ID, - 'brand_id>' => 0, - 'id not in (select o_id from lc_receiver_order_status where pid_status=1 and status=2)' => null, - 'biz_id' => $biz_id - ]; + $where = ['status>=' => 0, 'payway' => 0, 'id>=' => Orders_v2_entity::V2_START_ID, + 'brand_id>' => 0, 'biz_id' => $biz_id, + 'id not in (select o_id from lc_receiver_order_status where pid_status=1 and status=2)' => null]; $group_id == 1 && $where['sale_id'] = $uid; $group_id == 4 && $where['brand_id!='] = 3; //渠道经理过滤 $fq_total = $this->receiver_orders_v2_model->count($where); - $where = [ - 'status>=' => 0, - 'id>=' => Orders_v2_entity::V2_START_ID, - 'brand_id>' => 0, - 'id not in (select o_id from lc_receiver_order_status where pid_status=2 and status=1)' => null, - 'biz_id' => $biz_id - ]; + $where = ['status>=' => 0, 'id>=' => Orders_v2_entity::V2_START_ID, + 'brand_id>' => 0, 'biz_id' => $biz_id, + 'id not in (select o_id from lc_receiver_order_status where pid_status=2 and status=1)' => null]; $group_id == 1 && $where['sale_id'] = $uid; $group_id == 4 && $where['brand_id!='] = 3; //渠道经理过滤 $pc_total = $this->receiver_orders_v2_model->count($where); $where = [ - 'status>=' => 0, - 'id>=' => Orders_v2_entity::V2_START_ID, - 'brand_id>' => 0, + 'status>=' => 0, 'id>=' => Orders_v2_entity::V2_START_ID, + 'brand_id>' => 0, 'biz_id' => $biz_id, 'id not in (select o_id from lc_receiver_order_status where pid_status=3 and status=1)' => null, - 'id in (select o_id from lc_receiver_order_status where pid_status=0 and status=2)' => null, - 'biz_id' => $biz_id - ]; + 'id in (select o_id from lc_receiver_order_status where pid_status=0 and status=2)' => null]; $group_id == 1 && $where['sale_id'] = $uid; $group_id == 4 && $where['brand_id!='] = 3; //渠道经理过滤 $kp_total = $this->receiver_orders_v2_model->count($where); $where = [ - 'status>=' => 0, - 'id>=' => Orders_v2_entity::V2_START_ID, - 'brand_id>' => 0, + 'status>=' => 0, 'id>=' => Orders_v2_entity::V2_START_ID, + 'brand_id>' => 0, 'biz_id' => $biz_id, 'id in (select o_id from lc_receiver_order_status where pid_status=3 and status=1)' => null, - 'id not in (select o_id from lc_receiver_order_status where pid_status=4 and status=2)' => null, - 'biz_id' => $biz_id + 'id not in (select o_id from lc_receiver_order_status where pid_status=4 and status=2)' => null ]; $group_id == 1 && $where['sale_id'] = $uid; $group_id == 4 && $where['brand_id!='] = 3; //渠道经理过滤 @@ -314,8 +290,8 @@ class User extends Wxapp ['title' => '发票开具', 'icon' => 'icon-kaipiao1', 'total' => $kp_total, 'page' => '/pages/order/filterList/index2?type=kp&title=发票开具'], ['title' => '交付确认', 'icon' => 'icon-jiaofu', 'total' => $ck_total, 'page' => '/pages/order/filterList/index2?type=jf&title=交付确认'], ]; - $where_v = ['a.biz_id' => $biz_id, 'a.status in(0,1)' => null, 'b.t_day' => date('Y-m-d')]; - $where_c = ['biz_id' => $biz_id, 'status in(0,1)' => null]; + $where_v = ['a.biz_id' => $biz_id, 'a.cs_biz_id<>' => -1, 'a.status in(0,1)' => null, 'b.t_day' => date('Y-m-d')]; + $where_c = ['biz_id' => $biz_id, 'cs_biz_id<>' => -1, 'status in(0,1)' => null]; $group_id == 4 && $where_c['brand_id!='] = 3; if ($group_id == 1) { $where_v['b.sales_id'] = $uid; @@ -476,9 +452,17 @@ class User extends Wxapp $rows = $this->app_user_model->select($where, 'id desc', $page, $size, 'id,uname'); $lists = $rows; } + $tabs = $bizs = []; + $re_biz = $this->biz_model->get(['id' => $biz_id, 'status' => 1]); + if ($re_biz['type'] == 1) {//品牌店 + $tabs = [['id' => 1, 'name' => '本店'], ['id' => 2, 'name' => '其它门店']]; + $bizs = $this->biz_model->select(['type' => 1, 'status' => 1], 'id desc', 0, 0, 'id, biz_name as name'); + } $data = [ 'list' => $lists, - 'total' => $count + 'total' => $count, + 'tabs' => $tabs, + 'bizs' => $bizs, ]; return $data; }