From 91751b0f32056e60860666449c1b4421be3b70e5 Mon Sep 17 00:00:00 2001 From: SongZhang <2064194730@qq.com> Date: Wed, 21 Aug 2024 10:45:59 +0800 Subject: [PATCH] =?UTF-8?q?1.=E4=BB=A3=E5=AE=A2=E4=B8=8B=E5=8D=95=20?= =?UTF-8?q?=E5=8F=B0=E6=A1=8C=E7=8A=B6=E6=80=81=E5=90=8C=E6=AD=A5=E6=9B=B4?= =?UTF-8?q?=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/product/TbPlaceController.java | 17 +++++++++++------ .../impl/shopimpl/TbShopTableServiceImpl.java | 4 ++++ .../cn/ysk/cashier/utils/RabbitMsgUtils.java | 9 ++++----- 3 files changed, 19 insertions(+), 11 deletions(-) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/controller/product/TbPlaceController.java b/eladmin-system/src/main/java/cn/ysk/cashier/controller/product/TbPlaceController.java index 31002bc9..35348113 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/controller/product/TbPlaceController.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/controller/product/TbPlaceController.java @@ -7,6 +7,7 @@ import cn.ysk.cashier.dto.shoptable.*; import cn.ysk.cashier.pojo.order.TbCashierCart; import cn.ysk.cashier.service.product.TbProductService; import cn.ysk.cashier.service.shop.TbShopTableService; +import cn.ysk.cashier.utils.RabbitMsgUtils; import com.alibaba.fastjson.JSONObject; import io.swagger.annotations.ApiOperation; import org.springframework.amqp.rabbit.connection.CorrelationData; @@ -28,6 +29,7 @@ public class TbPlaceController { private final TbProductService tbProductService; private final Validator validator; + private final RabbitMsgUtils rabbitMsgUtils; @AnonymousAccess @@ -43,11 +45,12 @@ public class TbPlaceController { return new ResponseEntity<>(tbProductService.activateProduct(page, size, categoryId, shopId, productId),HttpStatus.OK); } - public TbPlaceController(TbShopTableService tbShopTableService, TbProductService tbProductService, Validator validator, RabbitTemplate rabbitTemplate) { + public TbPlaceController(TbShopTableService tbShopTableService, TbProductService tbProductService, Validator validator, RabbitTemplate rabbitTemplate, RabbitMsgUtils rabbitMsgUtils) { this.tbShopTableService = tbShopTableService; this.tbProductService = tbProductService; this.validator = validator; this.rabbitTemplate = rabbitTemplate; + this.rabbitMsgUtils = rabbitMsgUtils; } @AnonymousAccess @@ -199,13 +202,15 @@ public class TbPlaceController { private final RabbitTemplate rabbitTemplate; @AnonymousAccess @GetMapping("/test") - public void test() { + public void test( + @RequestParam Integer id + ) { JSONObject jsonObject = new JSONObject(); jsonObject.put("type", "create"); - jsonObject.put("orderId", "2980"); - rabbitTemplate.convertAndSend(RabbitConstants.CART_ORDER_COLLECT_PUT, RabbitConstants.CART_ORDER_COLLECT_ROUTINGKEY_PUT, jsonObject.toJSONString(), new CorrelationData(UUID.randomUUID().toString())); - - rabbitTemplate.convertAndSend(RabbitConstants.PRINT_MECHINE_COLLECT_PUT, RabbitConstants.PRINT_MECHINE_COLLECT_ROUTINGKEY_PUT, "2980", new CorrelationData(UUID.randomUUID().toString())); + jsonObject.put("orderId", id); +// rabbitTemplate.convertAndSend(RabbitConstants.CART_ORDER_COLLECT_PUT, RabbitConstants.CART_ORDER_COLLECT_ROUTINGKEY_PUT, jsonObject.toJSONString(), new CorrelationData(UUID.randomUUID().toString())); + rabbitMsgUtils.printTicket(String.valueOf(id)); +// rabbitTemplate.convertAndSend(RabbitConstants.PRINT_MECHINE_COLLECT_PUT, RabbitConstants.PRINT_MECHINE_COLLECT_ROUTINGKEY_PUT, id, new CorrelationData(UUID.randomUUID().toString())); } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java index 1164f3d9..d415e46d 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java @@ -711,6 +711,7 @@ public class TbShopTableServiceImpl implements TbShopTableService { @Override public TbOrderInfo createOrder(CreateOrderDTO createOrderDTO) { + String day = DateUtils.getDay(); LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper() .eq(TbCashierCart::getShopId, createOrderDTO.getShopId()) @@ -847,6 +848,9 @@ public class TbShopTableServiceImpl implements TbShopTableService { // 推送耗材信息 pushConsMsg(orderInfo, cashierCarts); + mpShopTableMapper.update(null, new LambdaUpdateWrapper() + .eq(TbShopTable::getQrcode, createOrderDTO.getTableId()) + .set(TbShopTable::getStatus, TableStateEnum.PENDING.getState())); return orderInfo; } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/utils/RabbitMsgUtils.java b/eladmin-system/src/main/java/cn/ysk/cashier/utils/RabbitMsgUtils.java index 8f0b7c22..ae7fd4cd 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/utils/RabbitMsgUtils.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/utils/RabbitMsgUtils.java @@ -28,19 +28,18 @@ public class RabbitMsgUtils implements RabbitTemplate.ConfirmCallback { } } - private void sendMsg(String exchange, String routingKey, T data, String note) { + private void sendMsg(String exchange, String routingKey, T data, String note, boolean isJson) { CorrelationData correlationId = new CorrelationData(UUID.randomUUID().toString()); log.info("开始发送{}mq消息, msgId: {}, exchange: {}, routingKey: {}, data: {}", correlationId.getId(), note, exchange, routingKey, data); - rabbitTemplate.convertAndSend(exchange, routingKey, JSONObject.toJSONString(data), correlationId); + rabbitTemplate.convertAndSend(exchange, routingKey, isJson ? JSONObject.toJSONString(data) : data, correlationId); } public void sendOrderCollectMsg(T data) { - sendMsg(RabbitConstants.CART_ORDER_COLLECT_PUT, RabbitConstants.CART_ORDER_COLLECT_ROUTINGKEY_PUT, data, "订单信息收集"); + sendMsg(RabbitConstants.CART_ORDER_COLLECT_PUT, RabbitConstants.CART_ORDER_COLLECT_ROUTINGKEY_PUT, data, "订单信息收集", true); } public void printTicket(String orderId){ - CorrelationData correlationId = new CorrelationData(UUID.randomUUID().toString()); - rabbitTemplate.convertAndSend(RabbitConstants.PRINT_MECHINE_COLLECT_PUT, RabbitConstants.PRINT_MECHINE_COLLECT_ROUTINGKEY_PUT, orderId, correlationId); + sendMsg(RabbitConstants.PRINT_MECHINE_COLLECT_PUT, RabbitConstants.PRINT_MECHINE_COLLECT_ROUTINGKEY_PUT, orderId, "打印票", false); } }