From 69ae1e31741a40fa24f78e1a78ca37a7b67660b9 Mon Sep 17 00:00:00 2001 From: Putoo <290555932@qq.com> Date: Thu, 28 May 2026 19:06:40 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Kx.SeaTime.sln.DotSettings.user | 2 + .../game/user/unit_user_message.cs | 63 +++ .../log/db/game_mall_log.cs | 69 +++ .../user => log/db}/unit_user_acc_log.cs | 2 +- .../user => log/db}/unit_user_weight_log.cs | 2 +- .../resource/game/game_mall.cs | 69 +++ .../view/MessageView.cs | 7 + .../Interface/Pub/IGameMallService.cs | 8 + .../Services/Interface/Pub/IMessageService.cs | 22 + .../Services/Service/Pub/GameMallService.cs | 40 ++ .../Services/Service/Pub/MessageService.cs | 166 ++++++ .../Service/User/UnitUserAccService.cs | 9 +- .../Application.Domain/Tool/Base/GameTool.cs | 4 +- .../Tool/ModelTool/UserModelTool.cs | 31 +- .../Controllers/Map/MapController.cs | 7 +- .../Controllers/Pub/MallController.cs | 86 +++ .../Controllers/Pub/MessageController.cs | 196 +++++++ .../Controllers/User/UserController.cs | 4 + .../Model/RequestParms/Mall/MallBuyParms.cs | 7 + .../RequestParms/Message/SendMsgParms.cs | 7 + Web/nuxt.config.ts | 2 +- Web/public/css/images/home/bar.gif | Bin 0 -> 473 bytes Web/public/css/images/home/btn_b_gold.gif | Bin 0 -> 346 bytes Web/public/css/images/home/btn_l_gray.gif | Bin 0 -> 380 bytes Web/public/css/images/home/btn_m_gray.gif | Bin 0 -> 344 bytes Web/public/css/images/home/btn_s_gray.gif | Bin 0 -> 307 bytes Web/public/css/images/home/unit/bao.jpg | Bin 0 -> 3093 bytes Web/src/assets/css/home.css | 508 ++++++++++++++++++ Web/src/assets/css/style.css | 4 +- Web/src/composables/LocalStorageHelper.ts | 3 +- Web/src/layouts/default.vue | 3 +- Web/src/pages/mall/index.vue | 116 +++- Web/src/pages/map/index.vue | 8 +- Web/src/pages/message/index.vue | 88 ++- Web/src/pages/message/log.vue | 60 +++ Web/src/pages/message/read.vue | 114 ++++ Web/src/pages/user/user.vue | 4 +- Web/src/services/Index/MallService.ts | 19 + Web/src/services/Index/MessageService.ts | 43 ++ 39 files changed, 1742 insertions(+), 31 deletions(-) create mode 100644 Service/Application.Domain.Entity/game/user/unit_user_message.cs create mode 100644 Service/Application.Domain.Entity/log/db/game_mall_log.cs rename Service/Application.Domain.Entity/{game/user => log/db}/unit_user_acc_log.cs (97%) rename Service/Application.Domain.Entity/{game/user => log/db}/unit_user_weight_log.cs (97%) create mode 100644 Service/Application.Domain.Entity/resource/game/game_mall.cs create mode 100644 Service/Application.Domain.Entity/view/MessageView.cs create mode 100644 Service/Application.Domain/Services/Interface/Pub/IGameMallService.cs create mode 100644 Service/Application.Domain/Services/Interface/Pub/IMessageService.cs create mode 100644 Service/Application.Domain/Services/Service/Pub/GameMallService.cs create mode 100644 Service/Application.Domain/Services/Service/Pub/MessageService.cs create mode 100644 Service/Application.Web/Controllers/Pub/MallController.cs create mode 100644 Service/Application.Web/Controllers/Pub/MessageController.cs create mode 100644 Service/Application.Web/Model/RequestParms/Mall/MallBuyParms.cs create mode 100644 Service/Application.Web/Model/RequestParms/Message/SendMsgParms.cs create mode 100644 Web/public/css/images/home/bar.gif create mode 100644 Web/public/css/images/home/btn_b_gold.gif create mode 100644 Web/public/css/images/home/btn_l_gray.gif create mode 100644 Web/public/css/images/home/btn_m_gray.gif create mode 100644 Web/public/css/images/home/btn_s_gray.gif create mode 100644 Web/public/css/images/home/unit/bao.jpg create mode 100644 Web/src/assets/css/home.css create mode 100644 Web/src/pages/message/log.vue create mode 100644 Web/src/pages/message/read.vue create mode 100644 Web/src/services/Index/MallService.ts create mode 100644 Web/src/services/Index/MessageService.ts diff --git a/Kx.SeaTime.sln.DotSettings.user b/Kx.SeaTime.sln.DotSettings.user index 9879620..d9b405e 100644 --- a/Kx.SeaTime.sln.DotSettings.user +++ b/Kx.SeaTime.sln.DotSettings.user @@ -4,7 +4,9 @@ ForceIncluded ForceIncluded ForceIncluded + ForceIncluded ForceIncluded + ForceIncluded ForceIncluded ForceIncluded ForceIncluded \ No newline at end of file diff --git a/Service/Application.Domain.Entity/game/user/unit_user_message.cs b/Service/Application.Domain.Entity/game/user/unit_user_message.cs new file mode 100644 index 0000000..6b49b2a --- /dev/null +++ b/Service/Application.Domain.Entity/game/user/unit_user_message.cs @@ -0,0 +1,63 @@ +using SqlSugar; +using System; + +namespace Application.Domain.Entity +{ + [Tenant("Kg.SeaTime.Game")] + public class unit_user_message + { + /// + /// msgId + /// + [SugarColumn(IsPrimaryKey = true)] + public long msgId { get; set; } + + /// + /// userId + /// + [SugarColumn(Length = 50, IsNullable = true)] + public string? userId { get; set; } + + /// + /// sendId + /// + [SugarColumn(Length = 50, IsNullable = true)] + public string? sendId { get; set; } + + /// + /// sign + /// + [SugarColumn(IsNullable = true)] + public string? sign { get; set; } + + /// + /// isRead + /// + [SugarColumn(IsNullable = true)] + public int? isRead { get; set; } + + /// + /// status + /// + [SugarColumn(IsNullable = true)] + public int? status { get; set; } + + /// + /// addTime + /// + [SugarColumn(IsNullable = true)] + public DateTime? addTime { get; set; } + + /// + /// endTime + /// + [SugarColumn(IsNullable = true)] + public long? endTime { get; set; } + + /// + /// 会话ID + /// + [SugarColumn(Length = 100, IsNullable = true)] + public string? talkId { get; set; } + } +} \ No newline at end of file diff --git a/Service/Application.Domain.Entity/log/db/game_mall_log.cs b/Service/Application.Domain.Entity/log/db/game_mall_log.cs new file mode 100644 index 0000000..374724f --- /dev/null +++ b/Service/Application.Domain.Entity/log/db/game_mall_log.cs @@ -0,0 +1,69 @@ +using SqlSugar; +using System; + +namespace Application.Domain.Entity +{ + [Tenant("Kg.SeaTime.Log")] + public class game_mall_log + { + /// + /// logId + /// + [SugarColumn(IsPrimaryKey = true, Length = 50)] + public string logId { get; set; } + + /// + /// mallId + /// + [SugarColumn(Length = 50, IsNullable = true)] + public string? mallId { get; set; } + + /// + /// type + /// + [SugarColumn(Length = 50, IsNullable = true)] + public string? type { get; set; } + + /// + /// pars + /// + [SugarColumn(Length = 50, IsNullable = true)] + public Int32? pars { get; set; } + + /// + /// count + /// + [SugarColumn(IsNullable = true)] + public int? count { get; set; } + + /// + /// price + /// + [SugarColumn(IsNullable = true)] + public long? price { get; set; } + + /// + /// payType + /// + [SugarColumn(Length = 50, IsNullable = true)] + public string? payType { get; set; } + + /// + /// userId + /// + [SugarColumn(Length = 50, IsNullable = true)] + public string? userId { get; set; } + + /// + /// addTime + /// + [SugarColumn(IsNullable = true)] + public DateTime? addTime { get; set; } + + /// + /// endTime + /// + [SugarColumn(IsNullable = true)] + public DateTime? endTime { get; set; } + } +} \ No newline at end of file diff --git a/Service/Application.Domain.Entity/game/user/unit_user_acc_log.cs b/Service/Application.Domain.Entity/log/db/unit_user_acc_log.cs similarity index 97% rename from Service/Application.Domain.Entity/game/user/unit_user_acc_log.cs rename to Service/Application.Domain.Entity/log/db/unit_user_acc_log.cs index 48124dc..df2c098 100644 --- a/Service/Application.Domain.Entity/game/user/unit_user_acc_log.cs +++ b/Service/Application.Domain.Entity/log/db/unit_user_acc_log.cs @@ -3,7 +3,7 @@ using System; namespace Application.Domain.Entity { - [Tenant("Kg.SeaTime.Game")] + [Tenant("Kg.SeaTime.Log")] public class unit_user_acc_log { /// diff --git a/Service/Application.Domain.Entity/game/user/unit_user_weight_log.cs b/Service/Application.Domain.Entity/log/db/unit_user_weight_log.cs similarity index 97% rename from Service/Application.Domain.Entity/game/user/unit_user_weight_log.cs rename to Service/Application.Domain.Entity/log/db/unit_user_weight_log.cs index c2544a2..697aaba 100644 --- a/Service/Application.Domain.Entity/game/user/unit_user_weight_log.cs +++ b/Service/Application.Domain.Entity/log/db/unit_user_weight_log.cs @@ -3,7 +3,7 @@ using System; namespace Application.Domain.Entity { - [Tenant("Kg.SeaTime.Game")] + [Tenant("Kg.SeaTime.Log")] public class unit_user_weight_log { /// diff --git a/Service/Application.Domain.Entity/resource/game/game_mall.cs b/Service/Application.Domain.Entity/resource/game/game_mall.cs new file mode 100644 index 0000000..b9094f9 --- /dev/null +++ b/Service/Application.Domain.Entity/resource/game/game_mall.cs @@ -0,0 +1,69 @@ +using SqlSugar; +using System; + +namespace Application.Domain.Entity +{ + [Tenant("Kg.SeaTime.Resource")] + public class game_mall + { + /// + /// mallId + /// + [SugarColumn(IsPrimaryKey = true, Length = 50)] + public string mallId { get; set; } + + /// + /// areaId + /// + [SugarColumn(Length = 50, IsNullable = true)] + public string? areaId { get; set; } + + /// + /// name + /// + [SugarColumn(Length = 50, IsNullable = true)] + public string? name { get; set; } + + /// + /// type + /// + [SugarColumn(Length = 50, IsNullable = true)] + public string? type { get; set; } + + /// + /// goodsId + /// + [SugarColumn(IsNullable = true)] + public int? goodsId { get; set; } + + /// + /// price + /// + [SugarColumn(IsNullable = true)] + public long? price { get; set; } + + /// + /// payType + /// + [SugarColumn(Length = 50, IsNullable = true)] + public string? payType { get; set; } + + /// + /// sort + /// + [SugarColumn(IsNullable = true)] + public int? sort { get; set; } + + /// + /// addTime + /// + [SugarColumn(IsNullable = true)] + public DateTime? addTime { get; set; } + + /// + /// endTime + /// + [SugarColumn(IsNullable = true)] + public DateTime? endTime { get; set; } + } +} \ No newline at end of file diff --git a/Service/Application.Domain.Entity/view/MessageView.cs b/Service/Application.Domain.Entity/view/MessageView.cs new file mode 100644 index 0000000..1a5e19f --- /dev/null +++ b/Service/Application.Domain.Entity/view/MessageView.cs @@ -0,0 +1,7 @@ +namespace Application.Domain.Entity; + +public class MessageView +{ + public string sign { get; set; } + public UserModel user { get; set;} +} \ No newline at end of file diff --git a/Service/Application.Domain/Services/Interface/Pub/IGameMallService.cs b/Service/Application.Domain/Services/Interface/Pub/IGameMallService.cs new file mode 100644 index 0000000..bd6f8f3 --- /dev/null +++ b/Service/Application.Domain/Services/Interface/Pub/IGameMallService.cs @@ -0,0 +1,8 @@ +namespace Application.Domain; + +public interface IGameMallService +{ + Task> GetMallData(int area, string type, int page, int limit, RefAsync total); + Task GetMallInfo(string mallId); + Task AddLog(game_mall mall, string userId, int count); +} \ No newline at end of file diff --git a/Service/Application.Domain/Services/Interface/Pub/IMessageService.cs b/Service/Application.Domain/Services/Interface/Pub/IMessageService.cs new file mode 100644 index 0000000..0d99597 --- /dev/null +++ b/Service/Application.Domain/Services/Interface/Pub/IMessageService.cs @@ -0,0 +1,22 @@ +namespace Application.Domain; + +public interface IMessageService +{ + Task GetNoReadCount(string userId); + + #region 私聊消息 + + string GetTalkId(string userId, string otId); + Task> GetUserNoReadData(string talkId); + + Task> GetUserMessageData(string talkId, int page, int limit, + RefAsync total); + Task> GetUserMessage(string userId, int type, int page, int limit, + RefAsync total); + + Task SendMsg(string sendId, string toUser, string msg); + Task SetMsgRead(List msgIds, string userId); + Task DeleteMsgByTalkId(string talkId, string userId); + + #endregion +} \ No newline at end of file diff --git a/Service/Application.Domain/Services/Service/Pub/GameMallService.cs b/Service/Application.Domain/Services/Service/Pub/GameMallService.cs new file mode 100644 index 0000000..328d6a1 --- /dev/null +++ b/Service/Application.Domain/Services/Service/Pub/GameMallService.cs @@ -0,0 +1,40 @@ +namespace Application.Domain; + +public class GameMallService(ISqlSugarClient DbClient, IRedisCache redis) : IGameMallService, ITransient +{ + public async Task> GetMallData(int area, string type, int page, int limit, RefAsync total) + { + DateTime onTime = DateTime.Now; + string _area = area.ToString(); + var db = DbClient.AsTenant().GetConnectionWithAttr(); + return await db.Queryable().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 GetMallInfo(string mallId) + { + var db = DbClient.AsTenant().GetConnectionWithAttr(); + return await db.Queryable().Where(it => it.mallId == mallId).SingleAsync(); + } + + public async Task 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(); + return await db.Insertable(log).ExecuteCommandAsync() > 0; + } +} \ No newline at end of file diff --git a/Service/Application.Domain/Services/Service/Pub/MessageService.cs b/Service/Application.Domain/Services/Service/Pub/MessageService.cs new file mode 100644 index 0000000..b4ff8b1 --- /dev/null +++ b/Service/Application.Domain/Services/Service/Pub/MessageService.cs @@ -0,0 +1,166 @@ +namespace Application.Domain; + +public class MessageService(ISqlSugarClient DbClient, IRedisCache redis) : IMessageService, ITransient +{ + public async Task GetNoReadCount(string userId) + { + string key = string.Format(UserCache.BaseCacheKeys, "Message", "Count"); + if (await redis.HExistsHashAsync(key, userId)) + { + return await redis.GetHashAsync(key, userId); + } + + int result = 0; + //普通消息 + int noRead = await GetUserNoReadDataCountByUserId(userId); + result += noRead; + //邮件详细 + //通知消息 + await redis.AddHashAsync(key, userId, result); + return result; + } + + private async Task ClearMessageCache(string userId) + { + string key = string.Format(UserCache.BaseCacheKeys, "Message", "Count"); + await redis.DelHashAsync(key, userId); + } + + #region 私信消息 + + public string GetTalkId(string userId, string otId) + { + return $"{userId}_{otId}"; + } + + private List GetTalkIdToUserId(string talkId) + { + return talkId.Split('_').ToList(); + } + + private async Task GetUserNoReadDataCountByUserId(string userId) + { + var db = DbClient.AsTenant().GetConnectionScopeWithAttr(); + return await db.Queryable() + .Where(it => it.status == 1 && it.userId == userId && it.isRead == 0).CountAsync(); + } + + public async Task> GetUserNoReadData(string talkId) + { + var db = DbClient.AsTenant().GetConnectionScopeWithAttr(); + return await db.Queryable() + .Where(it => it.status == 1 && it.talkId == talkId && it.isRead == 0) + .OrderByDescending(it => it.addTime).ToListAsync(); + } + + public async Task> GetUserMessageData(string talkId, int page, int limit, + RefAsync total) + { + var db = DbClient.AsTenant().GetConnectionScopeWithAttr(); + return await db.Queryable() + .Where(it => it.status == 1 && it.talkId == talkId) + .OrderByDescending(it => it.addTime) + .ToPageListAsync(page, limit, total); + } + + /// + /// 获取最新对话列表 + /// + /// + /// + /// + /// + /// + /// + public async Task> GetUserMessage(string userId, int type, int page, int limit, + RefAsync total) + { + var db = DbClient.AsTenant().GetConnectionScopeWithAttr(); + var talkData = await db.Queryable() + .GroupBy(it => new { it.talkId }) + .Where(it => it.userId == userId && it.status == 1) + .WhereIF(type == 0, it => it.isRead == 0) + .OrderByDescending(it => it.addTime) + .Select(it => new { mgsId = SqlFunc.AggregateMax(it.msgId) }) + .ToPageListAsync(page, limit, total); + + List result = new List(); + foreach (var item in talkData) + { + MessageView temp = new MessageView(); + var msgInfo = await db.Queryable().Where(it => it.msgId == item.mgsId).SingleAsync(); + temp.sign = msgInfo.sign; + var users = GetTalkIdToUserId(msgInfo.talkId); + temp.user = await UserModelTool.GetUserView(users[1]); + result.Add(temp); + } + + return result; + } + + public async Task SendMsg(string sendId, string toUser, string msg) + { + List adds = new List(); + unit_user_message message = new unit_user_message(); + message.msgId = SnowflakeAssist.NextId(); + message.userId = toUser; + message.sendId = sendId; + message.sign = msg; + message.isRead = 0; + message.status = 1; + message.addTime = DateTime.Now; + message.endTime = TimeExtend.GetTimeStampBySeconds(DateTime.Now.AddDays(90)); + message.talkId = GetTalkId(toUser, sendId); + adds.Add(message); + if (sendId != "0") + { + message = new unit_user_message(); + message.msgId = SnowflakeAssist.NextId(); + message.userId = sendId; + message.sendId = sendId; + message.sign = msg; + message.isRead = 1; + message.status = 1; + message.addTime = DateTime.Now; + message.endTime = TimeExtend.GetTimeStampBySeconds(DateTime.Now.AddDays(90)); + message.talkId = GetTalkId(sendId, toUser); + adds.Add(message); + } + + var db = DbClient.AsTenant().GetConnectionScopeWithAttr(); + bool result = await db.Insertable(adds).ExecuteCommandAsync() > 0; + if (result) + { + await ClearMessageCache(toUser); + } + + return result; + } + + public async Task SetMsgRead(List msgIds, string userId) + { + var db = DbClient.AsTenant().GetConnectionScopeWithAttr(); + bool result = await db.Updateable().SetColumns(it => it.isRead == 1) + .Where(it => msgIds.Contains(it.msgId)).ExecuteCommandAsync() > 0; + if (result) + { + await ClearMessageCache(userId); + } + } + + public async Task DeleteMsgByTalkId(string talkId, string userId) + { + var db = DbClient.AsTenant().GetConnectionScopeWithAttr(); + bool result = await db.Updateable().SetColumns(it => it.status == 0) + .Where(it => it.talkId == talkId && it.status == 1).ExecuteCommandAsync() > + 0; + if (result) + { + await ClearMessageCache(userId); + } + + return result; + } + + #endregion +} \ No newline at end of file diff --git a/Service/Application.Domain/Services/Service/User/UnitUserAccService.cs b/Service/Application.Domain/Services/Service/User/UnitUserAccService.cs index 5a2cac0..cd74126 100644 --- a/Service/Application.Domain/Services/Service/User/UnitUserAccService.cs +++ b/Service/Application.Domain/Services/Service/User/UnitUserAccService.cs @@ -70,9 +70,9 @@ public class UnitUserAccService(ISqlSugarClient DbClient, IRedisCache redis) : I userAccLog.name = name; userAccLog.amount = count; userAccLog.addTime = DateTime.Now; - userAccLog.endTime = DateTime.Now.AddDays(3); + userAccLog.endTime = DateTime.Now.AddDays(30); userAccLog.remark = remark; - await db.Insertable(userAccLog).ExecuteCommandAsync(); + await AddLog(userAccLog); } await DbClient.AsTenant().CommitTranAsync(); @@ -102,6 +102,11 @@ public class UnitUserAccService(ISqlSugarClient DbClient, IRedisCache redis) : I return result; } + private async Task AddLog(unit_user_acc_log log) + { + var db = DbClient.AsTenant().GetConnectionWithAttr(); + await db.Insertable(log).ExecuteCommandAsync(); + } public async Task GetUserCopperInfo(string userId) { diff --git a/Service/Application.Domain/Tool/Base/GameTool.cs b/Service/Application.Domain/Tool/Base/GameTool.cs index 7b486aa..4730921 100644 --- a/Service/Application.Domain/Tool/Base/GameTool.cs +++ b/Service/Application.Domain/Tool/Base/GameTool.cs @@ -34,8 +34,8 @@ public class GameTool public static bool AreaVerify(int area, string areas) { - List onArea = new List() { "0", area.ToString() }; - return onArea.Any(it => areas.Contains(it)); + List okArea = areas.Split(',').ToList(); + return okArea.Any(it => it == "0" || it == area.ToString()); } public static string GetCurrencyName(string payCode) diff --git a/Service/Application.Domain/Tool/ModelTool/UserModelTool.cs b/Service/Application.Domain/Tool/ModelTool/UserModelTool.cs index b96c197..c9188b0 100644 --- a/Service/Application.Domain/Tool/ModelTool/UserModelTool.cs +++ b/Service/Application.Domain/Tool/ModelTool/UserModelTool.cs @@ -11,22 +11,33 @@ public class UserModelTool public static async Task GetUserView(string userId,bool addIcon=false) { UserModel result = new UserModel(); - var userService = App.GetService(); - var userInfo = await userService.GetUserInfoByUserId(userId); - if (userInfo != null) + if (userId == "0") { - result.userNo = userInfo.userNo; - result.nick = userInfo.nick; - result.sex = userInfo.sex; - result.headImg = userInfo.headImg; - result.area = (int)userInfo.areaId; + result.userNo = "0"; + result.nick = "海精灵"; + result.sex = "女"; + result.headImg = ""; + result.area = 0; result.icon = ""; - if (addIcon)//获取图标信息 + } + else + { + var userService = App.GetService(); + var userInfo = await userService.GetUserInfoByUserId(userId); + if (userInfo != null) { + result.userNo = userInfo.userNo; + result.nick = userInfo.nick; + result.sex = userInfo.sex; + result.headImg = userInfo.headImg; + result.area = (int)userInfo.areaId; result.icon = ""; + if (addIcon)//获取图标信息 + { + result.icon = ""; + } } } - return result; } } \ No newline at end of file diff --git a/Service/Application.Web/Controllers/Map/MapController.cs b/Service/Application.Web/Controllers/Map/MapController.cs index 14359c4..f08690e 100644 --- a/Service/Application.Web/Controllers/Map/MapController.cs +++ b/Service/Application.Web/Controllers/Map/MapController.cs @@ -15,14 +15,16 @@ public class MapController : ControllerBase private readonly IGameMapService _mapService; private readonly IGameChatService _chatService; private readonly IUnitUserAttrService _attrService; + private readonly IMessageService _messageService; public MapController(IUnitUserService userService, IGameMapService mapService, IGameChatService chatService, - IUnitUserAttrService attrService) + IUnitUserAttrService attrService,IMessageService messageService) { _userService = userService; _mapService = mapService; _chatService = chatService; _attrService = attrService; + _messageService = messageService; } /// @@ -79,6 +81,7 @@ 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); #region 更新在线 string ip = ComHelper.GetClientUserIp(HttpContext); @@ -86,7 +89,7 @@ public class MapController : ControllerBase #endregion - object ret = new { mapInfo, cityInfo, npcData, chatData, cityShow, nearUser }; + object ret = new { mapInfo, cityInfo, npcData, chatData, cityShow, nearUser,noReadMsg }; return PoAction.Ok(ret); } diff --git a/Service/Application.Web/Controllers/Pub/MallController.cs b/Service/Application.Web/Controllers/Pub/MallController.cs new file mode 100644 index 0000000..b185ed3 --- /dev/null +++ b/Service/Application.Web/Controllers/Pub/MallController.cs @@ -0,0 +1,86 @@ +using Microsoft.AspNetCore.Mvc; + +namespace Application.Web.Controllers.Pub; + +/// +/// 商城接口 +/// +[Route("[controller]/[action]")] +[ApiController] +[Authorize] +public class MallController : ControllerBase +{ + private readonly IGameMallService _mallService; + private readonly IUnitUserAccService _accService; + + public MallController(IGameMallService mallService, IUnitUserAccService accService) + { + _mallService = mallService; + _accService = accService; + } + + /// + /// 获取商城列表 + /// + /// + /// + /// + [HttpGet] + public async Task GetMall(string type, int page) + { + int area = StateHelper.areaId; + string userId = StateHelper.userId; + var accInfo = await _accService.GetUserAccInfo(userId); + RefAsync total = 0; + var data = await _mallService.GetMallData(area, type, page, 10, total); + return PoAction.Ok(new { data, total = total.Value, accInfo.gold, accInfo.cowry }); + } + + /// + /// 购买物品 + /// + /// + /// + [HttpPost] + public async Task Buy([FromBody] MallBuyParms parms) + { + string userId = StateHelper.userId; + int area = StateHelper.areaId; + parms.count = parms.count < 1 ? 1 : parms.count; + var mallInfo = await _mallService.GetMallInfo(parms.id); + if (mallInfo == null) + { + return PoAction.Message("商品已下架!"); + } + + if (mallInfo.endTime < DateTime.Now) + { + return PoAction.Message("商品已下架!"); + } + + if (GameTool.AreaVerify(area, mallInfo.areaId) == false) + { + return PoAction.Message("商品已下架!"); + } + + var myAcc = await _accService.GetUserAccInfo(userId, mallInfo.payType); + long need = (long)mallInfo.price * parms.count; + if (myAcc < need) + { + return PoAction.Message($"您的{GameTool.GetCurrencyName(mallInfo.payType)}不足!"); + } + + if (await _accService.UpdateUserAcc(userId, 0, mallInfo.payType, need, nameof(AccEnum.Name.系统商城), "系统商店购买")) + { + if (await _mallService.AddLog(mallInfo, userId, parms.count)) + { + await GameBus.UpdateBag(userId, 1, mallInfo.type, mallInfo.goodsId.ToString(), parms.count, "系统商店购买"); + } + return PoAction.Ok(true); + } + else + { + return PoAction.Message("购买失败,请稍后尝试!"); + } + } +} \ No newline at end of file diff --git a/Service/Application.Web/Controllers/Pub/MessageController.cs b/Service/Application.Web/Controllers/Pub/MessageController.cs new file mode 100644 index 0000000..fa0afb3 --- /dev/null +++ b/Service/Application.Web/Controllers/Pub/MessageController.cs @@ -0,0 +1,196 @@ +using Microsoft.AspNetCore.Mvc; + +namespace Application.Web.Controllers.Pub; + +/// +/// 消息接口 +/// +[Route("[controller]/[action]")] +[ApiController] +[Authorize] +public class MessageController : ControllerBase +{ + private readonly IMessageService _messageService; + private readonly IUnitUserService _userService; + + public MessageController(IMessageService messageService, IUnitUserService userService) + { + _messageService = messageService; + _userService = userService; + } + + /// + /// 获取消息 + /// + /// + /// + /// + [HttpGet] + public async Task GetMessageData(int type, int page) + { + string userId = StateHelper.userId; + RefAsync total = 0; + if (type == 0) + { + var data = await _messageService.GetUserMessage(userId, 0, page, 10, total); + return PoAction.Ok(new { data, total = total.Value }); + } + else if (type == 1) + { + var data = await _messageService.GetUserMessage(userId, 1, page, 10, total); + return PoAction.Ok(new { data, total = total.Value }); + } + else + { + return PoAction.Ok(new { data = new List(), total = total.Value }); + } + } + + /// + /// 获取消息界面 + /// + /// + /// + [HttpGet] + public async Task GetReadInfo(int no) + { + string userId = StateHelper.userId; + UserModel user = new UserModel(); + string talkId = string.Empty; + if (no == 0) + { + user = await UserModelTool.GetUserView("0"); + talkId = _messageService.GetTalkId(userId, "0"); + } + else + { + var userInfo = await _userService.GetUserInfoByUserNo(no.ToString()); + if (userInfo == null) + { + return PoAction.Message("玩家不存在!"); + } + + talkId = _messageService.GetTalkId(userId, userInfo.userId); + user = await UserModelTool.GetUserView(userInfo.userId); + } + + + var noRead = await _messageService.GetUserNoReadData(talkId); //未读消息 + if (noRead.Count > 0) + { + List msgIds = noRead.Select(it => it.msgId).ToList(); + await _messageService.SetMsgRead(msgIds, userId); + } + + RefAsync total = 0; + var logs = await _messageService.GetUserMessageData(talkId, 1, 5, total); //消息记录 + return PoAction.Ok(new { user, data = noRead, logs }); + } + + /// + /// 发送消息 + /// + /// + /// + [HttpPost] + public async Task SendMsg([FromBody] SendMsgParms parms) + { + if (string.IsNullOrEmpty(parms.sign)) + { + return PoAction.Message("消息内容不能为空!"); + } + + string userId = StateHelper.userId; + int areaId = StateHelper.areaId; + + var toUser = await _userService.GetUserInfoByUserNo(parms.no.ToString()); + if (toUser == null) + { + return PoAction.Message("玩家不存在!", 100); + } + + if (toUser.areaId != areaId) + { + return PoAction.Message("暂不支持漫游消息!"); + } + + parms.sign = StringAssist.NoHTML(parms.sign); + if (await _messageService.SendMsg(userId, toUser.userId, parms.sign)) + { + return PoAction.Ok(true); + } + else + { + return PoAction.Message("发送失败,请稍后尝试"); + } + } + + /// + /// 聊天记录 + /// + /// + /// + /// + [HttpGet] + public async Task MessageLog(int no, int page) + { + string userId = StateHelper.userId; + UserModel user = new UserModel(); + string talkId = string.Empty; + if (no == 0) + { + user = await UserModelTool.GetUserView("0"); + talkId = _messageService.GetTalkId(userId, "0"); + } + else + { + var userInfo = await _userService.GetUserInfoByUserNo(no.ToString()); + if (userInfo == null) + { + return PoAction.Message("玩家不存在!"); + } + + talkId = _messageService.GetTalkId(userId, userInfo.userId); + user = await UserModelTool.GetUserView(userInfo.userId); + } + + RefAsync total = 0; + var logs = await _messageService.GetUserMessageData(talkId, page, 10, total); //消息记录 + return PoAction.Ok(new { user, data = logs, total = total.Value }); + } + + /// + /// 删除对话 + /// + /// + /// + [HttpGet] + public async Task DeleteMsg(int no) + { + string userId = StateHelper.userId; + string talkId = string.Empty; + if (no == 0) + { + talkId = _messageService.GetTalkId(userId, "0"); + } + else + { + var userInfo = await _userService.GetUserInfoByUserNo(no.ToString()); + if (userInfo == null) + { + return PoAction.Message("玩家不存在!"); + } + + talkId = _messageService.GetTalkId(userId, userInfo.userId); + } + + if (await _messageService.DeleteMsgByTalkId(talkId, userId)) + { + return PoAction.Ok(true); + } + else + { + return PoAction.Message("删除失败,请稍后尝试!"); + } + } +} \ No newline at end of file diff --git a/Service/Application.Web/Controllers/User/UserController.cs b/Service/Application.Web/Controllers/User/UserController.cs index b956143..a621d1b 100644 --- a/Service/Application.Web/Controllers/User/UserController.cs +++ b/Service/Application.Web/Controllers/User/UserController.cs @@ -63,6 +63,10 @@ public class UserController : ControllerBase { return PoAction.Message("用户本身!", 101); } + if (userInfo.areaId != StateHelper.areaId) + { + return PoAction.Message("玩家不存在!", 102); + } object user = new { userInfo.userNo, userInfo.nick, userInfo.sex, userInfo.sign }; var attrInfo = await _attrService.GetUserAttrModel(userInfo.userId); //基础属性 diff --git a/Service/Application.Web/Model/RequestParms/Mall/MallBuyParms.cs b/Service/Application.Web/Model/RequestParms/Mall/MallBuyParms.cs new file mode 100644 index 0000000..9280492 --- /dev/null +++ b/Service/Application.Web/Model/RequestParms/Mall/MallBuyParms.cs @@ -0,0 +1,7 @@ +namespace Application.Web; + +public class MallBuyParms +{ + public string id { get; set; } + public int count { get; set; } +} \ No newline at end of file diff --git a/Service/Application.Web/Model/RequestParms/Message/SendMsgParms.cs b/Service/Application.Web/Model/RequestParms/Message/SendMsgParms.cs new file mode 100644 index 0000000..d19040f --- /dev/null +++ b/Service/Application.Web/Model/RequestParms/Message/SendMsgParms.cs @@ -0,0 +1,7 @@ +namespace Application.Web; + +public class SendMsgParms +{ + public int no { get; set; } + public string sign { get; set; } +} \ No newline at end of file diff --git a/Web/nuxt.config.ts b/Web/nuxt.config.ts index c4c65c8..d35e6a9 100644 --- a/Web/nuxt.config.ts +++ b/Web/nuxt.config.ts @@ -58,7 +58,7 @@ export default defineNuxtConfig({ }, }, - css: ['~/assets/css/style.css'], + css: ['~/assets/css/style.css','~/assets/css/home.css'], compatibilityDate: '2024-04-03', }) diff --git a/Web/public/css/images/home/bar.gif b/Web/public/css/images/home/bar.gif new file mode 100644 index 0000000000000000000000000000000000000000..44ebdbee19b661407e5cf4db3df1ce58b1ee3db0 GIT binary patch literal 473 zcmV;~0Ve)ONk%w1VaNa(0J8u9S-Sl|n&CT>-8hcfG>6qWgVHj9(J_9{Fni4}dCV_& z%Pw`uE_22%bH^!bx&QzGA^8LV2LS&7EC2ui0LTCt000F4u*gZPy*TU5yZ>M)jv8Q| zXsWJk>%MR-&vb3yZlLdc@BhG{a7Zi~kI1BQDHJ%L(5Q4uty-_xtai)odcW3zcuX#v z&*-#z&2GEj@VI=gCfM)zynfH``~QG}f`f#GhKGIzii?bmj*pO$l9QB`mY0~Bnwydb zo}ZwhqNAjxrl+W>s;jK6uCJyDva__cwzs&sy1Tr+zQ4f1!o#`=#>dFX%FE2n&d<=% z($mz{*4NGo+S}aS-rwNi;^XAy=I7|?>g(bR?(gvN^7Hid_V@Vt`uqI-{{QwG2pmYT zpuvL(6DnNDu%W|;5F<*QsBnSBix@L%+{m$`$B!U}Ly8x z!-^eCwyaq;VA85x%eJlCw^*3SolCc_-Me^+;MmKzuiw9b1H*7YxUk{Fh!ZPb%($`R P$B-jSo=mwi;|Ksd`OpfZ literal 0 HcmV?d00001 diff --git a/Web/public/css/images/home/btn_b_gold.gif b/Web/public/css/images/home/btn_b_gold.gif new file mode 100644 index 0000000000000000000000000000000000000000..47256037ecada97c0c66b11752fea9126dbd909e GIT binary patch literal 346 zcmZ?wbhEHbv}F)wIKseiXIjF~_Zz=o&j0o4-1oa(kCs;a`gHiux2xYTRR90~|JSDj zf4-jley#fMob(@$XZ`uK=llDu-@l*x^W(wyYsEkX41|E=X$7=qC6(y&57^K)&m7Q*l zs_))V;iEVE{ELzw)&@K7f7nsuxBm9s`>jdm-~ayK(Ad;m9nZ$!(b?7A)7#fSp(CD$ zW$Lu)GiJ`3J!dW-A5-|;#Y>hh;aSA9YW146>(+1BxM}su&D*x`SjQ61w{zeAjk|gG z9yofGFP!n%>3t`7Po25AIsU?>YwN;TPjTG2d++{(hmRgV;b3ItxW)MT&D(eHKYaZ3 b`8g}+OJ0UwzyJLG_n(28O=hA33xhQPAt|ns literal 0 HcmV?d00001 diff --git a/Web/public/css/images/home/btn_l_gray.gif b/Web/public/css/images/home/btn_l_gray.gif new file mode 100644 index 0000000000000000000000000000000000000000..342c754a40243dec2677d11996eaad035bed47d6 GIT binary patch literal 380 zcmV-?0fYWWNk%w1VNd`R0K@gww0>FMa`=;h_*J}IK{Qds_00RmfNKhcY3=1MiSje!U!-o(f aN}Nbhq5=^C@@OOzpoPbeAVZo60RTH(5zP(& literal 0 HcmV?d00001 diff --git a/Web/public/css/images/home/btn_m_gray.gif b/Web/public/css/images/home/btn_m_gray.gif new file mode 100644 index 0000000000000000000000000000000000000000..f6db12d91a71c28c787a12e56c01b55ab7a2a0b7 GIT binary patch literal 344 zcmV-e0jK^)Nk%w1VLSj70K@gww0>FMa`=;h_*uQ!07w`fPsR8goO+SA_xzQjE#afByXb{rlIiUq65T{PE+*_wV1oef#$H>(?(|zI^`t z`O~LQA3uJ4|Ni~EckkZ5ef#RwtCufdzIgHC>C>lAo;-Q@@ZtUY_wU`iclYkyZCkf7 zU;xFREDY=n{~2^ZG9Wt{ST`i7^`&Ia%aCL_@?c+q&Uqt+U2f~%*S!DDEcnn}N2qyb zW8p~`F0L~#_*a_9th=$M?DXBBr3rGICTPq)|6)s3tbnA%haEM3>u>Wa9Z5d_{`dce zMh+z|0m1f;&aUpB9!@15VPTOeQ>RUzF>?lw60hj|1q&A~Ub2)|iBDW?^_sQo)^FIr zr^GL@ZTpU$yLRv4-y$Y{@X+BSM~@xbC&?`+boSi&3l}e4;!bm3m@BR5^-nnz$EJ z0N~3#0B0G1H^5=a6de0+RhJ_r~L*#+TV z0T=`V6AY2c;O&UCs4zM4FZEeT%13I55&U@fr4RNClBv`L_oYe zTn12K0N~^0;RnNDe9-Sj+zL1!SOg-kfh`;q6(c%IdQ*p>Qg(Ncnv@!GiAb`^BZVj( zm=-G8ytPu#NwoCWz zpexE*Yc;Mri$2tFos`F~W(1eVUI$aluY#{*&b11hBuO?6wyNAb=iQjQkh$R=S!bT6 zkz_Pdwg0^*JDPUtD({2SlbbjkKHN>_T?Lb8Ch)|n?v8(I=5dYmc{2SHwf%hQk&=Y^ z$<18(GJg#ZiZsLqyn53sV0PzQnsti`#T5JEkLDp6X6x55A1$1Y{=Xhr2tkz+KUXmLuvC%4D$Otf>^-uxzHEu+nD3-tgI<~%(tEx>t!}(+&@-e5g|kB* z#_(T(CHog5)sI|rD=cr&ZI_3AY`0Mk&O7>JXMfVrfjWn7l|$v7sh6erflt6 z(mXwq&@_k@ll=839zV=|CT>PYS&aAht~KuaM#h^?K2b4cF$db z1mQEh@!jcKg3c(>4=EccFN>S8cRi0u&>ANhCb!#leY3xy)x6P8-FJA}ObworiB-y7 zgyJ}Hwalr`xGE<4)>`gXw^Zx6jjNAQ(e?}lxc&PN*gxwpd$tmGDEfbXFzmm)XuQq= zPAu-+=bY|W|=A0RH^)2Pm|Pts;e9t`;LUrbPU%?NgxUXrh9n(X}3ek?%v?&8Od z)Y0muQ9O0XepN?Z4MQt+Bj)&7KXrLrAL*7s{k2*QhBqrLM3Urbx)@BuRK@8VsTj4N zf&Z|LF7M28fZ}USUv19Z-h8=jJhs_K`RdW=xayItUplvPsK3#VpYCSc6!K)H~ zY|M*-rWHon`TY`MuJqnm==6F6>NQ4dnbPb)^2>fEXI^U}*`dsOVjgLIT0l>gA-$^7 z6q|owqP+hwyP1d#OjiEGt_?RHC>H8oeE6%F< zyjwe6_x_-a!_AI9hL+O)FmN67$*_S<-R*CRuX>(fVxVQoA8+ z$wW>8&N1K>&x@qam7|_E{`ekCvXNEe7bU6CF0_@t(Nuf>|>dr^_LAXHdYTAzZ|I?V7reXP`>nm z=_Keg|)Kc_9y$_@96j{$@G^ET1EGT6< z@|EFi3h7f}1;S(^>7?BTP0;oke_fIS!^$>>{>k--Y|&u#J&(utTpX+HTq+3~ZSvv< zZ8SX{#rr!XYiCcM9n8Xt>x(7KA(3)H2M1!N1HvPpUJk7Zc2@K6jaQMN!OUbpj-cEe z9VJO4aU~TQ>1kTXsiy)?;u}0_mn^m%kCTi;o8_~Ki6uJrs!9j^T`e%U3-6Gydr&=F zV
-
-
+

返回游戏 diff --git a/Web/src/pages/mall/index.vue b/Web/src/pages/mall/index.vue index 27e0f69..41438af 100644 --- a/Web/src/pages/mall/index.vue +++ b/Web/src/pages/mall/index.vue @@ -1,3 +1,115 @@ \ No newline at end of file +
+ 【商城】
+ 金元:{{ gold }}
+ 金贝:{{ cowry }}
+
+
+ 〔 + 金贝 | + 金元 + 〕 +
+
+
名称|价格
+
+ {{ PageExtend.GetPageIndex(currentPage, 10, index + 1) }}. + + {{ item.name }}({{ GameTool.GetCurrency‌NameAll(item.price, item.payType) }}) + + {{ item.name }}({{ GameTool.GetCurrency‌NameAll(item.price, item.payType) }}) + [购买] +
+
+
+ +
+ + + +
+ 物品名称:{{ showGoods.name }}
+ 购买价格:{{ GameTool.GetCurrency‌NameAll(showGoods.price, showGoods.payType) }}
+
+
+ 购买数量:
+ +
+
+ + \ No newline at end of file diff --git a/Web/src/pages/map/index.vue b/Web/src/pages/map/index.vue index ead271d..0dcc58e 100644 --- a/Web/src/pages/map/index.vue +++ b/Web/src/pages/map/index.vue @@ -6,7 +6,7 @@ {{ cityInfo.cityName }}·{{ mapInfo.mapName }} 刷新 任务 - 消息 + 消息{{ messageCount > 0 ? "(" + messageCount + ")" : "" }}
@@ -20,7 +20,7 @@
- {{ item.npcName }}{{ item.tips }} + {{ item.npcName }}{{ item.tips }}
@@ -91,8 +91,9 @@ const npcData = ref>([]); const chatData = ref>([]); const cityShow = ref>([]); const mapUser = ref>([]); +const messageCount = ref(0); // 城内地图显示 -const showCity = ref(false) +const showCity = ref(false); onMounted(async () => { try { @@ -113,6 +114,7 @@ const BindData = async (map: string): Promise => { chatData.value = result.data.chatData; cityShow.value = result.data.cityShow; mapUser.value = result.data.nearUser; + messageCount.value = result.data.noReadMsg; MapVent(result.data.mapInfo.near); onMap.value = mapInfo.value.mapId; console.log(result.data); diff --git a/Web/src/pages/message/index.vue b/Web/src/pages/message/index.vue index 41a40c8..ee1d4c1 100644 --- a/Web/src/pages/message/index.vue +++ b/Web/src/pages/message/index.vue @@ -1 +1,87 @@ - \ No newline at end of file + + \ No newline at end of file diff --git a/Web/src/pages/message/log.vue b/Web/src/pages/message/log.vue new file mode 100644 index 0000000..7541ca0 --- /dev/null +++ b/Web/src/pages/message/log.vue @@ -0,0 +1,60 @@ + + \ No newline at end of file diff --git a/Web/src/pages/message/read.vue b/Web/src/pages/message/read.vue new file mode 100644 index 0000000..7d38b4c --- /dev/null +++ b/Web/src/pages/message/read.vue @@ -0,0 +1,114 @@ + + \ No newline at end of file diff --git a/Web/src/pages/user/user.vue b/Web/src/pages/user/user.vue index 0c73190..08d8a51 100644 --- a/Web/src/pages/user/user.vue +++ b/Web/src/pages/user/user.vue @@ -1,6 +1,6 @@