Merge branch 'master' of http://47.244.231.31:8099/zhl/globalso-v6 into lyh-server
正在显示
5 个修改的文件
包含
107 行增加
和
5 行删除
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace App\Console\Commands\WorkOrder; | ||
| 4 | + | ||
| 5 | +use App\Models\ProjectAssociation\ProjectAssociation; | ||
| 6 | +use App\Models\Workchat\MessagePush; | ||
| 7 | +use App\Models\WorkOrder\Tickets; | ||
| 8 | +use Illuminate\Console\Command; | ||
| 9 | + | ||
| 10 | +class PushNotify extends Command | ||
| 11 | +{ | ||
| 12 | + /** | ||
| 13 | + * The name and signature of the console command. | ||
| 14 | + * | ||
| 15 | + * @var string | ||
| 16 | + */ | ||
| 17 | + protected $signature = 'workorder:push-notify'; | ||
| 18 | + | ||
| 19 | + /** | ||
| 20 | + * The console command description. | ||
| 21 | + * | ||
| 22 | + * @var string | ||
| 23 | + */ | ||
| 24 | + protected $description = 'tickets push notify'; | ||
| 25 | + | ||
| 26 | + /** | ||
| 27 | + * Create a new command instance. | ||
| 28 | + * | ||
| 29 | + * @return void | ||
| 30 | + */ | ||
| 31 | + public function __construct() | ||
| 32 | + { | ||
| 33 | + parent::__construct(); | ||
| 34 | + } | ||
| 35 | + | ||
| 36 | + /** | ||
| 37 | + * Execute the console command. | ||
| 38 | + * | ||
| 39 | + * @return int | ||
| 40 | + */ | ||
| 41 | + public function handle() | ||
| 42 | + { | ||
| 43 | + while (true) { | ||
| 44 | + try { | ||
| 45 | + $tick = Tickets::where('ding', 0) | ||
| 46 | + ->where('submit_side', 2) | ||
| 47 | +// ->where('project_id', 1) | ||
| 48 | + ->first(); | ||
| 49 | + if (!$tick) { | ||
| 50 | + echo now() . " WARNING | 没有待推送的工单\n"; | ||
| 51 | + sleep(3); | ||
| 52 | + continue; | ||
| 53 | + } | ||
| 54 | + $project = $tick->project; | ||
| 55 | + if ($project->version != 6 || $project->is_del == 1) { | ||
| 56 | + echo now() . " WARNING | 项目版本或状态异常 \n"; | ||
| 57 | + $tick->ding = 1; | ||
| 58 | + $tick->save(); | ||
| 59 | + continue; | ||
| 60 | + } | ||
| 61 | + $message_push = new MessagePush(); | ||
| 62 | + $message_push->project_id = $project->table_id; | ||
| 63 | + $message_push->friend_id = ProjectAssociation::where('project_id', $project->table_id) | ||
| 64 | + ->where('status', ProjectAssociation::STATUS_NORMAL) | ||
| 65 | + ->where('binding_app', ProjectAssociation::ENTERPRISE_WECHAT) | ||
| 66 | + ->value('friend_id'); | ||
| 67 | + if (empty($message_push->friend_id)) | ||
| 68 | + { | ||
| 69 | + echo now() . " WARNING | 项目ID:{$project->table_id} 没有绑定企微群\n"; | ||
| 70 | + $tick->ding = 1; | ||
| 71 | + $tick->save(); | ||
| 72 | + continue; | ||
| 73 | + } | ||
| 74 | + $message_push->content_type = 'Link'; | ||
| 75 | + $message_push->content = json_encode([ | ||
| 76 | + 'title' => '工单查看 - ' . $project->company_name, | ||
| 77 | + 'desc' => $tick->title, | ||
| 78 | + 'size' => 0, | ||
| 79 | + 'thumbSize' => 0, | ||
| 80 | + 'thumbUrl' => 'https://www.cmer.com/uploads/logo1.png', | ||
| 81 | + 'url' => 'https://oa.quanqiusou.cn/tickets?project_id='.$project->uuid | ||
| 82 | + ], JSON_UNESCAPED_UNICODE); | ||
| 83 | + $message_push->send_time = now(); | ||
| 84 | + $message_push->type = MessagePush::TYPE_TICKET; | ||
| 85 | + $message_push->save(); | ||
| 86 | + $tick->ding = 1; | ||
| 87 | + $tick->save(); | ||
| 88 | + echo now() . " INFO | 项目ID:{$project->table_id} 工单ID:{$tick->id} 推送成功\n"; | ||
| 89 | + }catch (\Exception $exception){ | ||
| 90 | + echo date('Y-m-d H:i:s')." ERROR | ".$exception->getMessage()."\n"; | ||
| 91 | + break; | ||
| 92 | + } | ||
| 93 | + } | ||
| 94 | + } | ||
| 95 | +} |
| @@ -3,7 +3,6 @@ | @@ -3,7 +3,6 @@ | ||
| 3 | namespace App\Console\Commands\WorkOrder; | 3 | namespace App\Console\Commands\WorkOrder; |
| 4 | 4 | ||
| 5 | use App\Models\WorkOrder\TicketLog; | 5 | use App\Models\WorkOrder\TicketLog; |
| 6 | -use App\Models\WorkOrder\WorkOrderLog; | ||
| 7 | use App\Services\DingTalkService; | 6 | use App\Services\DingTalkService; |
| 8 | use Illuminate\Console\Command; | 7 | use Illuminate\Console\Command; |
| 9 | use Illuminate\Support\Facades\Http; | 8 | use Illuminate\Support\Facades\Http; |
| @@ -133,7 +133,7 @@ class NoticeController extends BaseController | @@ -133,7 +133,7 @@ class NoticeController extends BaseController | ||
| 133 | $origin_domain = $origin_array['host'] ?? ''; | 133 | $origin_domain = $origin_array['host'] ?? ''; |
| 134 | } | 134 | } |
| 135 | if (empty($origin_domain)) { | 135 | if (empty($origin_domain)) { |
| 136 | - return $this->error('origin_domain参数不能为空'); | 136 | + return $this->error('origin_domain参数填写有误'); |
| 137 | } | 137 | } |
| 138 | 138 | ||
| 139 | if(strpos($target_domain,'http') !== false){ | 139 | if(strpos($target_domain,'http') !== false){ |
| @@ -141,7 +141,7 @@ class NoticeController extends BaseController | @@ -141,7 +141,7 @@ class NoticeController extends BaseController | ||
| 141 | $target_domain = $target_array['host'] ?? ''; | 141 | $target_domain = $target_array['host'] ?? ''; |
| 142 | } | 142 | } |
| 143 | if (empty($target_domain)) { | 143 | if (empty($target_domain)) { |
| 144 | - return $this->error('target_domain参数不能为空'); | 144 | + return $this->error('target_domain参数填写有误'); |
| 145 | } | 145 | } |
| 146 | 146 | ||
| 147 | 147 | ||
| @@ -150,7 +150,14 @@ class NoticeController extends BaseController | @@ -150,7 +150,14 @@ class NoticeController extends BaseController | ||
| 150 | } | 150 | } |
| 151 | 151 | ||
| 152 | if($other_domain){ | 152 | if($other_domain){ |
| 153 | - foreach ($other_domain as $ov) { | 153 | + foreach ($other_domain as &$ov) { |
| 154 | + if(strpos($ov,'http') !== false){ | ||
| 155 | + $ov_array = parse_url($ov); | ||
| 156 | + $ov = $ov_array['host'] ?? ''; | ||
| 157 | + } | ||
| 158 | + if(empty($ov)){ | ||
| 159 | + return $this->error('other_domain参数填写有误'); | ||
| 160 | + } | ||
| 154 | if (!check_domain_record($ov, ['domain'=>'','ip'=>DomainInfo::SERVER_IP_301])) { | 161 | if (!check_domain_record($ov, ['domain'=>'','ip'=>DomainInfo::SERVER_IP_301])) { |
| 155 | return $this->error($ov . ' 未解析至 ' . DomainInfo::SERVER_IP_301); | 162 | return $this->error($ov . ' 未解析至 ' . DomainInfo::SERVER_IP_301); |
| 156 | } | 163 | } |
| @@ -26,7 +26,7 @@ class AsideTicketController extends BaseController | @@ -26,7 +26,7 @@ class AsideTicketController extends BaseController | ||
| 26 | 'logs.engineer:id,name', | 26 | 'logs.engineer:id,name', |
| 27 | 'project', | 27 | 'project', |
| 28 | ]) | 28 | ]) |
| 29 | - ->when($validated['engineer_id'], function ($query) use ($validated) { | 29 | + ->when(!empty($validated['engineer_id']), function ($query) use ($validated) { |
| 30 | // 查 gl_tickets 表 submit_user_id 或 gl_ticket_logs 表 engineer_id | 30 | // 查 gl_tickets 表 submit_user_id 或 gl_ticket_logs 表 engineer_id |
| 31 | $engineerId = $validated['engineer_id']; | 31 | $engineerId = $validated['engineer_id']; |
| 32 | return $query->where(function ($q) use ($engineerId) { | 32 | return $query->where(function ($q) use ($engineerId) { |
| @@ -27,6 +27,7 @@ class MessagePush extends Base | @@ -27,6 +27,7 @@ class MessagePush extends Base | ||
| 27 | 27 | ||
| 28 | const TYPE_INQUIRY = 'inquiry'; | 28 | const TYPE_INQUIRY = 'inquiry'; |
| 29 | const TYPE_WEEK = 'week'; | 29 | const TYPE_WEEK = 'week'; |
| 30 | + const TYPE_TICKET = 'ticket'; | ||
| 30 | //设置关联表名 | 31 | //设置关联表名 |
| 31 | /** | 32 | /** |
| 32 | * @var mixed | 33 | * @var mixed |
-
请 注册 或 登录 后发表评论