diff --git a/Kx.SeaTime.sln.DotSettings.user b/Kx.SeaTime.sln.DotSettings.user index 98f86ea..a7989e0 100644 --- a/Kx.SeaTime.sln.DotSettings.user +++ b/Kx.SeaTime.sln.DotSettings.user @@ -1,4 +1,5 @@  + ForceIncluded ForceIncluded ForceIncluded ForceIncluded diff --git a/Service/Application.Domain.Entity/game/game/game_trade.cs b/Service/Application.Domain.Entity/game/game/game_trade.cs index c00579b..74ad963 100644 --- a/Service/Application.Domain.Entity/game/game/game_trade.cs +++ b/Service/Application.Domain.Entity/game/game/game_trade.cs @@ -12,6 +12,12 @@ namespace Application.Domain.Entity [SugarColumn(IsPrimaryKey = true, Length = 50)] public string tradeId { get; set; } + /// + /// areaId + /// + [SugarColumn(IsNullable = true)] + public int? areaId { get; set; } + /// /// userId /// diff --git a/Service/Application.Domain/Services/Interface/Pub/ITradeService.cs b/Service/Application.Domain/Services/Interface/Pub/ITradeService.cs index f32a027..932dd8d 100644 --- a/Service/Application.Domain/Services/Interface/Pub/ITradeService.cs +++ b/Service/Application.Domain/Services/Interface/Pub/ITradeService.cs @@ -2,6 +2,12 @@ public interface ITradeService { - Task AddTrade(string userId, string code,string name, string propId, int count, long price,string content); + Task GetTradeInfo(string tradeId); + Task AddTrade(int areaId, string userId, string code,string name, string propId, int count, long price,string content); + Task UpdateTradeCount(string tradeId, int op, int count, bool isDel = false); Task GetUserTradeCount(string userId); + Task> GetUserTradeData(string userId); + + Task> GetUserTradeData(int areaId,string userId, int type, string query, int page, int limit, + RefAsync total); } \ No newline at end of file diff --git a/Service/Application.Domain/Services/Service/Pub/TradeService.cs b/Service/Application.Domain/Services/Service/Pub/TradeService.cs index 81633bf..e25a8d4 100644 --- a/Service/Application.Domain/Services/Service/Pub/TradeService.cs +++ b/Service/Application.Domain/Services/Service/Pub/TradeService.cs @@ -2,11 +2,19 @@ public class TradeService(ISqlSugarClient DbClient, IRedisCache redis) : ITradeService, ITransient { - public async Task AddTrade(string userId, string code,string name, string propId, int count,long price, string content) + public async Task GetTradeInfo(string tradeId) + { + var db = DbClient.AsTenant().GetConnectionWithAttr(); + return await db.Queryable().Where(it => it.tradeId == tradeId).SingleAsync(); + } + + public async Task AddTrade(int areaId, string userId, string code, string name, string propId, int count, + long price, string content) { game_trade trade = new game_trade() { tradeId = StringAssist.NewGuid, + areaId = areaId, userId = userId, code = code, name = name, @@ -20,9 +28,47 @@ public class TradeService(ISqlSugarClient DbClient, IRedisCache redis) : ITradeS return await db.Insertable(trade).ExecuteCommandAsync() > 0; } + public async Task UpdateTradeCount(string tradeId, int op, int count, bool isDel = false) + { + bool result = false; + var db = DbClient.AsTenant().GetConnectionWithAttr(); + if (isDel) + { + result = await db.Deleteable().Where(it => it.tradeId == tradeId).ExecuteCommandAsync() > 0; + } + else + { + int opCount = op == 1 ? count : (0 - count); + result = await db.Updateable() + .SetColumns(it => it.count == it.count + opCount) + .Where(it => it.tradeId == tradeId).ExecuteCommandAsync() > 0; + } + + return result; + } + public async Task GetUserTradeCount(string userId) { var db = DbClient.AsTenant().GetConnectionWithAttr(); return await db.Queryable().Where(it => it.userId == userId).CountAsync(); } + + public async Task> GetUserTradeData(string userId) + { + var db = DbClient.AsTenant().GetConnectionWithAttr(); + return await db.Queryable().Where(it => it.userId == userId).ToListAsync(); + } + + public async Task> GetUserTradeData(int areaId, string userId, int type, string query, int page, int limit, + RefAsync total) + { + var db = DbClient.AsTenant().GetConnectionWithAttr(); + return await db.Queryable().Where(it=>it.areaId==areaId) + .WhereIF(!string.IsNullOrEmpty(userId), it => it.userId == userId) + .WhereIF(type==1,it=>it.code=="Equ") + .WhereIF(type==2,it=>it.code=="Goods") + .WhereIF(!string.IsNullOrEmpty(query),it=>it.name.Contains(query)) + .OrderByDescending(it=>it.addTime) + .ToPageListAsync(page, limit, total); + } } \ No newline at end of file diff --git a/Service/Application.Domain/Services/Service/User/UnitUserAttrService.cs b/Service/Application.Domain/Services/Service/User/UnitUserAttrService.cs index 260db05..87f9110 100644 --- a/Service/Application.Domain/Services/Service/User/UnitUserAttrService.cs +++ b/Service/Application.Domain/Services/Service/User/UnitUserAttrService.cs @@ -514,7 +514,7 @@ public class UnitUserAttrService(ISqlSugarClient DbClient, IRedisCache redis) : var db = DbClient.AsTenant().GetConnectionWithAttr(); await db.Updateable().SetColumns(it => it.dayTime == 0) .WhereIF(day == 1, it => it.monthTime == 0) - .Where(it => true).ExecuteCommandAsync(); + .Where(it => it.userId != "0").ExecuteCommandAsync(); } #endregion diff --git a/Service/Application.Web/Controllers/Map/MapController.cs b/Service/Application.Web/Controllers/Map/MapController.cs index 87bae68..c20fb4d 100644 --- a/Service/Application.Web/Controllers/Map/MapController.cs +++ b/Service/Application.Web/Controllers/Map/MapController.cs @@ -1,5 +1,4 @@ - -namespace Application.Web.Controllers.Map; +namespace Application.Web.Controllers.Map; /// /// 地图接口 @@ -125,34 +124,24 @@ public class MapController : ControllerBase string ip = ComHelper.GetClientUserIp(HttpContext); await _mapService.UpdateUserOnMap(userId, ip, mapInfo.mapId); - //地图业务 - IEnumerable business = new List(); - if (mapInfo.isBus == 1) - { - var busData = await _mapService.GetMapBus(mapInfo.mapId, 0, 0); - business = busData.Select(it => new - { - busId = it.busId, - busName = it.busName - }); - } - - //地图资源 - List mapRes = new List(); - if (mapInfo.isRes == 1) - { - mapRes = await _mapService.GetMapResData(mapInfo.mapId, area); - } - #endregion + + var busData = await _mapService.GetMapBus(mapInfo.mapId, 0, 0);//地图业务 + IEnumerable business = busData.Select(it => new + { + busId = it.busId, + busName = it.busName + }); + + List mapRes = await _mapService.GetMapResData(mapInfo.mapId, area); //地图资源 var broadcast = await _messageService.GetBroadcastData(area); var userFight = await _fightService.GetUserFight(userId); string fightId = userFight.Count > 0 ? userFight[0] : ""; var mapGoods = await _fightService.GetMapFightGoods(mapInfo.mapId); mapGoods = mapGoods.FindAll(it => it.userId == "0" || it.userId == userId).Take(3).ToList(); - var taskData = await _taskService.GetUserTaskData(userId); + var taskData = await _taskService.GetUserTaskData(userId); int isHook = 0; //挂机处理 var onHook = await _hookService.GetUserOnHook(userId); isHook = (int)onHook.status; diff --git a/Service/Application.Web/Controllers/Map/TaskController.cs b/Service/Application.Web/Controllers/Map/TaskController.cs index a054cd8..248be8d 100644 --- a/Service/Application.Web/Controllers/Map/TaskController.cs +++ b/Service/Application.Web/Controllers/Map/TaskController.cs @@ -100,7 +100,10 @@ public class TaskController : ControllerBase int toGoods = await _goodsService.GetUserGoodsCount(userId, GameConfig.GameGetTaskGoods); int retGoods = await _goodsService.GetUserGoodsCount(userId, GameConfig.GameRetTaskGoods); return PoAction.Ok(new - { npc = npcInfo, data = data, talkMsg, taskState, btnTips = taskInfo.btnTips, toGoods, retGoods }); + { + npc = npcInfo, data = data, talkMsg, taskState, award = taskInfo.award, btnTips = taskInfo.btnTips, toGoods, + retGoods + }); } /// @@ -124,7 +127,7 @@ public class TaskController : ControllerBase public async Task RestTask(int task) { string userId = StateHelper.userId; - var onTaskInfo = await _taskService.GetUserTaskInfo(userId,task); + var onTaskInfo = await _taskService.GetUserTaskInfo(userId, task); if (onTaskInfo == null) { return PoAction.Message("暂无任务!"); @@ -188,7 +191,7 @@ public class TaskController : ControllerBase int toGoods = await _goodsService.GetUserGoodsCount(userId, GameConfig.GameGetTaskGoods); int retGoods = await _goodsService.GetUserGoodsCount(userId, GameConfig.GameRetTaskGoods); return PoAction.Ok(new - { data = data, talkMsg, taskState, toGoods, retGoods,lev = taskInfo.lev }); + { data = data, talkMsg, taskState, toGoods, retGoods, lev = taskInfo.lev, award = taskInfo.award }); } /// @@ -263,7 +266,7 @@ public class TaskController : ControllerBase } message = message.TrimEnd(','); - await GameBus.UpdateBag(userId, 1, award, "完成任务");//发放奖励 + await GameBus.UpdateBag(userId, 1, award, "完成任务"); //发放奖励 } return PoAction.Ok(true, message); diff --git a/Service/Application.Web/Controllers/Pub/TradeController.cs b/Service/Application.Web/Controllers/Pub/TradeController.cs index afbc12b..935e4c9 100644 --- a/Service/Application.Web/Controllers/Pub/TradeController.cs +++ b/Service/Application.Web/Controllers/Pub/TradeController.cs @@ -15,10 +15,11 @@ public class TradeController : ControllerBase private readonly IGameChatService _chatService; private readonly IUnitUserAttrService _attrService; private readonly ITradeService _tradeService; + private readonly IUnitUserAccService _accService; public TradeController(IGameGoodsService goodsService, IGameEquService equService, IUnitUserWeight weightService, IUnitUserService userService, IGameChatService chatService, - IUnitUserAttrService attrService, ITradeService tradeService) + IUnitUserAttrService attrService, ITradeService tradeService, IUnitUserAccService accService) { _goodsService = goodsService; _equService = equService; @@ -27,6 +28,7 @@ public class TradeController : ControllerBase _chatService = chatService; _attrService = attrService; _tradeService = tradeService; + _accService = accService; } /// @@ -41,6 +43,7 @@ public class TradeController : ControllerBase { count = count < 1 ? 1 : count; string userId = StateHelper.userId; + int areaId = StateHelper.areaId; int lev = await _attrService.GetUserLev(userId); if (lev < 60) { @@ -75,7 +78,7 @@ public class TradeController : ControllerBase if (await _equService.DeductUserEqu(userId, [equInfo], "寄售装备")) { string data = JsonConvert.SerializeObject(equInfo); - if (await _tradeService.AddTrade(userId, nameof(GameEnum.PropCode.Equ), equInfo.unitEquName, + if (await _tradeService.AddTrade(areaId, userId, nameof(GameEnum.PropCode.Equ), equInfo.unitEquName, equInfo.ueId, 1, price, data)) { return PoAction.Ok(true); @@ -123,7 +126,8 @@ public class TradeController : ControllerBase if (await _goodsService.UpdateUserGoods(userId, 0, goodsId, count, "寄售物品")) { - if (await _tradeService.AddTrade(userId, nameof(GameEnum.PropCode.Goods), MyGoods.goodsName, prop, + if (await _tradeService.AddTrade(areaId, userId, nameof(GameEnum.PropCode.Goods), MyGoods.goodsName, + prop, count, price, "")) { @@ -145,4 +149,236 @@ public class TradeController : ControllerBase return PoAction.Message("该物品不允许寄售!"); } } + + /// + /// 购买 + /// + /// + /// + /// + [HttpGet] + public async Task Buy(string tradeId, int count) + { + count = count < 1 ? 1 : count; + string userId = StateHelper.userId; + int areaId = StateHelper.areaId; + + var info = await _tradeService.GetTradeInfo(tradeId); + if (info == null) + { + return PoAction.Message("交易信息不存在!"); + } + + if (info.areaId != areaId) + { + return PoAction.Message("交易信息不存在!"); + } + + if (info.count < count) + { + return PoAction.Message("交易剩余数量不足!"); + } + + if (info.code == nameof(GameEnum.PropCode.Equ)) + { + var myAcc = await _accService.GetUserAccInfo(userId, nameof(AccEnum.AccType.copper)); + if (myAcc < info.price) + { + return PoAction.Message("您的铜贝不足!"); + } + + if (await _accService.UpdateUserCopper(userId, 0, (long)info.price, $"交易支付:{info.name}")) + { + if (await _tradeService.UpdateTradeCount(info.tradeId, 0, 1, true)) + { + unit_user_equ equInfo = JsonConvert.DeserializeObject(info.content); + equInfo.userId = userId; + await _equService.AddUserEqu(equInfo, "交易获得"); + long GetCopper = Convert.ToInt64(info.price * 0.9M); + if (await _accService.UpdateUserCopper(info.userId, 1, GetCopper, $"交易收入:{info.name}")) + { + string msg = $"您的装备[{info.name}]成功交易,交易价格{info.price}铜贝,到账{GetCopper}铜贝!"; + await _chatService.SendChat(info.userId, areaId, nameof(GameChatEnum.Code.Notice), msg); + } + + return PoAction.Ok(true); + } + else + { + return PoAction.Message("交易失败,请稍后尝试!"); + } + } + else + { + return PoAction.Message("交易失败,请稍后尝试!"); + } + } + else if (info.code == nameof(GameEnum.PropCode.Goods)) + { + var myAcc = await _accService.GetUserAccInfo(userId, nameof(AccEnum.AccType.copper)); + var needCopper = Convert.ToInt64(info.price) * count; + if (myAcc < needCopper) + { + return PoAction.Message("您的铜贝不足!"); + } + + if (await _accService.UpdateUserCopper(userId, 0, needCopper, $"交易支付:{info.name}×{count}")) + { + if (await _tradeService.UpdateTradeCount(info.tradeId, 0, count, info.count == count)) + { + long GetCopper = Convert.ToInt64(needCopper * 0.9M); + if (await _accService.UpdateUserCopper(info.userId, 1, GetCopper, $"交易收入:{info.name}")) + { + await _goodsService.UpdateUserGoods(userId, 1, Convert.ToInt32(info.propId), count, "交易获得"); + string msg = $"您成功交易物品[{info.name}]×{count},交易价格{needCopper}铜贝,到账{GetCopper}铜贝!"; + await _chatService.SendChat(info.userId, areaId, nameof(GameChatEnum.Code.Notice), msg); + } + + return PoAction.Ok(true); + } + else + { + return PoAction.Message("交易失败,请稍后尝试!"); + } + } + else + { + return PoAction.Message("交易失败,请稍后尝试!"); + } + } + else + { + return PoAction.Message("交易失败,请稍后尝试!"); + } + } + + /// + /// 获取交易列表 + /// + /// + /// + /// + /// + /// + [HttpGet] + public async Task GetTradeData(string? no, int type, string? query, int page) + { + string userId = string.Empty; + int areaId = StateHelper.areaId; + if (!string.IsNullOrEmpty(no)) + { + var userInfo = await _userService.GetUserInfoByUserNo(no); + if (userInfo != null) + { + userId = userInfo.userId; + } + } + + RefAsync total = 0; + var data = await _tradeService.GetUserTradeData(areaId, userId, type, query, page, 10, total); + return PoAction.Ok(new { data, total = total.Value }); + } + + /// + /// 获取个人交易列表 + /// + /// + [HttpGet] + public async Task GetMyTrade() + { + string userId = StateHelper.userId; + var data = await _tradeService.GetUserTradeData(userId); + return PoAction.Ok(data); + } + + /// + /// 下架交易 + /// + /// + /// + [HttpGet] + public async Task DownTrade(string tradeId) + { + string userId = StateHelper.userId; + var info = await _tradeService.GetTradeInfo(tradeId); + if (info == null) + { + return PoAction.Message("交易信息不存在!"); + } + + if (info.userId != userId) + { + return PoAction.Message("交易信息不存在!"); + } + + if (info.code == nameof(GameEnum.PropCode.Equ)) + { + if (await _tradeService.UpdateTradeCount(info.tradeId, 0, 1, true)) + { + unit_user_equ equInfo = JsonConvert.DeserializeObject(info.content); + await _equService.AddUserEqu(equInfo, "下架交易装备"); + return PoAction.Ok(true); + } + else + { + return PoAction.Message("下架失败,请稍后尝试!"); + } + } + else if (info.code == nameof(GameEnum.PropCode.Goods)) + { + int count = Convert.ToInt32(info.count); + if (await _tradeService.UpdateTradeCount(info.tradeId, 0, count, true)) + { + await _goodsService.UpdateUserGoods(userId, 1, Convert.ToInt32(info.propId), count, "下架交易物品"); + return PoAction.Ok(true); + } + else + { + return PoAction.Message("下架失败,请稍后尝试!"); + } + } + else + { + return PoAction.Message("下架失败,请稍后尝试!"); + } + } + + /// + /// 获取交易详情 + /// + /// + /// + [HttpGet] + public async Task GetTradeInfo(string tradeId) + { + string userId = StateHelper.userId; + int areaId = StateHelper.areaId; + var info = await _tradeService.GetTradeInfo(tradeId); + if (info == null) + { + return PoAction.Message("交易信息不存在!"); + } + + if (info.areaId != areaId) + { + return PoAction.Message("交易信息不存在!"); + } + + if (info.code != nameof(GameEnum.PropCode.Equ)) + { + return PoAction.Message(info.propId, 100); + } + + var ueInfo = JsonConvert.DeserializeObject(info.content); + var equInfo = await _equService.GetEquInfo((int)ueInfo.equId); + + game_equ_suit suit = new game_equ_suit(); + if (ueInfo.suitCode != "0" && !string.IsNullOrEmpty(ueInfo.suitCode)) + { + suit = await _equService.GetEuqSuitInfo(ueInfo.suitCode); + } + UserModel user = await UserModelTool.GetUserView(ueInfo.owerId); + + return PoAction.Ok(new { equ = equInfo, suit, equData = ueInfo, user }); + } } \ No newline at end of file diff --git a/Web/src/config/BaseConfig.ts b/Web/src/config/BaseConfig.ts index 03a2e06..300e453 100644 --- a/Web/src/config/BaseConfig.ts +++ b/Web/src/config/BaseConfig.ts @@ -2,8 +2,8 @@ 统一配置中心 */ export class BaseConfig { - public static BaseUrl: string = 'https://192.168.0.142:7198' - public static BaseMediaUrl: string = 'https://192.168.0.142:7198/' + public static BaseUrl: string = 'https://localhost:7198' + public static BaseMediaUrl: string = 'https://localhost:7198/' // public static BaseUrl:string="http://v3.pccsh.com"; // public static BaseMediaUrl:string="http://v3.pccsh.com"; } diff --git a/Web/src/pages/task/info.vue b/Web/src/pages/task/info.vue index dd94ebe..74f226f 100644 --- a/Web/src/pages/task/info.vue +++ b/Web/src/pages/task/info.vue @@ -3,13 +3,17 @@ {{ npcData.npcName }}:{{ talkMsg }}
- 恭喜,任务已全部完成! + 恭喜,任务已全部完成!
任务要求:
- + +
+
+ 任务奖励:
+
@@ -37,6 +41,7 @@ const btnTips = ref(''); const taskState = ref(-1); const toGoods = ref(0); const retGoods = ref(0); +const award = ref>([]); let taskId = PageExtend.QueryString("task"); let npcId = LocalStorageHelper.GetOnNpc(); onMounted(async () => { @@ -60,6 +65,9 @@ const BindData = async (): Promise => { taskState.value = result.data.taskState; toGoods.value = result.data.toGoods; retGoods.value = result.data.retGoods; + if (result.data.award != '') { + award.value = JSON.parse(result.data.award); + } verifyData.value = data.value.result; needs.value = verifyData.value.needs; taskId = data.value.itemId; @@ -84,9 +92,9 @@ const ReturnTask = async () => { } } -const mapTo = async (btnData: any) => { +const mapTo = async (btnData: any) => { MessageExtend.LoadingToast("传送中..."); - let result = await TaskService.NeedMapTo( Number(data.value.itemId), btnData.num); + let result = await TaskService.NeedMapTo(Number(data.value.itemId), btnData.num); MessageExtend.LoadingClose(); if (result.code == 0) { PageExtend.RedirectTo("/map"); @@ -96,9 +104,9 @@ const mapTo = async (btnData: any) => { } } -const retTask = async (btnData: any) => { +const retTask = async (btnData: any) => { MessageExtend.LoadingToast("传送中..."); - let result = await TaskService.ReturnTask( Number(data.value.itemId)); + let result = await TaskService.ReturnTask(Number(data.value.itemId)); MessageExtend.LoadingClose(); if (result.code == 0) { PageExtend.RedirectTo("/map"); diff --git a/Web/src/pages/task/look.vue b/Web/src/pages/task/look.vue index 96b89a5..96257d4 100644 --- a/Web/src/pages/task/look.vue +++ b/Web/src/pages/task/look.vue @@ -14,6 +14,10 @@ 任务要求:
+
+ 任务奖励:
+ +
我要传送(领路蝶:{{ retGoods }})
@@ -32,6 +36,7 @@ definePageMeta({ const data = ref({}); const verifyData = ref({}); const needs = ref>([]); +const award = ref>([]); const talkMsg = ref(''); const taskState = ref(-1); const toGoods = ref(0); @@ -58,7 +63,10 @@ const BindData = async (): Promise => { taskState.value = result.data.taskState; toGoods.value = result.data.toGoods; retGoods.value = result.data.retGoods; - lev.value =result.data.lev; + if (result.data.award != '') { + award.value = JSON.parse(result.data.award); + } + lev.value = result.data.lev; verifyData.value = data.value.result; needs.value = verifyData.value.needs; taskId = data.value.itemId; @@ -111,7 +119,7 @@ const restTask = async (btnData: any) => { let result = await TaskService.RestTask(Number(data.value.taskId)); MessageExtend.LoadingClose(); if (result.code == 0) { - MessageExtend.Notify("任务重置成功!","success"); + MessageExtend.Notify("任务重置成功!", "success"); } else { MessageExtend.Notify(result.msg, "danger"); diff --git a/Web/src/pages/trade/index.vue b/Web/src/pages/trade/index.vue index 41a40c8..7a367e4 100644 --- a/Web/src/pages/trade/index.vue +++ b/Web/src/pages/trade/index.vue @@ -1 +1,123 @@ - \ No newline at end of file + + \ No newline at end of file diff --git a/Web/src/pages/trade/info.vue b/Web/src/pages/trade/info.vue new file mode 100644 index 0000000..7ad0b98 --- /dev/null +++ b/Web/src/pages/trade/info.vue @@ -0,0 +1,122 @@ + + \ No newline at end of file diff --git a/Web/src/pages/trade/my.vue b/Web/src/pages/trade/my.vue index 41a40c8..eec486d 100644 --- a/Web/src/pages/trade/my.vue +++ b/Web/src/pages/trade/my.vue @@ -1 +1,79 @@ - \ No newline at end of file + + \ No newline at end of file diff --git a/Web/src/pages/trade/user.vue b/Web/src/pages/trade/user.vue index 41a40c8..0cffc67 100644 --- a/Web/src/pages/trade/user.vue +++ b/Web/src/pages/trade/user.vue @@ -1 +1,117 @@ - \ No newline at end of file + + \ No newline at end of file diff --git a/Web/src/pages/user/badge/index.vue b/Web/src/pages/user/badge/index.vue index ea300e3..c468cdf 100644 --- a/Web/src/pages/user/badge/index.vue +++ b/Web/src/pages/user/badge/index.vue @@ -1,11 +1,14 @@