customer_visit_1025
This commit is contained in:
@@ -20,7 +20,7 @@ class Common extends CI_Controller
|
||||
public function material()
|
||||
{
|
||||
$this->load->model('app/material/Material_template_model', 'mdTemplate');
|
||||
$rows = $this->mdTemplate->select(array('status' => 1, 'type in(1,2)' => null), 'id desc', '', '', 'id,title');
|
||||
$rows = $this->mdTemplate->select(array('status' => 1, 'type in(1,4)' => null), 'id desc', '', '', 'id,title');
|
||||
$this->data['data'] = $rows;
|
||||
return $this->show_json(SYS_CODE_SUCCESS);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,167 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Notes:狸车宝任务
|
||||
* Created on: 2021/10/19 17:15
|
||||
* Created by: dengbw
|
||||
*/
|
||||
class Licheb extends HD_Controller
|
||||
{
|
||||
|
||||
private $log_file;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->log_file = 'licheb.log';
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes:增加客户待回访
|
||||
* Created on: 2021/10/19 17:15
|
||||
* Created by: dengbw
|
||||
* https://liche-api-dev.xiaoyu.com/plan/licheb/customer_visit
|
||||
* https://api.liche.cn/plan/licheb/customer_visit
|
||||
*/
|
||||
public function customer_visit()
|
||||
{
|
||||
$params = $this->input->get();
|
||||
$hour = date('H');
|
||||
if ($hour != '00' && !$params['sd']) {
|
||||
echo '[0]点过后才会开始执行客户待回访[' . $hour . ']';
|
||||
return;
|
||||
}
|
||||
$this->load->model('receiver/receiver_customers_model', 'mdCustomers');
|
||||
$this->load->model('receiver/receiver_customers_visit_model', 'mdCustomersVisit');
|
||||
$size = 100;//每次最多处理多少条
|
||||
$rds = intval($this->input->get('rds'));
|
||||
$redis = &load_cache('redis');
|
||||
$redisVisit = 'customers_visit_cid';
|
||||
$day = date('Y-m-d');
|
||||
$day_1 = date('Y-m-d', strtotime('-1 day'));//前1天
|
||||
$day_7 = date('Y-m-d', strtotime('-7 day'));//1周前
|
||||
$day_30 = date('Y-m-d', strtotime('-1 month'));//1个月前
|
||||
$re_v = $this->mdCustomersVisit->get(array('day' => $day));//查找当天是否有数据
|
||||
if (!$re_v || $rds) {
|
||||
$redis->delete($redisVisit);
|
||||
}
|
||||
$c_id = $redis->get($redisVisit);
|
||||
!$c_id && $c_id = 0;
|
||||
$c_id = 0;
|
||||
$log = array();
|
||||
$where = array('id >' => $c_id, 'status in(0,1)', 'admin_id >' => 0, 'c_time <' => strtotime($day . ' 00:00:00'));
|
||||
$res_c = $this->mdCustomers->select($where, 'id asc', 1, $size, 'id,level');
|
||||
if (!$res_c) {
|
||||
echo '执行到当前客户id:' . $c_id . '暂无数据';
|
||||
return;
|
||||
}
|
||||
foreach ($res_c as $key => $value) {
|
||||
$c_id = $value['id'];
|
||||
$level = $value['level'];
|
||||
$if_add = 0;
|
||||
if ($level == 'H') {//每天回访一次
|
||||
$re_v = $this->mdCustomersVisit->get(array('day' => $day, 'c_id' => $c_id));
|
||||
!$re_v && $if_add = 1;
|
||||
} else if ($level == 'A') {//隔一天打
|
||||
$re_v = $this->mdCustomersVisit->get(array('day>=' => $day_1, 'day<=' => $day, 'c_id' => $c_id));
|
||||
!$re_v && $if_add = 1;
|
||||
} else if ($level == 'B') {//一周回访一次
|
||||
$re_v = $this->mdCustomersVisit->get(array('day>=' => $day_7, 'day<=' => $day, 'c_id' => $c_id));
|
||||
!$re_v && $if_add = 1;
|
||||
} else if ($level == 'C') {//一个月打一次
|
||||
$re_v = $this->mdCustomersVisit->get(array('day>=' => $day_30, 'day<=' => $day, 'c_id' => $c_id));
|
||||
!$re_v && $if_add = 1;
|
||||
}
|
||||
if ($if_add) {
|
||||
$this->mdCustomersVisit->update(array('status' => 2), array('c_id' => $c_id, 'status' => 1));
|
||||
$id = $this->mdCustomersVisit->add(array('c_id' => $c_id, 'day' => $day, 'level' => $level, 'c_time' => time()));
|
||||
$log[] = array('id' => $c_id, 'add_id' => $id);
|
||||
}
|
||||
}
|
||||
$redis->save($redisVisit, $c_id);//保存最后客户id
|
||||
echo '<br>执行到当前客户id:' . $redis->get($redisVisit);
|
||||
echo '日期:' . json_encode(array('day' => $day, 'day_1' => $day_1, 'day_7' => $day_7, 'day_30' => $day_30), JSON_UNESCAPED_UNICODE);
|
||||
echo '<br>成功新增:<br>';
|
||||
if ($log) {
|
||||
echo json_encode($log, JSON_UNESCAPED_UNICODE);
|
||||
echo '<br>';
|
||||
}
|
||||
echo '数据库获取:<br>';
|
||||
echo json_encode($res_c, JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes:更新客户等级
|
||||
* Created on: 2021/10/19 17:15
|
||||
* Created by: dengbw
|
||||
* https://liche-api-dev.xiaoyu.com/plan/licheb/customer_level
|
||||
* https://api.liche.cn/plan/licheb/customer_level
|
||||
*/
|
||||
public function customer_level()
|
||||
{
|
||||
$params = $this->input->get();
|
||||
$hour = date('H');
|
||||
if ($hour != '23' && !$params['sd']) {
|
||||
echo '[23]点过后才会更新客户等级[' . $hour . ']';
|
||||
return;
|
||||
}
|
||||
$this->load->model('receiver/receiver_customers_model', 'mdCustomers');
|
||||
$this->load->model('receiver/receiver_customers_visit_model', 'mdCustomersVisit');
|
||||
$size = 100;//每次最多处理多少条
|
||||
$rds = intval($this->input->get('rds'));
|
||||
$redis = &load_cache('redis');
|
||||
$redisVisit = 'customers_level_cid';
|
||||
$day = date('Y-m-d');
|
||||
$day_1 = date('Y-m-d', strtotime('-1 day'));//前1天
|
||||
$day_7 = date('Y-m-d', strtotime('-7 day'));//1周前
|
||||
$day_14 = date('Y-m-d', strtotime('-14 day'));//2周前
|
||||
$day_30 = date('Y-m-d', strtotime('-1 month'));//1个月前
|
||||
$re_v = $this->mdCustomersVisit->get(array('day' => $day));//查找当天是否有数据
|
||||
if (!$re_v || $rds) {
|
||||
$redis->delete($redisVisit);
|
||||
}
|
||||
$c_id = $redis->get($redisVisit);
|
||||
!$c_id && $c_id = 0;
|
||||
$c_id = 0;
|
||||
$log = array();
|
||||
$where = array('id >' => $c_id, 'status in(0,1)', 'admin_id >' => 0, 'c_time <' => strtotime($day . ' 00:00:00'));
|
||||
$res_c = $this->mdCustomers->select($where, 'id asc', 1, $size, 'id,level');
|
||||
if (!$res_c) {
|
||||
echo '执行到当前客户id:' . $c_id . '暂无数据';
|
||||
return;
|
||||
}
|
||||
foreach ($res_c as $key => $value) {
|
||||
$c_id = $value['id'];
|
||||
$level = $value['level'];
|
||||
$up_level = '';
|
||||
if ($level == 'H') {//每天回访一次,打7天后降为A
|
||||
$count = $this->mdCustomersVisit->count(array('day>=' => $day_7, 'day<=' => $day, 'c_id' => $c_id, 'level' => $level));
|
||||
$count >= 7 && $up_level = 'A';
|
||||
} else if ($level == 'A') {//隔一天打,打2周后降B
|
||||
$count = $this->mdCustomersVisit->count(array('day>=' => $day_14, 'day<=' => $day, 'c_id' => $c_id, 'level' => $level));
|
||||
$count >= 7 && $up_level = 'B';
|
||||
} else if ($level == 'B') {//一周回访一次,1个月后降C
|
||||
$count = $this->mdCustomersVisit->count(array('day>=' => $day_30, 'day<=' => $day, 'c_id' => $c_id, 'level' => $level));
|
||||
$count >= 4 && $up_level = 'C';
|
||||
}
|
||||
if ($up_level) {//降级更新
|
||||
$this->mdCustomers->update(array('level' => $up_level), array('id' => $c_id));
|
||||
$log[] = array('id' => $c_id, 'level' => $level, 'up_level' => $up_level);
|
||||
}
|
||||
}
|
||||
$redis->save($redisVisit, $c_id);//保存最后客户id
|
||||
echo '<br>执行到当前客户id:' . $redis->get($redisVisit);
|
||||
echo '日期:' . json_encode(array('day' => $day, 'day_1' => $day_1, 'day_7' => $day_7, 'day_14' => $day_14
|
||||
, 'day_30' => $day_30), JSON_UNESCAPED_UNICODE);
|
||||
echo '<br>成功更新:<br>';
|
||||
if ($log) {
|
||||
$_data = json_encode($log, JSON_UNESCAPED_UNICODE);
|
||||
echo $_data;
|
||||
echo '<br>';
|
||||
debug_log('降级客户:' . $_data, $this->log_file);
|
||||
}
|
||||
echo '数据库获取:<br>';
|
||||
echo json_encode($res_c, JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -26,9 +26,11 @@ class Plan extends CI_Controller
|
||||
|
||||
//执行失败的plan重跑
|
||||
$plan[] = array('url' => base_url(array('plan', 'plan', 'replan')), 'interval' => 1);
|
||||
$plan[] = array('url' => base_url(array('plan', 'bobing', 'lottery')), 'interval' => 30);//博饼每日中奖
|
||||
//$plan[] = array('url' => base_url(array('plan', 'bobing', 'lottery')), 'interval' => 30);//博饼每日中奖
|
||||
//$plan[] = array('url' => base_url(array('plan', 'bobing', 'mj')), 'interval' => 30);//马甲跑总分数
|
||||
$plan[] = array('url' => base_url(array('plan', 'bobing', 'mj_day')), 'interval' => 30);//马甲跑今日分数
|
||||
//$plan[] = array('url' => base_url(array('plan', 'bobing', 'mj_day')), 'interval' => 30);//马甲跑今日分数
|
||||
$plan[] = array('url' => base_url(array('plan', 'licheb', 'customer_visit')), 'interval' => 1);//增加客户待回访
|
||||
$plan[] = array('url' => base_url(array('plan', 'licheb', 'customer_level')), 'interval' => 1);//更新客户等级
|
||||
$this->plan = $plan;
|
||||
}
|
||||
|
||||
@@ -84,7 +86,8 @@ class Plan extends CI_Controller
|
||||
}
|
||||
|
||||
//执行异常的脚本重新跑
|
||||
public function replan(){
|
||||
public function replan()
|
||||
{
|
||||
$redis = &load_cache('redis');
|
||||
$redis = $redis->redis();
|
||||
|
||||
@@ -93,16 +96,16 @@ class Plan extends CI_Controller
|
||||
$now = time();
|
||||
$rows = $redis->zRangeByScore($key_batch, 0, $now);
|
||||
debug_log("[info]# return_plan_batch:" . json_encode($rows), __FUNCTION__, $this->log_dir);
|
||||
echo "return_plan_batch:" . json_encode($rows) ." \n";
|
||||
echo "return_plan_batch:" . json_encode($rows) . " \n";
|
||||
|
||||
$total = count($rows);
|
||||
$done = 0;
|
||||
foreach($rows as $k => $v){
|
||||
foreach ($rows as $k => $v) {
|
||||
$url = $v;
|
||||
|
||||
$res = $this->get_https($url);
|
||||
debug_log("[info]# url={$url}; res={$res}", __FUNCTION__, $this->log_dir);
|
||||
if($res){
|
||||
if ($res) {
|
||||
$done++;
|
||||
}
|
||||
$redis->zRem($key_batch, $v);
|
||||
|
||||
@@ -14,7 +14,7 @@ class Xzcall extends HD_Controller
|
||||
private $log_file;
|
||||
private $admin_config = [
|
||||
'app_id' => 1206,
|
||||
'app_key' => 'WX6HDVZX3AYSZDR1739332ZM'
|
||||
'app_key' => 'WX6HDVZX3AYSZDR1739332ZM'
|
||||
];
|
||||
|
||||
public function __construct()
|
||||
@@ -132,6 +132,11 @@ class Xzcall extends HD_Controller
|
||||
debug_log('error:文件上传七牛失败', $this->log_file);
|
||||
} else {
|
||||
$up_data['rec_url'] = $q_res['url'];
|
||||
if($row['cf_platform']=='api' && $row['cf_title']=='customer'){//更新客户回访
|
||||
$this->load->model('receiver/receiver_customers_visit_model', 'mdCustomersVisit');
|
||||
$this->mdCustomersVisit->update(array('contact' => 2,'status' => 2)
|
||||
, array('c_id' => $row['cf_id'], 'contact' => 1,'status' => 1));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
debug_log('error:' . json_encode($result, JSON_UNESCAPED_UNICODE), $this->log_file);
|
||||
|
||||
@@ -7,19 +7,22 @@ defined('WXAPP_APP') OR exit('No direct script access allowed');
|
||||
* Date: 2021/06/23
|
||||
* Time: 14:08
|
||||
*/
|
||||
require_once APPPATH.'controllers/wxapp/Wxapp.php';
|
||||
class Customers extends Wxapp{
|
||||
require_once APPPATH . 'controllers/wxapp/Wxapp.php';
|
||||
|
||||
function __construct($inputs, $app_key){
|
||||
class Customers extends Wxapp
|
||||
{
|
||||
|
||||
function __construct($inputs, $app_key)
|
||||
{
|
||||
parent::__construct($inputs, $app_key);
|
||||
|
||||
$this->login_white = array();//登录白名单
|
||||
$this->check_status = array();//用户状态校验
|
||||
$this->check_mobile = array();//需要手机号
|
||||
$this->check_headimg =array();//授权微信信息
|
||||
$this->check_headimg = array();//授权微信信息
|
||||
|
||||
$this->load->model('receiver/receiver_customers_model','customers_model');
|
||||
$this->load->model('receiver/receiver_customer_oplogs_model','customer_oplogs_model');
|
||||
$this->load->model('receiver/receiver_customers_model', 'customers_model');
|
||||
$this->load->model('receiver/receiver_customer_oplogs_model', 'customer_oplogs_model');
|
||||
$this->load->model('auto/auto_series_model');
|
||||
$this->load->model('auto/auto_brand_model');
|
||||
$this->load->model('auto/auto_attr_model');
|
||||
@@ -27,38 +30,39 @@ class Customers extends Wxapp{
|
||||
$this->load->model("biz/biz_model");
|
||||
}
|
||||
|
||||
protected function get(){
|
||||
protected function get()
|
||||
{
|
||||
$id = $this->input_param('id');
|
||||
if($id){
|
||||
if ($id) {
|
||||
$where = [
|
||||
'id' => $id,
|
||||
];
|
||||
$row = $this->customers_model->get($where);
|
||||
if(!$row){
|
||||
if (!$row) {
|
||||
throw new Exception('数据不存在', ERR_PARAMS_ERROR);
|
||||
}
|
||||
$admin = $this->app_user_model->get(['id'=>$row['admin_id']],'id,uname');
|
||||
$brand = $this->auto_brand_model->get(['id'=>$row['brand_id']],'name');
|
||||
$series = $this->auto_series_model->get(['id'=>$row['s_id']],'name');
|
||||
$car_json = json_decode($row['car_json'],true);
|
||||
$admin = $this->app_user_model->get(['id' => $row['admin_id']], 'id,uname');
|
||||
$brand = $this->auto_brand_model->get(['id' => $row['brand_id']], 'name');
|
||||
$series = $this->auto_series_model->get(['id' => $row['s_id']], 'name');
|
||||
$car_json = json_decode($row['car_json'], true);
|
||||
$color = isset($car_json['color']) ? $car_json['color']['title'] : '';
|
||||
$version = isset($car_json['version']) ? $car_json['version']['title'] : '';
|
||||
$tags = [$row['level'].'级用户'];
|
||||
$tags = [$row['level'] . '级用户'];
|
||||
$status_name = $this->customers_model->get_status();
|
||||
$tip = $status_name[$row['status']] ? $status_name[$row['status']] : '';
|
||||
|
||||
$other_data = [
|
||||
'品牌车型' => $brand['name'].$series['name'],
|
||||
'颜色型号' => $color.'-'.$version,
|
||||
'建卡时间' => date('Y-m-d',$row['c_time']),
|
||||
'品牌车型' => $brand['name'] . $series['name'],
|
||||
'颜色型号' => $color . '-' . $version,
|
||||
'建卡时间' => date('Y-m-d', $row['c_time']),
|
||||
'客户来源' => $row['cf_title'],
|
||||
'销售顾问' => isset($admin) ? $admin['uname'] : '',
|
||||
];
|
||||
$row['cont_time'] != '0000-00-00 00:00:00' && $other_data['上次联系'] = date('Y-m-d',strtotime($row['cont_time']));
|
||||
$row['cont_time'] != '0000-00-00 00:00:00' && $other_data['上次联系'] = date('Y-m-d', strtotime($row['cont_time']));
|
||||
$data = [
|
||||
'id' => $row['id'],
|
||||
'name' => $row['name'],
|
||||
'mobile' => '****'.substr($row['mobile'],-4),
|
||||
'mobile' => '****' . substr($row['mobile'], -4),
|
||||
'complete_mobile' => $row['mobile'],
|
||||
'tip' => $tip,
|
||||
'is_top' => $row['is_top'],
|
||||
@@ -67,35 +71,39 @@ class Customers extends Wxapp{
|
||||
'tags' => $tags
|
||||
];
|
||||
return $data;
|
||||
}else{
|
||||
} else {
|
||||
return $this->lists();
|
||||
}
|
||||
}
|
||||
|
||||
//获取客户其它信息
|
||||
protected function get_data(){
|
||||
protected function get_data()
|
||||
{
|
||||
$id = $this->input_param('id');
|
||||
$where = [
|
||||
'id' => $id
|
||||
];
|
||||
$row = $this->customers_model->get($where);
|
||||
if(!$row){
|
||||
if (!$row) {
|
||||
throw new Exception('数据不存在', ERR_PARAMS_ERROR);
|
||||
}
|
||||
$car_json = json_decode($row['car_json'],true);
|
||||
$car_json = json_decode($row['car_json'], true);
|
||||
$data['baseinfo'] = [
|
||||
'name' => ['value'=>$row['name'],'cn'=>'客户姓名'],
|
||||
'mobile' => ['value'=>mobile_asterisk($row['mobile']),'cn'=>'客户电话'],
|
||||
'brand_id' => ['value'=>$row['brand_id'],'cn'=>'车辆品牌'],
|
||||
'car_id' => ['value'=>$row['s_id'],'cn'=>'车辆车系'],
|
||||
'v_id' => ['value'=>$row['v_id'],'cn'=>'车型级别'],
|
||||
'color_id' => ['value'=>$car_json['c_id'],'cn'=>'车型颜色'],
|
||||
'cf_clues' => ['value'=>$row['cf_clues'],'cn'=>'线索来源'],
|
||||
'buy_time' => ['value'=>$row['buy_time'],'cn'=>'预计购车时间'],
|
||||
'name' => ['value' => $row['name'], 'cn' => '客户姓名'],
|
||||
'mobile' => ['value' => mobile_asterisk($row['mobile']), 'cn' => '客户电话'],
|
||||
'brand_id' => ['value' => $row['brand_id'], 'cn' => '车辆品牌'],
|
||||
'car_id' => ['value' => $row['s_id'], 'cn' => '车辆车系'],
|
||||
'v_id' => ['value' => $row['v_id'], 'cn' => '车型级别'],
|
||||
'color_id' => ['value' => $car_json['c_id'], 'cn' => '车型颜色'],
|
||||
'cf_clues' => ['value' => $row['cf_clues'], 'cn' => '线索来源'],
|
||||
'buy_time' => ['value' => $row['buy_time'], 'cn' => '预计购车时间'],
|
||||
];
|
||||
return $data;
|
||||
}
|
||||
|
||||
//修改基本信息
|
||||
protected function put_data(){
|
||||
protected function put_data()
|
||||
{
|
||||
$biz_id = $this->session['new_biz_id'] ? $this->session['new_biz_id'] : intval($this->session['biz_id']);
|
||||
|
||||
$id = $this->input_param('cus_id');
|
||||
@@ -106,67 +114,69 @@ class Customers extends Wxapp{
|
||||
$color_id = $this->input_param('color_id'); //颜色id
|
||||
$cf_clues = $this->input_param('cf_clues'); //线索来源
|
||||
$buy_time = $this->input_param('buy_time'); //预计购车时间
|
||||
$row = $this->customers_model->get(['id'=>$id]);
|
||||
if(!$row){
|
||||
$row = $this->customers_model->get(['id' => $id]);
|
||||
if (!$row) {
|
||||
throw new Exception('参数错误', ERR_PARAMS_ERROR);
|
||||
}
|
||||
$car_json = json_decode($row['car_json'],true);
|
||||
$car_json = json_decode($row['car_json'], true);
|
||||
$update = [];
|
||||
if($mobile){
|
||||
if(!mobile_valid($mobile)){
|
||||
if ($mobile) {
|
||||
if (!mobile_valid($mobile)) {
|
||||
throw new Exception('手机号格式错误', ERR_PARAMS_ERROR);
|
||||
}
|
||||
if($this->customers_model->count(['biz_id'=>$biz_id,'mobile'=>$mobile])){
|
||||
if ($this->customers_model->count(['biz_id' => $biz_id, 'mobile' => $mobile])) {
|
||||
throw new Exception('客户已存在', API_CODE_FAIL);
|
||||
}
|
||||
$update['mobile'] = $mobile;
|
||||
}
|
||||
$s_row = $this->auto_series_model->get(['id'=>$car_id]);
|
||||
$s_row = $this->auto_series_model->get(['id' => $car_id]);
|
||||
$ids_arr = [];
|
||||
if($v_id){
|
||||
if ($v_id) {
|
||||
$car_json['v_id'] = $v_id;
|
||||
$ids_arr[] = $v_id;
|
||||
}
|
||||
if($color_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]){
|
||||
if ($attr_row[$color_id]) {
|
||||
$color_row = $attr_row[$color_id][0];
|
||||
$color_row['jsondata'] = json_decode($color_row['jsondata'],true);
|
||||
$color_row['jsondata'] = json_decode($color_row['jsondata'], true);
|
||||
isset($color_row) && $car_json['color'] = $color_row;
|
||||
}
|
||||
if($attr_row[$v_id]){
|
||||
if ($attr_row[$v_id]) {
|
||||
$version_row = $attr_row[$v_id][0];
|
||||
$version_row['jsondata'] = json_decode($version_row['jsondata'],true);
|
||||
$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);
|
||||
$update['car_json'] = json_encode($car_json, JSON_UNESCAPED_UNICODE);
|
||||
$name && $update['name'] = $name;
|
||||
$cf_clues && $update['cf_clues'] = $cf_clues;
|
||||
$v_id && $update['v_id'] = $v_id;
|
||||
if($s_row){
|
||||
if ($s_row) {
|
||||
$update['s_id'] = $s_row['id'];
|
||||
$update['brand_id'] = $s_row['brand_id'];
|
||||
$update['brand_id'] = $s_row['brand_id'];
|
||||
}
|
||||
if($buy_time){
|
||||
if ($buy_time) {
|
||||
$this->load->library('receiver/customers_entity');
|
||||
$update['level'] = $this->customers_entity->cal_level($buy_time);
|
||||
$update['level'] = $this->customers_entity->cal_level($buy_time);
|
||||
$update['buy_time'] = $buy_time;
|
||||
}
|
||||
$result = $this->customers_model->update($update,['id'=>$id]);
|
||||
if($result){
|
||||
$result = $this->customers_model->update($update, ['id' => $id]);
|
||||
if ($result) {
|
||||
$uname = $this->session['uname'];
|
||||
$this->load->library('receiver/customers_entity');
|
||||
$this->customers_entity->add_log($id,$this->session['uid'],$uname,"修改用户基本信息");
|
||||
$this->customers_entity->add_log($id, $this->session['uid'], $uname, "修改用户基本信息");
|
||||
throw new Exception('保存成功', API_CODE_SUCCESS);
|
||||
}else{
|
||||
} else {
|
||||
throw new Exception('保存失败', ERR_PARAMS_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
//创建客户
|
||||
protected function post(){
|
||||
protected function post()
|
||||
{
|
||||
$biz_id = $this->session['new_biz_id'] ? $this->session['new_biz_id'] : intval($this->session['biz_id']);
|
||||
|
||||
$name = $this->input_param('name');
|
||||
@@ -178,26 +188,26 @@ class Customers extends Wxapp{
|
||||
$cf_clues = $this->input_param('cf_clues'); //线索来源
|
||||
$buy_time = $this->input_param('buy_time'); //预计购车时间
|
||||
|
||||
if(!mobile_valid($mobile)) throw new Exception('请输入正确的手机号码', ERR_PARAMS_ERROR);
|
||||
if(!$name || !$car_id || !$v_id || !$color_id){
|
||||
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' => $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]);
|
||||
$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]){
|
||||
$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);
|
||||
$color_row['jsondata'] = json_decode($color_row['jsondata'], true);
|
||||
}
|
||||
if($attr_row[$v_id]){
|
||||
if ($attr_row[$v_id]) {
|
||||
$version_row = $attr_row[$v_id][0];
|
||||
$version_row['jsondata'] = json_decode($version_row['jsondata'],true);
|
||||
$version_row['jsondata'] = json_decode($version_row['jsondata'], true);
|
||||
}
|
||||
$car_json = [
|
||||
'c_id' => $color_id,
|
||||
@@ -207,7 +217,7 @@ class Customers extends Wxapp{
|
||||
'version' => isset($version_row) ? $version_row : ''
|
||||
];
|
||||
$this->load->library('receiver/customers_entity');
|
||||
$level = $this->customers_entity->cal_level($buy_time);
|
||||
$level = $this->customers_entity->cal_level($buy_time);
|
||||
|
||||
$add_data = [
|
||||
'name' => $name,
|
||||
@@ -219,7 +229,7 @@ class Customers extends Wxapp{
|
||||
'admin_id' => $this->session['uid'],
|
||||
'level' => $level,
|
||||
'cf_title' => '自有资源',
|
||||
'car_json' => json_encode($car_json,JSON_UNESCAPED_UNICODE),
|
||||
'car_json' => json_encode($car_json, JSON_UNESCAPED_UNICODE),
|
||||
'cont_time' => date('Y-m-d H:i:s'),
|
||||
'c_time' => time()
|
||||
];
|
||||
@@ -228,80 +238,97 @@ class Customers extends Wxapp{
|
||||
$buy_time && $add_data['buy_time'] = $buy_time;
|
||||
$cf_clues && $add_data['cf_clues'] = $cf_clues;
|
||||
$result = $this->customers_model->add($add_data);
|
||||
if($result){
|
||||
if ($result) {
|
||||
$uname = $this->session['uname'];
|
||||
$this->load->library('receiver/customers_entity');
|
||||
$this->customers_entity->add_log($result,$this->session['uid'],$uname,"创建客户");
|
||||
$this->customers_entity->add_log($result, $this->session['uid'], $uname, "创建客户");
|
||||
throw new Exception('创建成功', API_CODE_SUCCESS);
|
||||
}else{
|
||||
} else {
|
||||
throw new Exception('创建失败', ERR_PARAMS_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
//修改客户
|
||||
protected function put(){
|
||||
protected function put()
|
||||
{
|
||||
$uid = $this->session['uid'];
|
||||
|
||||
$id = $this->input_param('id');
|
||||
$status = $this->input_param('status');
|
||||
$status = $this->input_param('status');
|
||||
$t_num = $this->input_param('t_num');
|
||||
$a_num = $this->input_param('a_num');
|
||||
$is_top = $this->input_param('is_top');
|
||||
$defeat_reason = $this->input_param('defeat_reason');
|
||||
|
||||
$row = $this->customers_model->get(['id'=>$id]);
|
||||
if(!$row){
|
||||
$row = $this->customers_model->get(['id' => $id]);
|
||||
if (!$row) {
|
||||
throw new Exception('数据不存在', ERR_PARAMS_ERROR);
|
||||
}
|
||||
$log = '';
|
||||
$up_data = [];
|
||||
//变成到店
|
||||
if(!$row['admin_id'] && $status==1){
|
||||
if (!$row['admin_id'] && $status == 1) {
|
||||
$up_data['admin_id'] = $uid;
|
||||
}
|
||||
if($row['admin_id']!=$uid){
|
||||
if ($row['admin_id'] != $uid) {
|
||||
throw new Exception('无法操作该客户', ERR_PARAMS_ERROR);
|
||||
}
|
||||
|
||||
strlen($status) && $up_data['status'] = $status;
|
||||
if ($status == 3) {
|
||||
if (!$defeat_reason) {
|
||||
throw new Exception('请输入战败理由', ERR_PARAMS_ERROR);
|
||||
}
|
||||
$defeat_time = date("Y-m-d H:i:s");
|
||||
$jsondata = $row['jsondata'] ? json_decode($row['jsondata'], true) : array();
|
||||
$jsondata['defeat']['time'] = $defeat_time;
|
||||
$jsondata['defeat']['reason'] = $defeat_reason;
|
||||
$up_data['defeat_time'] = strtotime($defeat_time);
|
||||
$up_data['jsondata'] = json_encode($jsondata, JSON_UNESCAPED_UNICODE);
|
||||
$log = '申请战败:' . $defeat_reason;
|
||||
} else {
|
||||
if (strlen($status)) { //变更状态
|
||||
$up_data['status'] = $status;
|
||||
$status_name = $this->customers_model->get_status();
|
||||
$log = '状态变更为' . $status_name[$status];
|
||||
}
|
||||
}
|
||||
strlen($is_top) && $up_data['is_top'] = $is_top;
|
||||
$t_num && $up_data['t_num = t_num+1'] = null;
|
||||
$a_num && $up_data['a_num = a_num+1'] = null;
|
||||
$result = true;
|
||||
if($up_data){
|
||||
$status==1 && $up_data['cont_time'] = date('Y-m-d H:i:s'); //修改到店状态修改最后联系时间
|
||||
if(($status==1 || $a_num) && $row['dt_time'] == '0000-00-00 00:00:00'){//首次到店时间
|
||||
if ($up_data) {
|
||||
$status == 1 && $up_data['cont_time'] = date('Y-m-d H:i:s'); //修改到店状态修改最后联系时间
|
||||
if (($status == 1 || $a_num) && $row['dt_time'] == '0000-00-00 00:00:00') {//首次到店时间
|
||||
$up_data['dt_time'] = date('Y-m-d H:i:s');
|
||||
}
|
||||
$result = $this->customers_model->update($up_data,['id'=>$id]);
|
||||
if($result){ //添加日志
|
||||
$result = $this->customers_model->update($up_data, ['id' => $id]);
|
||||
if ($result) { //添加日志
|
||||
$this->load->library('receiver/customers_entity');
|
||||
$log = '';
|
||||
if(strlen($status)){ //变更状态
|
||||
$status_name = $this->customers_model->get_status();
|
||||
$log .= '状态变更为'.$status_name[$status];
|
||||
}
|
||||
if($t_num){
|
||||
if ($t_num) {
|
||||
$msg = '试驾+1';
|
||||
$log = $log ? $log.','.$msg : $msg;
|
||||
$log = $log ? $log . ',' . $msg : $msg;
|
||||
}
|
||||
if($a_num){
|
||||
if ($a_num) {
|
||||
$msg = '到店+1';
|
||||
$log = $log ? $log.','.$msg : $msg;
|
||||
$log = $log ? $log . ',' . $msg : $msg;
|
||||
}
|
||||
$this->customers_entity->add_log($id,$uid,$this->session['uname'],$log);
|
||||
$this->customers_entity->add_log($id, $uid, $this->session['uname'], $log);
|
||||
}
|
||||
}
|
||||
if($result){
|
||||
if ($result) {
|
||||
throw new Exception('修改成功', API_CODE_SUCCESS);
|
||||
}else{
|
||||
} else {
|
||||
throw new Exception('修改失败', ERR_PARAMS_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
//订单列表头部
|
||||
protected function get_tabs(){
|
||||
protected function get_tabs()
|
||||
{
|
||||
$rows = $this->customers_model->get_status();
|
||||
$lists = [];
|
||||
if($rows){
|
||||
foreach($rows as $key=>$val){
|
||||
if($key!=-1){
|
||||
if ($rows) {
|
||||
foreach ($rows as $key => $val) {
|
||||
if ($key != -1) {
|
||||
$lists[] = [
|
||||
'key' => $key,
|
||||
'name' => $val
|
||||
@@ -313,20 +340,26 @@ class Customers extends Wxapp{
|
||||
}
|
||||
|
||||
//获取筛选条件
|
||||
protected function get_filter(){
|
||||
protected function get_filter()
|
||||
{
|
||||
$level = $this->customers_model->get_sdata('level');
|
||||
$cfrom = $this->customers_model->get_sdata();
|
||||
$buy_time = $this->customers_model->get_sdata('btime');
|
||||
$data = [
|
||||
'level' => $level,
|
||||
'cfrom' => $cfrom,
|
||||
'buy_time' => $buy_time
|
||||
'buy_time' => $buy_time
|
||||
];
|
||||
return $data;
|
||||
}
|
||||
|
||||
//获取客户列表
|
||||
private function lists(){
|
||||
private function lists()
|
||||
{
|
||||
$visit = $this->input_param('visit');
|
||||
if ($visit) {//待回访客户
|
||||
return $this->visit_lists($this->input_param());
|
||||
}
|
||||
$uid = $this->session['uid'];
|
||||
$group_id = $this->session['group_id'];
|
||||
$biz_id = $this->session['new_biz_id'] ? $this->session['new_biz_id'] : intval($this->session['biz_id']);
|
||||
@@ -348,18 +381,19 @@ class Customers extends Wxapp{
|
||||
$ismy = $this->input_param('ismy'); //是否只显示自己
|
||||
$name = $this->input_param('name');
|
||||
$mobile = $this->input_param('mobile');
|
||||
$cf_clues = $this->input_param('cf_clues');//线索来源
|
||||
|
||||
!$page && $page = 1;
|
||||
!$size && $size = 10;
|
||||
|
||||
if($o_type==1){ //创建时间排序
|
||||
if ($o_type == 1) { //创建时间排序
|
||||
$orderby = 'c_time desc';
|
||||
}elseif($o_type==2){//最近联系
|
||||
} elseif ($o_type == 2) {//最近联系
|
||||
$orderby = 'cont_time desc';
|
||||
}else{ //特别关注
|
||||
if($group_id==1){
|
||||
} else { //特别关注
|
||||
if ($group_id == 1) {
|
||||
$orderby = 'is_top desc,c_time desc';
|
||||
}else{
|
||||
} else {
|
||||
$orderby = 'c_time desc';
|
||||
}
|
||||
}
|
||||
@@ -369,21 +403,21 @@ class Customers extends Wxapp{
|
||||
'status>=' => 0
|
||||
];
|
||||
|
||||
if($group_id==1 || $ismy){
|
||||
if ($group_id == 1 || $ismy) {
|
||||
$where["admin_id"] = $uid;
|
||||
}
|
||||
if($group_id == 4 && $biz_id!=1){
|
||||
if ($group_id == 4 && $biz_id != 1) {
|
||||
$where['brand_id!='] = 3; //渠道经理过滤
|
||||
}
|
||||
if($s_time && $e_time){
|
||||
if ($s_time && $e_time) {
|
||||
$where['c_time >='] = strtotime($s_time);
|
||||
$where['c_time <='] = strtotime(date('Y-m-d 23:59:59',strtotime($e_time)));
|
||||
$where['c_time <='] = strtotime(date('Y-m-d 23:59:59', strtotime($e_time)));
|
||||
}
|
||||
|
||||
if(strlen($iscall)){
|
||||
if($iscall){
|
||||
if (strlen($iscall)) {
|
||||
if ($iscall) {
|
||||
$where['cont_time!='] = '0000-00-00 00:00:00';
|
||||
}else{
|
||||
} else {
|
||||
$where['cont_time'] = '0000-00-00 00:00:00';
|
||||
}
|
||||
}
|
||||
@@ -395,46 +429,53 @@ class Customers extends Wxapp{
|
||||
$cfrom && $where['cf_title'] = $cfrom;
|
||||
$name && $where['name'] = $name;
|
||||
$mobile && $where['mobile'] = $mobile;
|
||||
$count = $this->customers_model->count($where);
|
||||
$cf_clues && $where['cf_clues'] = $cf_clues;
|
||||
|
||||
$count = $this->customers_model->count($where);
|
||||
$lists = [];
|
||||
if($count){
|
||||
$fileds = 'id,name,admin_id,mobile,level,car_json,is_top,cf_title,brand_id,s_id,cont_time,c_time';
|
||||
$rows = $this->customers_model->select($where,$orderby,$page,$size,$fileds);
|
||||
if ($count) {
|
||||
$fileds = 'id,name,admin_id,mobile,level,car_json,is_top,cf_title,brand_id,s_id,cont_time,c_time,defeat_time';
|
||||
$rows = $this->customers_model->select($where, $orderby, $page, $size, $fileds);
|
||||
//获取管理员
|
||||
$admin_arr = array_unique(array_column($rows,'admin_id'));
|
||||
$admin_ids = implode(',',$admin_arr);
|
||||
$admin_arr = array_unique(array_column($rows, 'admin_id'));
|
||||
$admin_ids = implode(',', $admin_arr);
|
||||
$admins = [];
|
||||
if($admin_ids){
|
||||
if ($admin_ids) {
|
||||
$where = [
|
||||
"id in ({$admin_ids})" => null
|
||||
];
|
||||
$admins = $this->app_user_model->map('id','',$where,'','','','id,uname');
|
||||
$admins = $this->app_user_model->map('id', '', $where, '', '', '', 'id,uname');
|
||||
}
|
||||
|
||||
//品牌车型
|
||||
$brand_arr = array_unique(array_column($rows,'brand_id'));
|
||||
$brands = $this->auto_brand_model->get_map_by_ids($brand_arr,'id,name');
|
||||
$brand_arr = array_unique(array_column($rows, 'brand_id'));
|
||||
$brands = $this->auto_brand_model->get_map_by_ids($brand_arr, 'id,name');
|
||||
//车系车型
|
||||
$series_arr = array_unique(array_column($rows,'s_id'));
|
||||
$series = $this->auto_series_model->get_map_by_ids($series_arr,'id,name');
|
||||
|
||||
foreach($rows as $key => $val){
|
||||
$car_json = json_decode($val['car_json'],true);
|
||||
$series_arr = array_unique(array_column($rows, 's_id'));
|
||||
$series = $this->auto_series_model->get_map_by_ids($series_arr, 'id,name');
|
||||
|
||||
foreach ($rows as $key => $val) {
|
||||
$car_json = json_decode($val['car_json'], true);
|
||||
$color = isset($car_json['color']) ? $car_json['color']['title'] : '';
|
||||
$version = isset($car_json['version']) ? $car_json['version']['title'] : '';
|
||||
|
||||
$brand_name = isset($brands[$val['brand_id']]) ? $brands[$val['brand_id']][0]['name'] : '';
|
||||
$serie_name = isset($series[$val['s_id']]) ? $series[$val['s_id']][0]['name'] : '';
|
||||
$other_data = [
|
||||
'品牌车型' => $brand_name.$serie_name,
|
||||
'颜色型号' => $color.'-'.$version,
|
||||
'建卡时间' => date('Y-m-d',$val['c_time']),
|
||||
'品牌车型' => $brand_name . $serie_name,
|
||||
'颜色型号' => $color . '-' . $version,
|
||||
'建卡时间' => 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'].'级用户'];
|
||||
$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['defeat_time'] > 0) {
|
||||
$defeat = '战败申请中';
|
||||
} else if ($val['defeat_time'] == -1) {
|
||||
$defeat = '再战';
|
||||
}
|
||||
$lists[] = [
|
||||
'id' => $val['id'],
|
||||
'name' => $val['name'],
|
||||
@@ -442,7 +483,8 @@ class Customers extends Wxapp{
|
||||
'complete_mobile' => $val['mobile'],
|
||||
'is_top' => $val['is_top'],
|
||||
'other_data' => $other_data,
|
||||
'tags' => $tags
|
||||
'tags' => $tags,
|
||||
'defeat' => $defeat
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -452,14 +494,16 @@ class Customers extends Wxapp{
|
||||
];
|
||||
return $data;
|
||||
}
|
||||
|
||||
//派单给店员
|
||||
protected function put_admins(){
|
||||
protected function put_admins()
|
||||
{
|
||||
$uname = $this->session['uname'];
|
||||
$uid = $this->session['uid'];
|
||||
$id_arr = $this->input_param('ids');
|
||||
$admin_id = $this->input_param('admin_id');
|
||||
|
||||
$admin = $this->app_user_model->get(['id'=>$admin_id,'status'=>1]);
|
||||
$admin = $this->app_user_model->get(['id' => $admin_id, 'status' => 1]);
|
||||
if (!$id_arr || !$admin) {
|
||||
throw new Hd_exception('参数错误', API_CODE_INVILD_PARAM);
|
||||
}
|
||||
@@ -472,11 +516,166 @@ class Customers extends Wxapp{
|
||||
}
|
||||
//写日志
|
||||
$this->load->library('receiver/customers_entity');
|
||||
$customers = $this->customers_model->get_map_by_ids ($id_arr,'id,rid');
|
||||
foreach($id_arr as $val){
|
||||
$customers = $this->customers_model->get_map_by_ids($id_arr, 'id,rid');
|
||||
foreach ($id_arr as $val) {
|
||||
$log = "分配客户";
|
||||
$this->customers_entity->add_log($val,$uid,$uname,$log);
|
||||
$this->customers_entity->add_log($val, $uid, $uname, $log);
|
||||
}
|
||||
throw new Exception('分配成功', API_CODE_SUCCESS);
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes:待回访客户列表
|
||||
* Created on: 2021/10/21 14:27
|
||||
* Created by: dengbw
|
||||
* @param array $params
|
||||
* @return array
|
||||
*/
|
||||
private function visit_lists($params = array())
|
||||
{
|
||||
$biz_id = $this->session['new_biz_id'] ? $this->session['new_biz_id'] : intval($this->session['biz_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.admin_id' => $this->session['uid'], 'b.contact=' => 1, 'b.status=' => 1);
|
||||
$count = $this->mdCustomersVisit->count_visit($where);
|
||||
$lists = [];
|
||||
if ($count) {
|
||||
$fileds = 'a.id,a.name,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.defeat_time';
|
||||
$rows = $this->mdCustomersVisit->select_visit($where, 'a.id desc', $page, $size, $fileds);
|
||||
//品牌车型
|
||||
$brand_arr = array_unique(array_column($rows, 'brand_id'));
|
||||
$brands = $this->auto_brand_model->get_map_by_ids($brand_arr, 'id,name');
|
||||
//车系车型
|
||||
$series_arr = array_unique(array_column($rows, 's_id'));
|
||||
$series = $this->auto_series_model->get_map_by_ids($series_arr, 'id,name');
|
||||
foreach ($rows as $key => $val) {
|
||||
$car_json = json_decode($val['car_json'], true);
|
||||
$color = isset($car_json['color']) ? $car_json['color']['title'] : '';
|
||||
$version = isset($car_json['version']) ? $car_json['version']['title'] : '';
|
||||
$brand_name = isset($brands[$val['brand_id']]) ? $brands[$val['brand_id']][0]['name'] : '';
|
||||
$serie_name = isset($series[$val['s_id']]) ? $series[$val['s_id']][0]['name'] : '';
|
||||
$other_data = [
|
||||
'品牌车型' => $brand_name . $serie_name,
|
||||
'颜色型号' => $color . '-' . $version,
|
||||
'建卡时间' => date('Y-m-d', $val['c_time']),
|
||||
'客户来源' => $val['cf_title'],
|
||||
'销售顾问' => $this->session['uname'] ? $this->session['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['defeat_time'] > 0) {
|
||||
$defeat = '战败申请中';
|
||||
} else if ($val['defeat_time'] == -1) {
|
||||
$defeat = '再战';
|
||||
}
|
||||
$lists[] = [
|
||||
'id' => $val['id'],
|
||||
'name' => $val['name'],
|
||||
'mobile' => mobile_asterisk($val['mobile']),
|
||||
'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
|
||||
* Created by: dengbw
|
||||
* @return array
|
||||
* @throws Hd_exception
|
||||
*/
|
||||
protected function get_defeats()
|
||||
{
|
||||
$group_id = $this->session['group_id'];
|
||||
if ($group_id == 1) {
|
||||
return $data = ['list' => [], 'total' => 0];
|
||||
}
|
||||
$params = $this->input_param();
|
||||
$page = $params['page'];
|
||||
$size = $params['size'];
|
||||
!$page && $page = 1;
|
||||
!$size && $size = 10;
|
||||
$biz_id = $this->session['new_biz_id'] ? $this->session['new_biz_id'] : intval($this->session['biz_id']);
|
||||
$where = array('biz_id' => $biz_id, 'defeat_time >' => 0, 'status>' => -1);
|
||||
$count = $this->customers_model->count($where);
|
||||
$lists = [];
|
||||
if ($count) {
|
||||
$fileds = 'id,name,mobile,jsondata';
|
||||
$rows = $this->customers_model->select($where, 'id desc', $page, $size, $fileds);
|
||||
foreach ($rows as $key => $val) {
|
||||
$jsondata = $val['jsondata'] ? json_decode($val['jsondata'], true) : array();
|
||||
$reason = $jsondata['defeat']['reason'] ? '战败理由:' . $jsondata['defeat']['reason'] : '';
|
||||
$lists[] = [
|
||||
'id' => $val['id'],
|
||||
'name' => $val['name'],
|
||||
'mobile' => mobile_asterisk($val['mobile']),
|
||||
'reason' => $reason,
|
||||
];
|
||||
}
|
||||
}
|
||||
$data = [
|
||||
'list' => $lists,
|
||||
'total' => $count
|
||||
];
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes:通过战败申请
|
||||
* Created on: 2021/10/21 16:19
|
||||
* Created by: dengbw
|
||||
* @throws Exception
|
||||
*/
|
||||
protected function put_defeats()
|
||||
{
|
||||
$group_id = $this->session['group_id'];
|
||||
if ($group_id == 1) {
|
||||
throw new Exception('无操作权限', ERR_PARAMS_ERROR);
|
||||
}
|
||||
$params = $this->input_param();
|
||||
$id = intval($params['id']);
|
||||
$type = intval($params['type']);
|
||||
if (!$id) {
|
||||
throw new Exception('参数错误', ERR_PARAMS_ERROR);
|
||||
}
|
||||
$row = $this->customers_model->get(array('id' => $id));
|
||||
if (!$row) {
|
||||
throw new Exception('用户不存在', ERR_PARAMS_ERROR);
|
||||
}
|
||||
if (!$row['defeat_time']) {
|
||||
throw new Exception('未申请战败', ERR_PARAMS_ERROR);
|
||||
}
|
||||
$jsondata = $row['jsondata'] ? json_decode($row['jsondata'], true) : array();
|
||||
if ($type == 1) {
|
||||
$log = '拒绝战败申请';
|
||||
$update['defeat_time'] = -1;//再战
|
||||
} else {
|
||||
$jsondata['defeat']['pass_time'] = date("Y-m-d H:i:s");
|
||||
$update['status'] = 3;
|
||||
$log = '通过战败申请';
|
||||
$update['defeat_time'] = 0;
|
||||
}
|
||||
$update['jsondata'] = json_encode($jsondata, JSON_UNESCAPED_UNICODE);
|
||||
$ret = $this->customers_model->update($update, ['id' => $id]);
|
||||
if ($ret) {
|
||||
$this->load->library('receiver/customers_entity');
|
||||
$this->customers_entity->add_log($id, $this->session['uid'], $this->session['uname'], $log);
|
||||
throw new Exception('操作成功', API_CODE_SUCCESS);
|
||||
}
|
||||
throw new Exception('操作失败', ERR_PARAMS_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,17 +7,20 @@ defined('WXAPP_APP') OR exit('No direct script access allowed');
|
||||
* Date: 2021.06.23
|
||||
* Time: 14:08
|
||||
*/
|
||||
require_once APPPATH.'controllers/wxapp/Wxapp.php';
|
||||
class User extends Wxapp{
|
||||
require_once APPPATH . 'controllers/wxapp/Wxapp.php';
|
||||
|
||||
function __construct($inputs, $app_key){
|
||||
class User extends Wxapp
|
||||
{
|
||||
|
||||
function __construct($inputs, $app_key)
|
||||
{
|
||||
parent::__construct($inputs, $app_key);
|
||||
|
||||
$this->login_white = array('get_ukey');//登录白名单
|
||||
$this->majia_white = array('get_ukey', 'get');//超级管理员披上马甲可操作权限
|
||||
$this->check_status = array();//用户状态校验
|
||||
$this->check_mobile = array();//需要手机号
|
||||
$this->check_headimg =array();//授权微信信息
|
||||
$this->check_headimg = array();//授权微信信息
|
||||
|
||||
$this->load->model("biz/biz_model");
|
||||
$this->load->model('auto/auto_brand_model');
|
||||
@@ -28,53 +31,54 @@ class User extends Wxapp{
|
||||
* @return array
|
||||
* @throws Exception
|
||||
*/
|
||||
protected function get_ukey(){
|
||||
protected function get_ukey()
|
||||
{
|
||||
$code = $this->input_param('code');
|
||||
$mobile = $this->input_param('mobile');
|
||||
$sms_code = $this->input_param('sms_code');
|
||||
|
||||
if(!$code||!$mobile||!$sms_code){
|
||||
if (!$code || !$mobile || !$sms_code) {
|
||||
throw new Exception('参数错误', API_CODE_INVILD_PARAM);
|
||||
}
|
||||
//判断验证码
|
||||
if($mobile!='15359333655'){//测试号码
|
||||
if ($mobile != '15359333655') {//测试号码
|
||||
$mc = &load_cache();
|
||||
$key = "licheb_login_code_".$mobile;
|
||||
$key = "licheb_login_code_" . $mobile;
|
||||
$cache_code = $mc->get($key);
|
||||
if($sms_code!=$cache_code){
|
||||
if ($sms_code != $cache_code) {
|
||||
throw new Exception('验证码错误', API_CODE_FAIL);
|
||||
}
|
||||
}
|
||||
$user = $this->app_user_model->get(['mobile'=>$mobile,'status>'=> -1]);
|
||||
if(!$user){
|
||||
$user = $this->app_user_model->get(['mobile' => $mobile, 'status>' => -1]);
|
||||
if (!$user) {
|
||||
throw new Exception('用户不存在', API_CODE_FAIL);
|
||||
}
|
||||
if(!$user['status']){
|
||||
if (!$user['status']) {
|
||||
throw new Exception('该账号已停用', API_CODE_FAIL);
|
||||
}
|
||||
//判断门店是否存在
|
||||
if($user['group_id']<4){
|
||||
if ($user['group_id'] < 4) {
|
||||
$biz_id = intval($user['biz_id']);
|
||||
$biz = $this->biz_model->get(['id'=>$biz_id,'status'=>1]);
|
||||
if(!$biz){
|
||||
$biz = $this->biz_model->get(['id' => $biz_id, 'status' => 1]);
|
||||
if (!$biz) {
|
||||
throw new Exception('门店不存在', API_CODE_FAIL);
|
||||
}
|
||||
}
|
||||
$session = $this->wx_session($code);
|
||||
//print_r($session);
|
||||
if(!$session['session_key']){
|
||||
if (!$session['session_key']) {
|
||||
throw new Exception('登录失败', API_CODE_FAIL);
|
||||
}
|
||||
|
||||
|
||||
$uid = $user['id'];
|
||||
if(!$user['openid']){ //未绑定微信
|
||||
if (!$user['openid']) { //未绑定微信
|
||||
$upd = [
|
||||
'openid' => $session['openid']
|
||||
];
|
||||
$session['unionid'] && $upd['unionid'] = $session['unionid'];
|
||||
$ret = $this->app_user_model->update($upd, array('id' => $uid));
|
||||
if(!$ret){
|
||||
debug_log("[error]# code:{$code}; ".$this->app_user_model->db->last_query(), __FUNCTION__, $this->log_dir);
|
||||
if (!$ret) {
|
||||
debug_log("[error]# code:{$code}; " . $this->app_user_model->db->last_query(), __FUNCTION__, $this->log_dir);
|
||||
throw new Exception('授权用户信息失败', API_CODE_FAIL);
|
||||
}
|
||||
}
|
||||
@@ -89,20 +93,21 @@ class User extends Wxapp{
|
||||
* 用户信息
|
||||
* @return array
|
||||
*/
|
||||
protected function get(){
|
||||
protected function get()
|
||||
{
|
||||
$uid = $this->session['uid'];
|
||||
$biz_id = $this->session['new_biz_id'] ? $this->session['new_biz_id'] : intval($this->session['biz_id']);
|
||||
|
||||
$user = $this->app_user_model->get(array('id' => $uid));
|
||||
//获取所属店铺字段
|
||||
$biz = $this->biz_model->get(['id'=>$biz_id,'status'=>1],'biz_name');
|
||||
$biz = $this->biz_model->get(['id' => $biz_id, 'status' => 1], 'biz_name');
|
||||
//判断门店是否存在
|
||||
if(!$biz && $this->session['group_id']<4){
|
||||
if (!$biz && $this->session['group_id'] < 4) {
|
||||
$this->logout();
|
||||
throw new Exception('门店不存在', API_CODE_FAIL);
|
||||
}
|
||||
$group_arr = $this->app_user_model->get_group();
|
||||
|
||||
|
||||
$group_name = $group_arr[$user['group_id']] ? $group_arr[$user['group_id']] : '';
|
||||
|
||||
//获取拨打电话
|
||||
@@ -129,54 +134,50 @@ class User extends Wxapp{
|
||||
/**
|
||||
* 统计数据
|
||||
*/
|
||||
protected function get_cal(){
|
||||
protected function get_cal()
|
||||
{
|
||||
$uid = $this->session['uid'];
|
||||
$biz_id = $this->session['new_biz_id'] ? $this->session['new_biz_id'] : intval($this->session['biz_id']);
|
||||
$group_id = $this->session['group_id'];
|
||||
$this->load->model('receiver/receiver_customers_model','customers_model');
|
||||
$this->load->model('receiver/order/receiver_orders_model','orders_model');
|
||||
$this->load->model('receiver/order/receiver_order_signs_model','order_signs_model');
|
||||
$this->load->model('receiver/receiver_customers_model', 'customers_model');
|
||||
$this->load->model('receiver/order/receiver_orders_model', 'orders_model');
|
||||
$this->load->model('receiver/order/receiver_order_signs_model', 'order_signs_model');
|
||||
$this->load->model('receiver/receiver_customers_visit_model', 'mdCustomersVisit');
|
||||
$where = [
|
||||
"cont_time = '0000-00-00 00:00:00'"=>null,
|
||||
'biz_id'=>$biz_id
|
||||
"cont_time = '0000-00-00 00:00:00'" => null,
|
||||
'biz_id' => $biz_id
|
||||
];
|
||||
$group_id == 1 && $where['admin_id'] = $uid;
|
||||
$group_id == 4 && $where['brand_id!='] = 3; //渠道经理过滤
|
||||
$wl_count = $this->customers_model->count($where);
|
||||
$where = [
|
||||
'status>'=>-1,
|
||||
'is_top'=>1,
|
||||
'biz_id'=>$biz_id
|
||||
'status>' => -1,
|
||||
'is_top' => 1,
|
||||
'biz_id' => $biz_id
|
||||
];
|
||||
$group_id == 1 && $where['admin_id'] = $uid;
|
||||
$group_id == 4 && $where['brand_id!='] = 3; //渠道经理过滤
|
||||
$gz_count = $this->customers_model->count($where);
|
||||
$where = [
|
||||
'status'=>0,
|
||||
'biz_id'=>$biz_id
|
||||
'status' => 0,
|
||||
'biz_id' => $biz_id
|
||||
];
|
||||
$group_id == 1 && $where['admin_id'] = $uid;
|
||||
$group_id == 4 && $where['brand_id!='] = 3; //渠道经理过滤
|
||||
$sign_count = $this->orders_model->count($where);
|
||||
$where = [
|
||||
'status'=>1,
|
||||
'biz_id'=>$biz_id
|
||||
'status' => 1,
|
||||
'biz_id' => $biz_id
|
||||
];
|
||||
$group_id == 1 && $where['admin_id'] = $uid;
|
||||
$group_id == 4 && $where['brand_id!='] = 3; //渠道经理过滤
|
||||
$loan_count = $this->orders_model->count($where);
|
||||
//未派单客户
|
||||
$where = [
|
||||
'admin_id' => 0,
|
||||
'biz_id' => $biz_id
|
||||
];
|
||||
$group_id == 4 && $where['brand_id!='] = 3; //渠道经理过滤
|
||||
$unuse_count = $this->customers_model->count($where);
|
||||
|
||||
//为创建订单客户
|
||||
$where = [
|
||||
'lc_receiver_customers.status'=>2,
|
||||
'lc_receiver_customers.biz_id'=>$biz_id,
|
||||
'lc_receiver_orders.id is null'=>null
|
||||
'lc_receiver_customers.status' => 2,
|
||||
'lc_receiver_customers.biz_id' => $biz_id,
|
||||
'lc_receiver_orders.id is null' => null
|
||||
];
|
||||
$group_id == 1 && $where['lc_receiver_customers.admin_id'] = $uid;
|
||||
$group_id == 4 && $where['lc_receiver_customers.brand_id!='] = 3; //渠道经理过滤
|
||||
@@ -184,7 +185,7 @@ class User extends Wxapp{
|
||||
$t1 = 'lc_receiver_order_signs';
|
||||
$t2 = 'lc_receiver_orders';
|
||||
$where = [
|
||||
"status"=>0,
|
||||
"status" => 0,
|
||||
"biz_id" => $biz_id
|
||||
];
|
||||
$group_id == 1 && $where["admin_id"] = $uid;
|
||||
@@ -198,33 +199,51 @@ class User extends Wxapp{
|
||||
//$group_id == 4 && $where['brand_id!='] = 3; //渠道经理过滤
|
||||
//$loan_count = $this->orders_model->count($where);//未选择分期
|
||||
$where = [
|
||||
"status"=>3,
|
||||
"status" => 3,
|
||||
"biz_id" => $biz_id
|
||||
];
|
||||
$group_id == 1 && $where["admin_id"] = $uid;
|
||||
$group_id == 4 && $where['brand_id!='] = 3; //渠道经理过滤
|
||||
$bill_count = $this->orders_model->count($where);//开票相关
|
||||
$where = [
|
||||
"status"=>5,
|
||||
"status" => 5,
|
||||
"biz_id" => $biz_id
|
||||
];
|
||||
$group_id == 1 && $where["admin_id"] = $uid;
|
||||
$group_id == 4 && $where['brand_id!='] = 3; //渠道经理过滤
|
||||
$del_count = $this->orders_model->count($where);//交付确认
|
||||
$deallist = [
|
||||
['title'=>'登记订单','icon'=>'icon-dengji','total'=>$uncre_count,'page'=>'/pages/order/register/index'],
|
||||
['title'=>'需邀请签名','icon'=>'icon-qianming1','total'=>$need_sign,'page'=>'/pages/order/filterList/index?key=0&ismy=1'],
|
||||
['title' => '登记订单', 'icon' => 'icon-dengji', 'total' => $uncre_count, 'page' => '/pages/order/register/index'],
|
||||
['title' => '需邀请签名', 'icon' => 'icon-qianming1', 'total' => $need_sign, 'page' => '/pages/order/filterList/index?key=0&ismy=1'],
|
||||
//['title'=>'未选择分期','icon'=>'icon-fenpei','total'=>$loan_count,'page'=>'/pages/order/filterList/index?key=1&ismy=1'],
|
||||
['title'=>'开票相关','icon'=>'icon-kaipiao1','total'=>$bill_count,'page'=>'/pages/order/filterList/index?key=3&ismy=1'],
|
||||
['title'=>'交付确认','icon'=>'icon-jiaofu','total'=>$del_count,'page'=>'/pages/order/filterList/index?key=5&ismy=1'],
|
||||
['title' => '开票相关', 'icon' => 'icon-kaipiao1', 'total' => $bill_count, 'page' => '/pages/order/filterList/index?key=3&ismy=1'],
|
||||
['title' => '交付确认', 'icon' => 'icon-jiaofu', 'total' => $del_count, 'page' => '/pages/order/filterList/index?key=5&ismy=1'],
|
||||
];
|
||||
//客户代办事项
|
||||
$visit_count = $this->mdCustomersVisit->count_visit(array('a.biz_id' => $biz_id, 'a.admin_id' => $uid, 'b.contact=' => 1, 'b.status=' => 1));
|
||||
if ($group_id == 1) {
|
||||
$customer_op_list = [
|
||||
['title' => '待回访客户(人)', 'icon' => 'icon-dengji', 'total' => $visit_count, 'page' => '/pages/customer/filterList/index?visit=1&title=待回访客户'],
|
||||
];
|
||||
} else {
|
||||
//未派单客户
|
||||
$where = ['admin_id' => 0, 'biz_id' => $biz_id];
|
||||
$group_id == 4 && $where['brand_id!='] = 3; //渠道经理过滤
|
||||
$unuse_count = $this->customers_model->count($where);
|
||||
$defeat_count = $this->customers_model->count(array('biz_id' => $biz_id, 'defeat_time >' => 0, 'status>' => -1));
|
||||
$customer_op_list = [
|
||||
['title' => '待分配客户(人)', 'icon' => 'icon-daifenpei', 'total' => $unuse_count, 'page' => '/pages/customer/allot/index'],
|
||||
['title' => '待回访客户(人)', 'icon' => 'icon-statistics-custom-4', 'total' => $visit_count, 'page' => '/pages/customer/filterList/index?visit=1&title=待回访客户'],
|
||||
['title' => '战败客户(人)', 'icon' => 'icon-statistics-custom-5', 'total' => $defeat_count, 'page' => '/pages/customer/optDefeat/index'],
|
||||
];
|
||||
}
|
||||
$data = [
|
||||
'wl_count' => $wl_count,
|
||||
'gz_count' => $gz_count,
|
||||
'sign_count' => $sign_count,
|
||||
'loan_count' => $loan_count,
|
||||
'unuse_count' => $unuse_count,
|
||||
'deallist' => $deallist
|
||||
'deallist' => $deallist,
|
||||
'customer_op_list' => $customer_op_list,
|
||||
];
|
||||
return $data;
|
||||
}
|
||||
@@ -256,36 +275,37 @@ class User extends Wxapp{
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取门店信息
|
||||
* @return array
|
||||
*/
|
||||
protected function get_bizs(){
|
||||
protected function get_bizs()
|
||||
{
|
||||
$city_id = $this->input_param('city_id');
|
||||
$lists = [];
|
||||
|
||||
$biz_id_arr = explode(',',$this->session['biz_id']);
|
||||
|
||||
$biz_id_arr = explode(',', $this->session['biz_id']);
|
||||
$fileds = 'id,biz_name,jsondata';
|
||||
if($this->session['biz_id'] && $biz_id_arr){
|
||||
$city_id && $o_where = ['city_id'=>$city_id];
|
||||
$bizs = $this->biz_model->get_by_id_arr($biz_id_arr,$o_where,$fileds);
|
||||
}else{
|
||||
$bizs = $this->biz_model->select(['status'=>1,'city_id'=>$city_id],'id desc','','',$fileds);
|
||||
if ($this->session['biz_id'] && $biz_id_arr) {
|
||||
$city_id && $o_where = ['city_id' => $city_id];
|
||||
$bizs = $this->biz_model->get_by_id_arr($biz_id_arr, $o_where, $fileds);
|
||||
} else {
|
||||
$bizs = $this->biz_model->select(['status' => 1, 'city_id' => $city_id], 'id desc', '', '', $fileds);
|
||||
}
|
||||
if($bizs){
|
||||
foreach($bizs as $key => $val){
|
||||
if ($bizs) {
|
||||
foreach ($bizs as $key => $val) {
|
||||
$auto_brands = [];
|
||||
$jsondata = json_decode($val['jsondata'],true);
|
||||
$jsondata = json_decode($val['jsondata'], true);
|
||||
$auto_brands_arr = $jsondata['auto_brands'];
|
||||
$brand_ids = implode(',',$auto_brands_arr);
|
||||
if($auto_brands_arr && $brand_ids){
|
||||
$brand_ids = implode(',', $auto_brands_arr);
|
||||
if ($auto_brands_arr && $brand_ids) {
|
||||
$where = [
|
||||
"id in ($brand_ids)" => null,
|
||||
"id !=" => 3 //过滤狸车品牌
|
||||
];
|
||||
$brands = $this->auto_brand_model->select($where,'',0,0,'name');
|
||||
$auto_brands = array_column($brands,'name');
|
||||
$brands = $this->auto_brand_model->select($where, '', 0, 0, 'name');
|
||||
$auto_brands = array_column($brands, 'name');
|
||||
}
|
||||
$lists[] = [
|
||||
'id' => $val['id'],
|
||||
@@ -300,8 +320,10 @@ class User extends Wxapp{
|
||||
];
|
||||
return $data;
|
||||
}
|
||||
|
||||
//获取门店管理员
|
||||
protected function get_admins(){
|
||||
protected function get_admins()
|
||||
{
|
||||
$biz_id = $this->input_param('biz_id');
|
||||
$page = $this->input_param('page');
|
||||
$size = $this->input_param('size');
|
||||
@@ -314,8 +336,8 @@ class User extends Wxapp{
|
||||
];
|
||||
$lists = [];
|
||||
$count = $this->app_user_model->count($where);
|
||||
if($count){
|
||||
$rows = $this->app_user_model->select($where,'id desc',$page,$size,'id,uname');
|
||||
if ($count) {
|
||||
$rows = $this->app_user_model->select($where, 'id desc', $page, $size, 'id,uname');
|
||||
$lists = $rows;
|
||||
}
|
||||
$data = [
|
||||
@@ -324,17 +346,19 @@ class User extends Wxapp{
|
||||
];
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 重新设置用户session里的biz_id
|
||||
*/
|
||||
protected function put_resetbiz(){
|
||||
protected function put_resetbiz()
|
||||
{
|
||||
$ukey = $this->input_param('ukey');
|
||||
$biz_id = $this->input_param('biz_id');
|
||||
if (!$biz_id) {
|
||||
throw new Hd_Exception('参数错误', API_CODE_INVILD_PARAM);
|
||||
}
|
||||
$this->session['new_biz_id'] = $biz_id;
|
||||
$this->app_redis->save($this->redis_login.$ukey, json_encode($this->session, JSON_UNESCAPED_UNICODE), 30 * 24 * 3600);
|
||||
$this->app_redis->save($this->redis_login . $ukey, json_encode($this->session, JSON_UNESCAPED_UNICODE), 30 * 24 * 3600);
|
||||
throw new Exception('保存成功', API_CODE_SUCCESS);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,10 +12,11 @@ class Receiver_customers_model extends HD_Model
|
||||
{
|
||||
private $table_name = 'lc_receiver_customers';
|
||||
|
||||
private $status_arr = [-1 => '删除',0 => '未见客户',1 => '到店客户',2 => '订单客户',3 => '战败客户'];
|
||||
private $level = ['H','A','B','C','D'];
|
||||
private $cfrom_arr = ['自有资源','平台分配'];
|
||||
private $buy_time = [3,7,15,30];
|
||||
private $status_arr = [-1 => '删除', 0 => '未见客户', 1 => '到店客户', 2 => '订单客户', 3 => '战败客户'];
|
||||
private $level = ['H', 'A', 'B', 'C', 'D'];
|
||||
private $cfrom_arr = ['自有资源', '平台分配', '素材推广'];
|
||||
private $buy_time = [3, 7, 15, 30];
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct($this->table_name, 'default');
|
||||
@@ -40,13 +41,15 @@ class Receiver_customers_model extends HD_Model
|
||||
}
|
||||
return $rows;
|
||||
}
|
||||
|
||||
public function get_status(){
|
||||
return $this->status_arr;
|
||||
|
||||
public function get_status()
|
||||
{
|
||||
return $this->status_arr;
|
||||
}
|
||||
|
||||
public function get_sdata($type='cfrom'){
|
||||
switch($type){
|
||||
|
||||
public function get_sdata($type = 'cfrom')
|
||||
{
|
||||
switch ($type) {
|
||||
case 'cfrom':
|
||||
$result = $this->cfrom_arr;
|
||||
break;
|
||||
@@ -59,18 +62,20 @@ class Receiver_customers_model extends HD_Model
|
||||
default:
|
||||
$result = '';
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function count_order($where){
|
||||
return $this->select_order($where,'','','','',1);
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function select_order($where = array(), $order = '', $page = 0, $page_size = 20 , $fileds = '', $count = 0){
|
||||
public function count_order($where)
|
||||
{
|
||||
return $this->select_order($where, '', '', '', '', 1);
|
||||
}
|
||||
|
||||
public function select_order($where = array(), $order = '', $page = 0, $page_size = 20, $fileds = '', $count = 0)
|
||||
{
|
||||
!$fileds && $fileds = 'lc_receiver_customers.*';
|
||||
$this->db->distinct()->select($fileds);
|
||||
$this->db->from('lc_receiver_customers');
|
||||
$this->db->join('lc_receiver_orders', 'lc_receiver_orders.rid = lc_receiver_customers.id','left');
|
||||
$this->db->join('lc_receiver_orders', 'lc_receiver_orders.rid = lc_receiver_customers.id', 'left');
|
||||
|
||||
if ($where) {
|
||||
$this->db->where($where);
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
/**
|
||||
* Notes:客户待回访
|
||||
* Created on: 2021/10/19 17:15
|
||||
* Created by: dengbw
|
||||
*/
|
||||
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
class Receiver_customers_visit_model extends HD_Model
|
||||
{
|
||||
private $table_name = 'lc_receiver_customer_visit';
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct($this->table_name, 'default');
|
||||
}
|
||||
|
||||
//关联客户待回访
|
||||
public function count_visit($where)
|
||||
{
|
||||
return $this->select_visit($where, '', '', '', '', 1);
|
||||
}
|
||||
|
||||
public function select_visit($where = array(), $order = '', $page = 0, $page_size = 20, $fileds = '', $count = 0)
|
||||
{
|
||||
!$fileds && $fileds = 'a.*';
|
||||
$this->db->select($fileds);
|
||||
$this->db->from('lc_receiver_customers as a');
|
||||
$this->db->join('lc_receiver_customer_visit as b', 'b.c_id = a.id', 'left');
|
||||
if ($where) {
|
||||
$this->db->where($where);
|
||||
}
|
||||
if ($count) {
|
||||
return $this->db->count_all_results();
|
||||
}
|
||||
if ($order) {
|
||||
$this->db->order_by($order);
|
||||
}
|
||||
if ($page) {
|
||||
$offset = ($page - 1) * $page_size;
|
||||
$limit = $page_size;
|
||||
} else {
|
||||
$offset = null;
|
||||
$limit = null;
|
||||
}
|
||||
$this->db->limit($limit, $offset);
|
||||
return $this->db->get()->result_array();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user