user_id = $user_id; $this->type = $type; $this->type_id = $type_id; $this->content = $content; } /** * Execute the job. * * @return void */ public function handle() { switch ($this->type){ case 'team': $team = Team::with('owner:id,nickname')->where('id', $this->type_id)->first(); break; default: break; } foreach ($this->user_id as $user_id){ $result = $this->sendAttachMsg($this->type_id, 'team', $this->content, $team->owner, $user_id, $team->icon); } return true; } //发送系统通知 public function sendAttachMsg($type_id, $type, $content, $from, $to, $image) { $body = "点击查看>>"; //发送评论自定义系统消息 $im_service = new IMService(); $attach = ["myattach"=>$content, $type.'_id'=>$type_id]; $payload = [ "apsField"=>[ "alert"=>[ "title"=>$content, "body"=> $body, ], "mutable-content"=>1 ], "hwField"=>[ "click_action"=>[ "type"=>1, "intent"=>"intent://com.huawei.codelabpush/deeplink?id=".$type_id."&customType=".$type."#Intent;scheme=pushscheme;launchFlags=0x4000000;end", ], "title"=>$content, "body"=>$body, ], "oppoField"=>[ "click_action_type"=>1, "click_action_activity"=>"com.oppo.codelabpush.intent.action.test", "action_parameters"=>[ "id"=>$type_id, "customType"=>"moment", ], ], "apnsText"=>$body, "pushTitle"=>$content, "customType"=>$type, "content"=>$body, "media_image"=>$image, "media_type"=>'image', "id"=>$type_id, "type"=>$type, 'passThrough'=>1, ]; $result = $im_service->sendAttachMsg($from,0,$to,json_encode($attach),$content,$payload); return true; } }