Files
Kg.SeaTime/Service/Application.Domain/Services/Service/Pub/GameMallService.cs
2026-05-28 19:06:40 +08:00

40 lines
1.6 KiB
C#

namespace Application.Domain;
public class GameMallService(ISqlSugarClient DbClient, IRedisCache redis) : IGameMallService, ITransient
{
public async Task<List<game_mall>> GetMallData(int area, string type, int page, int limit, RefAsync<int> total)
{
DateTime onTime = DateTime.Now;
string _area = area.ToString();
var db = DbClient.AsTenant().GetConnectionWithAttr<game_mall>();
return await db.Queryable<game_mall>().Where(it =>
it.endTime > onTime && (it.areaId.Contains("0") || it.areaId.Contains(_area)))
.WhereIF(type=="0",it=>it.payType=="cowry")
.WhereIF(type=="1",it=>it.payType=="gold")
.OrderBy(it=>it.sort,OrderByType.Asc)
.ToPageListAsync(page, limit, total);
}
public async Task<game_mall> GetMallInfo(string mallId)
{
var db = DbClient.AsTenant().GetConnectionWithAttr<game_mall>();
return await db.Queryable<game_mall>().Where(it => it.mallId == mallId).SingleAsync();
}
public async Task<bool> AddLog(game_mall mall, string userId, int count)
{
game_mall_log log = new game_mall_log();
log.logId = StringAssist.NewGuid;
log.mallId = mall.mallId;
log.type = mall.type;
log.pars = mall.goodsId;
log.count = count;
log.price = mall.price;
log.payType = mall.payType;
log.userId = userId;
log.addTime = DateTime.Now;
log.endTime = DateTime.Now.AddDays(30);
var db = DbClient.AsTenant().GetConnectionWithAttr<game_mall_log>();
return await db.Insertable(log).ExecuteCommandAsync() > 0;
}
}