| | |
| | | * A币卖币规则,卖出100%销毁,30%回流底池溢价 |
| | | */ |
| | | DappMemberEntity member = LoginUserUtil.getAppUser(); |
| | | |
| | | DataDictionaryCustom systemStateDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | PoolEnum.SYSTEM.getType(), |
| | | PoolEnum.SYSTEM.getCode() |
| | | ); |
| | | String value = systemStateDic.getValue(); |
| | | if("STOP".equals(value)){ |
| | | throw new FebsException("Not yet open"); |
| | | } |
| | | //提币数量 |
| | | BigDecimal amount = withdrawDto.getAmount(); |
| | | if(BigDecimal.ZERO.compareTo(amount) >= 0){ |
| | |
| | | BigDecimal feePercent = new BigDecimal(toUsdtPercentFeeDic.getValue()); |
| | | //手续费扣除USDT |
| | | BigDecimal feeUsdtAmount = coinUsdtAmount.multiply(feePercent).setScale(4,BigDecimal.ROUND_DOWN); |
| | | //实际提现USDT数量 |
| | | BigDecimal realUsdtAmount = coinUsdtAmount.subtract(feeUsdtAmount).setScale(4,BigDecimal.ROUND_DOWN); |
| | | //实际提现USDT数量,先扣除1%的手续费后,只到账70% |
| | | |
| | | DataDictionaryCustom outPercentDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | PoolEnum.WALLET_COIN_OUT_PERCENT.getType(), |
| | | PoolEnum.WALLET_COIN_OUT_PERCENT.getCode() |
| | | ); |
| | | BigDecimal outPercent = new BigDecimal(outPercentDic.getValue()); |
| | | BigDecimal realUsdtAmount = coinUsdtAmount.subtract(feeUsdtAmount).setScale(4,BigDecimal.ROUND_DOWN); |
| | | BigDecimal realUsdtAmountFee = realUsdtAmount.multiply(outPercent).setScale(4,BigDecimal.ROUND_DOWN); |
| | | realUsdtAmount = realUsdtAmount.subtract(realUsdtAmountFee); |
| | | //减少闪对钱包的币的数量 |
| | | this.updateWalletCoinWithLock(amount, member.getId(), 2); |
| | | //增加流水 |
| | |
| | | /** |
| | | * A币卖币规则,卖出100%销毁,30%回流底池溢价 |
| | | */ |
| | | DataDictionaryCustom outPercentDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | PoolEnum.WALLET_COIN_OUT_PERCENT.getType(), |
| | | PoolEnum.WALLET_COIN_OUT_PERCENT.getCode() |
| | | ); |
| | | BigDecimal outPercent = new BigDecimal(outPercentDic.getValue()); |
| | | coinUsdtAmount = coinUsdtAmount.multiply(outPercent).setScale(4,BigDecimal.ROUND_DOWN); |
| | | //金本位底池数量 |
| | | DataDictionaryCustom coinAUsdtPriceDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | |
| | | 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); |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | public static void main(String[] args) { |
| | | String ss = "0x2bBAD0d2362a8dbdc655fBa5A0cd51d5379e38f7,0xd5c13dc4372d1e02b93add9dcca901bef51168be,0xe22bb5fB2e0F8ED9366785dADD33cA19355d037c,0x7685E62E679886494E3cdc3DE7103E026f815AF0,0x6893bE8F4fb73595A13f32bA5e1d198Ab135516C"; |
| | | if(ss.contains("0xd5c13dc4372d1e02b93add9dcca901bef51168be")){ |
| | | System.out.println(1); |
| | | }else{ |
| | | System.out.println(2); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public Long transferA(TransferADto transferADto) { |
| | | DappMemberEntity member = LoginUserUtil.getAppUser(); |
| | | DappMemberEntity dappMemberEntity = dappMemberDao.selectById(member.getId()); |
| | | |
| | | DataDictionaryCustom systemStateDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | PoolEnum.SYSTEM.getType(), |
| | | PoolEnum.SYSTEM.getCode() |
| | | ); |
| | | String value = systemStateDic.getValue(); |
| | | if("STOP".equals(value)){ |
| | | throw new FebsException("Not yet open"); |
| | | } |
| | | String upgrade = redisUtils.getString("APP_UPGRADE"); |
| | | if ("upgrade".equals(upgrade)) { |
| | | throw new FebsException("功能升级中"); |
| | |
| | | } |
| | | } |
| | | /** |
| | | * 入金限制 |
| | | * 每人总共入金100U |
| | | */ |
| | | BigDecimal amountIn = transferADto.getAmount(); |
| | | if(amountIn.compareTo(new BigDecimal(100)) != 0){ |
| | | throw new FebsException("Limit per address 100 USDT"); |
| | | } |
| | | |
| | | // BigDecimal amountInLast = dappChargeUsdtMapper.selectByMaxAmountMemberId(member.getId()); |
| | | /** |
| | | * 限制用户买入总额, |
| | | * 目前每人限一单,总金额限制100U |
| | | */ |
| | | BigDecimal amountInLast = dappChargeUsdtMapper.selectBySumAmountMemberId(member.getId()); |
| | | DataDictionaryCustom systemAddressDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | PoolEnum.SYSTEM_ADDRESS.getType(), |
| | | PoolEnum.SYSTEM_ADDRESS.getCode() |
| | | ); |
| | | if(StrUtil.isNotEmpty(systemAddressDic.getValue())){ |
| | | if(!(dappMemberEntity.getAddress().equals("0x2bBAD0d2362a8dbdc655fBa5A0cd51d5379e38f7") |
| | | ||dappMemberEntity.getAddress().equals("0xd5c13dc4372d1e02b93add9dcca901bef51168be") |
| | | ||dappMemberEntity.getAddress().equals("0xe22bb5fB2e0F8ED9366785dADD33cA19355d037c") |
| | | ||dappMemberEntity.getAddress().equals("0x7685E62E679886494E3cdc3DE7103E026f815AF0") |
| | | ||dappMemberEntity.getAddress().equals("0x6893bE8F4fb73595A13f32bA5e1d198Ab135516C") |
| | | )){ |
| | | if(BigDecimal.ZERO.compareTo(amountInLast) < 0){ |
| | | throw new FebsException("Limit per address 100 USDT"); |
| | | } |
| | | } |
| | | // if(!systemAddressDic.getValue().contains(dappMemberEntity.getAddress())){ |
| | | // if(BigDecimal.ZERO.compareTo(amountInLast) < 0){ |
| | | // throw new FebsException("Limit per address 100 USDT"); |
| | | // } |
| | | // } |
| | | }else{ |
| | | if(BigDecimal.ZERO.compareTo(amountInLast) < 0){ |
| | | throw new FebsException("Limit per address 100 USDT"); |
| | | } |
| | | } |
| | | /** |
| | | * 验证账户是否有入金金额的10%的AUSD |
| | | */ |
| | | DappUsdtPerkEntity dappUsdtPerkEntity = dappUsdtPerkEntityMapper.selectByMemberId(member.getId()); |
| | |
| | | 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数量不足"); |
| | | } |
| | | /** |
| | | * 出局复投要求等于戓大于自己上次投资金额 |
| | |
| | | dappFundFlowDao.insert(memberFeeflow); |
| | | //插入资产闪对手续费的流水 |
| | | DappFundFlowEntity dappFundFlowEntityFee = new DappFundFlowEntity( |
| | | 1L, |
| | | 295L, |
| | | feeCnt, |
| | | FundFlowEnum.WALLET_MINE_TO_COIN_FEE.getCode(), |
| | | 2, |
| | | BigDecimal.ZERO); |
| | | dappFundFlowDao.insert(dappFundFlowEntityFee); |
| | | this.updateWalletMineWithLock(feeCnt,1L,1); |
| | | this.updateWalletMineWithLock(feeCnt,295L,1); |
| | | } |
| | | |
| | | @Override |
| | |
| | | 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, |
| | | dappMemberEntity.getAddress(), |
| | | memberParent.getAddress(), |
| | | memberParent.getId()); |
| | | 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, |
| | | dappMemberEntity.getAddress(), |
| | | memberParent.getAddress(), |
| | | dappMemberEntity.getId()); |
| | | 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, |
| | | dappMemberEntity.getAddress(), |
| | | memberParent.getAddress(), |
| | | memberParent.getId()); |
| | | dappFundFlowDao.insert(aCoinCntFlow); |
| | | |
| | | DappUsdtPerkEntity parentEntity = dappUsdtPerkEntityMapper.selectByMemberId(memberParent.getId()); |
| | | if(ObjectUtil.isEmpty(parentEntity)){ |
| | | parentEntity = new DappUsdtPerkEntity(); |
| | | parentEntity.setMemberId(memberParent.getId()); |
| | | dappUsdtPerkEntityMapper.insert(parentEntity); |
| | | } |
| | | BigDecimal availableAmountParent = ObjectUtil.isEmpty(parentEntity.getAusdAmount()) ? BigDecimal.ZERO : 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, |
| | | dappMemberEntity.getAddress(), |
| | | memberParent.getAddress(), |
| | | dappMemberEntity.getId()); |
| | | dappFundFlowDao.insert(aCoinCntFlowParent); |
| | | } |
| | | } |