From 5409d83eb94c3a0c091cc36ca17929a18cdc2e48 Mon Sep 17 00:00:00 2001 From: xiaoyu Date: Thu, 28 Nov 2024 21:53:30 +0800 Subject: [PATCH] 11 --- admin/controllers/receiver/Clues.php | 75 +++++++++++- admin/views/receiver/clues/get.php | 164 ++++++++++++++++++--------- 2 files changed, 182 insertions(+), 57 deletions(-) diff --git a/admin/controllers/receiver/Clues.php b/admin/controllers/receiver/Clues.php index 942044f9..e74c9c6b 100644 --- a/admin/controllers/receiver/Clues.php +++ b/admin/controllers/receiver/Clues.php @@ -377,7 +377,7 @@ class Clues extends HD_Controller 'mobile' => '', 'cf_id' => '', 'cf2_id' => '', - 'province_id' => 0, + 'province_id' => 350000, 'city_id' => 0, 'county_id' => 0, 'biz_id' => 0, @@ -404,8 +404,8 @@ class Clues extends HD_Controller public function add() { $info = $this->input->post('info'); - if (!$info['name']) { - return $this->show_json(SYS_CODE_FAIL, '请填写姓名'); + if (!$info['name'] && !$info['sex']) { + return $this->show_json(SYS_CODE_FAIL, '请填写姓名或称谓'); } if (!mobile_valid($info['mobile'])) { @@ -424,7 +424,7 @@ class Clues extends HD_Controller } $add = array( - 'name' => $info['name'], + 'name' => $info['name'].$info['sex'], 'mobile' => $info['mobile'], 'cf_id' => $info['cf_id'], 'cf2_id' => $info['cf2_id'], @@ -445,6 +445,71 @@ class Clues extends HD_Controller if ($ret) { $log = '新增线索'; $this->addLog(array('clue_id' => $ret, 'type' => 3, 'log' => $log)); + + if($info['text']){ + $log = $info['text']; + sleep(1); + $this->addLog(array('clue_id' => $ret, 'type' => 0, 'log' => $log)); + } + + if($info['push'] && $info['biz_id']) { + if ($this->customers_model->get(array('mobile' => $info['mobile'], 'status >' => -1, 'biz_id' => $info['biz_id']))) { + $code = SYS_CODE_FAIL; + $msg = '门店已在跟踪'; + } else { + $this->load->helper("order"); + $biz = $this->biz_model->get(array('id' => $info['biz_id'])); + $add = array( + 'rid' => $ret, + 'cid' => create_customer_no($biz['county_id']), + 'name' => $info['name'].$info['sex'], + 'mobile' => $info['mobile'], + 'biz_id' => $info['biz_id'], + 'level' => 'H', + 'cf_title' => '数字营销中台', + 'of_id' => $info['cf_id'], + 'of2_id' => $info['cf2_id'], + 'brand_id' => $info['brand_id'], + 'series_id' => $info['series_id'], + 'p_time' => date('Y-m-d H:i:s'), + 'c_time' => time(), + ); + + $info['province_id'] && $add['province_id'] = $info['province_id']; + $info['city_id'] && $add['city_id'] = $info['city_id']; + $info['county_id'] && $add['county_id'] = $info['county_id']; + + $customers_id = $this->customers_model->add($add); + if ($customers_id) { + sleep(1); + $this->addLog(array('clue_id' => $ret, 'type' => 3, 'log' => '转交门店跟进')); + $this->clues_model->update(['status' => 1, 'status2' => 2], ['id' => $ret]); + + //同步线索日志到客户日志 + $this->load->library('receiver/customers_entity'); + $this->customers_entity->syn_clues($customers_id, $ret); + + //短信通知店长 + $this->load->model('app/licheb/app_licheb_users_model'); + $where = array('biz_id' => $info['biz_id'], 'status' => 1, 'group_id' => 2); + $res_u = $this->app_licheb_users_model->select($where); + if ($res_u) { + foreach ($res_u as $v) { + if ($info['biz_id'] != 1) { + b2m_send_sms($v['mobile'], '【理车宝】您好,门店新增了1个客户线索。请及时到小程序"理车宝-待分配客户”分配给销售顾问跟进。祝您生活愉快!'); + } + } + } + + $code = SYS_CODE_SUCCESS; + $msg = '转交成功'; + } else { + $code = SYS_CODE_FAIL; + $msg = '转交失败'; + } + } + return $this->show_json($code, $msg); + } return $this->show_json(SYS_CODE_SUCCESS, '新增成功'); } else { debug_log("[error]# add fail; " . $this->clues_model->db->last_query(), __FUNCTION__, $this->log_dir); @@ -654,7 +719,7 @@ class Clues extends HD_Controller $customers_id = $this->customers_model->add($add); if ($customers_id) { $this->addLog(array('clue_id' => $re['id'], 'type' => 3, 'log' => '转交门店跟进')); - $this->clues_model->update(['status' => 1, 'status2' => 1], ['id' => $re['id']]); + $this->clues_model->update(['status' => 1, 'status2' => 2], ['id' => $re['id']]); //同步线索日志到客户日志 $this->load->library('receiver/customers_entity'); diff --git a/admin/views/receiver/clues/get.php b/admin/views/receiver/clues/get.php index 8c3e018f..fef2a8d5 100644 --- a/admin/views/receiver/clues/get.php +++ b/admin/views/receiver/clues/get.php @@ -3,9 +3,13 @@ action="" id="edit-form">
-
+
+
+ + +
@@ -13,6 +17,32 @@
+
+ +
+ +
+
+ +
+
+ +
+
+ +
+
@@ -35,34 +65,6 @@
-
- -
- -
-
- -
-
- -
-
- -
-
-
@@ -78,20 +80,30 @@
-
- +
+ +
-
+
+
+ +
+ +
+
+
@@ -103,10 +115,10 @@ el: '#edit-form', data: { info: {}, - province_id:0, + province_id:350000, city_id:0, county_id:0, - province_id_admin:0, + province_id_admin:350000, city_id_admin:0, county_id_admin:0, biz_id_admin:0, @@ -119,6 +131,9 @@ seryAry: [], admins: {provinceAry: , cityAry: [], countyAry: [], bizAry: []}, action: "", + inputValue: "", + showSelect: false, + inputSelect: [] }, mounted: function () { this.init_provinces(); @@ -128,17 +143,29 @@ this.info = ; this.cfromAry = ; this.action = ""; - this.init_brands(); - if (this.info.series_id) { - this.get_series() - } - this.get_series(); + // this.init_brands(); + // this.get_series(); }, methods: { - init_brands: function () { - var vm = this; - $.get('/common/auto', {'type': 1, 'tp': 0}, function (response) { - vm.brandAry = response.data; + selectInput: function (item){ + console.log(item) + this.inputValue = item.name + this.info.brand_id = item.id + this.showSelect = false + }, + handleInput: function (event) { + console.log('输入值:', this.inputValue); + // 请求接口 + var that = this; + $.get('/common/auto_search', {'name': this.inputValue}, function (response) { + that.inputSelect = response.data; + setTimeout(function (){ + if(that.inputSelect && that.inputSelect.length>0){ + that.showSelect = true + }else{ + that.showSelect = false + } + },100) }) }, get_series: function () { @@ -146,10 +173,6 @@ vm.seryAry = {}; $.get('/common/auto', {'type': 2, 'tp': 0, 'pid': vm.info.brand_id}, function (response) { vm.seryAry = response.data; - // if (if_reset) { - // vm.params.series_id = 0; - // vm.params.car_id = 0; - // } }) }, init_provinces: function () { @@ -167,7 +190,7 @@ vm.cityAry = response.data; } }); - $.get('common/area', {id: vm.province_id_admin, key: 'city', type: 1}, function (response) { + $.get('common/area', {id: 350000, key: 'city', type: 1}, function (response) { if (response.code == 1) { vm.admins.cityAry = response.data; } @@ -213,6 +236,45 @@ loading = 1; vm.info.biz_id = vm.biz_id_admin; + $.ajax({ + url: "receiver/clues/" + vm.action, + type: 'post', + dataType: 'json', + data: { + info: vm.info + }, + beforeSend: function () { + layer.load(1, { + shade: [0.1, '#fff'] //0.1透明度的白色背景 + }); + }, + success: function (data) { + if (1 == data['code']) { + layer.msg(data.msg, { + icon: 1, + time: 2000 + }, function () { + window.location.reload(); + }); + } else { + layer.msg(data.msg, {icon: 2}); + } + }, + complete: function () { + loading = false; + layer.closeAll('loading'); + } + }); + }, + savePush: function () { + var vm = this; + if (loading) { + return; + } + loading = 1; + vm.info.biz_id = vm.biz_id_admin; + vm.info.push = 1; + $.ajax({ url: "receiver/clues/" + vm.action, type: 'post', @@ -249,7 +311,6 @@ if (nv !== '') { this.get_series() } - }, 'info.province_id': function (nv, ov) { var that = this; @@ -413,4 +474,3 @@ }); }); -