12121
This commit is contained in:
@@ -0,0 +1,45 @@
|
|||||||
|
using SqlSugar;
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace Application.Domain.Entity
|
||||||
|
{
|
||||||
|
[Tenant("Kg.SeaTime.Log")]
|
||||||
|
public class game_exchange_log
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// ueId
|
||||||
|
/// </summary>
|
||||||
|
[SugarColumn(IsPrimaryKey = true, Length = 50)]
|
||||||
|
public string ueId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// userId
|
||||||
|
/// </summary>
|
||||||
|
[SugarColumn(Length = 50, IsNullable = true)]
|
||||||
|
public string? userId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// exId
|
||||||
|
/// </summary>
|
||||||
|
[SugarColumn(IsNullable = true)]
|
||||||
|
public int? exId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// count
|
||||||
|
/// </summary>
|
||||||
|
[SugarColumn(IsNullable = true)]
|
||||||
|
public int? count { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// addTime
|
||||||
|
/// </summary>
|
||||||
|
[SugarColumn(IsNullable = true)]
|
||||||
|
public long? addTime { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// endTime
|
||||||
|
/// </summary>
|
||||||
|
[SugarColumn(IsNullable = true)]
|
||||||
|
public long? endTime { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,75 @@
|
|||||||
|
using SqlSugar;
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace Application.Domain.Entity
|
||||||
|
{
|
||||||
|
[Tenant("Kg.SeaTime.Resource")]
|
||||||
|
public class game_exchange
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// exId
|
||||||
|
/// </summary>
|
||||||
|
[SugarColumn(IsPrimaryKey = true)]
|
||||||
|
public int exId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// areaId
|
||||||
|
/// </summary>
|
||||||
|
[SugarColumn(Length = 50, IsNullable = true)]
|
||||||
|
public string? areaId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// npcId
|
||||||
|
/// </summary>
|
||||||
|
[SugarColumn(IsNullable = true)]
|
||||||
|
public int? npcId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// name
|
||||||
|
/// </summary>
|
||||||
|
[SugarColumn(Length = 50, IsNullable = true)]
|
||||||
|
public string? name { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// tips
|
||||||
|
/// </summary>
|
||||||
|
[SugarColumn(IsNullable = true)]
|
||||||
|
public string? tips { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// exType
|
||||||
|
/// </summary>
|
||||||
|
[SugarColumn(Length = 50, IsNullable = true)]
|
||||||
|
public string? exType { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// count
|
||||||
|
/// </summary>
|
||||||
|
[SugarColumn(IsNullable = true)]
|
||||||
|
public int? count { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// needData
|
||||||
|
/// </summary>
|
||||||
|
[SugarColumn(IsNullable = true,IsJson = true)]
|
||||||
|
public List<TowerNeed> needData { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// getData
|
||||||
|
/// </summary>
|
||||||
|
[SugarColumn(IsNullable = true,IsJson = true)]
|
||||||
|
public List<TowerGet> getData { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// startTime
|
||||||
|
/// </summary>
|
||||||
|
[SugarColumn(IsNullable = true)]
|
||||||
|
public DateTime? startTime { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// endTime
|
||||||
|
/// </summary>
|
||||||
|
[SugarColumn(IsNullable = true)]
|
||||||
|
public DateTime? endTime { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,18 +4,18 @@ public static class GameConfig
|
|||||||
{
|
{
|
||||||
public const int GameMaxLev = 320;//最大等级
|
public const int GameMaxLev = 320;//最大等级
|
||||||
public const int OnLineTime = 30;//在线延迟时间(分钟)
|
public const int OnLineTime = 30;//在线延迟时间(分钟)
|
||||||
public const int SendChatGoodsBase = 10014;//小海螺
|
public const int SendChatGoodsBase = 10000;//小海螺
|
||||||
public const int SendChatGoodsArea = 10001;//大海螺
|
public const int SendChatGoodsArea = 10001;//大海螺
|
||||||
public const int SendChatGoodsService = 10002;//金海螺
|
public const int SendChatGoodsService = 10002;//金海螺
|
||||||
public const int UpLevAddWeight = 10;//升级增加负重
|
public const int UpLevAddWeight = 10;//升级增加负重
|
||||||
public const int GameBaseVigour = 50;//初始活力
|
public const int GameBaseVigour = 50;//初始活力
|
||||||
public const int GameRelationEnemyNeedGold = 300;//添加仇人所需金元
|
public const int GameRelationEnemyNeedGold = 300;//添加仇人所需金元
|
||||||
public const int GameUpdateNickNeedGoods = 10001;//更新昵称所需道具
|
public const int GameUpdateNickNeedGoods = 10018;//更新昵称所需道具
|
||||||
public const int GameUpdateSexNeedGoods = 10001;//更新性别所需道具
|
public const int GameUpdateSexNeedGoods = 10065;//更新性别所需道具
|
||||||
public const int GameUserFriendMaxCount = 50;//好友最大上限人数
|
public const int GameUserFriendMaxCount = 50;//好友最大上限人数
|
||||||
public const int GameAutoBagGoodsId = 10001;//百宝箱物品ID
|
public const int GameAutoBagGoodsId = 10022;//百宝箱物品ID
|
||||||
public const int GameAutoDrugGoodsId = 10001;//急救箱物品ID
|
public const int GameAutoDrugGoodsId = 10023;//急救箱物品ID
|
||||||
public const int GameToMapNeedCopper = 5;//传送每海里费用
|
public const int GameToMapNeedCopper = 5;//传送每海里费用
|
||||||
public const int TeamCacheTime = 300;//队伍缓存时间
|
public const int TeamCacheTime = 300;//队伍缓存时间
|
||||||
public const int GameEquApprGoods = 10001;//鉴定装备道具
|
public const int GameEquApprGoods = 10019;//鉴定装备道具
|
||||||
}
|
}
|
||||||
@@ -59,6 +59,7 @@ public static class GameEnum
|
|||||||
MapTo,
|
MapTo,
|
||||||
Store,
|
Store,
|
||||||
Make,
|
Make,
|
||||||
|
Exchange,
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum DicCode
|
public enum DicCode
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
namespace Application.Domain;
|
||||||
|
|
||||||
|
public interface IExchangeService
|
||||||
|
{
|
||||||
|
Task<List<game_exchange>> GetExchangeData(int npcId);
|
||||||
|
Task<game_exchange> GetExchangeInfo(int exId);
|
||||||
|
Task<int> GetExchangeCount(string userId, int exId);
|
||||||
|
Task<bool> AddUserExchangeLog(string userId, int exId, int count, long endTime);
|
||||||
|
}
|
||||||
@@ -18,7 +18,7 @@ public interface IGameEquService
|
|||||||
Task<List<unit_user_equ>> GetUserEquData(string userId, string code, List<string> noUeId);
|
Task<List<unit_user_equ>> GetUserEquData(string userId, string code, List<string> noUeId);
|
||||||
Task<unit_user_equ> GetUserEquInfo(string ueId);
|
Task<unit_user_equ> GetUserEquInfo(string ueId);
|
||||||
Task<int> GetUserEquByEquIdCount(string userId, int equId);
|
Task<int> GetUserEquByEquIdCount(string userId, int equId);
|
||||||
Task<List<unit_user_equ>> GetUserEquByEquId(string userId, int equId);
|
Task<List<unit_user_equ>> GetUserEquByEquIdToDeduct(string userId, int equId);
|
||||||
Task<bool> AddUserEqu(string userId, int equId, int count, string remark);
|
Task<bool> AddUserEqu(string userId, int equId, int count, string remark);
|
||||||
Task<bool> AddUserEqu(unit_user_equ equData, string remark);
|
Task<bool> AddUserEqu(unit_user_equ equData, string remark);
|
||||||
Task<unit_user_equ> AddUserEqu(string userId, int equId, bool rdAttr = false, string remark = "");
|
Task<unit_user_equ> AddUserEqu(string userId, int equId, bool rdAttr = false, string remark = "");
|
||||||
|
|||||||
@@ -0,0 +1,41 @@
|
|||||||
|
namespace Application.Domain;
|
||||||
|
|
||||||
|
public class ExchangeService(ISqlSugarClient DbClient, IRedisCache redis) : IExchangeService, ITransient
|
||||||
|
{
|
||||||
|
public async Task<List<game_exchange>> GetExchangeData(int npcId)
|
||||||
|
{
|
||||||
|
var db = DbClient.AsTenant().GetConnectionWithAttr<game_exchange>();
|
||||||
|
var data = await db.Queryable<game_exchange>().Where(it => it.npcId == npcId).ToListAsync();
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<game_exchange> GetExchangeInfo(int exId)
|
||||||
|
{
|
||||||
|
var db = DbClient.AsTenant().GetConnectionWithAttr<game_exchange>();
|
||||||
|
return await db.Queryable<game_exchange>().Where(it => it.exId == exId).SingleAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<int> GetExchangeCount(string userId, int exId)
|
||||||
|
{
|
||||||
|
int result = 0;
|
||||||
|
string key = $"{userId}_{exId}";
|
||||||
|
var db = DbClient.AsTenant().GetConnectionWithAttr<game_exchange_log>();
|
||||||
|
return await db.Queryable<game_exchange_log>().Where(it => it.userId == userId && it.exId == exId)
|
||||||
|
.SumAsync(it => (int)it.count);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<bool> AddUserExchangeLog(string userId, int exId, int count,long endTime)
|
||||||
|
{
|
||||||
|
game_exchange_log log = new game_exchange_log();
|
||||||
|
log.ueId = StringAssist.NewGuid;
|
||||||
|
log.userId = userId;
|
||||||
|
log.exId = exId;
|
||||||
|
log.count = count;
|
||||||
|
log.addTime = TimeExtend.GetTimeStampSeconds;
|
||||||
|
log.endTime = endTime;
|
||||||
|
var db = DbClient.AsTenant().GetConnectionWithAttr<game_exchange_log>();
|
||||||
|
bool result = await db.Insertable(log).ExecuteCommandAsync() > 0;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -78,17 +78,22 @@ public class GameEquService(ISqlSugarClient DbClient, IRedisCache redis) : IGame
|
|||||||
public async Task<int> GetUserEquByEquIdCount(string userId, int equId)
|
public async Task<int> GetUserEquByEquIdCount(string userId, int equId)
|
||||||
{
|
{
|
||||||
int result = 0;
|
int result = 0;
|
||||||
var data = await GetUserEquByEquId(userId, equId);
|
var data = await GetUserEquData(userId, equId);
|
||||||
result = data.Count;
|
result = data.Count;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<List<unit_user_equ>> GetUserEquByEquId(string userId, int equId)
|
public async Task<List<unit_user_equ>> GetUserEquByEquIdToDeduct(string userId, int equId)
|
||||||
{
|
{
|
||||||
var db = DbClient.AsTenant().GetConnectionWithAttr<unit_user_equ>();
|
var userEqu = await GetUserEquData(userId, equId);
|
||||||
return await db.Queryable<unit_user_equ>().Where(i => i.userId == userId && i.equId == equId).ToListAsync();
|
userEqu = userEqu.FindAll(it => it.isLock == 0 && it.isOn == 0);
|
||||||
|
userEqu = userEqu.OrderBy(it => (int)it.intensifyLev)
|
||||||
|
.ThenBy(it => it.quality)
|
||||||
|
.ToList();
|
||||||
|
return userEqu;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public async Task<bool> AddUserEqu(string userId, int equId, int count, string remark)
|
public async Task<bool> AddUserEqu(string userId, int equId, int count, string remark)
|
||||||
{
|
{
|
||||||
bool result = false;
|
bool result = false;
|
||||||
@@ -358,21 +363,11 @@ public class GameEquService(ISqlSugarClient DbClient, IRedisCache redis) : IGame
|
|||||||
|
|
||||||
public async Task<bool> DeductUserEqu(string userId, int equId, int count, string remark)
|
public async Task<bool> DeductUserEqu(string userId, int equId, int count, string remark)
|
||||||
{
|
{
|
||||||
var userEqu = await GetUserEquData(userId, equId);
|
var userEqu = await GetUserEquByEquIdToDeduct(userId, equId);
|
||||||
if (userEqu.Count < 1)
|
if (userEqu.Count < 1)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
userEqu = userEqu.FindAll(it => it.isLock == 0 && it.isOn == 0);
|
|
||||||
if (userEqu.Count < count)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
userEqu = userEqu.OrderBy(it => (int)it.intensifyLev)
|
|
||||||
.OrderBy(it => it.quality)
|
|
||||||
.ToList();
|
|
||||||
var opData = userEqu.Take(count).ToList();
|
var opData = userEqu.Take(count).ToList();
|
||||||
return await DeductUserEqu(userId, opData, remark);
|
return await DeductUserEqu(userId, opData, remark);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,42 +48,42 @@ public class EquTool
|
|||||||
return onAttr;
|
return onAttr;
|
||||||
}
|
}
|
||||||
|
|
||||||
int result = onLev * 3;
|
int result = onLev;
|
||||||
result = result > 57 ? 57 : result;
|
result = result > 19 ? 19 : result;
|
||||||
|
|
||||||
if (onLev > 19)
|
if (onLev > 19)
|
||||||
{
|
{
|
||||||
int addLev = onLev - 19;
|
int addLev = onLev - 19;
|
||||||
addLev = addLev > 10 ? 10 : addLev;
|
addLev = addLev > 10 ? 10 : addLev;
|
||||||
result += addLev * 5;
|
result += addLev * 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (onLev > 29)
|
if (onLev > 29)
|
||||||
{
|
{
|
||||||
int addLev = onLev - 29;
|
int addLev = onLev - 29;
|
||||||
addLev = addLev > 10 ? 10 : addLev;
|
addLev = addLev > 10 ? 10 : addLev;
|
||||||
result += addLev * 10;
|
result += addLev * 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (onLev > 39)
|
if (onLev > 39)
|
||||||
{
|
{
|
||||||
int addLev = onLev - 39;
|
int addLev = onLev - 39;
|
||||||
addLev = addLev > 10 ? 10 : addLev;
|
addLev = addLev > 10 ? 10 : addLev;
|
||||||
result += addLev * 15;
|
result += addLev * 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (onLev > 49)
|
if (onLev > 49)
|
||||||
{
|
{
|
||||||
int addLev = onLev - 49;
|
int addLev = onLev - 49;
|
||||||
addLev = addLev > 10 ? 10 : addLev;
|
addLev = addLev > 10 ? 10 : addLev;
|
||||||
result += addLev * 20;
|
result += addLev * 15;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (onLev > 59)
|
if (onLev > 59)
|
||||||
{
|
{
|
||||||
int addLev = onLev - 59;
|
int addLev = onLev - 59;
|
||||||
addLev = addLev > 10 ? 10 : addLev;
|
addLev = addLev > 10 ? 10 : addLev;
|
||||||
result += addLev * 25;
|
result += addLev * 20;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (onLev > 69)
|
if (onLev > 69)
|
||||||
@@ -91,7 +91,7 @@ public class EquTool
|
|||||||
int addLev = onLev - 69;
|
int addLev = onLev - 69;
|
||||||
addLev = addLev > 10 ? 10 : addLev;
|
addLev = addLev > 10 ? 10 : addLev;
|
||||||
int unitAdd = Convert.ToInt32(onAttr * 0.05);
|
int unitAdd = Convert.ToInt32(onAttr * 0.05);
|
||||||
unitAdd = unitAdd < 30 ? 30 : unitAdd;
|
unitAdd = unitAdd < 25 ? 25 : unitAdd;
|
||||||
result += addLev * unitAdd;
|
result += addLev * unitAdd;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -100,7 +100,7 @@ public class EquTool
|
|||||||
int addLev = onLev - 79;
|
int addLev = onLev - 79;
|
||||||
addLev = addLev > 10 ? 10 : addLev;
|
addLev = addLev > 10 ? 10 : addLev;
|
||||||
int unitAdd = Convert.ToInt32(onAttr * 0.1);
|
int unitAdd = Convert.ToInt32(onAttr * 0.1);
|
||||||
unitAdd = unitAdd < 35 ? 35 : unitAdd;
|
unitAdd = unitAdd < 30 ? 30 : unitAdd;
|
||||||
result += addLev * unitAdd;
|
result += addLev * unitAdd;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -109,7 +109,7 @@ public class EquTool
|
|||||||
int addLev = onLev - 89;
|
int addLev = onLev - 89;
|
||||||
addLev = addLev > 10 ? 10 : addLev;
|
addLev = addLev > 10 ? 10 : addLev;
|
||||||
int unitAdd = Convert.ToInt32(onAttr * 0.15);
|
int unitAdd = Convert.ToInt32(onAttr * 0.15);
|
||||||
unitAdd = unitAdd < 40 ? 40 : unitAdd;
|
unitAdd = unitAdd < 35 ? 35 : unitAdd;
|
||||||
result += addLev * unitAdd;
|
result += addLev * unitAdd;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -112,7 +112,8 @@ public static class GameBus
|
|||||||
if (item.code == nameof(GameEnum.PropCode.Equ))
|
if (item.code == nameof(GameEnum.PropCode.Equ))
|
||||||
{
|
{
|
||||||
var equService = App.GetService<IGameEquService>();
|
var equService = App.GetService<IGameEquService>();
|
||||||
int MyCount = await equService.GetUserEquByEquIdCount(userId, Convert.ToInt32(item.parameter));
|
var myOpEqu = await equService.GetUserEquByEquIdToDeduct(userId, Convert.ToInt32(item.parameter));
|
||||||
|
int MyCount = myOpEqu.Count;
|
||||||
long needCount = item.count * count;
|
long needCount = item.count * count;
|
||||||
item.count = needCount;
|
item.count = needCount;
|
||||||
item.onCount = MyCount;
|
item.onCount = MyCount;
|
||||||
|
|||||||
169
Service/Application.Web/Controllers/Pub/ExchangeController.cs
Normal file
169
Service/Application.Web/Controllers/Pub/ExchangeController.cs
Normal file
@@ -0,0 +1,169 @@
|
|||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
|
namespace Application.Web.Controllers.Pub;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 兑换接口
|
||||||
|
/// </summary>
|
||||||
|
[Route("[controller]/[action]")]
|
||||||
|
[ApiController]
|
||||||
|
[Authorize]
|
||||||
|
public class ExchangeController : ControllerBase
|
||||||
|
{
|
||||||
|
private readonly IGameMapService _mapService;
|
||||||
|
private readonly IExchangeService _exchangeService;
|
||||||
|
|
||||||
|
public ExchangeController(IGameMapService mapService, IExchangeService exchangeService)
|
||||||
|
{
|
||||||
|
_mapService = mapService;
|
||||||
|
_exchangeService = exchangeService;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取兑换信息
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="npcId"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpGet]
|
||||||
|
public async Task<IPoAction> GetExchangeData(int npcId)
|
||||||
|
{
|
||||||
|
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 (!npcInfo.bus.Any(it => it.code == nameof(GameEnum.NpcBusCode.Exchange)))
|
||||||
|
{
|
||||||
|
return PoAction.Message("业务不可用!");
|
||||||
|
}
|
||||||
|
|
||||||
|
var onMap = await _mapService.GetUserOnMapId(userId);
|
||||||
|
if (npcInfo.mapId != onMap)
|
||||||
|
{
|
||||||
|
return PoAction.Message("Npc不存在!");
|
||||||
|
}
|
||||||
|
|
||||||
|
var data = await _exchangeService.GetExchangeData(npcId);
|
||||||
|
data = data.FindAll(it => GameTool.AreaVerify(areaId, it.areaId) && it.endTime > DateTime.Now);
|
||||||
|
|
||||||
|
return PoAction.Ok(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 兑换物品
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="npcId"></param>
|
||||||
|
/// <param name="exId"></param>
|
||||||
|
/// <param name="count"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpGet]
|
||||||
|
public async Task<IPoAction> ExchangeOk(int npcId, int exId, int count)
|
||||||
|
{
|
||||||
|
count = count < 1 ? 1 : count;
|
||||||
|
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 (!npcInfo.bus.Any(it => it.code == nameof(GameEnum.NpcBusCode.Exchange)))
|
||||||
|
{
|
||||||
|
return PoAction.Message("业务不可用!");
|
||||||
|
}
|
||||||
|
|
||||||
|
var onMap = await _mapService.GetUserOnMapId(userId);
|
||||||
|
if (npcInfo.mapId != onMap)
|
||||||
|
{
|
||||||
|
return PoAction.Message("Npc不存在!");
|
||||||
|
}
|
||||||
|
|
||||||
|
var exInfo = await _exchangeService.GetExchangeInfo(exId);
|
||||||
|
if (exInfo == null)
|
||||||
|
{
|
||||||
|
return PoAction.Message("兑换不存在!");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (exInfo.endTime < DateTime.Now)
|
||||||
|
{
|
||||||
|
return PoAction.Message("兑换已结束!");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (GameTool.AreaVerify(areaId, exInfo.areaId) == false)
|
||||||
|
{
|
||||||
|
return PoAction.Message("兑换不存在!");
|
||||||
|
}
|
||||||
|
|
||||||
|
int sumCount = await _exchangeService.GetExchangeCount(userId, exId);
|
||||||
|
if ((sumCount + count) > exInfo.count)
|
||||||
|
{
|
||||||
|
int endCount = (int)exInfo.count - sumCount;
|
||||||
|
if (endCount == 0)
|
||||||
|
{
|
||||||
|
return PoAction.Message("您已达到兑换上限!");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return PoAction.Message($"您最多还能兑换{endCount}次!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var result = await GameBus.CheckNeed(userId, exInfo.needData, count);
|
||||||
|
if (result.result)
|
||||||
|
{
|
||||||
|
if (await GameBus.UpdateBag(userId, 0, exInfo.needData, "兑换", count))
|
||||||
|
{
|
||||||
|
long endTime = 0;
|
||||||
|
switch (exInfo.exType)
|
||||||
|
{
|
||||||
|
case "Long":
|
||||||
|
endTime = TimeExtend.GetTimeStampBySeconds((DateTime)exInfo.endTime);
|
||||||
|
break;
|
||||||
|
case "Day":
|
||||||
|
endTime = TimeExtend.GetTimeStampBySeconds(TimeAssist.GetDateTimeYMD(1));
|
||||||
|
break;
|
||||||
|
case "Month":
|
||||||
|
DateTime nt = DateTime.Now.AddMonths(1);
|
||||||
|
nt = Convert.ToDateTime($"{nt.Year}-{nt.Month}-01");
|
||||||
|
endTime = TimeExtend.GetTimeStampBySeconds(nt);
|
||||||
|
break;
|
||||||
|
case "Week":
|
||||||
|
endTime = TimeExtend.GetTimeStampBySeconds(TimeAssist.WeekEndTime);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (await _exchangeService.AddUserExchangeLog(userId, exId, count, endTime))
|
||||||
|
{
|
||||||
|
await GameBus.UpdateBag(userId, 1, exInfo.getData, "兑换", count);
|
||||||
|
return PoAction.Ok(true);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return PoAction.Message("兑换失败,请稍后尝试!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return PoAction.Message("兑换失败,请稍后尝试!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return PoAction.Message("兑换失败,请稍后尝试!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
23
Web/src/components/Business/GameProp.vue
Normal file
23
Web/src/components/Business/GameProp.vue
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
<template>
|
||||||
|
<div class="common" v-for="item in data">
|
||||||
|
<div v-if="item.code == 'Goods'">
|
||||||
|
▸<Abar :href='"/prop/goods?id=" + item.parameter'>{{ item.name }}</Abar>+{{ item.count * props.count }}
|
||||||
|
</div>
|
||||||
|
<div v-else-if="item.code == 'Equ'">
|
||||||
|
▸<Abar :href='"/prop/equ?id=" + item.parameter'>{{ item.name }}</Abar>+{{ item.count * props.count }}
|
||||||
|
</div>
|
||||||
|
<div v-else>
|
||||||
|
▸{{ item.name }}+{{ item.count * props.count }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<script lang="ts" setup>
|
||||||
|
const props = defineProps({
|
||||||
|
// 字段名、类型、默认值
|
||||||
|
data: Array<any>,
|
||||||
|
count: {
|
||||||
|
type: Number,
|
||||||
|
default: () => (1)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
</script>
|
||||||
93
Web/src/pages/business/exchange.vue
Normal file
93
Web/src/pages/business/exchange.vue
Normal file
@@ -0,0 +1,93 @@
|
|||||||
|
<template>
|
||||||
|
<div class="content">
|
||||||
|
请选择:<br>
|
||||||
|
<div class="content" v-for="(item, index) in data" :key="index">
|
||||||
|
{{ index + 1 }}.<Abutton @click="btnShowView(item)">{{ item.name }}</Abutton>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<GamePopup v-model:show="showView" title="【兑换】">
|
||||||
|
<!-- 自定义内容 -->
|
||||||
|
<div class="common">
|
||||||
|
<strong style="font-size: 14px;">兑换标题:</strong> {{ onData.name }}<br>
|
||||||
|
<strong style="font-size: 14px;">兑换说明:</strong>{{ onData.tips }}<br>
|
||||||
|
<strong style="font-size: 14px;">结束时间:</strong>{{ TimeExtend.Format(onData.endTime) }}<br>
|
||||||
|
<strong style="font-size: 14px;">兑换次数:</strong>{{ GameTool.GetTimeCountTips(onData.exType,
|
||||||
|
onData.count)}}<br>
|
||||||
|
<strong style="font-size: 14px;">兑换奖励:</strong><br>
|
||||||
|
<GameProp :data="onData.getData" :count="count"></GameProp>
|
||||||
|
<strong style="font-size: 14px;">兑换所需:</strong><br>
|
||||||
|
<GamePropVerify :data="verifyData.needs"></GamePropVerify>
|
||||||
|
</div>
|
||||||
|
<div class="common" v-if="verifyData.result == true">
|
||||||
|
<strong style="font-size: 14px;">兑换数量:</strong><input type="number" class="search-ipt" v-model="count"><br>
|
||||||
|
<div style="text-align: center;">
|
||||||
|
<button class="ipt-btn" name="serch" @click="ExChangeOk" style="margin-top: 15px;">兑换</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</GamePopup>
|
||||||
|
</template>
|
||||||
|
<script setup lang="ts">
|
||||||
|
|
||||||
|
definePageMeta({
|
||||||
|
layout: layout.default,
|
||||||
|
middleware: 'page-loading'
|
||||||
|
})
|
||||||
|
const data = ref<Array<any>>([]);
|
||||||
|
const onData = ref<any>({});
|
||||||
|
const verifyData = ref<any>({});
|
||||||
|
const needs = ref<Array<any>>([]);
|
||||||
|
const showView = ref(false);
|
||||||
|
const count = ref(1);
|
||||||
|
let npcId = LocalStorageHelper.GetOnNpc();
|
||||||
|
|
||||||
|
onMounted(async () => {
|
||||||
|
try {
|
||||||
|
await BindData();
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
PageLoading.Close();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
const BindData = async (): Promise<void> => {
|
||||||
|
let result = await ExchangeService.GetExchangeData(Number(npcId));
|
||||||
|
if (result.code == 0) {
|
||||||
|
data.value = result.data;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
MessageExtend.ShowDialog("提示", result.msg);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const btnShowView = async (exData: any) => {
|
||||||
|
onData.value = exData;
|
||||||
|
MessageExtend.LoadingToast("操作中...");
|
||||||
|
let result = await BagService.CheckUserProp(0, count.value, JSON.stringify(exData.needData));
|
||||||
|
MessageExtend.LoadingClose();
|
||||||
|
if (result.code == 0) {
|
||||||
|
verifyData.value = result.data;
|
||||||
|
needs.value = verifyData.value.needs;
|
||||||
|
showView.value = true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
MessageExtend.ShowDialog("兑换", result.msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const ExChangeOk = async (): Promise<void> => {
|
||||||
|
MessageExtend.LoadingToast("兑换中...");
|
||||||
|
let result = await ExchangeService.ExchangeOk(Number(npcId), onData.value.exId, count.value)
|
||||||
|
MessageExtend.LoadingClose();
|
||||||
|
if (result.code == 0) {
|
||||||
|
showView.value = false;
|
||||||
|
MessageExtend.Notify("兑换成功!", "success");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
MessageExtend.ShowDialog("提示", result.msg);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
</script>
|
||||||
@@ -14,9 +14,9 @@
|
|||||||
<div class="common">名称|价格</div>
|
<div class="common">名称|价格</div>
|
||||||
<div class="item" v-for="(item, index) in data" :key="index">
|
<div class="item" v-for="(item, index) in data" :key="index">
|
||||||
{{ PageExtend.GetPageIndex(currentPage, 10, index + 1) }}.
|
{{ PageExtend.GetPageIndex(currentPage, 10, index + 1) }}.
|
||||||
<Abar :href='"/prop/equ?id=" + item.parameter' v-if="item.type == 'Equ'">
|
<Abar :href='"/prop/equ?id=" + item.goodsId' v-if="item.type == 'Equ'">
|
||||||
{{ item.name }}({{ GameTool.GetCurrencyNameAll(item.price, item.payType) }})</Abar>
|
{{ item.name }}({{ GameTool.GetCurrencyNameAll(item.price, item.payType) }})</Abar>
|
||||||
<Abar :href='"/prop/goods?id=" + item.parameter' v-else>
|
<Abar :href='"/prop/goods?id=" + item.goodsId' v-else>
|
||||||
{{ item.name }}({{ GameTool.GetCurrencyNameAll(item.price, item.payType) }})</Abar>
|
{{ item.name }}({{ GameTool.GetCurrencyNameAll(item.price, item.payType) }})</Abar>
|
||||||
[<Abutton @click="ShopView(item)">购买</Abutton>]
|
[<Abutton @click="ShopView(item)">购买</Abutton>]
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -124,9 +124,9 @@
|
|||||||
<span v-if="equData.isAppr == 1">
|
<span v-if="equData.isAppr == 1">
|
||||||
◈<Abutton @click="btnOpenAwaken">觉醒</Abutton><br>
|
◈<Abutton @click="btnOpenAwaken">觉醒</Abutton><br>
|
||||||
</span>
|
</span>
|
||||||
<span v-if="equData.isAppr == 1">
|
<!-- <span v-if="equData.isAppr == 1">
|
||||||
◈<Abar :href='"/user/equ/quality?ue=" + equData.ueId'>洗练</Abar><br>
|
◈<Abar :href='"/user/equ/quality?ue=" + equData.ueId'>洗练</Abar><br>
|
||||||
</span>
|
</span> -->
|
||||||
<span v-if="equData.isAppr == 0">
|
<span v-if="equData.isAppr == 0">
|
||||||
◈<Abutton @click="ApprEqu">鉴定</Abutton><br>
|
◈<Abutton @click="ApprEqu">鉴定</Abutton><br>
|
||||||
</span>
|
</span>
|
||||||
|
|||||||
@@ -57,7 +57,6 @@ const BindData = async (): Promise<void> => {
|
|||||||
monster.value = result.data;
|
monster.value = result.data;
|
||||||
if (monster.value.award != '') {
|
if (monster.value.award != '') {
|
||||||
AwardTips.value = awardTipsStr(JSON.parse(monster.value.award))
|
AwardTips.value = awardTipsStr(JSON.parse(monster.value.award))
|
||||||
console.log(result);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|||||||
17
Web/src/services/Index/ExchangeService.ts
Normal file
17
Web/src/services/Index/ExchangeService.ts
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
export class ExchangeService {
|
||||||
|
/**
|
||||||
|
* 获取兑换信息
|
||||||
|
* GET /Exchange/GetExchangeData
|
||||||
|
*/
|
||||||
|
static async GetExchangeData(npcId: number) {
|
||||||
|
return await ApiService.Request("get", "/Exchange/GetExchangeData", { npcId });
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 兑换物品
|
||||||
|
* GET /Exchange/ExchangeOk
|
||||||
|
*/
|
||||||
|
static async ExchangeOk(npcId: number, exId: number, count: number) {
|
||||||
|
return await ApiService.Request("get", "/Exchange/ExchangeOk", { npcId, exId, count });
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -128,6 +128,24 @@ export class GameTool {
|
|||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
public static GetTimeCountTips(code: string, count: number) {
|
||||||
|
let result = "";
|
||||||
|
switch (code) {
|
||||||
|
case "Long":
|
||||||
|
result = `永久${count}次`;
|
||||||
|
break;
|
||||||
|
case "Day":
|
||||||
|
result = `每天${count}次`;
|
||||||
|
break;
|
||||||
|
case "Week":
|
||||||
|
result = `每周${count}次`;
|
||||||
|
break;
|
||||||
|
case "Month":
|
||||||
|
result = `每月${count}次`;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user