| | |
| | | package cc.mrbird.febs.dapp.service.impl; |
| | | |
| | | import cc.mrbird.febs.common.contants.AppContants; |
| | | import cc.mrbird.febs.common.entity.FebsResponse; |
| | | 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.job.SystemTradeJob; |
| | | import cc.mrbird.febs.rabbit.producer.ChainProducer; |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.core.date.DateField; |
| | | import cn.hutool.core.date.DateTime; |
| | | import cn.hutool.core.date.DateUnit; |
| | | import cn.hutool.core.date.DateUtil; |
| | | import cn.hutool.core.util.ObjectUtil; |
| | | import cn.hutool.core.util.RandomUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import cn.hutool.json.JSONUtil; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | |
| | | private final DappMemberBoxRecordMapper dappMemberBoxRecordMapper; |
| | | private final DappWalletCoinDao dappWalletCoinDao; |
| | | private final DappSdeWithdrawFeeDao dappSdeWithdrawFeeDao; |
| | | private final DappPriceRecordDao dappPriceRecordDao; |
| | | |
| | | |
| | | @Override |
| | |
| | | // int count = nftCount == null ? 0 : nftCount.intValue(); |
| | | result.put("cardCnt", 1000); |
| | | result.put("nftPrice", AppContants.NFT_ACTIVE_PRICE); |
| | | result.put("rewardPool", ChainService.getInstance(ChainEnum.BSC_TFC.name()).balanceOf(ChainEnum.BSC_TFC_REWARD.getAddress())); |
| | | return result; |
| | | } |
| | | |
| | |
| | | |
| | | Object o = redisUtils.get(AppContants.REDIS_KEY_COIN_REMAIN + member.getAddress()); |
| | | |
| | | BigDecimal minLimit = new BigDecimal(50); |
| | | BigDecimal coinTotal; |
| | | if (balance.compareTo(minLimit) > 0) { |
| | | BigDecimal coinTotal = balance; |
| | | if (this.hasProfit(member.getAddress())) { |
| | | coinTotal = balance.multiply(BigDecimal.valueOf(0.3)).setScale(instance.decimals(), RoundingMode.HALF_DOWN); |
| | | } else { |
| | | coinTotal = new BigDecimal(50); |
| | | } |
| | | |
| | | BigDecimal remain; |
| | |
| | | // 源池USDT数量 |
| | | BigDecimal usdtBalance = ChainService.getInstance(ChainEnum.BSC_USDT_SOURCE.name()).balanceOf(ChainEnum.BSC_USDT_SOURCE.getAddress()); |
| | | |
| | | return tfcBalance.divide(usdtBalance, tfcInstance.decimals(), RoundingMode.HALF_UP); |
| | | return usdtBalance.divide(tfcBalance, tfcInstance.decimals(), RoundingMode.HALF_UP); |
| | | } else { |
| | | return new BigDecimal("0.05"); |
| | | } |
| | |
| | | return cardCntMap; |
| | | } |
| | | |
| | | @Autowired |
| | | private DappPriceRecordDao dappPriceRecordDao; |
| | | |
| | | @Override |
| | | public void tfcNewPrice() { |
| | | BigDecimal newPrice = newestPrice(); |
| | |
| | | // 给影子生态发送价格 |
| | | chainProducer.sendTfcNewPrice(newPrice.toPlainString()); |
| | | } |
| | | |
| | | @Override |
| | | public List<DappPriceRecordEntity> findPriceListIn24H() { |
| | | DateTime startTime = DateUtil.offset(new Date(), DateField.HOUR, -24); |
| | | List<DappPriceRecordEntity> list = dappPriceRecordDao.selectPriceListInStartTimeAndEndTime(startTime, new Date()); |
| | | list.forEach(item -> { |
| | | item.setTime(DateUtil.format(item.getCreateTime(), "HH:mm")); |
| | | }); |
| | | return list; |
| | | } |
| | | |
| | | @Override |
| | | public List<DataDictionaryCustom> findDataDicByType(String type) { |
| | | return dataDictionaryCustomMapper.selectDicByType(type); |
| | | } |
| | | |
| | | @Override |
| | | public void levelSystemSetting(Map<String, Object> map) { |
| | | for (Map.Entry<String, Object> entry : map.entrySet()) { |
| | | if (entry.getValue() instanceof String) { |
| | | dataDictionaryCustomMapper.updateDicValueByTypeAndCode(null, entry.getKey(), (String) entry.getValue()); |
| | | } else { |
| | | List<LinkedHashMap<String, Object>> value = (List<LinkedHashMap<String, Object>>) entry.getValue(); |
| | | |
| | | for (LinkedHashMap<String, Object> dic : value) { |
| | | String type = (String) dic.get("type"); |
| | | String code = (String) dic.get("code"); |
| | | String dataValue = (String) dic.get("value"); |
| | | dataDictionaryCustomMapper.updateDicValueByTypeAndCode(type, code, dataValue); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | @Transactional |
| | | public FebsResponse enableOnHook(Long id) { |
| | | DataDictionaryCustom dataDictionaryCustom = dataDictionaryCustomMapper.selectById(id); |
| | | if (ObjectUtil.isEmpty(dataDictionaryCustom)) { |
| | | return new FebsResponse().fail().message("网络繁忙,请刷新当前页面"); |
| | | } |
| | | String type = dataDictionaryCustom.getType(); |
| | | String code = dataDictionaryCustom.getCode(); |
| | | String dicValue = dataDictionaryCustom.getValue(); |
| | | cn.hutool.json.JSONObject jsonObject = JSONUtil.parseObj(dicValue); |
| | | jsonObject.set("state",1); |
| | | dataDictionaryCustomMapper.updateDicValueByTypeAndCode(type, code, jsonObject.toString()); |
| | | return new FebsResponse().success(); |
| | | } |
| | | |
| | | @Override |
| | | public FebsResponse disableOnHook(Long id) { |
| | | DataDictionaryCustom dataDictionaryCustom = dataDictionaryCustomMapper.selectById(id); |
| | | if (ObjectUtil.isEmpty(dataDictionaryCustom)) { |
| | | return new FebsResponse().fail().message("网络繁忙,请刷新当前页面"); |
| | | } |
| | | String type = dataDictionaryCustom.getType(); |
| | | String code = dataDictionaryCustom.getCode(); |
| | | String dicValue = dataDictionaryCustom.getValue(); |
| | | cn.hutool.json.JSONObject jsonObject = JSONUtil.parseObj(dicValue); |
| | | jsonObject.set("state",2); |
| | | dataDictionaryCustomMapper.updateDicValueByTypeAndCode(type, code, jsonObject.toString()); |
| | | return new FebsResponse().success(); |
| | | } |
| | | } |