KKSU
2025-02-12 1bb96bab1185f2e1aa2f468266512ee0beb83286
src/main/java/cc/mrbird/febs/rabbit/consumer/AgentConsumer.java
@@ -1,16 +1,13 @@
package cc.mrbird.febs.rabbit.consumer;
import cc.mrbird.febs.mall.service.IApiMallOrderInfoService;
import cc.mrbird.febs.mall.dto.ApiMemberChargeFailDto;
import cc.mrbird.febs.mall.service.IAgentService;
import cc.mrbird.febs.rabbit.constants.QueueConstants;
import cc.mrbird.febs.rabbit.enumerates.RabbitQueueEnum;
import com.rabbitmq.client.Channel;
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 java.util.Date;
/**
 * @author wzy
@@ -18,19 +15,62 @@
 **/
@Slf4j
@Component
@ConditionalOnProperty(prefix = "consumer", name = "open", havingValue = "true")
public class AgentConsumer {
    @Autowired
    private IApiMallOrderInfoService orderInfoService;
    private IAgentService agentService;
    @RabbitListener(queues = QueueConstants.QUEUE_DEFAULT)
    public void agentReturn(Message message, Channel channel) {
        log.info("消费者:{}", new String(message.getBody()));
    /**
     * 充值自动过期
     * @param apiMemberChargeFailDto
     */
    @RabbitListener(queues = QueueConstants.RUN_VIP_OPERATION_CHARGE_FAIL)
    public void memberChargeFailMsg(ApiMemberChargeFailDto apiMemberChargeFailDto) {
        try {
            agentService.sendMemberChargeFailMsg(apiMemberChargeFailDto);
        } catch (Exception e) {
            log.error("消费充值自动过期异常", e);
        }
    }
    @RabbitListener(queues = "queue_order_delay")
    public void orderCancelDelay(String id) {
        log.info("订单超时支付自动取消:{}", id);
        orderInfoService.autoCancelOrder(Long.parseLong(id));
    /**
     * 购买成功
     */
    @RabbitListener(queues = QueueConstants.RUN_VIP_OPERATION_CHARGE)
    public void buyVipSuccessMsg(Long chargeId) {
        try {
            agentService.buyVipSuccessMsg(chargeId);
        } catch (Exception e) {
            log.error("消费购买成功异常", e);
        }
    }
    /**
     * 充值成功
     */
    @RabbitListener(queues = QueueConstants.RUN_VIP_OPERATION_CHARGE_BALANCE)
    public void chargeSuccessMsg(Long chargeId) {
        try {
            agentService.chargeSuccessMsg(chargeId);
        } catch (Exception e) {
            log.error("消费充值异常", e);
        }
    }
    /**
     * 节点升级
     */
    @RabbitListener(queues = QueueConstants.RUN_VIP_NODE_UP)
    public void nodeUpMsg(Long memberId) {
        try {
            agentService.nodeUpMsg(memberId);
        } catch (Exception e) {
            log.error("消费节点升级异常", e);
        }
    }
}