xiaoyong931011
2022-10-21 45189f71f0eb2c119ea15de98c76839e9ee4b570
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
package cc.mrbird.febs;
 
import cc.mrbird.febs.common.configure.i18n.MessageSourceUtils;
import cc.mrbird.febs.common.contants.AppContants;
import cc.mrbird.febs.common.exception.FebsException;
import cc.mrbird.febs.common.utils.RedisUtils;
import cc.mrbird.febs.dapp.entity.DappMemberEntity;
import cc.mrbird.febs.dapp.entity.DappOnHookAward;
import cc.mrbird.febs.dapp.entity.DataDictionaryCustom;
import cc.mrbird.febs.dapp.entity.IgtOnHookPlanOrderItem;
import cc.mrbird.febs.dapp.enumerate.DataDictionaryEnum;
import cc.mrbird.febs.dapp.enumerate.MemberOnHookPlanEnum;
import cc.mrbird.febs.dapp.mapper.DappMemberDao;
import cc.mrbird.febs.dapp.mapper.DappOnHookAwardDao;
import cc.mrbird.febs.dapp.mapper.DataDictionaryCustomMapper;
import cc.mrbird.febs.dapp.service.MemberOnHookPlan;
import cc.mrbird.febs.job.MineProfitJob;
import cn.hutool.core.codec.Base64;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUnit;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.CharsetUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.crypto.SecureUtil;
import cn.hutool.crypto.asymmetric.KeyType;
import cn.hutool.crypto.asymmetric.RSA;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
 
import java.math.BigDecimal;
import java.security.KeyPair;
import java.util.*;
 
/**
 * @author 
 * @date 2022-03-28
 **/
@SpringBootTest
public class JunitTest {
 
//    @Autowired
//    private MineProfitJob mineProfitJob;
//    @Autowired
//    private DappMemberDao dappMemberDao;
//
//    @Test
//    public void incomeTest() {
//        mineProfitJob.start();
//    }
//
//    @Test
//    public void userTest() {
//        DappMemberEntity member = dappMemberDao.selectById(6L);
//        mineProfitJob.calAgentMoney(member, BigDecimal.TEN);
//    }
//
//    public static void main(String[] args) {
//        DateTime tomorrow = DateUtil.beginOfDay(DateUtil.tomorrow());
//        System.out.println(DateUtil.between(new Date(), tomorrow, DateUnit.SECOND, true));
//    }
//
//    public String PUBLIC_KEY = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC1cHrcMpXoKNC8rjAa/jAbgU2bhIBmJmn6iYDfqt0Him/p2s5F0L9nfzZOLYlPq3z12zvXl9IgThhtLIBLi86RPW0ljuwpTvIZz9O36Zae9eMk5bMNsFEFsxg1IOLIM2Oc4ffNvGL58Uupp9RL5NCN1MRQyY61ISy7H2VRTznoJQIDAQAB";
//    public String PRIVATE_KEY = "MIICdQIBADANBgkqhkiG9w0BAQEFAASCAl8wggJbAgEAAoGBALVwetwylego0LyuMBr+MBuBTZuEgGYmafqJgN+q3QeKb+nazkXQv2d/Nk4tiU+rfPXbO9eX0iBOGG0sgEuLzpE9bSWO7ClO8hnP07fplp714yTlsw2wUQWzGDUg4sgzY5zh9828YvnxS6mn1Evk0I3UxFDJjrUhLLsfZVFPOeglAgMBAAECgYAPKWWS5gVB37tFsRajAs+5VK5MCyABqT8c6QWkay5KNYbRl2+6RM3h068RjFuXlUB9eQMAqpasDWqcIOZdqcKqmxm0ILF2zfPzJr4RaQNSNwDCVrKEeaDtrZQcq/0ygaNDF9y203UMHT0dfEQSGp/xkjTgXNsOuC9iLM56XScOVwJBAPOZLbrCi0h4PL7g3rWsCw8/aN6ehkJ3iTDgjYpdBwJOJSyxV0qi0xmDthGqPd99Kvc14u1jy3ghpm1SAEunrj8CQQC+rS6qajIkK7NiRmX43chDhgMPGo0UFHbmHyYBb1Eyrxu1MNWQEh221p54GsB2HqAGRhxxQ98Ds2S26Au7QpibAkA2nQAAn/8kFzjfPoEPz+uG1puHVZkaK7yJRb7V53dbz/NLqtK8O/cCAGKAYV+PzHsmg2FGAZqrazfpyHmifIx3AkBnFau/+A/JnFKr09F3XTfSwZXPyZPyAipRuQ9MAUmNtDuvloovDIxB9//OgPACLAZpvefMmFvuXUMa25LUF2n3AkBGb+vO+69NSyQM2SHKZ9fUrxx9ZPhupNt/TXNL9OMEQiLaHCYgg0tfcojGe3QjBCA6wVG+dCyZUcv5OwiW23pI";
//
//    @Test
//    public void encodeTest() {
//        RSA rsa = new RSA(AppContants.REQ_PRIVATE_KEY, AppContants.REQ_PUBLIC_KEY);
//        Map<String, Object> map = new HashMap<>();
//        map.put("test", 123);
//        String s = JSONObject.toJSONString(map);
//        String s1 = rsa.encryptBase64(s, KeyType.PublicKey);
//        System.out.println(s1);
//    }
//
//    @Test
//    public void decodeTest() {
//        String ss = "pAEYpX4a+gm9lqy2/bQNx/EjJS0D7I/ezcCB+G/pgI5GDLWUj7+S7jhGWlV2PTGHcNj8vJQRXp5qpV7GOmaQX30HVao3srsOEL2CWU5F/5A4T9ncs3NuoYEv5LUCTolEEq8r5VdBRzU9BoZCISLFQxjFIp5inuydjz2JE9lnOBYQIP8kZSXHy2N1gkythypbj81q9cC83wNND7pvSjw140EDtXWqlCIhpoZlwB/n8+D5khBHwxWhuf0wacYLj9aKZ8tSKMyw0/WdQvpBZ6ymxuoHrLlcL36PTEN59rce9tnnRs5+AjAXppx4GIODdvbHLQJurBslw2GVHJeDbugRvA==";
//        RSA rsa = new RSA(AppContants.RESP_PRIVATE_KEY, AppContants.RESP_PUBLIC_KEY);
//        String s = rsa.decryptStr(ss, KeyType.PrivateKey);
//        System.out.println(s);
//    }
//
    @Autowired
    private DataDictionaryCustomMapper dataDictionaryCustomMapper;
    @Autowired
    private RedisUtils redisUtils;
    @Autowired
    private DappOnHookAwardDao dappOnHookAwardDao;
    @Test
    public void getmember(){//获取下一个开奖
        String redisKey = "on_hook_award_id";
        String onHookAwardRedisId = redisUtils.getString(redisKey);
        DappOnHookAward dappOnHookAward = dappOnHookAwardDao.selectById(Long.parseLong(onHookAwardRedisId));
        if(ObjectUtil.isEmpty(dappOnHookAward)){
            throw new FebsException(MessageSourceUtils.getString("login_err_003"));
        }
        Date awardTime = dappOnHookAward.getAwardTime();
        System.out.println(awardTime);
        DateTime dateTime = DateUtil.offsetMinute(awardTime, 5);
        for(int i =1; i < 100;i++){
            String yyyyMMddHHMM = DateUtil.format(dateTime, "yyyy-MM-dd HH:mm");
//            DappOnHookAward dappOnHookAwardNext = dappOnHookAwardDao.selectByByAwardTime(yyyyMMddHHMM);
            System.out.println(yyyyMMddHHMM);
            dateTime = DateUtil.offsetMinute(dateTime, 5);
        }
    }
 
    @Autowired
    private DappMemberDao dappMemberDao;
    @Test
    public void getplan(){
        DappMemberEntity dappMember = dappMemberDao.selectById(33);
        List<DataDictionaryCustom> dataDictionaryCustoms = dataDictionaryCustomMapper.selectDicByType(DataDictionaryEnum.PLAN_A.getType());
        LinkedList<Map<String,String>> strings = new LinkedList<>();
        for(DataDictionaryCustom dataDictionaryCustom : dataDictionaryCustoms){
            Map<String, String> stringStringHashMap = new HashMap<>();
            stringStringHashMap.put(dataDictionaryCustom.getDescription(),dataDictionaryCustom.getValue());
            strings.add(stringStringHashMap);
        }
        //收益率
        BigDecimal hangingRevenue = BigDecimal.ZERO;
        //挂机时长
        DataDictionaryCustom maxHours = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.MAX_HOURS.getType(), DataDictionaryEnum.MAX_HOURS.getCode());
        if(ObjectUtil.isEmpty(maxHours)){
            throw new FebsException(MessageSourceUtils.getString("login_err_003"));
        }
 
        Double maxHoursValue = Double.parseDouble(maxHours.getValue());
        //获取用户信息的是否盈利字段
        Integer isProfit = dappMember.getIsProfit() == null ? 1 : dappMember.getIsProfit();
        String identity = null;
        if(isProfit == 2){
            identity = "IS_PROFIT_NO";
        }else{
            identity = "LEVEL_MB";
            DataDictionaryCustom levelMember = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.LEVEL_MB.getType(), dappMember.getIdentity());
            if(ObjectUtil.isEmpty(levelMember)){
                throw new FebsException(MessageSourceUtils.getString("login_err_003"));
            }
            String levelMemberValue = levelMember.getValue();
            JSONObject levelMemberValueParse = JSONUtil.parseObj(levelMemberValue);
            hangingRevenue = new BigDecimal(levelMemberValueParse.get("hangingRevenue").toString())
                    .multiply(new BigDecimal(0.01)).setScale(4,BigDecimal.ROUND_DOWN);
        }
        //获取挂机字表的顺序
        LinkedList<String> isProfitPlan = new LinkedList<>();
        Map<String, LinkedList<String>> identity_level = MemberOnHookPlanEnum.valueOf(identity)
                .getMemberOnHook(maxHoursValue,hangingRevenue,strings);
        isProfitPlan = identity_level.get(identity);
        System.out.println(isProfitPlan);
 
    }
 
 
}