fix: 修复银行汇率问题

This commit is contained in:
chenchun
2024-07-05 17:40:02 +08:00
parent 426c67631a
commit 8bf01451a8

View File

@@ -70,23 +70,12 @@ namespace Yi.Framework.Bbs.Domain.Managers
/// <returns></returns> /// <returns></returns>
private async Task<InterestRecordsAggregateRoot> CreateInterestRecordsAsync() private async Task<InterestRecordsAggregateRoot> CreateInterestRecordsAsync()
{ {
//获取最新的实体
var lastEntity = await _interestRepository._DbQueryable.OrderByDescending(x => x.CreationTime).FirstAsync();
decimal oldValue = DefalutRate; decimal oldValue = DefalutRate;
var thirdPartyValue = await _bankValueProvider.GetValueAsync(); var thirdPartyValue = await _bankValueProvider.GetValueAsync();
//获取实际值的变化率 //获取实际值的变化率
decimal changeRate = (thirdPartyValue - _bankValueProvider.StandardValue) / (thirdPartyValue); decimal changeRate = (thirdPartyValue - _bankValueProvider.StandardValue) / (thirdPartyValue);
//说明不是第一次
if (lastEntity is not null)
{
oldValue = lastEntity.Value;
}
//判断市场是否波动 //判断市场是否波动
bool isFluctuate = IsMarketVolatility(); bool isFluctuate = IsMarketVolatility();
//市场波动 //市场波动
@@ -98,7 +87,7 @@ namespace Yi.Framework.Bbs.Domain.Managers
//根据上一次的老值进行变化率比较 //根据上一次的老值进行变化率比较
var currentValue = oldValue + (oldValue * changeRate); var currentValue = oldValue + (oldValue * changeRate);
var entity = new InterestRecordsAggregateRoot(thirdPartyValue, currentValue); var entity = new InterestRecordsAggregateRoot(thirdPartyValue, currentValue, isFluctuate);
var output = await _interestRepository.InsertReturnEntityAsync(entity); var output = await _interestRepository.InsertReturnEntityAsync(entity);
return output; return output;