合并分支 'workorder' 到 'master'
Workorder 查看合并请求 !2255
正在显示
5 个修改的文件
包含
102 行增加
和
1 行删除
| @@ -3,6 +3,7 @@ | @@ -3,6 +3,7 @@ | ||
| 3 | namespace App\Http\Controllers\Api\WorkOrder; | 3 | namespace App\Http\Controllers\Api\WorkOrder; |
| 4 | 4 | ||
| 5 | use App\Http\Controllers\Api\BaseController; | 5 | use App\Http\Controllers\Api\BaseController; |
| 6 | +use App\Http\Requests\Api\WorkOrder\TicketListRequest; | ||
| 6 | use App\Http\Requests\Api\WorkOrder\TicketStoreRequest; | 7 | use App\Http\Requests\Api\WorkOrder\TicketStoreRequest; |
| 7 | use App\Models\WorkOrder\TicketLog; | 8 | use App\Models\WorkOrder\TicketLog; |
| 8 | use App\Models\WorkOrder\TicketProject; | 9 | use App\Models\WorkOrder\TicketProject; |
| @@ -17,8 +18,9 @@ class TicketController extends BaseController | @@ -17,8 +18,9 @@ class TicketController extends BaseController | ||
| 17 | * | 18 | * |
| 18 | * @return \Illuminate\Http\Response | 19 | * @return \Illuminate\Http\Response |
| 19 | */ | 20 | */ |
| 20 | - public function index($project_id, Request $request) | 21 | + public function index(TicketListRequest $request, $project_id) |
| 21 | { | 22 | { |
| 23 | + $validated = $request->validated(); | ||
| 22 | $project = TicketProject::where('uuid', $project_id)->first(); | 24 | $project = TicketProject::where('uuid', $project_id)->first(); |
| 23 | if (!$project) return $this->error('未找到项目', 404); | 25 | if (!$project) return $this->error('未找到项目', 404); |
| 24 | $page = (int)$request->input('page', 1); | 26 | $page = (int)$request->input('page', 1); |
| @@ -30,6 +32,22 @@ class TicketController extends BaseController | @@ -30,6 +32,22 @@ class TicketController extends BaseController | ||
| 30 | ]) | 32 | ]) |
| 31 | ->where('project_id', $project->id) | 33 | ->where('project_id', $project->id) |
| 32 | // ->where('submit_side', 2) | 34 | // ->where('submit_side', 2) |
| 35 | + ->when($request->input('status') !== null, function ($query) use ($request) { | ||
| 36 | + // status 查 gl_tickets.status | ||
| 37 | + $status = $request->input('status'); | ||
| 38 | + return $query->where('status', $status); | ||
| 39 | + }) | ||
| 40 | + ->when($request->input('search'), function ($query) use ($request) { | ||
| 41 | + // search 查 gl_tickets.title 或 gl_ticket_projects.title 或 gl_ticket_projects.company_name | ||
| 42 | + $search = $request->input('search'); | ||
| 43 | + return $query->where(function ($q) use ($search) { | ||
| 44 | + $q->where('title', 'like', '%' . $search . '%') | ||
| 45 | + ->orWhereHas('project', function ($q1) use ($search) { | ||
| 46 | + $q1->where('title', 'like', '%' . $search . '%') | ||
| 47 | + ->orWhere('company_name', 'like', '%' . $search . '%'); | ||
| 48 | + }); | ||
| 49 | + }); | ||
| 50 | + }) | ||
| 33 | ->orderBy('id', 'desc') | 51 | ->orderBy('id', 'desc') |
| 34 | ->paginate($size, ['*'], 'page', $page); | 52 | ->paginate($size, ['*'], 'page', $page); |
| 35 | return response()->json(['data' => $tickets]); | 53 | return response()->json(['data' => $tickets]); |
| @@ -8,6 +8,8 @@ use App\Http\Requests\Aside\WorkOrder\AsideTicketStoreRequest; | @@ -8,6 +8,8 @@ use App\Http\Requests\Aside\WorkOrder\AsideTicketStoreRequest; | ||
| 8 | use App\Http\Requests\Aside\WorkOrder\AsideTicketListRequest; | 8 | use App\Http\Requests\Aside\WorkOrder\AsideTicketListRequest; |
| 9 | use App\Http\Requests\Aside\WorkOrder\AsideTicketUpdateRequest; | 9 | use App\Http\Requests\Aside\WorkOrder\AsideTicketUpdateRequest; |
| 10 | use App\Http\Requests\Aside\WorkOrder\TicketProjectListRequest; | 10 | use App\Http\Requests\Aside\WorkOrder\TicketProjectListRequest; |
| 11 | +use App\Models\ProjectAssociation\ProjectAssociation; | ||
| 12 | +use App\Models\Workchat\MessagePush; | ||
| 11 | use App\Models\WorkOrder\TicketLog; | 13 | use App\Models\WorkOrder\TicketLog; |
| 12 | use App\Models\WorkOrder\TicketProject; | 14 | use App\Models\WorkOrder\TicketProject; |
| 13 | use App\Models\WorkOrder\Tickets; | 15 | use App\Models\WorkOrder\Tickets; |
| @@ -216,4 +218,39 @@ class AsideTicketController extends BaseController | @@ -216,4 +218,39 @@ class AsideTicketController extends BaseController | ||
| 216 | { | 218 | { |
| 217 | // | 219 | // |
| 218 | } | 220 | } |
| 221 | + | ||
| 222 | + | ||
| 223 | + /** | ||
| 224 | + * 手动触发,推送工单到企微群 | ||
| 225 | + */ | ||
| 226 | + public function pushNotify($id) | ||
| 227 | + { | ||
| 228 | + $ticket = Tickets::find($id); | ||
| 229 | + if (!$ticket) { | ||
| 230 | + $this->response('工单不存在', Code::USER_MODEL_NOTFOUND_ERROE); | ||
| 231 | + } | ||
| 232 | + | ||
| 233 | + $project = $ticket->project; | ||
| 234 | + if (empty($project->association)) { | ||
| 235 | + $this->response('该工单没有绑定的企微群', Code::USER_MODEL_NOTFOUND_ERROE); | ||
| 236 | + } | ||
| 237 | + | ||
| 238 | + $message_push = new MessagePush(); | ||
| 239 | + $message_push->project_id = $project->table_id; | ||
| 240 | + $message_push->friend_id = $project->association->friend_id; | ||
| 241 | + $message_push->content_type = 'Link'; | ||
| 242 | + $message_push->content = json_encode([ | ||
| 243 | + 'title' => '工单查看 - ' . $project->company_name, | ||
| 244 | + 'desc' => $ticket->title, | ||
| 245 | + 'size' => 0, | ||
| 246 | + 'thumbSize' => 0, | ||
| 247 | + 'thumbUrl' => 'https://oa.quanqiusou.cn/logo.ico', | ||
| 248 | + 'url' => 'https://oa.quanqiusou.cn/tickets?project_id='.$project->uuid | ||
| 249 | + ], JSON_UNESCAPED_UNICODE); | ||
| 250 | + $message_push->send_time = now(); | ||
| 251 | + $message_push->type = MessagePush::TYPE_TICKET; | ||
| 252 | + $message_push->save(); | ||
| 253 | + | ||
| 254 | + $this->response('success', Code::SUCCESS); | ||
| 255 | + } | ||
| 219 | } | 256 | } |
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace App\Http\Requests\Api\WorkOrder; | ||
| 4 | + | ||
| 5 | +use Illuminate\Foundation\Http\FormRequest; | ||
| 6 | + | ||
| 7 | +class TicketListRequest extends FormRequest | ||
| 8 | +{ | ||
| 9 | + /** | ||
| 10 | + * Determine if the user is authorized to make this request. | ||
| 11 | + * | ||
| 12 | + * @return bool | ||
| 13 | + */ | ||
| 14 | + public function authorize() | ||
| 15 | + { | ||
| 16 | + return true; | ||
| 17 | + } | ||
| 18 | + | ||
| 19 | + /** | ||
| 20 | + * Get the validation rules that apply to the request. | ||
| 21 | + * | ||
| 22 | + * @return array | ||
| 23 | + */ | ||
| 24 | + public function rules() | ||
| 25 | + { | ||
| 26 | + return [ | ||
| 27 | + 'status' => 'nullable|in:0,1,2,3|integer', | ||
| 28 | + 'search' => 'nullable|string', // 搜索关键词 | ||
| 29 | + 'page' => 'nullable|integer', | ||
| 30 | + 'size' => 'nullable|integer', | ||
| 31 | + ]; | ||
| 32 | + } | ||
| 33 | +} |
| @@ -5,6 +5,7 @@ namespace App\Models\WorkOrder; | @@ -5,6 +5,7 @@ namespace App\Models\WorkOrder; | ||
| 5 | use App\Models\Base; | 5 | use App\Models\Base; |
| 6 | use App\Models\Manage\Manage; | 6 | use App\Models\Manage\Manage; |
| 7 | use App\Models\Project\Project; | 7 | use App\Models\Project\Project; |
| 8 | +use App\Models\ProjectAssociation\ProjectAssociation; | ||
| 8 | use Illuminate\Database\Eloquent\Factories\HasFactory; | 9 | use Illuminate\Database\Eloquent\Factories\HasFactory; |
| 9 | 10 | ||
| 10 | class TicketProject extends Base | 11 | class TicketProject extends Base |
| @@ -41,4 +42,15 @@ class TicketProject extends Base | @@ -41,4 +42,15 @@ class TicketProject extends Base | ||
| 41 | return $this->hasOne(Manage::class, 'id', 'engineer_id') | 42 | return $this->hasOne(Manage::class, 'id', 'engineer_id') |
| 42 | ->select(['id', 'name']); | 43 | ->select(['id', 'name']); |
| 43 | } | 44 | } |
| 45 | + | ||
| 46 | + /** | ||
| 47 | + * 绑定的企微群 | ||
| 48 | + */ | ||
| 49 | + public function association() | ||
| 50 | + { | ||
| 51 | + return $this->hasOne(ProjectAssociation::class, 'project_id', 'table_id') | ||
| 52 | + ->where('status', 1) | ||
| 53 | + ->where('binding_app', ProjectAssociation::ENTERPRISE_WECHAT) | ||
| 54 | + ->select(['id', 'project_id', 'friend_id', 'binding_app']); | ||
| 55 | + } | ||
| 44 | } | 56 | } |
| @@ -260,6 +260,7 @@ Route::middleware(['aloginauth'])->group(function () { | @@ -260,6 +260,7 @@ Route::middleware(['aloginauth'])->group(function () { | ||
| 260 | Route::post('/log/{id}', [Aside\WorkOrder\AsideTicketLogController::class, 'update'])->name('admin.tickets.log.update')->summary('A端工单操作日志更新,完成工单'); | 260 | Route::post('/log/{id}', [Aside\WorkOrder\AsideTicketLogController::class, 'update'])->name('admin.tickets.log.update')->summary('A端工单操作日志更新,完成工单'); |
| 261 | Route::get('/chat/{ticket_id}', [Aside\WorkOrder\TicketChatController::class, 'index'])->name('admin.tickets.chat.index')->summary('A端工单聊天记录'); | 261 | Route::get('/chat/{ticket_id}', [Aside\WorkOrder\TicketChatController::class, 'index'])->name('admin.tickets.chat.index')->summary('A端工单聊天记录'); |
| 262 | Route::post('/chat/{ticket_id}', [Aside\WorkOrder\TicketChatController::class, 'store'])->name('admin.tickets.chat.store')->summary('A端工单聊天记录创建'); | 262 | Route::post('/chat/{ticket_id}', [Aside\WorkOrder\TicketChatController::class, 'store'])->name('admin.tickets.chat.store')->summary('A端工单聊天记录创建'); |
| 263 | + Route::get('/pushNotify/{ticket_id}', [Aside\WorkOrder\TicketChatController::class, 'pushNotify'])->name('admin.tickets.pushNotify')->summary('A端工单推送企微群'); | ||
| 263 | }); | 264 | }); |
| 264 | 265 | ||
| 265 | //服务器配置 | 266 | //服务器配置 |
-
请 注册 或 登录 后发表评论