2025-10-23 21:58:47 +08:00
|
|
|
|
using SqlSugar;
|
|
|
|
|
|
using Volo.Abp.Domain.Entities.Auditing;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Yi.Framework.AiHub.Domain.Entities;
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 翻牌任务记录
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
[SugarTable("Ai_CardFlipTask")]
|
|
|
|
|
|
[SugarIndex($"index_{nameof(UserId)}_{nameof(WeekStartDate)}",
|
|
|
|
|
|
nameof(UserId), OrderByType.Asc,
|
|
|
|
|
|
nameof(WeekStartDate), OrderByType.Desc)]
|
|
|
|
|
|
public class CardFlipTaskAggregateRoot : FullAuditedAggregateRoot<Guid>
|
|
|
|
|
|
{
|
|
|
|
|
|
public CardFlipTaskAggregateRoot()
|
|
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public CardFlipTaskAggregateRoot(Guid userId, DateTime weekStartDate)
|
|
|
|
|
|
{
|
|
|
|
|
|
UserId = userId;
|
|
|
|
|
|
WeekStartDate = weekStartDate.Date; // 确保只存储日期部分
|
|
|
|
|
|
TotalFlips = 0;
|
|
|
|
|
|
FreeFlipsUsed = 0;
|
|
|
|
|
|
BonusFlipsUsed = 0;
|
|
|
|
|
|
InviteFlipsUsed = 0;
|
|
|
|
|
|
IsFirstFlipDone = false;
|
2025-10-27 21:57:26 +08:00
|
|
|
|
FlippedOrder = new List<int>();
|
2025-11-07 21:31:18 +08:00
|
|
|
|
WinRecords = new Dictionary<int, long>();
|
2025-10-23 21:58:47 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 用户ID
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public Guid UserId { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 本周开始日期(每周一)
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public DateTime WeekStartDate { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 总共已翻牌次数
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public int TotalFlips { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2025-10-30 19:51:56 +08:00
|
|
|
|
/// 已使用的免费次数(最多7次)
|
2025-10-23 21:58:47 +08:00
|
|
|
|
/// </summary>
|
|
|
|
|
|
public int FreeFlipsUsed { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2025-10-30 19:51:56 +08:00
|
|
|
|
/// 已使用的赠送次数(已废弃,保持为0)
|
2025-10-23 21:58:47 +08:00
|
|
|
|
/// </summary>
|
|
|
|
|
|
public int BonusFlipsUsed { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2025-10-30 19:51:56 +08:00
|
|
|
|
/// 已使用的邀请解锁次数(最多3次)
|
2025-10-23 21:58:47 +08:00
|
|
|
|
/// </summary>
|
|
|
|
|
|
public int InviteFlipsUsed { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 是否已完成首次翻牌(用于判断是否创建任务)
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public bool IsFirstFlipDone { get; set; }
|
|
|
|
|
|
|
2025-10-29 21:55:17 +08:00
|
|
|
|
/// <summary>
|
2025-11-07 21:31:18 +08:00
|
|
|
|
/// 中奖记录(以翻牌顺序为key,例如第1次翻牌中奖则key为1,奖励金额为value)
|
2025-10-29 21:55:17 +08:00
|
|
|
|
/// </summary>
|
2025-11-07 21:31:18 +08:00
|
|
|
|
[SugarColumn(IsJson = true, IsNullable = true)]
|
|
|
|
|
|
public Dictionary<int, long>? WinRecords { get; set; }
|
2025-10-23 21:58:47 +08:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 备注信息
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
[SugarColumn(Length = 500, IsNullable = true)]
|
|
|
|
|
|
public string? Remark { get; set; }
|
|
|
|
|
|
|
2025-10-27 21:57:26 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 已翻牌的顺序(存储用户实际翻牌的序号列表,如[3,7,1,5]表示依次翻了3号、7号、1号、5号牌)
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
[SugarColumn(IsJson = true, IsNullable = true)]
|
|
|
|
|
|
public List<int>? FlippedOrder { get; set; }
|
|
|
|
|
|
|
2025-10-23 21:58:47 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 增加翻牌次数
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="flipType">翻牌类型</param>
|
|
|
|
|
|
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;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-10-29 21:55:17 +08:00
|
|
|
|
/// <summary>
|
2025-11-07 21:31:18 +08:00
|
|
|
|
/// 记录中奖
|
2025-10-23 21:58:47 +08:00
|
|
|
|
/// </summary>
|
2025-11-07 21:31:18 +08:00
|
|
|
|
/// <param name="flipCount">第几次翻牌(1-10)</param>
|
2025-10-23 21:58:47 +08:00
|
|
|
|
/// <param name="amount">奖励金额</param>
|
2025-11-07 21:31:18 +08:00
|
|
|
|
public void SetWinReward(int flipCount, long amount)
|
2025-10-23 21:58:47 +08:00
|
|
|
|
{
|
2025-11-07 21:31:18 +08:00
|
|
|
|
if (WinRecords == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
WinRecords = new Dictionary<int, long>();
|
|
|
|
|
|
}
|
|
|
|
|
|
WinRecords[flipCount] = amount;
|
2025-10-23 21:58:47 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 翻牌类型枚举
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public enum FlipType
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
2025-10-30 19:51:56 +08:00
|
|
|
|
/// 免费翻牌(1-7次)
|
2025-10-23 21:58:47 +08:00
|
|
|
|
/// </summary>
|
|
|
|
|
|
Free = 0,
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2025-10-30 19:51:56 +08:00
|
|
|
|
/// 赠送翻牌(已废弃)
|
2025-10-23 21:58:47 +08:00
|
|
|
|
/// </summary>
|
|
|
|
|
|
Bonus = 1,
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2025-10-30 19:51:56 +08:00
|
|
|
|
/// 邀请解锁翻牌(8-10次)
|
2025-10-23 21:58:47 +08:00
|
|
|
|
/// </summary>
|
|
|
|
|
|
Invite = 2
|
|
|
|
|
|
}
|