| | |
| | | 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.entity.DataDictionaryCustom; |
| | | import cc.mrbird.febs.dapp.mapper.DataDictionaryCustomMapper; |
| | | import cc.mrbird.febs.dapp.service.DappSystemService; |
| | | import cc.mrbird.febs.dapp.vo.RedisTransferPoolVo; |
| | | 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 javax.annotation.Resource; |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | |
| | |
| | | **/ |
| | | @Slf4j |
| | | @Component |
| | | @ConditionalOnProperty(prefix = "system", name = "trade-job", havingValue = "true") |
| | | public class SystemTradeJob { |
| | | |
| | | @Autowired |
| | | private RedisUtils redisUtils; |
| | | @Autowired |
| | | private DappSystemService systemService; |
| | | @Resource |
| | | private DataDictionaryCustomMapper dataDictionaryCustomMapper; |
| | | |
| | | // 最低容量(百分比) |
| | | private final BigDecimal volProp = new BigDecimal("0.5"); |
| | | |
| | | private final BigDecimal basic_vol = BigDecimal.valueOf(1200000); |
| | | |
| | | /** |
| | | * 中转池容量计算 |
| | |
| | | @Scheduled(cron = "0 0 0 * * ?") |
| | | public void transferPoolVol() { |
| | | log.info("中转池容量"); |
| | | |
| | | String hasStart = redisUtils.getString(AppContants.SYSTEM_START_FLAG); |
| | | if (!"start".equals(hasStart)) { |
| | | log.info("系统未启动"); |
| | | return; |
| | | } |
| | | |
| | | // 源池初始化容量 |
| | | DataDictionaryCustom dic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(AppContants.DIC_TYPE_SYSTEM_SETTING, AppContants.DIC_VALUE_SYSTEM_SOURCE_POOL_VOL); |
| | | BigDecimal basicVol = new BigDecimal(dic.getValue()); |
| | | |
| | | Object o = redisUtils.get(AppContants.REDIS_KEY_TRANSFER_POOL_VOL); |
| | | if (o == null) { |
| | | RedisTransferPoolVo transferPool= new RedisTransferPoolVo(); |
| | | BigDecimal total = basic_vol.multiply(volProp.divide(BigDecimal.valueOf(100), 4, RoundingMode.HALF_UP)); |
| | | BigDecimal total = basicVol.multiply(volProp.divide(BigDecimal.valueOf(100), 4, RoundingMode.HALF_UP)); |
| | | transferPool.setTodayVol(total); |
| | | transferPool.setTodayProp(volProp); |
| | | transferPool.setFinishCnt(0); |
| | |
| | | transferPool.setFinishCnt(finishCnt); |
| | | } |
| | | |
| | | BigDecimal total = basic_vol.multiply(targetProp.divide(BigDecimal.valueOf(100), 4, RoundingMode.HALF_UP)); |
| | | BigDecimal total = basicVol.multiply(targetProp.divide(BigDecimal.valueOf(100), 4, RoundingMode.HALF_UP)); |
| | | transferPool.setTodayVol(total); |
| | | transferPool.setUnFinishCnt(0); |
| | | redisUtils.set(AppContants.REDIS_KEY_TRANSFER_POOL_VOL_REMAIN, total); |
| | |
| | | transferPool.setUnFinishCnt(unFinishCnt); |
| | | } |
| | | BigDecimal aa = targetProp.divide(BigDecimal.valueOf(100), 4, RoundingMode.HALF_UP); |
| | | BigDecimal total = basic_vol.multiply(aa); |
| | | BigDecimal total = basicVol.multiply(aa); |
| | | transferPool.setTodayVol(total); |
| | | redisUtils.set(AppContants.REDIS_KEY_TRANSFER_POOL_VOL_REMAIN, total); |
| | | } |
| | |
| | | @Scheduled(cron = "0 0 0 * * ?") |
| | | public void sourcePoolUsdtOutLimit() { |
| | | log.info("源池每日出U限制"); |
| | | |
| | | String hasStart = redisUtils.getString(AppContants.SYSTEM_START_FLAG); |
| | | if (!"start".equals(hasStart)) { |
| | | log.info("系统未启动"); |
| | | return; |
| | | } |
| | | BigDecimal sourceBalance = ChainService.getInstance(ChainEnum.BSC_USDT.name()).balanceOf(ChainEnum.BSC_USDT_SOURCE.getAddress()); |
| | | |
| | | BigDecimal total = sourceBalance.multiply(BigDecimal.valueOf(0.1)).setScale(4, RoundingMode.HALF_DOWN); |
| | |
| | | */ |
| | | @Scheduled(cron = "0 0 2 * * ?") |
| | | public void mineJob() { |
| | | log.info("挖矿"); |
| | | systemService.mining(); |
| | | } |
| | | } |