打印状态标识 允许重新操作
This commit is contained in:
@@ -1,267 +0,0 @@
|
||||
|
||||
package com.czg.order.dto;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import com.alibaba.fastjson2.annotation.JSONField;
|
||||
|
||||
import java.io.Serial;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 订单表 实体类。
|
||||
*
|
||||
* @author ww
|
||||
* @since 2025-02-13
|
||||
*/
|
||||
@Data
|
||||
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class OrderInfoDTO implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 订单编号
|
||||
* pc 收银机客户端 PC+雪花ID
|
||||
* wechat 微信小程序 WX+雪花ID
|
||||
* alipay 支付宝小程序 ALI+雪花ID
|
||||
* admin-pc PC管理端 WEB+雪花ID
|
||||
* admin-app APP管理端 APP+雪花ID
|
||||
*/
|
||||
private String orderNo;
|
||||
|
||||
/**
|
||||
* 店铺Id
|
||||
*/
|
||||
private Long shopId;
|
||||
|
||||
/**
|
||||
* 用户Id user_info表的id
|
||||
*/
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 退单金额
|
||||
*/
|
||||
private BigDecimal refundAmount;
|
||||
|
||||
/**
|
||||
* 订单原金额 不含折扣价格
|
||||
*/
|
||||
private BigDecimal originAmount;
|
||||
/**
|
||||
* 抹零金额 减免多少钱
|
||||
*/
|
||||
private BigDecimal roundAmount;
|
||||
/**
|
||||
* 优惠总金额
|
||||
*/
|
||||
private BigDecimal discountAllAmount;
|
||||
|
||||
/**
|
||||
* 订单金额 (扣除各类折扣)
|
||||
*/
|
||||
private BigDecimal orderAmount;
|
||||
|
||||
/**
|
||||
* 实际支付金额
|
||||
*/
|
||||
private BigDecimal payAmount;
|
||||
|
||||
/**
|
||||
* 积分抵扣金额
|
||||
*/
|
||||
private BigDecimal pointsDiscountAmount;
|
||||
|
||||
/**
|
||||
* 使用的积分数量
|
||||
*/
|
||||
private Integer pointsNum;
|
||||
|
||||
/**
|
||||
* 商品优惠券抵扣金额
|
||||
*/
|
||||
private BigDecimal productCouponDiscountAmount;
|
||||
|
||||
/**
|
||||
* 用户使用的卡券
|
||||
*/
|
||||
private String couponInfoList;
|
||||
|
||||
/**
|
||||
* 满减活动抵扣金额
|
||||
*/
|
||||
private BigDecimal discountActAmount;
|
||||
|
||||
/**
|
||||
* 折扣金额
|
||||
*/
|
||||
private BigDecimal discountAmount;
|
||||
|
||||
// /**
|
||||
// * 折扣比例
|
||||
// */
|
||||
// private BigDecimal discountRatio;
|
||||
|
||||
/**
|
||||
* 打包费
|
||||
*/
|
||||
private BigDecimal packFee;
|
||||
|
||||
/**
|
||||
* 台桌Id
|
||||
*/
|
||||
private String tableCode;
|
||||
|
||||
/**
|
||||
* 台桌名称
|
||||
*/
|
||||
private String tableName;
|
||||
|
||||
/**
|
||||
* 订单类型-
|
||||
* cash收银(除小程序以外 都属于收银)
|
||||
* miniapp小程序
|
||||
*/
|
||||
private String orderType;
|
||||
|
||||
/**
|
||||
* 平台类型 pc 收银机客户端 wechat 微信小程序 alipay 支付宝小程序 admin-pc PC管理端 admin-app APP管理端
|
||||
*/
|
||||
private String platformType;
|
||||
|
||||
/**
|
||||
* 用餐模式 堂食 dine-in 外带 take-out 外卖 take-away
|
||||
*/
|
||||
private String dineMode;
|
||||
|
||||
/**
|
||||
* 支付模式:
|
||||
* 后付费 after-pay
|
||||
* 先付费 before-pay
|
||||
* 无桌码 no-table
|
||||
*/
|
||||
private String payMode;
|
||||
|
||||
/**
|
||||
* 支付类型
|
||||
* 主扫 main-scan
|
||||
* 被扫 back-scan
|
||||
* 微信小程序 wechat-mini
|
||||
* 支付宝小程序 alipay-mini
|
||||
* 会员支付 vip-pay
|
||||
* 现金支付 cash-pay
|
||||
*/
|
||||
private String payType;
|
||||
|
||||
/**
|
||||
* 状态: unpaid-待支付;in-production 制作中;wait_out 待取餐;;done-订单完成;refunding-申请退单;refund-退单;part_refund 部分退单;cancelled-取消订单
|
||||
*/
|
||||
private String status;
|
||||
|
||||
/**
|
||||
* 折扣信息 json
|
||||
*/
|
||||
private String discountInfo;
|
||||
|
||||
/**
|
||||
* 限时折扣信息 json
|
||||
*/
|
||||
private String limitRate;
|
||||
|
||||
/**
|
||||
* 是否支持退款,1支持退单, 0不支持退单
|
||||
*/
|
||||
private Integer refundAble;
|
||||
|
||||
/**
|
||||
* 支付时间
|
||||
*/
|
||||
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime paidTime;
|
||||
|
||||
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
/**
|
||||
* 支付订单号
|
||||
* tb_order_payment.id
|
||||
* tb_shop_user_flow.id
|
||||
*/
|
||||
private Long payOrderId;
|
||||
|
||||
/**
|
||||
* 交易日期
|
||||
*/
|
||||
private String tradeDay;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 取餐码
|
||||
*/
|
||||
private String takeCode;
|
||||
|
||||
/**
|
||||
* 员工id
|
||||
*/
|
||||
private Long staffId;
|
||||
|
||||
/**
|
||||
* 当前订单下单次数
|
||||
*/
|
||||
private Integer placeNum;
|
||||
|
||||
/**
|
||||
* 用餐人数
|
||||
*/
|
||||
private Integer seatNum;
|
||||
|
||||
/**
|
||||
* 餐位费
|
||||
*/
|
||||
private BigDecimal seatAmount;
|
||||
|
||||
/**
|
||||
* 退款备注
|
||||
*/
|
||||
private String refundRemark;
|
||||
|
||||
/**
|
||||
* 是否使用了霸王餐
|
||||
*/
|
||||
private Integer isFreeDine;
|
||||
|
||||
/**
|
||||
* 是否等叫 0 否 1 等叫
|
||||
*/
|
||||
private Integer isWaitCall;
|
||||
|
||||
/**
|
||||
* 挂账人id
|
||||
*/
|
||||
private Long creditBuyerId;
|
||||
|
||||
/**
|
||||
* 是否回收站 0-否,1回收站
|
||||
*/
|
||||
private Integer isDel;
|
||||
private String failMsg;
|
||||
|
||||
}
|
||||
@@ -24,5 +24,9 @@ public class OrderInfoPrintDTO implements Serializable {
|
||||
*/
|
||||
@NotNull(message = "打印类型不为空")
|
||||
private Integer type;
|
||||
/**
|
||||
* 打印机id
|
||||
*/
|
||||
private Long machineId;
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.czg.order.entity;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson2.JSONArray;
|
||||
import com.czg.order.dto.LimitRateDTO;
|
||||
import com.mybatisflex.annotation.Column;
|
||||
import com.mybatisflex.annotation.Id;
|
||||
@@ -298,8 +299,10 @@ public class OrderInfo implements Serializable {
|
||||
private Integer isDel;
|
||||
|
||||
private String failMsg;
|
||||
|
||||
|
||||
/**
|
||||
* 打印状态 Json格式
|
||||
*/
|
||||
private String printStatus;
|
||||
|
||||
|
||||
public String getRefundRemark() {
|
||||
@@ -342,4 +345,16 @@ public class OrderInfo implements Serializable {
|
||||
// 如果需要加上抹零金额,可以取消下面这行注释
|
||||
// .add(this.getRoundAmount() != null ? this.getRoundAmount() : BigDecimal.ZERO);
|
||||
}
|
||||
|
||||
|
||||
public JSONArray getPrintStatus() {
|
||||
if (StrUtil.isBlank(printStatus)) {
|
||||
return new JSONArray();
|
||||
}
|
||||
try {
|
||||
return JSONArray.parseArray(printStatus.trim());
|
||||
} catch (Exception e) {
|
||||
return new JSONArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -133,6 +133,11 @@ public class OrderInfoVo implements Serializable {
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
/**
|
||||
* 打印状态 Json格式
|
||||
* [{"id":"124","name":"111","time":"2025-12-29 11:05:18"},{"id":"111","name":"标签","time":"2025-12-29 11:05:30"}]
|
||||
*/
|
||||
private String printStatus;
|
||||
|
||||
/**
|
||||
* 是否使用了霸王餐
|
||||
|
||||
@@ -49,9 +49,6 @@ public abstract class PrinterHandler {
|
||||
@Setter
|
||||
protected PrinterHandler nextPrinter;
|
||||
protected String printerBrand;
|
||||
// 创建 ThreadLocal 变量
|
||||
private static final ThreadLocal<String> ERR_MSG = ThreadLocal.withInitial(() -> "");
|
||||
|
||||
|
||||
@Resource
|
||||
protected OrderDetailService orderDetailService;
|
||||
@@ -148,16 +145,17 @@ public abstract class PrinterHandler {
|
||||
* @param printType 打印类型,JSON数组 refund-确认退款单 handover-交班单 queue-排队取号
|
||||
* @return 打印机列表
|
||||
*/
|
||||
private List<PrintMachine> getPrintMachine(Long shopId, String subType, String printMethod, String printType) {
|
||||
private List<PrintMachine> getPrintMachine(Long shopId, String subType, String printMethod, String printType, Long machineId) {
|
||||
QueryWrapper wrapper = new QueryWrapper()
|
||||
.eq(PrintMachine::getStatus, 1)
|
||||
.eq(PrintMachine::getId, machineId)
|
||||
.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 "all" -> Arrays.asList("one", "normal", "all");
|
||||
case "one" -> Arrays.asList("one", "all");
|
||||
case "normal" -> Arrays.asList("normal", "all");
|
||||
default -> new ArrayList<>();
|
||||
@@ -188,10 +186,11 @@ public abstract class PrinterHandler {
|
||||
|
||||
/**
|
||||
* 处理打印
|
||||
* @param data 传递的数据
|
||||
*
|
||||
* @param data 传递的数据
|
||||
* @param printTypeEnum order returnOrder preOrder one call handover
|
||||
*/
|
||||
public void handler(String data, PrintTypeEnum printTypeEnum) {
|
||||
public void handler(String data, PrintTypeEnum printTypeEnum, Long machineId) {
|
||||
Long shopId;
|
||||
String printMethod = "";
|
||||
String printType = "";
|
||||
@@ -262,7 +261,7 @@ public abstract class PrinterHandler {
|
||||
}
|
||||
|
||||
Object finalObj = obj;
|
||||
getPrintMachine(shopId, "cash", printMethod, printType).forEach(machine -> {
|
||||
getPrintMachine(shopId, "cash", printMethod, printType, machineId).forEach(machine -> {
|
||||
handleRequest(machine, finalObj, printTypeEnum);
|
||||
// printPlaceTicket(isReturn, machine, orderInfo, shopInfo);
|
||||
});
|
||||
@@ -314,7 +313,7 @@ public abstract class PrinterHandler {
|
||||
item.setNum(item.getNum().subtract(printDetailInfo.getPrintNum()));
|
||||
item.setReturnNum(item.getReturnNum().subtract(printDetailInfo.getPrintReturnNum()));
|
||||
orderDetails.add(item);
|
||||
}else {
|
||||
} else {
|
||||
orderDetails.add(item);
|
||||
}
|
||||
|
||||
@@ -334,7 +333,7 @@ public abstract class PrinterHandler {
|
||||
log.info("准备开始打印交班");
|
||||
if (data instanceof HandoverRecordDTO record) {
|
||||
handoverPrint(machine, record);
|
||||
}else {
|
||||
} else {
|
||||
throw new RuntimeException("传递数据类型有误");
|
||||
}
|
||||
break;
|
||||
@@ -343,7 +342,7 @@ public abstract class PrinterHandler {
|
||||
if (data instanceof OrderInfo orderInfo) {
|
||||
List<OrderDetail> orderDetailList = orderDetailService.list(new QueryWrapper().eq(OrderDetail::getOrderId, orderInfo.getId()));
|
||||
onlyFrontDesk(machine, false, orderInfo, orderDetailList);
|
||||
}else {
|
||||
} else {
|
||||
throw new RuntimeException("传递数据类型有误");
|
||||
}
|
||||
break;
|
||||
@@ -352,7 +351,7 @@ public abstract class PrinterHandler {
|
||||
if (data instanceof OrderInfo orderInfo) {
|
||||
List<OrderDetail> orderDetailList = orderDetailService.list(new QueryWrapper().eq(OrderDetail::getOrderId, orderInfo.getId()));
|
||||
onlyFrontDesk(machine, true, orderInfo, orderDetailList);
|
||||
}else {
|
||||
} else {
|
||||
throw new RuntimeException("传递数据类型有误");
|
||||
}
|
||||
break;
|
||||
@@ -361,7 +360,7 @@ public abstract class PrinterHandler {
|
||||
if (data instanceof OrderInfo orderInfo) {
|
||||
List<OrderDetail> orderDetailList = orderDetailService.list(new QueryWrapper().eq(OrderDetail::getOrderId, orderInfo.getId()));
|
||||
onlyKitchen(machine, orderInfo, orderDetailList);
|
||||
}else {
|
||||
} else {
|
||||
throw new RuntimeException("传递数据类型有误");
|
||||
}
|
||||
break;
|
||||
@@ -369,7 +368,7 @@ public abstract class PrinterHandler {
|
||||
log.info("准备开始打印叫号单");
|
||||
if (data instanceof CallQueue queue) {
|
||||
onlyCallNumPrint(machine, queue);
|
||||
}else {
|
||||
} else {
|
||||
throw new RuntimeException("传递数据类型有误");
|
||||
}
|
||||
break;
|
||||
@@ -393,7 +392,7 @@ public abstract class PrinterHandler {
|
||||
default:
|
||||
throw new RuntimeException("打印方法有误");
|
||||
}
|
||||
}else {
|
||||
} else {
|
||||
throw new RuntimeException("传递数据类型有误");
|
||||
}
|
||||
|
||||
|
||||
@@ -1060,8 +1060,7 @@ public class OrderInfoCustomServiceImpl implements OrderInfoCustomService {
|
||||
distributionUserService.costUpgradeLevelBefore(orderInfo.getUserId(), orderInfo.getShopId());
|
||||
// 分销奖励
|
||||
distributionUserService.distribute(orderInfo.getId(), orderInfo.getOrderNo(), payment.getAmount(), orderInfo.getUserId(), orderInfo.getShopId(), "order");
|
||||
}
|
||||
else if (PayTypeConstants.SourceType.MEMBER_IN.equals(payment.getSourceType()) || PayTypeConstants.SourceType.FREE.equals(payment.getSourceType())) {
|
||||
} else if (PayTypeConstants.SourceType.MEMBER_IN.equals(payment.getSourceType()) || PayTypeConstants.SourceType.FREE.equals(payment.getSourceType())) {
|
||||
boolean isFree = PayTypeConstants.SourceType.FREE.equals(payment.getSourceType());
|
||||
ShopUser shopUser = shopUserService.getById(payment.getSourceId());
|
||||
OrderInfo orderInfo = null;
|
||||
@@ -1113,22 +1112,17 @@ public class OrderInfoCustomServiceImpl implements OrderInfoCustomService {
|
||||
payment.getId(), payment.getSourceType(), bizEnum, orderInfo == null);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (PayTypeConstants.SourceType.MEMBER_PAY.equals(payment.getSourceType())) {
|
||||
} else if (PayTypeConstants.SourceType.MEMBER_PAY.equals(payment.getSourceType())) {
|
||||
//购买会员
|
||||
ShopUser shopUser = shopUserService.getById(payment.getSourceId());
|
||||
memberConfigService.joinMember(payment.getShopId(), shopUser.getUserId(), payment.getRelatedId());
|
||||
}
|
||||
else if (PayTypeConstants.SourceType.DISTRIBUTION.equals(payment.getSourceType())) {
|
||||
} else if (PayTypeConstants.SourceType.DISTRIBUTION.equals(payment.getSourceType())) {
|
||||
distributionUserService.open(payment.getSourceId(), payment.getAmount(), payment.getShopId(), payment.getId());
|
||||
}
|
||||
else if (PayTypeConstants.SourceType.POINT.equals(payment.getSourceType())) {
|
||||
} else if (PayTypeConstants.SourceType.POINT.equals(payment.getSourceType())) {
|
||||
goodPayService.payCallBack(payment.getSourceId(), payment.getId());
|
||||
}
|
||||
else if (PayTypeConstants.SourceType.WARE.equals(payment.getSourceType())) {
|
||||
} else if (PayTypeConstants.SourceType.WARE.equals(payment.getSourceType())) {
|
||||
gbOrderService.payCallBack(payment.getSourceId(), payment.getId());
|
||||
}
|
||||
else if (PayTypeConstants.SourceType.PP.equals(payment.getSourceType())) {
|
||||
} else if (PayTypeConstants.SourceType.PP.equals(payment.getSourceType())) {
|
||||
ppPackageOrderService.paySuccess(payment.getSourceId(), payment.getId());
|
||||
}
|
||||
}
|
||||
@@ -1529,13 +1523,13 @@ public class OrderInfoCustomServiceImpl implements OrderInfoCustomService {
|
||||
|
||||
switch (orderInfoPrintDTO.getType()) {
|
||||
case 0:
|
||||
printerHandler.handler(orderInfo.getId().toString(), PrinterHandler.PrintTypeEnum.ONE_AND_ORDER);
|
||||
printerHandler.handler(orderInfo.getId().toString(), PrinterHandler.PrintTypeEnum.ONE_AND_ORDER, orderInfoPrintDTO.getMachineId());
|
||||
break;
|
||||
case 1:
|
||||
printerHandler.handler(orderInfo.getId().toString(), PrinterHandler.PrintTypeEnum.PRE_ORDER);
|
||||
printerHandler.handler(orderInfo.getId().toString(), PrinterHandler.PrintTypeEnum.PRE_ORDER, orderInfoPrintDTO.getMachineId());
|
||||
break;
|
||||
case 2:
|
||||
printerHandler.handler(orderInfo.getId().toString(), PrinterHandler.PrintTypeEnum.ORDER);
|
||||
printerHandler.handler(orderInfo.getId().toString(), PrinterHandler.PrintTypeEnum.ORDER, orderInfoPrintDTO.getMachineId());
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user