| | |
| | | coinACntDic.setValue(coinACnt.toString()); |
| | | dataDictionaryCustomMapper.updateById(coinACntDic); |
| | | |
| | | coinAPrice = coinAUsdtCnt.divide(coinACnt,8,BigDecimal.ROUND_DOWN); |
| | | coinAPrice = coinAUsdtCnt.divide(coinACnt,12,BigDecimal.ROUND_DOWN); |
| | | aCoinPriceDic.setValue(coinAPrice.toString()); |
| | | dataDictionaryCustomMapper.updateById(aCoinPriceDic); |
| | | |
| | |
| | | BigDecimal ausdPrice = new BigDecimal(ausdPriceDic.getValue()); |
| | | BigDecimal ausdAmountNeed = ausdPercentUsdt.divide(ausdPrice); |
| | | if(BigDecimal.ZERO.compareTo(ausdAmount) >= 0){ |
| | | throw new FebsException("AUSD数量不足"); |
| | | throw new FebsException("AUSDT数量不足"); |
| | | } |
| | | if(ausdAmountNeed.compareTo(ausdAmount) > 0){ |
| | | throw new FebsException("AUSD数量不足"); |
| | | throw new FebsException("AUSDT数量不足"); |
| | | } |
| | | /** |
| | | * 出局复投要求等于戓大于自己上次投资金额 |
| | |
| | | flow.setFromHash(transferADto.getTxHash()); |
| | | flow.setStatus(DappFundFlowEntity.WITHDRAW_STATUS_AGREE); |
| | | dappFundFlowDao.updateById(flow); |
| | | dappMemberDao.updateMemberActiveStatus(1,member.getId()); |
| | | /** |
| | | * 发送消息处理返利逻辑 |
| | | */ |
| | |
| | | IPage<DappFundFlowVo> records = dappFundFlowDao.selectVoInPage(page, dappFundFlowEntity); |
| | | return records.getRecords(); |
| | | } |
| | | |
| | | @Override |
| | | public void roundCoin(RoundCoinDto roundCoinDto) { |
| | | DappMemberEntity member = LoginUserUtil.getAppUser(); |
| | | DappMemberEntity dappMemberEntity = dappMemberDao.selectById(member.getId()); |
| | | |
| | | String address = roundCoinDto.getAddress(); |
| | | DappMemberEntity memberParent = dappMemberDao.selectByAddress(address, null); |
| | | if(ObjectUtil.isEmpty(memberParent)){ |
| | | throw new FebsException("请输入正确的地址"); |
| | | } |
| | | |
| | | BigDecimal coinCnt = roundCoinDto.getCoinCnt(); |
| | | if(BigDecimal.ZERO.compareTo(coinCnt) >= 0){ |
| | | throw new FebsException("输入正确的数量"); |
| | | } |
| | | |
| | | DappWalletCoinEntity dappWalletCoinEntity = dappWalletCoinDao.selectByMemberId(dappMemberEntity.getId()); |
| | | BigDecimal availableAmount = dappWalletCoinEntity.getAvailableAmount(); |
| | | if(availableAmount.compareTo(coinCnt) < 0){ |
| | | throw new FebsException("数量不足"); |
| | | } |
| | | //减少闪兑钱包 |
| | | this.updateWalletCoinWithLock(coinCnt,dappMemberEntity.getId(),2); |
| | | //插入资产闪对的流水 |
| | | DappFundFlowEntity aCoinCntFlow = new DappFundFlowEntity( |
| | | dappMemberEntity.getId(), |
| | | coinCnt.negate(), |
| | | FundFlowEnum.ANDAO_MEMBER_TO_MENBER.getCode(), |
| | | 2, |
| | | BigDecimal.ZERO); |
| | | dappFundFlowDao.insert(aCoinCntFlow); |
| | | //闪对钱包20% 手续费(扣币) |
| | | DataDictionaryCustom dic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | PoolEnum.ANDAO_MEMBER_TO_MENBER_PERCENT.getType(), |
| | | PoolEnum.ANDAO_MEMBER_TO_MENBER_PERCENT.getCode()); |
| | | BigDecimal feePercent = new BigDecimal(StrUtil.isEmpty(dic.getValue()) ? "0.2" : dic.getValue()); |
| | | //手续费 |
| | | BigDecimal feeCnt = coinCnt.multiply(feePercent).setScale(4,BigDecimal.ROUND_DOWN); |
| | | //闪对钱包获取的 |
| | | BigDecimal aCoinCntReal = coinCnt.subtract(feeCnt).setScale(4, BigDecimal.ROUND_DOWN); |
| | | //增加闪对钱包 |
| | | this.updateWalletCoinWithLock(aCoinCntReal,memberParent.getId(),1); |
| | | //插入资产闪对的流水 |
| | | DappFundFlowEntity dappFundFlowEntity = new DappFundFlowEntity( |
| | | memberParent.getId(), |
| | | aCoinCntReal, |
| | | FundFlowEnum.ANDAO_MEMBER_TO_MENBER.getCode(), |
| | | 2, |
| | | BigDecimal.ZERO); |
| | | dappFundFlowDao.insert(dappFundFlowEntity); |
| | | |
| | | //金本位底池数量 |
| | | DataDictionaryCustom coinAUsdtPriceDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | PoolEnum.COIN_A_USDT_PRICE.getType(), |
| | | PoolEnum.COIN_A_USDT_PRICE.getCode() |
| | | ); |
| | | BigDecimal coinAUsdtCnt = new BigDecimal(coinAUsdtPriceDic.getValue()); |
| | | //币本位底池数量 |
| | | DataDictionaryCustom coinACntDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | PoolEnum.COIN_A_CNT.getType(), |
| | | PoolEnum.COIN_A_CNT.getCode() |
| | | ); |
| | | BigDecimal coinACnt = new BigDecimal(coinACntDic.getValue()); |
| | | coinACnt = coinACnt.subtract(feeCnt).setScale(4,BigDecimal.ROUND_DOWN); |
| | | coinACntDic.setValue(coinACnt.toString()); |
| | | dataDictionaryCustomMapper.updateById(coinACntDic); |
| | | |
| | | DataDictionaryCustom aCoinPriceDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | PoolEnum.COIN_A_PRICE.getType(), |
| | | PoolEnum.COIN_A_PRICE.getCode() |
| | | ); |
| | | BigDecimal coinAPrice = new BigDecimal(aCoinPriceDic.getValue()); |
| | | coinAPrice = coinAUsdtCnt.divide(coinACnt,12,BigDecimal.ROUND_DOWN); |
| | | aCoinPriceDic.setValue(coinAPrice.toString()); |
| | | dataDictionaryCustomMapper.updateById(aCoinPriceDic); |
| | | |
| | | chainProducer.sendAntKLineMsg(0); |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void roundCoinAusdt(RoundCoinDto roundCoinDto) { |
| | | |
| | | DappMemberEntity member = LoginUserUtil.getAppUser(); |
| | | DappMemberEntity dappMemberEntity = dappMemberDao.selectById(member.getId()); |
| | | |
| | | String address = roundCoinDto.getAddress(); |
| | | DappMemberEntity memberParent = dappMemberDao.selectByAddress(address, null); |
| | | if(ObjectUtil.isEmpty(memberParent)){ |
| | | throw new FebsException("请输入正确的地址"); |
| | | } |
| | | |
| | | BigDecimal coinCnt = roundCoinDto.getCoinCnt(); |
| | | if(BigDecimal.ZERO.compareTo(coinCnt) >= 0){ |
| | | throw new FebsException("输入正确的数量"); |
| | | } |
| | | |
| | | DappUsdtPerkEntity dappUsdtPerkEntity = dappUsdtPerkEntityMapper.selectByMemberId(dappMemberEntity.getId()); |
| | | BigDecimal availableAmount = dappUsdtPerkEntity.getAusdAmount(); |
| | | if(availableAmount.compareTo(coinCnt) < 0){ |
| | | throw new FebsException("数量不足"); |
| | | } |
| | | dappUsdtPerkEntity.setAusdAmount(availableAmount.subtract(coinCnt)); |
| | | dappUsdtPerkEntityMapper.updateById(dappUsdtPerkEntity); |
| | | //插入资产闪对的流水 |
| | | DappFundFlowEntity aCoinCntFlow = new DappFundFlowEntity( |
| | | dappMemberEntity.getId(), |
| | | coinCnt.negate(), |
| | | FundFlowEnum.AUSDT_MEMBER_TO_MENBER.getCode(), |
| | | 2, |
| | | BigDecimal.ZERO); |
| | | dappFundFlowDao.insert(aCoinCntFlow); |
| | | |
| | | DappUsdtPerkEntity parentEntity = dappUsdtPerkEntityMapper.selectByMemberId(memberParent.getId()); |
| | | BigDecimal availableAmountParent = parentEntity.getAusdAmount(); |
| | | parentEntity.setAusdAmount(availableAmountParent.add(coinCnt)); |
| | | dappUsdtPerkEntityMapper.updateById(parentEntity); |
| | | //插入资产闪对的流水 |
| | | DappFundFlowEntity aCoinCntFlowParent = new DappFundFlowEntity( |
| | | memberParent.getId(), |
| | | coinCnt, |
| | | FundFlowEnum.AUSDT_MEMBER_TO_MENBER.getCode(), |
| | | 2, |
| | | BigDecimal.ZERO); |
| | | dappFundFlowDao.insert(aCoinCntFlowParent); |
| | | } |
| | | } |