正在显示
3 个修改的文件
包含
50 行增加
和
0 行删除
| @@ -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 | } |
| @@ -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 | } |
| @@ -259,6 +259,7 @@ Route::middleware(['aloginauth'])->group(function () { | @@ -259,6 +259,7 @@ Route::middleware(['aloginauth'])->group(function () { | ||
| 259 | Route::post('/log/{id}', [Aside\WorkOrder\AsideTicketLogController::class, 'update'])->name('admin.tickets.log.update')->summary('A端工单操作日志更新,完成工单'); | 259 | Route::post('/log/{id}', [Aside\WorkOrder\AsideTicketLogController::class, 'update'])->name('admin.tickets.log.update')->summary('A端工单操作日志更新,完成工单'); |
| 260 | Route::get('/chat/{ticket_id}', [Aside\WorkOrder\TicketChatController::class, 'index'])->name('admin.tickets.chat.index')->summary('A端工单聊天记录'); | 260 | Route::get('/chat/{ticket_id}', [Aside\WorkOrder\TicketChatController::class, 'index'])->name('admin.tickets.chat.index')->summary('A端工单聊天记录'); |
| 261 | Route::post('/chat/{ticket_id}', [Aside\WorkOrder\TicketChatController::class, 'store'])->name('admin.tickets.chat.store')->summary('A端工单聊天记录创建'); | 261 | Route::post('/chat/{ticket_id}', [Aside\WorkOrder\TicketChatController::class, 'store'])->name('admin.tickets.chat.store')->summary('A端工单聊天记录创建'); |
| 262 | + Route::get('/pushNotify/{ticket_id}', [Aside\WorkOrder\TicketChatController::class, 'pushNotify'])->name('admin.tickets.pushNotify')->summary('A端工单推送企微群'); | ||
| 262 | }); | 263 | }); |
| 263 | 264 | ||
| 264 | //服务器配置 | 265 | //服务器配置 |
-
请 注册 或 登录 后发表评论