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">