| | |
| | | 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.FebsResponse; |
| | | 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.*; |
| | | 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.*; |
| | | 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 cn.hutool.core.util.ObjectUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | 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 com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import freemarker.template.utility.StringUtil; |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | import java.util.*; |
| | | |
| | | /** |
| | |
| | | private final DappAccountMoneyChangeDao dappAccountMoneyChangeDao; |
| | | private final RedisUtils redisUtils; |
| | | private final DataDictionaryCustomMapper dataDictionaryCustomMapper; |
| | | private final DappNftActivationDao dappNftActivationDao; |
| | | private final MemberCoinWithdrawDao memberCoinWithdrawDao; |
| | | |
| | | private final ChainProducer chainProducer; |
| | | private final DappSystemDao dappSystemDao; |
| | | private final DappSystemProfitDao dappSystemProfitDao; |
| | | |
| | | private final DappNodeOrderMapper dappNodeOrderMapper; |
| | | private final DappMemberNodeMapper dappMemberNodeMapper; |
| | | private final DappChargeUsdtMapper dappChargeUsdtMapper; |
| | | private final DappUsdtPerkEntityMapper dappUsdtPerkEntityMapper; |
| | | private final DappAKlineMapper dappAKlineMapper; |
| | | |
| | | @Override |
| | | public List<DappFundFlowEntity> recordInPage(RecordInPageDto recordInPageDto) { |
| | |
| | | BigDecimal feeAmount = amount.multiply(withdrawFee); |
| | | //减少余额 |
| | | this.updateWalletCoinWithLock(amount, member.getId(), 2); |
| | | |
| | | BigDecimal withdrawAmount = amount.divide(new BigDecimal(7),2,BigDecimal.ROUND_DOWN); |
| | | BigDecimal withdrawAmountFee = feeAmount.divide(new BigDecimal(7),2,BigDecimal.ROUND_DOWN); |
| | | //增加流水 |
| | | DappFundFlowEntity dappFundFlowEntity = new DappFundFlowEntity( |
| | | AccountFlowEnum.AMOUNT.getCode(), |
| | | member.getId(), |
| | | amount.negate(), |
| | | withdrawAmount.negate(), |
| | | FundFlowEnum.WITHDRAW_USDT.getCode(), |
| | | DappFundFlowEntity.WITHDRAW_STATUS_ING, |
| | | feeAmount); |
| | | withdrawAmountFee); |
| | | dappFundFlowDao.insert(dappFundFlowEntity); |
| | | //增加提现的记录 |
| | | MemberCoinWithdrawEntity memberCoinWithdraw = new MemberCoinWithdrawEntity(); |
| | | memberCoinWithdraw.setMemberId(member.getId()); |
| | | memberCoinWithdraw.setAddress(member.getAddress()); |
| | | memberCoinWithdraw.setAmount(amount.subtract(feeAmount)); |
| | | memberCoinWithdraw.setFeeAmount(feeAmount); |
| | | memberCoinWithdraw.setAmount(withdrawAmount.subtract(withdrawAmountFee)); |
| | | memberCoinWithdraw.setFeeAmount(withdrawAmountFee); |
| | | memberCoinWithdraw.setStatus(MemberCoinWithdrawEntity.STATUS_DOING); |
| | | memberCoinWithdraw.setSymbol("USDT"); |
| | | memberCoinWithdraw.setFlowId(dappFundFlowEntity.getId()); |
| | |
| | | if ("upgrade".equals(upgrade)) { |
| | | throw new FebsException("功能升级中"); |
| | | } |
| | | BigDecimal amountIn = transferAusdDto.getAmount(); |
| | | if(BigDecimal.ZERO.compareTo(amountIn) >= 0){ |
| | | throw new FebsException("请输入正确的金额"); |
| | | } |
| | | |
| | | /** |
| | | * 充值 |
| | |
| | | //生成一条进行中的入金资金流水记录 |
| | | DappFundFlowEntity fundFlow = new DappFundFlowEntity( |
| | | dappMemberEntity.getId(), |
| | | transferAusdDto.getAmount(), |
| | | transferAusdDto.getAmount().multiply(new BigDecimal(7)), |
| | | type, |
| | | 1, |
| | | transferAusdDto.getFee(), |
| | |
| | | /** |
| | | * 增加用户的余额 |
| | | */ |
| | | dappWalletCoinDao.addTotalAndaddAvailableByMemberId(member.getId(),amount); |
| | | dappWalletCoinDao.addTotalAndaddAvailableByMemberId(member.getId(),amount.multiply(new BigDecimal(7))); |
| | | |
| | | DappChargeUsdtEntity dappChargeUsdtEntity = new DappChargeUsdtEntity(); |
| | | dappChargeUsdtEntity.setMemberId(member.getId()); |
| | |
| | | dappChargeUsdtEntity.setMemberHash(transferAusdDto.getTxHash()); |
| | | dappChargeUsdtEntity.setStatus(2); |
| | | dappChargeUsdtEntity.setTotalCnt(amount); |
| | | dappChargeUsdtEntity.setRealCnt(amount); |
| | | dappChargeUsdtEntity.setRealCnt(amount.multiply(new BigDecimal(7))); |
| | | dappChargeUsdtMapper.insert(dappChargeUsdtEntity); |
| | | } else { |
| | | if (flow.getStatus() == 1) { |
| | |
| | | memberCoinWithdrawEntity.setStatus(MemberCoinWithdrawEntity.STATUS_YES); |
| | | memberCoinWithdrawEntity.setIsInside(MemberCoinWithdrawEntity.ISINSIDE_NO); |
| | | memberCoinWithdrawDao.updateById(memberCoinWithdrawEntity); |
| | | |
| | | /** |
| | | * 提现手续费10%进入资产管理池 |
| | | * USDT_ORDER_PERCENT |
| | | */ |
| | | BigDecimal withdrawFee = dappFundFlowEntity.getFee(); |
| | | if(BigDecimal.ZERO.compareTo(withdrawFee) < 0){ |
| | | BigDecimal addPoor = withdrawFee.multiply(new BigDecimal(7)); |
| | | |
| | | DataDictionaryCustom packageScorePriceDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | DataDictionaryEnum.PACKAGE_SCORE_PRICE.getType(), |
| | | DataDictionaryEnum.PACKAGE_SCORE_PRICE.getCode() |
| | | ); |
| | | DataDictionaryCustom packageTotalScoreDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | DataDictionaryEnum.PACKAGE_TOTAL_SCORE.getType(), |
| | | DataDictionaryEnum.PACKAGE_TOTAL_SCORE.getCode() |
| | | ); |
| | | BigDecimal packageTotalScore = new BigDecimal(ObjectUtil.isEmpty(packageTotalScoreDic) ? "21000" : packageTotalScoreDic.getValue()).setScale(2, BigDecimal.ROUND_DOWN); |
| | | //更新USDT底池 |
| | | DataDictionaryCustom packagePoorDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | DataDictionaryEnum.PACKAGE_POOR.getType(), |
| | | DataDictionaryEnum.PACKAGE_POOR.getCode() |
| | | ); |
| | | BigDecimal packagePoor = new BigDecimal(ObjectUtil.isEmpty(packagePoorDic) ? "0" : packagePoorDic.getValue()).setScale(2, BigDecimal.ROUND_DOWN); |
| | | BigDecimal avaPackagePoor = packagePoor.add(addPoor); |
| | | packagePoorDic.setValue(avaPackagePoor.toString()); |
| | | dataDictionaryCustomMapper.updateById(packagePoorDic); |
| | | //计算当前价格 |
| | | BigDecimal divide = avaPackagePoor.divide(packageTotalScore, 8, BigDecimal.ROUND_DOWN); |
| | | packageScorePriceDic.setValue(divide.toString()); |
| | | dataDictionaryCustomMapper.updateById(packageScorePriceDic); |
| | | |
| | | DappAKlineEntity dappAKlineEntity = new DappAKlineEntity(); |
| | | dappAKlineEntity.setOpenPrice(divide); |
| | | dappAKlineEntity.setType(1); |
| | | dappAKlineMapper.insert(dappAKlineEntity); |
| | | } |
| | | return new FebsResponse().success(); |
| | | } |
| | | |
| | |
| | | memberCoinWithdrawEntity.setIsInside(MemberCoinWithdrawEntity.ISINSIDE_NO); |
| | | memberCoinWithdrawDao.updateById(memberCoinWithdrawEntity); |
| | | //增加余额 |
| | | this.updateWalletCoinWithLock(dappFundFlowEntity.getAmount().negate(), dappMemberEntity.getId(), 1); |
| | | BigDecimal negate = dappFundFlowEntity.getAmount().negate().multiply(new BigDecimal(7)); |
| | | this.updateWalletCoinWithLock(negate, dappMemberEntity.getId(), 1); |
| | | return new FebsResponse().success(); |
| | | } |
| | | |
| | |
| | | IPage<DappAccountMoneyChangeEntity> memberMoneyFlowVos = dappAccountMoneyChangeDao.getChangeInPageInPage(page,changeInPageDto); |
| | | return new FebsResponse().success().data(memberMoneyFlowVos); |
| | | } |
| | | |
| | | @Override |
| | | public FebsResponse changeInToday() { |
| | | DappMemberEntity member = LoginUserUtil.getAppUser(); |
| | | Long memberId = member.getId(); |
| | | DappAccountMoneyChangeEntity dappAccountMoneyChangeEntity = dappAccountMoneyChangeDao.selectNewOneByMemberId(memberId); |
| | | return new FebsResponse().success().data(dappAccountMoneyChangeEntity); |
| | | } |
| | | } |