| | |
| | | import cc.mrbird.febs.dapp.dto.*; |
| | | import cc.mrbird.febs.dapp.entity.*; |
| | | import cc.mrbird.febs.dapp.enumerate.DataDictionaryEnum; |
| | | import cc.mrbird.febs.dapp.enumerate.MemberLevelEnum; |
| | | import cc.mrbird.febs.dapp.enumerate.MoneyFlowEnum; |
| | | import cc.mrbird.febs.dapp.enumerate.NodeType; |
| | | import cc.mrbird.febs.dapp.mapper.*; |
| | | import cc.mrbird.febs.dapp.service.DappWalletService; |
| | | import cc.mrbird.febs.dapp.vo.MemberNodeVo; |
| | | import cc.mrbird.febs.dapp.vo.NodeTypeVo; |
| | | import cc.mrbird.febs.dapp.vo.WalletInfoVo; |
| | | import cc.mrbird.febs.dapp.vo.*; |
| | | import cc.mrbird.febs.rabbit.producer.ChainProducer; |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.core.date.DateUtil; |
| | | import cn.hutool.core.util.ObjectUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * @author |
| | |
| | | private final ChainProducer chainProducer; |
| | | private final DappSystemDao dappSystemDao; |
| | | private final DbMemberNodeMapper dbMemberNodeMapper; |
| | | private final DappStorageMapper dappStorageMapper; |
| | | |
| | | @Override |
| | | public WalletInfoVo walletInfo() { |
| | |
| | | |
| | | DappMemberEntity memberInfo = dappMemberDao.selectById(member.getId()); |
| | | WalletInfoVo walletInfo = new WalletInfoVo(); |
| | | List<DappMemberEntity> direct = dappMemberDao.selectChildMemberDirectOrNot(member.getInviteId(), 1, 1); |
| | | DappWalletCoinEntity walletCoin = dappWalletCoinDao.selectByMemberId(member.getId()); |
| | | DappWalletMineEntity walletMine = dappWalletMineDao.selectByMemberId(member.getId()); |
| | | |
| | | DappMineDataEntity mineData = dappSystemDao.selectMineDataForOne(); |
| | | walletInfo.setDirectCnt(direct.size()); |
| | | // walletInfo.setInviteId(member.getActiveStatus() == 1 ? member.getInviteId() : "-"); |
| | | walletInfo.setInviteId(member.getInviteId()); |
| | | walletInfo.setBalance(walletCoin.getAvailableAmount()); |
| | | walletInfo.setHasBuy(memberInfo.getActiveStatus()); |
| | | walletInfo.setOutCnt(memberInfo.getOutCnt()); |
| | | walletInfo.setProfit(dappFundFlowDao.selectProfitAmountByMemberId(member.getId())); |
| | | walletInfo.setTfcBalance(walletMine.getAvailableAmount()); |
| | | walletInfo.setSafePool(mineData.getSafePool()); |
| | | |
| | | DataDictionaryCustom buyNodeAmountDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | DataDictionaryEnum.BUY_NODE_AMOUNT.getType(), |
| | | DataDictionaryEnum.BUY_NODE_AMOUNT.getCode() |
| | | walletInfo.setLevelName(MemberLevelEnum.DAO_0.getLevelType(member.getLevel())); |
| | | walletInfo.setNodeType(member.getNodeType()); |
| | | walletInfo.setActiveStatus(member.getActiveStatus()); |
| | | walletInfo.setUsdtBalance(member.getUsdtBalance()); |
| | | DataDictionaryCustom withdrawPercentDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | DataDictionaryEnum.WITHDRAW_PERCENT.getType(), |
| | | DataDictionaryEnum.WITHDRAW_PERCENT.getCode() |
| | | ); |
| | | BigDecimal buyNodeAmount = new BigDecimal(StrUtil.isEmpty(buyNodeAmountDic.getValue()) ? "100" : buyNodeAmountDic.getValue()); |
| | | walletInfo.setBuyNodeAmount(buyNodeAmount); |
| | | BigDecimal withdrawPercent = new BigDecimal(withdrawPercentDic.getValue()); |
| | | walletInfo.setWithdrawPercent(withdrawPercent); |
| | | |
| | | DataDictionaryCustom buyNodeCodeCntDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | DataDictionaryEnum.BUY_NODE_CNT.getType(), |
| | | DataDictionaryEnum.BUY_NODE_CNT.getCode() |
| | | ); |
| | | BigDecimal buyNodeCodeCnt = new BigDecimal(StrUtil.isEmpty(buyNodeCodeCntDic.getValue()) ? "3" : buyNodeCodeCntDic.getValue()); |
| | | walletInfo.setBuyNodeCnt(buyNodeCodeCnt); |
| | | walletInfo.setBuyNode(ObjectUtil.isEmpty(memberInfo.getBuyNode()) ? 0 : memberInfo.getBuyNode()); |
| | | QueryWrapper<DappStorage> objectQueryWrapper = new QueryWrapper<>(); |
| | | objectQueryWrapper.eq("member_id",member.getId()); |
| | | objectQueryWrapper.eq("state",1); |
| | | List<DappStorage> dappStorages = dappStorageMapper.selectList(objectQueryWrapper); |
| | | BigDecimal storageAva = BigDecimal.ZERO; |
| | | if(CollUtil.isNotEmpty(dappStorages)){ |
| | | storageAva = dappStorages.stream().map(DappStorage::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | } |
| | | walletInfo.setStorageAva(storageAva); |
| | | |
| | | BigDecimal bigDecimal = dappFundFlowDao.selectSumAmountByMemberIdAndType(member.getId(), 14); |
| | | walletInfo.setBuyNodePerk(bigDecimal); |
| | | BigDecimal staticPerk = dappFundFlowDao.selectSumAmountByMemberIdAndType(member.getId(), MoneyFlowEnum.STATIC_PERK.getValue()); |
| | | walletInfo.setStaticPerk(staticPerk); |
| | | |
| | | BigDecimal runPerk = dappFundFlowDao.selectSumRunPerkByMemberId(member.getId()); |
| | | walletInfo.setRunPerk(runPerk); |
| | | |
| | | |
| | | List<DappStorage> allAddressNums = dappStorageMapper.selectListGroupByMemberId(); |
| | | walletInfo.setAddressNum(CollUtil.isEmpty(allAddressNums) ? 0 : allAddressNums.size()); |
| | | |
| | | DappStorage dappStorage = dappStorageMapper.selectOneByCreateTimeDesc(0, 1); |
| | | walletInfo.setBuChangDate(ObjectUtil.isEmpty(dappStorage) ? |
| | | DateUtil.offsetDay(new Date(), 1) : DateUtil.offsetDay(dappStorage.getCreateTime(), 1)); |
| | | walletInfo.setBuchangChi(dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | DataDictionaryEnum.BUCAHNG_CHI.getType(), |
| | | DataDictionaryEnum.BUCAHNG_CHI.getCode() |
| | | ).getValue()); |
| | | |
| | | walletInfo.setJilichi(dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | DataDictionaryEnum.JILI_CHI.getType(), |
| | | DataDictionaryEnum.JILI_CHI.getCode() |
| | | ).getValue()); |
| | | |
| | | return walletInfo; |
| | | } |
| | | |
| | |
| | | dappFundFlowEntity.setType(recordInPageDto.getType()); |
| | | } |
| | | dappFundFlowEntity.setMemberId(member.getId()); |
| | | // dappFundFlowEntity.setStatus(2); |
| | | |
| | | IPage<DappFundFlowEntity> records = dappFundFlowDao.selectInPage(page, dappFundFlowEntity); |
| | | return records.getRecords(); |
| | | } |
| | |
| | | |
| | | @Override |
| | | public BigDecimal calPrice(PriceDto priceDto) { |
| | | // String priceStr = redisUtils.getString(AppContants.REDIS_KEY_TFC_NEW_PRICE); |
| | | DataDictionaryCustom symbolPrice = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.SYMBOL_PRICE.getType(), DataDictionaryEnum.SYMBOL_PRICE.getCode()); |
| | | DataDictionaryCustom serviceFeeDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.WITHDRAW_SERVICE_FEE.getType(), DataDictionaryEnum.WITHDRAW_SERVICE_FEE.getCode()); |
| | | |
| | | BigDecimal amount = priceDto.getAmount(); |
| | | if (priceDto.getAmount() == null) { |
| | | amount = BigDecimal.ZERO; |
| | | DappMemberEntity member = LoginUserUtil.getAppUser(); |
| | | //手续费率 |
| | | DataDictionaryCustom feePercentDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | DataDictionaryEnum.CHARGE_FEE_PERCENT.getType(), |
| | | DataDictionaryEnum.CHARGE_FEE_PERCENT.getCode()); |
| | | BigDecimal feePercent = new BigDecimal(feePercentDic.getValue()).multiply(new BigDecimal("0.01")); |
| | | //提现金额 |
| | | BigDecimal withdrawCnt = BigDecimal.ZERO; |
| | | if (ObjectUtil.isEmpty(priceDto.getWithdrawCnt())) { |
| | | withdrawCnt = BigDecimal.ZERO; |
| | | }else{ |
| | | withdrawCnt = priceDto.getWithdrawCnt(); |
| | | } |
| | | return amount.multiply(new BigDecimal(serviceFeeDic.getValue()).divide(BigDecimal.valueOf(100), 8, RoundingMode.HALF_DOWN)).divide(new BigDecimal(symbolPrice.getValue()), 2, RoundingMode.HALF_UP); |
| | | if(BigDecimal.ZERO.compareTo(withdrawCnt) >= 0){ |
| | | throw new FebsException("请输入正确的金额"); |
| | | } |
| | | DappWalletCoinEntity walletCoin = dappWalletCoinDao.selectByMemberId(member.getId()); |
| | | if (priceDto.getWithdrawCnt().compareTo(walletCoin.getAvailableAmount()) > 0) { |
| | | throw new FebsException("可提现不足"); |
| | | } |
| | | BigDecimal feeUsdt = withdrawCnt.multiply(feePercent).setScale(2, BigDecimal.ROUND_DOWN); |
| | | |
| | | return feeUsdt; |
| | | |
| | | // return feeUsdt.divide(priceDto.getAmount(), 2, BigDecimal.ROUND_DOWN); |
| | | } |
| | | |
| | | @Override |
| | |
| | | public void withdraw(WithdrawDto withdrawDto) { |
| | | DappMemberEntity member = LoginUserUtil.getAppUser(); |
| | | |
| | | DappMemberEntity memberEntity = dappMemberDao.selectById(member.getId()); |
| | | BigDecimal usdtBalance = memberEntity.getUsdtBalance(); |
| | | if(BigDecimal.ZERO.compareTo(usdtBalance) >= 0){ |
| | | throw new FebsException("额度不足"); |
| | | } |
| | | if(withdrawDto.getAmount().compareTo(usdtBalance) > 0){ |
| | | throw new FebsException("额度不足"); |
| | | } |
| | | |
| | | List<MemberCoinWithdrawEntity> memberCoinWithdrawEntities = memberCoinWithdrawDao.selectListByDate(member.getId(),new Date()); |
| | | if(CollUtil.isNotEmpty(memberCoinWithdrawEntities)){ |
| | | throw new FebsException("今日已提现"); |
| | | } |
| | | |
| | | DappWalletCoinEntity walletCoin = dappWalletCoinDao.selectByMemberId(member.getId()); |
| | | if (walletCoin.getAvailableAmount().compareTo(withdrawDto.getAmount()) < 0) { |
| | | throw new FebsException("Balance Not Enough"); |
| | | } |
| | | DataDictionaryCustom withdrawPercentDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | DataDictionaryEnum.WITHDRAW_PERCENT.getType(), |
| | | DataDictionaryEnum.WITHDRAW_PERCENT.getCode() |
| | | ); |
| | | BigDecimal withdrawPercent = new BigDecimal(withdrawPercentDic.getValue()); |
| | | |
| | | DappWalletMineEntity walletMine = dappWalletMineDao.selectByMemberId(member.getId()); |
| | | if (walletMine.getAvailableAmount().compareTo(withdrawDto.getFee()) < 0) { |
| | | throw new FebsException("DMD Not Enough"); |
| | | } |
| | | BigDecimal feeAmount = withdrawDto.getAmount().multiply(withdrawPercent).setScale(2, BigDecimal.ROUND_DOWN); |
| | | |
| | | updateWalletCoinWithLock(withdrawDto.getAmount(), member.getId(), 2); |
| | | updateWalletMineWithLock(withdrawDto.getFee(), member.getId(), 2); |
| | | |
| | | memberEntity.setUsdtBalance(usdtBalance.subtract(withdrawDto.getAmount()).setScale(2,BigDecimal.ROUND_DOWN)); |
| | | dappMemberDao.updateById(memberEntity); |
| | | |
| | | DappFundFlowEntity feeFlow = new DappFundFlowEntity(member.getId(), withdrawDto.getFee().negate(), 7, 2, null, null); |
| | | dappFundFlowDao.insert(feeFlow); |
| | | |
| | | DappFundFlowEntity fundFlow = new DappFundFlowEntity(member.getId(), withdrawDto.getAmount().negate(), 5, 2, withdrawDto.getFee(), null); |
| | | DappFundFlowEntity fundFlow = new DappFundFlowEntity( |
| | | member.getId(), |
| | | withdrawDto.getAmount().negate(), |
| | | MoneyFlowEnum.WITHDRAW.getValue(), |
| | | 2, |
| | | feeAmount, |
| | | StrUtil.format(MoneyFlowEnum.WITHDRAW.getDescrition(),withdrawDto.getAmount(),withdrawDto.getFee())); |
| | | dappFundFlowDao.insert(fundFlow); |
| | | |
| | | MemberCoinWithdrawEntity memberCoinWithdraw = new MemberCoinWithdrawEntity(); |
| | | memberCoinWithdraw.setMemberId(member.getId()); |
| | | memberCoinWithdraw.setAddress(member.getAddress()); |
| | | memberCoinWithdraw.setAmount(withdrawDto.getAmount()); |
| | | memberCoinWithdraw.setFeeAmount(withdrawDto.getFee()); |
| | | memberCoinWithdraw.setFeeAmount(feeAmount); |
| | | memberCoinWithdraw.setStatus(MemberCoinWithdrawEntity.STATUS_YES); |
| | | memberCoinWithdraw.setSymbol("USDT"); |
| | | memberCoinWithdraw.setSymbol("COIN"); |
| | | memberCoinWithdraw.setFlowId(fundFlow.getId()); |
| | | memberCoinWithdrawDao.insert(memberCoinWithdraw); |
| | | |
| | | String hash = ChainService.getInstance(ChainEnum.BSC_USDT.name()).transfer(member.getAddress(), withdrawDto.getAmount()); |
| | | fundFlow.setToHash(hash); |
| | | dappFundFlowDao.updateById(fundFlow); |
| | | ArrayList<BatchTransferDto> objects = new ArrayList<>(); |
| | | BigDecimal bigDecimal = withdrawDto.getAmount().subtract(feeAmount).setScale(2, BigDecimal.ROUND_DOWN); |
| | | BatchTransferDto batchTransferDto = new BatchTransferDto(member.getAddress(),bigDecimal); |
| | | objects.add(batchTransferDto); |
| | | |
| | | chainProducer.sendFeeDistributeMsg(fundFlow.getId()); |
| | | // Map<String, Object> map = new HashMap<>(); |
| | | // map.put("fee", withdrawDto.getFee()); |
| | | // map.put("address", ChainEnum.BSC_TFC_FEE.getAddress()); |
| | | // map.put("flow", feeFlow.getId()); |
| | | // chainProducer.sendTfcFee(JSONObject.toJSONString(map)); |
| | | BatchTransferDto batchTransferDtoFee = new BatchTransferDto("0x3caf594503573341ae7a83fc6daed9bd5276b6bd",feeAmount); |
| | | objects.add(batchTransferDtoFee); |
| | | ChainService.getInstance(ChainEnum.BSC_USDT.name()).transferList(objects); |
| | | } |
| | | |
| | | @Override |
| | |
| | | throw new FebsException("功能升级中"); |
| | | } |
| | | |
| | | member = dappMemberDao.selectById(member.getId()); |
| | | // int buyNode = ObjectUtil.isEmpty(member.getBuyNode()) ? 0 : 1; |
| | | int buyNode = member.getBuyNode(); |
| | | DataDictionaryCustom buyNodeCodeCntDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | DataDictionaryEnum.BUY_NODE_CNT.getType(), |
| | | DataDictionaryEnum.BUY_NODE_CNT.getCode() |
| | | ); |
| | | if (buyNode >= Integer.parseInt(buyNodeCodeCntDic.getValue())) { |
| | | throw new FebsException("Do not repeat purchase"); |
| | | BigDecimal amount = transferDto.getAmount(); |
| | | if(BigDecimal.ZERO.compareTo(amount) >= 0){ |
| | | throw new FebsException("请输入正确的存储数量"); |
| | | } |
| | | /** |
| | | * 检查一个BigDecimal是否能被500整除 |
| | | */ |
| | | BigDecimal bigDecimal = new BigDecimal("500"); |
| | | BigDecimal remainder = amount.remainder(bigDecimal); |
| | | if(remainder.compareTo(BigDecimal.ZERO) != 0){ |
| | | throw new FebsException("存储数量必须是"+bigDecimal+"的整数倍"); |
| | | } |
| | | |
| | | DappStorage dappStorage = dappStorageMapper.selectAmountByAmountDesc(member.getId(),0, 1); |
| | | if(ObjectUtil.isNotEmpty(dappStorage)){ |
| | | if(amount.compareTo(dappStorage.getAmount()) < 0){ |
| | | throw new FebsException("存储数量必须大于:"+dappStorage.getAmount()); |
| | | } |
| | | } |
| | | |
| | | if (ObjectUtil.isEmpty(transferDto.getId())) { |
| | | |
| | | DappFundFlowEntity fundFlow = new DappFundFlowEntity( |
| | | member.getId(), |
| | | transferDto.getAmount().negate(), |
| | | 13, |
| | | transferDto.getAmount().abs(), |
| | | MoneyFlowEnum.CUN_CHU.getValue(), |
| | | 1, |
| | | BigDecimal.ZERO, |
| | | transferDto.getTxHash()); |
| | | StrUtil.format(MoneyFlowEnum.CUN_CHU.getDescrition(),amount)); |
| | | dappFundFlowDao.insert(fundFlow); |
| | | return fundFlow.getId(); |
| | | } else { |
| | |
| | | if ("success".equals(transferDto.getFlag())) { |
| | | flow.setFromHash(transferDto.getTxHash()); |
| | | dappFundFlowDao.updateById(flow); |
| | | |
| | | } else { |
| | | if (flow.getStatus() == 1) { |
| | | dappFundFlowDao.deleteById(transferDto.getId()); |
| | |
| | | } |
| | | |
| | | if (ObjectUtil.isEmpty(buyStarDto.getId())) {//第一次 |
| | | List<DbMemberNode> dbMemberNodesDone = dbMemberNodeMapper.selectListByDate(new Date()); |
| | | if(CollUtil.isNotEmpty(dbMemberNodesDone)){ |
| | | DataDictionaryCustom buyNodeNumDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | DataDictionaryEnum.BUY_NODE_NUM.getType(), |
| | | DataDictionaryEnum.BUY_NODE_NUM.getCode() |
| | | ); |
| | | int buyNodeNum = Integer.parseInt(buyNodeNumDic.getValue()); |
| | | if(buyNodeNum < dbMemberNodesDone.size()){ |
| | | throw new FebsException("今日已满,请明日再来"); |
| | | } |
| | | }; |
| | | |
| | | DappFundFlowEntity fundFlow = new DappFundFlowEntity( |
| | | member.getId(), |
| | | buyStarDto.getAmount().negate(), |
| | |
| | | return buildTeamMatrix(dbMemberNode); |
| | | } |
| | | |
| | | @Override |
| | | public Long chargeFee(ChargeFeeDto chargeFeeDto) { |
| | | DappMemberEntity member = LoginUserUtil.getAppUser(); |
| | | |
| | | String upgrade = redisUtils.getString("APP_UPGRADE"); |
| | | if ("upgrade".equals(upgrade)) { |
| | | throw new FebsException("功能升级中"); |
| | | } |
| | | if (ObjectUtil.isEmpty(chargeFeeDto.getId())) {//第一次 |
| | | DappFundFlowEntity fundFlow = new DappFundFlowEntity( |
| | | member.getId(), |
| | | chargeFeeDto.getAmount().negate(), |
| | | 19, |
| | | 1, |
| | | BigDecimal.ZERO, |
| | | chargeFeeDto.getTxHash()); |
| | | dappFundFlowDao.insert(fundFlow); |
| | | return fundFlow.getId(); |
| | | } else {//第二次 |
| | | DappFundFlowEntity flow = dappFundFlowDao.selectById(chargeFeeDto.getId()); |
| | | if(ObjectUtil.isEmpty(flow)){ |
| | | return null; |
| | | } |
| | | if ("success".equals(chargeFeeDto.getFlag())) { |
| | | flow.setFromHash(chargeFeeDto.getTxHash()); |
| | | dappFundFlowDao.updateById(flow); |
| | | } else { |
| | | if (flow.getStatus() == 1) { |
| | | dappFundFlowDao.deleteById(chargeFeeDto.getId()); |
| | | } |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | @Override |
| | | public FebsResponse agreeWithdraw(Long id) { |
| | | QueryWrapper<MemberCoinWithdrawEntity> objectQueryWrapper = new QueryWrapper<>(); |
| | | objectQueryWrapper.eq("flow_id",id); |
| | | MemberCoinWithdrawEntity memberCoinWithdrawEntity = memberCoinWithdrawDao.selectOne(objectQueryWrapper); |
| | | if(ObjectUtil.isEmpty(memberCoinWithdrawEntity)){ |
| | | throw new FebsException("刷新页面重试"); |
| | | } |
| | | |
| | | if (MemberCoinWithdrawEntity.STATUS_DOING != memberCoinWithdrawEntity.getStatus()) { |
| | | throw new FebsException("非可审核状态"); |
| | | } |
| | | memberCoinWithdrawEntity.setStatus(MemberCoinWithdrawEntity.STATUS_YES); |
| | | memberCoinWithdrawDao.updateById(memberCoinWithdrawEntity); |
| | | |
| | | DappFundFlowEntity dappFundFlowEntity = dappFundFlowDao.selectById(memberCoinWithdrawEntity.getFlowId()); |
| | | dappFundFlowEntity.setStatus(DappFundFlowEntity.WITHDRAW_STATUS_AGREE); |
| | | dappFundFlowDao.updateById(dappFundFlowEntity); |
| | | |
| | | DappFundFlowEntity feeFlow = new DappFundFlowEntity(dappFundFlowEntity.getMemberId(), memberCoinWithdrawEntity.getFeeAmount().negate(), 20, 1, null, null); |
| | | dappFundFlowDao.insert(feeFlow); |
| | | |
| | | return new FebsResponse().success(); |
| | | } |
| | | |
| | | @Override |
| | | public FebsResponse disagreeWithdraw(Long id) { |
| | | |
| | | QueryWrapper<MemberCoinWithdrawEntity> objectQueryWrapper = new QueryWrapper<>(); |
| | | objectQueryWrapper.eq("flow_id",id); |
| | | MemberCoinWithdrawEntity memberCoinWithdrawEntity = memberCoinWithdrawDao.selectOne(objectQueryWrapper); |
| | | if(ObjectUtil.isEmpty(memberCoinWithdrawEntity)){ |
| | | throw new FebsException("刷新页面重试"); |
| | | } |
| | | |
| | | if (MemberCoinWithdrawEntity.STATUS_DOING != memberCoinWithdrawEntity.getStatus()) { |
| | | throw new FebsException("非可审核状态"); |
| | | } |
| | | |
| | | DappFundFlowEntity dappFundFlowEntity = dappFundFlowDao.selectById(memberCoinWithdrawEntity.getFlowId()); |
| | | if (dappFundFlowEntity == null) { |
| | | throw new FebsException("审核失败,联系管理员"); |
| | | } |
| | | memberCoinWithdrawEntity.setStatus(MemberCoinWithdrawEntity.STATUS_NO); |
| | | memberCoinWithdrawDao.updateById(memberCoinWithdrawEntity); |
| | | |
| | | dappFundFlowEntity.setStatus(DappFundFlowEntity.WITHDRAW_STATUS_DISAGREE); |
| | | dappFundFlowDao.updateById(dappFundFlowEntity); |
| | | |
| | | this.updateWalletCoinWithLock(memberCoinWithdrawEntity.getAmount(), memberCoinWithdrawEntity.getMemberId(), 1); |
| | | |
| | | DappFundFlowEntity feeFlow = new DappFundFlowEntity(memberCoinWithdrawEntity.getMemberId(), memberCoinWithdrawEntity.getAmount(), 22, 2, null, null); |
| | | dappFundFlowDao.insert(feeFlow); |
| | | return new FebsResponse().success(); |
| | | } |
| | | |
| | | @Override |
| | | public ApiIndexInfoVo indexInfo() { |
| | | ApiIndexInfoVo apiIndexInfoVo = new ApiIndexInfoVo(); |
| | | apiIndexInfoVo.setTuanduiChi(dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | DataDictionaryEnum.TUAN_DUI_CHI.getType(), |
| | | DataDictionaryEnum.TUAN_DUI_CHI.getCode() |
| | | ).getValue()); |
| | | apiIndexInfoVo.setJilichi(dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | DataDictionaryEnum.JILI_CHI.getType(), |
| | | DataDictionaryEnum.JILI_CHI.getCode() |
| | | ).getValue()); |
| | | apiIndexInfoVo.setBuchangChi(dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | DataDictionaryEnum.BUCAHNG_CHI.getType(), |
| | | DataDictionaryEnum.BUCAHNG_CHI.getCode() |
| | | ).getValue()); |
| | | apiIndexInfoVo.setJiedianChi(dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | DataDictionaryEnum.JIE_DIAN_CHI.getType(), |
| | | DataDictionaryEnum.JIE_DIAN_CHI.getCode() |
| | | ).getValue()); |
| | | apiIndexInfoVo.setJijinghuiChi(dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | DataDictionaryEnum.JI_JING_HUI_CHI.getType(), |
| | | DataDictionaryEnum.JI_JING_HUI_CHI.getCode() |
| | | ).getValue()); |
| | | apiIndexInfoVo.setJishuChi(dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | DataDictionaryEnum.JI_SHU_CHI.getType(), |
| | | DataDictionaryEnum.JI_SHU_CHI.getCode() |
| | | ).getValue()); |
| | | return apiIndexInfoVo; |
| | | } |
| | | |
| | | @Override |
| | | public List<ApiStorageInfoVo> storageIndex() { |
| | | List<ApiStorageInfoVo> apiStorageInfoVos = new ArrayList<>(); |
| | | List<DappStorage> dappStorages = dappStorageMapper.selectByAmountDesc(DateUtil.offsetHour(new Date(), -1), 0, 10); |
| | | if(CollUtil.isNotEmpty(dappStorages)){ |
| | | for(DappStorage dappStorage : dappStorages){ |
| | | ApiStorageInfoVo apiStorageInfoVo = new ApiStorageInfoVo(); |
| | | apiStorageInfoVo.setAddress(dappMemberDao.selectById(dappStorage.getMemberId()).getAddress()); |
| | | apiStorageInfoVo.setAmount(dappStorage.getAmount()); |
| | | |
| | | apiStorageInfoVos.add(apiStorageInfoVo); |
| | | } |
| | | } |
| | | |
| | | return apiStorageInfoVos; |
| | | } |
| | | |
| | | @Override |
| | | public List<ApiStorageInfoVo> directIndex() { |
| | | List<ApiStorageInfoVo> apiStorageInfoVos = new ArrayList<>(); |
| | | /** |
| | | * 存放直推业绩<上级的memberId,直推总业绩> |
| | | */ |
| | | HashMap<Long, BigDecimal> map = new HashMap<>(); |
| | | |
| | | List<DappStorage> dappStorages = dappStorageMapper.selectListByDate(new Date()); |
| | | if(CollUtil.isNotEmpty(dappStorages)){ |
| | | for(DappStorage dappStorage : dappStorages){ |
| | | DappMemberEntity member = dappMemberDao.selectById(dappStorage.getMemberId()); |
| | | if(StrUtil.isEmpty(member.getRefererId())){ |
| | | continue; |
| | | } |
| | | DappMemberEntity memberRef = dappMemberDao.selectMemberInfoByInviteId(member.getRefererId()); |
| | | if(ObjectUtil.isEmpty(memberRef)){ |
| | | continue; |
| | | } |
| | | Long id = memberRef.getId(); |
| | | if(map.containsKey(id)){ |
| | | BigDecimal bigDecimal = map.get(id); |
| | | BigDecimal add = bigDecimal.add(dappStorage.getAmount()); |
| | | map.put(id,add); |
| | | }else{ |
| | | map.put(id,dappStorage.getAmount()); |
| | | } |
| | | } |
| | | } |
| | | /** |
| | | * 获取这个map的直推总业绩前十,分发奖励 |
| | | */ |
| | | if(!map.isEmpty()){ |
| | | // 使用Stream API按照BigDecimal从大到小排序 |
| | | List<Map.Entry<Long, BigDecimal>> topTenEntries = map.entrySet().stream() |
| | | .sorted(Map.Entry.comparingByValue(Comparator.reverseOrder())) |
| | | .limit(10) |
| | | .collect(Collectors.toList()); |
| | | for (Map.Entry<Long, BigDecimal> entry : topTenEntries) { |
| | | |
| | | Long memberId = entry.getKey(); |
| | | BigDecimal directAchieve = entry.getValue(); |
| | | ApiStorageInfoVo apiStorageInfoVo = new ApiStorageInfoVo(); |
| | | apiStorageInfoVo.setAddress(dappMemberDao.selectById(memberId).getAddress()); |
| | | apiStorageInfoVo.setAmount(directAchieve); |
| | | |
| | | apiStorageInfoVos.add(apiStorageInfoVo); |
| | | } |
| | | } |
| | | return apiStorageInfoVos; |
| | | } |
| | | |
| | | public MemberNodeVo buildTeamMatrix(DbMemberNode dbMemberNode) { |
| | | Long id = dbMemberNode.getId(); |
| | | |
| | |
| | | QueryWrapper<DbMemberNode> childQuery = new QueryWrapper<>(); |
| | | childQuery.eq("parent_node",id); |
| | | childQuery.eq("type", dbMemberNode.getType()); |
| | | childQuery.eq("work_state", DbMemberNode.STATE_ONE); |
| | | // childQuery.eq("work_state", DbMemberNode.STATE_ONE); |
| | | List<DbMemberNode> childrenNode = dbMemberNodeMapper.selectList(childQuery); |
| | | if(CollUtil.isEmpty(childrenNode)){ |
| | | return memberNodeVo; |