| | |
| | | package cc.mrbird.febs.rabbit.consumer; |
| | | |
| | | import cc.mrbird.febs.mall.dto.ApiMemberChargeFailDto; |
| | | import cc.mrbird.febs.mall.service.IAgentService; |
| | | import cc.mrbird.febs.mall.service.IApiMallOrderInfoService; |
| | | 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 |
| | |
| | | **/ |
| | | @Slf4j |
| | | @Component |
| | | @ConditionalOnProperty(prefix = "consumer", name = "open", havingValue = "true") |
| | | public class AgentConsumer { |
| | | |
| | | @Autowired |
| | | private IApiMallOrderInfoService orderInfoService; |
| | | @Autowired |
| | | 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.AGENT_AUTO_LEVEL_UP) |
| | | public void agentAutoLevelUp(String id) { |
| | | log.info("收到代理自动升级消息:{}", id); |
| | | agentService.autoUpAgentLevel(Long.parseLong(id)); |
| | | |
| | | /** |
| | | * 充值成功 |
| | | */ |
| | | @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); |
| | | } |
| | | } |
| | | |
| | | |
| | | } |