xiaoyong931011
2022-12-14 44917e4eff170a1fc2d490b54146a6570505827e
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
package cc.mrbird.febs;
 
import cc.mrbird.febs.common.contants.AppContants;
import cc.mrbird.febs.dapp.chain.ChainEnum;
import cc.mrbird.febs.dapp.chain.ChainService;
import cc.mrbird.febs.dapp.entity.DappFundFlowEntity;
import cc.mrbird.febs.dapp.entity.DappMemberEntity;
import cc.mrbird.febs.dapp.entity.DataDictionaryCustom;
import cc.mrbird.febs.dapp.mapper.DappFundFlowDao;
import cc.mrbird.febs.dapp.mapper.DappMemberDao;
import cc.mrbird.febs.dapp.mapper.DataDictionaryCustomMapper;
import cc.mrbird.febs.rabbit.producer.ChainProducer;
import cn.hutool.core.util.StrUtil;
import org.apache.commons.lang3.StringUtils;
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.util.List;
 
/**
 * @author wzy
 * @date 2022-06-09
 **/
@SpringBootTest
public class MemberTest {
 
    @Autowired
    private DappMemberDao dappMemberDao;
 
    @Autowired
    private DataDictionaryCustomMapper dataDictionaryCustomMapper;
 
    @Autowired
    private DappFundFlowDao dappFundFlowDao;
 
    @Autowired
    private ChainProducer chainProducer;
    //        String address = dappMemberEntity.getAddress();
//        String hash = ChainService.getInstance(ChainEnum.BSC_USDT.name()).transfer(address, amount);
//        if(StrUtil.isEmpty(hash)){
//            return;
//        }
    @Test
    public void tranfer(){
        String address = "0xd9076245473060dda1a65f5f3d89a4d0598995e6";
        BigDecimal amount = new BigDecimal("0.00005000");
        String hash = ChainService.getInstance(ChainEnum.BNB.name()).transferBaseToken(address, amount);
////        if(StrUtil.isEmpty(hash)){
////            return;
////        }
//        BigDecimal balance = ChainService.getInstance(ChainEnum.WBNB.name()).balanceOf(ChainEnum.WBNB.getAddress());
//        Integer count = dappFundFlowDao.updateStatusById(DappFundFlowEntity.WITHDRAW_STATUS_AGREE,464L);
        System.out.println(hash);
 
        //发送转币消息
//        chainProducer.sendBnbTransferMsg(93L);
//        chainProducer.sendBnbTransferMsg(94L);
//        chainProducer.sendBnbTransferMsg(95L);
//        chainProducer.sendBnbTransferMsg(96L);
    }
 
    @Test
    public void balance() {
        BigDecimal hash = ChainService.getInstance(ChainEnum.BNB.name()).balanceOfBaseToken(ChainEnum.BNB.getAddress());
        System.out.println(hash);
    }
 
    @Test
    public void refererIdsTest() {
        DappMemberEntity member = dappMemberDao.selectById(24);
 
        boolean flag = false;
        String parentId = "35087336";
        String ids = "";
        String feeProfitIds = "";
 
        int i = 1;
        List<DataDictionaryCustom> feeProfitDic = dataDictionaryCustomMapper.selectDicByType(AppContants.DIC_TYPE_DISTRIBUTE_PROP);
        while (!flag && StringUtils.isNotBlank(parentId)) {
            if (StrUtil.isBlank(ids)) {
                ids += parentId;
            } else {
                ids += ("," + parentId);
            }
 
            if (i <= 4) {
                if (StrUtil.isBlank(feeProfitIds)) {
                    feeProfitIds += parentId;
                } else {
                    feeProfitIds += ("," + parentId);
                }
            }
 
            i++;
            DappMemberEntity parentMember = dappMemberDao.selectMemberInfoByInviteId(parentId);
            if (parentMember == null) {
                break;
            }
            parentId = parentMember.getRefererId();
            if(StringUtils.isBlank(parentId) || "0".equals(parentId)){
                break;
            }
            if (parentMember.getRefererId().equals(parentMember.getInviteId())) {
                flag = true;
            }
        }
        member.setRefererIds(ids);
        member.setFeeProfitIds(feeProfitIds);
    }
}