Files
chatroom/app/Jobs/ExpireWeddingEnvelopes.php
lkddi 143601c251 功能:婚姻系统第11步(Horizon Jobs + 定时任务)
5个 Job:
- ExpireMarriageProposals:每5分钟扫描超时求婚(广播通知)
- TriggerScheduledWeddings:每5分钟触发定时婚礼(广播庆典)
- AutoExpireDivorces:每小时处理离婚超时自动解除
- ExpireWeddingEnvelopes:每小时清理过期红包
- ProcessMarriageIntimacy:每日00:05全量亲密度时间奖励

console.php 注册5个 Schedule
2026-03-01 15:16:46 +08:00

37 lines
948 B
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?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']);
}
}