fix: 会员概览下一档按当前等级递进而非仅看积分门槛
All checks were successful
Build and Deploy / deploy (push) Successful in 1m22s
All checks were successful
Build and Deploy / deploy (push) Successful in 1m22s
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
80830e310f
commit
13257d9c24
@ -48,11 +48,14 @@ public class MarketingPortalMemberService : ApplicationService
|
||||
x => x.Id == mainCustomer.MemberLevelId.Value);
|
||||
}
|
||||
|
||||
var nextLevel = levels
|
||||
.Where(x => x.MinPoints > rollingPoints)
|
||||
// 下一档按「当前等级之后的下一档」算,不要只按积分阈值:
|
||||
// 否则铜卡客户积分已达更高档门槛、但等级尚未刷新时,会被误判为「已达最高」。
|
||||
var orderedLevels = levels
|
||||
.OrderBy(x => x.MinPoints)
|
||||
.ThenBy(x => x.Sort)
|
||||
.FirstOrDefault();
|
||||
.ThenBy(x => x.Id)
|
||||
.ToList();
|
||||
var nextLevel = ResolveOverviewNextLevel(orderedLevels, currentLevel);
|
||||
|
||||
return new MemberOverviewOutput
|
||||
{
|
||||
@ -72,6 +75,42 @@ public class MarketingPortalMemberService : ApplicationService
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 概览用下一档:有当前等级则取排序后的后一档;无当前等级则取最低档。
|
||||
/// </summary>
|
||||
private static MemberLevel? ResolveOverviewNextLevel(
|
||||
IReadOnlyList<MemberLevel> orderedLevels,
|
||||
MemberLevel? currentLevel)
|
||||
{
|
||||
if (orderedLevels.Count == 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if (currentLevel == null)
|
||||
{
|
||||
return orderedLevels[0];
|
||||
}
|
||||
|
||||
var index = -1;
|
||||
for (var i = 0; i < orderedLevels.Count; i++)
|
||||
{
|
||||
if (orderedLevels[i].Id == currentLevel.Id)
|
||||
{
|
||||
index = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (index < 0)
|
||||
{
|
||||
// 当前等级未在启用列表(停用/脏数据):按积分门槛找严格更高的下一档
|
||||
return orderedLevels.FirstOrDefault(x => x.MinPoints > currentLevel.MinPoints);
|
||||
}
|
||||
|
||||
return index + 1 < orderedLevels.Count ? orderedLevels[index + 1] : null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 我的积分流水。
|
||||
/// </summary>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user