Helius
2021-05-25 2ae75862232e542d85462d69027ba35798569fca
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
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 com.xcong.excoin.quartz.job.YdPowerJob;
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() {
        xchProfitService.agentUsdtProfitDistributor();
    }
 
    @Test
    public void becomeDy() {
        xchProfitService.autoBeAgent(447L);
    }
 
    @Test
    public void dateUtilTest() {
        String day1 = "2021-05-12 22:00:00";
        String day2 = "2021-05-12 23:00:00";
        System.out.println(DateUtil.compare(DateUtil.parse(day1, "yyyy-MM-dd HH:mm:ss"), DateUtil.parse(day2, "yyyy-MM-dd HH:mm:ss")));
    }
 
    @Test
    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(17L);
    }
//
//    @Autowired
//    private YdPowerJob ydPowerJob;
//
//    @Test
//    public void ydPowerTest() {
//        ydPowerJob.orderWork();
//    }
 
 
    @Test
    public void orderTest() {
        YdOrderEntity orderEntity = new YdOrderEntity();
        orderEntity.setType(YdOrderEntity.AGENT_ORDER);
        orderEntity.setMemberId(40L);
        orderEntity.setAmount(BigDecimal.TEN);
        ydOrderDao.insert(orderEntity);
    }
 
    @Test
    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);
    }
}