Files
liche/api/controllers/wxapp/licheb/Customerlogs.php
T
2021-07-27 16:14:03 +08:00

83 lines
2.6 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');
}
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){
if($val['type']==2){
$val['log'] = '拨打电话';
}
$lists[] = [
'content' => $val['log'],
'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;
}
}