From 61cf882b66d45560080b06a67272ca938d07d5ae Mon Sep 17 00:00:00 2001 From: Putoo <290555932@qq.com> Date: Mon, 25 May 2026 18:56:09 +0800 Subject: [PATCH] 112121 --- .../Services/Interface/Equ/IGameEquService.cs | 6 +++ .../Services/Service/Equ/GameEquService.cs | 48 ++++++++++++++++--- 2 files changed, 48 insertions(+), 6 deletions(-) diff --git a/Service/Application.Domain/Services/Interface/Equ/IGameEquService.cs b/Service/Application.Domain/Services/Interface/Equ/IGameEquService.cs index 820c66d..8875e85 100644 --- a/Service/Application.Domain/Services/Interface/Equ/IGameEquService.cs +++ b/Service/Application.Domain/Services/Interface/Equ/IGameEquService.cs @@ -14,8 +14,14 @@ public interface IGameEquService Task> GetUserEquData(string userId, int equId); Task AddUserEqu(string userId, int equId, int count, string remark); + + Task UpdateUserEquInfo(unit_user_equ equData, bool isAddLog = false, string code = "", + string remark = ""); Task DeductUserEqu(string userId, List equData, string remark); Task DeductUserEqu(string userId, int equId, int count, string remark); + + Task AddEquLog(unit_user_equ ueData, string code, string remark, + bool isAddAttr = false); #endregion diff --git a/Service/Application.Domain/Services/Service/Equ/GameEquService.cs b/Service/Application.Domain/Services/Service/Equ/GameEquService.cs index 406fed9..de9e422 100644 --- a/Service/Application.Domain/Services/Service/Equ/GameEquService.cs +++ b/Service/Application.Domain/Services/Service/Equ/GameEquService.cs @@ -121,7 +121,7 @@ public class GameEquService(ISqlSugarClient DbClient, IRedisCache redis) : IGame if (result) { //添加日志 - await AddEquLog(adds, 1, remark, userId, true); + await AddEquLogs(adds, 1, remark, true); //更新负重 int weightCount = Convert.ToInt32(equ.weight) * count; if (weightCount > 0) @@ -135,6 +135,22 @@ public class GameEquService(ISqlSugarClient DbClient, IRedisCache redis) : IGame return result; } + public async Task UpdateUserEquInfo(unit_user_equ equData, bool isAddLog = false, string code = "", + string remark = "") + { + var db = DbClient.AsTenant().GetConnectionWithAttr(); + bool result = await db.Updateable(equData).ExecuteCommandAsync() > 0; + if (result) + { + if (isAddLog) + { + await AddEquLog(equData, code, remark); + } + } + + return result; + } + public async Task DeductUserEqu(string userId, List equData, string remark) { bool result = false; @@ -149,7 +165,7 @@ public class GameEquService(ISqlSugarClient DbClient, IRedisCache redis) : IGame unit_user_equ_log log = new unit_user_equ_log(); log.logId = StringAssist.NewGuid; log.ueId = item.ueId; - log.userId = item.userId; + log.equId = item.equId; log.code = nameof(GameEnum.LogCode.减少); log.equData = item; log.remark = remark; @@ -172,7 +188,7 @@ public class GameEquService(ISqlSugarClient DbClient, IRedisCache redis) : IGame if (logs.Count > 0) { - await AddEquLog(logs); + await AddEquLogs(logs); } } } @@ -201,7 +217,27 @@ public class GameEquService(ISqlSugarClient DbClient, IRedisCache redis) : IGame return await DeductUserEqu(userId, opData, remark); } - private async Task AddEquLog(List ues, int code, string remark, string userId, + public async Task AddEquLog(unit_user_equ ueData, string code, string remark, + bool isAddAttr = false) + { + unit_user_equ_log log = new unit_user_equ_log(); + log.logId = StringAssist.NewGuid; + log.ueId = ueData.ueId; + log.equId = ueData.equId; + log.code = code; + if (isAddAttr) + { + log.equData = ueData; + } + + log.addTime = DateTime.Now; + log.remark = remark; + + var db = DbClient.AsTenant().GetConnectionWithAttr(); + await db.Insertable(log).ExecuteCommandAsync(); + } + + private async Task AddEquLogs(List ues, int code, string remark, bool isAddAttr = false) { List adds = new List(); @@ -209,7 +245,7 @@ public class GameEquService(ISqlSugarClient DbClient, IRedisCache redis) : IGame { unit_user_equ_log bagLog = new unit_user_equ_log(); bagLog.logId = StringAssist.NewGuid; - bagLog.userId = userId; + bagLog.equId = item.equId; bagLog.ueId = item.ueId; bagLog.code = code == 0 ? bagLog.code = nameof(GameEnum.LogCode.减少) @@ -228,7 +264,7 @@ public class GameEquService(ISqlSugarClient DbClient, IRedisCache redis) : IGame await db.Insertable(adds).ExecuteCommandAsync(); } - private async Task AddEquLog(List logs) + private async Task AddEquLogs(List logs) { var db = DbClient.AsTenant().GetConnectionWithAttr(); await db.Insertable(logs).ExecuteCommandAsync();