love_php/app/Jobs/SendServiceNews.php

48 lines
1.1 KiB
PHP
Raw Normal View History

2026-04-02 09:20:51 +08:00
<?php
namespace App\Jobs;
use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use EasyWeChat\Kernel\Messages\Text;
use Illuminate\Container\Container;
class SendServiceNews implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
protected $array;
/**
* Create a new job instance.
*
* @return void
*/
public function __construct($array)
{
$this->array = $array;
}
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
$array = $this->array;
$official_openid = $array['official_openid'];
$message = $array['text'];
$result = $this->textMessage($message, $official_openid);
}
public function textMessage($message, $openId)
{
$app = app('wechat.official_account');
$text = new Text($message);
$result = $app->customer_service->message($text)->to($openId)->send();
return $result;
}
}