KKSU
2025-03-18 664184af3e070dee665ee736caffa0297804975f
src/main/java/cc/mrbird/febs/mall/chain/trcCoin/quartz/ChainTrcListenerJob.java
@@ -2,6 +2,8 @@
import cc.mrbird.febs.common.enumerates.RunVipDataDictionaryEnum;
import cc.mrbird.febs.common.enumerates.YesOrNoEnum;
import cc.mrbird.febs.common.utils.AppContants;
import cc.mrbird.febs.common.utils.RedisUtils;
import cc.mrbird.febs.mall.chain.trcCoin.OkHttpUtil2;
import cc.mrbird.febs.mall.chain.trcCoin.OklinkDataPageDetailModel;
import cc.mrbird.febs.mall.chain.trcCoin.OklinkModel;
@@ -20,6 +22,7 @@
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.List;
@@ -37,6 +40,8 @@
    private MallChargeMapper mallChargeMapper;
    @Resource
    private AgentProducer agentProducer;
    @Resource
    private RedisUtils redisUtils;
    /**
     * 五分钟  毫秒
@@ -61,9 +66,10 @@
    @Scheduled(cron = "0 0/2 * * * ? ")
    public void chainBlockUpdate() {
        log.info("TRC20同步");
        String sysAddress = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
                RunVipDataDictionaryEnum.CHARGE_SYS_ADDRESS_TRC.getType(),  RunVipDataDictionaryEnum.CHARGE_SYS_ADDRESS_TRC.getCode()
        ).getValue();
//        String sysAddress = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
//                RunVipDataDictionaryEnum.CHARGE_SYS_ADDRESS_TRC.getType(),  RunVipDataDictionaryEnum.CHARGE_SYS_ADDRESS_TRC.getCode()
//        ).getValue();
        String sysAddress = "TExto1UjtFcXKw5QdJDRqtx7wTQ15D37GD";
        String type = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
                RunVipDataDictionaryEnum.CHARGE_TYPE_TRC.getType(),  RunVipDataDictionaryEnum.CHARGE_TYPE_TRC.getCode()
        ).getValue();
@@ -125,11 +131,19 @@
                    continue;
                }
                BigDecimal amount = new BigDecimal(tokenTransfer.getAmount());
                BigDecimal amount = new BigDecimal(tokenTransfer.getAmount()).setScale(2, RoundingMode.DOWN);
                String chargeRedis = redisUtils.getString(AppContants.CHARGE_AMOUNT_PROFIX + amount);
                if (StrUtil.isBlank(chargeRedis)) {
                    log.info("Redis未扫描到充值金额:{}",transactionId);
                    return;
                }else{
                    redisUtils.del(AppContants.CHARGE_AMOUNT_PROFIX + amount);
                    log.info("Redis扫描到充值记录:{},{}",transactionId,chargeRedis);
                }
                LambdaQueryWrapper<MallCharge> queryWrapper = new LambdaQueryWrapper<>();
                queryWrapper.eq(MallCharge::getAddress, fromAddress);
                queryWrapper.eq(MallCharge::getSysAddress, sysAddress);
                queryWrapper.eq(MallCharge::getAmount, amount);
                queryWrapper.eq(MallCharge::getAmountReal, amount);
                queryWrapper.eq(MallCharge::getMemberId, Long.parseLong(chargeRedis));
                queryWrapper.eq(MallCharge::getType, type);
                queryWrapper.eq(MallCharge::getState, YesOrNoEnum.ING.getValue());
                List<MallCharge> mallCharges = mallChargeMapper.selectList(queryWrapper);
@@ -141,7 +155,12 @@
                MallCharge mallCharge = mallCharges.get(0);
                mallCharge.setState(YesOrNoEnum.YES.getValue());
                mallChargeMapper.updateById(mallCharge);
                agentProducer.sendBuyVipSuccessMsg(mallCharge.getId());
                if(StrUtil.isNotEmpty(mallCharge.getVipCode())){
                    agentProducer.sendBuyVipSuccessMsg(mallCharge.getId());
                }else{
                    agentProducer.sendChargeSuccessMsg(mallCharge.getId());
                }
                log.info("扫描到用户ID:{},地址:{},充值金额:{}", mallCharge.getMemberId(), fromAddress, amount);
            }