From 1b44a9a25a51324dba8e8640cb405440f2cf7d48 Mon Sep 17 00:00:00 2001
From: Helius <wangdoubleone@gmail.com>
Date: Thu, 13 May 2021 11:21:32 +0800
Subject: [PATCH] modify
---
src/main/java/com/xcong/excoin/quartz/job/XchBaseDataUpdateJob.java | 32 +++++++++++++++++++++++++++++++-
1 files changed, 31 insertions(+), 1 deletions(-)
diff --git a/src/main/java/com/xcong/excoin/quartz/job/XchBaseDataUpdateJob.java b/src/main/java/com/xcong/excoin/quartz/job/XchBaseDataUpdateJob.java
index 4014f9d..b4ea8f0 100644
--- a/src/main/java/com/xcong/excoin/quartz/job/XchBaseDataUpdateJob.java
+++ b/src/main/java/com/xcong/excoin/quartz/job/XchBaseDataUpdateJob.java
@@ -4,6 +4,8 @@
import com.alibaba.fastjson.JSONObject;
import com.xcong.excoin.modules.yunding.dao.YdBasicSettingDao;
import com.xcong.excoin.modules.yunding.entity.YdBasicSettingEntity;
+import com.xcong.excoin.modules.yunding.service.XchProfitService;
+import com.xcong.excoin.utils.RedisUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
@@ -28,6 +30,10 @@
@Autowired
private YdBasicSettingDao ydBasicSettingDao;
+ @Autowired
+ private RedisUtils redisUtils;
+ @Autowired
+ private XchProfitService xchProfitService;
@Scheduled(cron = "* */1 * * * ? ")
public void baseDataUpdate() {
@@ -35,8 +41,11 @@
String result = getUrlResponse("https://api2.chiaexplorer.com/blockchainSummary");
// 每t预计收益
String profitPerT = getUrlResponse("https://api2.chiaexplorer.com/chart/xchTibDay?period=2w");
+
+ String xchPrice24HStr = getUrlResponse("https://api2.chiaexplorer.com/chart/xchPriceChart?period=24h");
JSONObject jsonObject = (JSONObject) JSONObject.parse(result);
JSONObject perTObject = (JSONObject) JSONObject.parse(profitPerT);
+ JSONObject xchPrice24HObj = (JSONObject) JSONObject.parse(xchPrice24HStr);
List<YdBasicSettingEntity> list = ydBasicSettingDao.selectList(null);
if (CollUtil.isNotEmpty(list)) {
YdBasicSettingEntity settingEntity = list.get(0);
@@ -45,7 +54,15 @@
BigDecimal netspace = new BigDecimal(netspaceStr).divide(baseUnit.multiply(baseUnit.multiply(baseUnit.multiply(baseUnit.multiply(baseUnit)))), 2, BigDecimal.ROUND_DOWN);
settingEntity.setAllPower(netspace);
- settingEntity.setCurrentPrice(new BigDecimal(jsonObject.getString("price")));
+ BigDecimal newPrice = new BigDecimal(jsonObject.getString("price"));
+ redisUtils.set("XCH_NEW_PRICE", newPrice);
+ settingEntity.setCurrentPrice(newPrice);
+
+ List<String> xchPrice24H = JSONObject.parseArray(xchPrice24HObj.getString("data"), String.class);
+ BigDecimal newestPrice = new BigDecimal(xchPrice24H.get(xchPrice24H.size() - 1));
+ BigDecimal lastPrice = new BigDecimal(xchPrice24H.get(xchPrice24H.size() - 1 -24));
+ BigDecimal upOrDown = newestPrice.subtract(lastPrice).multiply(BigDecimal.valueOf(100)).divide(lastPrice, 2, BigDecimal.ROUND_HALF_UP);
+ redisUtils.set("XCH_UP_DOWN", upOrDown);
List<String> data = JSONObject.parseArray(perTObject.getString("data"), String.class);
settingEntity.setPrifitT(new BigDecimal(data.get(0)));
settingEntity.setProfitDay(new BigDecimal(data.get(0)).multiply(BigDecimal.valueOf(1024)));
@@ -61,6 +78,7 @@
// 模拟浏览器
String userAgent = "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.66 Safari/537.36";
try {
+ System.setProperty("https.protocols", "TLSv1,TLSv1.1,TLSv1.2");
URL request = new URL(url);
HttpURLConnection connection = (HttpURLConnection) request.openConnection();
connection.setRequestMethod("GET");
@@ -84,4 +102,16 @@
return result;
}
+
+// @Scheduled(cron = "0 0 23 * * ?")
+ public void xchProfitJob() {
+ log.info("XCH收益返利任务");
+// xchProfitService.xchProfitDistributor();
+ }
+
+// @Scheduled(cron = "0 0 22 * * ?")
+ public void usdtProfitJob() {
+ log.info("USDT返利任务");
+// xchProfitService.agentUsdtProfitDistributor();
+ }
}
--
Gitblit v1.9.1