parent
152e2261e8
commit
ec32fc48f5
|
|
@ -1,5 +1,7 @@
|
||||||
package com.czg.controller.admin;
|
package com.czg.controller.admin;
|
||||||
|
|
||||||
|
import cn.hutool.core.convert.Convert;
|
||||||
|
import com.czg.config.RabbitPublisher;
|
||||||
import com.czg.exception.CzgException;
|
import com.czg.exception.CzgException;
|
||||||
import com.czg.log.annotation.OperationLog;
|
import com.czg.log.annotation.OperationLog;
|
||||||
import com.czg.product.dto.ProdConsBindDTO;
|
import com.czg.product.dto.ProdConsBindDTO;
|
||||||
|
|
@ -37,6 +39,7 @@ import java.util.List;
|
||||||
public class ProductController {
|
public class ProductController {
|
||||||
private final ProductService productService;
|
private final ProductService productService;
|
||||||
private final ProdConsRelationService prodConsRelationService;
|
private final ProdConsRelationService prodConsRelationService;
|
||||||
|
private final RabbitPublisher rabbitPublisher;
|
||||||
|
|
||||||
@GetMapping("page")
|
@GetMapping("page")
|
||||||
@OperationLog("商品-分页")
|
@OperationLog("商品-分页")
|
||||||
|
|
@ -74,6 +77,7 @@ public class ProductController {
|
||||||
Long shopId = StpKit.USER.getShopId(0L);
|
Long shopId = StpKit.USER.getShopId(0L);
|
||||||
dto.setShopId(shopId);
|
dto.setShopId(shopId);
|
||||||
productService.addProduct(dto);
|
productService.addProduct(dto);
|
||||||
|
rabbitPublisher.sendProductInfoChangeMsg(Convert.toStr(shopId));
|
||||||
return CzgResult.success();
|
return CzgResult.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -84,6 +88,7 @@ public class ProductController {
|
||||||
Long shopId = StpKit.USER.getShopId(0L);
|
Long shopId = StpKit.USER.getShopId(0L);
|
||||||
dto.setShopId(shopId);
|
dto.setShopId(shopId);
|
||||||
productService.updateProduct(dto);
|
productService.updateProduct(dto);
|
||||||
|
rabbitPublisher.sendProductInfoChangeMsg(Convert.toStr(shopId));
|
||||||
return CzgResult.success();
|
return CzgResult.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -95,6 +100,7 @@ public class ProductController {
|
||||||
AssertUtil.isNull(id, "{}不能为空", "id");
|
AssertUtil.isNull(id, "{}不能为空", "id");
|
||||||
Long shopId = StpKit.USER.getShopId(0L);
|
Long shopId = StpKit.USER.getShopId(0L);
|
||||||
productService.deleteProduct(shopId, id);
|
productService.deleteProduct(shopId, id);
|
||||||
|
rabbitPublisher.sendProductInfoChangeMsg(Convert.toStr(shopId));
|
||||||
return CzgResult.success();
|
return CzgResult.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -108,6 +114,7 @@ public class ProductController {
|
||||||
Long shopId = StpKit.USER.getShopId(0L);
|
Long shopId = StpKit.USER.getShopId(0L);
|
||||||
param.setShopId(shopId);
|
param.setShopId(shopId);
|
||||||
productService.onOffProduct(param);
|
productService.onOffProduct(param);
|
||||||
|
rabbitPublisher.sendProductInfoChangeMsg(Convert.toStr(shopId));
|
||||||
return CzgResult.success();
|
return CzgResult.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -121,6 +128,7 @@ public class ProductController {
|
||||||
Long shopId = StpKit.USER.getShopId(0L);
|
Long shopId = StpKit.USER.getShopId(0L);
|
||||||
param.setShopId(shopId);
|
param.setShopId(shopId);
|
||||||
productService.markProductIsSoldOut(param);
|
productService.markProductIsSoldOut(param);
|
||||||
|
rabbitPublisher.sendProductInfoChangeMsg(Convert.toStr(shopId));
|
||||||
return CzgResult.success();
|
return CzgResult.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,9 @@
|
||||||
package com.czg.config;
|
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.beans.factory.annotation.Value;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
@ -48,6 +51,11 @@ public class RabbitConfig {
|
||||||
return new Queue(activeProfile + "-" + RabbitConstants.Queue.ORDER_STOCK_QUEUE, true);
|
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
|
@Bean
|
||||||
@Primary
|
@Primary
|
||||||
public DirectExchange directExchange() {
|
public DirectExchange directExchange() {
|
||||||
|
|
@ -69,4 +77,9 @@ public class RabbitConfig {
|
||||||
public Binding bindingOrderStockExchange(Queue orderStockQueue, DirectExchange exchange) {
|
public Binding bindingOrderStockExchange(Queue orderStockQueue, DirectExchange exchange) {
|
||||||
return BindingBuilder.bind(orderStockQueue).to(exchange).with(activeProfile + "-" + RabbitConstants.Queue.ORDER_STOCK_QUEUE);
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,5 +15,6 @@ public interface RabbitConstants {
|
||||||
public static final String ORDER_PRINT_QUEUE = "order.print.queue";
|
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_MACHINE_PRINT_QUEUE = "order.machine.print.queue";
|
||||||
public static final String ORDER_HANDOVER_PRINT_QUEUE = "order.handover.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";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ public class RabbitPublisher {
|
||||||
* @param orderId 订单id
|
* @param orderId 订单id
|
||||||
*/
|
*/
|
||||||
public void sendOrderCancelMsg(String orderId) {
|
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);
|
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) {
|
private void sendMsg(String queue, String msg) {
|
||||||
|
|
|
||||||
|
|
@ -50,5 +50,9 @@ public class ProdConsRelationDTO implements Serializable {
|
||||||
*/
|
*/
|
||||||
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
|
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
|
||||||
private LocalDateTime createTime;
|
private LocalDateTime createTime;
|
||||||
|
/**
|
||||||
|
* 耗材单位
|
||||||
|
*/
|
||||||
|
private String conUnit;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -17,4 +17,11 @@
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.czg</groupId>
|
||||||
|
<artifactId>cash-common-mq</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
package com.czg.service.product.mapper;
|
package com.czg.service.product.mapper;
|
||||||
|
|
||||||
|
import com.czg.product.dto.ProdConsRelationDTO;
|
||||||
import com.czg.product.dto.ProductBriefDTO;
|
import com.czg.product.dto.ProductBriefDTO;
|
||||||
import com.czg.product.entity.ProdConsRelation;
|
import com.czg.product.entity.ProdConsRelation;
|
||||||
import com.mybatisflex.core.BaseMapper;
|
import com.mybatisflex.core.BaseMapper;
|
||||||
|
|
@ -19,4 +20,5 @@ public interface ProdConsRelationMapper extends BaseMapper<ProdConsRelation> {
|
||||||
|
|
||||||
List<ProductBriefDTO> getProductListByConId(@Param("conId") Long conId);
|
List<ProductBriefDTO> getProductListByConId(@Param("conId") Long conId);
|
||||||
|
|
||||||
|
List<ProdConsRelationDTO> selectListByProdId(@Param("prodId") Long prodId);
|
||||||
}
|
}
|
||||||
|
|
@ -2,7 +2,9 @@ package com.czg.service.product.service.impl;
|
||||||
|
|
||||||
import cn.hutool.core.bean.BeanUtil;
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import cn.hutool.core.convert.Convert;
|
||||||
import cn.hutool.core.util.NumberUtil;
|
import cn.hutool.core.util.NumberUtil;
|
||||||
|
import com.czg.config.RabbitPublisher;
|
||||||
import com.czg.constant.CacheConstant;
|
import com.czg.constant.CacheConstant;
|
||||||
import com.czg.product.dto.ProductStockSubtractDTO;
|
import com.czg.product.dto.ProductStockSubtractDTO;
|
||||||
import com.czg.product.entity.ConsInfo;
|
import com.czg.product.entity.ConsInfo;
|
||||||
|
|
@ -49,6 +51,8 @@ public class ProductRpcServiceImpl implements ProductRpcService {
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private ConsStockFlowMapper consStockFlowMapper;
|
private ConsStockFlowMapper consStockFlowMapper;
|
||||||
|
@Resource
|
||||||
|
private RabbitPublisher rabbitPublisher;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
|
@ -107,6 +111,7 @@ public class ProductRpcServiceImpl implements ProductRpcService {
|
||||||
consStockFlowMapper.insert(consStockFlow);
|
consStockFlowMapper.insert(consStockFlow);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
rabbitPublisher.sendProductInfoChangeMsg(Convert.toStr(shopId));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -165,5 +170,6 @@ public class ProductRpcServiceImpl implements ProductRpcService {
|
||||||
consStockFlowMapper.insert(consStockFlow);
|
consStockFlowMapper.insert(consStockFlow);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
rabbitPublisher.sendProductInfoChangeMsg(Convert.toStr(shopId));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -131,7 +131,7 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
|
||||||
lowMemberPriceIsPresent.ifPresent(record::setLowMemberPrice);
|
lowMemberPriceIsPresent.ifPresent(record::setLowMemberPrice);
|
||||||
}
|
}
|
||||||
record.setSkuList(skuList);
|
record.setSkuList(skuList);
|
||||||
List<ProdConsRelationDTO> consList = prodConsRelationMapper.selectListByQueryAs(query().eq(ProdConsRelation::getProductId, record.getId()), ProdConsRelationDTO.class);
|
List<ProdConsRelationDTO> consList = prodConsRelationMapper.selectListByProdId(record.getId());
|
||||||
record.setConsList(consList);
|
record.setConsList(consList);
|
||||||
if (CollUtil.isNotEmpty(consList)) {
|
if (CollUtil.isNotEmpty(consList)) {
|
||||||
List<Long> consIds = consList.stream().map(ProdConsRelationDTO::getConsInfoId).distinct().toList();
|
List<Long> consIds = consList.stream().map(ProdConsRelationDTO::getConsInfoId).distinct().toList();
|
||||||
|
|
|
||||||
|
|
@ -11,4 +11,11 @@
|
||||||
inner join tb_product t2 on t1.product_id = t2.id
|
inner join tb_product t2 on t1.product_id = t2.id
|
||||||
where t1.cons_info_id = #{conId}
|
where t1.cons_info_id = #{conId}
|
||||||
</select>
|
</select>
|
||||||
|
<select id="selectListByProdId" resultType="com.czg.product.dto.ProdConsRelationDTO">
|
||||||
|
SELECT t1.*,
|
||||||
|
t2.con_unit
|
||||||
|
FROM tb_prod_cons_relation t1
|
||||||
|
LEFT JOIN tb_cons_info t2 on t1.cons_info_id = t2.id
|
||||||
|
WHERE t1.product_id = #{prodId}
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
Loading…
Reference in New Issue