fix
wzy
2022-08-28 422be47bbda3dbf14a350b119bbf0d0eb3a91c3e
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
package cc.mrbird.febs;
 
import cc.mrbird.febs.common.contants.AppContants;
import cc.mrbird.febs.dapp.entity.DappFundFlowEntity;
import cc.mrbird.febs.dapp.entity.DappMemberBoxRecordEntity;
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.DappMemberBoxRecordMapper;
import cc.mrbird.febs.dapp.mapper.DappMemberDao;
import cc.mrbird.febs.dapp.mapper.DataDictionaryCustomMapper;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
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;
 
    @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);
    }
 
    @Autowired
    private DappFundFlowDao dappFundFlowDao;
 
    @Autowired
    private DappMemberBoxRecordMapper dappMemberBoxRecordMapper;
 
    @Test
    public void memberBoxTest() {
        QueryWrapper<DappFundFlowEntity> query = new QueryWrapper<>();
        query.eq("status", 2);
        query.eq("type", 1);
        List<DappFundFlowEntity> fundFLows = dappFundFlowDao.selectList(query);
        for (DappFundFlowEntity fundFLow : fundFLows) {
            DappMemberEntity member = dappMemberDao.selectById(fundFLow.getMemberId());
            DappMemberEntity parent = dappMemberDao.selectMemberInfoByInviteId(member.getRefererId());
            if (parent == null) {
                continue;
            }
 
            if (new BigDecimal(1600).compareTo(fundFLow.getAmount()) > 0) {
                System.out.println(fundFLow.getId());
                continue;
            }
 
            DappMemberBoxRecordEntity boxRecord = dappMemberBoxRecordMapper.selectByFromMemberId(fundFLow.getMemberId());
            if (boxRecord != null) {
                continue;
            }
 
            DappMemberBoxRecordEntity memberBoxRecordEntity = new DappMemberBoxRecordEntity();
            memberBoxRecordEntity.setMemberId(parent.getId());
            memberBoxRecordEntity.setAddress(parent.getAddress());
            memberBoxRecordEntity.setFromMemberId(member.getId());
            memberBoxRecordEntity.setFromAddress(member.getAddress());
            memberBoxRecordEntity.setCreateTime(fundFLow.getCreateTime());
            this.dappMemberBoxRecordMapper.insert(memberBoxRecordEntity);
        }
 
    }
}