70 lines
2.5 KiB
PHP
70 lines
2.5 KiB
PHP
<?php
|
|
|
|
/**
|
|
* 客户
|
|
*/
|
|
class Customers_entity{
|
|
|
|
private $ci;
|
|
|
|
private $level = [3=>'H',7=>'A',15=>'B',30=>'C'];
|
|
public function __construct(){
|
|
$this->ci = & get_instance();
|
|
}
|
|
|
|
/**
|
|
* 添加日志
|
|
* @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 && $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){
|
|
$n_time = time();
|
|
$sql = "insert into lc_receiver_customer_oplogs (customer_id,cf_platform,c_time,uid,uname,type,log) select {$customer_id},'admin',{$n_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();
|
|
}
|
|
}
|
|
|
|
?>
|