
package com.tmerclub.cloud.biz.linstener;

import com.tmerclub.cloud.api.order.feign.OrderFeignClient;
import com.tmerclub.cloud.biz.service.SendMessageService;
import com.tmerclub.cloud.common.order.vo.SendNotifyBO;
import com.tmerclub.cloud.common.rocketmq.config.RocketMqConstant;
import org.apache.dubbo.config.annotation.DubboReference;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @author lhd
 */
@Component
@RocketMQMessageListener(topic = RocketMqConstant.SEND_GROUP_NOTIFY_TO_USER_TOPIC, consumerGroup = RocketMqConstant.SEND_GROUP_NOTIFY_TO_USER_TOPIC)
public class OrderGroupBizConsumer implements RocketMQListener<SendNotifyBO> {

    @Autowired
    private SendMessageService sendMessageService;
    @DubboReference
    private OrderFeignClient orderFeignClient;

    /**
     * 开团成团相关通知（开团成功、拼团成功、拼团失败）
     */
    @Override
    public void onMessage(SendNotifyBO sendNotifyBO) {
        // 获取订单相关信息
        SendNotifyBO sendNotifyDb = orderFeignClient.getOrderDetailInfo(sendNotifyBO.getBizId()).getData();
        sendNotifyDb.setSendType(sendNotifyBO.getSendType());
        sendMessageService.sendOrderNotifyMsgToShop(sendNotifyDb);
    }
}
