Files
liche/api/controllers/wxapp/licheb/Customerlogs.php
T
2021-08-05 14:40:21 +08:00

109 lines
3.9 KiB
PHP

<?php
defined('WXAPP_APP') OR exit('No direct script access allowed');
/**
* Created by Vim
* User: lcc
* Date: 2021/06/23
* Time: 14:08
*/
require_once APPPATH.'controllers/wxapp/Wxapp.php';
class Customerlogs 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->load->model('receiver/receiver_customers_model','customers_model');
$this->load->model('receiver/receiver_customer_oplogs_model','customer_oplogs_model');
$this->load->model('receiver/receiver_xz_model');
}
protected function get(){
$uid = $this->session['uid'];
$id = $this->input_param('id');
$page = $this->input_param('page');
$size = $this->input_param('size');
!$page && $page = 1;
!$size && $size = 20;
$where = [
'customer_id' => $id
];
$count = $this->customer_oplogs_model->count($where);
$lists = [];
if($count){
$rows = $this->customer_oplogs_model->select($where,'id desc',$page,$size,'log,uname,type,c_time');
foreach($rows as $key => $val){
$record = '';
$second = 0;
$content = $val['log'];
if($val['type']==2){
$rec_row = $this->receiver_xz_model->get(['id'=>$val['log']],'rec_url,duration');
$content = '拨打电话';
!$rec_row['duration'] && $content .= '(未接通)';
$rec_row['rec_url'] && $record = $rec_row['rec_url'];
$rec_row['duration'] && $second = intval($rec_row['duration']/1000);
}
$lists[] = [
'content' => "{$val['uname']}".$content,
'record_url' => $record,
'second' => $second,
'c_time' => date('Y.m.d',$val['c_time'])
];
}
}
$data = [
'list' => $lists,
'total' => $count
];
if($page == 1){ //获取统计数据
$row = $this->customers_model->get(['id'=>$id]);
$statistics = [
[
'name' => '去电',
'val' => $this->customer_oplogs_model->count(['customer_id'=>$id,'type'=>2]),
'color' => '#f3f6fc',
],
[
'name' => '短信',
'val' => $this->customer_oplogs_model->count(['customer_id'=>$id,'type'=>1]),
'color' => '#fffaeb',
],
[
'name' => '到店',
'val' => $row['a_num'],
'color' => '#f1f9f8',
],
[
'name' => '试驾',
'val' => $row['t_num'],
'color' => '#fff6f8',
]
];
$data['statistics'] = $statistics;
}
return $data;
}
protected function post(){
$id = $this->input_param('cus_id');
$log = $this->input_param('content');
$img_arr = $this->input_param('imgs');
if(!$log && !$img_arr){
throw new Exception('参数错误', ERR_PARAMS_ERROR);
}
$this->load->library('receiver/customers_entity');
$result = $this->customers_entity->add_log($id,$this->session['uid'],$this->session['uname'],$log,'','wxapp',$img_arr);
if($result){
throw new Exception('修改成功', API_CODE_SUCCESS);
}else{
throw new Exception('修改失败', ERR_PARAMS_ERROR);
}
}
}