Files
chatroom/app/Jobs/ExpireWeddingEnvelopes.php

37 lines
948 B
PHP
Raw Normal View History

<?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']);
}
}