| | |
| | | @Override |
| | | public Object beforeBodyWrite(Object o, MethodParameter methodParameter, MediaType mediaType, Class aClass, ServerHttpRequest serverHttpRequest, ServerHttpResponse serverHttpResponse) { |
| | | if (!AppContants.ENCRYPT_METHOD.contains(methodParameter.getMethod().getName()) || isDebug) { |
| | | System.out.println(1111111); |
| | | return o; |
| | | } |
| | | |
| | |
| | | private BigDecimal amount; |
| | | |
| | | /** |
| | | * 类型 1-买入 2-矩阵收益 3-直推收益 |
| | | * 类型 1-买入 2-矩阵收益 3-直推收益 4-保险池 |
| | | */ |
| | | private Integer type; |
| | | |
| | |
| | | private Integer partnerCnt; |
| | | |
| | | private BigDecimal partnerIncome; |
| | | |
| | | /** |
| | | * 保险池 |
| | | */ |
| | | private BigDecimal safePool; |
| | | } |
| | |
| | | package cc.mrbird.febs.dapp.mapper; |
| | | |
| | | import cc.mrbird.febs.dapp.entity.DappMineDataEntity; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | public interface DappSystemDao { |
| | | |
| | | DappMineDataEntity selectMineDataForOne(); |
| | | |
| | | int updateMineData(@Param("record") DappMineDataEntity dappMineDataEntity); |
| | | } |
| | |
| | | DappWalletCoinEntity selectByMemberId(@Param("memberId") Long memberId); |
| | | |
| | | IPage<DappWalletCoinEntity> selectInPage(@Param("record") DappWalletCoinEntity walletCoin, Page<DappWalletCoinEntity> page); |
| | | |
| | | int updateWithLock(@Param("record") DappWalletCoinEntity dappWalletCoinEntity); |
| | | } |
| | |
| | | boolean hasProfit(String address); |
| | | |
| | | void achieveTree(Long memberId); |
| | | |
| | | /** |
| | | * 投入收益 |
| | | * |
| | | * @param isReIn |
| | | */ |
| | | void putIntoProfit(Long memberId, int isReIn); |
| | | } |
| | |
| | | |
| | | List<ActiveNftListVo> findUnActiveNftList(); |
| | | |
| | | void withdraw(@RequestBody WithdrawDto withdrawDto); |
| | | void withdraw(WithdrawDto withdrawDto); |
| | | |
| | | void updateWalletCoinWithLock(BigDecimal amount, Long memberId); |
| | | |
| | | } |
| | |
| | | } |
| | | OnlineTransferUtil.addTransferRecord(e.from, e.to, amount, e.log.getTransactionHash(), DappTransferRecordEntity.TRANSFER_SOURCE_FLAG_APPLICATION, "USDT"); |
| | | |
| | | fundFlow.setAmount(fundFlow.getAmount().negate()); |
| | | // 更改状态为已同步 |
| | | fundFlow.setStatus(2); |
| | | dappFundFlowDao.updateById(fundFlow); |
| | | |
| | | synchronized (this) { |
| | | DappWalletCoinEntity walletCoin = dappWalletCoinDao.selectByMemberId(fundFlow.getMemberId()); |
| | | walletCoin.setTotalAmount(walletCoin.getTotalAmount().add(amount)); |
| | | walletCoin.setAvailableAmount(walletCoin.getAvailableAmount().add(amount)); |
| | | dappWalletCoinDao.updateById(walletCoin); |
| | | } |
| | | |
| | | chainProducer.sendAchieveTreeMsg(fundFlow.getMemberId()); |
| | | } |
| | |
| | | if (child.size() == 6) { |
| | | throw new FebsException("Invite Code is Invalid"); |
| | | } |
| | | } else { |
| | | connectDto.setInviteId(null); |
| | | } |
| | | member = insertMember(connectDto.getAddress(), null); |
| | | member = insertMember(connectDto.getAddress(), connectDto.getInviteId()); |
| | | } |
| | | |
| | | String key = LoginUserUtil.getLoginKey(connectDto.getAddress(), connectDto.getNonce(), connectDto.getSign()); |
| | |
| | | member.setChainType(chainType); |
| | | member.setAccountType(accountType); |
| | | member.setActiveStatus(2); |
| | | // member.setBalance(ChainService.getInstance(ChainEnum.BSC_TFC.name()).balanceOf(address)); |
| | | // member.setUsdtBalance(ChainService.getInstance(ChainEnum.BSC_USDT.name()).balanceOf(address)); |
| | | |
| | | dappMemberDao.insert(member); |
| | | |
| | |
| | | boolean flag = false; |
| | | String parentId = refererId; |
| | | String ids = ""; |
| | | String feeProfitIds = ""; |
| | | |
| | | while (!flag && StringUtils.isNotBlank(parentId)) { |
| | | if (StrUtil.isBlank(ids)) { |
| | | ids += parentId; |
| | | } else { |
| | | ids += ("," + parentId); |
| | | } |
| | | |
| | | if (StrUtil.isBlank(feeProfitIds)) { |
| | | feeProfitIds += parentId; |
| | | } else { |
| | | feeProfitIds += ("," + parentId); |
| | | } |
| | | |
| | | DappMemberEntity parentMember = dappMemberDao.selectMemberInfoByInviteId(parentId); |
| | |
| | | } |
| | | } |
| | | member.setRefererIds(ids); |
| | | member.setFeeProfitIds(feeProfitIds); |
| | | } |
| | | dappMemberDao.updateById(member); |
| | | |
| | |
| | | import cc.mrbird.febs.dapp.enumerate.CardPeriod; |
| | | 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.utils.OnlineTransferUtil; |
| | | import cc.mrbird.febs.dapp.vo.RedisTransferPoolVo; |
| | | import cc.mrbird.febs.dapp.vo.SlipSettingVo; |
| | |
| | | |
| | | private final DappAchieveTreeDao dappAchieveTreeDao; |
| | | private final DappAchieveMemberTreeDao dappAchieveMemberTreeDao; |
| | | private final DappWalletService dappWalletService; |
| | | |
| | | |
| | | @Override |
| | |
| | | } |
| | | dappAchieveMemberTreeDao.insert(achieveMemberTree); |
| | | |
| | | // 激活用户状态 |
| | | member.setActiveStatus(1); |
| | | dappMemberDao.updateById(member); |
| | | |
| | | putIntoProfit(memberId, 2); |
| | | if (parentNode == null) { |
| | | return; |
| | | } |
| | |
| | | dappAchieveMemberTreeDao.resetMatrixTree(memberId); |
| | | dappAchieveMemberTreeDao.reentryMoney(memberId); |
| | | |
| | | putIntoProfit(memberId, 1); |
| | | DappAchieveMemberTreeEntity bottomNode = dappAchieveMemberTreeDao.selectNodeByDeep(memberId, 3); |
| | | if (bottomNode != null) { |
| | | finishMatrixTree(bottomNode.getTopNode()); |
| | | } |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void putIntoProfit(Long memberId, int isReIn) { |
| | | DappMemberEntity member = dappMemberDao.selectById(memberId); |
| | | DappMemberEntity parent = dappMemberDao.selectMemberInfoByInviteId(member.getRefererId()); |
| | | |
| | | if (parent != null) { |
| | | BigDecimal directProfit = new BigDecimal("100").multiply(new BigDecimal("0.15")); |
| | | dappWalletService.updateWalletCoinWithLock(directProfit, parent.getId()); |
| | | |
| | | DappFundFlowEntity fundFlow = new DappFundFlowEntity(parent.getId(), directProfit, 3, 2, null, null); |
| | | dappFundFlowDao.insert(fundFlow); |
| | | } |
| | | |
| | | // 如果是复投的,则需奖励 |
| | | if (isReIn == 1) { |
| | | dappWalletService.updateWalletCoinWithLock(new BigDecimal(190), member.getId()); |
| | | |
| | | DappFundFlowEntity matrixProfitFlow = new DappFundFlowEntity(memberId, new BigDecimal("190"), 2, 2, null, null); |
| | | dappFundFlowDao.insert(matrixProfitFlow); |
| | | |
| | | DappFundFlowEntity rePutInFlow = new DappFundFlowEntity(memberId, new BigDecimal("100").negate(), 1, 2, null, null); |
| | | dappFundFlowDao.insert(rePutInFlow); |
| | | |
| | | DappFundFlowEntity safePoolFlow = new DappFundFlowEntity(memberId, new BigDecimal("10").negate(), 4, 2, null, null); |
| | | dappFundFlowDao.insert(safePoolFlow); |
| | | |
| | | DappMineDataEntity mineData = dappSystemDao.selectMineDataForOne(); |
| | | mineData.setSafePool(mineData.getSafePool().add(BigDecimal.TEN)); |
| | | dappSystemDao.updateMineData(mineData); |
| | | } |
| | | } |
| | | } |
| | |
| | | import cc.mrbird.febs.dapp.dto.*; |
| | | import cc.mrbird.febs.dapp.entity.*; |
| | | 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.utils.BoxUtil; |
| | | import cc.mrbird.febs.dapp.vo.ActiveNftListVo; |
| | |
| | | private final DappAccountMoneyChangeDao dappAccountMoneyChangeDao; |
| | | private final RedisUtils redisUtils; |
| | | private final DataDictionaryCustomMapper dataDictionaryCustomMapper; |
| | | private final DappSystemService dappSystemService; |
| | | private final DappNftActivationDao dappNftActivationDao; |
| | | |
| | | private final ChainProducer chainProducer; |
| | |
| | | if (transferDto.getAmount().compareTo(walletCoin.getAvailableAmount()) > 0) { |
| | | throw new FebsException("Balance Not Enough"); |
| | | } |
| | | walletCoin.setTotalAmount(walletCoin.getTotalAmount().subtract(transferDto.getAmount())); |
| | | walletCoin.setAvailableAmount(walletCoin.getAvailableAmount().subtract(transferDto.getAmount())); |
| | | |
| | | dappWalletCoinDao.updateById(walletCoin); |
| | | updateWalletCoinWithLock(transferDto.getAmount().negate(), member.getId()); |
| | | |
| | | DappFundFlowEntity fundFlow = new DappFundFlowEntity(member.getId(), transferDto.getAmount(), 1, 2, transferDto.getFee(), transferDto.getTxHash()); |
| | | DappFundFlowEntity fundFlow = new DappFundFlowEntity(member.getId(), transferDto.getAmount().negate(), 1, 2, transferDto.getFee(), transferDto.getTxHash()); |
| | | dappFundFlowDao.insert(fundFlow); |
| | | |
| | | chainProducer.sendAchieveTreeMsg(member.getId()); |
| | |
| | | |
| | | @Override |
| | | public Map<String, BigDecimal> calPrice(PriceDto priceDto) { |
| | | DappMemberEntity member = LoginUserUtil.getAppUser(); |
| | | |
| | | if (!dappSystemService.systemHasStart()) { |
| | | HashMap<String, BigDecimal> map = new HashMap<>(); |
| | | map.put("x", new BigDecimal("0.05")); |
| | | map.put("y", new BigDecimal("0.05")); |
| | | return map; |
| | | } |
| | | |
| | | ContractChainService tfcInstance = ChainService.getInstance(ChainEnum.BSC_TFC.name()); |
| | | // u剩余数量 |
| | | BigDecimal sourceU = ChainService.getInstance(ChainEnum.BSC_USDT.name()).balanceOf(ChainEnum.BSC_USDT_SOURCE.getAddress()); |
| | | // 源池代币剩余数量 |
| | | BigDecimal sourceCoin = tfcInstance.balanceOf(ChainEnum.BSC_USDT_SOURCE.getAddress()); |
| | | // 用户卖出数量 |
| | | BigDecimal coin = priceDto.getAmount(); |
| | | BigDecimal x = sourceU.divide(sourceCoin, tfcInstance.decimals(), RoundingMode.HALF_UP); |
| | | BigDecimal y = sourceU.divide(sourceCoin.add(coin), tfcInstance.decimals(), RoundingMode.HALF_UP); |
| | | |
| | | log.info("购买价格:{}, 出卖价格:{}", x, y); |
| | | HashMap<String, BigDecimal> map = new HashMap<>(); |
| | | map.put("x", x); |
| | | map.put("y", y); |
| | | return map; |
| | | return null; |
| | | } |
| | | |
| | | @Override |
| | |
| | | public void withdraw(WithdrawDto withdrawDto) { |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void updateWalletCoinWithLock(BigDecimal amount, Long memberId) { |
| | | boolean isSuccess = false; |
| | | while(!isSuccess) { |
| | | DappWalletCoinEntity walletCoin = dappWalletCoinDao.selectByMemberId(memberId); |
| | | |
| | | walletCoin.setTotalAmount(walletCoin.getTotalAmount().add(amount)); |
| | | walletCoin.setAvailableAmount(walletCoin.getAvailableAmount().add(amount)); |
| | | |
| | | int i = dappWalletCoinDao.updateWithLock(walletCoin); |
| | | if (i > 0) { |
| | | isSuccess = true; |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | node.setMemberId(treeNode.getMidNode()); |
| | | instance.addNode(node); |
| | | } |
| | | System.out.println(11); |
| | | } |
| | | } |
| | |
| | | select * from dapp_mine_data limit 1 |
| | | </select> |
| | | |
| | | <update id="updateMineData"> |
| | | update dapp_mine_data |
| | | set safe_pool=#{record.safePool} |
| | | where id=#{record.id} |
| | | </update> |
| | | </mapper> |
| | |
| | | </if> |
| | | </where> |
| | | </select> |
| | | |
| | | <update id="updateWithLock"> |
| | | update dapp_wallet_coin |
| | | set total_amount=#{record.totalAmount}, |
| | | available_amount=#{record.availableAmount}, |
| | | version=version+1 |
| | | where id=#{record.id} and version=#{record.version} |
| | | </update> |
| | | </mapper> |