feat: 新增记录
This commit is contained in:
@@ -0,0 +1,37 @@
|
|||||||
|
using Volo.Abp.Application.Dtos;
|
||||||
|
using Yi.Framework.DigitalCollectibles.Application.Contracts.Dtos.Collectibles;
|
||||||
|
|
||||||
|
namespace Yi.Framework.DigitalCollectibles.Application.Contracts.Dtos.Records;
|
||||||
|
|
||||||
|
public class MarketRecordDto:EntityDto<Guid>
|
||||||
|
{
|
||||||
|
public DateTime CreationTime { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 出售数量
|
||||||
|
/// </summary>
|
||||||
|
public int SellNumber{ get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 出售者用户id
|
||||||
|
/// </summary>
|
||||||
|
public Guid SellUserId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 购买者用户id
|
||||||
|
/// </summary>
|
||||||
|
public Guid BuyId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 出售单价
|
||||||
|
/// </summary>
|
||||||
|
public decimal UnitPrice{ get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 实际到手价格(扣除税收)
|
||||||
|
/// </summary>
|
||||||
|
public decimal RealTotalPrice{ get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 交易的藏品
|
||||||
|
/// </summary>
|
||||||
|
public CollectiblesDto Collectibles { get; set; }
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
using Volo.Abp.Application.Dtos;
|
||||||
|
using Yi.Framework.DigitalCollectibles.Application.Contracts.Dtos.Collectibles;
|
||||||
|
|
||||||
|
namespace Yi.Framework.DigitalCollectibles.Application.Contracts.Dtos.Records;
|
||||||
|
|
||||||
|
public class MiningPoolRecordDto:EntityDto<Guid>
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 用户id
|
||||||
|
/// </summary>
|
||||||
|
public Guid UserId { get; set; }
|
||||||
|
|
||||||
|
public DateTime CreationTime { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 挖到的藏品
|
||||||
|
/// </summary>
|
||||||
|
public CollectiblesDto Collectibles { get; set; }
|
||||||
|
}
|
||||||
@@ -0,0 +1,83 @@
|
|||||||
|
using Microsoft.AspNetCore.Authorization;
|
||||||
|
using SqlSugar;
|
||||||
|
using Volo.Abp.Application.Dtos;
|
||||||
|
using Volo.Abp.Application.Services;
|
||||||
|
using Volo.Abp.Users;
|
||||||
|
using Yi.Framework.Ddd.Application.Contracts;
|
||||||
|
using Yi.Framework.DigitalCollectibles.Application.Contracts.Dtos.Collectibles;
|
||||||
|
using Yi.Framework.DigitalCollectibles.Application.Contracts.Dtos.Records;
|
||||||
|
using Yi.Framework.DigitalCollectibles.Domain.Entities;
|
||||||
|
using Yi.Framework.DigitalCollectibles.Domain.Entities.Record;
|
||||||
|
using Yi.Framework.SqlSugarCore.Abstractions;
|
||||||
|
|
||||||
|
namespace Yi.Framework.DigitalCollectibles.Application.Services.Record;
|
||||||
|
|
||||||
|
public class CollectiblesServiceRecordService : ApplicationService
|
||||||
|
{
|
||||||
|
private readonly ISqlSugarRepository<MiningPoolRecordAggregateRoot> _miningPoolRecordRepository;
|
||||||
|
private readonly ISqlSugarRepository<MarketRecordAggregateRoot> _marketRecordRepository;
|
||||||
|
public CollectiblesServiceRecordService(ISqlSugarRepository<MiningPoolRecordAggregateRoot> miningPoolRecordRepository)
|
||||||
|
{
|
||||||
|
_miningPoolRecordRepository = miningPoolRecordRepository;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取当前用户的挖矿记录
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="input"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[Authorize]
|
||||||
|
public async Task<PagedResultDto<MiningPoolRecordDto>> GetMiningPoolAsync(PagedAllResultRequestDto input)
|
||||||
|
{
|
||||||
|
RefAsync<int> total = 0;
|
||||||
|
var userId = CurrentUser.GetId();
|
||||||
|
var output = await _miningPoolRecordRepository._DbQueryable.WhereIF(input.StartTime is not null && input.EndTime is not null,
|
||||||
|
x => x.CreationTime >= input.StartTime && x.CreationTime <= input.EndTime)
|
||||||
|
.Where(x => x.UserId == userId)
|
||||||
|
.OrderByDescending(x => x.CreationTime)
|
||||||
|
.LeftJoin<CollectiblesAggregateRoot>((x, c) => x.CollectiblesId==c.Id)
|
||||||
|
.Select((x, c) =>
|
||||||
|
new MiningPoolRecordDto
|
||||||
|
{
|
||||||
|
Id = x.Id,
|
||||||
|
Collectibles = new CollectiblesDto()
|
||||||
|
{
|
||||||
|
Id = c.Id
|
||||||
|
}
|
||||||
|
},true
|
||||||
|
)
|
||||||
|
.ToPageListAsync(input.SkipCount, input.MaxResultCount, total);
|
||||||
|
|
||||||
|
return new PagedResultDto<MiningPoolRecordDto>(total,output);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取当前用户的交易记录
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="input"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[Authorize]
|
||||||
|
public async Task<PagedResultDto<MarketRecordDto>> GetMarketAsync(PagedAllResultRequestDto input)
|
||||||
|
{
|
||||||
|
RefAsync<int> total = 0;
|
||||||
|
var userId = CurrentUser.GetId();
|
||||||
|
var output = await _marketRecordRepository._DbQueryable.WhereIF(input.StartTime is not null && input.EndTime is not null,
|
||||||
|
x => x.CreationTime >= input.StartTime && x.CreationTime <= input.EndTime)
|
||||||
|
.Where(x => x.SellUserId == userId)
|
||||||
|
.OrderByDescending(x => x.CreationTime)
|
||||||
|
.LeftJoin<CollectiblesAggregateRoot>((x, c) => x.CollectiblesId==c.Id)
|
||||||
|
.Select((x, c) =>
|
||||||
|
new MarketRecordDto
|
||||||
|
{
|
||||||
|
Id = x.Id,
|
||||||
|
Collectibles = new CollectiblesDto()
|
||||||
|
{
|
||||||
|
Id = c.Id
|
||||||
|
}
|
||||||
|
},true
|
||||||
|
)
|
||||||
|
.ToPageListAsync(input.SkipCount, input.MaxResultCount, total);
|
||||||
|
|
||||||
|
return new PagedResultDto<MarketRecordDto>(total,output);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
using SqlSugar;
|
||||||
|
using Volo.Abp.Domain.Entities.Auditing;
|
||||||
|
|
||||||
|
namespace Yi.Framework.DigitalCollectibles.Domain.Entities.Record;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 交易记录
|
||||||
|
/// </summary>
|
||||||
|
[SugarTable("DC_MarketRecord")]
|
||||||
|
public class MarketRecordAggregateRoot:FullAuditedAggregateRoot<Guid>
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 出售者用户id
|
||||||
|
/// </summary>
|
||||||
|
public Guid SellUserId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 购买者用户id
|
||||||
|
/// </summary>
|
||||||
|
public Guid BuyId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 藏品id
|
||||||
|
/// </summary>
|
||||||
|
public Guid CollectiblesId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 出售数量
|
||||||
|
/// </summary>
|
||||||
|
public int SellNumber{ get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 出售单价
|
||||||
|
/// </summary>
|
||||||
|
public decimal UnitPrice{ get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 实际到手价格(扣除税收)
|
||||||
|
/// </summary>
|
||||||
|
public decimal RealTotalPrice{ get; set; }
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
using SqlSugar;
|
||||||
|
using Volo.Abp.Domain.Entities.Auditing;
|
||||||
|
|
||||||
|
namespace Yi.Framework.DigitalCollectibles.Domain.Entities.Record;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 挖矿记录
|
||||||
|
/// </summary>
|
||||||
|
[SugarTable("DC_MiningPoolRecord")]
|
||||||
|
public class MiningPoolRecordAggregateRoot:FullAuditedAggregateRoot<Guid>
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 用户id
|
||||||
|
/// </summary>
|
||||||
|
public Guid UserId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 挖到的藏品id
|
||||||
|
/// </summary>
|
||||||
|
public Guid CollectiblesId { get; set; }
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user