最新版本

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

@@ -0,0 +1,24 @@
<?php
namespace app\index\controller;
use app\BaseController;
use app\index\service\ClientTicketService;
use think\facade\Session;
class ClientTicket extends BaseController
{
/**
* 获取客户关联工单
*/
public function getClientTickets(ClientTicketService $ClientTicketService)
{
$clientId = Session::get('user_info.id'); // 获取当前登录客户ID
try {
$tickets = $ClientTicketService->getClientTickets($clientId);
return json(['code' => 200, 'msg' => '获取成功', 'data' => $tickets]);
} catch (\Exception $e) {
return json(['code' => 400, 'msg' => $e->getMessage(), 'data' => null]);
}
}
}

View File

@@ -35,7 +35,7 @@ class Login extends BaseController
/*
退出登录(已完成)
*/
protected function logout()
public function logout()
{
Session::clear();
return json(['code' => 200, 'message' => '退出成功']);

View File

@@ -1,6 +1,12 @@
<?php
use app\admin\middleware\Auth;
use think\facade\Route;
Route::post('login', 'Login/login'); // 登录
Route::post('logout', 'Login/logout'); // 退出登录
Route::post('api/login', 'Login/login'); // 登录
Route::group(function () {
Route::get('client/tickets', 'ClientTicket/getClientTickets'); // 获取客户关联工单
})->middleware(Auth::class);

View File

@@ -0,0 +1,27 @@
<?php
namespace app\index\service;
use app\common\model\User as UserModel;
class ClientTicketService
{
/* 获取客户关联工单 */
public function getClientTickets($clientId)
{
# 查询当前登录用户所对应的工单
$tickets = UserModel::with(['tickets'])->find($clientId);
$newList = [];
foreach ($tickets->tickets as $ticket) {
if (in_array($ticket->status, [0, 1, 2])) {
$ticket->visible(['id', 'website', 'datanum', 'progress', 'status']);
$newList[] = $ticket->toArray();
}
}
return $newList;
}
}