'datetime', 'triggered_at' => 'datetime', 'expires_at' => 'datetime', 'enabled' => 'boolean', 'total_amount' => 'integer', 'max_claimants' => 'integer', 'min_amount' => 'integer', 'max_amount' => 'integer', 'fixed_amount' => 'integer', 'expire_minutes' => 'integer', 'schedule_month' => 'integer', 'schedule_day' => 'integer', 'duration_days' => 'integer', 'daily_occurrences' => 'integer', 'occurrence_interval_minutes' => 'integer', 'claimed_count' => 'integer', 'claimed_amount' => 'integer', ]; } /** * 本次活动的所有领取记录。 */ public function claims(): HasMany { return $this->hasMany(HolidayClaim::class, 'event_id'); } /** * 本模板对应的所有发放批次。 */ public function runs(): HasMany { return $this->hasMany(HolidayEventRun::class, 'holiday_event_id'); } /** * 判断模板是否使用年度节日调度。 */ public function usesYearlySchedule(): bool { return $this->repeat_type === 'yearly'; } /** * 查询待触发的活动(定时任务调用)。 */ public static function pendingToTrigger(): \Illuminate\Database\Eloquent\Collection { return static::query() ->where('status', 'pending') ->where('enabled', true) ->whereNotNull('send_at') ->where('send_at', '<=', now()) ->get(); } }