feat: 新增ai-stock模块
This commit is contained in:
@@ -0,0 +1,66 @@
|
||||
using System;
|
||||
using Volo.Abp.Application.Dtos;
|
||||
|
||||
namespace Yi.Framework.Stock.Application.Contracts.Dtos.StockHolding
|
||||
{
|
||||
/// <summary>
|
||||
/// 用户股票持仓DTO
|
||||
/// </summary>
|
||||
public class StockHoldingDto : EntityDto<Guid>
|
||||
{
|
||||
/// <summary>
|
||||
/// 用户ID
|
||||
/// </summary>
|
||||
public Guid UserId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 股票ID
|
||||
/// </summary>
|
||||
public Guid StockId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 股票代码
|
||||
/// </summary>
|
||||
public string StockCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 股票名称
|
||||
/// </summary>
|
||||
public string StockName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 持有数量
|
||||
/// </summary>
|
||||
public int Quantity { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 持仓成本
|
||||
/// </summary>
|
||||
public decimal CostPrice { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 当前价格
|
||||
/// </summary>
|
||||
public decimal CurrentPrice { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 持仓市值
|
||||
/// </summary>
|
||||
public decimal MarketValue { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 盈亏金额
|
||||
/// </summary>
|
||||
public decimal ProfitLoss { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 盈亏百分比
|
||||
/// </summary>
|
||||
public decimal ProfitLossPercentage { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 创建时间
|
||||
/// </summary>
|
||||
public DateTime CreationTime { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using Volo.Abp.Application.Dtos;
|
||||
|
||||
namespace Yi.Framework.Stock.Application.Contracts.Dtos.StockHolding
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取用户持仓列表的输入DTO
|
||||
/// </summary>
|
||||
public class StockHoldingGetListInputDto : PagedAndSortedResultRequestDto
|
||||
{
|
||||
/// <summary>
|
||||
/// 股票代码
|
||||
/// </summary>
|
||||
public string? StockCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 股票名称
|
||||
/// </summary>
|
||||
public string? StockName { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
using System;
|
||||
using Volo.Abp.Application.Dtos;
|
||||
|
||||
namespace Yi.Framework.Stock.Application.Contracts.Dtos.StockMarket
|
||||
{
|
||||
/// <summary>
|
||||
/// 股市信息DTO
|
||||
/// </summary>
|
||||
public class StockMarketDto : EntityDto<Guid>
|
||||
{
|
||||
/// <summary>
|
||||
/// 股市代码
|
||||
/// </summary>
|
||||
public string MarketCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 股市名称
|
||||
/// </summary>
|
||||
public string MarketName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 股市描述
|
||||
/// </summary>
|
||||
public string Description { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 状态
|
||||
/// </summary>
|
||||
public bool State { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 创建时间
|
||||
/// </summary>
|
||||
public DateTime CreationTime { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
using System;
|
||||
using Volo.Abp.Application.Dtos;
|
||||
|
||||
namespace Yi.Framework.Stock.Application.Contracts.Dtos.StockMarket
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取股市列表的输入DTO
|
||||
/// </summary>
|
||||
public class StockMarketGetListInputDto : PagedAndSortedResultRequestDto
|
||||
{
|
||||
/// <summary>
|
||||
/// 股市代码
|
||||
/// </summary>
|
||||
public string? MarketCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 股市名称
|
||||
/// </summary>
|
||||
public string? MarketName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 状态
|
||||
/// </summary>
|
||||
public bool? State { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
using System;
|
||||
using Volo.Abp.Application.Dtos;
|
||||
|
||||
namespace Yi.Framework.Stock.Application.Contracts.Dtos.StockNews
|
||||
{
|
||||
/// <summary>
|
||||
/// 股市新闻DTO
|
||||
/// </summary>
|
||||
public class StockNewsDto : EntityDto<Guid>
|
||||
{
|
||||
/// <summary>
|
||||
/// 新闻标题
|
||||
/// </summary>
|
||||
public string Title { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 新闻内容
|
||||
/// </summary>
|
||||
public string Content { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 发布时间
|
||||
/// </summary>
|
||||
public DateTime PublishTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 新闻来源
|
||||
/// </summary>
|
||||
public string Source { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 创建时间
|
||||
/// </summary>
|
||||
public DateTime CreationTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 排序号
|
||||
/// </summary>
|
||||
public int OrderNum { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
using System;
|
||||
using Volo.Abp.Application.Dtos;
|
||||
|
||||
namespace Yi.Framework.Stock.Application.Contracts.Dtos.StockNews
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取股市新闻列表的输入DTO
|
||||
/// </summary>
|
||||
public class StockNewsGetListInputDto : PagedAndSortedResultRequestDto
|
||||
{
|
||||
/// <summary>
|
||||
/// 新闻标题关键词
|
||||
/// </summary>
|
||||
public string? Title { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 新闻来源
|
||||
/// </summary>
|
||||
public string? Source { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 开始时间
|
||||
/// </summary>
|
||||
public DateTime? StartTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 结束时间
|
||||
/// </summary>
|
||||
public DateTime? EndTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否只显示最近10天的新闻
|
||||
/// </summary>
|
||||
/// <remarks>默认为true,查询最近10天的新闻</remarks>
|
||||
public bool IsRecent { get; set; } = true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
using System;
|
||||
using Volo.Abp.Application.Dtos;
|
||||
using Yi.Framework.Stock.Domain.Shared;
|
||||
|
||||
namespace Yi.Framework.Stock.Application.Contracts.Dtos.StockPrice
|
||||
{
|
||||
/// <summary>
|
||||
/// 股市价格记录DTO
|
||||
/// </summary>
|
||||
public class StockPriceRecordDto : EntityDto<Guid>
|
||||
{
|
||||
/// <summary>
|
||||
/// 股票ID
|
||||
/// </summary>
|
||||
public Guid StockId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 记录时间
|
||||
/// </summary>
|
||||
public DateTime CreationTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 当前价
|
||||
/// </summary>
|
||||
public decimal CurrentPrice { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 交易量
|
||||
/// </summary>
|
||||
public long Volume { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 交易额
|
||||
/// </summary>
|
||||
public decimal Turnover { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 时间周期类型
|
||||
/// </summary>
|
||||
public PeriodTypeEnum PeriodType { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
using System;
|
||||
using Volo.Abp.Application.Dtos;
|
||||
using Yi.Framework.Stock.Domain.Shared;
|
||||
|
||||
namespace Yi.Framework.Stock.Application.Contracts.Dtos.StockPrice
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取股市价格记录的输入DTO
|
||||
/// </summary>
|
||||
public class StockPriceRecordGetListInputDto : PagedAndSortedResultRequestDto
|
||||
{
|
||||
/// <summary>
|
||||
/// 股票ID
|
||||
/// </summary>
|
||||
public Guid? StockId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 开始时间
|
||||
/// </summary>
|
||||
public DateTime? StartTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 结束时间
|
||||
/// </summary>
|
||||
public DateTime? EndTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 时间周期类型
|
||||
/// </summary>
|
||||
public PeriodTypeEnum? PeriodType { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
using System;
|
||||
using Volo.Abp.Application.Dtos;
|
||||
using Yi.Framework.Stock.Domain.Shared;
|
||||
|
||||
namespace Yi.Framework.Stock.Application.Contracts.Dtos.StockTransaction
|
||||
{
|
||||
/// <summary>
|
||||
/// 股票交易记录DTO
|
||||
/// </summary>
|
||||
public class StockTransactionDto : EntityDto<Guid>
|
||||
{
|
||||
/// <summary>
|
||||
/// 用户ID
|
||||
/// </summary>
|
||||
public Guid UserId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 股票ID
|
||||
/// </summary>
|
||||
public Guid StockId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 股票代码
|
||||
/// </summary>
|
||||
public string StockCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 股票名称
|
||||
/// </summary>
|
||||
public string StockName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 交易类型
|
||||
/// </summary>
|
||||
public TransactionTypeEnum TransactionType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 交易价格
|
||||
/// </summary>
|
||||
public decimal Price { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 交易数量
|
||||
/// </summary>
|
||||
public int Quantity { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 交易总额
|
||||
/// </summary>
|
||||
public decimal TotalAmount { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 交易费用
|
||||
/// </summary>
|
||||
public decimal Fee { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 交易时间
|
||||
/// </summary>
|
||||
public DateTime CreationTime { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
using System;
|
||||
using Volo.Abp.Application.Dtos;
|
||||
using Yi.Framework.Stock.Domain.Shared;
|
||||
|
||||
namespace Yi.Framework.Stock.Application.Contracts.Dtos.StockTransaction
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取交易记录的输入DTO
|
||||
/// </summary>
|
||||
public class StockTransactionGetListInputDto : PagedAndSortedResultRequestDto
|
||||
{
|
||||
/// <summary>
|
||||
/// 股票代码
|
||||
/// </summary>
|
||||
public string StockCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 股票名称
|
||||
/// </summary>
|
||||
public string StockName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 交易类型
|
||||
/// </summary>
|
||||
public TransactionTypeEnum? TransactionType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 开始时间
|
||||
/// </summary>
|
||||
public DateTime? StartTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 结束时间
|
||||
/// </summary>
|
||||
public DateTime? EndTime { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Volo.Abp.Application.Dtos;
|
||||
using Volo.Abp.Application.Services;
|
||||
using Yi.Framework.Stock.Application.Contracts.Dtos.StockHolding;
|
||||
using Yi.Framework.Stock.Application.Contracts.Dtos.StockTransaction;
|
||||
|
||||
namespace Yi.Framework.Stock.Application.Contracts.IServices
|
||||
{
|
||||
/// <summary>
|
||||
/// 用户持仓服务接口
|
||||
/// </summary>
|
||||
public interface IStockHoldingService : IApplicationService
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取当前用户的持仓列表
|
||||
/// </summary>
|
||||
/// <param name="input">查询条件</param>
|
||||
/// <returns>持仓列表</returns>
|
||||
Task<PagedResultDto<StockHoldingDto>> GetUserHoldingsAsync(StockHoldingGetListInputDto input);
|
||||
|
||||
/// <summary>
|
||||
/// 获取当前用户的交易记录
|
||||
/// </summary>
|
||||
/// <param name="input">查询条件</param>
|
||||
/// <returns>交易记录列表</returns>
|
||||
Task<PagedResultDto<StockTransactionDto>> GetUserTransactionsAsync(StockTransactionGetListInputDto input);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Volo.Abp.Application.Dtos;
|
||||
using Volo.Abp.Application.Services;
|
||||
using Yi.Framework.Stock.Application.Contracts.Dtos.StockMarket;
|
||||
using Yi.Framework.Stock.Application.Contracts.Dtos.StockPrice;
|
||||
|
||||
namespace Yi.Framework.Stock.Application.Contracts.IServices
|
||||
{
|
||||
/// <summary>
|
||||
/// 股市服务接口
|
||||
/// </summary>
|
||||
public interface IStockMarketService : IApplicationService
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取股市列表
|
||||
/// </summary>
|
||||
/// <param name="input">查询条件</param>
|
||||
/// <returns>股市列表</returns>
|
||||
Task<PagedResultDto<StockMarketDto>> GetStockMarketListAsync(StockMarketGetListInputDto input);
|
||||
|
||||
/// <summary>
|
||||
/// 获取股市价格记录看板
|
||||
/// </summary>
|
||||
/// <param name="input">查询条件</param>
|
||||
/// <returns>股价记录列表</returns>
|
||||
Task<PagedResultDto<StockPriceRecordDto>> GetStockPriceRecordListAsync(StockPriceRecordGetListInputDto input);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
using System.Threading.Tasks;
|
||||
using Volo.Abp.Application.Dtos;
|
||||
using Volo.Abp.Application.Services;
|
||||
using Yi.Framework.Stock.Application.Contracts.Dtos.StockNews;
|
||||
|
||||
namespace Yi.Framework.Stock.Application.Contracts.IServices
|
||||
{
|
||||
/// <summary>
|
||||
/// 股市新闻服务接口
|
||||
/// </summary>
|
||||
public interface IStockNewsService : IApplicationService
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取股市新闻列表
|
||||
/// </summary>
|
||||
/// <param name="input">查询条件</param>
|
||||
/// <returns>新闻列表</returns>
|
||||
Task<PagedResultDto<StockNewsDto>> GetStockNewsListAsync(StockNewsGetListInputDto input);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using SqlSugar;
|
||||
using Volo.Abp.Application.Dtos;
|
||||
using Volo.Abp.Application.Services;
|
||||
using Yi.Framework.Stock.Application.Contracts.Dtos.StockHolding;
|
||||
using Yi.Framework.Stock.Application.Contracts.Dtos.StockTransaction;
|
||||
using Yi.Framework.Stock.Application.Contracts.IServices;
|
||||
using Yi.Framework.Stock.Domain.Entities;
|
||||
using Yi.Framework.SqlSugarCore.Abstractions;
|
||||
using Volo.Abp.Users;
|
||||
|
||||
namespace Yi.Framework.Stock.Application.Services
|
||||
{
|
||||
/// <summary>
|
||||
/// 用户持仓服务实现
|
||||
/// </summary>
|
||||
[Authorize]
|
||||
public class StockHoldingService : ApplicationService, IStockHoldingService
|
||||
{
|
||||
private readonly ISqlSugarRepository<StockHoldingAggregateRoot> _stockHoldingRepository;
|
||||
private readonly ISqlSugarRepository<StockTransactionEntity> _stockTransactionRepository;
|
||||
|
||||
public StockHoldingService(
|
||||
ISqlSugarRepository<StockHoldingAggregateRoot> stockHoldingRepository,
|
||||
ISqlSugarRepository<StockTransactionEntity> stockTransactionRepository)
|
||||
{
|
||||
_stockHoldingRepository = stockHoldingRepository;
|
||||
_stockTransactionRepository = stockTransactionRepository;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取当前用户的持仓列表
|
||||
/// </summary>
|
||||
[Authorize]
|
||||
[HttpGet("stock/user-holdings")]
|
||||
public async Task<PagedResultDto<StockHoldingDto>> GetUserHoldingsAsync(StockHoldingGetListInputDto input)
|
||||
{
|
||||
Guid userId = CurrentUser.GetId();
|
||||
RefAsync<int> total = 0;
|
||||
|
||||
var query = _stockHoldingRepository._DbQueryable
|
||||
.Where(h => h.UserId == userId)
|
||||
.WhereIF(!string.IsNullOrEmpty(input.StockCode), h => h.StockCode.Contains(input.StockCode))
|
||||
.WhereIF(!string.IsNullOrEmpty(input.StockName), h => h.StockName.Contains(input.StockName))
|
||||
.OrderByIF(!string.IsNullOrEmpty(input.Sorting),input.Sorting)
|
||||
.OrderByIF(string.IsNullOrEmpty(input.Sorting),t=>t.CreationTime,OrderByType.Desc);
|
||||
|
||||
var list = await query
|
||||
.Select(h => new StockHoldingDto
|
||||
{
|
||||
Id = h.Id,
|
||||
UserId = h.UserId,
|
||||
StockId = h.StockId,
|
||||
StockCode = h.StockCode,
|
||||
StockName = h.StockName,
|
||||
CreationTime = h.CreationTime
|
||||
})
|
||||
.ToPageListAsync(input.SkipCount, input.MaxResultCount, total);
|
||||
|
||||
return new PagedResultDto<StockHoldingDto>(total, list);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取当前用户的交易记录
|
||||
/// </summary>
|
||||
[Authorize]
|
||||
[HttpGet("stock/user-transactions")]
|
||||
public async Task<PagedResultDto<StockTransactionDto>> GetUserTransactionsAsync(StockTransactionGetListInputDto input)
|
||||
{
|
||||
Guid userId = CurrentUser.GetId();
|
||||
RefAsync<int> total = 0;
|
||||
|
||||
var query = _stockTransactionRepository._DbQueryable
|
||||
.Where(t => t.UserId == userId)
|
||||
.WhereIF(!string.IsNullOrEmpty(input.StockCode), t => t.StockCode.Contains(input.StockCode))
|
||||
.WhereIF(!string.IsNullOrEmpty(input.StockName), t => t.StockName.Contains(input.StockName))
|
||||
.WhereIF(input.TransactionType.HasValue, t => t.TransactionType == input.TransactionType.Value)
|
||||
.WhereIF(input.StartTime.HasValue, t => t.CreationTime >= input.StartTime.Value)
|
||||
.WhereIF(input.EndTime.HasValue, t => t.CreationTime <= input.EndTime.Value)
|
||||
.OrderByIF(!string.IsNullOrEmpty(input.Sorting),input.Sorting)
|
||||
.OrderByIF(string.IsNullOrEmpty(input.Sorting),t=>t.CreationTime,OrderByType.Desc);
|
||||
|
||||
var list = await query
|
||||
.Select(t => new StockTransactionDto
|
||||
{
|
||||
Id = t.Id,
|
||||
UserId = t.UserId,
|
||||
StockId = t.StockId,
|
||||
StockCode = t.StockCode,
|
||||
StockName = t.StockName,
|
||||
TransactionType = t.TransactionType,
|
||||
Price = t.Price,
|
||||
Quantity = t.Quantity,
|
||||
TotalAmount = t.TotalAmount,
|
||||
Fee = t.Fee,
|
||||
CreationTime = t.CreationTime
|
||||
})
|
||||
.ToPageListAsync(input.SkipCount, input.MaxResultCount, total);
|
||||
|
||||
return new PagedResultDto<StockTransactionDto>(total, list);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using SqlSugar;
|
||||
using Volo.Abp.Application.Dtos;
|
||||
using Volo.Abp.Application.Services;
|
||||
using Yi.Framework.Stock.Application.Contracts.Dtos.StockMarket;
|
||||
using Yi.Framework.Stock.Application.Contracts.Dtos.StockPrice;
|
||||
using Yi.Framework.Stock.Application.Contracts.IServices;
|
||||
using Yi.Framework.Stock.Domain.Entities;
|
||||
using Yi.Framework.SqlSugarCore.Abstractions;
|
||||
|
||||
namespace Yi.Framework.Stock.Application.Services
|
||||
{
|
||||
/// <summary>
|
||||
/// 股市服务实现
|
||||
/// </summary>
|
||||
public class StockMarketService : ApplicationService, IStockMarketService
|
||||
{
|
||||
private readonly ISqlSugarRepository<StockMarketAggregateRoot> _stockMarketRepository;
|
||||
private readonly ISqlSugarRepository<StockPriceRecordEntity> _stockPriceRecordRepository;
|
||||
|
||||
public StockMarketService(
|
||||
ISqlSugarRepository<StockMarketAggregateRoot> stockMarketRepository,
|
||||
ISqlSugarRepository<StockPriceRecordEntity> stockPriceRecordRepository)
|
||||
{
|
||||
_stockMarketRepository = stockMarketRepository;
|
||||
_stockPriceRecordRepository = stockPriceRecordRepository;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取股市列表
|
||||
/// </summary>
|
||||
[HttpGet("stock/markets")]
|
||||
public async Task<PagedResultDto<StockMarketDto>> GetStockMarketListAsync(StockMarketGetListInputDto input)
|
||||
{
|
||||
RefAsync<int> total = 0;
|
||||
|
||||
var query = _stockMarketRepository._DbQueryable
|
||||
.WhereIF(!string.IsNullOrEmpty(input.MarketCode), m => m.MarketCode.Contains(input.MarketCode))
|
||||
.WhereIF(!string.IsNullOrEmpty(input.MarketName), m => m.MarketName.Contains(input.MarketName))
|
||||
.WhereIF(input.State.HasValue, m => m.State == input.State.Value)
|
||||
.OrderByIF(!string.IsNullOrEmpty(input.Sorting),input.Sorting)
|
||||
.OrderByIF(string.IsNullOrEmpty(input.Sorting),m=>m.OrderNum,OrderByType.Asc)
|
||||
.OrderByIF(string.IsNullOrEmpty(input.Sorting),m=>m.CreationTime,OrderByType.Desc);
|
||||
|
||||
var list = await query
|
||||
.Select(m => new StockMarketDto
|
||||
{
|
||||
Id = m.Id,
|
||||
MarketCode = m.MarketCode,
|
||||
MarketName = m.MarketName,
|
||||
Description = m.Description,
|
||||
State = m.State,
|
||||
CreationTime = m.CreationTime
|
||||
})
|
||||
.ToPageListAsync(input.SkipCount, input.MaxResultCount, total);
|
||||
|
||||
return new PagedResultDto<StockMarketDto>(total, list);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取股市价格记录看板
|
||||
/// </summary>
|
||||
[HttpGet("stock/price-records")]
|
||||
public async Task<PagedResultDto<StockPriceRecordDto>> GetStockPriceRecordListAsync(StockPriceRecordGetListInputDto input)
|
||||
{
|
||||
RefAsync<int> total = 0;
|
||||
|
||||
var query = _stockPriceRecordRepository._DbQueryable
|
||||
.WhereIF(input.StockId.HasValue, p => p.StockId == input.StockId.Value)
|
||||
.WhereIF(input.StartTime.HasValue, p => p.CreationTime >= input.StartTime.Value)
|
||||
.WhereIF(input.EndTime.HasValue, p => p.CreationTime <= input.EndTime.Value)
|
||||
.WhereIF(input.PeriodType.HasValue, p => p.PeriodType == input.PeriodType.Value)
|
||||
.OrderByIF(!string.IsNullOrEmpty(input.Sorting),input.Sorting)
|
||||
.OrderByIF(string.IsNullOrEmpty(input.Sorting),p=>p.CreationTime,OrderByType.Desc);
|
||||
|
||||
var list = await query
|
||||
.Select(p => new StockPriceRecordDto
|
||||
{
|
||||
Id = p.Id,
|
||||
StockId = p.StockId,
|
||||
CreationTime = p.CreationTime,
|
||||
CurrentPrice = p.CurrentPrice,
|
||||
Volume = p.Volume,
|
||||
Turnover = p.Turnover,
|
||||
PeriodType = p.PeriodType
|
||||
})
|
||||
.ToPageListAsync(input.SkipCount, input.MaxResultCount, total);
|
||||
|
||||
return new PagedResultDto<StockPriceRecordDto>(total, list);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using SqlSugar;
|
||||
using Volo.Abp.Application.Dtos;
|
||||
using Volo.Abp.Application.Services;
|
||||
using Yi.Framework.Stock.Application.Contracts.Dtos.StockNews;
|
||||
using Yi.Framework.Stock.Application.Contracts.IServices;
|
||||
using Yi.Framework.Stock.Domain.Entities;
|
||||
using Yi.Framework.SqlSugarCore.Abstractions;
|
||||
|
||||
namespace Yi.Framework.Stock.Application.Services
|
||||
{
|
||||
/// <summary>
|
||||
/// 股市新闻服务实现
|
||||
/// </summary>
|
||||
public class StockNewsService : ApplicationService, IStockNewsService
|
||||
{
|
||||
private readonly ISqlSugarRepository<StockNewsAggregateRoot> _stockNewsRepository;
|
||||
|
||||
public StockNewsService(ISqlSugarRepository<StockNewsAggregateRoot> stockNewsRepository)
|
||||
{
|
||||
_stockNewsRepository = stockNewsRepository;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取股市新闻列表
|
||||
/// </summary>
|
||||
[HttpGet("/api/stock/news")]
|
||||
public async Task<PagedResultDto<StockNewsDto>> GetStockNewsListAsync(StockNewsGetListInputDto input)
|
||||
{
|
||||
RefAsync<int> total = 0;
|
||||
|
||||
// 计算10天前的日期
|
||||
DateTime tenDaysAgo = DateTime.Now.AddDays(-10);
|
||||
|
||||
var query = _stockNewsRepository._DbQueryable
|
||||
.WhereIF(!string.IsNullOrEmpty(input.Title), n => n.Title.Contains(input.Title))
|
||||
.WhereIF(!string.IsNullOrEmpty(input.Source), n => n.Source.Contains(input.Source))
|
||||
.WhereIF(input.StartTime.HasValue, n => n.PublishTime >= input.StartTime.Value)
|
||||
.WhereIF(input.EndTime.HasValue, n => n.PublishTime <= input.EndTime.Value)
|
||||
// 如果IsRecent为true,则只查询最近10天的新闻
|
||||
.WhereIF(input.IsRecent, n => n.PublishTime >= tenDaysAgo)
|
||||
.OrderByIF(!string.IsNullOrEmpty(input.Sorting),input.Sorting)
|
||||
.OrderByIF(string.IsNullOrEmpty(input.Sorting),n=>n.OrderNum,OrderByType.Asc)
|
||||
.OrderByIF(string.IsNullOrEmpty(input.Sorting),n=>n.PublishTime,OrderByType.Desc) ;
|
||||
|
||||
|
||||
var list = await query
|
||||
.Select(n => new StockNewsDto
|
||||
{
|
||||
Id = n.Id,
|
||||
Title = n.Title,
|
||||
Content = n.Content,
|
||||
PublishTime = n.PublishTime,
|
||||
Source = n.Source,
|
||||
CreationTime = n.CreationTime,
|
||||
OrderNum = n.OrderNum
|
||||
})
|
||||
.ToPageListAsync(input.SkipCount, input.MaxResultCount, total);
|
||||
|
||||
return new PagedResultDto<StockNewsDto>(total, list);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
namespace Yi.Framework.Stock.Domain.Shared
|
||||
{
|
||||
/// <summary>
|
||||
/// 时间周期类型枚举
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// 用于定义股票价格记录的时间周期类型
|
||||
/// </remarks>
|
||||
public enum PeriodTypeEnum
|
||||
{
|
||||
/// <summary>
|
||||
/// 分钟
|
||||
/// </summary>
|
||||
Minute = 0,
|
||||
|
||||
/// <summary>
|
||||
/// 小时
|
||||
/// </summary>
|
||||
Hour = 1,
|
||||
|
||||
/// <summary>
|
||||
/// 天
|
||||
/// </summary>
|
||||
Day = 2,
|
||||
|
||||
/// <summary>
|
||||
/// 周
|
||||
/// </summary>
|
||||
Week = 3,
|
||||
|
||||
/// <summary>
|
||||
/// 月
|
||||
/// </summary>
|
||||
Month = 4,
|
||||
|
||||
/// <summary>
|
||||
/// 年
|
||||
/// </summary>
|
||||
Year = 5
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
namespace Yi.Framework.Stock.Domain.Shared
|
||||
{
|
||||
/// <summary>
|
||||
/// 交易类型枚举
|
||||
/// </summary>
|
||||
public enum TransactionTypeEnum
|
||||
{
|
||||
/// <summary>
|
||||
/// 买入
|
||||
/// </summary>
|
||||
Buy = 0,
|
||||
|
||||
/// <summary>
|
||||
/// 卖出
|
||||
/// </summary>
|
||||
Sell = 1
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,141 @@
|
||||
using SqlSugar;
|
||||
using Volo.Abp.Auditing;
|
||||
using Volo.Abp.Domain.Entities;
|
||||
using Yi.Framework.Core.Data;
|
||||
|
||||
namespace Yi.Framework.Stock.Domain.Entities
|
||||
{
|
||||
/// <summary>
|
||||
/// 用户股票持仓聚合根
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// 记录用户持有的股票数量和相关信息
|
||||
/// </remarks>
|
||||
[SugarTable("Stock_Holding")]
|
||||
public class StockHoldingAggregateRoot : AggregateRoot<Guid>, ISoftDelete, IAuditedObject
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 逻辑删除
|
||||
/// </summary>
|
||||
public bool IsDeleted { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 创建时间
|
||||
/// </summary>
|
||||
public DateTime CreationTime { get; set; } = DateTime.Now;
|
||||
|
||||
/// <summary>
|
||||
/// 创建者
|
||||
/// </summary>
|
||||
public Guid? CreatorId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 最后修改者
|
||||
/// </summary>
|
||||
public Guid? LastModifierId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 最后修改时间
|
||||
/// </summary>
|
||||
public DateTime? LastModificationTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 用户ID
|
||||
/// </summary>
|
||||
/// <remarks>关联到持有股票的用户</remarks>
|
||||
public Guid UserId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 股票ID
|
||||
/// </summary>
|
||||
/// <remarks>关联到具体的股票</remarks>
|
||||
public Guid StockId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 股票代码
|
||||
/// </summary>
|
||||
/// <remarks>冗余字段,方便查询</remarks>
|
||||
public string StockCode { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 股票名称
|
||||
/// </summary>
|
||||
/// <remarks>冗余字段,方便查询</remarks>
|
||||
public string StockName { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 持有数量
|
||||
/// </summary>
|
||||
/// <remarks>用户持有的股票数量</remarks>
|
||||
public int Quantity { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 平均成本价
|
||||
/// </summary>
|
||||
/// <remarks>用户购买这些股票的平均成本价</remarks>
|
||||
public decimal AverageCostPrice { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 持仓成本
|
||||
/// </summary>
|
||||
/// <remarks>总投入成本 = 平均成本价 * 持有数量</remarks>
|
||||
[SugarColumn(IsIgnore = true)]
|
||||
public decimal TotalCost => AverageCostPrice * Quantity;
|
||||
|
||||
public StockHoldingAggregateRoot() { }
|
||||
|
||||
public StockHoldingAggregateRoot(
|
||||
Guid userId,
|
||||
Guid stockId,
|
||||
string stockCode,
|
||||
string stockName,
|
||||
int quantity,
|
||||
decimal averageCostPrice)
|
||||
{
|
||||
UserId = userId;
|
||||
StockId = stockId;
|
||||
StockCode = stockCode;
|
||||
StockName = stockName;
|
||||
Quantity = quantity;
|
||||
AverageCostPrice = averageCostPrice;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 增加持仓数量
|
||||
/// </summary>
|
||||
/// <param name="quantity">增加的数量</param>
|
||||
/// <param name="price">本次购买价格</param>
|
||||
public void AddQuantity(int quantity, decimal price)
|
||||
{
|
||||
if (quantity <= 0)
|
||||
throw new ArgumentException("增加的数量必须大于0");
|
||||
|
||||
// 计算新的平均成本价
|
||||
decimal totalCost = AverageCostPrice * Quantity + price * quantity;
|
||||
Quantity += quantity;
|
||||
AverageCostPrice = totalCost / Quantity;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 减少持仓数量
|
||||
/// </summary>
|
||||
/// <param name="quantity">减少的数量</param>
|
||||
public void ReduceQuantity(int quantity)
|
||||
{
|
||||
if (quantity <= 0)
|
||||
throw new ArgumentException("减少的数量必须大于0");
|
||||
|
||||
if (quantity > Quantity)
|
||||
throw new ArgumentException("减少的数量不能大于持有数量");
|
||||
|
||||
Quantity -= quantity;
|
||||
|
||||
// 如果数量为0,标记为删除
|
||||
if (Quantity == 0)
|
||||
{
|
||||
IsDeleted = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
using SqlSugar;
|
||||
using Volo.Abp.Auditing;
|
||||
using Volo.Abp.Domain.Entities;
|
||||
using Yi.Framework.Core.Data;
|
||||
|
||||
namespace Yi.Framework.Stock.Domain.Entities
|
||||
{
|
||||
/// <summary>
|
||||
/// 股市聚合根实体
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// 用于定义有哪些公司上架的股市
|
||||
/// </remarks>
|
||||
[SugarTable("Stock_Market")]
|
||||
public class StockMarketAggregateRoot : AggregateRoot<Guid>, ISoftDelete, IAuditedObject, IOrderNum, IState
|
||||
{
|
||||
/// <summary>
|
||||
/// 逻辑删除
|
||||
/// </summary>
|
||||
public bool IsDeleted { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 创建时间
|
||||
/// </summary>
|
||||
public DateTime CreationTime { get; set; } = DateTime.Now;
|
||||
|
||||
/// <summary>
|
||||
/// 创建者
|
||||
/// </summary>
|
||||
public Guid? CreatorId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 最后修改者
|
||||
/// </summary>
|
||||
public Guid? LastModifierId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 最后修改时间
|
||||
/// </summary>
|
||||
public DateTime? LastModificationTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 排序
|
||||
/// </summary>
|
||||
public int OrderNum { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// 状态
|
||||
/// </summary>
|
||||
public bool State { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// 股市代码
|
||||
/// </summary>
|
||||
/// <remarks>如:SH、SZ、HK等</remarks>
|
||||
public string MarketCode { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 股市名称
|
||||
/// </summary>
|
||||
/// <remarks>如:上海证券交易所、深圳证券交易所等</remarks>
|
||||
public string MarketName { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 股市描述
|
||||
/// </summary>
|
||||
public string Description { get; set; } = string.Empty;
|
||||
|
||||
public StockMarketAggregateRoot() { }
|
||||
|
||||
public StockMarketAggregateRoot(
|
||||
string marketCode,
|
||||
string marketName,
|
||||
string description = "")
|
||||
{
|
||||
MarketCode = marketCode;
|
||||
MarketName = marketName;
|
||||
Description = description;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
using SqlSugar;
|
||||
using Volo.Abp.Auditing;
|
||||
using Volo.Abp.Domain.Entities;
|
||||
using Yi.Framework.Core.Data;
|
||||
|
||||
namespace Yi.Framework.Stock.Domain.Entities
|
||||
{
|
||||
/// <summary>
|
||||
/// 股市新闻聚合根实体
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// 用于记录影响股市波动的新闻事件
|
||||
/// </remarks>
|
||||
[SugarTable("Stock_News")]
|
||||
public class StockNewsAggregateRoot : AggregateRoot<Guid>, ISoftDelete, IAuditedObject, IOrderNum
|
||||
{
|
||||
/// <summary>
|
||||
/// 逻辑删除
|
||||
/// </summary>
|
||||
public bool IsDeleted { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 创建时间
|
||||
/// </summary>
|
||||
public DateTime CreationTime { get; set; } = DateTime.Now;
|
||||
|
||||
/// <summary>
|
||||
/// 创建者ID
|
||||
/// </summary>
|
||||
public Guid? CreatorId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 最后修改时间
|
||||
/// </summary>
|
||||
public DateTime? LastModificationTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 最后修改者ID
|
||||
/// </summary>
|
||||
public Guid? LastModifierId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 排序号
|
||||
/// </summary>
|
||||
public int OrderNum { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// 新闻标题
|
||||
/// </summary>
|
||||
public string Title { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 新闻内容
|
||||
/// </summary>
|
||||
public string Content { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 发布时间
|
||||
/// </summary>
|
||||
public DateTime PublishTime { get; set; } = DateTime.Now;
|
||||
|
||||
/// <summary>
|
||||
/// 新闻来源
|
||||
/// </summary>
|
||||
public string Source { get; set; } = string.Empty;
|
||||
|
||||
public StockNewsAggregateRoot() { }
|
||||
|
||||
public StockNewsAggregateRoot(
|
||||
string title,
|
||||
string content,
|
||||
string source = "")
|
||||
{
|
||||
Title = title;
|
||||
Content = content;
|
||||
Source = source;
|
||||
PublishTime = DateTime.Now;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
using SqlSugar;
|
||||
using Volo.Abp.Domain.Entities;
|
||||
using Volo.Abp.Auditing;
|
||||
using Yi.Framework.Stock.Domain.Shared;
|
||||
|
||||
namespace Yi.Framework.Stock.Domain.Entities
|
||||
{
|
||||
/// <summary>
|
||||
/// 股票价格记录实体
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// 用于记录每支股票在不同时间点的价格数据,支持趋势分析和图表展示
|
||||
/// </remarks>
|
||||
[SugarTable("Stock_PriceRecord")]
|
||||
public class StockPriceRecordEntity : Entity<Guid>, IHasCreationTime
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 股票ID
|
||||
/// </summary>
|
||||
/// <remarks>关联到具体的股票</remarks>
|
||||
public Guid StockId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 记录时间
|
||||
/// </summary>
|
||||
/// <remarks>价格记录的时间点</remarks>
|
||||
public DateTime CreationTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 当前价
|
||||
/// </summary>
|
||||
public decimal CurrentPrice { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 交易量
|
||||
/// </summary>
|
||||
/// <remarks>该时间段内的交易股数</remarks>
|
||||
public long Volume { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 交易额
|
||||
/// </summary>
|
||||
/// <remarks>该时间段内的交易金额</remarks>
|
||||
public decimal Turnover { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 时间周期类型
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// 记录的时间周期类型:分钟、小时、日、周、月等
|
||||
/// </remarks>
|
||||
public PeriodTypeEnum PeriodType { get; set; }
|
||||
|
||||
public StockPriceRecordEntity() { }
|
||||
|
||||
public StockPriceRecordEntity(
|
||||
Guid stockId,
|
||||
decimal currentPrice,
|
||||
long volume = 0,
|
||||
decimal turnover = 0,
|
||||
PeriodTypeEnum periodType = PeriodTypeEnum.Day)
|
||||
{
|
||||
StockId = stockId;
|
||||
CreationTime = DateTime.Now;
|
||||
CurrentPrice = currentPrice;
|
||||
Volume = volume;
|
||||
Turnover = turnover;
|
||||
PeriodType = periodType;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,121 @@
|
||||
using SqlSugar;
|
||||
using Volo.Abp.Domain.Entities;
|
||||
using Volo.Abp.Auditing;
|
||||
using Yi.Framework.Stock.Domain.Shared;
|
||||
|
||||
namespace Yi.Framework.Stock.Domain.Entities
|
||||
{
|
||||
/// <summary>
|
||||
/// 股票交易记录实体
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// 用于记录用户买入或卖出股票的交易历史
|
||||
/// </remarks>
|
||||
[SugarTable("Stock_Transaction")]
|
||||
public class StockTransactionEntity : Entity<Guid>, IAuditedObject
|
||||
{
|
||||
/// <summary>
|
||||
/// 用户ID
|
||||
/// </summary>
|
||||
/// <remarks>进行交易的用户</remarks>
|
||||
public Guid UserId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 股票ID
|
||||
/// </summary>
|
||||
/// <remarks>交易的股票</remarks>
|
||||
public Guid StockId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 股票代码
|
||||
/// </summary>
|
||||
/// <remarks>冗余字段,方便查询</remarks>
|
||||
public string StockCode { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 股票名称
|
||||
/// </summary>
|
||||
/// <remarks>冗余字段,方便查询</remarks>
|
||||
public string StockName { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 交易类型
|
||||
/// </summary>
|
||||
public TransactionTypeEnum TransactionType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 交易价格
|
||||
/// </summary>
|
||||
/// <remarks>股票的单价</remarks>
|
||||
public decimal Price { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 交易数量
|
||||
/// </summary>
|
||||
/// <remarks>买入或卖出的股票数量</remarks>
|
||||
public int Quantity { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 交易总额
|
||||
/// </summary>
|
||||
/// <remarks>价格 × 数量</remarks>
|
||||
public decimal TotalAmount { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 交易费用
|
||||
/// </summary>
|
||||
/// <remarks>手续费、佣金等</remarks>
|
||||
public decimal Fee { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 创建时间
|
||||
/// </summary>
|
||||
/// <remarks>交易发生时间</remarks>
|
||||
public DateTime CreationTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 创建者ID
|
||||
/// </summary>
|
||||
public Guid? CreatorId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 最后修改时间
|
||||
/// </summary>
|
||||
public DateTime? LastModificationTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 最后修改者ID
|
||||
/// </summary>
|
||||
public Guid? LastModifierId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 备注
|
||||
/// </summary>
|
||||
public string Remark { get; set; } = string.Empty;
|
||||
|
||||
public StockTransactionEntity() { }
|
||||
|
||||
public StockTransactionEntity(
|
||||
Guid userId,
|
||||
Guid stockId,
|
||||
string stockCode,
|
||||
string stockName,
|
||||
TransactionTypeEnum transactionType,
|
||||
decimal price,
|
||||
int quantity,
|
||||
decimal fee = 0)
|
||||
{
|
||||
Id = Guid.NewGuid();
|
||||
UserId = userId;
|
||||
StockId = stockId;
|
||||
StockCode = stockCode;
|
||||
StockName = stockName;
|
||||
TransactionType = transactionType;
|
||||
Price = price;
|
||||
Quantity = quantity;
|
||||
TotalAmount = price * quantity;
|
||||
Fee = fee;
|
||||
CreationTime = DateTime.Now;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -14,7 +14,6 @@
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="EventHandlers\" />
|
||||
<Folder Include="Entities\" />
|
||||
<Folder Include="Managers\" />
|
||||
<Folder Include="Repositories\" />
|
||||
</ItemGroup>
|
||||
@@ -1,15 +0,0 @@
|
||||
using Volo.Abp.Application.Services;
|
||||
|
||||
namespace Yi.Framework.Stock.Application.Services
|
||||
{
|
||||
/// <summary>
|
||||
/// 常用魔改及扩展示例
|
||||
/// </summary>
|
||||
public class TestService : ApplicationService
|
||||
{
|
||||
public string TTT()
|
||||
{
|
||||
return "你好";
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user