feat: 新增用户信息
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
namespace Yi.Framework.DigitalCollectibles.Application.Contracts.Dtos.Collectibles;
|
||||
|
||||
public class CollectiblesAccountInfoDto
|
||||
{
|
||||
public decimal TotalValue { get; set; }
|
||||
}
|
||||
@@ -6,5 +6,5 @@ public class ShelvedGoodsDto
|
||||
public Guid CollectiblesId { get; set; }
|
||||
public int Number { get; set; }
|
||||
|
||||
public decimal Mmoney { get; set; }
|
||||
public decimal Money { get; set; }
|
||||
}
|
||||
@@ -4,6 +4,7 @@ using Microsoft.AspNetCore.Mvc;
|
||||
using SqlSugar;
|
||||
using Volo.Abp.Application.Dtos;
|
||||
using Volo.Abp.Application.Services;
|
||||
using Volo.Abp.Users;
|
||||
using Yi.Framework.DigitalCollectibles.Application.Contracts.Dtos.Collectibles;
|
||||
using Yi.Framework.DigitalCollectibles.Application.Contracts.Dtos.Market;
|
||||
using Yi.Framework.DigitalCollectibles.Domain.Entities;
|
||||
@@ -24,6 +25,23 @@ public class CollectiblesService : ApplicationService
|
||||
_collectiblesUserStoreRepository = collectiblesUserStoreRepository;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取该用户的信息
|
||||
/// </summary>
|
||||
[HttpGet("collectibles/account")]
|
||||
[Authorize]
|
||||
public async Task<CollectiblesAccountInfoDto> GetAccountInfoAsync()
|
||||
{
|
||||
var userId = CurrentUser.GetId();
|
||||
var totalValue = await _collectiblesUserStoreRepository._DbQueryable.Where(store => store.UserId == userId)
|
||||
.LeftJoin<CollectiblesAggregateRoot>((store, c) => store.CollectiblesId == c.Id)
|
||||
.SumAsync((store, c) => c.ValueNumber);
|
||||
return new CollectiblesAccountInfoDto
|
||||
{
|
||||
TotalValue = totalValue
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取当前用户的藏品
|
||||
/// </summary>
|
||||
@@ -40,7 +58,7 @@ public class CollectiblesService : ApplicationService
|
||||
input.StartTime is not null && input.EndTime is not null,
|
||||
u => u.CreationTime >= input.StartTime && u.CreationTime <= input.EndTime)
|
||||
.LeftJoin<CollectiblesAggregateRoot>((u, c) => u.CollectiblesId == c.Id)
|
||||
.OrderBy((u,c) => c.OrderNum)
|
||||
.OrderBy((u, c) => c.OrderNum)
|
||||
.GroupBy((u, c) => u.CollectiblesId)
|
||||
.Select((u, c) =>
|
||||
new CollectiblesUserGetOutputDto
|
||||
|
||||
@@ -52,6 +52,7 @@ public class MarketService : ApplicationService
|
||||
CreationTime = m.CreationTime,
|
||||
SellUserId = m.SellUserId,
|
||||
SellNumber = m.SellNumber,
|
||||
UnitPrice=m.UnitPrice,
|
||||
Collectibles = new CollectiblesDto
|
||||
{
|
||||
Id = c.Id,
|
||||
@@ -75,17 +76,17 @@ public class MarketService : ApplicationService
|
||||
/// <summary>
|
||||
/// 上架商品
|
||||
/// </summary>
|
||||
[HttpPost("shelved")]
|
||||
[HttpPost("market/shelved")]
|
||||
[Authorize]
|
||||
public async Task ShelvedGoodsAsync(ShelvedGoodsDto input)
|
||||
{
|
||||
await _marketManager.ShelvedGoodsAsync(CurrentUser.GetId(), input.CollectiblesId, input.Number, input.Mmoney);
|
||||
await _marketManager.ShelvedGoodsAsync(CurrentUser.GetId(), input.CollectiblesId, input.Number, input.Money);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 购买商品
|
||||
/// </summary>
|
||||
[HttpPut("purchase")]
|
||||
[HttpPut("market/purchase")]
|
||||
[Authorize]
|
||||
public async Task PurchaseGoodsAsync(PurchaseGoodsDto input)
|
||||
{
|
||||
|
||||
@@ -9,11 +9,11 @@ namespace Yi.Framework.DigitalCollectibles.Domain.Shared.Consts;
|
||||
/// </summary>
|
||||
public enum RarityEnum
|
||||
{
|
||||
[Display(Name = "普通")][Probability(0.8f)] Ordinary = 0,
|
||||
[Display(Name = "高级")][Probability(0.1f)] Senior = 1,
|
||||
[Display(Name = "稀有")][Probability(0.06f)] Rare = 2,
|
||||
[Display(Name = "珍品")][Probability(0.039f)] Gem = 3,
|
||||
[Display(Name = "传说")][Probability(0.001f)] Legend = 4
|
||||
[Display(Name = "普通")][Probability(0.6f)] Ordinary = 0,
|
||||
[Display(Name = "高级")][Probability(0.25f)] Senior = 1,
|
||||
[Display(Name = "稀有")][Probability(0.1f)] Rare = 2,
|
||||
[Display(Name = "珍品")][Probability(0.04f)] Gem = 3,
|
||||
[Display(Name = "传说")][Probability(0.01f)] Legend = 4
|
||||
}
|
||||
|
||||
public static class RarityEnumExtensions
|
||||
|
||||
@@ -42,11 +42,11 @@ public class MarketManager : DomainService
|
||||
.Where(x => x.CollectiblesId == collectiblesId).ToListAsync();
|
||||
if (collectiblesList.Count < number)
|
||||
{
|
||||
throw new UserFriendlyException($"您的藏品不足{number}个,上架失败");
|
||||
throw new UserFriendlyException($"您的非上架该藏品不足{number}个,上架失败");
|
||||
}
|
||||
|
||||
//上架收藏品
|
||||
var shelvedcollectibles = collectiblesList.Take(2);
|
||||
var shelvedcollectibles = collectiblesList.Take(number);
|
||||
foreach (var store in shelvedcollectibles)
|
||||
{
|
||||
store.ShelvedMarket();
|
||||
@@ -99,7 +99,7 @@ public class MarketManager : DomainService
|
||||
var marketTaxRate = decimal.Parse(await _settingProvider.GetOrNullAsync("MarketTaxRate"));
|
||||
await _localEventBus.PublishAsync(new MoneyChangeEventArgs() { UserId = userId, Number = number*(1-marketTaxRate) },false);
|
||||
|
||||
//3-出售者删除对应库存,购买者新增对应库存
|
||||
//3-出售者删除对应库存,购买者新增对应库存(只需更改用户者即可)
|
||||
var collectiblesList = await _collectiblesUserStoreRepository._DbQueryable.Where(x => x.IsAtMarketing == true)
|
||||
.Where(x => x.UserId == marketGoods.SellUserId)
|
||||
.Where(x => x.CollectiblesId == marketGoods.CollectiblesId)
|
||||
|
||||
Reference in New Issue
Block a user