This commit is contained in:
Putoo
2026-07-12 17:36:07 +08:00
parent c40f3711bc
commit 035eb476ea
19 changed files with 932 additions and 22 deletions

View File

@@ -0,0 +1,63 @@
using SqlSugar;
using System;
namespace Application.Domain.Entity
{
[Tenant("Kg.SeaTime.Game")]
public class game_trade
{
/// <summary>
/// tradeId
/// </summary>
[SugarColumn(IsPrimaryKey = true, Length = 50)]
public string tradeId { get; set; }
/// <summary>
/// userId
/// </summary>
[SugarColumn(Length = 50, IsNullable = true)]
public string? userId { get; set; }
/// <summary>
/// code
/// </summary>
[SugarColumn(Length = 50, IsNullable = true)]
public string? code { get; set; }
/// <summary>
/// propId
/// </summary>
[SugarColumn(Length = 50, IsNullable = true)]
public string? propId { get; set; }
/// <summary>
/// name
/// </summary>
[SugarColumn(Length = 50, IsNullable = true)]
public string? name { get; set; }
/// <summary>
/// count
/// </summary>
[SugarColumn(IsNullable = true)]
public int? count { get; set; }
/// <summary>
/// price
/// </summary>
[SugarColumn(IsNullable = true)]
public long? price { get; set; }
/// <summary>
/// content
/// </summary>
[SugarColumn(IsNullable = true)]
public string? content { get; set; }
/// <summary>
/// addTime
/// </summary>
[SugarColumn(IsNullable = true)]
public DateTime? addTime { get; set; }
}
}

View File

@@ -17,6 +17,7 @@ public static class GoodsEnum
ChoicePack,//选择宝箱 ChoicePack,//选择宝箱
Weight,//负重 Weight,//负重
Gift,//礼物道具 Gift,//礼物道具
Tease,//整蛊道具
Exp,//经验 Exp,//经验
State,//状态物品 State,//状态物品
Ship,//船只 Ship,//船只

View File

@@ -14,6 +14,8 @@ public interface IGameEquService
Task<List<unit_user_equ>> GetUserEquData(string userId, int type, string equName, int PageIndex, int PageSize, Task<List<unit_user_equ>> GetUserEquData(string userId, int type, string equName, int PageIndex, int PageSize,
RefAsync<int> Total, bool isRemOn = false, bool isRemLock = false); RefAsync<int> Total, bool isRemOn = false, bool isRemLock = false);
Task<List<unit_user_equ>> GetUserEquData(string userId, int type, string equName, int PageIndex,
int PageSize, RefAsync<int> Total,int DealType);
Task<List<unit_user_equ>> GetUserEquData(string userId, string query); Task<List<unit_user_equ>> GetUserEquData(string userId, string query);
Task<List<unit_user_equ>> GetUserEquData(string userId, int equId); Task<List<unit_user_equ>> GetUserEquData(string userId, int equId);
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);

View File

@@ -18,6 +18,9 @@ public interface IGameGoodsService
Task<List<unit_user_goods>> GetUserGoodsData(string userId, List<string> code, List<string> noCode, string search, int page, Task<List<unit_user_goods>> GetUserGoodsData(string userId, List<string> code, List<string> noCode, string search, int page,
int limit, RefAsync<int> total); int limit, RefAsync<int> total);
Task<List<unit_user_goods>> GetUserGoodsData(string userId, List<string> code, List<string> noCode, string search, int page,
int limit, RefAsync<int> total,int DealType);
Task<List<unit_user_goods>> GetUserGoodsData(string userId, string code); Task<List<unit_user_goods>> GetUserGoodsData(string userId, string code);
Task<bool> UpdateUserGoods(string userId, int op, int goodsId, int count, string remark = ""); Task<bool> UpdateUserGoods(string userId, int op, int goodsId, int count, string remark = "");
#endregion #endregion

View File

@@ -0,0 +1,7 @@
namespace Application.Domain;
public interface ITradeService
{
Task<bool> AddTrade(string userId, string code,string name, string propId, int count, long price,string content);
Task<int> GetUserTradeCount(string userId);
}

View File

@@ -137,7 +137,7 @@ public class GameChatService : IGameChatService, ITransient
chat.delTime = TimeExtend.GetTimeStampBySeconds(DateTime.Now.AddHours(6)); chat.delTime = TimeExtend.GetTimeStampBySeconds(DateTime.Now.AddHours(6));
break; break;
case "Notice": case "Notice":
chat.delTime = TimeExtend.GetTimeStampBySeconds(DateTime.Now.AddDays(1)); chat.delTime = TimeExtend.GetTimeStampBySeconds(DateTime.Now.AddDays(7));
chat.code = nameof(GameChatEnum.Code.System); chat.code = nameof(GameChatEnum.Code.System);
break; break;
case "Group": case "Group":

View File

@@ -55,6 +55,24 @@ public class GameEquService(ISqlSugarClient DbClient, IRedisCache redis) : IGame
.OrderByDescending(it => it.lev) .OrderByDescending(it => it.lev)
.OrderByDescending(it => it.ueId).ToPageListAsync(PageIndex, PageSize, Total); .OrderByDescending(it => it.ueId).ToPageListAsync(PageIndex, PageSize, Total);
} }
public async Task<List<unit_user_equ>> GetUserEquData(string userId, int type, string equName, int PageIndex,
int PageSize, RefAsync<int> Total,int DealType)
{
long onTime = TimeExtend.GetTimeStampSeconds;
var db = DbClient.AsTenant().GetConnectionWithAttr<unit_user_equ>();
return await db.Queryable<unit_user_equ>().Where(it =>
it.userId == userId && it.isOn == 0 && it.isLock == 0 &&
it.useEndTime > onTime)
.WhereIF(DealType == 0, it => it.isDeal == 1)
.WhereIF(DealType == 1, it => it.isDeal == 1 && it.isGive == 1)
.WhereIF(!string.IsNullOrEmpty(equName),
it => it.equName.Contains(equName) || it.unitEquName.Contains(equName))
.OrderByDescending(it => it.isOn)
.OrderByDescending(it => it.lev)
.OrderByDescending(it => it.ueId).ToPageListAsync(PageIndex, PageSize, Total);
}
public async Task<List<unit_user_equ>> GetUserEquData(string userId, string query) public async Task<List<unit_user_equ>> GetUserEquData(string userId, string query)
{ {
long onTime = TimeExtend.GetTimeStampSeconds; long onTime = TimeExtend.GetTimeStampSeconds;
@@ -857,8 +875,8 @@ public class GameEquService(ISqlSugarClient DbClient, IRedisCache redis) : IGame
await EquOnOrDown(item, 0); await EquOnOrDown(item, 0);
} }
} }
} }
#endregion #endregion
#region #region

View File

@@ -70,6 +70,23 @@ public class GameGoodsService(ISqlSugarClient DbClient, IRedisCache redis) : IGa
.ToPageListAsync(page, limit, total); .ToPageListAsync(page, limit, total);
} }
public async Task<List<unit_user_goods>> GetUserGoodsData(string userId, List<string> code, List<string> noCode,
string search, int page,
int limit, RefAsync<int> total, int DealType)
{
var db = DbClient.AsTenant().GetConnectionWithAttr<unit_user_goods>();
return await db.Queryable<unit_user_goods>().Where(it =>
it.userId == userId && it.count > 0)
.WhereIF(DealType == 0, it => it.isDeal == 1)
.WhereIF(DealType == 1, it => it.isDeal == 1 && it.isGive == 1)
.WhereIF(code.Count > 0, it => code.Contains(it.code))
.WhereIF(noCode.Count > 0, it => !noCode.Contains(it.code))
.WhereIF(!string.IsNullOrEmpty(search), it => it.goodsName.Contains(search))
.OrderBy(it => it.lev, OrderByType.Desc)
.OrderBy(it => it.count, OrderByType.Desc)
.ToPageListAsync(page, limit, total);
}
public async Task<List<unit_user_goods>> GetUserGoodsData(string userId, string code) public async Task<List<unit_user_goods>> GetUserGoodsData(string userId, string code)
{ {
var db = DbClient.AsTenant().GetConnectionWithAttr<unit_user_goods>(); var db = DbClient.AsTenant().GetConnectionWithAttr<unit_user_goods>();
@@ -282,6 +299,7 @@ public class GameGoodsService(ISqlSugarClient DbClient, IRedisCache redis) : IGa
return result; return result;
} }
public async Task<string> CheckUseDrug(string userId, int goodsId, string scene = "") public async Task<string> CheckUseDrug(string userId, int goodsId, string scene = "")
{ {
string result = string.Empty; string result = string.Empty;
@@ -290,6 +308,7 @@ public class GameGoodsService(ISqlSugarClient DbClient, IRedisCache redis) : IGa
{ {
result = await CheckUseDrug(userId, goodsId, goodsInfo, scene); result = await CheckUseDrug(userId, goodsId, goodsInfo, scene);
} }
return result; return result;
} }
@@ -320,7 +339,8 @@ public class GameGoodsService(ISqlSugarClient DbClient, IRedisCache redis) : IGa
} }
else if (_drugConfig.cls == nameof(GoodsEnum.DrugCls.BloodStock)) else if (_drugConfig.cls == nameof(GoodsEnum.DrugCls.BloodStock))
{ {
result = await attrService.AddUserStock(userId, goodsId.ToString(), Convert.ToString(_drugConfig.name),Convert.ToString(_drugConfig.type), result = await attrService.AddUserStock(userId, goodsId.ToString(), Convert.ToString(_drugConfig.name),
Convert.ToString(_drugConfig.type),
Convert.ToString(_drugConfig.code), Convert.ToString(_drugConfig.code),
Convert.ToInt64(_drugConfig.num), Convert.ToString(_drugConfig.par), Convert.ToInt64(_drugConfig.num), Convert.ToString(_drugConfig.par),
Convert.ToInt32(_drugConfig.minute)); Convert.ToInt32(_drugConfig.minute));
@@ -332,6 +352,7 @@ public class GameGoodsService(ISqlSugarClient DbClient, IRedisCache redis) : IGa
return result; return result;
} }
public async Task<bool> UseDrug(string userId, int goodsId, string scene = "") public async Task<bool> UseDrug(string userId, int goodsId, string scene = "")
{ {
bool result = false; bool result = false;

View File

@@ -0,0 +1,28 @@
namespace Application.Domain;
public class TradeService(ISqlSugarClient DbClient, IRedisCache redis) : ITradeService, ITransient
{
public async Task<bool> AddTrade(string userId, string code,string name, string propId, int count,long price, string content)
{
game_trade trade = new game_trade()
{
tradeId = StringAssist.NewGuid,
userId = userId,
code = code,
name = name,
propId = propId,
count = count,
price = price,
content = content,
addTime = DateTime.Now
};
var db = DbClient.AsTenant().GetConnectionWithAttr<game_trade>();
return await db.Insertable(trade).ExecuteCommandAsync() > 0;
}
public async Task<int> GetUserTradeCount(string userId)
{
var db = DbClient.AsTenant().GetConnectionWithAttr<game_trade>();
return await db.Queryable<game_trade>().Where(it => it.userId == userId).CountAsync();
}
}

View File

@@ -0,0 +1,148 @@
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json;
namespace Application.Web.Controllers.Pub;
[Route("[controller]/[action]")]
[ApiController]
[Authorize]
public class TradeController : ControllerBase
{
private readonly IGameGoodsService _goodsService;
private readonly IGameEquService _equService;
private readonly IUnitUserWeight _weightService;
private readonly IUnitUserService _userService;
private readonly IGameChatService _chatService;
private readonly IUnitUserAttrService _attrService;
private readonly ITradeService _tradeService;
public TradeController(IGameGoodsService goodsService, IGameEquService equService, IUnitUserWeight weightService,
IUnitUserService userService, IGameChatService chatService,
IUnitUserAttrService attrService, ITradeService tradeService)
{
_goodsService = goodsService;
_equService = equService;
_weightService = weightService;
_userService = userService;
_chatService = chatService;
_attrService = attrService;
_tradeService = tradeService;
}
/// <summary>
/// 寄售物品
/// </summary>
/// <param name="type"></param>
/// <param name="prop"></param>
/// <param name="price"></param>
/// <returns></returns>
[HttpGet]
public async Task<IPoAction> Trade(int type, string prop, long price, int count)
{
count = count < 1 ? 1 : count;
string userId = StateHelper.userId;
int lev = await _attrService.GetUserLev(userId);
if (lev < 60)
{
return PoAction.Message("60级后才可以寄售物品哦!");
}
var tradeCount = await _tradeService.GetUserTradeCount(userId);
if (tradeCount >= 5)
{
return PoAction.Message("玩家最多同时寄售5件物品哦!");
}
if (type == 0) //装备
{
var equInfo = await _equService.GetUserEquInfo(prop);
if (equInfo == null)
{
return PoAction.Message("装备不存在!");
}
if (equInfo.userId != userId || equInfo.isOn == 1 || equInfo.isLock == 1 || equInfo.isDeal == 0)
{
return PoAction.Message("该装备无法寄售!");
}
long minPrice = (int)equInfo.lev * 100;
if (price < minPrice)
{
return PoAction.Message($"该装备最低寄售价格{minPrice}铜贝!");
}
if (await _equService.DeductUserEqu(userId, [equInfo], "寄售装备"))
{
string data = JsonConvert.SerializeObject(equInfo);
if (await _tradeService.AddTrade(userId, nameof(GameEnum.PropCode.Equ), equInfo.unitEquName,
equInfo.ueId, 1, price, data))
{
return PoAction.Ok(true);
}
else
{
await _equService.AddUserEqu(equInfo, "寄售失败返还!");
return PoAction.Message("寄售失败,请稍后尝试!");
}
}
else
{
return PoAction.Message("寄售失败,请稍后尝试!");
}
}
else if (type == 1) //物品
{
if (count > 99)
{
return PoAction.Message("单次寄售数量最多为99个!");
}
int goodsId = Convert.ToInt32(prop);
var MyGoods = await _goodsService.GetUserGoodsInfo(userId, goodsId);
if (MyGoods == null)
{
return PoAction.Message("物品数量不足!");
}
if (MyGoods.count < count)
{
return PoAction.Message("物品数量不足!");
}
if (MyGoods.isDeal == 0)
{
return PoAction.Message("该物品无法寄售!");
}
long minPrice = (int)MyGoods.lev * 100;
if (price < minPrice)
{
return PoAction.Message($"该物品最低寄售价格{minPrice}铜贝!");
}
if (await _goodsService.UpdateUserGoods(userId, 0, goodsId, count, "寄售物品"))
{
if (await _tradeService.AddTrade(userId, nameof(GameEnum.PropCode.Goods), MyGoods.goodsName, prop,
count, price,
""))
{
return PoAction.Ok(true);
}
else
{
await _goodsService.UpdateUserGoods(userId, 1, goodsId, count, "寄售失败返还!");
return PoAction.Message("寄售失败,请稍后尝试!");
}
}
else
{
return PoAction.Message("寄售失败,请稍后尝试!");
}
}
else
{
return PoAction.Message("该物品不允许寄售!");
}
}
}

View File

@@ -19,10 +19,11 @@ public class GiveController : ControllerBase
private readonly IUnitUserService _userService; private readonly IUnitUserService _userService;
private readonly IGameChatService _chatService; private readonly IGameChatService _chatService;
private readonly IMessageService _messageService; private readonly IMessageService _messageService;
private readonly IUnitUserAttrService _attrService;
public GiveController(IGameGoodsService goodsService, IGameEquService equService, IUnitUserWeight weightService, public GiveController(IGameGoodsService goodsService, IGameEquService equService, IUnitUserWeight weightService,
IUnitUserRelationService relationService, IUnitUserService userService, IGameChatService chatService, IUnitUserRelationService relationService, IUnitUserService userService, IGameChatService chatService,
IMessageService messageService) IMessageService messageService,IUnitUserAttrService attrService)
{ {
_goodsService = goodsService; _goodsService = goodsService;
_equService = equService; _equService = equService;
@@ -31,6 +32,7 @@ public class GiveController : ControllerBase
_userService = userService; _userService = userService;
_chatService = chatService; _chatService = chatService;
_messageService = messageService; _messageService = messageService;
_attrService = attrService;
} }
/// <summary> /// <summary>
@@ -159,4 +161,286 @@ public class GiveController : ControllerBase
return PoAction.Ok(new { data, total = total.Value }); return PoAction.Ok(new { data, total = total.Value });
} }
/// <summary>
/// 获取赠送物品列表
/// </summary>
/// <param name="npcId"></param>
/// <param name="type"></param>
/// <param name="query"></param>
/// <param name="page"></param>
/// <returns></returns>
[HttpGet]
public async Task<IPoAction> GetGoodsData(string no, int type, string? query, int page)
{
var fromInfo = await _userService.GetUserInfoByUserNo(no);
if (fromInfo == null)
{
return PoAction.Message("玩家不存在!");
}
string userId = StateHelper.userId;
int areaId = StateHelper.areaId;
if (areaId != fromInfo.areaId)
{
return PoAction.Message("玩家不存在!");
}
RefAsync<int> total = 0;
if (type == 0)
{
var data = await _equService.GetUserEquData(userId, 0, query, page, 10, total, 1);
return PoAction.Ok(new
{
userNo = fromInfo.userNo,
nick = fromInfo.nick, data, total = total.Value
});
}
else if (type == 1)
{
List<string> code = new List<string>() { nameof(GoodsEnum.Code.Drug) };
var data = await _goodsService.GetUserGoodsData(userId, code, new List<string>(), query, page, 10, total,
1);
return PoAction.Ok(new
{
userNo = fromInfo.userNo,
nick = fromInfo.nick, data, total = total.Value
});
}
else if (type == 2)
{
List<string> code = new List<string>();
List<string> noCode = new List<string>() { nameof(GoodsEnum.Code.Drug) };
var data = await _goodsService.GetUserGoodsData(userId, code, noCode, query, page, 10, total, 1);
return PoAction.Ok(new
{
userNo = fromInfo.userNo,
nick = fromInfo.nick, data, total = total.Value
});
}
else
{
return PoAction.Ok(new
{
userNo = fromInfo.userNo,
nick = fromInfo.nick, data = new List<string>(), total = total.Value
});
}
}
/// <summary>
/// 赠送物品
/// </summary>
/// <param name="no"></param>
/// <param name="type"></param>
/// <param name="propId"></param>
/// <param name="count"></param>
/// <returns></returns>
[HttpGet]
public async Task<IPoAction> GiveGoods(string no, int type, string propId, int count)
{
string userId = StateHelper.userId;
int myLev = await _attrService.GetUserLev(userId);
if (myLev < 60)
{
return PoAction.Message("等级达到60级才可以赠送哦!");
}
count = count < 1 ? 1 : count;
var fromInfo = await _userService.GetUserInfoByUserNo(no);
if (fromInfo == null)
{
return PoAction.Message("玩家不存在!");
}
int areaId = StateHelper.areaId;
if (areaId != fromInfo.areaId)
{
return PoAction.Message("玩家不存在!");
}
if (type == 0)
{
var equInfo = await _equService.GetUserEquInfo(propId);
if (equInfo == null)
{
return PoAction.Message("装备不存在!");
}
if (equInfo.userId != userId || equInfo.isOn == 1 || equInfo.isLock == 1)
{
return PoAction.Message("该装备锁定或穿戴中!");
}
if (equInfo.isDeal == 0 || equInfo.isGive == 0)
{
return PoAction.Message("该装备无法交易或不可赠送!");
}
//验证负重
if (await _weightService.CheckUserWeight(fromInfo.userId, (int)equInfo.weight) == false)
{
return PoAction.Message("对方负重不足!");
}
if (await _equService.DeductUserEqu(userId, [equInfo], $"赠送给玩家:{fromInfo.userId}"))
{
equInfo.userId = fromInfo.userId;
if (await _equService.AddUserEqu(equInfo, $"收到赠送,来源玩家:{userId}"))
{
var myInfo = await _userService.GetUserInfoByUserId(userId);
string msg = $"收到[{UbbTool.HomeUbb(myInfo.userNo, myInfo.nick)}]赠送的装备[{equInfo.equName}]";
await _chatService.SendChat(fromInfo.userId, (int)fromInfo.areaId, nameof(GameChatEnum.Code.Notice),
msg);
return PoAction.Ok(true);
}
else
{
return PoAction.Message("赠送失败,请稍后尝试!");
}
}
else
{
return PoAction.Message("赠送失败,请稍后尝试!");
}
}
else if (type == 1 || type == 2)
{
int goodsId = Convert.ToInt32(propId);
var MyGoods = await _goodsService.GetUserGoodsInfo(userId, goodsId);
if (MyGoods == null)
{
return PoAction.Message("物品数量不足!");
}
if (MyGoods.count < count)
{
return PoAction.Message("物品数量不足!");
}
if (MyGoods.isDeal == 0 || MyGoods.isGive == 0)
{
return PoAction.Message("该无法无法交易或不可赠送!");
}
int useWeight = (int)MyGoods.weight * count;
if (await _weightService.CheckUserWeight(fromInfo.userId, useWeight) == false)
{
return PoAction.Message("对方负重不足!");
}
if (await _goodsService.UpdateUserGoods(userId, 0, goodsId, count, $"赠送给玩家:{fromInfo.userId}"))
{
if (await _goodsService.UpdateUserGoods(fromInfo.userId, 1, goodsId, count, $"收到赠送,来源玩家:{userId}"))
{
var myInfo = await _userService.GetUserInfoByUserId(userId);
string msg = $"收到[{UbbTool.HomeUbb(myInfo.userNo, myInfo.nick)}]赠送的物品[{MyGoods.goodsName}]×{count}";
await _chatService.SendChat(fromInfo.userId, (int)fromInfo.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>
/// <returns></returns>
[HttpGet]
public async Task<IPoAction> GetUserDouGoods(string no)
{
var fromInfo = await _userService.GetUserInfoByUserNo(no);
if (fromInfo == null)
{
return PoAction.Message("玩家不存在!");
}
string userId = StateHelper.userId;
int areaId = StateHelper.areaId;
if (areaId != fromInfo.areaId)
{
return PoAction.Message("玩家不存在!");
}
var data = await _goodsService.GetUserGoodsData(userId, nameof(GoodsEnum.Code.Tease));
return PoAction.Ok(new
{
userNo = fromInfo.userNo,
nick = fromInfo.nick,
data = data
});
}
/// <summary>
/// 使用逗物品
/// </summary>
/// <param name="no"></param>
/// <param name="goodsId"></param>
/// <param name="count"></param>
/// <returns></returns>
[HttpGet]
public async Task<IPoAction> UseDou(string no,int goodsId, int count)
{
var fromInfo = await _userService.GetUserInfoByUserNo(no);
if (fromInfo == null)
{
return PoAction.Message("玩家不存在!");
}
string userId = StateHelper.userId;
int areaId = StateHelper.areaId;
if (areaId != fromInfo.areaId)
{
return PoAction.Message("玩家不存在!");
}
count = count < 1 ? 1 : count;
var myGoods = await _goodsService.GetUserGoodsInfo(userId, goodsId);
if (myGoods == null)
{
return PoAction.Message("您暂无该道具!");
}
if (myGoods.count < count)
{
return PoAction.Message("您的道具不足!");
}
if (myGoods.code != nameof(GoodsEnum.Code.Tease))
{
return PoAction.Message("该道具无法使用!");
}
if (await _goodsService.UpdateUserGoods(userId, 0, goodsId, count, "使用道具"))
{
var goodsInfo = await _goodsService.GetGoodsInfo(goodsId);
UserStateModel stateConfig = JsonConvert.DeserializeObject<UserStateModel>(goodsInfo.content);
if(await _attrService.AddUserState(fromInfo.userId, goodsInfo.goodsId.ToString(), stateConfig.name,
stateConfig.scene, stateConfig.tips, stateConfig.attr, stateConfig.time, count))
{
var myInfo = await _userService.GetUserInfoByUserId(userId);
string msg = $"[{UbbTool.HomeUbb(myInfo.userNo, myInfo.nick)}]对您使用了[{goodsInfo.goodsName}]×{count}";
await _chatService.SendChat(fromInfo.userId, (int)fromInfo.areaId, nameof(GameChatEnum.Code.Notice),
msg);
}
return PoAction.Ok(true);
}
else
{
return PoAction.Message("使用失败,请稍后尝试!");
}
}
} }

View File

@@ -134,7 +134,7 @@
<Abutton @click="LockEqu">{{ equData.isLock == 0 ? "绑定" : "解绑" }}</Abutton><br> <Abutton @click="LockEqu">{{ equData.isLock == 0 ? "绑定" : "解绑" }}</Abutton><br>
</span> </span>
<span v-if="equData.isOn == 0 && equData.isDeal == 1"> <span v-if="equData.isOn == 0 && equData.isDeal == 1">
<Abar href="/">寄售</Abar><br> <Abutton @click="saleState = true">寄售</Abutton><br>
</span> </span>
<!-- <span> <!-- <span>
<Abutton>个性化</Abutton><br> <Abutton>个性化</Abutton><br>
@@ -169,9 +169,20 @@
</div> </div>
</GamePopup> </GamePopup>
<!-- 寄售 -->
<GamePopup v-model:show="saleState" title="【寄售装备】" style="width: 60%;">
<div class="common" style="margin-top: 10px;">
装备名称:<span v-html="EquTool.ConvertEquName(equData, 0)"></span><br>
<span style="font-size: 16px;">寄售价格:</span><input type="number" class="search-ipt" v-model="salePrice" />铜贝
</div>
<div class="common" style="text-align: center;">
<button class="ipt-btn" name="serch" @click="SaleOk" style="margin-top: 15px;">寄售</button>
</div>
</GamePopup>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
definePageMeta({ definePageMeta({
layout: layout.default, layout: layout.default,
middleware: 'page-loading' middleware: 'page-loading'
@@ -292,4 +303,20 @@ const ApprEqu = async () => {
return true; return true;
}); });
} }
const saleState = ref(false);
const salePrice = ref(1);
const SaleOk = async () => {
MessageExtend.LoadingToast("寄售中...");
let result = await TradeService.Trade(0, ueId, salePrice.value, 1);
MessageExtend.LoadingClose();
if (result.code == 0) {
MessageExtend.ShowDialogEvent("寄售装备", "寄售成功!", () => {
PageExtend.RedirectTo("/user/bag");
});
}
else {
MessageExtend.ShowDialog("寄售装备", result.msg);
}
}
</script> </script>

View File

@@ -3,7 +3,7 @@
<div class="common" v-if="data.img != ''"> <div class="common" v-if="data.img != ''">
<Aimage :url="data.img" _alt="."></Aimage> <Aimage :url="data.img" _alt="."></Aimage>
</div> </div>
名称:{{ data.goodsName }} <Abar href="/" v-if="count > 0">寄售</Abar><br> 名称:{{ data.goodsName }}<br>
<div class="common" v-if="data.code == 'Card'"> <div class="common" v-if="data.code == 'Card'">
等级:{{ data.lev }} 等级:{{ data.lev }}
</div> </div>
@@ -29,6 +29,9 @@
<div class="common" v-if="useState == 3"> <div class="common" v-if="useState == 3">
<Abutton @click="btnChoice">使用物品</Abutton> <Abutton @click="btnChoice">使用物品</Abutton>
</div> </div>
<div class="common" v-if="data.isDeal == 1">
<Abutton @click="saleState=true">寄售</Abutton>
</div>
</div> </div>
@@ -78,6 +81,18 @@
</div> </div>
</div> </div>
</GamePopup> </GamePopup>
<!-- 寄售 -->
<GamePopup v-model:show="saleState" title="【寄售物品】" style="width: 60%;">
<div class="common" style="margin-top: 10px;">
物品名称{{ data.goodsName }}<br>
物品数量{{ count }}<br>
<span style="font-size: 16px;">寄售价格:</span><input type="number" class="search-ipt" v-model="salePrice" />铜贝<br>
<span style="font-size: 16px;">寄售数量:</span><input type="number" class="search-ipt" v-model="saleCount" />
</div>
<div class="common" style="text-align: center;">
<button class="ipt-btn" name="serch" @click="SaleOk" style="margin-top: 15px;">寄售</button>
</div>
</GamePopup>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
@@ -183,4 +198,21 @@ const btnChoiceOk = async (id: number) => {
} }
} }
const saleState = ref(false);
const salePrice = ref(1);
const saleCount = ref(1);
const SaleOk = async () => {
MessageExtend.LoadingToast("寄售中...");
let result = await TradeService.Trade(1, goodsId, salePrice.value, saleCount.value);
MessageExtend.LoadingClose();
if (result.code == 0) {
saleState.value =false;
await BindData();
MessageExtend.Notify("寄售成功!","success");
}
else {
MessageExtend.ShowDialog("寄售装备", result.msg);
}
}
</script> </script>

View File

@@ -1 +1,157 @@
<template></template> <template>
<div class="module-title">
赠送道具
</div>
<div class="module-content">
<div class="common">
赠送给<Abar :href='"/user/user?no=" + userNo'>{{ nick }}</Abar>(ID:{{ userNo }})
</div>
<div class="content">
选择出售
<Acheak @click="Change('0')" :on-value="type" on-cheak="0">装备</Acheak>.
<Acheak @click="Change('1')" :on-value="type" on-cheak="1">药品</Acheak>.
<Acheak @click="Change('2')" :on-value="type" on-cheak="2">物品</Acheak>
</div>
<div class="common serch">
搜索内容<input type="text" class="search-ipt" v-model="serch">&nbsp;
<button class="ipt-btn" name="serch" @click="refData">搜索</button>
</div>
<div class="content">
<div class="common" v-if="type == '0'">
<div class="item" v-for="(item, index) in data" :key="index">
{{ PageExtend.GetPageIndex(currentPage, 10, index + 1) }}.
<Abar :href='"/prop/equ?ue=" + item.ueId'>{{ item.equName }}({{ item.lev }})</Abar>
[<Abutton @click="SaleView(item)">赠送</Abutton>]
</div>
</div>
<div class="common" v-if="type == '1'">
<div class="item" v-for="(item, index) in data" :key="index">
{{ PageExtend.GetPageIndex(currentPage, 10, index + 1) }}.
<Abar :href='"/prop/goods?id=" + item.goodsId'>{{ item.goodsName }}({{ item.count }})</Abar>
[<Abutton @click="SaleView(item)">赠送</Abutton>]
</div>
</div>
<div class="common" v-if="type == '2'">
<div class="item" v-for="(item, index) in data" :key="index">
{{ PageExtend.GetPageIndex(currentPage, 10, index + 1) }}.
<span v-if="item.code == 'Card'">
<Abar :href='"/prop/goods?id=" + item.goodsId'>{{ item.goodsName }}({{ item.count }})</Abar>
</span>
<span v-else>
<Abar :href='"/prop/goods?id=" + item.goodsId'>{{ item.goodsName }}({{ item.count }})</Abar>
</span>
[<Abutton @click="SaleView(item)">赠送</Abutton>]
</div>
</div>
<span v-if="data.length == 0">暂无.</span>
</div>
<div class="content">
<Pagination :currentPage="currentPage" :limit="10" :total="total" @pageChange="handlePageChange" />
</div>
</div>
<!-- 购买 -->
<GamePopup v-model:show="showSale" title="【赠送物品】">
<!-- 自定义内容 -->
<div class="common" v-if="type == '0'">
装备名称{{ showGoods.equName }}<br>
装备等级{{ showGoods.lev }}
</div>
<div class="common" v-else>
物品名称{{ showGoods.goodsName }}<br>
背包数量{{ showGoods.count }}<br>
赠送数量<input type="number" class="search-ipt" v-model="count"><br>
</div>
<div class="common" style="text-align: center;">
<button class="ipt-btn" name="serch" @click="SaleOk" style="margin-top: 15px;">赠送</button>
</div>
</GamePopup>
</template>
<script setup lang="ts">
definePageMeta({
layout: layout.default,
middleware: 'page-loading'
})
const currentPage = ref<number>(1);
const total = ref<number>(0);
const data = ref<Array<any>>([]);
const serch = ref('');
const type = ref('0');
const userNo = ref('');
const nick = ref('');
let no = PageExtend.QueryString("no");
onMounted(async () => {
try {
await BindData();
}
finally {
PageLoading.Close();
}
})
const BindData = async (): Promise<void> => {
let result = await GiveService.GetGoodsData(no, Number(type.value), serch.value, currentPage.value);
if (result.code == 0) {
data.value = result.data.data;
total.value = result.data.total;
userNo.value = result.data.userNo;
nick.value = result.data.nick;
}
else {
MessageExtend.ShowDialog("提示", result.msg);
}
};
const refData = async () => {
currentPage.value = 1;
await BindData();
}
/**翻页 */
const handlePageChange = async (page: number): Promise<void> => {
currentPage.value = page;
await BindData();
};
const Change = async (_type: string): Promise<void> => {
type.value = _type;
await BindData();
};
//赠送
const showSale = ref(false);
const showGoods = ref<any>({});
const count = ref(1);
const SaleView = (info: any) => {
showGoods.value = info;
showSale.value = true;
count.value = 1;
}
const SaleOk = async (): Promise<void> => {
if (type.value != '0' && (count.value < 1 || count.value > showGoods.value.count)) {
MessageExtend.ShowToast("赠送数量不正确.");
return;
}
MessageExtend.LoadingToast("赠送中...");
let propId = '';
if (type.value == '0') {
propId = showGoods.value.ueId;
}
else {
propId = showGoods.value.goodsId;
}
let result = await GiveService.GiveGoods(no, Number(type.value), propId, count.value);
MessageExtend.LoadingClose();
if (result.code == 0) {
showSale.value = false;
MessageExtend.Notify("赠送成功!", "success");
await BindData();
}
else {
MessageExtend.ShowDialog("提示", result.msg);
}
};
</script>

View File

@@ -6,8 +6,6 @@
负重{{ bagInfo.onWeight }}/{{ bagInfo.maxWeight }}&nbsp;<span v-if="bagInfo.onWeight > bagInfo.maxWeight" 负重{{ bagInfo.onWeight }}/{{ bagInfo.maxWeight }}&nbsp;<span v-if="bagInfo.onWeight > bagInfo.maxWeight"
style="color: red;font-weight: bold;">!</span><br /> style="color: red;font-weight: bold;">!</span><br />
{{ GameTool.FormatCopper(bagInfo.copper) }}<br /> {{ GameTool.FormatCopper(bagInfo.copper) }}<br />
<Abar href="/">交易记录</Abar><br>
<Abar href="/">赠送记录</Abar>
</div> </div>
<div class="content"> <div class="content">
<div class="common" style=""> <div class="common" style="">

View File

@@ -1 +1,82 @@
<template></template> <template>
<div class="module-title">
逗一下
</div>
<div class="module-content">
<div class="common">
逗Ta<Abar :href='"/user/user?no=" + data.userNo'>{{ data.nick }}</Abar>(ID:{{ data.userNo }})
</div>
<div class="item" v-for="(item, index) in goods" :key="index">
{{ index + 1 }}.<Abar :href='"/prop/goods?id=" + item.goodsId'>{{ item.goodsName }}</Abar>({{ item.count }})
[<Abutton @click="showView(item)">使用</Abutton>]
</div>
<span v-if="goods.length == 0">暂无礼物.</span>
</div>
<GamePopup v-model:show="showInfo" title="【赠送礼物】" style="width: 50%;">
<div class="common" style="margin-top: 10px;">
道具名称{{ onShow.goodsName }}<br>
道具数量{{ onShow.count }}<br>
<span style="font-size: 16px;">使用数量:</span><input type="number" class="search-ipt" v-model="giveCount">
</div>
<div class="common" style="text-align: center;">
<button class="ipt-btn" name="serch" @click="GiveOk" style="margin-top: 15px;">使用</button>
</div>
</GamePopup>
</template>
<script setup lang="ts">
definePageMeta({
layout: layout.default,
middleware: middleware.loading
})
const data = ref<any>({});
const goods = ref<Array<any>>([]);
const showInfo = ref(false);
const onShow = ref<any>({});
const giveCount = ref(1);
onMounted(async () => {
try {
await BindData();
}
finally {
PageLoading.Close();
}
})
const BindData = async () => {
let no = PageExtend.QueryString("no");
let result = await GiveService.GetUserDouGoods(no);
if (result.code == 0) {
data.value = result.data;
goods.value = result.data.data;
}
else {
MessageExtend.ShowDialog("赠送礼物", result.msg);
}
console.log(result);
}
const showView = (data: any) => {
showInfo.value = true;
giveCount.value = 1;
onShow.value = data;
}
const GiveOk = async () => {
let no = PageExtend.QueryString("no");
MessageExtend.LoadingToast("使用中...");
let result = await GiveService.UseDou(no, onShow.value.goodsId, giveCount.value);
MessageExtend.LoadingClose();
if (result.code == 0) {
showInfo.value = false;
await BindData();
MessageExtend.Notify("使用成功!", "success");
}
else {
MessageExtend.ShowDialog("提示", result.msg);
}
}
</script>

View File

@@ -1,9 +1,9 @@
<template> <template>
<div class="content"> <div class="content">
<Abar :href='"/user/message/read?id=" + userData.userNo'>私聊</Abar>. <Abar <Abar :href='"/user/message/read?id=" + userData.userNo'>私聊</Abar>. <Abar
:href='"/user/gift/give?no=" + userData.userNo'>送礼物</Abar>. <Abar href="/user/interact/dou">逗一下</Abar><br /> :href='"/user/gift/give?no=" + userData.userNo'>送礼物</Abar>. <Abar :href='"/user/interact/dou?no="+userData.userNo'>逗一下</Abar><br />
<Abar href="/user/master/add">拜师</Abar>. <Abar :href='"/trade/user?no=" + userData.userNo'>交易</Abar>. <Abar <Abar href="/user/master/add">拜师</Abar>. <Abar :href='"/trade/user?no=" + userData.userNo'>交易</Abar>. <Abar
href="/user/bag/give">送道具</Abar><br> :href='"/user/bag/give?no="+userData.userNo'>送道具</Abar><br>
<Abutton @click="FriendHandle">{{ isFriend ? "删除好友" : "加好友" }}</Abutton> <Abutton @click="FriendHandle">{{ isFriend ? "删除好友" : "加好友" }}</Abutton>
<span v-if="isEnemy == false"> <span v-if="isEnemy == false">
.<Abutton @click="AddEnemy">加仇人</Abutton> .<Abutton @click="AddEnemy">加仇人</Abutton>

View File

@@ -0,0 +1,9 @@
export class TradeService {
/**
* 寄售物品
* GET /Trade/Trade
*/
static async Trade(type: number, prop: string, price: number, count: number) {
return await ApiService.Request("get", "/Trade/Trade", { type, prop, price, count });
}
}

View File

@@ -22,4 +22,36 @@ export class GiveService {
static async GetGiftLog(no: string, page: number) { static async GetGiftLog(no: string, page: number) {
return await ApiService.Request("get", "/User/Give/GetGiftLog", { no, page }); return await ApiService.Request("get", "/User/Give/GetGiftLog", { no, page });
} }
/**
* 获取赠送物品列表
* GET /User/Give/GetGoodsData
*/
static async GetGoodsData(no: string, type: number, query: string, page: number) {
return await ApiService.Request("get", "/User/Give/GetGoodsData", { no, type, query, page });
}
/**
* 赠送物品
* GET /User/Give/GiveGoods
*/
static async GiveGoods(no: string, type: number, propId: string, count: number) {
return await ApiService.Request("get", "/User/Give/GiveGoods", { no, type, propId, count });
}
/**
* 逗一下物品列表
* GET /User/Give/GetUserDouGoods
*/
static async GetUserDouGoods(no: string) {
return await ApiService.Request("get", "/User/Give/GetUserDouGoods", { no });
}
/**
* 使用逗物品
* GET /User/Give/UseDou
*/
static async UseDou(no: string, goodsId: number, count: number) {
return await ApiService.Request("get", "/User/Give/UseDou", { no, goodsId, count });
}
} }