Merge remote-tracking branch 'origin/test' into test
This commit is contained in:
@@ -4,7 +4,6 @@ package com.chaozhanggui.system.cashierservice.controller;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.chaozhanggui.system.cashierservice.entity.Enum.PayTypeConstant;
|
||||
import com.chaozhanggui.system.cashierservice.interceptor.RequestWrapper;
|
||||
import com.chaozhanggui.system.cashierservice.service.PayService;
|
||||
import com.chaozhanggui.system.cashierservice.sign.Result;
|
||||
@@ -17,7 +16,6 @@ import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
@CrossOrigin(origins = "*")
|
||||
@RestController
|
||||
@@ -81,6 +79,7 @@ public class NotifyController {
|
||||
&& !"0100".equals(object.getStr("payType"))
|
||||
){
|
||||
String orderNo=object.getStr("orderNumber");
|
||||
|
||||
return payService.callBackPay(orderNo);
|
||||
}
|
||||
}
|
||||
@@ -110,7 +109,8 @@ public class NotifyController {
|
||||
if("TRADE_SUCCESS".equals(object.get("state").toString())){
|
||||
String orderNo=object.get("mchOrderNo").toString();
|
||||
String tradeNo=object.get("payOrderId").toString();
|
||||
return payService.callBackPayFST(tradeNo);
|
||||
String payType=object.getStr("payType");
|
||||
return payService.callBackPayFST(tradeNo,payType);
|
||||
}else {
|
||||
String tradeNo=object.get("payOrderId").toString();
|
||||
return String.valueOf(payService.activateOrder(tradeNo));
|
||||
|
||||
@@ -66,11 +66,6 @@ public class TbProduct implements Serializable {
|
||||
|
||||
private String typeEnum;
|
||||
|
||||
/**
|
||||
* 是否共享库存
|
||||
*/
|
||||
private Byte isDistribute;
|
||||
|
||||
private Byte isDel;
|
||||
|
||||
private Byte isStock;
|
||||
@@ -406,13 +401,6 @@ public class TbProduct implements Serializable {
|
||||
this.typeEnum = typeEnum == null ? null : typeEnum.trim();
|
||||
}
|
||||
|
||||
public Byte getIsDistribute() {
|
||||
return isDistribute;
|
||||
}
|
||||
|
||||
public void setIsDistribute(Byte isDistribute) {
|
||||
this.isDistribute = isDistribute;
|
||||
}
|
||||
|
||||
public Byte getIsDel() {
|
||||
return isDel;
|
||||
|
||||
@@ -16,6 +16,7 @@ public class UserCouponVo {
|
||||
private String detail;
|
||||
private String shopId;
|
||||
private String shopName;
|
||||
private String orderId;
|
||||
/**
|
||||
* 优惠金额
|
||||
*/
|
||||
|
||||
@@ -103,7 +103,7 @@ public class PrintMechineConsumer {
|
||||
|
||||
String model = tbPrintMachineWithBLOBs.getPrintMethod();
|
||||
|
||||
String printerNum = StrUtil.isEmpty(tbPrintMachineWithBLOBs.getPrintQty()) ? "1" : tbPrintMachineWithBLOBs.getPrintQty().split("^")[1];
|
||||
String printerNum = StrUtil.isEmpty(tbPrintMachineWithBLOBs.getPrintQty()) ? "1" : tbPrintMachineWithBLOBs.getPrintQty().split("\\^")[1];
|
||||
|
||||
List<CategoryInfo> categoryInfos = JSONUtil.parseJSONStr2TList(StrUtil.emptyToDefault(tbPrintMachineWithBLOBs.getCategoryList(), "[]"), CategoryInfo.class);
|
||||
|
||||
@@ -125,6 +125,101 @@ public class PrintMechineConsumer {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 仅打印制作单「厨房」
|
||||
*/
|
||||
private void onlyKitchenForYxy(String orderId, TbPrintMachineWithBLOBs tbPrintMachineWithBLOBs, TbOrderInfo orderInfo, String printerNum, List<CategoryInfo> categoryInfos) {
|
||||
List<TbCashierCart> cashierCarts = tbCashierCartMapper.selectByOrderId(orderId, "final");
|
||||
log.info("一菜一品打印,待打印信息:{}", cashierCarts);
|
||||
if (ObjectUtil.isNotEmpty(cashierCarts) && cashierCarts.size() > 0) {
|
||||
|
||||
|
||||
cashierCarts.parallelStream().forEach(it -> {
|
||||
|
||||
// 取餐号不为空为代客下单
|
||||
if ("postPay".equals(orderInfo.getUseType()) && StrUtil.isNotBlank(it.getMasterId())) {
|
||||
log.info("--------------------代客下单 打印一菜一品");
|
||||
printTicket(Integer.valueOf(orderId), categoryInfos, tbPrintMachineWithBLOBs, orderInfo);
|
||||
return;
|
||||
}
|
||||
log.info("--------------------非代客下单 打印一菜一品");
|
||||
|
||||
String categoryId;
|
||||
if (ObjectUtil.isEmpty(it.getCategoryId())) {
|
||||
categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId();
|
||||
} else {
|
||||
categoryId = it.getCategoryId();
|
||||
}
|
||||
|
||||
|
||||
Long count = categoryInfos.stream().filter(c ->
|
||||
c.getId().toString().equals(categoryId)
|
||||
).count();
|
||||
|
||||
if (count > 0) {
|
||||
TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getSkuId()));
|
||||
String remark = "";
|
||||
if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) {
|
||||
remark = tbProductSkuWithBLOBs.getSpecSnap();
|
||||
}
|
||||
String data = PrinterUtils.getPrintData(orderInfo.getTableName(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), it.getName(), it.getNumber(), remark);
|
||||
PrinterUtils.printTickets(1, Integer.valueOf(printerNum), tbPrintMachineWithBLOBs.getAddress(), data);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 仅打印结算单「前台」
|
||||
*/
|
||||
private void onlyFrontDeskForYxy(String orderId, TbOrderInfo orderInfo, String printerNum, TbShopInfo shopInfo, TbPrintMachineWithBLOBs tbPrintMachineWithBLOBs, List<CategoryInfo> categoryInfos) {
|
||||
List<TbCashierCart> cashierCarts = tbCashierCartMapper.selectByOrderId(orderInfo.getId().toString(), "final");
|
||||
if (ObjectUtil.isNotEmpty(cashierCarts) && cashierCarts.size() > 0) {
|
||||
List<OrderDetailPO.Detail> detailList = new ArrayList<>();
|
||||
cashierCarts.parallelStream().forEach(it -> {
|
||||
String categoryId;
|
||||
if (ObjectUtil.isEmpty(it.getCategoryId())) {
|
||||
categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId();
|
||||
} else {
|
||||
categoryId = it.getCategoryId();
|
||||
}
|
||||
|
||||
|
||||
Long count = categoryInfos.stream().filter(c ->
|
||||
c.getId().toString().equals(categoryId)
|
||||
).count();
|
||||
|
||||
if (count > 0) {
|
||||
TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getSkuId()));
|
||||
String remark = "";
|
||||
if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) {
|
||||
remark = tbProductSkuWithBLOBs.getSpecSnap();
|
||||
}
|
||||
|
||||
OrderDetailPO.Detail detail = new OrderDetailPO.Detail(it.getName(), it.getNumber().toString(), it.getTotalAmount().toPlainString(), remark);
|
||||
detailList.add(detail);
|
||||
}
|
||||
});
|
||||
|
||||
String balance = "0";
|
||||
|
||||
if ("deposit".equals(orderInfo.getPayType())) {
|
||||
TbShopUser user = tbShopUserMapper.selectByPrimaryKey(orderInfo.getMemberId());
|
||||
if (ObjectUtil.isNotEmpty(user) && ObjectUtil.isNotEmpty(user.getAmount())) {
|
||||
balance = user.getAmount().toPlainString();
|
||||
}
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(detailList) && detailList.size() > 0) {
|
||||
|
||||
OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印", orderInfo.getTableName(), orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), "【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance, orderInfo.getPayType(), "0", detailList, orderInfo.getRemark());
|
||||
detailPO.setOutNumber(orderInfo.getOutNumber());
|
||||
String data = PrinterUtils.getCashPrintData(detailPO, "结算单");
|
||||
PrinterUtils.printTickets(1, Integer.valueOf(printerNum), tbPrintMachineWithBLOBs.getAddress(), data);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 博时结云打印机
|
||||
*
|
||||
@@ -136,105 +231,18 @@ public class PrintMechineConsumer {
|
||||
*/
|
||||
private void yxyPrinter(TbPrintMachineWithBLOBs tbPrintMachineWithBLOBs, String model, TbOrderInfo orderInfo, TbShopInfo shopInfo, String printerNum, List<CategoryInfo> categoryInfos) {
|
||||
String orderId = orderInfo.getId().toString();
|
||||
|
||||
|
||||
switch (tbPrintMachineWithBLOBs.getSubType()) {
|
||||
case "label": //标签打印机
|
||||
break;
|
||||
case "cash": //小票打印机
|
||||
switch (model) {
|
||||
case "normal": //普通出单
|
||||
List<TbCashierCart> cashierCarts = tbCashierCartMapper.selectByOrderId(orderInfo.getId().toString(), "final");
|
||||
if (ObjectUtil.isNotEmpty(cashierCarts) && cashierCarts.size() > 0) {
|
||||
List<OrderDetailPO.Detail> detailList = new ArrayList<>();
|
||||
cashierCarts.parallelStream().forEach(it -> {
|
||||
String categoryId;
|
||||
if (ObjectUtil.isEmpty(it.getCategoryId())) {
|
||||
categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId();
|
||||
} else {
|
||||
categoryId = it.getCategoryId();
|
||||
}
|
||||
|
||||
|
||||
Long count = categoryInfos.stream().filter(c ->
|
||||
c.getId().toString().equals(categoryId)
|
||||
).count();
|
||||
|
||||
if (count > 0) {
|
||||
TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getSkuId()));
|
||||
String remark = "";
|
||||
if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) {
|
||||
remark = tbProductSkuWithBLOBs.getSpecSnap();
|
||||
}
|
||||
|
||||
OrderDetailPO.Detail detail = new OrderDetailPO.Detail(it.getName(), it.getNumber().toString(), it.getTotalAmount().toPlainString(), remark);
|
||||
detailList.add(detail);
|
||||
}
|
||||
});
|
||||
|
||||
String balance = "0";
|
||||
|
||||
if ("deposit".equals(orderInfo.getPayType())) {
|
||||
TbShopUser user = tbShopUserMapper.selectByPrimaryKey(orderInfo.getMemberId());
|
||||
if (ObjectUtil.isNotEmpty(user) && ObjectUtil.isNotEmpty(user.getAmount())) {
|
||||
balance = user.getAmount().toPlainString();
|
||||
}
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(detailList) && detailList.size() > 0) {
|
||||
|
||||
OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印", orderInfo.getTableName(), orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), "【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance, orderInfo.getPayType(), "0", detailList, orderInfo.getRemark());
|
||||
detailPO.setOutNumber(orderInfo.getOutNumber());
|
||||
String data = PrinterUtils.getCashPrintData(detailPO, "结算单");
|
||||
PrinterUtils.printTickets(1, Integer.valueOf(printerNum), tbPrintMachineWithBLOBs.getAddress(), data);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
break;
|
||||
case "one": //一菜一品
|
||||
cashierCarts = tbCashierCartMapper.selectByOrderId(orderId, "final");
|
||||
log.info("一菜一品打印,待打印信息:{}", cashierCarts);
|
||||
if (ObjectUtil.isNotEmpty(cashierCarts) && cashierCarts.size() > 0) {
|
||||
|
||||
|
||||
cashierCarts.parallelStream().forEach(it -> {
|
||||
|
||||
// 取餐号不为空为代客下单
|
||||
if ("postPay".equals(orderInfo.getUseType()) && StrUtil.isNotBlank(it.getMasterId())) {
|
||||
log.info("--------------------代客下单 打印一菜一品");
|
||||
printTicket(Integer.valueOf(orderId), categoryInfos, tbPrintMachineWithBLOBs, orderInfo);
|
||||
return;
|
||||
}
|
||||
log.info("--------------------非代客下单 打印一菜一品");
|
||||
|
||||
String categoryId;
|
||||
if (ObjectUtil.isEmpty(it.getCategoryId())) {
|
||||
categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId();
|
||||
} else {
|
||||
categoryId = it.getCategoryId();
|
||||
}
|
||||
|
||||
|
||||
Long count = categoryInfos.stream().filter(c ->
|
||||
c.getId().toString().equals(categoryId)
|
||||
).count();
|
||||
|
||||
if (count > 0) {
|
||||
TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getSkuId()));
|
||||
String remark = "";
|
||||
if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) {
|
||||
remark = tbProductSkuWithBLOBs.getSpecSnap();
|
||||
}
|
||||
String data = PrinterUtils.getPrintData(orderInfo.getTableName(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), it.getName(), it.getNumber(), remark);
|
||||
PrinterUtils.printTickets(1, Integer.valueOf(printerNum), tbPrintMachineWithBLOBs.getAddress(), data);
|
||||
}
|
||||
});
|
||||
}
|
||||
break;
|
||||
case "category": //分类出单
|
||||
break;
|
||||
if ("normal".equals(model)) {
|
||||
onlyFrontDeskForYxy(orderId, orderInfo, printerNum, shopInfo, tbPrintMachineWithBLOBs, categoryInfos);
|
||||
} else if ("one".equals(model)) {
|
||||
onlyKitchenForYxy(orderId, tbPrintMachineWithBLOBs, orderInfo, printerNum, categoryInfos);
|
||||
} else if ("all".equals(model)) {
|
||||
onlyFrontDeskForYxy(orderId, orderInfo, printerNum, shopInfo, tbPrintMachineWithBLOBs, categoryInfos);
|
||||
onlyKitchenForYxy(orderId, tbPrintMachineWithBLOBs, orderInfo, printerNum, categoryInfos);
|
||||
}
|
||||
|
||||
break;
|
||||
case "kitchen": //出品打印机
|
||||
break;
|
||||
@@ -350,6 +358,141 @@ public class PrintMechineConsumer {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 仅打印结算单「前台」
|
||||
*/
|
||||
private void onlyFrontDeskForFe(String orderId, TbPrintMachineWithBLOBs tbPrintMachineWithBLOBs, String model, TbOrderInfo orderInfo, TbShopInfo shopInfo, String printerNum, List<CategoryInfo> categoryInfos) {
|
||||
if ("return".equals(orderInfo.getOrderType())) {
|
||||
List<TbOrderDetail> tbOrderDetails = tbOrderDetailMapper.selectAllByOrderId(Integer.valueOf(orderId));
|
||||
if (ObjectUtil.isNotEmpty(tbOrderDetails) && tbOrderDetails.size() > 0) {
|
||||
List<OrderDetailPO.Detail> detailList = new ArrayList<>();
|
||||
tbOrderDetails.parallelStream().forEach(it -> {
|
||||
String categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId();
|
||||
|
||||
Long count = categoryInfos.stream().filter(c ->
|
||||
c.getId().toString().equals(categoryId)
|
||||
).count();
|
||||
log.info("获取当前类别是否未打印类别:{}", count);
|
||||
|
||||
|
||||
TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getProductSkuId()));
|
||||
String remark = "";
|
||||
if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) {
|
||||
remark = tbProductSkuWithBLOBs.getSpecSnap();
|
||||
}
|
||||
OrderDetailPO.Detail detail = new OrderDetailPO.Detail(it.getProductName(), it.getNum().toString(), it.getPriceAmount().toPlainString(), remark);
|
||||
detailList.add(detail);
|
||||
|
||||
});
|
||||
String balance = "0";
|
||||
|
||||
if ("deposit".equals(orderInfo.getPayType())) {
|
||||
TbShopUser user = tbShopUserMapper.selectByPrimaryKey(orderInfo.getMemberId());
|
||||
if (ObjectUtil.isNotEmpty(user) && ObjectUtil.isNotEmpty(user.getAmount())) {
|
||||
balance = user.getAmount().toPlainString();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (ObjectUtil.isNotEmpty(detailList) && detailList.size() > 0) {
|
||||
// OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印", orderInfo.getMasterId(), orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), "【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance, orderInfo.getPayType(), "0", detailList);
|
||||
OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印", ObjectUtil.isEmpty(orderInfo.getMasterId()) || ObjectUtil.isNull(orderInfo.getMasterId()) ? orderInfo.getTableName() : orderInfo.getMasterId(), orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), "【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance, orderInfo.getPayType(), "0", detailList, orderInfo.getRemark());
|
||||
|
||||
String printType = "退款单";
|
||||
|
||||
String data = PrinterUtils.getCashPrintData(detailPO, printType);
|
||||
PrinterUtils.printTickets(1, Integer.valueOf(printerNum), tbPrintMachineWithBLOBs.getAddress(), data);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
List<TbCashierCart> cashierCarts = tbCashierCartMapper.selectByOrderId(orderInfo.getId().toString(), "final");
|
||||
|
||||
if (ObjectUtil.isNotEmpty(cashierCarts) && cashierCarts.size() > 0) {
|
||||
List<OrderDetailPO.Detail> detailList = new ArrayList<>();
|
||||
cashierCarts.parallelStream().forEach(it -> {
|
||||
String categoryId;
|
||||
if (ObjectUtil.isEmpty(it.getCategoryId())) {
|
||||
categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId();
|
||||
} else {
|
||||
categoryId = it.getCategoryId();
|
||||
}
|
||||
|
||||
|
||||
Long count = categoryInfos.stream().filter(c ->
|
||||
c.getId().toString().equals(categoryId)
|
||||
).count();
|
||||
|
||||
if (count > 0) {
|
||||
TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getSkuId()));
|
||||
String remark = "";
|
||||
if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) {
|
||||
remark = tbProductSkuWithBLOBs.getSpecSnap();
|
||||
}
|
||||
OrderDetailPO.Detail detail = new OrderDetailPO.Detail(it.getName(), it.getNumber().toString(), it.getTotalAmount().toPlainString(), remark);
|
||||
detailList.add(detail);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
String balance = "0";
|
||||
|
||||
if ("deposit".equals(orderInfo.getPayType())) {
|
||||
TbShopUser user = tbShopUserMapper.selectByPrimaryKey(orderInfo.getMemberId());
|
||||
if (ObjectUtil.isNotEmpty(user) && ObjectUtil.isNotEmpty(user.getAmount())) {
|
||||
balance = user.getAmount().toPlainString();
|
||||
}
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(detailList) && detailList.size() > 0) {
|
||||
OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印", orderInfo.getOrderType().equals("miniapp") ? orderInfo.getTableName() : orderInfo.getMasterId(), orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), "【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance, (ObjectUtil.isEmpty(orderInfo.getPayType()) || ObjectUtil.isNull(orderInfo.getPayType()) ? "" : orderInfo.getPayType()), "0", detailList, orderInfo.getRemark());
|
||||
String printType = "结算单";
|
||||
|
||||
if ("return".equals(orderInfo.getOrderType())) {
|
||||
printType = "退款单";
|
||||
}
|
||||
|
||||
|
||||
FeieyunPrintUtil.getCashPrintData(detailPO, tbPrintMachineWithBLOBs.getAddress(), printType, printType);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 仅打印制作单「厨房」
|
||||
*/
|
||||
private void onlyKitchenForFe(String orderId, TbPrintMachineWithBLOBs tbPrintMachineWithBLOBs, String model, TbOrderInfo orderInfo, TbShopInfo shopInfo, String printerNum, List<CategoryInfo> categoryInfos) {
|
||||
List<TbCashierCart> cashierCarts = tbCashierCartMapper.selectByOrderId(orderId, "final");
|
||||
if (ObjectUtil.isNotEmpty(cashierCarts) && cashierCarts.size() > 0) {
|
||||
|
||||
cashierCarts.parallelStream().forEach(it -> {
|
||||
|
||||
String categoryId;
|
||||
if (ObjectUtil.isEmpty(it.getCategoryId())) {
|
||||
categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId();
|
||||
} else {
|
||||
categoryId = it.getCategoryId();
|
||||
}
|
||||
|
||||
|
||||
Long count = categoryInfos.stream().filter(c ->
|
||||
c.getId().toString().equals(categoryId)
|
||||
).count();
|
||||
|
||||
if (count > 0) {
|
||||
TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getSkuId()));
|
||||
String remark = "";
|
||||
if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) {
|
||||
remark = tbProductSkuWithBLOBs.getSpecSnap();
|
||||
}
|
||||
FeieyunPrintUtil.getPrintData(tbPrintMachineWithBLOBs.getAddress(), orderInfo.getTableName(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), it.getName(), it.getNumber(), remark);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void fePrinter(TbPrintMachineWithBLOBs tbPrintMachineWithBLOBs, String model, TbOrderInfo orderInfo, TbShopInfo shopInfo, String printerNum, List<CategoryInfo> categoryInfos) {
|
||||
String orderId = orderInfo.getId().toString();
|
||||
@@ -389,136 +532,13 @@ public class PrintMechineConsumer {
|
||||
|
||||
break;
|
||||
case "cash": //小票打印机
|
||||
switch (model) {
|
||||
case "normal": //普通出单
|
||||
|
||||
if ("return".equals(orderInfo.getOrderType())) {
|
||||
List<TbOrderDetail> tbOrderDetails = tbOrderDetailMapper.selectAllByOrderId(Integer.valueOf(orderId));
|
||||
if (ObjectUtil.isNotEmpty(tbOrderDetails) && tbOrderDetails.size() > 0) {
|
||||
List<OrderDetailPO.Detail> detailList = new ArrayList<>();
|
||||
tbOrderDetails.parallelStream().forEach(it -> {
|
||||
String categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId();
|
||||
|
||||
Long count = categoryInfos.stream().filter(c ->
|
||||
c.getId().toString().equals(categoryId)
|
||||
).count();
|
||||
log.info("获取当前类别是否未打印类别:{}", count);
|
||||
|
||||
|
||||
TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getProductSkuId()));
|
||||
String remark = "";
|
||||
if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) {
|
||||
remark = tbProductSkuWithBLOBs.getSpecSnap();
|
||||
}
|
||||
OrderDetailPO.Detail detail = new OrderDetailPO.Detail(it.getProductName(), it.getNum().toString(), it.getPriceAmount().toPlainString(), remark);
|
||||
detailList.add(detail);
|
||||
|
||||
});
|
||||
String balance = "0";
|
||||
|
||||
if ("deposit".equals(orderInfo.getPayType())) {
|
||||
TbShopUser user = tbShopUserMapper.selectByPrimaryKey(orderInfo.getMemberId());
|
||||
if (ObjectUtil.isNotEmpty(user) && ObjectUtil.isNotEmpty(user.getAmount())) {
|
||||
balance = user.getAmount().toPlainString();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (ObjectUtil.isNotEmpty(detailList) && detailList.size() > 0) {
|
||||
// OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印", orderInfo.getMasterId(), orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), "【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance, orderInfo.getPayType(), "0", detailList);
|
||||
OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印", ObjectUtil.isEmpty(orderInfo.getMasterId()) || ObjectUtil.isNull(orderInfo.getMasterId()) ? orderInfo.getTableName() : orderInfo.getMasterId(), orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), "【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance, orderInfo.getPayType(), "0", detailList, orderInfo.getRemark());
|
||||
|
||||
String printType = "退款单";
|
||||
|
||||
String data = PrinterUtils.getCashPrintData(detailPO, printType);
|
||||
PrinterUtils.printTickets(1, Integer.valueOf(printerNum), tbPrintMachineWithBLOBs.getAddress(), data);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
cashierCarts = cashierCarts = tbCashierCartMapper.selectByOrderId(orderInfo.getId().toString(), "final");
|
||||
|
||||
if (ObjectUtil.isNotEmpty(cashierCarts) && cashierCarts.size() > 0) {
|
||||
List<OrderDetailPO.Detail> detailList = new ArrayList<>();
|
||||
cashierCarts.parallelStream().forEach(it -> {
|
||||
String categoryId;
|
||||
if (ObjectUtil.isEmpty(it.getCategoryId())) {
|
||||
categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId();
|
||||
} else {
|
||||
categoryId = it.getCategoryId();
|
||||
}
|
||||
|
||||
|
||||
Long count = categoryInfos.stream().filter(c ->
|
||||
c.getId().toString().equals(categoryId)
|
||||
).count();
|
||||
|
||||
if (count > 0) {
|
||||
TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getSkuId()));
|
||||
String remark = "";
|
||||
if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) {
|
||||
remark = tbProductSkuWithBLOBs.getSpecSnap();
|
||||
}
|
||||
OrderDetailPO.Detail detail = new OrderDetailPO.Detail(it.getName(), it.getNumber().toString(), it.getTotalAmount().toPlainString(), remark);
|
||||
detailList.add(detail);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
String balance = "0";
|
||||
|
||||
if ("deposit".equals(orderInfo.getPayType())) {
|
||||
TbShopUser user = tbShopUserMapper.selectByPrimaryKey(orderInfo.getMemberId());
|
||||
if (ObjectUtil.isNotEmpty(user) && ObjectUtil.isNotEmpty(user.getAmount())) {
|
||||
balance = user.getAmount().toPlainString();
|
||||
}
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(detailList) && detailList.size() > 0) {
|
||||
OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印", orderInfo.getOrderType().equals("miniapp") ? orderInfo.getTableName() : orderInfo.getMasterId(), orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), "【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance, (ObjectUtil.isEmpty(orderInfo.getPayType()) || ObjectUtil.isNull(orderInfo.getPayType()) ? "" : orderInfo.getPayType()), "0", detailList, orderInfo.getRemark());
|
||||
String printType = "结算单";
|
||||
|
||||
if ("return".equals(orderInfo.getOrderType())) {
|
||||
printType = "退款单";
|
||||
}
|
||||
|
||||
|
||||
FeieyunPrintUtil.getCashPrintData(detailPO, tbPrintMachineWithBLOBs.getAddress(), printType, printType);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
case "one": //一菜一品
|
||||
|
||||
cashierCarts = tbCashierCartMapper.selectByOrderId(orderId, "final");
|
||||
if (ObjectUtil.isNotEmpty(cashierCarts) && cashierCarts.size() > 0) {
|
||||
|
||||
cashierCarts.parallelStream().forEach(it -> {
|
||||
|
||||
String categoryId;
|
||||
if (ObjectUtil.isEmpty(it.getCategoryId())) {
|
||||
categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId();
|
||||
} else {
|
||||
categoryId = it.getCategoryId();
|
||||
}
|
||||
|
||||
|
||||
Long count = categoryInfos.stream().filter(c ->
|
||||
c.getId().toString().equals(categoryId)
|
||||
).count();
|
||||
|
||||
if (count > 0) {
|
||||
TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getSkuId()));
|
||||
String remark = "";
|
||||
if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) {
|
||||
remark = tbProductSkuWithBLOBs.getSpecSnap();
|
||||
}
|
||||
FeieyunPrintUtil.getPrintData(tbPrintMachineWithBLOBs.getAddress(), orderInfo.getTableName(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), it.getName(), it.getNumber(), remark);
|
||||
}
|
||||
});
|
||||
}
|
||||
if ("normal".equals(model)) {
|
||||
onlyFrontDeskForFe(orderId, tbPrintMachineWithBLOBs, model, orderInfo, shopInfo, printerNum, categoryInfos);
|
||||
} else if ("one".equals(model)) {
|
||||
onlyKitchenForFe(orderId, tbPrintMachineWithBLOBs, model, orderInfo, shopInfo, printerNum, categoryInfos);
|
||||
} else if ("all".equals(model)) {
|
||||
onlyFrontDeskForFe(orderId, tbPrintMachineWithBLOBs, model, orderInfo, shopInfo, printerNum, categoryInfos);
|
||||
onlyKitchenForFe(orderId, tbPrintMachineWithBLOBs, model, orderInfo, shopInfo, printerNum, categoryInfos);
|
||||
}
|
||||
break;
|
||||
case "kitchen": //出品打印机
|
||||
|
||||
@@ -350,17 +350,9 @@ public class CartService {
|
||||
return Result.fail("商品已下架");
|
||||
}
|
||||
if (tbProduct.getIsStock() == 1) {
|
||||
// 1:共享库存 0:独立库存
|
||||
if (Integer.valueOf(tbProduct.getIsDistribute()).equals(1)) {
|
||||
if (tbProduct.getIsPauseSale() == 1) {//是否售罄
|
||||
rmCart(jsonObject, skuId, tableCartKey);
|
||||
return Result.fail("该商品已售罄");
|
||||
}
|
||||
} else {
|
||||
if (tbProductSkuWithBLOBs.getIsPauseSale() == 1) {//是否售罄
|
||||
rmCart(jsonObject, skuId, tableCartKey);
|
||||
return Result.fail("该商品已售罄");
|
||||
}
|
||||
if (tbProduct.getIsPauseSale() == 1) {//是否售罄
|
||||
rmCart(jsonObject, skuId, tableCartKey);
|
||||
return Result.fail("该商品已售罄");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -625,19 +617,10 @@ public class CartService {
|
||||
if (productSku.getSuit() != null && productSku.getSuit() > 1 && isVip != 1) {
|
||||
if (product.getIsStock() == 1) {
|
||||
boolean isSale = false;
|
||||
// 1:共享库存 0:独立库存
|
||||
if (Integer.valueOf(product.getIsDistribute()).equals(1)) {
|
||||
if (num > productSku.getSuit()) {
|
||||
if (num > product.getStockNumber()) isSale = true;
|
||||
} else {
|
||||
if (productSku.getSuit() > product.getStockNumber()) isSale = true;
|
||||
}
|
||||
if (num > productSku.getSuit()) {
|
||||
if (num > product.getStockNumber()) isSale = true;
|
||||
} else {
|
||||
if (num > productSku.getSuit()) {
|
||||
if (num > productSku.getStockNumber()) isSale = true;
|
||||
} else {
|
||||
if (productSku.getSuit() > productSku.getStockNumber()) isSale = true;
|
||||
}
|
||||
if (productSku.getSuit() > product.getStockNumber()) isSale = true;
|
||||
}
|
||||
if (isSale) {
|
||||
throw new MsgException("商品起售库存不足");
|
||||
@@ -903,9 +886,9 @@ public class CartService {
|
||||
// 首次下单扣除库存
|
||||
if (StrUtil.isBlank(cart.getOrderId())) {
|
||||
if (tbProduct1.getIsStock() == 1) {
|
||||
productService.updateStock(tbProduct.getProductId(), tbProduct.getId(), cart.getNumber(), true);
|
||||
productService.updateStock(tbProduct.getProductId(), tbProduct.getId(), cart.getNumber());
|
||||
} else {
|
||||
productService.updateStockAndNoCheck(tbProduct.getProductId(), tbProduct.getId(), cart.getNumber(), true);
|
||||
productService.updateStockAndNoCheck(tbProduct.getProductId(), tbProduct.getId(), cart.getNumber());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -83,7 +83,7 @@ public class CloudPrinterService {
|
||||
|
||||
String model = tbPrintMachineWithBLOBs.getPrintMethod();
|
||||
|
||||
String printerNum = StrUtil.isEmpty(tbPrintMachineWithBLOBs.getPrintQty()) ? "1" : tbPrintMachineWithBLOBs.getPrintQty().split("^")[1];
|
||||
String printerNum = StrUtil.isEmpty(tbPrintMachineWithBLOBs.getPrintQty()) ? "1" : tbPrintMachineWithBLOBs.getPrintQty().split("\\^")[1];
|
||||
|
||||
List<CategoryInfo> categoryInfos = JSONUtil.parseJSONStr2TList(StrUtil.emptyToDefault(tbPrintMachineWithBLOBs.getCategoryList(), "[]"), CategoryInfo.class);
|
||||
|
||||
@@ -106,6 +106,90 @@ public class CloudPrinterService {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 仅打印结算单「前台」
|
||||
*/
|
||||
private void onlyFrontDeskForYxy(String orderId, TbPrintMachineWithBLOBs tbPrintMachineWithBLOBs, String model, TbOrderInfo orderInfo, TbShopInfo shopInfo, String printerNum, List<CategoryInfo> categoryInfos) {
|
||||
List<TbCashierCart> cashierCarts = tbCashierCartMapper.selectByOrderId(orderInfo.getId().toString(), "final");
|
||||
if (ObjectUtil.isNotEmpty(cashierCarts) && cashierCarts.size() > 0) {
|
||||
List<OrderDetailPO.Detail> detailList = new ArrayList<>();
|
||||
cashierCarts.parallelStream().forEach(it -> {
|
||||
String categoryId;
|
||||
if (ObjectUtil.isEmpty(it.getCategoryId())) {
|
||||
categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId();
|
||||
} else {
|
||||
categoryId = it.getCategoryId();
|
||||
}
|
||||
|
||||
|
||||
Long count = categoryInfos.stream().filter(c ->
|
||||
c.getId().toString().equals(categoryId)
|
||||
).count();
|
||||
|
||||
if (count > 0) {
|
||||
TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getSkuId()));
|
||||
String remark = "";
|
||||
if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) {
|
||||
remark = tbProductSkuWithBLOBs.getSpecSnap();
|
||||
}
|
||||
|
||||
OrderDetailPO.Detail detail = new OrderDetailPO.Detail(it.getName(), it.getNumber().toString(), it.getTotalAmount().toPlainString(), remark);
|
||||
detailList.add(detail);
|
||||
}
|
||||
});
|
||||
|
||||
String balance = "0";
|
||||
|
||||
if ("deposit".equals(orderInfo.getPayType())) {
|
||||
TbShopUser user = tbShopUserMapper.selectByPrimaryKey(orderInfo.getMemberId());
|
||||
if (ObjectUtil.isNotEmpty(user) && ObjectUtil.isNotEmpty(user.getAmount())) {
|
||||
balance = user.getAmount().toPlainString();
|
||||
}
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(detailList) && detailList.size() > 0) {
|
||||
|
||||
OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印", orderInfo.getTableName(), orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), "【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance, orderInfo.getPayType(), "0", detailList, orderInfo.getRemark());
|
||||
String data = PrinterUtils.getCashPrintData(detailPO, "结算单");
|
||||
PrinterUtils.printTickets(1, Integer.valueOf(printerNum), tbPrintMachineWithBLOBs.getAddress(), data);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 仅打印制作单「厨房」
|
||||
*/
|
||||
private void onlyKitchenForYxy(String orderId, TbPrintMachineWithBLOBs tbPrintMachineWithBLOBs, String model, TbOrderInfo orderInfo, TbShopInfo shopInfo, String printerNum, List<CategoryInfo> categoryInfos) {
|
||||
List<TbCashierCart> cashierCarts = tbCashierCartMapper.selectByOrderId(orderId, "final");
|
||||
if (ObjectUtil.isNotEmpty(cashierCarts) && cashierCarts.size() > 0) {
|
||||
|
||||
cashierCarts.parallelStream().forEach(it -> {
|
||||
|
||||
String categoryId;
|
||||
if (ObjectUtil.isEmpty(it.getCategoryId())) {
|
||||
categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId();
|
||||
} else {
|
||||
categoryId = it.getCategoryId();
|
||||
}
|
||||
|
||||
|
||||
Long count = categoryInfos.stream().filter(c ->
|
||||
c.getId().toString().equals(categoryId)
|
||||
).count();
|
||||
|
||||
if (count > 0) {
|
||||
TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getSkuId()));
|
||||
String remark = "";
|
||||
if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) {
|
||||
remark = tbProductSkuWithBLOBs.getSpecSnap();
|
||||
}
|
||||
String data = PrinterUtils.getPrintData(orderInfo.getTableName(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), it.getName(), it.getNumber(), remark);
|
||||
PrinterUtils.printTickets(1, Integer.valueOf(printerNum), tbPrintMachineWithBLOBs.getAddress(), data);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 博时结云打印机
|
||||
@@ -118,100 +202,159 @@ public class CloudPrinterService {
|
||||
*/
|
||||
private void yxyPrinter(TbPrintMachineWithBLOBs tbPrintMachineWithBLOBs, String model, TbOrderInfo orderInfo, TbShopInfo shopInfo, String printerNum, List<CategoryInfo> categoryInfos) {
|
||||
String orderId = orderInfo.getId().toString();
|
||||
|
||||
|
||||
switch (tbPrintMachineWithBLOBs.getSubType()) {
|
||||
case "label": //标签打印机
|
||||
break;
|
||||
case "cash": //小票打印机
|
||||
switch (model) {
|
||||
case "normal": //普通出单
|
||||
List<TbCashierCart> cashierCarts = tbCashierCartMapper.selectByOrderId(orderInfo.getId().toString(), "final");
|
||||
if (ObjectUtil.isNotEmpty(cashierCarts) && cashierCarts.size() > 0) {
|
||||
List<OrderDetailPO.Detail> detailList = new ArrayList<>();
|
||||
cashierCarts.parallelStream().forEach(it -> {
|
||||
String categoryId;
|
||||
if (ObjectUtil.isEmpty(it.getCategoryId())) {
|
||||
categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId();
|
||||
} else {
|
||||
categoryId = it.getCategoryId();
|
||||
}
|
||||
|
||||
|
||||
Long count = categoryInfos.stream().filter(c ->
|
||||
c.getId().toString().equals(categoryId)
|
||||
).count();
|
||||
|
||||
if (count > 0) {
|
||||
TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getSkuId()));
|
||||
String remark = "";
|
||||
if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) {
|
||||
remark = tbProductSkuWithBLOBs.getSpecSnap();
|
||||
}
|
||||
|
||||
OrderDetailPO.Detail detail = new OrderDetailPO.Detail(it.getName(), it.getNumber().toString(), it.getTotalAmount().toPlainString(), remark);
|
||||
detailList.add(detail);
|
||||
}
|
||||
});
|
||||
|
||||
String balance = "0";
|
||||
|
||||
if ("deposit".equals(orderInfo.getPayType())) {
|
||||
TbShopUser user = tbShopUserMapper.selectByPrimaryKey(orderInfo.getMemberId());
|
||||
if (ObjectUtil.isNotEmpty(user) && ObjectUtil.isNotEmpty(user.getAmount())) {
|
||||
balance = user.getAmount().toPlainString();
|
||||
}
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(detailList) && detailList.size() > 0) {
|
||||
|
||||
OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印", orderInfo.getTableName(), orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), "【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance, orderInfo.getPayType(), "0", detailList, orderInfo.getRemark());
|
||||
String data = PrinterUtils.getCashPrintData(detailPO, "结算单");
|
||||
PrinterUtils.printTickets(1, Integer.valueOf(printerNum), tbPrintMachineWithBLOBs.getAddress(), data);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
break;
|
||||
case "one": //一菜一品
|
||||
cashierCarts = tbCashierCartMapper.selectByOrderId(orderId, "final");
|
||||
if (ObjectUtil.isNotEmpty(cashierCarts) && cashierCarts.size() > 0) {
|
||||
|
||||
cashierCarts.parallelStream().forEach(it -> {
|
||||
|
||||
String categoryId;
|
||||
if (ObjectUtil.isEmpty(it.getCategoryId())) {
|
||||
categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId();
|
||||
} else {
|
||||
categoryId = it.getCategoryId();
|
||||
}
|
||||
|
||||
|
||||
Long count = categoryInfos.stream().filter(c ->
|
||||
c.getId().toString().equals(categoryId)
|
||||
).count();
|
||||
|
||||
if (count > 0) {
|
||||
TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getSkuId()));
|
||||
String remark = "";
|
||||
if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) {
|
||||
remark = tbProductSkuWithBLOBs.getSpecSnap();
|
||||
}
|
||||
String data = PrinterUtils.getPrintData(orderInfo.getTableName(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), it.getName(), it.getNumber(), remark);
|
||||
PrinterUtils.printTickets(1, Integer.valueOf(printerNum), tbPrintMachineWithBLOBs.getAddress(), data);
|
||||
}
|
||||
});
|
||||
}
|
||||
break;
|
||||
case "category": //分类出单
|
||||
break;
|
||||
if ("normal".equals(model)) {
|
||||
onlyFrontDeskForYxy(orderId, tbPrintMachineWithBLOBs, model, orderInfo, shopInfo, printerNum, categoryInfos);
|
||||
} else if ("one".equals(model)) {
|
||||
onlyKitchenForYxy(orderId, tbPrintMachineWithBLOBs, model, orderInfo, shopInfo, printerNum, categoryInfos);
|
||||
} else if ("all".equals(model)) {
|
||||
onlyFrontDeskForYxy(orderId, tbPrintMachineWithBLOBs, model, orderInfo, shopInfo, printerNum, categoryInfos);
|
||||
onlyKitchenForYxy(orderId, tbPrintMachineWithBLOBs, model, orderInfo, shopInfo, printerNum, categoryInfos);
|
||||
}
|
||||
|
||||
break;
|
||||
case "kitchen": //出品打印机
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 仅打印结算单「前台」
|
||||
*/
|
||||
private void onlyFrontDeskForFe(String orderId, TbPrintMachineWithBLOBs tbPrintMachineWithBLOBs, String model, TbOrderInfo orderInfo, TbShopInfo shopInfo, String printerNum, List<CategoryInfo> categoryInfos) {
|
||||
if ("return".equals(orderInfo.getOrderType())) {
|
||||
List<TbOrderDetail> tbOrderDetails = tbOrderDetailMapper.selectAllByOrderId(Integer.valueOf(orderId));
|
||||
if (ObjectUtil.isNotEmpty(tbOrderDetails) && tbOrderDetails.size() > 0) {
|
||||
List<OrderDetailPO.Detail> detailList = new ArrayList<>();
|
||||
tbOrderDetails.parallelStream().forEach(it -> {
|
||||
String categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId();
|
||||
|
||||
Long count = categoryInfos.stream().filter(c ->
|
||||
c.getId().toString().equals(categoryId)
|
||||
).count();
|
||||
log.info("获取当前类别是否未打印类别:{}", count);
|
||||
|
||||
|
||||
TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getProductSkuId()));
|
||||
String remark = "";
|
||||
if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) {
|
||||
remark = tbProductSkuWithBLOBs.getSpecSnap();
|
||||
}
|
||||
OrderDetailPO.Detail detail = new OrderDetailPO.Detail(it.getProductName(), it.getNum().toString(), it.getPriceAmount().toPlainString(), remark);
|
||||
detailList.add(detail);
|
||||
|
||||
});
|
||||
String balance = "0";
|
||||
|
||||
if ("deposit".equals(orderInfo.getPayType())) {
|
||||
TbShopUser user = tbShopUserMapper.selectByPrimaryKey(orderInfo.getMemberId());
|
||||
if (ObjectUtil.isNotEmpty(user) && ObjectUtil.isNotEmpty(user.getAmount())) {
|
||||
balance = user.getAmount().toPlainString();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (ObjectUtil.isNotEmpty(detailList) && detailList.size() > 0) {
|
||||
// OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印", orderInfo.getMasterId(), orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), "【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance, orderInfo.getPayType(), "0", detailList);
|
||||
OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印", ObjectUtil.isEmpty(orderInfo.getMasterId()) || ObjectUtil.isNull(orderInfo.getMasterId()) ? orderInfo.getTableName() : orderInfo.getMasterId(), orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), "【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance, orderInfo.getPayType(), "0", detailList, orderInfo.getRemark());
|
||||
|
||||
String printType = "退款单";
|
||||
|
||||
String data = PrinterUtils.getCashPrintData(detailPO, printType);
|
||||
PrinterUtils.printTickets(1, Integer.valueOf(printerNum), tbPrintMachineWithBLOBs.getAddress(), data);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
List<TbCashierCart> cashierCarts = tbCashierCartMapper.selectByOrderId(orderInfo.getId().toString(), "final");
|
||||
|
||||
if (ObjectUtil.isNotEmpty(cashierCarts) && cashierCarts.size() > 0) {
|
||||
List<OrderDetailPO.Detail> detailList = new ArrayList<>();
|
||||
cashierCarts.parallelStream().forEach(it -> {
|
||||
String categoryId;
|
||||
if (ObjectUtil.isEmpty(it.getCategoryId())) {
|
||||
categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId();
|
||||
} else {
|
||||
categoryId = it.getCategoryId();
|
||||
}
|
||||
|
||||
|
||||
Long count = categoryInfos.stream().filter(c ->
|
||||
c.getId().toString().equals(categoryId)
|
||||
).count();
|
||||
|
||||
if (count > 0) {
|
||||
TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getSkuId()));
|
||||
String remark = "";
|
||||
if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) {
|
||||
remark = tbProductSkuWithBLOBs.getSpecSnap();
|
||||
}
|
||||
OrderDetailPO.Detail detail = new OrderDetailPO.Detail(it.getName(), it.getNumber().toString(), it.getTotalAmount().toPlainString(), remark);
|
||||
detailList.add(detail);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
String balance = "0";
|
||||
|
||||
if ("deposit".equals(orderInfo.getPayType())) {
|
||||
TbShopUser user = tbShopUserMapper.selectByPrimaryKey(orderInfo.getMemberId());
|
||||
if (ObjectUtil.isNotEmpty(user) && ObjectUtil.isNotEmpty(user.getAmount())) {
|
||||
balance = user.getAmount().toPlainString();
|
||||
}
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(detailList) && detailList.size() > 0) {
|
||||
OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印", orderInfo.getOrderType().equals("miniapp") ? orderInfo.getTableName() : orderInfo.getMasterId(), orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), "【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance, (ObjectUtil.isEmpty(orderInfo.getPayType()) || ObjectUtil.isNull(orderInfo.getPayType()) ? "" : orderInfo.getPayType()), "0", detailList, orderInfo.getRemark());
|
||||
String printType = "结算单";
|
||||
|
||||
if ("return".equals(orderInfo.getOrderType())) {
|
||||
printType = "退款单";
|
||||
}
|
||||
|
||||
|
||||
FeieyunPrintUtil.getCashPrintData(detailPO, tbPrintMachineWithBLOBs.getAddress(), printType, printType);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 仅打印制作单「厨房」
|
||||
*/
|
||||
private void onlyKitchenForFe(String orderId, TbPrintMachineWithBLOBs tbPrintMachineWithBLOBs, String model, TbOrderInfo orderInfo, TbShopInfo shopInfo, String printerNum, List<CategoryInfo> categoryInfos) {
|
||||
List<TbCashierCart> cashierCarts = tbCashierCartMapper.selectByOrderId(orderId, "final");
|
||||
if (ObjectUtil.isNotEmpty(cashierCarts) && cashierCarts.size() > 0) {
|
||||
|
||||
cashierCarts.parallelStream().forEach(it -> {
|
||||
|
||||
String categoryId;
|
||||
if (ObjectUtil.isEmpty(it.getCategoryId())) {
|
||||
categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId();
|
||||
} else {
|
||||
categoryId = it.getCategoryId();
|
||||
}
|
||||
|
||||
|
||||
Long count = categoryInfos.stream().filter(c ->
|
||||
c.getId().toString().equals(categoryId)
|
||||
).count();
|
||||
|
||||
if (count > 0) {
|
||||
TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getSkuId()));
|
||||
String remark = "";
|
||||
if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) {
|
||||
remark = tbProductSkuWithBLOBs.getSpecSnap();
|
||||
}
|
||||
FeieyunPrintUtil.getPrintData(tbPrintMachineWithBLOBs.getAddress(), orderInfo.getTableName(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), it.getName(), it.getNumber(), remark);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void fePrinter(TbPrintMachineWithBLOBs tbPrintMachineWithBLOBs, String model, TbOrderInfo orderInfo, TbShopInfo shopInfo, String printerNum, List<CategoryInfo> categoryInfos) {
|
||||
String orderId = orderInfo.getId().toString();
|
||||
@@ -251,136 +394,13 @@ public class CloudPrinterService {
|
||||
|
||||
break;
|
||||
case "cash": //小票打印机
|
||||
switch (model) {
|
||||
case "normal": //普通出单
|
||||
|
||||
if ("return".equals(orderInfo.getOrderType())) {
|
||||
List<TbOrderDetail> tbOrderDetails = tbOrderDetailMapper.selectAllByOrderId(Integer.valueOf(orderId));
|
||||
if (ObjectUtil.isNotEmpty(tbOrderDetails) && tbOrderDetails.size() > 0) {
|
||||
List<OrderDetailPO.Detail> detailList = new ArrayList<>();
|
||||
tbOrderDetails.parallelStream().forEach(it -> {
|
||||
String categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId();
|
||||
|
||||
Long count = categoryInfos.stream().filter(c ->
|
||||
c.getId().toString().equals(categoryId)
|
||||
).count();
|
||||
log.info("获取当前类别是否未打印类别:{}", count);
|
||||
|
||||
|
||||
TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getProductSkuId()));
|
||||
String remark = "";
|
||||
if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) {
|
||||
remark = tbProductSkuWithBLOBs.getSpecSnap();
|
||||
}
|
||||
OrderDetailPO.Detail detail = new OrderDetailPO.Detail(it.getProductName(), it.getNum().toString(), it.getPriceAmount().toPlainString(), remark);
|
||||
detailList.add(detail);
|
||||
|
||||
});
|
||||
String balance = "0";
|
||||
|
||||
if ("deposit".equals(orderInfo.getPayType())) {
|
||||
TbShopUser user = tbShopUserMapper.selectByPrimaryKey(orderInfo.getMemberId());
|
||||
if (ObjectUtil.isNotEmpty(user) && ObjectUtil.isNotEmpty(user.getAmount())) {
|
||||
balance = user.getAmount().toPlainString();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (ObjectUtil.isNotEmpty(detailList) && detailList.size() > 0) {
|
||||
// OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印", orderInfo.getMasterId(), orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), "【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance, orderInfo.getPayType(), "0", detailList);
|
||||
OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印", ObjectUtil.isEmpty(orderInfo.getMasterId()) || ObjectUtil.isNull(orderInfo.getMasterId()) ? orderInfo.getTableName() : orderInfo.getMasterId(), orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), "【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance, orderInfo.getPayType(), "0", detailList, orderInfo.getRemark());
|
||||
|
||||
String printType = "退款单";
|
||||
|
||||
String data = PrinterUtils.getCashPrintData(detailPO, printType);
|
||||
PrinterUtils.printTickets(1, Integer.valueOf(printerNum), tbPrintMachineWithBLOBs.getAddress(), data);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
cashierCarts = cashierCarts = tbCashierCartMapper.selectByOrderId(orderInfo.getId().toString(), "final");
|
||||
|
||||
if (ObjectUtil.isNotEmpty(cashierCarts) && cashierCarts.size() > 0) {
|
||||
List<OrderDetailPO.Detail> detailList = new ArrayList<>();
|
||||
cashierCarts.parallelStream().forEach(it -> {
|
||||
String categoryId;
|
||||
if (ObjectUtil.isEmpty(it.getCategoryId())) {
|
||||
categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId();
|
||||
} else {
|
||||
categoryId = it.getCategoryId();
|
||||
}
|
||||
|
||||
|
||||
Long count = categoryInfos.stream().filter(c ->
|
||||
c.getId().toString().equals(categoryId)
|
||||
).count();
|
||||
|
||||
if (count > 0) {
|
||||
TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getSkuId()));
|
||||
String remark = "";
|
||||
if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) {
|
||||
remark = tbProductSkuWithBLOBs.getSpecSnap();
|
||||
}
|
||||
OrderDetailPO.Detail detail = new OrderDetailPO.Detail(it.getName(), it.getNumber().toString(), it.getTotalAmount().toPlainString(), remark);
|
||||
detailList.add(detail);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
String balance = "0";
|
||||
|
||||
if ("deposit".equals(orderInfo.getPayType())) {
|
||||
TbShopUser user = tbShopUserMapper.selectByPrimaryKey(orderInfo.getMemberId());
|
||||
if (ObjectUtil.isNotEmpty(user) && ObjectUtil.isNotEmpty(user.getAmount())) {
|
||||
balance = user.getAmount().toPlainString();
|
||||
}
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(detailList) && detailList.size() > 0) {
|
||||
OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印", orderInfo.getOrderType().equals("miniapp") ? orderInfo.getTableName() : orderInfo.getMasterId(), orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), "【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance, (ObjectUtil.isEmpty(orderInfo.getPayType()) || ObjectUtil.isNull(orderInfo.getPayType()) ? "" : orderInfo.getPayType()), "0", detailList, orderInfo.getRemark());
|
||||
String printType = "结算单";
|
||||
|
||||
if ("return".equals(orderInfo.getOrderType())) {
|
||||
printType = "退款单";
|
||||
}
|
||||
|
||||
|
||||
FeieyunPrintUtil.getCashPrintData(detailPO, tbPrintMachineWithBLOBs.getAddress(), printType, printType);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
case "one": //一菜一品
|
||||
|
||||
cashierCarts = tbCashierCartMapper.selectByOrderId(orderId, "final");
|
||||
if (ObjectUtil.isNotEmpty(cashierCarts) && cashierCarts.size() > 0) {
|
||||
|
||||
cashierCarts.parallelStream().forEach(it -> {
|
||||
|
||||
String categoryId;
|
||||
if (ObjectUtil.isEmpty(it.getCategoryId())) {
|
||||
categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId();
|
||||
} else {
|
||||
categoryId = it.getCategoryId();
|
||||
}
|
||||
|
||||
|
||||
Long count = categoryInfos.stream().filter(c ->
|
||||
c.getId().toString().equals(categoryId)
|
||||
).count();
|
||||
|
||||
if (count > 0) {
|
||||
TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getSkuId()));
|
||||
String remark = "";
|
||||
if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) {
|
||||
remark = tbProductSkuWithBLOBs.getSpecSnap();
|
||||
}
|
||||
FeieyunPrintUtil.getPrintData(tbPrintMachineWithBLOBs.getAddress(), orderInfo.getTableName(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), it.getName(), it.getNumber(), remark);
|
||||
}
|
||||
});
|
||||
}
|
||||
if ("normal".equals(model)) {
|
||||
onlyFrontDeskForFe(orderId, tbPrintMachineWithBLOBs, model, orderInfo, shopInfo, printerNum, categoryInfos);
|
||||
} else if ("one".equals(model)) {
|
||||
onlyKitchenForFe(orderId, tbPrintMachineWithBLOBs, model, orderInfo, shopInfo, printerNum, categoryInfos);
|
||||
} else if ("all".equals(model)) {
|
||||
onlyFrontDeskForFe(orderId, tbPrintMachineWithBLOBs, model, orderInfo, shopInfo, printerNum, categoryInfos);
|
||||
onlyKitchenForFe(orderId, tbPrintMachineWithBLOBs, model, orderInfo, shopInfo, printerNum, categoryInfos);
|
||||
}
|
||||
break;
|
||||
case "kitchen": //出品打印机
|
||||
|
||||
@@ -8,8 +8,8 @@ import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.chaozhanggui.system.cashierservice.dao.*;
|
||||
import com.chaozhanggui.system.cashierservice.entity.*;
|
||||
import com.chaozhanggui.system.cashierservice.entity.Enum.OrderUseTypeEnum;
|
||||
import com.chaozhanggui.system.cashierservice.entity.*;
|
||||
import com.chaozhanggui.system.cashierservice.entity.dto.ReturnGroupOrderDto;
|
||||
import com.chaozhanggui.system.cashierservice.entity.dto.ShopEatTypeInfoDTO;
|
||||
import com.chaozhanggui.system.cashierservice.entity.vo.ShopUserListVo;
|
||||
@@ -1064,7 +1064,7 @@ public class PayService {
|
||||
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public String callBackPayFST(String payOrderNO) {
|
||||
public String callBackPayFST(String payOrderNO,String payType) {
|
||||
TbOrderInfo orderInfo = tbOrderInfoMapper.selectByPayOrderNo(payOrderNO);
|
||||
if (ObjectUtil.isEmpty(orderInfo)) {
|
||||
return "订单信息不存在";
|
||||
@@ -1089,7 +1089,7 @@ public class PayService {
|
||||
|
||||
//修改主单状态
|
||||
orderInfo.setStatus("closed");
|
||||
orderInfo.setPayType("wx_lite");
|
||||
orderInfo.setPayType(payType);
|
||||
orderInfo.setPayOrderNo(payOrderNO);
|
||||
orderInfo.setPayAmount(orderInfo.getOrderAmount());
|
||||
orderInfo.setPaidTime(System.currentTimeMillis());
|
||||
|
||||
@@ -403,7 +403,7 @@ public class ProductService {
|
||||
spec.put("isGrounding", true);
|
||||
TbProductSku sku = (TbProductSku) spec.get("info");
|
||||
if (sku != null) {
|
||||
tbProduct.setIsPauseSale(tbProduct.getIsDistribute() == 1 ? tbProduct.getIsPauseSale() : sku.getIsPauseSale().byteValue());
|
||||
tbProduct.setIsPauseSale(sku.getIsPauseSale().byteValue());
|
||||
checkPauseSale(tbProduct, new ArrayList<>(Collections.singletonList(sku)), true);
|
||||
spec.put("isPauseSale", tbProduct.getIsPauseSale());
|
||||
}else {
|
||||
@@ -420,7 +420,7 @@ public class ProductService {
|
||||
itemMap.put("isGrounding", false);
|
||||
TbProductSku sku = unGroundingMap.get("specSnap");
|
||||
if (sku != null) {
|
||||
tbProduct.setIsPauseSale(tbProduct.getIsDistribute() == 1 ? tbProduct.getIsPauseSale() : sku.getIsPauseSale().byteValue());
|
||||
tbProduct.setIsPauseSale(sku.getIsPauseSale().byteValue());
|
||||
checkPauseSale(tbProduct, Collections.singletonList(sku), true);
|
||||
itemMap.put("isPauseSale", tbProduct.getIsPauseSale());
|
||||
}else {
|
||||
@@ -508,34 +508,14 @@ public class ProductService {
|
||||
|
||||
public void checkPauseSale(TbProduct tbProduct, List<TbProductSku> skus, boolean isSingle) {
|
||||
if (tbProduct.getIsStock() == 1) {//库存开关 1开启
|
||||
// if (Integer.valueOf(tbProduct.getIsDistribute()).equals(1)) {//共享库存 1开启
|
||||
if (tbProduct.getStockNumber() != null && tbProduct.getStockNumber() <= 0) {
|
||||
tbProduct.setIsPauseSale(Byte.parseByte("1"));//售罄 1暂停
|
||||
return;
|
||||
}
|
||||
if (tbProduct.getStockNumber() != null && tbProduct.getStockNumber() <= 0) {
|
||||
tbProduct.setIsPauseSale(Byte.parseByte("1"));//售罄 1暂停
|
||||
return;
|
||||
}
|
||||
|
||||
if (isSingle && tbProduct.getIsPauseSale() == 1) {
|
||||
return;
|
||||
}
|
||||
// } else {
|
||||
// if (isSingle && !skus.stream().filter(res -> res.getIsPauseSale().equals(1)).collect(Collectors.toList()).isEmpty()) {
|
||||
// tbProduct.setIsPauseSale(Byte.parseByte("1"));//售罄 1暂停
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// if (!tbProduct.getTypeEnum().equals("sku")) {
|
||||
// if (skus.stream().anyMatch(sku -> sku.getStockNumber() != null && sku.getStockNumber() <= 0)){
|
||||
// tbProduct.setIsPauseSale(Byte.parseByte("1"));//售罄 1暂停
|
||||
// return;
|
||||
// }
|
||||
// } else {
|
||||
// skus.removeIf(sku -> sku.getStockNumber() != null && sku.getStockNumber() <= 0);
|
||||
// if (CollectionUtils.isEmpty(skus)) {
|
||||
// tbProduct.setIsPauseSale(Byte.parseByte("1"));//售罄 1暂停
|
||||
// return;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
if (isSingle && tbProduct.getIsPauseSale() == 1) {
|
||||
return;
|
||||
}
|
||||
Iterator<TbProductSku> iterator = skus.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
TbProductSku tbProductSku = iterator.next();
|
||||
@@ -855,38 +835,20 @@ public class ProductService {
|
||||
* @param buyNum 购买数量
|
||||
*/
|
||||
public void updateStock(TbProduct tbProduct, TbProductSkuWithBLOBs tbProductSkuWithBLOBs, Integer buyNum) {
|
||||
if (tbProduct.getIsDistribute() == 1) {
|
||||
if (tbProductMapper.decrStock(String.valueOf(tbProduct.getId()), buyNum) < 1) {
|
||||
throw new MsgException("库存修改失败,请稍后再试");
|
||||
}
|
||||
} else {
|
||||
if (tbProductSkuMapper.decrStock(String.valueOf(tbProductSkuWithBLOBs.getId()), buyNum) < 1) {
|
||||
throw new MsgException("库存修改失败,请稍后再试");
|
||||
}
|
||||
if (tbProductMapper.decrStock(String.valueOf(tbProduct.getId()), buyNum) < 1) {
|
||||
throw new MsgException("库存修改失败,请稍后再试");
|
||||
}
|
||||
}
|
||||
|
||||
public void updateStock(String id, Integer skuId, Integer buyNum, boolean isDistribute) {
|
||||
if (isDistribute) {
|
||||
if (tbProductMapper.decrStock(String.valueOf(id), buyNum) < 1) {
|
||||
throw new MsgException("库存不足,下单失败");
|
||||
}
|
||||
} else {
|
||||
if (tbProductSkuMapper.decrStock(String.valueOf(skuId), buyNum) < 1) {
|
||||
throw new MsgException("库存不足,下单失败");
|
||||
}
|
||||
public void updateStock(String id, Integer skuId, Integer buyNum) {
|
||||
if (tbProductMapper.decrStock(String.valueOf(id), buyNum) < 1) {
|
||||
throw new MsgException("库存不足,下单失败");
|
||||
}
|
||||
}
|
||||
|
||||
public void updateStockAndNoCheck(String id, Integer skuId, Integer buyNum, boolean isDistribute) {
|
||||
if (isDistribute) {
|
||||
if (tbProductMapper.decrStockUnCheck(String.valueOf(id), buyNum) < 1) {
|
||||
throw new MsgException("库存不足,下单失败");
|
||||
}
|
||||
} else {
|
||||
if (tbProductSkuMapper.decrStockUnCheck(String.valueOf(skuId), buyNum) < 1) {
|
||||
throw new MsgException("库存不足,下单失败");
|
||||
}
|
||||
public void updateStockAndNoCheck(String id, Integer skuId, Integer buyNum) {
|
||||
if (tbProductMapper.decrStockUnCheck(String.valueOf(id), buyNum) < 1) {
|
||||
throw new MsgException("库存不足,下单失败");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
|
||||
<select id="queryVipPro" resultType="com.chaozhanggui.system.cashierservice.entity.vo.UserCouponVo">
|
||||
SELECT tb_product.NAME AS detail,
|
||||
tb_activate_out_record.order_id as orderId,
|
||||
1 AS status,
|
||||
tb_activate_out_record.use_num AS num,
|
||||
<choose>
|
||||
|
||||
@@ -31,7 +31,6 @@
|
||||
<result column="is_on_sale" jdbcType="TINYINT" property="isOnSale" />
|
||||
<result column="is_show" jdbcType="TINYINT" property="isShow" />
|
||||
<result column="type_enum" jdbcType="VARCHAR" property="typeEnum" />
|
||||
<result column="is_distribute" jdbcType="TINYINT" property="isDistribute" />
|
||||
<result column="is_del" jdbcType="TINYINT" property="isDel" />
|
||||
<result column="is_stock" jdbcType="TINYINT" property="isStock" />
|
||||
<result column="is_pause_sale" jdbcType="TINYINT" property="isPauseSale" />
|
||||
@@ -110,7 +109,7 @@
|
||||
sort, limit_number, product_score,
|
||||
status, fail_msg, is_recommend,
|
||||
is_hot, is_new, is_on_sale,
|
||||
is_show, type_enum, is_distribute,
|
||||
is_show, type_enum,
|
||||
is_del, is_stock, is_pause_sale,
|
||||
is_free_freight, freight_id, strategy_type,
|
||||
strategy_id, is_vip, is_delete,
|
||||
@@ -133,7 +132,7 @@
|
||||
#{sort,jdbcType=INTEGER}, #{limitNumber,jdbcType=INTEGER}, #{productScore,jdbcType=INTEGER},
|
||||
#{status,jdbcType=TINYINT}, #{failMsg,jdbcType=VARCHAR}, #{isRecommend,jdbcType=TINYINT},
|
||||
#{isHot,jdbcType=TINYINT}, #{isNew,jdbcType=TINYINT}, #{isOnSale,jdbcType=TINYINT},
|
||||
#{isShow,jdbcType=TINYINT}, #{typeEnum,jdbcType=VARCHAR}, #{isDistribute,jdbcType=TINYINT},
|
||||
#{isShow,jdbcType=TINYINT}, #{typeEnum,jdbcType=VARCHAR},
|
||||
#{isDel,jdbcType=TINYINT}, #{isStock,jdbcType=TINYINT}, #{isPauseSale,jdbcType=TINYINT},
|
||||
#{isFreeFreight,jdbcType=TINYINT}, #{freightId,jdbcType=BIGINT}, #{strategyType,jdbcType=VARCHAR},
|
||||
#{strategyId,jdbcType=INTEGER}, #{isVip,jdbcType=TINYINT}, #{isDelete,jdbcType=TINYINT},
|
||||
@@ -239,9 +238,6 @@
|
||||
<if test="typeEnum != null">
|
||||
type_enum,
|
||||
</if>
|
||||
<if test="isDistribute != null">
|
||||
is_distribute,
|
||||
</if>
|
||||
<if test="isDel != null">
|
||||
is_del,
|
||||
</if>
|
||||
@@ -448,9 +444,6 @@
|
||||
<if test="typeEnum != null">
|
||||
#{typeEnum,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="isDistribute != null">
|
||||
#{isDistribute,jdbcType=TINYINT},
|
||||
</if>
|
||||
<if test="isDel != null">
|
||||
#{isDel,jdbcType=TINYINT},
|
||||
</if>
|
||||
@@ -657,9 +650,6 @@
|
||||
<if test="typeEnum != null">
|
||||
type_enum = #{typeEnum,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="isDistribute != null">
|
||||
is_distribute = #{isDistribute,jdbcType=TINYINT},
|
||||
</if>
|
||||
<if test="isDel != null">
|
||||
is_del = #{isDel,jdbcType=TINYINT},
|
||||
</if>
|
||||
@@ -810,7 +800,6 @@
|
||||
is_on_sale = #{isOnSale,jdbcType=TINYINT},
|
||||
is_show = #{isShow,jdbcType=TINYINT},
|
||||
type_enum = #{typeEnum,jdbcType=VARCHAR},
|
||||
is_distribute = #{isDistribute,jdbcType=TINYINT},
|
||||
is_del = #{isDel,jdbcType=TINYINT},
|
||||
is_stock = #{isStock,jdbcType=TINYINT},
|
||||
is_pause_sale = #{isPauseSale,jdbcType=TINYINT},
|
||||
@@ -882,7 +871,6 @@
|
||||
is_on_sale = #{isOnSale,jdbcType=TINYINT},
|
||||
is_show = #{isShow,jdbcType=TINYINT},
|
||||
type_enum = #{typeEnum,jdbcType=VARCHAR},
|
||||
is_distribute = #{isDistribute,jdbcType=TINYINT},
|
||||
is_del = #{isDel,jdbcType=TINYINT},
|
||||
is_stock = #{isStock,jdbcType=TINYINT},
|
||||
is_pause_sale = #{isPauseSale,jdbcType=TINYINT},
|
||||
|
||||
Reference in New Issue
Block a user