From 5cd6151b964f49bde3775df5f71013dbcc9dd55e Mon Sep 17 00:00:00 2001 From: Putoo <290555932@qq.com> Date: Tue, 16 Jun 2026 18:30:53 +0800 Subject: [PATCH] 1212121 --- .../model/UserEquSuit.cs | 8 + Service/Application.Domain/Enum/EquEnum.cs | 6 + .../Services/Interface/Equ/IGameEquService.cs | 2 + .../Services/Service/Equ/GameEquService.cs | 83 +++++++++- .../Controllers/Pub/EquController.cs | 85 +++++++++- .../Controllers/User/BagController.cs | 11 +- Web/src/components/Business/GameEqu.vue | 21 +++ Web/src/components/Business/GamePopup.vue | 5 +- Web/src/config/BaseConfig.ts | 4 +- Web/src/pages/prop/equ.vue | 10 +- Web/src/pages/user/bag/index.vue | 4 +- Web/src/pages/user/equ/index.vue | 147 +++++++++++++----- Web/src/pages/user/equ/suit.vue | 68 ++++++++ Web/src/services/Index/EquService.ts | 16 ++ 14 files changed, 413 insertions(+), 57 deletions(-) create mode 100644 Service/Application.Domain.Entity/model/UserEquSuit.cs create mode 100644 Web/src/components/Business/GameEqu.vue create mode 100644 Web/src/pages/user/equ/suit.vue diff --git a/Service/Application.Domain.Entity/model/UserEquSuit.cs b/Service/Application.Domain.Entity/model/UserEquSuit.cs new file mode 100644 index 0000000..612af94 --- /dev/null +++ b/Service/Application.Domain.Entity/model/UserEquSuit.cs @@ -0,0 +1,8 @@ +namespace Application.Domain.Entity; + +public class UserEquSuit +{ + public string suitCode { get; set; } + public string suitName { get; set; } + public List SuitAttr { get; set; } +} \ No newline at end of file diff --git a/Service/Application.Domain/Enum/EquEnum.cs b/Service/Application.Domain/Enum/EquEnum.cs index 0469997..8c21736 100644 --- a/Service/Application.Domain/Enum/EquEnum.cs +++ b/Service/Application.Domain/Enum/EquEnum.cs @@ -21,5 +21,11 @@ public static class EquEnum Ornaments = 3, //佩戴 Fashion = 1, //时装 Wing = 1, //羽翼 + Decorate = 5, //装饰 + } + + public enum SuitAttrNeedType + { + ON_EQU } } \ No newline at end of file diff --git a/Service/Application.Domain/Services/Interface/Equ/IGameEquService.cs b/Service/Application.Domain/Services/Interface/Equ/IGameEquService.cs index 3b7d4c4..3d6876b 100644 --- a/Service/Application.Domain/Services/Interface/Equ/IGameEquService.cs +++ b/Service/Application.Domain/Services/Interface/Equ/IGameEquService.cs @@ -13,6 +13,7 @@ public interface IGameEquService RefAsync Total, bool isRemOn = false); Task> GetUserEquData(string userId, int equId); + Task> GetUserEquData(string userId, string code, List noUeId); Task GetUserEquInfo(string ueId); Task GetUserEquByEquIdCount(string userId, int equId); Task> GetUserEquByEquId(string userId, int equId); @@ -28,6 +29,7 @@ public interface IGameEquService Task> GetUserOnEqu(string userId); Task EquOnOrDown(unit_user_equ data, int state); + Task> GetUserEquSuit(string userId); #endregion #region 辅助 diff --git a/Service/Application.Domain/Services/Service/Equ/GameEquService.cs b/Service/Application.Domain/Services/Service/Equ/GameEquService.cs index c0d54d8..343ffcd 100644 --- a/Service/Application.Domain/Services/Service/Equ/GameEquService.cs +++ b/Service/Application.Domain/Services/Service/Equ/GameEquService.cs @@ -56,11 +56,18 @@ public class GameEquService(ISqlSugarClient DbClient, IRedisCache redis) : IGame public async Task> GetUserEquData(string userId, int equId) { - long onTime = TimeExtend.GetTimeStampSeconds; var db = DbClient.AsTenant().GetConnectionWithAttr(); return await db.Queryable().Where(it => it.userId == userId && it.equId == equId).ToListAsync(); } + public async Task> GetUserEquData(string userId, string code, List noUeId) + { + var db = DbClient.AsTenant().GetConnectionWithAttr(); + return await db.Queryable().Where(it => it.userId == userId && it.code == code) + .WhereIF(noUeId.Count > 0, it => !noUeId.Contains(it.ueId)) + .ToListAsync(); + } + public async Task GetUserEquInfo(string ueId) { var db = DbClient.AsTenant().GetConnectionWithAttr(); @@ -325,6 +332,15 @@ public class GameEquService(ISqlSugarClient DbClient, IRedisCache redis) : IGame } } + private async Task ClearUserOnEqu(string userId) + { + var key = string.Format(UserCache.BaseCacheKeys, "EquData", "UserOnEqu"); + await redis.DelHashAsync(key, userId); + //清理套装缓存 + key = string.Format(UserCache.BaseCacheKeys, "EquData:UserEquSuit", userId); + await redis.DelAsync(key); + } + public async Task EquOnOrDown(unit_user_equ data, int state) { data.isOn = state; @@ -334,21 +350,84 @@ public class GameEquService(ISqlSugarClient DbClient, IRedisCache redis) : IGame var equInfo = await GetEquInfo((int)data.equId); if (equInfo.useTime > 0) { - data.useEndTime = TimeExtend.GetTimeStampBySeconds(DateTime.Now.AddDays((int)equInfo.useTime)) ; + data.useEndTime = TimeExtend.GetTimeStampBySeconds(DateTime.Now.AddDays((int)equInfo.useTime)); } } + var db = DbClient.AsTenant().GetConnectionWithAttr(); bool result = await db.Updateable(data).ExecuteCommandAsync() > 0; if (result) { + await ClearUserOnEqu(data.userId); } return result; } + /// + /// 获取个人套装 + /// + /// + /// + public async Task> GetUserEquSuit(string userId) + { + List result = new List(); + long time = TimeExtend.GetTimeStampSeconds; + var key = string.Format(UserCache.BaseCacheKeys, "EquData:UserEquSuit", userId); + if (await redis.ExistsAsync(key)) + { + result = await redis.GetAsync>(key); + } + else + { + List opSuit = new List(); + var onEquData = await GetUserOnEqu(userId); + string[] onEqu = onEquData.Select(it => it.equId.ToString()).ToArray(); + onEquData = onEquData.FindAll(it => it.useEndTime > time && it.durability > 0); + foreach (var item in onEquData) + { + if (item.suitCode != "0" && !string.IsNullOrEmpty(item.suitCode)) + { + if (!opSuit.Contains(item.suitCode)) + { + opSuit.Add(item.suitCode); + } + } + } + foreach (var suit in opSuit) + { + UserEquSuit temp = new UserEquSuit(); + var suitInfo = await GetEuqSuitInfo(suit); + if (suitInfo != null) + { + temp.suitCode = suitInfo.suitCode; + temp.suitName = suitInfo.suitName; + temp.SuitAttr = new List(); + foreach (var item in suitInfo.attr) + { + if (item.NeedType == nameof(EquEnum.SuitAttrNeedType.ON_EQU)) + { + bool same = item.NeedData.All(item => onEqu.Contains(item)); + if (same) + { + temp.SuitAttr.Add(item); + } + } + } + if (temp.SuitAttr.Count > 0) //存在满足条件得属性 + { + result.Add(temp); + } + } + } + await redis.SetAsync(key, result, 300); + } + + return result; + } #endregion diff --git a/Service/Application.Web/Controllers/Pub/EquController.cs b/Service/Application.Web/Controllers/Pub/EquController.cs index 25f6584..11b416b 100644 --- a/Service/Application.Web/Controllers/Pub/EquController.cs +++ b/Service/Application.Web/Controllers/Pub/EquController.cs @@ -138,7 +138,8 @@ public class EquController : ControllerBase { string userId = StateHelper.userId; var data = await _equService.GetUserOnEqu(userId); - return PoAction.Ok(data); + var suit = await _equService.GetUserEquSuit(userId); + return PoAction.Ok(new { data, suit }); } /// @@ -200,6 +201,7 @@ public class EquController : ControllerBase return PoAction.Message($"该装备最多穿戴{equInfo.canEqualUp}件!"); } } + bool isOk = true; if (string.IsNullOrEmpty(de)) { @@ -222,6 +224,7 @@ public class EquController : ControllerBase { return PoAction.Message("装备未穿戴!"); } + if (DownOnEqu.code != equInfo.code) { return PoAction.Message("装备部位不一致!"); @@ -260,6 +263,82 @@ public class EquController : ControllerBase } } } - - + + /// + /// 获取可穿戴装备 + /// + /// + /// + [HttpGet] + public async Task GetCanOnEqu(int type) + { + string code = nameof(EquEnum.EquPlace.Hold); + switch (type) + { + case 1: + code = nameof(EquEnum.EquPlace.Hold); + break; + case 2: + code = nameof(EquEnum.EquPlace.Vice); + break; + case 3: + code = nameof(EquEnum.EquPlace.Head); + break; + case 4: + code = nameof(EquEnum.EquPlace.Wear); + break; + case 5: + code = nameof(EquEnum.EquPlace.Waist); + break; + case 6: + code = nameof(EquEnum.EquPlace.Foot); + break; + case 7: + code = nameof(EquEnum.EquPlace.Ornaments); + break; + case 8: + code = nameof(EquEnum.EquPlace.Fashion); + break; + case 9: + code = nameof(EquEnum.EquPlace.Wing); + break; + case 10: + code = nameof(EquEnum.EquPlace.Decorate); + break; + } + + string userId = StateHelper.userId; + var userOnEqu = await _equService.GetUserOnEqu(userId); + var NoEqu = userOnEqu.FindAll(it => it.code == code).Select(it => it.ueId).ToList(); + var CanEqu = await _equService.GetUserEquData(userId, code, NoEqu); + long onTime = TimeExtend.GetTimeStampSeconds; + CanEqu = CanEqu.FindAll(it => it.isAppr == 1 && it.useEndTime > onTime); + CanEqu = CanEqu.OrderByDescending(it => it.lev).ToList(); + return PoAction.Ok(CanEqu); + } + + /// + /// 获取激活套装属性 + /// + /// + /// + [HttpGet] + public async Task GetUserOnSuitInfo(string suitCode) + { + var userId = StateHelper.userId; + var onSuit = await _equService.GetUserEquSuit(userId); + var suit = onSuit.Find(it => it.suitCode == suitCode); + if (suit == null) + { + return PoAction.Message("套装不存在!"); + } + + var data = await _equService.GetEuqSuitInfo(suitCode); + if (data == null) + { + return PoAction.Message("套装不存在!"); + } + + return PoAction.Ok(new { data, suit }); + } } \ No newline at end of file diff --git a/Service/Application.Web/Controllers/User/BagController.cs b/Service/Application.Web/Controllers/User/BagController.cs index 6b150b5..1b5fdf0 100644 --- a/Service/Application.Web/Controllers/User/BagController.cs +++ b/Service/Application.Web/Controllers/User/BagController.cs @@ -24,7 +24,7 @@ public class BagController : ControllerBase _equService = equService; _accService = accService; } - + /// /// 获取背包信息 /// @@ -33,7 +33,6 @@ public class BagController : ControllerBase public async Task GetUserBagData() { string userId = StateHelper.userId; - var accInfo = await _accService.GetUserAccInfo(userId); long gold = (long)accInfo.gold; long cowry = (long)accInfo.cowry; @@ -76,13 +75,13 @@ public class BagController : ControllerBase } var data = await _equService.GetUserEquData(userId, _t, query, page, 10, total); - return PoAction.Ok(new { data, total.Value }); + return PoAction.Ok(new { data, total = total.Value}); } else if (type == 1) { List code = new List() { nameof(GoodsEnum.Code.Drug) }; var data = await _goodsService.GetUserGoodsData(userId, code, new List(), query, page, 10, total); - return PoAction.Ok(new { data, total.Value }); + return PoAction.Ok(new { data, total = total.Value }); } else if (type == 2) { @@ -120,11 +119,11 @@ public class BagController : ControllerBase } var data = await _goodsService.GetUserGoodsData(userId, code, noCode, query, page, 10, total); - return PoAction.Ok(new { data, total.Value }); + return PoAction.Ok(new { data, total = total.Value }); } else { - return PoAction.Ok(new { data = new List(), total.Value }); + return PoAction.Ok(new { data = new List(), total = total.Value }); } } } \ No newline at end of file diff --git a/Web/src/components/Business/GameEqu.vue b/Web/src/components/Business/GameEqu.vue new file mode 100644 index 0000000..0c29519 --- /dev/null +++ b/Web/src/components/Business/GameEqu.vue @@ -0,0 +1,21 @@ + + \ No newline at end of file diff --git a/Web/src/components/Business/GamePopup.vue b/Web/src/components/Business/GamePopup.vue index 5f766b7..5feba96 100644 --- a/Web/src/components/Business/GamePopup.vue +++ b/Web/src/components/Business/GamePopup.vue @@ -17,7 +17,10 @@ const props = defineProps({ // 字段名、类型、默认值 - isShow: Boolean, + isShow: { + type: Boolean, + default: false + }, title: String }) const visible = ref(props.isShow) diff --git a/Web/src/config/BaseConfig.ts b/Web/src/config/BaseConfig.ts index 18c1514..8f881cf 100644 --- a/Web/src/config/BaseConfig.ts +++ b/Web/src/config/BaseConfig.ts @@ -2,8 +2,8 @@ 统一配置中心 */ export class BaseConfig { - public static BaseUrl: string = 'https://192.168.0.142:7198' - public static BaseMediaUrl: string = 'https://192.168.0.142:7198' + public static BaseUrl: string = 'https://localhost:7198' + public static BaseMediaUrl: string = 'https://localhost:7198/' // public static BaseUrl:string="http://kx.iyba.cn:5291"; // public static BaseMediaUrl:string="http://kx.iyba.cn:5291"; } diff --git a/Web/src/pages/prop/equ.vue b/Web/src/pages/prop/equ.vue index d939664..ed8a2c1 100644 --- a/Web/src/pages/prop/equ.vue +++ b/Web/src/pages/prop/equ.vue @@ -55,7 +55,6 @@ 部位:{{ EquTool.GetEquPlaceName(equData.code) }}
等级:{{ equData.lev }}
- 品阶:{{ EquTool.EquStartTips(equData.start) }}
品质:equData.qualityName
@@ -117,16 +116,13 @@
- ◈{{equData.isOn==1?"卸下装备":"穿戴装备"}}
-
- - ◈洗练
+ ◈{{ equData.isOn == 1 ? "卸下装备" : "穿戴装备" }}
觉醒
- ◈升星
+ ◈洗练
{{ equData.isLock == 0 ? "绑定" : "解绑" }}
@@ -189,7 +185,7 @@ const BindData = async (): Promise => { /**穿/卸装备 */ const UpOrDownEqu = async () => { MessageExtend.LoadingToast("操作中..."); - let result = await EquService.DownOrUpEqu(ueId,""); + let result = await EquService.DownOrUpEqu(ueId, ""); MessageExtend.LoadingClose(); if (result.code == 0) { await BindData(); diff --git a/Web/src/pages/user/bag/index.vue b/Web/src/pages/user/bag/index.vue index e749c2f..c32a241 100644 --- a/Web/src/pages/user/bag/index.vue +++ b/Web/src/pages/user/bag/index.vue @@ -50,7 +50,7 @@
{{ PageExtend.GetPageIndex(currentPage, 10, index + 1) }}. {{ item.equName }}({{ item.lev }}级) - (穿) + (装) (未鉴定) (过期) (损坏) @@ -144,6 +144,7 @@ const BindData = async (): Promise => { /**切换背包 */ const ChangeBag = async (_type: string): Promise => { + currentPage.value = 1; type.value = _type; type_ch.value = '0'; serch.value=''; @@ -151,6 +152,7 @@ const ChangeBag = async (_type: string): Promise => { } const ChangeChildBag = async (ch: string): Promise => { + currentPage.value = 1; type_ch.value = ch; await BindData(); } diff --git a/Web/src/pages/user/equ/index.vue b/Web/src/pages/user/equ/index.vue index 6adb65c..1976fcc 100644 --- a/Web/src/pages/user/equ/index.vue +++ b/Web/src/pages/user/equ/index.vue @@ -1,72 +1,76 @@ \ No newline at end of file diff --git a/Web/src/pages/user/equ/suit.vue b/Web/src/pages/user/equ/suit.vue new file mode 100644 index 0000000..119bfbb --- /dev/null +++ b/Web/src/pages/user/equ/suit.vue @@ -0,0 +1,68 @@ + + \ No newline at end of file diff --git a/Web/src/services/Index/EquService.ts b/Web/src/services/Index/EquService.ts index 847e5d2..38a5195 100644 --- a/Web/src/services/Index/EquService.ts +++ b/Web/src/services/Index/EquService.ts @@ -38,4 +38,20 @@ export class EquService { static async DownOrUpEqu(ueId: string, de: string) { return await ApiService.Request("get", "/Equ/DownOrUpEqu", { ueId, de }); } + + /** + * 获取可穿戴装备 + * GET /Equ/GetCanOnEqu + */ + static async GetCanOnEqu(type: number) { + return await ApiService.Request("get", "/Equ/GetCanOnEqu", { type }); + } + + /** + * 获取激活套装属性 + * GET /Equ/GetUserOnSuitInfo + */ + static async GetUserOnSuitInfo(suitCode: string) { + return await ApiService.Request("get", "/Equ/GetUserOnSuitInfo", { suitCode }); + } } \ No newline at end of file