diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/CartService.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/CartService.java index a6c6c2e..4c6dd31 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/CartService.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/CartService.java @@ -592,6 +592,7 @@ public class CartService { String shopId = jsonObject.getString("shopId"); String tableId = jsonObject.getString("tableId"); String userId = jsonObject.getString("userId"); + String sendType = jsonObject.getString("sendType"); String remark = StringUtils.isBlank(jsonObject.getString("remark"))?"":jsonObject.getString("remark"); String tableCartKey = RedisCst.getTableCartKey(shopId, tableId, Integer.valueOf(userId)); JSONArray array = JSON.parseArray(redisUtil.getMessage(tableCartKey)); @@ -613,6 +614,10 @@ public class CartService { MsgException.throwException("生成订单失败"); } + if (StrUtil.isBlank(sendType)) { + MsgException.throwException("用餐类型不为空"); + } + // 获取当前下单次数和用餐类型 ShopEatTypeInfoDTO shopEatTypeInfoDTO = shopUtils.checkEatModel(tableId, shopId); Integer currentPlaceNum = getCurrentPlaceNum(tableId, shopId, shopEatTypeInfoDTO); @@ -633,8 +638,7 @@ public class CartService { queryWrapper.eq(TbCashierCart::getUserId, userId); // 台桌点单 } else { - queryWrapper.eq(TbCashierCart::getTableId, tableId) - .and(q -> q.eq(TbCashierCart::getUseType, shopEatTypeInfoDTO.getUseType()).or().isNull(TbCashierCart::getUseType)); + queryWrapper.eq(TbCashierCart::getTableId, tableId); shopTable = mpShopTableMapper.selectOne(new LambdaQueryWrapper() .eq(TbShopTable::getQrcode, tableId)); @@ -739,10 +743,8 @@ public class CartService { }else { tbProduct = null; saleAmount = saleAmount.add(shopEatTypeInfoDTO.getShopInfo().getTableFee()); - } - totalAmount = totalAmount.add(cart.getTotalAmount()); packAMount = packAMount.add(cart.getPackFee()); originAmount = originAmount.add(cart.getTotalAmount()); @@ -858,6 +860,7 @@ public class CartService { // 设置餐位费 TbShopInfo shopInfo = mpShopInfoMapper.selectById(shopId); + TbCashierCart seatCart = null; if (!shopEatTypeInfoDTO.isTakeout() && shopInfo.getIsTableFee() != null && shopInfo.getIsTableFee() == 0 && (orderInfo != null && orderInfo.getSeatCount() == null)) { seatNum = jsonObject.getInteger("dinersNum"); @@ -874,8 +877,18 @@ public class CartService { choseCountDTO.setShopId(Integer.valueOf(shopId)); choseCountDTO.setNum(seatNum); choseCountDTO.setUserId(userId); - productService.choseCount(choseCountDTO); + seatCart = productService.choseCount(choseCountDTO); + TbOrderDetail orderDetail = new TbOrderDetail(); + orderDetail.setCartId(seatCart.getId()); + orderDetail.setPrice(seatCart.getTotalAmount()); + orderDetail.setProductId(Integer.valueOf(seatCart.getProductId())); + orderDetail.setProductSkuId(Integer.valueOf(seatCart.getProductId())); + orderDetail.setUseType(seatCart.getUseType()); + orderDetail.setPrice(shopInfo.getTableFee()); + orderDetails.add(orderDetail); } + + totalAmount = totalAmount.add(seatCost); if (orderInfo != null) { log.info("订单状态:" + orderInfo.getStatus()); if (!"unpaid".equals(orderInfo.getStatus())) { @@ -908,6 +921,7 @@ public class CartService { orderInfo.setUseType(shopEatTypeInfoDTO.getUseType()); orderInfo.setSeatCount(seatNum); orderInfo.setSeatAmount(seatCost); + orderInfo.setSendType(sendType); mpOrderInfoMapper.updateById(orderInfo); } else { orderInfo = getOrder(totalAmount, packAMount, shopTable, tbMerchantAccount.getId().toString(), jsonObject, originAmount); @@ -941,6 +955,7 @@ public class CartService { } } orderInfo.setOutNumber(number + ""); + orderInfo.setSendType(sendType); redisUtil.saveMessage(RedisCst.OUT_NUMBER.concat(jsonObject.getString("shopId")), object.toString()); mpOrderInfoMapper.insert(orderInfo); orderId = orderInfo.getId(); diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/ProductService.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/ProductService.java index 36d11f8..9f42527 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/ProductService.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/ProductService.java @@ -872,7 +872,7 @@ public class ProductService { } } - public Object choseCount(ChoseCountDTO choseCountDTO) { + public TbCashierCart choseCount(ChoseCountDTO choseCountDTO) { ShopEatTypeInfoDTO shopEatTypeInfoDTO = shopUtils.checkEatModel(choseCountDTO.getTableId(), choseCountDTO.getShopId()); TbShopInfo shopInfo = tbShopInfoMapper.selectByPrimaryKey(choseCountDTO.getShopId());