Initial commit: queue workspace

Made-with: Cursor
This commit is contained in:
apple
2026-03-21 02:55:24 +08:00
commit 78de918c37
12388 changed files with 1840126 additions and 0 deletions

View File

@@ -0,0 +1,321 @@
<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
namespace app\controller\admin\v1\message\service;
use app\controller\admin\AuthController;
use app\services\kefu\LoginServices;
use app\services\message\service\StoreServiceLogServices;
use app\services\message\service\StoreServiceServices;
use app\services\user\UserServices;
use app\services\user\UserWechatuserServices;
use crmeb\exceptions\AdminException;
use crmeb\services\CacheService;
use think\annotation\Inject;
/**
* 客服管理
* Class StoreService
* @package app\admin\controller\store
*/
class StoreService extends AuthController
{
/**
* @var StoreServiceServices
*/
#[Inject]
protected StoreServiceServices $services;
/**
* 显示资源列表
*
* @return \think\Response
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function index()
{
return $this->success($this->services->getServiceList([]));
}
/**
* 显示创建资源表单页.
*
* @return \think\Response
*/
public function create(UserWechatuserServices $services)
{
$where = $this->request->getMore([
['nickname', ''],
['data', '', '', 'time'],
['type', '', '', 'user_type'],
['is_channel','']
]);
$where['is_filter_del'] = 1;
[$list, $count] = $services->getWhereUserList($where, 'u.nickname,u.uid,u.avatar as headimgurl,u.user_type,u.add_time,w.subscribe,w.province,w.country,w.city,w.sex');
foreach ($list as &$item) {
$item['subscribe'] = is_null($item['subscribe']) ? 0 : $item['subscribe'];
$item['country'] = is_null($item['country']) ? '' : $item['country'];
$item['province'] = is_null($item['province']) ? '' : $item['province'];
$item['city'] = is_null($item['city']) ? '' : $item['city'];
$item['sex'] = is_null($item['sex']) ? 0 : $item['sex'];
$item['add_time'] = date('Y-m-d H:i', $item['add_time']);
}
return $this->success(compact('list', 'count'));
}
/**
* 添加客服表单
* @return mixed
* @throws \FormBuilder\Exception\FormBuilderException
*/
public function add()
{
return $this->success($this->services->create());
}
/*
* 保存新建的资源
*/
public function save()
{
$data = $this->request->postMore([
['image', ''],
['uid', 0],
['avatar', ''],
['customer', ''],
['notify', ''],
['phone', ''],
['account', ''],
['password', ''],
['true_password', ''],
['phone', ''],
['nickname', ''],
['status', 1],
['account_status', 1],
]);
if ($data['image'] == '') return $this->fail('请选择用户');
$data['uid'] = $data['image']['uid'];
/** @var UserServices $userService */
$userService = app()->make(UserServices::class);
$userInfo = $userService->get($data['uid']);
if ($data['phone'] == '') {
if (!$userInfo['phone']) {
return $this->fail('该用户没有绑定手机号,请手动填写');
} else {
$data['phone'] = $userInfo['phone'];
}
} else {
if (!check_phone($data['phone'])) {
return $this->fail('请输入正确的手机号');
}
}
if ($data['nickname'] == '') $data['nickname'] = $userInfo['nickname'];
$data['avatar'] = $data['image']['image'];
if ($this->services->count(['uid' => $data['uid']])) {
return $this->fail('客服已存在!');
}
unset($data['image']);
$data['add_time'] = time();
if (!$data['account']) {
return $this->fail('请输入账号');
}
if (!preg_match('/^[a-zA-Z0-9]{4,30}$/', $data['account'])) {
return $this->fail('账号必须为数字或者字母的组合4-30位');
}
if (!$data['password']) {
return $this->fail('请输入密码');
}
if (!preg_match('/^[0-9a-z_$]{6,20}$/i', $data['password'])) {
return $this->fail('密码必须为数字或者字母的组合6-20位');
}
if ($this->services->count(['phone' => $data['phone']])) {
return $this->fail('该手机号的客服已存在!');
}
if ($this->services->count(['account' => $data['account']])) {
return $this->fail('该客服账号已存在!');
}
$data['password'] = password_hash($data['password'], PASSWORD_DEFAULT);
$res = $this->services->save($data);
if ($res) {
return $this->success('客服添加成功');
} else {
return $this->fail('客服添加失败,请稍后再试');
}
}
/**
* 显示编辑资源表单页.
*
* @param int $id
* @return \think\Response
*/
public function edit($id)
{
return $this->success($this->services->edit((int)$id));
}
/**
* 保存新建的资源
*
* @param \think\Request $request
* @return \think\Response
*/
public function update($id)
{
$data = $this->request->postMore([
['avatar', ''],
['nickname', ''],
['account', ''],
['phone', ''],
['status', 1],
['account_status', 1],
['notify', 1],
['customer', 1],
['password', ''],
['true_password', ''],
]);
$customer = $this->services->get((int)$id);
if (!$customer) {
return $this->fail('数据不存在');
}
if ($data["nickname"] == '') {
return $this->fail("客服名称不能为空!");
}
if (!check_phone($data['phone'])) {
return $this->fail('请输入正确的手机号');
}
if ($customer['phone'] != $data['phone'] && $this->services->count(['phone' => $data['phone']])) {
return $this->fail('该手机号的客服已存在!');
}
if ($data['password']) {
if (!preg_match('/^[0-9a-z_$]{6,16}$/i', $data['password'])) {
return $this->fail('密码必须为数字或者字母的组合');
}
if (!$data['true_password']) {
return $this->fail('请输入确认密码');
}
if ($data['password'] != $data['true_password']) {
return $this->fail('两次输入的密码不正确');
}
$data['password'] = password_hash($data['password'], PASSWORD_DEFAULT);
} else {
unset($data['password']);
}
$this->services->update($id, $data);
return $this->success('修改成功!');
}
/**
* 删除指定资源
*
* @param int $id
* @return \think\Response
*/
public function delete($id)
{
if (!$this->services->delete($id))
return $this->fail('删除失败,请稍候再试!');
else
return $this->success('删除成功!');
}
/**
* 修改状态
* @param $id
* @param $status
* @return mixed
*/
public function set_status(UserServices $services, $id, $status)
{
if ($status == '' || $id == 0) return $this->fail('参数错误');
$info = $this->services->get($id, ['account_status', 'uid']);
if (!$services->count(['uid' => $info['uid']])) {
$info->account_status = 1;
$info->save();
return $this->fail('用户不存在,客服将强制禁止登录');
}
$info->account_status = $status;
$info->save();
return $this->success($status == 0 ? '隐藏成功' : '显示成功');
}
/**
* 聊天记录
*
* @return \think\Response
*/
public function chat_user($id)
{
$uid = $this->services->value(['id' => $id], 'uid');
if (!$uid) {
return $this->fail('数据不存在!');
}
return $this->success($this->services->getChatUser((int)$uid));
}
/**
* 聊天记录
* @param StoreServiceLogServices $services
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function chat_list(StoreServiceLogServices $services)
{
$data = $this->request->getMore([
['uid', 0],
['to_uid', 0],
['id', 0]
]);
if ($data['uid']) {
CacheService::set('admin_chat_list' . $this->adminId, $data);
}
$data = CacheService::get('admin_chat_list' . $this->adminId);
if ($data['uid']) {
$where = [
'chat' => [$data['uid'], $data['to_uid']],
];
} else {
$where = [];
}
$list = $services->getChatLogList($where);
return $this->success($list);
}
/**
* 客服登录
* @param LoginServices $services
* @param $id
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function keufLogin(LoginServices $services, $id)
{
$serviceInfo = $services->get($id);
if (!$serviceInfo) {
return $this->fail('登录的客服不存在');
}
if (!$serviceInfo->account || !$serviceInfo->password) {
return $this->fail('请先填写客服账号和密码再尝试进入客服平台');
}
if (!$serviceInfo->account_status || !$serviceInfo->status) {
return $this->fail('客服帐号已被禁用');
}
return $this->success($services->authLogin($serviceInfo->account));
}
}

View File

@@ -0,0 +1,109 @@
<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
namespace app\controller\admin\v1\message\service;
use app\controller\admin\AuthController;
use app\services\message\service\StoreServiceFeedbackServices;
use think\annotation\Inject;
use think\db\exception\DataNotFoundException;
use think\db\exception\DbException;
use think\db\exception\ModelNotFoundException;
/**
* 客服用户留言反馈
* Class StoreServiceFeedback
* @package app\controller\admin\v1\application\wechat
*/
class StoreServiceFeedback extends AuthController
{
/**
* @var StoreServiceFeedbackServices
*/
#[Inject]
protected StoreServiceFeedbackServices $services;
/**
* 获取留言列表
* @return mixed
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
*/
public function index()
{
$where = $this->request->getMore([
['title', ''],
['time', '']
]);
return $this->success($this->services->getFeedbackList($where));
}
/**
* 获取修改表单
* @param $id
* @return mixed
* @throws \FormBuilder\Exception\FormBuilderException
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
*/
public function edit($id)
{
if (!$id) {
return $this->fail('缺少参数');
}
return $this->success($this->services->editForm((int)$id));
}
/**
* 修改
* @param $id
* @return mixed
*/
public function update($id)
{
$data = $this->request->postMore([
['make', ''],
['status', 0],
]);
if (!$id || !($feedInfo = $this->services->get($id))) {
return $this->fail('反馈内容不存在');
}
$feedInfo->make = $data['make'];
if ($data['status']) {
$feedInfo->status = $data['status'];
}
$feedInfo->save();
return $this->success('修改成功');
}
/**
* 删除反馈
* @param $id
* @return mixed
* @throws \Exception
*/
public function delete($id)
{
if (!$id) {
return $this->fail('缺少参数');
}
if ($this->services->delete($id)) {
return $this->success('删除成功');
} else {
return $this->fail('删除失败');
}
}
}

View File

@@ -0,0 +1,167 @@
<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
namespace app\controller\admin\v1\message\service;
use app\Request;
use think\annotation\Inject;
use app\controller\admin\AuthController;
use app\services\message\service\StoreServiceSpeechcraftServices;
use app\validate\admin\service\StoreServiceSpeechcraftValidate;
/**
* 话术空控制器
* Class StoreServiceSpeechcraft
* @package app\controller\admin\v1\application\wechat
*/
class StoreServiceSpeechcraft extends AuthController
{
/**
* @var StoreServiceSpeechcraftServices
*/
#[Inject]
protected StoreServiceSpeechcraftServices $services;
/**
* 显示资源列表
*
* @param Request $request
* @return \think\Response
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function index(Request $request)
{
$where = $request->getMore([
['title', ''],
['message', ''],
[['cate_id', 'd'], ''],
]);
$where['kefu_id'] = 0;
return $this->success($this->services->getSpeechcraftList($where));
}
/**
* 显示创建资源表单页.
*
* @return \think\Response
*/
public function create()
{
[$cate_id] = $this->request->getMore([
['cate_id', 0]
], true);
return $this->success($this->services->createForm((int)$cate_id));
}
/**
* 保存新建的资源
*
* @param \app\Request $request
* @return \think\Response
*/
public function save(Request $request)
{
$data = $request->postMore([
['title', ''],
['message', ''],
[['cate_id', 'd'], 0],
['sort', 0],
]);
$this->validate($data, StoreServiceSpeechcraftValidate::class);
$data['add_time'] = time();
$data['kefu_id'] = 0;
if ($this->services->count(['message' => $data['message']])) {
return $this->fail('话术不能重复添加');
}
if ($this->services->save($data)) {
return $this->success('创建话术成功');
} else {
return $this->fail('创建话术失败');
}
}
/**
* 显示指定的资源
*
* @param int $id
* @return \think\Response
*/
public function read($id)
{
$info = $this->services->get($id);
if (!$info) {
return $this->fail('获取失败');
}
return $this->success($info);
}
/**
* 显示编辑资源表单页.
*
* @param int $id
* @return \think\Response
*/
public function edit($id)
{
return $this->success($this->services->updateForm((int)$id));
}
/**
* 保存更新的资源
*
* @param \app\Request $request
* @param int $id
* @return \think\Response
*/
public function update(Request $request, $id)
{
$data = $request->postMore([
['title', ''],
['message', ''],
['sort', 0],
[['cate_id', 'd'], 0],
]);
$this->validate($data, StoreServiceSpeechcraftValidate::class);
$message = $this->services->get(['message' => $data['message']]);
if ($message && $message['id'] != $id) {
return $this->fail('话术不能重复添加');
}
if ($this->services->update($id, $data)) {
return $this->success('修改成功');
} else {
return $this->fail('修改失败');
}
}
/**
* 删除指定资源
*
* @param int $id
* @return \think\Response
*/
public function delete($id)
{
if (!$id || !($info = $this->services->get($id))) {
return $this->fail('删除的话术不存在!');
}
if ($info->delete()) {
return $this->success('删除成功');
} else {
return $this->fail('删除失败');
}
}
}

View File

@@ -0,0 +1,145 @@
<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
namespace app\controller\admin\v1\message\service;
use app\Request;
use think\annotation\Inject;
use app\controller\admin\AuthController;
use app\services\message\service\StoreServiceSpeechcraftCateServices;
/**
* Class StoreServiceSpeechcraftCate
* @package app\controller\admin\v1\application\wechat
*/
class StoreServiceSpeechcraftCate extends AuthController
{
/**
* @var StoreServiceSpeechcraftCateServices
*/
#[Inject]
protected StoreServiceSpeechcraftCateServices $services;
/**
* 获取列表
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function index()
{
$where = $this->request->getMore([
['name', '']
]);
$where['owner_id'] = 0;
$where['type'] = 0;
$where['group'] = 1;
return $this->success($this->services->getCateList($where));
}
/**
* 获取创建表单
* @return mixed
* @throws \FormBuilder\Exception\FormBuilderException
*/
public function create()
{
return $this->success($this->services->createForm());
}
/**
* 保存数据
* @return mixed
*/
public function save()
{
$data = $this->request->postMore([
['name', ''],
['sort', 0],
]);
if (!$data['name']) {
return $this->fail('请输入分类名称');
}
if ($this->services->count(['name' => $data['name'], 'group' => 1])) {
return $this->fail('分类已存在');
}
$data['add_time'] = time();
$data['group'] = 1;
$this->services->save($data);
return $this->success('添加成功');
}
/**
* 获取修改表单
* @param $id
* @return mixed
* @throws \FormBuilder\Exception\FormBuilderException
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function edit($id)
{
return $this->success($this->services->editForm((int)$id));
}
/**
* 修改保存
* @param Request $request
* @param $id
* @return mixed
*/
public function update(Request $request, $id)
{
$data = $request->postMore([
['name', ''],
[['sort', 'd'], 0],
]);
if (!$data['name']) {
return $this->fail('请输入分类名称');
}
$cateInfo = $this->services->get($id);
if (!$cateInfo) {
return $this->fail('修改的分类不存在');
}
$old = $this->services->getOne(['name' => $data['name'], 'group' => 1]);
if ($old && $old['id'] != $id) {
return $this->fail('分类已存在');
}
$cateInfo->name = $data['name'];
$cateInfo->sort = $data['sort'];
$cateInfo->save();
return $this->success('修改成功');
}
/**
* 删除
* @param $id
* @return mixed
*/
public function delete($id)
{
$cateInfo = $this->services->get($id);
if (!$cateInfo) {
return $this->fail('删除的分类不存在');
}
$cateInfo->delete();
return $this->success('删除成功');
}
}