最新版本

This commit is contained in:
2026-05-26 09:44:21 +08:00
parent 822ed9a099
commit fa41edf857
24 changed files with 597 additions and 163 deletions

View File

@@ -7,6 +7,14 @@ use app\admin\service\AccountService;
class AccountManagement extends BaseController
{
/* 查询所有用户 */
public function getAllUsers(AccountService $accountService)
{
$result = $accountService->getAllUsers();
return json(['code' => 200, 'message' => '查询成功', 'data' => $result]);
}
/* 注册用户 */
public function addAccount(AccountService $accountService)
{
@@ -14,7 +22,7 @@ class AccountManagement extends BaseController
$params = $this->request->post();
# 参数校验
if (empty($params['real_name'])) {
if (empty($params['username'])) {
return json(['code' => 400, 'message' => '缺少必要参数']);
}
@@ -31,4 +39,26 @@ class AccountManagement extends BaseController
]);
}
}
/* 更新用户状态 */
public function updateAccountStatus(AccountService $accountService, $id, $status)
{
try {
$result = $accountService->updateAccountStatus($id, $status);
return json(['code' => 200, 'message' => '账户状态更新成功', 'data' => $result]);
} catch (\Exception $e) {
return json(['code' => 400, 'message' => $e->getMessage(), 'data' => null]);
}
}
/* 删除用户 */
public function deleteAccount(AccountService $accountService, $id)
{
try {
$result = $accountService->deleteAccount($id);
return json(['code' => 200, 'message' => '账户删除成功', 'data' => $result]);
} catch (\Exception $e) {
return json(['code' => 400, 'message' => $e->getMessage(), 'data' => null]);
}
}
}

View File

@@ -0,0 +1,89 @@
<?php
namespace app\admin\controller;
use app\BaseController;
use app\common\service\TicketService;
use app\admin\service\CompanyOperatorsService;
class CompanyAndOperators extends BaseController
{
/**
* 获取所有运营人员名称
*/
public function getAllOperators(TicketService $ticketService)
{
$result = $ticketService->getAllOperators();
return json(['code' => 200, 'msg' => '查询成功', 'data' => $result]);
}
public function TestgetAllOperators(TicketService $ticketService)
{
$result = $ticketService->TestgetAllOperators();
return json(['code' => 200, 'msg' => '查询成功', 'data' => $result]);
}
/**
* 获取我方员工列表
*/
public function getStaffList(TicketService $ticketService)
{
$result = $ticketService->getStaffList();
return json(['code' => 200, 'msg' => '查询成功', 'data' => $result]);
}
/* 删除运营 */
public function deleteOperator(CompanyOperatorsService $CompanyOperatorService, $id)
{
$result = $CompanyOperatorService->deleteOperator($id);
return json(['code' => 200, 'msg' => '删除成功', 'data' => $result]);
}
/* 删除客户单位 */
public function deleteCompany(CompanyOperatorsService $CompanyOperatorService, $id)
{
$result = $CompanyOperatorService->deleteCompany($id);
if (!$result) {
return json(['code' => 400, 'msg' => '删除失败', 'data' => null]);
}
return json(['code' => 200, 'msg' => '删除成功']);
}
/* 新增公司(客户)单位 */
public function addCompany(CompanyOperatorsService $CompanyOperatorService)
{
$data = $this->request->post();
try {
$result = $CompanyOperatorService->addCompany($data);
return json(['code' => 200, 'msg' => '创建成功', 'data' => $result]);
} catch (\Exception $e) {
return json(['code' => 400, 'msg' => $e->getMessage(), 'data' => null]);
}
}
/* 新增运营人员 */
public function addOperator(CompanyOperatorsService $CompanyOperatorService)
{
$data = $this->request->post();
try {
$result = $CompanyOperatorService->addOperator($data);
return json(['code' => 200, 'msg' => '创建成功', 'data' => $result]);
} catch (\Exception $e) {
return json(['code' => 400, 'msg' => $e->getMessage(), 'data' => null]);
}
}
}

View File

@@ -22,7 +22,8 @@ class Ticket extends BaseController
"page" => $this->request->param('page', 1, 'intval'),
"limit" => $this->request->param('limit', 20, 'intval'),
"status" => $this->request->param('status', null),
"operator_name" => $this->request->param('operator_name', null),
"operator_id" => $this->request->param('operator_id', null),
"user_id" => $this->request->param('user_id', null),
"searchKeyword" => $this->request->param('search', null),
"sortOrder" => $this->request->param('sort_order', 'desc'),
];
@@ -69,6 +70,39 @@ class Ticket extends BaseController
}
}
/**
* 统计各状态工单数量
*/
public function getTicketDashboardStats(TicketService $ticketService)
{
$result = $ticketService->getTicketDashboardStats();
return json(['code' => 200, 'msg' => '查询成功', 'data' => $result]);
}
/**
* 批量更新工单
*/
public function batchUpdate(TicketService $ticketService)
{
$adminId = Session::get('user_info.id'); // 获取当前登录管理员ID
$data = $this->request->post();
$ids = $data['ids'] ?? [];
if (!is_array($ids) || empty($ids)) {
return json(['code' => 400, 'msg' => 'ids 必须是非空数组', 'data' => []]);
}
$allowFields = ['status', 'lock_time'];
try {
$result = $ticketService->batchUpdateTickets($ids, $data, $allowFields, $adminId, true);
return json(['code' => 200, 'msg' => '批量更新成功', 'data' => $result]);
} catch (\Exception $e) {
return json(['code' => 400, 'msg' => $e->getMessage(), 'data' => []]);
}
}
/**
* 删除一个工单(仅后台可调用)
*/

View File

@@ -1,30 +0,0 @@
<?php
namespace app\admin\controller;
use app\BaseController;
use app\common\service\TicketService;
class TicketFilter extends BaseController
{
/**
* 获取所有运营人员名称 (下拉筛选用)
*/
public function getAllOperators(TicketService $ticketService)
{
$result = $ticketService->getAllOperators();
return json(['code' => 200, 'msg' => '查询成功', 'data' => $result]);
}
/**
* 获取我方员工列表 (下拉选择用)
*/
public function getStaffList(TicketService $ticketService)
{
$result = $ticketService->getStaffList();
return json(['code' => 200, 'msg' => '查询成功', 'data' => $result]);
}
}

View File

@@ -0,0 +1,30 @@
<?php
namespace app\admin\controller;
use app\BaseController;
use app\admin\service\UtillService;
use think\facade\Session;
class Utill extends BaseController
{
/* 获取需要导出的数据
$range范围week,month
*/
public function getExportData(UtillService $UtillService)
{
$range = $this->request->post('range');
try {
# session中获取当前登录是否是管理员
$isAdmin = Session::get('user_info.role') === 'admin' ? true : false; // 后续用来判断
if (!$isAdmin) {
return json(['code' => 403, 'msg' => '权限不足', 'data' => []]);
}
$data = $UtillService->getExportData($range);
return json(['code' => 200, 'msg' => '查询成功', 'data' => $data]);
} catch (\Exception $e) {
return json(['code' => 500, 'msg' => '查询失败', 'data' => []]);
}
}
}