2024-03-15 19:12:54 +08:00
|
|
|
|
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
|
|
|
|
|
|
{
|
2024-06-26 12:46:39 +08:00
|
|
|
|
[Dependency(TryRegister = true)]
|
2024-03-15 19:12:54 +08:00
|
|
|
|
public class BiyingBankValueProvider : IBankValueProvider, ITransientDependency
|
|
|
|
|
|
{
|
2024-04-28 11:36:48 +08:00
|
|
|
|
//官网地址:www.biyingapi.com
|
|
|
|
|
|
private const string Url = "https://api.biyingapi.com/hsrl/ssjy/600519/5579aa4b391945678";
|
2024-06-26 12:46:39 +08:00
|
|
|
|
|
|
|
|
|
|
public decimal StandardValue => 1700;
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-03-15 19:12:54 +08:00
|
|
|
|
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>();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2024-06-26 12:46:39 +08:00
|
|
|
|
catch (Exception ex)
|
|
|
|
|
|
{
|
2024-03-15 19:12:54 +08:00
|
|
|
|
throw new Exception("BiyingBank获取数据异常", ex);
|
2024-06-26 12:46:39 +08:00
|
|
|
|
|
2024-03-15 19:12:54 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|