feat: 翻牌与邀请码逻辑重构,新增中奖记录与前7次中奖概率
- CardFlipTaskAggregateRoot.cs
- 用 WinRecords(Dictionary<int,long>) 替代原先第8/9/10次的各自字段,且以 JSON 存库(SugarColumn IsJson)。
- 构造函数初始化 WinRecords。
- 新增 SetWinReward(int flipCount, long amount) 统一记录中奖。
- CardFlipService.cs
- 读取并展示 WinRecords,按翻牌顺序映射中奖信息(不再依赖单独的第8/9/10字段)。
- CardFlipManager.cs
- 重构中奖逻辑:
- 前7次翻牌改为 50% 概率可中奖,奖励范围 1w–3w(新增配置常量 FREE_*)。
- 统一通过 SetWinReward 记录任意次的中奖金额。
- GenerateRandomReward 根据最小值自动选单位(1w 或 100w)。
- 邀请类型翻牌校验由“仅统计被填写次数”改为“统计本周作为邀请人或被邀请人的邀请记录数量”(双方都计入),并据此判断是否可解锁邀请翻牌次数。
- InviteCodeManager.cs
- 使用邀请码时:
- 验证规则调整:一个账号只能填写别人的邀请码一次(hasUsedOthersCode 检查)。
- 邀请记录的语义变化:当使用邀请码时,邀请记录同时代表邀请人和被邀请人各增加一次翻牌机会。
- 不再将邀请码标记为单次已用;改为增加 UsedCount(一个邀请码可以被多人使用)。
- 优化日志与提示信息。
- InviteCodeAggregateRoot.cs
- 移除 IsUsed、UsedTime、UsedByUserId、MarkAsUsed 等单次使用相关字段/方法。
- 保留 IsUserInvited(被邀请后不能再作为被邀请者使用)和 UsedCount(统计多人使用次数)。
注意事项
- 这是数据结构与业务逻辑的变更,数据库表结构发生变化(新增 WinRecords JSON 字段,移除若干字段)。上线前请准备相应的迁移脚本或数据迁移方案,确保历史中奖数据平滑迁移到 WinRecords。
- 变更会影响相关单元/集成测试、前端展示字段,需同步更新对应测试与界面展示逻辑。
This commit is contained in:
@@ -25,9 +25,8 @@ public class CardFlipTaskAggregateRoot : FullAuditedAggregateRoot<Guid>
|
||||
BonusFlipsUsed = 0;
|
||||
InviteFlipsUsed = 0;
|
||||
IsFirstFlipDone = false;
|
||||
HasNinthReward = false;
|
||||
HasTenthReward = false;
|
||||
FlippedOrder = new List<int>();
|
||||
WinRecords = new Dictionary<int, long>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -66,34 +65,10 @@ public class CardFlipTaskAggregateRoot : FullAuditedAggregateRoot<Guid>
|
||||
public bool IsFirstFlipDone { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否已获得第8次奖励
|
||||
/// 中奖记录(以翻牌顺序为key,例如第1次翻牌中奖则key为1,奖励金额为value)
|
||||
/// </summary>
|
||||
public bool HasEighthReward { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 第8次奖励金额(100-300w)
|
||||
/// </summary>
|
||||
public long? EighthRewardAmount { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否已获得第9次奖励
|
||||
/// </summary>
|
||||
public bool HasNinthReward { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 第9次奖励金额(100-500w)
|
||||
/// </summary>
|
||||
public long? NinthRewardAmount { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否已获得第10次奖励
|
||||
/// </summary>
|
||||
public bool HasTenthReward { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 第10次奖励金额(100-1000w)
|
||||
/// </summary>
|
||||
public long? TenthRewardAmount { get; set; }
|
||||
[SugarColumn(IsJson = true, IsNullable = true)]
|
||||
public Dictionary<int, long>? WinRecords { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 备注信息
|
||||
@@ -135,33 +110,17 @@ public class CardFlipTaskAggregateRoot : FullAuditedAggregateRoot<Guid>
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 记录第8次奖励
|
||||
/// 记录中奖
|
||||
/// </summary>
|
||||
/// <param name="flipCount">第几次翻牌(1-10)</param>
|
||||
/// <param name="amount">奖励金额</param>
|
||||
public void SetEighthReward(long amount)
|
||||
public void SetWinReward(int flipCount, long amount)
|
||||
{
|
||||
HasEighthReward = true;
|
||||
EighthRewardAmount = amount;
|
||||
}
|
||||
|
||||
/// <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;
|
||||
if (WinRecords == null)
|
||||
{
|
||||
WinRecords = new Dictionary<int, long>();
|
||||
}
|
||||
WinRecords[flipCount] = amount;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user