using SqlSugar; using Volo.Abp.Domain.Entities.Auditing; namespace Yi.Framework.AiHub.Domain.Entities; /// /// 翻牌任务记录 /// [SugarTable("Ai_CardFlipTask")] [SugarIndex($"index_{nameof(UserId)}_{nameof(WeekStartDate)}", nameof(UserId), OrderByType.Asc, nameof(WeekStartDate), OrderByType.Desc)] public class CardFlipTaskAggregateRoot : FullAuditedAggregateRoot { public CardFlipTaskAggregateRoot() { } public CardFlipTaskAggregateRoot(Guid userId, DateTime weekStartDate) { UserId = userId; WeekStartDate = weekStartDate.Date; // 确保只存储日期部分 TotalFlips = 0; FreeFlipsUsed = 0; BonusFlipsUsed = 0; InviteFlipsUsed = 0; IsFirstFlipDone = false; HasNinthReward = false; HasTenthReward = false; FlippedOrder = new List(); } /// /// 用户ID /// public Guid UserId { get; set; } /// /// 本周开始日期(每周一) /// public DateTime WeekStartDate { get; set; } /// /// 总共已翻牌次数 /// public int TotalFlips { get; set; } /// /// 已使用的免费次数(最多5次) /// public int FreeFlipsUsed { get; set; } /// /// 已使用的赠送次数(最多3次) /// public int BonusFlipsUsed { get; set; } /// /// 已使用的邀请解锁次数(最多2次) /// public int InviteFlipsUsed { get; set; } /// /// 是否已完成首次翻牌(用于判断是否创建任务) /// public bool IsFirstFlipDone { get; set; } /// /// 是否已获得第8次奖励 /// public bool HasEighthReward { get; set; } /// /// 第8次奖励金额(100-300w) /// public long? EighthRewardAmount { get; set; } /// /// 是否已获得第9次奖励 /// public bool HasNinthReward { get; set; } /// /// 第9次奖励金额(100-500w) /// public long? NinthRewardAmount { get; set; } /// /// 是否已获得第10次奖励 /// public bool HasTenthReward { get; set; } /// /// 第10次奖励金额(100-1000w) /// public long? TenthRewardAmount { get; set; } /// /// 备注信息 /// [SugarColumn(Length = 500, IsNullable = true)] public string? Remark { get; set; } /// /// 已翻牌的顺序(存储用户实际翻牌的序号列表,如[3,7,1,5]表示依次翻了3号、7号、1号、5号牌) /// [SugarColumn(IsJson = true, IsNullable = true)] public List? FlippedOrder { get; set; } /// /// 增加翻牌次数 /// /// 翻牌类型 public void IncrementFlip(FlipType flipType) { TotalFlips++; switch (flipType) { case FlipType.Free: FreeFlipsUsed++; break; case FlipType.Bonus: BonusFlipsUsed++; break; case FlipType.Invite: InviteFlipsUsed++; break; } if (!IsFirstFlipDone) { IsFirstFlipDone = true; } } /// /// 记录第8次奖励 /// /// 奖励金额 public void SetEighthReward(long amount) { HasEighthReward = true; EighthRewardAmount = amount; } /// /// 记录第9次奖励 /// /// 奖励金额 public void SetNinthReward(long amount) { HasNinthReward = true; NinthRewardAmount = amount; } /// /// 记录第10次奖励 /// /// 奖励金额 public void SetTenthReward(long amount) { HasTenthReward = true; TenthRewardAmount = amount; } } /// /// 翻牌类型枚举 /// public enum FlipType { /// /// 免费翻牌(1-5次) /// Free = 0, /// /// 赠送翻牌(6-8次) /// Bonus = 1, /// /// 邀请解锁翻牌(9-10次) /// Invite = 2 }