This commit is contained in:
Putoo
2026-07-12 17:36:07 +08:00
parent c40f3711bc
commit 035eb476ea
19 changed files with 932 additions and 22 deletions

View File

@@ -137,7 +137,7 @@ public class GameChatService : IGameChatService, ITransient
chat.delTime = TimeExtend.GetTimeStampBySeconds(DateTime.Now.AddHours(6));
break;
case "Notice":
chat.delTime = TimeExtend.GetTimeStampBySeconds(DateTime.Now.AddDays(1));
chat.delTime = TimeExtend.GetTimeStampBySeconds(DateTime.Now.AddDays(7));
chat.code = nameof(GameChatEnum.Code.System);
break;
case "Group":

View File

@@ -55,14 +55,32 @@ public class GameEquService(ISqlSugarClient DbClient, IRedisCache redis) : IGame
.OrderByDescending(it => it.lev)
.OrderByDescending(it => it.ueId).ToPageListAsync(PageIndex, PageSize, Total);
}
public async Task<List<unit_user_equ>> GetUserEquData(string userId,string query)
public async Task<List<unit_user_equ>> GetUserEquData(string userId, int type, string equName, int PageIndex,
int PageSize, RefAsync<int> Total,int DealType)
{
long onTime = TimeExtend.GetTimeStampSeconds;
var db = DbClient.AsTenant().GetConnectionWithAttr<unit_user_equ>();
return await db.Queryable<unit_user_equ>().Where(it =>
it.userId == userId && it.isOn == 0 && it.isLock == 0 &&
it.useEndTime > onTime)
.WhereIF(DealType == 0, it => it.isDeal == 1)
.WhereIF(DealType == 1, it => it.isDeal == 1 && it.isGive == 1)
.WhereIF(!string.IsNullOrEmpty(equName),
it => it.equName.Contains(equName) || it.unitEquName.Contains(equName))
.OrderByDescending(it => it.isOn)
.OrderByDescending(it => it.lev)
.OrderByDescending(it => it.ueId).ToPageListAsync(PageIndex, PageSize, Total);
}
public async Task<List<unit_user_equ>> GetUserEquData(string userId, string query)
{
long onTime = TimeExtend.GetTimeStampSeconds;
var db = DbClient.AsTenant().GetConnectionWithAttr<unit_user_equ>();
return await db.Queryable<unit_user_equ>().Where(it => it.userId == userId)
.WhereIF(!string.IsNullOrEmpty(query),
it => it.equName.Contains(query) || it.unitEquName.Contains(query))
.ToListAsync();
.ToListAsync();
}
public async Task<List<unit_user_equ>> GetUserEquData(string userId, int equId)
@@ -857,8 +875,8 @@ public class GameEquService(ISqlSugarClient DbClient, IRedisCache redis) : IGame
await EquOnOrDown(item, 0);
}
}
}
#endregion
#region

View File

@@ -70,6 +70,23 @@ public class GameGoodsService(ISqlSugarClient DbClient, IRedisCache redis) : IGa
.ToPageListAsync(page, limit, total);
}
public async Task<List<unit_user_goods>> GetUserGoodsData(string userId, List<string> code, List<string> noCode,
string search, int page,
int limit, RefAsync<int> total, int DealType)
{
var db = DbClient.AsTenant().GetConnectionWithAttr<unit_user_goods>();
return await db.Queryable<unit_user_goods>().Where(it =>
it.userId == userId && it.count > 0)
.WhereIF(DealType == 0, it => it.isDeal == 1)
.WhereIF(DealType == 1, it => it.isDeal == 1 && it.isGive == 1)
.WhereIF(code.Count > 0, it => code.Contains(it.code))
.WhereIF(noCode.Count > 0, it => !noCode.Contains(it.code))
.WhereIF(!string.IsNullOrEmpty(search), it => it.goodsName.Contains(search))
.OrderBy(it => it.lev, OrderByType.Desc)
.OrderBy(it => it.count, OrderByType.Desc)
.ToPageListAsync(page, limit, total);
}
public async Task<List<unit_user_goods>> GetUserGoodsData(string userId, string code)
{
var db = DbClient.AsTenant().GetConnectionWithAttr<unit_user_goods>();
@@ -263,7 +280,7 @@ public class GameGoodsService(ISqlSugarClient DbClient, IRedisCache redis) : IGa
{
result = "您已经使用过该药品啦!";
}
if (!string.IsNullOrEmpty(scene))
{
//要判断使用个数
@@ -282,14 +299,16 @@ public class GameGoodsService(ISqlSugarClient DbClient, IRedisCache redis) : IGa
return result;
}
public async Task<string> CheckUseDrug(string userId, int goodsId,string scene = "")
public async Task<string> CheckUseDrug(string userId, int goodsId, string scene = "")
{
string result = string.Empty;
var goodsInfo = await GetGoodsContent(goodsId);
if (!string.IsNullOrEmpty(goodsInfo))
{
result = await CheckUseDrug(userId,goodsId, goodsInfo, scene);
result = await CheckUseDrug(userId, goodsId, goodsInfo, scene);
}
return result;
}
@@ -320,7 +339,8 @@ public class GameGoodsService(ISqlSugarClient DbClient, IRedisCache redis) : IGa
}
else if (_drugConfig.cls == nameof(GoodsEnum.DrugCls.BloodStock))
{
result = await attrService.AddUserStock(userId, goodsId.ToString(), Convert.ToString(_drugConfig.name),Convert.ToString(_drugConfig.type),
result = await attrService.AddUserStock(userId, goodsId.ToString(), Convert.ToString(_drugConfig.name),
Convert.ToString(_drugConfig.type),
Convert.ToString(_drugConfig.code),
Convert.ToInt64(_drugConfig.num), Convert.ToString(_drugConfig.par),
Convert.ToInt32(_drugConfig.minute));
@@ -332,13 +352,14 @@ public class GameGoodsService(ISqlSugarClient DbClient, IRedisCache redis) : IGa
return result;
}
public async Task<bool> UseDrug(string userId, int goodsId, string scene = "")
{
bool result = false;
var goodsInfo = await GetGoodsContent(goodsId);
if (!string.IsNullOrEmpty(goodsInfo))
{
result = await UseDrug(userId,goodsId, goodsInfo, scene);
result = await UseDrug(userId, goodsId, goodsInfo, scene);
}
return result;

View File

@@ -0,0 +1,28 @@
namespace Application.Domain;
public class TradeService(ISqlSugarClient DbClient, IRedisCache redis) : ITradeService, ITransient
{
public async Task<bool> AddTrade(string userId, string code,string name, string propId, int count,long price, string content)
{
game_trade trade = new game_trade()
{
tradeId = StringAssist.NewGuid,
userId = userId,
code = code,
name = name,
propId = propId,
count = count,
price = price,
content = content,
addTime = DateTime.Now
};
var db = DbClient.AsTenant().GetConnectionWithAttr<game_trade>();
return await db.Insertable(trade).ExecuteCommandAsync() > 0;
}
public async Task<int> GetUserTradeCount(string userId)
{
var db = DbClient.AsTenant().GetConnectionWithAttr<game_trade>();
return await db.Queryable<game_trade>().Where(it => it.userId == userId).CountAsync();
}
}