1111
This commit is contained in:
@@ -7,34 +7,28 @@ namespace Application.Domain.Entity
|
||||
public class unit_user_friend
|
||||
{
|
||||
/// <summary>
|
||||
/// fId
|
||||
/// frId
|
||||
/// </summary>
|
||||
[SugarColumn(IsPrimaryKey = true, Length = 50)]
|
||||
public string fId { get; set; }
|
||||
[SugarColumn(IsPrimaryKey = true, Length = 100)]
|
||||
public string frId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// sId
|
||||
/// userId
|
||||
/// </summary>
|
||||
[SugarColumn(Length = 50, IsNullable = true)]
|
||||
public string? sId { get; set; }
|
||||
public string? userId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// mId
|
||||
/// toId
|
||||
/// </summary>
|
||||
[SugarColumn(Length = 50, IsNullable = true)]
|
||||
public string? mId { get; set; }
|
||||
public string? toId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// near
|
||||
/// 亲密度
|
||||
/// </summary>
|
||||
[SugarColumn(IsNullable = true)]
|
||||
public int? near { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// status
|
||||
/// </summary>
|
||||
[SugarColumn(IsNullable = true)]
|
||||
public int? status { get; set; }
|
||||
public long? near { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// addTime
|
||||
@@ -42,4 +36,4 @@ namespace Application.Domain.Entity
|
||||
[SugarColumn(IsNullable = true)]
|
||||
public DateTime? addTime { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
using SqlSugar;
|
||||
using System;
|
||||
|
||||
namespace Application.Domain.Entity
|
||||
{
|
||||
[Tenant("Kg.SeaTime.Game")]
|
||||
public class unit_user_mail
|
||||
{
|
||||
/// <summary>
|
||||
/// mailId
|
||||
/// </summary>
|
||||
[SugarColumn(IsPrimaryKey = true, Length = 50)]
|
||||
public string mailId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// userId
|
||||
/// </summary>
|
||||
[SugarColumn(Length = 50, IsNullable = true)]
|
||||
public string? userId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// name
|
||||
/// </summary>
|
||||
[SugarColumn(Length = 50, IsNullable = true)]
|
||||
public string? name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// sign
|
||||
/// </summary>
|
||||
[SugarColumn(IsNullable = true)]
|
||||
public string? sign { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// isRead
|
||||
/// </summary>
|
||||
[SugarColumn(IsNullable = true)]
|
||||
public int? isRead { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// isGet
|
||||
/// </summary>
|
||||
[SugarColumn(IsNullable = true)]
|
||||
public int? isGet { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// award
|
||||
/// </summary>
|
||||
[SugarColumn(IsNullable = true,IsJson = true)]
|
||||
public List<TowerGet> award { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// addTime
|
||||
/// </summary>
|
||||
[SugarColumn(IsNullable = true)]
|
||||
public DateTime? addTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// endTime
|
||||
/// </summary>
|
||||
[SugarColumn(IsNullable = true)]
|
||||
public long? endTime { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
using SqlSugar;
|
||||
using System;
|
||||
|
||||
namespace Application.Domain.Entity
|
||||
{
|
||||
[Tenant("Kg.SeaTime.Game")]
|
||||
public class unit_user_message_event
|
||||
{
|
||||
/// <summary>
|
||||
/// eventId
|
||||
/// </summary>
|
||||
[SugarColumn(IsPrimaryKey = true, Length = 50)]
|
||||
public string eventId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// userId
|
||||
/// </summary>
|
||||
[SugarColumn(Length = 50, IsNullable = true)]
|
||||
public string? userId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// code
|
||||
/// </summary>
|
||||
[SugarColumn(Length = 50, IsNullable = true)]
|
||||
public string? code { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// name
|
||||
/// </summary>
|
||||
[SugarColumn(Length = 50, IsNullable = true)]
|
||||
public string? name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// sign
|
||||
/// </summary>
|
||||
[SugarColumn(Length = 255, IsNullable = true)]
|
||||
public string? sign { get; set; }
|
||||
|
||||
[SugarColumn(IsNullable = true)]
|
||||
public string? pars { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// state
|
||||
/// </summary>
|
||||
[SugarColumn(IsNullable = true)]
|
||||
public int? state { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// btns
|
||||
/// </summary>
|
||||
[SugarColumn(IsNullable = true, IsJson = true)]
|
||||
public List<MsgEventBtn> btns { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// addTime
|
||||
/// </summary>
|
||||
[SugarColumn(IsNullable = true)]
|
||||
public DateTime? addTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// endTime
|
||||
/// </summary>
|
||||
[SugarColumn(IsNullable = true)]
|
||||
public long? endTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// token
|
||||
/// </summary>
|
||||
[SugarColumn(Length = 255, IsNullable = true)]
|
||||
public string? token { get; set; }
|
||||
}
|
||||
}
|
||||
8
Service/Application.Domain.Entity/model/MsgEventBtn.cs
Normal file
8
Service/Application.Domain.Entity/model/MsgEventBtn.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
namespace Application.Domain.Entity;
|
||||
|
||||
public class MsgEventBtn
|
||||
{
|
||||
public int status { get; set; }
|
||||
public string name { get; set; }
|
||||
public string tips { get; set; }
|
||||
}
|
||||
36
Service/Application.Domain.Entity/model/TowerGet.cs
Normal file
36
Service/Application.Domain.Entity/model/TowerGet.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
namespace Application.Domain.Entity;
|
||||
|
||||
public class TowerGet
|
||||
{
|
||||
private System.String _code;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public System.String code
|
||||
{ get { return this._code; } set { this._code = value; } }
|
||||
|
||||
private System.String _name;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public System.String name
|
||||
{ get { return this._name; } set { this._name = value; } }
|
||||
|
||||
private System.String _parameter;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public System.String parameter
|
||||
{ get { return this._parameter; } set { this._parameter = value; } }
|
||||
|
||||
private long _count;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public long count
|
||||
{ get { return this._count; } set { this._count = value; } }
|
||||
}
|
||||
@@ -8,4 +8,5 @@ public class UserModel
|
||||
public string headImg { get; set; }
|
||||
public int area { get; set; }
|
||||
public string icon { get; set; }
|
||||
public int lev { get; set; }
|
||||
}
|
||||
10
Service/Application.Domain.Entity/model/UserOnMap.cs
Normal file
10
Service/Application.Domain.Entity/model/UserOnMap.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
namespace Application.Domain.Entity;
|
||||
|
||||
public class UserOnMap
|
||||
{
|
||||
public string mapId { get; set; }
|
||||
public string mapName { get; set; }
|
||||
public int cityId { get; set; }
|
||||
public string cityName { get; set; }
|
||||
public int isOnline { get; set; }
|
||||
}
|
||||
11
Service/Application.Domain.Entity/view/RelationView.cs
Normal file
11
Service/Application.Domain.Entity/view/RelationView.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
namespace Application.Domain.Entity;
|
||||
|
||||
public class RelationView
|
||||
{
|
||||
public UserModel user { get; set; }
|
||||
public long near { get; set; }
|
||||
public string mapName { get; set; }
|
||||
public string cityName { get; set; }
|
||||
public long sort { get; set; }
|
||||
public int isOnline { get; set; }
|
||||
}
|
||||
11
Service/Application.Domain/Enum/MessageEnum.cs
Normal file
11
Service/Application.Domain/Enum/MessageEnum.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
namespace Application.Domain;
|
||||
|
||||
public static class MessageEnum
|
||||
{
|
||||
public enum EventCode
|
||||
{
|
||||
Friend,//交友消息
|
||||
Marry,//婚姻消息
|
||||
Trade,//交易通知
|
||||
}
|
||||
}
|
||||
55
Service/Application.Domain/Handle/MessageHandle.cs
Normal file
55
Service/Application.Domain/Handle/MessageHandle.cs
Normal file
@@ -0,0 +1,55 @@
|
||||
namespace Application.Domain;
|
||||
|
||||
public class MessageHandle
|
||||
{
|
||||
public async Task<MessageHandleResult> HandleMsg(unit_user_message_event events, int state)
|
||||
{
|
||||
if (events.code == nameof(MessageEnum.EventCode.Friend))
|
||||
{
|
||||
var relationService = App.GetRequiredService<IUnitUserRelationService>();
|
||||
var isFriend = await relationService.CheckIsFriend(events.userId, events.pars);
|
||||
if (isFriend)
|
||||
{
|
||||
return new MessageHandleResult() { success = true, msg = "你们已经是好友啦!" };
|
||||
}
|
||||
|
||||
if (state == 1)
|
||||
{
|
||||
if (await relationService.AddFriend(events.userId, events.pars))
|
||||
{
|
||||
var chatService = App.GetService<IGameChatService>();
|
||||
var userService = App.GetService<IUnitUserService>();
|
||||
var myInfo = await userService.GetUserInfoByUserId(events.userId);
|
||||
string sign = $"{UbbTool.HomeUbb(myInfo.userNo, myInfo.nick)}已通过了您的好友申请!";
|
||||
await chatService.SendChat(events.pars, (int)myInfo.areaId, nameof(GameChatEnum.Code.System), sign);
|
||||
return new MessageHandleResult() { success = true, msg = "已通过该好友申请!" };
|
||||
}
|
||||
else
|
||||
{
|
||||
return new MessageHandleResult() { success = false, msg = "好友添加失败,请稍后尝试!" };
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var chatService = App.GetService<IGameChatService>();
|
||||
var userService = App.GetService<IUnitUserService>();
|
||||
var myInfo = await userService.GetUserInfoByUserId(events.userId);
|
||||
string sign = $"{UbbTool.HomeUbb(myInfo.userNo, myInfo.nick)}拒绝了您的好友申请!";
|
||||
await chatService.SendChat(events.pars, (int)myInfo.areaId, nameof(GameChatEnum.Code.System), sign);
|
||||
return new MessageHandleResult() { success = true, msg = "已拒绝该好友申请!" };
|
||||
}
|
||||
}
|
||||
else if (events.code == nameof(MessageEnum.EventCode.Friend))
|
||||
{
|
||||
return new MessageHandleResult() { success = true, msg = "消息通知已处理!" };
|
||||
}
|
||||
|
||||
return new MessageHandleResult() { success = false, msg = "暂不支持该操作处理!" };
|
||||
}
|
||||
}
|
||||
|
||||
public class MessageHandleResult
|
||||
{
|
||||
public bool success { get; set; }
|
||||
public string msg { get; set; }
|
||||
}
|
||||
@@ -2,12 +2,13 @@
|
||||
|
||||
public interface IGameChatService
|
||||
{
|
||||
Task<List<GameChatView>> GetChatTop(int areaId, int top, string teamId, string groupId);
|
||||
Task<List<GameChatView>> GetChatTop(string userId,int areaId, int top, string teamId, string groupId);
|
||||
|
||||
Task<List<GameChatView>> GetChatData(int type, int areaId, string teamId, string groupId, int page, int limit,
|
||||
Task<List<GameChatView>> GetChatData(string userId, int type, int areaId, string teamId, string groupId, int page,
|
||||
int limit,
|
||||
RefAsync<int> total);
|
||||
|
||||
Task<bool> SendChat(string userId, int areaId, string code, string sign, string par = "");
|
||||
Task<bool> SendChat(string userId, string code, string sign, string par = "");
|
||||
Task<bool> DeleteChat(string chatId);
|
||||
|
||||
}
|
||||
@@ -20,6 +20,7 @@ public interface IGameMapService
|
||||
Task<unit_user_online> GetUserOnMap(string userId);
|
||||
Task UpdateUserOnMap(string userId, string ip, string mapId);
|
||||
Task<bool> UpdateUserOnMap(unit_user_online data, string mapId);
|
||||
Task<UserOnMap> GetUserOnMapInfo(string userId);
|
||||
Task SetUserMapDefult(string userId);
|
||||
Task<game_city_map> GetToMapInfo(string userId, string toMap, bool isUpUserMap = true, bool isChangeCity = false);
|
||||
#endregion
|
||||
|
||||
@@ -2,15 +2,16 @@
|
||||
|
||||
public interface IMessageService
|
||||
{
|
||||
Task<int> GetNoReadCount(string userId);
|
||||
Task<List<int>> GetNoReadCount(string userId);
|
||||
|
||||
#region 私聊消息
|
||||
#region 私聊消息
|
||||
|
||||
string GetTalkId(string userId, string otId);
|
||||
Task<List<unit_user_message>> GetUserNoReadData(string talkId);
|
||||
|
||||
Task<List<unit_user_message>> GetUserMessageData(string talkId, int page, int limit,
|
||||
RefAsync<int> total);
|
||||
|
||||
Task<List<MessageView>> GetUserMessage(string userId, int type, int page, int limit,
|
||||
RefAsync<int> total);
|
||||
|
||||
@@ -19,4 +20,27 @@ public interface IMessageService
|
||||
Task<bool> DeleteMsgByTalkId(string talkId, string userId);
|
||||
|
||||
#endregion
|
||||
|
||||
#region 邮件消息
|
||||
|
||||
Task<List<unit_user_mail>> GetUserMailData(string userId, int page, int limit, RefAsync<int> total);
|
||||
Task<unit_user_mail> GetMailInfo(string mailId);
|
||||
Task<bool> SendMaill(string userId, string name, string sign, List<TowerGet> award, int days = 10);
|
||||
Task<bool> UpdateMaillInfo(unit_user_mail data);
|
||||
|
||||
#endregion
|
||||
|
||||
#region 通知消息
|
||||
|
||||
Task<List<unit_user_message_event>> GetUserEventMessage(string userId, int page, int limit,
|
||||
RefAsync<int> total);
|
||||
|
||||
Task<unit_user_message_event> GetEventMessageInfo(string eventId);
|
||||
Task<bool> UpdateEventData(unit_user_message_event data);
|
||||
Task<bool> CheckAtEventMsg(string token);
|
||||
|
||||
Task<bool> SendEventMsg(string userId, string code, string name, string sign, string pars, string token,
|
||||
List<MsgEventBtn> btns = null, int days = 10);
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -6,7 +6,7 @@ public interface IUnitUserAttrService
|
||||
|
||||
Task<UserAttrModel> GetUserAttrModel(string userId);
|
||||
Task<unit_user_attr> GetUserAttr(string userId);
|
||||
|
||||
Task<int> GetUserLev(string userId);
|
||||
#endregion
|
||||
|
||||
#region 体力操作
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
namespace Application.Domain;
|
||||
|
||||
public interface IUnitUserRelationService
|
||||
{
|
||||
#region 好友关系
|
||||
|
||||
Task<int> GetUserFriendCount(string userId);
|
||||
Task<List<RelationView>> GetUserFriend(string userId);
|
||||
Task<bool> CheckIsFriend(string userId, string toId);
|
||||
Task<bool> AddFriend(string userId, string toId);
|
||||
Task<bool> DeleteFriend(string userId, string toId);
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -11,16 +11,18 @@ public class GameChatService : IGameChatService, ITransient
|
||||
_redisClient = redisClient;
|
||||
}
|
||||
|
||||
public async Task<List<GameChatView>> GetChatTop(int areaId, int top, string teamId, string groupId)
|
||||
public async Task<List<GameChatView>> GetChatTop(string userId, int areaId, int top, string teamId, string groupId)
|
||||
{
|
||||
var db = _dbClient.AsTenant().GetConnectionWithAttr<game_chat>();
|
||||
List<string> allCode = new List<string>() { "Public", "Region", "System" };
|
||||
List<string> allCode = new List<string>() { "Public", "Region" };
|
||||
var data = await db.Queryable<game_chat>().Where(it => it.state == 1 &&
|
||||
(
|
||||
(allCode.Contains(it.code) && it.areaId == areaId) ||
|
||||
(it.code == "Group" && it.par == groupId) ||
|
||||
(it.code == "Team" && it.par == teamId) ||
|
||||
(it.code == "Dress")
|
||||
(it.code == "Dress") ||
|
||||
(it.code == "System" && it.areaId == areaId &&
|
||||
(it.userId == "0" || it.userId == userId))
|
||||
)
|
||||
).Take(top).OrderByDescending(it => it.sort).ToListAsync();
|
||||
|
||||
@@ -34,7 +36,8 @@ public class GameChatService : IGameChatService, ITransient
|
||||
return result;
|
||||
}
|
||||
|
||||
public async Task<List<GameChatView>> GetChatData(int type, int areaId, string teamId, string groupId, int page,
|
||||
public async Task<List<GameChatView>> GetChatData(string userId, int type, int areaId, string teamId,
|
||||
string groupId, int page,
|
||||
int limit,
|
||||
RefAsync<int> total)
|
||||
{
|
||||
@@ -42,13 +45,15 @@ public class GameChatService : IGameChatService, ITransient
|
||||
var db = _dbClient.AsTenant().GetConnectionWithAttr<game_chat>();
|
||||
if (type == 0)
|
||||
{
|
||||
List<string> allCode = new List<string>() { "Public", "Region", "System" };
|
||||
List<string> allCode = new List<string>() { "Public", "Region" };
|
||||
data = await db.Queryable<game_chat>().Where(it => it.state == 1 &&
|
||||
(
|
||||
(allCode.Contains(it.code) && it.areaId == areaId) ||
|
||||
(it.code == "Group" && it.par == groupId) ||
|
||||
(it.code == "Team" && it.par == teamId) ||
|
||||
(it.code == "Dress")
|
||||
(it.code == "Dress") ||
|
||||
(it.code == "System" && it.areaId == areaId &&
|
||||
(it.userId == "0" || it.userId == userId))
|
||||
)
|
||||
).OrderByDescending(it => it.sort).ToPageListAsync(page, limit, total);
|
||||
}
|
||||
@@ -76,13 +81,16 @@ public class GameChatService : IGameChatService, ITransient
|
||||
else if (type == 5) //系统
|
||||
{
|
||||
data = await db.Queryable<game_chat>()
|
||||
.Where(it => it.state == 1 && it.code == "System" && it.areaId == areaId
|
||||
.Where(it =>
|
||||
it.state == 1 && it.code == "System" && it.areaId == areaId &&
|
||||
(it.userId == "0" || it.userId == userId)
|
||||
).OrderByDescending(it => it.sort).ToPageListAsync(page, limit, total);
|
||||
}
|
||||
else
|
||||
{
|
||||
data = new List<game_chat>();
|
||||
}
|
||||
|
||||
var result = new List<GameChatView>();
|
||||
foreach (var item in data)
|
||||
{
|
||||
@@ -138,6 +146,15 @@ public class GameChatService : IGameChatService, ITransient
|
||||
var db = _dbClient.AsTenant().GetConnectionWithAttr<game_chat>();
|
||||
return await db.Insertable(chat).ExecuteCommandAsync() > 0;
|
||||
}
|
||||
|
||||
public async Task<bool> SendChat(string userId, string code, string sign, string par = "")
|
||||
{
|
||||
var userService = App.GetService<IUnitUserService>();
|
||||
var userInfo = await userService.GetUserInfoByUserId(userId);
|
||||
if (userInfo == null) return false;
|
||||
|
||||
return await SendChat(userId, (int)userInfo.areaId, code, sign, par);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删除聊天
|
||||
|
||||
@@ -31,8 +31,7 @@ public class GameMapService(ISqlSugarClient DbClient, IRedisCache redis) : IGame
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public async Task<List<game_city_map>> GetCityMap(int cityId)
|
||||
{
|
||||
@@ -147,6 +146,22 @@ public class GameMapService(ISqlSugarClient DbClient, IRedisCache redis) : IGame
|
||||
return data;
|
||||
}
|
||||
|
||||
public async Task<UserOnMap> GetUserOnMapInfo(string userId)
|
||||
{
|
||||
var onMap = await GetUserOnMap(userId);
|
||||
var mapInfo = await GetMapInfo(onMap.mapId);
|
||||
var cityInfo = await GetCityInfo((int)mapInfo.cityId);
|
||||
int isOnline =
|
||||
onMap.upTime > (TimeExtend.GetTimeStampBySeconds(DateTime.Now.AddMinutes(0 - GameConfig.OnLineTime)))
|
||||
? 1
|
||||
: 0;
|
||||
return new UserOnMap()
|
||||
{
|
||||
mapId = mapInfo.mapId, mapName = mapInfo.mapName, cityId = cityInfo.cityId, cityName = cityInfo.cityName,
|
||||
isOnline = isOnline
|
||||
};
|
||||
}
|
||||
|
||||
public async Task UpdateUserOnMap(string userId, string ip, string mapId)
|
||||
{
|
||||
unit_user_online onLine = new unit_user_online();
|
||||
@@ -320,7 +335,7 @@ public class GameMapService(ISqlSugarClient DbClient, IRedisCache redis) : IGame
|
||||
#endregion
|
||||
|
||||
#region 自动寻路
|
||||
|
||||
|
||||
private async Task<List<game_city>> GetCityDataExcludeParent()
|
||||
{
|
||||
string key = string.Format(BaseCache.BaseCacheKeys, "MapPathData", "CityParent");
|
||||
@@ -332,8 +347,10 @@ public class GameMapService(ISqlSugarClient DbClient, IRedisCache redis) : IGame
|
||||
|
||||
await redis.SetAsync(key, data);
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
private async Task<List<game_city_map>> GetAllMaoToData()
|
||||
{
|
||||
string key = string.Format(BaseCache.BaseCacheKeys, "MapPathData", "CityInterCityPortal");
|
||||
@@ -343,7 +360,7 @@ public class GameMapService(ISqlSugarClient DbClient, IRedisCache redis) : IGame
|
||||
}
|
||||
|
||||
List<game_city_map> result = new List<game_city_map>();
|
||||
|
||||
|
||||
var cityData = await GetCityDataExcludeParent();
|
||||
foreach (var item in cityData)
|
||||
{
|
||||
@@ -356,9 +373,11 @@ public class GameMapService(ISqlSugarClient DbClient, IRedisCache redis) : IGame
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
await redis.SetAsync(key, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 城市信息
|
||||
/// </summary>
|
||||
@@ -378,7 +397,7 @@ public class GameMapService(ISqlSugarClient DbClient, IRedisCache redis) : IGame
|
||||
{
|
||||
var cityTemp = new CityNode(city.cityId, city.cityName, new Point((int)mdMap.x, (int)mdMap.y),
|
||||
mdMap.mapName, (int)city.x_s, (int)city.x_e, (int)city.y_s, (int)city.y_e);
|
||||
data.Add(cityTemp);
|
||||
data.Add(cityTemp);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -413,8 +432,7 @@ public class GameMapService(ISqlSugarClient DbClient, IRedisCache redis) : IGame
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 传送点信息
|
||||
/// </summary>
|
||||
|
||||
@@ -1,30 +1,29 @@
|
||||
namespace Application.Domain;
|
||||
using Dm.util;
|
||||
|
||||
namespace Application.Domain;
|
||||
|
||||
public class MessageService(ISqlSugarClient DbClient, IRedisCache redis) : IMessageService, ITransient
|
||||
{
|
||||
public async Task<int> GetNoReadCount(string userId)
|
||||
public async Task<List<int>> GetNoReadCount(string userId)
|
||||
{
|
||||
string key = string.Format(UserCache.BaseCacheKeys, "Message", "Count");
|
||||
if (await redis.HExistsHashAsync(key, userId))
|
||||
{
|
||||
return await redis.GetHashAsync<int>(key, userId);
|
||||
}
|
||||
|
||||
int result = 0;
|
||||
List<int> result = new List<int>();
|
||||
//普通消息
|
||||
int noRead = await GetUserNoReadDataCountByUserId(userId);
|
||||
result += noRead;
|
||||
//邮件详细
|
||||
int noRead = await GetUserNoReadMsgCount(userId);
|
||||
result.Add(noRead);
|
||||
|
||||
//通知消息
|
||||
await redis.AddHashAsync(key, userId, result);
|
||||
int noEvent = await GetUserNoReadEventMsgCount(userId);
|
||||
result.Add(noEvent);
|
||||
|
||||
//邮件详细
|
||||
int noMail = await GetUserNoReadMailCount(userId);
|
||||
result.Add(noMail);
|
||||
|
||||
//汇总
|
||||
result.Add(result.Sum());
|
||||
return result;
|
||||
}
|
||||
|
||||
private async Task ClearMessageCache(string userId)
|
||||
{
|
||||
string key = string.Format(UserCache.BaseCacheKeys, "Message", "Count");
|
||||
await redis.DelHashAsync(key, userId);
|
||||
}
|
||||
|
||||
#region 私信消息
|
||||
|
||||
@@ -38,11 +37,25 @@ public class MessageService(ISqlSugarClient DbClient, IRedisCache redis) : IMess
|
||||
return talkId.Split('_').ToList();
|
||||
}
|
||||
|
||||
private async Task<int> GetUserNoReadDataCountByUserId(string userId)
|
||||
private async Task<int> GetUserNoReadMsgCount(string userId)
|
||||
{
|
||||
string key = string.Format(UserCache.BaseCacheKeys, "Message", "MsgCount");
|
||||
if (await redis.HExistsHashAsync(key, userId))
|
||||
{
|
||||
return await redis.GetHashAsync<int>(key, userId);
|
||||
}
|
||||
|
||||
var db = DbClient.AsTenant().GetConnectionScopeWithAttr<unit_user_message>();
|
||||
return await db.Queryable<unit_user_message>()
|
||||
int count = await db.Queryable<unit_user_message>()
|
||||
.Where(it => it.status == 1 && it.userId == userId && it.isRead == 0).CountAsync();
|
||||
await redis.AddHashAsync(key, userId, count);
|
||||
return count;
|
||||
}
|
||||
|
||||
private async Task ClearMsgCountCache(string userId)
|
||||
{
|
||||
string key = string.Format(UserCache.BaseCacheKeys, "Message", "MsgCount");
|
||||
await redis.DelHashAsync(key, userId);
|
||||
}
|
||||
|
||||
public async Task<List<unit_user_message>> GetUserNoReadData(string talkId)
|
||||
@@ -131,7 +144,7 @@ public class MessageService(ISqlSugarClient DbClient, IRedisCache redis) : IMess
|
||||
bool result = await db.Insertable(adds).ExecuteCommandAsync() > 0;
|
||||
if (result)
|
||||
{
|
||||
await ClearMessageCache(toUser);
|
||||
await ClearMsgCountCache(toUser);
|
||||
}
|
||||
|
||||
return result;
|
||||
@@ -144,7 +157,7 @@ public class MessageService(ISqlSugarClient DbClient, IRedisCache redis) : IMess
|
||||
.Where(it => msgIds.Contains(it.msgId)).ExecuteCommandAsync() > 0;
|
||||
if (result)
|
||||
{
|
||||
await ClearMessageCache(userId);
|
||||
await ClearMsgCountCache(userId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -156,7 +169,178 @@ public class MessageService(ISqlSugarClient DbClient, IRedisCache redis) : IMess
|
||||
0;
|
||||
if (result)
|
||||
{
|
||||
await ClearMessageCache(userId);
|
||||
await ClearMsgCountCache(userId);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 邮件消息
|
||||
|
||||
private async Task<int> GetUserNoReadMailCount(string userId)
|
||||
{
|
||||
string key = string.Format(UserCache.BaseCacheKeys, "Message", "MailCount");
|
||||
if (await redis.HExistsHashAsync(key, userId))
|
||||
{
|
||||
return await redis.GetHashAsync<int>(key, userId);
|
||||
}
|
||||
|
||||
var db = DbClient.AsTenant().GetConnectionWithAttr<unit_user_mail>();
|
||||
int count = await db.Queryable<unit_user_mail>().Where(it => it.userId == userId && it.isRead == 0)
|
||||
.CountAsync();
|
||||
await redis.AddHashAsync(key, userId, count);
|
||||
return count;
|
||||
}
|
||||
|
||||
private async Task ClearMailCountCache(string userId)
|
||||
{
|
||||
string key = string.Format(UserCache.BaseCacheKeys, "Message", "MailCount");
|
||||
await redis.DelHashAsync(key, userId);
|
||||
}
|
||||
|
||||
public async Task<List<unit_user_mail>> GetUserMailData(string userId, int page, int limit, RefAsync<int> total)
|
||||
{
|
||||
long onTime = TimeExtend.GetTimeStampSeconds;
|
||||
var db = DbClient.AsTenant().GetConnectionWithAttr<unit_user_mail>();
|
||||
return await db.Queryable<unit_user_mail>().Where(it => it.userId == userId && it.endTime > onTime)
|
||||
.OrderBy(it => it.isGet, OrderByType.Asc)
|
||||
.OrderBy(it => it.isRead, OrderByType.Asc)
|
||||
.OrderByDescending(it => it.addTime)
|
||||
.ToPageListAsync(page, limit, total);
|
||||
}
|
||||
|
||||
public async Task<unit_user_mail> GetMailInfo(string mailId)
|
||||
{
|
||||
var db = DbClient.AsTenant().GetConnectionWithAttr<unit_user_mail>();
|
||||
return await db.Queryable<unit_user_mail>().Where(it => it.mailId == mailId)
|
||||
.SingleAsync();
|
||||
}
|
||||
|
||||
public async Task<bool> SendMaill(string userId, string name, string sign, List<TowerGet> award, int days = 10)
|
||||
{
|
||||
unit_user_mail mail = new unit_user_mail();
|
||||
mail.mailId = StringAssist.NewGuid;
|
||||
mail.userId = userId;
|
||||
mail.name = name;
|
||||
mail.sign = sign;
|
||||
mail.isRead = 0;
|
||||
mail.isGet = award.Count > 0 ? 0 : 1;
|
||||
mail.award = award;
|
||||
mail.addTime = DateTime.Now;
|
||||
mail.endTime = TimeExtend.GetTimeStampBySeconds(DateTime.Now.AddDays(days));
|
||||
var db = DbClient.AsTenant().GetConnectionWithAttr<unit_user_mail>();
|
||||
bool result = await db.Insertable(mail).ExecuteCommandAsync() > 0;
|
||||
if (result)
|
||||
{
|
||||
await ClearMailCountCache(userId);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public async Task<bool> UpdateMaillInfo(unit_user_mail data)
|
||||
{
|
||||
var db = DbClient.AsTenant().GetConnectionWithAttr<unit_user_mail>();
|
||||
bool result = await db.Updateable<unit_user_mail>(data).ExecuteCommandAsync() > 0;
|
||||
if (result)
|
||||
{
|
||||
await ClearMailCountCache(data.userId);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 通知消息
|
||||
|
||||
private async Task<int> GetUserNoReadEventMsgCount(string userId)
|
||||
{
|
||||
string key = string.Format(UserCache.BaseCacheKeys, "Message", "EventCount");
|
||||
if (await redis.HExistsHashAsync(key, userId))
|
||||
{
|
||||
return await redis.GetHashAsync<int>(key, userId);
|
||||
}
|
||||
|
||||
var db = DbClient.AsTenant().GetConnectionScopeWithAttr<unit_user_message_event>();
|
||||
int Count = await db.Queryable<unit_user_message_event>().Where(it => it.userId == userId && it.state == 0)
|
||||
.CountAsync();
|
||||
await redis.AddHashAsync(key, userId, Count);
|
||||
return Count;
|
||||
}
|
||||
|
||||
private async Task ClearEventCountCache(string userId)
|
||||
{
|
||||
string key = string.Format(UserCache.BaseCacheKeys, "Message", "EventCount");
|
||||
await redis.DelHashAsync(key, userId);
|
||||
}
|
||||
|
||||
public async Task<List<unit_user_message_event>> GetUserEventMessage(string userId, int page, int limit,
|
||||
RefAsync<int> total)
|
||||
{
|
||||
var db = DbClient.AsTenant().GetConnectionScopeWithAttr<unit_user_message_event>();
|
||||
return await db.Queryable<unit_user_message_event>().Where(it => it.userId == userId)
|
||||
.OrderByDescending(it => it.addTime)
|
||||
.ToPageListAsync(page, limit, total);
|
||||
}
|
||||
|
||||
public async Task<unit_user_message_event> GetEventMessageInfo(string eventId)
|
||||
{
|
||||
var db = DbClient.AsTenant().GetConnectionScopeWithAttr<unit_user_message_event>();
|
||||
return await db.Queryable<unit_user_message_event>().Where(it => it.eventId == eventId)
|
||||
.SingleAsync();
|
||||
}
|
||||
|
||||
public async Task<bool> UpdateEventData(unit_user_message_event data)
|
||||
{
|
||||
var db = DbClient.AsTenant().GetConnectionScopeWithAttr<unit_user_message_event>();
|
||||
var result = await db.Updateable(data).ExecuteCommandAsync() > 0;
|
||||
if (result)
|
||||
{
|
||||
await ClearEventCountCache(data.userId);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public async Task<bool> CheckAtEventMsg(string token)
|
||||
{
|
||||
var db = DbClient.AsTenant().GetConnectionScopeWithAttr<unit_user_message_event>();
|
||||
return await db.Queryable<unit_user_message_event>().Where(it => it.state == 0 && it.token == token).AnyAsync();
|
||||
}
|
||||
|
||||
public async Task<bool> SendEventMsg(string userId, string code, string name, string sign, string pars,string token,
|
||||
List<MsgEventBtn> btns=null, int days = 10)
|
||||
{
|
||||
unit_user_message_event data = new unit_user_message_event();
|
||||
data.eventId = StringAssist.NewGuid;
|
||||
data.userId = userId;
|
||||
data.code = code;
|
||||
data.name = name;
|
||||
data.sign = sign;
|
||||
data.pars = pars;
|
||||
data.state = 0;
|
||||
if (btns == null)
|
||||
{
|
||||
data.btns = new List<MsgEventBtn>()
|
||||
{
|
||||
new MsgEventBtn() { status = 1, name = "我知道啦", tips = "已处理" }
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
data.btns = btns;
|
||||
}
|
||||
data.addTime = DateTime.Now;
|
||||
data.endTime = TimeExtend.GetTimeStampBySeconds(DateTime.Now.AddDays(days));
|
||||
data.token = token;
|
||||
var db = DbClient.AsTenant().GetConnectionScopeWithAttr<unit_user_message_event>();
|
||||
var result = await db.Insertable(data).ExecuteCommandAsync() > 0;
|
||||
if (result)
|
||||
{
|
||||
await ClearEventCountCache(data.userId);
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
@@ -44,6 +44,18 @@ public class UnitUserAttrService(ISqlSugarClient DbClient, IRedisCache redis) :
|
||||
return data;
|
||||
}
|
||||
|
||||
public async Task<int> GetUserLev(string userId)
|
||||
{
|
||||
int lev = 0;
|
||||
var attrInfo = await GetUserAttr(userId);
|
||||
if (attrInfo != null)
|
||||
{
|
||||
lev = (int)attrInfo.lev;
|
||||
}
|
||||
|
||||
return lev;
|
||||
}
|
||||
|
||||
private async Task ClearUserAttrCache(string userId)
|
||||
{
|
||||
string key = string.Format(UserCache.BaseCacheKeys, "AttrData", "UserAttr");
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
namespace Application.Domain;
|
||||
|
||||
public class UnitUserRelationService(ISqlSugarClient DbClient, IRedisCache redis) : IUnitUserRelationService, ITransient
|
||||
{
|
||||
#region 好友关系
|
||||
|
||||
public async Task<int> GetUserFriendCount(string userId)
|
||||
{
|
||||
var db = DbClient.AsTenant().GetConnectionWithAttr<unit_user_friend>();
|
||||
return await db.Queryable<unit_user_friend>().Where(it => it.frId.Contains(userId)).CountAsync();
|
||||
}
|
||||
|
||||
public async Task<List<RelationView>> GetUserFriend(string userId)
|
||||
{
|
||||
List<RelationView> result = new List<RelationView>();
|
||||
var db = DbClient.AsTenant().GetConnectionWithAttr<unit_user_friend>();
|
||||
|
||||
var data = await db.Queryable<unit_user_friend>().Where(it => it.frId.Contains(userId))
|
||||
.ToListAsync();
|
||||
foreach (var item in data)
|
||||
{
|
||||
RelationView temp = new RelationView();
|
||||
string otUser = item.userId == userId ? item.toId : item.userId;
|
||||
temp.user = await UserModelTool.GetUserView(otUser);
|
||||
temp.near = (long)item.near;
|
||||
|
||||
var mapService = App.GetService<IGameMapService>();
|
||||
var onMap = await mapService.GetUserOnMapInfo(otUser);
|
||||
temp.mapName = onMap.mapName;
|
||||
temp.cityName = onMap.cityName;
|
||||
temp.sort = TimeExtend.GetTimeStampBySeconds((DateTime)item.addTime);
|
||||
temp.isOnline = onMap.isOnline;
|
||||
result.Add(temp);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public async Task<bool> CheckIsFriend(string userId, string toId)
|
||||
{
|
||||
string frId = StringAssist.GetSortKey(userId, toId);
|
||||
var db = DbClient.AsTenant().GetConnectionWithAttr<unit_user_friend>();
|
||||
return await db.Queryable<unit_user_friend>().Where(it => it.frId == frId).AnyAsync();
|
||||
}
|
||||
|
||||
public async Task<bool> AddFriend(string userId, string toId)
|
||||
{
|
||||
unit_user_friend friend = new unit_user_friend();
|
||||
friend.frId = StringAssist.GetSortKey(userId, toId);
|
||||
friend.userId = userId;
|
||||
friend.toId = toId;
|
||||
friend.near = 0;
|
||||
friend.addTime = DateTime.Now;
|
||||
var db = DbClient.AsTenant().GetConnectionWithAttr<unit_user_friend>();
|
||||
return await db.Insertable(friend).ExecuteCommandAsync() > 0;
|
||||
}
|
||||
|
||||
public async Task<bool> DeleteFriend(string userId, string toId)
|
||||
{
|
||||
string frId = StringAssist.GetSortKey(userId, toId);
|
||||
var db = DbClient.AsTenant().GetConnectionWithAttr<unit_user_friend>();
|
||||
return await db.Deleteable<unit_user_friend>().Where(it => it.frId == frId).ExecuteCommandAsync()>0;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -68,5 +68,29 @@ public class GameBus
|
||||
return isok;
|
||||
}
|
||||
|
||||
public static async Task<bool> UpdateBag(string userId, int operate, dynamic Reward, string remark = "",
|
||||
long count = 1)
|
||||
{
|
||||
try
|
||||
{
|
||||
foreach (var item in Reward)
|
||||
{
|
||||
long num = Convert.ToInt64(item.count) * count;
|
||||
if (num <= 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
await UpdateBag(userId, operate, item.code, item.parameter, num, remark);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
9
Service/Application.Domain/Tool/Base/UbbTool.cs
Normal file
9
Service/Application.Domain/Tool/Base/UbbTool.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
namespace Application.Domain;
|
||||
|
||||
public class UbbTool
|
||||
{
|
||||
public static string HomeUbb(string no, string name)
|
||||
{
|
||||
return $"<a data-type='go' data-parms='/user/user?no={no}' href='javascript:void'>{name}</a>";
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,7 @@ public class UserModelTool
|
||||
/// <param name="userId"></param>
|
||||
/// <param name="addIcon"></param>
|
||||
/// <returns></returns>
|
||||
public static async Task<UserModel> GetUserView(string userId,bool addIcon=false)
|
||||
public static async Task<UserModel> GetUserView(string userId, bool addIcon = false)
|
||||
{
|
||||
UserModel result = new UserModel();
|
||||
if (userId == "0")
|
||||
@@ -19,10 +19,12 @@ public class UserModelTool
|
||||
result.headImg = "";
|
||||
result.area = 0;
|
||||
result.icon = "";
|
||||
result.lev = 999;
|
||||
}
|
||||
else
|
||||
{
|
||||
var userService = App.GetService<IUnitUserService>();
|
||||
var attrService = App.GetRequiredService<IUnitUserAttrService>();
|
||||
var userInfo = await userService.GetUserInfoByUserId(userId);
|
||||
if (userInfo != null)
|
||||
{
|
||||
@@ -32,12 +34,14 @@ public class UserModelTool
|
||||
result.headImg = userInfo.headImg;
|
||||
result.area = (int)userInfo.areaId;
|
||||
result.icon = "";
|
||||
if (addIcon)//获取图标信息
|
||||
if (addIcon) //获取图标信息
|
||||
{
|
||||
result.icon = "";
|
||||
}
|
||||
result.lev = await attrService.GetUserLev(userId);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
27
Service/Application.Service.Pub/Extends/PageExtend.cs
Normal file
27
Service/Application.Service.Pub/Extends/PageExtend.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
namespace Application.Service.Pub;
|
||||
|
||||
public class PageExtend
|
||||
{
|
||||
/// <summary>
|
||||
/// List 通用分页
|
||||
/// </summary>
|
||||
/// <param name="list">数据源</param>
|
||||
/// <param name="pageIndex">当前页码(从1开始)</param>
|
||||
/// <param name="pageSize">每页条数</param>
|
||||
/// <returns>当前页数据</returns>
|
||||
public static List<T> GetPageList<T>(List<T> list, int pageIndex, int pageSize)
|
||||
{
|
||||
// 空值保护
|
||||
if (list == null || list.Count == 0)
|
||||
return new List<T>();
|
||||
|
||||
// 页码最小为 1
|
||||
pageIndex = pageIndex < 1 ? 1 : pageIndex;
|
||||
|
||||
// 分页核心
|
||||
return list
|
||||
.Skip((pageIndex - 1) * pageSize)
|
||||
.Take(pageSize)
|
||||
.ToList();
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,8 @@ public class ChatController : ControllerBase
|
||||
{
|
||||
private readonly IGameChatService _chatService;
|
||||
private readonly IGameGoodsService _goodsService;
|
||||
public ChatController(IGameChatService chatService,IGameGoodsService goodsService)
|
||||
|
||||
public ChatController(IGameChatService chatService, IGameGoodsService goodsService)
|
||||
{
|
||||
_chatService = chatService;
|
||||
_goodsService = goodsService;
|
||||
@@ -32,28 +33,28 @@ public class ChatController : ControllerBase
|
||||
string teamId = "";
|
||||
string groupId = "";
|
||||
RefAsync<int> Total = 0;
|
||||
var data = await _chatService.GetChatData(type, areaId, teamId, groupId, page, 10, Total);
|
||||
//物品数量
|
||||
int sendGoodsCount = 0;
|
||||
string sendGoodsName = "";
|
||||
switch (type)
|
||||
{
|
||||
case 0:
|
||||
sendGoodsCount = await _goodsService.GetUserGoodsCount(userId,GameConfig.SendChatGoodsBase);
|
||||
sendGoodsName = "小海螺";
|
||||
var data = await _chatService.GetChatData(userId, type, areaId, teamId, groupId, page, 10, Total);
|
||||
//物品数量
|
||||
int sendGoodsCount = 0;
|
||||
string sendGoodsName = "";
|
||||
switch (type)
|
||||
{
|
||||
case 0:
|
||||
sendGoodsCount = await _goodsService.GetUserGoodsCount(userId, GameConfig.SendChatGoodsBase);
|
||||
sendGoodsName = "小海螺";
|
||||
break;
|
||||
case 3:
|
||||
sendGoodsCount = await _goodsService.GetUserGoodsCount(userId,GameConfig.SendChatGoodsArea);
|
||||
sendGoodsName = "大海螺";
|
||||
break;
|
||||
case 4:
|
||||
sendGoodsCount = await _goodsService.GetUserGoodsCount(userId,GameConfig.SendChatGoodsService);
|
||||
sendGoodsName = "金海螺";
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
return PoAction.Ok(new { data, total = Total.Value ,sendGoodsCount,sendGoodsName});
|
||||
case 3:
|
||||
sendGoodsCount = await _goodsService.GetUserGoodsCount(userId, GameConfig.SendChatGoodsArea);
|
||||
sendGoodsName = "大海螺";
|
||||
break;
|
||||
case 4:
|
||||
sendGoodsCount = await _goodsService.GetUserGoodsCount(userId, GameConfig.SendChatGoodsService);
|
||||
sendGoodsName = "金海螺";
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
return PoAction.Ok(new { data, total = Total.Value, sendGoodsCount, sendGoodsName });
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -79,7 +80,7 @@ public class ChatController : ControllerBase
|
||||
{
|
||||
case 0:
|
||||
isSend = true;
|
||||
code =nameof(GameChatEnum.Code.Public);
|
||||
code = nameof(GameChatEnum.Code.Public);
|
||||
goodsId = GameConfig.SendChatGoodsBase;
|
||||
break;
|
||||
case 1:
|
||||
@@ -90,7 +91,7 @@ public class ChatController : ControllerBase
|
||||
case 2:
|
||||
isSend = true;
|
||||
code = nameof(GameChatEnum.Code.Group);
|
||||
par="";
|
||||
par = "";
|
||||
break;
|
||||
case 3:
|
||||
isSend = true;
|
||||
@@ -102,8 +103,8 @@ public class ChatController : ControllerBase
|
||||
goodsId = GameConfig.SendChatGoodsService;
|
||||
code = nameof(GameChatEnum.Code.Dress);
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
if (isSend == false)
|
||||
{
|
||||
return PoAction.Message("无法发言!");
|
||||
@@ -119,19 +120,19 @@ public class ChatController : ControllerBase
|
||||
}
|
||||
|
||||
string sign = StringAssist.NoHTML(pars.sign);
|
||||
bool result = await _chatService.SendChat(userId, areaId, code, sign, par);
|
||||
if (result)
|
||||
{
|
||||
if (goodsId != 0)//扣除道具
|
||||
{
|
||||
await _goodsService.UpdateUserGoods(userId, 0, goodsId, 1, "发言");
|
||||
}
|
||||
bool result = await _chatService.SendChat(userId, areaId, code, sign, par);
|
||||
if (result)
|
||||
{
|
||||
if (goodsId != 0) //扣除道具
|
||||
{
|
||||
await _goodsService.UpdateUserGoods(userId, 0, goodsId, 1, "发言");
|
||||
}
|
||||
|
||||
return PoAction.Ok(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
return PoAction.Message("发送失败,请稍后尝试!");
|
||||
}
|
||||
return PoAction.Ok(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
return PoAction.Message("发送失败,请稍后尝试!");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -18,7 +18,7 @@ public class MapController : ControllerBase
|
||||
private readonly IMessageService _messageService;
|
||||
|
||||
public MapController(IUnitUserService userService, IGameMapService mapService, IGameChatService chatService,
|
||||
IUnitUserAttrService attrService,IMessageService messageService)
|
||||
IUnitUserAttrService attrService, IMessageService messageService)
|
||||
{
|
||||
_userService = userService;
|
||||
_mapService = mapService;
|
||||
@@ -69,7 +69,7 @@ public class MapController : ControllerBase
|
||||
//公聊信息
|
||||
string teamId = "";
|
||||
string groupId = "";
|
||||
var chatData = await _chatService.GetChatTop(area, 2, teamId, groupId);
|
||||
var chatData = await _chatService.GetChatTop(userId, area, 2, teamId, groupId);
|
||||
|
||||
|
||||
var npcData = await _mapService.GetMapNpc(mapInfo.mapId); //NPC信息
|
||||
@@ -81,7 +81,8 @@ public class MapController : ControllerBase
|
||||
var cityInfo = await _mapService.GetCityInfo((int)mapInfo.cityId); //城市信息
|
||||
var cityShow = await _mapService.GetCityShowMap(cityInfo.cityId); //城内地图
|
||||
|
||||
int noReadMsg = await _messageService.GetNoReadCount(userId);
|
||||
var noReadMsg = await _messageService.GetNoReadCount(userId);
|
||||
|
||||
#region 更新在线
|
||||
|
||||
string ip = ComHelper.GetClientUserIp(HttpContext);
|
||||
@@ -89,7 +90,7 @@ public class MapController : ControllerBase
|
||||
|
||||
#endregion
|
||||
|
||||
object ret = new { mapInfo, cityInfo, npcData, chatData, cityShow, nearUser,noReadMsg };
|
||||
object ret = new { mapInfo, cityInfo, npcData, chatData, cityShow, nearUser, noReadMsg = noReadMsg[3] };
|
||||
|
||||
return PoAction.Ok(ret);
|
||||
}
|
||||
@@ -166,7 +167,7 @@ public class MapController : ControllerBase
|
||||
}
|
||||
}
|
||||
|
||||
#region npc相关
|
||||
#region npc相关
|
||||
|
||||
/// <summary>
|
||||
/// 获取NPC相关信息
|
||||
@@ -197,6 +198,5 @@ public class MapController : ControllerBase
|
||||
return PoAction.Ok(data);
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System.Reflection;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Application.Web.Controllers.Pub;
|
||||
|
||||
@@ -30,19 +31,30 @@ public class MessageController : ControllerBase
|
||||
{
|
||||
string userId = StateHelper.userId;
|
||||
RefAsync<int> total = 0;
|
||||
List<int> msgCount = await _messageService.GetNoReadCount(userId);
|
||||
if (type == 0)
|
||||
{
|
||||
var data = await _messageService.GetUserMessage(userId, 0, page, 10, total);
|
||||
return PoAction.Ok(new { data, total = total.Value });
|
||||
return PoAction.Ok(new { data, total = total.Value, msgCount });
|
||||
}
|
||||
else if (type == 1)
|
||||
{
|
||||
var data = await _messageService.GetUserMessage(userId, 1, page, 10, total);
|
||||
return PoAction.Ok(new { data, total = total.Value });
|
||||
return PoAction.Ok(new { data, total = total.Value, msgCount });
|
||||
}
|
||||
else if (type == 2)
|
||||
{
|
||||
var data = await _messageService.GetUserEventMessage(userId, page, 10, total);
|
||||
return PoAction.Ok(new { data, total = total.Value, msgCount });
|
||||
}
|
||||
else if (type == 3)
|
||||
{
|
||||
var data = await _messageService.GetUserMailData(userId, page, 10, total);
|
||||
return PoAction.Ok(new { data, total = total.Value, msgCount });
|
||||
}
|
||||
else
|
||||
{
|
||||
return PoAction.Ok(new { data = new List<string>(), total = total.Value });
|
||||
return PoAction.Ok(new { data = new List<string>(), total = total.Value, msgCount });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -193,4 +205,134 @@ public class MessageController : ControllerBase
|
||||
return PoAction.Message("删除失败,请稍后尝试!");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取邮件详情
|
||||
/// </summary>
|
||||
/// <param name="no"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<IPoAction> GetMailInfo(string no)
|
||||
{
|
||||
string userId = StateHelper.userId;
|
||||
var data = await _messageService.GetMailInfo(no);
|
||||
if (data == null)
|
||||
{
|
||||
return PoAction.Message("邮件不存在!");
|
||||
}
|
||||
|
||||
if (data.userId != userId)
|
||||
{
|
||||
return PoAction.Message("邮件不存在!");
|
||||
}
|
||||
|
||||
if (data.endTime < TimeExtend.GetTimeStampSeconds)
|
||||
{
|
||||
return PoAction.Message("邮件已过期!");
|
||||
}
|
||||
|
||||
if (data.isRead == 0)
|
||||
{
|
||||
data.isRead = 1;
|
||||
await _messageService.UpdateMaillInfo(data);
|
||||
}
|
||||
|
||||
return PoAction.Ok(data);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 领取附件
|
||||
/// </summary>
|
||||
/// <param name="no"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<IPoAction> GetAward(string no)
|
||||
{
|
||||
string userId = StateHelper.userId;
|
||||
var data = await _messageService.GetMailInfo(no);
|
||||
if (data == null)
|
||||
{
|
||||
return PoAction.Message("邮件不存在!");
|
||||
}
|
||||
|
||||
if (data.userId != userId)
|
||||
{
|
||||
return PoAction.Message("邮件不存在!");
|
||||
}
|
||||
|
||||
if (data.endTime < TimeExtend.GetTimeStampSeconds)
|
||||
{
|
||||
return PoAction.Message("邮件已过期!");
|
||||
}
|
||||
|
||||
if (data.isGet == 1)
|
||||
{
|
||||
return PoAction.Message("邮件附件已领取!");
|
||||
}
|
||||
|
||||
data.isGet = 1;
|
||||
data.isRead = 1;
|
||||
if (await _messageService.UpdateMaillInfo(data))
|
||||
{
|
||||
await GameBus.UpdateBag(userId, 1, data.award, $"邮件领取:{data.name}");
|
||||
return PoAction.Ok(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
return PoAction.Message("领取失败,请稍后尝试!");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 处理事件消息
|
||||
/// </summary>
|
||||
/// <param name="eventId"></param>
|
||||
/// <param name="state"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<IPoAction> EventHandle(string eventId, int state)
|
||||
{
|
||||
string userId = StateHelper.userId;
|
||||
var eventInfo = await _messageService.GetEventMessageInfo(eventId);
|
||||
if (eventInfo == null)
|
||||
{
|
||||
return PoAction.Message("通知消息不存在!");
|
||||
}
|
||||
|
||||
if (eventInfo.userId != userId)
|
||||
{
|
||||
return PoAction.Message("通知消息不存在!");
|
||||
}
|
||||
|
||||
if (eventInfo.state != 0)
|
||||
{
|
||||
return PoAction.Message("消息已处理!");
|
||||
}
|
||||
|
||||
if (eventInfo.btns.All(it => it.status != state))
|
||||
{
|
||||
return PoAction.Message("无法进行当前处理,请重试!");
|
||||
}
|
||||
|
||||
eventInfo.state = state;
|
||||
if (await _messageService.UpdateEventData(eventInfo))
|
||||
{
|
||||
MessageHandle handle = new MessageHandle();
|
||||
var result = await handle.HandleMsg(eventInfo, state);
|
||||
if (result.success)
|
||||
{
|
||||
return PoAction.Ok(true, result.msg);
|
||||
}
|
||||
else
|
||||
{
|
||||
eventInfo.state = 0;
|
||||
await _messageService.UpdateEventData(eventInfo);
|
||||
return PoAction.Message(result.msg);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return PoAction.Message("处理失败,请稍后尝试!");
|
||||
}
|
||||
}
|
||||
}
|
||||
117
Service/Application.Web/Controllers/User/RelationController.cs
Normal file
117
Service/Application.Web/Controllers/User/RelationController.cs
Normal file
@@ -0,0 +1,117 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Application.Web.Controllers.User;
|
||||
|
||||
/// <summary>
|
||||
/// 关系接口
|
||||
/// </summary>
|
||||
[ApiExplorerSettings(GroupName = "User")]
|
||||
[Route("User/[controller]/[action]")]
|
||||
[ApiController]
|
||||
[Authorize]
|
||||
public class RelationController : ControllerBase
|
||||
{
|
||||
private readonly IUnitUserRelationService _relationService;
|
||||
private readonly IUnitUserService _userService;
|
||||
private readonly IMessageService _messageService;
|
||||
|
||||
public RelationController(IUnitUserRelationService relationService, IUnitUserService userService,
|
||||
IMessageService messageService)
|
||||
{
|
||||
_relationService = relationService;
|
||||
_userService = userService;
|
||||
_messageService = messageService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 关系列表数据
|
||||
/// </summary>
|
||||
/// <param name="type"></param>
|
||||
/// <param name="page"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<IPoAction> GetRelation(int type, int page)
|
||||
{
|
||||
string userId = StateHelper.userId;
|
||||
RefAsync<int> total = 0;
|
||||
List<RelationView> result = new List<RelationView>();
|
||||
if (type == 0)
|
||||
{
|
||||
var data = await _relationService.GetUserFriend(userId);
|
||||
total = data.Count;
|
||||
data = data.OrderByDescending(it => it.isOnline).ThenByDescending(it => it.sort).ToList();
|
||||
result = PageExtend.GetPageList(data, page, 10);
|
||||
}
|
||||
else if (type == 1)
|
||||
{
|
||||
var data = await _relationService.GetUserFriend(userId);
|
||||
data = data.FindAll(it => it.near >= 1000);
|
||||
total = data.Count;
|
||||
data = data.OrderByDescending(it => it.isOnline).ThenByDescending(it => it.near)
|
||||
.ThenByDescending(it => it.sort).ToList();
|
||||
result = PageExtend.GetPageList(data, page, 10);
|
||||
}
|
||||
|
||||
return PoAction.Ok(new { data = result, total = total.Value, online = result.Count(it => it.isOnline == 1) });
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public async Task<IPoAction> FriendHandle(string no)
|
||||
{
|
||||
string userId = StateHelper.userId;
|
||||
var userInfo = await _userService.GetUserInfoByUserNo(no); //基础资料
|
||||
if (userInfo == null)
|
||||
{
|
||||
return PoAction.Message("玩家不存在!");
|
||||
}
|
||||
|
||||
if (userInfo.userId == userId)
|
||||
{
|
||||
return PoAction.Message("不能加自己为好友!");
|
||||
}
|
||||
|
||||
if (userInfo.areaId != StateHelper.areaId)
|
||||
{
|
||||
return PoAction.Message("玩家不存在!");
|
||||
}
|
||||
|
||||
bool IsFriend = await _relationService.CheckIsFriend(userId, userInfo.userId);
|
||||
if (IsFriend == false)
|
||||
{
|
||||
string token = $"{nameof(MessageEnum.EventCode.Friend)}_{userId}_{userInfo.userId}";
|
||||
if (await _messageService.CheckAtEventMsg(token))
|
||||
{
|
||||
return PoAction.Message("已发送过交友消息,等待对方通过!");
|
||||
}
|
||||
|
||||
var myInfo = await _userService.GetUserInfoByUserId(userId);
|
||||
string sign = $"{UbbTool.HomeUbb(myInfo.userNo, myInfo.nick)} 希望添加您为好友?";
|
||||
List<MsgEventBtn> btns = new List<MsgEventBtn>()
|
||||
{
|
||||
new MsgEventBtn() { status = 1, name = "通过", tips = "已通过申请" },
|
||||
new MsgEventBtn() { status = 2, name = "拒绝", tips = "已拒绝申请" }
|
||||
};
|
||||
if (await _messageService.SendEventMsg(userInfo.userId, nameof(MessageEnum.EventCode.Friend), "交友消息通知",
|
||||
sign, userId, token, btns, 3))
|
||||
{
|
||||
return PoAction.Ok(true, "好友申请已发送,请等待对方确认!");
|
||||
}
|
||||
else
|
||||
{
|
||||
return PoAction.Message("添加失败,请稍后尝试!");
|
||||
}
|
||||
}
|
||||
else //删除好友
|
||||
{
|
||||
bool result = await _relationService.DeleteFriend(userId, userInfo.userId);
|
||||
if (result)
|
||||
{
|
||||
return PoAction.Ok(true, "删除好友成功!");
|
||||
}
|
||||
else
|
||||
{
|
||||
return PoAction.Message("删除失败,请稍后尝试.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -12,16 +12,19 @@ public class UserController : ControllerBase
|
||||
private readonly IUnitUserAttrService _attrService;
|
||||
private readonly IUnitUserAccService _accService;
|
||||
private readonly IGameMapService _mapService;
|
||||
private readonly IUnitUserRelationService _relationService;
|
||||
|
||||
public UserController(IUnitUserService userService, IUnitUserAttrService attrService,
|
||||
IUnitUserAccService accService, IGameMapService mapService)
|
||||
IUnitUserAccService accService, IGameMapService mapService,IUnitUserRelationService relationService)
|
||||
{
|
||||
_userService = userService;
|
||||
_attrService = attrService;
|
||||
_accService = accService;
|
||||
_mapService = mapService;
|
||||
_relationService = relationService;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取个人资料信息
|
||||
@@ -44,6 +47,33 @@ public class UserController : ControllerBase
|
||||
return PoAction.Ok(result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取基础资料信息
|
||||
/// </summary>
|
||||
/// <param name="no"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<IPoAction> GetUserBaseInfo(string no)
|
||||
{
|
||||
string userId = StateHelper.userId;
|
||||
var userInfo = await _userService.GetUserInfoByUserNo(no); //基础资料
|
||||
if (userInfo == null)
|
||||
{
|
||||
return PoAction.Message("玩家不存在!", 102);
|
||||
}
|
||||
|
||||
if (userInfo.userId == userId)
|
||||
{
|
||||
return PoAction.Message("用户本身!", 101);
|
||||
}
|
||||
if (userInfo.areaId != StateHelper.areaId)
|
||||
{
|
||||
return PoAction.Message("玩家不存在!", 102);
|
||||
}
|
||||
|
||||
var model = await UserModelTool.GetUserView(userInfo.userId);
|
||||
return PoAction.Ok(model);
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取用户资料
|
||||
/// </summary>
|
||||
@@ -81,8 +111,8 @@ public class UserController : ControllerBase
|
||||
var onMapInfo = await _mapService.GetMapInfo(online.mapId);
|
||||
var onCity = await _mapService.GetCityInfo((int)onMapInfo.cityId);
|
||||
string onMapName = $"{onCity.cityName}-{onMapInfo.mapName}";
|
||||
|
||||
object result = new { user, attr = new { attrInfo.lev }, acc, isOnline, onMapName };
|
||||
bool isFriend = await _relationService.CheckIsFriend(userId, userInfo.userId);
|
||||
object result = new { user, attr = new { attrInfo.lev }, acc, isOnline, onMapName ,isFriend};
|
||||
return PoAction.Ok(result);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user