功能:婚姻系统第11步(Horizon Jobs + 定时任务)
5个 Job: - ExpireMarriageProposals:每5分钟扫描超时求婚(广播通知) - TriggerScheduledWeddings:每5分钟触发定时婚礼(广播庆典) - AutoExpireDivorces:每小时处理离婚超时自动解除 - ExpireWeddingEnvelopes:每小时清理过期红包 - ProcessMarriageIntimacy:每日00:05全量亲密度时间奖励 console.php 注册5个 Schedule
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* 文件功能:清理过期婚礼红包(24h 后自动消失)
|
||||
*
|
||||
* 每小时执行一次,将超过 expires_at 且有未领取 claims 的婚礼标记为 expired。
|
||||
* 未领取的金额不退还(设计决定:促进即时领取)。
|
||||
*
|
||||
* @author ChatRoom Laravel
|
||||
*
|
||||
* @version 1.0.0
|
||||
*/
|
||||
|
||||
namespace App\Jobs;
|
||||
|
||||
use App\Models\WeddingCeremony;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Queue\Queueable;
|
||||
|
||||
class ExpireWeddingEnvelopes implements ShouldQueue
|
||||
{
|
||||
use Queueable;
|
||||
|
||||
/**
|
||||
* 执行 Job:将过期的 active 婚礼标记为 completed(已过领取期)。
|
||||
*/
|
||||
public function handle(): void
|
||||
{
|
||||
// 将已过期的婚礼状态改为 completed
|
||||
WeddingCeremony::query()
|
||||
->where('status', 'active')
|
||||
->whereNotNull('expires_at')
|
||||
->where('expires_at', '<', now())
|
||||
->update(['status' => 'completed']);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user