|
|
|
|
@@ -2,6 +2,7 @@ package com.chaozhanggui.system.cashierservice.service;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
import com.chaozhanggui.system.cashierservice.dao.*;
|
|
|
|
|
import com.chaozhanggui.system.cashierservice.entity.*;
|
|
|
|
|
@@ -64,9 +65,7 @@ public class CloudPrinterService {
|
|
|
|
|
ShopUserDutyPayMapper shopUserDutyPayMapper;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public Result printReceipt(String type,String orderId,Boolean ispre){
|
|
|
|
|
public Result printReceipt(String type, String orderId, Boolean ispre) {
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
|
|
@@ -89,7 +88,7 @@ public class CloudPrinterService {
|
|
|
|
|
return Result.fail(CodeEnum.printmachinenoexsit);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
list.parallelStream().forEach(tbPrintMachineWithBLOBs->{
|
|
|
|
|
list.parallelStream().forEach(tbPrintMachineWithBLOBs -> {
|
|
|
|
|
if (!"network".equals(tbPrintMachineWithBLOBs.getConnectionType())) {
|
|
|
|
|
log.error("非网络打印机");
|
|
|
|
|
return;
|
|
|
|
|
@@ -100,29 +99,24 @@ public class CloudPrinterService {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
JSONObject config = JSONObject.parseObject(tbPrintMachineWithBLOBs.getConfig());
|
|
|
|
|
String model = config.getString("model");
|
|
|
|
|
String model = tbPrintMachineWithBLOBs.getPrintMethod();
|
|
|
|
|
|
|
|
|
|
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");
|
|
|
|
|
|
|
|
|
|
List<CategoryInfo> categoryInfos=JSONUtil.parseJSONStr2TList(config.getJSONArray("categoryList").toString(),CategoryInfo.class);
|
|
|
|
|
|
|
|
|
|
switch (tbPrintMachineWithBLOBs.getContentType()){
|
|
|
|
|
switch (tbPrintMachineWithBLOBs.getContentType()) {
|
|
|
|
|
case "yxyPrinter":
|
|
|
|
|
yxyPrinter(tbPrintMachineWithBLOBs,model,orderInfo,shopInfo,printerNum,categoryInfos,type,ispre);
|
|
|
|
|
yxyPrinter(tbPrintMachineWithBLOBs, model, orderInfo, shopInfo, printerNum, categoryInfos, type, ispre);
|
|
|
|
|
break;
|
|
|
|
|
case "fePrinter":
|
|
|
|
|
fePrinter(tbPrintMachineWithBLOBs,model,orderInfo,shopInfo,printerNum,categoryInfos,type,ispre);
|
|
|
|
|
fePrinter(tbPrintMachineWithBLOBs, model, orderInfo, shopInfo, printerNum, categoryInfos, type, ispre);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
return Result.success(CodeEnum.SUCCESS);
|
|
|
|
|
|
|
|
|
|
}catch (Exception e){
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -131,18 +125,17 @@ public class CloudPrinterService {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 博时结云打印机
|
|
|
|
|
* 博时结云打印机
|
|
|
|
|
*
|
|
|
|
|
* @param tbPrintMachineWithBLOBs
|
|
|
|
|
* @param model
|
|
|
|
|
* @param orderInfo
|
|
|
|
|
* @param shopInfo
|
|
|
|
|
* @param printerNum
|
|
|
|
|
*/
|
|
|
|
|
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();
|
|
|
|
|
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();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
switch (tbPrintMachineWithBLOBs.getSubType()) {
|
|
|
|
|
@@ -151,21 +144,21 @@ public class CloudPrinterService {
|
|
|
|
|
case "cash": //小票打印机
|
|
|
|
|
switch (model) {
|
|
|
|
|
case "normal": //普通出单
|
|
|
|
|
if(!"normal".equals(type)){
|
|
|
|
|
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){
|
|
|
|
|
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();
|
|
|
|
|
tbOrderDetails.parallelStream().forEach(it -> {
|
|
|
|
|
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)
|
|
|
|
|
).count();
|
|
|
|
|
log.info("获取当前类别是否未打印类别:{}",count);
|
|
|
|
|
log.info("获取当前类别是否未打印类别:{}", count);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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(), "普通打印",
|
|
|
|
|
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())),
|
|
|
|
|
"【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance, orderInfo.getPayType(), "0",
|
|
|
|
|
detailList,orderInfo.getRemark(),null,null);
|
|
|
|
|
detailList, orderInfo.getRemark(), null, null);
|
|
|
|
|
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\":\"您有一笔新的订单,请及时处理\"}";
|
|
|
|
|
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<>();
|
|
|
|
|
if(ispre){
|
|
|
|
|
cashierCarts=tbCashierCartMapper.selectByOrderId(orderInfo.getId().toString(),"create");
|
|
|
|
|
}else {
|
|
|
|
|
cashierCarts = tbCashierCartMapper.selectByOrderId(orderInfo.getId().toString(),"final");
|
|
|
|
|
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();
|
|
|
|
|
if (ObjectUtil.isEmpty(it.getCategoryId())) {
|
|
|
|
|
categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId();
|
|
|
|
|
} else {
|
|
|
|
|
categoryId = it.getCategoryId();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Long count= categoryInfos.stream().filter(c->
|
|
|
|
|
Long count = categoryInfos.stream().filter(c ->
|
|
|
|
|
c.getId().toString().equals(categoryId)
|
|
|
|
|
).count();
|
|
|
|
|
|
|
|
|
|
if(count>0){
|
|
|
|
|
if (count > 0) {
|
|
|
|
|
TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getSkuId()));
|
|
|
|
|
String remark = "";
|
|
|
|
|
if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) {
|
|
|
|
|
@@ -246,7 +239,7 @@ public class CloudPrinterService {
|
|
|
|
|
String balance = "0";
|
|
|
|
|
|
|
|
|
|
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()));
|
|
|
|
|
if (ObjectUtil.isNotEmpty(user) && ObjectUtil.isNotEmpty(user.getAmount())) {
|
|
|
|
|
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(), "普通打印",
|
|
|
|
|
orderInfo.getOrderType().equals("miniapp")?orderInfo.getTableName():orderInfo.getMasterId(),
|
|
|
|
|
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="结算单";
|
|
|
|
|
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 (ispre) {
|
|
|
|
|
printType = "预结算单";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if("return".equals(orderInfo.getOrderType())){
|
|
|
|
|
printType="退款单";
|
|
|
|
|
if ("return".equals(orderInfo.getOrderType())) {
|
|
|
|
|
printType = "退款单";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String data= PrinterUtils.getCashPrintData(detailPO,printType,orderInfo.getOrderType());
|
|
|
|
|
String data = PrinterUtils.getCashPrintData(detailPO, printType, orderInfo.getOrderType());
|
|
|
|
|
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;
|
|
|
|
|
case "one": //一菜一品
|
|
|
|
|
if(!"one".equals(type)){
|
|
|
|
|
if (!"one".equals(type)) {
|
|
|
|
|
return Result.fail("非出品打印");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(ispre){
|
|
|
|
|
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->{
|
|
|
|
|
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->
|
|
|
|
|
String categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId();
|
|
|
|
|
Long count = categoryInfos.stream().filter(c ->
|
|
|
|
|
c.getId().toString().equals(categoryId)
|
|
|
|
|
).count();
|
|
|
|
|
|
|
|
|
|
if(count>0){
|
|
|
|
|
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 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);
|
|
|
|
|
PrinterUtils.printTickets(voiceJson, 3, Integer.valueOf(printerNum), tbPrintMachineWithBLOBs.getAddress(), data);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
return Result.success(CodeEnum.SUCCESS);
|
|
|
|
|
}else {
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
|
|
cashierCarts = tbCashierCartMapper.selectByOrderId(orderId,"final");
|
|
|
|
|
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();
|
|
|
|
|
if (ObjectUtil.isEmpty(it.getCategoryId())) {
|
|
|
|
|
categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId();
|
|
|
|
|
} else {
|
|
|
|
|
categoryId = it.getCategoryId();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Long count= categoryInfos.stream().filter(c->
|
|
|
|
|
Long count = categoryInfos.stream().filter(c ->
|
|
|
|
|
c.getId().toString().equals(categoryId)
|
|
|
|
|
).count();
|
|
|
|
|
|
|
|
|
|
if(count>0){
|
|
|
|
|
if (count > 0) {
|
|
|
|
|
TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getSkuId()));
|
|
|
|
|
String remark = "";
|
|
|
|
|
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\":\"您有一笔新的订单,请及时处理\"}";
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
case "category": //分类出单
|
|
|
|
|
if(!"category".equals(type)){
|
|
|
|
|
if (!"category".equals(type)) {
|
|
|
|
|
return Result.fail("非分类打印");
|
|
|
|
|
}
|
|
|
|
|
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()) {
|
|
|
|
|
case "label": //标签打印机
|
|
|
|
|
if(!"label".equals(type)){
|
|
|
|
|
if (!"label".equals(type)) {
|
|
|
|
|
return Result.fail("非标签打印机");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(ispre){
|
|
|
|
|
if (ispre) {
|
|
|
|
|
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) {
|
|
|
|
|
cashierCarts.parallelStream().forEach(it->{
|
|
|
|
|
Long count= categoryInfos.stream().filter(c->
|
|
|
|
|
cashierCarts.parallelStream().forEach(it -> {
|
|
|
|
|
Long count = categoryInfos.stream().filter(c ->
|
|
|
|
|
c.getId().toString().equals(it.getCategoryId().toString())
|
|
|
|
|
).count();
|
|
|
|
|
|
|
|
|
|
if(count>0) {
|
|
|
|
|
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.getOrderType().equals("miniapp")?orderInfo.getTableName():orderInfo.getMasterId(), it.getName(), 1, DateUtils.getTimes(new Date(orderInfo.getCreatedAt())), it.getSalePrice().toPlainString(), remark);
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
@@ -412,21 +400,21 @@ public class CloudPrinterService {
|
|
|
|
|
case "cash": //小票打印机
|
|
|
|
|
switch (model) {
|
|
|
|
|
case "normal": //普通出单
|
|
|
|
|
if(!"normal".equals(type)){
|
|
|
|
|
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){
|
|
|
|
|
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();
|
|
|
|
|
tbOrderDetails.parallelStream().forEach(it -> {
|
|
|
|
|
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)
|
|
|
|
|
).count();
|
|
|
|
|
log.info("获取当前类别是否未打印类别:{}",count);
|
|
|
|
|
log.info("获取当前类别是否未打印类别:{}", count);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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(), "普通打印", 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);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@@ -463,29 +451,29 @@ public class CloudPrinterService {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cashierCarts =new ArrayList<>();
|
|
|
|
|
if(ispre){
|
|
|
|
|
cashierCarts=tbCashierCartMapper.selectByOrderId(orderInfo.getId().toString(),"create");
|
|
|
|
|
}else {
|
|
|
|
|
cashierCarts = tbCashierCartMapper.selectByOrderId(orderInfo.getId().toString(),"final");
|
|
|
|
|
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();
|
|
|
|
|
if (ObjectUtil.isEmpty(it.getCategoryId())) {
|
|
|
|
|
categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId();
|
|
|
|
|
} else {
|
|
|
|
|
categoryId = it.getCategoryId();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Long count= categoryInfos.stream().filter(c->
|
|
|
|
|
Long count = categoryInfos.stream().filter(c ->
|
|
|
|
|
c.getId().toString().equals(categoryId)
|
|
|
|
|
).count();
|
|
|
|
|
|
|
|
|
|
if(count>0){
|
|
|
|
|
if (count > 0) {
|
|
|
|
|
TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getSkuId()));
|
|
|
|
|
String remark = "";
|
|
|
|
|
if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) {
|
|
|
|
|
@@ -505,68 +493,68 @@ public class CloudPrinterService {
|
|
|
|
|
balance = user.getAmount().toPlainString();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
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.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="预结算单";
|
|
|
|
|
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="退款单";
|
|
|
|
|
if ("return".equals(orderInfo.getOrderType())) {
|
|
|
|
|
printType = "退款单";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
FeieyunPrintUtil.getCashPrintData(detailPO, tbPrintMachineWithBLOBs.getAddress(),printType, printType);
|
|
|
|
|
FeieyunPrintUtil.getCashPrintData(detailPO, tbPrintMachineWithBLOBs.getAddress(), printType, printType);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
case "one": //一菜一品
|
|
|
|
|
if(!"one".equals(type)){
|
|
|
|
|
if (!"one".equals(type)) {
|
|
|
|
|
return Result.fail("非出品打印");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(ispre){
|
|
|
|
|
if (ispre) {
|
|
|
|
|
return Result.fail("预结算单不打印菜单");
|
|
|
|
|
}
|
|
|
|
|
cashierCarts = tbCashierCartMapper.selectByOrderId(orderId,"final");
|
|
|
|
|
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();
|
|
|
|
|
if (ObjectUtil.isEmpty(it.getCategoryId())) {
|
|
|
|
|
categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId();
|
|
|
|
|
} else {
|
|
|
|
|
categoryId = it.getCategoryId();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Long count= categoryInfos.stream().filter(c->
|
|
|
|
|
Long count = categoryInfos.stream().filter(c ->
|
|
|
|
|
c.getId().toString().equals(categoryId)
|
|
|
|
|
).count();
|
|
|
|
|
|
|
|
|
|
if(count>0){
|
|
|
|
|
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);
|
|
|
|
|
FeieyunPrintUtil.getPrintData(tbPrintMachineWithBLOBs.getAddress(), orderInfo.getMasterId(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), it.getName(), it.getNumber(), remark);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case "category": //分类出单
|
|
|
|
|
if(!"category".equals(type)){
|
|
|
|
|
if (!"category".equals(type)) {
|
|
|
|
|
return Result.fail("非分类打印");
|
|
|
|
|
}
|
|
|
|
|
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);
|
|
|
|
|
MsgException.checkNull(info,"获取信息失败");
|
|
|
|
|
JSONObject info = TokenUtil.parseParamFromToken(token);
|
|
|
|
|
MsgException.checkNull(info, "获取信息失败");
|
|
|
|
|
|
|
|
|
|
TbmerchantAccount tbmerchantAccount= tbmerchantAccountMapper.selectByPrimaryKey(Integer.valueOf(info.get("accountId").toString()));
|
|
|
|
|
MsgException.checkNull(tbmerchantAccount,"商户信息不存在");
|
|
|
|
|
TbmerchantAccount tbmerchantAccount = tbmerchantAccountMapper.selectByPrimaryKey(Integer.valueOf(info.get("accountId").toString()));
|
|
|
|
|
MsgException.checkNull(tbmerchantAccount, "商户信息不存在");
|
|
|
|
|
|
|
|
|
|
TbShopInfo tbShopInfo= tbShopInfoMapper.selectByPrimaryKey(Integer.valueOf(tbmerchantAccount.getShopId()));
|
|
|
|
|
MsgException.checkNull(tbShopInfo,"店铺信息不存在");
|
|
|
|
|
TbShopInfo tbShopInfo = tbShopInfoMapper.selectByPrimaryKey(Integer.valueOf(tbmerchantAccount.getShopId()));
|
|
|
|
|
MsgException.checkNull(tbShopInfo, "店铺信息不存在");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TbShopInfo shopInfo = tbShopInfoMapper.selectByPrimaryKey(tbShopInfo.getId());
|
|
|
|
|
@@ -607,7 +595,7 @@ public class CloudPrinterService {
|
|
|
|
|
return Result.fail(CodeEnum.printmachinenoexsit);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bloBsList.parallelStream().forEach(it->{
|
|
|
|
|
bloBsList.parallelStream().forEach(it -> {
|
|
|
|
|
|
|
|
|
|
if (!"network".equals(it.getConnectionType())) {
|
|
|
|
|
log.error("非网络打印机");
|
|
|
|
|
@@ -619,75 +607,70 @@ public class CloudPrinterService {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(!it.getSubType().equals("cash")){
|
|
|
|
|
log.error("非小票打印机");
|
|
|
|
|
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);
|
|
|
|
|
if (!it.getSubType().equals("cash")) {
|
|
|
|
|
log.error("非小票打印机");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
memberData=new ArrayList<>();
|
|
|
|
|
ShopUserDutyPay shopUserDutyPay=shopUserDutyPayMapper.selectByDuctIdAndType(shopUserDuty.getId(),"deposit");
|
|
|
|
|
if(ObjectUtil.isNotEmpty(shopUserDutyPay)){
|
|
|
|
|
memberData.add(new HandoverInfo.MemberData(shopUserDutyPay.getAmount().toPlainString(),"会员卡消费"));
|
|
|
|
|
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<>();
|
|
|
|
|
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.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){
|
|
|
|
|
productCategories=JSONUtil.parseJSONStr2TList(JSONUtil.toJSONString(categries),HandoverInfo.ProductCategory.class);
|
|
|
|
|
List<Map<String, Object>> categries = shopUserDutyPayMapper.selectCetoryBydutyId(shopUserDuty.getId());
|
|
|
|
|
if (ObjectUtil.isNotEmpty(categries) && categries.size() > 0) {
|
|
|
|
|
productCategories = JSONUtil.parseJSONStr2TList(JSONUtil.toJSONString(categries), HandoverInfo.ProductCategory.class);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
List<ProductInfoPO> productInfoPOS=null;
|
|
|
|
|
List<ProductInfo> productInfos=null;
|
|
|
|
|
if(isprintProduct){
|
|
|
|
|
List<ProductInfoPO> productInfoPOS = null;
|
|
|
|
|
List<ProductInfo> productInfos = null;
|
|
|
|
|
if (isprintProduct) {
|
|
|
|
|
// productInfoPOS=shopUserDutyPayMapper.selectProductByDutyId(shopUserDuty.getId());
|
|
|
|
|
productInfos=shopUserDutyMapper.selectByDutyId(shopUserDuty.getId());
|
|
|
|
|
productInfos = shopUserDutyMapper.selectByDutyId(shopUserDuty.getId());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
HandoverInfo handoverInfo=new HandoverInfo(tbShopInfo.getShopName(),
|
|
|
|
|
ObjectUtil.isNotEmpty(shopUserDuty.getLoginTime())?DateUtils.getTime(shopUserDuty.getLoginTime()):null,
|
|
|
|
|
ObjectUtil.isNotEmpty(shopUserDuty.getLoginOutTime())?DateUtils.getTime(shopUserDuty.getLoginOutTime()):DateUtils.getTime(new Date()),
|
|
|
|
|
ObjectUtil.isNull(shopStaff.getName())?"":shopStaff.getName(),
|
|
|
|
|
list,memberData,shopUserDuty.getAmount().add(ObjectUtil.isNull(shopUserDuty.getQuickAmount())?BigDecimal.ZERO:shopUserDuty.getQuickAmount()).toPlainString(),
|
|
|
|
|
HandoverInfo handoverInfo = new HandoverInfo(tbShopInfo.getShopName(),
|
|
|
|
|
ObjectUtil.isNotEmpty(shopUserDuty.getLoginTime()) ? DateUtils.getTime(shopUserDuty.getLoginTime()) : null,
|
|
|
|
|
ObjectUtil.isNotEmpty(shopUserDuty.getLoginOutTime()) ? DateUtils.getTime(shopUserDuty.getLoginOutTime()) : DateUtils.getTime(new Date()),
|
|
|
|
|
ObjectUtil.isNull(shopStaff.getName()) ? "" : shopStaff.getName(),
|
|
|
|
|
list, memberData, shopUserDuty.getAmount().add(ObjectUtil.isNull(shopUserDuty.getQuickAmount()) ? BigDecimal.ZERO : shopUserDuty.getQuickAmount()).toPlainString(),
|
|
|
|
|
"0",
|
|
|
|
|
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.getOrderNum().toString(),
|
|
|
|
|
productCategories,ObjectUtil.isNull(shopUserDuty.getQuickAmount())?"0":shopUserDuty.getQuickAmount().toPlainString(),
|
|
|
|
|
productCategories, ObjectUtil.isNull(shopUserDuty.getQuickAmount()) ? "0" : shopUserDuty.getQuickAmount().toPlainString(),
|
|
|
|
|
productInfoPOS,
|
|
|
|
|
productInfos
|
|
|
|
|
|
|
|
|
|
);
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
@@ -709,7 +688,7 @@ public class CloudPrinterService {
|
|
|
|
|
return Result.fail(CodeEnum.printmachinenoexsit);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bloBsList.parallelStream().forEach(it->{
|
|
|
|
|
bloBsList.parallelStream().forEach(it -> {
|
|
|
|
|
if (!"network".equals(it.getConnectionType())) {
|
|
|
|
|
log.error("非网络打印机");
|
|
|
|
|
return;
|
|
|
|
|
@@ -720,17 +699,16 @@ public class CloudPrinterService {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(!it.getSubType().equals("cash")){
|
|
|
|
|
if (!it.getSubType().equals("cash")) {
|
|
|
|
|
log.error("非小票打印机");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|