分割线

This commit is contained in:
2026-04-16 17:03:37 +08:00
parent 46b4ee45d4
commit f53fb1d916
4 changed files with 46 additions and 36 deletions

View File

@@ -45,7 +45,7 @@ public class ShopUser implements Serializable {
/**
* 用户昵称
*/
@ColumnMask(Masks.CHINESE_NAME)
// @ColumnMask(Masks.CHINESE_NAME)
private String nickName;
/**

View File

@@ -9,7 +9,7 @@ import lombok.Getter;
@Getter
public enum ShopUserFlowBizEnum {
// 会员充值
CASH_IN("cashIn", "会员充值"),
CASH_IN("cashIn", "现金充值"),
CASHBACK("cashback", "消费返现"),
CASHBACK_REFUND("cashbackRefund", "消费返现扣减"),

View File

@@ -1,6 +1,7 @@
package com.czg.service.market.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.DesensitizedUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson2.JSONArray;
import com.czg.account.dto.shopuser.ShopUserMoneyEditDTO;
@@ -234,7 +235,7 @@ public class MkShopRechargeServiceImpl extends ServiceImpl<MkShopRechargeMapper,
RechargePrintDTO rechargePrintDTO = new RechargePrintDTO();
rechargePrintDTO.setUserId(shopUserId);
rechargePrintDTO.setUserName(shopUser.getNickName());
rechargePrintDTO.setUserPhone(shopUser.getPhone());
rechargePrintDTO.setUserPhone(DesensitizedUtil.mobilePhone(shopUser.getPhone()));
rechargePrintDTO.setPayTime(payTime);
rechargePrintDTO.setRechargeAmount(finalRechargeAmount);
rechargePrintDTO.setGiftAmount(finalGiftAmount);

View File

@@ -106,6 +106,18 @@ public interface PrinterImpl {
*/
PrintSignLabel getSignLabelInfo();
/**
* 获取分割线
*/
default String getDividingLine() {
String line = StrUtil.repeat("-", 32);
return getFormatLabel(line, getSignLabelInfo().s);
}
default String getDividingLine(Integer num) {
int length = num == null ? 32 : num;
String line = StrUtil.repeat("-", length);
return getFormatLabel(line, getSignLabelInfo().s);
}
default String getFormatLabel(String text, String[]... labels) {
StringBuilder str = new StringBuilder();
@@ -146,11 +158,11 @@ public interface PrinterImpl {
.append(getFormatLabel("非实际收款的支付方式", signLabelInfo.s)).append(signLabelInfo.br)
.append(getFormatLabel(leftRightAlign(" 挂账:", handoverRecord.getOwed().toPlainString(), 32), signLabelInfo.s)).append(signLabelInfo.br)
.append(getFormatLabel(leftRightAlign(" 余额:", handoverRecord.getBalance().toPlainString(), 32), signLabelInfo.s)).append(signLabelInfo.br)
.append(getFormatLabel("--------------------------------", signLabelInfo.s)).append(signLabelInfo.br)
.append(getDividingLine()).append(signLabelInfo.br)
.append(getFormatLabel("退菜/退款", signLabelInfo.s)).append(signLabelInfo.br)
.append(getFormatLabel(leftRightAlign(" 退款金额:", handoverRecord.getRefundAmount().toPlainString(), 32), signLabelInfo.s)).append(signLabelInfo.br)
.append(getFormatLabel(leftRightAlign(" 退菜数量:", handoverRecord.getReturnDishCount().toString(), 32), signLabelInfo.s)).append(signLabelInfo.br)
.append(getFormatLabel("--------------------------------", signLabelInfo.s)).append(signLabelInfo.br)
.append(getDividingLine()).append(signLabelInfo.br)
.append(getFormatLabel(leftRightAlign("订单数量/订单总额", handoverRecord.getOrderCount() + "/" + handoverRecord.getOrderTurnover(), 32), signLabelInfo.s)).append(signLabelInfo.br)
.append(getFormatLabel("----------- 销售数据 -----------", signLabelInfo.s)).append(signLabelInfo.br)
.append(getFormatLabel(key3("商品分类", "数量", "总计", 14, 8), signLabelInfo.s))
@@ -165,7 +177,7 @@ public interface PrinterImpl {
builder.append(getFormatLabel(key3(categoryName, quantity.toString(), amount.toPlainString(), 14, 8), signLabelInfo.s)).append(signLabelInfo.br);
});
}
builder.append(getFormatLabel("--------------------------------", signLabelInfo.s)).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(signLabelInfo.getOut(180))
.append(signLabelInfo.cut);
@@ -190,7 +202,7 @@ public interface PrinterImpl {
if (StrUtil.isNotBlank(orderPrintDTO.getTradeDate())) {
data.append(getFormatLabel(StrUtil.format("结账时间:{}", orderPrintDTO.getTradeDate()), signLabelInfo.s)).append(signLabelInfo.br);
}
data.append(getFormatLabel("--------------------------------", signLabelInfo.s)).append(signLabelInfo.br);
data.append(getDividingLine()).append(signLabelInfo.br);
data.append(getFormatLabel(key3("品名", "单价", "数量", 18, 9), signLabelInfo.s)).append(signLabelInfo.br);
for (OrderDetail detail : detailList) {
@@ -230,7 +242,7 @@ public interface PrinterImpl {
data.append(getFormatLabel(key3("打包费", toPlainStr(orderPrintDTO.getPackFee()), "", 18, 9), signLabelInfo.s)).append(signLabelInfo.br);
}
data.append(getFormatLabel("--------------------------------", signLabelInfo.s))
data.append(getDividingLine())
.append(signLabelInfo.br);
data.append(getFormatLabel(leftRightAlign("原价:", orderPrintDTO.getOriginalAmount(), 32), signLabelInfo.s)).append(signLabelInfo.br);
if (ObjectUtil.isNotNull(orderPrintDTO.getDiscountAmount())) {
@@ -239,16 +251,16 @@ public interface PrinterImpl {
if (StrUtil.isNotBlank(orderPrintDTO.getRemark())) {
data.append(getFormatLabel(StrUtil.format("备注:{}", orderPrintDTO.getRemark()), signLabelInfo.s)).append(signLabelInfo.br);
}
data.append(getFormatLabel("--------------------------------", signLabelInfo.s)).append(signLabelInfo.br);
data.append(getDividingLine()).append(signLabelInfo.br);
data.append(getFormatLabel(leftRightAlign("应付:", orderPrintDTO.getPayAmount(), 16), signLabelInfo.f)).append(signLabelInfo.br);
if ("结算单".equals(orderPrintDTO.getPrintTitle())) {
data.append(getFormatLabel("--------------------------------", signLabelInfo.s)).append(signLabelInfo.br);
data.append(getDividingLine()).append(signLabelInfo.br);
data.append(getFormatLabel(leftRightAlign("已付:", orderPrintDTO.getPayAmount(), 16), signLabelInfo.f)).append(signLabelInfo.br);
data.append(getFormatLabel(leftRightAlign("支付方式:", orderPrintDTO.getPayType(), 32), signLabelInfo.s)).append(signLabelInfo.br);
}
data.append(getFormatLabel("--------------------------------", signLabelInfo.s)).append(signLabelInfo.br);
data.append(getDividingLine()).append(signLabelInfo.br);
data.append(getFormatLabel(StrUtil.format("操作员:{}", orderPrintDTO.getOperator()), signLabelInfo.s)).append(signLabelInfo.br);
data.append(getFormatLabel(StrUtil.format("打印时间:{}", DateUtil.date().toString()), signLabelInfo.s)).append(signLabelInfo.br);
data.append(getFormatLabel(StrUtil.format("订单号:{}", orderPrintDTO.getOrderNo()), signLabelInfo.s)).append(signLabelInfo.br);
@@ -274,7 +286,7 @@ public interface PrinterImpl {
}
data.append(getFormatLabel(getFormatLabel(leftRightAlign(orderPrintDTO.getPrintType(), StrUtil.isNotBlank(orderPrintDTO.getSeatNum()) ? orderPrintDTO.getSeatNum() + "" : "", 32))
, signLabelInfo.s)).append(signLabelInfo.br);
data.append(getFormatLabel("--------------------------------", signLabelInfo.s)).append(signLabelInfo.br);
data.append(getDividingLine()).append(signLabelInfo.br);
data.append(getFormatLabel(key3("品名", "单价", "数量", 18, 9), signLabelInfo.s)).append(signLabelInfo.br);
for (OrderDetail detail : detailList) {
@@ -313,8 +325,7 @@ public interface PrinterImpl {
if (StrUtil.isNotBlank(orderPrintDTO.getPackFee())) {
data.append(getFormatLabel(key3("打包费", toPlainStr(orderPrintDTO.getPackFee()), "", 18, 9), signLabelInfo.s)).append(signLabelInfo.br);
}
data.append(getFormatLabel("-------------------------------", signLabelInfo.s))
.append(signLabelInfo.br);
data.append(getDividingLine()).append(signLabelInfo.br);
data.append(getFormatLabel(leftRightAlign("原价:", orderPrintDTO.getOriginalAmount(), 32), signLabelInfo.s)).append(signLabelInfo.br);
if (ObjectUtil.isNotNull(orderPrintDTO.getDiscountAmount())) {
data.append(getFormatLabel(leftRightAlign("优惠:", "-" + orderPrintDTO.getDiscountAmount(), 32), signLabelInfo.s)).append(signLabelInfo.br);
@@ -322,8 +333,7 @@ public interface PrinterImpl {
if (StrUtil.isNotBlank(orderPrintDTO.getRemark())) {
data.append(getFormatLabel(StrUtil.format("备注:{}", orderPrintDTO.getRemark()), signLabelInfo.s)).append(signLabelInfo.br);
}
data.append(getFormatLabel("--------------------------------", signLabelInfo.s))
.append(signLabelInfo.br);
data.append(getDividingLine()).append(signLabelInfo.br);
data.append(getFormatLabel(StrUtil.format("操作员:{}", orderPrintDTO.getOperator()), signLabelInfo.s)).append(signLabelInfo.br);
data.append(getFormatLabel(StrUtil.format("打印时间:{}", DateUtil.date().toString()), signLabelInfo.s)).append(signLabelInfo.br);
data.append(getFormatLabel(StrUtil.format("订单号:{}", orderPrintDTO.getOrderNo()), signLabelInfo.s)).append(signLabelInfo.br);
@@ -347,7 +357,7 @@ public interface PrinterImpl {
data.append(getFormatLabel(orderPrintDTO.getPickupNum(), signLabelInfo.f)).append(signLabelInfo.br);
data.append(getFormatLabel(getFormatLabel(leftRightAlign(orderPrintDTO.getPrintType(), StrUtil.isNotBlank(orderPrintDTO.getSeatNum()) ? orderPrintDTO.getSeatNum() + "" : "", 32))
, signLabelInfo.s)).append(signLabelInfo.br);
data.append(getFormatLabel("--------------------------------", signLabelInfo.s)).append(signLabelInfo.br);
data.append(getDividingLine()).append(signLabelInfo.br);
if (CollUtil.isNotEmpty(detailList)) {
data.append(getFormatLabel(key3("退款明细", "数量", "小计", 18, 9), signLabelInfo.s)).append(signLabelInfo.br);
@@ -379,7 +389,7 @@ public interface PrinterImpl {
});
}
}
data.append(getFormatLabel("--------------------------------", signLabelInfo.s))
data.append(getDividingLine())
.append(signLabelInfo.br);
}
if ("退款单".equals(orderPrintDTO.getPrintTitle())) {
@@ -392,7 +402,7 @@ public interface PrinterImpl {
data.append(getFormatLabel(StrUtil.format("退菜原因: {}", orderPrintDTO.getRefundReason()), signLabelInfo.s))
.append(signLabelInfo.br);
}
data.append(getFormatLabel("--------------------------------", signLabelInfo.s))
data.append(getDividingLine())
.append(signLabelInfo.br);
data.append(getFormatLabel(StrUtil.format("操作员:{}", orderPrintDTO.getOperator()), signLabelInfo.s)).append(signLabelInfo.br);
data.append(getFormatLabel(StrUtil.format("打印时间:{}", DateUtil.date().toString()), signLabelInfo.s)).append(signLabelInfo.br);
@@ -415,7 +425,7 @@ public interface PrinterImpl {
data.append(getFormatLabel(orderPrintDTO.getPrintTitle(), signLabelInfo.s, signLabelInfo.center)).append(signLabelInfo.br);
data.append(getFormatLabel(orderPrintDTO.getPickupNum(), signLabelInfo.f)).append(signLabelInfo.br);
data.append(getFormatLabel(getFormatLabel(orderPrintDTO.getPrintType()), signLabelInfo.s)).append(signLabelInfo.br);
data.append(getFormatLabel("--------------------------------", signLabelInfo.s)).append(signLabelInfo.br);
data.append(getDividingLine()).append(signLabelInfo.br);
if (CollUtil.isNotEmpty(detailList)) {
data.append(getFormatLabel(leftRightAlign("品名", "数量", 32), signLabelInfo.s)).append(signLabelInfo.br);
for (OrderDetail detail : detailList) {
@@ -440,11 +450,11 @@ public interface PrinterImpl {
}
data.append(getFormatLabel(StrUtil.format(" 备注:{}", detail.getRemark()), signLabelInfo.s)).append(signLabelInfo.br);
}
data.append(getFormatLabel("--------------------------------", signLabelInfo.s))
data.append(getDividingLine())
.append(signLabelInfo.br);
}
data.append(getFormatLabel(StrUtil.format("备注: {}", orderPrintDTO.getRemark()), signLabelInfo.s)).append(signLabelInfo.br);
data.append(getFormatLabel("--------------------------------", signLabelInfo.s))
data.append(getDividingLine())
.append(signLabelInfo.br);
data.append(getFormatLabel(StrUtil.format("操作员:{}", orderPrintDTO.getOperator()), signLabelInfo.s)).append(signLabelInfo.br);
data.append(getFormatLabel(StrUtil.format("打印时间:{}", DateUtil.date().toString()), signLabelInfo.s)).append(signLabelInfo.br);
@@ -538,7 +548,7 @@ public interface PrinterImpl {
// 入库时间
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(getFormatLabel("--------------------------------")).append(signLabelInfo.br);
builder.append(getDividingLine()).append(signLabelInfo.br);
builder.append(getFormatLabel(key4("耗材名称", "库存单位", "IN".equals(record.getType()) ? "入库数量" : "出库数量", "金额",
14, 6, 6), signLabelInfo.s)).append(signLabelInfo.br);
@@ -561,7 +571,7 @@ public interface PrinterImpl {
String totalLine = key4("总计", consCountStr, stockNumberCountStr, amountCountStr, 8, 8, 8);
builder.append(getFormatLabel(totalLine, signLabelInfo.s)).append(signLabelInfo.br);
builder.append(getFormatLabel("--------------------------------")).append(signLabelInfo.br);
builder.append(getDividingLine()).append(signLabelInfo.br);
// 操作员、打印时间
builder.append(getFormatLabel(StrUtil.format("操作员: {}", record.getOperator()), signLabelInfo.s)).append(signLabelInfo.br);
@@ -606,7 +616,7 @@ public interface PrinterImpl {
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);
builder.append(getFormatLabel("--------------------------------")).append(signLabelInfo.br);
builder.append(getDividingLine()).append(signLabelInfo.br);
// 退款/退菜
String refundAmountStr = record.getRefundAmount().stripTrailingZeros().toPlainString();
@@ -615,13 +625,13 @@ public interface PrinterImpl {
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);
builder.append(getFormatLabel("--------------------------------")).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);
builder.append(getFormatLabel("--------------------------------")).append(signLabelInfo.br);
builder.append(getDividingLine()).append(signLabelInfo.br);
// 数据统计
DayReportPrintDTO.Sts sts = record.getSts();
@@ -660,7 +670,7 @@ public interface PrinterImpl {
String totalCountStr = record.getTotalProductCount().stripTrailingZeros().toPlainString();
String totalActualStr = record.getTotalActualAmount().stripTrailingZeros().toPlainString();
builder.append(getFormatLabel(StrUtil.format("总计商品{}件,实收金额{}元", totalCountStr, totalActualStr), signLabelInfo.s)).append(signLabelInfo.br);
builder.append(getFormatLabel("--------------------------------")).append(signLabelInfo.br).append(signLabelInfo.br);
builder.append(getDividingLine()).append(signLabelInfo.br).append(signLabelInfo.br);
// 表头:商品、数量、实收、销售额(四列对齐,和示例图完全匹配)
String header = key4("商品", "数量", "实收", "销售额", 12, 6, 6);
@@ -707,11 +717,11 @@ public interface PrinterImpl {
builder.append(getFormatLabel("充值凭证", signLabelInfo.center)).append(signLabelInfo.br);
// 用户信息
builder.append(getFormatLabel(StrUtil.format("充值用户: {}(id{})", record.getUserName(), record.getUserId()), signLabelInfo.s)).append(signLabelInfo.br);
builder.append(getFormatLabel(StrUtil.format("充值用户: {}", record.getUserName(), signLabelInfo.s))).append(signLabelInfo.br);
builder.append(getFormatLabel(StrUtil.format("手机号: {}", record.getUserPhone()), signLabelInfo.s)).append(signLabelInfo.br);
builder.append(getFormatLabel(StrUtil.format("支付时间: {}", DateUtil.format(record.getPayTime(), "yyyy/MM/dd HH:mm:ss")), signLabelInfo.s)).append(signLabelInfo.br);
// 充值明细
builder.append(getFormatLabel("--------------------------------")).append(signLabelInfo.br);
builder.append(getDividingLine()).append(signLabelInfo.br);
builder.append(getFormatLabel(leftRightAlign(" 充值金额:", record.getRechargeAmount().stripTrailingZeros().toPlainString(), 32), signLabelInfo.s)).append(signLabelInfo.br);
if (record.getGiftAmount() != null && record.getGiftAmount().compareTo(BigDecimal.ZERO) > 0) {
builder.append(getFormatLabel(leftRightAlign(" 赠送金额:", record.getGiftAmount().stripTrailingZeros().toPlainString(), 32), signLabelInfo.s)).append(signLabelInfo.br);
@@ -723,11 +733,11 @@ public interface PrinterImpl {
builder.append(getFormatLabel(leftRightAlign(" 赠送优惠券:", record.getGiftCoupon() + "", 32), signLabelInfo.s)).append(signLabelInfo.br);
}
builder.append(getFormatLabel(leftRightAlign(" 充值后余额:", record.getBalance().stripTrailingZeros().toPlainString(), 32), signLabelInfo.s)).append(signLabelInfo.br);
builder.append(getFormatLabel("--------------------------------")).append(signLabelInfo.br);
builder.append(getDividingLine()).append(signLabelInfo.br);
// 支付信息
builder.append(getFormatLabel(leftRightAlign("已付金额:", record.getRechargeAmount().stripTrailingZeros().toPlainString(), 32), signLabelInfo.s)).append(signLabelInfo.br);
builder.append(getFormatLabel(leftRightAlign("支付方式:", record.getPayType(), 32), signLabelInfo.s)).append(signLabelInfo.br);
builder.append(getFormatLabel("--------------------------------")).append(signLabelInfo.br);
builder.append(getDividingLine()).append(signLabelInfo.br);
builder.append(getFormatLabel(StrUtil.format("操作员: {}", record.getOperator()), signLabelInfo.s)).append(signLabelInfo.br);
builder.append(getFormatLabel(StrUtil.format("充值编号: {}", record.getRechargeId()), signLabelInfo.s)).append(signLabelInfo.br);
@@ -764,7 +774,7 @@ public interface PrinterImpl {
}
}
builder.append(getFormatLabel("--------------------------------")).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);
@@ -772,7 +782,7 @@ public interface PrinterImpl {
builder.append(getFormatLabel(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(getFormatLabel("--------------------------------")).append(signLabelInfo.br).append(signLabelInfo.br);
builder.append(getDividingLine()).append(signLabelInfo.br).append(signLabelInfo.br);
// 操作员、打印时间
builder.append(getFormatLabel(StrUtil.format("操作员: {}", record.getOperator()), signLabelInfo.s)).append(signLabelInfo.br);
// 打印时间复用之前的DateUtil格式化若DTO需补充printTime字段可按需求添加
@@ -808,8 +818,7 @@ public interface PrinterImpl {
getFormatLabel("怕过号,扫一扫", signLabelInfo.center, signLabelInfo.bold) +
signLabelInfo.br +
getFormatLabel(codeUrl, signLabelInfo.center, signLabelInfo.qr) +
signLabelInfo.br +
"--------------------------------" + signLabelInfo.br +
signLabelInfo.br + getDividingLine() + signLabelInfo.br +
getFormatLabel(shopNote, signLabelInfo.s) +
getFormatLabel(StrUtil.format("取号时间: {}", DateUtil.format(takeTime, "yyyy-MM-dd HH:mm:ss")), signLabelInfo.s) +
signLabelInfo.br +