后付费多余的打印
This commit is contained in:
@@ -1,10 +1,12 @@
|
||||
package com.czg.mq;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.czg.config.RabbitConstants;
|
||||
import com.czg.config.RabbitPublisher;
|
||||
import com.czg.config.RedisCst;
|
||||
import com.czg.exception.CzgException;
|
||||
import com.czg.order.entity.MqLog;
|
||||
import com.czg.order.entity.SysPrintData;
|
||||
import com.czg.order.service.MqLogService;
|
||||
@@ -59,19 +61,33 @@ public class PrintMqListener {
|
||||
// 执行核心打印逻辑
|
||||
invokeFun(RabbitConstants.Queue.ORDER_MACHINE_PRINT_QUEUE, "orderPrint", "java.order", req, (data) -> {
|
||||
JSONObject jsonObject = JSONObject.parseObject(data);
|
||||
String orderId = jsonObject.getString("orderId");
|
||||
if (orderId == null) {
|
||||
String orderIdStr = jsonObject.getString("orderId");
|
||||
|
||||
if (StrUtil.isBlank(orderIdStr)) {
|
||||
throw new RuntimeException("订单打印失败,未传递orderId");
|
||||
}
|
||||
|
||||
String[] split = orderIdStr.split("_");
|
||||
if (split.length < 3) {
|
||||
throw new CzgException("订单ID格式不正确:" + orderIdStr);
|
||||
}
|
||||
|
||||
Long orderId = Long.parseLong(split[0]);
|
||||
//付费类型 0后付费/1先付费
|
||||
Integer payType = Integer.parseInt(split[1]);
|
||||
//订单状态 0未完成/1完成
|
||||
Integer orderStatus = Integer.parseInt(split[2]);
|
||||
//该字段表示 网络打印机是否打印订单 本地传参来的
|
||||
Boolean printOrder = jsonObject.getBoolean("printOrder");
|
||||
redisService.runFunAndCheckKey(() -> {
|
||||
if (printOrder) {
|
||||
printConfig.orderHandler(orderId, PrinterHandler.PrintTypeEnum.ORDER, null);
|
||||
}
|
||||
//菜品打印 全是后端
|
||||
printConfig.orderHandler(orderId, PrinterHandler.PrintTypeEnum.ALL_KITCHEN, null);
|
||||
printConfig.orderHandler(orderId, PrinterHandler.PrintTypeEnum.ONLY_KITCHEN, null);
|
||||
if (payType == 1 || orderStatus == 0) {
|
||||
//菜品打印 全是后端
|
||||
printConfig.orderHandler(orderId, PrinterHandler.PrintTypeEnum.ALL_KITCHEN, null);
|
||||
printConfig.orderHandler(orderId, PrinterHandler.PrintTypeEnum.ONLY_KITCHEN, null);
|
||||
}
|
||||
return null;
|
||||
}, RedisCst.getLockKey("orderPrint", orderId));
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user