- 在 CardFlipStatusOutput 与前端 types 添加 FlipOrderIndex 字段以记录牌在翻牌顺序中的位置 - 在域实体 CardFlipTaskAggregateRoot 增加 FlippedOrder(Json 列)以保存用户实际翻牌顺序 - 将 CardFlipService 重构为调用 CardFlipManager 与 InviteCodeManager,移除大量内聚的业务实现与常量(职责下沉到 Manager) - 调整翻牌、使用邀请码和查询相关流程为 Manager 驱动,更新返回结构与提示文本 - 更新前端 CardFlipActivity 组件与 types,允许任意未翻的卡片被点击并显示翻牌顺序位置 - 若干文案、格式与日志细节修正
168 lines
4.0 KiB
C#
168 lines
4.0 KiB
C#
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;
|
||
HasNinthReward = false;
|
||
HasTenthReward = false;
|
||
FlippedOrder = new List<int>();
|
||
}
|
||
|
||
/// <summary>
|
||
/// 用户ID
|
||
/// </summary>
|
||
public Guid UserId { get; set; }
|
||
|
||
/// <summary>
|
||
/// 本周开始日期(每周一)
|
||
/// </summary>
|
||
public DateTime WeekStartDate { get; set; }
|
||
|
||
/// <summary>
|
||
/// 总共已翻牌次数
|
||
/// </summary>
|
||
public int TotalFlips { get; set; }
|
||
|
||
/// <summary>
|
||
/// 已使用的免费次数(最多5次)
|
||
/// </summary>
|
||
public int FreeFlipsUsed { get; set; }
|
||
|
||
/// <summary>
|
||
/// 已使用的赠送次数(最多3次)
|
||
/// </summary>
|
||
public int BonusFlipsUsed { get; set; }
|
||
|
||
/// <summary>
|
||
/// 已使用的邀请解锁次数(最多2次)
|
||
/// </summary>
|
||
public int InviteFlipsUsed { get; set; }
|
||
|
||
/// <summary>
|
||
/// 是否已完成首次翻牌(用于判断是否创建任务)
|
||
/// </summary>
|
||
public bool IsFirstFlipDone { get; set; }
|
||
|
||
/// <summary>
|
||
/// 是否已获得第9次奖励
|
||
/// </summary>
|
||
public bool HasNinthReward { get; set; }
|
||
|
||
/// <summary>
|
||
/// 第9次奖励金额(300-700w)
|
||
/// </summary>
|
||
public long? NinthRewardAmount { get; set; }
|
||
|
||
/// <summary>
|
||
/// 是否已获得第10次奖励
|
||
/// </summary>
|
||
public bool HasTenthReward { get; set; }
|
||
|
||
/// <summary>
|
||
/// 第10次奖励金额(800-1200w)
|
||
/// </summary>
|
||
public long? TenthRewardAmount { get; set; }
|
||
|
||
/// <summary>
|
||
/// 备注信息
|
||
/// </summary>
|
||
[SugarColumn(Length = 500, IsNullable = true)]
|
||
public string? Remark { get; set; }
|
||
|
||
/// <summary>
|
||
/// 已翻牌的顺序(存储用户实际翻牌的序号列表,如[3,7,1,5]表示依次翻了3号、7号、1号、5号牌)
|
||
/// </summary>
|
||
[SugarColumn(IsJson = true, IsNullable = true)]
|
||
public List<int>? FlippedOrder { get; set; }
|
||
|
||
/// <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;
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 记录第9次奖励
|
||
/// </summary>
|
||
/// <param name="amount">奖励金额</param>
|
||
public void SetNinthReward(long amount)
|
||
{
|
||
HasNinthReward = true;
|
||
NinthRewardAmount = amount;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 记录第10次奖励
|
||
/// </summary>
|
||
/// <param name="amount">奖励金额</param>
|
||
public void SetTenthReward(long amount)
|
||
{
|
||
HasTenthReward = true;
|
||
TenthRewardAmount = amount;
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 翻牌类型枚举
|
||
/// </summary>
|
||
public enum FlipType
|
||
{
|
||
/// <summary>
|
||
/// 免费翻牌(1-5次)
|
||
/// </summary>
|
||
Free = 0,
|
||
|
||
/// <summary>
|
||
/// 赠送翻牌(6-8次)
|
||
/// </summary>
|
||
Bonus = 1,
|
||
|
||
/// <summary>
|
||
/// 邀请解锁翻牌(9-10次)
|
||
/// </summary>
|
||
Invite = 2
|
||
}
|