From 7d263d2b96addcfb23cd28657c447c73f147a5c3 Mon Sep 17 00:00:00 2001
From: Putoo <290555932@qq.com>
Date: Fri, 22 May 2026 18:47:25 +0800
Subject: [PATCH] 222
---
.../resource/game/game_goods.cs | 81 +++++++++
Service/Application.Domain/Enum/GameEnum.cs | 10 ++
.../Services/Interface/Equ/IGameEquService.cs | 6 +
.../Interface/Goods/IGameGoodsService.cs | 24 +++
.../Services/Interface/Map/IGameMapService.cs | 1 +
.../Services/Service/Equ/GameEquService.cs | 5 +
.../Service/Goods/GameGoodsService.cs | 156 ++++++++++++++++++
.../Services/Service/Map/GameMapService.cs | 60 +++----
.../Controllers/Map/MapController.cs | 4 +-
Web/src/components/Business/GamePopup.vue | 99 +++++++++++
Web/src/pages/chat/index.vue | 5 +-
Web/src/pages/customer/chat.vue | 34 ++++
Web/src/pages/customer/rule.vue | 37 +++++
Web/src/pages/map/index.vue | 41 ++++-
Web/src/pages/message/index.vue | 1 +
Web/src/pages/task/index.vue | 3 +
16 files changed, 527 insertions(+), 40 deletions(-)
create mode 100644 Service/Application.Domain.Entity/resource/game/game_goods.cs
create mode 100644 Service/Application.Domain/Enum/GameEnum.cs
create mode 100644 Service/Application.Domain/Services/Interface/Equ/IGameEquService.cs
create mode 100644 Service/Application.Domain/Services/Interface/Goods/IGameGoodsService.cs
create mode 100644 Service/Application.Domain/Services/Service/Equ/GameEquService.cs
create mode 100644 Service/Application.Domain/Services/Service/Goods/GameGoodsService.cs
create mode 100644 Web/src/components/Business/GamePopup.vue
create mode 100644 Web/src/pages/customer/chat.vue
create mode 100644 Web/src/pages/customer/rule.vue
create mode 100644 Web/src/pages/message/index.vue
create mode 100644 Web/src/pages/task/index.vue
diff --git a/Service/Application.Domain.Entity/resource/game/game_goods.cs b/Service/Application.Domain.Entity/resource/game/game_goods.cs
new file mode 100644
index 0000000..ebc738c
--- /dev/null
+++ b/Service/Application.Domain.Entity/resource/game/game_goods.cs
@@ -0,0 +1,81 @@
+using SqlSugar;
+using System;
+
+namespace Application.Domain.Entity
+{
+ [Tenant("Kg.SeaTime.Resource")]
+ public class game_goods
+ {
+ ///
+ /// goodsId
+ ///
+ [SugarColumn(IsPrimaryKey = true)]
+ public int goodsId { get; set; }
+
+ ///
+ /// goodsName
+ ///
+ [SugarColumn(Length = 50, IsNullable = true)]
+ public string? goodsName { get; set; }
+
+ ///
+ /// lev
+ ///
+ [SugarColumn(IsNullable = true)]
+ public int? lev { get; set; }
+
+ ///
+ /// code
+ ///
+ [SugarColumn(Length = 50, IsNullable = true)]
+ public string? code { get; set; }
+
+ ///
+ /// img
+ ///
+ [SugarColumn(Length = 50, IsNullable = true)]
+ public string? img { get; set; }
+
+ ///
+ /// tips
+ ///
+ [SugarColumn(IsNullable = true)]
+ public string? tips { get; set; }
+
+ ///
+ /// source
+ ///
+ [SugarColumn(IsNullable = true)]
+ public string? source { get; set; }
+
+ ///
+ /// weight
+ ///
+ [SugarColumn(IsNullable = true)]
+ public int? weight { get; set; }
+
+ ///
+ /// sysPrice
+ ///
+ [SugarColumn(Length = 18, IsNullable = true)]
+ public decimal? sysPrice { get; set; }
+
+ ///
+ /// content
+ ///
+ [SugarColumn(IsNullable = true)]
+ public string? content { get; set; }
+
+ ///
+ /// 0不可交易1可交易
+ ///
+ [SugarColumn(IsNullable = true)]
+ public int? isDeal { get; set; }
+
+ ///
+ /// 0不可赠送 1可赠送
+ ///
+ [SugarColumn(IsNullable = true)]
+ public int? isGive { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/Service/Application.Domain/Enum/GameEnum.cs b/Service/Application.Domain/Enum/GameEnum.cs
new file mode 100644
index 0000000..dce917a
--- /dev/null
+++ b/Service/Application.Domain/Enum/GameEnum.cs
@@ -0,0 +1,10 @@
+namespace Application.Domain;
+
+public class GameEnum
+{
+ public enum LogCode
+ {
+ 减少,
+ 增加
+ }
+}
\ No newline at end of file
diff --git a/Service/Application.Domain/Services/Interface/Equ/IGameEquService.cs b/Service/Application.Domain/Services/Interface/Equ/IGameEquService.cs
new file mode 100644
index 0000000..31f2ad1
--- /dev/null
+++ b/Service/Application.Domain/Services/Interface/Equ/IGameEquService.cs
@@ -0,0 +1,6 @@
+namespace Application.Domain;
+
+public interface IGameEquService
+{
+
+}
\ No newline at end of file
diff --git a/Service/Application.Domain/Services/Interface/Goods/IGameGoodsService.cs b/Service/Application.Domain/Services/Interface/Goods/IGameGoodsService.cs
new file mode 100644
index 0000000..5fec967
--- /dev/null
+++ b/Service/Application.Domain/Services/Interface/Goods/IGameGoodsService.cs
@@ -0,0 +1,24 @@
+namespace Application.Domain;
+
+public interface IGameGoodsService
+{
+ #region 道具资源
+
+ Task GetGoodsInfo(int goodsId);
+ Task GetGoodsContent(int goodsId);
+
+ #endregion
+
+ #region 个人道具
+
+ Task GetUserGoodsInfo(string ugId);
+ Task GetUserGoodsInfo(string userId, int goodsId);
+ Task GetUserGoodsCount(string userId, int goodsId);
+
+ Task> GetUserGoodsData(string userId, List code, string search, int page,
+ int limit, RefAsync total);
+
+ Task UpdateUserGoods(string userId, int op, int goodsId, int count, string remark = "");
+
+ #endregion
+}
\ No newline at end of file
diff --git a/Service/Application.Domain/Services/Interface/Map/IGameMapService.cs b/Service/Application.Domain/Services/Interface/Map/IGameMapService.cs
index e430396..6c09fcc 100644
--- a/Service/Application.Domain/Services/Interface/Map/IGameMapService.cs
+++ b/Service/Application.Domain/Services/Interface/Map/IGameMapService.cs
@@ -6,6 +6,7 @@ public interface IGameMapService
Task GetCityInfo(int cityId);
Task GetMapInfo(string mapId);
+ Task> GetMapCity(int cityId);
Task GetMapCityByMapId(string mapId);
Task> GetMapNpc(string mapId);
Task GetNpcInfo(int npcId);
diff --git a/Service/Application.Domain/Services/Service/Equ/GameEquService.cs b/Service/Application.Domain/Services/Service/Equ/GameEquService.cs
new file mode 100644
index 0000000..c1ad506
--- /dev/null
+++ b/Service/Application.Domain/Services/Service/Equ/GameEquService.cs
@@ -0,0 +1,5 @@
+namespace Application.Domain;
+
+public class GameEquService(ISqlSugarClient DbClient, IRedisCache redis) : IGameEquService, ITransient
+{
+}
\ No newline at end of file
diff --git a/Service/Application.Domain/Services/Service/Goods/GameGoodsService.cs b/Service/Application.Domain/Services/Service/Goods/GameGoodsService.cs
new file mode 100644
index 0000000..2d0afd0
--- /dev/null
+++ b/Service/Application.Domain/Services/Service/Goods/GameGoodsService.cs
@@ -0,0 +1,156 @@
+using System.Reflection.Metadata;
+
+namespace Application.Domain;
+
+public class GameGoodsService(ISqlSugarClient DbClient, IRedisCache redis) : IGameEquService, ITransient
+{
+ #region 道具资源
+
+ public async Task GetGoodsInfo(int goodsId)
+ {
+ string key = string.Format(BaseCache.BaseCacheKey, "GoodsData");
+ var data = await redis.GetHashAsync(key, goodsId.ToString());
+ if (data == null)
+ {
+ var db = DbClient.AsTenant().GetConnectionWithAttr();
+ data = await db.Queryable().Where(it => it.goodsId == goodsId).SingleAsync();
+ await redis.AddHashAsync(key, goodsId.ToString(), data);
+ }
+
+ return data;
+ }
+
+ public async Task GetGoodsContent(int goodsId)
+ {
+ var goodsInfo = await GetGoodsInfo(goodsId);
+ if (goodsInfo == null)
+ {
+ return "";
+ }
+ else
+ {
+ return goodsInfo.content;
+ }
+ }
+
+ #endregion
+
+ #region 个人道具
+
+ public async Task GetUserGoodsInfo(string ugId)
+ {
+ var db = DbClient.AsTenant().GetConnectionWithAttr();
+ return await db.Queryable().Where(it => it.ugId == ugId).SingleAsync();
+ }
+
+ public async Task GetUserGoodsInfo(string userId, int goodsId)
+ {
+ string ugId = GetUserGoodsKey(userId, goodsId);
+ return await GetUserGoodsInfo(ugId);
+ }
+
+ public async Task GetUserGoodsCount(string userId, int goodsId)
+ {
+ var info = await GetUserGoodsInfo(userId, goodsId);
+ return info == null ? 0 : (int)info.count;
+ }
+
+ public async Task> GetUserGoodsData(string userId, List code, string search, int page,
+ int limit, RefAsync total)
+ {
+ var db = DbClient.AsTenant().GetConnectionWithAttr();
+ return await db.Queryable().Where(it => it.userId == userId && it.count > 0)
+ .WhereIF(code.Count > 0, it => code.Contains(it.code))
+ .WhereIF(!string.IsNullOrEmpty(search), it => it.goodsName.Contains(search))
+ .OrderBy(it => it.lev, OrderByType.Desc)
+ .OrderBy(it => it.count, OrderByType.Desc)
+ .ToPageListAsync(page, limit, total);
+ }
+
+
+ public async Task UpdateUserGoods(string userId, int op, int goodsId, int count, string remark = "")
+ {
+ bool isOk = false;
+ unit_user_goods UserGoods = new unit_user_goods();
+ string ugId = GetUserGoodsKey(userId, goodsId);
+ try
+ {
+ var db = DbClient.AsTenant().GetConnectionWithAttr();
+ UserGoods = await db.Queryable().Where(it => it.ugId == ugId).SingleAsync();
+ await DbClient.AsTenant().BeginTranAsync();
+ if (op == 1) //增加
+ {
+ if (UserGoods == null)
+ {
+ var goodsInfo = await GetGoodsInfo(goodsId);
+ UserGoods = new unit_user_goods();
+ UserGoods.ugId = ugId;
+ UserGoods.userId = userId;
+ UserGoods.goodsId = goodsId;
+ UserGoods.count = count;
+ UserGoods.lev = goodsInfo.lev;
+ UserGoods.code = goodsInfo.code;
+ UserGoods.goodsName = goodsInfo.goodsName;
+ UserGoods.weight = goodsInfo.weight;
+ UserGoods.sysPrice = goodsInfo.sysPrice;
+ UserGoods.isDeal = goodsInfo.isDeal;
+ UserGoods.isGive = goodsInfo.isGive;
+ isOk = await db.Insertable(UserGoods).ExecuteCommandAsync() > 0;
+ }
+ else
+ {
+ isOk = await db.Updateable().SetColumns(it => it.count == it.count + count)
+ .Where(it => it.ugId == ugId).ExecuteCommandAsync() > 0;
+ }
+ }
+ else
+ {
+ isOk = await db.Updateable().SetColumns(it => it.count == it.count - count)
+ .Where(it => it.ugId == ugId).ExecuteCommandAsync() > 0;
+ }
+
+ await DbClient.AsTenant().CommitTranAsync();
+ }
+ catch
+ {
+ await DbClient.AsTenant().RollbackTranAsync();
+ isOk = false;
+ }
+
+ if (isOk)
+ {
+ //更新负重
+
+ //添加日志
+
+ await AddGoodsLog(userId, goodsId, op, count, remark);
+ }
+
+ return isOk;
+ }
+
+ private async Task AddGoodsLog(string userId, int goodsId, int code, int count, string remark)
+ {
+ unit_user_goods_log bagLog = new unit_user_goods_log();
+ bagLog.logId = StringAssist.NewGuid;
+ bagLog.userId = userId;
+ bagLog.goodsId = goodsId;
+ bagLog.code = code == 0 ? bagLog.code = nameof(GameEnum.LogCode.减少) : bagLog.code = nameof(GameEnum.LogCode.增加);
+ bagLog.count = count;
+ bagLog.addTime = DateTime.Now;
+ bagLog.remark = remark;
+ var db = DbClient.AsTenant().GetConnectionWithAttr();
+ return await db.Insertable(bagLog).SplitTable().ExecuteCommandAsync() > 0;
+ }
+
+ #endregion
+
+ #region 辅助
+
+ private string GetUserGoodsKey(string userId, int goodsId)
+ {
+ return $"{userId}_{goodsId}";
+ }
+
+ #endregion
+}
\ No newline at end of file
diff --git a/Service/Application.Domain/Services/Service/Map/GameMapService.cs b/Service/Application.Domain/Services/Service/Map/GameMapService.cs
index bc44d5d..a906471 100644
--- a/Service/Application.Domain/Services/Service/Map/GameMapService.cs
+++ b/Service/Application.Domain/Services/Service/Map/GameMapService.cs
@@ -1,27 +1,18 @@
namespace Application.Domain;
-public class GameMapService : IGameMapService, ITransient
+public class GameMapService (ISqlSugarClient DbClient, IRedisCache redis): IGameMapService, ITransient
{
- private readonly ISqlSugarClient _dbClient;
- private readonly IRedisCache _redisClient;
-
- public GameMapService(ISqlSugarClient dbClient, IRedisCache redisClient)
- {
- _dbClient = dbClient;
- _redisClient = redisClient;
- }
-
#region 城市地图数据
public async Task GetCityInfo(int cityId)
{
string key = string.Format(BaseCache.BaseCacheKeys, "MapCityData", "CityData");
- var data = await _redisClient.GetHashAsync(key, cityId.ToString());
+ var data = await redis.GetHashAsync(key, cityId.ToString());
if (data == null)
{
- var db = _dbClient.AsTenant().GetConnectionWithAttr();
+ var db = DbClient.AsTenant().GetConnectionWithAttr();
data = await db.Queryable().Where(it => it.cityId == cityId).SingleAsync();
- await _redisClient.AddHashAsync(key, cityId.ToString(), data);
+ await redis.AddHashAsync(key, cityId.ToString(), data);
}
return data;
@@ -30,17 +21,28 @@ public class GameMapService : IGameMapService, ITransient
public async Task GetMapInfo(string mapId)
{
string key = string.Format(BaseCache.BaseCacheKeys, "MapCityData", "MapData");
- var data = await _redisClient.GetHashAsync(key, mapId);
+ var data = await redis.GetHashAsync(key, mapId);
if (data == null)
{
- var db = _dbClient.AsTenant().GetConnectionWithAttr();
+ var db = DbClient.AsTenant().GetConnectionWithAttr();
data = await db.Queryable().Where(it => it.mapId == mapId).SingleAsync();
- await _redisClient.AddHashAsync(key, mapId, data);
+ await redis.AddHashAsync(key, mapId, data);
}
return data;
}
-
+ public async Task> GetMapCity(int cityId)
+ {
+ string key = string.Format(BaseCache.BaseCacheKeys, "MapCityData", "CityShowMap");
+ var data = await redis.GetHashAsync>(key, cityId.ToString());
+ if (data == null)
+ {
+ var db = DbClient.AsTenant().GetConnectionWithAttr();
+ data = await db.Queryable().Where(it => it.cityId == cityId && it.show == 1).ToListAsync();
+ await redis.AddHashAsync(key, cityId.ToString(), data);
+ }
+ return data;
+ }
public async Task GetMapCityByMapId(string mapId)
{
var data = await GetMapInfo(mapId);
@@ -57,12 +59,12 @@ public class GameMapService : IGameMapService, ITransient
public async Task> GetMapNpc(string mapId)
{
string key = string.Format(BaseCache.BaseCacheKeys, "MapCityData", "NpcData");
- var data = await _redisClient.GetHashAsync>(key, mapId);
+ var data = await redis.GetHashAsync>(key, mapId);
if (data == null)
{
- var db = _dbClient.AsTenant().GetConnectionWithAttr();
+ var db = DbClient.AsTenant().GetConnectionWithAttr();
data = await db.Queryable().Where(it => it.mapId == mapId && it.status == 1).ToListAsync();
- await _redisClient.AddHashAsync(key, mapId, data);
+ await redis.AddHashAsync(key, mapId, data);
}
return data;
@@ -70,12 +72,12 @@ public class GameMapService : IGameMapService, ITransient
public async Task GetNpcInfo(int npcId)
{
string key = string.Format(BaseCache.BaseCacheKeys, "MapCityData", "NpcInfo");
- var data = await _redisClient.GetHashAsync(key, npcId.ToString());
+ var data = await redis.GetHashAsync(key, npcId.ToString());
if (data == null)
{
- var db = _dbClient.AsTenant().GetConnectionWithAttr();
+ var db = DbClient.AsTenant().GetConnectionWithAttr();
data = await db.Queryable().Where(it => it.npcId == npcId).SingleAsync();
- await _redisClient.AddHashAsync(key, npcId.ToString(),data);
+ await redis.AddHashAsync(key, npcId.ToString(),data);
}
return data;
}
@@ -98,14 +100,14 @@ public class GameMapService : IGameMapService, ITransient
public async Task GetUserOnMap(string userId)
{
string key = string.Format(UserCache.BaseCacheKey, "UserOnline");
- if (await _redisClient.HExistsHashAsync(key, userId))
+ if (await redis.HExistsHashAsync(key, userId))
{
- return await _redisClient.GetHashAsync(key, userId);
+ return await redis.GetHashAsync(key, userId);
}
- var db = _dbClient.AsTenant().GetConnectionWithAttr();
+ var db = DbClient.AsTenant().GetConnectionWithAttr();
var data = await db.Queryable().Where(it => it.userId == userId).SingleAsync();
- await _redisClient.AddHashAsync(key, userId, data);
+ await redis.AddHashAsync(key, userId, data);
return data;
}
@@ -117,9 +119,9 @@ public class GameMapService : IGameMapService, ITransient
onLine.ip = ip;
onLine.upTime = TimeAssist.GetTimeStampNum;
string key = string.Format(UserCache.BaseCacheKey, "UserOnline");
- if (await _redisClient.AddHashAsync(key, userId, onLine))
+ if (await redis.AddHashAsync(key, userId, onLine))
{
- var db = _dbClient.AsTenant().GetConnectionWithAttr();
+ var db = DbClient.AsTenant().GetConnectionWithAttr();
await db.Updateable(onLine).ExecuteCommandAsync();
}
}
diff --git a/Service/Application.Web/Controllers/Map/MapController.cs b/Service/Application.Web/Controllers/Map/MapController.cs
index 99161a2..216193b 100644
--- a/Service/Application.Web/Controllers/Map/MapController.cs
+++ b/Service/Application.Web/Controllers/Map/MapController.cs
@@ -53,7 +53,7 @@ public class MapController : ControllerBase
npcData = npcData.FindAll(it => GameTool.AreaVerify(StateHelper.areaId, it.areaId));
//城市信息
var cityInfo = await _mapService.GetCityInfo((int)mapInfo.cityId);
-
+ var cityShow = await _mapService.GetMapCity(cityInfo.cityId);
#region 更新在线
string ip = ComHelper.GetClientUserIp(HttpContext);
@@ -61,7 +61,7 @@ public class MapController : ControllerBase
#endregion
- object ret = new { mapInfo, cityInfo, npcData, chatData };
+ object ret = new { mapInfo, cityInfo, npcData, chatData,cityShow };
return PoAction.Ok(ret);
}
diff --git a/Web/src/components/Business/GamePopup.vue b/Web/src/components/Business/GamePopup.vue
new file mode 100644
index 0000000..9b02efa
--- /dev/null
+++ b/Web/src/components/Business/GamePopup.vue
@@ -0,0 +1,99 @@
+
+
+
+
+
+
+ {{ title }}
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Web/src/pages/chat/index.vue b/Web/src/pages/chat/index.vue
index 1dca849..6bdfc55 100644
--- a/Web/src/pages/chat/index.vue
+++ b/Web/src/pages/chat/index.vue
@@ -33,8 +33,8 @@
- *公聊频道发言规范
- *游戏用户守则规范
+ *公聊频道发言规范
+ *游戏用户守则规范
\ No newline at end of file
diff --git a/Web/src/pages/customer/rule.vue b/Web/src/pages/customer/rule.vue
new file mode 100644
index 0000000..e657093
--- /dev/null
+++ b/Web/src/pages/customer/rule.vue
@@ -0,0 +1,37 @@
+
+
+
+
\ No newline at end of file
diff --git a/Web/src/pages/map/index.vue b/Web/src/pages/map/index.vue
index 9a63742..d60d9f9 100644
--- a/Web/src/pages/map/index.vue
+++ b/Web/src/pages/map/index.vue
@@ -5,16 +5,16 @@
+
\ No newline at end of file
diff --git a/Web/src/pages/message/index.vue b/Web/src/pages/message/index.vue
new file mode 100644
index 0000000..41a40c8
--- /dev/null
+++ b/Web/src/pages/message/index.vue
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/Web/src/pages/task/index.vue b/Web/src/pages/task/index.vue
new file mode 100644
index 0000000..27e0f69
--- /dev/null
+++ b/Web/src/pages/task/index.vue
@@ -0,0 +1,3 @@
+
+
+
\ No newline at end of file