112121
This commit is contained in:
@@ -14,9 +14,15 @@ public interface IGameEquService
|
||||
|
||||
Task<List<unit_user_equ>> GetUserEquData(string userId, int equId);
|
||||
Task<bool> AddUserEqu(string userId, int equId, int count, string remark);
|
||||
|
||||
Task<bool> UpdateUserEquInfo(unit_user_equ equData, bool isAddLog = false, string code = "",
|
||||
string remark = "");
|
||||
Task<bool> DeductUserEqu(string userId, List<unit_user_equ> equData, string remark);
|
||||
Task<bool> DeductUserEqu(string userId, int equId, int count, string remark);
|
||||
|
||||
Task AddEquLog(unit_user_equ ueData, string code, string remark,
|
||||
bool isAddAttr = false);
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
@@ -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<bool> UpdateUserEquInfo(unit_user_equ equData, bool isAddLog = false, string code = "",
|
||||
string remark = "")
|
||||
{
|
||||
var db = DbClient.AsTenant().GetConnectionWithAttr<unit_user_equ>();
|
||||
bool result = await db.Updateable(equData).ExecuteCommandAsync() > 0;
|
||||
if (result)
|
||||
{
|
||||
if (isAddLog)
|
||||
{
|
||||
await AddEquLog(equData, code, remark);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public async Task<bool> DeductUserEqu(string userId, List<unit_user_equ> 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<unit_user_equ> 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<unit_user_equ_log>();
|
||||
await db.Insertable(log).ExecuteCommandAsync();
|
||||
}
|
||||
|
||||
private async Task AddEquLogs(List<unit_user_equ> ues, int code, string remark,
|
||||
bool isAddAttr = false)
|
||||
{
|
||||
List<unit_user_equ_log> adds = new List<unit_user_equ_log>();
|
||||
@@ -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<unit_user_equ_log> logs)
|
||||
private async Task AddEquLogs(List<unit_user_equ_log> logs)
|
||||
{
|
||||
var db = DbClient.AsTenant().GetConnectionWithAttr<unit_user_equ_log>();
|
||||
await db.Insertable(logs).ExecuteCommandAsync();
|
||||
|
||||
Reference in New Issue
Block a user