From 677dca22311620e14313149eb536d3d1073faecd Mon Sep 17 00:00:00 2001 From: chenchun Date: Wed, 30 Oct 2024 11:48:13 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=E8=AE=B0=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Dtos/Records/MarketRecordDto.cs | 37 +++++++++ .../Dtos/Records/MiningPoolRecordDto.cs | 19 +++++ .../CollectiblesServiceRecordService.cs | 83 +++++++++++++++++++ .../Record/MarketRecordAggregateRoot.cs | 41 +++++++++ .../Record/MiningPoolRecordAggregateRoot.cs | 21 +++++ 5 files changed, 201 insertions(+) create mode 100644 Yi.Abp.Net8/module/digital-collectibles/Yi.Framework.DigitalCollectibles.Application.Contracts/Dtos/Records/MarketRecordDto.cs create mode 100644 Yi.Abp.Net8/module/digital-collectibles/Yi.Framework.DigitalCollectibles.Application.Contracts/Dtos/Records/MiningPoolRecordDto.cs create mode 100644 Yi.Abp.Net8/module/digital-collectibles/Yi.Framework.DigitalCollectibles.Application/Services/Record/CollectiblesServiceRecordService.cs create mode 100644 Yi.Abp.Net8/module/digital-collectibles/Yi.Framework.DigitalCollectibles.Domain/Entities/Record/MarketRecordAggregateRoot.cs create mode 100644 Yi.Abp.Net8/module/digital-collectibles/Yi.Framework.DigitalCollectibles.Domain/Entities/Record/MiningPoolRecordAggregateRoot.cs diff --git a/Yi.Abp.Net8/module/digital-collectibles/Yi.Framework.DigitalCollectibles.Application.Contracts/Dtos/Records/MarketRecordDto.cs b/Yi.Abp.Net8/module/digital-collectibles/Yi.Framework.DigitalCollectibles.Application.Contracts/Dtos/Records/MarketRecordDto.cs new file mode 100644 index 00000000..f23bf269 --- /dev/null +++ b/Yi.Abp.Net8/module/digital-collectibles/Yi.Framework.DigitalCollectibles.Application.Contracts/Dtos/Records/MarketRecordDto.cs @@ -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 +{ + public DateTime CreationTime { get; set; } + /// + /// 出售数量 + /// + public int SellNumber{ get; set; } + + /// + /// 出售者用户id + /// + public Guid SellUserId { get; set; } + + /// + /// 购买者用户id + /// + public Guid BuyId { get; set; } + + /// + /// 出售单价 + /// + public decimal UnitPrice{ get; set; } + + /// + /// 实际到手价格(扣除税收) + /// + public decimal RealTotalPrice{ get; set; } + /// + /// 交易的藏品 + /// + public CollectiblesDto Collectibles { get; set; } +} \ No newline at end of file diff --git a/Yi.Abp.Net8/module/digital-collectibles/Yi.Framework.DigitalCollectibles.Application.Contracts/Dtos/Records/MiningPoolRecordDto.cs b/Yi.Abp.Net8/module/digital-collectibles/Yi.Framework.DigitalCollectibles.Application.Contracts/Dtos/Records/MiningPoolRecordDto.cs new file mode 100644 index 00000000..4e90e84e --- /dev/null +++ b/Yi.Abp.Net8/module/digital-collectibles/Yi.Framework.DigitalCollectibles.Application.Contracts/Dtos/Records/MiningPoolRecordDto.cs @@ -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 +{ + /// + /// 用户id + /// + public Guid UserId { get; set; } + + public DateTime CreationTime { get; set; } + + /// + /// 挖到的藏品 + /// + public CollectiblesDto Collectibles { get; set; } +} \ No newline at end of file diff --git a/Yi.Abp.Net8/module/digital-collectibles/Yi.Framework.DigitalCollectibles.Application/Services/Record/CollectiblesServiceRecordService.cs b/Yi.Abp.Net8/module/digital-collectibles/Yi.Framework.DigitalCollectibles.Application/Services/Record/CollectiblesServiceRecordService.cs new file mode 100644 index 00000000..e015b2b7 --- /dev/null +++ b/Yi.Abp.Net8/module/digital-collectibles/Yi.Framework.DigitalCollectibles.Application/Services/Record/CollectiblesServiceRecordService.cs @@ -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 _miningPoolRecordRepository; + private readonly ISqlSugarRepository _marketRecordRepository; + public CollectiblesServiceRecordService(ISqlSugarRepository miningPoolRecordRepository) + { + _miningPoolRecordRepository = miningPoolRecordRepository; + } + + /// + /// 获取当前用户的挖矿记录 + /// + /// + /// + [Authorize] + public async Task> GetMiningPoolAsync(PagedAllResultRequestDto input) + { + RefAsync 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((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(total,output); + } + + /// + /// 获取当前用户的交易记录 + /// + /// + /// + [Authorize] + public async Task> GetMarketAsync(PagedAllResultRequestDto input) + { + RefAsync 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((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(total,output); + } +} \ No newline at end of file diff --git a/Yi.Abp.Net8/module/digital-collectibles/Yi.Framework.DigitalCollectibles.Domain/Entities/Record/MarketRecordAggregateRoot.cs b/Yi.Abp.Net8/module/digital-collectibles/Yi.Framework.DigitalCollectibles.Domain/Entities/Record/MarketRecordAggregateRoot.cs new file mode 100644 index 00000000..fb61b358 --- /dev/null +++ b/Yi.Abp.Net8/module/digital-collectibles/Yi.Framework.DigitalCollectibles.Domain/Entities/Record/MarketRecordAggregateRoot.cs @@ -0,0 +1,41 @@ +using SqlSugar; +using Volo.Abp.Domain.Entities.Auditing; + +namespace Yi.Framework.DigitalCollectibles.Domain.Entities.Record; + +/// +/// 交易记录 +/// +[SugarTable("DC_MarketRecord")] +public class MarketRecordAggregateRoot:FullAuditedAggregateRoot +{ + /// + /// 出售者用户id + /// + public Guid SellUserId { get; set; } + + /// + /// 购买者用户id + /// + public Guid BuyId { get; set; } + + /// + /// 藏品id + /// + public Guid CollectiblesId { get; set; } + + /// + /// 出售数量 + /// + public int SellNumber{ get; set; } + + /// + /// 出售单价 + /// + public decimal UnitPrice{ get; set; } + + /// + /// 实际到手价格(扣除税收) + /// + public decimal RealTotalPrice{ get; set; } +} \ No newline at end of file diff --git a/Yi.Abp.Net8/module/digital-collectibles/Yi.Framework.DigitalCollectibles.Domain/Entities/Record/MiningPoolRecordAggregateRoot.cs b/Yi.Abp.Net8/module/digital-collectibles/Yi.Framework.DigitalCollectibles.Domain/Entities/Record/MiningPoolRecordAggregateRoot.cs new file mode 100644 index 00000000..8eea0874 --- /dev/null +++ b/Yi.Abp.Net8/module/digital-collectibles/Yi.Framework.DigitalCollectibles.Domain/Entities/Record/MiningPoolRecordAggregateRoot.cs @@ -0,0 +1,21 @@ +using SqlSugar; +using Volo.Abp.Domain.Entities.Auditing; + +namespace Yi.Framework.DigitalCollectibles.Domain.Entities.Record; + +/// +/// 挖矿记录 +/// +[SugarTable("DC_MiningPoolRecord")] +public class MiningPoolRecordAggregateRoot:FullAuditedAggregateRoot +{ + /// + /// 用户id + /// + public Guid UserId { get; set; } + + /// + /// 挖到的藏品id + /// + public Guid CollectiblesId { get; set; } +} \ No newline at end of file