1.代客下单 商品数量减少增加打印退单票据
This commit is contained in:
@@ -0,0 +1,6 @@
|
|||||||
|
package com.chaozhanggui.system.cashierservice.bean;
|
||||||
|
|
||||||
|
public class PrintProductInfo {
|
||||||
|
private Integer orderDetailId;
|
||||||
|
private Integer num;
|
||||||
|
}
|
||||||
@@ -34,6 +34,15 @@ public class TbPrintMachine implements Serializable {
|
|||||||
private String vendorId;
|
private String vendorId;
|
||||||
|
|
||||||
private String productId;
|
private String productId;
|
||||||
|
private String config;
|
||||||
|
|
||||||
|
public String getConfig() {
|
||||||
|
return config;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setConfig(String config) {
|
||||||
|
this.config = config;
|
||||||
|
}
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
package com.chaozhanggui.system.cashierservice.mybatis;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.chaozhanggui.system.cashierservice.entity.TbCashierCart;
|
||||||
|
import com.chaozhanggui.system.cashierservice.entity.TbPrintMachine;
|
||||||
|
|
||||||
|
public interface MpPrintMachineMapper extends BaseMapper<TbPrintMachine> {
|
||||||
|
}
|
||||||
@@ -3,24 +3,25 @@ package com.chaozhanggui.system.cashierservice.rabbit;
|
|||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||||
import com.chaozhanggui.system.cashierservice.dao.*;
|
import com.chaozhanggui.system.cashierservice.dao.*;
|
||||||
import com.chaozhanggui.system.cashierservice.entity.*;
|
import com.chaozhanggui.system.cashierservice.entity.*;
|
||||||
import com.chaozhanggui.system.cashierservice.model.CategoryInfo;
|
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.mybatis.MpPrintMachineMapper;
|
||||||
import com.chaozhanggui.system.cashierservice.sign.Result;
|
|
||||||
import com.chaozhanggui.system.cashierservice.util.*;
|
import com.chaozhanggui.system.cashierservice.util.*;
|
||||||
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;
|
||||||
import org.springframework.amqp.rabbit.annotation.RabbitListeners;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.data.redis.core.RedisTemplate;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.Date;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.List;
|
import java.util.concurrent.atomic.AtomicReference;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Component
|
@Component
|
||||||
@@ -51,6 +52,14 @@ public class PrintMechineConsumer {
|
|||||||
|
|
||||||
private RedisUtil redisUtils;
|
private RedisUtil redisUtils;
|
||||||
|
|
||||||
|
private final RedisTemplate<String, Object> redisTemplate;
|
||||||
|
@Autowired
|
||||||
|
private MpPrintMachineMapper mpPrintMachineMapper;
|
||||||
|
|
||||||
|
public PrintMechineConsumer(RedisTemplate<String, Object> redisTemplate) {
|
||||||
|
this.redisTemplate = redisTemplate;
|
||||||
|
}
|
||||||
|
|
||||||
@RabbitHandler
|
@RabbitHandler
|
||||||
public void listener(String message) {
|
public void listener(String message) {
|
||||||
|
|
||||||
@@ -114,7 +123,6 @@ public class PrintMechineConsumer {
|
|||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
@@ -123,6 +131,7 @@ public class PrintMechineConsumer {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 博时结云打印机
|
* 博时结云打印机
|
||||||
|
*
|
||||||
* @param tbPrintMachineWithBLOBs
|
* @param tbPrintMachineWithBLOBs
|
||||||
* @param model
|
* @param model
|
||||||
* @param orderInfo
|
* @param orderInfo
|
||||||
@@ -238,7 +247,7 @@ public class PrintMechineConsumer {
|
|||||||
String data = PrinterUtils.getCashPrintData(detailPO, printType, orderInfo.getOrderType());
|
String data = PrinterUtils.getCashPrintData(detailPO, printType, orderInfo.getOrderType());
|
||||||
String voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔新的订单,请及时处理\"}";
|
String voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔新的订单,请及时处理\"}";
|
||||||
|
|
||||||
PrinterUtils.printTickets(voiceJson, 3, Integer.valueOf(printerNum), tbPrintMachineWithBLOBs.getAddress(), data);
|
PrinterUtils.printTickets(voiceJson, 3, 1, tbPrintMachineWithBLOBs.getAddress(), data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -270,8 +279,11 @@ public class PrintMechineConsumer {
|
|||||||
private void printTicket(Integer orderId, List<CategoryInfo> categoryInfos, TbPrintMachineWithBLOBs tbPrintMachineWithBLOBs, TbOrderInfo orderInfo) {
|
private void printTicket(Integer orderId, List<CategoryInfo> categoryInfos, TbPrintMachineWithBLOBs tbPrintMachineWithBLOBs, TbOrderInfo orderInfo) {
|
||||||
List<TbOrderDetail> tbOrderDetails = tbOrderDetailMapper.selectAllByOrderId(orderId);
|
List<TbOrderDetail> tbOrderDetails = tbOrderDetailMapper.selectAllByOrderId(orderId);
|
||||||
if (!tbOrderDetails.isEmpty()) {
|
if (!tbOrderDetails.isEmpty()) {
|
||||||
|
String printKey = RedisCst.ORDER_PRINT_PRO + orderId;
|
||||||
tbOrderDetails.parallelStream().forEach(it -> {
|
AtomicReference<Set<Object>> printProductSet = new AtomicReference<>(redisTemplate.opsForSet().members(printKey));
|
||||||
|
// 重置打印数据
|
||||||
|
redisTemplate.delete(printKey);
|
||||||
|
tbOrderDetails.forEach(it -> {
|
||||||
log.info("开始打印一菜一品票据,:{}", it.getProductName());
|
log.info("开始打印一菜一品票据,:{}", it.getProductName());
|
||||||
String categoryId = tbProductMapper.selectByPrimaryKey(it.getProductId()).getCategoryId();
|
String categoryId = tbProductMapper.selectByPrimaryKey(it.getProductId()).getCategoryId();
|
||||||
|
|
||||||
@@ -288,21 +300,40 @@ public class PrintMechineConsumer {
|
|||||||
String key = RedisCst.ORDER_PRINT + orderId + ":" + it.getProductId() + ":" + it.getProductSkuId();
|
String key = RedisCst.ORDER_PRINT + orderId + ":" + it.getProductId() + ":" + it.getProductSkuId();
|
||||||
String info = redisUtils.getMessage(key);
|
String info = redisUtils.getMessage(key);
|
||||||
redisUtils.saveMessage(key, String.valueOf(it.getNum()), 60 * 60 * 24);
|
redisUtils.saveMessage(key, String.valueOf(it.getNum()), 60 * 60 * 24);
|
||||||
|
|
||||||
|
// 删除已打印数据
|
||||||
|
if (printProductSet.get() != null) {
|
||||||
|
printProductSet.set(printProductSet.get().stream().filter(r -> {
|
||||||
|
TbOrderDetail detail = (TbOrderDetail) r;
|
||||||
|
return !detail.getProductSkuId().equals(it.getProductSkuId()) || !detail.getProductId().equals(it.getProductId());
|
||||||
|
}).collect(Collectors.toSet()));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (info != null) {
|
if (info != null) {
|
||||||
isReturn = it.getNum() - Integer.parseInt(info) < 0;
|
isReturn = it.getNum() - Integer.parseInt(info) < 0;
|
||||||
|
printerNum = it.getNum() - Integer.parseInt(info);
|
||||||
|
}else {
|
||||||
|
printerNum = it.getNum();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(it.getProductSkuId());
|
||||||
|
String remark = "";
|
||||||
|
if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) {
|
||||||
|
remark = tbProductSkuWithBLOBs.getSpecSnap();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 将已打印信息加入redis
|
||||||
|
it.setRemark(remark);
|
||||||
|
redisTemplate.opsForSet().add(printKey, it);
|
||||||
|
redisTemplate.expire(printKey, 24, TimeUnit.HOURS);
|
||||||
|
|
||||||
// 已打印不再打印
|
// 已打印不再打印
|
||||||
if (info != null && it.getNum() - Integer.parseInt(info) == 0) {
|
if (info != null && it.getNum() - Integer.parseInt(info) == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getProductSkuId()));
|
|
||||||
String remark = "";
|
|
||||||
if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) {
|
|
||||||
remark = tbProductSkuWithBLOBs.getSpecSnap();
|
|
||||||
}
|
|
||||||
|
|
||||||
String data;
|
String data;
|
||||||
String voiceJson;
|
String voiceJson;
|
||||||
if (isReturn) {
|
if (isReturn) {
|
||||||
@@ -311,7 +342,7 @@ public class PrintMechineConsumer {
|
|||||||
StrUtil.isBlank(orderInfo.getTableName()) ? orderInfo.getMasterId() : orderInfo.getTableName(),
|
StrUtil.isBlank(orderInfo.getTableName()) ? orderInfo.getMasterId() : orderInfo.getTableName(),
|
||||||
DateUtils.getTime(new Date(orderInfo.getCreatedAt())), it.getProductName(), it.getNum(), remark);
|
DateUtils.getTime(new Date(orderInfo.getCreatedAt())), it.getProductName(), it.getNum(), remark);
|
||||||
voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔退款订单,请及时处理\"}";
|
voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔退款订单,请及时处理\"}";
|
||||||
PrinterUtils.printTickets(voiceJson,3, 2, tbPrintMachineWithBLOBs.getAddress(), data);
|
PrinterUtils.printTickets(voiceJson, 3, 1, tbPrintMachineWithBLOBs.getAddress(), data);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
data = PrinterUtils.getPrintData("", orderInfo.getMasterId(),
|
data = PrinterUtils.getPrintData("", orderInfo.getMasterId(),
|
||||||
@@ -322,14 +353,101 @@ public class PrintMechineConsumer {
|
|||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
// PrinterUtils.printTickets(voiceJson,3, printerNum, tbPrintMachineWithBLOBs.getAddress(), data);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
// 已删除的商品打印退款信息
|
||||||
|
if (printProductSet.get() != null) {
|
||||||
|
printProductSet.get().forEach(item -> {
|
||||||
|
log.info("已删除订单,打印退款票据, {}", item);
|
||||||
|
TbOrderDetail orderDetail = (TbOrderDetail) item;
|
||||||
|
String data = PrinterUtils.getPrintData("return",
|
||||||
|
StrUtil.isBlank(orderInfo.getTableName()) ? orderInfo.getMasterId() : orderInfo.getTableName(),
|
||||||
|
DateUtils.getTime(new Date(orderInfo.getCreatedAt())), orderDetail.getProductName(), orderDetail.getNum(), orderDetail.getRemark());
|
||||||
|
String voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔退款订单,请及时处理\"}";
|
||||||
|
PrinterUtils.printTickets(voiceJson, 3, 1, tbPrintMachineWithBLOBs.getAddress(), data);
|
||||||
|
|
||||||
|
String key = RedisCst.ORDER_PRINT + orderId + ":" + orderDetail.getProductId() + ":" + orderDetail.getProductSkuId();
|
||||||
|
log.info("删除商品数量记录key, {}", key);
|
||||||
|
redisUtils.deleteByKey(key);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 打印退款订单
|
||||||
|
* @param orderId 订单id
|
||||||
|
* @param tbOrderDetails 现有订单
|
||||||
|
*/
|
||||||
|
public void printReturnTicket(Integer orderId, List<TbOrderDetail> tbOrderDetails) {
|
||||||
|
TbOrderInfo orderInfo = tbOrderInfoMapper.selectByPrimaryKey(orderId);
|
||||||
|
List<TbPrintMachine> list = mpPrintMachineMapper.selectList(new LambdaUpdateWrapper<TbPrintMachine>()
|
||||||
|
.eq(TbPrintMachine::getContentType, "yxyPrinter")
|
||||||
|
.eq(TbPrintMachine::getConnectionType, "network")
|
||||||
|
.eq(TbPrintMachine::getSubType, "cash")
|
||||||
|
.eq(TbPrintMachine::getStatus, 1)
|
||||||
|
.eq(TbPrintMachine::getShopId, orderInfo.getShopId()));
|
||||||
|
String printKey = RedisCst.ORDER_PRINT_PRO + orderId;
|
||||||
|
Set<Object> printProductSet = redisTemplate.opsForSet().members(printKey);
|
||||||
|
Set<Object> printProductSetCopy = redisTemplate.opsForSet().members(printKey);
|
||||||
|
|
||||||
|
log.info("-------------------开始打印退款订单,打印机列表: {}", list);
|
||||||
|
log.info("-------------------待打印数据: {}", printProductSet);
|
||||||
|
if (printProductSet != null && !printProductSet.isEmpty()) {
|
||||||
|
|
||||||
|
// 过滤出已经删除的订单
|
||||||
|
if (tbOrderDetails != null && !tbOrderDetails.isEmpty()) {
|
||||||
|
for (TbOrderDetail it : tbOrderDetails) {
|
||||||
|
printProductSet = printProductSet.stream().filter(r -> {
|
||||||
|
TbOrderDetail detail = (TbOrderDetail) r;
|
||||||
|
return !detail.getProductSkuId().equals(it.getProductSkuId()) || !detail.getProductId().equals(it.getProductId());
|
||||||
|
}).collect(Collectors.toSet());
|
||||||
|
|
||||||
|
printProductSetCopy = printProductSet.stream().filter(r -> {
|
||||||
|
TbOrderDetail detail = (TbOrderDetail) r;
|
||||||
|
return detail.getProductSkuId().equals(it.getProductSkuId()) && detail.getProductId().equals(it.getProductId());
|
||||||
|
}).collect(Collectors.toSet());
|
||||||
|
}
|
||||||
|
|
||||||
|
redisTemplate.delete(printKey);
|
||||||
|
for (Object o : printProductSetCopy) {
|
||||||
|
redisTemplate.opsForSet().add(printKey, o);
|
||||||
|
}
|
||||||
|
}else if (tbOrderDetails != null) {
|
||||||
|
redisTemplate.delete(printKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
log.info("-------------------打印机数量{}", list.size());
|
||||||
|
for (TbPrintMachine machine : list) {
|
||||||
|
|
||||||
|
String config = machine.getConfig();
|
||||||
|
if (config != null) {
|
||||||
|
JSONObject jsonObject = JSONObject.parseObject(config);
|
||||||
|
if (!"one".equals(jsonObject.getString("model"))) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
log.info("-------------------商品数量{}", printProductSet.size());
|
||||||
|
printProductSet.forEach(item -> {
|
||||||
|
log.info("已删除订单,打印退款票据, {}", item);
|
||||||
|
TbOrderDetail orderDetail = (TbOrderDetail) item;
|
||||||
|
String data = PrinterUtils.getPrintData("return",
|
||||||
|
StrUtil.isBlank(orderInfo.getTableName()) ? orderInfo.getMasterId() : orderInfo.getTableName(),
|
||||||
|
DateUtils.getTime(new Date(orderInfo.getCreatedAt())), orderDetail.getProductName(), orderDetail.getNum(), orderDetail.getRemark());
|
||||||
|
String voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔退款订单,请及时处理\"}";
|
||||||
|
PrinterUtils.printTickets(voiceJson, 3, 1, machine.getAddress(), data);
|
||||||
|
|
||||||
|
String key = RedisCst.ORDER_PRINT + orderId + ":" + orderDetail.getProductId() + ":" + orderDetail.getProductSkuId();
|
||||||
|
log.info("删除商品数量记录key, {}", key);
|
||||||
|
redisUtils.deleteByKey(key);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -362,7 +480,7 @@ public class PrintMechineConsumer {
|
|||||||
DateUtils.getTime(new Date(orderInfo.getCreatedAt())), it.getProductName(),
|
DateUtils.getTime(new Date(orderInfo.getCreatedAt())), it.getProductName(),
|
||||||
it.getNum(), remark);
|
it.getNum(), remark);
|
||||||
String voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔新的订单,请及时处理\"}";
|
String voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔新的订单,请及时处理\"}";
|
||||||
PrinterUtils.printTickets(voiceJson,3, Integer.valueOf(printerNum), tbPrintMachineWithBLOBs.getAddress(), data);
|
PrinterUtils.printTickets(voiceJson, 3, 1, tbPrintMachineWithBLOBs.getAddress(), data);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -390,7 +508,7 @@ public class PrintMechineConsumer {
|
|||||||
}
|
}
|
||||||
String data = PrinterUtils.getPrintData("return", orderInfo.getPayType().equals("wx_lite") ? orderInfo.getTableName() : orderInfo.getMasterId(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), it.getProductName(), it.getNum(), remark);
|
String data = PrinterUtils.getPrintData("return", orderInfo.getPayType().equals("wx_lite") ? orderInfo.getTableName() : orderInfo.getMasterId(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), it.getProductName(), it.getNum(), remark);
|
||||||
String voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔退款订单,请及时处理\"}";
|
String voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔退款订单,请及时处理\"}";
|
||||||
PrinterUtils.printTickets(voiceJson,3, Integer.valueOf(printerNum), tbPrintMachineWithBLOBs.getAddress(), data);
|
PrinterUtils.printTickets(voiceJson, 3, 1, tbPrintMachineWithBLOBs.getAddress(), data);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -399,6 +517,7 @@ public class PrintMechineConsumer {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 判断商品是否已打票
|
* 判断商品是否已打票
|
||||||
|
*
|
||||||
* @return true 已打 false 未打
|
* @return true 已打 false 未打
|
||||||
*/
|
*/
|
||||||
private boolean isPrint(TbOrderDetail orderDetail, Integer orderId) {
|
private boolean isPrint(TbOrderDetail orderDetail, Integer orderId) {
|
||||||
@@ -413,8 +532,6 @@ public class PrintMechineConsumer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private void fePrinter(TbPrintMachineWithBLOBs tbPrintMachineWithBLOBs, String model, TbOrderInfo orderInfo, TbShopInfo shopInfo, String printerNum, List<CategoryInfo> categoryInfos) {
|
private void fePrinter(TbPrintMachineWithBLOBs tbPrintMachineWithBLOBs, String model, TbOrderInfo orderInfo, TbShopInfo shopInfo, String printerNum, List<CategoryInfo> categoryInfos) {
|
||||||
String orderId = orderInfo.getId().toString();
|
String orderId = orderInfo.getId().toString();
|
||||||
switch (tbPrintMachineWithBLOBs.getSubType()) {
|
switch (tbPrintMachineWithBLOBs.getSubType()) {
|
||||||
@@ -586,7 +703,6 @@ public class PrintMechineConsumer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
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);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ import com.chaozhanggui.system.cashierservice.entity.vo.CartVo;
|
|||||||
import com.chaozhanggui.system.cashierservice.exception.MsgException;
|
import com.chaozhanggui.system.cashierservice.exception.MsgException;
|
||||||
import com.chaozhanggui.system.cashierservice.mybatis.MPCashierCartMapper;
|
import com.chaozhanggui.system.cashierservice.mybatis.MPCashierCartMapper;
|
||||||
import com.chaozhanggui.system.cashierservice.mybatis.MpShopTableMapper;
|
import com.chaozhanggui.system.cashierservice.mybatis.MpShopTableMapper;
|
||||||
|
import com.chaozhanggui.system.cashierservice.rabbit.PrintMechineConsumer;
|
||||||
import com.chaozhanggui.system.cashierservice.rabbit.RabbitProducer;
|
import com.chaozhanggui.system.cashierservice.rabbit.RabbitProducer;
|
||||||
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;
|
||||||
@@ -28,6 +29,7 @@ import lombok.extern.slf4j.Slf4j;
|
|||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.beans.BeanUtils;
|
import org.springframework.beans.BeanUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Qualifier;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
@@ -91,20 +93,28 @@ public class OrderService {
|
|||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
TbConsInfoMapper tbConsInfoMapper;
|
TbConsInfoMapper tbConsInfoMapper;
|
||||||
|
private final TbCashierCartMapper tbCashierCartMapper;
|
||||||
|
|
||||||
|
|
||||||
private static ConcurrentHashMap<String, HashSet<Integer>> codeMap = new ConcurrentHashMap<>();
|
private static ConcurrentHashMap<String, HashSet<Integer>> codeMap = new ConcurrentHashMap<>();
|
||||||
private static ConcurrentHashMap<String, HashSet<String>> userMap = new ConcurrentHashMap<>();
|
private static ConcurrentHashMap<String, HashSet<String>> userMap = new ConcurrentHashMap<>();
|
||||||
@Autowired
|
@Autowired
|
||||||
private ProductService productService;
|
private ProductService productService;
|
||||||
|
@Qualifier("printMechineConsumer")
|
||||||
|
@Autowired
|
||||||
|
private PrintMechineConsumer printMechineConsumer;
|
||||||
|
@Qualifier("tbOrderDetailMapper")
|
||||||
|
@Autowired
|
||||||
|
private TbOrderDetailMapper tbOrderDetailMapper;
|
||||||
|
|
||||||
public OrderService(WxAccountUtil wxAccountUtil, MPCashierCartMapper mpCashierCartMapper, WechatUtil wechatUtil, TbUserShopMsgMapper tbUserShopMsgMapper, TbShopOpenIdMapper shopOpenIdMapper, MpShopTableMapper mpShopTableMapper) {
|
public OrderService(WxAccountUtil wxAccountUtil, MPCashierCartMapper mpCashierCartMapper, WechatUtil wechatUtil, TbUserShopMsgMapper tbUserShopMsgMapper, TbShopOpenIdMapper shopOpenIdMapper, MpShopTableMapper mpShopTableMapper, TbCashierCartMapper tbCashierCartMapper) {
|
||||||
this.wxAccountUtil = wxAccountUtil;
|
this.wxAccountUtil = wxAccountUtil;
|
||||||
this.mpCashierCartMapper = mpCashierCartMapper;
|
this.mpCashierCartMapper = mpCashierCartMapper;
|
||||||
this.wechatUtil = wechatUtil;
|
this.wechatUtil = wechatUtil;
|
||||||
this.tbUserShopMsgMapper = tbUserShopMsgMapper;
|
this.tbUserShopMsgMapper = tbUserShopMsgMapper;
|
||||||
this.shopOpenIdMapper = shopOpenIdMapper;
|
this.shopOpenIdMapper = shopOpenIdMapper;
|
||||||
this.mpShopTableMapper = mpShopTableMapper;
|
this.mpShopTableMapper = mpShopTableMapper;
|
||||||
|
this.tbCashierCartMapper = tbCashierCartMapper;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
@@ -203,6 +213,7 @@ public class OrderService {
|
|||||||
tbOrderInfoMapper.deleteByPrimaryKey(Integer.valueOf(finalCart.getOrderId()));
|
tbOrderInfoMapper.deleteByPrimaryKey(Integer.valueOf(finalCart.getOrderId()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return Result.success(CodeEnum.SUCCESS, masterId);
|
return Result.success(CodeEnum.SUCCESS, masterId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -343,6 +354,14 @@ public class OrderService {
|
|||||||
redisUtil.saveMessage("SHOP:CODE:SET" + clientType + ":" + shopId + ":" + DateUtils.getDay(),masterId.substring(1,masterId.length()));
|
redisUtil.saveMessage("SHOP:CODE:SET" + clientType + ":" + shopId + ":" + DateUtils.getDay(),masterId.substring(1,masterId.length()));
|
||||||
|
|
||||||
|
|
||||||
|
TbCashierCart finalCart1 = cart;
|
||||||
|
ThreadUtil.execute(() -> {
|
||||||
|
ThreadUtil.sleep(1, TimeUnit.SECONDS);
|
||||||
|
if (finalCart1.getOrderId() != null && finalCart1.getTableId() != null) {
|
||||||
|
log.info("购物车数量改变,开始校验订单是否为空");
|
||||||
|
printMechineConsumer.printReturnTicket(Integer.valueOf(finalCart1.getOrderId()), tbOrderDetailMapper.selectAllByOrderId(Integer.valueOf(finalCart1.getOrderId())));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
return Result.success(CodeEnum.SUCCESS, masterId);
|
return Result.success(CodeEnum.SUCCESS, masterId);
|
||||||
}
|
}
|
||||||
@@ -546,7 +565,13 @@ public class OrderService {
|
|||||||
|
|
||||||
if (list.isEmpty()) {
|
if (list.isEmpty()) {
|
||||||
tbOrderInfoMapper.deleteByPrimaryKey(Integer.valueOf(cashierCart.getOrderId()));
|
tbOrderInfoMapper.deleteByPrimaryKey(Integer.valueOf(cashierCart.getOrderId()));
|
||||||
|
ThreadUtil.execute(() -> {
|
||||||
|
log.info("购物车数量改变,开始校验订单是否为空");
|
||||||
|
printMechineConsumer.printReturnTicket(Integer.valueOf(cashierCart.getOrderId()), null);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return Result.success(CodeEnum.SUCCESS);
|
return Result.success(CodeEnum.SUCCESS);
|
||||||
@@ -1213,6 +1238,12 @@ public class OrderService {
|
|||||||
.eq(TbShopTable::getQrcode, cartVo.getTableId())
|
.eq(TbShopTable::getQrcode, cartVo.getTableId())
|
||||||
.set(TbShopTable::getStatus, TableStateEnum.IDLE.getState()));
|
.set(TbShopTable::getStatus, TableStateEnum.IDLE.getState()));
|
||||||
|
|
||||||
|
// 打印退款票据
|
||||||
|
int finalOrderId = orderId;
|
||||||
|
ThreadUtil.execute(() -> {
|
||||||
|
printMechineConsumer.printReturnTicket(finalOrderId, null);
|
||||||
|
});
|
||||||
|
|
||||||
return Result.success(CodeEnum.SUCCESS);
|
return Result.success(CodeEnum.SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -21,4 +21,5 @@ public class RedisCst {
|
|||||||
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:";
|
public static final String ORDER_PRINT = "ORDER_PRINT:";
|
||||||
|
public static final String ORDER_PRINT_PRO = "ORDER_PRINT_PRODUCT:";
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user