新增每日签到与补签卡功能

This commit is contained in:
2026-04-24 22:47:27 +08:00
parent 34356a26ae
commit be9fc09d9d
46 changed files with 3934 additions and 55 deletions
+42
View File
@@ -0,0 +1,42 @@
<?php
/**
* 文件功能:每日签到记录测试工厂。
*
* 用于测试中快速构造用户签到流水和连续签到奖励快照。
*/
namespace Database\Factories;
use App\Models\DailySignIn;
use App\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
* @extends Factory<DailySignIn>
*/
class DailySignInFactory extends Factory
{
/**
* 定义默认每日签到测试数据。
*
* @return array<string, mixed>
*/
public function definition(): array
{
return [
'user_id' => User::factory(),
'room_id' => null,
'sign_in_date' => today(),
'streak_days' => 1,
'reward_rule_id' => null,
'gold_reward' => 0,
'exp_reward' => 0,
'charm_reward' => 0,
'identity_badge_code' => null,
'identity_badge_name' => null,
'identity_badge_icon' => null,
'identity_badge_color' => null,
];
}
}
@@ -0,0 +1,40 @@
<?php
/**
* 文件功能:每日签到奖励规则测试工厂。
*
* 用于测试中快速构造不同连续天数门槛的签到奖励规则。
*/
namespace Database\Factories;
use App\Models\SignInRewardRule;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
* @extends Factory<SignInRewardRule>
*/
class SignInRewardRuleFactory extends Factory
{
/**
* 定义默认签到奖励规则测试数据。
*
* @return array<string, mixed>
*/
public function definition(): array
{
return [
'streak_days' => fake()->unique()->numberBetween(1, 30),
'gold_reward' => 100,
'exp_reward' => 10,
'charm_reward' => 0,
'identity_badge_code' => null,
'identity_badge_name' => null,
'identity_badge_icon' => null,
'identity_badge_color' => '#0f766e',
'identity_duration_days' => 0,
'is_enabled' => true,
'sort_order' => 0,
];
}
}
@@ -0,0 +1,40 @@
<?php
/**
* 文件功能:用户身份徽章测试工厂。
*
* 用于测试中快速构造签到来源或其他来源的身份徽章。
*/
namespace Database\Factories;
use App\Models\User;
use App\Models\UserIdentityBadge;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
* @extends Factory<UserIdentityBadge>
*/
class UserIdentityBadgeFactory extends Factory
{
/**
* 定义默认身份徽章测试数据。
*
* @return array<string, mixed>
*/
public function definition(): array
{
return [
'user_id' => User::factory(),
'source' => UserIdentityBadge::SOURCE_SIGN_IN,
'badge_code' => 'sign_in_beginner',
'badge_name' => '签到新星',
'badge_icon' => null,
'badge_color' => '#0f766e',
'acquired_at' => now(),
'expires_at' => null,
'is_active' => true,
'metadata' => [],
];
}
}