'H', 7 => 'A', 15 => 'B', 30 => 'C']; public function __construct() { $this->ci = &get_instance(); } /** * Notes:添加日志/更新客户已回访 * Created on: 2021/11/2 14:10 * Created by: dengbw * @param $customer_id * @param $uid * @param $uname * @param $content * @param string $type * @param int $visit * @param array $imgs * @param string $cf_platform * @return mixed */ public function add_log_visit($customer_id, $uid, $uname, $content, $type = '', $visit = 0, $imgs = [], $cf_platform = 'wxapp') { $result = $this->add_log($customer_id, $uid, $uname, $content, $type, $cf_platform, $imgs); if ($visit && $result) {//更新客户已回访 $this->ci->load->model('receiver/receiver_customers_visit_model', 'mdCustomersVisit'); $result = $this->ci->mdCustomersVisit->update(array('contact' => 2, 'status' => 2) , array('c_id' => $customer_id, 'contact' => 1, 'status' => 1)); } return $result; } /** * 添加日志 * @param $customer_id int 客户id * @param $uid int 操作用户id * @param $uname int 操作用户名 * @param $content string 日志内容 * @param $type int 操作类型 (0普通日志 1短信 2拨打电话) * @param $cf_platform string 来源 (wxapp小程序 admin后台) */ public function add_log($customer_id, $uid, $uname, $content, $type = '', $cf_platform = 'wxapp', $imgs = []) { $this->ci->load->model('receiver/receiver_customer_oplogs_model', 'customer_oplogs_model'); $add_data = [ 'customer_id' => $customer_id, 'uid' => $uid, 'c_time' => time() ]; $content && $add_data['log'] = $content; $uname && $add_data['uname'] = $uname; $type && $add_data['type'] = $type; $cf_platform && $add_data['cf_platform'] = $cf_platform; $imgs && $add_data['imgs'] = json_encode($imgs, JSON_UNESCAPED_UNICODE); $result = $this->ci->customer_oplogs_model->add($add_data); if (($type == 2 || $type == 1) && $result) { //更新最后联系时间 $this->ci->load->model('receiver/receiver_customers_model'); $this->ci->receiver_customers_model->update(['cont_time' => date('Y-m-d H:i:s')], ['id' => $customer_id]); } return $result; } /** * 购车时间计算用户等级 * @param $buy_time int 预计购车天数 */ public function cal_level($buy_time) { if ($this->level[$buy_time]) { $level = $this->level[$buy_time]; } else { $level = 'C'; } return $level; } /** * 同步线索日志到客户日志 * @param $customer_id int 客户id * @param $clue_id int 线索id */ public function syn_clues($customer_id, $clue_id) { $sql = "insert into lc_receiver_customer_oplogs (customer_id,cf_platform,c_time,uid,uname,type,log) select {$customer_id},'admin',c_time,uid,uname,type,log from lc_receiver_clue_oplogs where clue_id={$clue_id}"; $this->ci->load->model('receiver/receiver_customer_oplogs_model', 'customer_oplogs_model'); $this->ci->customer_oplogs_model->db->query($sql); return $this->ci->customer_oplogs_model->db->affected_rows(); } } ?>