19 files modified
1 files added
| | |
| | | import java.math.BigDecimal; |
| | | |
| | | /** |
| | | * @author |
| | | * @author |
| | | * @date 2022-03-21 |
| | | **/ |
| | | @Controller("dappView") |
| | |
| | | } |
| | | |
| | | |
| | | @GetMapping(value ="priceSetting") |
| | | @GetMapping(value = "priceSetting") |
| | | @RequiresPermissions("price:setting:view") |
| | | public String priceSetting(Model model) { |
| | | BigDecimal price = (BigDecimal) redisUtils.get(AppContants.REDIS_KEY_ETH_NEW_PRICE); |
| | |
| | | } |
| | | |
| | | //费率设置 |
| | | @GetMapping(value ="systemFeeSet") |
| | | @GetMapping(value = "systemFeeSet") |
| | | @RequiresPermissions("fee:setting:view") |
| | | public String systemFeeSet(Model model) { |
| | | AdminSystemFeeVo adminSystemFeeVo = new AdminSystemFeeVo(); |
| | | DataDictionaryCustom rebateDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.REBATE_PERCENT.getType(), DataDictionaryEnum.REBATE_PERCENT.getCode()); |
| | | if(ObjectUtil.isNotEmpty(rebateDic)){ |
| | | String value = rebateDic.getValue() == null ? "0":rebateDic.getValue(); |
| | | if (ObjectUtil.isNotEmpty(rebateDic)) { |
| | | String value = rebateDic.getValue() == null ? "0" : rebateDic.getValue(); |
| | | adminSystemFeeVo.setRebatePercent(value); |
| | | } |
| | | DataDictionaryCustom memberFeeDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.MEMBER_FEE.getType(), DataDictionaryEnum.MEMBER_FEE.getCode()); |
| | | if(ObjectUtil.isNotEmpty(memberFeeDic)){ |
| | | String value = memberFeeDic.getValue() == null ? "0":memberFeeDic.getValue(); |
| | | if (ObjectUtil.isNotEmpty(memberFeeDic)) { |
| | | String value = memberFeeDic.getValue() == null ? "0" : memberFeeDic.getValue(); |
| | | adminSystemFeeVo.setMemberFee(value); |
| | | } |
| | | DataDictionaryCustom serviceFeeDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.WITHDRAW_SERVICE_FEE.getType(), DataDictionaryEnum.WITHDRAW_SERVICE_FEE.getCode()); |
| | | if(ObjectUtil.isNotEmpty(serviceFeeDic)){ |
| | | String value = serviceFeeDic.getValue() == null ? "0":serviceFeeDic.getValue(); |
| | | if (ObjectUtil.isNotEmpty(serviceFeeDic)) { |
| | | String value = serviceFeeDic.getValue() == null ? "0" : serviceFeeDic.getValue(); |
| | | adminSystemFeeVo.setServiceFee(value); |
| | | } |
| | | |
| | | DataDictionaryCustom symbolPrice = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.SYMBOL_PRICE.getType(), DataDictionaryEnum.SYMBOL_PRICE.getCode()); |
| | | if (ObjectUtil.isNotEmpty(symbolPrice)) { |
| | | String value = symbolPrice.getValue() == null ? "0" : symbolPrice.getValue(); |
| | | adminSystemFeeVo.setSymbolPrice(value); |
| | | } |
| | | model.addAttribute("systemFee", adminSystemFeeVo); |
| | | return FebsUtil.view("dapp/system-fee-set"); |
| | | } |
| | |
| | | private BigDecimal amount; |
| | | |
| | | /** |
| | | * 类型 1-买入 2-矩阵收益 3-直推收益 4-保险池 5-提现 6-手续费充值 7-手续费扣除 8-结算 9-冻结 10-冻结释放 |
| | | * 类型 1-买入 2-矩阵收益 3-直推收益 4-保险池 5-提现 6-手续费充值 7-手续费扣除 8-结算 9-冻结 10-冻结释放 11-产矿 12-手续费返利 |
| | | */ |
| | | private Integer type; |
| | | |
| | |
| | | |
| | | private String tag; |
| | | |
| | | private Long flowId; |
| | | |
| | | /** |
| | | * 后台操作用户的标识 |
| | | */ |
| | |
| | | |
| | | @Getter |
| | | public enum DataDictionaryEnum { |
| | | //每日返利的产矿百分比 |
| | | // 每日返利的产矿百分比 |
| | | REBATE_PERCENT("SYSTEM_SETTING","REBATE_PERCENT"), |
| | | //分给推荐三人的终身VIP会员手续费 |
| | | // 分给推荐三人的终身VIP会员手续费 |
| | | MEMBER_FEE("SYSTEM_SETTING","MEMBER_FEE"), |
| | | //提现手续费 |
| | | WITHDRAW_SERVICE_FEE("SYSTEM_SETTING", "WITHDRAW_SERVICE_FEE"); |
| | | // 提现手续费 |
| | | WITHDRAW_SERVICE_FEE("SYSTEM_SETTING", "WITHDRAW_SERVICE_FEE"), |
| | | // 币的价格 |
| | | SYMBOL_PRICE("SYSTEM_SETTING", "SYMBOL_PRICE"); |
| | | |
| | | private String type; |
| | | |
| | |
| | | int updateMemberActive(); |
| | | |
| | | DappMemberEntity selectNewestDirectMember(@Param("inviteId") String inviteId); |
| | | |
| | | List<DappMemberEntity> selectMemberListNeedProfit(); |
| | | } |
| | |
| | | void tfcNewPrice(String data); |
| | | |
| | | void resetMatrix(); |
| | | |
| | | void feeDistribute(String data); |
| | | } |
| | |
| | | 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.dapp.entity.DappAccountMoneyChangeEntity; |
| | | import cc.mrbird.febs.dapp.entity.DappMemberEntity; |
| | | import cc.mrbird.febs.dapp.entity.DappWalletCoinEntity; |
| | | import cc.mrbird.febs.dapp.entity.MemberCoinWithdrawEntity; |
| | | import cc.mrbird.febs.dapp.mapper.DappAccountMoneyChangeDao; |
| | | import cc.mrbird.febs.dapp.mapper.DappMemberDao; |
| | | import cc.mrbird.febs.dapp.mapper.DappWalletCoinDao; |
| | | import cc.mrbird.febs.dapp.mapper.MemberCoinWithdrawDao; |
| | | import cc.mrbird.febs.dapp.entity.*; |
| | | import cc.mrbird.febs.dapp.mapper.*; |
| | | import cc.mrbird.febs.dapp.service.AdminOperationService; |
| | | import cc.mrbird.febs.dapp.service.DappWalletService; |
| | | import cc.mrbird.febs.dapp.vo.AdminMemberCoinWithdrawVo; |
| | | import cc.mrbird.febs.rabbit.producer.ChainProducer; |
| | | import cn.hutool.core.util.ObjectUtil; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | |
| | | private final DappWalletCoinDao dappWalletCoinDao; |
| | | private final DappMemberDao dappMemberDao; |
| | | private final DappAccountMoneyChangeDao dappAccountMoneyChangeDao; |
| | | private final DappWalletService dappWalletService; |
| | | private final DappFundFlowDao dappFundFlowDao; |
| | | private final ChainProducer chainProducer; |
| | | |
| | | @Override |
| | | public IPage<AdminMemberCoinWithdrawVo> findMemberWithdrawCoinAllOneInPage(MemberCoinWithdrawEntity memberCoinWithdrawEntity, QueryRequest request) { |
| | |
| | | } |
| | | memberCoinWithdrawEntity.setStatus(MemberCoinWithdrawEntity.STATUS_YES); |
| | | memberCoinWithdrawDao.updateById(memberCoinWithdrawEntity); |
| | | //转出账户,总额减少,冻结减少 |
| | | BigDecimal amount = memberCoinWithdrawEntity.getAmount().setScale(4,BigDecimal.ROUND_DOWN); |
| | | Long memberIdOut = memberCoinWithdrawEntity.getMemberId(); |
| | | DappWalletCoinEntity dappWalletCoinEntityOut = dappWalletCoinDao.selectByMemberId(memberIdOut); |
| | | dappWalletCoinDao.delTotalAndDelFrozenById(dappWalletCoinEntityOut.getId(),amount); |
| | | |
| | | String isInside = memberCoinWithdrawEntity.getIsInside(); |
| | | String content = ""; |
| | | Integer type = 0; |
| | | if(MemberCoinWithdrawEntity.ISINSIDE_NO.equals(isInside)){ |
| | | content = "提现"; |
| | | type = 2; |
| | | }else{ |
| | | content = "转账"; |
| | | type = 4; |
| | | } |
| | | //转出账户生成一条账户资金变化记录 |
| | | DappAccountMoneyChangeEntity dappAccountMoneyChangeEntityOut = new DappAccountMoneyChangeEntity(memberIdOut, |
| | | dappWalletCoinEntityOut.getTotalAmount().setScale(4,BigDecimal.ROUND_DOWN), |
| | | amount.negate(), |
| | | dappWalletCoinEntityOut.getTotalAmount().setScale(4,BigDecimal.ROUND_DOWN).subtract(amount), |
| | | content, |
| | | type); |
| | | dappAccountMoneyChangeDao.insert(dappAccountMoneyChangeEntityOut); |
| | | DappFundFlowEntity dappFundFlowEntity = dappFundFlowDao.selectById(memberCoinWithdrawEntity.getFlowId()); |
| | | dappFundFlowEntity.setStatus(DappFundFlowEntity.WITHDRAW_STATUS_AGREE); |
| | | dappFundFlowDao.updateById(dappFundFlowEntity); |
| | | |
| | | //转入账户,总额增加,余额增加 |
| | | //转账 |
| | | // if(MemberCoinWithdrawEntity.ISINSIDE_YES.equals(isInside)){ |
| | | // String addressIn = memberCoinWithdrawEntity.getAddress(); |
| | | // DappMemberEntity dappMemberEntityIn = dappMemberDao.selectMemberInfoByInviteId(addressIn); |
| | | // if(ObjectUtil.isEmpty(dappMemberEntityIn)){ |
| | | // throw new FebsException("系统异常,联系开发人员"); |
| | | // } |
| | | // DappWalletCoinEntity dappWalletCoinEntityIn = dappWalletCoinDao.selectByMemberId(dappMemberEntityIn.getId()); |
| | | // Integer countIn = dappWalletCoinDao.addTotalAndaddAvailableById(dappWalletCoinEntityIn.getId(), memberCoinWithdrawEntity.getAmount()); |
| | | // if(1 != countIn){ |
| | | // throw new FebsException("系统异常,联系开发人员"); |
| | | // } |
| | | // //生成流水记录 |
| | | // DappAccountMoneyChangeEntity dappAccountMoneyChangeEntityIn = new DappAccountMoneyChangeEntity(dappMemberEntityIn.getId(), |
| | | // dappWalletCoinEntityIn.getTotalAmount().setScale(4,BigDecimal.ROUND_DOWN), |
| | | // amount, |
| | | // dappWalletCoinEntityIn.getTotalAmount().setScale(4,BigDecimal.ROUND_DOWN).add(amount), |
| | | // "转账", |
| | | // 4); |
| | | // dappAccountMoneyChangeDao.insert(dappAccountMoneyChangeEntityIn); |
| | | // } |
| | | chainProducer.sendFeeDistributeMsg(dappFundFlowEntity.getId()); |
| | | return new FebsResponse().success(); |
| | | } |
| | | |
| | |
| | | if(ObjectUtil.isEmpty(memberCoinWithdrawEntity)){ |
| | | throw new FebsException("刷新页面重试"); |
| | | } |
| | | |
| | | DappFundFlowEntity dappFundFlowEntity = dappFundFlowDao.selectById(memberCoinWithdrawEntity.getFlowId()); |
| | | if (dappFundFlowEntity == null) { |
| | | throw new FebsException("审核失败,联系管理员"); |
| | | } |
| | | memberCoinWithdrawEntity.setStatus(MemberCoinWithdrawEntity.STATUS_NO); |
| | | memberCoinWithdrawDao.updateById(memberCoinWithdrawEntity); |
| | | |
| | | DappWalletCoinEntity dappWalletCoinEntity = dappWalletCoinDao.selectByMemberId(memberCoinWithdrawEntity.getMemberId()); |
| | | Integer count = dappWalletCoinDao.addFrozenAndDelAvailableById(dappWalletCoinEntity.getId(),memberCoinWithdrawEntity.getAmount()); |
| | | if(1 != count){ |
| | | throw new FebsException("系统异常,联系开发人员"); |
| | | } |
| | | dappFundFlowEntity.setStatus(DappFundFlowEntity.WITHDRAW_STATUS_DISAGREE); |
| | | dappFundFlowDao.updateById(dappFundFlowEntity); |
| | | |
| | | dappWalletService.updateWalletCoinWithLock(memberCoinWithdrawEntity.getAmount(), memberCoinWithdrawEntity.getMemberId(), 1); |
| | | dappWalletService.updateWalletMineWithLock(memberCoinWithdrawEntity.getFeeAmount(), memberCoinWithdrawEntity.getMemberId(), 1); |
| | | |
| | | DappFundFlowEntity feeFlow = new DappFundFlowEntity(memberCoinWithdrawEntity.getMemberId(), memberCoinWithdrawEntity.getFeeAmount(), 7, 2, null, null); |
| | | dappFundFlowDao.insert(feeFlow); |
| | | |
| | | DappFundFlowEntity fundFlow = new DappFundFlowEntity(memberCoinWithdrawEntity.getMemberId(), memberCoinWithdrawEntity.getAmount(), 5, 1, memberCoinWithdrawEntity.getFeeAmount(), null); |
| | | dappFundFlowDao.insert(fundFlow); |
| | | return new FebsResponse().success(); |
| | | } |
| | | } |
| | |
| | | DataDictionaryCustom memberFeeDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.MEMBER_FEE.getType(), DataDictionaryEnum.MEMBER_FEE.getCode()); |
| | | memberFeeDic.setValue(memberFee); |
| | | dataDictionaryCustomMapper.updateById(memberFeeDic); |
| | | |
| | | String symbolPrice = adminSystemFeeVo.getSymbolPrice(); |
| | | DataDictionaryCustom symbolPriceDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.SYMBOL_PRICE.getType(), DataDictionaryEnum.SYMBOL_PRICE.getCode()); |
| | | symbolPriceDic.setValue(symbolPrice); |
| | | dataDictionaryCustomMapper.updateById(symbolPriceDic); |
| | | } |
| | | |
| | | public TeamListVo buildTeamMatrix(DappAchieveMemberTreeEntity node) { |
| | |
| | | import cc.mrbird.febs.dapp.chain.ChainService; |
| | | import cc.mrbird.febs.dapp.dto.SystemDto; |
| | | 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.DappSystemService; |
| | | import cc.mrbird.febs.dapp.service.DappWalletService; |
| | |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.core.date.DateUnit; |
| | | import cn.hutool.core.date.DateUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | private final DappAchieveTreeDao dappAchieveTreeDao; |
| | | private final DappAchieveMemberTreeDao dappAchieveMemberTreeDao; |
| | | private final DappWalletService dappWalletService; |
| | | private final DataDictionaryCustomMapper dataDictionaryCustomMapper; |
| | | |
| | | |
| | | @Override |
| | |
| | | amount = TreeConstants.FULL_PROFIT_AMOUNT; |
| | | } |
| | | |
| | | dappWalletService.releaseFrozenAmountWithLock(memberId); |
| | | |
| | | member.setOutCnt(member.getOutCnt() + 1); |
| | | dappMemberDao.updateById(member); |
| | | |
| | |
| | | dappAchieveMemberTreeDao.emptyTable(); |
| | | dappMemberDao.updateMemberActive(); |
| | | } |
| | | |
| | | @Override |
| | | public void feeDistribute(String data) { |
| | | if (StrUtil.isBlank(data)) { |
| | | return; |
| | | } |
| | | |
| | | Long flowId = Long.parseLong(data); |
| | | DappFundFlowEntity fundFlow = dappFundFlowDao.selectById(flowId); |
| | | if (fundFlow == null) { |
| | | return; |
| | | } |
| | | |
| | | DataDictionaryCustom memberFeeDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.MEMBER_FEE.getType(), DataDictionaryEnum.MEMBER_FEE.getCode()); |
| | | if (memberFeeDic == null) { |
| | | log.info("未设置手续费返利比例"); |
| | | return; |
| | | } |
| | | List<DappMemberEntity> memberList = dappMemberDao.selectMemberListNeedProfit(); |
| | | if (CollUtil.isEmpty(memberList)) { |
| | | return; |
| | | } |
| | | |
| | | BigDecimal feeReturnRatio = new BigDecimal(memberFeeDic.getValue()); |
| | | int size = memberList.size(); |
| | | BigDecimal totalProfit = fundFlow.getFee().multiply(feeReturnRatio.divide(BigDecimal.valueOf(100), 2, RoundingMode.HALF_DOWN)); |
| | | BigDecimal perProfit = totalProfit.divide(BigDecimal.valueOf(size), 2, RoundingMode.HALF_DOWN); |
| | | |
| | | memberList.forEach(item -> { |
| | | dappWalletService.updateWalletMineWithLock(perProfit, item.getId(), 1); |
| | | |
| | | DappFundFlowEntity profitFlow = new DappFundFlowEntity(item.getId(), perProfit, 12, 2, null, null); |
| | | dappFundFlowDao.insert(profitFlow); |
| | | }); |
| | | } |
| | | } |
| | |
| | | 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; |
| | |
| | | private final RedisUtils redisUtils; |
| | | private final DataDictionaryCustomMapper dataDictionaryCustomMapper; |
| | | private final DappNftActivationDao dappNftActivationDao; |
| | | private final MemberCoinWithdrawDao memberCoinWithdrawDao; |
| | | |
| | | private final ChainProducer chainProducer; |
| | | private final DappSystemDao dappSystemDao; |
| | |
| | | |
| | | @Override |
| | | public BigDecimal calPrice(PriceDto priceDto) { |
| | | String priceStr = redisUtils.getString(AppContants.REDIS_KEY_TFC_NEW_PRICE); |
| | | // 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; |
| | | } |
| | | return amount.multiply(new BigDecimal("0.1")).divide(new BigDecimal(priceStr), 2, RoundingMode.HALF_UP); |
| | | return amount.multiply(new BigDecimal(serviceFeeDic.getValue()).divide(BigDecimal.valueOf(100), 2, RoundingMode.HALF_DOWN)).divide(new BigDecimal(symbolPrice.getValue()), 2, RoundingMode.HALF_UP); |
| | | } |
| | | |
| | | @Override |
| | |
| | | |
| | | DappWalletMineEntity walletMine = dappWalletMineDao.selectByMemberId(member.getId()); |
| | | if (walletMine.getAvailableAmount().compareTo(withdrawDto.getFee()) < 0) { |
| | | throw new FebsException("TFC Not Enough"); |
| | | throw new FebsException("DMD Not Enough"); |
| | | } |
| | | |
| | | updateWalletCoinWithLock(withdrawDto.getAmount(), member.getId(), 2); |
| | | updateWalletMineWithLock(withdrawDto.getFee(), member.getId(), 2); |
| | | |
| | | |
| | | 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, 1, withdrawDto.getFee(), null); |
| | | dappFundFlowDao.insert(fundFlow); |
| | | |
| | | MemberCoinWithdrawEntity memberCoinWithdraw = new MemberCoinWithdrawEntity(); |
| | | memberCoinWithdraw.setMemberId(member.getId()); |
| | | memberCoinWithdraw.setAddress(member.getAddress()); |
| | | memberCoinWithdraw.setAmount(withdrawDto.getAmount()); |
| | | memberCoinWithdraw.setFeeAmount(withdrawDto.getFee()); |
| | | memberCoinWithdraw.setStatus(MemberCoinWithdrawEntity.STATUS_DOING); |
| | | memberCoinWithdraw.setSymbol("USDT"); |
| | | memberCoinWithdraw.setFlowId(fundFlow.getId()); |
| | | memberCoinWithdrawDao.insert(memberCoinWithdraw); |
| | | |
| | | // String hash = ChainService.getInstance(ChainEnum.BSC_USDT.name()).transfer(member.getAddress(), withdrawDto.getAmount()); |
| | | // fundFlow.setToHash(hash); |
| | |
| | | walletMine.setAvailableAmount(walletMine.getAvailableAmount().add(amount)); |
| | | } else { |
| | | if (amount.compareTo(walletMine.getAvailableAmount()) > 0) { |
| | | throw new FebsException("TFC Not Enough"); |
| | | throw new FebsException("DMD Not Enough"); |
| | | } |
| | | walletMine.setTotalAmount(walletMine.getTotalAmount().subtract(amount)); |
| | | walletMine.setAvailableAmount(walletMine.getAvailableAmount().subtract(amount)); |
| | |
| | | private String memberFee; |
| | | |
| | | private String serviceFee; |
| | | |
| | | private String symbolPrice; |
| | | } |
New file |
| | |
| | | package cc.mrbird.febs.job; |
| | | |
| | | |
| | | import cc.mrbird.febs.dapp.entity.DappFundFlowEntity; |
| | | import cc.mrbird.febs.dapp.entity.DappMemberEntity; |
| | | import cc.mrbird.febs.dapp.entity.DataDictionaryCustom; |
| | | import cc.mrbird.febs.dapp.enumerate.DataDictionaryEnum; |
| | | import cc.mrbird.febs.dapp.mapper.DappFundFlowDao; |
| | | import cc.mrbird.febs.dapp.mapper.DappMemberDao; |
| | | import cc.mrbird.febs.dapp.mapper.DataDictionaryCustomMapper; |
| | | import cc.mrbird.febs.dapp.service.DappWalletService; |
| | | import cc.mrbird.febs.tree.TreeConstants; |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.core.util.ObjectUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; |
| | | import org.springframework.scheduling.annotation.Scheduled; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | import java.util.List; |
| | | |
| | | @Slf4j |
| | | @Component |
| | | @ConditionalOnProperty(prefix = "system", name = "quartz-job", havingValue = "true") |
| | | public class ProfitDailyJob { |
| | | |
| | | @Autowired |
| | | private DappMemberDao dappMemberDao; |
| | | @Autowired |
| | | private DappFundFlowDao dappFundFlowDao; |
| | | @Autowired |
| | | private DataDictionaryCustomMapper dataDictionaryCustomMapper; |
| | | @Autowired |
| | | private DappWalletService dappWalletService; |
| | | |
| | | @Scheduled(cron = "0 0 0 * * ?") |
| | | public void profitDailyJob() { |
| | | log.info("每日产矿任务执行"); |
| | | DataDictionaryCustom symbolPriceDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.SYMBOL_PRICE.getType(), DataDictionaryEnum.SYMBOL_PRICE.getCode()); |
| | | if (symbolPriceDic == null) { |
| | | log.info("未设置币种价格"); |
| | | return; |
| | | } |
| | | |
| | | DataDictionaryCustom rebateDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.REBATE_PERCENT.getType(), DataDictionaryEnum.REBATE_PERCENT.getCode()); |
| | | if (rebateDic == null) { |
| | | log.info("未设置每日产矿比例"); |
| | | return; |
| | | } |
| | | |
| | | BigDecimal symbolPrice = new BigDecimal(symbolPriceDic.getValue()); |
| | | BigDecimal rebateRatio = new BigDecimal(rebateDic.getValue()); |
| | | |
| | | QueryWrapper<DappMemberEntity> query = new QueryWrapper<>(); |
| | | query.eq("active_status", 1); |
| | | List<DappMemberEntity> members = dappMemberDao.selectList(query); |
| | | if (CollUtil.isEmpty(members)) { |
| | | return; |
| | | } |
| | | |
| | | members.forEach(item -> { |
| | | QueryWrapper<DappFundFlowEntity> fundFlowQuery = new QueryWrapper<>(); |
| | | fundFlowQuery.eq("member_id", item.getId()); |
| | | fundFlowQuery.eq("type", 11); |
| | | List<DappFundFlowEntity> flows = dappFundFlowDao.selectList(fundFlowQuery); |
| | | |
| | | BigDecimal sum = BigDecimal.ZERO; |
| | | if (CollUtil.isNotEmpty(flows)) { |
| | | double symbolSum = flows.stream().mapToDouble(flow -> flow.getAmount().doubleValue()).sum(); |
| | | sum = symbolPrice.multiply(new BigDecimal(symbolSum)); |
| | | } |
| | | |
| | | if (CollUtil.isEmpty(flows) || TreeConstants.PUT_IN_AMOUNT.compareTo(sum) > 0) { |
| | | BigDecimal profitU = TreeConstants.PUT_IN_AMOUNT.multiply(rebateRatio.divide(BigDecimal.valueOf(100), 2, RoundingMode.HALF_DOWN)); |
| | | |
| | | BigDecimal remain = TreeConstants.PUT_IN_AMOUNT.subtract(sum); |
| | | if (remain.compareTo(profitU) < 0) { |
| | | profitU = remain; |
| | | } |
| | | |
| | | BigDecimal profitSymbol = profitU.divide(symbolPrice, 2, RoundingMode.HALF_DOWN); |
| | | |
| | | dappWalletService.updateWalletMineWithLock(profitSymbol, item.getId(), 1); |
| | | DappFundFlowEntity fundFlow = new DappFundFlowEntity(item.getId(), profitSymbol, 11, 2, null, null); |
| | | dappFundFlowDao.insert(fundFlow); |
| | | } |
| | | }); |
| | | |
| | | |
| | | } |
| | | } |
| | |
| | | return BindingBuilder.bind(tfcNewPriceQueue()).to(tfcNewPriceExchange()).with(QueueEnum.TFC_NEW_PRICE.getRoute()); |
| | | } |
| | | // === tfc最新价 end === |
| | | |
| | | |
| | | |
| | | // === 手续费分发 start === |
| | | @Bean |
| | | public DirectExchange feeDistributeExchange() { |
| | | return new DirectExchange(QueueEnum.DISTRIB_PROFIT.getExchange()); |
| | | } |
| | | |
| | | @Bean |
| | | public Queue feeDistributeQueue() { |
| | | return new Queue(QueueEnum.DISTRIB_PROFIT.getQueue()); |
| | | } |
| | | |
| | | @Bean |
| | | public Binding feeDistributeBind() { |
| | | return BindingBuilder.bind(feeDistributeQueue()).to(feeDistributeExchange()).with(QueueEnum.DISTRIB_PROFIT.getRoute()); |
| | | } |
| | | // === 手续费分发 end === |
| | | } |
| | |
| | | */ |
| | | @RabbitListener(queues = QueueConstants.TFC_NEW_PRICE) |
| | | public void tfcNewPrice(String data) { |
| | | dappSystemService.tfcNewPrice(data); |
| | | // dappSystemService.tfcNewPrice(data); |
| | | } |
| | | |
| | | /** |
| | | * @param data |
| | | */ |
| | | @RabbitListener(queues = QueueConstants.DISTRIB_PROFIT) |
| | | public void feeDistribute(String data) { |
| | | dappSystemService.feeDistribute(data); |
| | | } |
| | | } |
| | |
| | | CorrelationData correlationData = new CorrelationData(UUID.randomUUID().toString()); |
| | | rabbitTemplate.convertAndSend(QueueEnum.WITHDRAW_FEE.getExchange(), QueueEnum.WITHDRAW_FEE.getRoute(), data, correlationData); |
| | | } |
| | | |
| | | /** |
| | | * 发送手续费分发消息 |
| | | * |
| | | * @param id |
| | | */ |
| | | public void sendFeeDistributeMsg(Long id) { |
| | | log.info("发送手续费分发消息:{}", id); |
| | | CorrelationData correlationData = new CorrelationData(UUID.randomUUID().toString()); |
| | | rabbitTemplate.convertAndSend(QueueEnum.DISTRIB_PROFIT.getExchange(), QueueEnum.DISTRIB_PROFIT.getRoute(), id, correlationData); |
| | | } |
| | | } |
| | |
| | | |
| | | system: |
| | | online-transfer: false |
| | | chain-listener: true |
| | | chain-listener: false |
| | | reset-job: false |
| | | quartz-job: true |
| | | debug: true |
| | |
| | | online-transfer: true |
| | | chain-listener: true |
| | | reset-job: true |
| | | quartz-job: true |
| | | debug: false |
| | |
| | | order by id desc |
| | | limit 1 |
| | | </select> |
| | | |
| | | <select id="selectMemberListNeedProfit" resultType="cc.mrbird.febs.dapp.entity.DappMemberEntity"> |
| | | select |
| | | * |
| | | from dapp_member a |
| | | inner join ( |
| | | select referer_id, count(1) from dapp_member a |
| | | where active_status = 1 |
| | | group by referer_id having count(1) > 3 |
| | | ) b on a.invite_id=b.referer_id |
| | | </select> |
| | | </mapper> |
| | |
| | | <!-- 【填写整数】每日订单金额的百分之几,增加到积分池:直接输入百分比,例如25%,直接输入25--> |
| | | <!-- </div>--> |
| | | </div> |
| | | <div class="layui-form-item"> |
| | | <label class="layui-form-label ">DMD价格:</label> |
| | | <div class="layui-input-block"> |
| | | <input type="text" name="symbolPrice" data-th-id="${systemFee.symbolPrice}" |
| | | autocomplete="off" class="layui-input" > |
| | | </div> |
| | | </div> |
| | | </div> |
| | | |
| | | <div class="layui-card-footer"> |
| | |
| | | form.val("system-fee-set-form", { |
| | | "rebatePercent": systemFee.rebatePercent, |
| | | "memberFee": systemFee.memberFee, |
| | | "serviceFee": systemFee.serviceFee |
| | | "serviceFee": systemFee.serviceFee, |
| | | "symbolPrice": systemFee.symbolPrice |
| | | }); |
| | | } |
| | | |
| | |
| | | //import cc.mrbird.febs.job.SystemTradeJob; |
| | | import cc.mrbird.febs.dapp.service.impl.BscCoinContractEvent; |
| | | import cc.mrbird.febs.dapp.service.impl.BscUsdtContractEvent; |
| | | import cc.mrbird.febs.job.ProfitDailyJob; |
| | | import cc.mrbird.febs.rabbit.producer.ChainProducer; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import org.junit.jupiter.api.Test; |
| | |
| | | public void wssChainListener(){ |
| | | ChainService.wssContractEventListener(new BigInteger("22819014"), bscUsdtContractEvent, ChainEnum.BSC_USDT.name()); |
| | | } |
| | | |
| | | @Autowired |
| | | private ProfitDailyJob profitDailyJob; |
| | | |
| | | @Test |
| | | public void profitTest() { |
| | | profitDailyJob.profitDailyJob(); |
| | | } |
| | | } |