小票打印bug修复

This commit is contained in:
谭凯凯
2024-11-28 17:45:35 +08:00
committed by Tankaikai
parent b75bb50f63
commit 059d8718dd
2 changed files with 7 additions and 3 deletions

View File

@@ -89,6 +89,7 @@ public abstract class PrinterHandler {
String categoryId = "0"; String categoryId = "0";
if (isTemporary == 1) { if (isTemporary == 1) {
item.setProductId(0); item.setProductId(0);
item.setProductSkuId(0);
} }
// 台位费不打印 // 台位费不打印
if (item.getProductId().equals(-999)) { if (item.getProductId().equals(-999)) {
@@ -104,6 +105,8 @@ public abstract class PrinterHandler {
if (isTemporary == 0 && sku == null) { if (isTemporary == 0 && sku == null) {
log.error("商品不存在, id: {}", item.getProductSkuId()); log.error("商品不存在, id: {}", item.getProductSkuId());
return; return;
} else {
sku = new TbProductSkuWithBLOBs();
} }
if (StrUtil.isEmpty(machine.getClassifyPrint())) { if (StrUtil.isEmpty(machine.getClassifyPrint())) {
log.error("分类打印是空, classifyPrint: {}", machine.getClassifyPrint()); log.error("分类打印是空, classifyPrint: {}", machine.getClassifyPrint());

View File

@@ -27,6 +27,7 @@ import org.apache.http.util.EntityUtils;
import java.io.IOException; import java.io.IOException;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.*; import java.util.*;
@Slf4j @Slf4j
@@ -249,7 +250,7 @@ public class FeieyunPrintUtil {
data.append(StrUtil.format("折扣:-{}<BR>", toPlainStr(detailPO.getDiscountAmount()))); data.append(StrUtil.format("折扣:-{}<BR>", toPlainStr(detailPO.getDiscountAmount())));
} }
data.append("--------------------------------<BR>"); data.append("--------------------------------<BR>");
String t = "" + (ObjectUtil.isEmpty(detailPO.getDiscountAmount()) || ObjectUtil.isNull(detailPO.getDiscountAmount()) ? toPlainStr(detailPO.getReceiptsAmount()) : NumberUtil.sub(new BigDecimal(detailPO.getReceiptsAmount()),new BigDecimal(detailPO.getDiscountAmount())).toPlainString()); String t = "" + (ObjectUtil.isEmpty(detailPO.getDiscountAmount()) || ObjectUtil.isNull(detailPO.getDiscountAmount()) ? toPlainStr(detailPO.getReceiptsAmount()) : NumberUtil.sub(new BigDecimal(detailPO.getReceiptsAmount()), new BigDecimal(detailPO.getDiscountAmount())).setScale(2, RoundingMode.DOWN).toPlainString());
if (orderType.equals("return")) { if (orderType.equals("return")) {
data.append(StrUtil.format("<B>应退:{}</B><BR>", t)); data.append(StrUtil.format("<B>应退:{}</B><BR>", t));
} else { } else {
@@ -271,7 +272,7 @@ public class FeieyunPrintUtil {
} }
private static String toPlainStr(String str) { private static String toPlainStr(String str) {
if(StrUtil.isBlank(str)){ if (StrUtil.isBlank(str)) {
return "0"; return "0";
} }
return NumberUtil.roundDown(new BigDecimal(str), 2).toPlainString(); return NumberUtil.roundDown(new BigDecimal(str), 2).toPlainString();
@@ -496,7 +497,7 @@ public class FeieyunPrintUtil {
//testPrint(); //testPrint();
//testPrint2(); //testPrint2();
String a = "12.0000"; String a = "12.0000";
String s = new BigDecimal(a).toPlainString(); String s = new BigDecimal(a).setScale(2, RoundingMode.DOWN).toPlainString();
System.out.println(s); System.out.println(s);
String s1 = toPlainStr(a); String s1 = toPlainStr(a);
System.out.println(s1); System.out.println(s1);