feat: 完成

This commit is contained in:
橙子
2024-10-17 00:27:20 +08:00
parent cb1bac25a3
commit 260d87c97e
15 changed files with 361 additions and 59 deletions

View File

@@ -7,6 +7,7 @@ using Volo.Abp.Application.Services;
using Yi.Framework.DigitalCollectibles.Application.Contracts.Dtos.Collectibles;
using Yi.Framework.DigitalCollectibles.Application.Contracts.Dtos.Market;
using Yi.Framework.DigitalCollectibles.Domain.Entities;
using Yi.Framework.DigitalCollectibles.Domain.Shared.Consts;
using Yi.Framework.SqlSugarCore.Abstractions;
namespace Yi.Framework.DigitalCollectibles.Application.Services;
@@ -35,12 +36,31 @@ public class CollectiblesService : ApplicationService
CollectiblesUserGetInput input)
{
RefAsync<int> total = 0;
var entities = await _collectiblesUserStoreRepository._DbQueryable.WhereIF(
var output = await _collectiblesUserStoreRepository._DbQueryable.WhereIF(
input.StartTime is not null && input.EndTime is not null,
x => x.CreationTime >= input.StartTime && x.CreationTime <= input.EndTime)
.OrderByDescending(x => x.CreationTime)
u => u.CreationTime >= input.StartTime && u.CreationTime <= input.EndTime)
.LeftJoin<CollectiblesAggregateRoot>((u, c) => u.CollectiblesId == c.Id)
.GroupBy((u, c) => u.CollectiblesId)
.Select((u, c) =>
new CollectiblesUserGetOutputDto
{
Id = c.Id,
Collectibles = new CollectiblesDto
{
Id = c.Id,
Code = c.Code,
Name = c.Name,
Describe = c.Describe,
ValueNumber = c.ValueNumber,
Url = c.Url,
Rarity = c.Rarity,
FindTotal = c.FindTotal,
OrderNum = c.OrderNum
},
Number = SqlFunc.AggregateCount(u.CollectiblesId)
})
.OrderBy(dto => dto.Collectibles.OrderNum)
.ToPageListAsync(input.SkipCount, input.MaxResultCount, total);
var output = entities.Adapt<List<CollectiblesUserGetOutputDto>>();
return new PagedResultDto<CollectiblesUserGetOutputDto>(total, output);
}
}

View File

@@ -1,23 +1,33 @@
using Mapster;
using Microsoft.AspNetCore.Authorization;
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;
using Yi.Framework.DigitalCollectibles.Domain.Managers;
using Yi.Framework.DigitalCollectibles.Domain.Shared.Consts;
using Yi.Framework.SqlSugarCore.Abstractions;
namespace Yi.Framework.DigitalCollectibles.Application.Services;
/// <summary>
/// 市场应用服务
/// 交易市场应用服务
/// </summary>
public class MarketService:ApplicationService
public class MarketService : ApplicationService
{
private readonly ISqlSugarRepository<MarketGoodsAggregateRoot> _marketGoodsRepository;
public MarketService(ISqlSugarRepository<MarketGoodsAggregateRoot> marketGoodsRepository)
private readonly MarketManager _marketManager;
public MarketService(ISqlSugarRepository<MarketGoodsAggregateRoot> marketGoodsRepository,
MarketManager marketManager)
{
_marketGoodsRepository = marketGoodsRepository;
_marketManager = marketManager;
}
/// <summary>
@@ -28,12 +38,56 @@ public class MarketService:ApplicationService
public async Task<PagedResultDto<MarketGetListOutputDto>> GetListAsync(MarketGetListInput input)
{
RefAsync<int> total = 0;
var entities = await _marketGoodsRepository._DbQueryable.WhereIF(
var output = await _marketGoodsRepository._DbQueryable.WhereIF(
input.StartTime is not null && input.EndTime is not null,
x => x.CreationTime >= input.StartTime && x.CreationTime <= input.EndTime)
.OrderByDescending(x => x.CreationTime)
m => m.CreationTime >= input.StartTime && m.CreationTime <= input.EndTime)
.LeftJoin<CollectiblesAggregateRoot>((m, c) => m.CollectiblesId == c.Id)
.Select((m, c) =>
new MarketGetListOutputDto
{
Id = m.Id,
CreationTime = m.CreationTime,
SellUserId = m.SellUserId,
SellNumber = m.SellNumber,
Collectibles = new CollectiblesDto
{
Id = c.Id,
Code = c.Code,
Name = c.Name,
Describe = c.Describe,
ValueNumber = c.ValueNumber,
Url = c.Url,
Rarity =c.Rarity,
FindTotal = c.FindTotal,
OrderNum = c.OrderNum
}
}
)
.OrderByDescending(dto => dto.CreationTime)
.ToPageListAsync(input.SkipCount, input.MaxResultCount, total);
var output = entities.Adapt<List<MarketGetListOutputDto>>();
return new PagedResultDto<MarketGetListOutputDto>(total, output);
}
/// <summary>
/// 上架商品
/// </summary>
[HttpPost("shelved")]
[Authorize]
public async Task ShelvedGoodsAsync(ShelvedGoodsDto input)
{
await _marketManager.ShelvedGoodsAsync(CurrentUser.GetId(), input.CollectiblesId, input.Number, input.Mmoney);
}
/// <summary>
/// 购买商品
/// </summary>
[HttpPut("purchase")]
[Authorize]
public async Task PurchaseGoodsAsync(PurchaseGoodsDto input)
{
await _marketManager.PurchaseGoodsAsync(CurrentUser.GetId(),input.MarketGoodsId, input.Number);
}
}

View File

@@ -8,10 +8,22 @@ using Yi.Framework.DigitalCollectibles.Domain.Managers;
namespace Yi.Framework.DigitalCollectibles.Application.Services;
/// <summary>
/// 矿池应用服务
/// </summary>
public class MiningPoolService : ApplicationService
{
private readonly MiningPoolManager _manager;
/// <summary>
/// 内测-白嫖-获取自动挖矿卡
/// </summary>
[HttpPost("mining-pool/on-hook")]
public async Task GetOnHookAsync()
{
await _manager.GetOnHookAsync(CurrentUser.GetId());
}
/// <summary>
/// 获取矿池状态
/// </summary>