| | |
| | | package cc.mrbird.febs.dapp.service.impl; |
| | | |
| | | import cc.mrbird.febs.common.configure.i18n.MessageSourceUtils; |
| | | import cc.mrbird.febs.common.contants.AppContants; |
| | | import cc.mrbird.febs.common.entity.QueryRequest; |
| | | import cc.mrbird.febs.common.exception.FebsException; |
| | | import cc.mrbird.febs.common.utils.FebsUtil; |
| | | import cc.mrbird.febs.common.utils.LoginUserUtil; |
| | | import cc.mrbird.febs.common.utils.RedisUtils; |
| | | import cc.mrbird.febs.dapp.chain.ChainEnum; |
| | | import cc.mrbird.febs.dapp.chain.ChainService; |
| | | import cc.mrbird.febs.dapp.chain.ContractChainService; |
| | | import cc.mrbird.febs.dapp.dto.*; |
| | | import cc.mrbird.febs.dapp.entity.*; |
| | | import cc.mrbird.febs.dapp.enumerate.DataDictionaryEnum; |
| | | import cc.mrbird.febs.dapp.mapper.*; |
| | | import cc.mrbird.febs.dapp.service.DappWalletService; |
| | | import cc.mrbird.febs.dapp.utils.BoxUtil; |
| | | import cc.mrbird.febs.dapp.vo.ActiveNftListVo; |
| | | import cc.mrbird.febs.dapp.vo.WalletInfoVo; |
| | | import cc.mrbird.febs.rabbit.producer.ChainProducer; |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.core.date.DateField; |
| | | import cn.hutool.core.date.DateUnit; |
| | | import cn.hutool.core.date.DateUtil; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.Wrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
| | | import cn.hutool.core.util.ObjectUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import lombok.RequiredArgsConstructor; |
| | |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | import java.util.*; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author |
| | |
| | | |
| | | DappMemberEntity memberInfo = dappMemberDao.selectById(member.getId()); |
| | | WalletInfoVo walletInfo = new WalletInfoVo(); |
| | | List<DappMemberEntity> direct = dappMemberDao.selectChildMemberDirectOrNot(member.getInviteId(), 1, null); |
| | | List<DappMemberEntity> direct = dappMemberDao.selectChildMemberDirectOrNot(member.getInviteId(), 1, 1); |
| | | DappWalletCoinEntity walletCoin = dappWalletCoinDao.selectByMemberId(member.getId()); |
| | | DappWalletMineEntity walletMine = dappWalletMineDao.selectByMemberId(member.getId()); |
| | | |
| | |
| | | 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() |
| | | ); |
| | | BigDecimal buyNodeAmount = new BigDecimal(StrUtil.isEmpty(buyNodeAmountDic.getValue()) ? "100" : buyNodeAmountDic.getValue()); |
| | | walletInfo.setBuyNodeAmount(buyNodeAmount); |
| | | walletInfo.setBuyNode(ObjectUtil.isEmpty(memberInfo.getBuyNode()) ? 0 : memberInfo.getBuyNode()); |
| | | return walletInfo; |
| | | } |
| | | |
| | |
| | | if (priceDto.getAmount() == null) { |
| | | amount = BigDecimal.ZERO; |
| | | } |
| | | return amount.multiply(new BigDecimal(serviceFeeDic.getValue()).divide(BigDecimal.valueOf(100), 2, RoundingMode.HALF_DOWN)).divide(new BigDecimal(symbolPrice.getValue()), 2, RoundingMode.HALF_UP); |
| | | return amount.multiply(new BigDecimal(serviceFeeDic.getValue()).divide(BigDecimal.valueOf(100), 8, RoundingMode.HALF_DOWN)).divide(new BigDecimal(symbolPrice.getValue()), 2, RoundingMode.HALF_UP); |
| | | } |
| | | |
| | | @Override |
| | |
| | | public DappWalletCoinEntity findByMemberId(Long memberId) { |
| | | return dappWalletCoinDao.selectByMemberId(memberId); |
| | | } |
| | | |
| | | @Override |
| | | public Long buyNode(BuyNodeDto transferDto) { |
| | | DappMemberEntity member = LoginUserUtil.getAppUser(); |
| | | |
| | | String upgrade = redisUtils.getString("APP_UPGRADE"); |
| | | if ("upgrade".equals(upgrade)) { |
| | | throw new FebsException("功能升级中"); |
| | | } |
| | | |
| | | member = dappMemberDao.selectById(member.getId()); |
| | | int buyNode = ObjectUtil.isEmpty(member.getBuyNode()) ? 0 : 1; |
| | | if (1 == buyNode) { |
| | | throw new FebsException("Do not repeat purchase"); |
| | | } |
| | | |
| | | if (ObjectUtil.isEmpty(transferDto.getId())) { |
| | | DappFundFlowEntity fundFlow = new DappFundFlowEntity( |
| | | member.getId(), |
| | | transferDto.getAmount().negate(), |
| | | 13, |
| | | 1, |
| | | BigDecimal.ZERO, |
| | | transferDto.getTxHash()); |
| | | dappFundFlowDao.insert(fundFlow); |
| | | return fundFlow.getId(); |
| | | } else { |
| | | DappFundFlowEntity flow = dappFundFlowDao.selectById(transferDto.getId()); |
| | | if(ObjectUtil.isEmpty(flow)){ |
| | | return null; |
| | | } |
| | | if ("success".equals(transferDto.getFlag())) { |
| | | flow.setFromHash(transferDto.getTxHash()); |
| | | dappFundFlowDao.updateById(flow); |
| | | |
| | | } else { |
| | | if (flow.getStatus() == 1) { |
| | | dappFundFlowDao.deleteById(transferDto.getId()); |
| | | } |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | } |