前台退菜单 默认打印
This commit is contained in:
@@ -17,6 +17,7 @@ import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
@@ -141,21 +142,21 @@ public interface PrinterImpl {
|
||||
.append(signLabelInfo.br)
|
||||
.append(getFormatLabel("当班营业总额: " + handoverRecord.getTurnover(), signLabelInfo.s)).append(signLabelInfo.br)
|
||||
.append(getFormatLabel("实际收款的支付方式", signLabelInfo.s)).append(signLabelInfo.br)
|
||||
.append(getFormatLabel(leftRightAlign(" 现金:", bigDecimalToString(handoverRecord.getCash()), 32), signLabelInfo.s)).append(signLabelInfo.br)
|
||||
.append(getFormatLabel(leftRightAlign(" 微信:", bigDecimalToString(handoverRecord.getWechat()), 32), signLabelInfo.s)).append(signLabelInfo.br)
|
||||
.append(getFormatLabel(leftRightAlign(" 支付宝:", bigDecimalToString(handoverRecord.getAlipay()), 32), signLabelInfo.s)).append(signLabelInfo.br)
|
||||
.append(getFormatLabel(leftRightAlign(" 二维码收款:", bigDecimalToString(handoverRecord.getSelfScan()), 32), signLabelInfo.s)).append(signLabelInfo.br)
|
||||
.append(getFormatLabel(leftRightAlign(" 扫码收款:", bigDecimalToString(handoverRecord.getBarScan()), 32), signLabelInfo.s)).append(signLabelInfo.br)
|
||||
.append(getFormatLabel(leftRightAlign(" 充值:", bigDecimalToString(handoverRecord.getRecharge()), 32), signLabelInfo.s)).append(signLabelInfo.br)
|
||||
.append(getFormatLabel(leftRightAlign(" 现金:", bdToStr(handoverRecord.getCash()), 32), signLabelInfo.s)).append(signLabelInfo.br)
|
||||
.append(getFormatLabel(leftRightAlign(" 微信:", bdToStr(handoverRecord.getWechat()), 32), signLabelInfo.s)).append(signLabelInfo.br)
|
||||
.append(getFormatLabel(leftRightAlign(" 支付宝:", bdToStr(handoverRecord.getAlipay()), 32), signLabelInfo.s)).append(signLabelInfo.br)
|
||||
.append(getFormatLabel(leftRightAlign(" 二维码收款:", bdToStr(handoverRecord.getSelfScan()), 32), signLabelInfo.s)).append(signLabelInfo.br)
|
||||
.append(getFormatLabel(leftRightAlign(" 扫码收款:", bdToStr(handoverRecord.getBarScan()), 32), signLabelInfo.s)).append(signLabelInfo.br)
|
||||
.append(getFormatLabel(leftRightAlign(" 充值:", bdToStr(handoverRecord.getRecharge()), 32), signLabelInfo.s)).append(signLabelInfo.br)
|
||||
.append(getFormatLabel("非实际收款的支付方式", signLabelInfo.s)).append(signLabelInfo.br)
|
||||
.append(getFormatLabel(leftRightAlign(" 挂账:", bigDecimalToString(handoverRecord.getOwed()), 32), signLabelInfo.s)).append(signLabelInfo.br)
|
||||
.append(getFormatLabel(leftRightAlign(" 余额:", bigDecimalToString(handoverRecord.getBalance()), 32), signLabelInfo.s)).append(signLabelInfo.br)
|
||||
.append(getFormatLabel(leftRightAlign(" 挂账:", bdToStr(handoverRecord.getOwed()), 32), signLabelInfo.s)).append(signLabelInfo.br)
|
||||
.append(getFormatLabel(leftRightAlign(" 余额:", bdToStr(handoverRecord.getBalance()), 32), signLabelInfo.s)).append(signLabelInfo.br)
|
||||
.append(getDividingLine()).append(signLabelInfo.br)
|
||||
.append(getFormatLabel("退菜/退款", signLabelInfo.s)).append(signLabelInfo.br)
|
||||
.append(getFormatLabel(leftRightAlign(" 退款金额:", bigDecimalToString(handoverRecord.getRefundAmount()), 32), signLabelInfo.s)).append(signLabelInfo.br)
|
||||
.append(getFormatLabel(leftRightAlign(" 退菜数量:", bigDecimalToString(handoverRecord.getReturnDishCount()), 32), signLabelInfo.s)).append(signLabelInfo.br)
|
||||
.append(getFormatLabel(leftRightAlign(" 退款金额:", bdToStr(handoverRecord.getRefundAmount()), 32), signLabelInfo.s)).append(signLabelInfo.br)
|
||||
.append(getFormatLabel(leftRightAlign(" 退菜数量:", bdToStr(handoverRecord.getReturnDishCount()), 32), signLabelInfo.s)).append(signLabelInfo.br)
|
||||
.append(getDividingLine()).append(signLabelInfo.br)
|
||||
.append(getFormatLabel(leftRightAlign("订单数量/订单总额", handoverRecord.getOrderCount() + "/" + bigDecimalToString(handoverRecord.getOrderTurnover()), 32), signLabelInfo.s))
|
||||
.append(getFormatLabel(leftRightAlign("订单数量/订单总额", handoverRecord.getOrderCount() + "/" + bdToStr(handoverRecord.getOrderTurnover()), 32), signLabelInfo.s))
|
||||
.append(signLabelInfo.br);
|
||||
|
||||
if (StrUtil.isNotBlank(handoverRecord.getCategoryData())) {
|
||||
@@ -167,7 +168,7 @@ public interface PrinterImpl {
|
||||
String categoryName = info.getString("categoryName");
|
||||
Integer quantity = info.getInteger("quantity");
|
||||
BigDecimal amount = info.getBigDecimal("amount");
|
||||
builder.append(getFormatLabel(key3(categoryName, quantity.toString(), bigDecimalToString(amount), 14, 8), signLabelInfo.s)).append(signLabelInfo.br);
|
||||
builder.append(getFormatLabel(key3(categoryName, quantity.toString(), bdToStr(amount), 14, 8), signLabelInfo.s)).append(signLabelInfo.br);
|
||||
});
|
||||
}
|
||||
builder.append(getDividingLine()).append(signLabelInfo.br)
|
||||
@@ -272,8 +273,8 @@ public interface PrinterImpl {
|
||||
default String buildGuestOrderPrintData(OrderPrintDTO orderPrintDTO, List<OrderDetail> detailList) {
|
||||
PrintSignLabel signLabelInfo = getSignLabelInfo();
|
||||
StringBuilder data = new StringBuilder();
|
||||
data.append(getFormatLabel(orderPrintDTO.getShopName(), signLabelInfo.center)).append(signLabelInfo.br);
|
||||
data.append(getFormatLabel("客看单", signLabelInfo.center)).append(signLabelInfo.br);
|
||||
data.append(getFormatLabel(orderPrintDTO.getShopName(), signLabelInfo.center)).append(signLabelInfo.br);
|
||||
data.append(getFormatLabel("客看单", signLabelInfo.center)).append(signLabelInfo.br);
|
||||
if (StrUtil.isNotBlank(orderPrintDTO.getPickupNum())) {
|
||||
data.append(getFormatLabel(orderPrintDTO.getPickupNum(), signLabelInfo.f)).append(signLabelInfo.br);
|
||||
}
|
||||
@@ -580,7 +581,7 @@ public interface PrinterImpl {
|
||||
}
|
||||
|
||||
/**
|
||||
* 日报表打印单
|
||||
* 经营日报打印单
|
||||
*/
|
||||
default String buildDayReportData(DayReportPrintDTO record) {
|
||||
PrintSignLabel signLabelInfo = getSignLabelInfo();
|
||||
@@ -593,54 +594,52 @@ public interface PrinterImpl {
|
||||
// 基础信息:打印时间、操作人、统计时间
|
||||
builder.append(getFormatLabel(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(getFormatLabel(StrUtil.format("时间: {}", record.getStatisticsTime()), signLabelInfo.s)).append(signLabelInfo.br).append(signLabelInfo.br);
|
||||
builder.append(getFormatLabel(StrUtil.format("统计时间: {}", record.getStatisticsTime()), signLabelInfo.s)).append(signLabelInfo.br).append(signLabelInfo.br);
|
||||
|
||||
// 营业总额
|
||||
DayReportPrintDTO.TurnoverSts turnover = record.getTurnover();
|
||||
String turnoverStr = turnover.getTurnover().stripTrailingZeros().toPlainString();
|
||||
builder.append(getFormatLabel(leftRightAlign("营业总额:", turnoverStr, 32), signLabelInfo.s)).append(signLabelInfo.br).append(signLabelInfo.br);
|
||||
|
||||
// 实际收款的支付方式
|
||||
builder.append(getFormatLabel("实际收款的支付方式", signLabelInfo.s)).append(signLabelInfo.br);
|
||||
builder.append(getFormatLabel(leftRightAlign(" 现金", turnover.getCash().stripTrailingZeros().toPlainString(), 32), signLabelInfo.s)).append(signLabelInfo.br);
|
||||
builder.append(getFormatLabel(leftRightAlign(" 微信", turnover.getWechat().stripTrailingZeros().toPlainString(), 32), signLabelInfo.s)).append(signLabelInfo.br);
|
||||
builder.append(getFormatLabel(leftRightAlign(" 支付宝", turnover.getAlipay().stripTrailingZeros().toPlainString(), 32), signLabelInfo.s)).append(signLabelInfo.br);
|
||||
builder.append(getFormatLabel(leftRightAlign(" 二维码收款", turnover.getSelfScan().stripTrailingZeros().toPlainString(), 32), signLabelInfo.s)).append(signLabelInfo.br);
|
||||
builder.append(getFormatLabel(leftRightAlign(" 扫码收款", turnover.getBarScan().stripTrailingZeros().toPlainString(), 32), signLabelInfo.s)).append(signLabelInfo.br);
|
||||
builder.append(getFormatLabel(leftRightAlign(" 充值", turnover.getRecharge().stripTrailingZeros().toPlainString(), 32), signLabelInfo.s)).append(signLabelInfo.br).append(signLabelInfo.br);
|
||||
|
||||
// 非实际收款的支付方式
|
||||
builder.append(getFormatLabel("非实际收款的支付方式", signLabelInfo.s)).append(signLabelInfo.br);
|
||||
builder.append(getFormatLabel(leftRightAlign(" 挂账", turnover.getOwed().stripTrailingZeros().toPlainString(), 32), signLabelInfo.s)).append(signLabelInfo.br);
|
||||
builder.append(getFormatLabel(leftRightAlign(" 余额", turnover.getBalance().stripTrailingZeros().toPlainString(), 32), signLabelInfo.s)).append(signLabelInfo.br);
|
||||
DayReportPrintDTO.BusinessSts turnover = record.getTurnover();
|
||||
builder.append(getFormatLabel("营业指标:", signLabelInfo.bold)).append(signLabelInfo.br).append(signLabelInfo.br);
|
||||
builder.append(getFormatLabel(leftRightAlign(" 订单原价总额", bdToStr(turnover.getOriginAmount()), 32), signLabelInfo.s)).append(signLabelInfo.br);
|
||||
builder.append(getFormatLabel(leftRightAlign(" 营业额", bdToStr(turnover.getTurnover()), 32), signLabelInfo.s)).append(signLabelInfo.br);
|
||||
builder.append(getFormatLabel(leftRightAlign(" 优惠金额", 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(getFormatLabel(leftRightAlign(" 折前单均价", bdToStr(turnover.getAverageOrderAmount()), 32), signLabelInfo.s)).append(signLabelInfo.br);
|
||||
builder.append(getFormatLabel(leftRightAlign(" 折后单均价", bdToStr(turnover.getAverageTurnover()), 32), signLabelInfo.s)).append(signLabelInfo.br);
|
||||
builder.append(getFormatLabel(leftRightAlign(" 退款金额", 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(getDividingLine()).append(signLabelInfo.br);
|
||||
|
||||
// 退款/退菜
|
||||
String refundAmountStr = record.getRefundAmount().stripTrailingZeros().toPlainString();
|
||||
// 退菜数量:示例图为固定4,这里按业务逻辑预留,若DTO无该字段可按需求补充
|
||||
String returnDishCount = "4";
|
||||
builder.append(getFormatLabel("退款/退菜", signLabelInfo.s)).append(signLabelInfo.br);
|
||||
builder.append(getFormatLabel(leftRightAlign(" 退款金额", refundAmountStr, 32), signLabelInfo.s)).append(signLabelInfo.br);
|
||||
builder.append(getFormatLabel(leftRightAlign(" 退菜数量", returnDishCount, 32), signLabelInfo.s)).append(signLabelInfo.br);
|
||||
// 收入来源
|
||||
DayReportPrintDTO.Income soIncome = record.getSourceIncome();
|
||||
builder.append(getFormatLabel("收入来源", signLabelInfo.bold)).append(signLabelInfo.br);
|
||||
builder.append(getFormatLabel(leftRightAlign(" 现金", bdToStr(soIncome.getCash()), 32), signLabelInfo.s)).append(signLabelInfo.br);
|
||||
builder.append(getFormatLabel(leftRightAlign(" 微信", bdToStr(soIncome.getWechat()), 32), signLabelInfo.s)).append(signLabelInfo.br);
|
||||
builder.append(getFormatLabel(leftRightAlign(" 支付宝", bdToStr(soIncome.getAlipay()), 32), signLabelInfo.s)).append(signLabelInfo.br);
|
||||
builder.append(getFormatLabel(leftRightAlign(" 美团团购", bdToStr(soIncome.getMeituan()), 32), signLabelInfo.s)).append(signLabelInfo.br);
|
||||
builder.append(getFormatLabel(leftRightAlign(" 抖音团购", bdToStr(soIncome.getDouyin()), 32), signLabelInfo.s)).append(signLabelInfo.br);
|
||||
builder.append(getFormatLabel(leftRightAlign(" 其它", bdToStr(soIncome.getOther()), 32), signLabelInfo.s)).append(signLabelInfo.br);
|
||||
builder.append(getDividingLine()).append(signLabelInfo.br);
|
||||
|
||||
// 订单(数量/订单总额)
|
||||
DayReportPrintDTO.OrderSts order = record.getOrder();
|
||||
String orderInfo = order.getOrderCount() + "/" + order.getOrderAmount().stripTrailingZeros().toPlainString();
|
||||
builder.append(getFormatLabel(leftRightAlign("订单(数量/订单总额)", orderInfo, 32), signLabelInfo.s)).append(signLabelInfo.br);
|
||||
// 实收统计
|
||||
DayReportPrintDTO.Income actualIncome = record.getActualIncome();
|
||||
builder.append(getFormatLabel("实收统计", signLabelInfo.bold)).append(signLabelInfo.br);
|
||||
builder.append(getFormatLabel(leftRightAlign(" 现金", bdToStr(actualIncome.getCash()), 32), signLabelInfo.s)).append(signLabelInfo.br);
|
||||
builder.append(getFormatLabel(leftRightAlign(" 微信", bdToStr(actualIncome.getWechat()), 32), signLabelInfo.s)).append(signLabelInfo.br);
|
||||
builder.append(getFormatLabel(leftRightAlign(" 支付宝", bdToStr(actualIncome.getAlipay()), 32), signLabelInfo.s)).append(signLabelInfo.br);
|
||||
builder.append(getFormatLabel(leftRightAlign(" 美团团购", bdToStr(actualIncome.getMeituan()), 32), signLabelInfo.s)).append(signLabelInfo.br);
|
||||
builder.append(getFormatLabel(leftRightAlign(" 抖音团购", bdToStr(actualIncome.getDouyin()), 32), signLabelInfo.s)).append(signLabelInfo.br);
|
||||
builder.append(getFormatLabel(leftRightAlign(" 其它", bdToStr(actualIncome.getOther()), 32), signLabelInfo.s)).append(signLabelInfo.br);
|
||||
builder.append(getDividingLine()).append(signLabelInfo.br);
|
||||
|
||||
// 数据统计
|
||||
DayReportPrintDTO.Sts sts = record.getSts();
|
||||
builder.append(getFormatLabel("数据统计", signLabelInfo.s)).append(signLabelInfo.br);
|
||||
builder.append(getFormatLabel(leftRightAlign("就餐人数", sts.getCustomerCount().toString(), 32), signLabelInfo.s)).append(signLabelInfo.br);
|
||||
builder.append(getFormatLabel(leftRightAlign("客单价", sts.getAvgPayAmount().stripTrailingZeros().toPlainString(), 32), signLabelInfo.s)).append(signLabelInfo.br);
|
||||
// 翻台率、毛利率:保留%符号,按示例格式输出
|
||||
String turnoverRateStr = sts.getTurnoverRate().stripTrailingZeros().toPlainString() + "%";
|
||||
String profitRateStr = sts.getProfitRate().stripTrailingZeros().toPlainString() + "%";
|
||||
builder.append(getFormatLabel(leftRightAlign("翻台率", turnoverRateStr, 32), signLabelInfo.s)).append(signLabelInfo.br);
|
||||
builder.append(getFormatLabel(leftRightAlign("毛利率", profitRateStr, 32), signLabelInfo.s)).append(signLabelInfo.br);
|
||||
builder.append(getFormatLabel(leftRightAlign("商品成本", sts.getProductCostAmount().stripTrailingZeros().toPlainString(), 32), signLabelInfo.s)).append(signLabelInfo.br);
|
||||
// 实收统计
|
||||
DayReportPrintDTO.DiscountSts disSta = record.getDiscountSta();
|
||||
builder.append(getFormatLabel("优惠统计", signLabelInfo.bold)).append(signLabelInfo.br);
|
||||
builder.append(getFormatLabel(leftRightAlign(" 新客立减", bdToStr(disSta.getNewConsumerDiscount()), 32), signLabelInfo.s)).append(signLabelInfo.br);
|
||||
builder.append(getFormatLabel(leftRightAlign(" 霸王餐", bdToStr(disSta.getFreeCashAmount()), 32), signLabelInfo.s)).append(signLabelInfo.br);
|
||||
builder.append(getFormatLabel(leftRightAlign(" 满减活动", bdToStr(disSta.getFullMinusAmount()), 32), signLabelInfo.s)).append(signLabelInfo.br);
|
||||
builder.append(getFormatLabel(leftRightAlign(" 优惠券", bdToStr(disSta.getCouponAmount()), 32), signLabelInfo.s)).append(signLabelInfo.br);
|
||||
builder.append(getFormatLabel(leftRightAlign(" 会员折扣", bdToStr(disSta.getMemberDiscount()), 32), signLabelInfo.s)).append(signLabelInfo.br);
|
||||
builder.append(getFormatLabel(leftRightAlign(" 积分抵扣金额", bdToStr(disSta.getPointsDiscountAmount()), 32), signLabelInfo.s)).append(signLabelInfo.br);
|
||||
builder.append(getFormatLabel(leftRightAlign(" 订单改价", bdToStr(disSta.getOrderDiscount()), 32), signLabelInfo.s)).append(signLabelInfo.br);
|
||||
|
||||
// 结尾空行 + 切纸(和充值/入库单完全一致)
|
||||
builder.append(signLabelInfo.getOut(150)).append(signLabelInfo.cut);
|
||||
@@ -710,7 +709,7 @@ public interface PrinterImpl {
|
||||
PrintSignLabel signLabelInfo = getSignLabelInfo();
|
||||
StringBuilder builder = new StringBuilder();
|
||||
// 标题:店铺名称 + 充值凭证
|
||||
builder.append(getFormatLabel(record.getShopName(),signLabelInfo.center)).append(signLabelInfo.br);
|
||||
builder.append(getFormatLabel(record.getShopName(), signLabelInfo.center)).append(signLabelInfo.br);
|
||||
builder.append(getFormatLabel("充值凭证", signLabelInfo.center)).append(signLabelInfo.br);
|
||||
|
||||
// 用户信息
|
||||
@@ -837,11 +836,16 @@ public interface PrinterImpl {
|
||||
return NumberUtil.round(new BigDecimal(str), 2).toPlainString();
|
||||
}
|
||||
|
||||
default String bigDecimalToString(BigDecimal bigDecimal) {
|
||||
/**
|
||||
* BigDecimal 转 String
|
||||
* 保留两位小数
|
||||
*/
|
||||
default String bdToStr(BigDecimal bigDecimal) {
|
||||
if (bigDecimal == null) {
|
||||
return "0";
|
||||
}
|
||||
return bigDecimal.toPlainString();
|
||||
//四舍五入
|
||||
return bigDecimal.setScale(2, RoundingMode.HALF_UP).toPlainString();
|
||||
}
|
||||
|
||||
// 两个内容 左 右对齐
|
||||
|
||||
Reference in New Issue
Block a user