1111
This commit is contained in:
@@ -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