1.打票增加代客下单重复校验
This commit is contained in:
@@ -8,10 +8,7 @@ import com.chaozhanggui.system.cashierservice.model.CategoryInfo;
|
|||||||
import com.chaozhanggui.system.cashierservice.model.OrderDetailPO;
|
import com.chaozhanggui.system.cashierservice.model.OrderDetailPO;
|
||||||
import com.chaozhanggui.system.cashierservice.sign.CodeEnum;
|
import com.chaozhanggui.system.cashierservice.sign.CodeEnum;
|
||||||
import com.chaozhanggui.system.cashierservice.sign.Result;
|
import com.chaozhanggui.system.cashierservice.sign.Result;
|
||||||
import com.chaozhanggui.system.cashierservice.util.DateUtils;
|
import com.chaozhanggui.system.cashierservice.util.*;
|
||||||
import com.chaozhanggui.system.cashierservice.util.FeieyunPrintUtil;
|
|
||||||
import com.chaozhanggui.system.cashierservice.util.JSONUtil;
|
|
||||||
import com.chaozhanggui.system.cashierservice.util.PrinterUtils;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
|
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
|
||||||
import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
||||||
@@ -49,6 +46,9 @@ public class PrintMechineConsumer {
|
|||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private TbOrderDetailMapper tbOrderDetailMapper;
|
private TbOrderDetailMapper tbOrderDetailMapper;
|
||||||
|
@Autowired
|
||||||
|
|
||||||
|
private RedisUtil redisUtils;
|
||||||
|
|
||||||
@RabbitHandler
|
@RabbitHandler
|
||||||
public void listener(String message) {
|
public void listener(String message) {
|
||||||
@@ -127,7 +127,8 @@ public class PrintMechineConsumer {
|
|||||||
* @param shopInfo
|
* @param shopInfo
|
||||||
* @param printerNum
|
* @param printerNum
|
||||||
*/
|
*/
|
||||||
private void yxyPrinter(TbPrintMachineWithBLOBs tbPrintMachineWithBLOBs,String model,TbOrderInfo orderInfo,TbShopInfo shopInfo,String printerNum, List<CategoryInfo> categoryInfos){
|
private void yxyPrinter(TbPrintMachineWithBLOBs tbPrintMachineWithBLOBs,String model,
|
||||||
|
TbOrderInfo orderInfo,TbShopInfo shopInfo,String printerNum, List<CategoryInfo> categoryInfos){
|
||||||
String orderId=orderInfo.getId().toString();
|
String orderId=orderInfo.getId().toString();
|
||||||
|
|
||||||
|
|
||||||
@@ -257,10 +258,13 @@ public class PrintMechineConsumer {
|
|||||||
return;
|
return;
|
||||||
}else {
|
}else {
|
||||||
tbOrderDetails = tbOrderDetailMapper.selectAllByOrderId(Integer.valueOf(orderId));
|
tbOrderDetails = tbOrderDetailMapper.selectAllByOrderId(Integer.valueOf(orderId));
|
||||||
if (ObjectUtil.isNotEmpty(tbOrderDetails) && tbOrderDetails.size() > 0) {
|
if (ObjectUtil.isNotEmpty(tbOrderDetails) && !tbOrderDetails.isEmpty()) {
|
||||||
|
|
||||||
tbOrderDetails.parallelStream().forEach(it -> {
|
tbOrderDetails.parallelStream().forEach(it -> {
|
||||||
|
// 已经打印过的菜品不再打印
|
||||||
|
if ("postPay".equals(orderInfo.getUseType()) && isPrint(it.getId())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
String categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId();
|
String categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId();
|
||||||
|
|
||||||
Long count = categoryInfos.stream().filter(c ->
|
Long count = categoryInfos.stream().filter(c ->
|
||||||
@@ -294,6 +298,20 @@ public class PrintMechineConsumer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 判断商品是否已打票
|
||||||
|
* @param orderDetailId 订单详情id
|
||||||
|
* @return true 已打 false 未打
|
||||||
|
*/
|
||||||
|
private boolean isPrint(Integer orderDetailId) {
|
||||||
|
Object info = redisUtils.getMessage(RedisCst.ORDER_PRINT + orderDetailId);
|
||||||
|
if (info == null) {
|
||||||
|
redisUtils.saveMessage(RedisCst.ORDER_PRINT + orderDetailId, "1", 60 * 60 * 24);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -20,4 +20,5 @@ public class RedisCst {
|
|||||||
public static final String ORDER_MESSAGE="ORDER:MESSAGE:";
|
public static final String ORDER_MESSAGE="ORDER:MESSAGE:";
|
||||||
public static final String ORDER_PRODUCT_NUM = "ORDER_NUM:";
|
public static final String ORDER_PRODUCT_NUM = "ORDER_NUM:";
|
||||||
public static final String ORDER_CART_EXISTS = "ORDER_CART_EXISTS:";
|
public static final String ORDER_CART_EXISTS = "ORDER_CART_EXISTS:";
|
||||||
|
public static final String ORDER_PRINT = "ORDER_PRINT:";
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user