Merge remote-tracking branch 'origin/test' into test
This commit is contained in:
@@ -24,6 +24,7 @@ public class TbMerchantThirdApply implements Serializable {
|
|||||||
private String appToken;
|
private String appToken;
|
||||||
|
|
||||||
private String smallAppid;
|
private String smallAppid;
|
||||||
|
private String alipaySmallAppid;
|
||||||
|
|
||||||
private String storeId;
|
private String storeId;
|
||||||
|
|
||||||
@@ -124,4 +125,12 @@ public class TbMerchantThirdApply implements Serializable {
|
|||||||
public void setStoreId(String storeId) {
|
public void setStoreId(String storeId) {
|
||||||
this.storeId = storeId;
|
this.storeId = storeId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getAlipaySmallAppid() {
|
||||||
|
return alipaySmallAppid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAlipaySmallAppid(String alipaySmallAppid) {
|
||||||
|
this.alipaySmallAppid = alipaySmallAppid;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -65,11 +65,11 @@ public class TbPrintMachineLog implements Serializable {
|
|||||||
*/
|
*/
|
||||||
private String printQty;
|
private String printQty;
|
||||||
/**
|
/**
|
||||||
* 打印方式 normal-普通出单 one-一菜一品 callTicket-排队取号
|
* 打印方式 all-全部打印 normal-仅打印结账单「前台」one-仅打印制作单「厨房」
|
||||||
*/
|
*/
|
||||||
private String printMethod;
|
private String printMethod;
|
||||||
/**
|
/**
|
||||||
* 打印类型 JSON数组字符串数据 1-确认退款单 2-交班单 3-排队取号,如:[1,2,3]
|
* 打印类型,JSON数组 refund-确认退款单 handover-交班单 queue-排队取号,如:['refund','handover','queue']
|
||||||
*/
|
*/
|
||||||
private String printType;
|
private String printType;
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -59,11 +59,11 @@ public class ShopPrintLogDTO implements Serializable {
|
|||||||
*/
|
*/
|
||||||
private String printQty;
|
private String printQty;
|
||||||
/**
|
/**
|
||||||
* 打印方式 normal-普通出单 one-一菜一品 callTicket-排队取号
|
* 打印方式 all-全部打印 normal-仅打印结账单「前台」one-仅打印制作单「厨房」
|
||||||
*/
|
*/
|
||||||
private String printMethod;
|
private String printMethod;
|
||||||
/**
|
/**
|
||||||
* 打印类型 JSON数组字符串数据 1-确认退款单 2-交班单 3-排队取号,如:[1,2,3]
|
* 打印类型,JSON数组 refund-确认退款单 handover-交班单 queue-排队取号,如:['refund','handover','queue']
|
||||||
*/
|
*/
|
||||||
private String printType;
|
private String printType;
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -21,8 +21,8 @@ import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
|||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Component
|
@Component
|
||||||
@@ -68,7 +68,7 @@ public class PrintConsumer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 菜品票
|
// 菜品票
|
||||||
getPrintMachine(Integer.valueOf(orderInfo.getShopId()), "cash", "one").forEach(machine -> {
|
getPrintMachine(Integer.valueOf(orderInfo.getShopId()), "cash", "one", null).forEach(machine -> {
|
||||||
log.info("打印机信息: {}", machine);
|
log.info("打印机信息: {}", machine);
|
||||||
machine.setCurrentUserId(currentUserId);
|
machine.setCurrentUserId(currentUserId);
|
||||||
machine.setCurrentUserName(currentUserName);
|
machine.setCurrentUserName(currentUserName);
|
||||||
@@ -77,7 +77,7 @@ public class PrintConsumer {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// 标签打印
|
// 标签打印
|
||||||
getPrintMachine(Integer.valueOf(orderInfo.getShopId()), "label", "one").forEach(machine -> {
|
getPrintMachine(Integer.valueOf(orderInfo.getShopId()), "label", "one", null).forEach(machine -> {
|
||||||
log.info("打印机信息: {}", machine);
|
log.info("打印机信息: {}", machine);
|
||||||
machine.setCurrentUserId(currentUserId);
|
machine.setCurrentUserId(currentUserId);
|
||||||
machine.setCurrentUserName(currentUserName);
|
machine.setCurrentUserName(currentUserName);
|
||||||
@@ -104,7 +104,7 @@ public class PrintConsumer {
|
|||||||
TbShopInfo shopInfo = tbShopInfoMapper.selectByPrimaryKey(Integer.valueOf(orderInfo.getShopId()));
|
TbShopInfo shopInfo = tbShopInfoMapper.selectByPrimaryKey(Integer.valueOf(orderInfo.getShopId()));
|
||||||
Utils.checkValueUnReturn(shopInfo, "店铺信息不存在");
|
Utils.checkValueUnReturn(shopInfo, "店铺信息不存在");
|
||||||
|
|
||||||
getPrintMachine(shopInfo.getId(), "cash", "normal").forEach(machine -> {
|
getPrintMachine(shopInfo.getId(), "cash", "normal", null).forEach(machine -> {
|
||||||
List<TbOrderDetail> tbOrderDetails = tbOrderDetailMapper.selectAllByOrderId(orderInfo.getId());
|
List<TbOrderDetail> tbOrderDetails = tbOrderDetailMapper.selectAllByOrderId(orderInfo.getId());
|
||||||
printerHandler.handleRequest(machine, isReturn, orderInfo, tbOrderDetails, null);
|
printerHandler.handleRequest(machine, isReturn, orderInfo, tbOrderDetails, null);
|
||||||
// printPlaceTicket(isReturn, machine, orderInfo, shopInfo);
|
// printPlaceTicket(isReturn, machine, orderInfo, shopInfo);
|
||||||
@@ -121,7 +121,7 @@ public class PrintConsumer {
|
|||||||
log.info("打印消息mq 接收到打印取号小票消息,消息内容: {}", msg);
|
log.info("打印消息mq 接收到打印取号小票消息,消息内容: {}", msg);
|
||||||
CallNumPrintDTO printDTO = JSONObject.parseObject(msg, CallNumPrintDTO.class);
|
CallNumPrintDTO printDTO = JSONObject.parseObject(msg, CallNumPrintDTO.class);
|
||||||
|
|
||||||
getPrintMachine(printDTO.getShopId(), "cash", "callTicket").forEach(machine -> {
|
getPrintMachine(printDTO.getShopId(), "cash", null, "callTicket").forEach(machine -> {
|
||||||
machine.setCurrentUserId(printDTO.getCurrentUserId());
|
machine.setCurrentUserId(printDTO.getCurrentUserId());
|
||||||
machine.setCurrentUserName(printDTO.getCurrentUserName());
|
machine.setCurrentUserName(printDTO.getCurrentUserName());
|
||||||
machine.setCurrentUserNickName(printDTO.getCurrentUserNickName());
|
machine.setCurrentUserNickName(printDTO.getCurrentUserNickName());
|
||||||
@@ -134,19 +134,32 @@ public class PrintConsumer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private List<TbPrintMachine> getPrintMachine(Integer shopId, String subType, String printMethod) {
|
private List<TbPrintMachine> getPrintMachine(Integer shopId, String subType, String printMethod, String printType) {
|
||||||
|
|
||||||
TbShopInfo shopInfo = tbShopInfoMapper.selectByPrimaryKey(shopId);
|
TbShopInfo shopInfo = tbShopInfoMapper.selectByPrimaryKey(shopId);
|
||||||
if (ObjectUtil.isEmpty(shopInfo)) {
|
if (ObjectUtil.isEmpty(shopInfo)) {
|
||||||
log.error("店铺信息不存在");
|
log.error("店铺信息不存在");
|
||||||
return new ArrayList<>();
|
return new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
LambdaQueryWrapper<TbPrintMachine> wrapper = new LambdaQueryWrapper<TbPrintMachine>()
|
||||||
List<TbPrintMachine> list = mpPrintMachineMapper.selectList(new LambdaQueryWrapper<TbPrintMachine>()
|
|
||||||
.eq(TbPrintMachine::getStatus, 1)
|
.eq(TbPrintMachine::getStatus, 1)
|
||||||
.eq(TbPrintMachine::getShopId, shopId)
|
.eq(TbPrintMachine::getShopId, shopId)
|
||||||
.eq(TbPrintMachine::getSubType, subType)
|
.eq(TbPrintMachine::getSubType, subType)
|
||||||
.eq(TbPrintMachine::getPrintMethod, printMethod)
|
.eq(TbPrintMachine::getConnectionType, "network");
|
||||||
.eq(TbPrintMachine::getConnectionType, "network"));
|
if (StrUtil.isNotEmpty(printMethod)) {
|
||||||
|
wrapper.in(TbPrintMachine::getPrintMethod, Arrays.asList(printMethod, "all"));
|
||||||
|
}
|
||||||
|
if ("callTicket".equals(printType)) {
|
||||||
|
printType = "queue";
|
||||||
|
}
|
||||||
|
if (StrUtil.isNotEmpty(printType)) {
|
||||||
|
wrapper.like(TbPrintMachine::getPrintType, printType);
|
||||||
|
}
|
||||||
|
List<TbPrintMachine> list = mpPrintMachineMapper.selectList(wrapper);
|
||||||
|
for (TbPrintMachine item : list) {
|
||||||
|
//实际打印以传递的参数为准
|
||||||
|
item.setPrintMethod(printMethod);
|
||||||
|
}
|
||||||
if (list.isEmpty()) {
|
if (list.isEmpty()) {
|
||||||
log.error("店铺未配置打印机,店铺id: {}", shopId);
|
log.error("店铺未配置打印机,店铺id: {}", shopId);
|
||||||
return list;
|
return list;
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package com.chaozhanggui.system.cashierservice.rabbit;
|
|||||||
|
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||||
import com.chaozhanggui.system.cashierservice.dao.*;
|
import com.chaozhanggui.system.cashierservice.dao.*;
|
||||||
import com.chaozhanggui.system.cashierservice.entity.*;
|
import com.chaozhanggui.system.cashierservice.entity.*;
|
||||||
@@ -104,7 +105,7 @@ public class PrintMechineConsumer {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
String model = StrUtil.isEmpty(it.getPrintMethod()) ? "normal" : it.getPrintMethod();
|
String model = StrUtil.isEmpty(it.getPrintMethod()) ? "normal" : it.getPrintMethod();
|
||||||
String printerNum = StrUtil.isEmpty(it.getPrintQty()) ? "1" : it.getPrintQty().split("^")[1];
|
String printerNum = StrUtil.isEmpty(it.getPrintQty()) ? "1" : it.getPrintQty().split("\\^")[1];
|
||||||
|
|
||||||
List<CategoryInfo> categoryInfos = JSONUtil.parseJSONStr2TList(StrUtil.emptyToDefault(it.getCategoryList(), "[]"), CategoryInfo.class);
|
List<CategoryInfo> categoryInfos = JSONUtil.parseJSONStr2TList(StrUtil.emptyToDefault(it.getCategoryList(), "[]"), CategoryInfo.class);
|
||||||
|
|
||||||
@@ -137,140 +138,144 @@ public class PrintMechineConsumer {
|
|||||||
private void yxyPrinter(TbPrintMachineWithBLOBs tbPrintMachineWithBLOBs, String model,
|
private void yxyPrinter(TbPrintMachineWithBLOBs tbPrintMachineWithBLOBs, String model,
|
||||||
TbOrderInfo orderInfo, TbShopInfo shopInfo, String printerNum, List<CategoryInfo> categoryInfos) {
|
TbOrderInfo orderInfo, TbShopInfo shopInfo, String printerNum, List<CategoryInfo> categoryInfos) {
|
||||||
String orderId = orderInfo.getId().toString();
|
String orderId = orderInfo.getId().toString();
|
||||||
|
|
||||||
|
|
||||||
switch (tbPrintMachineWithBLOBs.getSubType()) {
|
switch (tbPrintMachineWithBLOBs.getSubType()) {
|
||||||
case "label": //标签打印机
|
case "label": //标签打印机
|
||||||
break;
|
break;
|
||||||
case "cash": //小票打印机
|
case "cash": //小票打印机
|
||||||
switch (model) {
|
if ("one".equals(model)) {
|
||||||
case "normal": //普通出单
|
onlyKitchenForYxy(orderId, orderInfo, printerNum, tbPrintMachineWithBLOBs, categoryInfos);
|
||||||
|
} else if ("normal".equals(model)) {
|
||||||
|
onlyFrontDeskForYxy(orderId, orderInfo, printerNum, shopInfo, tbPrintMachineWithBLOBs, categoryInfos);
|
||||||
if ("return".equals(orderInfo.getOrderType())) {
|
} else if ("all".equals(model)) {
|
||||||
List<TbOrderDetail> tbOrderDetails = tbOrderDetailMapper.selectAllByOrderId(Integer.valueOf(orderId));
|
onlyKitchenForYxy(orderId, orderInfo, printerNum, tbPrintMachineWithBLOBs, categoryInfos);
|
||||||
if (ObjectUtil.isNotEmpty(tbOrderDetails) && tbOrderDetails.size() > 0) {
|
onlyFrontDeskForYxy(orderId, orderInfo, printerNum, shopInfo, tbPrintMachineWithBLOBs, categoryInfos);
|
||||||
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(Integer.valueOf(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(), "普通打印", ObjectUtil.isEmpty(orderInfo.getMasterId()) || ObjectUtil.isNull(orderInfo.getMasterId()) ? orderInfo.getTableName() : orderInfo.getMasterId(), orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), "【POS-1】001", orderInfo.getPayAmount().toPlainString(), balance, orderInfo.getPayType(), "0", detailList, orderInfo.getRemark(), null, null);
|
|
||||||
|
|
||||||
String printType = "退款单";
|
|
||||||
|
|
||||||
String data = PrinterUtils.getCashPrintData(detailPO, printType, "return");
|
|
||||||
String voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔新的订单,请及时处理\"}";
|
|
||||||
PrinterUtils.printTickets(voiceJson, 1, Integer.valueOf(printerNum), tbPrintMachineWithBLOBs.getAddress(), data);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((!orderInfo.getStatus().equals("closed"))) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
List<TbOrderDetail> tbOrderDetails = tbOrderDetailMapper.selectAllByOrderId(Integer.valueOf(orderId));
|
|
||||||
if (ObjectUtil.isNotEmpty(tbOrderDetails) && tbOrderDetails.size() > 0) {
|
|
||||||
List<OrderDetailPO.Detail> detailList = new ArrayList<>();
|
|
||||||
tbOrderDetails.stream().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);
|
|
||||||
|
|
||||||
if (count > 0) {
|
|
||||||
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(Integer.valueOf(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(), orderInfo.getDiscountAmount() != null ? orderInfo.getDiscountAmount().toPlainString() : null,
|
|
||||||
orderInfo.getDiscountRatio() != null ? orderInfo.getDiscountRatio().toPlainString() : null);
|
|
||||||
// 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);
|
|
||||||
detailPO.setOutNumber(orderInfo.getOutNumber());
|
|
||||||
String printType = "结算单";
|
|
||||||
|
|
||||||
String data = PrinterUtils.getCashPrintData(detailPO, printType, orderInfo.getOrderType());
|
|
||||||
String voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔新的订单,请及时处理\"}";
|
|
||||||
|
|
||||||
PrinterUtils.printTickets(voiceJson, 3, 1, tbPrintMachineWithBLOBs.getAddress(), data);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
break;
|
|
||||||
case "one": //一菜一品
|
|
||||||
// if (StrUtil.isNotBlank(orderInfo.getUseType()) && orderInfo.getUseType().equals("postPay")
|
|
||||||
// && (!orderInfo.getStatus().equals("unpaid"))) {
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
if ("return".equals(orderInfo.getOrderType())) {
|
|
||||||
printReturnTicket(tbPrintMachineWithBLOBs, orderInfo, printerNum, categoryInfos, orderId);
|
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
printTicket(Integer.valueOf(orderId), categoryInfos, tbPrintMachineWithBLOBs, orderInfo);
|
|
||||||
// printNormalTicket(tbPrintMachineWithBLOBs, orderInfo, printerNum, categoryInfos, orderId);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case "category": //分类出单
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case "kitchen": //出品打印机
|
case "kitchen": //出品打印机
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 仅打印结算单「前台」
|
||||||
|
*/
|
||||||
|
private void onlyFrontDeskForYxy(String orderId, TbOrderInfo orderInfo, String printerNum, TbShopInfo shopInfo, TbPrintMachineWithBLOBs tbPrintMachineWithBLOBs, 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(Integer.valueOf(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(), "普通打印", ObjectUtil.isEmpty(orderInfo.getMasterId()) || ObjectUtil.isNull(orderInfo.getMasterId()) ? orderInfo.getTableName() : orderInfo.getMasterId(), orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), "【POS-1】001", orderInfo.getPayAmount().toPlainString(), balance, orderInfo.getPayType(), "0", detailList, orderInfo.getRemark(), null, null);
|
||||||
|
|
||||||
|
String printType = "退款单";
|
||||||
|
|
||||||
|
String data = PrinterUtils.getCashPrintData(detailPO, printType, "return");
|
||||||
|
String voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔新的订单,请及时处理\"}";
|
||||||
|
PrinterUtils.printTickets(voiceJson, 1, Integer.valueOf(printerNum), tbPrintMachineWithBLOBs.getAddress(), data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((!orderInfo.getStatus().equals("closed"))) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
List<TbOrderDetail> tbOrderDetails = tbOrderDetailMapper.selectAllByOrderId(Integer.valueOf(orderId));
|
||||||
|
if (ObjectUtil.isNotEmpty(tbOrderDetails) && tbOrderDetails.size() > 0) {
|
||||||
|
List<OrderDetailPO.Detail> detailList = new ArrayList<>();
|
||||||
|
tbOrderDetails.stream().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);
|
||||||
|
|
||||||
|
if (count > 0) {
|
||||||
|
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(Integer.valueOf(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(), orderInfo.getDiscountAmount() != null ? orderInfo.getDiscountAmount().toPlainString() : null,
|
||||||
|
orderInfo.getDiscountRatio() != null ? orderInfo.getDiscountRatio().toPlainString() : null);
|
||||||
|
// 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);
|
||||||
|
detailPO.setOutNumber(orderInfo.getOutNumber());
|
||||||
|
String printType = "结算单";
|
||||||
|
|
||||||
|
String data = PrinterUtils.getCashPrintData(detailPO, printType, orderInfo.getOrderType());
|
||||||
|
String voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔新的订单,请及时处理\"}";
|
||||||
|
|
||||||
|
PrinterUtils.printTickets(voiceJson, 3, 1, tbPrintMachineWithBLOBs.getAddress(), data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 仅打印制作单「厨房」
|
||||||
|
*/
|
||||||
|
private void onlyKitchenForYxy(String orderId, TbOrderInfo orderInfo, String printerNum, TbPrintMachineWithBLOBs tbPrintMachineWithBLOBs, List<CategoryInfo> categoryInfos) {
|
||||||
|
//if (StrUtil.isNotBlank(orderInfo.getUseType()) && orderInfo.getUseType().equals("postPay")
|
||||||
|
// && (!orderInfo.getStatus().equals("unpaid"))) {
|
||||||
|
// return;
|
||||||
|
//}
|
||||||
|
if ("return".equals(orderInfo.getOrderType())) {
|
||||||
|
printReturnTicket(tbPrintMachineWithBLOBs, orderInfo, printerNum, categoryInfos, orderId);
|
||||||
|
} else {
|
||||||
|
printTicket(Integer.valueOf(orderId), categoryInfos, tbPrintMachineWithBLOBs, orderInfo);
|
||||||
|
// printNormalTicket(tbPrintMachineWithBLOBs, orderInfo, printerNum, categoryInfos, orderId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void printTicket(Integer orderId, List<CategoryInfo> categoryInfos, TbPrintMachineWithBLOBs tbPrintMachineWithBLOBs, TbOrderInfo orderInfo) {
|
private void printTicket(Integer orderId, List<CategoryInfo> categoryInfos, TbPrintMachineWithBLOBs tbPrintMachineWithBLOBs, TbOrderInfo orderInfo) {
|
||||||
String printKey = RedisCst.ORDER_PRINT_PRO + orderId;
|
String printKey = RedisCst.ORDER_PRINT_PRO + orderId;
|
||||||
AtomicReference<Set<Object>> printProductSet = new AtomicReference<>(redisTemplate.opsForSet().members(printKey));
|
AtomicReference<Set<Object>> printProductSet = new AtomicReference<>(redisTemplate.opsForSet().members(printKey));
|
||||||
@@ -522,6 +527,157 @@ public class PrintMechineConsumer {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 仅打印结算单「前台」
|
||||||
|
*/
|
||||||
|
private void onlyFrontDeskForFe(TbPrintMachineWithBLOBs tbPrintMachineWithBLOBs, TbOrderInfo orderInfo, TbShopInfo shopInfo, String printerNum, List<CategoryInfo> categoryInfos, String orderId) {
|
||||||
|
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(Integer.valueOf(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(), orderInfo.getDiscountAmount() == null ? null : orderInfo.getDiscountAmount().toPlainString(),
|
||||||
|
orderInfo.getDiscountRatio() == null ? null : orderInfo.getDiscountRatio().toPlainString());
|
||||||
|
|
||||||
|
String printType = "退款单";
|
||||||
|
|
||||||
|
String data = PrinterUtils.getCashPrintData(detailPO, printType, "return");
|
||||||
|
String voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔新的订单,请及时处理\"}";
|
||||||
|
PrinterUtils.printTickets(voiceJson, 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(Integer.valueOf(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(), orderInfo.getDiscountAmount() == null ? null : orderInfo.getDiscountAmount().toPlainString(), orderInfo.getDiscountRatio() == null ? null : orderInfo.getDiscountRatio().toPlainString());
|
||||||
|
String printType = "结算单";
|
||||||
|
|
||||||
|
if ("return".equals(orderInfo.getOrderType())) {
|
||||||
|
printType = "退款单";
|
||||||
|
}
|
||||||
|
|
||||||
|
log.error("打印数据2>>>>>>>>>>>>>>>>>>>>>>>>: {}", JSON.toJSONString(detailPO));
|
||||||
|
FeieyunPrintUtil.getCashPrintData(detailPO, tbPrintMachineWithBLOBs.getAddress(), printType, printType);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 仅打印制作单「厨房」
|
||||||
|
*/
|
||||||
|
private void onlyKitchenForFe(String orderId, TbOrderInfo orderInfo, String printerNum, TbPrintMachineWithBLOBs tbPrintMachineWithBLOBs, List<CategoryInfo> categoryInfos) {
|
||||||
|
if (orderInfo.getPayType() != null
|
||||||
|
&& "postPay".equals(orderInfo.getPayType())
|
||||||
|
&& !orderInfo.getStatus().equals("unpaid")) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
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.getMasterId(), 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) {
|
private void fePrinter(TbPrintMachineWithBLOBs tbPrintMachineWithBLOBs, String model, TbOrderInfo orderInfo, TbShopInfo shopInfo, String printerNum, List<CategoryInfo> categoryInfos) {
|
||||||
String orderId = orderInfo.getId().toString();
|
String orderId = orderInfo.getId().toString();
|
||||||
@@ -561,157 +717,14 @@ public class PrintMechineConsumer {
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
case "cash": //小票打印机
|
case "cash": //小票打印机
|
||||||
switch (model) {
|
if ("one".equals(model)) {
|
||||||
case "normal": //普通出单
|
onlyKitchenForFe(orderId, orderInfo, printerNum, tbPrintMachineWithBLOBs, categoryInfos);
|
||||||
|
} else if ("normal".equals(model)) {
|
||||||
if ("return".equals(orderInfo.getOrderType())) {
|
onlyFrontDeskForFe(tbPrintMachineWithBLOBs, orderInfo, shopInfo, printerNum, categoryInfos, orderId);
|
||||||
List<TbOrderDetail> tbOrderDetails = tbOrderDetailMapper.selectAllByOrderId(Integer.valueOf(orderId));
|
} else if ("all".equals(model)) {
|
||||||
if (ObjectUtil.isNotEmpty(tbOrderDetails) && tbOrderDetails.size() > 0) {
|
onlyKitchenForFe(orderId, orderInfo, printerNum, tbPrintMachineWithBLOBs, categoryInfos);
|
||||||
List<OrderDetailPO.Detail> detailList = new ArrayList<>();
|
onlyFrontDeskForFe(tbPrintMachineWithBLOBs, orderInfo, shopInfo, printerNum, categoryInfos, orderId);
|
||||||
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(Integer.valueOf(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(), orderInfo.getDiscountAmount() == null ? null : orderInfo.getDiscountAmount().toPlainString(),
|
|
||||||
orderInfo.getDiscountRatio() == null ? null : orderInfo.getDiscountRatio().toPlainString());
|
|
||||||
|
|
||||||
String printType = "退款单";
|
|
||||||
|
|
||||||
String data = PrinterUtils.getCashPrintData(detailPO, printType, "return");
|
|
||||||
String voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔新的订单,请及时处理\"}";
|
|
||||||
PrinterUtils.printTickets(voiceJson, 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(Integer.valueOf(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(), null, null);
|
|
||||||
String printType = "结算单";
|
|
||||||
|
|
||||||
if ("return".equals(orderInfo.getOrderType())) {
|
|
||||||
printType = "退款单";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
FeieyunPrintUtil.getCashPrintData(detailPO, tbPrintMachineWithBLOBs.getAddress(), printType, printType);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
case "one": //一菜一品
|
|
||||||
|
|
||||||
if (orderInfo.getPayType() != null
|
|
||||||
&& "postPay".equals(orderInfo.getPayType())
|
|
||||||
&& !orderInfo.getStatus().equals("unpaid")) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
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.getMasterId(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), it.getName(), it.getNumber(), remark);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case "category": //分类出单
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case "kitchen": //出品打印机
|
case "kitchen": //出品打印机
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.chaozhanggui.system.cashierservice.rabbit.print;
|
package com.chaozhanggui.system.cashierservice.rabbit.print;
|
||||||
|
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.chaozhanggui.system.cashierservice.dao.TbProductMapper;
|
import com.chaozhanggui.system.cashierservice.dao.TbProductMapper;
|
||||||
import com.chaozhanggui.system.cashierservice.dao.TbProductSkuMapper;
|
import com.chaozhanggui.system.cashierservice.dao.TbProductSkuMapper;
|
||||||
import com.chaozhanggui.system.cashierservice.dao.TbShopUserMapper;
|
import com.chaozhanggui.system.cashierservice.dao.TbShopUserMapper;
|
||||||
@@ -67,8 +68,9 @@ public class FeiPrinter extends PrinterHandler {
|
|||||||
orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())),
|
orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())),
|
||||||
"【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance,
|
"【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance,
|
||||||
(ObjectUtil.isEmpty(orderInfo.getPayType()) || ObjectUtil.isNull(orderInfo.getPayType()) ? "" : orderInfo.getPayType()),
|
(ObjectUtil.isEmpty(orderInfo.getPayType()) || ObjectUtil.isNull(orderInfo.getPayType()) ? "" : orderInfo.getPayType()),
|
||||||
"0", detailList, orderInfo.getRemark(), null, null);
|
"0", detailList, orderInfo.getRemark(), orderInfo.getDiscountAmount() == null ? null : orderInfo.getDiscountAmount().toPlainString(), orderInfo.getDiscountRatio() == null ? null : orderInfo.getDiscountRatio().toPlainString());
|
||||||
String printType = "退款单";
|
String printType = "退款单";
|
||||||
|
log.error("打印数据3>>>>>>>>>>>>>>>>>>>>>>>>: {}", JSON.toJSONString(detailPO));
|
||||||
String[] resp = FeieyunPrintUtil.getCashPrintData(detailPO, machine.getAddress(), printType, printType);
|
String[] resp = FeieyunPrintUtil.getCashPrintData(detailPO, machine.getAddress(), printType, printType);
|
||||||
shopPrintLogService.save(machine, "退款单", resp[0], resp[1]);
|
shopPrintLogService.save(machine, "退款单", resp[0], resp[1]);
|
||||||
}
|
}
|
||||||
@@ -81,8 +83,9 @@ public class FeiPrinter extends PrinterHandler {
|
|||||||
orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())),
|
orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())),
|
||||||
"【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance,
|
"【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance,
|
||||||
(ObjectUtil.isEmpty(orderInfo.getPayType()) || ObjectUtil.isNull(orderInfo.getPayType()) ? "" : orderInfo.getPayType()),
|
(ObjectUtil.isEmpty(orderInfo.getPayType()) || ObjectUtil.isNull(orderInfo.getPayType()) ? "" : orderInfo.getPayType()),
|
||||||
"0", detailList, orderInfo.getRemark(), null, null);
|
"0", detailList, orderInfo.getRemark(), orderInfo.getDiscountAmount() == null ? null : orderInfo.getDiscountAmount().toPlainString(), orderInfo.getDiscountRatio() == null ? null : orderInfo.getDiscountRatio().toPlainString());
|
||||||
String printType = "结算单";
|
String printType = "结算单";
|
||||||
|
log.error("打印数据1>>>>>>>>>>>>>>>>>>>>>>>>: {}", JSON.toJSONString(detailPO));
|
||||||
String[] resp = FeieyunPrintUtil.getCashPrintData(detailPO, machine.getAddress(), printType, printType);
|
String[] resp = FeieyunPrintUtil.getCashPrintData(detailPO, machine.getAddress(), printType, printType);
|
||||||
shopPrintLogService.save(machine, "结算单", resp[0], resp[1]);
|
shopPrintLogService.save(machine, "结算单", resp[0], resp[1]);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
package com.chaozhanggui.system.cashierservice.rabbit.print;
|
package com.chaozhanggui.system.cashierservice.rabbit.print;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import cn.hutool.json.JSONArray;
|
||||||
import com.chaozhanggui.system.cashierservice.dao.TbProductMapper;
|
import com.chaozhanggui.system.cashierservice.dao.TbProductMapper;
|
||||||
import com.chaozhanggui.system.cashierservice.dao.TbProductSkuMapper;
|
import com.chaozhanggui.system.cashierservice.dao.TbProductSkuMapper;
|
||||||
import com.chaozhanggui.system.cashierservice.dao.TbShopUserMapper;
|
import com.chaozhanggui.system.cashierservice.dao.TbShopUserMapper;
|
||||||
@@ -43,83 +45,110 @@ public abstract class PrinterHandler {
|
|||||||
throw new MsgException("打印机配置为空");
|
throw new MsgException("打印机配置为空");
|
||||||
}
|
}
|
||||||
List<CategoryInfo> categoryInfos = JSONUtil.parseJSONStr2TList(StrUtil.emptyToDefault(machine.getCategoryList(), "[]"), CategoryInfo.class);
|
List<CategoryInfo> categoryInfos = JSONUtil.parseJSONStr2TList(StrUtil.emptyToDefault(machine.getCategoryList(), "[]"), CategoryInfo.class);
|
||||||
|
//仅打印后厨-一菜一品
|
||||||
|
if ("one".equals(printMethod)) {
|
||||||
|
onlyKitchen(machine, orderInfo, tbOrderDetailList, categoryInfos, isReturn);
|
||||||
|
} else if ("normal".equals(printMethod)) {
|
||||||
|
//仅打印前台
|
||||||
|
onlyFrontDesk(machine, orderInfo, tbOrderDetailList, isReturn);
|
||||||
|
} else if ("all".equals(printMethod)) {
|
||||||
|
//全部打印 前台+后厨
|
||||||
|
onlyFrontDesk(machine, orderInfo, tbOrderDetailList, isReturn);
|
||||||
|
onlyKitchen(machine, orderInfo, tbOrderDetailList, categoryInfos, isReturn);
|
||||||
|
} else {
|
||||||
|
log.warn("未知打印类型: {}", printMethod);
|
||||||
|
}
|
||||||
|
if (StrUtil.isBlank(machine.getPrintType())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!cn.hutool.json.JSONUtil.isJsonArray(machine.getPrintType())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
JSONArray options = cn.hutool.json.JSONUtil.parseArray(machine.getPrintType());
|
||||||
|
List<String> optionList = cn.hutool.json.JSONUtil.toList(options, String.class);
|
||||||
|
//是否包含排队取号
|
||||||
|
if (!CollUtil.contains(optionList, "queue")) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
callNumPrint(machine, printDTO);
|
||||||
|
if (StrUtil.isBlank(printMethod)) {
|
||||||
|
throw new MsgException("打印机配置为空");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
switch (printMethod) {
|
/**
|
||||||
case "one":
|
* 仅打印制作单「厨房」
|
||||||
tbOrderDetailList.forEach(item -> {
|
*/
|
||||||
log.info("开始打印退单菜品,商品名:{}", item.getProductName());
|
private void onlyKitchen(TbPrintMachine machine, TbOrderInfo orderInfo, List<TbOrderDetail> tbOrderDetailList, List<CategoryInfo> categoryInfos, boolean isReturn) {
|
||||||
// 台位费不打印
|
tbOrderDetailList.forEach(item -> {
|
||||||
if (item.getProductId().equals(-999)) {
|
log.info("开始打印退单菜品,商品名:{}", item.getProductName());
|
||||||
log.info("台位费商品,不打印");
|
// 台位费不打印
|
||||||
return;
|
if (item.getProductId().equals(-999)) {
|
||||||
}
|
log.info("台位费商品,不打印");
|
||||||
String categoryId = tbProductMapper.selectByPrimaryKey(item.getProductId()).getCategoryId();
|
return;
|
||||||
TbProductSkuWithBLOBs sku = tbProductSkuMapper.selectByPrimaryKey(item.getProductSkuId());
|
}
|
||||||
if (sku == null) {
|
String categoryId = tbProductMapper.selectByPrimaryKey(item.getProductId()).getCategoryId();
|
||||||
log.error("商品不存在, id: {}", item.getProductSkuId());
|
TbProductSkuWithBLOBs sku = tbProductSkuMapper.selectByPrimaryKey(item.getProductSkuId());
|
||||||
return;
|
if (sku == null) {
|
||||||
}
|
log.error("商品不存在, id: {}", item.getProductSkuId());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
long count = categoryInfos.stream().filter(c ->
|
long count = categoryInfos.stream().filter(c ->
|
||||||
c.getId().toString().equals(categoryId)
|
c.getId().toString().equals(categoryId)
|
||||||
).count();
|
).count();
|
||||||
|
|
||||||
if (machine.getClassifyPrint() != null && "1".equals(machine.getClassifyPrint()) && count == 0) {
|
if (machine.getClassifyPrint() != null && "1".equals(machine.getClassifyPrint()) && count == 0) {
|
||||||
log.warn("分类未添加菜品: {} : {}", item.getProductName(), sku.getSpecSnap());
|
log.warn("分类未添加菜品: {} : {}", item.getProductName(), sku.getSpecSnap());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
String remark = StrUtil.isNotBlank(sku.getSpecSnap()) ? sku.getSpecSnap() : "";
|
String remark = StrUtil.isNotBlank(sku.getSpecSnap()) ? sku.getSpecSnap() : "";
|
||||||
item.setRemark(remark);
|
item.setRemark(remark);
|
||||||
String data;
|
if (isReturn) {
|
||||||
String voiceJson;
|
returnDishesPrint(orderInfo, item, machine);
|
||||||
if (isReturn) {
|
} else {
|
||||||
returnDishesPrint(orderInfo, item, machine);
|
normalDishesPrint(orderInfo, item, machine);
|
||||||
} else {
|
}
|
||||||
normalDishesPrint(orderInfo, item, machine);
|
});
|
||||||
}
|
}
|
||||||
});
|
|
||||||
break;
|
|
||||||
case "normal":
|
|
||||||
if (tbOrderDetailList.isEmpty()) {
|
|
||||||
log.info("待打印列表为空");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
List<OrderDetailPO.Detail> detailList = new ArrayList<>();
|
|
||||||
tbOrderDetailList.forEach(it -> {
|
|
||||||
TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(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";
|
* 仅打印结算单「前台」
|
||||||
|
*/
|
||||||
|
private void onlyFrontDesk(TbPrintMachine machine, TbOrderInfo orderInfo, List<TbOrderDetail> tbOrderDetailList, boolean isReturn) {
|
||||||
|
if (tbOrderDetailList.isEmpty()) {
|
||||||
|
log.info("待打印列表为空");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
List<OrderDetailPO.Detail> detailList = new ArrayList<>();
|
||||||
|
tbOrderDetailList.forEach(it -> {
|
||||||
|
TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(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);
|
||||||
|
|
||||||
if ("deposit".equals(orderInfo.getPayType())) {
|
});
|
||||||
TbShopUser user = tbShopUserMapper.selectByPrimaryKey(Integer.valueOf(orderInfo.getMemberId()));
|
String balance = "0";
|
||||||
if (ObjectUtil.isNotEmpty(user) && ObjectUtil.isNotEmpty(user.getAmount())) {
|
|
||||||
balance = user.getAmount().toPlainString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!detailList.isEmpty()) {
|
if ("deposit".equals(orderInfo.getPayType())) {
|
||||||
if (isReturn) {
|
TbShopUser user = tbShopUserMapper.selectByPrimaryKey(Integer.valueOf(orderInfo.getMemberId()));
|
||||||
returnOrderPrint(orderInfo, machine, balance, detailList);
|
if (ObjectUtil.isNotEmpty(user) && ObjectUtil.isNotEmpty(user.getAmount())) {
|
||||||
|
balance = user.getAmount().toPlainString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
if (!detailList.isEmpty()) {
|
||||||
normalOrderPrint(orderInfo, machine, balance, detailList);
|
if (isReturn) {
|
||||||
|
returnOrderPrint(orderInfo, machine, balance, detailList);
|
||||||
|
|
||||||
}
|
} else {
|
||||||
}
|
normalOrderPrint(orderInfo, machine, balance, detailList);
|
||||||
break;
|
|
||||||
case "callTicket":
|
}
|
||||||
callNumPrint(machine, printDTO);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
log.warn("未知打印类型: {}", printMethod);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package com.chaozhanggui.system.cashierservice.service;
|
|||||||
|
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.chaozhanggui.system.cashierservice.dao.*;
|
import com.chaozhanggui.system.cashierservice.dao.*;
|
||||||
import com.chaozhanggui.system.cashierservice.entity.*;
|
import com.chaozhanggui.system.cashierservice.entity.*;
|
||||||
@@ -103,7 +104,7 @@ public class CloudPrinterService {
|
|||||||
|
|
||||||
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);
|
List<CategoryInfo> categoryInfos = JSONUtil.parseJSONStr2TList(StrUtil.emptyToDefault(tbPrintMachineWithBLOBs.getCategoryList(), "[]"), CategoryInfo.class);
|
||||||
|
|
||||||
switch (tbPrintMachineWithBLOBs.getContentType()) {
|
switch (tbPrintMachineWithBLOBs.getContentType()) {
|
||||||
case "yxyPrinter":
|
case "yxyPrinter":
|
||||||
@@ -136,232 +137,401 @@ public class CloudPrinterService {
|
|||||||
*/
|
*/
|
||||||
private Result yxyPrinter(TbPrintMachineWithBLOBs tbPrintMachineWithBLOBs, String model, TbOrderInfo orderInfo, TbShopInfo shopInfo, String printerNum, List<CategoryInfo> categoryInfos, String type, Boolean ispre) {
|
private Result yxyPrinter(TbPrintMachineWithBLOBs tbPrintMachineWithBLOBs, String model, TbOrderInfo orderInfo, TbShopInfo shopInfo, String printerNum, List<CategoryInfo> categoryInfos, String type, Boolean ispre) {
|
||||||
String orderId = orderInfo.getId().toString();
|
String orderId = orderInfo.getId().toString();
|
||||||
|
|
||||||
|
|
||||||
switch (tbPrintMachineWithBLOBs.getSubType()) {
|
switch (tbPrintMachineWithBLOBs.getSubType()) {
|
||||||
case "label": //标签打印机
|
case "label": //标签打印机
|
||||||
break;
|
break;
|
||||||
case "cash": //小票打印机
|
case "cash": //小票打印机
|
||||||
switch (model) {
|
if ("normal".equals(model)) {
|
||||||
case "normal": //普通出单
|
onlyFrontDeskForYxy(tbPrintMachineWithBLOBs, model, orderInfo, shopInfo, printerNum, categoryInfos, type, ispre, orderId);
|
||||||
if (!"normal".equals(type)) {
|
} else if ("one".equals(model)) {
|
||||||
return Result.fail("非小票打印");
|
onlyKitchenForYxy(tbPrintMachineWithBLOBs, model, orderInfo, shopInfo, printerNum, categoryInfos, type, ispre, orderId);
|
||||||
}
|
} else if ("all".equals(model)) {
|
||||||
|
onlyFrontDeskForYxy(tbPrintMachineWithBLOBs, model, orderInfo, shopInfo, printerNum, categoryInfos, type, ispre, orderId);
|
||||||
if ("return".equals(orderInfo.getOrderType())) {
|
onlyKitchenForYxy(tbPrintMachineWithBLOBs, model, orderInfo, shopInfo, printerNum, categoryInfos, type, ispre, orderId);
|
||||||
List<TbOrderDetail> tbOrderDetails = tbOrderDetailMapper.selectAllByOrderId(Integer.valueOf(orderId));
|
} else {
|
||||||
if (ObjectUtil.isNotEmpty(tbOrderDetails) && tbOrderDetails.size() > 0) {
|
log.error("未知的打印方式");
|
||||||
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(Integer.valueOf(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(), null, null);
|
|
||||||
detailPO.setOutNumber(orderInfo.getOutNumber());
|
|
||||||
String printType = "退款单";
|
|
||||||
|
|
||||||
String data = PrinterUtils.getCashPrintData(detailPO, printType, "return");
|
|
||||||
|
|
||||||
|
|
||||||
String voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔新的订单,请及时处理\"}";
|
|
||||||
PrinterUtils.printTickets(voiceJson, 1, Integer.valueOf(printerNum), tbPrintMachineWithBLOBs.getAddress(), data);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return Result.success(CodeEnum.SUCCESS);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
List<TbCashierCart> cashierCarts = new ArrayList<>();
|
|
||||||
if (ispre) {
|
|
||||||
cashierCarts = tbCashierCartMapper.selectByOrderId(orderInfo.getId().toString(), "create");
|
|
||||||
} else {
|
|
||||||
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())) {
|
|
||||||
if (ObjectUtil.isNotEmpty(orderInfo.getMemberId()) && ObjectUtil.isNotNull(orderInfo.getMemberId())) {
|
|
||||||
TbShopUser user = tbShopUserMapper.selectByPrimaryKey(Integer.valueOf(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(), orderInfo.getDiscountAmount() != null ? orderInfo.getDiscountAmount().toPlainString() : null, orderInfo.getDiscountRatio() != null ? orderInfo.getDiscountRatio().toPlainString() : null);
|
|
||||||
String printType = "结算单";
|
|
||||||
|
|
||||||
detailPO.setOutNumber(orderInfo.getOutNumber());
|
|
||||||
if (ispre) {
|
|
||||||
printType = "预结算单";
|
|
||||||
}
|
|
||||||
|
|
||||||
if ("return".equals(orderInfo.getOrderType())) {
|
|
||||||
printType = "退款单";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
String data = PrinterUtils.getCashPrintData(detailPO, printType, orderInfo.getOrderType());
|
|
||||||
String voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔新的订单,请及时处理\"}";
|
|
||||||
PrinterUtils.printTickets(voiceJson, 3, Integer.valueOf(printerNum), tbPrintMachineWithBLOBs.getAddress(), data);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
case "one": //一菜一品
|
|
||||||
if (!"one".equals(type)) {
|
|
||||||
return Result.fail("非出品打印");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ispre) {
|
|
||||||
return Result.fail("预结算单不打印菜单");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if ("return".equals(orderInfo.getOrderType())) {
|
|
||||||
List<TbOrderDetail> details = tbOrderDetailMapper.selectAllByOrderId(Integer.valueOf(orderId));
|
|
||||||
if (ObjectUtil.isNotEmpty(details) && details.size() > 0) {
|
|
||||||
details.parallelStream().forEach(it -> {
|
|
||||||
|
|
||||||
|
|
||||||
String categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId();
|
|
||||||
Long count = categoryInfos.stream().filter(c ->
|
|
||||||
c.getId().toString().equals(categoryId)
|
|
||||||
).count();
|
|
||||||
|
|
||||||
if (count > 0) {
|
|
||||||
TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getProductSkuId()));
|
|
||||||
String remark = "";
|
|
||||||
if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) {
|
|
||||||
remark = tbProductSkuWithBLOBs.getSpecSnap();
|
|
||||||
}
|
|
||||||
String data = PrinterUtils.getPrintData("return", orderInfo.getPayType().equals("wx_lite") ?
|
|
||||||
orderInfo.getTableName() : orderInfo.getMasterId(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), it.getProductName(), it.getNum(), remark, null);
|
|
||||||
String voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔退款订单,请及时处理\"}";
|
|
||||||
PrinterUtils.printTickets(voiceJson, 3, Integer.valueOf(printerNum), tbPrintMachineWithBLOBs.getAddress(), data);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return Result.success(CodeEnum.SUCCESS);
|
|
||||||
} else {
|
|
||||||
|
|
||||||
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.getOrderType().equals("miniapp") ?
|
|
||||||
orderInfo.getTableName() : orderInfo.getMasterId(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), it.getName(), it.getNumber(), remark, null);
|
|
||||||
String voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔新的订单,请及时处理\"}";
|
|
||||||
|
|
||||||
PrinterUtils.printTickets(voiceJson, 3, Integer.valueOf(printerNum), tbPrintMachineWithBLOBs.getAddress(), data);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
case "category": //分类出单
|
|
||||||
if (!"category".equals(type)) {
|
|
||||||
return Result.fail("非分类打印");
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case "kitchen": //出品打印机
|
case "kitchen": //出品打印机
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return Result.success(CodeEnum.SUCCESS);
|
return Result.success(CodeEnum.SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 仅打印制作单「厨房」
|
||||||
|
*/
|
||||||
|
private Result onlyKitchenForYxy(TbPrintMachineWithBLOBs tbPrintMachineWithBLOBs, String model, TbOrderInfo orderInfo, TbShopInfo shopInfo, String printerNum, List<CategoryInfo> categoryInfos, String type, Boolean ispre, String orderId) {
|
||||||
|
if (!"one".equals(type)) {
|
||||||
|
return Result.fail("非出品打印");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ispre) {
|
||||||
|
return Result.fail("预结算单不打印菜单");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if ("return".equals(orderInfo.getOrderType())) {
|
||||||
|
List<TbOrderDetail> details = tbOrderDetailMapper.selectAllByOrderId(Integer.valueOf(orderId));
|
||||||
|
if (ObjectUtil.isNotEmpty(details) && details.size() > 0) {
|
||||||
|
details.parallelStream().forEach(it -> {
|
||||||
|
|
||||||
|
|
||||||
|
String categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId();
|
||||||
|
Long count = categoryInfos.stream().filter(c ->
|
||||||
|
c.getId().toString().equals(categoryId)
|
||||||
|
).count();
|
||||||
|
|
||||||
|
if (count > 0) {
|
||||||
|
TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getProductSkuId()));
|
||||||
|
String remark = "";
|
||||||
|
if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) {
|
||||||
|
remark = tbProductSkuWithBLOBs.getSpecSnap();
|
||||||
|
}
|
||||||
|
String data = PrinterUtils.getPrintData("return", orderInfo.getPayType().equals("wx_lite") ?
|
||||||
|
orderInfo.getTableName() : orderInfo.getMasterId(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), it.getProductName(), it.getNum(), remark, null);
|
||||||
|
String voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔退款订单,请及时处理\"}";
|
||||||
|
PrinterUtils.printTickets(voiceJson, 3, Integer.valueOf(printerNum), tbPrintMachineWithBLOBs.getAddress(), data);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return Result.success(CodeEnum.SUCCESS);
|
||||||
|
} else {
|
||||||
|
|
||||||
|
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.getOrderType().equals("miniapp") ?
|
||||||
|
orderInfo.getTableName() : orderInfo.getMasterId(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), it.getName(), it.getNumber(), remark, null);
|
||||||
|
String voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔新的订单,请及时处理\"}";
|
||||||
|
|
||||||
|
PrinterUtils.printTickets(voiceJson, 3, Integer.valueOf(printerNum), tbPrintMachineWithBLOBs.getAddress(), data);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Result.success(CodeEnum.SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 仅打印结算单「前台」
|
||||||
|
*/
|
||||||
|
private Result onlyFrontDeskForYxy(TbPrintMachineWithBLOBs tbPrintMachineWithBLOBs, String model, TbOrderInfo orderInfo, TbShopInfo shopInfo, String printerNum, List<CategoryInfo> categoryInfos, String type, Boolean ispre, String orderId) {
|
||||||
|
if (!"normal".equals(type)) {
|
||||||
|
return Result.fail("非小票打印");
|
||||||
|
}
|
||||||
|
|
||||||
|
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(Integer.valueOf(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(), orderInfo.getDiscountAmount()==null?null:orderInfo.getDiscountAmount().toPlainString(), orderInfo.getDiscountRatio()==null?null:orderInfo.getDiscountRatio().toPlainString());
|
||||||
|
detailPO.setOutNumber(orderInfo.getOutNumber());
|
||||||
|
String printType = "退款单";
|
||||||
|
|
||||||
|
String data = PrinterUtils.getCashPrintData(detailPO, printType, "return");
|
||||||
|
|
||||||
|
|
||||||
|
String voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔新的订单,请及时处理\"}";
|
||||||
|
PrinterUtils.printTickets(voiceJson, 1, Integer.valueOf(printerNum), tbPrintMachineWithBLOBs.getAddress(), data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return Result.success(CodeEnum.SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
List<TbCashierCart> cashierCarts = new ArrayList<>();
|
||||||
|
if (ispre) {
|
||||||
|
cashierCarts = tbCashierCartMapper.selectByOrderId(orderInfo.getId().toString(), "create");
|
||||||
|
} else {
|
||||||
|
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())) {
|
||||||
|
if (ObjectUtil.isNotEmpty(orderInfo.getMemberId()) && ObjectUtil.isNotNull(orderInfo.getMemberId())) {
|
||||||
|
TbShopUser user = tbShopUserMapper.selectByPrimaryKey(Integer.valueOf(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(), orderInfo.getDiscountAmount() != null ? orderInfo.getDiscountAmount().toPlainString() : null, orderInfo.getDiscountRatio() != null ? orderInfo.getDiscountRatio().toPlainString() : null);
|
||||||
|
String printType = "结算单";
|
||||||
|
|
||||||
|
detailPO.setOutNumber(orderInfo.getOutNumber());
|
||||||
|
if (ispre) {
|
||||||
|
printType = "预结算单";
|
||||||
|
}
|
||||||
|
|
||||||
|
if ("return".equals(orderInfo.getOrderType())) {
|
||||||
|
printType = "退款单";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
String data = PrinterUtils.getCashPrintData(detailPO, printType, orderInfo.getOrderType());
|
||||||
|
String voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔新的订单,请及时处理\"}";
|
||||||
|
PrinterUtils.printTickets(voiceJson, 3, Integer.valueOf(printerNum), tbPrintMachineWithBLOBs.getAddress(), data);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
return Result.success(CodeEnum.SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 仅打印结算单「前台」
|
||||||
|
*/
|
||||||
|
private Result onlyFrontDeskForFe(TbPrintMachineWithBLOBs tbPrintMachineWithBLOBs, String model, TbOrderInfo orderInfo, TbShopInfo shopInfo, String printerNum, List<CategoryInfo> categoryInfos, String type, Boolean ispre,String orderId) {
|
||||||
|
if (!"normal".equals(type)) {
|
||||||
|
return Result.fail("非小票打印");
|
||||||
|
}
|
||||||
|
|
||||||
|
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(Integer.valueOf(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(), null, null);
|
||||||
|
|
||||||
|
String printType = "退款单";
|
||||||
|
|
||||||
|
String data = PrinterUtils.getCashPrintData(detailPO, printType, "return");
|
||||||
|
// PrinterUtils.printTickets(1, Integer.valueOf(printerNum), tbPrintMachineWithBLOBs.getAddress(), data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return Result.success(CodeEnum.SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
List<TbCashierCart> cashierCarts = new ArrayList<>();
|
||||||
|
if (ispre) {
|
||||||
|
cashierCarts = tbCashierCartMapper.selectByOrderId(orderInfo.getId().toString(), "create");
|
||||||
|
} else {
|
||||||
|
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(Integer.valueOf(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(), orderInfo.getDiscountAmount()==null?null:orderInfo.getDiscountAmount().toPlainString(), orderInfo.getDiscountRatio()==null?null:orderInfo.getDiscountRatio().toPlainString());
|
||||||
|
String printType = "结算单";
|
||||||
|
if (ispre) {
|
||||||
|
printType = "预结算单";
|
||||||
|
}
|
||||||
|
|
||||||
|
if ("return".equals(orderInfo.getOrderType())) {
|
||||||
|
printType = "退款单";
|
||||||
|
}
|
||||||
|
|
||||||
|
log.error("打印数据4>>>>>>>>>>>>>>>>>>>>>>>>: {}", JSON.toJSONString(detailPO));
|
||||||
|
FeieyunPrintUtil.getCashPrintData(detailPO, tbPrintMachineWithBLOBs.getAddress(), printType, printType);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
return Result.success(CodeEnum.SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 仅打印制作单「厨房」
|
||||||
|
*/
|
||||||
|
private Result onlyKitchenForFe(TbPrintMachineWithBLOBs tbPrintMachineWithBLOBs, String model, TbOrderInfo orderInfo, TbShopInfo shopInfo, String printerNum, List<CategoryInfo> categoryInfos, String type, Boolean ispre, String orderId) {
|
||||||
|
if (!"one".equals(type)) {
|
||||||
|
return Result.fail("非出品打印");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ispre) {
|
||||||
|
return Result.fail("预结算单不打印菜单");
|
||||||
|
}
|
||||||
|
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.getMasterId(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), it.getName(), it.getNumber(), remark);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return Result.success(CodeEnum.SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
private Result fePrinter(TbPrintMachineWithBLOBs tbPrintMachineWithBLOBs, String model, TbOrderInfo orderInfo, TbShopInfo shopInfo, String printerNum, List<CategoryInfo> categoryInfos, String type, Boolean ispre) {
|
private Result fePrinter(TbPrintMachineWithBLOBs tbPrintMachineWithBLOBs, String model, TbOrderInfo orderInfo, TbShopInfo shopInfo, String printerNum, List<CategoryInfo> categoryInfos, String type, Boolean ispre) {
|
||||||
String orderId = orderInfo.getId().toString();
|
String orderId = orderInfo.getId().toString();
|
||||||
@@ -398,168 +568,16 @@ public class CloudPrinterService {
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
case "cash": //小票打印机
|
case "cash": //小票打印机
|
||||||
switch (model) {
|
if ("normal".equals(model)) {
|
||||||
case "normal": //普通出单
|
onlyFrontDeskForFe(tbPrintMachineWithBLOBs, model, orderInfo, shopInfo, printerNum, categoryInfos, type, ispre, orderId);
|
||||||
if (!"normal".equals(type)) {
|
} else if ("one".equals(model)) {
|
||||||
return Result.fail("非小票打印");
|
onlyKitchenForFe(tbPrintMachineWithBLOBs, model, orderInfo, shopInfo, printerNum, categoryInfos, type, ispre, orderId);
|
||||||
}
|
} else if ("all".equals(model)) {
|
||||||
|
onlyFrontDeskForFe(tbPrintMachineWithBLOBs, model, orderInfo, shopInfo, printerNum, categoryInfos, type, ispre, orderId);
|
||||||
if ("return".equals(orderInfo.getOrderType())) {
|
onlyKitchenForFe(tbPrintMachineWithBLOBs, model, orderInfo, shopInfo, printerNum, categoryInfos, type, ispre, orderId);
|
||||||
List<TbOrderDetail> tbOrderDetails = tbOrderDetailMapper.selectAllByOrderId(Integer.valueOf(orderId));
|
} else {
|
||||||
if (ObjectUtil.isNotEmpty(tbOrderDetails) && tbOrderDetails.size() > 0) {
|
log.error("未知的打印方式");
|
||||||
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(Integer.valueOf(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(), null, null);
|
|
||||||
|
|
||||||
String printType = "退款单";
|
|
||||||
|
|
||||||
String data = PrinterUtils.getCashPrintData(detailPO, printType, "return");
|
|
||||||
// PrinterUtils.printTickets(1, Integer.valueOf(printerNum), tbPrintMachineWithBLOBs.getAddress(), data);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return Result.success(CodeEnum.SUCCESS);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
cashierCarts = new ArrayList<>();
|
|
||||||
if (ispre) {
|
|
||||||
cashierCarts = tbCashierCartMapper.selectByOrderId(orderInfo.getId().toString(), "create");
|
|
||||||
} else {
|
|
||||||
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(Integer.valueOf(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(), null, null);
|
|
||||||
String printType = "结算单";
|
|
||||||
if (ispre) {
|
|
||||||
printType = "预结算单";
|
|
||||||
}
|
|
||||||
|
|
||||||
if ("return".equals(orderInfo.getOrderType())) {
|
|
||||||
printType = "退款单";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
FeieyunPrintUtil.getCashPrintData(detailPO, tbPrintMachineWithBLOBs.getAddress(), printType, printType);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
case "one": //一菜一品
|
|
||||||
if (!"one".equals(type)) {
|
|
||||||
return Result.fail("非出品打印");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ispre) {
|
|
||||||
return Result.fail("预结算单不打印菜单");
|
|
||||||
}
|
|
||||||
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.getMasterId(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), it.getName(), it.getNumber(), remark);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case "category": //分类出单
|
|
||||||
if (!"category".equals(type)) {
|
|
||||||
return Result.fail("非分类打印");
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case "kitchen": //出品打印机
|
case "kitchen": //出品打印机
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -1936,7 +1936,7 @@ public class PayService {
|
|||||||
*/
|
*/
|
||||||
public Result createOrder(String ip, String userId, String payType, String shopId, String orderId,
|
public Result createOrder(String ip, String userId, String payType, String shopId, String orderId,
|
||||||
BigDecimal amount, String remark) throws JsonProcessingException {
|
BigDecimal amount, String remark) throws JsonProcessingException {
|
||||||
|
log.info("createOrder:{}", JSONObject.toJSONString(new Object[]{ip, userId, payType, shopId, orderId, amount, remark}));
|
||||||
if (ObjectUtil.isNull(userId) || ObjectUtil.isEmpty(userId) || ObjectUtil.isEmpty(payType) ||
|
if (ObjectUtil.isNull(userId) || ObjectUtil.isEmpty(userId) || ObjectUtil.isEmpty(payType) ||
|
||||||
ObjectUtil.isNull(payType) || ObjectUtil.isNull(shopId) || ObjectUtil.isEmpty(shopId) ||
|
ObjectUtil.isNull(payType) || ObjectUtil.isNull(shopId) || ObjectUtil.isEmpty(shopId) ||
|
||||||
ObjectUtil.isNull(shopId) || ObjectUtil.isNull(amount) || ObjectUtil.isEmpty(amount)) {
|
ObjectUtil.isNull(shopId) || ObjectUtil.isNull(amount) || ObjectUtil.isEmpty(amount)) {
|
||||||
@@ -2022,7 +2022,6 @@ public class PayService {
|
|||||||
reqbody, reqbody, amount.multiply(new BigDecimal(100)).longValue(),
|
reqbody, reqbody, amount.multiply(new BigDecimal(100)).longValue(),
|
||||||
payType, thirdApply.getSmallAppid(), userId, ip,
|
payType, thirdApply.getSmallAppid(), userId, ip,
|
||||||
DateUtils.getSsdfTimes(), thirdApply.getStoreId(), backUrl, backUrl);
|
DateUtils.getSsdfTimes(), thirdApply.getStoreId(), backUrl, backUrl);
|
||||||
|
|
||||||
if (ObjectUtil.isNotNull(publicResp) && ObjectUtil.isNotEmpty(publicResp)) {
|
if (ObjectUtil.isNotNull(publicResp) && ObjectUtil.isNotEmpty(publicResp)) {
|
||||||
if ("000000".equals(publicResp.getCode())) {
|
if ("000000".equals(publicResp.getCode())) {
|
||||||
JspayResp scanpayResp = publicResp.getObjData();
|
JspayResp scanpayResp = publicResp.getObjData();
|
||||||
|
|||||||
@@ -70,8 +70,8 @@ public class ShopPrintLogServiceImpl extends ServiceImpl<TbPrintMachineLogMapper
|
|||||||
@Override
|
@Override
|
||||||
public PageInfo<TbPrintMachineLog> page(Map<String, Object> params) {
|
public PageInfo<TbPrintMachineLog> page(Map<String, Object> params) {
|
||||||
MapProxy mapProxy = MapProxy.create(params);
|
MapProxy mapProxy = MapProxy.create(params);
|
||||||
Integer pageNum = mapProxy.getInt("pageNum",1);
|
Integer pageNum = mapProxy.getInt("pageNum", 1);
|
||||||
Integer pageSize = mapProxy.getInt("pageSize",10);
|
Integer pageSize = mapProxy.getInt("pageSize", 10);
|
||||||
PageInfo<TbPrintMachineLog> pageInfo = PageHelper.startPage(pageNum, pageSize).doSelectPageInfo(() -> baseMapper.selectList(getWrapper(params)));
|
PageInfo<TbPrintMachineLog> pageInfo = PageHelper.startPage(pageNum, pageSize).doSelectPageInfo(() -> baseMapper.selectList(getWrapper(params)));
|
||||||
return pageInfo;
|
return pageInfo;
|
||||||
}
|
}
|
||||||
@@ -114,19 +114,19 @@ public class ShopPrintLogServiceImpl extends ServiceImpl<TbPrintMachineLogMapper
|
|||||||
|
|
||||||
respMsg = status + "_" + yxxStatusMap.get(status);
|
respMsg = status + "_" + yxxStatusMap.get(status);
|
||||||
}
|
}
|
||||||
if(code == 0){
|
if (code == 0) {
|
||||||
String taskId = resp.getJSONObject("data").getStr("orderId");
|
String taskId = resp.getJSONObject("data").getStr("orderId");
|
||||||
entity.setTaskId(taskId);
|
entity.setTaskId(taskId);
|
||||||
}
|
}
|
||||||
// 飞鹅云打印机暂时没有适配,先return不做打印记录
|
// 飞鹅云打印机暂时没有适配,先return不做打印记录
|
||||||
}else if ("fePrinter".equals(config.getContentType())) {
|
} else if ("fePrinter".equals(config.getContentType())) {
|
||||||
cn.hutool.json.JSONObject resp = JSONUtil.parseObj(respJson);
|
cn.hutool.json.JSONObject resp = JSONUtil.parseObj(respJson);
|
||||||
int ret = resp.getInt("ret");
|
int ret = resp.getInt("ret");
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
failFlag = 1;
|
failFlag = 1;
|
||||||
respCode = ret + "";
|
respCode = ret + "";
|
||||||
respMsg = resp.getStr("msg");
|
respMsg = resp.getStr("msg");
|
||||||
}else{
|
} else {
|
||||||
String printOrderId = resp.getStr("data");
|
String printOrderId = resp.getStr("data");
|
||||||
entity.setTaskId(printOrderId);
|
entity.setTaskId(printOrderId);
|
||||||
}
|
}
|
||||||
@@ -142,7 +142,7 @@ public class ShopPrintLogServiceImpl extends ServiceImpl<TbPrintMachineLogMapper
|
|||||||
}
|
}
|
||||||
entity.setPrintContent(printContent);
|
entity.setPrintContent(printContent);
|
||||||
entity.setCreateTime(new Date());
|
entity.setCreateTime(new Date());
|
||||||
if(failFlag == 0){
|
if (failFlag == 0) {
|
||||||
entity.setPrintTime(entity.getCreateTime());
|
entity.setPrintTime(entity.getCreateTime());
|
||||||
}
|
}
|
||||||
entity.setFailFlag(failFlag);
|
entity.setFailFlag(failFlag);
|
||||||
@@ -153,53 +153,59 @@ public class ShopPrintLogServiceImpl extends ServiceImpl<TbPrintMachineLogMapper
|
|||||||
// 云想印
|
// 云想印
|
||||||
if ("yxyPrinter".equals(config.getContentType())) {
|
if ("yxyPrinter".equals(config.getContentType())) {
|
||||||
// 延迟3ms,复查打印状态 (用户可以根据设备信息查询到当前设备的在线情况(注:该接口只能提供参考,设备的离线状态是在设备离线3分钟后才会生效))
|
// 延迟3ms,复查打印状态 (用户可以根据设备信息查询到当前设备的在线情况(注:该接口只能提供参考,设备的离线状态是在设备离线3分钟后才会生效))
|
||||||
ThreadUtil.safeSleep(1000*3);
|
ThreadUtil.safeSleep(1000 * 5);
|
||||||
String jsonStr = PrinterUtils.checkPrintStatus(config.getAddress(), entity.getTaskId());
|
String jsonStr = PrinterUtils.checkPrintStatus(config.getAddress(), entity.getTaskId());
|
||||||
cn.hutool.json.JSONObject resp = JSONUtil.parseObj(jsonStr);
|
cn.hutool.json.JSONObject resp = JSONUtil.parseObj(jsonStr);
|
||||||
int code = resp.getInt("code");
|
int code = resp.getInt("code");
|
||||||
if(code == 0){
|
if (code == 0) {
|
||||||
cn.hutool.json.JSONObject data = resp.getJSONObject("data");
|
cn.hutool.json.JSONObject data = resp.getJSONObject("data");
|
||||||
boolean status = data.containsKey("status");
|
boolean status = data.containsKey("status");
|
||||||
if(!status){
|
if (!status) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
boolean success = data.getBool("status",false);
|
boolean success = data.getBool("status", false);
|
||||||
if(entity.getFailFlag()==0 && success){
|
if (entity.getFailFlag() == 0 && success) {
|
||||||
entity.setFailFlag(0);
|
entity.setFailFlag(0);
|
||||||
entity.setRespMsg("打印成功");
|
entity.setRespMsg("打印成功");
|
||||||
entity.setPrintTime(entity.getCreateTime());
|
entity.setPrintTime(entity.getCreateTime());
|
||||||
}else if(entity.getFailFlag()==1 && success) {
|
} else if (entity.getFailFlag() == 1 && success) {
|
||||||
entity.setFailFlag(0);
|
entity.setFailFlag(0);
|
||||||
entity.setPrintTime(new Date());
|
entity.setPrintTime(new Date());
|
||||||
entity.setRespMsg("打印成功");
|
entity.setRespMsg("打印成功");
|
||||||
// 如果设备在线 and 休眠5秒后查询结果是未打印,即视为设备已离线,云端3分钟后才会同步到离线信息
|
// 如果设备在线 and 休眠5秒后查询结果是未打印,即视为设备已离线,云端3分钟后才会同步到离线信息
|
||||||
}else if(entity.getFailFlag()==0 && !success){
|
} else if (entity.getFailFlag() == 0 && !success) {
|
||||||
entity.setFailFlag(1);
|
entity.setFailFlag(1);
|
||||||
entity.setPrintTime(null);
|
entity.setPrintTime(null);
|
||||||
entity.setRespMsg("0_离线(设备上线后自动补打)");
|
entity.setRespMsg("0_离线(设备上线后自动补打)");
|
||||||
}else {
|
} else {
|
||||||
entity.setFailFlag(1);
|
entity.setFailFlag(1);
|
||||||
entity.setPrintTime(null);
|
entity.setPrintTime(null);
|
||||||
entity.setRespMsg(StrUtil.concat(true,"打印失败,", "_", entity.getRespMsg()));
|
entity.setRespMsg(StrUtil.concat(true, "打印失败,", "_", entity.getRespMsg()));
|
||||||
}
|
}
|
||||||
super.updateById(entity);
|
super.updateById(entity);
|
||||||
}
|
}
|
||||||
// 飞鹅云打印机
|
// 飞鹅云打印机
|
||||||
}else if("fePrinter".equals(config.getContentType())){
|
} else if ("fePrinter".equals(config.getContentType())) {
|
||||||
ThreadUtil.safeSleep(1000*3);
|
ThreadUtil.safeSleep(1000 * 5);
|
||||||
Boolean success = FeieyunPrintUtil.checkPrintStatus(entity.getTaskId());
|
Boolean success = FeieyunPrintUtil.checkPrintStatus(entity.getTaskId());
|
||||||
if(success == null){
|
if (success == null) {
|
||||||
entity.setFailFlag(1);
|
entity.setFailFlag(1);
|
||||||
entity.setRespMsg("打印失败,未知错误");
|
entity.setRespMsg("打印失败,未知错误");
|
||||||
}else if(success) {
|
} else if (success) {
|
||||||
entity.setFailFlag(0);
|
entity.setFailFlag(0);
|
||||||
entity.setPrintTime(new Date());
|
entity.setPrintTime(new Date());
|
||||||
entity.setRespMsg("打印成功");
|
entity.setRespMsg("打印成功");
|
||||||
}else {
|
} else {
|
||||||
String msg = FeieyunPrintUtil.checkOnline(entity.getAddress());
|
String msg = FeieyunPrintUtil.checkOnline(entity.getAddress());
|
||||||
entity.setFailFlag(1);
|
if (msg.indexOf("在线,工作状态正常") > 0) {
|
||||||
entity.setPrintTime(null);
|
entity.setFailFlag(0);
|
||||||
entity.setRespMsg(StrUtil.concat(true,"打印失败,", "_", msg));
|
entity.setPrintTime(new Date());
|
||||||
|
entity.setRespMsg("打印成功");
|
||||||
|
} else {
|
||||||
|
entity.setFailFlag(1);
|
||||||
|
entity.setPrintTime(null);
|
||||||
|
entity.setRespMsg(StrUtil.concat(true, "打印失败,", "_", msg));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
super.updateById(entity);
|
super.updateById(entity);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,143 @@
|
|||||||
|
package com.chaozhanggui.system.cashierservice.util;
|
||||||
|
|
||||||
|
import lombok.experimental.UtilityClass;
|
||||||
|
|
||||||
|
import java.io.UnsupportedEncodingException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author tankaikai
|
||||||
|
* @since 2024-10-15 15:12
|
||||||
|
*/
|
||||||
|
@UtilityClass
|
||||||
|
public class FeieYunUtil {
|
||||||
|
|
||||||
|
public String titleAddSpace(String str, int b1) {
|
||||||
|
int k = 0;
|
||||||
|
int b = b1;
|
||||||
|
try {
|
||||||
|
k = str.getBytes("GBK").length;
|
||||||
|
} catch (UnsupportedEncodingException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
for (int i = 0; i < b - k; i++) {
|
||||||
|
str += " ";
|
||||||
|
}
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getStringByEnter(int length, String string) throws Exception {
|
||||||
|
for (int i = 1; i <= string.length(); i++) {
|
||||||
|
if (string.substring(0, i).getBytes("GBK").length > length) {
|
||||||
|
return string.substring(0, i - 1) + "<BR>" + getStringByEnter(length, string.substring(i - 1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return string;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String addSpace(String str, int size) {
|
||||||
|
int len = str.length();
|
||||||
|
if (len < size) {
|
||||||
|
for (int i = 0; i < size - len; i++) {
|
||||||
|
str += " ";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Boolean isEn(String str) {
|
||||||
|
Boolean b = false;
|
||||||
|
try {
|
||||||
|
b = str.getBytes("GBK").length == str.length();
|
||||||
|
} catch (UnsupportedEncodingException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return b;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<String> getStrList(String inputString, int length) {
|
||||||
|
int size = inputString.length() / length;
|
||||||
|
if (inputString.length() % length != 0) {
|
||||||
|
size += 1;
|
||||||
|
}
|
||||||
|
return getStrList(inputString, length, size);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<String> getStrList(String inputString, int length, int size) {
|
||||||
|
List<String> list = new ArrayList<String>();
|
||||||
|
for (int index = 0; index < size; index++) {
|
||||||
|
String childStr = substring(inputString, index * length, (index + 1) * length);
|
||||||
|
list.add(childStr);
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String substring(String str, int f, int t) {
|
||||||
|
if (f > str.length()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (t > str.length()) {
|
||||||
|
return str.substring(f, str.length());
|
||||||
|
} else {
|
||||||
|
return str.substring(f, t);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取对齐后的小票明细行数据
|
||||||
|
* 58mm的机器,一行打印16个汉字,32个字母;80mm的机器,一行打印24个汉字,48个字母
|
||||||
|
* b1代表名称列占用字节 b2单价列 b3数量列 b4金额列-->这里的字节数可按自己需求自由改写
|
||||||
|
*
|
||||||
|
* @param title 品名
|
||||||
|
* @param price 单价
|
||||||
|
* @param num 数量
|
||||||
|
* @param total 小计
|
||||||
|
* @param b1 品名占用字节
|
||||||
|
* @param b2 单价占用字节
|
||||||
|
* @param b3 数量占用字节
|
||||||
|
* @param b4 小计占用字节
|
||||||
|
* @return 对齐后的行数据
|
||||||
|
*/
|
||||||
|
public static String getRow(String title, String price, String num, String total, int b1, int b2, int b3, int b4) {
|
||||||
|
price = addSpace(price, b2);
|
||||||
|
num = addSpace(num, b3);
|
||||||
|
total = addSpace(total, b4);
|
||||||
|
String otherStr = " " + price + num + " " + total;
|
||||||
|
int tl = 0;
|
||||||
|
try {
|
||||||
|
tl = title.getBytes("GBK").length;
|
||||||
|
} catch (UnsupportedEncodingException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
int spaceNum = (tl / b1 + 1) * b1 - tl;
|
||||||
|
if (tl < b1) {
|
||||||
|
for (int k = 0; k < spaceNum; k++) {
|
||||||
|
title += " ";
|
||||||
|
}
|
||||||
|
title += otherStr;
|
||||||
|
} else if (tl == b1) {
|
||||||
|
title += otherStr;
|
||||||
|
} else {
|
||||||
|
List<String> list = null;
|
||||||
|
if (isEn(title)) {
|
||||||
|
list = getStrList(title, b1);
|
||||||
|
} else {
|
||||||
|
list = getStrList(title, b1 / 2);
|
||||||
|
}
|
||||||
|
String s0 = titleAddSpace(list.get(0), b1);
|
||||||
|
title = s0 + otherStr + "<BR>";// 添加 单价 数量 总额
|
||||||
|
String s = "";
|
||||||
|
for (int k = 1; k < list.size(); k++) {
|
||||||
|
s += list.get(k);
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
s = getStringByEnter(b1, s);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
title += s;
|
||||||
|
}
|
||||||
|
return title + "<BR>";
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,11 +2,14 @@ package com.chaozhanggui.system.cashierservice.util;
|
|||||||
|
|
||||||
|
|
||||||
import cn.hutool.core.text.UnicodeUtil;
|
import cn.hutool.core.text.UnicodeUtil;
|
||||||
|
import cn.hutool.core.util.NumberUtil;
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.hutool.http.HttpUtil;
|
import cn.hutool.http.HttpUtil;
|
||||||
import cn.hutool.json.JSONObject;
|
import cn.hutool.json.JSONObject;
|
||||||
import cn.hutool.json.JSONUtil;
|
import cn.hutool.json.JSONUtil;
|
||||||
import com.chaozhanggui.system.cashierservice.model.OrderDetailPO;
|
import com.chaozhanggui.system.cashierservice.model.OrderDetailPO;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.codec.digest.DigestUtils;
|
import org.apache.commons.codec.digest.DigestUtils;
|
||||||
import org.apache.http.HttpEntity;
|
import org.apache.http.HttpEntity;
|
||||||
import org.apache.http.NameValuePair;
|
import org.apache.http.NameValuePair;
|
||||||
@@ -20,8 +23,10 @@ import org.apache.http.message.BasicNameValuePair;
|
|||||||
import org.apache.http.util.EntityUtils;
|
import org.apache.http.util.EntityUtils;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.math.BigDecimal;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
public class FeieyunPrintUtil {
|
public class FeieyunPrintUtil {
|
||||||
|
|
||||||
public static final String URL = "http://api.feieyun.cn/Api/Open/";//不需要修改
|
public static final String URL = "http://api.feieyun.cn/Api/Open/";//不需要修改
|
||||||
@@ -117,17 +122,14 @@ public class FeieyunPrintUtil {
|
|||||||
|
|
||||||
builder.append("<CB>" + pickupNumber + "</CB><BR><BR>");
|
builder.append("<CB>" + pickupNumber + "</CB><BR><BR>");
|
||||||
builder.append("<L>时间: " + date + " </L><BR><BR><BR>");
|
builder.append("<L>时间: " + date + " </L><BR><BR><BR>");
|
||||||
|
remark = StrUtil.emptyToDefault(remark, "");
|
||||||
if (productName.length() > 4 || remark.length() > 4) {
|
if (productName.length() > 4 || remark.length() > 4) {
|
||||||
builder.append("<B><BOLD>" + productName + " " + number + "</BOLD></B><BR><BR>");
|
builder.append("<B><BOLD>" + productName + " x " + number + "</BOLD></B><BR><BR>");
|
||||||
builder.append("<B><BOLD>" + remark + " </BOLD></B><BR>");
|
builder.append("<B><BOLD>" + remark + " </BOLD></B><BR>");
|
||||||
} else {
|
} else {
|
||||||
builder.append("<B><BOLD>" + productName + " " + number + "</BOLD></B><BR><BR>");
|
builder.append("<B><BOLD>" + productName + " x " + number + "</BOLD></B><BR><BR>");
|
||||||
builder.append("<B><BOLD>" + remark + " </BOLD></B><BR>");
|
builder.append("<B><BOLD>" + remark + " </BOLD></B><BR>");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
builder.append("<BR><BR><BR><BR><BR><BR>");
|
|
||||||
builder.append("<CUT>");
|
builder.append("<CUT>");
|
||||||
return builder.toString();
|
return builder.toString();
|
||||||
}
|
}
|
||||||
@@ -197,67 +199,63 @@ public class FeieyunPrintUtil {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String buildPrintContent(OrderDetailPO detailPO, String type, String orderType) {
|
||||||
public static String[] getCashPrintData(OrderDetailPO detailPO, String sn, String type, String orderType) {
|
StringBuffer data = new StringBuffer();
|
||||||
StringBuilder sb = new StringBuilder();
|
data.append(StrUtil.format("<CB>{}</CB><BR>", detailPO.getMerchantName()));
|
||||||
sb.append("<CB>" + detailPO.getMerchantName() + "</CB><BR><BR>");
|
data.append("<BR>");
|
||||||
sb.append("<C><BOLD>" + type + "【" + detailPO.getMasterId() + "】</BOLD></C><BR><BR>");
|
data.append(StrUtil.format("<C><BOLD>{}【{}】</C></BOLD><BR>", type, detailPO.getMasterId()));
|
||||||
sb.append("订单号: " + detailPO.getOrderNo() + " <BR>");
|
data.append("<BR>");
|
||||||
sb.append("交易时间: " + detailPO.getTradeDate() + " <BR>");
|
data.append(StrUtil.format("订单号:{}<BR>", detailPO.getOrderNo()));
|
||||||
sb.append("收银员: " + detailPO.getOperator() + " <BR><BR><BR>");
|
data.append(StrUtil.format("交易时间:{}<BR>", detailPO.getTradeDate()));
|
||||||
sb.append("------------------------<BR>");
|
data.append(StrUtil.format("收银员:{}<BR>", detailPO.getOperator()));
|
||||||
char paddingCharacter = ' ';
|
data.append("<BR>");
|
||||||
sb.append("<S>" + String.format("%-15s", "品名").replace(' ', paddingCharacter) + String.format("%-4s", "数量").replace(' ', paddingCharacter) + String.format("%4s", "小计").replace(' ', paddingCharacter) + "</S><BR>");
|
data.append("品名 数量 小计<BR>");
|
||||||
|
data.append("--------------------------------<BR>");
|
||||||
for (OrderDetailPO.Detail detail : detailPO.getDetailList()) {
|
for (OrderDetailPO.Detail detail : detailPO.getDetailList()) {
|
||||||
if (detail.getProductName().length() > 4) {
|
String productName = detail.getProductName();
|
||||||
|
String number = detail.getNumber();
|
||||||
int count = getProducrName(detail.getProductName());
|
String amount = detail.getAmount();
|
||||||
if (count <= 0) {
|
//58mm的机器,一行打印16个汉字,32个字母; 80mm的机器,一行打印24个汉字,48个字母
|
||||||
int length = 15 - (detail.getProductName().length() - 4);
|
//展示4列 b1代表名称列占用(14个字节) b2单价列(6个字节) b3数量列(3个字节) b4金额列(6个字节)-->这里的字节数可按自己需求自由改写,14+6+3+6再加上代码写的3个空格就是32了,58mm打印机一行总占32字节
|
||||||
sb.append("" + String.format("%-" + length + "s", detail.getProductName()).replace(' ', paddingCharacter) + String.format("%-4s", detail.getNumber()).replace(' ', paddingCharacter) + String.format("%8s", detail.getAmount()).replace(' ', paddingCharacter) + "<BR>");
|
//String row = FeieYunUtil.getRow(productName, "",number, amount, 14, 6,3, 6)
|
||||||
} else {
|
//展示3列 b1代表名称列占用(20个字节) b2单价列(0个字节) b3数量列(3个字节) b4金额列(6个字节)-->这里的字节数可按自己需求自由改写,20+0+3+6再加上代码写的3个空格就是32了,58mm打印机一行总占32字节
|
||||||
int length = 15 + count - (detail.getProductName().length() - 4);
|
String row = FeieYunUtil.getRow(productName, "", number, amount, 20, 0, 3, 6);
|
||||||
sb.append("" + String.format("%-" + length + "s", detail.getProductName()).replace(' ', paddingCharacter) + String.format("%-4s", detail.getNumber()).replace(' ', paddingCharacter) + String.format("%8s", detail.getAmount()).replace(' ', paddingCharacter) + "<BR>");
|
data.append(row);
|
||||||
}
|
if (StrUtil.isBlank(detail.getSpec())) {
|
||||||
|
continue;
|
||||||
} else {
|
|
||||||
sb.append("" + String.format("%-15s", detail.getProductName()).replace(' ', paddingCharacter) + String.format("%-4s", detail.getNumber()).replace(' ', paddingCharacter) + String.format("%8s", detail.getAmount()).replace(' ', paddingCharacter) + "<BR>");
|
|
||||||
}
|
}
|
||||||
|
data.append("规格:" + detail.getSpec() + "<BR>");
|
||||||
if (detail.getSpec() != null && ObjectUtil.isNotEmpty(detail.getSpec())) {
|
|
||||||
sb.append("规格:" + detail.getSpec() + "<BR>");
|
|
||||||
}
|
|
||||||
|
|
||||||
sb.append("<BR>");
|
|
||||||
|
|
||||||
}
|
}
|
||||||
sb.append("------------------------<BR>");
|
log.error("打印数据>>>>>>>>>>>>>>>>>>>>>:{}{}", detailPO.getDiscountAmount(), detailPO.getDiscountAdio());
|
||||||
String t = "¥" + detailPO.getReceiptsAmount();
|
if (ObjectUtil.isNotNull(detailPO.getDiscountAmount()) && ObjectUtil.isNotNull(detailPO.getDiscountAdio())) {
|
||||||
t = String.format("%11s", t).replace(' ', paddingCharacter);
|
data.append("--------------------------------<BR>");
|
||||||
|
data.append(StrUtil.format("原价:{}<BR>", detailPO.getReceiptsAmount()));
|
||||||
|
data.append(StrUtil.format("折扣:-{}<BR>", NumberUtil.null2Zero(new BigDecimal(detailPO.getDiscountAmount())).toPlainString()));
|
||||||
|
}
|
||||||
|
data.append("--------------------------------<BR>");
|
||||||
|
String t = "¥" + (ObjectUtil.isEmpty(detailPO.getDiscountAmount()) || ObjectUtil.isNull(detailPO.getDiscountAmount()) ? detailPO.getReceiptsAmount() : new BigDecimal(detailPO.getReceiptsAmount()).subtract(new BigDecimal(detailPO.getDiscountAmount())).toPlainString());
|
||||||
if (orderType.equals("return")) {
|
if (orderType.equals("return")) {
|
||||||
sb.append("<B>应退" + t + "</B><BR>");
|
data.append(StrUtil.format("<B>应退:{}</B><BR>", t));
|
||||||
} else {
|
} else {
|
||||||
sb.append("<B>应收" + t + "</B><BR>");
|
data.append(StrUtil.format("<B>应收:{}</B><BR>", t));
|
||||||
}
|
}
|
||||||
if (ObjectUtil.isNotEmpty(detailPO.getPayType()) && ObjectUtil.isNotNull(detailPO.getPayType()) && detailPO.getPayType().equals("deposit")) {
|
if (ObjectUtil.isNotEmpty(detailPO.getPayType()) && ObjectUtil.isNotNull(detailPO.getPayType()) && detailPO.getPayType().equals("deposit")) {
|
||||||
sb.append("储值¥" + detailPO.getReceiptsAmount() + " <BR>");
|
data.append("--------------------------------<BR>");
|
||||||
sb.append("------------------------<BR>");
|
data.append(StrUtil.format("储值:{}<BR>", detailPO.getReceiptsAmount()));
|
||||||
sb.append("积分:" + detailPO.getIntegral() + "<BR>");
|
data.append(StrUtil.format("积分:{}<BR>", detailPO.getIntegral()));
|
||||||
}
|
}
|
||||||
|
data.append(StrUtil.format("余额:{}<BR>", detailPO.getBalance()));
|
||||||
sb.append("余额:" + detailPO.getBalance() + "<BR>");
|
data.append("--------------------------------<BR>");
|
||||||
sb.append("------------------------<BR>");
|
|
||||||
|
|
||||||
if (ObjectUtil.isNotEmpty(detailPO.getRemark()) && ObjectUtil.isNotNull(detailPO.getRemark())) {
|
if (ObjectUtil.isNotEmpty(detailPO.getRemark()) && ObjectUtil.isNotNull(detailPO.getRemark())) {
|
||||||
sb.append("<L>备注:" + detailPO.getRemark() + "</L><BR>");
|
data.append(StrUtil.format("<L><BOLD>备注:{}</BOLD></L><BR>", detailPO.getRemark()));
|
||||||
}
|
}
|
||||||
|
data.append("打印时间:" + DateUtils.getTime(new Date()) + "<BR>");
|
||||||
|
data.append("<CUT>");
|
||||||
|
return data.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String[] getCashPrintData(OrderDetailPO detailPO, String sn, String type, String orderType) {
|
||||||
sb.append("打印时间:" + DateUtils.getTime(new Date()) + "<BR>");
|
String content = buildPrintContent(detailPO, type, orderType);
|
||||||
|
|
||||||
sb.append("<CUT>");
|
|
||||||
|
|
||||||
String content = sb.toString();
|
|
||||||
|
|
||||||
//通过POST请求,发送打印信息到服务器
|
//通过POST请求,发送打印信息到服务器
|
||||||
RequestConfig requestConfig = RequestConfig.custom()
|
RequestConfig requestConfig = RequestConfig.custom()
|
||||||
@@ -341,10 +339,11 @@ public class FeieyunPrintUtil {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 检查飞鹅打印机是否在线
|
* 检查飞鹅打印机是否在线
|
||||||
|
*
|
||||||
* @param sn 设备编号
|
* @param sn 设备编号
|
||||||
* @return 在线,工作状态正常。/离线。/未知错误
|
* @return 在线,工作状态正常。/离线。/未知错误
|
||||||
*/
|
*/
|
||||||
public static String checkOnline(String sn){
|
public static String checkOnline(String sn) {
|
||||||
String STIME = String.valueOf(System.currentTimeMillis() / 1000);
|
String STIME = String.valueOf(System.currentTimeMillis() / 1000);
|
||||||
Map<String, Object> paramMap = new HashMap<>();
|
Map<String, Object> paramMap = new HashMap<>();
|
||||||
paramMap.put("user", USER);
|
paramMap.put("user", USER);
|
||||||
@@ -359,7 +358,7 @@ public class FeieyunPrintUtil {
|
|||||||
//成功 离线 {"msg":"ok","ret":0,"data":"离线。","serverExecutedTime":7}
|
//成功 离线 {"msg":"ok","ret":0,"data":"离线。","serverExecutedTime":7}
|
||||||
JSONObject json = JSONUtil.parseObj(UnicodeUtil.toString(resp));
|
JSONObject json = JSONUtil.parseObj(UnicodeUtil.toString(resp));
|
||||||
msg = json.getStr("data");
|
msg = json.getStr("data");
|
||||||
}catch (Exception e){
|
} catch (Exception e) {
|
||||||
msg = "未知错误";
|
msg = "未知错误";
|
||||||
}
|
}
|
||||||
return msg;
|
return msg;
|
||||||
@@ -367,10 +366,11 @@ public class FeieyunPrintUtil {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 检查飞鹅打印机打印任务是否已打印
|
* 检查飞鹅打印机打印任务是否已打印
|
||||||
|
*
|
||||||
* @param printOrderId 打印订单编号
|
* @param printOrderId 打印订单编号
|
||||||
* @return null-未知错误,true-已打印,false-未打印
|
* @return null-未知错误,true-已打印,false-未打印
|
||||||
*/
|
*/
|
||||||
public static Boolean checkPrintStatus(String printOrderId){
|
public static Boolean checkPrintStatus(String printOrderId) {
|
||||||
String STIME = String.valueOf(System.currentTimeMillis() / 1000);
|
String STIME = String.valueOf(System.currentTimeMillis() / 1000);
|
||||||
Map<String, Object> paramMap = new HashMap<>();
|
Map<String, Object> paramMap = new HashMap<>();
|
||||||
paramMap.put("user", USER);
|
paramMap.put("user", USER);
|
||||||
@@ -385,7 +385,7 @@ public class FeieyunPrintUtil {
|
|||||||
//失败 {"msg":"ok","ret":0,"data":false,"serverExecutedTime":4}
|
//失败 {"msg":"ok","ret":0,"data":false,"serverExecutedTime":4}
|
||||||
JSONObject json = JSONUtil.parseObj(UnicodeUtil.toString(resp));
|
JSONObject json = JSONUtil.parseObj(UnicodeUtil.toString(resp));
|
||||||
ret = json.getBool("data");
|
ret = json.getBool("data");
|
||||||
}catch (Exception e){
|
} catch (Exception e) {
|
||||||
ret = null;
|
ret = null;
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
@@ -398,7 +398,7 @@ public class FeieyunPrintUtil {
|
|||||||
testPrint3();
|
testPrint3();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void testPrint(){
|
public static void testPrint() {
|
||||||
String STIME = String.valueOf(System.currentTimeMillis() / 1000);
|
String STIME = String.valueOf(System.currentTimeMillis() / 1000);
|
||||||
String content = buildPrintContent("123456789", "2024-10-10 18:11:11", "澳洲大龙虾", 1, "一只吃爽爽");
|
String content = buildPrintContent("123456789", "2024-10-10 18:11:11", "澳洲大龙虾", 1, "一只吃爽爽");
|
||||||
Map<String, Object> paramMap = new HashMap<>();
|
Map<String, Object> paramMap = new HashMap<>();
|
||||||
@@ -421,7 +421,7 @@ public class FeieyunPrintUtil {
|
|||||||
/**
|
/**
|
||||||
* 查询打印机状态
|
* 查询打印机状态
|
||||||
*/
|
*/
|
||||||
public static void testPrint2(){
|
public static void testPrint2() {
|
||||||
String STIME = String.valueOf(System.currentTimeMillis() / 1000);
|
String STIME = String.valueOf(System.currentTimeMillis() / 1000);
|
||||||
String content = buildPrintContent("123456789", "2024-10-10 18:11:11", "澳洲大龙虾", 1, "一只吃爽爽");
|
String content = buildPrintContent("123456789", "2024-10-10 18:11:11", "澳洲大龙虾", 1, "一只吃爽爽");
|
||||||
Map<String, Object> paramMap = new HashMap<>();
|
Map<String, Object> paramMap = new HashMap<>();
|
||||||
@@ -441,7 +441,7 @@ public class FeieyunPrintUtil {
|
|||||||
/**
|
/**
|
||||||
* 查询打印任务是否打印成功
|
* 查询打印任务是否打印成功
|
||||||
*/
|
*/
|
||||||
public static void testPrint3(){
|
public static void testPrint3() {
|
||||||
String STIME = String.valueOf(System.currentTimeMillis() / 1000);
|
String STIME = String.valueOf(System.currentTimeMillis() / 1000);
|
||||||
String content = buildPrintContent("123456789", "2024-10-10 18:11:11", "澳洲大龙虾", 1, "一只吃爽爽");
|
String content = buildPrintContent("123456789", "2024-10-10 18:11:11", "澳洲大龙虾", 1, "一只吃爽爽");
|
||||||
Map<String, Object> paramMap = new HashMap<>();
|
Map<String, Object> paramMap = new HashMap<>();
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ public class PrinterUtils {
|
|||||||
builder.append("<C><B>").append(pickupNumber).append("</B></C><BR><BR>");
|
builder.append("<C><B>").append(pickupNumber).append("</B></C><BR><BR>");
|
||||||
}
|
}
|
||||||
builder.append("<S><L>时间: ").append(date).append(" </L></S><BR><BR><BR>");
|
builder.append("<S><L>时间: ").append(date).append(" </L></S><BR><BR><BR>");
|
||||||
|
remark = StrUtil.emptyToDefault(remark, "");
|
||||||
if (productName.length() > 4 || remark.length() > 4) {
|
if (productName.length() > 4 || remark.length() > 4) {
|
||||||
builder.append("<CS:32>").append(productName).append(" ").append(number).append("</CS><BR>");
|
builder.append("<CS:32>").append(productName).append(" ").append(number).append("</CS><BR>");
|
||||||
if (StrUtil.isNotBlank(remark)) {
|
if (StrUtil.isNotBlank(remark)) {
|
||||||
@@ -120,9 +120,9 @@ public class PrinterUtils {
|
|||||||
sb.append("<S><L>订单号: ").append(detailPO.getOrderNo()).append(" </L></S><BR>");
|
sb.append("<S><L>订单号: ").append(detailPO.getOrderNo()).append(" </L></S><BR>");
|
||||||
sb.append("<S><L>交易时间: ").append(detailPO.getTradeDate()).append(" </L></S><BR>");
|
sb.append("<S><L>交易时间: ").append(detailPO.getTradeDate()).append(" </L></S><BR>");
|
||||||
sb.append("<S><L>收银员: ").append(detailPO.getOperator()).append(" </L></S><BR><BR><BR>");
|
sb.append("<S><L>收银员: ").append(detailPO.getOperator()).append(" </L></S><BR><BR><BR>");
|
||||||
sb.append("------------------------<BR>");
|
|
||||||
char paddingCharacter = ' ';
|
char paddingCharacter = ' ';
|
||||||
sb.append("<S>").append(String.format("%-15s", "品名").replace(' ', paddingCharacter)).append(String.format("%-4s", "数量").replace(' ', paddingCharacter)).append(String.format("%4s", "小计").replace(' ', paddingCharacter)).append("</S><BR>");
|
sb.append("<S>").append(String.format("%-15s", "品名").replace(' ', paddingCharacter)).append(String.format("%-4s", "数量").replace(' ', paddingCharacter)).append(String.format("%4s", "小计").replace(' ', paddingCharacter)).append("<S><BR>");
|
||||||
|
sb.append("------------------------<BR>");
|
||||||
for (OrderDetailPO.Detail detail : detailPO.getDetailList()) {
|
for (OrderDetailPO.Detail detail : detailPO.getDetailList()) {
|
||||||
|
|
||||||
if (detail.getProductName().length() > 4 && detail.getProductName().length() <= 10) {
|
if (detail.getProductName().length() > 4 && detail.getProductName().length() <= 10) {
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
<result column="updated_at" jdbcType="BIGINT" property="updatedAt" />
|
<result column="updated_at" jdbcType="BIGINT" property="updatedAt" />
|
||||||
<result column="shop_id" jdbcType="INTEGER" property="shopId" />
|
<result column="shop_id" jdbcType="INTEGER" property="shopId" />
|
||||||
<result column="small_appid" jdbcType="VARCHAR" property="smallAppid" />
|
<result column="small_appid" jdbcType="VARCHAR" property="smallAppid" />
|
||||||
|
<result column="alipay_small_appid" jdbcType="VARCHAR" property="alipaySmallAppid" />
|
||||||
<result column="store_id" jdbcType="VARCHAR" property="storeId" />
|
<result column="store_id" jdbcType="VARCHAR" property="storeId" />
|
||||||
</resultMap>
|
</resultMap>
|
||||||
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="com.chaozhanggui.system.cashierservice.entity.TbMerchantThirdApply">
|
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="com.chaozhanggui.system.cashierservice.entity.TbMerchantThirdApply">
|
||||||
@@ -19,7 +20,7 @@
|
|||||||
</resultMap>
|
</resultMap>
|
||||||
<sql id="Base_Column_List">
|
<sql id="Base_Column_List">
|
||||||
id, type, app_id, status, pay_password, applyment_state, created_at, updated_at,
|
id, type, app_id, status, pay_password, applyment_state, created_at, updated_at,
|
||||||
shop_id,small_appid,store_id
|
shop_id,small_appid,alipay_small_appid,store_id
|
||||||
</sql>
|
</sql>
|
||||||
<sql id="Blob_Column_List">
|
<sql id="Blob_Column_List">
|
||||||
app_token
|
app_token
|
||||||
|
|||||||
Reference in New Issue
Block a user