From 8a77a1527073aa587cedd29e8ef707800f073396 Mon Sep 17 00:00:00 2001 From: dengbw Date: Tue, 8 Mar 2022 11:15:49 +0800 Subject: [PATCH] admin_transfer_308 --- api/controllers/wxapp/licheb/Customers.php | 16 +++ api/controllers/wxapp/licheb/Goods.php | 11 ++- api/controllers/wxapp/licheb/Inventory.php | 9 +- api/controllers/wxapp/licheb/Transfer.php | 97 +++++++++++++++---- common/models/items/Items_inventory_model.php | 17 ++++ .../receiver/Receiver_customers_model.php | 34 ++++++- 6 files changed, 157 insertions(+), 27 deletions(-) diff --git a/api/controllers/wxapp/licheb/Customers.php b/api/controllers/wxapp/licheb/Customers.php index 12cb8bfd..2a5160b0 100644 --- a/api/controllers/wxapp/licheb/Customers.php +++ b/api/controllers/wxapp/licheb/Customers.php @@ -356,6 +356,22 @@ class Customers extends Wxapp return $data; } + /** + * Notes:线下来源 + * Created on: 2022/3/7 10:01 + * Created by: dengbw + * @return mixed + */ + protected function get_offline_sources() + { + $status = $this->input_param('status'); + $offline_sources = $this->customers_model->offlineSources(); + if (strlen($status) && $status == 0) {//未见客户 + unset($offline_sources[1]); + } + return $offline_sources; + } + //获取客户列表 private function lists() { diff --git a/api/controllers/wxapp/licheb/Goods.php b/api/controllers/wxapp/licheb/Goods.php index d004a58a..0719729a 100644 --- a/api/controllers/wxapp/licheb/Goods.php +++ b/api/controllers/wxapp/licheb/Goods.php @@ -35,6 +35,13 @@ class Goods extends Wxapp */ protected function get_remind() { + $type = intval($this->input_param('type')); + if ($type == 1) { + $this->load->model('items/Items_inventory_model', 'mdInventory'); + if (!$this->mdInventory->addrManage($this->myuid)) {//非指定信息员管理地址不显示库存 + return ['show' => 0, 'inventory' => '']; + } + } $where = ['status<>' => 0, 'biz_id' => $this->biz_id, 'bill_time' => '0000-00-00 00:00:00']; $res = $this->mdItems->select($where, 'id DESC', 0, 0, 'id,in_time,biz_id'); $total = count($res); @@ -57,10 +64,10 @@ class Goods extends Wxapp $list && $warning = ['title' => '库存超期预警', 'note' => '库存天数已超过20天,请尽快销售,以免造成损失!', 'list' => $list]; } if ($warning) {//库存预警 - $date = ['total' =>2,'inventory' => ['title' => "库存车辆({$total})", 'value' => '库存超期' + $date = ['show' => 1, 'inventory' => ['title' => "库存车辆({$total})", 'value' => '库存超期' , 'color1' => '#fe606c', 'color2' => '#ff9026'], 'warning' => $warning]; } else { - $date = ['inventory' => ['title' => "库存车辆({$total})", 'value' => '库存良好' + $date = ['show' => 1, 'inventory' => ['title' => "库存车辆({$total})", 'value' => '库存良好' , 'color1' => '#30cfbd', 'color2' => '#2cbf8b'], 'warning' => $warning]; } return $date; diff --git a/api/controllers/wxapp/licheb/Inventory.php b/api/controllers/wxapp/licheb/Inventory.php index 00d649ee..b8a00632 100644 --- a/api/controllers/wxapp/licheb/Inventory.php +++ b/api/controllers/wxapp/licheb/Inventory.php @@ -11,7 +11,6 @@ require_once APPPATH . 'controllers/wxapp/Wxapp.php'; class Inventory extends Wxapp { private $biz_id;//门店id - private $addrManage = [491 => '129', 492 => '130'];//信息员管理地址 function __construct($inputs, $app_key) { @@ -46,8 +45,8 @@ class Inventory extends Wxapp protected function get_remind() { $total = 0; - if ($this->addrManage[$this->myuid]) {//信息员管理 - $where = ['biz_id' => -1, "addr_id in({$this->addrManage[$this->myuid]})" => null, 'status' => 0]; + if ($this->mdInventory->addrManage($this->myuid)) {//信息员管理 + $where = ['biz_id' => -1, "addr_id in({$this->mdInventory->addrManage($this->myuid)})" => null, 'status' => 0]; $total = $this->mdInventoryLog->count($where); } else if ($this->biz_id) {//门店 $where = ['biz_id' => $this->biz_id, 'status' => 0]; @@ -66,8 +65,8 @@ class Inventory extends Wxapp !$size && $size = 5; $where = ['id' => 0]; $tabs_id = intval($this->input_param('tabs_id')); - if ($this->addrManage[$this->myuid]) {//信息员管理 - $where = ['biz_id' => -1, "addr_id in({$this->addrManage[$this->myuid]})" => null]; + if ($this->mdInventory->addrManage($this->myuid)) {//信息员管理 + $where = ['biz_id' => -1, "addr_id in({$this->mdInventory->addrManage($this->myuid)})" => null]; $where['status'] = $tabs_id == 2 ? 1 : 0; } elseif ($this->biz_id) {//门店 $where = ['biz_id' => $this->biz_id]; diff --git a/api/controllers/wxapp/licheb/Transfer.php b/api/controllers/wxapp/licheb/Transfer.php index 9d73661f..c70cc91b 100644 --- a/api/controllers/wxapp/licheb/Transfer.php +++ b/api/controllers/wxapp/licheb/Transfer.php @@ -60,31 +60,41 @@ class Transfer extends Wxapp $size = $this->input_param('size'); $s_date = $this->input_param('s_date'); $e_date = $this->input_param('e_date'); - $channel = intval($this->input_param('channel'));//1渠道自已提醒操作 - + $tabs_id = intval($this->input_param('tabs_id')); + $city_id = intval($this->input_param('city_id')); !$page && $page = 1; !$size && $size = 5; - if ($this->session['group_id'] == 4 && !$channel) {//渠道经理 - $biz_id = $this->session['new_biz_id'] ? $this->session['new_biz_id'] : intval($this->session['biz_id']); - !$biz_id && $biz_id = -1; - $where = ['status <>' => -1, "biz_id in({$biz_id})" => null]; + $select_type = 0;//查找类型 + $tran_id = 'tran_id'; + $biz_id = $this->session['new_biz_id'] ? $this->session['new_biz_id'] : intval($this->session['biz_id']); + if ($this->session['group_id'] == 4 && $city_id) {//渠道经理 + $select_type = 1; + $tran_id = 'id'; + $biz_id = $this->session['biz_id'] ? $this->session['biz_id'] : 0; + } + if ($select_type) {//渠道经理 + $this->load->model("biz/biz_model"); + $biz_id_arr = explode(',', $this->session['biz_id']); + if ($this->session['biz_id'] && $biz_id_arr) { + $bizs = $this->biz_model->get_by_id_arr($biz_id_arr, ['city_id' => $city_id, 'type<>' => 4], 'id'); + } else { + $bizs = $this->biz_model->select(['status' => 1, 'city_id' => $city_id, 'type<>' => 4], 'id desc', '', '', 'id'); + } + $biz_id_str = $bizs ? implode(',', array_column($bizs, 'id')) : 0; + $where = ['status <>' => -1, "biz_id in({$biz_id_str})" => null]; + $where['status'] = $tabs_id == 2 ? 2 : 1; $s_date && $where['c_time >='] = strtotime($s_date . ' 00:00:00'); $e_date && $where['c_time <='] = strtotime($e_date . ' 23:59:59'); $count = $this->mdTransfer->count($where); } else { $type = intval($this->input_param('type')); - $tabs_id = intval($this->input_param('tabs_id')); $where = ['lc_items_transfer_remind.uid' => $this->myuid, 'lc_items_transfer.status<>' => -1]; if ($type == 1) {//提车人/备用提车人 $where['lc_items_transfer_remind.type in(1,2)'] = null; } else if ($type == 2) {//接车人/备用接车人 $where['lc_items_transfer_remind.type in(3,4)'] = null; } - if ($tabs_id == 2) {//已完成 - $where['lc_items_transfer_remind.status'] = 2; - } else {//进行中 - $where['lc_items_transfer_remind.status'] = 1; - } + $where['lc_items_transfer_remind.status'] = $tabs_id == 2 ? 2 : 1; $s_date && $where['lc_items_transfer_remind.c_time >='] = strtotime($s_date . ' 00:00:00'); $e_date && $where['lc_items_transfer_remind.c_time <='] = strtotime($e_date . ' 23:59:59'); $count = $this->db->select('lc_items_transfer_remind.tran_id') @@ -98,14 +108,16 @@ class Transfer extends Wxapp if ($count) { $offset = ($page - 1) * $size; $limit = $size; - if ($this->session['group_id'] == 4 && !$channel) {//渠道经理 - $res = $this->mdTransfer->select($where, 'id desc', $page, $limit, 'id,item_id,out_uid,in_uid,jsondata,c_time,biz_id'); + if ($select_type) {//渠道经理 + $res = $this->mdTransfer->select($where, 'id desc', $page, $limit, 'id,item_id,out_uid,in_uid,jsondata + ,c_time,biz_id,out_type,in_type,out_time,in_time'); $url = '/pages/allot/detail/index?tran_id='; } else { $this->db->from('lc_items_transfer_remind'); $this->db->join('lc_items_transfer', "lc_items_transfer.id = lc_items_transfer_remind.tran_id", 'left'); - $this->db->select('lc_items_transfer_remind.id,lc_items_transfer.item_id,lc_items_transfer.out_uid,lc_items_transfer.in_uid - ,lc_items_transfer.jsondata,lc_items_transfer.c_time,lc_items_transfer.biz_id,lc_items_transfer.out_type,lc_items_transfer.in_type'); + $this->db->select('lc_items_transfer_remind.id,lc_items_transfer_remind.tran_id,lc_items_transfer.item_id,lc_items_transfer.out_uid,lc_items_transfer.in_uid + ,lc_items_transfer.jsondata,lc_items_transfer.c_time,lc_items_transfer.biz_id,lc_items_transfer.out_type,lc_items_transfer.in_type + ,lc_items_transfer.out_time,lc_items_transfer.in_time'); $this->db->where($where); $this->db->order_by('lc_items_transfer_remind.id Desc'); $this->db->group_by('lc_items_transfer_remind.tran_id'); @@ -139,7 +151,41 @@ class Transfer extends Wxapp $jsondata = $val['jsondata'] ? json_decode($val['jsondata'], true) : []; $item_info = $this->item_info($val['item_id']); $setValue = $other_data = []; - $setValue['biz_name'] = $val['biz_id'] ? $bizs[$val['biz_id']][0]['biz_name'] : ''; + $out_car_title = $in_car_title = '-'; + $out_car_color = $in_car_color = '#1a1a1a';//'#f9394d' + $where_out = $val['out_uid'] ? ['tran_id' => $val[$tran_id], 'uid' => $val['out_uid'], 'type in(1,2)' => null] + : ['tran_id' => $val[$tran_id], 'type' => 1]; + if ($val['out_type'] == 1) {//门店 + $re_rem = $this->mdTransferRemind->get($where_out); + if ($re_rem) { + $re_biz = $this->mdBiz->get(['id' => $re_rem['biz_id']]); + if ($re_biz && $re_biz['biz_name']) { + $out_car_title = $re_biz['biz_name']; + if (strstr($biz_id . ',', $re_rem['biz_id'] . ',')) { + $out_car_color = '#f9394d'; + } + } + } + } else if ($val['out_type'] == 2) {//信息员 + $re_adm = $this->mdTransferAdmin->get($where_out); + if ($re_adm) { + $row_addr = $this->mdAddr->get(array('id' => $re_adm['addr_id'])); + if ($row_addr && $row_addr['title']) { + $out_car_title = $row_addr['title']; + if ($re_adm['uid'] == $this->myuid) { + $out_car_color = '#f9394d'; + } + } + } + } + if ($val['biz_id'] && $bizs[$val['biz_id']][0]['biz_name']) { + $in_car_title = $bizs[$val['biz_id']][0]['biz_name']; + if (strstr($biz_id . ',', $val['biz_id'] . ',')) { + $in_car_color = '#f9394d'; + } + } + $setValue['out_car'] = ['title' => $out_car_title, 'color' => $out_car_color]; + $setValue['in_car'] = ['title' => $in_car_title, 'color' => $in_car_color]; $setValue['c_time'] = '调拨时间:' . date('Y-m-d H:i', $val['c_time']); $out_uid_title = $in_uid_title = '-'; if ($val['out_uid']) { @@ -161,7 +207,13 @@ class Transfer extends Wxapp $other_data[] = ['title' => '车架号', 'value' => $item_info['vin']]; $other_data[] = ['title' => '调拨时间', 'value' => date('Y-m-d', $val['c_time'])]; $other_data[] = ['title' => '提车人', 'value' => $out_uid_title]; + if ($out_uid_title && $val['out_time'] != '0000-00-00 00:00:00') { + $other_data[] = ['title' => '提车时间', 'value' => date('Y-m-d', strtotime($val['out_time']))]; + } $other_data[] = ['title' => '接车人', 'value' => $in_uid_title]; + if ($in_uid_title && $val['in_time'] != '0000-00-00 00:00:00') { + $other_data[] = ['title' => '接车时间', 'value' => date('Y-m-d', strtotime($val['in_time']))]; + } $other_data[] = ['title' => '运输员', 'value' => $jsondata['transport']['name']]; $setValue['other_data'] = $other_data; $setValue['url'] = $url ? $url . $val['id'] : ''; @@ -170,7 +222,8 @@ class Transfer extends Wxapp } $data = [ 'list' => $lists, - 'total' => $count + 'total' => $count, + 'biz_id' => $biz_id, ]; return $data; } @@ -273,8 +326,14 @@ class Transfer extends Wxapp } $other_data[] = ['title' => '提车人', 'value' => $uname1]; $uname2 && $other_data[] = ['title' => '备用提车人', 'value' => $uname2]; + if ($re['out_time'] != '0000-00-00 00:00:00') { + $other_data[] = ['title' => '提车时间', 'value' => date('Y-m-d', strtotime($re['out_time']))]; + } $other_data[] = ['title' => '接车人', 'value' => $uname3]; $uname4 && $other_data[] = ['title' => '备用接车人', 'value' => $uname4]; + if ($re['in_time'] != '0000-00-00 00:00:00') { + $other_data[] = ['title' => '接车时间', 'value' => date('Y-m-d', strtotime($re['in_time']))]; + } if ($re['arti_id']) { $this->load->model('auto/auto_article_model', 'mdArticle'); $res_a = $this->mdArticle->select(["id in ({$re['arti_id']})" => null], 'id desc', 0, 0, 'title'); @@ -316,7 +375,7 @@ class Transfer extends Wxapp throw new Exception('数据不存在', ERR_PARAMS_ERROR); } if ($re_m['status'] != 1) { - throw new Exception('已不能操作', ERR_PARAMS_ERROR); + throw new Exception('已确认,请勿重复操作', ERR_PARAMS_ERROR); } if ($re_m['uid'] != $this->myuid) { throw new Exception('无操作权限', ERR_PARAMS_ERROR); diff --git a/common/models/items/Items_inventory_model.php b/common/models/items/Items_inventory_model.php index 766b3f2a..60335815 100644 --- a/common/models/items/Items_inventory_model.php +++ b/common/models/items/Items_inventory_model.php @@ -15,4 +15,21 @@ class Items_inventory_model extends HD_Model parent::__construct($this->table_name, 'default'); } + /** + * Notes:信息员管理地址 + * Created on: 2022/3/7 11:22 + * Created by: dengbw + * @param int $uid + * @return mixed|string + */ + public function addrManage($uid = 0) + { + $ary = [491 => '129', 492 => '130']; + $key = ''; + if ($uid) { + $key = $ary[$uid] ? $ary[$uid] : ''; + } + return $key; + } + } \ No newline at end of file diff --git a/common/models/receiver/Receiver_customers_model.php b/common/models/receiver/Receiver_customers_model.php index 602f74af..a1815747 100644 --- a/common/models/receiver/Receiver_customers_model.php +++ b/common/models/receiver/Receiver_customers_model.php @@ -15,7 +15,7 @@ class Receiver_customers_model extends HD_Model private $status_arr = [-1 => '删除', 0 => '未见客户', 1 => '到店客户', 2 => '订单客户', 3 => '战败客户']; private $level = ['H', 'A', 'B', 'C', 'D']; private $cfrom_arr = ['自有资源', '平台分配', '素材推广', '私域活动']; - private $cfrom_clues_arr = ['自然进店', '外展', 'DM', '转介绍', '其它','网站','外展外拓','垂直媒体','自媒体']; + private $cfrom_clues_arr = ['自然进店', '外展', 'DM', '转介绍', '其它', '网站', '外展外拓', '垂直媒体', '自媒体']; private $buy_time = [3, 7, 15, 30]; public function __construct() @@ -69,6 +69,38 @@ class Receiver_customers_model extends HD_Model return $result; } + /** + * Notes:线下来源 + * Created on: 2022/3/4 16:54 + * Created by: dengbw + * @param int $id + * @return mixed + */ + public function offlineSources($id = 0) + { +// $arr[1] = ['id' => 1, 'name' => '自然到店', 'list' => []]; +// $arr[2] = ['id' => 2, 'name' => '转介绍', 'list' => [20 => ['id' => 20, 'name' => '其他4S店'], 21 => ['id' => 21, 'name' => '其他二网'] +// , 22 => ['id' => 22, 'name' => '汽车美容'], 23 => ['id' => 23, 'name' => '二手车'], 24 => ['id' => 24, 'name' => '修车厂'] +// , 25 => ['id' => 25, 'name' => '驾校'], 26 => ['id' => 26, 'name' => '老车主']]]; +// $arr[3] = ['id' => 3, 'name' => '网络推广', 'list' => [30 => ['id' => 30, 'name' => '抖音'], 31 => ['id' => 31, 'name' => '区域媒体'] +// , 32 => ['id' => 32, 'name' => '懂车帝'], 33 => ['id' => 33, 'name' => '易车'], 34 => ['id' => 34, 'name' => '汽车之家'] +// , 35 => ['id' => 35, 'name' => '网红']]]; +// $arr[4] = ['id' => 4, 'name' => '外展外拓', 'list' => [40 => ['id' => 40, 'name' => '巡展'], 41 => ['id' => 41, 'name' => '车展'] +// , 42 => ['id' => 42, 'name' => '静展'], 43 => ['id' => 43, 'name' => '大客户']]]; +// $arr[5] = ['id' => 5, 'name' => '自媒体', 'list' => [50 => ['id' => 50, 'name' => '小红书'], 51 => ['id' => 51, 'name' => '咸鱼'] +// , 52 => ['id' => 52, 'name' => '抖音'], 53 => ['id' => 53, 'name' => '狸车']]]; + $arr[1] = ['name' => '自然到店', 'list' => []]; + $arr[2] = ['name' => '转介绍', 'list' => [20 => '其他4S店', 21 => '其他二网', 22 => '汽车美容', 23 => '二手车', 24 => '修车厂', 25 => '驾校', 26 => '老车主']]; + $arr[3] = ['name' => '网络推广', 'list' => [30 => '抖音', 31 => '区域媒体', 32 => '懂车帝', 33 => '易车', 34 => '汽车之家', 35 => '网红']]; + $arr[4] = ['name' => '外展外拓', 'list' => [40 => '巡展', 41 => '车展', 42 => '静展', 43 => '大客户']]; + $arr[5] = ['name' => '自媒体', 'list' => [50 => '小红书', 51 => '咸鱼', 52 => '抖音', 53 => '狸车']]; + if ($id) { + return $arr[$id]; + } else { + return $arr; + } + } + public function count_order($where) { return $this->select_order($where, '', '', '', '', 1);