| | |
| | | package cc.mrbird.febs; |
| | | |
| | | import cc.mrbird.febs.common.contants.AppContants; |
| | | import cc.mrbird.febs.common.contants.SystemConstants; |
| | | 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.contract.ContractMain; |
| | | import cc.mrbird.febs.dapp.entity.DappAKlineEntity; |
| | | import cc.mrbird.febs.dapp.entity.DappMemberEntity; |
| | | import cc.mrbird.febs.dapp.entity.DataDictionaryCustom; |
| | | import cc.mrbird.febs.dapp.mapper.DappAKlineMapper; |
| | | 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.dapp.service.DappSystemService; |
| | | import cc.mrbird.febs.dapp.vo.AKLineLimitVo; |
| | | import cc.mrbird.febs.dapp.vo.AKLineVo; |
| | | import cc.mrbird.febs.rabbit.producer.ChainProducer; |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.core.date.DateTime; |
| | | import cn.hutool.core.date.DateUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import cn.hutool.json.JSONArray; |
| | | import cn.hutool.json.JSONObject; |
| | | import cn.hutool.json.JSONUtil; |
| | | 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 org.web3j.utils.Convert; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.math.BigInteger; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * @author wzy |
| | |
| | | @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 DappMemberDao dappMemberDao; |
| | | // |
| | | // @Autowired |
| | | // private DataDictionaryCustomMapper dataDictionaryCustomMapper; |
| | | // |
| | | // @Autowired |
| | | // private DappFundFlowDao dappFundFlowDao; |
| | | // |
| | | // @Autowired |
| | | // private ContractMain contractMain; |
| | | // |
| | | // @Autowired |
| | | // private ChainProducer chainProducer; |
| | | // |
| | | // @Autowired |
| | | // private DappAKlineMapper dappAKlineMapper; |
| | | // |
| | | // @Autowired |
| | | // private RedisUtils redisUtils; |
| | | // // String address = dappMemberEntity.getAddress(); |
| | | //// String hash = ChainService.getInstance(ChainEnum.BSC_USDT.name()).transfer(address, amount); |
| | | //// if(StrUtil.isEmpty(hash)){ |
| | | //// return; |
| | | //// } |
| | | // |
| | | // public static void main(String[] args) { |
| | | // } |
| | | // @Test |
| | | // public void tranfer(){ |
| | | // dappSystemService.antKLineMsg(1); |
| | | //// boolean allowance = ChainService.getInstance(ChainEnum.BSC_USDT_A_POOL.name()).isAllowance("0x458ff43d5ddddb4fd44dd60170ae4831e0d97c9c"); |
| | | //// System.out.println(allowance); |
| | | // |
| | | //// dappSystemService.AntACoinInMsg(780L); |
| | | //// dappSystemService.aKlineJobHour(); |
| | | //// dappSystemService.aKlineJobDay(); |
| | | //// dappSystemService.AntACoinInMsg(164L); |
| | | // |
| | | //// List<JSONObject> objects = new ArrayList<>(); |
| | | //// AKLineVo akLineVo = new AKLineVo(); |
| | | //// akLineVo.setCreateTime(DateUtil.date()); |
| | | //// akLineVo.setClosePrice(BigDecimal.ZERO); |
| | | //// akLineVo.setOpenPrice(BigDecimal.ZERO); |
| | | //// akLineVo.setLowestPrice(BigDecimal.ZERO); |
| | | //// akLineVo.setHighestPrice(BigDecimal.ZERO); |
| | | //// JSONObject parseObj = JSONUtil.parseObj(akLineVo); |
| | | //// objects.add(parseObj); |
| | | //// objects.add(parseObj); |
| | | //// objects.add(parseObj); |
| | | //// objects.add(parseObj); |
| | | //// System.out.println(objects); |
| | | //// System.out.println(objects.toString()); |
| | | //// redisUtils.set("test",objects.toString()); |
| | | //// Object test = redisUtils.get("test"); |
| | | //// System.out.println(test.toString()); |
| | | //// JSONArray jsonArray = JSONUtil.parseArray(test); |
| | | //// System.out.println(jsonArray); |
| | | // |
| | | //// String hash = ChainService.getInstance(ChainEnum.BNB.name()).transferBaseToken(address, amount); |
| | | ////// if(StrUtil.isEmpty(hash)){ |
| | | ////// return; |
| | | ////// } |
| | | //// BigDecimal balance = ChainService.getInstance(ChainEnum.BSC_USDT.name()).balanceOf(ChainEnum.BSC_USDT.getAddress()); |
| | | ////// Integer count = dappFundFlowDao.updateStatusById(DappFundFlowEntity.WITHDRAW_STATUS_AGREE,464L); |
| | | ////// String address = dappMemberEntity.getAddress(); |
| | | ////// log.info("{}",address); |
| | | //// System.out.println(balance); |
| | | // |
| | | // |
| | | //// dappSystemService.bnbTransferTest(44L); |
| | | // |
| | | // |
| | | // //发送转币消息 |
| | | //// chainProducer.sendBnbTransferMsg(93L); |
| | | //// chainProducer.sendBnbTransferMsg(94L); |
| | | //// chainProducer.sendBnbTransferMsg(95L); |
| | | //// chainProducer.sendBnbTransferMsg(96L); |
| | | // } |
| | | // |
| | | // |
| | | // @Autowired |
| | | // private SystemConstants systemConstants; |
| | | // @Autowired |
| | | // private DappSystemService dappSystemService; |
| | | // @Test |
| | | // public void balance() { |
| | | // |
| | | // dappSystemService.selectAndInsertDics(); |
| | | //// /** |
| | | //// * 从contractAddress合约地址中转移对应发行的代币到address中 |
| | | //// */ |
| | | //// dappSystemService.bnbTransfer(6L); |
| | | // |
| | | // |
| | | //// String address = AppContants.ADDRESS_A_POOL_PEOJECT; |
| | | //// /** |
| | | //// * 发起USDT转账 |
| | | //// */ |
| | | //// String hash = ChainService.getInstance(ChainEnum.BSC_USDT.name()).transfer(address, new BigDecimal("0.01")); |
| | | //// 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); |
| | | // } |
| | | } |