CustomerChangeProducer.java 1.46 KB
package cn.fw.valhalla.component.producer;

import cn.fw.valhalla.domain.vo.customer.CustomerDetailVO;
import cn.fw.valhalla.sdk.result.CustomerInfoDto;
import cn.fw.valhalla.service.bus.cust.CustomerBizService;
import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.spring.core.RocketMQTemplate;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.Objects;

/**
 * @author kurisu
 */
@Slf4j
@Component
public class CustomerChangeProducer {
    @Autowired
    private RocketMQTemplate rocketMQTemplate;
    @Autowired
    private CustomerBizService customerBizService;

    @RequestMapping(value = "send")
    public void send(CustomerInfoDto customerInfoDto) {
        try {
            log.info("售后保有客信息变更mq: body:[{}]", customerInfoDto);
            if (Objects.isNull(customerInfoDto.getGroupId())) {
                log.warn("售后保有客信息变更mq集团id为空");
                return;
            }
            CustomerDetailVO detailByVin = customerBizService.getDetailByVin(customerInfoDto.getFrameNo(), customerInfoDto.getGroupId());
            BeanUtils.copyProperties(detailByVin, customerInfoDto);
            rocketMQTemplate.syncSend(CustomerInfoDto.TOPIC + ":*", customerInfoDto);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}