diff --git a/server/HoneyBox/src/HoneyBox.Admin.Business/Controllers/PrizeLevelController.cs b/server/HoneyBox/src/HoneyBox.Admin.Business/Controllers/PrizeLevelController.cs index c4ac17e8..b360e31a 100644 --- a/server/HoneyBox/src/HoneyBox.Admin.Business/Controllers/PrizeLevelController.cs +++ b/server/HoneyBox/src/HoneyBox.Admin.Business/Controllers/PrizeLevelController.cs @@ -118,6 +118,19 @@ public class PrizeLevelController : BusinessControllerBase return Ok(result); } + /// + /// 根据盒子类型获取奖品等级选项 + /// + /// 请求参数 + /// 奖品等级选项列表 + [HttpGet("options-by-type")] + [BusinessPermission("goods:list")] + public async Task GetPrizeLevelOptionsByType([FromQuery] PrizeLevelOptionsByTypeRequest request) + { + var result = await _prizeLevelService.GetPrizeLevelOptionsByTypeAsync(request.GoodsType, request.IsChildPrize); + return Ok(result); + } + /// /// 获取概率统计 /// diff --git a/server/HoneyBox/src/HoneyBox.Admin.Business/Models/Goods/PrizeLevelModels.cs b/server/HoneyBox/src/HoneyBox.Admin.Business/Models/Goods/PrizeLevelModels.cs index e7ce5291..91c3023d 100644 --- a/server/HoneyBox/src/HoneyBox.Admin.Business/Models/Goods/PrizeLevelModels.cs +++ b/server/HoneyBox/src/HoneyBox.Admin.Business/Models/Goods/PrizeLevelModels.cs @@ -154,3 +154,20 @@ public class PrizeLevelOptionResponse /// public string? Color { get; set; } } + +/// +/// 根据盒子类型获取奖品等级选项请求 +/// +public class PrizeLevelOptionsByTypeRequest +{ + /// + /// 盒子类型 + /// 1=一番赏, 2=无限赏, 3=擂台赏, 5=积分赏, 6=限时活动, 8=领主赏, 9=连击赏, 10=商城赏, 11=自制赏, 15=福利屋, 16=翻倍赏, 17=外卖盒子 + /// + public int GoodsType { get; set; } + + /// + /// 是否为子奖品(宝箱内奖品) + /// + public bool IsChildPrize { get; set; } = false; +} diff --git a/server/HoneyBox/src/HoneyBox.Admin.Business/Services/Interfaces/IPrizeLevelService.cs b/server/HoneyBox/src/HoneyBox.Admin.Business/Services/Interfaces/IPrizeLevelService.cs index 96b13033..bac0d46c 100644 --- a/server/HoneyBox/src/HoneyBox.Admin.Business/Services/Interfaces/IPrizeLevelService.cs +++ b/server/HoneyBox/src/HoneyBox.Admin.Business/Services/Interfaces/IPrizeLevelService.cs @@ -38,6 +38,13 @@ public interface IPrizeLevelService /// Task> GetPrizeLevelOptionsAsync(); + /// + /// 根据盒子类型获取奖品等级选项 + /// + /// 盒子类型 + /// 是否为子奖品(宝箱内奖品) + Task> GetPrizeLevelOptionsByTypeAsync(int goodsType, bool isChildPrize = false); + /// /// 获取概率总和 /// diff --git a/server/HoneyBox/src/HoneyBox.Admin.Business/Services/PrizeLevelService.cs b/server/HoneyBox/src/HoneyBox.Admin.Business/Services/PrizeLevelService.cs index 6af355af..0e5946f4 100644 --- a/server/HoneyBox/src/HoneyBox.Admin.Business/Services/PrizeLevelService.cs +++ b/server/HoneyBox/src/HoneyBox.Admin.Business/Services/PrizeLevelService.cs @@ -169,6 +169,68 @@ public class PrizeLevelService : IPrizeLevelService .ToListAsync(); } + /// + public async Task> GetPrizeLevelOptionsByTypeAsync(int goodsType, bool isChildPrize = false) + { + var query = _dbContext.PrizeLevels.AsNoTracking(); + + // 根据盒子类型过滤等级 + // PHP逻辑参考:server/php/app/admin/controller/Goods.php goodslist_add方法 + switch (goodsType) + { + case 1: // 一番赏 + case 5: // 积分赏 + case 6: // 限时活动 + case 10: // 商城赏 + case 11: // 自制赏 + if (isChildPrize) + { + // 子奖品(宝箱内奖品):id <= 33 且 id > 5 + query = query.Where(pl => pl.Id <= 33 && pl.Id > 5); + } + else + { + // 父奖品:id <= 33 且 id != 5 + query = query.Where(pl => pl.Id <= 33 && pl.Id != 5); + } + break; + + case 2: // 无限赏 + case 8: // 领主赏 + case 9: // 连击赏 + case 16: // 翻倍赏 + case 17: // 外卖盒子 + // id between 34 and 38(无上、传说、隐藏、史诗、稀有) + query = query.Where(pl => pl.Id >= 34 && pl.Id <= 38); + break; + + case 3: // 擂台赏 + // id between 4 and 33 + query = query.Where(pl => pl.Id >= 4 && pl.Id <= 33); + break; + + case 15: // 福利屋 + // id >= 114(普通、大奖) + query = query.Where(pl => pl.Id >= 114); + break; + + default: + // 默认返回所有等级 + break; + } + + return await query + .OrderBy(pl => pl.Sort) + .ThenBy(pl => pl.Id) + .Select(pl => new PrizeLevelOptionResponse + { + Id = pl.Id, + Title = pl.Title, + Color = pl.Color + }) + .ToListAsync(); + } + /// public async Task GetTotalProbabilityAsync() { diff --git a/server/HoneyBox/src/HoneyBox.Admin/admin-web/src/views/business/goods/components/PrizeLevelFormDialog.vue b/server/HoneyBox/src/HoneyBox.Admin/admin-web/src/views/business/goods/components/PrizeLevelFormDialog.vue index 45701df2..2c9460be 100644 --- a/server/HoneyBox/src/HoneyBox.Admin/admin-web/src/views/business/goods/components/PrizeLevelFormDialog.vue +++ b/server/HoneyBox/src/HoneyBox.Admin/admin-web/src/views/business/goods/components/PrizeLevelFormDialog.vue @@ -2,7 +2,7 @@ @@ -34,21 +34,28 @@ - -
- - -
-
- - - - + + + + + + + + + + + + @@ -69,6 +76,7 @@ import { ref, reactive, computed, watch } from 'vue' import { ElMessage } from 'element-plus' import type { FormInstance, FormRules } from 'element-plus' +import ImageUpload from '@/components/ImageUpload/index.vue' import { getPrizeLevel, createPrizeLevel, @@ -187,19 +195,6 @@ const handleSubmit = async () => {