1. 商品信息变动刷新库存

2. 商品信息变动发生Mq消息
This commit is contained in:
Tankaikai
2025-03-03 10:31:05 +08:00
parent 152e2261e8
commit ec32fc48f5
10 changed files with 60 additions and 3 deletions

View File

@@ -1,6 +1,9 @@
package com.czg.config;
import org.springframework.amqp.core.*;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@@ -48,6 +51,11 @@ public class RabbitConfig {
return new Queue(activeProfile + "-" + RabbitConstants.Queue.ORDER_STOCK_QUEUE, true);
}
@Bean
public Queue productInfoChangeQueue() {
return new Queue(activeProfile + "-" + RabbitConstants.Queue.PRODUCT_INFO_CHANGE_QUEUE, true);
}
@Bean
@Primary
public DirectExchange directExchange() {
@@ -69,4 +77,9 @@ public class RabbitConfig {
public Binding bindingOrderStockExchange(Queue orderStockQueue, DirectExchange exchange) {
return BindingBuilder.bind(orderStockQueue).to(exchange).with(activeProfile + "-" + RabbitConstants.Queue.ORDER_STOCK_QUEUE);
}
@Bean
public Binding bindingProductInfoChange(Queue productInfoChangeQueue, DirectExchange exchange) {
return BindingBuilder.bind(productInfoChangeQueue).to(exchange).with(activeProfile + "-" + RabbitConstants.Queue.PRODUCT_INFO_CHANGE_QUEUE);
}
}

View File

@@ -15,5 +15,6 @@ public interface RabbitConstants {
public static final String ORDER_PRINT_QUEUE = "order.print.queue";
public static final String ORDER_MACHINE_PRINT_QUEUE = "order.machine.print.queue";
public static final String ORDER_HANDOVER_PRINT_QUEUE = "order.handover.print.queue";
public static final String PRODUCT_INFO_CHANGE_QUEUE = "product.info.change.queue";
}
}

View File

@@ -23,7 +23,7 @@ public class RabbitPublisher {
* @param orderId 订单id
*/
public void sendOrderCancelMsg(String orderId) {
sendMsg(RabbitConstants.Queue.ORDER_STOCK_QUEUE, orderId);
sendMsg(RabbitConstants.Queue.ORDER_CANCEL_QUEUE, orderId);
}
/**
@@ -54,6 +54,15 @@ public class RabbitPublisher {
sendMsg(RabbitConstants.Queue.ORDER_HANDOVER_PRINT_QUEUE, handoverRecordId);
}
/**
* 商品信息变动消息
*
* @param shopId 店铺id
*/
public void sendProductInfoChangeMsg(String shopId) {
sendMsg(RabbitConstants.Queue.PRODUCT_INFO_CHANGE_QUEUE, shopId);
}
private void sendMsg(String queue, String msg) {