1.代客下单 商品数量减少增加打印退单票据

This commit is contained in:
2024-08-30 15:06:56 +08:00
parent e0b62b66d4
commit 83d3aa444f
6 changed files with 280 additions and 109 deletions

View File

@@ -19,6 +19,7 @@ import com.chaozhanggui.system.cashierservice.entity.vo.CartVo;
import com.chaozhanggui.system.cashierservice.exception.MsgException;
import com.chaozhanggui.system.cashierservice.mybatis.MPCashierCartMapper;
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.sign.CodeEnum;
import com.chaozhanggui.system.cashierservice.sign.Result;
@@ -28,6 +29,7 @@ import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -91,20 +93,28 @@ public class OrderService {
@Autowired
TbConsInfoMapper tbConsInfoMapper;
private final TbCashierCartMapper tbCashierCartMapper;
private static ConcurrentHashMap<String, HashSet<Integer>> codeMap = new ConcurrentHashMap<>();
private static ConcurrentHashMap<String, HashSet<String>> userMap = new ConcurrentHashMap<>();
@Autowired
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.mpCashierCartMapper = mpCashierCartMapper;
this.wechatUtil = wechatUtil;
this.tbUserShopMsgMapper = tbUserShopMsgMapper;
this.shopOpenIdMapper = shopOpenIdMapper;
this.mpShopTableMapper = mpShopTableMapper;
this.tbCashierCartMapper = tbCashierCartMapper;
}
@Transactional(rollbackFor = Exception.class)
@@ -203,6 +213,7 @@ public class OrderService {
tbOrderInfoMapper.deleteByPrimaryKey(Integer.valueOf(finalCart.getOrderId()));
}
}
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()));
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);
}
@@ -546,7 +565,13 @@ public class OrderService {
if (list.isEmpty()) {
tbOrderInfoMapper.deleteByPrimaryKey(Integer.valueOf(cashierCart.getOrderId()));
ThreadUtil.execute(() -> {
log.info("购物车数量改变,开始校验订单是否为空");
printMechineConsumer.printReturnTicket(Integer.valueOf(cashierCart.getOrderId()), null);
});
}
}
return Result.success(CodeEnum.SUCCESS);
@@ -1213,6 +1238,12 @@ public class OrderService {
.eq(TbShopTable::getQrcode, cartVo.getTableId())
.set(TbShopTable::getStatus, TableStateEnum.IDLE.getState()));
// 打印退款票据
int finalOrderId = orderId;
ThreadUtil.execute(() -> {
printMechineConsumer.printReturnTicket(finalOrderId, null);
});
return Result.success(CodeEnum.SUCCESS);
}