12121
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
|
||||
namespace Application.Web.Controllers.Map;
|
||||
namespace Application.Web.Controllers.Map;
|
||||
|
||||
/// <summary>
|
||||
/// 地图接口
|
||||
@@ -125,34 +124,24 @@ public class MapController : ControllerBase
|
||||
string ip = ComHelper.GetClientUserIp(HttpContext);
|
||||
await _mapService.UpdateUserOnMap(userId, ip, mapInfo.mapId);
|
||||
|
||||
//地图业务
|
||||
IEnumerable<object> business = new List<object>();
|
||||
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<MapResModel> mapRes = new List<MapResModel>();
|
||||
if (mapInfo.isRes == 1)
|
||||
{
|
||||
mapRes = await _mapService.GetMapResData(mapInfo.mapId, area);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
var busData = await _mapService.GetMapBus(mapInfo.mapId, 0, 0);//地图业务
|
||||
IEnumerable<object> business = busData.Select(it => new
|
||||
{
|
||||
busId = it.busId,
|
||||
busName = it.busName
|
||||
});
|
||||
|
||||
List<MapResModel> 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;
|
||||
|
||||
@@ -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
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -124,7 +127,7 @@ public class TaskController : ControllerBase
|
||||
public async Task<IPoAction> 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 });
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -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("该物品不允许寄售!");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 购买
|
||||
/// </summary>
|
||||
/// <param name="tradeId"></param>
|
||||
/// <param name="count"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<IPoAction> 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<unit_user_equ>(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("交易失败,请稍后尝试!");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取交易列表
|
||||
/// </summary>
|
||||
/// <param name="no"></param>
|
||||
/// <param name="type"></param>
|
||||
/// <param name="query"></param>
|
||||
/// <param name="page"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<IPoAction> 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<int> total = 0;
|
||||
var data = await _tradeService.GetUserTradeData(areaId, userId, type, query, page, 10, total);
|
||||
return PoAction.Ok(new { data, total = total.Value });
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取个人交易列表
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<IPoAction> GetMyTrade()
|
||||
{
|
||||
string userId = StateHelper.userId;
|
||||
var data = await _tradeService.GetUserTradeData(userId);
|
||||
return PoAction.Ok(data);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 下架交易
|
||||
/// </summary>
|
||||
/// <param name="tradeId"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<IPoAction> 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<unit_user_equ>(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("下架失败,请稍后尝试!");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取交易详情
|
||||
/// </summary>
|
||||
/// <param name="tradeId"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<IPoAction> 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<unit_user_equ>(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 });
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user