feat: 牛牛单独限红 - 新增limit_low_nn/limit_high_nn字段,代理端添加/编辑代理和会员支持牛牛限红设置,语言包三语支持

This commit is contained in:
li
2026-02-11 19:53:50 +08:00
parent 1ce6c3d780
commit 71d7ff1d7b
36 changed files with 2590 additions and 18 deletions
@@ -0,0 +1,229 @@
<?php
namespace app\admin\controller;
use think\Db;
use think\Request;
/**
* 快捷回复管理控制器
* Class ChatQuickReply
* @package app\admin\controller
*/
class ChatQuickReply extends Common
{
/**
* 快捷回复列表
*/
public function index()
{
$get = Request::instance()->get();
$this->assign('get', $get);
$category = Request::instance()->get('category');
$status = Request::instance()->get('status');
$where = [];
if ($category) {
$where['category'] = $category;
}
if ($status !== null && $status !== '') {
$where['status'] = (int)$status;
}
$list = Db::name('chat_quick_reply')
->where($where)
->order('sort asc, id desc')
->paginate(15, false, ['query' => $get]);
// 获取分类列表
$categories = Db::name('chat_quick_reply')
->whereNotNull('category')
->where('category', '<>', '')
->group('category')
->column('category');
$this->assign('list', $list);
$this->assign('categories', $categories);
return $this->fetch();
}
/**
* 添加快捷回复
*/
public function add()
{
if (Request::instance()->isPost()) {
$data = Request::instance()->post();
// 验证
if (empty($data['title'])) {
$this->error('标题不能为空');
}
if (empty($data['content'])) {
$this->error('内容不能为空');
}
$insertData = [
'category' => $data['category'] ?? null,
'title' => $data['title'],
'content' => $data['content'],
'sort' => (int)($data['sort'] ?? 0),
'status' => (int)($data['status'] ?? 1),
'create_time' => time(),
'update_time' => time(),
];
$result = Db::name('chat_quick_reply')->insert($insertData);
if ($result) {
insertAdminLog('添加快捷回复', '标题: ' . $data['title']);
$this->success('添加成功', '/chat_quick_reply/index');
} else {
$this->error('添加失败');
}
}
// 获取分类列表
$categories = Db::name('chat_quick_reply')
->whereNotNull('category')
->where('category', '<>', '')
->group('category')
->column('category');
$this->assign('categories', $categories);
$this->assign('info', []);
return $this->fetch();
}
/**
* 编辑快捷回复
*/
public function edit()
{
$id = Request::instance()->param('id');
if (Request::instance()->isPost()) {
$data = Request::instance()->post();
// 验证
if (empty($data['title'])) {
$this->error('标题不能为空');
}
if (empty($data['content'])) {
$this->error('内容不能为空');
}
$updateData = [
'category' => $data['category'] ?? null,
'title' => $data['title'],
'content' => $data['content'],
'sort' => (int)($data['sort'] ?? 0),
'status' => (int)($data['status'] ?? 1),
'update_time' => time(),
];
$result = Db::name('chat_quick_reply')->where('id', $id)->update($updateData);
if ($result !== false) {
insertAdminLog('编辑快捷回复', 'ID: ' . $id);
$this->success('修改成功', '/chat_quick_reply/index');
} else {
$this->error('修改失败');
}
}
$info = Db::name('chat_quick_reply')->where('id', $id)->find();
if (!$info) {
$this->error('记录不存在');
}
// 获取分类列表
$categories = Db::name('chat_quick_reply')
->whereNotNull('category')
->where('category', '<>', '')
->group('category')
->column('category');
$this->assign('info', $info);
$this->assign('categories', $categories);
return $this->fetch('add');
}
/**
* 删除快捷回复
*/
public function del()
{
$id = Request::instance()->param('id');
if (!$id) {
$this->error('参数错误');
}
$info = Db::name('chat_quick_reply')->where('id', $id)->find();
if (!$info) {
$this->error('记录不存在');
}
$result = Db::name('chat_quick_reply')->where('id', $id)->delete();
if ($result) {
insertAdminLog('删除快捷回复', 'ID: ' . $id . ', 标题: ' . $info['title']);
$this->success('删除成功');
} else {
$this->error('删除失败');
}
}
/**
* 修改状态
*/
public function status()
{
$id = Request::instance()->post('id');
$status = Request::instance()->post('status');
if (!$id) {
return json(['code' => 1, 'msg' => '参数错误']);
}
$result = Db::name('chat_quick_reply')->where('id', $id)->update([
'status' => (int)$status,
'update_time' => time(),
]);
if ($result !== false) {
return json(['code' => 0, 'msg' => '操作成功']);
} else {
return json(['code' => 1, 'msg' => '操作失败']);
}
}
/**
* 修改排序
*/
public function sort()
{
$id = Request::instance()->post('id');
$sort = Request::instance()->post('sort');
if (!$id) {
return json(['code' => 1, 'msg' => '参数错误']);
}
$result = Db::name('chat_quick_reply')->where('id', $id)->update([
'sort' => (int)$sort,
'update_time' => time(),
]);
if ($result !== false) {
return json(['code' => 0, 'msg' => '操作成功']);
} else {
return json(['code' => 1, 'msg' => '操作失败']);
}
}
}
+4
View File
@@ -29,6 +29,8 @@ class Common extends Controller{
'Info',
'Log',
'Login',
'Chat',
'ChatQuickReply',
);
if($user_info['role'] == 1){
if(!in_array($curContrller, $jiankongController)){
@@ -40,6 +42,8 @@ class Common extends Controller{
'Index',
'Agent',
'Login',
'Chat',
'ChatQuickReply',
);
if($user_info['role'] == 2){
if(!in_array($curContrller, $dlController)){
+9 -1
View File
@@ -59,7 +59,15 @@ class Login extends Controller{
}
$last_login_info = Db::name('admin')->where(array('id' => $admin_info['id']))->field(['last_login_time','last_login_ip'])->find();
Session::set('last_login_info',$last_login_info);
Db::name('admin')->where(array('id' => $admin_info['id']))->update(array('last_login_time' => time(), 'last_login_ip' => getIP()));
// 生成login_token用于WebSocket连接验证
$login_token = md5($admin_info['id'] . time() . uniqid());
Db::name('admin')->where(array('id' => $admin_info['id']))->update(array(
'last_login_time' => time(),
'last_login_ip' => getIP(),
'login_token' => $login_token
));
$user_info = Db::name('admin')->where('id',$admin_info['id'])->find();
Session::set('user_info',$user_info);
insertAdminLog('登录');
+3 -3
View File
@@ -36,17 +36,17 @@ class Report extends Common{
}
$agent_list = Db::name('user')->where($where)->select();
// 时间条件
// 时间条件(默认:今天07:00:00 ~ 明天06:59:59)
if($startDate){
$startTime = strtotime($startDate);
}else{
$startTime = strtotime(date('Y-m-d'));
$startTime = strtotime(date('Y-m-d') . ' 07:00:00');
$get['startDate'] = date('Y-m-d H:i:s',$startTime);
}
if($endDate){
$endTime = strtotime($endDate);
}else{
$endTime = time();
$endTime = strtotime(date('Y-m-d', strtotime('+1 day')) . ' 06:59:59');
$get['endDate'] = date('Y-m-d H:i:s',$endTime);
}
$this->assign('get',$get);