调整打印机配置参数
This commit is contained in:
@@ -103,7 +103,7 @@ public class PrintMechineConsumer {
|
||||
|
||||
String model = tbPrintMachineWithBLOBs.getPrintMethod();
|
||||
|
||||
String printerNum = StrUtil.isEmpty(tbPrintMachineWithBLOBs.getPrintQty()) ? "1" : tbPrintMachineWithBLOBs.getPrintQty().split("^")[1];
|
||||
String printerNum = StrUtil.isEmpty(tbPrintMachineWithBLOBs.getPrintQty()) ? "1" : tbPrintMachineWithBLOBs.getPrintQty().split("\\^")[1];
|
||||
|
||||
List<CategoryInfo> categoryInfos = JSONUtil.parseJSONStr2TList(StrUtil.emptyToDefault(tbPrintMachineWithBLOBs.getCategoryList(), "[]"), CategoryInfo.class);
|
||||
|
||||
@@ -125,6 +125,101 @@ public class PrintMechineConsumer {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 仅打印制作单「厨房」
|
||||
*/
|
||||
private void onlyKitchenForYxy(String orderId, TbPrintMachineWithBLOBs tbPrintMachineWithBLOBs, TbOrderInfo orderInfo, String printerNum, List<CategoryInfo> categoryInfos) {
|
||||
List<TbCashierCart> cashierCarts = tbCashierCartMapper.selectByOrderId(orderId, "final");
|
||||
log.info("一菜一品打印,待打印信息:{}", cashierCarts);
|
||||
if (ObjectUtil.isNotEmpty(cashierCarts) && cashierCarts.size() > 0) {
|
||||
|
||||
|
||||
cashierCarts.parallelStream().forEach(it -> {
|
||||
|
||||
// 取餐号不为空为代客下单
|
||||
if ("postPay".equals(orderInfo.getUseType()) && StrUtil.isNotBlank(it.getMasterId())) {
|
||||
log.info("--------------------代客下单 打印一菜一品");
|
||||
printTicket(Integer.valueOf(orderId), categoryInfos, tbPrintMachineWithBLOBs, orderInfo);
|
||||
return;
|
||||
}
|
||||
log.info("--------------------非代客下单 打印一菜一品");
|
||||
|
||||
String categoryId;
|
||||
if (ObjectUtil.isEmpty(it.getCategoryId())) {
|
||||
categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId();
|
||||
} else {
|
||||
categoryId = it.getCategoryId();
|
||||
}
|
||||
|
||||
|
||||
Long count = categoryInfos.stream().filter(c ->
|
||||
c.getId().toString().equals(categoryId)
|
||||
).count();
|
||||
|
||||
if (count > 0) {
|
||||
TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getSkuId()));
|
||||
String remark = "";
|
||||
if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) {
|
||||
remark = tbProductSkuWithBLOBs.getSpecSnap();
|
||||
}
|
||||
String data = PrinterUtils.getPrintData(orderInfo.getTableName(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), it.getName(), it.getNumber(), remark);
|
||||
PrinterUtils.printTickets(1, Integer.valueOf(printerNum), tbPrintMachineWithBLOBs.getAddress(), data);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 仅打印结算单「前台」
|
||||
*/
|
||||
private void onlyFrontDeskForYxy(String orderId, TbOrderInfo orderInfo, String printerNum, TbShopInfo shopInfo, TbPrintMachineWithBLOBs tbPrintMachineWithBLOBs, List<CategoryInfo> categoryInfos) {
|
||||
List<TbCashierCart> cashierCarts = tbCashierCartMapper.selectByOrderId(orderInfo.getId().toString(), "final");
|
||||
if (ObjectUtil.isNotEmpty(cashierCarts) && cashierCarts.size() > 0) {
|
||||
List<OrderDetailPO.Detail> detailList = new ArrayList<>();
|
||||
cashierCarts.parallelStream().forEach(it -> {
|
||||
String categoryId;
|
||||
if (ObjectUtil.isEmpty(it.getCategoryId())) {
|
||||
categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId();
|
||||
} else {
|
||||
categoryId = it.getCategoryId();
|
||||
}
|
||||
|
||||
|
||||
Long count = categoryInfos.stream().filter(c ->
|
||||
c.getId().toString().equals(categoryId)
|
||||
).count();
|
||||
|
||||
if (count > 0) {
|
||||
TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getSkuId()));
|
||||
String remark = "";
|
||||
if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) {
|
||||
remark = tbProductSkuWithBLOBs.getSpecSnap();
|
||||
}
|
||||
|
||||
OrderDetailPO.Detail detail = new OrderDetailPO.Detail(it.getName(), it.getNumber().toString(), it.getTotalAmount().toPlainString(), remark);
|
||||
detailList.add(detail);
|
||||
}
|
||||
});
|
||||
|
||||
String balance = "0";
|
||||
|
||||
if ("deposit".equals(orderInfo.getPayType())) {
|
||||
TbShopUser user = tbShopUserMapper.selectByPrimaryKey(orderInfo.getMemberId());
|
||||
if (ObjectUtil.isNotEmpty(user) && ObjectUtil.isNotEmpty(user.getAmount())) {
|
||||
balance = user.getAmount().toPlainString();
|
||||
}
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(detailList) && detailList.size() > 0) {
|
||||
|
||||
OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印", orderInfo.getTableName(), orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), "【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance, orderInfo.getPayType(), "0", detailList, orderInfo.getRemark());
|
||||
detailPO.setOutNumber(orderInfo.getOutNumber());
|
||||
String data = PrinterUtils.getCashPrintData(detailPO, "结算单");
|
||||
PrinterUtils.printTickets(1, Integer.valueOf(printerNum), tbPrintMachineWithBLOBs.getAddress(), data);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 博时结云打印机
|
||||
*
|
||||
@@ -136,105 +231,18 @@ public class PrintMechineConsumer {
|
||||
*/
|
||||
private void yxyPrinter(TbPrintMachineWithBLOBs tbPrintMachineWithBLOBs, String model, TbOrderInfo orderInfo, TbShopInfo shopInfo, String printerNum, List<CategoryInfo> categoryInfos) {
|
||||
String orderId = orderInfo.getId().toString();
|
||||
|
||||
|
||||
switch (tbPrintMachineWithBLOBs.getSubType()) {
|
||||
case "label": //标签打印机
|
||||
break;
|
||||
case "cash": //小票打印机
|
||||
switch (model) {
|
||||
case "normal": //普通出单
|
||||
List<TbCashierCart> cashierCarts = tbCashierCartMapper.selectByOrderId(orderInfo.getId().toString(), "final");
|
||||
if (ObjectUtil.isNotEmpty(cashierCarts) && cashierCarts.size() > 0) {
|
||||
List<OrderDetailPO.Detail> detailList = new ArrayList<>();
|
||||
cashierCarts.parallelStream().forEach(it -> {
|
||||
String categoryId;
|
||||
if (ObjectUtil.isEmpty(it.getCategoryId())) {
|
||||
categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId();
|
||||
} else {
|
||||
categoryId = it.getCategoryId();
|
||||
}
|
||||
|
||||
|
||||
Long count = categoryInfos.stream().filter(c ->
|
||||
c.getId().toString().equals(categoryId)
|
||||
).count();
|
||||
|
||||
if (count > 0) {
|
||||
TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getSkuId()));
|
||||
String remark = "";
|
||||
if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) {
|
||||
remark = tbProductSkuWithBLOBs.getSpecSnap();
|
||||
}
|
||||
|
||||
OrderDetailPO.Detail detail = new OrderDetailPO.Detail(it.getName(), it.getNumber().toString(), it.getTotalAmount().toPlainString(), remark);
|
||||
detailList.add(detail);
|
||||
}
|
||||
});
|
||||
|
||||
String balance = "0";
|
||||
|
||||
if ("deposit".equals(orderInfo.getPayType())) {
|
||||
TbShopUser user = tbShopUserMapper.selectByPrimaryKey(orderInfo.getMemberId());
|
||||
if (ObjectUtil.isNotEmpty(user) && ObjectUtil.isNotEmpty(user.getAmount())) {
|
||||
balance = user.getAmount().toPlainString();
|
||||
}
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(detailList) && detailList.size() > 0) {
|
||||
|
||||
OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印", orderInfo.getTableName(), orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), "【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance, orderInfo.getPayType(), "0", detailList, orderInfo.getRemark());
|
||||
detailPO.setOutNumber(orderInfo.getOutNumber());
|
||||
String data = PrinterUtils.getCashPrintData(detailPO, "结算单");
|
||||
PrinterUtils.printTickets(1, Integer.valueOf(printerNum), tbPrintMachineWithBLOBs.getAddress(), data);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
break;
|
||||
case "one": //一菜一品
|
||||
cashierCarts = tbCashierCartMapper.selectByOrderId(orderId, "final");
|
||||
log.info("一菜一品打印,待打印信息:{}", cashierCarts);
|
||||
if (ObjectUtil.isNotEmpty(cashierCarts) && cashierCarts.size() > 0) {
|
||||
|
||||
|
||||
cashierCarts.parallelStream().forEach(it -> {
|
||||
|
||||
// 取餐号不为空为代客下单
|
||||
if ("postPay".equals(orderInfo.getUseType()) && StrUtil.isNotBlank(it.getMasterId())) {
|
||||
log.info("--------------------代客下单 打印一菜一品");
|
||||
printTicket(Integer.valueOf(orderId), categoryInfos, tbPrintMachineWithBLOBs, orderInfo);
|
||||
return;
|
||||
}
|
||||
log.info("--------------------非代客下单 打印一菜一品");
|
||||
|
||||
String categoryId;
|
||||
if (ObjectUtil.isEmpty(it.getCategoryId())) {
|
||||
categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId();
|
||||
} else {
|
||||
categoryId = it.getCategoryId();
|
||||
}
|
||||
|
||||
|
||||
Long count = categoryInfos.stream().filter(c ->
|
||||
c.getId().toString().equals(categoryId)
|
||||
).count();
|
||||
|
||||
if (count > 0) {
|
||||
TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getSkuId()));
|
||||
String remark = "";
|
||||
if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) {
|
||||
remark = tbProductSkuWithBLOBs.getSpecSnap();
|
||||
}
|
||||
String data = PrinterUtils.getPrintData(orderInfo.getTableName(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), it.getName(), it.getNumber(), remark);
|
||||
PrinterUtils.printTickets(1, Integer.valueOf(printerNum), tbPrintMachineWithBLOBs.getAddress(), data);
|
||||
}
|
||||
});
|
||||
}
|
||||
break;
|
||||
case "category": //分类出单
|
||||
break;
|
||||
if ("normal".equals(model)) {
|
||||
onlyFrontDeskForYxy(orderId, orderInfo, printerNum, shopInfo, tbPrintMachineWithBLOBs, categoryInfos);
|
||||
} else if ("one".equals(model)) {
|
||||
onlyKitchenForYxy(orderId, tbPrintMachineWithBLOBs, orderInfo, printerNum, categoryInfos);
|
||||
} else if ("all".equals(model)) {
|
||||
onlyFrontDeskForYxy(orderId, orderInfo, printerNum, shopInfo, tbPrintMachineWithBLOBs, categoryInfos);
|
||||
onlyKitchenForYxy(orderId, tbPrintMachineWithBLOBs, orderInfo, printerNum, categoryInfos);
|
||||
}
|
||||
|
||||
break;
|
||||
case "kitchen": //出品打印机
|
||||
break;
|
||||
@@ -350,6 +358,141 @@ public class PrintMechineConsumer {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 仅打印结算单「前台」
|
||||
*/
|
||||
private void onlyFrontDeskForFe(String orderId, TbPrintMachineWithBLOBs tbPrintMachineWithBLOBs, String model, TbOrderInfo orderInfo, TbShopInfo shopInfo, String printerNum, List<CategoryInfo> categoryInfos) {
|
||||
if ("return".equals(orderInfo.getOrderType())) {
|
||||
List<TbOrderDetail> tbOrderDetails = tbOrderDetailMapper.selectAllByOrderId(Integer.valueOf(orderId));
|
||||
if (ObjectUtil.isNotEmpty(tbOrderDetails) && tbOrderDetails.size() > 0) {
|
||||
List<OrderDetailPO.Detail> detailList = new ArrayList<>();
|
||||
tbOrderDetails.parallelStream().forEach(it -> {
|
||||
String categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId();
|
||||
|
||||
Long count = categoryInfos.stream().filter(c ->
|
||||
c.getId().toString().equals(categoryId)
|
||||
).count();
|
||||
log.info("获取当前类别是否未打印类别:{}", count);
|
||||
|
||||
|
||||
TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getProductSkuId()));
|
||||
String remark = "";
|
||||
if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) {
|
||||
remark = tbProductSkuWithBLOBs.getSpecSnap();
|
||||
}
|
||||
OrderDetailPO.Detail detail = new OrderDetailPO.Detail(it.getProductName(), it.getNum().toString(), it.getPriceAmount().toPlainString(), remark);
|
||||
detailList.add(detail);
|
||||
|
||||
});
|
||||
String balance = "0";
|
||||
|
||||
if ("deposit".equals(orderInfo.getPayType())) {
|
||||
TbShopUser user = tbShopUserMapper.selectByPrimaryKey(orderInfo.getMemberId());
|
||||
if (ObjectUtil.isNotEmpty(user) && ObjectUtil.isNotEmpty(user.getAmount())) {
|
||||
balance = user.getAmount().toPlainString();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (ObjectUtil.isNotEmpty(detailList) && detailList.size() > 0) {
|
||||
// OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印", orderInfo.getMasterId(), orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), "【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance, orderInfo.getPayType(), "0", detailList);
|
||||
OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印", ObjectUtil.isEmpty(orderInfo.getMasterId()) || ObjectUtil.isNull(orderInfo.getMasterId()) ? orderInfo.getTableName() : orderInfo.getMasterId(), orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), "【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance, orderInfo.getPayType(), "0", detailList, orderInfo.getRemark());
|
||||
|
||||
String printType = "退款单";
|
||||
|
||||
String data = PrinterUtils.getCashPrintData(detailPO, printType);
|
||||
PrinterUtils.printTickets(1, Integer.valueOf(printerNum), tbPrintMachineWithBLOBs.getAddress(), data);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
List<TbCashierCart> cashierCarts = tbCashierCartMapper.selectByOrderId(orderInfo.getId().toString(), "final");
|
||||
|
||||
if (ObjectUtil.isNotEmpty(cashierCarts) && cashierCarts.size() > 0) {
|
||||
List<OrderDetailPO.Detail> detailList = new ArrayList<>();
|
||||
cashierCarts.parallelStream().forEach(it -> {
|
||||
String categoryId;
|
||||
if (ObjectUtil.isEmpty(it.getCategoryId())) {
|
||||
categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId();
|
||||
} else {
|
||||
categoryId = it.getCategoryId();
|
||||
}
|
||||
|
||||
|
||||
Long count = categoryInfos.stream().filter(c ->
|
||||
c.getId().toString().equals(categoryId)
|
||||
).count();
|
||||
|
||||
if (count > 0) {
|
||||
TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getSkuId()));
|
||||
String remark = "";
|
||||
if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) {
|
||||
remark = tbProductSkuWithBLOBs.getSpecSnap();
|
||||
}
|
||||
OrderDetailPO.Detail detail = new OrderDetailPO.Detail(it.getName(), it.getNumber().toString(), it.getTotalAmount().toPlainString(), remark);
|
||||
detailList.add(detail);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
String balance = "0";
|
||||
|
||||
if ("deposit".equals(orderInfo.getPayType())) {
|
||||
TbShopUser user = tbShopUserMapper.selectByPrimaryKey(orderInfo.getMemberId());
|
||||
if (ObjectUtil.isNotEmpty(user) && ObjectUtil.isNotEmpty(user.getAmount())) {
|
||||
balance = user.getAmount().toPlainString();
|
||||
}
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(detailList) && detailList.size() > 0) {
|
||||
OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印", orderInfo.getOrderType().equals("miniapp") ? orderInfo.getTableName() : orderInfo.getMasterId(), orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), "【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance, (ObjectUtil.isEmpty(orderInfo.getPayType()) || ObjectUtil.isNull(orderInfo.getPayType()) ? "" : orderInfo.getPayType()), "0", detailList, orderInfo.getRemark());
|
||||
String printType = "结算单";
|
||||
|
||||
if ("return".equals(orderInfo.getOrderType())) {
|
||||
printType = "退款单";
|
||||
}
|
||||
|
||||
|
||||
FeieyunPrintUtil.getCashPrintData(detailPO, tbPrintMachineWithBLOBs.getAddress(), printType, printType);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 仅打印制作单「厨房」
|
||||
*/
|
||||
private void onlyKitchenForFe(String orderId, TbPrintMachineWithBLOBs tbPrintMachineWithBLOBs, String model, TbOrderInfo orderInfo, TbShopInfo shopInfo, String printerNum, List<CategoryInfo> categoryInfos) {
|
||||
List<TbCashierCart> cashierCarts = tbCashierCartMapper.selectByOrderId(orderId, "final");
|
||||
if (ObjectUtil.isNotEmpty(cashierCarts) && cashierCarts.size() > 0) {
|
||||
|
||||
cashierCarts.parallelStream().forEach(it -> {
|
||||
|
||||
String categoryId;
|
||||
if (ObjectUtil.isEmpty(it.getCategoryId())) {
|
||||
categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId();
|
||||
} else {
|
||||
categoryId = it.getCategoryId();
|
||||
}
|
||||
|
||||
|
||||
Long count = categoryInfos.stream().filter(c ->
|
||||
c.getId().toString().equals(categoryId)
|
||||
).count();
|
||||
|
||||
if (count > 0) {
|
||||
TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getSkuId()));
|
||||
String remark = "";
|
||||
if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) {
|
||||
remark = tbProductSkuWithBLOBs.getSpecSnap();
|
||||
}
|
||||
FeieyunPrintUtil.getPrintData(tbPrintMachineWithBLOBs.getAddress(), orderInfo.getTableName(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), it.getName(), it.getNumber(), remark);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void fePrinter(TbPrintMachineWithBLOBs tbPrintMachineWithBLOBs, String model, TbOrderInfo orderInfo, TbShopInfo shopInfo, String printerNum, List<CategoryInfo> categoryInfos) {
|
||||
String orderId = orderInfo.getId().toString();
|
||||
@@ -389,136 +532,13 @@ public class PrintMechineConsumer {
|
||||
|
||||
break;
|
||||
case "cash": //小票打印机
|
||||
switch (model) {
|
||||
case "normal": //普通出单
|
||||
|
||||
if ("return".equals(orderInfo.getOrderType())) {
|
||||
List<TbOrderDetail> tbOrderDetails = tbOrderDetailMapper.selectAllByOrderId(Integer.valueOf(orderId));
|
||||
if (ObjectUtil.isNotEmpty(tbOrderDetails) && tbOrderDetails.size() > 0) {
|
||||
List<OrderDetailPO.Detail> detailList = new ArrayList<>();
|
||||
tbOrderDetails.parallelStream().forEach(it -> {
|
||||
String categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId();
|
||||
|
||||
Long count = categoryInfos.stream().filter(c ->
|
||||
c.getId().toString().equals(categoryId)
|
||||
).count();
|
||||
log.info("获取当前类别是否未打印类别:{}", count);
|
||||
|
||||
|
||||
TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getProductSkuId()));
|
||||
String remark = "";
|
||||
if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) {
|
||||
remark = tbProductSkuWithBLOBs.getSpecSnap();
|
||||
}
|
||||
OrderDetailPO.Detail detail = new OrderDetailPO.Detail(it.getProductName(), it.getNum().toString(), it.getPriceAmount().toPlainString(), remark);
|
||||
detailList.add(detail);
|
||||
|
||||
});
|
||||
String balance = "0";
|
||||
|
||||
if ("deposit".equals(orderInfo.getPayType())) {
|
||||
TbShopUser user = tbShopUserMapper.selectByPrimaryKey(orderInfo.getMemberId());
|
||||
if (ObjectUtil.isNotEmpty(user) && ObjectUtil.isNotEmpty(user.getAmount())) {
|
||||
balance = user.getAmount().toPlainString();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (ObjectUtil.isNotEmpty(detailList) && detailList.size() > 0) {
|
||||
// OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印", orderInfo.getMasterId(), orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), "【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance, orderInfo.getPayType(), "0", detailList);
|
||||
OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印", ObjectUtil.isEmpty(orderInfo.getMasterId()) || ObjectUtil.isNull(orderInfo.getMasterId()) ? orderInfo.getTableName() : orderInfo.getMasterId(), orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), "【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance, orderInfo.getPayType(), "0", detailList, orderInfo.getRemark());
|
||||
|
||||
String printType = "退款单";
|
||||
|
||||
String data = PrinterUtils.getCashPrintData(detailPO, printType);
|
||||
PrinterUtils.printTickets(1, Integer.valueOf(printerNum), tbPrintMachineWithBLOBs.getAddress(), data);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
cashierCarts = cashierCarts = tbCashierCartMapper.selectByOrderId(orderInfo.getId().toString(), "final");
|
||||
|
||||
if (ObjectUtil.isNotEmpty(cashierCarts) && cashierCarts.size() > 0) {
|
||||
List<OrderDetailPO.Detail> detailList = new ArrayList<>();
|
||||
cashierCarts.parallelStream().forEach(it -> {
|
||||
String categoryId;
|
||||
if (ObjectUtil.isEmpty(it.getCategoryId())) {
|
||||
categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId();
|
||||
} else {
|
||||
categoryId = it.getCategoryId();
|
||||
}
|
||||
|
||||
|
||||
Long count = categoryInfos.stream().filter(c ->
|
||||
c.getId().toString().equals(categoryId)
|
||||
).count();
|
||||
|
||||
if (count > 0) {
|
||||
TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getSkuId()));
|
||||
String remark = "";
|
||||
if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) {
|
||||
remark = tbProductSkuWithBLOBs.getSpecSnap();
|
||||
}
|
||||
OrderDetailPO.Detail detail = new OrderDetailPO.Detail(it.getName(), it.getNumber().toString(), it.getTotalAmount().toPlainString(), remark);
|
||||
detailList.add(detail);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
String balance = "0";
|
||||
|
||||
if ("deposit".equals(orderInfo.getPayType())) {
|
||||
TbShopUser user = tbShopUserMapper.selectByPrimaryKey(orderInfo.getMemberId());
|
||||
if (ObjectUtil.isNotEmpty(user) && ObjectUtil.isNotEmpty(user.getAmount())) {
|
||||
balance = user.getAmount().toPlainString();
|
||||
}
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(detailList) && detailList.size() > 0) {
|
||||
OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印", orderInfo.getOrderType().equals("miniapp") ? orderInfo.getTableName() : orderInfo.getMasterId(), orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), "【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance, (ObjectUtil.isEmpty(orderInfo.getPayType()) || ObjectUtil.isNull(orderInfo.getPayType()) ? "" : orderInfo.getPayType()), "0", detailList, orderInfo.getRemark());
|
||||
String printType = "结算单";
|
||||
|
||||
if ("return".equals(orderInfo.getOrderType())) {
|
||||
printType = "退款单";
|
||||
}
|
||||
|
||||
|
||||
FeieyunPrintUtil.getCashPrintData(detailPO, tbPrintMachineWithBLOBs.getAddress(), printType, printType);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
case "one": //一菜一品
|
||||
|
||||
cashierCarts = tbCashierCartMapper.selectByOrderId(orderId, "final");
|
||||
if (ObjectUtil.isNotEmpty(cashierCarts) && cashierCarts.size() > 0) {
|
||||
|
||||
cashierCarts.parallelStream().forEach(it -> {
|
||||
|
||||
String categoryId;
|
||||
if (ObjectUtil.isEmpty(it.getCategoryId())) {
|
||||
categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId();
|
||||
} else {
|
||||
categoryId = it.getCategoryId();
|
||||
}
|
||||
|
||||
|
||||
Long count = categoryInfos.stream().filter(c ->
|
||||
c.getId().toString().equals(categoryId)
|
||||
).count();
|
||||
|
||||
if (count > 0) {
|
||||
TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getSkuId()));
|
||||
String remark = "";
|
||||
if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) {
|
||||
remark = tbProductSkuWithBLOBs.getSpecSnap();
|
||||
}
|
||||
FeieyunPrintUtil.getPrintData(tbPrintMachineWithBLOBs.getAddress(), orderInfo.getTableName(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), it.getName(), it.getNumber(), remark);
|
||||
}
|
||||
});
|
||||
}
|
||||
if ("normal".equals(model)) {
|
||||
onlyFrontDeskForFe(orderId, tbPrintMachineWithBLOBs, model, orderInfo, shopInfo, printerNum, categoryInfos);
|
||||
} else if ("one".equals(model)) {
|
||||
onlyKitchenForFe(orderId, tbPrintMachineWithBLOBs, model, orderInfo, shopInfo, printerNum, categoryInfos);
|
||||
} else if ("all".equals(model)) {
|
||||
onlyFrontDeskForFe(orderId, tbPrintMachineWithBLOBs, model, orderInfo, shopInfo, printerNum, categoryInfos);
|
||||
onlyKitchenForFe(orderId, tbPrintMachineWithBLOBs, model, orderInfo, shopInfo, printerNum, categoryInfos);
|
||||
}
|
||||
break;
|
||||
case "kitchen": //出品打印机
|
||||
|
||||
@@ -83,7 +83,7 @@ public class CloudPrinterService {
|
||||
|
||||
String model = tbPrintMachineWithBLOBs.getPrintMethod();
|
||||
|
||||
String printerNum = StrUtil.isEmpty(tbPrintMachineWithBLOBs.getPrintQty()) ? "1" : tbPrintMachineWithBLOBs.getPrintQty().split("^")[1];
|
||||
String printerNum = StrUtil.isEmpty(tbPrintMachineWithBLOBs.getPrintQty()) ? "1" : tbPrintMachineWithBLOBs.getPrintQty().split("\\^")[1];
|
||||
|
||||
List<CategoryInfo> categoryInfos = JSONUtil.parseJSONStr2TList(StrUtil.emptyToDefault(tbPrintMachineWithBLOBs.getCategoryList(), "[]"), CategoryInfo.class);
|
||||
|
||||
@@ -106,6 +106,90 @@ public class CloudPrinterService {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 仅打印结算单「前台」
|
||||
*/
|
||||
private void onlyFrontDeskForYxy(String orderId, TbPrintMachineWithBLOBs tbPrintMachineWithBLOBs, String model, TbOrderInfo orderInfo, TbShopInfo shopInfo, String printerNum, List<CategoryInfo> categoryInfos) {
|
||||
List<TbCashierCart> cashierCarts = tbCashierCartMapper.selectByOrderId(orderInfo.getId().toString(), "final");
|
||||
if (ObjectUtil.isNotEmpty(cashierCarts) && cashierCarts.size() > 0) {
|
||||
List<OrderDetailPO.Detail> detailList = new ArrayList<>();
|
||||
cashierCarts.parallelStream().forEach(it -> {
|
||||
String categoryId;
|
||||
if (ObjectUtil.isEmpty(it.getCategoryId())) {
|
||||
categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId();
|
||||
} else {
|
||||
categoryId = it.getCategoryId();
|
||||
}
|
||||
|
||||
|
||||
Long count = categoryInfos.stream().filter(c ->
|
||||
c.getId().toString().equals(categoryId)
|
||||
).count();
|
||||
|
||||
if (count > 0) {
|
||||
TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getSkuId()));
|
||||
String remark = "";
|
||||
if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) {
|
||||
remark = tbProductSkuWithBLOBs.getSpecSnap();
|
||||
}
|
||||
|
||||
OrderDetailPO.Detail detail = new OrderDetailPO.Detail(it.getName(), it.getNumber().toString(), it.getTotalAmount().toPlainString(), remark);
|
||||
detailList.add(detail);
|
||||
}
|
||||
});
|
||||
|
||||
String balance = "0";
|
||||
|
||||
if ("deposit".equals(orderInfo.getPayType())) {
|
||||
TbShopUser user = tbShopUserMapper.selectByPrimaryKey(orderInfo.getMemberId());
|
||||
if (ObjectUtil.isNotEmpty(user) && ObjectUtil.isNotEmpty(user.getAmount())) {
|
||||
balance = user.getAmount().toPlainString();
|
||||
}
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(detailList) && detailList.size() > 0) {
|
||||
|
||||
OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印", orderInfo.getTableName(), orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), "【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance, orderInfo.getPayType(), "0", detailList, orderInfo.getRemark());
|
||||
String data = PrinterUtils.getCashPrintData(detailPO, "结算单");
|
||||
PrinterUtils.printTickets(1, Integer.valueOf(printerNum), tbPrintMachineWithBLOBs.getAddress(), data);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 仅打印制作单「厨房」
|
||||
*/
|
||||
private void onlyKitchenForYxy(String orderId, TbPrintMachineWithBLOBs tbPrintMachineWithBLOBs, String model, TbOrderInfo orderInfo, TbShopInfo shopInfo, String printerNum, List<CategoryInfo> categoryInfos) {
|
||||
List<TbCashierCart> cashierCarts = tbCashierCartMapper.selectByOrderId(orderId, "final");
|
||||
if (ObjectUtil.isNotEmpty(cashierCarts) && cashierCarts.size() > 0) {
|
||||
|
||||
cashierCarts.parallelStream().forEach(it -> {
|
||||
|
||||
String categoryId;
|
||||
if (ObjectUtil.isEmpty(it.getCategoryId())) {
|
||||
categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId();
|
||||
} else {
|
||||
categoryId = it.getCategoryId();
|
||||
}
|
||||
|
||||
|
||||
Long count = categoryInfos.stream().filter(c ->
|
||||
c.getId().toString().equals(categoryId)
|
||||
).count();
|
||||
|
||||
if (count > 0) {
|
||||
TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getSkuId()));
|
||||
String remark = "";
|
||||
if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) {
|
||||
remark = tbProductSkuWithBLOBs.getSpecSnap();
|
||||
}
|
||||
String data = PrinterUtils.getPrintData(orderInfo.getTableName(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), it.getName(), it.getNumber(), remark);
|
||||
PrinterUtils.printTickets(1, Integer.valueOf(printerNum), tbPrintMachineWithBLOBs.getAddress(), data);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 博时结云打印机
|
||||
@@ -118,100 +202,159 @@ public class CloudPrinterService {
|
||||
*/
|
||||
private void yxyPrinter(TbPrintMachineWithBLOBs tbPrintMachineWithBLOBs, String model, TbOrderInfo orderInfo, TbShopInfo shopInfo, String printerNum, List<CategoryInfo> categoryInfos) {
|
||||
String orderId = orderInfo.getId().toString();
|
||||
|
||||
|
||||
switch (tbPrintMachineWithBLOBs.getSubType()) {
|
||||
case "label": //标签打印机
|
||||
break;
|
||||
case "cash": //小票打印机
|
||||
switch (model) {
|
||||
case "normal": //普通出单
|
||||
List<TbCashierCart> cashierCarts = tbCashierCartMapper.selectByOrderId(orderInfo.getId().toString(), "final");
|
||||
if (ObjectUtil.isNotEmpty(cashierCarts) && cashierCarts.size() > 0) {
|
||||
List<OrderDetailPO.Detail> detailList = new ArrayList<>();
|
||||
cashierCarts.parallelStream().forEach(it -> {
|
||||
String categoryId;
|
||||
if (ObjectUtil.isEmpty(it.getCategoryId())) {
|
||||
categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId();
|
||||
} else {
|
||||
categoryId = it.getCategoryId();
|
||||
}
|
||||
|
||||
|
||||
Long count = categoryInfos.stream().filter(c ->
|
||||
c.getId().toString().equals(categoryId)
|
||||
).count();
|
||||
|
||||
if (count > 0) {
|
||||
TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getSkuId()));
|
||||
String remark = "";
|
||||
if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) {
|
||||
remark = tbProductSkuWithBLOBs.getSpecSnap();
|
||||
}
|
||||
|
||||
OrderDetailPO.Detail detail = new OrderDetailPO.Detail(it.getName(), it.getNumber().toString(), it.getTotalAmount().toPlainString(), remark);
|
||||
detailList.add(detail);
|
||||
}
|
||||
});
|
||||
|
||||
String balance = "0";
|
||||
|
||||
if ("deposit".equals(orderInfo.getPayType())) {
|
||||
TbShopUser user = tbShopUserMapper.selectByPrimaryKey(orderInfo.getMemberId());
|
||||
if (ObjectUtil.isNotEmpty(user) && ObjectUtil.isNotEmpty(user.getAmount())) {
|
||||
balance = user.getAmount().toPlainString();
|
||||
}
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(detailList) && detailList.size() > 0) {
|
||||
|
||||
OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印", orderInfo.getTableName(), orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), "【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance, orderInfo.getPayType(), "0", detailList, orderInfo.getRemark());
|
||||
String data = PrinterUtils.getCashPrintData(detailPO, "结算单");
|
||||
PrinterUtils.printTickets(1, Integer.valueOf(printerNum), tbPrintMachineWithBLOBs.getAddress(), data);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
break;
|
||||
case "one": //一菜一品
|
||||
cashierCarts = tbCashierCartMapper.selectByOrderId(orderId, "final");
|
||||
if (ObjectUtil.isNotEmpty(cashierCarts) && cashierCarts.size() > 0) {
|
||||
|
||||
cashierCarts.parallelStream().forEach(it -> {
|
||||
|
||||
String categoryId;
|
||||
if (ObjectUtil.isEmpty(it.getCategoryId())) {
|
||||
categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId();
|
||||
} else {
|
||||
categoryId = it.getCategoryId();
|
||||
}
|
||||
|
||||
|
||||
Long count = categoryInfos.stream().filter(c ->
|
||||
c.getId().toString().equals(categoryId)
|
||||
).count();
|
||||
|
||||
if (count > 0) {
|
||||
TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getSkuId()));
|
||||
String remark = "";
|
||||
if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) {
|
||||
remark = tbProductSkuWithBLOBs.getSpecSnap();
|
||||
}
|
||||
String data = PrinterUtils.getPrintData(orderInfo.getTableName(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), it.getName(), it.getNumber(), remark);
|
||||
PrinterUtils.printTickets(1, Integer.valueOf(printerNum), tbPrintMachineWithBLOBs.getAddress(), data);
|
||||
}
|
||||
});
|
||||
}
|
||||
break;
|
||||
case "category": //分类出单
|
||||
break;
|
||||
if ("normal".equals(model)) {
|
||||
onlyFrontDeskForYxy(orderId, tbPrintMachineWithBLOBs, model, orderInfo, shopInfo, printerNum, categoryInfos);
|
||||
} else if ("one".equals(model)) {
|
||||
onlyKitchenForYxy(orderId, tbPrintMachineWithBLOBs, model, orderInfo, shopInfo, printerNum, categoryInfos);
|
||||
} else if ("all".equals(model)) {
|
||||
onlyFrontDeskForYxy(orderId, tbPrintMachineWithBLOBs, model, orderInfo, shopInfo, printerNum, categoryInfos);
|
||||
onlyKitchenForYxy(orderId, tbPrintMachineWithBLOBs, model, orderInfo, shopInfo, printerNum, categoryInfos);
|
||||
}
|
||||
|
||||
break;
|
||||
case "kitchen": //出品打印机
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 仅打印结算单「前台」
|
||||
*/
|
||||
private void onlyFrontDeskForFe(String orderId, TbPrintMachineWithBLOBs tbPrintMachineWithBLOBs, String model, TbOrderInfo orderInfo, TbShopInfo shopInfo, String printerNum, List<CategoryInfo> categoryInfos) {
|
||||
if ("return".equals(orderInfo.getOrderType())) {
|
||||
List<TbOrderDetail> tbOrderDetails = tbOrderDetailMapper.selectAllByOrderId(Integer.valueOf(orderId));
|
||||
if (ObjectUtil.isNotEmpty(tbOrderDetails) && tbOrderDetails.size() > 0) {
|
||||
List<OrderDetailPO.Detail> detailList = new ArrayList<>();
|
||||
tbOrderDetails.parallelStream().forEach(it -> {
|
||||
String categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId();
|
||||
|
||||
Long count = categoryInfos.stream().filter(c ->
|
||||
c.getId().toString().equals(categoryId)
|
||||
).count();
|
||||
log.info("获取当前类别是否未打印类别:{}", count);
|
||||
|
||||
|
||||
TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getProductSkuId()));
|
||||
String remark = "";
|
||||
if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) {
|
||||
remark = tbProductSkuWithBLOBs.getSpecSnap();
|
||||
}
|
||||
OrderDetailPO.Detail detail = new OrderDetailPO.Detail(it.getProductName(), it.getNum().toString(), it.getPriceAmount().toPlainString(), remark);
|
||||
detailList.add(detail);
|
||||
|
||||
});
|
||||
String balance = "0";
|
||||
|
||||
if ("deposit".equals(orderInfo.getPayType())) {
|
||||
TbShopUser user = tbShopUserMapper.selectByPrimaryKey(orderInfo.getMemberId());
|
||||
if (ObjectUtil.isNotEmpty(user) && ObjectUtil.isNotEmpty(user.getAmount())) {
|
||||
balance = user.getAmount().toPlainString();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (ObjectUtil.isNotEmpty(detailList) && detailList.size() > 0) {
|
||||
// OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印", orderInfo.getMasterId(), orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), "【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance, orderInfo.getPayType(), "0", detailList);
|
||||
OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印", ObjectUtil.isEmpty(orderInfo.getMasterId()) || ObjectUtil.isNull(orderInfo.getMasterId()) ? orderInfo.getTableName() : orderInfo.getMasterId(), orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), "【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance, orderInfo.getPayType(), "0", detailList, orderInfo.getRemark());
|
||||
|
||||
String printType = "退款单";
|
||||
|
||||
String data = PrinterUtils.getCashPrintData(detailPO, printType);
|
||||
PrinterUtils.printTickets(1, Integer.valueOf(printerNum), tbPrintMachineWithBLOBs.getAddress(), data);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
List<TbCashierCart> cashierCarts = tbCashierCartMapper.selectByOrderId(orderInfo.getId().toString(), "final");
|
||||
|
||||
if (ObjectUtil.isNotEmpty(cashierCarts) && cashierCarts.size() > 0) {
|
||||
List<OrderDetailPO.Detail> detailList = new ArrayList<>();
|
||||
cashierCarts.parallelStream().forEach(it -> {
|
||||
String categoryId;
|
||||
if (ObjectUtil.isEmpty(it.getCategoryId())) {
|
||||
categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId();
|
||||
} else {
|
||||
categoryId = it.getCategoryId();
|
||||
}
|
||||
|
||||
|
||||
Long count = categoryInfos.stream().filter(c ->
|
||||
c.getId().toString().equals(categoryId)
|
||||
).count();
|
||||
|
||||
if (count > 0) {
|
||||
TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getSkuId()));
|
||||
String remark = "";
|
||||
if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) {
|
||||
remark = tbProductSkuWithBLOBs.getSpecSnap();
|
||||
}
|
||||
OrderDetailPO.Detail detail = new OrderDetailPO.Detail(it.getName(), it.getNumber().toString(), it.getTotalAmount().toPlainString(), remark);
|
||||
detailList.add(detail);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
String balance = "0";
|
||||
|
||||
if ("deposit".equals(orderInfo.getPayType())) {
|
||||
TbShopUser user = tbShopUserMapper.selectByPrimaryKey(orderInfo.getMemberId());
|
||||
if (ObjectUtil.isNotEmpty(user) && ObjectUtil.isNotEmpty(user.getAmount())) {
|
||||
balance = user.getAmount().toPlainString();
|
||||
}
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(detailList) && detailList.size() > 0) {
|
||||
OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印", orderInfo.getOrderType().equals("miniapp") ? orderInfo.getTableName() : orderInfo.getMasterId(), orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), "【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance, (ObjectUtil.isEmpty(orderInfo.getPayType()) || ObjectUtil.isNull(orderInfo.getPayType()) ? "" : orderInfo.getPayType()), "0", detailList, orderInfo.getRemark());
|
||||
String printType = "结算单";
|
||||
|
||||
if ("return".equals(orderInfo.getOrderType())) {
|
||||
printType = "退款单";
|
||||
}
|
||||
|
||||
|
||||
FeieyunPrintUtil.getCashPrintData(detailPO, tbPrintMachineWithBLOBs.getAddress(), printType, printType);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 仅打印制作单「厨房」
|
||||
*/
|
||||
private void onlyKitchenForFe(String orderId, TbPrintMachineWithBLOBs tbPrintMachineWithBLOBs, String model, TbOrderInfo orderInfo, TbShopInfo shopInfo, String printerNum, List<CategoryInfo> categoryInfos) {
|
||||
List<TbCashierCart> cashierCarts = tbCashierCartMapper.selectByOrderId(orderId, "final");
|
||||
if (ObjectUtil.isNotEmpty(cashierCarts) && cashierCarts.size() > 0) {
|
||||
|
||||
cashierCarts.parallelStream().forEach(it -> {
|
||||
|
||||
String categoryId;
|
||||
if (ObjectUtil.isEmpty(it.getCategoryId())) {
|
||||
categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId();
|
||||
} else {
|
||||
categoryId = it.getCategoryId();
|
||||
}
|
||||
|
||||
|
||||
Long count = categoryInfos.stream().filter(c ->
|
||||
c.getId().toString().equals(categoryId)
|
||||
).count();
|
||||
|
||||
if (count > 0) {
|
||||
TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getSkuId()));
|
||||
String remark = "";
|
||||
if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) {
|
||||
remark = tbProductSkuWithBLOBs.getSpecSnap();
|
||||
}
|
||||
FeieyunPrintUtil.getPrintData(tbPrintMachineWithBLOBs.getAddress(), orderInfo.getTableName(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), it.getName(), it.getNumber(), remark);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void fePrinter(TbPrintMachineWithBLOBs tbPrintMachineWithBLOBs, String model, TbOrderInfo orderInfo, TbShopInfo shopInfo, String printerNum, List<CategoryInfo> categoryInfos) {
|
||||
String orderId = orderInfo.getId().toString();
|
||||
@@ -251,136 +394,13 @@ public class CloudPrinterService {
|
||||
|
||||
break;
|
||||
case "cash": //小票打印机
|
||||
switch (model) {
|
||||
case "normal": //普通出单
|
||||
|
||||
if ("return".equals(orderInfo.getOrderType())) {
|
||||
List<TbOrderDetail> tbOrderDetails = tbOrderDetailMapper.selectAllByOrderId(Integer.valueOf(orderId));
|
||||
if (ObjectUtil.isNotEmpty(tbOrderDetails) && tbOrderDetails.size() > 0) {
|
||||
List<OrderDetailPO.Detail> detailList = new ArrayList<>();
|
||||
tbOrderDetails.parallelStream().forEach(it -> {
|
||||
String categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId();
|
||||
|
||||
Long count = categoryInfos.stream().filter(c ->
|
||||
c.getId().toString().equals(categoryId)
|
||||
).count();
|
||||
log.info("获取当前类别是否未打印类别:{}", count);
|
||||
|
||||
|
||||
TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getProductSkuId()));
|
||||
String remark = "";
|
||||
if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) {
|
||||
remark = tbProductSkuWithBLOBs.getSpecSnap();
|
||||
}
|
||||
OrderDetailPO.Detail detail = new OrderDetailPO.Detail(it.getProductName(), it.getNum().toString(), it.getPriceAmount().toPlainString(), remark);
|
||||
detailList.add(detail);
|
||||
|
||||
});
|
||||
String balance = "0";
|
||||
|
||||
if ("deposit".equals(orderInfo.getPayType())) {
|
||||
TbShopUser user = tbShopUserMapper.selectByPrimaryKey(orderInfo.getMemberId());
|
||||
if (ObjectUtil.isNotEmpty(user) && ObjectUtil.isNotEmpty(user.getAmount())) {
|
||||
balance = user.getAmount().toPlainString();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (ObjectUtil.isNotEmpty(detailList) && detailList.size() > 0) {
|
||||
// OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印", orderInfo.getMasterId(), orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), "【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance, orderInfo.getPayType(), "0", detailList);
|
||||
OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印", ObjectUtil.isEmpty(orderInfo.getMasterId()) || ObjectUtil.isNull(orderInfo.getMasterId()) ? orderInfo.getTableName() : orderInfo.getMasterId(), orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), "【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance, orderInfo.getPayType(), "0", detailList, orderInfo.getRemark());
|
||||
|
||||
String printType = "退款单";
|
||||
|
||||
String data = PrinterUtils.getCashPrintData(detailPO, printType);
|
||||
PrinterUtils.printTickets(1, Integer.valueOf(printerNum), tbPrintMachineWithBLOBs.getAddress(), data);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
cashierCarts = cashierCarts = tbCashierCartMapper.selectByOrderId(orderInfo.getId().toString(), "final");
|
||||
|
||||
if (ObjectUtil.isNotEmpty(cashierCarts) && cashierCarts.size() > 0) {
|
||||
List<OrderDetailPO.Detail> detailList = new ArrayList<>();
|
||||
cashierCarts.parallelStream().forEach(it -> {
|
||||
String categoryId;
|
||||
if (ObjectUtil.isEmpty(it.getCategoryId())) {
|
||||
categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId();
|
||||
} else {
|
||||
categoryId = it.getCategoryId();
|
||||
}
|
||||
|
||||
|
||||
Long count = categoryInfos.stream().filter(c ->
|
||||
c.getId().toString().equals(categoryId)
|
||||
).count();
|
||||
|
||||
if (count > 0) {
|
||||
TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getSkuId()));
|
||||
String remark = "";
|
||||
if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) {
|
||||
remark = tbProductSkuWithBLOBs.getSpecSnap();
|
||||
}
|
||||
OrderDetailPO.Detail detail = new OrderDetailPO.Detail(it.getName(), it.getNumber().toString(), it.getTotalAmount().toPlainString(), remark);
|
||||
detailList.add(detail);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
String balance = "0";
|
||||
|
||||
if ("deposit".equals(orderInfo.getPayType())) {
|
||||
TbShopUser user = tbShopUserMapper.selectByPrimaryKey(orderInfo.getMemberId());
|
||||
if (ObjectUtil.isNotEmpty(user) && ObjectUtil.isNotEmpty(user.getAmount())) {
|
||||
balance = user.getAmount().toPlainString();
|
||||
}
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(detailList) && detailList.size() > 0) {
|
||||
OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印", orderInfo.getOrderType().equals("miniapp") ? orderInfo.getTableName() : orderInfo.getMasterId(), orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), "【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance, (ObjectUtil.isEmpty(orderInfo.getPayType()) || ObjectUtil.isNull(orderInfo.getPayType()) ? "" : orderInfo.getPayType()), "0", detailList, orderInfo.getRemark());
|
||||
String printType = "结算单";
|
||||
|
||||
if ("return".equals(orderInfo.getOrderType())) {
|
||||
printType = "退款单";
|
||||
}
|
||||
|
||||
|
||||
FeieyunPrintUtil.getCashPrintData(detailPO, tbPrintMachineWithBLOBs.getAddress(), printType, printType);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
case "one": //一菜一品
|
||||
|
||||
cashierCarts = tbCashierCartMapper.selectByOrderId(orderId, "final");
|
||||
if (ObjectUtil.isNotEmpty(cashierCarts) && cashierCarts.size() > 0) {
|
||||
|
||||
cashierCarts.parallelStream().forEach(it -> {
|
||||
|
||||
String categoryId;
|
||||
if (ObjectUtil.isEmpty(it.getCategoryId())) {
|
||||
categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId();
|
||||
} else {
|
||||
categoryId = it.getCategoryId();
|
||||
}
|
||||
|
||||
|
||||
Long count = categoryInfos.stream().filter(c ->
|
||||
c.getId().toString().equals(categoryId)
|
||||
).count();
|
||||
|
||||
if (count > 0) {
|
||||
TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getSkuId()));
|
||||
String remark = "";
|
||||
if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) {
|
||||
remark = tbProductSkuWithBLOBs.getSpecSnap();
|
||||
}
|
||||
FeieyunPrintUtil.getPrintData(tbPrintMachineWithBLOBs.getAddress(), orderInfo.getTableName(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), it.getName(), it.getNumber(), remark);
|
||||
}
|
||||
});
|
||||
}
|
||||
if ("normal".equals(model)) {
|
||||
onlyFrontDeskForFe(orderId, tbPrintMachineWithBLOBs, model, orderInfo, shopInfo, printerNum, categoryInfos);
|
||||
} else if ("one".equals(model)) {
|
||||
onlyKitchenForFe(orderId, tbPrintMachineWithBLOBs, model, orderInfo, shopInfo, printerNum, categoryInfos);
|
||||
} else if ("all".equals(model)) {
|
||||
onlyFrontDeskForFe(orderId, tbPrintMachineWithBLOBs, model, orderInfo, shopInfo, printerNum, categoryInfos);
|
||||
onlyKitchenForFe(orderId, tbPrintMachineWithBLOBs, model, orderInfo, shopInfo, printerNum, categoryInfos);
|
||||
}
|
||||
break;
|
||||
case "kitchen": //出品打印机
|
||||
|
||||
Reference in New Issue
Block a user