打印 调整
This commit is contained in:
@@ -1,18 +1,14 @@
|
||||
package com.czg.service.order.print;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.text.UnicodeUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.http.HttpUtil;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.czg.account.dto.HandoverRecordDTO;
|
||||
import com.czg.account.entity.PrintMachine;
|
||||
import com.czg.account.entity.ShopInfo;
|
||||
import com.czg.order.entity.OrderDetail;
|
||||
import com.czg.order.entity.OrderInfo;
|
||||
import com.czg.service.order.enums.OrderStatusEnums;
|
||||
import com.czg.print.*;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.codec.digest.DigestUtils;
|
||||
import org.springframework.http.HttpEntity;
|
||||
@@ -22,9 +18,7 @@ import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.LinkedMultiValueMap;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -67,57 +61,71 @@ public class FeiPrinter extends PrinterHandler implements PrinterImpl {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void normalDishesPrint(String operator, OrderInfo orderInfo, OrderDetail orderDetail, PrintMachine machine) {
|
||||
String buildDishPrintData = buildDishPrintData(false, getPickupNum(orderInfo), DateUtil.format(orderDetail.getCreateTime(), "yyyy-MM-dd HH:mm:ss"), orderDetail.getProductName(), orderDetail.getSkuName(),
|
||||
orderDetail.getNum(), orderDetail.getRemark(), orderDetail.getProGroupInfo(), orderDetail.getId(), orderDetail.isUrgent());
|
||||
protected void onlyKitchenPrint(OrderInfo orderInfo, OrderDetail orderDetail, PrintMachine machine) {
|
||||
String buildDishPrintData = buildOnlyKitchenPrintData(getPickupNum(orderInfo), orderDetail);
|
||||
String voiceJson = "{\"bizType\":\"2\",\"content\":\"\"}";
|
||||
if (1 == machine.getVolumeSwitch()) {
|
||||
voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔新的订单,请及时处理\"}";
|
||||
}
|
||||
String resp = sendPrintRequest(machine.getAddress(), buildDishPrintData, voiceJson, "1");
|
||||
printMachineLogService.save(orderInfo.getId(), machine, "新订单", buildDishPrintData, resp);
|
||||
|
||||
String resp = sendPrintRequest(machine.getAddress(), buildDishPrintData, voiceJson, machine.getPrintNum() == null ? "1" : machine.getPrintNum().toString());
|
||||
printMachineLogService.save(orderInfo.getId(), machine, "后厨商品单", buildDishPrintData, resp);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void returnDishesPrint(String operator, OrderInfo orderInfo, OrderDetail orderDetail, PrintMachine machine) {
|
||||
String buildDishPrintData = buildDishPrintData(true, getPickupNum(orderInfo), DateUtil.format(orderDetail.getCreateTime(), "yyyy-MM-dd HH:mm:ss"), orderDetail.getProductName(), orderDetail.getSkuName(),
|
||||
orderDetail.getReturnNum(), orderDetail.getRemark(), orderDetail.getProGroupInfo(), orderDetail.getId(), orderDetail.isUrgent());
|
||||
public OrderPrintDTO allKitchenPrint(OrderInfo orderInfo, List<OrderDetail> orderDetails, PrintMachine machine) {
|
||||
OrderPrintDTO orderPrintDTO = super.allKitchenPrint(orderInfo, orderDetails, machine);
|
||||
String buildDishPrintData = buildAllKitchenPrintData(orderPrintDTO, orderDetails);
|
||||
String voiceJson = "{\"bizType\":\"2\",\"content\":\"\"}";
|
||||
String resp = sendPrintRequest(machine.getAddress(), buildDishPrintData, voiceJson, "1");
|
||||
printMachineLogService.save(orderInfo.getId(), machine, "厨房退菜", buildDishPrintData, resp);
|
||||
|
||||
if (1 == machine.getVolumeSwitch()) {
|
||||
voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔新的订单,请及时处理\"}";
|
||||
}
|
||||
String resp = sendPrintRequest(machine.getAddress(), buildDishPrintData, voiceJson, machine.getPrintNum() == null ? "1" : machine.getPrintNum().toString());
|
||||
printMachineLogService.save(orderInfo.getId(), machine, "后厨总单", buildDishPrintData, resp);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PrintInfoDTO returnOrderPrint(String printTitle,String operator, String refundAmount, String refundReason, String refundType,
|
||||
OrderInfo orderInfo, PrintMachine machine, List<OrderDetail> detailList) {
|
||||
PrintInfoDTO printInfoDTO = super.returnOrderPrint(printTitle,operator, refundAmount, refundReason, refundType, orderInfo, machine, detailList);
|
||||
String data = buildRefundOrderPrintData(printInfoDTO, detailList);
|
||||
public OrderPrintDTO returnKitchenPrint(String operator, OrderInfo orderInfo, List<OrderDetail> orderDetail, PrintMachine machine) {
|
||||
OrderPrintDTO orderPrintDTO = super.returnKitchenPrint(operator, orderInfo, orderDetail, machine);
|
||||
String buildDishPrintData = buildAllKitchenPrintData(orderPrintDTO, orderDetail);
|
||||
String voiceJson = "{\"bizType\":\"2\",\"content\":\"\"}";
|
||||
if (1 == machine.getVolumeSwitch()) {
|
||||
voiceJson = "{\"bizType\":\"2\",\"content\":\"退菜消息,请及时处理\"}";
|
||||
}
|
||||
String resp = sendPrintRequest(machine.getAddress(), buildDishPrintData, voiceJson, machine.getPrintNum() == null ? "1" : machine.getPrintNum().toString());
|
||||
printMachineLogService.save(orderInfo.getId(), machine, "后厨退菜", buildDishPrintData, resp);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public OrderPrintDTO returnOrderPrint(String printTitle, String operator, String refundAmount, String refundReason, String refundType,
|
||||
OrderInfo orderInfo, PrintMachine machine, List<OrderDetail> detailList) {
|
||||
OrderPrintDTO orderPrintDTO = super.returnOrderPrint(printTitle, operator, refundAmount, refundReason, refundType, orderInfo, machine, detailList);
|
||||
String data = buildRefundOrderPrintData(orderPrintDTO, detailList);
|
||||
sendOrderPrint(data, orderInfo.getId(), machine, "退款单");
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PrintInfoDTO guestOrderPrint(OrderInfo orderInfo, PrintMachine machine, List<OrderDetail> detailList) {
|
||||
PrintInfoDTO printInfoDTO = super.guestOrderPrint(orderInfo, machine, detailList);
|
||||
String data = buildGuestOrderPrintData(printInfoDTO, detailList);
|
||||
public OrderPrintDTO guestOrderPrint(OrderInfo orderInfo, PrintMachine machine, List<OrderDetail> detailList) {
|
||||
OrderPrintDTO orderPrintDTO = super.guestOrderPrint(orderInfo, machine, detailList);
|
||||
String data = buildGuestOrderPrintData(orderPrintDTO, detailList);
|
||||
sendOrderPrint(data, orderInfo.getId(), machine, "客看单");
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PrintInfoDTO preOrderPrint(OrderInfo orderInfo, PrintMachine machine, List<OrderDetail> detailList) {
|
||||
PrintInfoDTO printInfoDTO = super.preOrderPrint(orderInfo, machine, detailList);
|
||||
String data = buildOrderPrintData(printInfoDTO, detailList);
|
||||
public OrderPrintDTO preOrderPrint(OrderInfo orderInfo, PrintMachine machine, List<OrderDetail> detailList) {
|
||||
OrderPrintDTO orderPrintDTO = super.preOrderPrint(orderInfo, machine, detailList);
|
||||
String data = buildOrderPrintData(orderPrintDTO, detailList);
|
||||
sendOrderPrint(data, orderInfo.getId(), machine, "预结算单");
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PrintInfoDTO orderPrint(OrderInfo orderInfo, PrintMachine machine, List<OrderDetail> detailList) {
|
||||
PrintInfoDTO printInfoDTO = super.orderPrint(orderInfo, machine, detailList);
|
||||
String data = buildOrderPrintData(printInfoDTO, detailList);
|
||||
public OrderPrintDTO orderPrint(OrderInfo orderInfo, PrintMachine machine, List<OrderDetail> detailList) {
|
||||
OrderPrintDTO orderPrintDTO = super.orderPrint(orderInfo, machine, detailList);
|
||||
String data = buildOrderPrintData(orderPrintDTO, detailList);
|
||||
sendOrderPrint(data, orderInfo.getId(), machine, "结算单");
|
||||
|
||||
return null;
|
||||
@@ -130,15 +138,55 @@ public class FeiPrinter extends PrinterHandler implements PrinterImpl {
|
||||
voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一条新的排号记录\"}";
|
||||
}
|
||||
String data = buildCallTicketData(shopName, tableName, callNum, preNum, codeUrl, shopNote, takeTime);
|
||||
String resp = sendPrintRequest(machine.getAddress(), data, voiceJson, "1");
|
||||
String resp = sendPrintRequest(machine.getAddress(), data, voiceJson, machine.getPrintNum() == null ? "1" : machine.getPrintNum().toString());
|
||||
printMachineLogService.save(machine, "叫号单", data, resp);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void stockPrint(PrintMachine machine, StockPrintDTO record) {
|
||||
String voiceJson = "{\"bizType\":\"2\",\"content\":\"\"}";
|
||||
String data = buildStockData(record);
|
||||
String resp = sendPrintRequest(machine.getAddress(), data, voiceJson, machine.getPrintNum() == null ? "1" : machine.getPrintNum().toString());
|
||||
printMachineLogService.save(machine, "IN".equals(record.getType()) ? "入库单" : "出库单", data, resp);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void dayReportPrint(PrintMachine machine, DayReportPrintDTO record) {
|
||||
String voiceJson = "{\"bizType\":\"2\",\"content\":\"\"}";
|
||||
String data = buildDayReportData(record);
|
||||
String resp = sendPrintRequest(machine.getAddress(), data, voiceJson, machine.getPrintNum() == null ? "1" : machine.getPrintNum().toString());
|
||||
printMachineLogService.save(machine, "经营日报单", data, resp);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void productReportPrint(PrintMachine machine, ProductReportPrintDTO record) {
|
||||
String voiceJson = "{\"bizType\":\"2\",\"content\":\"\"}";
|
||||
String data = buildProductReportData(record);
|
||||
String resp = sendPrintRequest(machine.getAddress(), data, voiceJson, machine.getPrintNum() == null ? "1" : machine.getPrintNum().toString());
|
||||
printMachineLogService.save(machine, "商品报表单", data, resp);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void rechargePrint(PrintMachine machine, RechargePrintDTO record) {
|
||||
String voiceJson = "{\"bizType\":\"2\",\"content\":\"\"}";
|
||||
String data = buildRechargeData(record);
|
||||
String resp = sendPrintRequest(machine.getAddress(), data, voiceJson, machine.getPrintNum() == null ? "1" : machine.getPrintNum().toString());
|
||||
printMachineLogService.save(machine, "储值单", data, resp);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void stockCheckPrint(PrintMachine machine, StockCheckPrintDTO record) {
|
||||
String voiceJson = "{\"bizType\":\"2\",\"content\":\"\"}";
|
||||
String data = buildStockCheckData(record);
|
||||
String resp = sendPrintRequest(machine.getAddress(), data, voiceJson, machine.getPrintNum() == null ? "1" : machine.getPrintNum().toString());
|
||||
printMachineLogService.save(machine, "盘点单", data, resp);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void handoverPrint(PrintMachine machine, HandoverRecordDTO record) {
|
||||
String string = buildHandoverData(record);
|
||||
String voiceJson = "{\"bizType\":\"2\",\"content\":\"\"}";
|
||||
sendPrintRequest(machine.getAddress(), string, voiceJson, "1");
|
||||
sendPrintRequest(machine.getAddress(), string, voiceJson, machine.getPrintNum() == null ? "1" : machine.getPrintNum().toString());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -153,11 +201,7 @@ public class FeiPrinter extends PrinterHandler implements PrinterImpl {
|
||||
if (1 == machine.getVolumeSwitch()) {
|
||||
voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔新的订单,请及时处理\"}";
|
||||
}
|
||||
String printerNum = "1";
|
||||
if (StrUtil.isNotBlank(machine.getPrintQty())) {
|
||||
printerNum = machine.getPrintQty().split("\\^")[1];
|
||||
}
|
||||
String resp = sendPrintRequest(machine.getAddress(), data, voiceJson, printerNum);
|
||||
String resp = sendPrintRequest(machine.getAddress(), data, voiceJson, machine.getPrintNum() == null ? "1" : machine.getPrintNum().toString());
|
||||
printMachineLogService.save(orderId, machine, bizType, data, resp);
|
||||
}
|
||||
|
||||
@@ -244,20 +288,4 @@ public class FeiPrinter extends PrinterHandler implements PrinterImpl {
|
||||
}
|
||||
return msg;
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算优惠金额:优先使用 discountAllAmount,如果为 null 则用原价 - 实付计算
|
||||
*/
|
||||
private String calculateDiscountAmount(OrderInfo orderInfo) {
|
||||
if (orderInfo.getDiscountAllAmount() != null) {
|
||||
return orderInfo.getDiscountAllAmount().toPlainString();
|
||||
}
|
||||
// 兜底计算:原价 + 餐位费 + 打包费 - 实付
|
||||
BigDecimal originalTotal = orderInfo.getOriginAmount()
|
||||
.add(orderInfo.getSeatAmount() != null ? orderInfo.getSeatAmount() : BigDecimal.ZERO)
|
||||
.add(orderInfo.getPackFee() != null ? orderInfo.getPackFee() : BigDecimal.ZERO);
|
||||
BigDecimal discount = originalTotal.subtract(orderInfo.getPayAmount());
|
||||
return discount.compareTo(BigDecimal.ZERO) >= 0 ? discount.toPlainString() : "0.00";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,42 +1,56 @@
|
||||
package com.czg.service.order.print;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import com.czg.exception.CzgException;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Primary;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
|
||||
/**
|
||||
* 打印机责任链初始化
|
||||
*
|
||||
* @author Administrator
|
||||
*/
|
||||
@Slf4j
|
||||
@Configuration
|
||||
public class PrintConfig {
|
||||
|
||||
@Resource
|
||||
private List<PrinterHandler> printers;
|
||||
private ApplicationContext applicationContext;
|
||||
|
||||
// 直接使用实例变量,不需要静态
|
||||
private Map<String, PrinterHandler> printerMap;
|
||||
|
||||
// 初始化责任链
|
||||
@PostConstruct
|
||||
public void initChain() {
|
||||
// 检查打印处理器列表是否为空
|
||||
if (printers != null && !printers.isEmpty()) {
|
||||
for (int i = 0; i < printers.size() - 1; i++) {
|
||||
// 设置当前处理器的下一个处理器
|
||||
printers.get(i).setNextPrinter(printers.get(i + 1));
|
||||
public void init() {
|
||||
Map<String, PrinterHandler> printers = applicationContext.getBeansOfType(PrinterHandler.class);
|
||||
printerMap = new ConcurrentHashMap<>();
|
||||
|
||||
printers.forEach((beanName, printer) -> {
|
||||
String brand = printer.printerBrand;
|
||||
if (brand != null && !brand.trim().isEmpty()) {
|
||||
printerMap.put(brand, printer);
|
||||
}
|
||||
});
|
||||
|
||||
log.info("已注册打印机: {}", printerMap.keySet());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取打印机
|
||||
*/
|
||||
public PrinterHandler getPrinter(String key) {
|
||||
PrinterHandler printer = printerMap.get(key);
|
||||
if (printer == null) {
|
||||
throw new CzgException("未找到打印机: " + key);
|
||||
}
|
||||
return printer;
|
||||
}
|
||||
|
||||
@Bean
|
||||
@Primary
|
||||
public PrinterHandler printerHandler() {
|
||||
// 返回责任链的起始处理器
|
||||
return printers.getFirst();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.czg.service.order.print;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
@@ -9,6 +9,8 @@ import com.czg.account.dto.HandoverRecordDTO;
|
||||
import com.czg.account.dto.PrintOrderDetailDTO;
|
||||
import com.czg.account.entity.*;
|
||||
import com.czg.account.service.*;
|
||||
import com.czg.exception.CzgException;
|
||||
import com.czg.print.*;
|
||||
import com.czg.config.RedisCst;
|
||||
import com.czg.constants.ParamCodeCst;
|
||||
import com.czg.market.service.OrderInfoService;
|
||||
@@ -25,13 +27,11 @@ import com.czg.service.RedisService;
|
||||
import com.czg.service.order.enums.OrderStatusEnums;
|
||||
import com.czg.system.dto.SysParamsDTO;
|
||||
import com.czg.system.service.SysParamsService;
|
||||
import com.czg.utils.FunUtils;
|
||||
import com.mybatisflex.core.query.QueryWrapper;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.Data;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
import lombok.experimental.Accessors;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.dubbo.config.annotation.DubboReference;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
@@ -48,10 +48,9 @@ import java.util.stream.Collectors;
|
||||
@Slf4j
|
||||
@ToString
|
||||
public abstract class PrinterHandler {
|
||||
@Setter
|
||||
protected PrinterHandler nextPrinter;
|
||||
protected String printerBrand;
|
||||
|
||||
public String printerBrand;
|
||||
@Resource
|
||||
protected PrintConfig printConfig;
|
||||
@Resource
|
||||
protected RestTemplate restTemplate;
|
||||
@Resource
|
||||
@@ -88,157 +87,206 @@ public abstract class PrinterHandler {
|
||||
|
||||
@Getter
|
||||
public enum PrintTypeEnum {
|
||||
HANDOVER("交班", "handover"),
|
||||
GUEST_ORDER("客看单"),
|
||||
PRE_ORDER("预结算单"),
|
||||
ORDER("订单结算单"),
|
||||
RETURN_ORDER("退菜单"),
|
||||
REFUND_ORDER("退款单"),
|
||||
|
||||
ONE_AND_ORDER("菜品和结算单同时打印", "oneAndOrder"),
|
||||
PRE_ORDER("预结算单", "preOrder"),
|
||||
ORDER("订单结算单", "order"),
|
||||
GUEST_ORDER("客看单", "guestOrder"),
|
||||
ALL_KITCHEN("后厨整单"),
|
||||
ONLY_KITCHEN("后厨分单"),
|
||||
REFUND_KITCHEN("后厨退菜单"),
|
||||
|
||||
RETURN_FOOD("退菜", "returnFood"),
|
||||
RETURN_ORDER("退单", "returnOrder"),
|
||||
HANDOVER("交班单"),
|
||||
CALL("排队取号"),
|
||||
RECHARGE("储值单"),
|
||||
STOCK("出入库单"),
|
||||
STOCK_CHECK("盘点单"),
|
||||
PRODUCT_REPORT("商品报表"),
|
||||
DAY_REPORT("经营日报"),
|
||||
DAY_ORDER("日结单");
|
||||
|
||||
ONE("菜品", "one"),
|
||||
CALL("叫号", "call");
|
||||
private final String name;
|
||||
private final String code;
|
||||
|
||||
PrintTypeEnum(String name, String code) {
|
||||
PrintTypeEnum(String name) {
|
||||
this.name = name;
|
||||
this.code = code;
|
||||
}
|
||||
}
|
||||
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public static class PrintDetailInfo {
|
||||
private boolean isPrint;
|
||||
// private boolean isReturn;
|
||||
private long orderId;
|
||||
private long detailId;
|
||||
private BigDecimal printNum;
|
||||
private BigDecimal printReturnNum;
|
||||
}
|
||||
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public static class PrintInfoDTO {
|
||||
private long count;
|
||||
// 打印标题 结算单/客看单/预结算单 退菜单/退款单
|
||||
private String printTitle;
|
||||
private String shopName;
|
||||
//打印类型 收银-堂食
|
||||
private String printType;
|
||||
//台桌区域-台桌号
|
||||
private String pickupNum;
|
||||
private String orderNo;
|
||||
//结账时间
|
||||
private String tradeDate;
|
||||
//操作人名称
|
||||
private String operator;
|
||||
private String payAmount;
|
||||
private String originalAmount;
|
||||
//余额
|
||||
// private String balance;
|
||||
private String payType;
|
||||
private String remark;
|
||||
//取餐码
|
||||
private String outNumber;
|
||||
private String discountAmount;
|
||||
// private String discountRadio;
|
||||
// private String orderNum;
|
||||
private String seatNum;
|
||||
private String seatAmount;
|
||||
private String packFee;
|
||||
// 是否退款单
|
||||
private boolean isReturn;
|
||||
//退款单用
|
||||
private String refundAmount;
|
||||
//退款方式 现金退款/原路退回
|
||||
private String refundType;
|
||||
//退款原因
|
||||
private String refundReason;
|
||||
|
||||
}
|
||||
|
||||
public PrinterHandler(String printerBrand) {
|
||||
this.printerBrand = printerBrand;
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理订单打印
|
||||
*
|
||||
* @param data 传递的数据
|
||||
* @param printTypeEnum GUEST_ORDER ORDER PRE_ORDER ONLY_KITCHEN ALL_KITCHEN
|
||||
*/
|
||||
public void orderHandler(String data, PrintTypeEnum printTypeEnum, Integer placeNum) {
|
||||
OrderInfo orderInfo = orderInfoService.getById(data);
|
||||
if (orderInfo == null) {
|
||||
throw new RuntimeException("订单打印失败,订单不存在");
|
||||
}
|
||||
List<OrderDetail> orderDetailList = new ArrayList<>();
|
||||
orderDetailList = switch (printTypeEnum) {
|
||||
case PrintTypeEnum.GUEST_ORDER -> {
|
||||
orderInfo.setPlaceNum(placeNum);
|
||||
yield orderDetailService.list(new QueryWrapper().eq(OrderDetail::getOrderId, orderInfo.getId()).eq(OrderDetail::getPlaceNum, placeNum));
|
||||
}
|
||||
case PrintTypeEnum.ORDER, PrintTypeEnum.PRE_ORDER, PrintTypeEnum.ONLY_KITCHEN, PrintTypeEnum.ALL_KITCHEN ->
|
||||
orderDetailService.list(new QueryWrapper().eq(OrderDetail::getOrderId, orderInfo.getId()));
|
||||
default -> orderDetailList;
|
||||
};
|
||||
for (PrintMachine machine : getPrintMachine(orderInfo.getShopId(), printTypeEnum)) {
|
||||
PrinterHandler printer = printConfig.getPrinter(machine.getBrand());
|
||||
redisService.set("order:print:" + orderInfo.getId(), "", 180);
|
||||
switch (printTypeEnum) {
|
||||
case PrintTypeEnum.GUEST_ORDER:
|
||||
log.info("准备开始打印客看订单");
|
||||
printer.guestOrderPrint(orderInfo, machine, orderDetailList);
|
||||
break;
|
||||
case PrintTypeEnum.ORDER:
|
||||
log.info("准备开始打印订单");
|
||||
printer.orderPrint(machine, orderInfo, orderDetailList);
|
||||
|
||||
break;
|
||||
case PrintTypeEnum.PRE_ORDER:
|
||||
log.info("准备开始打印预结算订单");
|
||||
printer.preOrderPrint(machine, orderInfo, orderDetailList);
|
||||
break;
|
||||
case PrintTypeEnum.ONLY_KITCHEN:
|
||||
// 判断订单是否是先付费或者已结算
|
||||
if (!"after-pay".equals(orderInfo.getPayMode()) && (OrderStatusEnums.UNPAID.getCode().equals(orderInfo.getStatus()) || OrderStatusEnums.CANCELLED.getCode().equals(orderInfo.getStatus()))) {
|
||||
log.warn("此订单未支付, 订单信息: {}", orderInfo.getId());
|
||||
}
|
||||
List<OrderDetail> tbOrderDetailList = getCanPrintOrderDetails(machine, orderInfo.getId(), orderDetailList);
|
||||
if (CollUtil.isEmpty(tbOrderDetailList)) {
|
||||
log.info("此订单无打印菜品, 订单信息: {}", orderInfo.getId());
|
||||
break;
|
||||
}
|
||||
log.info("准备开始打印菜品单");
|
||||
//后厨单菜品
|
||||
tbOrderDetailList.forEach(item -> {
|
||||
Boolean b = redisService.hasKey(RedisCst.kitchenNormal(orderInfo.getId(), machine.getId(), item.getId()));
|
||||
if (!b) {
|
||||
FunUtils.safeRunVoid(() -> onlyKitchenPrint(orderInfo, item, machine),
|
||||
"订单id:{} ,后厨分单打印失败", orderInfo.getId());
|
||||
// 保存已打印信息
|
||||
redisService.set(RedisCst.kitchenNormal(orderInfo.getId(), machine.getId(), item.getId()), "", 180);
|
||||
}
|
||||
});
|
||||
break;
|
||||
case PrintTypeEnum.ALL_KITCHEN:
|
||||
Boolean exit = redisService.hasKey(RedisCst.kitchenAll(orderInfo.getId(), machine.getId()));
|
||||
if (exit) {
|
||||
break;
|
||||
}
|
||||
// 判断订单是否是先付费或者已结算
|
||||
if (!"after-pay".equals(orderInfo.getPayMode()) && (OrderStatusEnums.UNPAID.getCode().equals(orderInfo.getStatus()) || OrderStatusEnums.CANCELLED.getCode().equals(orderInfo.getStatus()))) {
|
||||
log.warn("此订单未支付, 订单信息: {}", orderInfo.getId());
|
||||
}
|
||||
List<OrderDetail> allOrderDetailList = getCanPrintOrderDetails(machine, orderInfo.getId(), orderDetailList);
|
||||
if (CollUtil.isEmpty(allOrderDetailList)) {
|
||||
log.info("此订单无打印菜品, 订单信息: {}", orderInfo.getId());
|
||||
break;
|
||||
}
|
||||
log.info("准备开始打印后厨整单");
|
||||
printer.allKitchenPrint(orderInfo, allOrderDetailList, machine);
|
||||
redisService.set(RedisCst.kitchenAll(orderInfo.getId(), machine.getId()), "", 180);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理其它打印
|
||||
*
|
||||
* @param data 传递的数据
|
||||
* @param printTypeEnum IN_STOCK DAY_REPORT PRODUCT_REPORT RECHARGE STOCK_CHECK
|
||||
*/
|
||||
public void otherHandler(Long shopId, Object data, PrintTypeEnum printTypeEnum) {
|
||||
if (shopId == null || Objects.isNull(data)) {
|
||||
log.info("otherHandler 打印数据为空, shopId: {}, data: {}", shopId, data);
|
||||
return;
|
||||
}
|
||||
switch (printTypeEnum) {
|
||||
case PrintTypeEnum.STOCK:
|
||||
getPrintMachine(shopId, printTypeEnum)
|
||||
.forEach(machine -> printConfig.getPrinter(machine.getBrand()).stockPrint(machine, (StockPrintDTO) data));
|
||||
break;
|
||||
case PrintTypeEnum.DAY_REPORT:
|
||||
getPrintMachine(shopId, printTypeEnum)
|
||||
.forEach(machine -> printConfig.getPrinter(machine.getBrand()).dayReportPrint(machine, (DayReportPrintDTO) data));
|
||||
break;
|
||||
case PrintTypeEnum.PRODUCT_REPORT:
|
||||
getPrintMachine(shopId, printTypeEnum)
|
||||
.forEach(machine -> printConfig.getPrinter(machine.getBrand()).productReportPrint(machine, (ProductReportPrintDTO) data));
|
||||
break;
|
||||
case PrintTypeEnum.RECHARGE:
|
||||
getPrintMachine(shopId, printTypeEnum)
|
||||
.forEach(machine -> printConfig.getPrinter(machine.getBrand()).rechargePrint(machine, (RechargePrintDTO) data));
|
||||
break;
|
||||
case PrintTypeEnum.STOCK_CHECK:
|
||||
getPrintMachine(shopId, printTypeEnum)
|
||||
.forEach(machine -> printConfig.getPrinter(machine.getBrand()).stockCheckPrint(machine, (StockCheckPrintDTO) data));
|
||||
break;
|
||||
case PrintTypeEnum.HANDOVER:
|
||||
log.info("准备开始打印交班");
|
||||
getPrintMachine(shopId, printTypeEnum)
|
||||
.forEach(machine -> printConfig.getPrinter(machine.getBrand()).handoverPrint(machine, (HandoverRecordDTO) data));
|
||||
break;
|
||||
case PrintTypeEnum.CALL:
|
||||
log.info("准备开始打印叫号单");
|
||||
getPrintMachine(shopId, printTypeEnum)
|
||||
.forEach(machine -> printConfig.getPrinter(machine.getBrand()).callNumPrintBefore(machine, (CallQueue) data));
|
||||
break;
|
||||
default:
|
||||
throw new CzgException("otherHandler 未知打印类型");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取可用打印机
|
||||
*
|
||||
* @param shopId 店铺id
|
||||
* @param subType 打印类型(分类)label标签 cash小票 kitchen出品
|
||||
* @param printMethod 打印方式 all-全部打印 normal-仅打印结账单「前台」one-仅打印制作单「厨房」
|
||||
* @param printType 打印类型,JSON数组 refund-确认退款单 handover-交班单 queue-排队取号
|
||||
* @param contentType GUEST_ORDER("客看单"),
|
||||
* PRE_ORDER("预结算单"),
|
||||
* ORDER("订单结算单"),
|
||||
* RETURN_ORDER("退菜单"),
|
||||
* REFUND_ORDER("退款单"),
|
||||
* <p>
|
||||
* ALL_KITCHEN("后厨整单"),
|
||||
* ONLY_KITCHEN("后厨分单"),
|
||||
* REFUND_KITCHEN("后厨退菜单"),
|
||||
* <p>
|
||||
* HANDOVER("交班单"),
|
||||
* CALL("排队取号"),
|
||||
* RECHARGE("储值单"),
|
||||
* STOCK("出入库单"),
|
||||
* STOCK_CHECK("盘点单"),
|
||||
* PRODUCT_REPORT("商品报表"),
|
||||
* DAY_REPORT("经营日报"),
|
||||
* DAY_ORDER("日结单");
|
||||
* @return 打印机列表
|
||||
*/
|
||||
private List<PrintMachine> getPrintMachine(Long shopId, String subType, String printMethod, String printType) {
|
||||
private List<PrintMachine> getPrintMachine(Long shopId, PrintTypeEnum contentType) {
|
||||
QueryWrapper wrapper = new QueryWrapper()
|
||||
.eq(PrintMachine::getStatus, 1)
|
||||
.eq(PrintMachine::getShopId, shopId)
|
||||
.eq(PrintMachine::getSubType, subType)
|
||||
.eq(PrintMachine::getConnectionType, "网络");
|
||||
|
||||
if (StrUtil.isNotEmpty(printMethod)) {
|
||||
List<String> arrayList = switch (printMethod) {
|
||||
case "all" -> Arrays.asList("one", "normal", "all");
|
||||
case "one" -> Arrays.asList("one", "all");
|
||||
case "normal" -> Arrays.asList("normal", "all");
|
||||
default -> new ArrayList<>();
|
||||
};
|
||||
if (!arrayList.isEmpty()) {
|
||||
wrapper.in(PrintMachine::getPrintMethod, arrayList);
|
||||
}
|
||||
}
|
||||
if ("callTicket".equals(printType)) {
|
||||
printType = "queue";
|
||||
}
|
||||
if (StrUtil.isNotEmpty(printType)) {
|
||||
wrapper.like(PrintMachine::getPrintType, printType);
|
||||
}
|
||||
.eq(PrintMachine::getPrintType, "cash")
|
||||
.like(PrintMachine::getPrintContentType, contentType)
|
||||
.eq(PrintMachine::getConnectionType, "云打印");
|
||||
List<PrintMachine> list = printMachineService.list(wrapper);
|
||||
if (list.isEmpty()) {
|
||||
log.error("店铺未配置打印机,店铺id: {}", shopId);
|
||||
return list;
|
||||
}
|
||||
|
||||
log.info("打印机列表: {}", list);
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理订单打印
|
||||
*
|
||||
* @param data 传递的数据
|
||||
* @param printTypeEnum order preOrder one
|
||||
*/
|
||||
public void orderHandler(String data, PrintTypeEnum printTypeEnum, Integer placeNum) {
|
||||
String printMethod;
|
||||
OrderInfo orderInfo = orderInfoService.getById(data);
|
||||
if (orderInfo == null) {
|
||||
throw new RuntimeException("订单打印失败,订单不存在");
|
||||
}
|
||||
switch (printTypeEnum) {
|
||||
case PrintTypeEnum.GUEST_ORDER:
|
||||
case PrintTypeEnum.PRE_ORDER:
|
||||
case PrintTypeEnum.ORDER:
|
||||
printMethod = "normal";
|
||||
break;
|
||||
case PrintTypeEnum.ONE:
|
||||
printMethod = "one";
|
||||
break;
|
||||
case PrintTypeEnum.ONE_AND_ORDER:
|
||||
printMethod = "all";
|
||||
break;
|
||||
default:
|
||||
throw new RuntimeException("未知打印类型");
|
||||
}
|
||||
getPrintMachine(orderInfo.getShopId(), "cash", printMethod, "").forEach(machine -> {
|
||||
handleRequest(machine, placeNum, orderInfo, printTypeEnum);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理退菜退款订单打印
|
||||
@@ -253,269 +301,69 @@ public abstract class PrinterHandler {
|
||||
*/
|
||||
public void refundOrderHandler(String printTitle, String operator, String refundAmount, String refundReason, String refundType,
|
||||
OrderInfo orderInfo, List<OrderDetail> detailList) {
|
||||
getPrintMachine(orderInfo.getShopId(), "cash", "normal", "").forEach(machine -> {
|
||||
refundHandleRequest(machine, printTitle, operator, refundAmount, refundReason, refundType, orderInfo, detailList);
|
||||
//前台退菜单
|
||||
if ("退菜单".equals(printTitle)) {
|
||||
getPrintMachine(orderInfo.getShopId(), PrintTypeEnum.RETURN_ORDER).forEach(machine ->
|
||||
printConfig.getPrinter(machine.getBrand()).returnOrderPrint(printTitle, operator, refundAmount, refundReason, refundType, orderInfo, machine, detailList));
|
||||
} else if ("退款单".equals(printTitle)) {
|
||||
getPrintMachine(orderInfo.getShopId(), PrintTypeEnum.REFUND_ORDER).forEach(machine ->
|
||||
printConfig.getPrinter(machine.getBrand()).returnOrderPrint(printTitle, operator, refundAmount, refundReason, refundType, orderInfo, machine, detailList));
|
||||
} else {
|
||||
log.error("未知的前台退款打印类型: {}", printTitle);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理退菜退款订单打印
|
||||
*/
|
||||
public void kitchenRefundAllHandler(String operator, OrderInfo orderInfo, List<OrderDetail> detailList) {
|
||||
//后厨退菜单
|
||||
getPrintMachine(orderInfo.getShopId(), PrintTypeEnum.REFUND_KITCHEN).forEach(machine -> {
|
||||
Boolean isPrint = redisService.hasKey(RedisCst.kitchenRefundAll(orderInfo.getId(), machine.getId()));
|
||||
if (!isPrint) {
|
||||
printConfig.getPrinter(machine.getBrand()).returnKitchenPrint(operator, orderInfo, detailList, machine);
|
||||
redisService.set(RedisCst.kitchenRefundAll(orderInfo.getId(), machine.getId()), "", 180);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 叫号打印
|
||||
*
|
||||
* @param data 传递的数据
|
||||
*/
|
||||
public void callHandler(String data) {
|
||||
|
||||
CallQueue queue = callQueueService.getById(data);
|
||||
if (queue == null) {
|
||||
throw new RuntimeException("叫号信息不存在: " + data);
|
||||
protected List<OrderDetail> getCanPrintOrderDetails(PrintMachine machine, Long orderId, List<OrderDetail> tbOrderDetailList) {
|
||||
Set<Long> canPrintProSet = new HashSet<>();
|
||||
boolean partPrint = false;
|
||||
if ("1".equals(machine.getClassifyPrint())) {
|
||||
partPrint = true;
|
||||
List categoryIds = JSONObject.parseObject(StrUtil.emptyToDefault(machine.getCategoryIds(), "[]"), List.class);
|
||||
if (CollUtil.isEmpty(categoryIds)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
List<Long> productIds = tbOrderDetailList.stream().map(OrderDetail::getProductId).collect(Collectors.toList());
|
||||
canPrintProSet = productService.list(new QueryWrapper()
|
||||
.in(Product::getCategoryId, categoryIds)
|
||||
.in(Product::getId, productIds))
|
||||
.stream()
|
||||
.map(Product::getId)
|
||||
.collect(Collectors.toSet());
|
||||
}
|
||||
Long shopId = queue.getShopId();
|
||||
if (shopId == null) {
|
||||
throw new RuntimeException("店铺不存在, id:" + shopId);
|
||||
}
|
||||
getPrintMachine(shopId, "cash", "", "queue").forEach(machine -> handleRequest(machine, null, queue, PrintTypeEnum.CALL));
|
||||
}
|
||||
|
||||
/**
|
||||
* 交班打印
|
||||
*
|
||||
* @param data 传递的数据
|
||||
*/
|
||||
public void handoverHandler(String data) {
|
||||
HandoverRecordDTO record = handoverRecordService.getHandoverRecordById(Long.parseLong(data));
|
||||
if (record == null) {
|
||||
throw new RuntimeException("交班票打印失败,交班记录不存在");
|
||||
}
|
||||
Long shopId = record.getShopId();
|
||||
if (shopId == null) {
|
||||
throw new RuntimeException("店铺不存在, id:" + shopId);
|
||||
}
|
||||
getPrintMachine(shopId, "cash", "", "handover").forEach(machine -> handleRequest(machine, null, record, PrintTypeEnum.HANDOVER));
|
||||
}
|
||||
|
||||
private void handleRequest(PrintMachine machine, Integer placeNum, Object data, PrintTypeEnum printTypeEnum) {
|
||||
if (canHandleRequest(machine.getContentType(), machine.getConnectionType())) {
|
||||
log.info("打印机: {}, 传递信息: {}", machine.getName(), data);
|
||||
print(machine, placeNum, data, printTypeEnum);
|
||||
} else if (nextPrinter != null) {
|
||||
log.info("当前打印机无法处理: {},将请求传递给下一个打印机:{}...", this.printerBrand, nextPrinter.printerBrand);
|
||||
nextPrinter.handleRequest(machine, placeNum, data, printTypeEnum);
|
||||
} else {
|
||||
log.warn("未找到匹配打印机");
|
||||
}
|
||||
}
|
||||
|
||||
private void refundHandleRequest(PrintMachine machine, String printTitle, String operator, String refundAmount, String refundReason, String refundType,
|
||||
OrderInfo orderInfo, List<OrderDetail> detailList) {
|
||||
if (canHandleRequest(machine.getContentType(), machine.getConnectionType())) {
|
||||
log.info("退款打印机: {}, 传递信息: {}", machine.getName(), orderInfo.getId());
|
||||
returnOrderPrint(printTitle, operator, refundAmount, refundReason, refundType, orderInfo, machine, detailList);
|
||||
} else if (nextPrinter != null) {
|
||||
log.info("当前打印机无法处理: {},将请求传递给下一个打印机:{}...", this.printerBrand, nextPrinter.printerBrand);
|
||||
nextPrinter.refundHandleRequest(machine, printTitle, operator, refundAmount, refundReason, refundType, orderInfo, detailList);
|
||||
} else {
|
||||
log.warn("未找到匹配打印机");
|
||||
}
|
||||
}
|
||||
|
||||
boolean canHandleRequest(String currentBrand, String connectType) {
|
||||
log.info("handle判断是否可处理: {}, 连接类型: {}, handler类型: {}", currentBrand, connectType, printerBrand);
|
||||
if (StrUtil.isBlank(printerBrand)) {
|
||||
throw new RuntimeException("打印机品牌未赋值");
|
||||
}
|
||||
return printerBrand.equals(currentBrand) && "网络".equals(connectType);
|
||||
}
|
||||
|
||||
protected List<OrderDetail> getCanPrintOrderDetails(boolean partPrint, Long orderId, List<OrderDetail> tbOrderDetailList, List<?> categoryIds) {
|
||||
List<Long> productIds = tbOrderDetailList.stream().map(OrderDetail::getProductId).collect(Collectors.toList());
|
||||
|
||||
Map<Long, Boolean> canPrintProMap = categoryIds.isEmpty() ? new HashMap<>() :
|
||||
productService.list(new QueryWrapper().in(Product::getCategoryId, categoryIds).in(Product::getId, productIds))
|
||||
.stream().collect(Collectors.toMap(Product::getId, i -> true));
|
||||
|
||||
ArrayList<OrderDetail> orderDetails = new ArrayList<>();
|
||||
tbOrderDetailList.forEach(item -> {
|
||||
Object o = redisService.get(RedisCst.getPrintOrderDetailKey(orderId, item.getId()));
|
||||
|
||||
if (item.getIsPrint() != null && item.getIsPrint() == 1 && (canPrintProMap.get(item.getProductId()) != null || !partPrint)) {
|
||||
item.setReturnNum(item.getReturnNum() == null ? BigDecimal.ZERO : item.getReturnNum());
|
||||
PrintDetailInfo printDetailInfo = o != null ? JSONObject.parseObject((String) o, PrintDetailInfo.class) : null;
|
||||
if (printDetailInfo != null) {
|
||||
if (item.getNum().compareTo(BigDecimal.ZERO) != 0 && item.getNum().compareTo(printDetailInfo.getPrintNum()) <= 0) {
|
||||
log.info("此菜品已打印, {} {} {}", item.getProductName(), item.getSkuName(), printDetailInfo);
|
||||
}
|
||||
|
||||
if (item.getReturnNum().compareTo(BigDecimal.ZERO) != 0 && item.getReturnNum().compareTo(printDetailInfo.getPrintReturnNum()) <= 0) {
|
||||
log.info("此退菜菜品已打印, {} {} {}", item.getProductName(), item.getSkuName(), printDetailInfo);
|
||||
}
|
||||
item.setNum(item.getNum().subtract(printDetailInfo.getPrintNum()));
|
||||
item.setReturnNum(item.getReturnNum().subtract(printDetailInfo.getPrintReturnNum()));
|
||||
orderDetails.add(item);
|
||||
} else {
|
||||
orderDetails.add(item);
|
||||
}
|
||||
|
||||
|
||||
for (OrderDetail item : tbOrderDetailList) {
|
||||
//-999 台位费
|
||||
if (item.getNum().compareTo(BigDecimal.ZERO) <= 0 || item.getProductId().equals(-999L)) {
|
||||
continue;
|
||||
}
|
||||
Boolean isPrint = redisService.hasKey(RedisCst.kitchenNormal(orderId, machine.getId(), item.getId()));
|
||||
if (isPrint) {
|
||||
continue;
|
||||
}
|
||||
if (item.getIsPrint() != null && item.getIsPrint() == 1 && (!partPrint || canPrintProSet.contains(item.getProductId()))) {
|
||||
orderDetails.add(item);
|
||||
} else {
|
||||
log.info("此菜品不在打印分类或属于免打, {} {} {}", item.getProductName(), item.getSkuName(), item.getId());
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
return orderDetails;
|
||||
}
|
||||
|
||||
|
||||
protected void print(PrintMachine machine, Integer placeNum, Object data, PrintTypeEnum printTypeEnum) {
|
||||
switch (printTypeEnum) {
|
||||
case PrintTypeEnum.HANDOVER:
|
||||
log.info("准备开始打印交班");
|
||||
if (data instanceof HandoverRecordDTO record) {
|
||||
handoverPrint(machine, record);
|
||||
} else {
|
||||
throw new RuntimeException("传递数据类型有误");
|
||||
}
|
||||
break;
|
||||
case PrintTypeEnum.GUEST_ORDER:
|
||||
log.info("准备开始打印客看订单");
|
||||
if (data instanceof OrderInfo orderInfo) {
|
||||
orderInfo.setPlaceNum(placeNum);
|
||||
List<OrderDetail> orderDetailList = orderDetailService.list(new QueryWrapper().eq(OrderDetail::getOrderId, orderInfo.getId()).eq(OrderDetail::getPlaceNum, placeNum));
|
||||
guestOrderPrint(orderInfo, machine, orderDetailList);
|
||||
} else {
|
||||
throw new RuntimeException("传递数据类型有误");
|
||||
}
|
||||
break;
|
||||
case PrintTypeEnum.ORDER:
|
||||
log.info("准备开始打印订单");
|
||||
if (data instanceof OrderInfo orderInfo) {
|
||||
redisService.set("order:print:" + orderInfo.getId(), "", 180);
|
||||
List<OrderDetail> orderDetailList = orderDetailService.list(new QueryWrapper().eq(OrderDetail::getOrderId, orderInfo.getId()));
|
||||
orderPrint(machine, orderInfo, orderDetailList);
|
||||
} else {
|
||||
throw new RuntimeException("传递数据类型有误");
|
||||
}
|
||||
break;
|
||||
case PrintTypeEnum.PRE_ORDER:
|
||||
log.info("准备开始打印预结算订单");
|
||||
if (data instanceof OrderInfo orderInfo) {
|
||||
redisService.set("order:print:" + orderInfo.getId(), "", 180);
|
||||
List<OrderDetail> orderDetailList = orderDetailService.list(new QueryWrapper().eq(OrderDetail::getOrderId, orderInfo.getId()));
|
||||
preOrderPrint(machine, orderInfo, orderDetailList);
|
||||
} else {
|
||||
throw new RuntimeException("传递数据类型有误");
|
||||
}
|
||||
break;
|
||||
case PrintTypeEnum.ONE:
|
||||
log.info("准备开始打印菜品单");
|
||||
if (data instanceof OrderInfo orderInfo) {
|
||||
redisService.set("order:print:" + orderInfo.getId(), "", 180);
|
||||
List<OrderDetail> orderDetailList = orderDetailService.list(new QueryWrapper().eq(OrderDetail::getOrderId, orderInfo.getId()));
|
||||
onlyKitchen(machine, orderInfo, orderDetailList);
|
||||
} else {
|
||||
throw new RuntimeException("传递数据类型有误");
|
||||
}
|
||||
break;
|
||||
case PrintTypeEnum.CALL:
|
||||
log.info("准备开始打印叫号单");
|
||||
if (data instanceof CallQueue queue) {
|
||||
onlyCallNumPrint(machine, queue);
|
||||
} else {
|
||||
throw new RuntimeException("传递数据类型有误");
|
||||
}
|
||||
break;
|
||||
case PrintTypeEnum.ONE_AND_ORDER:
|
||||
log.info("准备开始打印菜品以及结算单");
|
||||
if (data instanceof OrderInfo orderInfo) {
|
||||
redisService.set("order:print:" + orderInfo.getId(), "", 180);
|
||||
List<OrderDetail> orderDetailList = orderDetailService.list(new QueryWrapper().eq(OrderDetail::getOrderId, orderInfo.getId()));
|
||||
switch (machine.getPrintMethod()) {
|
||||
case "all":
|
||||
orderPrint(machine, orderInfo, orderDetailList);
|
||||
onlyKitchen(machine, orderInfo, orderDetailList);
|
||||
break;
|
||||
case "one":
|
||||
log.info("打印机仅打印one");
|
||||
onlyKitchen(machine, orderInfo, orderDetailList);
|
||||
break;
|
||||
case "normal":
|
||||
log.info("打印机仅打印normal");
|
||||
orderPrint(machine, orderInfo, orderDetailList);
|
||||
break;
|
||||
default:
|
||||
throw new RuntimeException("打印方法有误");
|
||||
}
|
||||
} else {
|
||||
throw new RuntimeException("传递数据类型有误");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 仅打印制作单「厨房」
|
||||
*/
|
||||
private void onlyKitchen(PrintMachine machine, OrderInfo orderInfo, List<OrderDetail> tbOrderDetailList) {
|
||||
// 判断订单是否是先付费或者已结算
|
||||
if (!"after-pay".equals(orderInfo.getPayMode()) && (OrderStatusEnums.UNPAID.getCode().equals(orderInfo.getStatus()) || OrderStatusEnums.CANCELLED.getCode().equals(orderInfo.getStatus()))) {
|
||||
log.warn("此订单未支付, 订单信息: {}", orderInfo);
|
||||
}
|
||||
|
||||
List<?> categoryIds = JSONObject.parseObject(StrUtil.emptyToDefault(machine.getCategoryIds(), "[]"), List.class);
|
||||
if (StrUtil.isEmpty(machine.getClassifyPrint())) {
|
||||
log.error("分类打印是空, classifyPrint: {}", machine.getClassifyPrint());
|
||||
return;
|
||||
}
|
||||
|
||||
// 已打印详情信息
|
||||
Map<Long, OrderDetail> detailMap = tbOrderDetailList.stream().map(item -> BeanUtil.copyProperties(item, OrderDetail.class)).collect(Collectors.toMap(OrderDetail::getId, i -> i));
|
||||
tbOrderDetailList = getCanPrintOrderDetails("1".equals(machine.getClassifyPrint()), orderInfo.getId(), tbOrderDetailList, categoryIds);
|
||||
tbOrderDetailList.parallelStream().filter(o -> ObjectUtil.defaultIfNull(o.getIsPrint(), 0) == 1).forEach(item -> {
|
||||
if (item.getNum().compareTo(BigDecimal.ZERO) <= 0 && item.getReturnNum().compareTo(BigDecimal.ZERO) <= 0) {
|
||||
return;
|
||||
}
|
||||
Integer isWaitCall = ObjectUtil.defaultIfNull(item.getIsWaitCall(), 0);
|
||||
if (isWaitCall == 1) {
|
||||
if (!item.getProductName().contains("【等叫】")) {
|
||||
item.setProductName("【等叫】" + item.getProductName());
|
||||
}
|
||||
}
|
||||
Integer isTemporary = ObjectUtil.defaultIfNull(item.getIsTemporary(), 0);
|
||||
if (isTemporary == 1) {
|
||||
item.setProductId(0L);
|
||||
item.setSkuId(0L);
|
||||
if (!item.getProductName().contains("【临】")) {
|
||||
item.setProductName("【临】" + item.getProductName());
|
||||
}
|
||||
}
|
||||
boolean isGift = item.getIsGift() != null && item.getIsGift() == 1;
|
||||
if (isGift && !item.getProductName().contains("【赠】")) {
|
||||
item.setProductName("【赠】" + item.getProductName());
|
||||
}
|
||||
// 台位费不打印
|
||||
if (item.getProductId().equals(-999L)) {
|
||||
log.info("台位费商品,不打印");
|
||||
return;
|
||||
}
|
||||
|
||||
if (item.getReturnNum().compareTo(BigDecimal.ZERO) > 0) {
|
||||
returnDishesPrint("操作人名称", orderInfo, item, machine);
|
||||
}
|
||||
|
||||
if (item.getNum().compareTo(BigDecimal.ZERO) > 0) {
|
||||
normalDishesPrint("操作人名称", orderInfo, item, machine);
|
||||
}
|
||||
|
||||
// 保存已打印信息
|
||||
OrderDetail orderDetail = detailMap.get(item.getId());
|
||||
redisService.set(RedisCst.getPrintOrderDetailKey(orderInfo.getId(), item.getId()),
|
||||
JSONObject.toJSONString(new PrintDetailInfo().setPrint(item.getIsPrint() == 1).setDetailId(item.getId())
|
||||
.setPrintNum(orderDetail.getNum()).setPrintReturnNum(orderDetail.getReturnNum())), 3600 * 24);
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 打印预结算单「前台」
|
||||
*/
|
||||
@@ -617,7 +465,7 @@ public abstract class PrinterHandler {
|
||||
/**
|
||||
* 打印排队小票
|
||||
*/
|
||||
private void onlyCallNumPrint(PrintMachine machine, CallQueue queue) {
|
||||
private void callNumPrintBefore(PrintMachine machine, CallQueue queue) {
|
||||
if (queue == null) {
|
||||
log.warn("叫号记录不存在");
|
||||
return;
|
||||
@@ -648,26 +496,26 @@ public abstract class PrinterHandler {
|
||||
}
|
||||
|
||||
|
||||
public PrintInfoDTO returnOrderPrint(String printTitle, String operator, String refundAmount, String refundReason, String refundType,
|
||||
OrderInfo orderInfo, PrintMachine machine, List<OrderDetail> detailList) {
|
||||
public OrderPrintDTO returnOrderPrint(String printTitle, String operator, String refundAmount, String refundReason, String refundType,
|
||||
OrderInfo orderInfo, PrintMachine machine, List<OrderDetail> detailList) {
|
||||
ShopInfo shopInfo = shopInfoService.getById(orderInfo.getShopId());
|
||||
PrintInfoDTO printInfoDTO = new PrintInfoDTO().setShopName(shopInfo.getShopName()).setPrintType("收银-堂食")
|
||||
OrderPrintDTO orderPrintDTO = new OrderPrintDTO().setShopName(shopInfo.getShopName()).setPrintType("收银-堂食")
|
||||
.setOrderNo(orderInfo.getOrderNo())
|
||||
.setTradeDate(DateUtil.format(orderInfo.getCreateTime(), "yyyy/MM/dd HH:mm:ss"))
|
||||
.setOperator(operator)
|
||||
.setReturn(true)
|
||||
.setPrintTitle(printTitle);
|
||||
printInfoDTO.setSeatNum(orderInfo.getSeatNum() == null ? "" : orderInfo.getSeatNum().toString());
|
||||
printInfoDTO.setPickupNum(orderInfo.getTableName());
|
||||
printInfoDTO.setRefundAmount(refundAmount);
|
||||
printInfoDTO.setRefundReason(refundReason);
|
||||
printInfoDTO.setRefundType("cash".equals(refundType) ? "线下退款" : "原路退回");
|
||||
return printInfoDTO;
|
||||
orderPrintDTO.setSeatNum(orderInfo.getSeatNum() == null ? "" : orderInfo.getSeatNum().toString());
|
||||
orderPrintDTO.setPickupNum(orderInfo.getTableName());
|
||||
orderPrintDTO.setRefundAmount(refundAmount);
|
||||
orderPrintDTO.setRefundReason(refundReason);
|
||||
orderPrintDTO.setRefundType("cash".equals(refundType) ? "线下退款" : "原路退回");
|
||||
return orderPrintDTO;
|
||||
}
|
||||
|
||||
|
||||
public PrintInfoDTO guestOrderPrint(OrderInfo orderInfo, PrintMachine machine, List<OrderDetail> detailList) {
|
||||
PrintInfoDTO printInfoDTO = getPrintInfoDTO(orderInfo, "客看单");
|
||||
public OrderPrintDTO guestOrderPrint(OrderInfo orderInfo, PrintMachine machine, List<OrderDetail> detailList) {
|
||||
OrderPrintDTO orderPrintDTO = getPrintInfoDTO(orderInfo, "客看单");
|
||||
|
||||
BigDecimal originalAmount = BigDecimal.ZERO;
|
||||
for (OrderDetail orderDetail : detailList) {
|
||||
@@ -692,24 +540,24 @@ public abstract class PrinterHandler {
|
||||
orderDetail.setProductName("【赠】%s".formatted(orderDetail.getProductName()));
|
||||
}
|
||||
}
|
||||
log.info("客看单 第{}次下单--------------------------------------------", orderInfo.getPlaceNum());
|
||||
// log.info("客看单 第{}次下单--------------------------------------------", orderInfo.getPlaceNum());
|
||||
if (orderInfo.getPlaceNum() != null && orderInfo.getPlaceNum() != 1) {
|
||||
orderInfo.setSeatAmount(BigDecimal.ZERO);
|
||||
printInfoDTO.setSeatAmount("");
|
||||
orderPrintDTO.setSeatAmount("");
|
||||
}
|
||||
printInfoDTO.setOriginalAmount((originalAmount.add(orderInfo.getSeatAmount()).add(orderInfo.getPackFee()))
|
||||
orderPrintDTO.setOriginalAmount((originalAmount.add(orderInfo.getSeatAmount()).add(orderInfo.getPackFee()))
|
||||
.setScale(2, RoundingMode.HALF_UP).toPlainString());
|
||||
printInfoDTO.setPayAmount((originalAmount.add(orderInfo.getSeatAmount()).add(orderInfo.getPackFee())
|
||||
orderPrintDTO.setPayAmount((originalAmount.add(orderInfo.getSeatAmount()).add(orderInfo.getPackFee())
|
||||
.subtract(orderInfo.getDiscountAllAmount())).setScale(2, RoundingMode.HALF_UP).toPlainString());
|
||||
|
||||
if (orderInfo.getPackFee().compareTo(BigDecimal.ZERO) > 0) {
|
||||
printInfoDTO.setPackFee(orderInfo.getPackFee().toPlainString());
|
||||
orderPrintDTO.setPackFee(orderInfo.getPackFee().toPlainString());
|
||||
}
|
||||
return printInfoDTO;
|
||||
return orderPrintDTO;
|
||||
}
|
||||
|
||||
public PrintInfoDTO preOrderPrint(OrderInfo orderInfo, PrintMachine machine, List<OrderDetail> detailList) {
|
||||
PrintInfoDTO printInfoDTO = getPrintInfoDTO(orderInfo, "预结算单");
|
||||
public OrderPrintDTO preOrderPrint(OrderInfo orderInfo, PrintMachine machine, List<OrderDetail> detailList) {
|
||||
OrderPrintDTO orderPrintDTO = getPrintInfoDTO(orderInfo, "预结算单");
|
||||
|
||||
BigDecimal originalAmount = BigDecimal.ZERO;
|
||||
for (OrderDetail orderDetail : detailList) {
|
||||
@@ -721,97 +569,48 @@ public abstract class PrinterHandler {
|
||||
originalAmount = originalAmount.add((orderDetail.getNum().subtract(orderDetail.getReturnNum()).subtract(orderDetail.getRefundNum())).multiply(orderDetail.getPrice()));
|
||||
}
|
||||
}
|
||||
printInfoDTO.setOriginalAmount((originalAmount.add(orderInfo.getSeatAmount()).add(orderInfo.getPackFee()))
|
||||
orderPrintDTO.setOriginalAmount((originalAmount.add(orderInfo.getSeatAmount()).add(orderInfo.getPackFee()))
|
||||
.setScale(2, RoundingMode.HALF_UP).toPlainString());
|
||||
printInfoDTO.setPayAmount(originalAmount.add(orderInfo.getSeatAmount()).add(orderInfo.getPackFee())
|
||||
orderPrintDTO.setPayAmount(originalAmount.add(orderInfo.getSeatAmount()).add(orderInfo.getPackFee())
|
||||
.subtract(orderInfo.getDiscountAllAmount()).setScale(2, RoundingMode.HALF_UP).toPlainString());
|
||||
if (orderInfo.getPackFee().compareTo(BigDecimal.ZERO) > 0) {
|
||||
printInfoDTO.setPackFee(orderInfo.getPackFee().toPlainString());
|
||||
orderPrintDTO.setPackFee(orderInfo.getPackFee().toPlainString());
|
||||
}
|
||||
return printInfoDTO;
|
||||
return orderPrintDTO;
|
||||
}
|
||||
|
||||
public PrintInfoDTO orderPrint(OrderInfo orderInfo, PrintMachine machine, List<OrderDetail> detailList) {
|
||||
PrintInfoDTO printInfoDTO = getPrintInfoDTO(orderInfo, "结算单");
|
||||
public OrderPrintDTO orderPrint(OrderInfo orderInfo, PrintMachine machine, List<OrderDetail> detailList) {
|
||||
OrderPrintDTO orderPrintDTO = getPrintInfoDTO(orderInfo, "结算单");
|
||||
|
||||
BigDecimal originalAmount = orderInfo.getOriginAmount() == null ? BigDecimal.ZERO : orderInfo.getOriginAmount();
|
||||
printInfoDTO.setOriginalAmount(originalAmount.toPlainString());
|
||||
printInfoDTO.setPayAmount(originalAmount.subtract(orderInfo.getDiscountAllAmount()).setScale(2, RoundingMode.HALF_UP).toPlainString());
|
||||
orderPrintDTO.setOriginalAmount(originalAmount.toPlainString());
|
||||
orderPrintDTO.setPayAmount(originalAmount.subtract(orderInfo.getDiscountAllAmount()).setScale(2, RoundingMode.HALF_UP).toPlainString());
|
||||
if (orderInfo.getPackFee().compareTo(BigDecimal.ZERO) > 0) {
|
||||
printInfoDTO.setPackFee(orderInfo.getPackFee().toPlainString());
|
||||
orderPrintDTO.setPackFee(orderInfo.getPackFee().toPlainString());
|
||||
}
|
||||
return printInfoDTO;
|
||||
}
|
||||
|
||||
private PrintInfoDTO getPrintInfoDTO(OrderInfo orderInfo, String printTitle) {
|
||||
ShopInfo shopInfo = shopInfoService.getById(orderInfo.getShopId());
|
||||
long count = orderInfoService.count(new QueryWrapper().eq(OrderInfo::getTradeDay, orderInfo.getTradeDay())
|
||||
.eq(OrderInfo::getStatus, OrderStatusEnums.DONE.getCode())
|
||||
.eq(OrderInfo::getShopId, orderInfo.getShopId())
|
||||
.le(OrderInfo::getCreateTime, orderInfo.getCreateTime()));
|
||||
|
||||
PrintInfoDTO printInfoDTO = new PrintInfoDTO().setShopName(shopInfo.getShopName())
|
||||
.setPrintTitle(printTitle)
|
||||
.setPickupNum(orderInfo.getTableName())
|
||||
.setOrderNo(orderInfo.getOrderNo()).setPayAmount(orderInfo.getPayAmount().toPlainString()).setReturn(false)
|
||||
.setOutNumber(orderInfo.getTakeCode()).setCount(count).setRemark(orderInfo.getRemark())
|
||||
// 使用累计的总优惠金额,null 表示没有优惠
|
||||
.setDiscountAmount(orderInfo.getDiscountAllAmount() != null
|
||||
? orderInfo.getDiscountAllAmount().toPlainString()
|
||||
: "0.00");
|
||||
|
||||
printInfoDTO.setSeatNum(orderInfo.getSeatNum() == null ? "" : orderInfo.getSeatNum().toString());
|
||||
if (orderInfo.getSeatNum() != null && orderInfo.getSeatAmount().compareTo(BigDecimal.ZERO) > 0) {
|
||||
printInfoDTO.setSeatAmount(orderInfo.getSeatAmount().divide(BigDecimal.valueOf(orderInfo.getSeatNum()), 2, RoundingMode.DOWN).toPlainString());
|
||||
}
|
||||
if (StrUtil.isNotBlank(orderInfo.getDineMode())) {
|
||||
switch (orderInfo.getDineMode()) {
|
||||
case "dine-in" -> printInfoDTO.setPrintType("收银-堂食");
|
||||
case "take-out" -> printInfoDTO.setPrintType("收银-外带");
|
||||
case "take-away" -> printInfoDTO.setPrintType("收银-外卖");
|
||||
}
|
||||
if (!"dine-in".equals(orderInfo.getDineMode())) {
|
||||
orderInfo.setSeatAmount(BigDecimal.ZERO);
|
||||
printInfoDTO.setSeatAmount("");
|
||||
}
|
||||
}
|
||||
if (orderInfo.getStaffId() != null) {
|
||||
ShopStaff detail = shopStaffService.getOne(new QueryWrapper().eq(ShopStaff::getId, orderInfo.getStaffId()).eq(ShopStaff::getShopId, orderInfo.getShopId()));
|
||||
if (detail != null) {
|
||||
printInfoDTO.setOperator(detail.getName());
|
||||
} else {
|
||||
printInfoDTO.setOperator("");
|
||||
}
|
||||
} else {
|
||||
printInfoDTO.setOperator("");
|
||||
}
|
||||
if ("结算单".equals(printTitle)) {
|
||||
if (StrUtil.isNotBlank(orderInfo.getPayType())) {
|
||||
switch (orderInfo.getPayType()) {
|
||||
case "main_scan" -> printInfoDTO.setPayType("二维码收款");
|
||||
case "back_scan" -> printInfoDTO.setPayType("扫码收款");
|
||||
case "wechat_mini" -> printInfoDTO.setPayType("微信小程序");
|
||||
case "alipay_mini" -> printInfoDTO.setPayType("支付宝小程序");
|
||||
case "vip_pay" -> printInfoDTO.setPayType("余额支付");
|
||||
case "cash_pay" -> printInfoDTO.setPayType("现金支付");
|
||||
case "credit_pay" -> printInfoDTO.setPayType("挂账支付");
|
||||
case "free_pay" -> printInfoDTO.setPayType("霸王餐支付");
|
||||
}
|
||||
}
|
||||
printInfoDTO.setTradeDate(DateUtil.format(orderInfo.getPaidTime(), "yyyy/MM/dd HH:mm:ss"));
|
||||
}
|
||||
return printInfoDTO;
|
||||
return orderPrintDTO;
|
||||
}
|
||||
|
||||
/**
|
||||
* 菜品打印
|
||||
* 后厨 总单打印
|
||||
*/
|
||||
protected abstract void normalDishesPrint(String operator, OrderInfo orderInfo, OrderDetail orderDetail, PrintMachine machine);
|
||||
public OrderPrintDTO allKitchenPrint(OrderInfo orderInfo, List<OrderDetail> orderDetails, PrintMachine machine) {
|
||||
return getPrintInfoDTO(orderInfo, "后厨总单");
|
||||
}
|
||||
|
||||
/**
|
||||
* 菜品 退菜打印
|
||||
* 后厨 菜品打印
|
||||
*/
|
||||
protected abstract void returnDishesPrint(String operator, OrderInfo orderInfo, OrderDetail orderDetail, PrintMachine machine);
|
||||
protected abstract void onlyKitchenPrint(OrderInfo orderInfo, OrderDetail orderDetail, PrintMachine machine);
|
||||
|
||||
/**
|
||||
* 后厨 退菜整单打印
|
||||
*/
|
||||
public OrderPrintDTO returnKitchenPrint(String operator, OrderInfo orderInfo, List<OrderDetail> orderDetail, PrintMachine machine) {
|
||||
OrderPrintDTO printInfo = getPrintInfoDTO(orderInfo, "后厨退菜单");
|
||||
printInfo.setOperator(operator);
|
||||
return printInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 叫号打印
|
||||
@@ -819,9 +618,91 @@ public abstract class PrinterHandler {
|
||||
protected abstract void callNumPrint(PrintMachine machine, String callNum, String shopName, String tableName, String tableNote, String preNum,
|
||||
String codeUrl, LocalDateTime takeTime, String shopNote);
|
||||
|
||||
/**
|
||||
* 出入库打印单
|
||||
*/
|
||||
protected abstract void stockPrint(PrintMachine machine, StockPrintDTO record);
|
||||
|
||||
/**
|
||||
* 经营日报打印
|
||||
*/
|
||||
protected abstract void dayReportPrint(PrintMachine machine, DayReportPrintDTO record);
|
||||
|
||||
/**
|
||||
* 商品报表打印
|
||||
*/
|
||||
protected abstract void productReportPrint(PrintMachine machine, ProductReportPrintDTO record);
|
||||
|
||||
/**
|
||||
* 储值单打印
|
||||
*/
|
||||
protected abstract void rechargePrint(PrintMachine machine, RechargePrintDTO record);
|
||||
|
||||
/**
|
||||
* 库存盘点打印
|
||||
*/
|
||||
protected abstract void stockCheckPrint(PrintMachine machine, StockCheckPrintDTO record);
|
||||
|
||||
|
||||
/**
|
||||
* 交班打印
|
||||
*/
|
||||
protected abstract void handoverPrint(PrintMachine machine, HandoverRecordDTO record);
|
||||
|
||||
|
||||
private OrderPrintDTO getPrintInfoDTO(OrderInfo orderInfo, String printTitle) {
|
||||
ShopInfo shopInfo = shopInfoService.getById(orderInfo.getShopId());
|
||||
OrderPrintDTO orderPrintDTO = new OrderPrintDTO().setShopName(shopInfo.getShopName())
|
||||
.setPrintTitle(printTitle)
|
||||
.setPickupNum(orderInfo.getTableName())
|
||||
.setOrderNo(orderInfo.getOrderNo()).setPayAmount(orderInfo.getPayAmount().toPlainString()).setReturn(false)
|
||||
.setOutNumber(orderInfo.getTakeCode())
|
||||
.setRemark(orderInfo.getRemark())
|
||||
// 使用累计的总优惠金额,null 表示没有优惠
|
||||
.setDiscountAmount(orderInfo.getDiscountAllAmount() != null
|
||||
? orderInfo.getDiscountAllAmount().toPlainString()
|
||||
: "0.00");
|
||||
|
||||
orderPrintDTO.setSeatNum(orderInfo.getSeatNum() == null ? "" : orderInfo.getSeatNum().toString());
|
||||
if (orderInfo.getSeatNum() != null && orderInfo.getSeatAmount().compareTo(BigDecimal.ZERO) > 0) {
|
||||
orderPrintDTO.setSeatAmount(orderInfo.getSeatAmount().divide(BigDecimal.valueOf(orderInfo.getSeatNum()), 2, RoundingMode.DOWN).toPlainString());
|
||||
}
|
||||
if (StrUtil.isNotBlank(orderInfo.getDineMode())) {
|
||||
switch (orderInfo.getDineMode()) {
|
||||
case "dine-in" -> orderPrintDTO.setPrintType("收银-堂食");
|
||||
case "take-out" -> orderPrintDTO.setPrintType("收银-外带");
|
||||
case "take-away" -> orderPrintDTO.setPrintType("收银-外卖");
|
||||
}
|
||||
if (!"dine-in".equals(orderInfo.getDineMode())) {
|
||||
orderInfo.setSeatAmount(BigDecimal.ZERO);
|
||||
orderPrintDTO.setSeatAmount("");
|
||||
}
|
||||
}
|
||||
if (orderInfo.getStaffId() != null) {
|
||||
ShopStaff detail = shopStaffService.getOne(new QueryWrapper().eq(ShopStaff::getId, orderInfo.getStaffId()).eq(ShopStaff::getShopId, orderInfo.getShopId()));
|
||||
if (detail != null) {
|
||||
orderPrintDTO.setOperator(detail.getName());
|
||||
} else {
|
||||
orderPrintDTO.setOperator("");
|
||||
}
|
||||
} else {
|
||||
orderPrintDTO.setOperator("");
|
||||
}
|
||||
if ("结算单".equals(printTitle)) {
|
||||
if (StrUtil.isNotBlank(orderInfo.getPayType())) {
|
||||
switch (orderInfo.getPayType()) {
|
||||
case "main_scan" -> orderPrintDTO.setPayType("二维码收款");
|
||||
case "back_scan" -> orderPrintDTO.setPayType("扫码收款");
|
||||
case "wechat_mini" -> orderPrintDTO.setPayType("微信小程序");
|
||||
case "alipay_mini" -> orderPrintDTO.setPayType("支付宝小程序");
|
||||
case "vip_pay" -> orderPrintDTO.setPayType("余额支付");
|
||||
case "cash_pay" -> orderPrintDTO.setPayType("现金支付");
|
||||
case "credit_pay" -> orderPrintDTO.setPayType("挂账支付");
|
||||
case "free_pay" -> orderPrintDTO.setPayType("霸王餐支付");
|
||||
}
|
||||
}
|
||||
orderPrintDTO.setTradeDate(DateUtil.format(orderInfo.getPaidTime(), "yyyy/MM/dd HH:mm:ss"));
|
||||
}
|
||||
return orderPrintDTO;
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,13 +1,12 @@
|
||||
package com.czg.service.order.print;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.crypto.SecureUtil;
|
||||
import cn.hutool.http.HttpUtil;
|
||||
import com.czg.account.dto.HandoverRecordDTO;
|
||||
import com.czg.account.entity.PrintMachine;
|
||||
import com.czg.order.entity.OrderDetail;
|
||||
import com.czg.order.entity.OrderInfo;
|
||||
import com.czg.print.*;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.http.HttpEntity;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
@@ -56,12 +55,157 @@ public class YxyPrinter extends PrinterHandler implements PrinterImpl {
|
||||
.setBr("<BR>")
|
||||
.setBold(new String[]{"<B>", "</B>"});
|
||||
|
||||
|
||||
@Override
|
||||
protected void onlyKitchenPrint(OrderInfo orderInfo, OrderDetail orderDetail, PrintMachine machine) {
|
||||
String buildDishPrintData = buildOnlyKitchenPrintData(getPickupNum(orderInfo), orderDetail);
|
||||
String voiceJson = "{\"bizType\":\"2\",\"content\":\"\"}";
|
||||
if (1 == machine.getVolumeSwitch()) {
|
||||
voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔新的订单,请及时处理\"}";
|
||||
}
|
||||
String resp = sendPrintRequest(machine.getAddress(), buildDishPrintData, voiceJson, machine.getPrintNum() == null ? "1" : machine.getPrintNum().toString());
|
||||
printMachineLogService.save(orderInfo.getId(), machine, "后厨商品单", buildDishPrintData, resp);
|
||||
}
|
||||
|
||||
@Override
|
||||
public OrderPrintDTO allKitchenPrint(OrderInfo orderInfo, List<OrderDetail> orderDetails, PrintMachine machine) {
|
||||
OrderPrintDTO orderPrintDTO = super.allKitchenPrint(orderInfo, orderDetails, machine);
|
||||
String buildDishPrintData = buildAllKitchenPrintData(orderPrintDTO, orderDetails);
|
||||
String voiceJson = "{\"bizType\":\"2\",\"content\":\"\"}";
|
||||
if (1 == machine.getVolumeSwitch()) {
|
||||
voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔新的订单,请及时处理\"}";
|
||||
}
|
||||
String resp = sendPrintRequest(machine.getAddress(), buildDishPrintData, voiceJson, machine.getPrintNum() == null ? "1" : machine.getPrintNum().toString());
|
||||
printMachineLogService.save(orderInfo.getId(), machine, "后厨总单", buildDishPrintData, resp);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public OrderPrintDTO returnKitchenPrint(String operator, OrderInfo orderInfo, List<OrderDetail> orderDetail, PrintMachine machine) {
|
||||
OrderPrintDTO orderPrintDTO = super.returnKitchenPrint(operator, orderInfo, orderDetail, machine);
|
||||
String buildDishPrintData = buildAllKitchenPrintData(orderPrintDTO, orderDetail);
|
||||
String voiceJson = "{\"bizType\":\"2\",\"content\":\"\"}";
|
||||
if (1 == machine.getVolumeSwitch()) {
|
||||
voiceJson = "{\"bizType\":\"2\",\"content\":\"退菜消息,请及时处理\"}";
|
||||
}
|
||||
String resp = sendPrintRequest(machine.getAddress(), buildDishPrintData, voiceJson, machine.getPrintNum() == null ? "1" : machine.getPrintNum().toString());
|
||||
printMachineLogService.save(orderInfo.getId(), machine, "后厨退菜", buildDishPrintData, resp);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public OrderPrintDTO returnOrderPrint(String printTitle, String operator, String refundAmount, String refundReason, String refundType,
|
||||
OrderInfo orderInfo, PrintMachine machine, List<OrderDetail> detailList) {
|
||||
OrderPrintDTO orderPrintDTO = super.returnOrderPrint(printTitle, operator, refundAmount, refundReason, refundType, orderInfo, machine, detailList);
|
||||
String data = buildRefundOrderPrintData(orderPrintDTO, detailList);
|
||||
sendOrderPrint(data, orderInfo.getId(), machine, "退款单");
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public OrderPrintDTO guestOrderPrint(OrderInfo orderInfo, PrintMachine machine, List<OrderDetail> detailList) {
|
||||
OrderPrintDTO orderPrintDTO = super.guestOrderPrint(orderInfo, machine, detailList);
|
||||
String data = buildGuestOrderPrintData(orderPrintDTO, detailList);
|
||||
sendOrderPrint(data, orderInfo.getId(), machine, "客看单");
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public OrderPrintDTO preOrderPrint(OrderInfo orderInfo, PrintMachine machine, List<OrderDetail> detailList) {
|
||||
OrderPrintDTO orderPrintDTO = super.preOrderPrint(orderInfo, machine, detailList);
|
||||
String data = buildOrderPrintData(orderPrintDTO, detailList);
|
||||
sendOrderPrint(data, orderInfo.getId(), machine, "预结算单");
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public OrderPrintDTO orderPrint(OrderInfo orderInfo, PrintMachine machine, List<OrderDetail> detailList) {
|
||||
OrderPrintDTO orderPrintDTO = super.orderPrint(orderInfo, machine, detailList);
|
||||
String data = buildOrderPrintData(orderPrintDTO, detailList);
|
||||
sendOrderPrint(data, orderInfo.getId(), machine, "结算单");
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 叫号单打印
|
||||
*/
|
||||
@Override
|
||||
protected void callNumPrint(PrintMachine machine, String callNum, String shopName, String tableName, String tableNote, String preNum, String codeUrl, LocalDateTime takeTime, String shopNote) {
|
||||
String resp = buildCallTicketData(shopName, tableName, callNum, preNum, codeUrl, shopNote, takeTime);
|
||||
String voiceJson = "{\"bizType\":\"2\",\"content\":\"\"}";
|
||||
if (1 == machine.getVolumeSwitch()) {
|
||||
voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一条新的排号记录\"}";
|
||||
}
|
||||
sendPrintRequest(machine.getAddress(), resp, voiceJson, machine.getPrintNum() == null ? "1" : machine.getPrintNum().toString());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void stockPrint(PrintMachine machine, StockPrintDTO record) {
|
||||
String voiceJson = "{\"bizType\":\"2\",\"content\":\"\"}";
|
||||
String data = buildStockData(record);
|
||||
String resp = sendPrintRequest(machine.getAddress(), data, voiceJson, machine.getPrintNum() == null ? "1" : machine.getPrintNum().toString());
|
||||
printMachineLogService.save(machine, "入库单", data, resp);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void dayReportPrint(PrintMachine machine, DayReportPrintDTO record) {
|
||||
String voiceJson = "{\"bizType\":\"2\",\"content\":\"\"}";
|
||||
String data = buildDayReportData(record);
|
||||
String resp = sendPrintRequest(machine.getAddress(), data, voiceJson, machine.getPrintNum() == null ? "1" : machine.getPrintNum().toString());
|
||||
printMachineLogService.save(machine, "经营日报单", data, resp);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void productReportPrint(PrintMachine machine, ProductReportPrintDTO record) {
|
||||
String voiceJson = "{\"bizType\":\"2\",\"content\":\"\"}";
|
||||
String data = buildProductReportData(record);
|
||||
String resp = sendPrintRequest(machine.getAddress(), data, voiceJson, machine.getPrintNum() == null ? "1" : machine.getPrintNum().toString());
|
||||
printMachineLogService.save(machine, "商品报表单", data, resp);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void rechargePrint(PrintMachine machine, RechargePrintDTO record) {
|
||||
String voiceJson = "{\"bizType\":\"2\",\"content\":\"\"}";
|
||||
String data = buildRechargeData(record);
|
||||
String resp = sendPrintRequest(machine.getAddress(), data, voiceJson, machine.getPrintNum() == null ? "1" : machine.getPrintNum().toString());
|
||||
printMachineLogService.save(machine, "储值单", data, resp);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void stockCheckPrint(PrintMachine machine, StockCheckPrintDTO record) {
|
||||
String voiceJson = "{\"bizType\":\"2\",\"content\":\"\"}";
|
||||
String data = buildStockCheckData(record);
|
||||
String resp = sendPrintRequest(machine.getAddress(), data, voiceJson, machine.getPrintNum() == null ? "1" : machine.getPrintNum().toString());
|
||||
printMachineLogService.save(machine, "盘点单", data, resp);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 交班单打印
|
||||
*/
|
||||
@Override
|
||||
protected void handoverPrint(PrintMachine machine, HandoverRecordDTO record) {
|
||||
String string = buildHandoverData(record);
|
||||
String voiceJson = "{\"bizType\":\"2\",\"content\":\"\"}";
|
||||
sendPrintRequest(machine.getAddress(), string, voiceJson, machine.getPrintNum() == null ? "1" : machine.getPrintNum().toString());
|
||||
}
|
||||
|
||||
|
||||
private void sendOrderPrint(String data, Long orderId, PrintMachine machine, String bizType) {
|
||||
String voiceJson = "{\"bizType\":\"2\",\"content\":\"\"}";
|
||||
if (1 == machine.getVolumeSwitch()) {
|
||||
voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔新的订单,请及时处理\"}";
|
||||
}
|
||||
String resp = sendPrintRequest(machine.getAddress(), data, voiceJson, machine.getPrintNum() == null ? "1" : machine.getPrintNum().toString());
|
||||
printMachineLogService.save(orderId, machine, bizType, data, resp);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PrintSignLabel getSignLabelInfo() {
|
||||
return printSignLabel;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String sendPrintRequest(String address, String metaPrintData, String voiceData, String printNum) {
|
||||
log.info("开始请求云享印,请求数据:{}, {}", voiceData, metaPrintData);
|
||||
@@ -98,85 +242,6 @@ public class YxyPrinter extends PrinterHandler implements PrinterImpl {
|
||||
return httpResponse;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void normalDishesPrint(String operator, OrderInfo orderInfo, OrderDetail orderDetail, PrintMachine machine) {
|
||||
String buildDishPrintData = buildDishPrintData(false, getPickupNum(orderInfo), DateUtil.format(orderDetail.getCreateTime(), "yyyy-MM-dd HH:mm:ss"), orderDetail.getProductName(), orderDetail.getSkuName(),
|
||||
orderDetail.getNum(), orderDetail.getRemark(), orderDetail.getProGroupInfo(), orderDetail.getId(), orderDetail.isUrgent());
|
||||
String voiceJson = "{\"bizType\":\"2\",\"content\":\"\"}";
|
||||
if (1 == machine.getVolumeSwitch()) {
|
||||
voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔新的订单,请及时处理\"}";
|
||||
}
|
||||
String resp = sendPrintRequest(machine.getAddress(), buildDishPrintData, voiceJson, "1");
|
||||
printMachineLogService.save(orderInfo.getId(), machine, "新订单", buildDishPrintData, resp);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void returnDishesPrint(String operator, OrderInfo orderInfo, OrderDetail orderDetail, PrintMachine machine) {
|
||||
String buildDishPrintData = buildDishPrintData(true, getPickupNum(orderInfo), DateUtil.format(orderDetail.getCreateTime(), "yyyy-MM-dd HH:mm:ss"), orderDetail.getProductName(), orderDetail.getSkuName(),
|
||||
orderDetail.getReturnNum(), orderDetail.getRemark(), orderDetail.getProGroupInfo(), orderDetail.getId(), orderDetail.isUrgent());
|
||||
String voiceJson = "{\"bizType\":\"2\",\"content\":\"\"}";
|
||||
String resp = sendPrintRequest(machine.getAddress(), buildDishPrintData, voiceJson, "1");
|
||||
printMachineLogService.save(orderInfo.getId(), machine, "退款单", buildDishPrintData, resp);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public PrintInfoDTO returnOrderPrint(String printTitle, String operator, String refundAmount, String refundReason, String refundType,
|
||||
OrderInfo orderInfo, PrintMachine machine, List<OrderDetail> detailList) {
|
||||
PrintInfoDTO printInfoDTO = super.returnOrderPrint(printTitle, operator, refundAmount, refundReason, refundType, orderInfo, machine, detailList);
|
||||
String data = buildRefundOrderPrintData(printInfoDTO, detailList);
|
||||
sendOrderPrint(data, orderInfo.getId(), machine, "退款单");
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PrintInfoDTO guestOrderPrint(OrderInfo orderInfo, PrintMachine machine, List<OrderDetail> detailList) {
|
||||
PrintInfoDTO printInfoDTO = super.guestOrderPrint(orderInfo, machine, detailList);
|
||||
String data = buildGuestOrderPrintData(printInfoDTO, detailList);
|
||||
sendOrderPrint(data, orderInfo.getId(), machine, "客看单");
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PrintInfoDTO preOrderPrint(OrderInfo orderInfo, PrintMachine machine, List<OrderDetail> detailList) {
|
||||
PrintInfoDTO printInfoDTO = super.preOrderPrint(orderInfo, machine, detailList);
|
||||
String data = buildOrderPrintData(printInfoDTO, detailList);
|
||||
sendOrderPrint(data, orderInfo.getId(), machine, "预结算单");
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PrintInfoDTO orderPrint(OrderInfo orderInfo, PrintMachine machine, List<OrderDetail> detailList) {
|
||||
PrintInfoDTO printInfoDTO = super.orderPrint(orderInfo, machine, detailList);
|
||||
String data = buildOrderPrintData(printInfoDTO, detailList);
|
||||
sendOrderPrint(data, orderInfo.getId(), machine, "结算单");
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 叫号单打印
|
||||
*/
|
||||
@Override
|
||||
protected void callNumPrint(PrintMachine machine, String callNum, String shopName, String tableName, String tableNote, String preNum, String codeUrl, LocalDateTime takeTime, String shopNote) {
|
||||
String resp = buildCallTicketData(shopName, tableName, callNum, preNum, codeUrl, shopNote, takeTime);
|
||||
String voiceJson = "{\"bizType\":\"2\",\"content\":\"\"}";
|
||||
if (1 == machine.getVolumeSwitch()) {
|
||||
voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一条新的排号记录\"}";
|
||||
}
|
||||
sendPrintRequest(machine.getAddress(), resp, voiceJson, "1");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 交班单打印
|
||||
*/
|
||||
@Override
|
||||
protected void handoverPrint(PrintMachine machine, HandoverRecordDTO record) {
|
||||
String string = buildHandoverData(record);
|
||||
String voiceJson = "{\"bizType\":\"2\",\"content\":\"\"}";
|
||||
sendPrintRequest(machine.getAddress(), string, voiceJson, "1");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取TOKEN值
|
||||
@@ -200,20 +265,6 @@ public class YxyPrinter extends PrinterHandler implements PrinterImpl {
|
||||
return SecureUtil.md5(token + APP_SECRET).toUpperCase();
|
||||
}
|
||||
|
||||
private void sendOrderPrint(String data, Long orderId, PrintMachine machine, String bizType) {
|
||||
String voiceJson = "{\"bizType\":\"2\",\"content\":\"\"}";
|
||||
if (1 == machine.getVolumeSwitch()) {
|
||||
voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔新的订单,请及时处理\"}";
|
||||
}
|
||||
String printerNum = "1";
|
||||
if (StrUtil.isNotBlank(machine.getPrintQty())) {
|
||||
printerNum = machine.getPrintQty().split("\\^")[1];
|
||||
}
|
||||
String resp = sendPrintRequest(machine.getAddress(), data, voiceJson, printerNum);
|
||||
printMachineLogService.save(orderId, machine, bizType, data, resp);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 检查打印状态
|
||||
*
|
||||
|
||||
@@ -332,11 +332,13 @@ public class OrderInfoCustomServiceImpl implements OrderInfoCustomService {
|
||||
if ("after-pay".equals(orderInfo.getPayMode())) {
|
||||
//
|
||||
log.info("后付费生成订单{},第{}", orderInfo.getId(), orderInfo.getPlaceNum());
|
||||
//客看单
|
||||
printerHandler.orderHandler(orderInfo.getId().toString(), PrinterHandler.PrintTypeEnum.GUEST_ORDER, orderInfo.getPlaceNum());
|
||||
//发送打票信息 后付费推送多次 需要处理
|
||||
//orderId_0_0 订单ID_先付后付(1先付0后付)_订单状态 0未完成 1完成_第几次下单
|
||||
//orderInfo.getId() + "_" + (!"after-pay".equals(orderInfo.getPayMode()) ? 1 : 0) + "_0"
|
||||
//后付费 菜品单
|
||||
rabbitPublisher.sendKitchenOrderPrintMsg(orderInfo.getId() + "_0_0", false, "后付费打印");
|
||||
// 消息通知 本地打印机执行
|
||||
rabbitPublisher.sendOrderPrintMsg(orderInfo.getId() + "_0_0_" + orderInfo.getPlaceNum(), true, "后付费打印");
|
||||
} else {
|
||||
redisService.set(RedisCst.classKeyExpired.EXPIRED_ORDER + orderInfo.getId(), "", 60 * 15);
|
||||
@@ -1616,9 +1618,6 @@ public class OrderInfoCustomServiceImpl implements OrderInfoCustomService {
|
||||
}
|
||||
|
||||
switch (orderInfoPrintDTO.getType()) {
|
||||
case 0://菜品和结算单同时打印
|
||||
printerHandler.orderHandler(orderInfo.getId().toString(), PrinterHandler.PrintTypeEnum.ONE_AND_ORDER, null);
|
||||
break;
|
||||
case 1://预结算单
|
||||
printerHandler.orderHandler(orderInfo.getId().toString(), PrinterHandler.PrintTypeEnum.PRE_ORDER, null);
|
||||
break;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.czg.service.order.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.util.NumberUtil;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.czg.account.entity.HandoverRecord;
|
||||
@@ -25,7 +24,8 @@ import org.apache.dubbo.config.annotation.DubboService;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 订单Rpc ServiceImpl
|
||||
@@ -169,7 +169,8 @@ public class OrderInfoRpcServiceImpl implements OrderInfoRpcService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendHandoverReceiptPrintMsgToMq(Long handoverRecordId) {
|
||||
rabbitPublisher.sendHandoverPrintMsg(Convert.toStr(handoverRecordId));
|
||||
public void sendHandoverReceiptPrintMsgToMq(Long shopId, HandoverRecord record) {
|
||||
rabbitPublisher.sendOtherPrintMsg(shopId, record, "HANDOVER");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -381,7 +381,7 @@ public class OrderPayServiceImpl implements OrderPayService {
|
||||
}
|
||||
boolean isFirstRefund = orderInfo.getRefundAmount().compareTo(BigDecimal.ZERO) == 0;
|
||||
ShopInfo shopInfo = shopInfoService.getById(orderInfo.getShopId());
|
||||
Map<Long,BigDecimal> productStockMap = new HashMap<>();
|
||||
Map<Long, BigDecimal> productStockMap = new HashMap<>();
|
||||
boolean isPay = true;
|
||||
String refPayOrderNo = "REFO" + IdUtil.getSnowflakeNextId();
|
||||
if (orderInfo.getStatus().equals(OrderStatusEnums.UNPAID.getCode())) {
|
||||
@@ -524,13 +524,20 @@ public class OrderPayServiceImpl implements OrderPayService {
|
||||
orderInfoService.updateById(orderInfo);
|
||||
//退款后续 退款单/退菜单
|
||||
if (param.isPrint()) {
|
||||
printerHandler.refundOrderHandler(printTitle, StrUtil.isNotBlank(param.getOperator()) ? param.getOperator() : ""
|
||||
, isPay ? param.getRefundAmount().toPlainString() : "0"
|
||||
, param.getRefundReason(), orderInfo.getRefundType(), orderInfo, param.getRefundDetails());
|
||||
String finalPrintTitle = printTitle;
|
||||
boolean finalIsPay = isPay;
|
||||
FunUtils.safeRunVoid(() -> printerHandler.refundOrderHandler(finalPrintTitle, StrUtil.isNotBlank(param.getOperator()) ? param.getOperator() : ""
|
||||
, finalIsPay ? param.getRefundAmount().toPlainString() : "0"
|
||||
, param.getRefundReason(), orderInfo.getRefundType(), orderInfo, param.getRefundDetails()),
|
||||
"订单id:{} 退款,前台打印消息失败", orderInfo.getId());
|
||||
}
|
||||
//后厨退菜单
|
||||
FunUtils.safeRunVoid(() -> printerHandler.kitchenRefundAllHandler(StrUtil.isNotBlank(param.getOperator()) ? param.getOperator() : "", orderInfo, param.getRefundDetails()),
|
||||
"订单id:{} 退款,后厨退菜单打印消息失败", orderInfo.getId());
|
||||
//退款返还库存
|
||||
if (!productStockMap.isEmpty()) {
|
||||
orderInfoCustomService.refundStock(shopInfo, orderInfo.getId(), productStockMap, param.isRefundStock());
|
||||
FunUtils.safeRunVoid(() -> orderInfoCustomService.refundStock(shopInfo, orderInfo.getId(), productStockMap, param.isRefundStock()),
|
||||
"订单id:{} 退款,库存处理失败", orderInfo.getId());
|
||||
}
|
||||
refundOrderAfter(orderInfo.getId(), orderInfo.getShopId(), orderInfo.getUserId(), orderInfo.getOrderNo(),
|
||||
orderInfo.getPointsNum(), isFirstRefund, orderInfo.getStatus().equals(OrderStatusEnums.REFUND.getCode()));
|
||||
|
||||
@@ -93,7 +93,7 @@ public class PrintMachineLogServiceImpl extends ServiceImpl<PrintMachineLogMappe
|
||||
String respMsg = "打印中";
|
||||
JSONObject resp = JSONObject.parseObject(respJson);
|
||||
// 云想印
|
||||
if ("云想印".equals(config.getContentType())) {
|
||||
if ("云想印".equals(config.getBrand())) {
|
||||
int code = resp.getIntValue("code");
|
||||
JSONObject respData = resp.getJSONObject("data");
|
||||
JSONObject data = respData.getJSONObject("data");
|
||||
@@ -112,7 +112,7 @@ public class PrintMachineLogServiceImpl extends ServiceImpl<PrintMachineLogMappe
|
||||
entity.setTaskId(respData.getString("orderId"));
|
||||
}
|
||||
// 飞鹅云打印机暂时没有适配,先return不做打印记录
|
||||
} else if ("飞鹅".equals(config.getContentType())) {
|
||||
} else if ("飞鹅".equals(config.getBrand())) {
|
||||
int ret = resp.getIntValue("ret");
|
||||
if (ret != 0) {
|
||||
failFlag = 1;
|
||||
@@ -170,7 +170,7 @@ public class PrintMachineLogServiceImpl extends ServiceImpl<PrintMachineLogMappe
|
||||
|
||||
try {
|
||||
// 1. 云想印打印机状态查询
|
||||
if ("云想印".equals(config.getContentType())) {
|
||||
if ("云想印".equals(config.getBrand())) {
|
||||
String jsonStr = yxyPrinter.checkPrintStatus(config.getAddress(), entity.getTaskId());
|
||||
log.info("云想印打印状态查询结果(第{}次,虚拟线程:{}):{}",
|
||||
currentTimes, Thread.currentThread().getName(), jsonStr);
|
||||
@@ -185,7 +185,7 @@ public class PrintMachineLogServiceImpl extends ServiceImpl<PrintMachineLogMappe
|
||||
}
|
||||
}
|
||||
// 2. 飞鹅云打印机状态查询
|
||||
else if ("飞鹅".equals(config.getContentType())) {
|
||||
else if ("飞鹅".equals(config.getBrand())) {
|
||||
Boolean success = feiPrinter.checkFPrintStatus(entity.getTaskId());
|
||||
if (success == null) {
|
||||
entity.setFailFlag(1);
|
||||
|
||||
Reference in New Issue
Block a user