feat: 完成第三方利息汇率对接

This commit is contained in:
陈淳
2024-03-15 19:12:54 +08:00
parent e989313b0d
commit 822febba2e
6 changed files with 201 additions and 17 deletions

View File

@@ -0,0 +1,35 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Volo.Abp.DependencyInjection;
namespace Yi.Framework.Bbs.Domain.Managers.BankValue
{
public class BiyingBankValueProvider : IBankValueProvider, ITransientDependency
{
private const string Url = "https://api.biyingapi.com/hsrl/ssjy/600519/504d30854dbd93312d";
public async Task<decimal> GetValueAsync()
{
try
{
using (HttpClient client = new HttpClient())
{
var reponse = await client.GetAsync(Url);
reponse.EnsureSuccessStatusCode();
var dataStr = await reponse.Content.ReadAsStringAsync();
JObject jsonObject = JObject.Parse(dataStr);
return jsonObject["p"].Value<decimal>();
}
}
catch(Exception ex) {
throw new Exception("BiyingBank获取数据异常", ex);
}
}
}
}

View File

@@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Yi.Framework.Bbs.Domain.Managers.BankValue
{
public interface IBankValueProvider
{
public Task<decimal> GetValueAsync();
}
}