67 lines
2.0 KiB
PHP
67 lines
2.0 KiB
PHP
<?php
|
|
|
|
/**
|
|
* 文件功能:节日福利发放批次测试工厂
|
|
*
|
|
* 用于测试中快速创建已触发的节日福利批次与历史快照。
|
|
*/
|
|
|
|
namespace Database\Factories;
|
|
|
|
use App\Models\HolidayEvent;
|
|
use App\Models\HolidayEventRun;
|
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
|
|
|
/**
|
|
* @extends Factory<HolidayEventRun>
|
|
*/
|
|
class HolidayEventRunFactory extends Factory
|
|
{
|
|
/**
|
|
* 定义默认批次测试数据。
|
|
*
|
|
* @return array<string, mixed>
|
|
*/
|
|
public function definition(): array
|
|
{
|
|
$event = HolidayEvent::query()->create([
|
|
'name' => '节日福利测试模板',
|
|
'description' => '用于测试的节日福利模板',
|
|
'total_amount' => 6000,
|
|
'max_claimants' => 10,
|
|
'distribute_type' => 'fixed',
|
|
'min_amount' => 100,
|
|
'max_amount' => 1000,
|
|
'fixed_amount' => 600,
|
|
'send_at' => now(),
|
|
'expire_minutes' => 30,
|
|
'repeat_type' => 'once',
|
|
'target_type' => 'all',
|
|
'status' => 'pending',
|
|
'enabled' => true,
|
|
]);
|
|
|
|
return [
|
|
'holiday_event_id' => $event->id,
|
|
'event_name' => $event->name,
|
|
'event_description' => $event->description,
|
|
'total_amount' => $event->total_amount,
|
|
'max_claimants' => $event->max_claimants,
|
|
'distribute_type' => $event->distribute_type,
|
|
'min_amount' => $event->min_amount,
|
|
'max_amount' => $event->max_amount,
|
|
'fixed_amount' => $event->fixed_amount,
|
|
'target_type' => $event->target_type,
|
|
'target_value' => $event->target_value,
|
|
'repeat_type' => $event->repeat_type,
|
|
'scheduled_for' => now(),
|
|
'triggered_at' => now(),
|
|
'expires_at' => now()->addMinutes(30),
|
|
'status' => 'active',
|
|
'audience_count' => 0,
|
|
'claimed_count' => 0,
|
|
'claimed_amount' => 0,
|
|
];
|
|
}
|
|
}
|