12121
This commit is contained in:
@@ -20,6 +20,8 @@ namespace Application.Domain
|
||||
HandleExchangeData,//处理兑换数据
|
||||
HandleTaskLog,//处理任务日志
|
||||
HandelTaskUser,//处理角色任务
|
||||
HandleClearChat,//清理频道信息
|
||||
HandleMessageData,//处理消息类
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -105,5 +105,22 @@
|
||||
var taskService = App.GetService<IGameTaskService>();
|
||||
await taskService.HandleUserTask();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 清理频道信息
|
||||
/// </summary>
|
||||
/// <param name="context"></param>
|
||||
[EventSubscribe(BusEventsEnum.BusEventsName.HandleClearChat, NumRetries = 0,RetryTimeout = 999999999)]
|
||||
public async Task HandleClearChat(EventHandlerExecutingContext context)
|
||||
{
|
||||
var chatService = App.GetService<IGameChatService>();
|
||||
await chatService.ClearChat();
|
||||
}
|
||||
[EventSubscribe(BusEventsEnum.BusEventsName.HandleMessageData, NumRetries = 0,RetryTimeout = 999999999)]
|
||||
public async Task HandleMessageData(EventHandlerExecutingContext context)
|
||||
{
|
||||
var messageService = App.GetService<IMessageService>();
|
||||
await messageService.HandleMessageData();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -17,6 +17,8 @@ public static class GameEnum
|
||||
UpdateExchangeData,//更新兑换的记录
|
||||
UpdateTaskLog,//更新任务日志
|
||||
UpdateTaskUser,//更新角色任务
|
||||
ClearChat,//清理频道信息
|
||||
ClearMessage,//清理个人消息信息
|
||||
}
|
||||
public enum PropCode//游戏资源编码
|
||||
{
|
||||
|
||||
@@ -12,4 +12,5 @@ public interface IGameChatService
|
||||
Task<bool> SendChat(string userId, string code, string sign, string par = "");
|
||||
Task<game_chat> GetChatInfo(string chatId);
|
||||
Task<bool> DeleteChat(string chatId, string opUser);
|
||||
Task ClearChat();
|
||||
}
|
||||
@@ -53,4 +53,6 @@ public interface IMessageService
|
||||
Task<bool> SendBroadcast(string userId, string code, string msg);
|
||||
|
||||
#endregion
|
||||
|
||||
Task HandleMessageData();
|
||||
}
|
||||
@@ -3,6 +3,7 @@
|
||||
public interface INoticeService
|
||||
{
|
||||
Task<List<game_notice>> GetNoticeDataByTake(int take);
|
||||
Task<List<game_notice>> GetNoticeDataByMap();
|
||||
Task<List<game_notice>> GetNoticeData(int page, int limit, RefAsync<int> total);
|
||||
Task<game_notice> GetNoticeInfo(string id);
|
||||
}
|
||||
@@ -181,4 +181,11 @@ public class GameChatService : IGameChatService, ITransient
|
||||
.Where(it => it.chatId == chatId)
|
||||
.ExecuteCommandAsync() > 0;
|
||||
}
|
||||
|
||||
public async Task ClearChat()
|
||||
{
|
||||
long time = TimeExtend.GetTimeStampSeconds;
|
||||
var db = _dbClient.AsTenant().GetConnectionWithAttr<game_chat>();
|
||||
await db.Deleteable<game_chat>().Where(it => it.delTime < time).ExecuteCommandAsync();
|
||||
}
|
||||
}
|
||||
@@ -827,7 +827,7 @@ public class GameEquService(ISqlSugarClient DbClient, IRedisCache redis) : IGame
|
||||
|
||||
private async Task<List<game_equ_make>> GetEquMakeData(int goodsId)
|
||||
{
|
||||
string key = string.Format(BaseCache.BaseCacheKeys, "EquData", "EquUpData");
|
||||
string key = string.Format(BaseCache.BaseCacheKeys, "EquData", "EquMakeData");
|
||||
if (await redis.HExistsHashAsync(key, goodsId.ToString()))
|
||||
{
|
||||
return await redis.GetHashAsync<List<game_equ_make>>(key, goodsId.ToString());
|
||||
|
||||
@@ -435,4 +435,21 @@ public class MessageService(ISqlSugarClient DbClient, IRedisCache redis) : IMess
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public async Task HandleMessageData()
|
||||
{
|
||||
long time = TimeExtend.GetTimeStampSeconds;
|
||||
var db = DbClient.AsTenant().GetConnectionWithAttr<unit_user_message>();
|
||||
|
||||
await db.Deleteable<unit_user_mail>().Where(it => it.endTime < time && it.isRead == 1)
|
||||
.ExecuteCommandAsync(); //清理邮件
|
||||
await db.Deleteable<unit_user_message>().Where(it => it.endTime < time && it.isRead == 1)
|
||||
.ExecuteCommandAsync(); //清理消息
|
||||
await db.Deleteable<unit_user_message_event>().Where(it => it.endTime < time).ExecuteCommandAsync(); //清理通知
|
||||
//删除缓存
|
||||
string msgKey = string.Format(UserCache.BaseCacheKeys, "Message", "MsgCount");
|
||||
string eventKey = string.Format(UserCache.BaseCacheKeys, "Message", "EventCount");
|
||||
string mailKey = string.Format(UserCache.BaseCacheKeys, "Message", "MailCount");
|
||||
await redis.DelAsync(msgKey, eventKey, mailKey);
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
namespace Application.Domain;
|
||||
|
||||
public class NoticeService:INoticeService,ITransient
|
||||
public class NoticeService : INoticeService, ITransient
|
||||
{
|
||||
private readonly ISqlSugarClient _dbClient;
|
||||
private readonly IRedisCache _redisClient;
|
||||
@@ -14,13 +14,14 @@ public class NoticeService:INoticeService,ITransient
|
||||
public async Task<List<game_notice>> GetNoticeDataByTake(int take)
|
||||
{
|
||||
var db = _dbClient.AsTenant().GetConnectionWithAttr<game_notice>();
|
||||
return await db.Queryable<game_notice>().Take(take).OrderByDescending(it=>it.addTime).ToListAsync();
|
||||
return await db.Queryable<game_notice>().Take(take).OrderByDescending(it => it.addTime).ToListAsync();
|
||||
}
|
||||
|
||||
public async Task<List<game_notice>> GetNoticeData(int page, int limit, RefAsync<int> total)
|
||||
{
|
||||
var db = _dbClient.AsTenant().GetConnectionWithAttr<game_notice>();
|
||||
return await db.Queryable<game_notice>().OrderByDescending(it=>it.addTime).ToPageListAsync(page, limit, total);
|
||||
return await db.Queryable<game_notice>().OrderByDescending(it => it.addTime)
|
||||
.ToPageListAsync(page, limit, total);
|
||||
}
|
||||
|
||||
public async Task<game_notice> GetNoticeInfo(string id)
|
||||
@@ -28,4 +29,19 @@ public class NoticeService:INoticeService,ITransient
|
||||
var db = _dbClient.AsTenant().GetConnectionWithAttr<game_notice>();
|
||||
return await db.Queryable<game_notice>().Where(it => it.noticeId == id).SingleAsync();
|
||||
}
|
||||
|
||||
public async Task<List<game_notice>> GetNoticeDataByMap()
|
||||
{
|
||||
string key = string.Format(BaseCache.BaseCacheKey, "Notice");
|
||||
if (await _redisClient.ExistsAsync(key))
|
||||
{
|
||||
return await _redisClient.GetAsync<List<game_notice>>(key);
|
||||
}
|
||||
|
||||
DateTime time = DateTime.Now;
|
||||
var db = _dbClient.AsTenant().GetConnectionWithAttr<game_notice>();
|
||||
var data = await db.Queryable<game_notice>().OrderByDescending(it => it.endTime > time).ToListAsync();
|
||||
await _redisClient.SetAsync(key, data, 3600);
|
||||
return data;
|
||||
}
|
||||
}
|
||||
@@ -105,5 +105,17 @@ public class GameAutoJobService(ISqlSugarClient DbClient, IRedisCache redis, ITi
|
||||
await _eventPublisher.PublishAsync(new ChannelEventSource(BusEventsEnum.BusEventsName.HandelTaskUser,
|
||||
data));
|
||||
}
|
||||
else if (data.code == nameof(GameEnum.JobCode.ClearChat)) //清理频道信息
|
||||
{
|
||||
var _eventPublisher = App.GetService<IEventPublisher>();
|
||||
await _eventPublisher.PublishAsync(new ChannelEventSource(BusEventsEnum.BusEventsName.HandleClearChat,
|
||||
data));
|
||||
}
|
||||
else if (data.code == nameof(GameEnum.JobCode.ClearMessage)) //清理频道信息
|
||||
{
|
||||
var _eventPublisher = App.GetService<IEventPublisher>();
|
||||
await _eventPublisher.PublishAsync(new ChannelEventSource(BusEventsEnum.BusEventsName.HandleMessageData,
|
||||
data));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -23,12 +23,13 @@ public class MapController : ControllerBase
|
||||
private readonly IGameFightService _fightService;
|
||||
private readonly IOnHookService _hookService;
|
||||
private readonly IGameTaskService _taskService;
|
||||
private readonly INoticeService _noticeService;
|
||||
|
||||
public MapController(IUnitUserService userService, IGameMapService mapService, IGameChatService chatService,
|
||||
IUnitUserAttrService attrService, IMessageService messageService, IUnitUserWeight weightService,
|
||||
IUnitUserAccService accService, IGameSkillService skillService, IGameGoodsService goodsService,
|
||||
IGameTeamService teamService, IGameMonsterService monsterService, IGameFightService fightService,
|
||||
IOnHookService hookService, IGameTaskService taskService)
|
||||
IOnHookService hookService, IGameTaskService taskService,INoticeService noticeService)
|
||||
{
|
||||
_userService = userService;
|
||||
_mapService = mapService;
|
||||
@@ -44,6 +45,7 @@ public class MapController : ControllerBase
|
||||
_fightService = fightService;
|
||||
_hookService = hookService;
|
||||
_taskService = taskService;
|
||||
_noticeService = noticeService;
|
||||
}
|
||||
|
||||
#region 地图相关
|
||||
@@ -146,6 +148,8 @@ public class MapController : ControllerBase
|
||||
var onHook = await _hookService.GetUserOnHook(userId);
|
||||
isHook = (int)onHook.status;
|
||||
|
||||
var notice = await _noticeService.GetNoticeDataByMap();
|
||||
|
||||
object ret = new
|
||||
{
|
||||
mapInfo,
|
||||
@@ -163,6 +167,7 @@ public class MapController : ControllerBase
|
||||
fightId,
|
||||
gameTips,
|
||||
isHook,
|
||||
notice,
|
||||
taskCount = taskData.Count
|
||||
};
|
||||
|
||||
|
||||
@@ -296,6 +296,7 @@ public class RecoverController : ControllerBase
|
||||
myEqu = myEqu.FindAll(it =>
|
||||
it.isAppr == 1 && it.durability < it.maxdurability && it.useEndTime > TimeExtend.GetTimeStampSeconds);
|
||||
int need = myEqu.Sum(it => (int)it.maxdurability - (int)it.durability);
|
||||
need = need * 500;
|
||||
if (need < 1)
|
||||
{
|
||||
return PoAction.Message("耐久已满,无需恢复!");
|
||||
@@ -351,6 +352,7 @@ public class RecoverController : ControllerBase
|
||||
}
|
||||
|
||||
int need = (int)equInfo.maxdurability - (int)equInfo.durability;
|
||||
need = need * 500;
|
||||
var myAcc = await _accService.GetUserAccInfo(userId, nameof(AccEnum.AccType.copper));
|
||||
if (need > myAcc)
|
||||
{
|
||||
|
||||
@@ -257,6 +257,15 @@ public class GiveController : ControllerBase
|
||||
{
|
||||
return PoAction.Message("玩家不存在!");
|
||||
}
|
||||
//此处判断赠送玩家的设置
|
||||
var roleConfig = await _userService.GetUserConfigInfo(fromInfo.userId);
|
||||
if (roleConfig.giveRole == 1)//判断是否为好友
|
||||
{
|
||||
if (await _relationService.CheckIsFriend(userId, fromInfo.userId)==false)
|
||||
{
|
||||
return PoAction.Message("玩家设置了拒绝陌生人赠送!");
|
||||
}
|
||||
}
|
||||
|
||||
if (type == 0)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user