diff --git a/Service/Application.Domain.Entity/model/MapBusTo.cs b/Service/Application.Domain.Entity/model/MapBusTo.cs new file mode 100644 index 0000000..f698f9c --- /dev/null +++ b/Service/Application.Domain.Entity/model/MapBusTo.cs @@ -0,0 +1,12 @@ +namespace Application.Domain.Entity; + +public class MapBusTo +{ + public string name { get; set; } + public string mapId { get; set; } + public string code { get; set; } + public string par { get; set; } + public int time { get; set; } + public int sTime { get; set; } + public int eTime { get; set; } +} \ No newline at end of file diff --git a/Service/Application.Domain.Entity/resource/game/game_city_map_bus.cs b/Service/Application.Domain.Entity/resource/game/game_city_map_bus.cs index 8fe186f..1d6e8f9 100644 --- a/Service/Application.Domain.Entity/resource/game/game_city_map_bus.cs +++ b/Service/Application.Domain.Entity/resource/game/game_city_map_bus.cs @@ -57,8 +57,8 @@ namespace Application.Domain.Entity /// /// busNeed /// - [SugarColumn(IsNullable = true)] - public string? busNeed { get; set; } + [SugarColumn(IsNullable = true, IsJson = true)] + public List busNeed { get; set; } /// /// busContent diff --git a/Service/Application.Domain/Tool/Base/GameBus.cs b/Service/Application.Domain/Tool/Base/GameBus.cs index 5c4d1bf..30a3d8b 100644 --- a/Service/Application.Domain/Tool/Base/GameBus.cs +++ b/Service/Application.Domain/Tool/Base/GameBus.cs @@ -198,6 +198,7 @@ public static class GameBus item.onCount = MyLev; if (MyLev < item.count) { + item.isAsk = 0; isok = false; } } diff --git a/Service/Application.Web/Controllers/Map/MapBusController.cs b/Service/Application.Web/Controllers/Map/MapBusController.cs new file mode 100644 index 0000000..5d9649a --- /dev/null +++ b/Service/Application.Web/Controllers/Map/MapBusController.cs @@ -0,0 +1,105 @@ +using Microsoft.AspNetCore.Mvc; +using Newtonsoft.Json; + +namespace Application.Web.Controllers.Map; + +[ApiExplorerSettings(GroupName = "Map")] +[Route("Map/[controller]/[action]")] +[ApiController] +[Authorize] +public class MapBusController : ControllerBase +{ + private readonly IGameMapService _mapService; + + public MapBusController(IGameMapService mapService) + { + _mapService = mapService; + } + + /// + /// 获取业务信息 + /// + /// + /// + [HttpGet] + public async Task GetBusiness(int id) + { + string userId = StateHelper.userId; + var busData = await _mapService.GetMapBusInfo(id); + if (busData == null) + { + return PoAction.Message("业务不存在!"); + } + + var onMap = await _mapService.GetUserOnMapId(userId); + if (busData.busCode != onMap) + { + return PoAction.Message("业务不存在!"); + } + + var checkResult = await GameBus.CheckNeed(userId, busData.busNeed, 1); + return PoAction.Ok(new { data = busData, result = checkResult }); + } + + /// + /// 传送 + /// + /// + /// + /// + [HttpGet] + public async Task MapBusTo(int id, int num) + { + string userId = StateHelper.userId; + var busData = await _mapService.GetMapBusInfo(id); + if (busData == null) + { + return PoAction.Message("业务不存在!"); + } + + if (busData.busType != "ToMap") + { + return PoAction.Message("业务不存在!"); + } + + var toData = JsonConvert.DeserializeObject >(busData.busContent); + if (num > (toData.Count - 1)) + { + return PoAction.Message("业务不存在!"); + } + var onMap = await _mapService.GetUserOnMapId(userId); + if (busData.busCode != onMap) + { + return PoAction.Message("业务不存在!"); + } + var mapToData = toData[num]; + if (TimeAssist.GetHourNum < mapToData.sTime || TimeAssist.GetHourNum > mapToData.eTime) + { + return PoAction.Message($"当前时间不允许进入"); + } + + var checkResult = await GameBus.CheckNeed(userId, busData.busNeed, 1); + if (checkResult.result==false) + { + return PoAction.Message("不满足传送要求!"); + } + + + if (await GameBus.UpdateBag(userId, 0, busData.busNeed, "业务传送")) + { + var ResultMap = await _mapService.GetToMapInfo(userId, mapToData.mapId, true, true); + if (ResultMap != null) + { + return PoAction.Ok(true); + } + else + { + return PoAction.Message("操作失败,请稍后尝试!"); + } + } + else + { + return PoAction.Message("操作失败,请稍后尝试!"); + } + } +} \ No newline at end of file diff --git a/Service/Application.Web/applicationsettings.json b/Service/Application.Web/applicationsettings.json index 768baea..87b360a 100644 --- a/Service/Application.Web/applicationsettings.json +++ b/Service/Application.Web/applicationsettings.json @@ -1,5 +1,5 @@ { - "AutoProgram": 1, + "AutoProgram": 0, "Redis": { "connection": "127.0.0.1:6379,password=,defaultdatabase=5" }, diff --git a/Web/src/pages/map/business.vue b/Web/src/pages/map/business.vue index 41a40c8..60b33e9 100644 --- a/Web/src/pages/map/business.vue +++ b/Web/src/pages/map/business.vue @@ -1 +1,70 @@ - \ No newline at end of file + + \ No newline at end of file diff --git a/Web/src/pages/map/index.vue b/Web/src/pages/map/index.vue index d58d2a0..68c1042 100644 --- a/Web/src/pages/map/index.vue +++ b/Web/src/pages/map/index.vue @@ -171,7 +171,7 @@ const BindData = async (map: string): Promise => { cityShow.value = result.data.cityShow; mapUser.value = result.data.nearUser; messageCount.value = result.data.noReadMsg; - business.value = result.data.business; + business.value = result.data.business; mapRes.value = result.data.mapRes; broadcast.value = result.data.broadcast; MapVent(result.data.mapInfo.near); diff --git a/Web/src/pages/user/index.vue b/Web/src/pages/user/index.vue index f718a28..406d6bb 100644 --- a/Web/src/pages/user/index.vue +++ b/Web/src/pages/user/index.vue @@ -1,7 +1,7 @@