121212
This commit is contained in:
@@ -140,7 +140,7 @@ public class GameMapService(ISqlSugarClient DbClient, IRedisCache redis) : IGame
|
||||
};
|
||||
if (item.code == nameof(MapEnum.NpcCode.Task))
|
||||
{
|
||||
var task = await taskService.GetTaskDataByNpc(userId,item.npcId);
|
||||
var task = await taskService.GetTaskDataByNpc(userId, item.npcId);
|
||||
if (task.Count > 0)
|
||||
{
|
||||
temp.state = task.Any(it => it.state == 0) ? 1 : 2;
|
||||
@@ -218,9 +218,14 @@ public class GameMapService(ISqlSugarClient DbClient, IRedisCache redis) : IGame
|
||||
};
|
||||
}
|
||||
|
||||
public async Task UpdateUserOnMap(string userId)
|
||||
public async Task UpdateUserOnMap(string userId, string mapId = "")
|
||||
{
|
||||
unit_user_online onLine = await GetUserOnMap(userId);
|
||||
if (!string.IsNullOrEmpty(mapId))
|
||||
{
|
||||
onLine.mapId = mapId;
|
||||
}
|
||||
|
||||
onLine.upTime = TimeExtend.GetTimeStampSeconds;
|
||||
string key = string.Format(UserCache.BaseCacheKey, "UserOnline");
|
||||
if (await redis.AddHashAsync(key, userId, onLine))
|
||||
@@ -400,7 +405,28 @@ public class GameMapService(ISqlSugarClient DbClient, IRedisCache redis) : IGame
|
||||
|
||||
#region 其他相关
|
||||
|
||||
private async Task<List<UserModel>> GetMapUser(string mapId, int area, int showArea, List<string> noUser)
|
||||
public async Task<List<UserModel>> GetMapUserByAll(string mapId, int area, int showArea, List<string> noUser)
|
||||
{
|
||||
var db = DbClient.AsTenant().GetConnectionWithAttr<unit_user_online>();
|
||||
var data = await db.Queryable<unit_user_online>().Where(it => it.mapId == mapId)
|
||||
.WhereIF(noUser.Count > 0, it => !noUser.Contains(it.userId))
|
||||
.OrderByDescending(it => it.upTime)
|
||||
.ToListAsync();
|
||||
|
||||
List<UserModel> result = new List<UserModel>();
|
||||
data.ForEach(async it =>
|
||||
{
|
||||
var temp = await UserModelTool.GetUserView(it.userId);
|
||||
bool isAdd = showArea == 1 && area != temp.area ? false : true;
|
||||
if (isAdd)
|
||||
{
|
||||
result.Add(temp);
|
||||
}
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
public async Task<List<UserModel>> GetMapUser(string mapId, int area, int showArea, List<string> noUser)
|
||||
{
|
||||
var db = DbClient.AsTenant().GetConnectionWithAttr<unit_user_online>();
|
||||
long time = TimeExtend.GetTimeStampBySeconds(DateTime.Now.AddMinutes(0 - GameConfig.OnLineTime));
|
||||
|
||||
Reference in New Issue
Block a user