Merge branch 'abp-dev' into abp

This commit is contained in:
chenchun
2024-06-27 17:06:42 +08:00
2 changed files with 10 additions and 10 deletions

View File

@@ -17,16 +17,16 @@ namespace Yi.Framework.Bbs.Application.Jobs
Trigger = TriggerBuilder.Create().WithIdentity(nameof(InterestRecordsJob)).WithCronSchedule("0 0 * * * ?").Build(); Trigger = TriggerBuilder.Create().WithIdentity(nameof(InterestRecordsJob)).WithCronSchedule("0 0 * * * ?").Build();
//测试 //测试
// Trigger = TriggerBuilder.Create().WithIdentity(nameof(InterestRecordsJob)) // Trigger = TriggerBuilder.Create().WithIdentity(nameof(InterestRecordsJob))
//.WithSimpleSchedule(x => x //.WithSimpleSchedule(x => x
// .WithIntervalInSeconds(10) // .WithIntervalInSeconds(10)
// .RepeatForever()) // .RepeatForever())
//.Build(); //.Build();
} }
public override async Task Execute(IJobExecutionContext context) public override async Task Execute(IJobExecutionContext context)
{ {
//创建一个记录,莫得了 //创建一个记录,莫得了
await _bankManager.CreateInterestRecordsAsync(); await _bankManager.GetCurrentInterestRate();
} }
} }
} }

View File

@@ -31,7 +31,7 @@ namespace Yi.Framework.Bbs.Domain.Managers
/// <summary> /// <summary>
/// 获取当前银行汇率 /// 获取当前银行汇率
/// </summary> /// </summary>
public BankInterestRecordDto CurrentRate => GetCurrentInterestRate(); public BankInterestRecordDto CurrentRate => GetCurrentInterestRate().GetAwaiter().GetResult();
/// <summary> /// <summary>
/// 用于存储当前汇率数据 /// 用于存储当前汇率数据
@@ -42,13 +42,13 @@ namespace Yi.Framework.Bbs.Domain.Managers
/// 获取当前的银行汇率,如果为空会从数据库拿最新一条 /// 获取当前的银行汇率,如果为空会从数据库拿最新一条
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
private BankInterestRecordDto GetCurrentInterestRate() public async Task<BankInterestRecordDto> GetCurrentInterestRate()
{ {
var output = new BankInterestRecordDto(); var output = new BankInterestRecordDto();
//先判断时间是否与当前时间差1小时小于1小时直接返回即可,可以由一个单例类提供 //先判断时间是否与当前时间差1小时小于1小时直接返回即可,可以由一个单例类提供
if (_currentRateStore is null || _currentRateStore.IsExpire()) if (_currentRateStore is null || _currentRateStore.IsExpire())
{ {
var currentInterestRecords = CreateInterestRecordsAsync().GetAwaiter().GetResult(); var currentInterestRecords =await CreateInterestRecordsAsync();
output.ComparisonValue = currentInterestRecords.ComparisonValue; output.ComparisonValue = currentInterestRecords.ComparisonValue;
output.CreationTime = currentInterestRecords.CreationTime; output.CreationTime = currentInterestRecords.CreationTime;
output.Value = currentInterestRecords.Value; output.Value = currentInterestRecords.Value;
@@ -68,7 +68,7 @@ namespace Yi.Framework.Bbs.Domain.Managers
/// 强制创建一个记录,不管时间到没到 /// 强制创建一个记录,不管时间到没到
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
public async Task<InterestRecordsAggregateRoot> CreateInterestRecordsAsync() private async Task<InterestRecordsAggregateRoot> CreateInterestRecordsAsync()
{ {
//获取最新的实体 //获取最新的实体
var lastEntity = await _interestRepository._DbQueryable.OrderByDescending(x => x.CreationTime).FirstAsync(); var lastEntity = await _interestRepository._DbQueryable.OrderByDescending(x => x.CreationTime).FirstAsync();