package com.slodon.b2b2c.mq;

import com.slodon.b2b2c.core.constant.StarterConfigConst;
import com.slodon.b2b2c.model.promotion.SpellModel;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * mq处理拼团信息
 */
@Slf4j
@Component
public class MqSpellConsumer {

    @Resource
    private SpellModel spellModel;

    /**
     * 处理拼团状态
     *
     * @param orderSn 订单号
     */
    @RabbitListener(queues = StarterConfigConst.MQ_QUEUE_NAME_SPELL_TEAM_STATE, containerFactory = StarterConfigConst.MQ_FACTORY_NAME_SINGLE_PASS_ERR)
    public void spellTeamStateConsumer(String orderSn) {
        try {
            spellModel.updateSpellTeamState(orderSn);
        } catch (Exception e) {
            //修改拼团活动团队状态失败
            log.error("修改拼团活动团队状态失败，支付单号：{}", orderSn, e);
        }
    }
}
