叫号提示打印修改
This commit is contained in:
@@ -5,70 +5,38 @@ import cn.hutool.core.util.StrUtil;
|
|||||||
import com.alibaba.fastjson.JSONArray;
|
import com.alibaba.fastjson.JSONArray;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
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.*;
|
||||||
import com.chaozhanggui.system.cashierservice.entity.dto.CallNumPrintDTO;
|
import com.chaozhanggui.system.cashierservice.entity.dto.CallNumPrintDTO;
|
||||||
import com.chaozhanggui.system.cashierservice.model.CategoryInfo;
|
|
||||||
import com.chaozhanggui.system.cashierservice.model.OrderDetailPO;
|
|
||||||
import com.chaozhanggui.system.cashierservice.mybatis.MPOrderDetailMapper;
|
|
||||||
import com.chaozhanggui.system.cashierservice.mybatis.MpPrintMachineMapper;
|
import com.chaozhanggui.system.cashierservice.mybatis.MpPrintMachineMapper;
|
||||||
import com.chaozhanggui.system.cashierservice.rabbit.print.PrinterHandler;
|
import com.chaozhanggui.system.cashierservice.rabbit.print.PrinterHandler;
|
||||||
import com.chaozhanggui.system.cashierservice.util.*;
|
import com.chaozhanggui.system.cashierservice.util.*;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
|
|
||||||
import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.data.redis.core.RedisTemplate;
|
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
import java.util.concurrent.atomic.AtomicReference;
|
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Component
|
@Component
|
||||||
@Service
|
|
||||||
public class PrintConsumer {
|
public class PrintConsumer {
|
||||||
|
private final TbOrderInfoMapper tbOrderInfoMapper;
|
||||||
|
private final TbShopInfoMapper tbShopInfoMapper;
|
||||||
@Autowired
|
private final TbOrderDetailMapper tbOrderDetailMapper;
|
||||||
TbShopUserMapper tbShopUserMapper;
|
private final MpPrintMachineMapper mpPrintMachineMapper;
|
||||||
@Autowired
|
|
||||||
private TbOrderInfoMapper tbOrderInfoMapper;
|
|
||||||
@Autowired
|
|
||||||
private TbPrintMachineMapper tbPrintMachineMapper;
|
|
||||||
@Autowired
|
|
||||||
private TbCashierCartMapper tbCashierCartMapper;
|
|
||||||
@Autowired
|
|
||||||
private TbProductSkuMapper tbProductSkuMapper;
|
|
||||||
@Autowired
|
|
||||||
private TbShopInfoMapper tbShopInfoMapper;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private TbProductMapper tbProductMapper;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private TbOrderDetailMapper tbOrderDetailMapper;
|
|
||||||
@Autowired
|
|
||||||
|
|
||||||
private RedisUtil redisUtils;
|
|
||||||
|
|
||||||
private final RedisTemplate<String, Object> redisTemplate;
|
|
||||||
@Autowired
|
|
||||||
private MpPrintMachineMapper mpPrintMachineMapper;
|
|
||||||
@Autowired
|
|
||||||
private MPOrderDetailMapper mPOrderDetailMapper;
|
|
||||||
|
|
||||||
private final PrinterHandler printerHandler;
|
private final PrinterHandler printerHandler;
|
||||||
|
|
||||||
public PrintConsumer(RedisTemplate<String, Object> redisTemplate, PrinterHandler printerHandler) {
|
public PrintConsumer(TbOrderInfoMapper tbOrderInfoMapper, TbShopInfoMapper tbShopInfoMapper, TbOrderDetailMapper tbOrderDetailMapper, MpPrintMachineMapper mpPrintMachineMapper, PrinterHandler printerHandler) {
|
||||||
this.redisTemplate = redisTemplate;
|
this.tbOrderInfoMapper = tbOrderInfoMapper;
|
||||||
|
this.tbShopInfoMapper = tbShopInfoMapper;
|
||||||
|
this.tbOrderDetailMapper = tbOrderDetailMapper;
|
||||||
|
this.mpPrintMachineMapper = mpPrintMachineMapper;
|
||||||
this.printerHandler = printerHandler;
|
this.printerHandler = printerHandler;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@RabbitListener(queues = {RabbitConstants.QUEUE_PRINT_DISHES})
|
@RabbitListener(queues = {RabbitConstants.QUEUE_PRINT_DISHES})
|
||||||
public void printDishesListener(String msg) {
|
public void printDishesListener(String msg) {
|
||||||
try {
|
try {
|
||||||
@@ -138,13 +106,6 @@ public class PrintConsumer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean checkMachineModel(String type, TbPrintMachine machine) {
|
|
||||||
Utils.checkValueUnReturn(machine, "打印机为null");
|
|
||||||
JSONObject config = JSONObject.parseObject(machine.getConfig());
|
|
||||||
String model = config.getString("model");
|
|
||||||
return type.equals(model);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private List<TbPrintMachine> getPrintMachine(Integer shopId, String subType, String model) {
|
private List<TbPrintMachine> getPrintMachine(Integer shopId, String subType, String model) {
|
||||||
TbShopInfo shopInfo = tbShopInfoMapper.selectByPrimaryKey(shopId);
|
TbShopInfo shopInfo = tbShopInfoMapper.selectByPrimaryKey(shopId);
|
||||||
@@ -170,310 +131,4 @@ public class PrintConsumer {
|
|||||||
return list;
|
return list;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 打印菜品单
|
|
||||||
*
|
|
||||||
* @param isReturn 是否退款单
|
|
||||||
*/
|
|
||||||
private void printDishesTicket(boolean isReturn, TbPrintMachine tbPrintMachineWithBLOBs, TbOrderDetail item, TbOrderInfo orderInfo, List<CategoryInfo> categoryInfos) {
|
|
||||||
log.info("开始打印一菜一品票据,商品名:{}", item.getProductName());
|
|
||||||
if (item.getProductId().equals(-999)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
String categoryId = tbProductMapper.selectByPrimaryKey(item.getProductId()).getCategoryId();
|
|
||||||
TbProductSkuWithBLOBs sku = tbProductSkuMapper.selectByPrimaryKey(item.getProductSkuId());
|
|
||||||
if (sku == null) {
|
|
||||||
log.error("商品不存在, id: {}", item.getProductSkuId());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
long count = categoryInfos.stream().filter(c ->
|
|
||||||
c.getId().toString().equals(categoryId)
|
|
||||||
).count();
|
|
||||||
|
|
||||||
if (count == 0) {
|
|
||||||
log.warn("分类未添加菜品: {} : {}", item.getProductName(), sku.getSpecSnap());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
String remark = StrUtil.isNotBlank(sku.getSpecSnap()) ? sku.getSpecSnap() : "";
|
|
||||||
item.setRemark(remark);
|
|
||||||
|
|
||||||
String data;
|
|
||||||
String voiceJson;
|
|
||||||
if (isReturn) {
|
|
||||||
|
|
||||||
data = PrinterUtils.getPrintData("return",
|
|
||||||
StrUtil.isBlank(orderInfo.getTableName()) ? orderInfo.getMasterId() : orderInfo.getTableName(),
|
|
||||||
DateUtils.getTime(new Date(orderInfo.getCreatedAt())), item.getProductName(), Math.abs(item.getNum()), remark);
|
|
||||||
voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔退款订单,请及时处理\"}";
|
|
||||||
PrinterUtils.printTickets(voiceJson, 3, 1, tbPrintMachineWithBLOBs.getAddress(), data);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
data = PrinterUtils.getPrintData("", orderInfo.getMasterId(),
|
|
||||||
DateUtils.getTime(new Date(orderInfo.getCreatedAt())), item.getProductName(),
|
|
||||||
item.getNum(), remark);
|
|
||||||
voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔新的订单,请及时处理\"}";
|
|
||||||
PrinterUtils.printTickets(voiceJson, 3, 1, tbPrintMachineWithBLOBs.getAddress(), data);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 打印结算单
|
|
||||||
*/
|
|
||||||
private void printPlaceTicket(boolean isReturn, TbPrintMachine printMachine, TbOrderInfo orderInfo, TbShopInfo shopInfo) {
|
|
||||||
log.info("打印机信息: {}", printMachine);
|
|
||||||
JSONObject config = JSONObject.parseObject(printMachine.getConfig());
|
|
||||||
String model = config.getString("model");
|
|
||||||
if (!"normal".equals(model)) {
|
|
||||||
log.info("当前打印机非小票打印机, {}", printMachine);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
List<TbOrderDetail> tbOrderDetails = tbOrderDetailMapper.selectAllByOrderId(orderInfo.getId());
|
|
||||||
if (!tbOrderDetails.isEmpty()) {
|
|
||||||
List<OrderDetailPO.Detail> detailList = new ArrayList<>();
|
|
||||||
tbOrderDetails.parallelStream().forEach(it -> {
|
|
||||||
|
|
||||||
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 (!detailList.isEmpty()) {
|
|
||||||
if (isReturn) {
|
|
||||||
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, 1, printMachine.getAddress(), data);
|
|
||||||
} else {
|
|
||||||
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);
|
|
||||||
detailPO.setOutNumber(orderInfo.getOutNumber());
|
|
||||||
String printType = "结算单";
|
|
||||||
String data = PrinterUtils.getCashPrintData(detailPO, printType, orderInfo.getOrderType());
|
|
||||||
String voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔新的订单,请及时处理\"}";
|
|
||||||
PrinterUtils.printTickets(voiceJson, 3, 1, printMachine.getAddress(), data);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private void fePrinter(TbPrintMachine tbPrintMachineWithBLOBs, String model, TbOrderInfo orderInfo, TbShopInfo shopInfo, String printerNum, List<CategoryInfo> categoryInfos) {
|
|
||||||
String orderId = orderInfo.getId().toString();
|
|
||||||
switch (tbPrintMachineWithBLOBs.getSubType()) {
|
|
||||||
case "label": //标签打印机
|
|
||||||
List<TbCashierCart> cashierCarts = tbCashierCartMapper.selectByOrderId(orderInfo.getId().toString(), "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();
|
|
||||||
|
|
||||||
log.info("获取当前类别是否未打印类别:{}", 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();
|
|
||||||
}
|
|
||||||
for (int i = 0; i < it.getNumber(); i++) {
|
|
||||||
FeieyunPrintUtil.printLabelMsg(tbPrintMachineWithBLOBs.getAddress(), orderInfo.getTableName(), it.getName(), 1, DateUtils.getTimes(new Date(orderInfo.getCreatedAt())), it.getSalePrice().toPlainString(), remark);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
case "cash": //小票打印机
|
|
||||||
switch (model) {
|
|
||||||
case "normal": //普通出单
|
|
||||||
|
|
||||||
if ("return".equals(orderInfo.getOrderType())) {
|
|
||||||
List<TbOrderDetail> tbOrderDetails = tbOrderDetailMapper.selectAllByOrderId(Integer.valueOf(orderId));
|
|
||||||
if (ObjectUtil.isNotEmpty(tbOrderDetails) && tbOrderDetails.size() > 0) {
|
|
||||||
List<OrderDetailPO.Detail> detailList = new ArrayList<>();
|
|
||||||
tbOrderDetails.parallelStream().forEach(it -> {
|
|
||||||
String categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId();
|
|
||||||
|
|
||||||
Long count = categoryInfos.stream().filter(c ->
|
|
||||||
c.getId().toString().equals(categoryId)
|
|
||||||
).count();
|
|
||||||
log.info("获取当前类别是否未打印类别:{}", count);
|
|
||||||
|
|
||||||
|
|
||||||
TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getProductSkuId()));
|
|
||||||
String remark = "";
|
|
||||||
if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) {
|
|
||||||
remark = tbProductSkuWithBLOBs.getSpecSnap();
|
|
||||||
}
|
|
||||||
OrderDetailPO.Detail detail = new OrderDetailPO.Detail(it.getProductName(), it.getNum().toString(), it.getPriceAmount().toPlainString(), remark);
|
|
||||||
detailList.add(detail);
|
|
||||||
|
|
||||||
});
|
|
||||||
String balance = "0";
|
|
||||||
|
|
||||||
if ("deposit".equals(orderInfo.getPayType())) {
|
|
||||||
TbShopUser user = tbShopUserMapper.selectByPrimaryKey(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().toPlainString(), 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.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;
|
|
||||||
case "kitchen": //出品打印机
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -116,7 +116,7 @@ public class YxyPrinter extends PrinterHandler{
|
|||||||
po.setCallNum(queue.getCallNum());
|
po.setCallNum(queue.getCallNum());
|
||||||
po.setCodeUrl(StrUtil.format(callPageUrl, queue.getShopId(), queue.getId()));
|
po.setCodeUrl(StrUtil.format(callPageUrl, queue.getShopId(), queue.getId()));
|
||||||
po.setTakeTime(queue.getCreateTime());
|
po.setTakeTime(queue.getCreateTime());
|
||||||
po.setShopNote("过号顺延三桌 三桌后需重新排号 谢谢理解!");
|
po.setShopNote(StrUtil.format("过号顺延{}桌 {}桌后需重新排号 谢谢理解!", tbCallTable.getPostponeNum(), tbCallTable.getPostponeNum()));
|
||||||
String data = PrinterUtils.getCallNumPrintData(po);
|
String data = PrinterUtils.getCallNumPrintData(po);
|
||||||
String voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一条新的排号记录\"}";
|
String voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一条新的排号记录\"}";
|
||||||
PrinterUtils.printTickets(voiceJson, 3, 1, "ZF544PG03W00005", data);
|
PrinterUtils.printTickets(voiceJson, 3, 1, "ZF544PG03W00005", data);
|
||||||
|
|||||||
Reference in New Issue
Block a user