1212
This commit is contained in:
@@ -296,4 +296,61 @@ public class StoreController : ControllerBase
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 批量出售装备
|
||||
/// </summary>
|
||||
/// <param name="npcId"></param>
|
||||
/// <param name="query"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<IPoAction> BathSaleEqu(int npcId, string? query)
|
||||
{
|
||||
if (string.IsNullOrEmpty(query))
|
||||
{
|
||||
return PoAction.Message("需要筛选搜索后才可以一键出售!");
|
||||
}
|
||||
|
||||
string userId = StateHelper.userId;
|
||||
int areaId = StateHelper.areaId;
|
||||
var npcInfo = await _mapService.GetNpcInfo(npcId);
|
||||
if (npcInfo == null)
|
||||
{
|
||||
return PoAction.Message("Npc不存在!");
|
||||
}
|
||||
|
||||
if (npcInfo.status != 1)
|
||||
{
|
||||
return PoAction.Message("Npc不存在!");
|
||||
}
|
||||
|
||||
if (GameTool.AreaVerify(areaId, npcInfo.areaId) == false)
|
||||
{
|
||||
return PoAction.Message("Npc不存在!");
|
||||
}
|
||||
|
||||
if (!npcInfo.bus.Any(it => it.code == nameof(GameEnum.NpcBusCode.Store)))
|
||||
{
|
||||
return PoAction.Message("业务不可用!");
|
||||
}
|
||||
|
||||
var onMap = await _mapService.GetUserOnMapId(userId);
|
||||
if (npcInfo.mapId != onMap)
|
||||
{
|
||||
return PoAction.Message("Npc不存在!");
|
||||
}
|
||||
|
||||
var myEqu = await _equService.GetUserEquData(userId, query);
|
||||
myEqu = myEqu.FindAll(it => it.isOn == 0 && it.isLock == 0 && it.intensifyLev == 0);
|
||||
long getCopper = myEqu.Sum(it => (int)it.sysPrice);
|
||||
if (await _equService.DeductUserEqu(userId, myEqu, "出售装备"))
|
||||
{
|
||||
await _accService.UpdateUserCopper(userId, 1, getCopper, "出售装备");
|
||||
return PoAction.Ok(true, $"共出售{myEqu.Count}件装备,获得{getCopper}铜贝!");
|
||||
}
|
||||
else
|
||||
{
|
||||
return PoAction.Message("出售失败,请稍后尝试!");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user