| | |
| | | package cc.mrbird.febs; |
| | | |
| | | import cc.mrbird.febs.common.contants.AppContants; |
| | | import cc.mrbird.febs.common.enumerates.DataDicEnum; |
| | | import cc.mrbird.febs.common.utils.RedisUtils; |
| | | import cc.mrbird.febs.dapp.chain.ChainEnum; |
| | | import cc.mrbird.febs.dapp.chain.ChainService; |
| | | import cc.mrbird.febs.dapp.chain.ContractEventService; |
| | | import cc.mrbird.febs.dapp.entity.DappAchieve; |
| | | import cc.mrbird.febs.dapp.entity.DappMemberEntity; |
| | | import cc.mrbird.febs.dapp.entity.DataDictionaryCustom; |
| | | import cc.mrbird.febs.dapp.mapper.DappAchieveMapper; |
| | | import cc.mrbird.febs.dapp.mapper.DappMemberDao; |
| | | import cc.mrbird.febs.dapp.mapper.DataDictionaryCustomMapper; |
| | | import cc.mrbird.febs.dapp.service.AsyncCjService; |
| | | import cc.mrbird.febs.dapp.service.DappSystemService; |
| | | import cc.mrbird.febs.rabbit.producer.ChainProducer; |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import org.junit.jupiter.api.Test; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.boot.test.context.SpringBootTest; |
| | | import org.springframework.scheduling.annotation.Scheduled; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.math.BigInteger; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * @author wzy |
| | |
| | | @Autowired |
| | | private ContractEventService bscCoinContractEvent; |
| | | |
| | | @Autowired |
| | | private DappMemberDao dappMemberDao; |
| | | |
| | | public static boolean shouldOutputString(String inputString, String target) { |
| | | // 按逗号分隔字符串 |
| | | String[] substrings = inputString.split(","); |
| | | |
| | | // 从前往后遍历子串数组 |
| | | for (int i = 0; i < substrings.length; i++) { |
| | | // 去掉子串两侧的空白字符(如果有的话) |
| | | String trimmedSubstring = substrings[i].trim(); |
| | | |
| | | // 检查子串是否与目标字符串匹配 |
| | | if (trimmedSubstring.equals(target)) { |
| | | // 如果匹配且位置小于8(基于0索引,所以实际上是前8个或更前的位置) |
| | | if (i < 8) { |
| | | return true; // 输出整个原始字符串 |
| | | } |
| | | break; // 匹配但位置不在要求范围内,退出循环 |
| | | } |
| | | } |
| | | |
| | | return false; // 没有找到匹配项或匹配项位置不符合要求 |
| | | } |
| | | @Test |
| | | public void mineJob() { |
| | | ChainService.coinRewardEventListener(BigInteger.valueOf(40116050), null, bscCoinContractEvent, ChainEnum.BSC_GFA.name()); |
| | | List<DappMemberEntity> dappMemberEntities1 = dappMemberDao.selectList(null); |
| | | for(DappMemberEntity member: dappMemberEntities1){ |
| | | List<DappMemberEntity> dappMemberEntities = dappMemberDao.selectChildMemberDirectOrNot(member.getInviteId(), 2); |
| | | //八层团队业绩 |
| | | if(CollUtil.isNotEmpty(dappMemberEntities)){ |
| | | ArrayList<DappMemberEntity> objects = new ArrayList<>(); |
| | | for(DappMemberEntity memberEntity : dappMemberEntities){ |
| | | String refererIds = memberEntity.getRefererIds(); |
| | | if (shouldOutputString(refererIds, member.getInviteId())) { |
| | | objects.add(memberEntity); |
| | | } |
| | | } |
| | | List<Long> collect = objects.stream().map(DappMemberEntity::getId).collect(Collectors.toList()); |
| | | QueryWrapper<DappAchieve> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.in("member_id",collect); |
| | | List<DappAchieve> dappAchieveSumList = dappAchieveMapper.selectList(queryWrapper); |
| | | |
| | | List<DappAchieve> filteredList = dappAchieveSumList.stream() |
| | | .filter(obj -> obj.getState() == 1) |
| | | .collect(Collectors.toList()); |
| | | BigDecimal perkAmount = filteredList.stream().map(DappAchieve::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | System.out.println("address:"+member.getAddress()+",金额:"+perkAmount); |
| | | |
| | | }else{ |
| | | System.out.println("address:"+member.getAddress()+",金额:"+BigDecimal.ZERO); |
| | | } |
| | | } |
| | | |
| | | // ChainService.coinRewardEventListener(BigInteger.valueOf(40116050), null, bscCoinContractEvent, ChainEnum.BSC_GFA.name()); |
| | | // List<DappAchieve> dappAchieves = dappAchieveMapper.selectList(null); |
| | | // if(CollUtil.isNotEmpty(dappAchieves)){ |
| | | // for(DappAchieve dappAchieve : dappAchieves){ |