店铺管理-店铺配置:打印机设置相关接口

This commit is contained in:
谭凯凯 2024-10-12 10:42:45 +08:00 committed by Tankaikai
parent b7205fca9a
commit 3b77cfb33d
6 changed files with 263 additions and 223 deletions

View File

@ -77,6 +77,14 @@ public class TbPrintPCMachine implements Serializable {
*/ */
private String productId; private String productId;
private String receiptSize;
private String classifyPrint;
private String tablePrint;
private String printQty;
private String printMethod;
private String printType;
private String printReceipt;
private Integer pageSize; private Integer pageSize;
private Integer page; private Integer page;
@ -242,5 +250,60 @@ public class TbPrintPCMachine implements Serializable {
this.productId = productId; this.productId = productId;
} }
public String getReceiptSize() {
return receiptSize;
}
public void setReceiptSize(String receiptSize) {
this.receiptSize = receiptSize;
}
public String getClassifyPrint() {
return classifyPrint;
}
public void setClassifyPrint(String classifyPrint) {
this.classifyPrint = classifyPrint;
}
public String getTablePrint() {
return tablePrint;
}
public void setTablePrint(String tablePrint) {
this.tablePrint = tablePrint;
}
public String getPrintQty() {
return printQty;
}
public void setPrintQty(String printQty) {
this.printQty = printQty;
}
public String getPrintMethod() {
return printMethod;
}
public void setPrintMethod(String printMethod) {
this.printMethod = printMethod;
}
public String getPrintType() {
return printType;
}
public void setPrintType(String printType) {
this.printType = printType;
}
public String getPrintReceipt() {
return printReceipt;
}
public void setPrintReceipt(String printReceipt) {
this.printReceipt = printReceipt;
}
} }

View File

@ -152,8 +152,8 @@ public class PrintConsumer {
} }
list = list.stream() list = list.stream()
.filter(item -> StrUtil.isNotBlank(item.getConfig()) .filter(item -> StrUtil.isNotBlank(item.getPrintMethod())
&& model.equals(JSONObject.parseObject(item.getConfig()).getString("model"))).collect(Collectors.toList()); && model.equals(item.getPrintMethod())).collect(Collectors.toList());
log.info("打印机列表: {}", list); log.info("打印机列表: {}", list);
return list; return list;

View File

@ -2,7 +2,6 @@ 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.JSONObject;
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.*;
@ -18,9 +17,10 @@ import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.*; import java.util.ArrayList;
import java.util.concurrent.ConcurrentHashMap; import java.util.Date;
import java.util.concurrent.ConcurrentMap; import java.util.List;
import java.util.Set;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference; import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -103,16 +103,10 @@ public class PrintMechineConsumer {
log.error("打印机状态异常:{},{}", it.getAddress(), it.getStatus()); log.error("打印机状态异常:{},{}", it.getAddress(), it.getStatus());
return; return;
} }
String model = StrUtil.isEmpty(it.getPrintMethod()) ? "normal" : it.getPrintMethod();
String printerNum = StrUtil.isEmpty(it.getPrintQty()) ? "1" : it.getPrintQty().split("^")[1];
JSONObject config = JSONObject.parseObject(it.getConfig()); List<CategoryInfo> categoryInfos = JSONUtil.parseJSONStr2TList(StrUtil.emptyToDefault(it.getCategoryList(), "[]"), CategoryInfo.class);
String model = config.getString("model");
String printerNum = config.getString("printerNum");
String feet = config.getString("feet");
String autoCut = config.getString("autoCut");
List<CategoryInfo> categoryInfos = JSONUtil.parseJSONStr2TList(config.getJSONArray("categoryList").toString(), CategoryInfo.class);
switch (it.getContentType()) { switch (it.getContentType()) {
case "yxyPrinter": case "yxyPrinter":
@ -313,7 +307,7 @@ public class PrintMechineConsumer {
if (info != null) { if (info != null) {
isReturn = it.getNum() - Integer.parseInt(info) < 0; isReturn = it.getNum() - Integer.parseInt(info) < 0;
printerNum = it.getNum() - Integer.parseInt(info); printerNum = it.getNum() - Integer.parseInt(info);
}else { } else {
printerNum = it.getNum(); printerNum = it.getNum();
} }
@ -379,7 +373,8 @@ public class PrintMechineConsumer {
/** /**
* 打印退款订单 * 打印退款订单
* @param orderId 订单id *
* @param orderId 订单id
* @param tbOrderDetails 现有订单 * @param tbOrderDetails 现有订单
*/ */
public void printReturnTicket(Integer orderId, List<TbOrderDetail> tbOrderDetails) { public void printReturnTicket(Integer orderId, List<TbOrderDetail> tbOrderDetails) {
@ -416,19 +411,16 @@ public class PrintMechineConsumer {
for (Object o : printProductSetCopy) { for (Object o : printProductSetCopy) {
redisTemplate.opsForSet().add(printKey, o); redisTemplate.opsForSet().add(printKey, o);
} }
}else if (tbOrderDetails != null) { } else if (tbOrderDetails != null) {
redisTemplate.delete(printKey); redisTemplate.delete(printKey);
} }
log.info("-------------------打印机数量{}", list.size()); log.info("-------------------打印机数量{}", list.size());
for (TbPrintMachine machine : list) { for (TbPrintMachine machine : list) {
String config = machine.getConfig(); String printMethod = machine.getPrintMethod();
if (config != null) { if (!"one".equals(printMethod)) {
JSONObject jsonObject = JSONObject.parseObject(config); continue;
if (!"one".equals(jsonObject.getString("model"))) {
continue;
}
} }
log.info("-------------------商品数量{}", printProductSet.size()); log.info("-------------------商品数量{}", printProductSet.size());
printProductSet.forEach(item -> { printProductSet.forEach(item -> {
@ -619,7 +611,7 @@ public class PrintMechineConsumer {
String data = PrinterUtils.getCashPrintData(detailPO, printType, "return"); String data = PrinterUtils.getCashPrintData(detailPO, printType, "return");
String voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔新的订单,请及时处理\"}"; String voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔新的订单,请及时处理\"}";
PrinterUtils.printTickets(voiceJson,1, Integer.valueOf(printerNum), tbPrintMachineWithBLOBs.getAddress(), data); PrinterUtils.printTickets(voiceJson, 1, Integer.valueOf(printerNum), tbPrintMachineWithBLOBs.getAddress(), data);
} }
} }

View File

@ -2,6 +2,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 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.*;
@ -64,9 +65,7 @@ public class CloudPrinterService {
ShopUserDutyPayMapper shopUserDutyPayMapper; ShopUserDutyPayMapper shopUserDutyPayMapper;
public Result printReceipt(String type, String orderId, Boolean ispre) {
public Result printReceipt(String type,String orderId,Boolean ispre){
try { try {
@ -89,7 +88,7 @@ public class CloudPrinterService {
return Result.fail(CodeEnum.printmachinenoexsit); return Result.fail(CodeEnum.printmachinenoexsit);
} }
list.parallelStream().forEach(tbPrintMachineWithBLOBs->{ list.parallelStream().forEach(tbPrintMachineWithBLOBs -> {
if (!"network".equals(tbPrintMachineWithBLOBs.getConnectionType())) { if (!"network".equals(tbPrintMachineWithBLOBs.getConnectionType())) {
log.error("非网络打印机"); log.error("非网络打印机");
return; return;
@ -100,29 +99,24 @@ public class CloudPrinterService {
return; return;
} }
JSONObject config = JSONObject.parseObject(tbPrintMachineWithBLOBs.getConfig()); String model = tbPrintMachineWithBLOBs.getPrintMethod();
String model = config.getString("model");
String printerNum = config.getString("printerNum"); String printerNum = StrUtil.isEmpty(tbPrintMachineWithBLOBs.getPrintQty()) ? "1" : tbPrintMachineWithBLOBs.getPrintQty().split("^")[1];
String feet = config.getString("feet"); List<CategoryInfo> categoryInfos = JSONUtil.parseJSONStr2TList(StrUtil.emptyToDefault(tbPrintMachineWithBLOBs.getCategoryList(),"[]"), CategoryInfo.class);
String autoCut = config.getString("autoCut"); switch (tbPrintMachineWithBLOBs.getContentType()) {
List<CategoryInfo> categoryInfos=JSONUtil.parseJSONStr2TList(config.getJSONArray("categoryList").toString(),CategoryInfo.class);
switch (tbPrintMachineWithBLOBs.getContentType()){
case "yxyPrinter": case "yxyPrinter":
yxyPrinter(tbPrintMachineWithBLOBs,model,orderInfo,shopInfo,printerNum,categoryInfos,type,ispre); yxyPrinter(tbPrintMachineWithBLOBs, model, orderInfo, shopInfo, printerNum, categoryInfos, type, ispre);
break; break;
case "fePrinter": case "fePrinter":
fePrinter(tbPrintMachineWithBLOBs,model,orderInfo,shopInfo,printerNum,categoryInfos,type,ispre); fePrinter(tbPrintMachineWithBLOBs, model, orderInfo, shopInfo, printerNum, categoryInfos, type, ispre);
break; break;
} }
}); });
return Result.success(CodeEnum.SUCCESS); return Result.success(CodeEnum.SUCCESS);
}catch (Exception e){ } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
@ -131,18 +125,17 @@ public class CloudPrinterService {
} }
/** /**
* 博时结云打印机 * 博时结云打印机
*
* @param tbPrintMachineWithBLOBs * @param tbPrintMachineWithBLOBs
* @param model * @param model
* @param orderInfo * @param orderInfo
* @param shopInfo * @param shopInfo
* @param printerNum * @param printerNum
*/ */
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()) {
@ -151,21 +144,21 @@ public class CloudPrinterService {
case "cash": //小票打印机 case "cash": //小票打印机
switch (model) { switch (model) {
case "normal": //普通出单 case "normal": //普通出单
if(!"normal".equals(type)){ if (!"normal".equals(type)) {
return Result.fail("非小票打印"); return Result.fail("非小票打印");
} }
if("return".equals(orderInfo.getOrderType())){ if ("return".equals(orderInfo.getOrderType())) {
List<TbOrderDetail> tbOrderDetails=tbOrderDetailMapper.selectAllByOrderId(Integer.valueOf(orderId)); List<TbOrderDetail> tbOrderDetails = tbOrderDetailMapper.selectAllByOrderId(Integer.valueOf(orderId));
if(ObjectUtil.isNotEmpty(tbOrderDetails)&&tbOrderDetails.size()>0){ if (ObjectUtil.isNotEmpty(tbOrderDetails) && tbOrderDetails.size() > 0) {
List<OrderDetailPO.Detail> detailList = new ArrayList<>(); List<OrderDetailPO.Detail> detailList = new ArrayList<>();
tbOrderDetails.parallelStream().forEach(it->{ tbOrderDetails.parallelStream().forEach(it -> {
String categoryId= tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId(); String categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId();
Long count= categoryInfos.stream().filter(c-> Long count = categoryInfos.stream().filter(c ->
c.getId().toString().equals(categoryId) c.getId().toString().equals(categoryId)
).count(); ).count();
log.info("获取当前类别是否未打印类别:{}",count); log.info("获取当前类别是否未打印类别:{}", count);
TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getProductSkuId())); TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getProductSkuId()));
@ -187,21 +180,21 @@ 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(), "普通打印", OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印",
ObjectUtil.isEmpty(orderInfo.getMasterId())||ObjectUtil.isNull(orderInfo.getMasterId())?orderInfo.getTableName():orderInfo.getMasterId(), ObjectUtil.isEmpty(orderInfo.getMasterId()) || ObjectUtil.isNull(orderInfo.getMasterId()) ? orderInfo.getTableName() : orderInfo.getMasterId(),
orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())),
"【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance, orderInfo.getPayType(), "0", "【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance, orderInfo.getPayType(), "0",
detailList,orderInfo.getRemark(),null,null); detailList, orderInfo.getRemark(), null, null);
detailPO.setOutNumber(orderInfo.getOutNumber()); detailPO.setOutNumber(orderInfo.getOutNumber());
String printType="退款单"; String printType = "退款单";
String data= PrinterUtils.getCashPrintData(detailPO,printType,"return"); String data = PrinterUtils.getCashPrintData(detailPO, printType, "return");
String voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔新的订单,请及时处理\"}"; String voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔新的订单,请及时处理\"}";
PrinterUtils.printTickets(voiceJson,1, Integer.valueOf(printerNum), tbPrintMachineWithBLOBs.getAddress(), data); PrinterUtils.printTickets(voiceJson, 1, Integer.valueOf(printerNum), tbPrintMachineWithBLOBs.getAddress(), data);
} }
} }
@ -209,29 +202,29 @@ public class CloudPrinterService {
} }
List<TbCashierCart> cashierCarts =new ArrayList<>(); List<TbCashierCart> cashierCarts = new ArrayList<>();
if(ispre){ if (ispre) {
cashierCarts=tbCashierCartMapper.selectByOrderId(orderInfo.getId().toString(),"create"); cashierCarts = tbCashierCartMapper.selectByOrderId(orderInfo.getId().toString(), "create");
}else { } else {
cashierCarts = tbCashierCartMapper.selectByOrderId(orderInfo.getId().toString(),"final"); cashierCarts = tbCashierCartMapper.selectByOrderId(orderInfo.getId().toString(), "final");
} }
if (ObjectUtil.isNotEmpty(cashierCarts) && cashierCarts.size() > 0) { if (ObjectUtil.isNotEmpty(cashierCarts) && cashierCarts.size() > 0) {
List<OrderDetailPO.Detail> detailList = new ArrayList<>(); List<OrderDetailPO.Detail> detailList = new ArrayList<>();
cashierCarts.parallelStream().forEach(it -> { cashierCarts.parallelStream().forEach(it -> {
String categoryId; String categoryId;
if(ObjectUtil.isEmpty(it.getCategoryId())){ if (ObjectUtil.isEmpty(it.getCategoryId())) {
categoryId= tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId(); categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId();
} else { } else {
categoryId = it.getCategoryId(); categoryId = it.getCategoryId();
} }
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(count>0){ if (count > 0) {
TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getSkuId())); TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getSkuId()));
String remark = ""; String remark = "";
if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) { if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) {
@ -246,7 +239,7 @@ public class CloudPrinterService {
String balance = "0"; String balance = "0";
if ("deposit".equals(orderInfo.getPayType())) { if ("deposit".equals(orderInfo.getPayType())) {
if(ObjectUtil.isNotEmpty(orderInfo.getMemberId())&&ObjectUtil.isNotNull(orderInfo.getMemberId())){ if (ObjectUtil.isNotEmpty(orderInfo.getMemberId()) && ObjectUtil.isNotNull(orderInfo.getMemberId())) {
TbShopUser user = tbShopUserMapper.selectByPrimaryKey(Integer.valueOf(orderInfo.getMemberId())); TbShopUser user = tbShopUserMapper.selectByPrimaryKey(Integer.valueOf(orderInfo.getMemberId()));
if (ObjectUtil.isNotEmpty(user) && ObjectUtil.isNotEmpty(user.getAmount())) { if (ObjectUtil.isNotEmpty(user) && ObjectUtil.isNotEmpty(user.getAmount())) {
balance = user.getAmount().toPlainString(); balance = user.getAmount().toPlainString();
@ -254,89 +247,88 @@ public class CloudPrinterService {
} }
} }
if(ObjectUtil.isNotEmpty(detailList)&&detailList.size()>0){ if (ObjectUtil.isNotEmpty(detailList) && detailList.size() > 0) {
OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印", OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印",
orderInfo.getOrderType().equals("miniapp")?orderInfo.getTableName():orderInfo.getMasterId(), orderInfo.getOrderType().equals("miniapp") ? orderInfo.getTableName() : orderInfo.getMasterId(),
orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())),
"【POS-1】001", orderInfo.getOrderAmount().toPlainString(), "【POS-1】001", orderInfo.getOrderAmount().toPlainString(),
balance, (ObjectUtil.isEmpty(orderInfo.getPayType())||ObjectUtil.isNull(orderInfo.getPayType())?"":orderInfo.getPayType() ), "0", 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); 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());
if(ispre){ if (ispre) {
printType="预结算单"; printType = "预结算单";
} }
if("return".equals(orderInfo.getOrderType())){ if ("return".equals(orderInfo.getOrderType())) {
printType="退款单"; printType = "退款单";
} }
String data= PrinterUtils.getCashPrintData(detailPO,printType,orderInfo.getOrderType()); String data = PrinterUtils.getCashPrintData(detailPO, printType, orderInfo.getOrderType());
String voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔新的订单,请及时处理\"}"; String voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔新的订单,请及时处理\"}";
PrinterUtils.printTickets(voiceJson,3, Integer.valueOf(printerNum), tbPrintMachineWithBLOBs.getAddress(), data); PrinterUtils.printTickets(voiceJson, 3, Integer.valueOf(printerNum), tbPrintMachineWithBLOBs.getAddress(), data);
} }
} }
break; break;
case "one": //一菜一品 case "one": //一菜一品
if(!"one".equals(type)){ if (!"one".equals(type)) {
return Result.fail("非出品打印"); return Result.fail("非出品打印");
} }
if(ispre){ if (ispre) {
return Result.fail("预结算单不打印菜单"); return Result.fail("预结算单不打印菜单");
} }
if ("return".equals(orderInfo.getOrderType())) {
if("return".equals(orderInfo.getOrderType())){ List<TbOrderDetail> details = tbOrderDetailMapper.selectAllByOrderId(Integer.valueOf(orderId));
List<TbOrderDetail> details= tbOrderDetailMapper.selectAllByOrderId(Integer.valueOf(orderId)); if (ObjectUtil.isNotEmpty(details) && details.size() > 0) {
if(ObjectUtil.isNotEmpty(details)&&details.size()>0){ details.parallelStream().forEach(it -> {
details.parallelStream().forEach(it->{
String categoryId= tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId(); String categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId();
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(count>0){ if (count > 0) {
TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getProductSkuId())); TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getProductSkuId()));
String remark = ""; String remark = "";
if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) { if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) {
remark = tbProductSkuWithBLOBs.getSpecSnap(); remark = tbProductSkuWithBLOBs.getSpecSnap();
} }
String data = PrinterUtils.getPrintData("return",orderInfo.getPayType().equals("wx_lite") ? 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); orderInfo.getTableName() : orderInfo.getMasterId(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), it.getProductName(), it.getNum(), remark, null);
String voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔退款订单,请及时处理\"}"; String voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔退款订单,请及时处理\"}";
PrinterUtils.printTickets(voiceJson,3, Integer.valueOf(printerNum), tbPrintMachineWithBLOBs.getAddress(), data); PrinterUtils.printTickets(voiceJson, 3, Integer.valueOf(printerNum), tbPrintMachineWithBLOBs.getAddress(), data);
} }
}); });
} }
return Result.success(CodeEnum.SUCCESS); return Result.success(CodeEnum.SUCCESS);
}else { } else {
cashierCarts = tbCashierCartMapper.selectByOrderId(orderId,"final"); cashierCarts = tbCashierCartMapper.selectByOrderId(orderId, "final");
if (ObjectUtil.isNotEmpty(cashierCarts) && cashierCarts.size() > 0) { if (ObjectUtil.isNotEmpty(cashierCarts) && cashierCarts.size() > 0) {
cashierCarts.parallelStream().forEach(it -> { cashierCarts.parallelStream().forEach(it -> {
String categoryId; String categoryId;
if(ObjectUtil.isEmpty(it.getCategoryId())){ if (ObjectUtil.isEmpty(it.getCategoryId())) {
categoryId= tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId(); categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId();
} else { } else {
categoryId = it.getCategoryId(); categoryId = it.getCategoryId();
} }
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(count>0){ if (count > 0) {
TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getSkuId())); TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getSkuId()));
String remark = ""; String remark = "";
if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) { if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) {
@ -344,13 +336,11 @@ public class CloudPrinterService {
} }
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 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\":\"您有一笔新的订单,请及时处理\"}"; String voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔新的订单,请及时处理\"}";
PrinterUtils.printTickets(voiceJson,3, Integer.valueOf(printerNum), tbPrintMachineWithBLOBs.getAddress(), data); PrinterUtils.printTickets(voiceJson, 3, Integer.valueOf(printerNum), tbPrintMachineWithBLOBs.getAddress(), data);
} }
}); });
} }
@ -358,7 +348,7 @@ public class CloudPrinterService {
break; break;
case "category": //分类出单 case "category": //分类出单
if(!"category".equals(type)){ if (!"category".equals(type)) {
return Result.fail("非分类打印"); return Result.fail("非分类打印");
} }
break; break;
@ -373,35 +363,33 @@ public class CloudPrinterService {
} }
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();
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();
switch (tbPrintMachineWithBLOBs.getSubType()) { switch (tbPrintMachineWithBLOBs.getSubType()) {
case "label": //标签打印机 case "label": //标签打印机
if(!"label".equals(type)){ if (!"label".equals(type)) {
return Result.fail("非标签打印机"); return Result.fail("非标签打印机");
} }
if(ispre){ if (ispre) {
return Result.fail("预结算单不打印标签"); return Result.fail("预结算单不打印标签");
} }
List<TbCashierCart> cashierCarts = tbCashierCartMapper.selectByOrderId(orderInfo.getId().toString(),"final"); List<TbCashierCart> cashierCarts = tbCashierCartMapper.selectByOrderId(orderInfo.getId().toString(), "final");
if (ObjectUtil.isNotEmpty(cashierCarts) && cashierCarts.size() > 0) { if (ObjectUtil.isNotEmpty(cashierCarts) && cashierCarts.size() > 0) {
cashierCarts.parallelStream().forEach(it->{ cashierCarts.parallelStream().forEach(it -> {
Long count= categoryInfos.stream().filter(c-> Long count = categoryInfos.stream().filter(c ->
c.getId().toString().equals(it.getCategoryId().toString()) c.getId().toString().equals(it.getCategoryId().toString())
).count(); ).count();
if(count>0) { if (count > 0) {
TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getSkuId())); TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getSkuId()));
String remark = ""; String remark = "";
if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) { if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) {
remark = tbProductSkuWithBLOBs.getSpecSnap(); remark = tbProductSkuWithBLOBs.getSpecSnap();
} }
for(int i=0;i<it.getNumber();i++){ for (int i = 0; i < it.getNumber(); i++) {
FeieyunPrintUtil.printLabelMsg(tbPrintMachineWithBLOBs.getAddress(), orderInfo.getOrderType().equals("miniapp")?orderInfo.getTableName():orderInfo.getMasterId(), it.getName(), 1, DateUtils.getTimes(new Date(orderInfo.getCreatedAt())), it.getSalePrice().toPlainString(), remark); FeieyunPrintUtil.printLabelMsg(tbPrintMachineWithBLOBs.getAddress(), orderInfo.getOrderType().equals("miniapp") ? orderInfo.getTableName() : orderInfo.getMasterId(), it.getName(), 1, DateUtils.getTimes(new Date(orderInfo.getCreatedAt())), it.getSalePrice().toPlainString(), remark);
} }
} }
@ -412,21 +400,21 @@ public class CloudPrinterService {
case "cash": //小票打印机 case "cash": //小票打印机
switch (model) { switch (model) {
case "normal": //普通出单 case "normal": //普通出单
if(!"normal".equals(type)){ if (!"normal".equals(type)) {
return Result.fail("非小票打印"); return Result.fail("非小票打印");
} }
if("return".equals(orderInfo.getOrderType())){ if ("return".equals(orderInfo.getOrderType())) {
List<TbOrderDetail> tbOrderDetails=tbOrderDetailMapper.selectAllByOrderId(Integer.valueOf(orderId)); List<TbOrderDetail> tbOrderDetails = tbOrderDetailMapper.selectAllByOrderId(Integer.valueOf(orderId));
if(ObjectUtil.isNotEmpty(tbOrderDetails)&&tbOrderDetails.size()>0){ if (ObjectUtil.isNotEmpty(tbOrderDetails) && tbOrderDetails.size() > 0) {
List<OrderDetailPO.Detail> detailList = new ArrayList<>(); List<OrderDetailPO.Detail> detailList = new ArrayList<>();
tbOrderDetails.parallelStream().forEach(it->{ tbOrderDetails.parallelStream().forEach(it -> {
String categoryId= tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId(); String categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId();
Long count= categoryInfos.stream().filter(c-> Long count = categoryInfos.stream().filter(c ->
c.getId().toString().equals(categoryId) c.getId().toString().equals(categoryId)
).count(); ).count();
log.info("获取当前类别是否未打印类别:{}",count); log.info("获取当前类别是否未打印类别:{}", count);
TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getProductSkuId())); TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getProductSkuId()));
@ -448,13 +436,13 @@ 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.getOrderAmount().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.getOrderAmount().toPlainString(), balance, orderInfo.getPayType(), "0", detailList, orderInfo.getRemark(), null, null);
String printType="退款单"; String printType = "退款单";
String data= PrinterUtils.getCashPrintData(detailPO,printType,"return"); String data = PrinterUtils.getCashPrintData(detailPO, printType, "return");
// PrinterUtils.printTickets(1, Integer.valueOf(printerNum), tbPrintMachineWithBLOBs.getAddress(), data); // PrinterUtils.printTickets(1, Integer.valueOf(printerNum), tbPrintMachineWithBLOBs.getAddress(), data);
} }
} }
@ -463,29 +451,29 @@ public class CloudPrinterService {
} }
cashierCarts =new ArrayList<>(); cashierCarts = new ArrayList<>();
if(ispre){ if (ispre) {
cashierCarts=tbCashierCartMapper.selectByOrderId(orderInfo.getId().toString(),"create"); cashierCarts = tbCashierCartMapper.selectByOrderId(orderInfo.getId().toString(), "create");
}else { } else {
cashierCarts = tbCashierCartMapper.selectByOrderId(orderInfo.getId().toString(),"final"); cashierCarts = tbCashierCartMapper.selectByOrderId(orderInfo.getId().toString(), "final");
} }
if (ObjectUtil.isNotEmpty(cashierCarts) && cashierCarts.size() > 0) { if (ObjectUtil.isNotEmpty(cashierCarts) && cashierCarts.size() > 0) {
List<OrderDetailPO.Detail> detailList = new ArrayList<>(); List<OrderDetailPO.Detail> detailList = new ArrayList<>();
cashierCarts.parallelStream().forEach(it -> { cashierCarts.parallelStream().forEach(it -> {
String categoryId; String categoryId;
if(ObjectUtil.isEmpty(it.getCategoryId())){ if (ObjectUtil.isEmpty(it.getCategoryId())) {
categoryId= tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId(); categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId();
} else { } else {
categoryId = it.getCategoryId(); categoryId = it.getCategoryId();
} }
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(count>0){ if (count > 0) {
TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getSkuId())); TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getSkuId()));
String remark = ""; String remark = "";
if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) { if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) {
@ -505,68 +493,68 @@ public class CloudPrinterService {
balance = user.getAmount().toPlainString(); balance = user.getAmount().toPlainString();
} }
} }
if(ObjectUtil.isNotEmpty(detailList)&&detailList.size()>0){ if (ObjectUtil.isNotEmpty(detailList) && detailList.size() > 0) {
OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印", OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印",
orderInfo.getOrderType().equals("miniapp")?orderInfo.getTableName():orderInfo.getMasterId(), orderInfo.getOrderType().equals("miniapp") ? orderInfo.getTableName() : orderInfo.getMasterId(),
orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())),
"【POS-1】001", orderInfo.getOrderAmount().toPlainString(), "【POS-1】001", orderInfo.getOrderAmount().toPlainString(),
balance,(ObjectUtil.isEmpty(orderInfo.getPayType())||ObjectUtil.isNull(orderInfo.getPayType())?"":orderInfo.getPayType() ), balance, (ObjectUtil.isEmpty(orderInfo.getPayType()) || ObjectUtil.isNull(orderInfo.getPayType()) ? "" : orderInfo.getPayType()),
"0", detailList,orderInfo.getRemark(),null,null); "0", detailList, orderInfo.getRemark(), null, null);
String printType="结算单"; String printType = "结算单";
if(ispre){ if (ispre) {
printType="预结算单"; printType = "预结算单";
} }
if("return".equals(orderInfo.getOrderType())){ if ("return".equals(orderInfo.getOrderType())) {
printType="退款单"; printType = "退款单";
} }
FeieyunPrintUtil.getCashPrintData(detailPO, tbPrintMachineWithBLOBs.getAddress(),printType, printType); FeieyunPrintUtil.getCashPrintData(detailPO, tbPrintMachineWithBLOBs.getAddress(), printType, printType);
} }
} }
break; break;
case "one": //一菜一品 case "one": //一菜一品
if(!"one".equals(type)){ if (!"one".equals(type)) {
return Result.fail("非出品打印"); return Result.fail("非出品打印");
} }
if(ispre){ if (ispre) {
return Result.fail("预结算单不打印菜单"); return Result.fail("预结算单不打印菜单");
} }
cashierCarts = tbCashierCartMapper.selectByOrderId(orderId,"final"); cashierCarts = tbCashierCartMapper.selectByOrderId(orderId, "final");
if (ObjectUtil.isNotEmpty(cashierCarts) && cashierCarts.size() > 0) { if (ObjectUtil.isNotEmpty(cashierCarts) && cashierCarts.size() > 0) {
cashierCarts.parallelStream().forEach(it -> { cashierCarts.parallelStream().forEach(it -> {
String categoryId; String categoryId;
if(ObjectUtil.isEmpty(it.getCategoryId())){ if (ObjectUtil.isEmpty(it.getCategoryId())) {
categoryId= tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId(); categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId();
} else { } else {
categoryId = it.getCategoryId(); categoryId = it.getCategoryId();
} }
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(count>0){ if (count > 0) {
TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getSkuId())); TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getSkuId()));
String remark = ""; String remark = "";
if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) { if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) {
remark = tbProductSkuWithBLOBs.getSpecSnap(); remark = tbProductSkuWithBLOBs.getSpecSnap();
} }
FeieyunPrintUtil.getPrintData(tbPrintMachineWithBLOBs.getAddress(),orderInfo.getMasterId(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), it.getName(), it.getNumber(), remark); FeieyunPrintUtil.getPrintData(tbPrintMachineWithBLOBs.getAddress(), orderInfo.getMasterId(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), it.getName(), it.getNumber(), remark);
} }
}); });
} }
break; break;
case "category": //分类出单 case "category": //分类出单
if(!"category".equals(type)){ if (!"category".equals(type)) {
return Result.fail("非分类打印"); return Result.fail("非分类打印");
} }
break; break;
@ -580,17 +568,17 @@ public class CloudPrinterService {
} }
public Result handoverprintData(String token,Integer id,String loginName,boolean isprintProduct){ public Result handoverprintData(String token, Integer id, String loginName, boolean isprintProduct) {
JSONObject info= TokenUtil.parseParamFromToken(token); JSONObject info = TokenUtil.parseParamFromToken(token);
MsgException.checkNull(info,"获取信息失败"); MsgException.checkNull(info, "获取信息失败");
TbmerchantAccount tbmerchantAccount= tbmerchantAccountMapper.selectByPrimaryKey(Integer.valueOf(info.get("accountId").toString())); TbmerchantAccount tbmerchantAccount = tbmerchantAccountMapper.selectByPrimaryKey(Integer.valueOf(info.get("accountId").toString()));
MsgException.checkNull(tbmerchantAccount,"商户信息不存在"); MsgException.checkNull(tbmerchantAccount, "商户信息不存在");
TbShopInfo tbShopInfo= tbShopInfoMapper.selectByPrimaryKey(Integer.valueOf(tbmerchantAccount.getShopId())); TbShopInfo tbShopInfo = tbShopInfoMapper.selectByPrimaryKey(Integer.valueOf(tbmerchantAccount.getShopId()));
MsgException.checkNull(tbShopInfo,"店铺信息不存在"); MsgException.checkNull(tbShopInfo, "店铺信息不存在");
TbShopInfo shopInfo = tbShopInfoMapper.selectByPrimaryKey(tbShopInfo.getId()); TbShopInfo shopInfo = tbShopInfoMapper.selectByPrimaryKey(tbShopInfo.getId());
@ -607,7 +595,7 @@ public class CloudPrinterService {
return Result.fail(CodeEnum.printmachinenoexsit); return Result.fail(CodeEnum.printmachinenoexsit);
} }
bloBsList.parallelStream().forEach(it->{ bloBsList.parallelStream().forEach(it -> {
if (!"network".equals(it.getConnectionType())) { if (!"network".equals(it.getConnectionType())) {
log.error("非网络打印机"); log.error("非网络打印机");
@ -619,75 +607,70 @@ public class CloudPrinterService {
return; return;
} }
if(!it.getSubType().equals("cash")){ if (!it.getSubType().equals("cash")) {
log.error("非小票打印机"); log.error("非小票打印机");
return; return;
}
ShopUserDuty shopUserDuty=shopUserDutyMapper.selectByPrimaryKey(id);
// ShopUserDuty shopUserDuty=shopUserDutyMapper.selectByShopIdAndDay(tbShopInfo.getId(),tradeDay);
MsgException.checkNull(shopUserDuty,"交班信息不存在");
TbPlussShopStaff shopStaff= tbPlussShopStaffMapper.selectByPrimaryKey(Integer.valueOf(info.get("staffId").toString()));
MsgException.checkNull(shopStaff,"员工信息不存在");
List<HandoverInfo.PayInfo> list=null;
List<HandoverInfo.MemberData> memberData=null;
List<HandoverInfo.ProductCategory> productCategories=null;
List<Map<String,Object>> mapList= shopUserDutyPayMapper.selectByDutyId(shopUserDuty.getId());
if(ObjectUtil.isNotEmpty(mapList)&&mapList.size()>0){
list= JSONUtil.parseJSONStr2TList(JSONUtil.toJSONString(mapList), HandoverInfo.PayInfo.class);
} }
memberData=new ArrayList<>(); ShopUserDuty shopUserDuty = shopUserDutyMapper.selectByPrimaryKey(id);
ShopUserDutyPay shopUserDutyPay=shopUserDutyPayMapper.selectByDuctIdAndType(shopUserDuty.getId(),"deposit"); // ShopUserDuty shopUserDuty=shopUserDutyMapper.selectByShopIdAndDay(tbShopInfo.getId(),tradeDay);
if(ObjectUtil.isNotEmpty(shopUserDutyPay)){ MsgException.checkNull(shopUserDuty, "交班信息不存在");
memberData.add(new HandoverInfo.MemberData(shopUserDutyPay.getAmount().toPlainString(),"会员卡消费"));
TbPlussShopStaff shopStaff = tbPlussShopStaffMapper.selectByPrimaryKey(Integer.valueOf(info.get("staffId").toString()));
MsgException.checkNull(shopStaff, "员工信息不存在");
List<HandoverInfo.PayInfo> list = null;
List<HandoverInfo.MemberData> memberData = null;
List<HandoverInfo.ProductCategory> productCategories = null;
List<Map<String, Object>> mapList = shopUserDutyPayMapper.selectByDutyId(shopUserDuty.getId());
if (ObjectUtil.isNotEmpty(mapList) && mapList.size() > 0) {
list = JSONUtil.parseJSONStr2TList(JSONUtil.toJSONString(mapList), HandoverInfo.PayInfo.class);
}
memberData = new ArrayList<>();
ShopUserDutyPay shopUserDutyPay = shopUserDutyPayMapper.selectByDuctIdAndType(shopUserDuty.getId(), "deposit");
if (ObjectUtil.isNotEmpty(shopUserDutyPay)) {
memberData.add(new HandoverInfo.MemberData(shopUserDutyPay.getAmount().toPlainString(), "会员卡消费"));
// memberData.add(new HandoverInfo.MemberData(ObjectUtil.isNull(shopUserDuty.getMemberOutAmount())? BigDecimal.ZERO.toPlainString() : shopUserDuty.getMemberOutAmount().toPlainString(),"会员卡支付")); // memberData.add(new HandoverInfo.MemberData(ObjectUtil.isNull(shopUserDuty.getMemberOutAmount())? BigDecimal.ZERO.toPlainString() : shopUserDuty.getMemberOutAmount().toPlainString(),"会员卡支付"));
// memberData.add(new HandoverInfo.MemberData(ObjectUtil.isNull(shopUserDuty.getMemberOutAmount())? BigDecimal.ONE.toPlainString() : shopUserDuty.getMemberOutAmount().toPlainString(),"储值卡支付")); // memberData.add(new HandoverInfo.MemberData(ObjectUtil.isNull(shopUserDuty.getMemberOutAmount())? BigDecimal.ONE.toPlainString() : shopUserDuty.getMemberOutAmount().toPlainString(),"储值卡支付"));
} }
memberData.add(new HandoverInfo.MemberData(ObjectUtil.isNull(shopUserDuty.getMemberInAmount())? BigDecimal.ZERO.toPlainString() : shopUserDuty.getMemberInAmount().toPlainString(),"会员卡充值")); memberData.add(new HandoverInfo.MemberData(ObjectUtil.isNull(shopUserDuty.getMemberInAmount()) ? BigDecimal.ZERO.toPlainString() : shopUserDuty.getMemberInAmount().toPlainString(), "会员卡充值"));
List<Map<String, Object>> categries = shopUserDutyPayMapper.selectCetoryBydutyId(shopUserDuty.getId());
if (ObjectUtil.isNotEmpty(categries) && categries.size() > 0) {
List<Map<String,Object>> categries= shopUserDutyPayMapper.selectCetoryBydutyId(shopUserDuty.getId()); productCategories = JSONUtil.parseJSONStr2TList(JSONUtil.toJSONString(categries), HandoverInfo.ProductCategory.class);
if(ObjectUtil.isNotEmpty(categries)&&categries.size()>0){
productCategories=JSONUtil.parseJSONStr2TList(JSONUtil.toJSONString(categries),HandoverInfo.ProductCategory.class);
} }
List<ProductInfoPO> productInfoPOS=null; List<ProductInfoPO> productInfoPOS = null;
List<ProductInfo> productInfos=null; List<ProductInfo> productInfos = null;
if(isprintProduct){ if (isprintProduct) {
// productInfoPOS=shopUserDutyPayMapper.selectProductByDutyId(shopUserDuty.getId()); // productInfoPOS=shopUserDutyPayMapper.selectProductByDutyId(shopUserDuty.getId());
productInfos=shopUserDutyMapper.selectByDutyId(shopUserDuty.getId()); productInfos = shopUserDutyMapper.selectByDutyId(shopUserDuty.getId());
} }
HandoverInfo handoverInfo=new HandoverInfo(tbShopInfo.getShopName(), HandoverInfo handoverInfo = new HandoverInfo(tbShopInfo.getShopName(),
ObjectUtil.isNotEmpty(shopUserDuty.getLoginTime())?DateUtils.getTime(shopUserDuty.getLoginTime()):null, ObjectUtil.isNotEmpty(shopUserDuty.getLoginTime()) ? DateUtils.getTime(shopUserDuty.getLoginTime()) : null,
ObjectUtil.isNotEmpty(shopUserDuty.getLoginOutTime())?DateUtils.getTime(shopUserDuty.getLoginOutTime()):DateUtils.getTime(new Date()), ObjectUtil.isNotEmpty(shopUserDuty.getLoginOutTime()) ? DateUtils.getTime(shopUserDuty.getLoginOutTime()) : DateUtils.getTime(new Date()),
ObjectUtil.isNull(shopStaff.getName())?"":shopStaff.getName(), ObjectUtil.isNull(shopStaff.getName()) ? "" : shopStaff.getName(),
list,memberData,shopUserDuty.getAmount().add(ObjectUtil.isNull(shopUserDuty.getQuickAmount())?BigDecimal.ZERO:shopUserDuty.getQuickAmount()).toPlainString(), list, memberData, shopUserDuty.getAmount().add(ObjectUtil.isNull(shopUserDuty.getQuickAmount()) ? BigDecimal.ZERO : shopUserDuty.getQuickAmount()).toPlainString(),
"0", "0",
shopUserDuty.getAmount().subtract(shopUserDuty.getReturnAmount()).toPlainString(), shopUserDuty.getAmount().subtract(shopUserDuty.getReturnAmount()).toPlainString(),
shopUserDuty.getAmount().add(ObjectUtil.isNull(shopUserDuty.getQuickAmount())?BigDecimal.ZERO:shopUserDuty.getQuickAmount()).toPlainString(), shopUserDuty.getAmount().add(ObjectUtil.isNull(shopUserDuty.getQuickAmount()) ? BigDecimal.ZERO : shopUserDuty.getQuickAmount()).toPlainString(),
shopUserDuty.getReturnAmount().toPlainString(), shopUserDuty.getReturnAmount().toPlainString(),
shopUserDuty.getOrderNum().toString(), shopUserDuty.getOrderNum().toString(),
productCategories,ObjectUtil.isNull(shopUserDuty.getQuickAmount())?"0":shopUserDuty.getQuickAmount().toPlainString(), productCategories, ObjectUtil.isNull(shopUserDuty.getQuickAmount()) ? "0" : shopUserDuty.getQuickAmount().toPlainString(),
productInfoPOS, productInfoPOS,
productInfos productInfos
); );
String voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔新的订单,请及时处理\"}"; String voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔新的订单,请及时处理\"}";
PrinterUtils.printTickets(voiceJson,1,1,it.getAddress(),PrinterUtils.handoverprintData(handoverInfo)); PrinterUtils.printTickets(voiceJson, 1, 1, it.getAddress(), PrinterUtils.handoverprintData(handoverInfo));
}); });
@ -696,11 +679,7 @@ public class CloudPrinterService {
} }
public Result printInvoice(String shopId, String content, String remark, String amount) {
public Result printInvoice(String shopId,String content,String remark,String amount){
List<TbPrintMachineWithBLOBs> bloBsList = tbPrintMachineMapper.selectByShopId(shopId); List<TbPrintMachineWithBLOBs> bloBsList = tbPrintMachineMapper.selectByShopId(shopId);
@ -709,7 +688,7 @@ public class CloudPrinterService {
return Result.fail(CodeEnum.printmachinenoexsit); return Result.fail(CodeEnum.printmachinenoexsit);
} }
bloBsList.parallelStream().forEach(it->{ bloBsList.parallelStream().forEach(it -> {
if (!"network".equals(it.getConnectionType())) { if (!"network".equals(it.getConnectionType())) {
log.error("非网络打印机"); log.error("非网络打印机");
return; return;
@ -720,17 +699,16 @@ public class CloudPrinterService {
return; return;
} }
if(!it.getSubType().equals("cash")){ if (!it.getSubType().equals("cash")) {
log.error("非小票打印机"); log.error("非小票打印机");
return; return;
} }
String voiceJson = "{\"bizType\":\"1\",\"content\":\"您有一笔新的订单,请及时处理\"}"; String voiceJson = "{\"bizType\":\"1\",\"content\":\"您有一笔新的订单,请及时处理\"}";
PrinterUtils.printTickets(voiceJson,1,1,it.getAddress(),PrinterUtils.printInvoice(content, remark, amount)); PrinterUtils.printTickets(voiceJson, 1, 1, it.getAddress(), PrinterUtils.printInvoice(content, remark, amount));
}); });
return Result.success(CodeEnum.SUCCESS); return Result.success(CodeEnum.SUCCESS);
} }
} }

View File

@ -273,8 +273,7 @@ public class DataService {
JSONObject config = JSONObject.parseObject(it.getConfig()); String model = it.getPrintMethod();
String model = config.getString("model");
if(!"normal".equals(model)){ if(!"normal".equals(model)){
log.error("打印机类型错误"); log.error("打印机类型错误");
return; return;

View File

@ -21,11 +21,19 @@
<result property="sort" column="sort" jdbcType="INTEGER"/> <result property="sort" column="sort" jdbcType="INTEGER"/>
<result property="vendorId" column="vendor_id" jdbcType="VARCHAR"/> <result property="vendorId" column="vendor_id" jdbcType="VARCHAR"/>
<result property="productId" column="product_id" jdbcType="VARCHAR"/> <result property="productId" column="product_id" jdbcType="VARCHAR"/>
<result column="receipt_size" jdbcType="VARCHAR" property="receiptSize" />
<result column="classify_print" jdbcType="VARCHAR" property="classifyPrint" />
<result column="table_print" jdbcType="VARCHAR" property="tablePrint" />
<result column="print_qty" jdbcType="VARCHAR" property="printQty" />
<result column="print_method" jdbcType="VARCHAR" property="printMethod" />
<result column="print_type" jdbcType="VARCHAR" property="printType" />
<result column="print_receipt" jdbcType="VARCHAR" property="printReceipt" />
</resultMap> </resultMap>
<sql id="Base_Column_List"> <sql id="Base_Column_List">
id id
, name, type, connection_type, address, port, sub_type, status, shop_id, category_ids, content_type, config, created_at, updated_at, category_list, sort, vendor_id, product_id </sql> , name, type, connection_type, address, port, sub_type, status, shop_id, category_ids, content_type, config, created_at, updated_at, category_list, sort, vendor_id, product_id, receipt_size, classify_print, table_print, print_qty, print_method, print_type, print_receipt </sql>
<!--查询单个--> <!--查询单个-->
<select id="queryById" resultMap="TbPrintMachineMap"> <select id="queryById" resultMap="TbPrintMachineMap">