|
|
|
|
@@ -582,7 +582,7 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
|
|
|
|
cashierCartMapper.delete(new LambdaQueryWrapper<TbCashierCart>()
|
|
|
|
|
.eq(TbCashierCart::getShopId, clearCartDTO.getShopId())
|
|
|
|
|
.eq(TbCashierCart::getTableId, clearCartDTO.getTableId())
|
|
|
|
|
.eq(TbCashierCart::getPlaceNum, currentPlaceNum)
|
|
|
|
|
.isNull(TbCashierCart::getPlaceNum)
|
|
|
|
|
.and(q -> {
|
|
|
|
|
q.eq(TbCashierCart::getMasterId, clearCartDTO.getMasterId())
|
|
|
|
|
.or()
|
|
|
|
|
@@ -1005,6 +1005,7 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 查询此次添加购物车的商品
|
|
|
|
|
String day = DateUtils.getDay();
|
|
|
|
|
LambdaQueryWrapper<TbCashierCart> queryWrapper = new LambdaQueryWrapper<TbCashierCart>()
|
|
|
|
|
.eq(TbCashierCart::getShopId, createOrderDTO.getShopId())
|
|
|
|
|
@@ -1026,6 +1027,11 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
|
|
|
|
if (cashierCarts.isEmpty()) {
|
|
|
|
|
throw new BadRequestException("购物车为空,请先添加商品");
|
|
|
|
|
}
|
|
|
|
|
if (cashierCarts.stream().noneMatch(item -> "-999".equals(item.getProductId()))) {
|
|
|
|
|
throw new BadRequestException("请选择用餐人数");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
cashierCarts = cashierCarts.stream().filter(item -> item.getPlaceNum() == null).collect(Collectors.toList());
|
|
|
|
|
|
|
|
|
|
BigDecimal totalAmount = BigDecimal.ZERO;
|
|
|
|
|
BigDecimal packAMount = BigDecimal.ZERO;
|
|
|
|
|
@@ -1041,10 +1047,9 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
|
|
|
|
if (addMaterId && unAdd) {
|
|
|
|
|
throw new BadRequestException("此次未添加新商品,清先添加商品");
|
|
|
|
|
}
|
|
|
|
|
// 查询订单详情
|
|
|
|
|
|
|
|
|
|
for (TbCashierCart cashierCart : cashierCarts) {
|
|
|
|
|
if ("-999".equals(cashierCart.getProductId())) {
|
|
|
|
|
mealNum = cashierCart.getNumber();
|
|
|
|
|
}
|
|
|
|
|
if (!"return".equals(cashierCart.getStatus())) {
|
|
|
|
|
totalAmount = totalAmount.add(cashierCart.getTotalAmount());
|
|
|
|
|
packAMount = packAMount.add(cashierCart.getPackFee());
|
|
|
|
|
@@ -1052,6 +1057,8 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TbProductSku productSku = productSkuRepository.findById(Integer.valueOf(cashierCart.getSkuId())).orElse(null);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TbOrderDetail orderDetail = new TbOrderDetail();
|
|
|
|
|
|
|
|
|
|
if (Objects.nonNull(productSku)) {
|
|
|
|
|
@@ -1080,16 +1087,12 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
|
|
|
|
orderDetail.setPlaceNum(placeNum);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (mealNum == null) {
|
|
|
|
|
throw new BadRequestException("请选择用餐人数");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 修改订单信息
|
|
|
|
|
if (orderInfo != null) {
|
|
|
|
|
// 删除历史订单
|
|
|
|
|
// 更新取餐号
|
|
|
|
|
orderInfo.setOutNumber(updateOutNumber(String.valueOf(createOrderDTO.getShopId())).toString());
|
|
|
|
|
orderDetailMapper.delete(new LambdaQueryWrapper<TbOrderDetail>().eq(TbOrderDetail::getOrderId, orderId));
|
|
|
|
|
// orderDetailMapper.delete(new LambdaQueryWrapper<TbOrderDetail>().eq(TbOrderDetail::getOrderId, orderId));
|
|
|
|
|
orderInfo.setUpdatedAt(System.currentTimeMillis());
|
|
|
|
|
orderInfo.setSettlementAmount(totalAmount);
|
|
|
|
|
orderInfo.setAmount(totalAmount);
|
|
|
|
|
@@ -1153,6 +1156,7 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
|
|
|
|
orderDetailMapper.insert(orderDetail);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 更新购物车记录的orderId
|
|
|
|
|
// 是否是第一次添加的商品
|
|
|
|
|
boolean isFirst = true;
|
|
|
|
|
@@ -1176,12 +1180,15 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
|
|
|
|
}
|
|
|
|
|
cashierCartMapper.updateById(cashierCart);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (createOrderDTO.isPostPay()) {
|
|
|
|
|
rabbitMsgUtils.printDishesTicket(orderId, false, orderDetails);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (isFirst) {
|
|
|
|
|
// 后付费,不增加当前台桌取餐号
|
|
|
|
|
if (createOrderDTO.isPostPay()) {
|
|
|
|
|
addGlobalCode(day, "pc", String.valueOf(createOrderDTO.getShopId()));
|
|
|
|
|
// String key = "SHOP:CODE:USER:pc" + ":" + createOrderDTO.getShopId() + ":" + day + ":" + orderInfo.getTableId();
|
|
|
|
|
// redisTemplate.delete(key);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!createOrderDTO.isPostPay() || (addMaterId && "pending".equals(orderInfo.getStatus()))) {
|
|
|
|
|
@@ -1194,14 +1201,14 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
|
|
|
|
// 推送耗材信息
|
|
|
|
|
pushConsMsg(orderInfo, cashierCarts);
|
|
|
|
|
|
|
|
|
|
if (createOrderDTO.isPostPay() && isPrint) {
|
|
|
|
|
Long count = orderInfoMapper.selectCount(new LambdaQueryWrapper<TbOrderInfo>()
|
|
|
|
|
.eq(TbOrderInfo::getStatus, "unpaid")
|
|
|
|
|
.eq(TbOrderInfo::getId, orderId));
|
|
|
|
|
if (count != 0) {
|
|
|
|
|
rabbitMsgUtils.printTicket(String.valueOf(orderId));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// if (createOrderDTO.isPostPay() && isPrint) {
|
|
|
|
|
// Long count = orderInfoMapper.selectCount(new LambdaQueryWrapper<TbOrderInfo>()
|
|
|
|
|
// .eq(TbOrderInfo::getStatus, "unpaid")
|
|
|
|
|
// .eq(TbOrderInfo::getId, orderId));
|
|
|
|
|
// if (count != 0) {
|
|
|
|
|
// rabbitMsgUtils.printTicket(String.valueOf(orderId));
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
LambdaUpdateWrapper<TbShopTable> wrapper = new LambdaUpdateWrapper<TbShopTable>()
|
|
|
|
|
.eq(TbShopTable::getShopId, createOrderDTO.getShopId())
|
|
|
|
|
@@ -1225,6 +1232,32 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void printDishesTicketByCashier(Integer orderId, List<TbCashierCart> cashierCartList, List<TbOrderDetail> orderDetailList) {
|
|
|
|
|
ArrayList<TbOrderDetail> normalPrintDetail = new ArrayList<>();
|
|
|
|
|
ArrayList<TbOrderDetail> returnPrintDetail = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
HashMap<String, TbOrderDetail> oldDetailMap = new HashMap<>();
|
|
|
|
|
orderDetailList.forEach(item -> {
|
|
|
|
|
oldDetailMap.put(item.getCartId().toString() + item.getPlaceNum().toString(), item);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
cashierCartList.forEach(cashierCart -> {
|
|
|
|
|
TbOrderDetail detail = oldDetailMap.get(cashierCart.getId().toString() + cashierCart.getPlaceNum());
|
|
|
|
|
if (detail.getNum() > cashierCart.getNumber()) {
|
|
|
|
|
detail.setNum(detail.getNum() - cashierCart.getNumber());
|
|
|
|
|
returnPrintDetail.add(detail);
|
|
|
|
|
} else if (detail.getNum() < cashierCart.getNumber()) {
|
|
|
|
|
detail.setNum(cashierCart.getNumber() - detail.getNum());
|
|
|
|
|
normalPrintDetail.add(detail);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// 菜品单
|
|
|
|
|
rabbitMsgUtils.printDishesTicket(orderId, false, normalPrintDetail);
|
|
|
|
|
// 退款单
|
|
|
|
|
rabbitMsgUtils.printDishesTicket(orderId, true, returnPrintDetail);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public Object pending(PendingDTO pendingDTO) {
|
|
|
|
|
@@ -1741,7 +1774,7 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
|
|
|
|
for (int i = 0; i < detailList.size(); i++) {
|
|
|
|
|
detailIds[i] = detailList.get(i).getId();
|
|
|
|
|
}
|
|
|
|
|
rabbitMsgUtils.printDishesTicket(currentOrder.getId(), false, detailIds);
|
|
|
|
|
rabbitMsgUtils.printDishesTicket(currentOrder.getId(), false, detailList);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|