| | |
| | | package com.xcong.excoin; |
| | | |
| | | |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.core.date.DateUnit; |
| | | import cn.hutool.core.date.DateUtil; |
| | | import cn.hutool.core.util.ObjectUtil; |
| | | import cn.hutool.http.HttpRequest; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.xcong.excoin.modules.coin.parameter.dto.CoinInListDto; |
| | | import com.xcong.excoin.modules.coin.service.CoinService; |
| | | import com.xcong.excoin.modules.yunding.dao.YdOrderDao; |
| | | import com.xcong.excoin.modules.yunding.entity.YdOrderEntity; |
| | | import com.xcong.excoin.modules.yunding.service.XchProfitService; |
| | |
| | | import org.junit.jupiter.api.Test; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.boot.test.context.SpringBootTest; |
| | | import org.springframework.util.ClassUtils; |
| | | |
| | | import java.io.BufferedReader; |
| | | import java.io.IOException; |
| | | import java.io.InputStreamReader; |
| | | import java.io.LineNumberReader; |
| | | import java.math.BigDecimal; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | @SpringBootTest |
| | | public class XchTest { |
| | | |
| | | @Autowired |
| | | private XchProfitService xchProfitService; |
| | | @Autowired |
| | | private YdOrderDao ydOrderDao; |
| | | |
| | | @Test |
| | | public void usdtReturnTest() { |
| | |
| | | } |
| | | |
| | | @Test |
| | | public void becomeAgentTest() { |
| | | xchProfitService.autoBeAgent(40L); |
| | | public void orderWork() { |
| | | QueryWrapper<YdOrderEntity> objectQueryWrapper = new QueryWrapper<>(); |
| | | objectQueryWrapper.eq("state",YdOrderEntity.ORDER_STATE_READY); |
| | | objectQueryWrapper.eq("type",YdOrderEntity.PRODUCT_ORDER); |
| | | List<YdOrderEntity> ydOrderEntities = ydOrderDao.selectList(objectQueryWrapper); |
| | | Date date = new Date(); |
| | | if(CollUtil.isNotEmpty(ydOrderEntities)){ |
| | | for(YdOrderEntity ydOrderEntity : ydOrderEntities){ |
| | | Date workTime = ydOrderEntity.getWorkTime(); |
| | | if(ObjectUtil.isNotEmpty(workTime) && DateUtil.compare(date, workTime) > -1){ |
| | | Long id = ydOrderEntity.getId(); |
| | | ydOrderDao.UpdateByIdAndState(id,YdOrderEntity.ORDER_STATE_WORK); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | @Test |
| | | public void orderUsdtProfitTest() { |
| | | xchProfitService.usdtProfitDistributorByOrderId(7L); |
| | | xchProfitService.usdtProfitDistributorByOrderId(17L); |
| | | } |
| | | // |
| | | // @Autowired |
| | |
| | | // ydPowerJob.orderWork(); |
| | | // } |
| | | |
| | | @Autowired |
| | | private YdOrderDao ydOrderDao; |
| | | |
| | | @Test |
| | | public void orderTest() { |
| | |
| | | public void xchProfitTest() { |
| | | xchProfitService.xchProfitDistributor(BigDecimal.valueOf(1)); |
| | | } |
| | | |
| | | @Autowired |
| | | private CoinService coinService; |
| | | |
| | | @Test |
| | | public void coinTest() { |
| | | CoinInListDto coin = new CoinInListDto(); |
| | | coin.setType(4); |
| | | coin.setPageNum(1); |
| | | coin.setPageSize(10); |
| | | coinService.coinInList(coin); |
| | | } |
| | | |
| | | public static void main(String[] args) { |
| | | // String s = execCurl("https://api2.chiaexplorer.com/blockchainSummary"); |
| | | // System.out.println(s); |
| | | |
| | | String body = HttpRequest.get("https://api2.chiaexplorer.com/blockchainSummary").execute().body(); |
| | | System.out.println(body); |
| | | } |
| | | |
| | | private static String execCurl(String url) { |
| | | String[] cmds = {"curl", url |
| | | , "-H", "sec-ch-ua: \" Not A;Brand\";v=\"99\", \"Chromium\";v=\"90\", \"Google Chrome\";v=\"90\"" |
| | | ,"-H", "Accept: application/json, text/plain, */*" |
| | | ,"-H", "Referer: https://www.chiaexplorer.com/" |
| | | ,"-H", "sec-ch-ua-mobile: ?0" |
| | | ,"-H", "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.212 Safari/537.36" |
| | | ," --compressed"}; |
| | | |
| | | ProcessBuilder process = new ProcessBuilder(cmds); |
| | | Process p; |
| | | try { |
| | | p = process.start(); |
| | | BufferedReader reader = new BufferedReader(new InputStreamReader(p.getInputStream())); |
| | | StringBuilder builder = new StringBuilder(); |
| | | String line; |
| | | while ((line = reader.readLine()) != null) { |
| | | builder.append(line); |
| | | builder.append(System.getProperty("line.separator")); |
| | | } |
| | | return builder.toString(); |
| | | |
| | | } catch (IOException e) { |
| | | System.out.print("error"); |
| | | e.printStackTrace(); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | @Test |
| | | public void pyExec() { |
| | | String result = ""; |
| | | String path = ClassUtils.getDefaultClassLoader().getResource("").getPath(); |
| | | String filePath = path + "static/xch.py"; |
| | | System.out.println(filePath); |
| | | try { |
| | | Process process = Runtime.getRuntime().exec("python " + filePath); |
| | | process.waitFor(); |
| | | InputStreamReader ir = new InputStreamReader(process.getInputStream()); |
| | | LineNumberReader input = new LineNumberReader(ir); |
| | | result = input.readLine(); |
| | | input.close(); |
| | | ir.close(); |
| | | // process.waitFor(); |
| | | } catch (IOException | InterruptedException e) { |
| | | System.out.println(11); |
| | | } |
| | | System.out.println(result); |
| | | } |
| | | } |