Compare commits
11 Commits
2ea8b3364c
...
test
| Author | SHA1 | Date | |
|---|---|---|---|
| 6a94645076 | |||
| 24ea4bfc32 | |||
| 052becc835 | |||
| 732a4718f6 | |||
| 451c880d71 | |||
| 0a0f6d53bc | |||
| 2ddd4ba481 | |||
| 79aeec76b7 | |||
| d9d95da453 | |||
| 962e6d7a0c | |||
| 976f4ad1c4 |
@@ -12,9 +12,11 @@ import com.czg.order.entity.MqLog;
|
||||
import com.czg.order.entity.SysPrintData;
|
||||
import com.czg.order.service.MqLogService;
|
||||
import com.czg.order.service.SysPrintDataService;
|
||||
import com.czg.print.StockPrintDTO;
|
||||
import com.czg.service.RedisService;
|
||||
import com.czg.service.order.print.PrintConfig;
|
||||
import com.czg.service.order.print.PrinterHandler;
|
||||
import com.czg.utils.FunUtils;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
||||
@@ -100,9 +102,11 @@ public class PrintMqListener {
|
||||
Long shopId = jsonObject.getLong("shopId");
|
||||
String printTypeEnum = jsonObject.getString("printTypeEnum");
|
||||
JSONObject data2 = jsonObject.getJSONObject("data");
|
||||
JSONArray data3 = null;
|
||||
JSONArray data3;
|
||||
if (data2 == null) {
|
||||
data3 = jsonObject.getJSONArray("data");
|
||||
} else {
|
||||
data3 = null;
|
||||
}
|
||||
PrinterHandler.PrintTypeEnum typeEnum = PrinterHandler.PrintTypeEnum.valueOf(printTypeEnum);
|
||||
if (typeEnum != PrinterHandler.PrintTypeEnum.HANDOVER) {
|
||||
@@ -117,6 +121,6 @@ public class PrintMqListener {
|
||||
printDataService.save(sysPrintData);
|
||||
rabbitPublisher.sendOtherPrintLocalMsg(shopId, printTypeEnum, sysPrintData.getId());
|
||||
}
|
||||
printConfig.otherHandler(shopId, data2, data3, typeEnum);
|
||||
FunUtils.asyncSafeRunVoid(() -> printConfig.otherHandler(shopId, data2, data3, typeEnum));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,7 +63,6 @@ public class ProductController {
|
||||
* 商品-分页
|
||||
*/
|
||||
@GetMapping("page")
|
||||
@OperationLog("商品-分页")
|
||||
//@SaAdminCheckPermission("product:page")
|
||||
public CzgResult<Map<String, Object>> getProductPage(ProductDTO param) {
|
||||
Page<ProductDTO> data = productService.getProductPage(param);
|
||||
@@ -83,7 +82,6 @@ public class ProductController {
|
||||
* 商品-列表
|
||||
*/
|
||||
@GetMapping("list")
|
||||
@OperationLog("商品-列表")
|
||||
public CzgResult<List<ProductDTO>> getProductList(@RequestParam(required = false) Long categoryId) {
|
||||
return CzgResult.success(productService.getProductCacheList(StpKit.USER.getShopId(), categoryId));
|
||||
}
|
||||
@@ -92,7 +90,6 @@ public class ProductController {
|
||||
* 商品-详情
|
||||
*/
|
||||
@GetMapping("{id}")
|
||||
@OperationLog("商品-详情")
|
||||
//@SaAdminCheckPermission("product:info")
|
||||
public CzgResult<ProductDTO> getProductById(@PathVariable("id") Long id) {
|
||||
AssertUtil.isNull(id, "{}不能为空", "id");
|
||||
@@ -242,7 +239,6 @@ public class ProductController {
|
||||
* 商品-统计
|
||||
*/
|
||||
@GetMapping("statistics")
|
||||
@OperationLog("商品-统计")
|
||||
//@SaAdminCheckPermission("product:statistics")
|
||||
public CzgResult<ProductStatisticsVo> statistics(ProductInfoParam param) {
|
||||
Long shopId = StpKit.USER.getShopId(0L);
|
||||
@@ -251,6 +247,17 @@ public class ProductController {
|
||||
return CzgResult.success(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 商品-批量操作
|
||||
*/
|
||||
@GetMapping("batchOperate")
|
||||
public CzgResult<Void> batchOperate(ProductBatchParam param) {
|
||||
Long shopId = StpKit.USER.getShopId();
|
||||
param.setShopId(shopId);
|
||||
productService.batchOperate(param);
|
||||
return CzgResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 商品-报损
|
||||
*/
|
||||
|
||||
@@ -5,7 +5,10 @@ import com.alibaba.fastjson2.JSONWriter;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.data.redis.core.Cursor;
|
||||
import org.springframework.data.redis.core.RedisCallback;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.data.redis.core.ScanOptions;
|
||||
import org.springframework.data.redis.core.script.DefaultRedisScript;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
@@ -52,6 +55,34 @@ public class RedisService {
|
||||
return redisTemplate.delete(keys);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除某前缀Key
|
||||
* @param prefix
|
||||
*/
|
||||
public void deleteKeysByPrefixSafe(String prefix) {
|
||||
// 拼接匹配规则:前缀 + * → 比如传入 user → 匹配 user*
|
||||
String pattern = prefix + "*";
|
||||
|
||||
// redisTemplate.execute:使用 Redis 底层连接执行原生命令(性能更高)
|
||||
redisTemplate.execute((RedisCallback<Void>) connection -> {
|
||||
// try-with-resources:自动关闭游标,避免资源泄漏
|
||||
try (Cursor<byte[]> cursor = connection.scan(
|
||||
// SCAN 配置:匹配规则、每次扫描1000条
|
||||
ScanOptions.scanOptions().match(pattern).count(1000).build()
|
||||
)) {
|
||||
// 迭代遍历扫描到的所有 key
|
||||
while (cursor.hasNext()) {
|
||||
// 删除当前遍历到的 key
|
||||
connection.del(cursor.next());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// 异常捕获打印,避免删除失败导致程序报错
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 指定缓存失效时间
|
||||
*
|
||||
|
||||
@@ -19,9 +19,14 @@ public class OrderInfoPrintDTO implements Serializable {
|
||||
*/
|
||||
@NotNull(message = "id不为空")
|
||||
private Long id;
|
||||
/**
|
||||
* 店铺id
|
||||
*/
|
||||
private Long shopId;
|
||||
/**
|
||||
* 1 预结算单
|
||||
* 2 结算单
|
||||
* 3 后厨单
|
||||
*/
|
||||
@NotNull(message = "打印类型不为空")
|
||||
private Integer type;
|
||||
|
||||
@@ -117,7 +117,7 @@ public class ProductDTO implements Serializable {
|
||||
* 称重 价格/千克
|
||||
*/
|
||||
// @NotNull(message = "重量不能为空", groups = DefaultGroup.class)
|
||||
private BigDecimal weight;
|
||||
private String weight;
|
||||
/**
|
||||
* 是否允许临时改价
|
||||
*/
|
||||
|
||||
@@ -85,7 +85,7 @@ public class Product implements Serializable {
|
||||
/**
|
||||
* 称重 价格/千克
|
||||
*/
|
||||
private BigDecimal weight;
|
||||
private String weight;
|
||||
/**
|
||||
* 是否允许临时改价
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
package com.czg.product.param;
|
||||
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 商品批量操作
|
||||
*
|
||||
* @author ww
|
||||
*/
|
||||
@Data
|
||||
public class ProductBatchParam implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
/**
|
||||
* 商品id集合
|
||||
*/
|
||||
@NotNull(message = "商品id集合不能为空")
|
||||
private List<Long> ids;
|
||||
/**
|
||||
* 商品操作
|
||||
* category 修改分类
|
||||
* isSale 上下架
|
||||
* is_sold_stock 售罄
|
||||
* isAutoSoldStock 自动售罄
|
||||
*/
|
||||
@NotBlank(message = "操作类型不能为空")
|
||||
private String type;
|
||||
/**
|
||||
* 操作值
|
||||
*/
|
||||
@NotBlank(message = "操作值不能为空")
|
||||
private String value;
|
||||
/**
|
||||
* 店铺id
|
||||
*/
|
||||
private Long shopId;
|
||||
}
|
||||
@@ -110,7 +110,10 @@ public interface ProductService extends IService<Product> {
|
||||
* @param param 商品报损入参
|
||||
*/
|
||||
void reportDamage(ProductReportDamageParam param);
|
||||
|
||||
/**
|
||||
* 批量操作商品
|
||||
*/
|
||||
void batchOperate(ProductBatchParam param);
|
||||
/**
|
||||
* 商品统计
|
||||
*
|
||||
|
||||
@@ -41,7 +41,7 @@ public class FeiPrinter extends PrinterHandler implements PrinterImpl {
|
||||
super("飞鹅");
|
||||
}
|
||||
|
||||
private final PrintSignLabel printSignLabel = new PrintSignLabel()
|
||||
private final PrintLabel printLabel = new PrintLabel()
|
||||
.setBr("<BR>")
|
||||
.setCut("<PCUT>")
|
||||
.setOut("OUT")
|
||||
@@ -55,8 +55,8 @@ public class FeiPrinter extends PrinterHandler implements PrinterImpl {
|
||||
.setBold(new String[]{"<BOLD>", "</BOLD>"});
|
||||
|
||||
@Override
|
||||
public PrintSignLabel getSignLabelInfo() {
|
||||
return printSignLabel;
|
||||
public PrintLabel getSignLabelInfo() {
|
||||
return printLabel;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -30,7 +30,7 @@ import java.util.Objects;
|
||||
public interface PrinterImpl {
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
class PrintSignLabel {
|
||||
class PrintLabel {
|
||||
/**
|
||||
* <BR> :换行符
|
||||
* <CUT> :切刀指令/自动走纸(主动切纸,仅限切刀打印机使用才有效果/手动撕纸设备使用该指令时为自动走纸)
|
||||
@@ -61,7 +61,7 @@ public interface PrinterImpl {
|
||||
private String[] centerBold;
|
||||
private String[] bold;
|
||||
private String br;
|
||||
//f 的行数字符为 30
|
||||
//s 的行数字符为 30
|
||||
private String[] s;
|
||||
//f 的行数字符为 14
|
||||
private String[] f;
|
||||
@@ -71,11 +71,26 @@ public interface PrinterImpl {
|
||||
private String out;
|
||||
private String rs;
|
||||
|
||||
public String getOut(int num) {
|
||||
if (out != null) {
|
||||
return StrUtil.format("<{}:{}>", out, num);
|
||||
}
|
||||
return "";
|
||||
|
||||
/**
|
||||
* 走纸
|
||||
*/
|
||||
public String out(int num) {
|
||||
return StrUtil.format("<{}:{}>", out, num);
|
||||
}
|
||||
|
||||
public String out() {
|
||||
return out(180);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置可变字体大小
|
||||
* <CS:x>:设置可变字体大小</CS>(x:16,24,32,48,64,72,96都可支持,如x=96则为96*96字体)
|
||||
*
|
||||
* @param num 字号
|
||||
*/
|
||||
public String[] cs(int num) {
|
||||
return new String[]{StrUtil.format("<CS:{}>", num), "</CS>"};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,7 +111,7 @@ public interface PrinterImpl {
|
||||
*
|
||||
* @return 标签信息
|
||||
*/
|
||||
PrintSignLabel getSignLabelInfo();
|
||||
PrintLabel getSignLabelInfo();
|
||||
|
||||
/**
|
||||
* 获取分割线
|
||||
@@ -129,7 +144,7 @@ public interface PrinterImpl {
|
||||
* 构建交班 打印元数据
|
||||
*/
|
||||
default String buildHandoverData(HandoverRecordDTO handoverRecord) {
|
||||
PrintSignLabel signLabelInfo = getSignLabelInfo();
|
||||
PrintLabel signLabelInfo = getSignLabelInfo();
|
||||
StringBuilder builder = new StringBuilder()
|
||||
.append(formatLabel(handoverRecord.getShopName(), signLabelInfo.center)).append(signLabelInfo.br)
|
||||
.append(formatLabel("交班小票", signLabelInfo.center)).append(signLabelInfo.br)
|
||||
@@ -161,19 +176,19 @@ public interface PrinterImpl {
|
||||
|
||||
if (StrUtil.isNotBlank(handoverRecord.getCategoryData())) {
|
||||
builder.append(formatLabel("----------- 销售数据 -----------", signLabelInfo.s)).append(signLabelInfo.br)
|
||||
.append(formatLabel(key3("商品分类", "数量", "总计", 14, 8), signLabelInfo.s))
|
||||
.append(formatLabel(key3("商品分类", "数量", "总计", 14, 8, 32), signLabelInfo.s))
|
||||
.append(signLabelInfo.br);
|
||||
JSONArray.parseArray(handoverRecord.getCategoryData()).forEach(item -> {
|
||||
JSONObject info = (JSONObject) item;
|
||||
String categoryName = info.getString("categoryName");
|
||||
Integer quantity = info.getInteger("quantity");
|
||||
BigDecimal amount = info.getBigDecimal("amount");
|
||||
builder.append(formatLabel(key3(categoryName, quantity.toString(), bdToStr(amount), 14, 8), signLabelInfo.s)).append(signLabelInfo.br);
|
||||
builder.append(formatLabel(key3(categoryName, quantity.toString(), bdToStr(amount), 14, 8, 32), signLabelInfo.s)).append(signLabelInfo.br);
|
||||
});
|
||||
}
|
||||
builder.append(getDividingLine()).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.out())
|
||||
.append(signLabelInfo.cut);
|
||||
return builder.toString();
|
||||
}
|
||||
@@ -186,18 +201,18 @@ public interface PrinterImpl {
|
||||
* @return 订单打印元数据
|
||||
*/
|
||||
default String buildOrderPrintData(OrderPrintDTO orderPrintDTO, List<OrderDetail> detailList) {
|
||||
PrintSignLabel signLabelInfo = getSignLabelInfo();
|
||||
PrintLabel signLabel = getSignLabelInfo();
|
||||
StringBuilder data = new StringBuilder();
|
||||
data.append(formatLabel(orderPrintDTO.getShopName(), signLabelInfo.center)).append(signLabelInfo.br);
|
||||
data.append(formatLabel(orderPrintDTO.getPrintTitle(), signLabelInfo.center)).append(signLabelInfo.br);
|
||||
data.append(formatLabel(orderPrintDTO.getPickupNum(), signLabelInfo.f)).append(signLabelInfo.br);
|
||||
data.append(formatLabel(orderPrintDTO.getShopName(), signLabel.center)).append(signLabel.br);
|
||||
data.append(formatLabel(orderPrintDTO.getPrintTitle(), signLabel.center)).append(signLabel.br);
|
||||
data.append(formatLabel(orderPrintDTO.getPickupNum(), signLabel.f)).append(signLabel.br);
|
||||
data.append(formatLabel(formatLabel(LRAlign(orderPrintDTO.getPrintType(), StrUtil.isNotBlank(orderPrintDTO.getSeatNum()) ? orderPrintDTO.getSeatNum() + "人" : "", 32))
|
||||
, signLabelInfo.s)).append(signLabelInfo.br);
|
||||
, signLabel.s)).append(signLabel.br);
|
||||
if (StrUtil.isNotBlank(orderPrintDTO.getTradeDate())) {
|
||||
data.append(formatLabel(StrUtil.format("结账时间:{}", orderPrintDTO.getTradeDate()), signLabelInfo.s)).append(signLabelInfo.br);
|
||||
data.append(formatLabel(StrUtil.format("结账时间:{}", orderPrintDTO.getTradeDate()), signLabel.s)).append(signLabel.br);
|
||||
}
|
||||
data.append(getDividingLine()).append(signLabelInfo.br);
|
||||
data.append(formatLabel(key3("品名", "单价", "数量", 18, 9), signLabelInfo.s)).append(signLabelInfo.br);
|
||||
data.append(getDividingLine()).append(signLabel.br);
|
||||
data.append(formatLabel(key3("品名", "单价", "数量", 18, 9, 32), signLabel.s)).append(signLabel.br);
|
||||
|
||||
for (OrderDetail detail : detailList) {
|
||||
BigDecimal subtract = detail.getNum().subtract(detail.getReturnNum());
|
||||
@@ -206,11 +221,12 @@ public interface PrinterImpl {
|
||||
}
|
||||
String number = subtract.stripTrailingZeros().toPlainString();
|
||||
String unitPrice = toPlainStr(detail.getUnitPrice().stripTrailingZeros().toPlainString());
|
||||
data.append(formatLabel(key3(detail.getProductName(), unitPrice, number, 18, 7), signLabelInfo.s)).append(signLabelInfo.br);
|
||||
data.append(formatLabel(key3(detail.getProductName(), unitPrice, number, 18, 7, 32), signLabel.s)).append(signLabel.br);
|
||||
// data.append(formatLabel(key3(detail.getProductName(), unitPrice, number, 13, 4,24), signLabel.cs(32))).append(signLabel.br);
|
||||
|
||||
if (StrUtil.isNotBlank(detail.getSkuName())) {
|
||||
data.append(formatLabel(StrUtil.format("规格:{}", detail.getSkuName()), signLabelInfo.s))
|
||||
.append(signLabelInfo.br);
|
||||
data.append(formatLabel(StrUtil.format("规格:{}", detail.getSkuName()), signLabel.s))
|
||||
.append(signLabel.br);
|
||||
}
|
||||
String proGroupInfo = detail.getProGroupInfo();
|
||||
if (StrUtil.isBlank(proGroupInfo)) {
|
||||
@@ -225,41 +241,41 @@ public interface PrinterImpl {
|
||||
jsonObject.getJSONArray("goods").forEach(item -> {
|
||||
String proName = ((JSONObject) item).getString("proName");
|
||||
String qty = ((JSONObject) item).getString("number");
|
||||
data.append(formatLabel(key3(" - " + proName, "", qty, 18, 9), signLabelInfo.s)).append(signLabelInfo.br);
|
||||
data.append(formatLabel(key3(" - " + proName, "", qty, 18, 9, 32), signLabel.s)).append(signLabel.br);
|
||||
});
|
||||
}
|
||||
}
|
||||
if (StrUtil.isNotBlank(orderPrintDTO.getSeatAmount())) {
|
||||
data.append(formatLabel(key3("餐位费", orderPrintDTO.getSeatAmount(), orderPrintDTO.getSeatNum(), 18, 9), signLabelInfo.s)).append(signLabelInfo.br);
|
||||
data.append(formatLabel(key3("餐位费", orderPrintDTO.getSeatAmount(), orderPrintDTO.getSeatNum(), 18, 9, 32), signLabel.s)).append(signLabel.br);
|
||||
}
|
||||
if (StrUtil.isNotBlank(orderPrintDTO.getPackFee())) {
|
||||
data.append(formatLabel(key3("打包费", toPlainStr(orderPrintDTO.getPackFee()), "", 18, 9), signLabelInfo.s)).append(signLabelInfo.br);
|
||||
data.append(formatLabel(key3("打包费", toPlainStr(orderPrintDTO.getPackFee()), "", 18, 9, 32), signLabel.s)).append(signLabel.br);
|
||||
|
||||
}
|
||||
data.append(getDividingLine())
|
||||
.append(signLabelInfo.br);
|
||||
data.append(formatLabel(LRAlign("原价:", orderPrintDTO.getOriginalAmount(), 32), signLabelInfo.s)).append(signLabelInfo.br);
|
||||
.append(signLabel.br);
|
||||
data.append(formatLabel(LRAlign("原价:", orderPrintDTO.getOriginalAmount(), 32), signLabel.s)).append(signLabel.br);
|
||||
if (ObjectUtil.isNotNull(orderPrintDTO.getDiscountAmount())) {
|
||||
data.append(formatLabel(LRAlign("优惠:", "-" + orderPrintDTO.getDiscountAmount(), 32), signLabelInfo.s)).append(signLabelInfo.br);
|
||||
data.append(formatLabel(LRAlign("优惠:", "-" + orderPrintDTO.getDiscountAmount(), 32), signLabel.s)).append(signLabel.br);
|
||||
}
|
||||
if (StrUtil.isNotBlank(orderPrintDTO.getRemark())) {
|
||||
data.append(formatLabel(StrUtil.format("备注:{}", orderPrintDTO.getRemark()), signLabelInfo.s)).append(signLabelInfo.br);
|
||||
data.append(formatLabel(StrUtil.format("备注:{}", orderPrintDTO.getRemark()), signLabel.s)).append(signLabel.br);
|
||||
}
|
||||
data.append(getDividingLine()).append(signLabelInfo.br);
|
||||
data.append(formatLabel(LRAlign("应付:", orderPrintDTO.getPayAmount(), 16), signLabelInfo.f)).append(signLabelInfo.br);
|
||||
data.append(getDividingLine()).append(signLabel.br);
|
||||
data.append(formatLabel(LRAlign("应付:", orderPrintDTO.getPayAmount(), 16), signLabel.f)).append(signLabel.br);
|
||||
|
||||
if ("结算单".equals(orderPrintDTO.getPrintTitle())) {
|
||||
data.append(getDividingLine()).append(signLabelInfo.br);
|
||||
data.append(formatLabel(LRAlign("已付:", orderPrintDTO.getPayAmount(), 16), signLabelInfo.f)).append(signLabelInfo.br);
|
||||
data.append(formatLabel(LRAlign("支付方式:", orderPrintDTO.getPayType(), 32), signLabelInfo.s)).append(signLabelInfo.br);
|
||||
data.append(getDividingLine()).append(signLabel.br);
|
||||
data.append(formatLabel(LRAlign("已付:", orderPrintDTO.getPayAmount(), 16), signLabel.f)).append(signLabel.br);
|
||||
data.append(formatLabel(LRAlign("支付方式:", orderPrintDTO.getPayType(), 32), signLabel.s)).append(signLabel.br);
|
||||
}
|
||||
|
||||
data.append(getDividingLine()).append(signLabelInfo.br);
|
||||
data.append(formatLabel(StrUtil.format("操作员:{}", orderPrintDTO.getOperator()), signLabelInfo.s)).append(signLabelInfo.br);
|
||||
data.append(formatLabel(StrUtil.format("打印时间:{}", DateUtil.date().toString()), 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.cut);
|
||||
data.append(getDividingLine()).append(signLabel.br);
|
||||
data.append(formatLabel(StrUtil.format("操作员:{}", orderPrintDTO.getOperator()), signLabel.s)).append(signLabel.br);
|
||||
data.append(formatLabel(StrUtil.format("打印时间:{}", DateUtil.date().toString()), signLabel.s)).append(signLabel.br);
|
||||
data.append(formatLabel(StrUtil.format("订单号:{}", orderPrintDTO.getOrderNo()), signLabel.s)).append(signLabel.br);
|
||||
data.append(signLabel.out());
|
||||
data.append(signLabel.cut);
|
||||
return data.toString();
|
||||
}
|
||||
|
||||
@@ -271,7 +287,7 @@ public interface PrinterImpl {
|
||||
* @return 订单打印元数据
|
||||
*/
|
||||
default String buildGuestOrderPrintData(OrderPrintDTO orderPrintDTO, List<OrderDetail> detailList) {
|
||||
PrintSignLabel signLabelInfo = getSignLabelInfo();
|
||||
PrintLabel signLabelInfo = getSignLabelInfo();
|
||||
StringBuilder data = new StringBuilder();
|
||||
data.append(formatLabel(orderPrintDTO.getShopName(), signLabelInfo.center)).append(signLabelInfo.br);
|
||||
data.append(formatLabel("客看单", signLabelInfo.center)).append(signLabelInfo.br);
|
||||
@@ -281,7 +297,7 @@ public interface PrinterImpl {
|
||||
data.append(formatLabel(formatLabel(LRAlign(orderPrintDTO.getPrintType(), StrUtil.isNotBlank(orderPrintDTO.getSeatNum()) ? orderPrintDTO.getSeatNum() + "人" : "", 32))
|
||||
, signLabelInfo.s)).append(signLabelInfo.br);
|
||||
data.append(getDividingLine()).append(signLabelInfo.br);
|
||||
data.append(formatLabel(key3("品名", "单价", "数量", 18, 9), signLabelInfo.s)).append(signLabelInfo.br);
|
||||
data.append(formatLabel(key3("品名", "单价", "数量", 18, 9, 32), signLabelInfo.s)).append(signLabelInfo.br);
|
||||
|
||||
for (OrderDetail detail : detailList) {
|
||||
BigDecimal subtract = detail.getNum().subtract(detail.getReturnNum());
|
||||
@@ -290,7 +306,7 @@ public interface PrinterImpl {
|
||||
}
|
||||
String number = subtract.stripTrailingZeros().toPlainString();
|
||||
String unitPrice = toPlainStr(detail.getUnitPrice().stripTrailingZeros().toPlainString());
|
||||
data.append(formatLabel(key3(detail.getProductName(), unitPrice, number, 18, 7), signLabelInfo.s)).append(signLabelInfo.br);
|
||||
data.append(formatLabel(key3(detail.getProductName(), unitPrice, number, 18, 7, 32), signLabelInfo.s)).append(signLabelInfo.br);
|
||||
|
||||
if (StrUtil.isNotBlank(detail.getSkuName())) {
|
||||
data.append(formatLabel(StrUtil.format("规格:{}", detail.getSkuName()), signLabelInfo.s))
|
||||
@@ -309,15 +325,15 @@ public interface PrinterImpl {
|
||||
jsonObject.getJSONArray("goods").forEach(item -> {
|
||||
String proName = ((JSONObject) item).getString("proName");
|
||||
String qty = ((JSONObject) item).getString("number");
|
||||
data.append(formatLabel(key3(" - " + proName, "", qty, 18, 9), signLabelInfo.s)).append(signLabelInfo.br);
|
||||
data.append(formatLabel(key3(" - " + proName, "", qty, 18, 9, 32), signLabelInfo.s)).append(signLabelInfo.br);
|
||||
});
|
||||
}
|
||||
}
|
||||
if (StrUtil.isNotBlank(orderPrintDTO.getSeatAmount())) {
|
||||
data.append(formatLabel(key3("餐位费", orderPrintDTO.getSeatAmount(), orderPrintDTO.getSeatNum(), 18, 9), signLabelInfo.s)).append(signLabelInfo.br);
|
||||
data.append(formatLabel(key3("餐位费", orderPrintDTO.getSeatAmount(), orderPrintDTO.getSeatNum(), 18, 9, 32), signLabelInfo.s)).append(signLabelInfo.br);
|
||||
}
|
||||
if (StrUtil.isNotBlank(orderPrintDTO.getPackFee())) {
|
||||
data.append(formatLabel(key3("打包费", toPlainStr(orderPrintDTO.getPackFee()), "", 18, 9), signLabelInfo.s)).append(signLabelInfo.br);
|
||||
data.append(formatLabel(key3("打包费", toPlainStr(orderPrintDTO.getPackFee()), "", 18, 9, 32), signLabelInfo.s)).append(signLabelInfo.br);
|
||||
}
|
||||
data.append(getDividingLine()).append(signLabelInfo.br);
|
||||
data.append(formatLabel(LRAlign("原价:", orderPrintDTO.getOriginalAmount(), 32), signLabelInfo.s)).append(signLabelInfo.br);
|
||||
@@ -331,7 +347,7 @@ public interface PrinterImpl {
|
||||
data.append(formatLabel(StrUtil.format("操作员:{}", orderPrintDTO.getOperator()), signLabelInfo.s)).append(signLabelInfo.br);
|
||||
data.append(formatLabel(StrUtil.format("打印时间:{}", DateUtil.date().toString()), 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.out());
|
||||
data.append(signLabelInfo.cut);
|
||||
return data.toString();
|
||||
}
|
||||
@@ -344,7 +360,7 @@ public interface PrinterImpl {
|
||||
* @return 订单打印元数据
|
||||
*/
|
||||
default String buildRefundOrderPrintData(OrderPrintDTO orderPrintDTO, List<OrderDetail> detailList) {
|
||||
PrintSignLabel signLabelInfo = getSignLabelInfo();
|
||||
PrintLabel signLabelInfo = getSignLabelInfo();
|
||||
StringBuilder data = new StringBuilder();
|
||||
data.append(formatLabel(orderPrintDTO.getShopName(), signLabelInfo.center)).append(signLabelInfo.br);
|
||||
data.append(formatLabel(orderPrintDTO.getPrintTitle(), signLabelInfo.center)).append(signLabelInfo.br);
|
||||
@@ -353,7 +369,7 @@ public interface PrinterImpl {
|
||||
, signLabelInfo.s)).append(signLabelInfo.br);
|
||||
data.append(getDividingLine()).append(signLabelInfo.br);
|
||||
if (CollUtil.isNotEmpty(detailList)) {
|
||||
data.append(formatLabel(key3("退款明细", "数量", "小计", 18, 9), signLabelInfo.s)).append(signLabelInfo.br);
|
||||
data.append(formatLabel(key3("退款明细", "数量", "小计", 18, 9, 32), signLabelInfo.s)).append(signLabelInfo.br);
|
||||
|
||||
for (OrderDetail detail : detailList) {
|
||||
String number = detail.getNum().stripTrailingZeros().toPlainString();
|
||||
@@ -361,7 +377,7 @@ public interface PrinterImpl {
|
||||
if ("退款单".equals(orderPrintDTO.getPrintTitle())) {
|
||||
amount = detail.getReturnAmount().stripTrailingZeros().toPlainString();
|
||||
}
|
||||
data.append(formatLabel(key3(detail.getProductName(), number, amount, 18, 7), signLabelInfo.s)).append(signLabelInfo.br);
|
||||
data.append(formatLabel(key3(detail.getProductName(), number, amount, 18, 7, 32), signLabelInfo.s)).append(signLabelInfo.br);
|
||||
if (StrUtil.isNotBlank(detail.getSkuName())) {
|
||||
data.append(formatLabel(StrUtil.format("规格:{}", detail.getSkuName()), signLabelInfo.s))
|
||||
.append(signLabelInfo.br);
|
||||
@@ -379,7 +395,7 @@ public interface PrinterImpl {
|
||||
jsonObject.getJSONArray("goods").forEach(item -> {
|
||||
String proName = ((JSONObject) item).getString("proName");
|
||||
String qty = ((JSONObject) item).getString("number");
|
||||
data.append(formatLabel(key3(" - " + proName, "", qty, 18, 9), signLabelInfo.s)).append(signLabelInfo.br);
|
||||
data.append(formatLabel(key3(" - " + proName, "", qty, 18, 9, 32), signLabelInfo.s)).append(signLabelInfo.br);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -401,7 +417,7 @@ public interface PrinterImpl {
|
||||
data.append(formatLabel(StrUtil.format("操作员:{}", orderPrintDTO.getOperator()), signLabelInfo.s)).append(signLabelInfo.br);
|
||||
data.append(formatLabel(StrUtil.format("打印时间:{}", DateUtil.date().toString()), 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.out());
|
||||
data.append(signLabelInfo.cut);
|
||||
return data.toString();
|
||||
}
|
||||
@@ -413,7 +429,7 @@ public interface PrinterImpl {
|
||||
* @return 元数据
|
||||
*/
|
||||
default String buildAllKitchenPrintData(OrderPrintDTO orderPrintDTO, List<OrderDetail> detailList) {
|
||||
PrintSignLabel signLabelInfo = getSignLabelInfo();
|
||||
PrintLabel signLabelInfo = getSignLabelInfo();
|
||||
StringBuilder data = new StringBuilder();
|
||||
data.append(formatLabel(orderPrintDTO.getShopName(), signLabelInfo.center)).append(signLabelInfo.br);
|
||||
data.append(formatLabel(orderPrintDTO.getPrintTitle(), signLabelInfo.center)).append(signLabelInfo.br);
|
||||
@@ -438,7 +454,7 @@ public interface PrinterImpl {
|
||||
jsonObject.getJSONArray("goods").forEach(item -> {
|
||||
String proName = ((JSONObject) item).getString("proName");
|
||||
String qty = ((JSONObject) item).getString("number");
|
||||
data.append(formatLabel(key3(" - " + proName, "", qty, 18, 9), signLabelInfo.s)).append(signLabelInfo.br);
|
||||
data.append(formatLabel(key3(" - " + proName, "", qty, 18, 9, 32), signLabelInfo.s)).append(signLabelInfo.br);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -457,7 +473,7 @@ public interface PrinterImpl {
|
||||
data.append(formatLabel(StrUtil.format("操作员:{}", orderPrintDTO.getOperator()), signLabelInfo.s)).append(signLabelInfo.br);
|
||||
data.append(formatLabel(StrUtil.format("打印时间:{}", DateUtil.date().toString()), 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.out());
|
||||
data.append(signLabelInfo.cut);
|
||||
return data.toString();
|
||||
}
|
||||
@@ -469,12 +485,17 @@ public interface PrinterImpl {
|
||||
* @return 元数据
|
||||
*/
|
||||
default String buildOnlyKitchenPrintData(Integer isCode, String pickupNumber, OrderDetail orderDetail) {
|
||||
PrintSignLabel signLabelInfo = getSignLabelInfo();
|
||||
PrintLabel signLabelInfo = getSignLabelInfo();
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append(formatLabel(pickupNumber, signLabelInfo.centerBold))
|
||||
.append(signLabelInfo.br);
|
||||
builder.append(signLabelInfo.br);
|
||||
builder.append(signLabelInfo.br);
|
||||
builder.append(signLabelInfo.br);
|
||||
builder.append(formatLabel(StrUtil.format("时间:{}", DateUtil.format(orderDetail.getCreateTime(), "yyyy-MM-dd HH:mm:ss")), signLabelInfo.s, signLabelInfo.center))
|
||||
.append(signLabelInfo.br);
|
||||
builder.append(signLabelInfo.out(70));
|
||||
|
||||
Integer isWaitCall = ObjectUtil.defaultIfNull(orderDetail.getIsWaitCall(), 0);
|
||||
if (isWaitCall == 1) {
|
||||
if (!orderDetail.getProductName().contains("【等叫】")) {
|
||||
@@ -532,7 +553,7 @@ public interface PrinterImpl {
|
||||
.append(signLabelInfo.br);
|
||||
}
|
||||
builder.append(signLabelInfo.br)
|
||||
.append(signLabelInfo.getOut(150))
|
||||
.append(signLabelInfo.out())
|
||||
.append(signLabelInfo.cut);
|
||||
return builder.toString();
|
||||
}
|
||||
@@ -541,7 +562,7 @@ public interface PrinterImpl {
|
||||
* 出入库打印单
|
||||
*/
|
||||
default String buildStockData(StockPrintDTO record) {
|
||||
PrintSignLabel signLabelInfo = getSignLabelInfo();
|
||||
PrintLabel signLabelInfo = getSignLabelInfo();
|
||||
StringBuilder builder = new StringBuilder();
|
||||
|
||||
// 标题:入库 + 店铺名称 + 入库单
|
||||
@@ -558,10 +579,11 @@ public interface PrinterImpl {
|
||||
List<StockPrintDTO.InStockItem> items = record.getItems();
|
||||
if (CollUtil.isNotEmpty(items)) {
|
||||
for (StockPrintDTO.InStockItem item : items) {
|
||||
String stockNumber = item.getStockNumber().stripTrailingZeros().toPlainString();
|
||||
String amount = item.getAmount().stripTrailingZeros().toPlainString();
|
||||
String stockNumber = bdToStr(item.getStockNumber());
|
||||
String amount = bdToStr(item.getAmount());
|
||||
|
||||
// 左对齐排版,保证列对齐
|
||||
String itemLine = key4(item.getConsName(), item.getUnit(), stockNumber, amount, 11, 9, 7);
|
||||
String itemLine = key4(item.getConsName(), StrUtil.isBlank(item.getUnit()) ? "" : item.getUnit(), stockNumber, amount, 11, 9, 7);
|
||||
builder.append(formatLabel(itemLine, signLabelInfo.s)).append(signLabelInfo.br);
|
||||
}
|
||||
}
|
||||
@@ -580,7 +602,7 @@ public interface PrinterImpl {
|
||||
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.out()).append(signLabelInfo.cut);
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
@@ -588,7 +610,7 @@ public interface PrinterImpl {
|
||||
* 经营日报打印单
|
||||
*/
|
||||
default String buildDayReportData(DayReportPrintDTO record) {
|
||||
PrintSignLabel signLabelInfo = getSignLabelInfo();
|
||||
PrintLabel signLabelInfo = getSignLabelInfo();
|
||||
StringBuilder builder = new StringBuilder();
|
||||
|
||||
// 标题:店铺名称 + 经营日报(居中,和充值/入库单风格统一)
|
||||
@@ -646,7 +668,7 @@ public interface PrinterImpl {
|
||||
builder.append(formatLabel(LRAlign(" 订单改价", bdToStr(disSta.getOrderDiscount()), 32), signLabelInfo.s)).append(signLabelInfo.br);
|
||||
|
||||
// 结尾空行 + 切纸(和充值/入库单完全一致)
|
||||
builder.append(signLabelInfo.getOut(150)).append(signLabelInfo.cut);
|
||||
builder.append(signLabelInfo.out()).append(signLabelInfo.cut);
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
@@ -654,7 +676,7 @@ public interface PrinterImpl {
|
||||
* 日结单
|
||||
*/
|
||||
default String buildDaySettleData(DaySettlePrintDTO record) {
|
||||
PrintSignLabel signLabelInfo = getSignLabelInfo();
|
||||
PrintLabel signLabelInfo = getSignLabelInfo();
|
||||
StringBuilder builder = new StringBuilder();
|
||||
|
||||
builder.append(formatLabel(record.getShopName(), signLabelInfo.center)).append(signLabelInfo.br);
|
||||
@@ -704,11 +726,11 @@ public interface PrinterImpl {
|
||||
builder.append(formatLabel("敏感操作记录", signLabelInfo.bold)).append(signLabelInfo.br);
|
||||
for (DaySettlePrintDTO.OperationRecord operation : operationRecords) {
|
||||
builder.append(formatLabel(
|
||||
key3(operation.getOperation(), "数量:" + operation.getCount(), "金额" + bdToStr(operation.getAmount()), 8, 14)
|
||||
key3(operation.getOperation(), "数量:" + operation.getCount(), "金额" + bdToStr(operation.getAmount()), 8, 14, 32)
|
||||
, signLabelInfo.s)).append(signLabelInfo.br);
|
||||
}
|
||||
}
|
||||
builder.append(signLabelInfo.getOut(150)).append(signLabelInfo.cut);
|
||||
builder.append(signLabelInfo.out()).append(signLabelInfo.cut);
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
@@ -716,7 +738,7 @@ public interface PrinterImpl {
|
||||
* 商品报表打印单
|
||||
*/
|
||||
default String buildProductReportData(ProductReportPrintDTO record) {
|
||||
PrintSignLabel signLabelInfo = getSignLabelInfo();
|
||||
PrintLabel signLabelInfo = getSignLabelInfo();
|
||||
StringBuilder builder = new StringBuilder();
|
||||
|
||||
// 标题:店铺名称 + 商品报表(居中,和之前的报表风格统一)
|
||||
@@ -763,7 +785,7 @@ public interface PrinterImpl {
|
||||
}
|
||||
}
|
||||
// 结尾空行 + 切纸(和之前所有打印单完全一致)
|
||||
builder.append(signLabelInfo.getOut(150)).append(signLabelInfo.cut);
|
||||
builder.append(signLabelInfo.out()).append(signLabelInfo.cut);
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
@@ -772,7 +794,7 @@ public interface PrinterImpl {
|
||||
* 充值打印单
|
||||
*/
|
||||
default String buildRechargeData(RechargePrintDTO record) {
|
||||
PrintSignLabel signLabelInfo = getSignLabelInfo();
|
||||
PrintLabel signLabelInfo = getSignLabelInfo();
|
||||
StringBuilder builder = new StringBuilder();
|
||||
// 标题:店铺名称 + 充值凭证
|
||||
builder.append(formatLabel(record.getShopName(), signLabelInfo.center)).append(signLabelInfo.br);
|
||||
@@ -805,7 +827,7 @@ public interface PrinterImpl {
|
||||
builder.append(formatLabel(StrUtil.format("充值编号: {}", record.getRechargeId()), signLabelInfo.s)).append(signLabelInfo.br);
|
||||
|
||||
// 结尾空行 + 切纸
|
||||
builder.append(signLabelInfo.getOut(150)).append(signLabelInfo.cut);
|
||||
builder.append(signLabelInfo.out()).append(signLabelInfo.cut);
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
@@ -813,7 +835,7 @@ public interface PrinterImpl {
|
||||
* 库存盘点打印单
|
||||
*/
|
||||
default String buildStockCheckData(StockCheckPrintDTO record) {
|
||||
PrintSignLabel signLabelInfo = getSignLabelInfo();
|
||||
PrintLabel signLabelInfo = getSignLabelInfo();
|
||||
StringBuilder builder = new StringBuilder();
|
||||
|
||||
// 标题:店铺名称 + 盘点单(居中,和之前所有打印单风格统一)
|
||||
@@ -852,7 +874,7 @@ public interface PrinterImpl {
|
||||
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.out()).append(signLabelInfo.cut);
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
@@ -864,7 +886,7 @@ public interface PrinterImpl {
|
||||
* @return 元数据
|
||||
*/
|
||||
default String buildCallTicketData(String shopName, CallTablePrintDTO printDTO) {
|
||||
PrintSignLabel signLabelInfo = getSignLabelInfo();
|
||||
PrintLabel signLabelInfo = getSignLabelInfo();
|
||||
CallTable callTable = printDTO.getCallTable();
|
||||
CallQueue callQueue = printDTO.getCallQueue();
|
||||
String str = formatLabel(shopName, signLabelInfo.center) +
|
||||
@@ -884,7 +906,7 @@ public interface PrinterImpl {
|
||||
}
|
||||
str = str + formatLabel(StrUtil.format("取号时间: {}", DateUtil.format(callQueue.getCreateTime(), "yyyy-MM-dd HH:mm:ss")), signLabelInfo.s) +
|
||||
signLabelInfo.br +
|
||||
signLabelInfo.getOut(150) + signLabelInfo.cut;
|
||||
signLabelInfo.out() + signLabelInfo.cut;
|
||||
return str;
|
||||
}
|
||||
|
||||
@@ -936,11 +958,11 @@ public interface PrinterImpl {
|
||||
/**
|
||||
* 通用三列对齐方法(严格总长度)
|
||||
* 规则:key1=左对齐,key2=左对齐,key3=右对齐
|
||||
* 整行总长度 = totalWidth,绝不超界
|
||||
* 24的字体 最大宽度32
|
||||
* 32的字体 最大宽度24
|
||||
*/
|
||||
default String key3(String key1, String key2, String key3,
|
||||
int key1Width,
|
||||
int key2Width) {
|
||||
int key1Width, int key2Width, int allWidth) {
|
||||
// 1. 空值安全处理
|
||||
key1 = Objects.toString(key1, "");
|
||||
key2 = Objects.toString(key2, "");
|
||||
@@ -958,7 +980,7 @@ public interface PrinterImpl {
|
||||
|
||||
// 6. 最终按总显示宽度截断(100%不超界)
|
||||
int usedWidth = key1Width + key2Width + w3;
|
||||
int space3 = Math.max(32 - usedWidth, 0);
|
||||
int space3 = Math.max(allWidth - usedWidth, 0);
|
||||
|
||||
// 5. 拼接:左1 + 空格 + 左2 + 空格 + (靠右空格) + 右3
|
||||
return key1 + " ".repeat(space1)
|
||||
@@ -967,6 +989,13 @@ public interface PrinterImpl {
|
||||
+ key3;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通用四列对齐方法(严格总长度)
|
||||
* 规则:key1=左对齐,key2=左对齐,key3=左对齐,key4=右对齐
|
||||
* 24的字体 最大宽度32
|
||||
* 32的字体 最大宽度24
|
||||
* 目前写死了最大宽度32
|
||||
*/
|
||||
default String key4(String key1, String key2, String key3, String key4,
|
||||
int key1Width, int key2Width, int key3Width) {
|
||||
// 1. 空值安全处理
|
||||
|
||||
@@ -40,7 +40,7 @@ public class YxyPrinter extends PrinterHandler implements PrinterImpl {
|
||||
super("云想印");
|
||||
}
|
||||
|
||||
private final PrintSignLabel printSignLabel = new PrintSignLabel()
|
||||
private final PrintLabel printLabel = new PrintLabel()
|
||||
.setBr("<BR>")
|
||||
.setCut("<PCUT>")
|
||||
.setOut("OUT")
|
||||
@@ -217,8 +217,8 @@ public class YxyPrinter extends PrinterHandler implements PrinterImpl {
|
||||
}
|
||||
|
||||
@Override
|
||||
public PrintSignLabel getSignLabelInfo() {
|
||||
return printSignLabel;
|
||||
public PrintLabel getSignLabelInfo() {
|
||||
return printLabel;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1605,6 +1605,10 @@ public class OrderInfoCustomServiceImpl implements OrderInfoCustomService {
|
||||
case 2://结算单
|
||||
printConfig.orderHandler(orderInfo.getId(), PrinterHandler.PrintTypeEnum.ORDER, null);
|
||||
break;
|
||||
case 3://后厨单
|
||||
printConfig.orderHandler(orderInfo.getId(), PrinterHandler.PrintTypeEnum.ALL_KITCHEN, null);
|
||||
printConfig.orderHandler(orderInfo.getId(), PrinterHandler.PrintTypeEnum.ONLY_KITCHEN, null);
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -401,6 +401,19 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
|
||||
redisService.del(CacheConstant.USER_CLIENT_HOTS_PRODUCT + "::" + shopId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 清除某个商品分类的缓存
|
||||
*/
|
||||
private void clearProductAllCache(Long shopId) {
|
||||
//分类缓存
|
||||
redisService.deleteKeysByPrefixSafe(ADMIN_CLIENT_PRODUCT_LIST + "::" + shopId);
|
||||
//用户端分组缓存
|
||||
redisService.del(CacheConstant.USER_CLIENT_GROUPS_PRODUCT + "::" + shopId);
|
||||
//用户端热销缓存
|
||||
redisService.del(CacheConstant.USER_CLIENT_HOTS_PRODUCT + "::" + shopId);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 计算是否在可售时间内
|
||||
*
|
||||
@@ -527,9 +540,7 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
|
||||
}
|
||||
Product old = super.getById(dto.getId());
|
||||
Product entity = BeanUtil.copyProperties(dto, Product.class);
|
||||
if ("weight".equals(entity.getType()) && (entity.getWeight() == null || entity.getWeight().compareTo(BigDecimal.ZERO) <= 0)) {
|
||||
throw new CzgException("称重商品重量必须大于0");
|
||||
}
|
||||
|
||||
entity.setImages(JSON.toJSONString(dto.getImages(), JSONWriter.Feature.WriteMapNullValue));
|
||||
entity.setGroupSnap("[]");
|
||||
//套餐
|
||||
@@ -778,6 +789,32 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
|
||||
consStockByProduct(shopId, InOutTypeEnum.OUT, InOutItemEnum.DAMAGE_OUT, productStockList, null, "【商品报损,自动报损相关耗材】");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void batchOperate(ProductBatchParam param) {
|
||||
Product product = new Product();
|
||||
//商品操作
|
||||
//category 修改分类
|
||||
//isSale 上下架
|
||||
//is_sold_stock 售罄
|
||||
//isAutoSoldStock 自动售罄
|
||||
switch (param.getType()) {
|
||||
case "category":
|
||||
product.setCategoryId(Long.valueOf(param.getValue()));
|
||||
break;
|
||||
case "isSale":
|
||||
product.setIsSale(Integer.valueOf(param.getValue()));
|
||||
break;
|
||||
case "is_sold_stock":
|
||||
product.setIsSoldStock(Integer.valueOf(param.getValue()));
|
||||
break;
|
||||
case "isAutoSoldStock":
|
||||
product.setIsAutoSoldStock(Integer.valueOf(param.getValue()));
|
||||
break;
|
||||
}
|
||||
update(product, query().eq(Product::getShopId, param.getShopId()).in(Product::getId, param.getIds()));
|
||||
clearProductAllCache(param.getShopId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProductStatisticsVo getProductStatistics(ProductInfoParam param) {
|
||||
ProductStatisticsVo data = productStockFlowMapper.getProductStatistics(param);
|
||||
|
||||
Reference in New Issue
Block a user