1.打印折扣值为空报错修复
This commit is contained in:
@@ -250,59 +250,11 @@ public class PrintMechineConsumer {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if("return".equals(orderInfo.getOrderType())){
|
if("return".equals(orderInfo.getOrderType())){
|
||||||
List<TbOrderDetail> details= tbOrderDetailMapper.selectAllByOrderId(Integer.valueOf(orderId));
|
printReturnTicket(tbPrintMachineWithBLOBs, orderInfo, printerNum, categoryInfos, 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);
|
|
||||||
String voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔退款订单,请及时处理\"}";
|
|
||||||
PrinterUtils.printTickets(voiceJson,3, Integer.valueOf(printerNum), tbPrintMachineWithBLOBs.getAddress(), data);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
}else {
|
}else {
|
||||||
tbOrderDetails = tbOrderDetailMapper.selectAllByOrderId(Integer.valueOf(orderId));
|
printTicket(Integer.valueOf(orderId), categoryInfos, tbPrintMachineWithBLOBs, orderInfo);
|
||||||
if (ObjectUtil.isNotEmpty(tbOrderDetails) && !tbOrderDetails.isEmpty()) {
|
// printNormalTicket(tbPrintMachineWithBLOBs, orderInfo, printerNum, categoryInfos, orderId);
|
||||||
|
|
||||||
tbOrderDetails.parallelStream().forEach(it -> {
|
|
||||||
// 已经打印过的菜品不再打印
|
|
||||||
if ("postPay".equals(orderInfo.getUseType()) && isPrint(it, orderInfo.getId())) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
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();
|
|
||||||
}
|
|
||||||
String data = PrinterUtils.getPrintData("",orderInfo.getMasterId(),
|
|
||||||
DateUtils.getTime(new Date(orderInfo.getCreatedAt())), it.getProductName(),
|
|
||||||
it.getNum(), remark);
|
|
||||||
String voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔新的订单,请及时处理\"}";
|
|
||||||
PrinterUtils.printTickets(voiceJson,3, Integer.valueOf(printerNum), tbPrintMachineWithBLOBs.getAddress(), data);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "category": //分类出单
|
case "category": //分类出单
|
||||||
@@ -315,6 +267,127 @@ public class PrintMechineConsumer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void printTicket(Integer orderId, List<CategoryInfo> categoryInfos, TbPrintMachineWithBLOBs tbPrintMachineWithBLOBs, TbOrderInfo orderInfo) {
|
||||||
|
List<TbOrderDetail> tbOrderDetails = tbOrderDetailMapper.selectAllByOrderId(orderId);
|
||||||
|
if (!tbOrderDetails.isEmpty()) {
|
||||||
|
|
||||||
|
tbOrderDetails.parallelStream().forEach(it -> {
|
||||||
|
log.info("开始打印一菜一品票据,:{}", it.getProductName());
|
||||||
|
String categoryId = tbProductMapper.selectByPrimaryKey(it.getProductId()).getCategoryId();
|
||||||
|
|
||||||
|
long count = categoryInfos.stream().filter(c ->
|
||||||
|
c.getId().toString().equals(categoryId)
|
||||||
|
).count();
|
||||||
|
|
||||||
|
log.info("获取当前类别是否未打印类别:{}", count);
|
||||||
|
if(count>0){
|
||||||
|
|
||||||
|
// 统计已打数量
|
||||||
|
int printerNum = 0;
|
||||||
|
boolean isReturn = false;
|
||||||
|
String key = RedisCst.ORDER_PRINT + orderId + ":" + it.getProductId() + ":" + it.getProductSkuId();
|
||||||
|
String info = redisUtils.getMessage(key);
|
||||||
|
redisUtils.saveMessage(key, String.valueOf(it.getNum()), 60 * 60 * 24);
|
||||||
|
if (info != null) {
|
||||||
|
isReturn = it.getNum() - Integer.parseInt(info) < 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 已打印不再打印
|
||||||
|
if (info != null && it.getNum() - Integer.parseInt(info) == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(it.getProductSkuId());
|
||||||
|
String remark = "";
|
||||||
|
if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) {
|
||||||
|
remark = tbProductSkuWithBLOBs.getSpecSnap();
|
||||||
|
}
|
||||||
|
|
||||||
|
String data;
|
||||||
|
String voiceJson;
|
||||||
|
if (isReturn) {
|
||||||
|
data = PrinterUtils.getPrintData("return",
|
||||||
|
orderInfo.getPayType().equals("wx_lite")? orderInfo.getTableName(): orderInfo.getMasterId(),
|
||||||
|
DateUtils.getTime(new Date(orderInfo.getCreatedAt())), it.getProductName(), it.getNum(), remark);
|
||||||
|
voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔退款订单,请及时处理\"}";
|
||||||
|
}else {
|
||||||
|
data = PrinterUtils.getPrintData("", orderInfo.getMasterId(),
|
||||||
|
DateUtils.getTime(new Date(orderInfo.getCreatedAt())), it.getProductName(),
|
||||||
|
it.getNum(), remark);
|
||||||
|
voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔新的订单,请及时处理\"}";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
PrinterUtils.printTickets(voiceJson,3, printerNum, tbPrintMachineWithBLOBs.getAddress(), data);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 普通出菜单打印
|
||||||
|
*/
|
||||||
|
private void printNormalTicket(TbPrintMachineWithBLOBs tbPrintMachineWithBLOBs, TbOrderInfo orderInfo, String printerNum, List<CategoryInfo> categoryInfos, String orderId) {
|
||||||
|
List<TbOrderDetail> tbOrderDetails;
|
||||||
|
tbOrderDetails = tbOrderDetailMapper.selectAllByOrderId(Integer.valueOf(orderId));
|
||||||
|
if (ObjectUtil.isNotEmpty(tbOrderDetails) && !tbOrderDetails.isEmpty()) {
|
||||||
|
|
||||||
|
tbOrderDetails.parallelStream().forEach(it -> {
|
||||||
|
// 已经打印过的菜品不再打印
|
||||||
|
if ("postPay".equals(orderInfo.getUseType()) && isPrint(it, orderInfo.getId())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
String data = PrinterUtils.getPrintData("", orderInfo.getMasterId(),
|
||||||
|
DateUtils.getTime(new Date(orderInfo.getCreatedAt())), it.getProductName(),
|
||||||
|
it.getNum(), remark);
|
||||||
|
String voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔新的订单,请及时处理\"}";
|
||||||
|
PrinterUtils.printTickets(voiceJson,3, Integer.valueOf(printerNum), tbPrintMachineWithBLOBs.getAddress(), data);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 退款单打印
|
||||||
|
*/
|
||||||
|
private void printReturnTicket(TbPrintMachineWithBLOBs tbPrintMachineWithBLOBs, TbOrderInfo orderInfo, String printerNum, List<CategoryInfo> categoryInfos, String orderId) {
|
||||||
|
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);
|
||||||
|
String voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔退款订单,请及时处理\"}";
|
||||||
|
PrinterUtils.printTickets(voiceJson,3, Integer.valueOf(printerNum), tbPrintMachineWithBLOBs.getAddress(), data);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 判断商品是否已打票
|
* 判断商品是否已打票
|
||||||
* @return true 已打 false 未打
|
* @return true 已打 false 未打
|
||||||
|
|||||||
@@ -189,7 +189,11 @@ public class CloudPrinterService {
|
|||||||
|
|
||||||
if(ObjectUtil.isNotEmpty(detailList)&&detailList.size()>0){
|
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(), "普通打印", 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.getPayAmount().toPlainString(), balance, orderInfo.getPayType(), "0", detailList,orderInfo.getRemark(),null,null);
|
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() != null ? orderInfo.getPayAmount().toPlainString() : orderInfo.getOrderAmount().toPlainString(), balance, orderInfo.getPayType(), "0",
|
||||||
|
detailList,orderInfo.getRemark(),null,null);
|
||||||
detailPO.setOutNumber(orderInfo.getOutNumber());
|
detailPO.setOutNumber(orderInfo.getOutNumber());
|
||||||
String printType="退款单";
|
String printType="退款单";
|
||||||
|
|
||||||
@@ -251,7 +255,12 @@ public class CloudPrinterService {
|
|||||||
|
|
||||||
}
|
}
|
||||||
if(ObjectUtil.isNotEmpty(detailList)&&detailList.size()>0){
|
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.getPayAmount().toPlainString(), balance,(ObjectUtil.isEmpty(orderInfo.getPayType())||ObjectUtil.isNull(orderInfo.getPayType())?"":orderInfo.getPayType() ), "0", detailList,orderInfo.getRemark(),orderInfo.getDiscountAmount().toPlainString(),orderInfo.getDiscountRatio().toPlainString());
|
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.getPayAmount() != null ? orderInfo.getPayAmount().toPlainString() : 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="结算单";
|
String printType="结算单";
|
||||||
|
|
||||||
detailPO.setOutNumber(orderInfo.getOutNumber());
|
detailPO.setOutNumber(orderInfo.getOutNumber());
|
||||||
@@ -495,7 +504,12 @@ public class CloudPrinterService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(ObjectUtil.isNotEmpty(detailList)&&detailList.size()>0){
|
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.getPayAmount().toPlainString(), balance,(ObjectUtil.isEmpty(orderInfo.getPayType())||ObjectUtil.isNull(orderInfo.getPayType())?"":orderInfo.getPayType() ), "0", detailList,orderInfo.getRemark(),null,null);
|
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.getPayAmount() != null ? orderInfo.getPayAmount().toPlainString() : orderInfo.getOrderAmount().toPlainString(),
|
||||||
|
balance,(ObjectUtil.isEmpty(orderInfo.getPayType())||ObjectUtil.isNull(orderInfo.getPayType())?"":orderInfo.getPayType() ),
|
||||||
|
"0", detailList,orderInfo.getRemark(),null,null);
|
||||||
String printType="结算单";
|
String printType="结算单";
|
||||||
if(ispre){
|
if(ispre){
|
||||||
printType="预结算单";
|
printType="预结算单";
|
||||||
|
|||||||
Reference in New Issue
Block a user