mirror of
https://gitee.com/zhc02/timely_service.git
synced 2025-06-24 04:01:23 +08:00
后台功能
This commit is contained in:
parent
282988bcdd
commit
db4a8a0b84
@ -8,7 +8,9 @@
|
||||
|
||||
namespace app\admin\controller;
|
||||
|
||||
|
||||
use Logic\KefuLogic;
|
||||
use Logic\Visitor;
|
||||
use Logic\VisitorService;
|
||||
class Index extends Base
|
||||
{
|
||||
public function index(){
|
||||
@ -17,6 +19,40 @@ class Index extends Base
|
||||
}
|
||||
|
||||
public function home(){
|
||||
//获取所有客服数量
|
||||
$kefu_num=KefuLogic::kefuCount();
|
||||
//获取在线客服数量
|
||||
$online_kefu_num=KefuLogic::kefuCount(['online_status'=>1]);
|
||||
//获取当前在线游客数量
|
||||
$online_visitor_num=Visitor::visitorCount(['online_status'=>1]);
|
||||
|
||||
//获取当天的会话次数
|
||||
$service_num=VisitorService::getServiceNum();
|
||||
$days= date('t');
|
||||
$service_num_list=[];
|
||||
for($i=0;$i<$days;$i++){
|
||||
$start_time = strtotime(date('Y-m-01')); //获取本月第一天时间戳
|
||||
$date=date('Y-m-d', $start_time+$i*86400);
|
||||
$endDate=date('Y-m-d 23:59:59',strtotime($date));
|
||||
$where1[]=['create_time','between time',[$date, $endDate]];
|
||||
|
||||
$service_num_list[]=[
|
||||
'date'=>$date,
|
||||
'new_kefu_num'=>KefuLogic::kefuCount($where1),
|
||||
'new_visitor_num'=>Visitor::visitorCount($where1),
|
||||
'add_service_num'=>VisitorService::getServiceNum($date),
|
||||
];
|
||||
}
|
||||
$this->assign([
|
||||
'kefu_num'=>$kefu_num,
|
||||
'online_kefu_num'=>$online_kefu_num,
|
||||
'online_visitor_num'=>$online_visitor_num,
|
||||
'service_num'=>$service_num,
|
||||
'date_list'=>json_encode(array_column($service_num_list,'date')),
|
||||
'new_kefu_num'=>json_encode(array_column($service_num_list,'new_kefu_num')),
|
||||
'new_visitor_num'=>json_encode(array_column($service_num_list,'new_visitor_num')),
|
||||
'add_service_num'=>json_encode(array_column($service_num_list,'add_service_num')),
|
||||
]);
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
|
@ -9,6 +9,7 @@
|
||||
namespace app\admin\controller;
|
||||
|
||||
use Logic\KefuLogic;
|
||||
use think\Validate;
|
||||
class Kefu extends Base
|
||||
{
|
||||
|
||||
@ -19,26 +20,105 @@ class Kefu extends Base
|
||||
*/
|
||||
public function index(){
|
||||
if (request()->isAjax()) {
|
||||
$page = input('param.page');
|
||||
$limit = input('param.limit');
|
||||
$where = [];
|
||||
if (input('param.name')) {
|
||||
$where[] = ['kf_name', '=', input('param.name')];
|
||||
}
|
||||
|
||||
if ( input('param.status') == 1 || input('param.status') ==2) {
|
||||
$where[] = ['kf_status', '=', input('param.status')];
|
||||
$where[] = ['kefu_name', '=', input('param.name')];
|
||||
}
|
||||
if ( input('param.online') == 1 || input('param.online') ==2) {
|
||||
$where[] = ['online_status', '=', input('param.online')];
|
||||
}
|
||||
if (input('param.merchant')) {
|
||||
$where[] = ['mc_id', '=', input('param.merchant')];
|
||||
}
|
||||
$list = KefuLogic::getKefuByPage($where, '*', $limit);
|
||||
return $this->response->api($list->items() ? $list->items() : '',self::SUCCESS_CODE,'操作成功',['count'=>$list->total()]);
|
||||
}
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加客服
|
||||
* @param $param
|
||||
* @return array
|
||||
*/
|
||||
public function addKefu()
|
||||
{
|
||||
$param = input('param.');
|
||||
$validate = Validate::make([
|
||||
'kefu_name' => 'require|max:50',
|
||||
'kefu_password' => 'require'
|
||||
], [
|
||||
'kefu_name.require' => '客服名必须',
|
||||
'kefu_name.max' => '客服名最多不能超过50个字符',
|
||||
'kefu_password.require' => '客服密码必须',
|
||||
|
||||
]);
|
||||
if (!$validate->check($param)) {
|
||||
return $this->response->api('', 1001, $validate->getError());
|
||||
}
|
||||
KefuLogic::addKefu($param['kefu_name'], $param['kefu_password']);
|
||||
return $this->response->api('', self::SUCCESS_CODE, '添加成功');
|
||||
}
|
||||
/**
|
||||
* 编辑客服
|
||||
* @param $param
|
||||
* @return array
|
||||
*/
|
||||
public function updateKefu()
|
||||
{
|
||||
$param = input('post.');
|
||||
$validate = Validate::make([
|
||||
'kefu_name' => 'require|max:50',
|
||||
'kefu_id' => 'require',
|
||||
|
||||
], [
|
||||
'kf_name.require' => '客服名必须',
|
||||
'kf_name.max' => '客服名最多不能超过50个字符',
|
||||
'kefu_id.require' => '记录id必须'
|
||||
]);
|
||||
if (!$validate->check($param)) {
|
||||
return $this->response->api('', 1001, $validate->getError());
|
||||
}
|
||||
KefuLogic::saveKefu($param['kefu_id'], $param['kefu_name']);
|
||||
|
||||
return $this->response->api('', self::SUCCESS_CODE, '修改成功');
|
||||
}
|
||||
/**
|
||||
* 修改客服密码
|
||||
* @param $param
|
||||
* @return array
|
||||
*/
|
||||
public function resetPassword(){
|
||||
if( session('admin_id')!= 1){
|
||||
return $this->response->api('', 1001, '暂无权限');
|
||||
}
|
||||
$param = input('post.');
|
||||
$validate = Validate::make([
|
||||
'password' => 'require|max:50',
|
||||
'kefu_id' => 'require',
|
||||
|
||||
], [
|
||||
'kf_name.require' => '密码必须',
|
||||
'kf_name.max' => '密码最多不能超过50个字符',
|
||||
'kefu_id.require' => '记录id必须'
|
||||
]);
|
||||
if (!$validate->check($param)) {
|
||||
return $this->response->api('', 1001, $validate->getError());
|
||||
}
|
||||
KefuLogic::resetPassword($param['kefu_id'], $param['password']);
|
||||
return $this->response->api('',self::SUCCESS_CODE,'修改密码成功');
|
||||
}
|
||||
/**
|
||||
* 删除客服
|
||||
* @param $param
|
||||
* @return array
|
||||
*/
|
||||
public function delKefu()
|
||||
{
|
||||
if( session('admin_id')!= 1){
|
||||
return $this->response->api('', 1001, '暂无权限');
|
||||
}
|
||||
$id = input('post.kid/d');
|
||||
KefuLogic::delKefu($id);
|
||||
return $this->response->api('', self::SUCCESS_CODE, '删除成功');
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -11,6 +11,7 @@ namespace app\admin\controller;
|
||||
use Logic\AdminLogic;
|
||||
class Login extends Base
|
||||
{
|
||||
protected $_require_login = false;
|
||||
/**
|
||||
* 登录展示
|
||||
* @param $param
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* Author: baihu
|
||||
Visitor
|
||||
* Date: 2019/12/16
|
||||
* Time: 17:32
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user