diff --git a/admin/controllers/receiver/Clues.php b/admin/controllers/receiver/Clues.php index a1c0b0df..1c7cca25 100644 --- a/admin/controllers/receiver/Clues.php +++ b/admin/controllers/receiver/Clues.php @@ -73,7 +73,7 @@ class Clues extends HD_Controller strlen($params['status2']) && $where["status2"] = $params['status2']; $city_id && $where['city_id'] = $city_id; $county_id && $where['county_id'] = $county_id; - if($this->role==37){ //特殊处理,丰田店只能看到丰田保养数据 + if ($this->role == 37) { //特殊处理,丰田店只能看到丰田保养数据 $params['cfrom_id2'] = 37; $where['admin_id'] = $this->uid; } @@ -137,7 +137,7 @@ class Clues extends HD_Controller foreach ($this->clues_model->statusAry() as $key => $value) { $cate = array(); $where = array("status" => $key); - if($this->role == 37){ + if ($this->role == 37) { $where['cf_id'] = 37; $where['admin_id'] = $this->uid; } @@ -613,6 +613,9 @@ class Clues extends HD_Controller 'p_time' => date('Y-m-d H:i:s'), 'c_time' => $clues_row['en_time'] == '0000-00-00 00:00:00' ? $clues_row['c_time'] : strtotime($clues_row['en_time']) ]; + if ($biz['type'] == 5) {//异业店 + $add_data['cf_clues'] = '异业店'; + } if ($jsondata['car']) { isset($jsondata['car']['version']) && $add_data['v_id'] = $jsondata['car']['version']['id']; $add_data['car_json'] = json_encode($jsondata['car'], JSON_UNESCAPED_UNICODE); @@ -843,7 +846,7 @@ class Clues extends HD_Controller 'pid' => 0 ]; $id && $where['pid'] = $id; - if($this->role==37){ + if ($this->role == 37) { !$id && $where['id'] = 36; } $rows = $this->clues_cfrom_model->select($where, 'id desc', '', '', 'id,title'); diff --git a/api/controllers/wxapp/licheb/Customers.php b/api/controllers/wxapp/licheb/Customers.php index 367824c5..1114ab42 100644 --- a/api/controllers/wxapp/licheb/Customers.php +++ b/api/controllers/wxapp/licheb/Customers.php @@ -48,11 +48,11 @@ class Customers extends Wxapp $tags = [$row['level'] . '级用户']; $status_name = $this->customers_model->get_status(); $tip = $status_name[$row['status']] ? $status_name[$row['status']] : ''; - $other_data = [ - '客户等级' => $row['level'], - '客户来源' => $this->get_cfTitle($row), - '建卡时间' => date('Y-m-d', $row['c_time']), - ]; + $other_data = ['客户等级' => $row['level']]; + if ($this->get_biz('type') != 5) { + $other_data['客户来源'] = $this->get_cfTitle($row); + } + $other_data['建卡时间'] = date('Y-m-d', $row['c_time']); $row['cont_time'] != '0000-00-00 00:00:00' && $other_data['最近联系'] = date('Y-m-d', strtotime($row['cont_time'])); if ($this->session['group_id'] == 1) { $where_visit = ['c_id' => $id, 'biz_id' => $this->biz_id, 'sales_id' => $this->session['uid']]; @@ -108,8 +108,7 @@ class Customers extends Wxapp $id = intval($this->input_param('id')); $type = $this->input_param('type'); $tags = $res_td = []; - $re_biz = $this->biz_model->get(['id' => $this->biz_id, 'status' => 1], 'type'); - if ($re_biz['type'] == 5) {//异业店 + if ($this->get_biz('type') == 5) {//异业店 if ($type == 'detail') {//详情显示标签 $re_cus = $this->customers_model->get(['id' => $id]); if ($re_cus['cf_clues'] != '异业店') { @@ -175,37 +174,6 @@ class Customers extends Wxapp $update['mobile'] = $mobile; } } - //$car_id = $this->input_param('car_id'); //品牌车型id - //$v_id = $this->input_param('v_id'); //车型id - //$color_id = $this->input_param('color_id'); //颜色id - //$car_json = json_decode($row['car_json'], true); - //$s_row = $this->auto_series_model->get(['id' => $car_id]); - //$ids_arr = []; - //if ($v_id) { - //$car_json['v_id'] = $v_id; - //$ids_arr[] = $v_id; - //} - //if ($color_id) { - //$car_json['c_id'] = $color_id; - //$ids_arr[] = $color_id; - //} - //$attr_row = $this->auto_attr_model->get_map_by_ids($ids_arr); - //if ($attr_row[$color_id]) { - //$color_row = $attr_row[$color_id][0]; - //$color_row['jsondata'] = json_decode($color_row['jsondata'], true); - //isset($color_row) && $car_json['color'] = $color_row; - //} - //if ($attr_row[$v_id]) { - //$version_row = $attr_row[$v_id][0]; - //$version_row['jsondata'] = json_decode($version_row['jsondata'], true); - //isset($version_row) && $car_json['version'] = $version_row; - //} - //$update['car_json'] = json_encode($car_json, JSON_UNESCAPED_UNICODE); - // $v_id && $update['v_id'] = $v_id; - //if ($s_row) { - //$update['s_id'] = $s_row['id']; - //$update['brand_id'] = $s_row['brand_id']; - //} $name && $update['name'] = $name; $of_id && $update['of_id'] = $of_id; $of2_id && $update['of2_id'] = $of2_id; @@ -247,64 +215,33 @@ class Customers extends Wxapp //创建客户 protected function post() { - $biz_id = $this->biz_id; $name = $this->input_param('name'); $mobile = $this->input_param('mobile'); - //$car_id = $this->input_param('car_id'); //品牌车型id - //$v_id = $this->input_param('v_id'); //车型id - //$color_id = $this->input_param('color_id'); //颜色id - //$back_s_id = $this->input_param('b_s_id'); //备选车型 $buy_time = $this->input_param('buy_time'); //预计购车时间 $of_id = $this->input_param('of_id'); //线下来源一级 $of2_id = $this->input_param('of2_id'); //线下来源一级 $status = intval($this->input_param('status')); //状态 $tag = $this->input_param('tag'); //客户标签 if (!mobile_valid($mobile)) throw new Exception('请输入正确的手机号码', ERR_PARAMS_ERROR); - //if (!$name || !$car_id || !$v_id || !$color_id) { - //throw new Exception('参数错误', ERR_PARAMS_ERROR); - //} - if ($this->customers_model->count(['biz_id' => $biz_id, 'mobile' => $mobile])) { + if ($this->customers_model->count(['biz_id' => $this->biz_id, 'mobile' => $mobile])) { throw new Exception('客户已存在', API_CODE_FAIL); } - $biz_row = $this->biz_model->get(['id' => $biz_id]); - //$row = $this->auto_series_model->get(['id' => $car_id]); - //$where = ["id in ($v_id,$color_id)" => null]; - //$attr_row = $this->auto_attr_model->map('id', '', $where); - //if ($attr_row[$color_id]) { - //$color_row = $attr_row[$color_id][0]; - //$color_row['jsondata'] = json_decode($color_row['jsondata'], true); - //} - //if ($attr_row[$v_id]) { - //$version_row = $attr_row[$v_id][0]; - //$version_row['jsondata'] = json_decode($version_row['jsondata'], true); - //} - //$car_json = [ - //'c_id' => $color_id, - //'v_id' => $v_id, - //'back_s_id' => $back_s_id, - //'color' => isset($color_row) ? $color_row : '', - //'version' => isset($version_row) ? $version_row : '' - //]; + $biz_row = $this->biz_model->get(['id' => $this->biz_id]); $this->load->library('receiver/customers_entity'); $level = $this->customers_entity->cal_level($buy_time); $time = date('Y-m-d H:i:s'); $add_data = [ 'name' => $name, 'mobile' => $mobile, - 'biz_id' => $biz_id, - //'brand_id' => $row['brand_id'], - //'s_id' => $row['id'], - //'v_id' => $v_id, + 'biz_id' => $this->biz_id, 'admin_id' => $this->session['uid'], 'level' => $level, 'cf_title' => '自有资源', - //'car_json' => json_encode($car_json, JSON_UNESCAPED_UNICODE), 'cont_time' => $time, 'status' => $status, 'c_time' => time() ]; - $re_biz = $this->biz_model->get(['id' => $this->biz_id, 'status' => 1], 'type'); - if ($re_biz['type'] == 5) {//异业店 + if ($biz_row['type'] == 5) {//异业店 $add_data['cf_clues'] = '异业店'; } if ($status == 1) {//到店客户 到店次数默认1 @@ -553,12 +490,15 @@ class Customers extends Wxapp */ protected function get_offline_sources() { + $show = []; + if ($this->get_biz('type') == 5) { + return ['sources' => $show]; + } $status = $this->input_param('status'); $offline_sources = $this->customers_model->offlineSources(); if (strlen($status) && $status == 0) {//未见客户 unset($offline_sources[1]); } - $show = []; foreach ($offline_sources as $key => $val) { $list = []; foreach ($val['list'] as $key2 => $val2) { @@ -566,7 +506,7 @@ class Customers extends Wxapp } $show[] = ['id' => $key, 'name' => $val['name'], 'list' => $list]; } - return $show; + return ['sources' => $show]; } //获取客户列表 @@ -578,15 +518,12 @@ class Customers extends Wxapp } $uid = $this->session['uid']; $group_id = $this->session['group_id']; - $biz_id = $this->biz_id; - + $biz_type = $this->get_biz('type'); $s_time = $this->input_param('s_time'); $e_time = $this->input_param('e_time'); $if_driver = $this->input_param('if_driver'); $level = $this->input_param('level'); $brand_id = $this->input_param('brand_id'); - //$s_id = $this->input_param('s_id'); //车系id - //$v_id = $this->input_param('v_id'); //车型级别id $cfrom = $this->input_param('cfrom'); //客户来源id $status = $this->input_param('status'); //状态 $o_type = $this->input_param('o_type'); //排序 @@ -622,7 +559,7 @@ class Customers extends Wxapp } } $where = [ - 'biz_id' => $biz_id, + 'biz_id' => $this->biz_id, 'status>=' => 0 ]; if ($of_id) { @@ -638,7 +575,7 @@ class Customers extends Wxapp if ($group_id == 1 || $ismy) { $where["admin_id"] = $uid; } - if ($group_id == 4 && $biz_id != 1) { + if ($group_id == 4 && $this->biz_id != 1) { $where['brand_id!='] = 3; //渠道经理过滤 } if ($s_time && $e_time) { @@ -671,7 +608,6 @@ class Customers extends Wxapp $cfrom && $where['cf_title'] = $cfrom; $name && $where["name like '%{$name}%'"] = null; $mobile && $where["mobile like '%$mobile%'"] = null; - $count = $this->customers_model->count($where); $lists = []; if ($count) { @@ -691,10 +627,10 @@ class Customers extends Wxapp $allot = $this->get_allot(); $status_name = $this->customers_model->get_status(); foreach ($rows as $key => $val) { - $other_data = [ - '客户来源' => $this->get_cfTitle($val), - '建卡时间' => date('Y-m-d', $val['c_time']), - ]; + if ($biz_type != 5) { + $other_data['客户来源'] = $this->get_cfTitle($val); + } + $other_data['建卡时间'] = date('Y-m-d', $val['c_time']); $val['cont_time'] != '0000-00-00 00:00:00' && $other_data['最近联系'] = date('Y-m-d', strtotime($val['cont_time'])); if ($group_id == 1) { $where_visit = ['c_id' => $val['id'], 'biz_id' => $this->biz_id, 'sales_id' => $this->session['uid']]; @@ -820,6 +756,7 @@ class Customers extends Wxapp private function visit_lists($params = []) { $group_id = $this->session['group_id']; + $biz_type = $this->get_biz('type'); $page = intval($params['page']); $size = intval($params['size']); $status = intval($params['status']); @@ -854,10 +791,10 @@ class Customers extends Wxapp } $status_name = $this->customers_model->get_status(); foreach ($rows as $key => $val) { - $other_data = [ - '客户来源' => $this->get_cfTitle($val), - '建卡时间' => date('Y-m-d', $val['c_time']), - ]; + if ($biz_type != 5) { + $other_data['客户来源'] = $this->get_cfTitle($val); + } + $other_data['建卡时间'] = date('Y-m-d', $val['c_time']); $val['cont_time'] != '0000-00-00 00:00:00' && $other_data['上次联系'] = date('Y-m-d', strtotime($val['cont_time'])); if ($group_id == 1) { $where_visit = ['c_id' => $val['id'], 'biz_id' => $this->biz_id, 'sales_id' => $this->session['uid']]; @@ -895,70 +832,6 @@ class Customers extends Wxapp return $data; } - /** - * Notes:待回访客户列表(已废除) - * Created on: 2021/10/21 14:27 - * Created by: dengbw - * @param array $params - * @return array - */ - private function visit_lists_temp($params = array()) - { - $biz_id = $this->biz_id; - $group_id = $this->session['group_id']; - $this->load->model('receiver/receiver_customers_visit_model', 'mdCustomersVisit'); - $page = $params['page']; - $size = $params['size']; - !$page && $page = 1; - !$size && $size = 10; - $where = array('a.biz_id' => $biz_id, 'a.status<>' => 2, 'b.contact' => 1, 'b.status' => 1); - $group_id == 1 && $where['a.admin_id'] = $this->session['uid']; - $count = $this->mdCustomersVisit->count_visit($where); - $lists = []; - if ($count) { - $fileds = 'a.id,a.name,a.admin_id,a.mobile,a.level,a.car_json,a.is_top,a.cf_title,a.brand_id,a.s_id - ,a.cont_time,a.c_time,a.if_defeat,a.of_id,a.of2_id'; - $rows = $this->mdCustomersVisit->select_visit($where, 'a.id desc', $page, $size, $fileds); - //获取管理员 - $admin_arr = array_unique(array_column($rows, 'admin_id')); - $admin_ids = implode(',', $admin_arr); - $admins = []; - if ($admin_ids) { - $admins = $this->app_user_model->map('id', '', ["id in ({$admin_ids})" => null], '', '', '', 'id,uname'); - } - foreach ($rows as $key => $val) { - $other_data = [ - '建卡时间' => date('Y-m-d', $val['c_time']), - '客户来源' => $val['cf_title'], - '销售顾问' => isset($admins[$val['admin_id']]) ? $admins[$val['admin_id']][0]['uname'] : '', - ]; - $val['cont_time'] != '0000-00-00 00:00:00' && $other_data['上次联系'] = date('Y-m-d', strtotime($val['cont_time'])); - $tags = [$val['level'] . '级用户']; - $defeat = ''; - if ($val['if_defeat'] == 1) { - $defeat = '战败申请中'; - } else if ($val['if_defeat'] == 2) { - $defeat = '再战'; - } - $lists[] = [ - 'id' => $val['id'], - 'name' => $val['name'], - 'mobile' => $this->get_mobile(['mobile' => $val['mobile'], 'of_id' => $val['of_id'], 'of2_id' => $val['of2_id']]), - 'complete_mobile' => $val['mobile'], - 'is_top' => $val['is_top'], - 'other_data' => $other_data, - 'tags' => $tags, - 'defeat' => $defeat - ]; - } - } - $data = [ - 'list' => $lists, - 'total' => $count - ]; - return $data; - } - /** * Notes:战败申请列表 * Created on: 2021/10/21 15:19 @@ -977,8 +850,7 @@ class Customers extends Wxapp $size = $params['size']; !$page && $page = 1; !$size && $size = 10; - $biz_id = $this->biz_id; - $where = array('biz_id' => $biz_id, 'if_defeat' => 1, 'status>' => -1); + $where = array('biz_id' => $this->biz_id, 'if_defeat' => 1, 'status>' => -1); $count = $this->customers_model->count($where); $lists = []; if ($count) { @@ -1151,4 +1023,22 @@ class Customers extends Wxapp return $visit_time; } -} + /** + * Notes:获取门店信息 + * Created on: 2022/6/30 15:09 + * Created by: dengbw + * @param string $params + * @return string + */ + private function get_biz($params = '') + { + if ($params) { + $re = $this->biz_model->get(['id' => $this->biz_id, 'status' => 1], $params); + $re = $re ? $re[$params] : ''; + } else { + $re = $this->biz_model->get(['id' => $this->biz_id, 'status' => 1]); + } + return $re; + } + +} \ No newline at end of file diff --git a/common/libraries/Wx_qyapi.php b/common/libraries/Wx_qyapi.php index 78437531..8529a608 100644 --- a/common/libraries/Wx_qyapi.php +++ b/common/libraries/Wx_qyapi.php @@ -176,8 +176,9 @@ class Wx_qyapi $res = $this->ci->mycurl->httpPost($url, $params, 'is_json'); } else if ($param['url'] == 'remark') {//修改客户备注信息 https://developer.work.weixin.qq.com/document/path/92115 $url = "https://qyapi.weixin.qq.com/cgi-bin/externalcontact/remark?access_token={$access_token}"; - $res = $this->ci->mycurl->httpPost($url, array('userid' => $param['userid'], 'external_userid' => $param['external_userid'] - , 'remark_mobiles' => $param['remark_mobiles'], 'description' => $param['description']), 'is_json'); + $params = ['userid' => $param['userid'], 'external_userid' => $param['external_userid'], 'remark_mobiles' => $param['remark_mobiles']]; + isset($param['description']) && $params['description'] = $param['description']; + $res = $this->ci->mycurl->httpPost($url, $params, 'is_json'); } else if ($param['url'] == 'get_user_behavior_data') {//联系客户统计 https://developer.work.weixin.qq.com/document/path/92132 $url = "https://qyapi.weixin.qq.com/cgi-bin/externalcontact/get_user_behavior_data?access_token={$access_token}"; $params = ['userid' => $param['userid'], 'start_time' => $param['start_time'], 'end_time' => $param['end_time']]; diff --git a/home/controllers/h5/Different.php b/home/controllers/h5/Different.php index 15b7aae2..477cc9c7 100644 --- a/home/controllers/h5/Different.php +++ b/home/controllers/h5/Different.php @@ -72,10 +72,9 @@ class Different extends CI_Controller { $params = $this->input->get(); $this->load->model('receiver/receiver_customers_model', 'mdCustomers'); - $c_id = $of_id = $of2_id = $buddy_type = 0; - $of_id_index = -1; + $c_id = $buddy_type = 0; $tagList = $res_td = $sources = $userInfo = []; - $tag_data = $tags_name = $description = ''; + $tag_data = $tags_name = ''; $userid = $this->userid; if (!$userid) { $this->show_json(400, '加载企业成员失败请重试~'); @@ -99,7 +98,6 @@ class Different extends CI_Controller } $tags_ary = $follow_user['tags'];//客户画像 $remark_mobiles = $follow_user['remark_mobiles'];//用户手机 - $description = $follow_user['description'];//描述 if ($tags_ary && $tags_ary != '[]' && is_array($tags_ary)) { foreach ($tags_ary as $key => $val) { if ($val['type'] == 1) {//企业标签 @@ -134,8 +132,6 @@ class Different extends CI_Controller $re_cus = $this->mdCustomers->get(['biz_id' => $biz_id, 'mobile' => $mobile, 'status<>' => -1]); if ($re_cus) { $c_id = $re_cus['id']; - $of_id = $re_cus['of_id']; - $of2_id = $re_cus['of2_id']; $buddy_type = $re_cus['buddy_type']; } } @@ -166,39 +162,9 @@ class Different extends CI_Controller $groupKey = array_column($tagList, 'order'); array_multisort($groupKey, SORT_DESC, $tagList); } - //线索来源 - $status = 0; - $offline_sources = $this->mdCustomers->offlineSources(); - if (strlen($status) && $status == 0) {//未见客户 - unset($offline_sources[1]); - } - $ii = 0; - $description_arr = $description ? explode('-', $description) : []; - foreach ($offline_sources as $key => $val) { - $list = []; - if (!$c_id) { - if ($description_arr[0] == $val['name']) { - $of_id = $key; - $of_id_index = $ii; - } - } else { - $of_id == $key && $of_id_index = $ii; - } - foreach ($val['list'] as $key2 => $val2) { - if (!$c_id) { - $description_arr[1] == $val2 && $of2_id = $key2; - } - $list[] = ['id' => $key2, 'name' => $val2]; - } - $sources[] = ['id' => $key, 'name' => $val['name'], 'list' => $list]; - $ii++; - } $data['tagList'] = $tagList; $data['sources'] = $sources; $data['userInfo'] = $userInfo; - $data['of_id'] = $of_id; - $data['of2_id'] = $of2_id; - $data['of_id_index'] = $of_id_index; $data['buddy_type'] = $buddy_type; $data['buddyTypeAry'] = $this->mdCustomers->buddyTypeAry(); $this->show_json(200, '获取用户信息成功', $data); @@ -237,7 +203,7 @@ class Different extends CI_Controller } } if ($c_id) {//已存在客户,更新资料 - $up_data = ['of_id' => $params['of_id'], 'of2_id' => $params['of2_id'], 'buddy_type' => $params['buddy_type']]; + $up_data = ['buddy_type' => $params['buddy_type']]; $re_cus2 = $this->mdCustomers->get(['id' => $c_id, 'status<>' => -1]); if (!$re_cus2) { $this->show_json(200, '客户不存在'); @@ -275,8 +241,6 @@ class Different extends CI_Controller 'county_id' => $county_id, 'unionid' => $userInfo['unionid'], 'wxqy' => 1, - 'of_id' => $params['of_id'], - 'of2_id' => $params['of2_id'], 'buddy_type' => $params['buddy_type'], 'cf_title' => '自有资源', 'cf_clues' => '异业店', @@ -308,13 +272,9 @@ class Different extends CI_Controller $up_qy && $result = true; //企微操作 $remark_mobiles = $userInfo['mobile'] ? [$userInfo['mobile']] : ''; - $description = $params['of_title'] ? $params['of_title'] : ''; - if ($description && $params['of2_title']) { - $description .= '-' . $params['of2_title']; - } //企微备注操作 $this->wx_qyapi->get_external_contact(['url' => 'remark', 'userid' => $userInfo['userid'] - , 'external_userid' => $userInfo['external_userid'], 'remark_mobiles' => $remark_mobiles, 'description' => $description]); + , 'external_userid' => $userInfo['external_userid'], 'remark_mobiles' => $remark_mobiles]); //标签操作 $tags_id = $userInfo['tags_id']; $add_tag = $remove_tag = ''; diff --git a/home/views/h5/different/index.php b/home/views/h5/different/index.php index 4dccf756..3065fa83 100644 --- a/home/views/h5/different/index.php +++ b/home/views/h5/different/index.php @@ -35,27 +35,6 @@ -
-
线索来源
-
- -
-
-
-
{{sources[of_id_index].name}}
-
- -
-
好友类型
@@ -99,9 +78,6 @@ submitFlag: false, userInfo: {avatar: '/img/h5/avatar.png', c_id: 0}, taglList: [], - of_id_index: -1, - of_id: 0, - of2_id: 0, sources: [], bid: , buddy_type: 0, @@ -113,19 +89,6 @@ mounted() { }, methods: { - //选择一级线索来源 - changeOf1() { - if (this.of_id > 0) { - this.sources.forEach((item, index) => { - if (item.id == this.of_id) { - this.of_id_index = index; - this.of2_id = 0; - } - }) - } else { - this.of_id_index = -1; - } - }, //获取用户信息 getUser(external_userid) { let that = this; @@ -144,9 +107,6 @@ that.taglList = re.data['tagList']; that.sources = re.data['sources']; that.userInfo = re.data['userInfo']; - that.of_id = re.data['of_id']; - that.of2_id = re.data['of2_id']; - that.of_id_index = re.data['of_id_index']; that.buddy_type = re.data['buddy_type']; that.buddyTypeAry = re.data['buddyTypeAry']; } else { @@ -165,8 +125,6 @@ mDialog.msg({content: "保存失败"}); return } - var of_title = that.of_id ? $("#id-of_id").find("option:selected").text() : ''; - var of2_title = that.of2_id ? $("#id-of2_id").find("option:selected").text() : ''; $.ajax({ url: '/h5/different/post_user', type: 'post', @@ -174,10 +132,6 @@ data: { userInfo: that.userInfo, taglList: that.taglList, - of_id: that.of_id, - of2_id: that.of2_id, - of_title: of_title, - of2_title: of2_title, bid: that.bid, buddy_type: that.buddy_type, },