| | |
| | | package cc.mrbird.febs.dapp.service.impl; |
| | | |
| | | import cc.mrbird.febs.common.contants.AppContants; |
| | | import cc.mrbird.febs.common.exception.FebsException; |
| | | import cc.mrbird.febs.common.tree.MatrixTree; |
| | | import cc.mrbird.febs.common.tree.MemberNode; |
| | | import cc.mrbird.febs.common.utils.LoginUserUtil; |
| | | import cc.mrbird.febs.common.utils.RedisUtils; |
| | | import cc.mrbird.febs.common.utils.SpringContextUtil; |
| | |
| | | import cc.mrbird.febs.dapp.mapper.*; |
| | | import cc.mrbird.febs.dapp.service.DappSystemService; |
| | | import cc.mrbird.febs.dapp.service.DappWalletService; |
| | | import cc.mrbird.febs.dapp.service.IMatrixTreeNodeService; |
| | | import cc.mrbird.febs.dapp.vo.AKLineLimitVo; |
| | | import cc.mrbird.febs.rabbit.producer.ChainProducer; |
| | | import cc.mrbird.febs.tree.MatrixTree; |
| | | import cc.mrbird.febs.tree.MemberNode; |
| | | import cc.mrbird.febs.tree.TreeConstants; |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.core.date.DateTime; |
| | |
| | | import java.math.BigInteger; |
| | | import java.math.RoundingMode; |
| | | import java.util.*; |
| | | import java.util.concurrent.locks.Lock; |
| | | import java.util.concurrent.locks.ReentrantLock; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | |
| | | private final DappWalletMineDao dappWalletMineDao; |
| | | private final DappAKlineMapper dappAKlineMapper; |
| | | |
| | | private final MallOrderInfoMapper mallOrderInfoMapper; |
| | | private final MallAchieveRecordMapper mallAchieveRecordMapper; |
| | | private final DappAccountMoneyChangeDao dappAccountMoneyChangeDao; |
| | | |
| | | |
| | | |
| | | @Override |
| | |
| | | SystemDto system = new SystemDto(); |
| | | system.setBuyAmount(new BigDecimal("100")); |
| | | return system; |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public synchronized void achieveTree(Long memberId) { |
| | | DappMemberEntity member = dappMemberDao.selectById(memberId); |
| | | |
| | | int batchNo = 0; |
| | | DappAchieveTreeEntity newestTreeNode = dappAchieveTreeDao.selectNewestTreeNode(); |
| | | if (newestTreeNode != null) { |
| | | if (newestTreeNode.getValidState() == 2) { |
| | | batchNo = newestTreeNode.getBatchNo() + 1; |
| | | } else { |
| | | batchNo = newestTreeNode.getBatchNo(); |
| | | } |
| | | } |
| | | |
| | | // 在大树中,插入当前节点 |
| | | DappAchieveTreeEntity achieveTree = new DappAchieveTreeEntity(); |
| | | achieveTree.setMidNode(memberId); |
| | | achieveTree.setValidState(1); |
| | | achieveTree.setBatchNo(batchNo); |
| | | dappAchieveTreeDao.insert(achieveTree); |
| | | |
| | | // 在内存树(大树)中插入当前节点,并返回父节点 |
| | | MemberNode node = new MemberNode(member.getId(), member.getAddress(), member.getInviteId(), member.getRefererId()); |
| | | |
| | | MatrixTree tree = MatrixTree.getInstance(); |
| | | MemberNode exist = tree.getNode(member.getId()); |
| | | if (exist != null) { |
| | | return; |
| | | } |
| | | |
| | | MemberNode parentNode = tree.addNode(node); |
| | | |
| | | // 创建该节点的矩阵 |
| | | DappAchieveMemberTreeEntity achieveMemberTree = new DappAchieveMemberTreeEntity(); |
| | | achieveMemberTree.setTreeNode(memberId); |
| | | achieveMemberTree.setTopNode(memberId); |
| | | achieveMemberTree.setDeep(1); |
| | | achieveMemberTree.setHasMoney(1); |
| | | if (parentNode != null) { |
| | | achieveMemberTree.setParentNode(parentNode.getMemberId()); |
| | | } |
| | | dappAchieveMemberTreeDao.insert(achieveMemberTree); |
| | | |
| | | // 激活用户状态 |
| | | member.setActiveStatus(1); |
| | | dappMemberDao.updateById(member); |
| | | |
| | | putIntoProfit(memberId, 2); |
| | | if (parentNode == null) { |
| | | return; |
| | | } |
| | | |
| | | // 修改父节点在数据库中的左/右节点数据 |
| | | DappAchieveTreeEntity treeMidNode = dappAchieveTreeDao.selectByMidNode(parentNode.getMemberId()); |
| | | boolean isLeft = false; |
| | | if (parentNode.getLeft() != null && memberId.equals(parentNode.getLeft().getMemberId())) { |
| | | treeMidNode.setLeftNode(memberId); |
| | | isLeft = true; |
| | | } else { |
| | | treeMidNode.setRightNode(memberId); |
| | | } |
| | | dappAchieveTreeDao.updateById(treeMidNode); |
| | | |
| | | // 更新矩阵中的数据 |
| | | List<DappAchieveMemberTreeEntity> matrixNodes = dappAchieveMemberTreeDao.selectNotBottomNodeInMatrix(parentNode.getMemberId()); |
| | | for (DappAchieveMemberTreeEntity matrixNode : matrixNodes) { |
| | | if (isLeft) { |
| | | matrixNode.setLeftNode(memberId); |
| | | } else { |
| | | matrixNode.setRightNode(memberId); |
| | | } |
| | | |
| | | dappAchieveMemberTreeDao.updateById(matrixNode); |
| | | |
| | | DappAchieveMemberTreeEntity newMatrixNode = new DappAchieveMemberTreeEntity(); |
| | | newMatrixNode.setTreeNode(memberId); |
| | | newMatrixNode.setTopNode(matrixNode.getTopNode()); |
| | | newMatrixNode.setParentNode(parentNode.getMemberId()); |
| | | newMatrixNode.setHasMoney(1); |
| | | newMatrixNode.setDeep(matrixNode.getDeep() + 1); |
| | | dappAchieveMemberTreeDao.insert(newMatrixNode); |
| | | |
| | | if (matrixNode.getDeep() == 2) { |
| | | finishMatrixTree(matrixNode.getTopNode()); |
| | | } |
| | | } |
| | | } |
| | | |
| | | // 完成矩阵树,并重置矩阵且重入 |
| | | public void finishMatrixTree(Long memberId) { |
| | | List<DappAchieveMemberTreeEntity> matrixTree = dappAchieveMemberTreeDao.selectMatrixTreeByTopNode(memberId, 1); |
| | | // 如果达到标准,则重置该矩阵树 |
| | | if (matrixTree.size() == 7) { |
| | | dappAchieveMemberTreeDao.resetMatrixTree(memberId); |
| | | dappAchieveMemberTreeDao.reentryMoney(memberId); |
| | | |
| | | putIntoProfit(memberId, 1); |
| | | DappAchieveMemberTreeEntity bottomNode = dappAchieveMemberTreeDao.selectNodeByDeep(memberId, 3); |
| | | if (bottomNode != null) { |
| | | finishMatrixTree(bottomNode.getTopNode()); |
| | | } |
| | | } |
| | | } |
| | | |
| | | @Override |
| | |
| | | /** |
| | | * 20%全网加权平分,按照个人投资占比全网的比例去平分 |
| | | */ |
| | | BigDecimal poolAllMemberAPercentCntAva = allMemberPerk(poolAllMemberAPercentCnt, FundFlowEnum.POOL_MEMBER_A_CNT.getCode()); |
| | | DappFundFlowEntity poolAllMemberAFundFlowAva = new DappFundFlowEntity( |
| | | 294L, |
| | | poolAllMemberAPercentCnt.subtract(poolAllMemberAPercentCntAva), |
| | | FundFlowEnum.POOL_MEMBER_A_CNT.getCode(), |
| | | 2, |
| | | BigDecimal.ZERO, |
| | | null, |
| | | chergeRecordId); |
| | | dappFundFlowDao.insert(poolAllMemberAFundFlowAva); |
| | | dappWalletService.updateWalletMineWithLock(poolAllMemberAPercentCnt.subtract(poolAllMemberAPercentCntAva), |
| | | 294L,1); |
| | | chainProducer.sendAllMemberPerkAvaMsg(poolAllMemberAFundFlow.getId()); |
| | | // BigDecimal poolAllMemberAPercentCntAva = allMemberPerk(poolAllMemberAPercentCnt, FundFlowEnum.POOL_MEMBER_A_CNT.getCode()); |
| | | // DappFundFlowEntity poolAllMemberAFundFlowAva = new DappFundFlowEntity( |
| | | // 1L, |
| | | // poolAllMemberAPercentCnt.subtract(poolAllMemberAPercentCntAva), |
| | | // FundFlowEnum.POOL_MEMBER_A_CNT.getCode(), |
| | | // 2, |
| | | // BigDecimal.ZERO, |
| | | // null, |
| | | // chergeRecordId); |
| | | // dappFundFlowDao.insert(poolAllMemberAFundFlowAva); |
| | | // dappWalletService.updateWalletMineWithLock(poolAllMemberAPercentCnt.subtract(poolAllMemberAPercentCntAva), |
| | | // 1L,1); |
| | | |
| | | /** |
| | | * 10%直推 |
| | |
| | | } |
| | | if(directAPercentCnt.compareTo(directAPercentFundFlowToMemberFlag) > 0){ |
| | | DappFundFlowEntity directAPercentFundFlowToMemberAva = new DappFundFlowEntity( |
| | | 294L, |
| | | 1L, |
| | | directAPercentCnt.subtract(directAPercentFundFlowToMemberFlag), |
| | | FundFlowEnum.DIRECT_A_PERCENT.getCode(), |
| | | 2, |
| | |
| | | chergeRecordId); |
| | | dappFundFlowDao.insert(directAPercentFundFlowToMemberAva); |
| | | dappWalletService.updateWalletMineWithLock(directAPercentCnt.subtract(directAPercentFundFlowToMemberFlag), |
| | | 294L,1); |
| | | AppContants.YL_MEMBER_ID,1); |
| | | } |
| | | } |
| | | /** |
| | |
| | | |
| | | if(nodeAPercentCnt.compareTo(nodeAPercentCntAva) > 0){ |
| | | DappFundFlowEntity nodeAPercentFundFlowAva = new DappFundFlowEntity( |
| | | 294L, |
| | | 1L, |
| | | nodeAPercentCnt.subtract(nodeAPercentCntAva), |
| | | FundFlowEnum.NODE_A_PERCENT_TO_MEMBER.getCode(), |
| | | 2, |
| | |
| | | chergeRecordId); |
| | | dappFundFlowDao.insert(nodeAPercentFundFlowAva); |
| | | dappWalletService.updateWalletMineWithLock(nodeAPercentCnt.subtract(nodeAPercentCntAva), |
| | | 294L,1); |
| | | AppContants.YL_MEMBER_ID,1); |
| | | } |
| | | /** |
| | | * 5%基金会 |
| | |
| | | } |
| | | |
| | | // public static void main(String[] args) { |
| | | // String address = AppContants.ADDRESS_A_POOL_PEOJECT; |
| | | // String address = "0x7a9bfE048d110EF90a467803653f9B8666f9096C"; |
| | | // /** |
| | | // * 发起USDT转账 |
| | | // */ |
| | | // String hash = ChainService.getInstance(ChainEnum.BSC_USDT_A_POOL.name()).transfer(address, new BigDecimal("0.01")); |
| | | // String hash = ChainService.getInstance(ChainEnum.BSC_USDT_W_POOL_CONTRACT.name()).transferUSDT(address, new BigDecimal("0.99")); |
| | | // System.out.println(hash); |
| | | // } |
| | | |
| | | @Override |
| | |
| | | dappFundFlowDao.updateById(dappFundFlowEntity); |
| | | BigDecimal subtract = amountTC.subtract(teamIncomePerkTotal); |
| | | //用户的A币账户增加divide数量 |
| | | if(amountTC.compareTo(teamIncomePerkTotal) > 0){ |
| | | DappFundFlowEntity nodeAPercentFundFlowAva = new DappFundFlowEntity( |
| | | 294L, |
| | | subtract, |
| | | FundFlowEnum.LEVEL_A_PERCENT_CNT_MEMBER.getCode(), |
| | | 2, |
| | | BigDecimal.ZERO, |
| | | null, |
| | | systemProfitId); |
| | | dappFundFlowDao.insert(nodeAPercentFundFlowAva); |
| | | dappWalletService.updateWalletMineWithLock(subtract, |
| | | 294L,1); |
| | | } |
| | | // if(amountTC.compareTo(teamIncomePerkTotal) > 0){ |
| | | // DappFundFlowEntity nodeAPercentFundFlowAva = new DappFundFlowEntity( |
| | | // 1L, |
| | | // subtract, |
| | | // FundFlowEnum.LEVEL_A_PERCENT_CNT_MEMBER.getCode(), |
| | | // 2, |
| | | // BigDecimal.ZERO, |
| | | // null, |
| | | // systemProfitId); |
| | | // dappFundFlowDao.insert(nodeAPercentFundFlowAva); |
| | | // dappWalletService.updateWalletMineWithLock(subtract, |
| | | // 1L,1); |
| | | // } |
| | | } |
| | | } |
| | | } |
| | |
| | | //用户的A币账户增加divide数量 |
| | | if(averagePerkCnt.compareTo(averagePerkCntAva) > 0){ |
| | | DappFundFlowEntity nodeAPercentFundFlowAva = new DappFundFlowEntity( |
| | | 294L, |
| | | 1L, |
| | | averagePerkCnt.subtract(averagePerkCntAva), |
| | | FundFlowEnum.DAO_3_NODE_PERK.getCode(), |
| | | 2, |
| | |
| | | systemProfitId); |
| | | dappFundFlowDao.insert(nodeAPercentFundFlowAva); |
| | | dappWalletService.updateWalletMineWithLock(averagePerkCnt.subtract(averagePerkCntAva), |
| | | 294L,1); |
| | | AppContants.YL_MEMBER_ID,1); |
| | | } |
| | | //生成流水记录 |
| | | DappFundFlowEntity nodeThreeFundFlow = new DappFundFlowEntity( |
| | |
| | | //用户的A币账户增加divide数量 |
| | | if(averagePerkFourCnt.compareTo(averagePerkFourCntAva) > 0){ |
| | | DappFundFlowEntity nodeAPercentFundFlowAva = new DappFundFlowEntity( |
| | | 294L, |
| | | 1L, |
| | | averagePerkFourCnt.subtract(averagePerkFourCntAva), |
| | | FundFlowEnum.DAO_4_NODE_PERK.getCode(), |
| | | 2, |
| | |
| | | systemProfitId); |
| | | dappFundFlowDao.insert(nodeAPercentFundFlowAva); |
| | | dappWalletService.updateWalletMineWithLock(averagePerkFourCnt.subtract(averagePerkFourCntAva), |
| | | 294L,1); |
| | | AppContants.YL_MEMBER_ID,1); |
| | | } |
| | | DappFundFlowEntity nodeFourFundFlow = new DappFundFlowEntity( |
| | | 1L, |
| | |
| | | //用户的A币账户增加divide数量 |
| | | if(averagePerkFiveCnt.compareTo(averagePerkFiveCntAva) > 0){ |
| | | DappFundFlowEntity nodeAPercentFundFlowAva = new DappFundFlowEntity( |
| | | 294L, |
| | | 1L, |
| | | averagePerkFiveCnt.subtract(averagePerkFiveCntAva), |
| | | FundFlowEnum.DAO_5_NODE_PERK.getCode(), |
| | | 2, |
| | |
| | | systemProfitId); |
| | | dappFundFlowDao.insert(nodeAPercentFundFlowAva); |
| | | dappWalletService.updateWalletMineWithLock(averagePerkFiveCnt.subtract(averagePerkFiveCntAva), |
| | | 294L,1); |
| | | AppContants.YL_MEMBER_ID,1); |
| | | } |
| | | DappFundFlowEntity nodeFiveFundFlow = new DappFundFlowEntity( |
| | | 1L, |
| | |
| | | //用户的A币账户增加divide数量 |
| | | if(nodeFiveEqualsCnt.compareTo(nodeFiveEqualsCntAva) > 0){ |
| | | DappFundFlowEntity nodeAPercentFundFlowAva = new DappFundFlowEntity( |
| | | 294L, |
| | | 1L, |
| | | nodeFiveEqualsCnt.subtract(nodeFiveEqualsCntAva), |
| | | FundFlowEnum.DAO_5_NODE_EQUALS_PERK.getCode(), |
| | | 2, |
| | |
| | | systemProfitId); |
| | | dappFundFlowDao.insert(nodeAPercentFundFlowAva); |
| | | dappWalletService.updateWalletMineWithLock(nodeFiveEqualsCnt.subtract(nodeFiveEqualsCntAva), |
| | | 294L,1); |
| | | AppContants.YL_MEMBER_ID,1); |
| | | } |
| | | DappFundFlowEntity nodeFiveEqualsFundFlow = new DappFundFlowEntity( |
| | | 1L, |
| | |
| | | * 发起USDT转账 |
| | | */ |
| | | log.info("amount:{},address:{}",amount,address); |
| | | String hash = ChainService.getInstance(ChainEnum.BSC_USDT_W_POOL.name()).transfer(address, amount); |
| | | |
| | | String hash = ChainService.getInstance(ChainEnum.BSC_USDT_W_POOL_CONTRACT.name()).transferUSDT(address, amount); |
| | | if(StrUtil.isEmpty(hash)){ |
| | | // hash = ChainService.getInstance(ChainEnum.BSC_USDT_W_POOL.name()).transfer(address, amount); |
| | | return; |
| | | } |
| | | // if(StrUtil.isEmpty(hash)){ |
| | | // return; |
| | | // } |
| | | log.info("{},{}",id,hash); |
| | | dappFundFlowEntity.setFromHash(hash); |
| | | dappFundFlowEntity.setStatus(2); |
| | | dappFundFlowDao.updateById(dappFundFlowEntity); |
| | | } |
| | | |
| | | /** |
| | | * 紧急提现方法 |
| | | */ |
| | | public static void main(String[] args) { |
| | | BigDecimal amount = new BigDecimal("0.01"); |
| | | String address = "0xB3cF9669F398f444DfCAebbAd2A49bF32ba41fE3"; |
| | | |
| | | String hash = ChainService.getInstance(ChainEnum.BSC_USDT_W_POOL_CONTRACT.name()).transferUSDT(address, amount); |
| | | |
| | | System.out.println(hash); |
| | | |
| | | |
| | | // int i = ChainService.getInstance(ChainEnum.BSC_TFC.name()).allowanceCnt("0x80098f854950f9327C4F4E747d285Fd2d41fbf3e"); |
| | | } |
| | | |
| | | @Override |
| | |
| | | PoolEnum.COIN_A_CNT.getType(), |
| | | PoolEnum.COIN_A_CNT.getCode()); |
| | | BigDecimal coinACnt = new BigDecimal(coinACntDic.getValue()); |
| | | coinACnt = coinACnt.subtract(totalCnt); |
| | | coinACnt = coinACnt.subtract(totalCnt.multiply(new BigDecimal(0.8))); |
| | | coinACntDic.setValue(coinACnt.toString()); |
| | | dataDictionaryCustomMapper.updateById(coinACntDic); |
| | | |
| | |
| | | |
| | | } |
| | | |
| | | public static void main(String[] args) { |
| | | System.out.println(ChainEnum.BSC_USDT_W_POOL.getAddress()); |
| | | // public static void main(String[] args) { |
| | | // for(int i = 0; i < 100; i++){ |
| | | // ChainService.getInstance(ChainEnum.BSC_USDT_A_POOL.name()).transfer(AppContants.ADDRESS_A_POOL_PEOJECT, new BigDecimal(70)); |
| | | // try { |
| | | // Thread.sleep(20000); |
| | | // } catch (InterruptedException e) { |
| | | // e.printStackTrace(); |
| | | // } |
| | | // |
| | | // ChainService.getInstance(ChainEnum.BSC_USDT_A_POOL.name()).transfer(AppContants.ADDRESS_B_POOL_PEOJECT, new BigDecimal(20)); |
| | | // |
| | | // try { |
| | | // Thread.sleep(20000); |
| | | // } catch (InterruptedException e) { |
| | | // e.printStackTrace(); |
| | | // } |
| | | // |
| | | // ChainService.getInstance(ChainEnum.BSC_USDT_A_POOL.name()).transfer(ChainEnum.BSC_USDT_W_POOL.getAddress(), new BigDecimal(10)); |
| | | // try { |
| | | // Thread.sleep(20000); |
| | | // } catch (InterruptedException e) { |
| | | // e.printStackTrace(); |
| | | // } |
| | | // } |
| | | // } |
| | | |
| | | @Override |
| | | public void allMemberPerkAvaMsg(Long id) { |
| | | DappFundFlowEntity dappFundFlowEntity = dappFundFlowDao.selectById(id); |
| | | if(ObjectUtil.isEmpty(dappFundFlowEntity)){ |
| | | return; |
| | | } |
| | | |
| | | BigDecimal poolAllMemberAPercentCnt = dappFundFlowEntity.getAmount(); |
| | | BigDecimal poolAllMemberAPercentCntAva = allMemberPerk(poolAllMemberAPercentCnt, FundFlowEnum.POOL_MEMBER_A_CNT.getCode()); |
| | | DappFundFlowEntity poolAllMemberAFundFlowAva = new DappFundFlowEntity( |
| | | 1L, |
| | | poolAllMemberAPercentCnt.subtract(poolAllMemberAPercentCntAva), |
| | | FundFlowEnum.POOL_MEMBER_A_CNT.getCode(), |
| | | 2, |
| | | BigDecimal.ZERO, |
| | | null, |
| | | dappFundFlowEntity.getSystemProfitId()); |
| | | dappFundFlowDao.insert(poolAllMemberAFundFlowAva); |
| | | dappWalletService.updateWalletMineWithLock(poolAllMemberAPercentCnt.subtract(poolAllMemberAPercentCntAva), |
| | | AppContants.YL_MEMBER_ID,1); |
| | | |
| | | } |
| | | @Override |
| | | public void contractAnDaoMsg(Long flowId) { |
| | | DappFundFlowEntity flow = dappFundFlowDao.selectById(flowId); |
| | | if(ObjectUtil.isEmpty(flow)){ |
| | | return; |
| | | } |
| | | Long memberId = flow.getMemberId(); |
| | | if(DappFundFlowEntity.WITHDRAW_STATUS_AGREE == flow.getStatus()){ |
| | | return; |
| | | } |
| | | DappMemberEntity dappMemberEntity = dappMemberDao.selectById(memberId); |
| | | if(ObjectUtil.isEmpty(dappMemberEntity)){ |
| | | return; |
| | | } |
| | | /** |
| | | * 生成会员入金买A币的记录 |
| | | */ |
| | | DappChargeUsdtEntity dappChargeUsdtEntity = new DappChargeUsdtEntity( |
| | | memberId, |
| | | dappMemberEntity.getAddress(), |
| | | null, |
| | | 2, |
| | | flow.getAmount(), |
| | | BigDecimal.ZERO, |
| | | BigDecimal.ZERO); |
| | | dappChargeUsdtMapper.insert(dappChargeUsdtEntity); |
| | | /** |
| | | * 减少用户的AUSD数量 |
| | | */ |
| | | DappUsdtPerkEntity dappUsdtPerkEntity = dappUsdtPerkEntityMapper.selectByMemberId(memberId); |
| | | BigDecimal ausdAmount = dappUsdtPerkEntity.getAusdAmount(); |
| | | ausdAmount = ausdAmount.subtract(flow.getFee()).setScale(4,BigDecimal.ROUND_DOWN); |
| | | dappUsdtPerkEntity.setAusdAmount(ausdAmount); |
| | | dappUsdtPerkEntityMapper.updateById(dappUsdtPerkEntity); |
| | | /** |
| | | * 流水关联用户购买记录 |
| | | */ |
| | | flow.setSystemProfitId(dappChargeUsdtEntity.getId()); |
| | | /** |
| | | * 链上转账的hash值 |
| | | */ |
| | | // flow.setFromHash(null); |
| | | flow.setStatus(DappFundFlowEntity.WITHDRAW_STATUS_AGREE); |
| | | dappFundFlowDao.updateById(flow); |
| | | |
| | | /** |
| | | * 发送消息处理返利逻辑 |
| | | */ |
| | | chainProducer.sendAntACoinInContractMsg(flow.getId()); |
| | | /** |
| | | * 发送消息处理代理升级 |
| | | */ |
| | | chainProducer.sendAntMemberLevelMsg(memberId); |
| | | } |
| | | |
| | | @Override |
| | | public void contractAnDaoInMsg(Long flowId) { |
| | | /** |
| | | * 获取对应的流水记录 |
| | | */ |
| | | DappFundFlowEntity dappFundFlowEntity = dappFundFlowDao.selectInfoById(flowId); |
| | | if(ObjectUtil.isEmpty(dappFundFlowEntity)){ |
| | | return; |
| | | } |
| | | if(DappFundFlowEntity.WITHDRAW_STATUS_AGREE != dappFundFlowEntity.getStatus()){ |
| | | return; |
| | | } |
| | | Long memberId = dappFundFlowEntity.getMemberId(); |
| | | DappMemberEntity dappMemberEntity = dappMemberDao.selectById(memberId); |
| | | if(ObjectUtil.isEmpty(dappMemberEntity)){ |
| | | return; |
| | | } |
| | | /** |
| | | * 会员充值金额 |
| | | */ |
| | | BigDecimal amount = dappFundFlowEntity.getAmount(); |
| | | /** |
| | | * A币的当前价格 |
| | | */ |
| | | DataDictionaryCustom coinAPriceDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | PoolEnum.COIN_A_PRICE.getType(), |
| | | PoolEnum.COIN_A_PRICE.getCode() |
| | | ); |
| | | BigDecimal coinAPrice = new BigDecimal(StrUtil.isEmpty(coinAPriceDic.getValue()) ? "0" : coinAPriceDic.getValue()).setScale(12,BigDecimal.ROUND_DOWN); |
| | | /** |
| | | * 会员充值USDT买入A币记录的ID |
| | | */ |
| | | Long chergeRecordId = dappFundFlowEntity.getSystemProfitId() == null ? 0L : dappFundFlowEntity.getSystemProfitId(); |
| | | DappChargeUsdtEntity dappChargeUsdtEntity = dappChargeUsdtMapper.selectById(chergeRecordId); |
| | | if(ObjectUtil.isEmpty(dappChargeUsdtEntity)){ |
| | | return; |
| | | } |
| | | if(2 != dappChargeUsdtEntity.getStatus()){ |
| | | return; |
| | | } |
| | | // if(StrUtil.isEmpty(dappChargeUsdtEntity.getMemberHash())){ |
| | | // return; |
| | | // } |
| | | /** |
| | | * 金本位的三倍额度,增加业绩,增加对应的NFT的值 |
| | | */ |
| | | DappUsdtPerkEntity dappUsdtPerkEntity = dappUsdtPerkEntityMapper.selectByMemberId(memberId); |
| | | if(ObjectUtil.isEmpty(dappUsdtPerkEntity)){ |
| | | dappUsdtPerkEntity = new DappUsdtPerkEntity(); |
| | | dappUsdtPerkEntity.setAmount(amount.multiply(new BigDecimal(3))); |
| | | dappUsdtPerkEntity.setNftDevote(amount); |
| | | dappUsdtPerkEntity.setMemberId(memberId); |
| | | dappUsdtPerkEntityMapper.insert(dappUsdtPerkEntity); |
| | | } |
| | | //金本位的三倍额度 |
| | | BigDecimal amountPerk = dappUsdtPerkEntity.getAmount(); |
| | | amountPerk = amountPerk.add(amount.multiply(new BigDecimal(3))); |
| | | dappUsdtPerkEntity.setAmount(amountPerk); |
| | | //生成一条金本位的三倍额度的资金流水记录 |
| | | DappFundFlowEntity amountPerkFundFlow = new DappFundFlowEntity( |
| | | memberId, |
| | | amount.multiply(new BigDecimal(3)), |
| | | FundFlowEnum.MEMBER_AMOUNT_PERK_TOTAL.getCode(), |
| | | 2, |
| | | BigDecimal.ZERO, |
| | | null, |
| | | chergeRecordId); |
| | | dappFundFlowDao.insert(amountPerkFundFlow); |
| | | |
| | | //增加业绩 |
| | | BigDecimal achieveAmount = dappUsdtPerkEntity.getAchieveAmount(); |
| | | achieveAmount = achieveAmount.add(amount); |
| | | dappUsdtPerkEntity.setAchieveAmount(achieveAmount); |
| | | //增加对应的NFT的值 |
| | | BigDecimal nftDevote = dappUsdtPerkEntity.getNftDevote(); |
| | | nftDevote = nftDevote.add(amount); |
| | | dappUsdtPerkEntity.setNftDevote(nftDevote); |
| | | dappUsdtPerkEntityMapper.updateById(dappUsdtPerkEntity); |
| | | /** |
| | | * 1.90%底池的USDT做成100%溢价,铸造出70%金本位价值的A币。 |
| | | */ |
| | | DataDictionaryCustom produceAPercentDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | PoolEnum.PRODUCE_A_PERCENT.getType(), |
| | | PoolEnum.PRODUCE_A_PERCENT.getCode() |
| | | ); |
| | | BigDecimal produceAPercent = new BigDecimal(StrUtil.isEmpty(produceAPercentDic.getValue()) ? "0.7" : produceAPercentDic.getValue()); |
| | | //购买数量 |
| | | BigDecimal totalCnt = amount.divide(coinAPrice, 4, BigDecimal.ROUND_DOWN); |
| | | /** |
| | | * 铸造出70%金本位价值的A币。实际产生数量 |
| | | */ |
| | | BigDecimal realCnt = totalCnt.multiply(produceAPercent).setScale(4, BigDecimal.ROUND_DOWN); |
| | | dappChargeUsdtEntity.setTotalCnt(totalCnt); |
| | | dappChargeUsdtEntity.setRealCnt(realCnt); |
| | | dappChargeUsdtMapper.updateById(dappChargeUsdtEntity); |
| | | /** |
| | | * 重新计算A币的价格 |
| | | */ |
| | | DataDictionaryCustom coinACntDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | PoolEnum.COIN_A_CNT.getType(), |
| | | PoolEnum.COIN_A_CNT.getCode() |
| | | ); |
| | | //A币币本位底池-A币的数量 |
| | | BigDecimal coinACntDicCnt = new BigDecimal(coinACntDic.getValue()); |
| | | coinACntDicCnt = coinACntDicCnt.add(realCnt); |
| | | coinACntDic.setValue(coinACntDicCnt.toString()); |
| | | dataDictionaryCustomMapper.updateById(coinACntDic); |
| | | |
| | | DataDictionaryCustom coinAUsdtPriceDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | PoolEnum.COIN_A_USDT_PRICE.getType(), |
| | | PoolEnum.COIN_A_USDT_PRICE.getCode() |
| | | ); |
| | | //A币金本位底池-usdt数量 |
| | | BigDecimal coinAUsdtPriceDicCnt = new BigDecimal(coinAUsdtPriceDic.getValue()); |
| | | coinAUsdtPriceDicCnt = coinAUsdtPriceDicCnt.add(amount.multiply(new BigDecimal(0.8))); |
| | | coinAUsdtPriceDic.setValue(coinAUsdtPriceDicCnt.toString()); |
| | | dataDictionaryCustomMapper.updateById(coinAUsdtPriceDic); |
| | | |
| | | BigDecimal divide = coinAUsdtPriceDicCnt.divide(coinACntDicCnt, 12, BigDecimal.ROUND_DOWN); |
| | | coinAPriceDic.setValue(divide.toString()); |
| | | dataDictionaryCustomMapper.updateById(coinAPriceDic); |
| | | |
| | | chainProducer.sendAntKLineMsg(0); |
| | | /** |
| | | * A币的分配 walletMine |
| | | * 【70%换算100%分配】 |
| | | * 50%客户秒到 |
| | | * 20%全网加权分红(按20%释放递减) |
| | | * 10%直推 |
| | | * 5%节点 |
| | | * 5%基金会 |
| | | * 10%级差奖 |
| | | */ |
| | | /** |
| | | * 50%客户秒到 |
| | | */ |
| | | DataDictionaryCustom memberGetAPercentDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | PoolEnum.MEMBER_GET_A_PERCENT.getType(), |
| | | PoolEnum.MEMBER_GET_A_PERCENT.getCode() |
| | | ); |
| | | BigDecimal memberGetAPercent = new BigDecimal(StrUtil.isEmpty(memberGetAPercentDic.getValue()) ? "0.5" : memberGetAPercentDic.getValue()); |
| | | BigDecimal memberGetACnt = realCnt.multiply(memberGetAPercent).setScale(4, BigDecimal.ROUND_DOWN); |
| | | |
| | | BigDecimal fundFlowToMemberFlag = this.getAndUpdateMemberPerk(dappFundFlowEntity.getMemberId(), memberGetACnt); |
| | | if(fundFlowToMemberFlag.compareTo(BigDecimal.ZERO) > 0){ |
| | | //生成一条50%客户秒到的资金流水记录 |
| | | DappFundFlowEntity fundFlowToMember = new DappFundFlowEntity( |
| | | dappFundFlowEntity.getMemberId(), |
| | | fundFlowToMemberFlag, |
| | | FundFlowEnum.MEMBER_GET_A_CNT.getCode(), |
| | | 2, |
| | | BigDecimal.ZERO, |
| | | null, |
| | | chergeRecordId); |
| | | dappFundFlowDao.insert(fundFlowToMember); |
| | | //用户的A币账户增加memberGetACnt数量 |
| | | dappWalletService.updateWalletMineWithLock(fundFlowToMemberFlag,dappFundFlowEntity.getMemberId(),1); |
| | | } |
| | | /** |
| | | * 20%全网加权分红(按20%释放递减)进入加权分红底池 |
| | | */ |
| | | DataDictionaryCustom poolAllMemberAPercentDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | PoolEnum.POOL_ALL_MEMBER_A_PERCENT.getType(), |
| | | PoolEnum.POOL_ALL_MEMBER_A_PERCENT.getCode() |
| | | ); |
| | | BigDecimal poolAllMemberAPercent = new BigDecimal(StrUtil.isEmpty(poolAllMemberAPercentDic.getValue()) ? "0.2" : poolAllMemberAPercentDic.getValue()); |
| | | BigDecimal poolAllMemberAPercentCnt = realCnt.multiply(poolAllMemberAPercent).setScale(4, BigDecimal.ROUND_DOWN); |
| | | |
| | | DataDictionaryCustom poolAllMemberACntDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | PoolEnum.POOL_ALL_MEMBER_A_CNT.getType(), |
| | | PoolEnum.POOL_ALL_MEMBER_A_CNT.getCode() |
| | | ); |
| | | BigDecimal poolAllMemberACnt = new BigDecimal(StrUtil.isEmpty(poolAllMemberACntDic.getValue()) ? "0" : poolAllMemberACntDic.getValue()); |
| | | poolAllMemberACnt = poolAllMemberACnt.add(poolAllMemberAPercentCnt); |
| | | poolAllMemberACntDic.setValue(poolAllMemberACnt.toString()); |
| | | dataDictionaryCustomMapper.updateById(poolAllMemberACntDic); |
| | | //生成一条20%全网加权分红(按20%释放递减)进入加权分红底池的资金流水记录 |
| | | DappFundFlowEntity poolAllMemberAFundFlow = new DappFundFlowEntity( |
| | | 1L, |
| | | poolAllMemberAPercentCnt, |
| | | FundFlowEnum.POOL_ALL_MEMBER_A_CNT.getCode(), |
| | | 2, |
| | | BigDecimal.ZERO, |
| | | null, |
| | | chergeRecordId); |
| | | dappFundFlowDao.insert(poolAllMemberAFundFlow); |
| | | |
| | | /** |
| | | * 20%全网加权平分,按照个人投资占比全网的比例去平分 |
| | | */ |
| | | chainProducer.sendAllMemberPerkAvaMsg(poolAllMemberAFundFlow.getId()); |
| | | /** |
| | | * 10%直推 |
| | | */ |
| | | DataDictionaryCustom directAPercentDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | PoolEnum.DIRECT_A_PERCENT.getType(), |
| | | PoolEnum.DIRECT_A_PERCENT.getCode() |
| | | ); |
| | | BigDecimal directAPercent = new BigDecimal(StrUtil.isEmpty(directAPercentDic.getValue()) ? "0.1" : directAPercentDic.getValue()); |
| | | BigDecimal directAPercentCnt = realCnt.multiply(directAPercent).setScale(4, BigDecimal.ROUND_DOWN); |
| | | |
| | | String refererId = dappMemberEntity.getRefererId(); |
| | | DappMemberEntity directMemberEntity = dappMemberDao.selectMemberInfoByInviteId(refererId); |
| | | if(ObjectUtil.isNotEmpty(directMemberEntity)){ |
| | | /** |
| | | *推荐用户入单可享有贡献值.例.推荐100获得100贡献值 |
| | | */ |
| | | DappUsdtPerkEntity directDappUsdtPerkEntity = dappUsdtPerkEntityMapper.selectByMemberId(directMemberEntity.getId()); |
| | | if(ObjectUtil.isEmpty(directDappUsdtPerkEntity)){ |
| | | directDappUsdtPerkEntity = new DappUsdtPerkEntity(); |
| | | directDappUsdtPerkEntity.setNftDevote(amount); |
| | | directDappUsdtPerkEntity.setMemberId(directMemberEntity.getId()); |
| | | dappUsdtPerkEntityMapper.insert(directDappUsdtPerkEntity); |
| | | } |
| | | |
| | | BigDecimal directNftDevote = directDappUsdtPerkEntity.getNftDevote(); |
| | | directNftDevote = directNftDevote.add(amount); |
| | | directDappUsdtPerkEntity.setNftDevote(directNftDevote); |
| | | dappUsdtPerkEntityMapper.updateById(directDappUsdtPerkEntity); |
| | | |
| | | BigDecimal directAPercentFundFlowToMemberFlag = this.getAndUpdateMemberPerk(directMemberEntity.getId(), directAPercentCnt); |
| | | if(directAPercentFundFlowToMemberFlag.compareTo(BigDecimal.ZERO) > 0){ |
| | | //生成一条10%直推的资金流水记录 |
| | | DappFundFlowEntity directAPercentFundFlowToMember = new DappFundFlowEntity( |
| | | directMemberEntity.getId(), |
| | | directAPercentFundFlowToMemberFlag, |
| | | FundFlowEnum.DIRECT_A_PERCENT.getCode(), |
| | | 2, |
| | | BigDecimal.ZERO, |
| | | null, |
| | | chergeRecordId); |
| | | dappFundFlowDao.insert(directAPercentFundFlowToMember); |
| | | //用户的A币账户增加directAPercentCnt数量 |
| | | dappWalletService.updateWalletMineWithLock(directAPercentFundFlowToMemberFlag,directMemberEntity.getId(),1); |
| | | } |
| | | if(directAPercentCnt.compareTo(directAPercentFundFlowToMemberFlag) > 0){ |
| | | DappFundFlowEntity directAPercentFundFlowToMemberAva = new DappFundFlowEntity( |
| | | 1L, |
| | | directAPercentCnt.subtract(directAPercentFundFlowToMemberFlag), |
| | | FundFlowEnum.DIRECT_A_PERCENT.getCode(), |
| | | 2, |
| | | BigDecimal.ZERO, |
| | | null, |
| | | chergeRecordId); |
| | | dappFundFlowDao.insert(directAPercentFundFlowToMemberAva); |
| | | dappWalletService.updateWalletMineWithLock(directAPercentCnt.subtract(directAPercentFundFlowToMemberFlag), |
| | | AppContants.YL_MEMBER_ID,1); |
| | | } |
| | | } |
| | | /** |
| | | * 5%节点 |
| | | */ |
| | | DataDictionaryCustom nodeAPercentDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | PoolEnum.NODE_A_PERCENT.getType(), |
| | | PoolEnum.NODE_A_PERCENT.getCode() |
| | | ); |
| | | BigDecimal nodeAPercent = new BigDecimal(StrUtil.isEmpty(nodeAPercentDic.getValue()) ? "0.05" : nodeAPercentDic.getValue()); |
| | | BigDecimal nodeAPercentCnt = realCnt.multiply(nodeAPercent).setScale(4, BigDecimal.ROUND_DOWN); |
| | | //生成一条5%节点的资金流水记录 |
| | | DappFundFlowEntity nodeAPercentFundFlow = new DappFundFlowEntity( |
| | | 1L, |
| | | nodeAPercentCnt, |
| | | FundFlowEnum.NODE_A_PERCENT.getCode(), |
| | | 2, |
| | | BigDecimal.ZERO, |
| | | null, |
| | | chergeRecordId); |
| | | dappFundFlowDao.insert(nodeAPercentFundFlow); |
| | | // chainProducer.sendAntACoinInNodeMsg(nodeAPercentFundFlow.getId()); |
| | | DataDictionaryCustom nodeAPercentPoolDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | PoolEnum.NODE_A_PERCENT_POOL.getType(), |
| | | PoolEnum.NODE_A_PERCENT_POOL.getCode() |
| | | ); |
| | | BigDecimal nodeAPercentPoolDicCnt = new BigDecimal(StrUtil.isEmpty(nodeAPercentPoolDic.getValue()) ? "0" : nodeAPercentPoolDic.getValue()); |
| | | nodeAPercentPoolDicCnt = nodeAPercentPoolDicCnt.add(nodeAPercentCnt); |
| | | nodeAPercentPoolDic.setValue(nodeAPercentPoolDicCnt.toString()); |
| | | dataDictionaryCustomMapper.updateById(nodeAPercentPoolDic); |
| | | |
| | | BigDecimal nodeAPercentCntAva = superNodePoolPerk(nodeAPercentCnt, NodeCodeEnum.SUPER_NODE.getCode(), FundFlowEnum.NODE_A_PERCENT_TO_MEMBER.getCode()); |
| | | |
| | | if(nodeAPercentCnt.compareTo(nodeAPercentCntAva) > 0){ |
| | | DappFundFlowEntity nodeAPercentFundFlowAva = new DappFundFlowEntity( |
| | | 1L, |
| | | nodeAPercentCnt.subtract(nodeAPercentCntAva), |
| | | FundFlowEnum.NODE_A_PERCENT_TO_MEMBER.getCode(), |
| | | 2, |
| | | BigDecimal.ZERO, |
| | | null, |
| | | chergeRecordId); |
| | | dappFundFlowDao.insert(nodeAPercentFundFlowAva); |
| | | dappWalletService.updateWalletMineWithLock(nodeAPercentCnt.subtract(nodeAPercentCntAva), |
| | | AppContants.YL_MEMBER_ID,1); |
| | | } |
| | | /** |
| | | * 5%基金会 |
| | | */ |
| | | DataDictionaryCustom foundationAPercentDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | PoolEnum.FOUNDATION_A_PERCENT.getType(), |
| | | PoolEnum.FOUNDATION_A_PERCENT.getCode() |
| | | ); |
| | | BigDecimal foundationAPercent = new BigDecimal(StrUtil.isEmpty(foundationAPercentDic.getValue()) ? "0.05" : foundationAPercentDic.getValue()); |
| | | BigDecimal foundationAPercentCnt = realCnt.multiply(foundationAPercent).setScale(4, BigDecimal.ROUND_DOWN); |
| | | |
| | | //生成一条5%基金会的资金流水记录 |
| | | DappFundFlowEntity foundationAPercentFundFlow = new DappFundFlowEntity( |
| | | 295L, |
| | | foundationAPercentCnt, |
| | | FundFlowEnum.FOUNDATION_A_PERCENT.getCode(), |
| | | 2, |
| | | BigDecimal.ZERO, |
| | | null, |
| | | chergeRecordId); |
| | | dappFundFlowDao.insert(foundationAPercentFundFlow); |
| | | //用户的A币账户增加memberGetACnt数量 |
| | | dappWalletService.updateWalletMineWithLock(foundationAPercentCnt,295L,1); |
| | | /** |
| | | * 10%级差奖 |
| | | */ |
| | | DataDictionaryCustom levelAPercentDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | PoolEnum.LEVEL_A_PERCENT.getType(), |
| | | PoolEnum.LEVEL_A_PERCENT.getCode() |
| | | ); |
| | | BigDecimal levelAPercent = new BigDecimal(StrUtil.isEmpty(levelAPercentDic.getValue()) ? "0.1" : levelAPercentDic.getValue()); |
| | | BigDecimal levelAPercentCnt = realCnt.multiply(levelAPercent).setScale(4, BigDecimal.ROUND_DOWN); |
| | | |
| | | //生成一条10%级差奖进入10%级差奖底池的资金流水记录 |
| | | DappFundFlowEntity levelAPercentCntFundFlow = new DappFundFlowEntity( |
| | | 1L, |
| | | levelAPercentCnt, |
| | | FundFlowEnum.LEVEL_A_PERCENT_CNT.getCode(), |
| | | 2, |
| | | BigDecimal.ZERO, |
| | | null, |
| | | chergeRecordId); |
| | | dappFundFlowDao.insert(levelAPercentCntFundFlow); |
| | | chainProducer.sendAntACoinInLevelMsg(levelAPercentCntFundFlow.getId()); |
| | | |
| | | /** |
| | | * 更新用户为有效用户 |
| | | */ |
| | | dappMemberDao.updateMemberActiveStatus(1,memberId); |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void speedPayOrderMsg(Long orderId) { |
| | | MallOrderInfo mallOrderInfo = mallOrderInfoMapper.selectById(orderId); |
| | | if(ObjectUtil.isEmpty(mallOrderInfo)){ |
| | | return; |
| | | } |
| | | if(MallOrderInfo.STATUS_PAY != mallOrderInfo.getStatus()){ |
| | | return; |
| | | } |
| | | Long memberId = mallOrderInfo.getMemberId(); |
| | | /** |
| | | * 赠送消费金额1.5倍增值积分 |
| | | */ |
| | | BigDecimal amount = mallOrderInfo.getAmount(); |
| | | DataDictionaryCustom donateScorePercentDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | DataDictionaryEnum.DONATE_SCORE_PERCENT.getType(), |
| | | DataDictionaryEnum.DONATE_SCORE_PERCENT.getCode() |
| | | ); |
| | | BigDecimal donateScorePercent = new BigDecimal(donateScorePercentDic.getValue()); |
| | | BigDecimal donateScore = amount.multiply(donateScorePercent); |
| | | dappWalletMineDao.updateBalance(donateScore,donateScore,memberId); |
| | | DappFundFlowEntity donateScoreFlow = new DappFundFlowEntity( |
| | | memberId, |
| | | donateScore, |
| | | FundFlowEnum.DONATE_SCORE.getCode(), |
| | | 2, |
| | | BigDecimal.ZERO, |
| | | null, |
| | | orderId); |
| | | dappFundFlowDao.insert(donateScoreFlow); |
| | | /** |
| | | * 新增一条业绩 |
| | | */ |
| | | MallAchieveRecord mallAchieveRecord = new MallAchieveRecord( |
| | | memberId,amount,amount,DateUtil.date(),orderId,1,mallOrderInfo.getPayTime() |
| | | ); |
| | | mallAchieveRecordMapper.insert(mallAchieveRecord); |
| | | |
| | | } |
| | | |
| | | |
| | | private final IMatrixTreeNodeService matrixTreeNodeService; |
| | | |
| | | @Override |
| | | public void speedAutoLevelUpMsg(Long memberId) {log.info("###代理自动升级###"); |
| | | DappMemberEntity member = dappMemberDao.selectById(memberId); |
| | | if (MemberLevelEnum.V7.getType().equals(member.getAccountType())) { |
| | | return; |
| | | } |
| | | |
| | | MemberNode parentNode = matrixTreeNodeService.addTreeNode(memberId); |
| | | if (parentNode == null) { |
| | | log.info("父级节点未找到:{}", memberId); |
| | | return; |
| | | } |
| | | |
| | | MatrixTree matrixTree = MatrixTree.getInstance(); |
| | | List<MemberNode> allNodes = matrixTree.getAllAncestors(parentNode); // 获取某一个MemberNode的所有上级节点 |
| | | allNodes.add(parentNode); |
| | | if(CollUtil.isEmpty(allNodes)){ |
| | | return; |
| | | } |
| | | /** |
| | | * 更新所有上级的小区业绩 |
| | | */ |
| | | for(MemberNode memberNode : allNodes){ |
| | | BigDecimal smallAchieve = BigDecimal.ZERO; |
| | | List<MemberNode> allNodesChildList = memberNode.getCHILD(); |
| | | if(CollUtil.isNotEmpty(allNodesChildList)){ |
| | | List<Long> left = allNodesChildList.stream().filter(allNodesChild -> allNodesChild.getType() == 1).map(MemberNode::getMemberId).collect(Collectors.toList()); |
| | | List<Long> right = allNodesChildList.stream().filter(allNodesChild -> allNodesChild.getType() == 2).map(MemberNode::getMemberId).collect(Collectors.toList()); |
| | | |
| | | BigDecimal leftAmount = mallAchieveRecordMapper.selectSumAchieveByMemberIdList(left); |
| | | |
| | | BigDecimal rightAmount = mallAchieveRecordMapper.selectSumAchieveByMemberIdList(right); |
| | | if(leftAmount.compareTo(rightAmount) > 0){ |
| | | smallAchieve = rightAmount; |
| | | }else{ |
| | | smallAchieve = leftAmount; |
| | | } |
| | | //更新用户的区域业绩 |
| | | DappMemberEntity dappMemberEntity = dappMemberDao.selectById(memberNode.getMemberId()); |
| | | dappMemberEntity.setUsdtBalance(smallAchieve); |
| | | dappMemberEntity.setLeftAchieve(leftAmount); |
| | | dappMemberEntity.setRightAchieve(rightAmount); |
| | | dappMemberDao.updateById(dappMemberEntity); |
| | | log.info("用户:{},leftAchieve :{}, rightAchieve:{}, smallAchieve:{}", |
| | | dappMemberEntity.getAddress(), leftAmount, rightAmount, smallAchieve); |
| | | |
| | | /** |
| | | * 判断是否符合升级条件 |
| | | */ |
| | | String nextLevel = MemberLevelEnum.MEMBER.getNextLevel(dappMemberEntity.getAccountType()); |
| | | DataDictionaryCustom memberLevelDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | DataDictionaryEnum.V1.getType() |
| | | , nextLevel); |
| | | if(ObjectUtil.isNotEmpty(memberLevelDic)){ |
| | | String value = memberLevelDic.getValue(); |
| | | cn.hutool.json.JSONObject parseObj = JSONUtil.parseObj(value); |
| | | BigDecimal smallAchieveDic = new BigDecimal(parseObj.get("smallAchieve").toString()); |
| | | if(smallAchieve.compareTo(smallAchieveDic) >= 0){ |
| | | //升级 |
| | | dappMemberEntity.setAccountType(nextLevel); |
| | | dappMemberDao.updateById(dappMemberEntity); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void memberPerk() { |
| | | List<DappMemberEntity> dappMemberEntityList = dappMemberDao.selectMemberByActiveStatus(); |
| | | if(CollUtil.isEmpty(dappMemberEntityList)){ |
| | | return; |
| | | } |
| | | DataDictionaryCustom staticReleaseDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | DataDictionaryEnum.STATIC_RELEASE.getType(), |
| | | DataDictionaryEnum.STATIC_RELEASE.getCode() |
| | | ); |
| | | if(ObjectUtil.isEmpty(staticReleaseDic)){ |
| | | return; |
| | | } |
| | | BigDecimal staticRelease = new BigDecimal(staticReleaseDic.getValue() == null ? "0" : staticReleaseDic.getValue()); |
| | | if(BigDecimal.ZERO.compareTo(staticRelease) >= 0){ |
| | | return; |
| | | } |
| | | for(DappMemberEntity dappMemberEntity : dappMemberEntityList){ |
| | | if(1 != dappMemberEntity.getActiveStatus()){ |
| | | continue; |
| | | } |
| | | Long perkMemberId = dappMemberEntity.getId(); |
| | | //获取当前用户所有进行中的业绩释放 |
| | | List<MallAchieveRecord> mallAchieveRecords = mallAchieveRecordMapper.selectListByMemberId(perkMemberId); |
| | | |
| | | if(CollUtil.isEmpty(mallAchieveRecords)){ |
| | | continue; |
| | | } |
| | | /** |
| | | * 按照订单、比例生成对应的静态释放 |
| | | */ |
| | | for(MallAchieveRecord mallAchieveRecord : mallAchieveRecords){ |
| | | //释放总额 |
| | | BigDecimal costAmount = mallAchieveRecord.getCostAmount(); |
| | | //剩余 |
| | | BigDecimal amount = mallAchieveRecord.getAmount(); |
| | | if(BigDecimal.ZERO.compareTo(amount) >= 0){ |
| | | mallAchieveRecord.setIsNormal(2); |
| | | mallAchieveRecordMapper.updateById(mallAchieveRecord); |
| | | continue; |
| | | } |
| | | //每日释放金额 |
| | | BigDecimal eachDayPerk = costAmount.multiply(staticRelease).setScale(2,BigDecimal.ROUND_DOWN); |
| | | if(eachDayPerk.compareTo(amount) >= 0){ |
| | | eachDayPerk = amount; |
| | | mallAchieveRecord.setIsNormal(2); |
| | | } |
| | | DappMemberEntity mallAchieveMemberEntity = dappMemberDao.selectById(mallAchieveRecord.getMemberId()); |
| | | sendPerk(mallAchieveMemberEntity,eachDayPerk,mallAchieveRecord.getOrderId(),FundFlowEnum.STATIC_RELEASE.getCode()); |
| | | //实时更新用户等级 |
| | | chainProducer.sendAutoLevelUpTeamMsg(perkMemberId); |
| | | } |
| | | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | @Override |
| | | public void speedAutoLevelUpTeamMsg(Long memberId) { |
| | | DappMemberEntity member = dappMemberDao.selectById(memberId); |
| | | if(StrUtil.isBlank(member.getRefererIds())) { |
| | | return; |
| | | } |
| | | |
| | | List<String> ids = StrUtil.split(member.getRefererIds(), ','); |
| | | List<DappMemberEntity> parentMembers = dappMemberDao.selectByInviteIds(ids); |
| | | for (DappMemberEntity parent : parentMembers) { |
| | | //V7不能再升级了 |
| | | if (MemberLevelEnum.V7.getType().equals(member.getAccountType())) { |
| | | continue; |
| | | } |
| | | |
| | | String nextLevelName = MemberLevelEnum.MEMBER.getNextLevel(parent.getAccountType()); |
| | | |
| | | DataDictionaryCustom newLevelDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode("TEAM_LEVEL", nextLevelName); |
| | | if(ObjectUtil.isEmpty(newLevelDic)){ |
| | | continue; |
| | | } |
| | | TeamLevelPerk teamLevelPerk = JSONObject.parseObject(newLevelDic.getValue(), TeamLevelPerk.class); |
| | | |
| | | //需要判断小区业绩 |
| | | if( MemberLevelEnum.V1.getType().equals(nextLevelName)){ |
| | | if (!teamAchieve(parent, teamLevelPerk)) { |
| | | continue; |
| | | } |
| | | }else{ |
| | | if (!agentCntFinish(parent, teamLevelPerk)) { |
| | | continue; |
| | | } |
| | | if (!teamAchieveOther(parent, teamLevelPerk)) { |
| | | continue; |
| | | } |
| | | } |
| | | |
| | | parent.setAccountType(nextLevelName); |
| | | dappMemberDao.updateById(parent); |
| | | } |
| | | } |
| | | /** |
| | | * 判断下级代理数量是否达标 |
| | | * |
| | | * @return |
| | | */ |
| | | private boolean agentCntFinish(DappMemberEntity member,TeamLevelPerk teamLevelPerk) { |
| | | if (teamLevelPerk.getLastAgentCnt() == null || teamLevelPerk.getLastAgentCnt() == 0) { |
| | | return true; |
| | | } |
| | | |
| | | // 直推用户 |
| | | List<DappMemberEntity> directMember = dappMemberDao.selectMemberInfoByRefererId(member.getInviteId()); |
| | | if (CollUtil.isEmpty(directMember)) { |
| | | return false; |
| | | } |
| | | |
| | | // 用户团队达到指定代理数量,且都不在同一条线 |
| | | int i = 0; |
| | | for (DappMemberEntity child : directMember) { |
| | | List<DappMemberEntity> mallMembers = dappMemberDao.selectChildAgentList(child.getInviteId(), member.getAccountType()); |
| | | if (CollUtil.isNotEmpty(mallMembers)) { |
| | | i++; |
| | | } |
| | | } |
| | | |
| | | if (i >= teamLevelPerk.getLastAgentCnt()) { |
| | | return true; |
| | | } |
| | | |
| | | log.info("用户:{}代理数量未达标, 当前等级:{}, 当前数量:{}, 目标数量:{}", member.getAddress(), member.getAccountType(), i, teamLevelPerk.getLastAgentCnt()); |
| | | return false; |
| | | } |
| | | /** |
| | | * 团队业绩是否达标 |
| | | * 除去直属的最大的一个业绩团队,剩余的所有业绩之和 |
| | | */ |
| | | private boolean teamAchieveOther(DappMemberEntity member, TeamLevelPerk teamLevelPerk ) { |
| | | BigDecimal teamIncome = teamLevelPerk.getSmallAchieve(); |
| | | //总业绩 |
| | | BigDecimal teamIncomeMax = BigDecimal.ZERO; |
| | | //所有直推团队,就是这个会员的所有区域的业绩。 |
| | | |
| | | // 直推用户 |
| | | List<DappMemberEntity> childs = dappMemberDao.selectMemberInfoByRefererId(member.getInviteId()); |
| | | List<String> childsInviteIds = childs.stream().map(DappMemberEntity::getInviteId).collect(Collectors.toList()); |
| | | for(String inviteId : childsInviteIds){ |
| | | BigDecimal totalIncomeMember = dappMemberDao.selectAchieveRecordByInviteId(inviteId); |
| | | teamIncomeMax = teamIncomeMax.add(totalIncomeMember); |
| | | } |
| | | |
| | | if (teamIncomeMax.compareTo(teamIncome) >= 0) { |
| | | return true; |
| | | } |
| | | log.info("用户:{}团队业绩未达标, 当前等级:{}, 当前业绩:{}, 目标业绩:{}", member.getAddress(), member.getAccountType(), teamIncomeMax, teamIncome); |
| | | return false; |
| | | } |
| | | |
| | | /** |
| | | * 团队业绩是否达标 |
| | | * 除去直属的最大的一个业绩团队,剩余的所有业绩之和 |
| | | */ |
| | | private boolean teamAchieve(DappMemberEntity member, TeamLevelPerk teamLevelPerk ) { |
| | | BigDecimal teamIncome = teamLevelPerk.getSmallAchieve(); |
| | | //业绩集合 |
| | | List<BigDecimal> list = new ArrayList<>(); |
| | | //总业绩 |
| | | BigDecimal teamIncomeMax = BigDecimal.ZERO; |
| | | //所有直推团队,就是这个会员的所有区域的业绩。 |
| | | |
| | | // 直推用户 |
| | | List<DappMemberEntity> childs = dappMemberDao.selectMemberInfoByRefererId(member.getInviteId()); |
| | | List<String> childsInviteIds = childs.stream().map(DappMemberEntity::getInviteId).collect(Collectors.toList()); |
| | | for(String inviteId : childsInviteIds){ |
| | | BigDecimal totalIncomeMember = dappMemberDao.selectAchieveRecordByInviteId(inviteId); |
| | | teamIncomeMax = teamIncomeMax.add(totalIncomeMember); |
| | | list.add(totalIncomeMember); |
| | | } |
| | | //去掉一个最大区的业绩 |
| | | BigDecimal bigMax = list.stream().max(BigDecimal::compareTo).get(); |
| | | teamIncomeMax = teamIncomeMax.subtract(bigMax); |
| | | |
| | | if (teamIncomeMax.compareTo(teamIncome) >= 0) { |
| | | return true; |
| | | } |
| | | log.info("用户:{}团队业绩未达标, 当前等级:{}, 当前业绩:{}, 目标业绩:{}", member.getAddress(), member.getAccountType(), teamIncomeMax, teamIncome); |
| | | return false; |
| | | } |
| | | |
| | | |
| | | |
| | | @Override |
| | | public BigDecimal getRealNum(Long memberId, BigDecimal amount) { |
| | | BigDecimal returnAmount = BigDecimal.ZERO; |
| | | DappWalletMineEntity dappWalletMineEntity = dappWalletMineDao.selectByMemberId(memberId); |
| | | BigDecimal totalScore = dappWalletMineEntity.getTotalAmount(); |
| | | if(totalScore.compareTo(amount) >= 0){ |
| | | returnAmount = amount; |
| | | }else{ |
| | | returnAmount = totalScore; |
| | | } |
| | | return returnAmount; |
| | | } |
| | | |
| | | @Override |
| | | public void directMemberPerk() { |
| | | List<DappMemberEntity> dappMemberEntityList = dappMemberDao.selectMemberByActiveStatus(); |
| | | if(CollUtil.isEmpty(dappMemberEntityList)){ |
| | | return; |
| | | } |
| | | /** |
| | | * 直推消费分享:享受直接分享人每日消费金额释放的100%加速; |
| | | */ |
| | | for(DappMemberEntity dappMemberEntity : dappMemberEntityList){ |
| | | Long memberId = dappMemberEntity.getId(); |
| | | String inviteId = dappMemberEntity.getInviteId(); |
| | | //该用户全部的直推用户 |
| | | List<DappMemberEntity> dappMemberEntities = dappMemberDao.selectChildMemberDirectOrNot(inviteId, 1, 1); |
| | | for(DappMemberEntity directMember : dappMemberEntities){ |
| | | Long directMemberId = directMember.getId(); |
| | | chainProducer.sendDirectPerkMsg(directMemberId); |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void speedDirectPerkMsg(Long memberId) { |
| | | DappMemberEntity dappMemberEntity = dappMemberDao.selectById(memberId); |
| | | if(1 != dappMemberEntity.getActiveStatus()){ |
| | | return; |
| | | } |
| | | |
| | | DataDictionaryCustom directReleaseDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | DataDictionaryEnum.DIRECT_RELEASE.getType(), |
| | | DataDictionaryEnum.DIRECT_RELEASE.getCode() |
| | | ); |
| | | if(ObjectUtil.isEmpty(directReleaseDic)){ |
| | | return; |
| | | } |
| | | BigDecimal directRelease = new BigDecimal(directReleaseDic.getValue() == null ? "0" : directReleaseDic.getValue()); |
| | | if(BigDecimal.ZERO.compareTo(directRelease) >= 0){ |
| | | return; |
| | | } |
| | | DappMemberEntity parentMember = dappMemberDao.selectMemberInfoByInviteId(dappMemberEntity.getRefererId()); |
| | | /** |
| | | * 获取用户前一天的所有返利记录 |
| | | */ |
| | | List<DappFundFlowEntity> dappFundFlowEntities = dappFundFlowDao.selectListByMemberIdAndTypeAndDate(memberId, |
| | | FundFlowEnum.STATIC_RELEASE.getCode(),DateUtil.now()); |
| | | for(DappFundFlowEntity dappFundFlowEntity : dappFundFlowEntities){ |
| | | BigDecimal staticReleaseAmount = dappFundFlowEntity.getAmount(); |
| | | BigDecimal directReleaseAmount = staticReleaseAmount.multiply(directRelease).setScale(2, BigDecimal.ROUND_DOWN); |
| | | sendPerk(parentMember,directReleaseAmount,dappFundFlowEntity.getSystemProfitId(),FundFlowEnum.DIRECT_AMOUNT.getCode()); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void teamStaticPerk() { |
| | | List<DappMemberEntity> dappMemberEntities = dappMemberDao.selectMemberByAccountType(MemberLevelEnum.V1.getType()); |
| | | if(CollUtil.isEmpty(dappMemberEntities)){ |
| | | return; |
| | | } |
| | | |
| | | //平级 |
| | | DataDictionaryCustom teamPerkEqualsDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | DataDictionaryEnum.TEAM_PERK_LEVEL_EQUALS.getType(), |
| | | DataDictionaryEnum.TEAM_PERK_LEVEL_EQUALS.getCode()); |
| | | BigDecimal teamPerkEquals = new BigDecimal(ObjectUtil.isEmpty(teamPerkEqualsDic) ? "0.1" : teamPerkEqualsDic.getValue()); |
| | | DataDictionaryCustom staticReleaseDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | DataDictionaryEnum.STATIC_RELEASE.getType(), |
| | | DataDictionaryEnum.STATIC_RELEASE.getCode()); |
| | | BigDecimal staticRelease = new BigDecimal(ObjectUtil.isEmpty(staticReleaseDic) ? "0.006" : staticReleaseDic.getValue()); |
| | | |
| | | for(DappMemberEntity dappMemberEntity : dappMemberEntities){ |
| | | if(StrUtil.isNotEmpty(dappMemberEntity.getRefererIds())){ |
| | | String referrerIds = dappMemberEntity.getRefererIds(); |
| | | List<String> referrerIdList = StrUtil.splitTrim(referrerIds, ","); |
| | | |
| | | if(CollUtil.isNotEmpty(referrerIdList)){ |
| | | List<DappMemberEntity> mallMemberTeamPerk = dappMemberDao.selectByInviteIds(referrerIdList); |
| | | |
| | | if(CollUtil.isNotEmpty(mallMemberTeamPerk)){ |
| | | String levelNormal = MemberLevelEnum.V1.getType(); |
| | | BigDecimal cashPercentNormal = BigDecimal.ZERO; |
| | | |
| | | for(DappMemberEntity teamPerkMember : mallMemberTeamPerk){ |
| | | String level = teamPerkMember.getAccountType(); |
| | | //比较两个级别的大小,level大于levelNormal返回1 |
| | | int compareMin = MemberLevelEnum.V1.compareLevel(level, levelNormal); |
| | | int compareMax = MemberLevelEnum.V1.compareLevel(MemberLevelEnum.V7.getType(), level); |
| | | if(compareMin >= 1 && compareMax >= 1){ |
| | | DataDictionaryCustom teamPerkMemberDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | "TEAM_LEVEL", level); |
| | | TeamLevelPerk adminAgentInfo = JSONObject.parseObject(teamPerkMemberDic.getValue(), TeamLevelPerk.class); |
| | | BigDecimal cashPercent = adminAgentInfo.getTeamPercent(); |
| | | //极差 |
| | | if(MemberLevelEnum.V1.compareLevel(levelNormal, level) == 0){ |
| | | //平级 |
| | | cashPercent = cashPercent.subtract(teamPerkEquals); |
| | | }else{ |
| | | cashPercent = cashPercent.subtract(cashPercentNormal); |
| | | } |
| | | //总业绩 |
| | | BigDecimal teamIncomeMax = BigDecimal.ZERO; |
| | | //所有直推团队,就是这个会员的所有区域的业绩。 |
| | | |
| | | // 直推用户 |
| | | List<DappMemberEntity> childs = dappMemberDao.selectMemberInfoByRefererId(teamPerkMember.getInviteId()); |
| | | List<String> childsInviteIds = childs.stream().map(DappMemberEntity::getInviteId).collect(Collectors.toList()); |
| | | for(String inviteId : childsInviteIds){ |
| | | BigDecimal totalIncomeMember = dappMemberDao.selectAllAchieveByInviteId(inviteId); |
| | | teamIncomeMax = teamIncomeMax.add(totalIncomeMember); |
| | | } |
| | | if(BigDecimal.ZERO.compareTo(teamIncomeMax) >= 0){ |
| | | continue; |
| | | } |
| | | //V1加速团队静态收益的15%=每日静态的20000*6‰*15%=18元的额外释放加速 |
| | | BigDecimal cashAmount = teamIncomeMax.multiply(cashPercent).multiply(staticRelease).setScale(2, BigDecimal.ROUND_DOWN); |
| | | |
| | | BigDecimal bigDecimal = sendPerk(teamPerkMember, cashAmount, null, FundFlowEnum.TEAM_PERK.getCode()); |
| | | levelNormal = level; |
| | | cashPercentNormal = adminAgentInfo.getTeamPercent(); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | private BigDecimal sendPerk(DappMemberEntity parentMember,BigDecimal directReleaseAmount,Long orderId |
| | | ,Integer fundFlowEnumType){ |
| | | |
| | | BigDecimal realScoreReduce = BigDecimal.ZERO; |
| | | //用户减少赠送积分 |
| | | DappWalletMineEntity dappWalletMineEntity = dappWalletMineDao.selectByMemberId(parentMember.getId()); |
| | | BigDecimal totalScore = dappWalletMineEntity.getTotalAmount(); |
| | | BigDecimal availableScore = dappWalletMineEntity.getAvailableAmount(); |
| | | if(BigDecimal.ZERO.compareTo(totalScore) >= 0){ |
| | | parentMember.setActiveStatus(2); |
| | | dappMemberDao.updateById(parentMember); |
| | | return realScoreReduce; |
| | | } |
| | | if(directReleaseAmount.compareTo(totalScore) > 0){ |
| | | realScoreReduce = totalScore; |
| | | }else{ |
| | | realScoreReduce = directReleaseAmount; |
| | | } |
| | | BigDecimal totalScoreRelease = totalScore.subtract(realScoreReduce); |
| | | BigDecimal availableScoreRelease = availableScore.subtract(realScoreReduce); |
| | | //更新积分账户 |
| | | dappWalletMineEntity.setTotalAmount(totalScoreRelease); |
| | | dappWalletMineEntity.setAvailableAmount(availableScoreRelease); |
| | | dappWalletMineDao.updateById(dappWalletMineEntity); |
| | | //插入积分流水 |
| | | DappFundFlowEntity scoreFlow = new DappFundFlowEntity( |
| | | parentMember.getId(), |
| | | realScoreReduce.negate(), |
| | | FundFlowEnum.REDUCE_SCORE.getCode(), |
| | | DappFundFlowEntity.WITHDRAW_STATUS_AGREE, |
| | | BigDecimal.ZERO, |
| | | orderId); |
| | | dappFundFlowDao.insert(scoreFlow); |
| | | DappAccountMoneyChangeEntity reduceScoreAMC = new DappAccountMoneyChangeEntity( |
| | | parentMember.getId(), |
| | | totalScore, |
| | | realScoreReduce.negate(), |
| | | totalScoreRelease, |
| | | FundFlowEnum.REDUCE_SCORE.getCode(), |
| | | orderId.toString()); |
| | | dappAccountMoneyChangeDao.insert(reduceScoreAMC); |
| | | |
| | | //生成一条静态补贴的流水 |
| | | DappFundFlowEntity realUsdtAmountFlow = new DappFundFlowEntity( |
| | | parentMember.getId(), |
| | | realScoreReduce, |
| | | fundFlowEnumType, |
| | | DappFundFlowEntity.WITHDRAW_STATUS_AGREE, |
| | | BigDecimal.ZERO, |
| | | orderId); |
| | | dappFundFlowDao.insert(realUsdtAmountFlow); |
| | | //用户增加余额 |
| | | DappWalletCoinEntity dappWalletCoinEntity = dappWalletCoinDao.selectByMemberId(parentMember.getId()); |
| | | BigDecimal totalAmount = dappWalletCoinEntity.getTotalAmount(); |
| | | BigDecimal availableAmount = dappWalletCoinEntity.getAvailableAmount(); |
| | | |
| | | BigDecimal totalAmountRelease = totalAmount.add(realScoreReduce); |
| | | BigDecimal availableAmountRelease = availableAmount.add(realScoreReduce); |
| | | //更新余额账户 |
| | | dappWalletCoinEntity.setTotalAmount(totalAmountRelease); |
| | | dappWalletCoinEntity.setAvailableAmount(availableAmountRelease); |
| | | dappWalletCoinDao.updateById(dappWalletCoinEntity); |
| | | //插入余额流水 |
| | | DappFundFlowEntity amountFlow = new DappFundFlowEntity( |
| | | parentMember.getId(), |
| | | realScoreReduce, |
| | | FundFlowEnum.ADD_AMOUNT.getCode(), |
| | | DappFundFlowEntity.WITHDRAW_STATUS_AGREE, |
| | | BigDecimal.ZERO, |
| | | orderId); |
| | | dappFundFlowDao.insert(amountFlow); |
| | | DappAccountMoneyChangeEntity addAmountAMC = new DappAccountMoneyChangeEntity( |
| | | parentMember.getId(), |
| | | totalAmount, |
| | | realScoreReduce, |
| | | totalAmountRelease, |
| | | FundFlowEnum.ADD_AMOUNT.getCode(), |
| | | orderId.toString()); |
| | | dappAccountMoneyChangeDao.insert(addAmountAMC); |
| | | |
| | | return realScoreReduce; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 测试转账 |
| | | * @param args |
| | | */ |
| | | // public static void main(String[] args) { |
| | | // String transfer = ChainService.getInstance(ChainEnum.BSC_USDT_A_POOL.name()).transfer("0x74fC0e035f315F7BD8b7686e22581AB1afC45e97", new BigDecimal(1)); |
| | | // System.out.println(transfer); |
| | | // |
| | | // } |
| | | |
| | | /** |
| | | * 生成当前分钟的k线数据,type为0 |