zainali5120
2020-10-28 8fda5eddb56178a0c1e0e247b5c7f45ffc739c92
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package com.xcong.excoin.rabbit.consumer;
 
import com.alibaba.fastjson.JSONObject;
import com.xcong.excoin.configurations.RabbitMqConfig;
import com.xcong.excoin.modules.blackchain.model.EthUsdtChargeDto;
import com.xcong.excoin.modules.blackchain.service.UsdtErc20UpdateService;
import com.xcong.excoin.modules.coin.service.BlockCoinService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.stereotype.Component;
 
import javax.annotation.Resource;
 
/**
 * @author wzy
 * @date 2020-05-25
 **/
@Slf4j
@Component
@ConditionalOnProperty(prefix = "app", name = "block-job", havingValue = "true")
public class UsdtUpdateConsumer {
 
 
    @Resource
    private BlockCoinService blockCoinService;
 
 
    @RabbitListener(queues = RabbitMqConfig.QUEUE_USDT_UPDATE)
    public void doSomething(String content) {
        log.info("#USDT同步---->{}#", content);
        EthUsdtChargeDto ethUsdtChargeDto = JSONObject.parseObject(content, EthUsdtChargeDto.class);
        // 更新这个用户的余额
        blockCoinService.updateEthUsdtNew(ethUsdtChargeDto);
    }
 
    @RabbitListener(queues = RabbitMqConfig.QUEUE_USDT_ADDRESS)
    public void addUsdtAddress(String content) {
        if(!UsdtErc20UpdateService.ALL_ADDRESS_LIST.contains(content)){
            log.debug("#添加新地址---->{}#", content);
            UsdtErc20UpdateService.ALL_ADDRESS_LIST.add(content);
        }
    }
}