222
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
using SqlSugar;
|
||||
using System;
|
||||
|
||||
namespace Application.Domain.Entity
|
||||
{
|
||||
[Tenant("Kg.SeaTime.Game")]
|
||||
public class unit_user_ship
|
||||
{
|
||||
/// <summary>
|
||||
/// usId
|
||||
/// </summary>
|
||||
[SugarColumn(IsPrimaryKey = true, Length = 50)]
|
||||
public string usId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// userId
|
||||
/// </summary>
|
||||
[SugarColumn(Length = 50, IsNullable = true)]
|
||||
public string? userId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// goodsId
|
||||
/// </summary>
|
||||
[SugarColumn(IsNullable = true)]
|
||||
public int? goodsId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// name
|
||||
/// </summary>
|
||||
[SugarColumn(Length = 50, IsNullable = true)]
|
||||
public string? name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// speed
|
||||
/// </summary>
|
||||
[SugarColumn(IsNullable = true)]
|
||||
public int? speed { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// weight
|
||||
/// </summary>
|
||||
[SugarColumn(IsNullable = true)]
|
||||
public int? weight { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -23,5 +23,11 @@ namespace Application.Domain.Entity
|
||||
/// </summary>
|
||||
[SugarColumn(IsNullable = true)]
|
||||
public int? maxWeight { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 船只当前负重
|
||||
/// </summary>
|
||||
[SugarColumn(IsNullable = true)]
|
||||
public int? shipOnWeight { get; set; }
|
||||
}
|
||||
}
|
||||
9
Service/Application.Domain/Config/GameConfig.cs
Normal file
9
Service/Application.Domain/Config/GameConfig.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
namespace Application.Domain;
|
||||
|
||||
public static class GameConfig
|
||||
{
|
||||
public const int OnLineTime = 30;//在线延迟时间(分钟)
|
||||
public const int SendChatGoodsBase = 10014;//小海螺
|
||||
public const int SendChatGoodsArea = 10001;//大海螺
|
||||
public const int SendChatGoodsService = 10002;//金海螺
|
||||
}
|
||||
11
Service/Application.Domain/Enum/GoodsEnum.cs
Normal file
11
Service/Application.Domain/Enum/GoodsEnum.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
namespace Application.Domain;
|
||||
|
||||
public static class GoodsEnum
|
||||
{
|
||||
public enum Code
|
||||
{
|
||||
Drug,//药品
|
||||
Prop,//物品
|
||||
Cargo,//货物
|
||||
}
|
||||
}
|
||||
@@ -19,4 +19,13 @@ public interface IGameMapService
|
||||
Task UpdateUserOnMap(string userId, string ip, string mapId);
|
||||
|
||||
#endregion
|
||||
|
||||
#region 其他相关
|
||||
|
||||
Task<List<UserModel>> GetMapUser(string mapId, int area, int showArea, List<string> noUser, int take);
|
||||
|
||||
Task<List<UserModel>> GetMapUser(string mapId, int area, int showArea, List<string> noUser, int page,
|
||||
int limit, RefAsync<int> total);
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -24,5 +24,12 @@ public interface IUnitUserService
|
||||
|
||||
Task<bool> RegisterUserInfo(string userId, string nick, string sex);
|
||||
|
||||
#endregion
|
||||
|
||||
#region 其他
|
||||
|
||||
Task<int> GetOnlineCount();
|
||||
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
namespace Application.Domain;
|
||||
|
||||
public interface IUnitUserWeight
|
||||
{
|
||||
Task<unit_user_weight> GetUserWeightInfo(string userId);
|
||||
Task<bool> UpdateUserWeight(string userId, int op, int weight);
|
||||
Task<bool> UpdateUserMaxWeight(string userId, int op, int weight);
|
||||
Task<bool> AddUserWeightLog(string userId, int goodsId, string goodsName, int weight, int count);
|
||||
Task<bool> CheakUserWeight(string userId, int useWeight);
|
||||
|
||||
#region 船只相关
|
||||
|
||||
Task<List<unit_user_ship>> GetUserShip(string userId);
|
||||
Task<int> GetUserShipMaxWeight(string userId);
|
||||
Task<bool> UpdateUserShipOnWeight(string userId, int op, int weight);
|
||||
Task<bool> CheakUserShipWeight(string userId, int useWeight);
|
||||
Task<bool> DeleteUserShip(string usId, string userId);
|
||||
Task<bool> AddUserShip(string userId, string name, int goodsId, int speed, int weight);
|
||||
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace Application.Domain;
|
||||
|
||||
public class GameGoodsService(ISqlSugarClient DbClient, IRedisCache redis) : IGameEquService, ITransient
|
||||
public class GameGoodsService(ISqlSugarClient DbClient, IRedisCache redis) : IGameGoodsService, ITransient
|
||||
{
|
||||
#region 道具资源
|
||||
|
||||
@@ -120,10 +120,21 @@ public class GameGoodsService(ISqlSugarClient DbClient, IRedisCache redis) : IGa
|
||||
if (isOk)
|
||||
{
|
||||
//更新负重
|
||||
int weightCount = Convert.ToInt32(UserGoods.weight) * count;
|
||||
if (weightCount > 0)
|
||||
{
|
||||
var weightService = App.GetService<IUnitUserWeight>();
|
||||
if (UserGoods.code == nameof(GoodsEnum.Code.Cargo))//跑商物品处理
|
||||
{
|
||||
await weightService.UpdateUserShipOnWeight(userId, op, weightCount);
|
||||
}
|
||||
else
|
||||
{
|
||||
await weightService.UpdateUserWeight(userId, op, weightCount);
|
||||
}
|
||||
}
|
||||
|
||||
//添加日志
|
||||
|
||||
await AddGoodsLog(userId, goodsId, op, count, remark);
|
||||
await AddGoodsLog(userId, goodsId, op, count, remark); //添加日志
|
||||
}
|
||||
|
||||
return isOk;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
namespace Application.Domain;
|
||||
|
||||
public class GameMapService (ISqlSugarClient DbClient, IRedisCache redis): IGameMapService, ITransient
|
||||
public class GameMapService(ISqlSugarClient DbClient, IRedisCache redis) : IGameMapService, ITransient
|
||||
{
|
||||
#region 城市地图数据
|
||||
|
||||
@@ -31,6 +31,7 @@ public class GameMapService (ISqlSugarClient DbClient, IRedisCache redis): IGame
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
public async Task<List<game_city_map>> GetMapCity(int cityId)
|
||||
{
|
||||
string key = string.Format(BaseCache.BaseCacheKeys, "MapCityData", "CityShowMap");
|
||||
@@ -41,8 +42,10 @@ public class GameMapService (ISqlSugarClient DbClient, IRedisCache redis): IGame
|
||||
data = await db.Queryable<game_city_map>().Where(it => it.cityId == cityId && it.show == 1).ToListAsync();
|
||||
await redis.AddHashAsync(key, cityId.ToString(), data);
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
public async Task<int> GetMapCityByMapId(string mapId)
|
||||
{
|
||||
var data = await GetMapInfo(mapId);
|
||||
@@ -69,6 +72,7 @@ public class GameMapService (ISqlSugarClient DbClient, IRedisCache redis): IGame
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
public async Task<game_city_npc> GetNpcInfo(int npcId)
|
||||
{
|
||||
string key = string.Format(BaseCache.BaseCacheKeys, "MapCityData", "NpcInfo");
|
||||
@@ -77,8 +81,9 @@ public class GameMapService (ISqlSugarClient DbClient, IRedisCache redis): IGame
|
||||
{
|
||||
var db = DbClient.AsTenant().GetConnectionWithAttr<game_city_npc>();
|
||||
data = await db.Queryable<game_city_npc>().Where(it => it.npcId == npcId).SingleAsync();
|
||||
await redis.AddHashAsync(key, npcId.ToString(),data);
|
||||
await redis.AddHashAsync(key, npcId.ToString(), data);
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
@@ -126,5 +131,48 @@ public class GameMapService (ISqlSugarClient DbClient, IRedisCache redis): IGame
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 其他相关
|
||||
|
||||
private async Task<List<UserModel>> GetMapUser(string mapId, int area, int showArea, List<string> noUser)
|
||||
{
|
||||
var db = DbClient.AsTenant().GetConnectionWithAttr<unit_user_online>();
|
||||
long time = TimeExtend.GetTimeStampBySeconds(DateTime.Now.AddMinutes(0 - GameConfig.OnLineTime));
|
||||
var data = await db.Queryable<unit_user_online>().Where(it => it.upTime > time && it.mapId == mapId)
|
||||
.WhereIF(noUser.Count > 0, it => !noUser.Contains(it.userId))
|
||||
.OrderByDescending(it=>it.upTime)
|
||||
.ToListAsync();
|
||||
|
||||
List<UserModel> result = new List<UserModel>();
|
||||
data.ForEach(async it =>
|
||||
{
|
||||
var temp = await UserModelTool.GetUserView(it.userId);
|
||||
bool isAdd = showArea == 1 && area != temp.area ? false : true;
|
||||
if (isAdd)
|
||||
{
|
||||
result.Add(temp);
|
||||
}
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
public async Task<List<UserModel>> GetMapUser(string mapId, int area, int showArea, List<string> noUser, int take)
|
||||
{
|
||||
var data = await GetMapUser(mapId, area, showArea, noUser);
|
||||
return data.Take(take).ToList();
|
||||
}
|
||||
|
||||
public async Task<List<UserModel>> GetMapUser(string mapId, int area, int showArea, List<string> noUser, int page,
|
||||
int limit, RefAsync<int> total)
|
||||
{
|
||||
var data = await GetMapUser(mapId, area, showArea, noUser);
|
||||
total = data.Count;
|
||||
return data.Skip((page - 1) * limit) // 跳过前面的页
|
||||
.Take(limit) // 取当前页
|
||||
.ToList();
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -91,7 +91,6 @@ public class UnitUserService : IUnitUserService, ITransient
|
||||
await _redisClient.DelHashAsync(string.Format(UserCache.BaseCacheKeys, "UserInfo", "Sid"), result.token);
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region 用户注册
|
||||
@@ -144,7 +143,7 @@ public class UnitUserService : IUnitUserService, ITransient
|
||||
.Where(it => it.userId == userId).ExecuteCommandAsync() > 0;
|
||||
if (result)
|
||||
{
|
||||
await ClearUserInfo(0, userId);//清理个人信息表缓存
|
||||
await ClearUserInfo(0, userId); //清理个人信息表缓存
|
||||
|
||||
//注册账户
|
||||
unit_user_acc acc = new unit_user_acc();
|
||||
@@ -206,7 +205,6 @@ public class UnitUserService : IUnitUserService, ITransient
|
||||
db.Insertable(online).AddQueue();
|
||||
|
||||
await db.SaveQueuesAsync(false);
|
||||
|
||||
}
|
||||
|
||||
return result;
|
||||
@@ -245,4 +243,15 @@ public class UnitUserService : IUnitUserService, ITransient
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 其他
|
||||
|
||||
public async Task<int> GetOnlineCount()
|
||||
{
|
||||
long time = TimeExtend.GetTimeStampBySeconds(DateTime.Now.AddMinutes(0-GameConfig.OnLineTime));
|
||||
var db = _dbClient.AsTenant().GetConnectionWithAttr<unit_user_online>();
|
||||
return await db.Queryable<unit_user_online>().Where(it => it.upTime > time).CountAsync();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -0,0 +1,177 @@
|
||||
namespace Application.Domain;
|
||||
|
||||
public class UnitUserWeight(ISqlSugarClient DbClient, IRedisCache redis) : IUnitUserWeight, ITransient
|
||||
{
|
||||
public async Task<unit_user_weight> GetUserWeightInfo(string userId)
|
||||
{
|
||||
string key = string.Format(UserCache.BaseCacheKeys, "WeightData", "Weight");
|
||||
var data = await redis.GetHashAsync<unit_user_weight>(key, userId);
|
||||
if (data == null)
|
||||
{
|
||||
var db = DbClient.AsTenant().GetConnectionWithAttr<unit_user_weight>();
|
||||
data = await db.Queryable<unit_user_weight>().Where(it => it.userId == userId).SingleAsync();
|
||||
await redis.AddHashAsync(key, userId, data);
|
||||
}
|
||||
|
||||
data.maxWeight = await GetUserMaxWeight(data);
|
||||
return data;
|
||||
}
|
||||
|
||||
private async Task<int> GetUserMaxWeight(unit_user_weight data)
|
||||
{
|
||||
int result = (int)data.maxWeight;
|
||||
//其他属性加层
|
||||
return result;
|
||||
}
|
||||
|
||||
private async Task ClearUserWeightInfo(string userId)
|
||||
{
|
||||
string key = string.Format(UserCache.BaseCacheKeys, "WeightData", "Weight");
|
||||
await redis.DelHashAsync(key, userId);
|
||||
}
|
||||
|
||||
public async Task<bool> UpdateUserWeight(string userId, int op, int weight)
|
||||
{
|
||||
var db = DbClient.AsTenant().GetConnectionWithAttr<unit_user_weight>();
|
||||
bool result = await db.Updateable<unit_user_weight>()
|
||||
.SetColumnsIF(op == 0, it => it.onWeight == it.onWeight - weight)
|
||||
.SetColumnsIF(op == 1, it => it.onWeight == it.onWeight + weight)
|
||||
.SetColumnsIF(op == 2, it => it.onWeight == weight)
|
||||
.Where(it => it.userId == userId).ExecuteCommandAsync() > 0;
|
||||
if (result)
|
||||
{
|
||||
await ClearUserWeightInfo(userId);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public async Task<bool> UpdateUserMaxWeight(string userId, int op, int weight)
|
||||
{
|
||||
var db = DbClient.AsTenant().GetConnectionWithAttr<unit_user_weight>();
|
||||
bool result = await db.Updateable<unit_user_weight>()
|
||||
.SetColumnsIF(op == 0, it => it.maxWeight == it.maxWeight - weight)
|
||||
.SetColumnsIF(op == 1, it => it.maxWeight == it.maxWeight + weight)
|
||||
.Where(it => it.userId == userId).ExecuteCommandAsync() > 0;
|
||||
if (result)
|
||||
{
|
||||
await ClearUserWeightInfo(userId);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public async Task<bool> AddUserWeightLog(string userId, int goodsId, string goodsName, int weight, int count)
|
||||
{
|
||||
var db = DbClient.AsTenant().GetConnectionWithAttr<unit_user_weight_log>();
|
||||
unit_user_weight_log log = new unit_user_weight_log();
|
||||
log.logId = StringAssist.NewGuid;
|
||||
log.userId = userId;
|
||||
log.goodsId = goodsId;
|
||||
log.goodsName = goodsName;
|
||||
log.weight = weight;
|
||||
log.count = count;
|
||||
log.sum = weight * count;
|
||||
log.addTime = DateTime.Now;
|
||||
return await db.Insertable(log).ExecuteCommandAsync() > 0;
|
||||
}
|
||||
|
||||
public async Task<bool> CheakUserWeight(string userId, int useWeight)
|
||||
{
|
||||
bool result = false;
|
||||
var weightInfo = await GetUserWeightInfo(userId);
|
||||
if (weightInfo != null)
|
||||
{
|
||||
result = (useWeight + weightInfo.onWeight) <= weightInfo.maxWeight;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
#region 船只相关
|
||||
|
||||
public async Task<List<unit_user_ship>> GetUserShip(string userId)
|
||||
{
|
||||
string key = string.Format(UserCache.BaseCacheKeys, "WeightData", "Ship");
|
||||
var data = await redis.GetHashAsync<List<unit_user_ship>>(key, userId);
|
||||
if (data == null)
|
||||
{
|
||||
var db = DbClient.AsTenant().GetConnectionWithAttr<unit_user_ship>();
|
||||
data = await db.Queryable<unit_user_ship>().Where(it => it.userId == userId).ToListAsync();
|
||||
await redis.AddHashAsync(key, userId, data);
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
public async Task<int> GetUserShipMaxWeight(string userId)
|
||||
{
|
||||
var data = await GetUserShip(userId);
|
||||
return data.Sum(it => (int)it.weight);
|
||||
}
|
||||
private async Task ClearUserShipData(string userId)
|
||||
{
|
||||
string key = string.Format(UserCache.BaseCacheKeys, "WeightData", "Ship");
|
||||
await redis.DelHashAsync(key, userId);
|
||||
}
|
||||
|
||||
public async Task<bool> UpdateUserShipOnWeight(string userId, int op, int weight)
|
||||
{
|
||||
var db = DbClient.AsTenant().GetConnectionWithAttr<unit_user_weight>();
|
||||
bool result = await db.Updateable<unit_user_weight>()
|
||||
.SetColumnsIF(op == 0, it => it.shipOnWeight == it.shipOnWeight - weight)
|
||||
.SetColumnsIF(op == 1, it => it.shipOnWeight == it.shipOnWeight + weight)
|
||||
.Where(it => it.userId == userId).ExecuteCommandAsync() > 0;
|
||||
if (result)
|
||||
{
|
||||
await ClearUserWeightInfo(userId);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public async Task<bool> CheakUserShipWeight(string userId, int useWeight)
|
||||
{
|
||||
bool result = false;
|
||||
var weightInfo = await GetUserWeightInfo(userId);
|
||||
var maxShipWeight = await GetUserShipMaxWeight(userId);
|
||||
if (weightInfo != null)
|
||||
{
|
||||
result = (useWeight + weightInfo.onWeight) <= maxShipWeight;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public async Task<bool> DeleteUserShip(string usId,string userId)
|
||||
{
|
||||
var db = DbClient.AsTenant().GetConnectionWithAttr<unit_user_ship>();
|
||||
bool result = await db.Deleteable<unit_user_ship>().Where(it => it.usId == usId).ExecuteCommandAsync() > 0;
|
||||
if (result)
|
||||
{
|
||||
await ClearUserShipData(userId);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public async Task<bool> AddUserShip(string userId,string name,int goodsId,int speed,int weight)
|
||||
{
|
||||
unit_user_ship ship = new unit_user_ship();
|
||||
ship.usId = StringAssist.NewGuid;
|
||||
ship.userId = userId;
|
||||
ship.goodsId = goodsId;
|
||||
ship.name = name;
|
||||
ship.speed = speed;
|
||||
ship.weight = weight;
|
||||
var db = DbClient.AsTenant().GetConnectionWithAttr<unit_user_ship>();
|
||||
bool result = await db.Insertable(ship).ExecuteCommandAsync() > 0;
|
||||
if (result)
|
||||
{
|
||||
await ClearUserShipData(userId);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -11,10 +11,11 @@ namespace Application.Web.Controllers.Chat;
|
||||
public class ChatController : ControllerBase
|
||||
{
|
||||
private readonly IGameChatService _chatService;
|
||||
|
||||
public ChatController(IGameChatService chatService)
|
||||
private readonly IGameGoodsService _goodsService;
|
||||
public ChatController(IGameChatService chatService,IGameGoodsService goodsService)
|
||||
{
|
||||
_chatService = chatService;
|
||||
_goodsService = goodsService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -26,6 +27,7 @@ public class ChatController : ControllerBase
|
||||
[HttpGet]
|
||||
public async Task<IPoAction> GetChatData(int type, int page)
|
||||
{
|
||||
string userId = StateHelper.userId;
|
||||
int areaId = StateHelper.areaId;
|
||||
string teamId = "";
|
||||
string groupId = "";
|
||||
@@ -37,15 +39,15 @@ public class ChatController : ControllerBase
|
||||
switch (type)
|
||||
{
|
||||
case 0:
|
||||
sendGoodsCount = 199;
|
||||
sendGoodsCount = await _goodsService.GetUserGoodsCount(userId,GameConfig.SendChatGoodsBase);
|
||||
sendGoodsName = "小海螺";
|
||||
break;
|
||||
case 3:
|
||||
sendGoodsCount = 15;
|
||||
sendGoodsCount = await _goodsService.GetUserGoodsCount(userId,GameConfig.SendChatGoodsArea);
|
||||
sendGoodsName = "大海螺";
|
||||
break;
|
||||
case 4:
|
||||
sendGoodsCount = 9;
|
||||
sendGoodsCount = await _goodsService.GetUserGoodsCount(userId,GameConfig.SendChatGoodsService);
|
||||
sendGoodsName = "金海螺";
|
||||
break;
|
||||
}
|
||||
@@ -71,12 +73,14 @@ public class ChatController : ControllerBase
|
||||
int areaId = StateHelper.areaId;
|
||||
string par = string.Empty;
|
||||
string code = GameChatEnum.Code.Public.ToString();
|
||||
int goodsId = 0;
|
||||
bool isSend = false;
|
||||
switch (pars.type)
|
||||
{
|
||||
case 0:
|
||||
isSend = true;
|
||||
code =nameof(GameChatEnum.Code.Public);
|
||||
goodsId = GameConfig.SendChatGoodsBase;
|
||||
break;
|
||||
case 1:
|
||||
isSend = true;
|
||||
@@ -90,23 +94,39 @@ public class ChatController : ControllerBase
|
||||
break;
|
||||
case 3:
|
||||
isSend = true;
|
||||
goodsId = GameConfig.SendChatGoodsArea;
|
||||
code = nameof(GameChatEnum.Code.Region);
|
||||
break;
|
||||
case 4:
|
||||
isSend = true;
|
||||
goodsId = GameConfig.SendChatGoodsService;
|
||||
code = nameof(GameChatEnum.Code.Dress);
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
if (isSend == false)
|
||||
{
|
||||
return PoAction.Message("无法发言!");
|
||||
}
|
||||
|
||||
if (goodsId != 0)
|
||||
{
|
||||
var myCount = await _goodsService.GetUserGoodsCount(userId, goodsId);
|
||||
if (myCount < 1)
|
||||
{
|
||||
return PoAction.Message("暂无发言道具,去商城购买海螺才可以发言哦!");
|
||||
}
|
||||
}
|
||||
|
||||
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, "发言");
|
||||
}
|
||||
|
||||
return PoAction.Ok(true);
|
||||
}
|
||||
else
|
||||
|
||||
@@ -47,13 +47,17 @@ public class MapController : ControllerBase
|
||||
string teamId = "";
|
||||
string groupId = "";
|
||||
var chatData = await _chatService.GetChatTop(area, 2, teamId, groupId);
|
||||
//NPC信息
|
||||
|
||||
var npcData = await _mapService.GetMapNpc(mapInfo.mapId);
|
||||
|
||||
var npcData = await _mapService.GetMapNpc(mapInfo.mapId); //NPC信息
|
||||
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);
|
||||
var nearUser =
|
||||
await _mapService.GetMapUser(mapInfo.mapId, area, (int)mapInfo.lookArea, new List<string> { userId },
|
||||
3); //获取附近的人
|
||||
|
||||
var cityInfo = await _mapService.GetCityInfo((int)mapInfo.cityId); //城市信息
|
||||
var cityShow = await _mapService.GetMapCity(cityInfo.cityId); //城内地图
|
||||
|
||||
#region 更新在线
|
||||
|
||||
string ip = ComHelper.GetClientUserIp(HttpContext);
|
||||
@@ -61,8 +65,34 @@ public class MapController : ControllerBase
|
||||
|
||||
#endregion
|
||||
|
||||
object ret = new { mapInfo, cityInfo, npcData, chatData,cityShow };
|
||||
object ret = new { mapInfo, cityInfo, npcData, chatData, cityShow, nearUser };
|
||||
|
||||
return PoAction.Ok(ret);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取地图在线玩家
|
||||
/// </summary>
|
||||
/// <param name="map"></param>
|
||||
/// <param name="page"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<IPoAction> GetMapUser(int page)
|
||||
{
|
||||
RefAsync<int> Total = 0;
|
||||
string userId = StateHelper.userId;
|
||||
int areaId = StateHelper.areaId;
|
||||
var onMap = await _mapService.GetUserOnMap(userId);
|
||||
|
||||
var mapInfo = await _mapService.GetMapInfo(onMap.mapId);
|
||||
if (mapInfo == null)
|
||||
{
|
||||
return PoAction.Message("地图不存在!");
|
||||
}
|
||||
|
||||
var data = await _mapService.GetMapUser(onMap.mapId, areaId, (int)mapInfo.lookArea, new List<string> { userId }, page,
|
||||
10, Total);
|
||||
|
||||
return PoAction.Ok(new { data, total = Total.Value});
|
||||
}
|
||||
}
|
||||
@@ -52,7 +52,7 @@ namespace Application.Web.Controllers.Pub
|
||||
|
||||
var notice = await _noticeService.GetNoticeDataByTake(5);
|
||||
|
||||
int OnCount = 100;
|
||||
int OnCount = await _userService.GetOnlineCount();
|
||||
return PoAction.Ok(new { area = areaData, notice, isOnline, onCount = OnCount, account,userData });
|
||||
}
|
||||
|
||||
|
||||
38
Service/Application.Web/Controllers/User/BagController.cs
Normal file
38
Service/Application.Web/Controllers/User/BagController.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
namespace Application.Web.Controllers.User;
|
||||
|
||||
/// <summary>
|
||||
/// 用户背包信息
|
||||
/// </summary>
|
||||
[ApiExplorerSettings(GroupName = "User")]
|
||||
[Route("User/[controller]/[action]")]
|
||||
[ApiController]
|
||||
[Authorize]
|
||||
public class BagController : ControllerBase
|
||||
{
|
||||
private readonly IUnitUserWeight _weightService;
|
||||
|
||||
public BagController(IUnitUserWeight weightService)
|
||||
{
|
||||
_weightService = weightService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取背包信息
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<IPoAction> GetUserBagData()
|
||||
{
|
||||
string userId = StateHelper.userId;
|
||||
int onWeight = 0;
|
||||
int maxWeight = 0;
|
||||
int gold = 0;
|
||||
int cowry = 0;
|
||||
long copper = 0;
|
||||
var userWeight = await _weightService.GetUserWeightInfo(userId);
|
||||
onWeight = (int)userWeight.onWeight;
|
||||
maxWeight = (int)userWeight.maxWeight;
|
||||
|
||||
return PoAction.Ok(new { onWeight, maxWeight,cowry, gold, copper });
|
||||
}
|
||||
}
|
||||
BIN
Web/public/css/images/btn_b_gold.gif
Normal file
BIN
Web/public/css/images/btn_b_gold.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 346 B |
@@ -53,4 +53,9 @@ onMounted(() => {
|
||||
<style>
|
||||
/* 页面级样式可以在这里定义 */
|
||||
/* 全局样式已移至 src/assets/css/style.css */
|
||||
|
||||
:root{
|
||||
--van-base-font: initial !important;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
@@ -120,6 +120,26 @@ a:focus {
|
||||
height: 20px;
|
||||
border: none;
|
||||
}
|
||||
.serch{
|
||||
display: flex;
|
||||
align-items: flex-end;
|
||||
}
|
||||
.search-ipt{
|
||||
width: 80px;
|
||||
font-size: 11px;
|
||||
padding: 0 ;
|
||||
}
|
||||
|
||||
.ipt-btn{
|
||||
width: 61px;
|
||||
height: 21px;
|
||||
font-size: 13px;
|
||||
border: none;
|
||||
margin-top: 5px;
|
||||
background: url(/css/images/btn_b_gold.gif) no-repeat;
|
||||
color: #af4c00;
|
||||
}
|
||||
|
||||
.chat {
|
||||
word-wrap: break-word;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<div class="common">
|
||||
<Abar href="/">状态</Abar>.
|
||||
<Abar href="/">物品</Abar>.
|
||||
<Abar href="/bag">物品</Abar>.
|
||||
<Abar href="/chat">聊天</Abar>
|
||||
</div>
|
||||
<div class="common">
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
<div class="main">
|
||||
<slot />
|
||||
</div>
|
||||
<div class="clear"></div>
|
||||
<div class="content ">
|
||||
<button class="btn btn-ret" @click="GoBack">返回</button><br />
|
||||
<Abar href="/map">返回游戏</Abar>
|
||||
|
||||
125
Web/src/pages/bag/index.vue
Normal file
125
Web/src/pages/bag/index.vue
Normal file
@@ -0,0 +1,125 @@
|
||||
<template>
|
||||
<div class="content">
|
||||
【我的物品】.<Abutton @click="Refresh">刷新</Abutton> <br>
|
||||
金元: {{ bagInfo.gold }}<br />
|
||||
金贝: {{ bagInfo.cowry }} <br />
|
||||
负重:{{ bagInfo.onWeight }}/{{ bagInfo.maxWeight }} <br />
|
||||
{{ bagInfo.copper }}铜<br />
|
||||
<Abar href="/">交易记录</Abar><br>
|
||||
<Abar href="/">赠送记录</Abar>
|
||||
</div>
|
||||
<div class="content">
|
||||
<div class="common">
|
||||
【
|
||||
<Acheak @click="ChangeBag('0')" :on-value="type" on-cheak="0">装备</Acheak>|
|
||||
<Acheak @click="ChangeBag('1')" :on-value="type" on-cheak="1">药品</Acheak>|
|
||||
<Acheak @click="ChangeBag('2')" :on-value="type" on-cheak="2">物品</Acheak>|
|
||||
<Acheak @click="ChangeBag('3')" :on-value="type" on-cheak="3">坐骑</Acheak>
|
||||
】
|
||||
</div>
|
||||
<div class="common">
|
||||
|
||||
</div>
|
||||
<div class="common serch">
|
||||
搜索内容:<input type="text" class="search-ipt" v-model="serch">
|
||||
<button class="ipt-btn" name="serch" @click="BindData">搜索</button>
|
||||
</div>
|
||||
<div class="common">
|
||||
<div v-if="type == '0'">
|
||||
<Acheak @click="ChangeChildBag('0')" :on-value="type_ch" on-cheak="0">全部</Acheak>.
|
||||
<Acheak @click="ChangeChildBag('1')" :on-value="type_ch" on-cheak="1">穿戴</Acheak>.
|
||||
<Acheak @click="ChangeChildBag('2')" :on-value="type_ch" on-cheak="2">到期</Acheak>
|
||||
</div>
|
||||
<div v-if="type == '2'">
|
||||
<Acheak @click="ChangeChildBag('0')" :on-value="type_ch" on-cheak="0">全部</Acheak>.<Acheak
|
||||
@click="ChangeChildBag('1')" :on-value="type_ch" on-cheak="1">宝石</Acheak>.<Acheak
|
||||
@click="ChangeChildBag('2')" :on-value="type_ch" on-cheak="2">九宫</Acheak>.<Acheak
|
||||
@click="ChangeChildBag('3')" :on-value="type_ch" on-cheak="3">圣痕</Acheak>.<Acheak
|
||||
@click="ChangeChildBag('4')" :on-value="type_ch" on-cheak="4">宝箱</Acheak>.<Acheak
|
||||
@click="ChangeChildBag('5')" :on-value="type_ch" on-cheak="5">材料</Acheak>.<Acheak
|
||||
@click="ChangeChildBag('6')" :on-value="type_ch" on-cheak="6">图纸</Acheak>.<Acheak
|
||||
@click="ChangeChildBag('7')" :on-value="type_ch" on-cheak="7">卡片</Acheak>.<Acheak
|
||||
@click="ChangeChildBag('8')" :on-value="type_ch" on-cheak="8">货物</Acheak>.<Acheak
|
||||
@click="ChangeChildBag('9')" :on-value="type_ch" on-cheak="9">其他</Acheak>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="content">
|
||||
暂无道具.
|
||||
</div>
|
||||
<div class="content">
|
||||
<Pagination :currentPage="currentPage" :limit="10" :total="total" @pageChange="handlePageChange" />
|
||||
</div>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
|
||||
definePageMeta({
|
||||
layout: layout.default,
|
||||
middleware: 'page-loading'
|
||||
})
|
||||
|
||||
const currentPage = ref<number>(1);
|
||||
const total = ref<number>(0);
|
||||
const bagInfo = ref<any>({});
|
||||
const data = ref<Array<any>>([]);
|
||||
const type = ref('0');
|
||||
const type_ch = ref('0');
|
||||
const serch = ref('');
|
||||
|
||||
|
||||
onMounted(async () => {
|
||||
try {
|
||||
|
||||
let result = await BagService.GetUserBagData();
|
||||
if (result.code == 0) {
|
||||
bagInfo.value = result.data;
|
||||
await BindData();
|
||||
}
|
||||
console.log(result);
|
||||
}
|
||||
finally {
|
||||
PageLoading.Close();
|
||||
}
|
||||
})
|
||||
|
||||
const BindData = async (): Promise<void> => {
|
||||
let result = await MapService.GetMapUser(currentPage.value);
|
||||
if (result.code == 0) {
|
||||
data.value = result.data.data;
|
||||
total.value = result.data.total;
|
||||
console.log(result);
|
||||
}
|
||||
else {
|
||||
MessageExtend.ShowDialog("提示", result.msg);
|
||||
}
|
||||
};
|
||||
|
||||
/**切换背包 */
|
||||
const ChangeBag = async (_type: string): Promise<void> => {
|
||||
type.value = _type;
|
||||
await BindData();
|
||||
}
|
||||
|
||||
const ChangeChildBag = async (ch: string): Promise<void> => {
|
||||
type_ch.value = ch;
|
||||
await BindData();
|
||||
}
|
||||
|
||||
/**刷新 */
|
||||
const Refresh = async (): Promise<void> => {
|
||||
serch.value = '';
|
||||
MessageExtend.LoadingToast("刷新中...");
|
||||
currentPage.value = 1;
|
||||
await BindData();
|
||||
MessageExtend.LoadingClose();
|
||||
PageExtend.ScrollToTop();
|
||||
}
|
||||
|
||||
/**翻页 */
|
||||
const handlePageChange = async (page: number): Promise<void> => {
|
||||
currentPage.value = page;
|
||||
await BindData();
|
||||
};
|
||||
|
||||
</script>
|
||||
@@ -4,12 +4,12 @@
|
||||
<Abar href="/news">*更新内容早知道</Abar>
|
||||
</div>
|
||||
<div class="title">
|
||||
<Acheak @click="BindData('0')" :on-value="type" on-cheak="0">公共</Acheak>.
|
||||
<Acheak @click="BindData('1')" :on-value="type" on-cheak="1">队伍</Acheak>.
|
||||
<Acheak @click="BindData('2')" :on-value="type" on-cheak="2">帮派</Acheak>.
|
||||
<Acheak @click="BindData('3')" :on-value="type" on-cheak="3">全区</Acheak>.
|
||||
<Acheak @click="BindData('4')" :on-value="type" on-cheak="4">全服</Acheak>.
|
||||
<Acheak @click="BindData('5')" :on-value="type" on-cheak="5">系统</Acheak>
|
||||
<Acheak @click="ChangeChat('0')" :on-value="type" on-cheak="0">公共</Acheak>.
|
||||
<Acheak @click="ChangeChat('1')" :on-value="type" on-cheak="1">队伍</Acheak>.
|
||||
<Acheak @click="ChangeChat('2')" :on-value="type" on-cheak="2">帮派</Acheak>.
|
||||
<Acheak @click="ChangeChat('3')" :on-value="type" on-cheak="3">全区</Acheak>.
|
||||
<Acheak @click="ChangeChat('4')" :on-value="type" on-cheak="4">全服</Acheak>.
|
||||
<Acheak @click="ChangeChat('5')" :on-value="type" on-cheak="5">系统</Acheak>
|
||||
</div>
|
||||
<div class="content">
|
||||
<GameChat :data="data" :show-time="1"></GameChat>
|
||||
@@ -54,18 +54,15 @@ const sign = ref('');
|
||||
|
||||
onMounted(async () => {
|
||||
try {
|
||||
await BindData(type.value);
|
||||
await BindData();
|
||||
}
|
||||
finally {
|
||||
PageLoading.Close();
|
||||
}
|
||||
})
|
||||
|
||||
const BindData = async (typeid: string): Promise<void> => {
|
||||
if (type.value != typeid) {
|
||||
type.value = typeid;
|
||||
}
|
||||
let result = await ChatService.GetChatData(Number(typeid), currentPage.value);
|
||||
const BindData = async (): Promise<void> => {
|
||||
let result = await ChatService.GetChatData(Number(type.value), currentPage.value);
|
||||
if (result.code == 0) {
|
||||
data.value = result.data.data;
|
||||
goodsCount.value = result.data.sendGoodsCount
|
||||
@@ -80,7 +77,7 @@ const BindData = async (typeid: string): Promise<void> => {
|
||||
/**刷新 */
|
||||
const Refresh = async (): Promise<void> => {
|
||||
MessageExtend.LoadingToast("刷新中...");
|
||||
await BindData(type.value);
|
||||
await BindData();
|
||||
MessageExtend.LoadingClose();
|
||||
PageExtend.ScrollToTop();
|
||||
}
|
||||
@@ -88,7 +85,7 @@ const Refresh = async (): Promise<void> => {
|
||||
/**翻页 */
|
||||
const handlePageChange = async (page: number): Promise<void> => {
|
||||
currentPage.value = page;
|
||||
await BindData(type.value);
|
||||
await BindData();
|
||||
};
|
||||
|
||||
/**发送消息 */
|
||||
@@ -105,7 +102,7 @@ const SendChat = async (): Promise<void> => {
|
||||
send = true;
|
||||
if (result.code == 0) {
|
||||
sign.value = '';
|
||||
await BindData(type.value);
|
||||
await BindData();
|
||||
PageExtend.ScrollToTop();
|
||||
}
|
||||
else {
|
||||
@@ -115,4 +112,13 @@ const SendChat = async (): Promise<void> => {
|
||||
|
||||
}
|
||||
|
||||
/**切换频道 */
|
||||
const ChangeChat = async (typeid: string): Promise<void> => {
|
||||
if (type.value != typeid) {
|
||||
type.value = typeid;
|
||||
}
|
||||
currentPage.value = 1;
|
||||
await BindData();
|
||||
};
|
||||
|
||||
</script>
|
||||
@@ -14,16 +14,16 @@
|
||||
</div>
|
||||
<div class="content">
|
||||
您看到:
|
||||
<a class="" href="/Map/Index/MapUser/16_27?sid=W6Wg8iH9gY7wIBNSEdtFcQ3KbI5YiKDo">1111
|
||||
</a>
|
||||
<Abar href="/map/user" v-if="mapUser.length>0">
|
||||
<span v-for="item in mapUser">{{item.nick}} </span>
|
||||
</Abar>
|
||||
</div>
|
||||
<div class="content">
|
||||
<div class="item" v-for="item in npcData">
|
||||
<Abar href="">{{ item.npcName }}{{ item.tips }}</Abar>
|
||||
</div>
|
||||
</div>
|
||||
<div class="content">
|
||||
</div>
|
||||
|
||||
<div class="content">
|
||||
请选择出口:<br />
|
||||
<span v-if="mapDong.mapId != ''">东:<Abutton @click="BindData(mapDong.mapId)">{{ mapDong.name }}</Abutton></span>
|
||||
@@ -34,9 +34,7 @@
|
||||
</div>
|
||||
|
||||
<div class="content">
|
||||
【<Abutton @click="ShowCityProp">城内地图</Abutton>】.<a class=""
|
||||
href="/Business/Help/Index?sid=W6Wg8iH9gY7wIBNSEdtFcQ3KbI5YiKDo">帮助</a>.<a class=""
|
||||
href="/Privilege/Purdiam/MapTo?sid=W6Wg8iH9gY7wIBNSEdtFcQ3KbI5YiKDo">传送</a><br />
|
||||
【<Abutton @click="ShowCityProp">城内地图</Abutton>】.<Abar href="/">寻路</Abar><br />
|
||||
</div>
|
||||
<div class="content">
|
||||
{{ mapInfo.tips }}
|
||||
@@ -67,6 +65,7 @@ const cityInfo = ref<any>({});
|
||||
const npcData = ref<Array<any>>([]);
|
||||
const chatData = ref<Array<any>>([]);
|
||||
const cityShow = ref<Array<any>>([]);
|
||||
const mapUser = ref<Array<any>>([]);
|
||||
// 城内地图显示
|
||||
const showCity = ref(false)
|
||||
|
||||
@@ -88,6 +87,7 @@ const BindData = async (map: string): Promise<void> => {
|
||||
npcData.value = result.data.npcData;
|
||||
chatData.value = result.data.chatData;
|
||||
cityShow.value = result.data.cityShow;
|
||||
mapUser.value = result.data.nearUser;
|
||||
MapVent(result.data.mapInfo.near);
|
||||
onMap.value = mapInfo.value.mapId;
|
||||
console.log(result.data);
|
||||
|
||||
61
Web/src/pages/map/user.vue
Normal file
61
Web/src/pages/map/user.vue
Normal file
@@ -0,0 +1,61 @@
|
||||
<template>
|
||||
<div class="content">
|
||||
【附近的人】.<Abutton @click="Refresh">刷新</Abutton>
|
||||
</div>
|
||||
<div class="content">
|
||||
<div class="item" v-for="(item, index) in data" :key="index">
|
||||
{{ index + 1 }}.<GameUser :data="item" :show-icon="0"></GameUser>
|
||||
</div>
|
||||
<span v-if="data.length == 0">暂无玩家.</span>
|
||||
</div>
|
||||
<div class="content">
|
||||
<Pagination :currentPage="currentPage" :limit="10" :total="total" @pageChange="handlePageChange" />
|
||||
</div>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
|
||||
definePageMeta({
|
||||
layout: layout.default,
|
||||
middleware: 'page-loading'
|
||||
})
|
||||
|
||||
const currentPage = ref<number>(1);
|
||||
const total = ref<number>(0);
|
||||
const data = ref<Array<any>>([]);
|
||||
|
||||
onMounted(async () => {
|
||||
try {
|
||||
await BindData();
|
||||
}
|
||||
finally {
|
||||
PageLoading.Close();
|
||||
}
|
||||
})
|
||||
|
||||
const BindData = async (): Promise<void> => {
|
||||
let result = await MapService.GetMapUser(currentPage.value);
|
||||
if (result.code == 0) {
|
||||
data.value = result.data.data;
|
||||
total.value = result.data.total;
|
||||
}
|
||||
else {
|
||||
MessageExtend.ShowDialog("提示", result.msg);
|
||||
}
|
||||
};
|
||||
|
||||
/**刷新 */
|
||||
const Refresh = async (): Promise<void> => {
|
||||
MessageExtend.LoadingToast("刷新中...");
|
||||
currentPage.value = 1;
|
||||
await BindData();
|
||||
MessageExtend.LoadingClose();
|
||||
PageExtend.ScrollToTop();
|
||||
}
|
||||
|
||||
/**翻页 */
|
||||
const handlePageChange = async (page: number): Promise<void> => {
|
||||
currentPage.value = page;
|
||||
await BindData();
|
||||
};
|
||||
|
||||
</script>
|
||||
@@ -6,4 +6,12 @@ export class MapService {
|
||||
static async GetMapData(map: string) {
|
||||
return await ApiService.Request("get", "/Map/Map/GetMapData", { map });
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取地图在线玩家
|
||||
* GET /Map/Map/GetMapUser
|
||||
*/
|
||||
static async GetMapUser(page: number) {
|
||||
return await ApiService.Request("get", "/Map/Map/GetMapUser", { page });
|
||||
}
|
||||
}
|
||||
9
Web/src/services/user/BagService.ts
Normal file
9
Web/src/services/user/BagService.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
export class BagService {
|
||||
/**
|
||||
* 获取背包信息
|
||||
* GET /User/Bag/GetUserBagData
|
||||
*/
|
||||
static async GetUserBagData() {
|
||||
return await ApiService.Request("get", "/User/Bag/GetUserBagData");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user