\App\JobsSendChannelJob

渠道发送任务骨架

职责:把「注册表启用校验 + 渠道发送 + sent=false 抛异常走重试/终败」模板化—— 子类只需实现 send()(按注册表绑定调 MailService/SmsService)与 channelName()(失败文案用「邮件/短信」)。

Summary

Methods
Properties
Constants
__construct()
handle()
$typeCode
$data
$logId
No constants found
execute()
channelName()
send()
No protected properties found
N/A
No private methods found
No private properties found
N/A

Properties

$typeCode

$typeCode : string

队列编码(注册表锚点,处理器据此读取界面配置)

Type

string

$data

$data : array

载荷内容(schema 校验后的业务数据,执行台账全量快照)。 命名 $data 而非 $payload:InteractsWithQueue 以 __get('payload') 读取队列原始载荷 (attempts() 依赖它),同名属性会遮蔽魔术方法导致重试计数恒为 1——命名冲突不可犯。

Type

array

$logId

$logId : int

执行台账行 id(状态推进锚点)

Type

int

Methods

__construct()

__construct(string  $typeCode, array  $payload, int  $logId) : mixed

构造:从注册表动态应用重试策略——tries/backoff/timeout/queue 全部界面配置; afterCommit 在此赋值(Queueable 声明同属性默认 false,类内重复声明被 PHP 判为 不兼容——事务提交后投递统一规避 after_commit=false 的抢跑竞态,业务方零感知)。

Parameters

string $typeCode
array $payload
int $logId

Throws

\Illuminate\Database\Eloquent\ModelNotFoundException

队列未登记

Returns

mixed —

handle()

handle() : void

执行模板(final):记账 + 调度 execute(),业务不得覆写。

流程:① 标记处理中(幂等,与 JobProcessing 事件协作) ② execute() 正常返回 → 结果入台账、标记成功 ③ execute() 抛异常 → 单次失败入台账、原样上抛交 Laravel 重试/终败

execute()

execute() : mixed

执行模板:注册表启用校验 → 渠道发送 → sent=false 抛异常(失败原因带内容入台账)。

Returns

mixed —

结果(数组优先原样入台账;标量包为 {result: value})

channelName()

channelName() : string

渠道名(失败文案用:邮件/短信)

Returns

string —

send()

send(\App\Models\SysJobType  $type) : array

渠道发送动作:返回 {sent: bool, message?: string} 契约结果。

Parameters

\App\Models\SysJobType $type

Returns

array —