| | |
| | | import cc.mrbird.febs.common.enumerates.FlowTypeEnum; |
| | | import cc.mrbird.febs.common.exception.FebsException; |
| | | import cc.mrbird.febs.common.utils.RedisUtils; |
| | | import cc.mrbird.febs.dapp.dto.TransferDto; |
| | | import cc.mrbird.febs.dapp.dto.ZhiyaAddDto; |
| | | import cc.mrbird.febs.dapp.entity.*; |
| | | import cc.mrbird.febs.dapp.mapper.*; |
| | |
| | | |
| | | //用户质押代币数量 |
| | | Long memberId = fundFlow.getMemberId(); |
| | | //新增一条用户质押记录 |
| | | DappAchieve dappAchieve = new DappAchieve(); |
| | | dappAchieve.setMemberId(memberId); |
| | | DappHdRecord dappHdRecord = dappHdRecordMapper.selectNewRecord(); |
| | | dappAchieve.setPrice(dappHdRecord.getPrice()); |
| | | dappAchieve.setAmount(amount); |
| | | BigDecimal achieveReleasePercent = new BigDecimal("0.01").multiply( |
| | | new BigDecimal(redisUtils.getString(DataDicEnum.GFA_ACHIEVE_RELEASE.getValue())).setScale(2,BigDecimal.ROUND_DOWN) |
| | | ); |
| | | DappHdRecord dappHdRecord = dappHdRecordMapper.selectNewRecord(); |
| | | dappAchieve.setPrice(dappHdRecord.getPrice()); |
| | | dappAchieve.setAmountDay(achieveReleasePercent.multiply(amount).setScale(2,BigDecimal.ROUND_DOWN)); |
| | | BigDecimal achieveOut = new BigDecimal(redisUtils.getString(DataDicEnum.GFA_ACHIEVE_OUT.getValue())).setScale(2,BigDecimal.ROUND_DOWN); |
| | | dappAchieve.setAmountMax(achieveOut.multiply(amount).setScale(2,BigDecimal.ROUND_DOWN)); |
| | | dappAchieve.setState(DappAchieve.STATUS_ING); |
| | | dappAchieve.setAmountDone(BigDecimal.ZERO); |
| | | |
| | | /** |
| | | * 计算金本位和币本位 |
| | | * 金本位:数量*价格*70*产矿百分比 |
| | | * 币本位:数量*30*产矿百分比 |
| | | */ |
| | | BigDecimal price = dappHdRecord.getPrice(); |
| | | BigDecimal goldAmount = amount.multiply(price).multiply(new BigDecimal("0.7")).multiply(achieveOut).setScale(8, BigDecimal.ROUND_DOWN); |
| | | BigDecimal coinAmount = amount.multiply(new BigDecimal("0.3")).multiply(achieveOut).setScale(8, BigDecimal.ROUND_DOWN); |
| | | dappAchieve.setGoldAmount(goldAmount); |
| | | dappAchieve.setCoinAmount(coinAmount); |
| | | dappAchieveMapper.insert(dappAchieve); |
| | | asyncCjService.insertTeamPerk(fundFlow.getId(), dappAchieve.getId()); |
| | | //新增一条用户质押记录 |
| | | // DappAchieve dappAchieve = new DappAchieve(); |
| | | // dappAchieve.setMemberId(memberId); |
| | | // dappAchieve.setAmount(amount); |
| | | // BigDecimal achieveReleasePercent = new BigDecimal("0.01").multiply( |
| | | // new BigDecimal(redisUtils.getString(DataDicEnum.GFA_ACHIEVE_RELEASE.getValue())).setScale(2,BigDecimal.ROUND_DOWN) |
| | | // ); |
| | | // DappHdRecord dappHdRecord = dappHdRecordMapper.selectNewRecord(); |
| | | // dappAchieve.setPrice(dappHdRecord.getPrice()); |
| | | // dappAchieve.setAmountDay(achieveReleasePercent.multiply(amount).setScale(2,BigDecimal.ROUND_DOWN)); |
| | | // BigDecimal achieveOut = new BigDecimal(redisUtils.getString(DataDicEnum.GFA_ACHIEVE_OUT.getValue())).setScale(2,BigDecimal.ROUND_DOWN); |
| | | // dappAchieve.setAmountMax(achieveOut.multiply(amount).setScale(2,BigDecimal.ROUND_DOWN)); |
| | | // dappAchieve.setState(DappAchieve.STATUS_ING); |
| | | // dappAchieve.setAmountDone(BigDecimal.ZERO); |
| | | // dappAchieveMapper.insert(dappAchieve); |
| | | // asyncCjService.insertTeamPerk(fundFlow.getId(), dappAchieve.getId()); |
| | | // asyncCjService.calculateAchieve(dappAchieve); |
| | | return new FebsResponse().success(); |
| | | } |
| | | |
| | | @Override |
| | | public FebsResponse zhiyaAddNew() { |
| | | List<DappFundFlowEntity> dappFundFlowEntities = dappFundFlowDao.selectList( |
| | | new QueryWrapper<DappFundFlowEntity>() |
| | | .ge("id", 7599L) |
| | | .lt("id", 7688L)); |
| | | |
| | | if(CollUtil.isNotEmpty(dappFundFlowEntities)){ |
| | | for(DappFundFlowEntity dappFundFlowEntity : dappFundFlowEntities){ |
| | | Integer type = dappFundFlowEntity.getType(); |
| | | if(FlowTypeEnum.HUA_DIAN_GEREN.getValue() == type || FlowTypeEnum.HUA_DIAN_TUANDUI_USDT.getValue() == type){ |
| | | Long memberId = dappFundFlowEntity.getMemberId(); |
| | | BigDecimal amount = dappFundFlowEntity.getAmount(); |
| | | DappMemberEntity dappMemberEntity = dappMemberDao.selectById(memberId); |
| | | BigDecimal usdtBalance = dappMemberEntity.getUsdtBalance(); |
| | | dappMemberEntity.setUsdtBalance(usdtBalance.subtract(amount)); |
| | | dappMemberDao.updateUsdtBalanceWithVersion(dappMemberEntity); |
| | | log.info("流水处理中。。。。。。"+dappFundFlowEntity.getId()+",处理金额"+amount+",账户余额:"+usdtBalance+",操作后余额:"+dappMemberEntity.getUsdtBalance()); |
| | | dappFundFlowDao.deleteById(dappFundFlowEntity.getId()); |
| | | } |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | } |