love_php/app/Jobs/ParticipantPacketNotice.php
2026-04-02 09:20:51 +08:00

56 lines
1.5 KiB
PHP

<?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;
class ParticipantPacketNotice implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
protected $participants;
/**
* Create a new job instance.
*
* @return void
*/
public function __construct($participants)
{
$this->participants = $participants;
}
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
foreach ($this->participants as $participant) {
$result = $this->textMessage($participant);
}
return;
}
//客服信息
public function textMessage($participant)
{
$app = app('wechat.official_account');
// $url = env('APP_URL')."/rp/#/redPacketFruit?official_openid=".$participant['official_openid'];
$url = env('APP_URL')."/red/packet/activity/wechat/auth";
$nickname = $participant['nickname']?:'朋友';
$message = $nickname.',恭喜您!,已经获得本月领取九果红包资格,<a href="'.$url.'">马上领取GO!</a>
如已领取,请过滤此消息。
';
$text = new Text($message);
$openId = $participant['official_openid'];
$result = $app->customer_service->message($text)->to($openId)->send();
return $result;
}
}