diff --git a/honey_box/package/mine/equity.vue b/honey_box/package/mine/equity.vue index 7b4ad639..5f23d84b 100644 --- a/honey_box/package/mine/equity.vue +++ b/honey_box/package/mine/equity.vue @@ -49,7 +49,7 @@ 普通奖励 - + 高级奖励 @@ -65,7 +65,7 @@ - + item.gao_jiang && item.gao_jiang.length > 0); + } + }, + onLoad(options) { this.getData() this.tabChange(this.tabCur) diff --git a/server/HoneyBox/src/HoneyBox.Core/Services/QuanYiService.cs b/server/HoneyBox/src/HoneyBox.Core/Services/QuanYiService.cs index e8533b89..b65857d4 100644 --- a/server/HoneyBox/src/HoneyBox.Core/Services/QuanYiService.cs +++ b/server/HoneyBox/src/HoneyBox.Core/Services/QuanYiService.cs @@ -32,10 +32,16 @@ public class QuanYiService : IQuanYiService throw new InvalidOperationException("用户不存在"); } + // 从数据库获取等级配置 + var vipLevelConfigs = await _dbContext.VipLevels + .Where(v => v.DeletedAt == null) + .OrderBy(v => v.Level) + .ToListAsync(); + var response = new QuanYiResponse { UserImg = GetImageUrl(user.HeadImg), - QuanYiLevel = GetQuanYiLevelInfo(user.OuQiLevel ?? 0, user.OuQi ?? 0) + QuanYiLevel = GetQuanYiLevelInfo(user.OuQiLevel ?? 0, user.OuQi ?? 0, vipLevelConfigs) }; // Get all VIP levels with level > 0 @@ -374,43 +380,53 @@ public class QuanYiService : IQuanYiService /// /// Get QuanYi level info based on ou_qi_level and ou_qi /// - private QuanYiLevelInfo GetQuanYiLevelInfo(int ouQiLevel, int ouQi) + private QuanYiLevelInfo GetQuanYiLevelInfo(int ouQiLevel, int ouQi, List vipLevelConfigs) { - // This mimics the PHP User::ou_qi_level method - // Level titles based on ou_qi_level - var levelTitles = new Dictionary - { - { 0, "普通" }, - { 1, "青铜" }, - { 2, "白银" }, - { 3, "黄金" }, - { 4, "铂金" }, - { 5, "钻石" }, - { 6, "星耀" }, - { 7, "王者" } - }; + // 从数据库配置构建等级阈值 + var levelThresholds = vipLevelConfigs + .ToDictionary(v => v.Level, v => v.Number); + + // 构建等级标题 + var levelTitles = vipLevelConfigs + .ToDictionary(v => v.Level, v => v.Title ?? $"等级{v.Level}"); - var levelThresholds = new Dictionary + // 如果没有配置,使用默认值 + if (!levelThresholds.Any()) { - { 0, 0 }, - { 1, 100 }, - { 2, 500 }, - { 3, 1000 }, - { 4, 3000 }, - { 5, 6000 }, - { 6, 10000 }, - { 7, 20000 } - }; + levelThresholds = new Dictionary + { + { 0, 0 }, + { 1, 100 }, + { 2, 500 }, + { 3, 1000 }, + { 4, 3000 }, + { 5, 6000 }, + { 6, 10000 }, + { 7, 20000 } + }; + levelTitles = new Dictionary + { + { 0, "普通" }, + { 1, "青铜" }, + { 2, "白银" }, + { 3, "黄金" }, + { 4, "铂金" }, + { 5, "钻石" }, + { 6, "星耀" }, + { 7, "王者" } + }; + } var title = levelTitles.GetValueOrDefault(ouQiLevel, "普通"); var nextLevel = ouQiLevel + 1; - var nextOuQi = levelThresholds.GetValueOrDefault(nextLevel, 99999); + var nextOuQi = levelThresholds.GetValueOrDefault(nextLevel, 0); var currentLevelOuQi = levelThresholds.GetValueOrDefault(ouQiLevel, 0); + var maxLevel = levelThresholds.Keys.DefaultIfEmpty(0).Max(); // 计算差值和进度 int cha; int jindu; - if (nextLevel > 7) + if (nextLevel > maxLevel || nextOuQi == 0) { // 已满级 cha = -1;