
package com.tmerclub.cloud.coupon.listener;

import com.tmerclub.cloud.api.coupon.bo.CouponGiveBO;
import com.tmerclub.cloud.common.rocketmq.config.RocketMqConstant;
import com.tmerclub.cloud.coupon.service.CouponUserService;
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 tmerclub
 */
@Component
@RocketMQMessageListener(topic = RocketMqConstant.COUPON_GIVE_TOPIC, consumerGroup = RocketMqConstant.COUPON_GIVE_TOPIC)
public class CouponGiveConsumer implements RocketMQListener<CouponGiveBO> {

    @Autowired
    private CouponUserService couponUserService;


    /**
     * 赠送优惠券给用户
     *
     * @param couponGiveBO
     */
    @Override
    public void onMessage(CouponGiveBO couponGiveBO) {
        couponUserService.giveCoupon(couponGiveBO);
    }
}
