前台退菜单 默认打印

This commit is contained in:
2026-04-20 13:52:50 +08:00
parent 6b95d82124
commit ff319c3a13
9 changed files with 576 additions and 246 deletions

View File

@@ -38,4 +38,13 @@ public class FinanceStsController {
public void exportFinanceSts(@Validated(FinanceStsQueryParam.Export.class) FinanceStsQueryParam param, HttpServletResponse response) { public void exportFinanceSts(@Validated(FinanceStsQueryParam.Export.class) FinanceStsQueryParam param, HttpServletResponse response) {
financeStsService.exportFinanceSts(param, response); financeStsService.exportFinanceSts(param, response);
} }
/**
* 查询财务报表
*/
@GetMapping("/print")
public CzgResult<FinanceStsDTO> printFinanceSts(FinanceStsQueryParam param) {
return CzgResult.success(financeStsService.getFinanceSts(param));
}
} }

View File

@@ -53,7 +53,7 @@ public class OrderInfoRefundDTO implements Serializable {
/** /**
* 是否打印退菜/退款票 * 是否打印退菜/退款票
*/ */
private boolean print; private boolean print = true;
/** /**
* 是否退库存 * 是否退库存
*/ */

View File

@@ -32,52 +32,101 @@ public class DayReportPrintDTO implements Serializable {
*/ */
private String statisticsTime; private String statisticsTime;
/**
* 退款金额
*/
private BigDecimal refundAmount;
/**
* 退菜数量
*/
private Long returnDishCount;
/** /**
* 营业额 * 营业额
*/ */
private TurnoverSts turnover; private BusinessSts turnover;
/** /**
* 订单 * 收入来源
* 原价统计金额
*/ */
private OrderSts order; private Income sourceIncome;
/** /**
* 数据统计 * 实收统计
* 实际收入统计金额
*
*/ */
private Sts sts; private Income actualIncome;
/** /**
* 营业额 类 * 优惠统计
*/
private DiscountSts discountSta;
/**
* 营业统计
*/ */
@Data @Data
@Accessors(chain = true) @Accessors(chain = true)
public static class TurnoverSts { public static class BusinessSts {
/**
* 订单原价总额
*/
private BigDecimal originAmount;
/** /**
* 营业额 * 营业额
*/ */
private BigDecimal turnover; private BigDecimal turnover;
/**
* 优惠金额
*/
private BigDecimal discountAmount;
/**
* 订单总数
*/
private Long orderCount;
/**
* 折前单均价
* 订单原价总额/订单数量(含退款)
*/
private BigDecimal averageOrderAmount;
/**
* 折后单均价
* 营业额/订单数量(含退款)
*/
private BigDecimal averageTurnover;
/**
* 退款金额
*/
private BigDecimal refundAmount;
/**
* 退款订单数
*/
private Long refundOrderCount;
}
/**
* 收入统计类
*/
@Data
@Accessors(chain = true)
public static class Income {
/**
* 现金收款
*/
private BigDecimal cash;
/** /**
* 微信支付金额 * 微信支付金额
*/ */
private BigDecimal wechat; private BigDecimal wechat;
/** /**
* 支付宝支付金额 * 支付宝支付金额
*/ */
private BigDecimal alipay; private BigDecimal alipay;
/**
* 美团团购
*/
private BigDecimal meituan;
/**
* 抖音团购
*/
private BigDecimal douyin;
/**
* 其他
*/
private BigDecimal other;
/** /**
* 二维码收款 * 二维码收款
@@ -88,11 +137,6 @@ public class DayReportPrintDTO implements Serializable {
*/ */
private BigDecimal barScan; private BigDecimal barScan;
/**
* 现金收款
*/
private BigDecimal cash;
/** /**
* 充值 * 充值
*/ */
@@ -109,54 +153,45 @@ public class DayReportPrintDTO implements Serializable {
private BigDecimal balance; private BigDecimal balance;
} }
/**
* 订单 类
*/
@Data
@Accessors(chain = true)
public static class OrderSts {
/**
* 订单金额
*/
private BigDecimal orderAmount;
/**
* 订单总数
*/
private Long orderCount;
}
/** /**
* 数据统计 类 * 数据统计 类
*/ */
@Data @Data
@Accessors(chain = true) @Accessors(chain = true)
public static class Sts { public static class DiscountSts {
/** /**
* 就餐人数 * 新客立减
*/ */
private Long customerCount; private BigDecimal newConsumerDiscount;
/** /**
* 客单价 * 霸王餐
* 实付金额(包含现金支付 包含会员支付 包含挂账)/就餐人数
* 没有具体人数时默认一桌按照1人计算
*/ */
private BigDecimal avgPayAmount; private BigDecimal freeCashAmount;
/** /**
* 翻台率 * 满减活动
* (订单数-桌台数)/桌台数*100%
*/ */
private BigDecimal turnoverRate; private BigDecimal fullMinusAmount;
/** /**
* 商品成本 * 优惠券
*/ */
private BigDecimal productCostAmount; private BigDecimal couponAmount;
/** /**
* 毛利率(订单实付金额-商品成本)/订单实付金额*100% * 会员折扣
*/ */
private BigDecimal profitRate; private BigDecimal memberDiscount;
/**
* 积分抵扣金额
*/
private BigDecimal pointsDiscountAmount;
/**
* 订单改价
*/
private BigDecimal orderDiscount;
} }
} }

View File

@@ -0,0 +1,195 @@
package com.czg.print;
import lombok.Data;
import lombok.experimental.Accessors;
import java.io.Serial;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.List;
/**
* 日结单
*
* @author ww
*/
@Data
@Accessors(chain = true)
public class DaySettlePrintDTO implements Serializable {
@Serial
private static final long serialVersionUID = 1L;
/**
* 店铺名称
*/
private String shopName;
/**
* 操作人
*/
private String operator;
/**
* 统计时间
*/
private String statisticsTime;
/**
* 营业统计
*/
private BusinessSts turnover;
/**
* 收款构成
*/
private Income income;
/**
* 优惠统计
*/
private DiscountSts discountSta;
/**
* 敏感操作记录
* 退单/退菜/折扣/未结款
* 退单:仅统计整单退款(订单全额退款)的数据
* 退菜:仅统计单菜品退款的数据
* 折扣:使用任一折扣的订单数量和折扣金额
* 未结款:当天有待支付订单的数量和应付金额
*/
private List<OperationRecord> operationRecords;
/**
* 营业统计
*/
@Data
@Accessors(chain = true)
public static class BusinessSts {
/**
* 订单原价总额
*/
private BigDecimal originAmount;
/**
* 营业额
*/
private BigDecimal turnover;
/**
* 优惠金额
*/
private BigDecimal discountAmount;
/**
* 订单总数
*/
private Long orderCount;
/**
* 退款订单数
*/
private Long refundOrderCount;
/**
* 退款金额
*/
private BigDecimal refundAmount;
/**
* 现金收款
*/
private BigDecimal cash;
/**
* 备用金
*/
private BigDecimal reserve;
/**
* 钱箱剩余
*/
private BigDecimal cashBoxRemaining;
}
/**
* 收入统计类
*/
@Data
@Accessors(chain = true)
public static class Income {
/**
* 现金收款
*/
private BigDecimal cash;
/**
* 微信支付金额
*/
private BigDecimal wechat;
/**
* 支付宝支付金额
*/
private BigDecimal alipay;
/**
* 团购
*/
private BigDecimal group;
}
/**
* 优惠统计 类
*/
@Data
@Accessors(chain = true)
public static class DiscountSts {
/**
* 新客立减
*/
private BigDecimal newConsumerDiscount;
/**
* 霸王餐
*/
private BigDecimal freeCashAmount;
/**
* 满减活动
*/
private BigDecimal fullMinusAmount;
/**
* 优惠券
*/
private BigDecimal couponAmount;
/**
* 会员折扣
*/
private BigDecimal memberDiscount;
/**
* 积分抵扣金额
*/
private BigDecimal pointsDiscountAmount;
/**
* 订单改价
*/
private BigDecimal orderDiscount;
}
/**
* 敏感操作记录
*/
@Data
@Accessors(chain = true)
public static class OperationRecord {
/**
* 操作类型
*/
private String operation;
/**
* 数量
*/
private Long count;
/**
* 金额
*/
private BigDecimal amount;
}
}

View File

@@ -158,6 +158,15 @@ public class FeiPrinter extends PrinterHandler implements PrinterImpl {
printMachineLogService.save(machine, "经营日报单", data, resp); printMachineLogService.save(machine, "经营日报单", data, resp);
} }
@Override
protected void daySettlePrint(PrintMachine machine, String shopName, DaySettlePrintDTO record) {
record.setShopName(shopName);
String voiceJson = "{\"bizType\":\"2\",\"content\":\"\"}";
String data = buildDaySettleData(record);
String resp = sendPrintRequest(machine.getAddress(), data, voiceJson, machine.getPrintNum() == null ? "1" : machine.getPrintNum().toString());
printMachineLogService.save(machine, "日结单打印", data, resp);
}
@Override @Override
protected void productReportPrint(PrintMachine machine, String shopName, ProductReportPrintDTO record) { protected void productReportPrint(PrintMachine machine, String shopName, ProductReportPrintDTO record) {
record.setShopName(shopName); record.setShopName(shopName);

View File

@@ -200,6 +200,11 @@ public class PrintConfig implements ApplicationRunner {
.forEach(machine -> getPrinter(machine.getBrand()) .forEach(machine -> getPrinter(machine.getBrand())
.dayReportPrint(machine, shopInfo.getShopName(), JSONObject.parseObject(data.toJSONString(), DayReportPrintDTO.class))); .dayReportPrint(machine, shopInfo.getShopName(), JSONObject.parseObject(data.toJSONString(), DayReportPrintDTO.class)));
break; break;
case PrinterHandler.PrintTypeEnum.DAY_ORDER:
getPrintMachine(shopId, printTypeEnum)
.forEach(machine -> getPrinter(machine.getBrand())
.daySettlePrint(machine, shopInfo.getShopName(), JSONObject.parseObject(data.toJSONString(), DaySettlePrintDTO.class)));
break;
case PrinterHandler.PrintTypeEnum.PRODUCT_REPORT: case PrinterHandler.PrintTypeEnum.PRODUCT_REPORT:
getPrintMachine(shopId, printTypeEnum) getPrintMachine(shopId, printTypeEnum)
.forEach(machine -> getPrinter(machine.getBrand()) .forEach(machine -> getPrinter(machine.getBrand())

View File

@@ -363,6 +363,11 @@ public abstract class PrinterHandler {
*/ */
protected abstract void dayReportPrint(PrintMachine machine, String shopName, DayReportPrintDTO record); protected abstract void dayReportPrint(PrintMachine machine, String shopName, DayReportPrintDTO record);
/**
* 日结算单打印
*/
protected abstract void daySettlePrint(PrintMachine machine, String shopName, DaySettlePrintDTO record);
/** /**
* 商品报表打印 * 商品报表打印
*/ */

View File

@@ -103,16 +103,16 @@ public interface PrinterImpl {
*/ */
default String getDividingLine() { default String getDividingLine() {
String line = StrUtil.repeat("-", 32); String line = StrUtil.repeat("-", 32);
return getFormatLabel(line, getSignLabelInfo().s); return formatLabel(line, getSignLabelInfo().s);
} }
default String getDividingLine(Integer num) { default String getDividingLine(Integer num) {
int length = num == null ? 32 : num; int length = num == null ? 32 : num;
String line = StrUtil.repeat("-", length); String line = StrUtil.repeat("-", length);
return getFormatLabel(line, getSignLabelInfo().s); return formatLabel(line, getSignLabelInfo().s);
} }
default String getFormatLabel(String text, String[]... labels) { default String formatLabel(String text, String[]... labels) {
StringBuilder str = new StringBuilder(); StringBuilder str = new StringBuilder();
for (String[] label : labels) { for (String[] label : labels) {
str.append(label[0]); str.append(label[0]);
@@ -131,48 +131,48 @@ public interface PrinterImpl {
default String buildHandoverData(HandoverRecordDTO handoverRecord) { default String buildHandoverData(HandoverRecordDTO handoverRecord) {
PrintSignLabel signLabelInfo = getSignLabelInfo(); PrintSignLabel signLabelInfo = getSignLabelInfo();
StringBuilder builder = new StringBuilder() StringBuilder builder = new StringBuilder()
.append(getFormatLabel(handoverRecord.getShopName(), signLabelInfo.center)).append(signLabelInfo.br) .append(formatLabel(handoverRecord.getShopName(), signLabelInfo.center)).append(signLabelInfo.br)
.append(getFormatLabel("交班小票", signLabelInfo.center)).append(signLabelInfo.br) .append(formatLabel("交班小票", signLabelInfo.center)).append(signLabelInfo.br)
.append(getFormatLabel("交班时间: " + DateUtil.format(handoverRecord.getHandoverTime(), "yyyy/MM/dd HH:mm:ss"), signLabelInfo.s)).append(signLabelInfo.br) .append(formatLabel("交班时间: " + DateUtil.format(handoverRecord.getHandoverTime(), "yyyy/MM/dd HH:mm:ss"), signLabelInfo.s)).append(signLabelInfo.br)
.append(getFormatLabel("收银员: " + handoverRecord.getStaffName(), signLabelInfo.s)).append(signLabelInfo.br) .append(formatLabel("收银员: " + handoverRecord.getStaffName(), signLabelInfo.s)).append(signLabelInfo.br)
.append(getFormatLabel("交班周期: " + DateUtil.format(handoverRecord.getLoginTime(), "dd日HH:mm") + "--" + .append(formatLabel("交班周期: " + DateUtil.format(handoverRecord.getLoginTime(), "dd日HH:mm") + "--" +
DateUtil.format(handoverRecord.getHandoverTime(), "dd日HH:mm"), signLabelInfo.s)).append(signLabelInfo.br) DateUtil.format(handoverRecord.getHandoverTime(), "dd日HH:mm"), signLabelInfo.s)).append(signLabelInfo.br)
.append(signLabelInfo.br) .append(signLabelInfo.br)
.append(signLabelInfo.br) .append(signLabelInfo.br)
.append(getFormatLabel("当班营业总额: " + handoverRecord.getTurnover(), signLabelInfo.s)).append(signLabelInfo.br) .append(formatLabel("当班营业总额: " + handoverRecord.getTurnover(), signLabelInfo.s)).append(signLabelInfo.br)
.append(getFormatLabel("实际收款的支付方式", signLabelInfo.s)).append(signLabelInfo.br) .append(formatLabel("实际收款的支付方式", signLabelInfo.s)).append(signLabelInfo.br)
.append(getFormatLabel(leftRightAlign(" 现金:", bdToStr(handoverRecord.getCash()), 32), signLabelInfo.s)).append(signLabelInfo.br) .append(formatLabel(LRAlign(" 现金:", bdToStr(handoverRecord.getCash()), 32), signLabelInfo.s)).append(signLabelInfo.br)
.append(getFormatLabel(leftRightAlign(" 微信:", bdToStr(handoverRecord.getWechat()), 32), signLabelInfo.s)).append(signLabelInfo.br) .append(formatLabel(LRAlign(" 微信:", bdToStr(handoverRecord.getWechat()), 32), signLabelInfo.s)).append(signLabelInfo.br)
.append(getFormatLabel(leftRightAlign(" 支付宝:", bdToStr(handoverRecord.getAlipay()), 32), signLabelInfo.s)).append(signLabelInfo.br) .append(formatLabel(LRAlign(" 支付宝:", bdToStr(handoverRecord.getAlipay()), 32), signLabelInfo.s)).append(signLabelInfo.br)
.append(getFormatLabel(leftRightAlign(" 二维码收款:", bdToStr(handoverRecord.getSelfScan()), 32), signLabelInfo.s)).append(signLabelInfo.br) .append(formatLabel(LRAlign(" 二维码收款:", bdToStr(handoverRecord.getSelfScan()), 32), signLabelInfo.s)).append(signLabelInfo.br)
.append(getFormatLabel(leftRightAlign(" 扫码收款:", bdToStr(handoverRecord.getBarScan()), 32), signLabelInfo.s)).append(signLabelInfo.br) .append(formatLabel(LRAlign(" 扫码收款:", bdToStr(handoverRecord.getBarScan()), 32), signLabelInfo.s)).append(signLabelInfo.br)
.append(getFormatLabel(leftRightAlign(" 充值:", bdToStr(handoverRecord.getRecharge()), 32), signLabelInfo.s)).append(signLabelInfo.br) .append(formatLabel(LRAlign(" 充值:", bdToStr(handoverRecord.getRecharge()), 32), signLabelInfo.s)).append(signLabelInfo.br)
.append(getFormatLabel("非实际收款的支付方式", signLabelInfo.s)).append(signLabelInfo.br) .append(formatLabel("非实际收款的支付方式", signLabelInfo.s)).append(signLabelInfo.br)
.append(getFormatLabel(leftRightAlign(" 挂账:", bdToStr(handoverRecord.getOwed()), 32), signLabelInfo.s)).append(signLabelInfo.br) .append(formatLabel(LRAlign(" 挂账:", bdToStr(handoverRecord.getOwed()), 32), signLabelInfo.s)).append(signLabelInfo.br)
.append(getFormatLabel(leftRightAlign(" 余额:", bdToStr(handoverRecord.getBalance()), 32), signLabelInfo.s)).append(signLabelInfo.br) .append(formatLabel(LRAlign(" 余额:", bdToStr(handoverRecord.getBalance()), 32), signLabelInfo.s)).append(signLabelInfo.br)
.append(getDividingLine()).append(signLabelInfo.br) .append(getDividingLine()).append(signLabelInfo.br)
.append(getFormatLabel("退菜/退款", signLabelInfo.s)).append(signLabelInfo.br) .append(formatLabel("退菜/退款", signLabelInfo.s)).append(signLabelInfo.br)
.append(getFormatLabel(leftRightAlign(" 退款金额:", bdToStr(handoverRecord.getRefundAmount()), 32), signLabelInfo.s)).append(signLabelInfo.br) .append(formatLabel(LRAlign(" 退款金额:", bdToStr(handoverRecord.getRefundAmount()), 32), signLabelInfo.s)).append(signLabelInfo.br)
.append(getFormatLabel(leftRightAlign(" 退菜数量:", bdToStr(handoverRecord.getReturnDishCount()), 32), signLabelInfo.s)).append(signLabelInfo.br) .append(formatLabel(LRAlign(" 退菜数量:", bdToStr(handoverRecord.getReturnDishCount()), 32), signLabelInfo.s)).append(signLabelInfo.br)
.append(getDividingLine()).append(signLabelInfo.br) .append(getDividingLine()).append(signLabelInfo.br)
.append(getFormatLabel(leftRightAlign("订单数量/订单总额", handoverRecord.getOrderCount() + "/" + bdToStr(handoverRecord.getOrderTurnover()), 32), signLabelInfo.s)) .append(formatLabel(LRAlign("订单数量/订单总额", handoverRecord.getOrderCount() + "/" + bdToStr(handoverRecord.getOrderTurnover()), 32), signLabelInfo.s))
.append(signLabelInfo.br); .append(signLabelInfo.br);
if (StrUtil.isNotBlank(handoverRecord.getCategoryData())) { if (StrUtil.isNotBlank(handoverRecord.getCategoryData())) {
builder.append(getFormatLabel("----------- 销售数据 -----------", signLabelInfo.s)).append(signLabelInfo.br) builder.append(formatLabel("----------- 销售数据 -----------", signLabelInfo.s)).append(signLabelInfo.br)
.append(getFormatLabel(key3("商品分类", "数量", "总计", 14, 8), signLabelInfo.s)) .append(formatLabel(key3("商品分类", "数量", "总计", 14, 8), signLabelInfo.s))
.append(signLabelInfo.br); .append(signLabelInfo.br);
JSONArray.parseArray(handoverRecord.getCategoryData()).forEach(item -> { JSONArray.parseArray(handoverRecord.getCategoryData()).forEach(item -> {
JSONObject info = (JSONObject) item; JSONObject info = (JSONObject) item;
String categoryName = info.getString("categoryName"); String categoryName = info.getString("categoryName");
Integer quantity = info.getInteger("quantity"); Integer quantity = info.getInteger("quantity");
BigDecimal amount = info.getBigDecimal("amount"); BigDecimal amount = info.getBigDecimal("amount");
builder.append(getFormatLabel(key3(categoryName, quantity.toString(), bdToStr(amount), 14, 8), signLabelInfo.s)).append(signLabelInfo.br); builder.append(formatLabel(key3(categoryName, quantity.toString(), bdToStr(amount), 14, 8), signLabelInfo.s)).append(signLabelInfo.br);
}); });
} }
builder.append(getDividingLine()).append(signLabelInfo.br) builder.append(getDividingLine()).append(signLabelInfo.br)
.append(getFormatLabel("打印时间: " + DateUtil.format(DateUtil.date(), "yyyy/MM/dd HH:mm:ss"), signLabelInfo.s)).append(signLabelInfo.br) .append(formatLabel("打印时间: " + DateUtil.format(DateUtil.date(), "yyyy/MM/dd HH:mm:ss"), signLabelInfo.s)).append(signLabelInfo.br)
.append(signLabelInfo.getOut(180)) .append(signLabelInfo.getOut(180))
.append(signLabelInfo.cut); .append(signLabelInfo.cut);
return builder.toString(); return builder.toString();
@@ -188,16 +188,16 @@ public interface PrinterImpl {
default String buildOrderPrintData(OrderPrintDTO orderPrintDTO, List<OrderDetail> detailList) { default String buildOrderPrintData(OrderPrintDTO orderPrintDTO, List<OrderDetail> detailList) {
PrintSignLabel signLabelInfo = getSignLabelInfo(); PrintSignLabel signLabelInfo = getSignLabelInfo();
StringBuilder data = new StringBuilder(); StringBuilder data = new StringBuilder();
data.append(getFormatLabel(orderPrintDTO.getShopName(), signLabelInfo.center)).append(signLabelInfo.br); data.append(formatLabel(orderPrintDTO.getShopName(), signLabelInfo.center)).append(signLabelInfo.br);
data.append(getFormatLabel(orderPrintDTO.getPrintTitle(), signLabelInfo.center)).append(signLabelInfo.br); data.append(formatLabel(orderPrintDTO.getPrintTitle(), signLabelInfo.center)).append(signLabelInfo.br);
data.append(getFormatLabel(orderPrintDTO.getPickupNum(), signLabelInfo.f)).append(signLabelInfo.br); data.append(formatLabel(orderPrintDTO.getPickupNum(), signLabelInfo.f)).append(signLabelInfo.br);
data.append(getFormatLabel(getFormatLabel(leftRightAlign(orderPrintDTO.getPrintType(), StrUtil.isNotBlank(orderPrintDTO.getSeatNum()) ? orderPrintDTO.getSeatNum() + "" : "", 32)) data.append(formatLabel(formatLabel(LRAlign(orderPrintDTO.getPrintType(), StrUtil.isNotBlank(orderPrintDTO.getSeatNum()) ? orderPrintDTO.getSeatNum() + "" : "", 32))
, signLabelInfo.s)).append(signLabelInfo.br); , signLabelInfo.s)).append(signLabelInfo.br);
if (StrUtil.isNotBlank(orderPrintDTO.getTradeDate())) { if (StrUtil.isNotBlank(orderPrintDTO.getTradeDate())) {
data.append(getFormatLabel(StrUtil.format("结账时间:{}", orderPrintDTO.getTradeDate()), signLabelInfo.s)).append(signLabelInfo.br); data.append(formatLabel(StrUtil.format("结账时间:{}", orderPrintDTO.getTradeDate()), signLabelInfo.s)).append(signLabelInfo.br);
} }
data.append(getDividingLine()).append(signLabelInfo.br); data.append(getDividingLine()).append(signLabelInfo.br);
data.append(getFormatLabel(key3("品名", "单价", "数量", 18, 9), signLabelInfo.s)).append(signLabelInfo.br); data.append(formatLabel(key3("品名", "单价", "数量", 18, 9), signLabelInfo.s)).append(signLabelInfo.br);
for (OrderDetail detail : detailList) { for (OrderDetail detail : detailList) {
BigDecimal subtract = detail.getNum().subtract(detail.getReturnNum()); BigDecimal subtract = detail.getNum().subtract(detail.getReturnNum());
@@ -206,10 +206,10 @@ public interface PrinterImpl {
} }
String number = subtract.stripTrailingZeros().toPlainString(); String number = subtract.stripTrailingZeros().toPlainString();
String unitPrice = toPlainStr(detail.getUnitPrice().stripTrailingZeros().toPlainString()); String unitPrice = toPlainStr(detail.getUnitPrice().stripTrailingZeros().toPlainString());
data.append(getFormatLabel(key3(detail.getProductName(), unitPrice, number, 18, 7), signLabelInfo.s)).append(signLabelInfo.br); data.append(formatLabel(key3(detail.getProductName(), unitPrice, number, 18, 7), signLabelInfo.s)).append(signLabelInfo.br);
if (StrUtil.isNotBlank(detail.getSkuName())) { if (StrUtil.isNotBlank(detail.getSkuName())) {
data.append(getFormatLabel(StrUtil.format("规格:{}", detail.getSkuName()), signLabelInfo.s)) data.append(formatLabel(StrUtil.format("规格:{}", detail.getSkuName()), signLabelInfo.s))
.append(signLabelInfo.br); .append(signLabelInfo.br);
} }
String proGroupInfo = detail.getProGroupInfo(); String proGroupInfo = detail.getProGroupInfo();
@@ -225,39 +225,39 @@ public interface PrinterImpl {
jsonObject.getJSONArray("goods").forEach(item -> { jsonObject.getJSONArray("goods").forEach(item -> {
String proName = ((JSONObject) item).getString("proName"); String proName = ((JSONObject) item).getString("proName");
String qty = ((JSONObject) item).getString("number"); String qty = ((JSONObject) item).getString("number");
data.append(getFormatLabel(key3(" - " + proName, "", qty, 18, 9), signLabelInfo.s)).append(signLabelInfo.br); data.append(formatLabel(key3(" - " + proName, "", qty, 18, 9), signLabelInfo.s)).append(signLabelInfo.br);
}); });
} }
} }
if (StrUtil.isNotBlank(orderPrintDTO.getSeatAmount())) { if (StrUtil.isNotBlank(orderPrintDTO.getSeatAmount())) {
data.append(getFormatLabel(key3("餐位费", orderPrintDTO.getSeatAmount(), orderPrintDTO.getSeatNum(), 18, 9), signLabelInfo.s)).append(signLabelInfo.br); data.append(formatLabel(key3("餐位费", orderPrintDTO.getSeatAmount(), orderPrintDTO.getSeatNum(), 18, 9), signLabelInfo.s)).append(signLabelInfo.br);
} }
if (StrUtil.isNotBlank(orderPrintDTO.getPackFee())) { if (StrUtil.isNotBlank(orderPrintDTO.getPackFee())) {
data.append(getFormatLabel(key3("打包费", toPlainStr(orderPrintDTO.getPackFee()), "", 18, 9), signLabelInfo.s)).append(signLabelInfo.br); data.append(formatLabel(key3("打包费", toPlainStr(orderPrintDTO.getPackFee()), "", 18, 9), signLabelInfo.s)).append(signLabelInfo.br);
} }
data.append(getDividingLine()) data.append(getDividingLine())
.append(signLabelInfo.br); .append(signLabelInfo.br);
data.append(getFormatLabel(leftRightAlign("原价:", orderPrintDTO.getOriginalAmount(), 32), signLabelInfo.s)).append(signLabelInfo.br); data.append(formatLabel(LRAlign("原价:", orderPrintDTO.getOriginalAmount(), 32), signLabelInfo.s)).append(signLabelInfo.br);
if (ObjectUtil.isNotNull(orderPrintDTO.getDiscountAmount())) { if (ObjectUtil.isNotNull(orderPrintDTO.getDiscountAmount())) {
data.append(getFormatLabel(leftRightAlign("优惠:", "-" + orderPrintDTO.getDiscountAmount(), 32), signLabelInfo.s)).append(signLabelInfo.br); data.append(formatLabel(LRAlign("优惠:", "-" + orderPrintDTO.getDiscountAmount(), 32), signLabelInfo.s)).append(signLabelInfo.br);
} }
if (StrUtil.isNotBlank(orderPrintDTO.getRemark())) { if (StrUtil.isNotBlank(orderPrintDTO.getRemark())) {
data.append(getFormatLabel(StrUtil.format("备注:{}", orderPrintDTO.getRemark()), signLabelInfo.s)).append(signLabelInfo.br); data.append(formatLabel(StrUtil.format("备注:{}", orderPrintDTO.getRemark()), signLabelInfo.s)).append(signLabelInfo.br);
} }
data.append(getDividingLine()).append(signLabelInfo.br); data.append(getDividingLine()).append(signLabelInfo.br);
data.append(getFormatLabel(leftRightAlign("应付:", orderPrintDTO.getPayAmount(), 16), signLabelInfo.f)).append(signLabelInfo.br); data.append(formatLabel(LRAlign("应付:", orderPrintDTO.getPayAmount(), 16), signLabelInfo.f)).append(signLabelInfo.br);
if ("结算单".equals(orderPrintDTO.getPrintTitle())) { if ("结算单".equals(orderPrintDTO.getPrintTitle())) {
data.append(getDividingLine()).append(signLabelInfo.br); data.append(getDividingLine()).append(signLabelInfo.br);
data.append(getFormatLabel(leftRightAlign("已付:", orderPrintDTO.getPayAmount(), 16), signLabelInfo.f)).append(signLabelInfo.br); data.append(formatLabel(LRAlign("已付:", orderPrintDTO.getPayAmount(), 16), signLabelInfo.f)).append(signLabelInfo.br);
data.append(getFormatLabel(leftRightAlign("支付方式:", orderPrintDTO.getPayType(), 32), signLabelInfo.s)).append(signLabelInfo.br); data.append(formatLabel(LRAlign("支付方式:", orderPrintDTO.getPayType(), 32), signLabelInfo.s)).append(signLabelInfo.br);
} }
data.append(getDividingLine()).append(signLabelInfo.br); data.append(getDividingLine()).append(signLabelInfo.br);
data.append(getFormatLabel(StrUtil.format("操作员:{}", orderPrintDTO.getOperator()), signLabelInfo.s)).append(signLabelInfo.br); data.append(formatLabel(StrUtil.format("操作员:{}", orderPrintDTO.getOperator()), signLabelInfo.s)).append(signLabelInfo.br);
data.append(getFormatLabel(StrUtil.format("打印时间:{}", DateUtil.date().toString()), signLabelInfo.s)).append(signLabelInfo.br); data.append(formatLabel(StrUtil.format("打印时间:{}", DateUtil.date().toString()), signLabelInfo.s)).append(signLabelInfo.br);
data.append(getFormatLabel(StrUtil.format("订单号:{}", orderPrintDTO.getOrderNo()), signLabelInfo.s)).append(signLabelInfo.br); data.append(formatLabel(StrUtil.format("订单号:{}", orderPrintDTO.getOrderNo()), signLabelInfo.s)).append(signLabelInfo.br);
data.append(signLabelInfo.getOut(180)); data.append(signLabelInfo.getOut(180));
data.append(signLabelInfo.cut); data.append(signLabelInfo.cut);
return data.toString(); return data.toString();
@@ -273,15 +273,15 @@ public interface PrinterImpl {
default String buildGuestOrderPrintData(OrderPrintDTO orderPrintDTO, List<OrderDetail> detailList) { default String buildGuestOrderPrintData(OrderPrintDTO orderPrintDTO, List<OrderDetail> detailList) {
PrintSignLabel signLabelInfo = getSignLabelInfo(); PrintSignLabel signLabelInfo = getSignLabelInfo();
StringBuilder data = new StringBuilder(); StringBuilder data = new StringBuilder();
data.append(getFormatLabel(orderPrintDTO.getShopName(), signLabelInfo.center)).append(signLabelInfo.br); data.append(formatLabel(orderPrintDTO.getShopName(), signLabelInfo.center)).append(signLabelInfo.br);
data.append(getFormatLabel("客看单", signLabelInfo.center)).append(signLabelInfo.br); data.append(formatLabel("客看单", signLabelInfo.center)).append(signLabelInfo.br);
if (StrUtil.isNotBlank(orderPrintDTO.getPickupNum())) { if (StrUtil.isNotBlank(orderPrintDTO.getPickupNum())) {
data.append(getFormatLabel(orderPrintDTO.getPickupNum(), signLabelInfo.f)).append(signLabelInfo.br); data.append(formatLabel(orderPrintDTO.getPickupNum(), signLabelInfo.f)).append(signLabelInfo.br);
} }
data.append(getFormatLabel(getFormatLabel(leftRightAlign(orderPrintDTO.getPrintType(), StrUtil.isNotBlank(orderPrintDTO.getSeatNum()) ? orderPrintDTO.getSeatNum() + "" : "", 32)) data.append(formatLabel(formatLabel(LRAlign(orderPrintDTO.getPrintType(), StrUtil.isNotBlank(orderPrintDTO.getSeatNum()) ? orderPrintDTO.getSeatNum() + "" : "", 32))
, signLabelInfo.s)).append(signLabelInfo.br); , signLabelInfo.s)).append(signLabelInfo.br);
data.append(getDividingLine()).append(signLabelInfo.br); data.append(getDividingLine()).append(signLabelInfo.br);
data.append(getFormatLabel(key3("品名", "单价", "数量", 18, 9), signLabelInfo.s)).append(signLabelInfo.br); data.append(formatLabel(key3("品名", "单价", "数量", 18, 9), signLabelInfo.s)).append(signLabelInfo.br);
for (OrderDetail detail : detailList) { for (OrderDetail detail : detailList) {
BigDecimal subtract = detail.getNum().subtract(detail.getReturnNum()); BigDecimal subtract = detail.getNum().subtract(detail.getReturnNum());
@@ -290,10 +290,10 @@ public interface PrinterImpl {
} }
String number = subtract.stripTrailingZeros().toPlainString(); String number = subtract.stripTrailingZeros().toPlainString();
String unitPrice = toPlainStr(detail.getUnitPrice().stripTrailingZeros().toPlainString()); String unitPrice = toPlainStr(detail.getUnitPrice().stripTrailingZeros().toPlainString());
data.append(getFormatLabel(key3(detail.getProductName(), unitPrice, number, 18, 7), signLabelInfo.s)).append(signLabelInfo.br); data.append(formatLabel(key3(detail.getProductName(), unitPrice, number, 18, 7), signLabelInfo.s)).append(signLabelInfo.br);
if (StrUtil.isNotBlank(detail.getSkuName())) { if (StrUtil.isNotBlank(detail.getSkuName())) {
data.append(getFormatLabel(StrUtil.format("规格:{}", detail.getSkuName()), signLabelInfo.s)) data.append(formatLabel(StrUtil.format("规格:{}", detail.getSkuName()), signLabelInfo.s))
.append(signLabelInfo.br); .append(signLabelInfo.br);
} }
String proGroupInfo = detail.getProGroupInfo(); String proGroupInfo = detail.getProGroupInfo();
@@ -309,28 +309,28 @@ public interface PrinterImpl {
jsonObject.getJSONArray("goods").forEach(item -> { jsonObject.getJSONArray("goods").forEach(item -> {
String proName = ((JSONObject) item).getString("proName"); String proName = ((JSONObject) item).getString("proName");
String qty = ((JSONObject) item).getString("number"); String qty = ((JSONObject) item).getString("number");
data.append(getFormatLabel(key3(" - " + proName, "", qty, 18, 9), signLabelInfo.s)).append(signLabelInfo.br); data.append(formatLabel(key3(" - " + proName, "", qty, 18, 9), signLabelInfo.s)).append(signLabelInfo.br);
}); });
} }
} }
if (StrUtil.isNotBlank(orderPrintDTO.getSeatAmount())) { if (StrUtil.isNotBlank(orderPrintDTO.getSeatAmount())) {
data.append(getFormatLabel(key3("餐位费", orderPrintDTO.getSeatAmount(), orderPrintDTO.getSeatNum(), 18, 9), signLabelInfo.s)).append(signLabelInfo.br); data.append(formatLabel(key3("餐位费", orderPrintDTO.getSeatAmount(), orderPrintDTO.getSeatNum(), 18, 9), signLabelInfo.s)).append(signLabelInfo.br);
} }
if (StrUtil.isNotBlank(orderPrintDTO.getPackFee())) { if (StrUtil.isNotBlank(orderPrintDTO.getPackFee())) {
data.append(getFormatLabel(key3("打包费", toPlainStr(orderPrintDTO.getPackFee()), "", 18, 9), signLabelInfo.s)).append(signLabelInfo.br); data.append(formatLabel(key3("打包费", toPlainStr(orderPrintDTO.getPackFee()), "", 18, 9), signLabelInfo.s)).append(signLabelInfo.br);
} }
data.append(getDividingLine()).append(signLabelInfo.br); data.append(getDividingLine()).append(signLabelInfo.br);
data.append(getFormatLabel(leftRightAlign("原价:", orderPrintDTO.getOriginalAmount(), 32), signLabelInfo.s)).append(signLabelInfo.br); data.append(formatLabel(LRAlign("原价:", orderPrintDTO.getOriginalAmount(), 32), signLabelInfo.s)).append(signLabelInfo.br);
if (ObjectUtil.isNotNull(orderPrintDTO.getDiscountAmount())) { if (ObjectUtil.isNotNull(orderPrintDTO.getDiscountAmount())) {
data.append(getFormatLabel(leftRightAlign("优惠:", "-" + orderPrintDTO.getDiscountAmount(), 32), signLabelInfo.s)).append(signLabelInfo.br); data.append(formatLabel(LRAlign("优惠:", "-" + orderPrintDTO.getDiscountAmount(), 32), signLabelInfo.s)).append(signLabelInfo.br);
} }
if (StrUtil.isNotBlank(orderPrintDTO.getRemark())) { if (StrUtil.isNotBlank(orderPrintDTO.getRemark())) {
data.append(getFormatLabel(StrUtil.format("备注:{}", orderPrintDTO.getRemark()), signLabelInfo.s)).append(signLabelInfo.br); data.append(formatLabel(StrUtil.format("备注:{}", orderPrintDTO.getRemark()), signLabelInfo.s)).append(signLabelInfo.br);
} }
data.append(getDividingLine()).append(signLabelInfo.br); data.append(getDividingLine()).append(signLabelInfo.br);
data.append(getFormatLabel(StrUtil.format("操作员:{}", orderPrintDTO.getOperator()), signLabelInfo.s)).append(signLabelInfo.br); data.append(formatLabel(StrUtil.format("操作员:{}", orderPrintDTO.getOperator()), signLabelInfo.s)).append(signLabelInfo.br);
data.append(getFormatLabel(StrUtil.format("打印时间:{}", DateUtil.date().toString()), signLabelInfo.s)).append(signLabelInfo.br); data.append(formatLabel(StrUtil.format("打印时间:{}", DateUtil.date().toString()), signLabelInfo.s)).append(signLabelInfo.br);
data.append(getFormatLabel(StrUtil.format("订单号:{}", orderPrintDTO.getOrderNo()), signLabelInfo.s)).append(signLabelInfo.br); data.append(formatLabel(StrUtil.format("订单号:{}", orderPrintDTO.getOrderNo()), signLabelInfo.s)).append(signLabelInfo.br);
data.append(signLabelInfo.getOut(180)); data.append(signLabelInfo.getOut(180));
data.append(signLabelInfo.cut); data.append(signLabelInfo.cut);
return data.toString(); return data.toString();
@@ -346,14 +346,14 @@ public interface PrinterImpl {
default String buildRefundOrderPrintData(OrderPrintDTO orderPrintDTO, List<OrderDetail> detailList) { default String buildRefundOrderPrintData(OrderPrintDTO orderPrintDTO, List<OrderDetail> detailList) {
PrintSignLabel signLabelInfo = getSignLabelInfo(); PrintSignLabel signLabelInfo = getSignLabelInfo();
StringBuilder data = new StringBuilder(); StringBuilder data = new StringBuilder();
data.append(getFormatLabel(orderPrintDTO.getShopName(), signLabelInfo.center)).append(signLabelInfo.br); data.append(formatLabel(orderPrintDTO.getShopName(), signLabelInfo.center)).append(signLabelInfo.br);
data.append(getFormatLabel(orderPrintDTO.getPrintTitle(), signLabelInfo.center)).append(signLabelInfo.br); data.append(formatLabel(orderPrintDTO.getPrintTitle(), signLabelInfo.center)).append(signLabelInfo.br);
data.append(getFormatLabel(orderPrintDTO.getPickupNum(), signLabelInfo.f)).append(signLabelInfo.br); data.append(formatLabel(orderPrintDTO.getPickupNum(), signLabelInfo.f)).append(signLabelInfo.br);
data.append(getFormatLabel(getFormatLabel(leftRightAlign(orderPrintDTO.getPrintType(), StrUtil.isNotBlank(orderPrintDTO.getSeatNum()) ? orderPrintDTO.getSeatNum() + "" : "", 32)) data.append(formatLabel(formatLabel(LRAlign(orderPrintDTO.getPrintType(), StrUtil.isNotBlank(orderPrintDTO.getSeatNum()) ? orderPrintDTO.getSeatNum() + "" : "", 32))
, signLabelInfo.s)).append(signLabelInfo.br); , signLabelInfo.s)).append(signLabelInfo.br);
data.append(getDividingLine()).append(signLabelInfo.br); data.append(getDividingLine()).append(signLabelInfo.br);
if (CollUtil.isNotEmpty(detailList)) { if (CollUtil.isNotEmpty(detailList)) {
data.append(getFormatLabel(key3("退款明细", "数量", "小计", 18, 9), signLabelInfo.s)).append(signLabelInfo.br); data.append(formatLabel(key3("退款明细", "数量", "小计", 18, 9), signLabelInfo.s)).append(signLabelInfo.br);
for (OrderDetail detail : detailList) { for (OrderDetail detail : detailList) {
String number = detail.getNum().stripTrailingZeros().toPlainString(); String number = detail.getNum().stripTrailingZeros().toPlainString();
@@ -361,9 +361,9 @@ public interface PrinterImpl {
if ("退款单".equals(orderPrintDTO.getPrintTitle())) { if ("退款单".equals(orderPrintDTO.getPrintTitle())) {
amount = detail.getReturnAmount().stripTrailingZeros().toPlainString(); amount = detail.getReturnAmount().stripTrailingZeros().toPlainString();
} }
data.append(getFormatLabel(key3(detail.getProductName(), number, amount, 18, 7), signLabelInfo.s)).append(signLabelInfo.br); data.append(formatLabel(key3(detail.getProductName(), number, amount, 18, 7), signLabelInfo.s)).append(signLabelInfo.br);
if (StrUtil.isNotBlank(detail.getSkuName())) { if (StrUtil.isNotBlank(detail.getSkuName())) {
data.append(getFormatLabel(StrUtil.format("规格:{}", detail.getSkuName()), signLabelInfo.s)) data.append(formatLabel(StrUtil.format("规格:{}", detail.getSkuName()), signLabelInfo.s))
.append(signLabelInfo.br); .append(signLabelInfo.br);
} }
String proGroupInfo = detail.getProGroupInfo(); String proGroupInfo = detail.getProGroupInfo();
@@ -379,7 +379,7 @@ public interface PrinterImpl {
jsonObject.getJSONArray("goods").forEach(item -> { jsonObject.getJSONArray("goods").forEach(item -> {
String proName = ((JSONObject) item).getString("proName"); String proName = ((JSONObject) item).getString("proName");
String qty = ((JSONObject) item).getString("number"); String qty = ((JSONObject) item).getString("number");
data.append(getFormatLabel(key3(" - " + proName, "", qty, 18, 9), signLabelInfo.s)).append(signLabelInfo.br); data.append(formatLabel(key3(" - " + proName, "", qty, 18, 9), signLabelInfo.s)).append(signLabelInfo.br);
}); });
} }
} }
@@ -387,20 +387,20 @@ public interface PrinterImpl {
.append(signLabelInfo.br); .append(signLabelInfo.br);
} }
if ("退款单".equals(orderPrintDTO.getPrintTitle())) { if ("退款单".equals(orderPrintDTO.getPrintTitle())) {
data.append(getFormatLabel(leftRightAlign("退款总计", orderPrintDTO.getRefundAmount(), 16), signLabelInfo.f)).append(signLabelInfo.br); data.append(formatLabel(LRAlign("退款总计", orderPrintDTO.getRefundAmount(), 16), signLabelInfo.f)).append(signLabelInfo.br);
data.append(getFormatLabel(StrUtil.format("退款方式: {}", orderPrintDTO.getRefundType()), signLabelInfo.s)) data.append(formatLabel(StrUtil.format("退款方式: {}", orderPrintDTO.getRefundType()), signLabelInfo.s))
.append(signLabelInfo.br); .append(signLabelInfo.br);
data.append(getFormatLabel(StrUtil.format("退款原因: {}", orderPrintDTO.getRefundReason()), signLabelInfo.s)) data.append(formatLabel(StrUtil.format("退款原因: {}", orderPrintDTO.getRefundReason()), signLabelInfo.s))
.append(signLabelInfo.br); .append(signLabelInfo.br);
} else { } else {
data.append(getFormatLabel(StrUtil.format("退菜原因: {}", orderPrintDTO.getRefundReason()), signLabelInfo.s)) data.append(formatLabel(StrUtil.format("退菜原因: {}", orderPrintDTO.getRefundReason()), signLabelInfo.s))
.append(signLabelInfo.br); .append(signLabelInfo.br);
} }
data.append(getDividingLine()) data.append(getDividingLine())
.append(signLabelInfo.br); .append(signLabelInfo.br);
data.append(getFormatLabel(StrUtil.format("操作员:{}", orderPrintDTO.getOperator()), signLabelInfo.s)).append(signLabelInfo.br); data.append(formatLabel(StrUtil.format("操作员:{}", orderPrintDTO.getOperator()), signLabelInfo.s)).append(signLabelInfo.br);
data.append(getFormatLabel(StrUtil.format("打印时间:{}", DateUtil.date().toString()), signLabelInfo.s)).append(signLabelInfo.br); data.append(formatLabel(StrUtil.format("打印时间:{}", DateUtil.date().toString()), signLabelInfo.s)).append(signLabelInfo.br);
data.append(getFormatLabel(StrUtil.format("订单号:{}", orderPrintDTO.getOrderNo()), signLabelInfo.s)).append(signLabelInfo.br); data.append(formatLabel(StrUtil.format("订单号:{}", orderPrintDTO.getOrderNo()), signLabelInfo.s)).append(signLabelInfo.br);
data.append(signLabelInfo.getOut(180)); data.append(signLabelInfo.getOut(180));
data.append(signLabelInfo.cut); data.append(signLabelInfo.cut);
return data.toString(); return data.toString();
@@ -415,19 +415,19 @@ public interface PrinterImpl {
default String buildAllKitchenPrintData(OrderPrintDTO orderPrintDTO, List<OrderDetail> detailList) { default String buildAllKitchenPrintData(OrderPrintDTO orderPrintDTO, List<OrderDetail> detailList) {
PrintSignLabel signLabelInfo = getSignLabelInfo(); PrintSignLabel signLabelInfo = getSignLabelInfo();
StringBuilder data = new StringBuilder(); StringBuilder data = new StringBuilder();
data.append(getFormatLabel(orderPrintDTO.getShopName(), signLabelInfo.center)).append(signLabelInfo.br); data.append(formatLabel(orderPrintDTO.getShopName(), signLabelInfo.center)).append(signLabelInfo.br);
data.append(getFormatLabel(orderPrintDTO.getPrintTitle(), signLabelInfo.center)).append(signLabelInfo.br); data.append(formatLabel(orderPrintDTO.getPrintTitle(), signLabelInfo.center)).append(signLabelInfo.br);
data.append(getFormatLabel(orderPrintDTO.getPickupNum(), signLabelInfo.f)).append(signLabelInfo.br); data.append(formatLabel(orderPrintDTO.getPickupNum(), signLabelInfo.f)).append(signLabelInfo.br);
data.append(getFormatLabel(getFormatLabel(orderPrintDTO.getPrintType()), signLabelInfo.s)).append(signLabelInfo.br); data.append(formatLabel(formatLabel(orderPrintDTO.getPrintType()), signLabelInfo.s)).append(signLabelInfo.br);
data.append(getDividingLine()).append(signLabelInfo.br); data.append(getDividingLine()).append(signLabelInfo.br);
if (CollUtil.isNotEmpty(detailList)) { if (CollUtil.isNotEmpty(detailList)) {
data.append(getFormatLabel(leftRightAlign("品名", "数量", 32), signLabelInfo.s)).append(signLabelInfo.br); data.append(formatLabel(LRAlign("品名", "数量", 32), signLabelInfo.s)).append(signLabelInfo.br);
for (OrderDetail detail : detailList) { for (OrderDetail detail : detailList) {
BigDecimal num = detail.getNum().subtract(detail.getReturnNum()); BigDecimal num = detail.getNum().subtract(detail.getReturnNum());
data.append(getFormatLabel(leftRightAlign(detail.getProductName(), num.stripTrailingZeros().toPlainString(), 32), signLabelInfo.s)).append(signLabelInfo.br); data.append(formatLabel(LRAlign(detail.getProductName(), num.stripTrailingZeros().toPlainString(), 32), signLabelInfo.s)).append(signLabelInfo.br);
if (StrUtil.isNotBlank(detail.getSkuName())) { if (StrUtil.isNotBlank(detail.getSkuName())) {
data.append(getFormatLabel(StrUtil.format("规格:{}", detail.getSkuName()), signLabelInfo.s)) data.append(formatLabel(StrUtil.format("规格:{}", detail.getSkuName()), signLabelInfo.s))
.append(signLabelInfo.br); .append(signLabelInfo.br);
} }
String proGroupInfo = detail.getProGroupInfo(); String proGroupInfo = detail.getProGroupInfo();
@@ -438,25 +438,25 @@ public interface PrinterImpl {
jsonObject.getJSONArray("goods").forEach(item -> { jsonObject.getJSONArray("goods").forEach(item -> {
String proName = ((JSONObject) item).getString("proName"); String proName = ((JSONObject) item).getString("proName");
String qty = ((JSONObject) item).getString("number"); String qty = ((JSONObject) item).getString("number");
data.append(getFormatLabel(key3(" - " + proName, "", qty, 18, 9), signLabelInfo.s)).append(signLabelInfo.br); data.append(formatLabel(key3(" - " + proName, "", qty, 18, 9), signLabelInfo.s)).append(signLabelInfo.br);
}); });
} }
} }
if (StrUtil.isNotBlank(detail.getRemark()) && !"null".equals(detail.getRemark())) { if (StrUtil.isNotBlank(detail.getRemark()) && !"null".equals(detail.getRemark())) {
data.append(getFormatLabel(StrUtil.format(" 备注:{}", detail.getRemark()), signLabelInfo.s)).append(signLabelInfo.br); data.append(formatLabel(StrUtil.format(" 备注:{}", detail.getRemark()), signLabelInfo.s)).append(signLabelInfo.br);
} }
} }
data.append(getDividingLine()) data.append(getDividingLine())
.append(signLabelInfo.br); .append(signLabelInfo.br);
} }
if (StrUtil.isNotBlank(orderPrintDTO.getRemark()) && !"null".equals(orderPrintDTO.getRemark())) { if (StrUtil.isNotBlank(orderPrintDTO.getRemark()) && !"null".equals(orderPrintDTO.getRemark())) {
data.append(getFormatLabel(StrUtil.format("备注: {}", orderPrintDTO.getRemark()), signLabelInfo.s)).append(signLabelInfo.br); data.append(formatLabel(StrUtil.format("备注: {}", orderPrintDTO.getRemark()), signLabelInfo.s)).append(signLabelInfo.br);
data.append(getDividingLine()).append(signLabelInfo.br); data.append(getDividingLine()).append(signLabelInfo.br);
} }
data.append(getFormatLabel(StrUtil.format("操作员:{}", orderPrintDTO.getOperator()), signLabelInfo.s)).append(signLabelInfo.br); data.append(formatLabel(StrUtil.format("操作员:{}", orderPrintDTO.getOperator()), signLabelInfo.s)).append(signLabelInfo.br);
data.append(getFormatLabel(StrUtil.format("打印时间:{}", DateUtil.date().toString()), signLabelInfo.s)).append(signLabelInfo.br); data.append(formatLabel(StrUtil.format("打印时间:{}", DateUtil.date().toString()), signLabelInfo.s)).append(signLabelInfo.br);
data.append(getFormatLabel(StrUtil.format("订单号:{}", orderPrintDTO.getOrderNo()), signLabelInfo.s)).append(signLabelInfo.br); data.append(formatLabel(StrUtil.format("订单号:{}", orderPrintDTO.getOrderNo()), signLabelInfo.s)).append(signLabelInfo.br);
data.append(signLabelInfo.getOut(180)); data.append(signLabelInfo.getOut(180));
data.append(signLabelInfo.cut); data.append(signLabelInfo.cut);
return data.toString(); return data.toString();
@@ -471,9 +471,9 @@ public interface PrinterImpl {
default String buildOnlyKitchenPrintData(String pickupNumber, OrderDetail orderDetail) { default String buildOnlyKitchenPrintData(String pickupNumber, OrderDetail orderDetail) {
PrintSignLabel signLabelInfo = getSignLabelInfo(); PrintSignLabel signLabelInfo = getSignLabelInfo();
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
builder.append(getFormatLabel(pickupNumber, signLabelInfo.centerBold)) builder.append(formatLabel(pickupNumber, signLabelInfo.centerBold))
.append(signLabelInfo.br); .append(signLabelInfo.br);
builder.append(getFormatLabel(StrUtil.format("时间:{}", DateUtil.format(orderDetail.getCreateTime(), "yyyy-MM-dd HH:mm:ss")), signLabelInfo.s, signLabelInfo.center)) builder.append(formatLabel(StrUtil.format("时间:{}", DateUtil.format(orderDetail.getCreateTime(), "yyyy-MM-dd HH:mm:ss")), signLabelInfo.s, signLabelInfo.center))
.append(signLabelInfo.br); .append(signLabelInfo.br);
Integer isWaitCall = ObjectUtil.defaultIfNull(orderDetail.getIsWaitCall(), 0); Integer isWaitCall = ObjectUtil.defaultIfNull(orderDetail.getIsWaitCall(), 0);
if (isWaitCall == 1) { if (isWaitCall == 1) {
@@ -494,21 +494,21 @@ public interface PrinterImpl {
orderDetail.setProductName("【赠】" + orderDetail.getProductName()); orderDetail.setProductName("【赠】" + orderDetail.getProductName());
} }
if (orderDetail.getProductName().length() > 4) { if (orderDetail.getProductName().length() > 4) {
builder.append(getFormatLabel(StrUtil.format("{} x {}", orderDetail.getProductName(), orderDetail.getNum().stripTrailingZeros().toPlainString()), signLabelInfo.f, signLabelInfo.center)) builder.append(formatLabel(StrUtil.format("{} x {}", orderDetail.getProductName(), orderDetail.getNum().stripTrailingZeros().toPlainString()), signLabelInfo.f, signLabelInfo.center))
.append(signLabelInfo.br); .append(signLabelInfo.br);
if (StrUtil.isNotBlank(orderDetail.getSkuName())) { if (StrUtil.isNotBlank(orderDetail.getSkuName())) {
builder.append(getFormatLabel("(" + orderDetail.getSkuName() + ")", signLabelInfo.f, signLabelInfo.center)).append(signLabelInfo.br); builder.append(formatLabel("(" + orderDetail.getSkuName() + ")", signLabelInfo.f, signLabelInfo.center)).append(signLabelInfo.br);
} }
} else { } else {
builder.append(getFormatLabel(StrUtil.format("{} x {}", orderDetail.getProductName(), orderDetail.getNum().stripTrailingZeros().toPlainString()), signLabelInfo.f, signLabelInfo.center)) builder.append(formatLabel(StrUtil.format("{} x {}", orderDetail.getProductName(), orderDetail.getNum().stripTrailingZeros().toPlainString()), signLabelInfo.f, signLabelInfo.center))
.append(signLabelInfo.br); .append(signLabelInfo.br);
if (StrUtil.isNotBlank(orderDetail.getSkuName())) { if (StrUtil.isNotBlank(orderDetail.getSkuName())) {
builder.append(getFormatLabel("(" + orderDetail.getSkuName() + ")", signLabelInfo.f, signLabelInfo.center)) builder.append(formatLabel("(" + orderDetail.getSkuName() + ")", signLabelInfo.f, signLabelInfo.center))
.append(signLabelInfo.br); .append(signLabelInfo.br);
} }
} }
if (StrUtil.isNotBlank(orderDetail.getRemark()) && !"null".equals(orderDetail.getRemark())) { if (StrUtil.isNotBlank(orderDetail.getRemark()) && !"null".equals(orderDetail.getRemark())) {
builder.append(getFormatLabel(StrUtil.format("备注:{}", orderDetail.getRemark()), signLabelInfo.f)) builder.append(formatLabel(StrUtil.format("备注:{}", orderDetail.getRemark()), signLabelInfo.f))
.append(signLabelInfo.br); .append(signLabelInfo.br);
} }
if (!StrUtil.isBlank(orderDetail.getProGroupInfo()) && JSONUtil.isTypeJSONArray(orderDetail.getProGroupInfo())) { if (!StrUtil.isBlank(orderDetail.getProGroupInfo()) && JSONUtil.isTypeJSONArray(orderDetail.getProGroupInfo())) {
@@ -524,7 +524,7 @@ public interface PrinterImpl {
} }
} }
if (orderDetail.isUrgent()) { if (orderDetail.isUrgent()) {
builder.append(getFormatLabel("【加急】", signLabelInfo.center, signLabelInfo.bold)) builder.append(formatLabel("【加急】", signLabelInfo.center, signLabelInfo.bold))
.append(signLabelInfo.br); .append(signLabelInfo.br);
} }
builder.append(signLabelInfo.br) builder.append(signLabelInfo.br)
@@ -541,13 +541,13 @@ public interface PrinterImpl {
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
// 标题:入库 + 店铺名称 + 入库单 // 标题:入库 + 店铺名称 + 入库单
builder.append(getFormatLabel(record.getShopName(), signLabelInfo.center)).append(signLabelInfo.br); builder.append(formatLabel(record.getShopName(), signLabelInfo.center)).append(signLabelInfo.br);
builder.append(getFormatLabel("IN".equals(record.getType()) ? "入库单" : "出库单", signLabelInfo.center)).append(signLabelInfo.br); builder.append(formatLabel("IN".equals(record.getType()) ? "入库单" : "出库单", signLabelInfo.center)).append(signLabelInfo.br);
// 入库时间 // 入库时间
builder.append(getFormatLabel(StrUtil.format("IN".equals(record.getType()) ? "入库时间: {}" : "出库时间: {}", DateUtil.format(record.getInStockTime(), "yyyy/MM/dd HH:mm:ss")), signLabelInfo.s)).append(signLabelInfo.br); builder.append(formatLabel(StrUtil.format("IN".equals(record.getType()) ? "入库时间: {}" : "出库时间: {}", DateUtil.format(record.getInStockTime(), "yyyy/MM/dd HH:mm:ss")), signLabelInfo.s)).append(signLabelInfo.br);
builder.append(getDividingLine()).append(signLabelInfo.br); builder.append(getDividingLine()).append(signLabelInfo.br);
builder.append(getFormatLabel(key4("耗材名称", "库存单位", "IN".equals(record.getType()) ? "入库数量" : "出库数量", "金额", builder.append(formatLabel(key4("耗材名称", "库存单位", "IN".equals(record.getType()) ? "入库数量" : "出库数量", "金额",
10, 9, 9), signLabelInfo.s)).append(signLabelInfo.br); 10, 9, 9), signLabelInfo.s)).append(signLabelInfo.br);
// 遍历耗材明细,逐行打印 // 遍历耗材明细,逐行打印
@@ -558,7 +558,7 @@ public interface PrinterImpl {
String amount = item.getAmount().stripTrailingZeros().toPlainString(); String amount = item.getAmount().stripTrailingZeros().toPlainString();
// 左对齐排版,保证列对齐 // 左对齐排版,保证列对齐
String itemLine = key4(item.getConsName(), item.getUnit(), stockNumber, amount, 11, 9, 7); String itemLine = key4(item.getConsName(), item.getUnit(), stockNumber, amount, 11, 9, 7);
builder.append(getFormatLabel(itemLine, signLabelInfo.s)).append(signLabelInfo.br); builder.append(formatLabel(itemLine, signLabelInfo.s)).append(signLabelInfo.br);
} }
} }
builder.append(signLabelInfo.br); builder.append(signLabelInfo.br);
@@ -568,12 +568,12 @@ public interface PrinterImpl {
String amountCountStr = "金额" + record.getAmountCount(); String amountCountStr = "金额" + record.getAmountCount();
String totalLine = key4("总计", consCountStr, stockNumberCountStr, amountCountStr, 6, 9, 7); String totalLine = key4("总计", consCountStr, stockNumberCountStr, amountCountStr, 6, 9, 7);
builder.append(getFormatLabel(totalLine, signLabelInfo.s)).append(signLabelInfo.br); builder.append(formatLabel(totalLine, signLabelInfo.s)).append(signLabelInfo.br);
builder.append(getDividingLine()).append(signLabelInfo.br); builder.append(getDividingLine()).append(signLabelInfo.br);
// 操作员、打印时间 // 操作员、打印时间
builder.append(getFormatLabel(StrUtil.format("操作员: {}", StrUtil.isNotBlank(record.getOperator()) ? record.getOperator() : ""), signLabelInfo.s)).append(signLabelInfo.br); builder.append(formatLabel(StrUtil.format("操作员: {}", StrUtil.isNotBlank(record.getOperator()) ? record.getOperator() : ""), signLabelInfo.s)).append(signLabelInfo.br);
builder.append(getFormatLabel(StrUtil.format("打印时间: {}", DateUtil.format(record.getPrintTime(), "yyyy/MM/dd HH:mm:ss")), signLabelInfo.s)).append(signLabelInfo.br); builder.append(formatLabel(StrUtil.format("打印时间: {}", DateUtil.format(record.getPrintTime(), "yyyy/MM/dd HH:mm:ss")), signLabelInfo.s)).append(signLabelInfo.br);
// 结尾空行 + 切纸(和充值单保持一致) // 结尾空行 + 切纸(和充值单保持一致)
builder.append(signLabelInfo.getOut(150)).append(signLabelInfo.cut); builder.append(signLabelInfo.getOut(150)).append(signLabelInfo.cut);
@@ -588,64 +588,127 @@ public interface PrinterImpl {
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
// 标题:店铺名称 + 经营日报(居中,和充值/入库单风格统一) // 标题:店铺名称 + 经营日报(居中,和充值/入库单风格统一)
builder.append(getFormatLabel(record.getShopName(), signLabelInfo.center)).append(signLabelInfo.br); builder.append(formatLabel(record.getShopName(), signLabelInfo.center)).append(signLabelInfo.br);
builder.append(getFormatLabel("经营日报", signLabelInfo.center)).append(signLabelInfo.br).append(signLabelInfo.br); builder.append(formatLabel("经营日报", signLabelInfo.center)).append(signLabelInfo.br).append(signLabelInfo.br);
// 基础信息:打印时间、操作人、统计时间 // 基础信息:打印时间、操作人、统计时间
builder.append(getFormatLabel(StrUtil.format("打印时间: {}", DateUtil.format(LocalDateTime.now(), "yyyy/MM/dd HH:mm:ss")), signLabelInfo.s)).append(signLabelInfo.br); builder.append(formatLabel(StrUtil.format("打印时间: {}", DateUtil.format(LocalDateTime.now(), "yyyy/MM/dd HH:mm:ss")), signLabelInfo.s)).append(signLabelInfo.br);
builder.append(getFormatLabel(StrUtil.format("操作人: {}", StrUtil.isNotBlank(record.getOperator()) ? record.getOperator() : ""), signLabelInfo.s)).append(signLabelInfo.br); builder.append(formatLabel(StrUtil.format("操作人: {}", StrUtil.isNotBlank(record.getOperator()) ? record.getOperator() : ""), signLabelInfo.s)).append(signLabelInfo.br);
builder.append(getFormatLabel(StrUtil.format("统计时间: {}", record.getStatisticsTime()), signLabelInfo.s)).append(signLabelInfo.br).append(signLabelInfo.br); builder.append(formatLabel(StrUtil.format("统计时间: {}", record.getStatisticsTime()), signLabelInfo.s)).append(signLabelInfo.br).append(signLabelInfo.br);
// 营业总额 // 营业总额
DayReportPrintDTO.BusinessSts turnover = record.getTurnover(); DayReportPrintDTO.BusinessSts turnover = record.getTurnover();
builder.append(getFormatLabel("营业指标:", signLabelInfo.bold)).append(signLabelInfo.br).append(signLabelInfo.br); builder.append(formatLabel("营业指标:", signLabelInfo.bold)).append(signLabelInfo.br).append(signLabelInfo.br);
builder.append(getFormatLabel(leftRightAlign(" 订单原价总额", bdToStr(turnover.getOriginAmount()), 32), signLabelInfo.s)).append(signLabelInfo.br); builder.append(formatLabel(LRAlign(" 订单原价总额", bdToStr(turnover.getOriginAmount()), 32), signLabelInfo.s)).append(signLabelInfo.br);
builder.append(getFormatLabel(leftRightAlign(" 营业额", bdToStr(turnover.getTurnover()), 32), signLabelInfo.s)).append(signLabelInfo.br); builder.append(formatLabel(LRAlign(" 营业额", bdToStr(turnover.getTurnover()), 32), signLabelInfo.s)).append(signLabelInfo.br);
builder.append(getFormatLabel(leftRightAlign(" 优惠金额", bdToStr(turnover.getDiscountAmount()), 32), signLabelInfo.s)).append(signLabelInfo.br); builder.append(formatLabel(LRAlign(" 优惠金额", bdToStr(turnover.getDiscountAmount()), 32), signLabelInfo.s)).append(signLabelInfo.br);
builder.append(getFormatLabel(leftRightAlign(" 订单数(含退款)", String.valueOf(turnover.getOrderCount()), 32), signLabelInfo.s)).append(signLabelInfo.br); builder.append(formatLabel(LRAlign(" 订单数(含退款)", String.valueOf(turnover.getOrderCount()), 32), signLabelInfo.s)).append(signLabelInfo.br);
builder.append(getFormatLabel(leftRightAlign(" 折前单均价", bdToStr(turnover.getAverageOrderAmount()), 32), signLabelInfo.s)).append(signLabelInfo.br); builder.append(formatLabel(LRAlign(" 折前单均价", bdToStr(turnover.getAverageOrderAmount()), 32), signLabelInfo.s)).append(signLabelInfo.br);
builder.append(getFormatLabel(leftRightAlign(" 折后单均价", bdToStr(turnover.getAverageTurnover()), 32), signLabelInfo.s)).append(signLabelInfo.br); builder.append(formatLabel(LRAlign(" 折后单均价", bdToStr(turnover.getAverageTurnover()), 32), signLabelInfo.s)).append(signLabelInfo.br);
builder.append(getFormatLabel(leftRightAlign(" 退款金额", bdToStr(turnover.getRefundAmount()), 32), signLabelInfo.s)).append(signLabelInfo.br); builder.append(formatLabel(LRAlign(" 退款金额", bdToStr(turnover.getRefundAmount()), 32), signLabelInfo.s)).append(signLabelInfo.br);
builder.append(getFormatLabel(leftRightAlign(" 退款订单数", String.valueOf(turnover.getRefundOrderCount()), 32), signLabelInfo.s)).append(signLabelInfo.br); builder.append(formatLabel(LRAlign(" 退款订单数", String.valueOf(turnover.getRefundOrderCount()), 32), signLabelInfo.s)).append(signLabelInfo.br);
builder.append(getDividingLine()).append(signLabelInfo.br); builder.append(getDividingLine()).append(signLabelInfo.br);
// 收入来源 // 收入来源
DayReportPrintDTO.Income soIncome = record.getSourceIncome(); DayReportPrintDTO.Income soIncome = record.getSourceIncome();
builder.append(getFormatLabel("收入来源", signLabelInfo.bold)).append(signLabelInfo.br); builder.append(formatLabel("收入来源", signLabelInfo.bold)).append(signLabelInfo.br);
builder.append(getFormatLabel(leftRightAlign(" 现金", bdToStr(soIncome.getCash()), 32), signLabelInfo.s)).append(signLabelInfo.br); builder.append(formatLabel(LRAlign(" 现金", bdToStr(soIncome.getCash()), 32), signLabelInfo.s)).append(signLabelInfo.br);
builder.append(getFormatLabel(leftRightAlign(" 微信", bdToStr(soIncome.getWechat()), 32), signLabelInfo.s)).append(signLabelInfo.br); builder.append(formatLabel(LRAlign(" 微信", bdToStr(soIncome.getWechat()), 32), signLabelInfo.s)).append(signLabelInfo.br);
builder.append(getFormatLabel(leftRightAlign(" 支付宝", bdToStr(soIncome.getAlipay()), 32), signLabelInfo.s)).append(signLabelInfo.br); builder.append(formatLabel(LRAlign(" 支付宝", bdToStr(soIncome.getAlipay()), 32), signLabelInfo.s)).append(signLabelInfo.br);
builder.append(getFormatLabel(leftRightAlign(" 美团团购", bdToStr(soIncome.getMeituan()), 32), signLabelInfo.s)).append(signLabelInfo.br); builder.append(formatLabel(LRAlign(" 美团团购", bdToStr(soIncome.getMeituan()), 32), signLabelInfo.s)).append(signLabelInfo.br);
builder.append(getFormatLabel(leftRightAlign(" 抖音团购", bdToStr(soIncome.getDouyin()), 32), signLabelInfo.s)).append(signLabelInfo.br); builder.append(formatLabel(LRAlign(" 抖音团购", bdToStr(soIncome.getDouyin()), 32), signLabelInfo.s)).append(signLabelInfo.br);
builder.append(getFormatLabel(leftRightAlign(" 其它", bdToStr(soIncome.getOther()), 32), signLabelInfo.s)).append(signLabelInfo.br); builder.append(formatLabel(LRAlign(" 其它", bdToStr(soIncome.getOther()), 32), signLabelInfo.s)).append(signLabelInfo.br);
builder.append(getDividingLine()).append(signLabelInfo.br); builder.append(getDividingLine()).append(signLabelInfo.br);
// 实收统计 // 实收统计
DayReportPrintDTO.Income actualIncome = record.getActualIncome(); DayReportPrintDTO.Income actualIncome = record.getActualIncome();
builder.append(getFormatLabel("实收统计", signLabelInfo.bold)).append(signLabelInfo.br); builder.append(formatLabel("实收统计", signLabelInfo.bold)).append(signLabelInfo.br);
builder.append(getFormatLabel(leftRightAlign(" 现金", bdToStr(actualIncome.getCash()), 32), signLabelInfo.s)).append(signLabelInfo.br); builder.append(formatLabel(LRAlign(" 现金", bdToStr(actualIncome.getCash()), 32), signLabelInfo.s)).append(signLabelInfo.br);
builder.append(getFormatLabel(leftRightAlign(" 微信", bdToStr(actualIncome.getWechat()), 32), signLabelInfo.s)).append(signLabelInfo.br); builder.append(formatLabel(LRAlign(" 微信", bdToStr(actualIncome.getWechat()), 32), signLabelInfo.s)).append(signLabelInfo.br);
builder.append(getFormatLabel(leftRightAlign(" 支付宝", bdToStr(actualIncome.getAlipay()), 32), signLabelInfo.s)).append(signLabelInfo.br); builder.append(formatLabel(LRAlign(" 支付宝", bdToStr(actualIncome.getAlipay()), 32), signLabelInfo.s)).append(signLabelInfo.br);
builder.append(getFormatLabel(leftRightAlign(" 美团团购", bdToStr(actualIncome.getMeituan()), 32), signLabelInfo.s)).append(signLabelInfo.br); builder.append(formatLabel(LRAlign(" 美团团购", bdToStr(actualIncome.getMeituan()), 32), signLabelInfo.s)).append(signLabelInfo.br);
builder.append(getFormatLabel(leftRightAlign(" 抖音团购", bdToStr(actualIncome.getDouyin()), 32), signLabelInfo.s)).append(signLabelInfo.br); builder.append(formatLabel(LRAlign(" 抖音团购", bdToStr(actualIncome.getDouyin()), 32), signLabelInfo.s)).append(signLabelInfo.br);
builder.append(getFormatLabel(leftRightAlign(" 其它", bdToStr(actualIncome.getOther()), 32), signLabelInfo.s)).append(signLabelInfo.br); builder.append(formatLabel(LRAlign(" 其它", bdToStr(actualIncome.getOther()), 32), signLabelInfo.s)).append(signLabelInfo.br);
builder.append(getDividingLine()).append(signLabelInfo.br); builder.append(getDividingLine()).append(signLabelInfo.br);
// 实收统计 // 实收统计
DayReportPrintDTO.DiscountSts disSta = record.getDiscountSta(); DayReportPrintDTO.DiscountSts disSta = record.getDiscountSta();
builder.append(getFormatLabel("优惠统计", signLabelInfo.bold)).append(signLabelInfo.br); builder.append(formatLabel("优惠统计", signLabelInfo.bold)).append(signLabelInfo.br);
builder.append(getFormatLabel(leftRightAlign(" 新客立减", bdToStr(disSta.getNewConsumerDiscount()), 32), signLabelInfo.s)).append(signLabelInfo.br); builder.append(formatLabel(LRAlign(" 新客立减", bdToStr(disSta.getNewConsumerDiscount()), 32), signLabelInfo.s)).append(signLabelInfo.br);
builder.append(getFormatLabel(leftRightAlign(" 霸王餐", bdToStr(disSta.getFreeCashAmount()), 32), signLabelInfo.s)).append(signLabelInfo.br); builder.append(formatLabel(LRAlign(" 霸王餐", bdToStr(disSta.getFreeCashAmount()), 32), signLabelInfo.s)).append(signLabelInfo.br);
builder.append(getFormatLabel(leftRightAlign(" 满减活动", bdToStr(disSta.getFullMinusAmount()), 32), signLabelInfo.s)).append(signLabelInfo.br); builder.append(formatLabel(LRAlign(" 满减活动", bdToStr(disSta.getFullMinusAmount()), 32), signLabelInfo.s)).append(signLabelInfo.br);
builder.append(getFormatLabel(leftRightAlign(" 优惠券", bdToStr(disSta.getCouponAmount()), 32), signLabelInfo.s)).append(signLabelInfo.br); builder.append(formatLabel(LRAlign(" 优惠券", bdToStr(disSta.getCouponAmount()), 32), signLabelInfo.s)).append(signLabelInfo.br);
builder.append(getFormatLabel(leftRightAlign(" 会员折扣", bdToStr(disSta.getMemberDiscount()), 32), signLabelInfo.s)).append(signLabelInfo.br); builder.append(formatLabel(LRAlign(" 会员折扣", bdToStr(disSta.getMemberDiscount()), 32), signLabelInfo.s)).append(signLabelInfo.br);
builder.append(getFormatLabel(leftRightAlign(" 积分抵扣金额", bdToStr(disSta.getPointsDiscountAmount()), 32), signLabelInfo.s)).append(signLabelInfo.br); builder.append(formatLabel(LRAlign(" 积分抵扣金额", bdToStr(disSta.getPointsDiscountAmount()), 32), signLabelInfo.s)).append(signLabelInfo.br);
builder.append(getFormatLabel(leftRightAlign(" 订单改价", bdToStr(disSta.getOrderDiscount()), 32), signLabelInfo.s)).append(signLabelInfo.br); builder.append(formatLabel(LRAlign(" 订单改价", bdToStr(disSta.getOrderDiscount()), 32), signLabelInfo.s)).append(signLabelInfo.br);
// 结尾空行 + 切纸(和充值/入库单完全一致) // 结尾空行 + 切纸(和充值/入库单完全一致)
builder.append(signLabelInfo.getOut(150)).append(signLabelInfo.cut); builder.append(signLabelInfo.getOut(150)).append(signLabelInfo.cut);
return builder.toString(); return builder.toString();
} }
/**
* 日结单
*/
default String buildDaySettleData(DaySettlePrintDTO record) {
PrintSignLabel signLabelInfo = getSignLabelInfo();
StringBuilder builder = new StringBuilder();
// 标题:店铺名称 + 经营日报(居中,和充值/入库单风格统一)
builder.append(formatLabel(record.getShopName(), signLabelInfo.center)).append(signLabelInfo.br);
builder.append(formatLabel("经营日报", signLabelInfo.center)).append(signLabelInfo.br).append(signLabelInfo.br);
// 基础信息:打印时间、操作人、统计时间
builder.append(formatLabel(StrUtil.format("打印时间: {}", DateUtil.format(LocalDateTime.now(), "yyyy/MM/dd HH:mm:ss")), signLabelInfo.s)).append(signLabelInfo.br);
builder.append(formatLabel(StrUtil.format("操作人: {}", StrUtil.isNotBlank(record.getOperator()) ? record.getOperator() : ""), signLabelInfo.s)).append(signLabelInfo.br);
builder.append(formatLabel(StrUtil.format("统计时间: {}", record.getStatisticsTime()), signLabelInfo.s)).append(signLabelInfo.br).append(signLabelInfo.br);
// 营业统计
DaySettlePrintDTO.BusinessSts turnover = record.getTurnover();
builder.append(formatLabel("营业统计:", signLabelInfo.bold)).append(signLabelInfo.br).append(signLabelInfo.br);
builder.append(formatLabel(LRAlign(" 订单原价总额", bdToStr(turnover.getOriginAmount()), 32), signLabelInfo.s)).append(signLabelInfo.br);
builder.append(formatLabel(LRAlign(" 营业额", bdToStr(turnover.getTurnover()), 32), signLabelInfo.s)).append(signLabelInfo.br);
builder.append(formatLabel(LRAlign(" 优惠金额", bdToStr(turnover.getDiscountAmount()), 32), signLabelInfo.s)).append(signLabelInfo.br);
builder.append(formatLabel(LRAlign(" 订单数(含退款)", String.valueOf(turnover.getOrderCount()), 32), signLabelInfo.s)).append(signLabelInfo.br);
builder.append(formatLabel(LRAlign(" 退款订单数", String.valueOf(turnover.getRefundOrderCount()), 32), signLabelInfo.s)).append(signLabelInfo.br);
builder.append(formatLabel(LRAlign(" 退款金额", bdToStr(turnover.getRefundAmount()), 32), signLabelInfo.s)).append(signLabelInfo.br);
builder.append(formatLabel(LRAlign(" 现金收款", bdToStr(turnover.getCash()), 32), signLabelInfo.s)).append(signLabelInfo.br);
builder.append(formatLabel(" 备用金", signLabelInfo.s)).append(signLabelInfo.br);
builder.append(formatLabel(" 钱箱剩余", signLabelInfo.s)).append(signLabelInfo.br);
builder.append(getDividingLine()).append(signLabelInfo.br);
// 收入来源
DaySettlePrintDTO.Income income = record.getIncome();
builder.append(formatLabel("收款构成", signLabelInfo.bold)).append(signLabelInfo.br);
builder.append(formatLabel(LRAlign(" 现金", bdToStr(income.getCash()), 32), signLabelInfo.s)).append(signLabelInfo.br);
builder.append(formatLabel(LRAlign(" 微信", bdToStr(income.getWechat()), 32), signLabelInfo.s)).append(signLabelInfo.br);
builder.append(formatLabel(LRAlign(" 支付宝", bdToStr(income.getAlipay()), 32), signLabelInfo.s)).append(signLabelInfo.br);
builder.append(formatLabel(LRAlign(" 团购", bdToStr(income.getGroup()), 32), signLabelInfo.s)).append(signLabelInfo.br);
builder.append(getDividingLine()).append(signLabelInfo.br);
// 实收统计
DaySettlePrintDTO.DiscountSts disSta = record.getDiscountSta();
builder.append(formatLabel("优惠统计", signLabelInfo.bold)).append(signLabelInfo.br);
builder.append(formatLabel(LRAlign(" 新客立减", bdToStr(disSta.getNewConsumerDiscount()), 32), signLabelInfo.s)).append(signLabelInfo.br);
builder.append(formatLabel(LRAlign(" 霸王餐", bdToStr(disSta.getFreeCashAmount()), 32), signLabelInfo.s)).append(signLabelInfo.br);
builder.append(formatLabel(LRAlign(" 满减活动", bdToStr(disSta.getFullMinusAmount()), 32), signLabelInfo.s)).append(signLabelInfo.br);
builder.append(formatLabel(LRAlign(" 优惠券", bdToStr(disSta.getCouponAmount()), 32), signLabelInfo.s)).append(signLabelInfo.br);
builder.append(formatLabel(LRAlign(" 会员折扣", bdToStr(disSta.getMemberDiscount()), 32), signLabelInfo.s)).append(signLabelInfo.br);
builder.append(formatLabel(LRAlign(" 积分抵扣金额", bdToStr(disSta.getPointsDiscountAmount()), 32), signLabelInfo.s)).append(signLabelInfo.br);
builder.append(formatLabel(LRAlign(" 订单改价", bdToStr(disSta.getOrderDiscount()), 32), signLabelInfo.s)).append(signLabelInfo.br);
List<DaySettlePrintDTO.OperationRecord> operationRecords = record.getOperationRecords();
if (CollUtil.isNotEmpty(operationRecords)) {
builder.append(formatLabel("敏感操作记录", signLabelInfo.bold)).append(signLabelInfo.br);
for (DaySettlePrintDTO.OperationRecord operation : operationRecords) {
builder.append(formatLabel(
key3(operation.getOperation(), "数量:" + operation.getCount(), "金额" + operation.getAmount(), 8, 14)
, signLabelInfo.s)).append(signLabelInfo.br);
}
}
builder.append(signLabelInfo.getOut(150)).append(signLabelInfo.cut);
return builder.toString();
}
/** /**
* 商品报表打印单 * 商品报表打印单
*/ */
@@ -654,23 +717,23 @@ public interface PrinterImpl {
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
// 标题:店铺名称 + 商品报表(居中,和之前的报表风格统一) // 标题:店铺名称 + 商品报表(居中,和之前的报表风格统一)
builder.append(getFormatLabel(record.getShopName(), signLabelInfo.center)).append(signLabelInfo.br); builder.append(formatLabel(record.getShopName(), signLabelInfo.center)).append(signLabelInfo.br);
builder.append(getFormatLabel("商品报表", signLabelInfo.center)).append(signLabelInfo.br).append(signLabelInfo.br); builder.append(formatLabel("商品报表", signLabelInfo.center)).append(signLabelInfo.br).append(signLabelInfo.br);
// 基础信息:打印时间、操作人、统计时间 // 基础信息:打印时间、操作人、统计时间
builder.append(getFormatLabel(StrUtil.format("打印时间: {}", DateUtil.format(LocalDateTime.now(), "yyyy/MM/dd HH:mm:ss")), signLabelInfo.s)).append(signLabelInfo.br); builder.append(formatLabel(StrUtil.format("打印时间: {}", DateUtil.format(LocalDateTime.now(), "yyyy/MM/dd HH:mm:ss")), signLabelInfo.s)).append(signLabelInfo.br);
builder.append(getFormatLabel(StrUtil.format("操作人: {}", StrUtil.isNotBlank(record.getOperator()) ? record.getOperator() : ""), signLabelInfo.s)).append(signLabelInfo.br); builder.append(formatLabel(StrUtil.format("操作人: {}", StrUtil.isNotBlank(record.getOperator()) ? record.getOperator() : ""), signLabelInfo.s)).append(signLabelInfo.br);
builder.append(getFormatLabel(StrUtil.format("时间: {}", record.getStatisticsTime()), signLabelInfo.s)).append(signLabelInfo.br).append(signLabelInfo.br); builder.append(formatLabel(StrUtil.format("时间: {}", record.getStatisticsTime()), signLabelInfo.s)).append(signLabelInfo.br).append(signLabelInfo.br);
// 总计行总计商品X件实收金额X元 // 总计行总计商品X件实收金额X元
String totalCountStr = record.getTotalProductCount().stripTrailingZeros().toPlainString(); String totalCountStr = record.getTotalProductCount().stripTrailingZeros().toPlainString();
String totalActualStr = record.getTotalActualAmount().stripTrailingZeros().toPlainString(); String totalActualStr = record.getTotalActualAmount().stripTrailingZeros().toPlainString();
builder.append(getFormatLabel(StrUtil.format("总计商品{}件,实收金额{}元", totalCountStr, totalActualStr), signLabelInfo.s)).append(signLabelInfo.br); builder.append(formatLabel(StrUtil.format("总计商品{}件,实收金额{}元", totalCountStr, totalActualStr), signLabelInfo.s)).append(signLabelInfo.br);
builder.append(getDividingLine()).append(signLabelInfo.br).append(signLabelInfo.br); builder.append(getDividingLine()).append(signLabelInfo.br).append(signLabelInfo.br);
// 表头:商品、数量、实收、销售额(四列对齐,和示例图完全匹配) // 表头:商品、数量、实收、销售额(四列对齐,和示例图完全匹配)
String header = key4("商品", "数量", "实收", "销售额", 12, 6, 6); String header = key4("商品", "数量", "实收", "销售额", 12, 6, 6);
builder.append(getFormatLabel(header, signLabelInfo.s)).append(signLabelInfo.br); builder.append(formatLabel(header, signLabelInfo.s)).append(signLabelInfo.br);
// 遍历分类+商品明细 // 遍历分类+商品明细
List<ProductReportPrintDTO.CategoryItem> items = record.getItems(); List<ProductReportPrintDTO.CategoryItem> items = record.getItems();
@@ -683,7 +746,7 @@ public interface PrinterImpl {
item.getActualAmount().stripTrailingZeros().toPlainString(), item.getActualAmount().stripTrailingZeros().toPlainString(),
item.getSalesAmount().stripTrailingZeros().toPlainString(), item.getSalesAmount().stripTrailingZeros().toPlainString(),
12, 8, 8); 12, 8, 8);
builder.append(getFormatLabel(categoryLine, signLabelInfo.s)).append(signLabelInfo.br); builder.append(formatLabel(categoryLine, signLabelInfo.s)).append(signLabelInfo.br);
// 再打印该分类下的商品明细缩进2个空格和示例图一致 // 再打印该分类下的商品明细缩进2个空格和示例图一致
for (ProductReportPrintDTO.ProductItem pro : productList) { for (ProductReportPrintDTO.ProductItem pro : productList) {
@@ -692,7 +755,7 @@ public interface PrinterImpl {
String salesStr = pro.getSalesAmount().stripTrailingZeros().toPlainString(); String salesStr = pro.getSalesAmount().stripTrailingZeros().toPlainString();
// 商品名称前加2个空格实现缩进效果 // 商品名称前加2个空格实现缩进效果
String productLine = key4(" " + pro.getProductName(), numStr, actualStr, salesStr, 12, 8, 8); String productLine = key4(" " + pro.getProductName(), numStr, actualStr, salesStr, 12, 8, 8);
builder.append(getFormatLabel(productLine, signLabelInfo.s)).append(signLabelInfo.br); builder.append(formatLabel(productLine, signLabelInfo.s)).append(signLabelInfo.br);
} }
} }
} }
@@ -709,34 +772,34 @@ public interface PrinterImpl {
PrintSignLabel signLabelInfo = getSignLabelInfo(); PrintSignLabel signLabelInfo = getSignLabelInfo();
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
// 标题:店铺名称 + 充值凭证 // 标题:店铺名称 + 充值凭证
builder.append(getFormatLabel(record.getShopName(), signLabelInfo.center)).append(signLabelInfo.br); builder.append(formatLabel(record.getShopName(), signLabelInfo.center)).append(signLabelInfo.br);
builder.append(getFormatLabel("充值凭证", signLabelInfo.center)).append(signLabelInfo.br); builder.append(formatLabel("充值凭证", signLabelInfo.center)).append(signLabelInfo.br);
// 用户信息 // 用户信息
builder.append(getFormatLabel("充值用户:" + record.getUserName(), signLabelInfo.s)).append(signLabelInfo.br); builder.append(formatLabel("充值用户:" + record.getUserName(), signLabelInfo.s)).append(signLabelInfo.br);
builder.append(getFormatLabel("手机号:" + record.getUserPhone(), signLabelInfo.s)).append(signLabelInfo.br); builder.append(formatLabel("手机号:" + record.getUserPhone(), signLabelInfo.s)).append(signLabelInfo.br);
builder.append(getFormatLabel("支付时间:" + DateUtil.format(record.getPayTime(), "yyyy/MM/dd HH:mm:ss"), signLabelInfo.s)).append(signLabelInfo.br); builder.append(formatLabel("支付时间:" + DateUtil.format(record.getPayTime(), "yyyy/MM/dd HH:mm:ss"), signLabelInfo.s)).append(signLabelInfo.br);
// 充值明细 // 充值明细
builder.append(getDividingLine()).append(signLabelInfo.br); builder.append(getDividingLine()).append(signLabelInfo.br);
builder.append(getFormatLabel(leftRightAlign("充值金额:", record.getRechargeAmount().stripTrailingZeros().toPlainString(), 24), signLabelInfo.bold)).append(signLabelInfo.br); builder.append(formatLabel(LRAlign("充值金额:", record.getRechargeAmount().stripTrailingZeros().toPlainString(), 24), signLabelInfo.bold)).append(signLabelInfo.br);
if (record.getGiftAmount() != null && record.getGiftAmount().compareTo(BigDecimal.ZERO) > 0) { if (record.getGiftAmount() != null && record.getGiftAmount().compareTo(BigDecimal.ZERO) > 0) {
builder.append(getFormatLabel(leftRightAlign("赠送金额:", record.getGiftAmount().stripTrailingZeros().toPlainString(), 32), signLabelInfo.s)).append(signLabelInfo.br); builder.append(formatLabel(LRAlign("赠送金额:", record.getGiftAmount().stripTrailingZeros().toPlainString(), 32), signLabelInfo.s)).append(signLabelInfo.br);
} }
if (record.getGiftPoints() != null && record.getGiftPoints().compareTo(BigDecimal.ZERO) > 0) { if (record.getGiftPoints() != null && record.getGiftPoints().compareTo(BigDecimal.ZERO) > 0) {
builder.append(getFormatLabel(leftRightAlign("赠送积分:", record.getGiftPoints().stripTrailingZeros().toPlainString(), 32), signLabelInfo.s)).append(signLabelInfo.br); builder.append(formatLabel(LRAlign("赠送积分:", record.getGiftPoints().stripTrailingZeros().toPlainString(), 32), signLabelInfo.s)).append(signLabelInfo.br);
} }
if (record.getGiftCoupon() != null && record.getGiftCoupon() > 0) { if (record.getGiftCoupon() != null && record.getGiftCoupon() > 0) {
builder.append(getFormatLabel(leftRightAlign("赠送优惠券:", record.getGiftCoupon() + "", 32), signLabelInfo.s)).append(signLabelInfo.br); builder.append(formatLabel(LRAlign("赠送优惠券:", record.getGiftCoupon() + "", 32), signLabelInfo.s)).append(signLabelInfo.br);
} }
builder.append(getFormatLabel(leftRightAlign("充值后余额:", record.getBalance().stripTrailingZeros().toPlainString(), 32), signLabelInfo.s)).append(signLabelInfo.br); builder.append(formatLabel(LRAlign("充值后余额:", record.getBalance().stripTrailingZeros().toPlainString(), 32), signLabelInfo.s)).append(signLabelInfo.br);
builder.append(getDividingLine()).append(signLabelInfo.br); builder.append(getDividingLine()).append(signLabelInfo.br);
// 支付信息 // 支付信息
builder.append(getFormatLabel(leftRightAlign("已付金额:", record.getRechargeAmount().stripTrailingZeros().toPlainString(), 24), signLabelInfo.bold)).append(signLabelInfo.br); builder.append(formatLabel(LRAlign("已付金额:", record.getRechargeAmount().stripTrailingZeros().toPlainString(), 24), signLabelInfo.bold)).append(signLabelInfo.br);
builder.append(getFormatLabel(leftRightAlign("支付方式:", record.getPayType(), 32), signLabelInfo.s)).append(signLabelInfo.br); builder.append(formatLabel(LRAlign("支付方式:", record.getPayType(), 32), signLabelInfo.s)).append(signLabelInfo.br);
builder.append(getDividingLine()).append(signLabelInfo.br); builder.append(getDividingLine()).append(signLabelInfo.br);
builder.append(getFormatLabel(StrUtil.format("操作员: {}", StrUtil.isNotBlank(record.getOperator()) ? record.getOperator() : ""), signLabelInfo.s)).append(signLabelInfo.br); builder.append(formatLabel(StrUtil.format("操作员: {}", StrUtil.isNotBlank(record.getOperator()) ? record.getOperator() : ""), signLabelInfo.s)).append(signLabelInfo.br);
builder.append(getFormatLabel(StrUtil.format("打印时间: {}", DateUtil.format(LocalDateTime.now(), "yyyy/MM/dd HH:mm:ss")), signLabelInfo.s)).append(signLabelInfo.br); builder.append(formatLabel(StrUtil.format("打印时间: {}", DateUtil.format(LocalDateTime.now(), "yyyy/MM/dd HH:mm:ss")), signLabelInfo.s)).append(signLabelInfo.br);
builder.append(getFormatLabel(StrUtil.format("充值编号: {}", record.getRechargeId()), signLabelInfo.s)).append(signLabelInfo.br); builder.append(formatLabel(StrUtil.format("充值编号: {}", record.getRechargeId()), signLabelInfo.s)).append(signLabelInfo.br);
// 结尾空行 + 切纸 // 结尾空行 + 切纸
builder.append(signLabelInfo.getOut(150)).append(signLabelInfo.cut); builder.append(signLabelInfo.getOut(150)).append(signLabelInfo.cut);
@@ -751,12 +814,12 @@ public interface PrinterImpl {
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
// 标题:店铺名称 + 盘点单(居中,和之前所有打印单风格统一) // 标题:店铺名称 + 盘点单(居中,和之前所有打印单风格统一)
builder.append(getFormatLabel(record.getShopName(), signLabelInfo.center)).append(signLabelInfo.br); builder.append(formatLabel(record.getShopName(), signLabelInfo.center)).append(signLabelInfo.br);
builder.append(getFormatLabel("盘点单", signLabelInfo.center)).append(signLabelInfo.br).append(signLabelInfo.br); builder.append(formatLabel("盘点单", signLabelInfo.center)).append(signLabelInfo.br).append(signLabelInfo.br);
// 表头耗材名称、单价、实际数、盈亏数四列对齐复用key4工具方法 // 表头耗材名称、单价、实际数、盈亏数四列对齐复用key4工具方法
String header = key4("耗材名称", "单价", "实际数", "盈亏数", 10, 7, 7); String header = key4("耗材名称", "单价", "实际数", "盈亏数", 10, 7, 7);
builder.append(getFormatLabel(header, signLabelInfo.s)).append(signLabelInfo.br); builder.append(formatLabel(header, signLabelInfo.s)).append(signLabelInfo.br);
// 遍历耗材明细,逐行打印 // 遍历耗材明细,逐行打印
List<StockCheckPrintDTO.StockCheckItem> items = record.getItems(); List<StockCheckPrintDTO.StockCheckItem> items = record.getItems();
@@ -767,23 +830,23 @@ public interface PrinterImpl {
String winLossNumberStr = item.getWinLossNumber().toString(); String winLossNumberStr = item.getWinLossNumber().toString();
// 四列对齐打印 // 四列对齐打印
String itemLine = key4(item.getConsName(), priceStr, actualNumberStr, winLossNumberStr, 10, 8, 8); String itemLine = key4(item.getConsName(), priceStr, actualNumberStr, winLossNumberStr, 10, 8, 8);
builder.append(getFormatLabel(itemLine, signLabelInfo.s)).append(signLabelInfo.br); builder.append(formatLabel(itemLine, signLabelInfo.s)).append(signLabelInfo.br);
} }
} }
builder.append(getDividingLine()).append(signLabelInfo.br).append(signLabelInfo.br); builder.append(getDividingLine()).append(signLabelInfo.br).append(signLabelInfo.br);
// 账存数量、盈亏金额、备注 // 账存数量、盈亏金额、备注
builder.append(getFormatLabel(StrUtil.format("账存数量: {}", record.getWinLossNumberCount()), signLabelInfo.s)).append(signLabelInfo.br); builder.append(formatLabel(StrUtil.format("账存数量: {}", record.getWinLossNumberCount()), signLabelInfo.s)).append(signLabelInfo.br);
String winLossAmountStr = record.getWinLossAmount().stripTrailingZeros().toPlainString(); String winLossAmountStr = record.getWinLossAmount().stripTrailingZeros().toPlainString();
builder.append(getFormatLabel(StrUtil.format("盈亏金额: {}", winLossAmountStr), signLabelInfo.s)).append(signLabelInfo.br); builder.append(formatLabel(StrUtil.format("盈亏金额: {}", winLossAmountStr), signLabelInfo.s)).append(signLabelInfo.br);
builder.append(getFormatLabel(StrUtil.format("备注: {}", StrUtil.isBlank(record.getRemark()) ? "" : record.getRemark()), signLabelInfo.s)).append(signLabelInfo.br); builder.append(formatLabel(StrUtil.format("备注: {}", StrUtil.isBlank(record.getRemark()) ? "" : record.getRemark()), signLabelInfo.s)).append(signLabelInfo.br);
builder.append(getDividingLine()).append(signLabelInfo.br).append(signLabelInfo.br); builder.append(getDividingLine()).append(signLabelInfo.br).append(signLabelInfo.br);
// 操作员、打印时间 // 操作员、打印时间
builder.append(getFormatLabel(StrUtil.format("操作员: {}", StrUtil.isNotBlank(record.getOperator()) ? record.getOperator() : ""), signLabelInfo.s)).append(signLabelInfo.br); builder.append(formatLabel(StrUtil.format("操作员: {}", StrUtil.isNotBlank(record.getOperator()) ? record.getOperator() : ""), signLabelInfo.s)).append(signLabelInfo.br);
// 打印时间复用之前的DateUtil格式化若DTO需补充printTime字段可按需求添加 // 打印时间复用之前的DateUtil格式化若DTO需补充printTime字段可按需求添加
builder.append(getFormatLabel(StrUtil.format("打印时间: {}", DateUtil.format(LocalDateTime.now(), "yyyy/MM/dd HH:mm:ss")), signLabelInfo.s)).append(signLabelInfo.br); builder.append(formatLabel(StrUtil.format("打印时间: {}", DateUtil.format(LocalDateTime.now(), "yyyy/MM/dd HH:mm:ss")), signLabelInfo.s)).append(signLabelInfo.br);
// 结尾空行 + 切纸(和之前所有打印单完全一致) // 结尾空行 + 切纸(和之前所有打印单完全一致)
builder.append(signLabelInfo.getOut(150)).append(signLabelInfo.cut); builder.append(signLabelInfo.getOut(150)).append(signLabelInfo.cut);
@@ -801,22 +864,22 @@ public interface PrinterImpl {
PrintSignLabel signLabelInfo = getSignLabelInfo(); PrintSignLabel signLabelInfo = getSignLabelInfo();
CallTable callTable = printDTO.getCallTable(); CallTable callTable = printDTO.getCallTable();
CallQueue callQueue = printDTO.getCallQueue(); CallQueue callQueue = printDTO.getCallQueue();
String str = getFormatLabel(shopName, signLabelInfo.center) + String str = formatLabel(shopName, signLabelInfo.center) +
signLabelInfo.br + signLabelInfo.br +
signLabelInfo.br + signLabelInfo.br +
getFormatLabel(StrUtil.format("{} {}", callTable.getName(), callQueue.getCallNum()), signLabelInfo.center, signLabelInfo.bold) + formatLabel(StrUtil.format("{} {}", callTable.getName(), callQueue.getCallNum()), signLabelInfo.center, signLabelInfo.bold) +
signLabelInfo.br + signLabelInfo.br +
getFormatLabel(StrUtil.format("前面有{}桌", printDTO.getPreNum()), signLabelInfo.center) + formatLabel(StrUtil.format("前面有{}桌", printDTO.getPreNum()), signLabelInfo.center) +
signLabelInfo.br + signLabelInfo.br +
getFormatLabel("怕过号,扫一扫", signLabelInfo.center, signLabelInfo.f) + formatLabel("怕过号,扫一扫", signLabelInfo.center, signLabelInfo.f) +
signLabelInfo.br + signLabelInfo.br +
getFormatLabel(printDTO.getCallUrl(), signLabelInfo.center, signLabelInfo.qr) + formatLabel(printDTO.getCallUrl(), signLabelInfo.center, signLabelInfo.qr) +
signLabelInfo.br + getDividingLine() + signLabelInfo.br + signLabelInfo.br + getDividingLine() + signLabelInfo.br +
getFormatLabel("描述:" + callTable.getNote(), signLabelInfo.s) + signLabelInfo.br; formatLabel("描述:" + callTable.getNote(), signLabelInfo.s) + signLabelInfo.br;
if (callTable.getIsPostpone() != null && callTable.getIsPostpone() == 1) { if (callTable.getIsPostpone() != null && callTable.getIsPostpone() == 1) {
str = str + getFormatLabel(StrUtil.format("过号顺延{}桌 {}桌后需重新排号", callTable.getPostponeNum(), callTable.getPostponeNum()), signLabelInfo.s) + signLabelInfo.br; str = str + formatLabel(StrUtil.format("过号顺延{}桌 {}桌后需重新排号", callTable.getPostponeNum(), callTable.getPostponeNum()), signLabelInfo.s) + signLabelInfo.br;
} }
str = str + getFormatLabel(StrUtil.format("取号时间: {}", DateUtil.format(callQueue.getCreateTime(), "yyyy-MM-dd HH:mm:ss")), signLabelInfo.s) + str = str + formatLabel(StrUtil.format("取号时间: {}", DateUtil.format(callQueue.getCreateTime(), "yyyy-MM-dd HH:mm:ss")), signLabelInfo.s) +
signLabelInfo.br + signLabelInfo.br +
signLabelInfo.getOut(150) + signLabelInfo.cut; signLabelInfo.getOut(150) + signLabelInfo.cut;
return str; return str;
@@ -849,7 +912,7 @@ public interface PrinterImpl {
} }
// 两个内容 左 右对齐 // 两个内容 左 右对齐
default String leftRightAlign(String leftText, String rightText, int totalWidth) { default String LRAlign(String leftText, String rightText, int totalWidth) {
if (leftText == null) leftText = ""; if (leftText == null) leftText = "";
if (rightText == null) rightText = ""; if (rightText == null) rightText = "";

View File

@@ -156,6 +156,15 @@ public class YxyPrinter extends PrinterHandler implements PrinterImpl {
printMachineLogService.save(machine, "经营日报单", data, resp); printMachineLogService.save(machine, "经营日报单", data, resp);
} }
@Override
protected void daySettlePrint(PrintMachine machine, String shopName, DaySettlePrintDTO record) {
record.setShopName(shopName);
String voiceJson = "{\"bizType\":\"2\",\"content\":\"\"}";
String data = buildDaySettleData(record);
String resp = sendPrintRequest(machine.getAddress(), data, voiceJson, machine.getPrintNum() == null ? "1" : machine.getPrintNum().toString());
printMachineLogService.save(machine, "日结单打印", data, resp);
}
@Override @Override
protected void productReportPrint(PrintMachine machine, String shopName, ProductReportPrintDTO record) { protected void productReportPrint(PrintMachine machine, String shopName, ProductReportPrintDTO record) {
record.setShopName(shopName); record.setShopName(shopName);