136 lines
5.0 KiB
PHP
136 lines
5.0 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_comments_model', 'mdComments');
|
|
$this->load->model('receiver/receiver_yx_model');
|
|
$this->load->model('receiver/receiver_xz_model');
|
|
}
|
|
|
|
protected function get()
|
|
{
|
|
$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, 'id,log,uname,type,c_time,imgs,sub_type,cf_platform');
|
|
foreach ($rows as $key => $val) {
|
|
$record = '';
|
|
$second = 0;
|
|
$content = $val['log'];
|
|
$img_json = json_decode($val['imgs'], true);
|
|
$imgs = [];
|
|
if ($img_json) {
|
|
foreach ($img_json as $val2) {
|
|
$imgs[] = build_qiniu_image_url($val2);
|
|
}
|
|
}
|
|
if ($val['type'] == 2) {
|
|
$content = '拨打电话';
|
|
if ($val['cf_platform'] == 'wxapp') {
|
|
list($rec_url, $rec_text, $duration) = $this->customer_oplogs_model->getRecordUrl($val['id']);
|
|
$rec_url && $record = $rec_url;
|
|
$duration && $second = intval($duration);
|
|
!$duration && $content .= '(未接通)';
|
|
}
|
|
}
|
|
$comments = [];
|
|
$res = $this->mdComments->select(['pid' => $val['id'], 'status' => 1, 'type' => 0], 'id asc', 0, 0
|
|
, 'uname,content');
|
|
foreach ($res as $key2 => $val2) {
|
|
$comments[] = [
|
|
'uname' => $val2['uname'],
|
|
'content' => $val2['content']
|
|
];
|
|
}
|
|
$lists[] = [
|
|
'id' => $val['id'],
|
|
'content' => "【{$val['uname']}】" . $content,
|
|
'record_url' => $record,
|
|
'second' => $second,
|
|
'imgs' => $imgs,
|
|
'comments' => $comments,
|
|
'type_name' => $this->customer_oplogs_model->typeAry($val['type']),
|
|
'c_time' => date('Y.m.d H:i', $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 = trim($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_visit($id, $this->session['uid'], $this->session['uname'], $log, 0, 1, $img_arr);
|
|
if ($result) {
|
|
throw new Exception('修改成功', API_CODE_SUCCESS);
|
|
} else {
|
|
throw new Exception('修改失败', ERR_PARAMS_ERROR);
|
|
}
|
|
}
|
|
}
|