updateTicket.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. namespace App\Console\Commands;
  3. use App\Models\TicketReply;
  4. use App\Models\User;
  5. use Illuminate\Console\Command;
  6. use Log;
  7. class updateTicket extends Command {
  8. protected $signature = 'updateTicket';
  9. protected $description = '更新工单';
  10. public function __construct() {
  11. parent::__construct();
  12. }
  13. public function handle() {
  14. Log::info('----------------------------【更新工单】开始----------------------------');
  15. // 获取管理员
  16. $adminList = User::query()->whereIsAdmin(1)->get();
  17. foreach($adminList as $admin){
  18. Log::info('----------------------------【更新管理员'.$admin->id.'回复工单】开始----------------------------');
  19. // 获取该管理回复过的工单
  20. $replyList = TicketReply::query()->whereUserId($admin->id)->get();
  21. // 更新工单
  22. foreach($replyList as $reply){
  23. $ret = TicketReply::query()->whereId($reply->id)->update(['user_id' => 0, 'admin_id' => $admin->id]);
  24. if($ret){
  25. Log::info('--- 管理员:'.$admin->email.'回复子单ID:'.$reply->id.' ---');
  26. }else{
  27. Log::error('更新回复子单ID:【'.$reply->id.'】 失败!');
  28. }
  29. }
  30. Log::info('----------------------------【更新管理员'.$admin->id.'回复工单】完成----------------------------');
  31. }
  32. Log::info('----------------------------【更新工单】结束----------------------------');
  33. }
  34. }