Helius
2021-04-16 6b48b8c7c3240f9499bbe477c17de0a9968b045a
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
45
46
package com.xcong.excoin.rabbit.consumer;
 
import com.alibaba.fastjson.JSONObject;
import com.rabbitmq.client.Channel;
import com.xcong.excoin.configurations.RabbitMqConfig;
import com.xcong.excoin.modules.contract.parameter.dto.ChangeBondDto;
import com.xcong.excoin.modules.documentary.service.FollowOrderOperationService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.stereotype.Component;
import org.web3j.abi.datatypes.Int;
 
import java.math.BigDecimal;
import java.util.Map;
 
/**
 * @author wzy
 * @date 2021-03-04
 **/
@Slf4j
@Component
@ConditionalOnProperty(prefix = "app", name = "rabbit-consumer", havingValue = "true")
public class FollowConsumer {
 
    @Autowired
    private FollowOrderOperationService followOrderOperationService;
 
    @RabbitListener(queues = RabbitMqConfig.QUEUE_FOLLOW_ORDER)
    public void addFollowOrder(Message message, Channel channel) {
        String content = new String(message.getBody());
        log.info("==收到跟单下单消息 : {}", content);
 
        followOrderOperationService.addFollowerOrder(Long.parseLong(content));
    }
 
    @RabbitListener(queues = RabbitMqConfig.QUEUE_FOLLOW_CHANGE_BOND)
    public void changeFollowOrderBond(Message message, Channel channel) {
        String content = new String(message.getBody());
        log.info("==收到跟单保证金调整消息 : {}", content);
        ChangeBondDto changeBondDto = JSONObject.parseObject(content, ChangeBondDto.class);
        followOrderOperationService.changeFollowOrdersBond(changeBondDto.getId(), changeBondDto.getAmount(), changeBondDto.getType());
    }
}