diff --git a/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Application/Jobs/InterestRecordsJob.cs b/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Application/Jobs/InterestRecordsJob.cs index 4fb57230..80837a9e 100644 --- a/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Application/Jobs/InterestRecordsJob.cs +++ b/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Application/Jobs/InterestRecordsJob.cs @@ -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)) -//.WithSimpleSchedule(x => x -// .WithIntervalInSeconds(10) -// .RepeatForever()) -//.Build(); + // Trigger = TriggerBuilder.Create().WithIdentity(nameof(InterestRecordsJob)) + //.WithSimpleSchedule(x => x + // .WithIntervalInSeconds(10) + // .RepeatForever()) + //.Build(); } public override async Task Execute(IJobExecutionContext context) { //创建一个记录,莫得了 - await _bankManager.CreateInterestRecordsAsync(); + await _bankManager.GetCurrentInterestRate(); } } } diff --git a/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Domain/Managers/BankManager.cs b/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Domain/Managers/BankManager.cs index 5a8ee7ac..40308737 100644 --- a/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Domain/Managers/BankManager.cs +++ b/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Domain/Managers/BankManager.cs @@ -31,7 +31,7 @@ namespace Yi.Framework.Bbs.Domain.Managers /// /// 获取当前银行汇率 /// - public BankInterestRecordDto CurrentRate => GetCurrentInterestRate(); + public BankInterestRecordDto CurrentRate => GetCurrentInterestRate().GetAwaiter().GetResult(); /// /// 用于存储当前汇率数据 @@ -42,13 +42,13 @@ namespace Yi.Framework.Bbs.Domain.Managers /// 获取当前的银行汇率,如果为空会从数据库拿最新一条 /// /// - private BankInterestRecordDto GetCurrentInterestRate() + public async Task GetCurrentInterestRate() { var output = new BankInterestRecordDto(); //先判断时间是否与当前时间差1小时,小于1小时直接返回即可,可以由一个单例类提供 if (_currentRateStore is null || _currentRateStore.IsExpire()) { - var currentInterestRecords = CreateInterestRecordsAsync().GetAwaiter().GetResult(); + var currentInterestRecords =await CreateInterestRecordsAsync(); output.ComparisonValue = currentInterestRecords.ComparisonValue; output.CreationTime = currentInterestRecords.CreationTime; output.Value = currentInterestRecords.Value; @@ -68,7 +68,7 @@ namespace Yi.Framework.Bbs.Domain.Managers /// 强制创建一个记录,不管时间到没到 /// /// - public async Task CreateInterestRecordsAsync() + private async Task CreateInterestRecordsAsync() { //获取最新的实体 var lastEntity = await _interestRepository._DbQueryable.OrderByDescending(x => x.CreationTime).FirstAsync();