first commit

This commit is contained in:
2026-05-07 16:37:25 +08:00
commit 822ed9a099
67 changed files with 1799 additions and 0 deletions

View File

@@ -0,0 +1,34 @@
<?php
namespace app\admin\controller;
use app\BaseController;
use app\admin\service\AccountService;
class AccountManagement extends BaseController
{
public function addAccount(AccountService $accountService)
{
# 获取数据
$params = $this->request->post();
# 参数校验
if (empty($params['real_name'])) {
return json(['code' => 400, 'message' => '缺少必要参数']);
}
# 业务逻辑
try {
$result = $accountService->createAccount($params);
return json(['code' => 200, 'message' => '账户创建成功', 'data' => $result]);
} catch (\Exception $e) {
return json([
'code' => 400,
'message' => $e->getMessage(),
'data' => null
]);
}
}
}

View File

@@ -0,0 +1,84 @@
<?php
namespace app\admin\controller;
use app\BaseController;
use app\common\model\Tickets;
use app\common\service\TicketService;
use think\facade\Session;
class Ticket extends BaseController
{
/**
* 查询工单
*/
public function ticketsFind(TicketService $ticketService)
{
// 在控制器明确接收参数
$params = [
"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),
"searchKeyword" => $this->request->param('search', null),
"sortOrder" => $this->request->param('sort_order', 'desc'),
];
$result = $ticketService->getTicketList($params);
return json(['code' => 200, 'msg' => '查询成功', 'data' => $result]);
}
/**
* 新增工单
*/
public function createTicket(TicketService $ticketService)
{
$data = $this->request->post();
try {
$result = $ticketService->createTicket($data);
return json(['code' => 200, 'msg' => '创建成功', 'data' => $result]);
} catch (\Exception $e) {
return json(['code' => 400, 'msg' => $e->getMessage(), 'data' => null]);
}
}
/**
* 更新工单(后台调用)
*/
public function updateTicket(TicketService $ticketService, $id)
{
$adminId = Session::get('id'); // 获取当前登录管理员ID
$data = $this->request->post();
$allowFields = ['company_id', 'operator_id', 'user_id', 'website', 'datanum', 'progress', 'status', 'remark'];
try {
$result = $ticketService->updateTicket($id, $data, $allowFields, $adminId, true);
return json(['code' => 200, 'msg' => '更新成功', 'data' => $result]);
} catch (\Exception $e) {
return json(['code' => 400, 'msg' => $e->getMessage(), 'data' => []]);
}
}
/**
* 删除一个工单(仅后台可调用)
*/
public function deleteTicket($id)
{
$ticket = Tickets::find($id);
if (!$ticket) return json(['code' => false, 'msg' => '工单不存在', 'data' => []]);
return $ticket->delete()
? json(['code' => true, 'msg' => '删除成功', 'data' => []])
: json(['code' => false, 'msg' => '删除失败', 'data' => []]);
}
}

View File

@@ -0,0 +1,30 @@
<?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]);
}
}