|
|
@@ -9,19 +9,19 @@ import org.springframework.stereotype.Service;
|
|
|
import org.springframework.util.StringUtils;
|
|
|
import shop.alien.dining.config.BaseRedisService;
|
|
|
import shop.alien.dining.service.CartService;
|
|
|
-import shop.alien.entity.store.wechat.WechatStoreCart;
|
|
|
-import shop.alien.entity.store.wechat.WechatStoreCouponUsage;
|
|
|
-import shop.alien.entity.store.wechat.WechatStoreCuisine;
|
|
|
+import shop.alien.entity.store.StoreCart;
|
|
|
+import shop.alien.entity.store.StoreCouponUsage;
|
|
|
+import shop.alien.entity.store.StoreCuisine;
|
|
|
import shop.alien.entity.store.StoreInfo;
|
|
|
-import shop.alien.entity.store.wechat.WechatStoreTable;
|
|
|
-import shop.alien.entity.store.dto.wechat.WechatAddCartItemDTO;
|
|
|
-import shop.alien.entity.store.dto.wechat.WechatCartDTO;
|
|
|
-import shop.alien.entity.store.dto.wechat.WechatCartItemDTO;
|
|
|
-import shop.alien.mapper.wechat.WechatStoreCartMapper;
|
|
|
-import shop.alien.mapper.wechat.WechatStoreCouponUsageMapper;
|
|
|
-import shop.alien.mapper.wechat.WechatStoreCuisineMapper;
|
|
|
+import shop.alien.entity.store.StoreTable;
|
|
|
+import shop.alien.entity.store.dto.AddCartItemDTO;
|
|
|
+import shop.alien.entity.store.dto.CartDTO;
|
|
|
+import shop.alien.entity.store.dto.CartItemDTO;
|
|
|
+import shop.alien.mapper.StoreCartMapper;
|
|
|
+import shop.alien.mapper.StoreCouponUsageMapper;
|
|
|
+import shop.alien.mapper.StoreCuisineMapper;
|
|
|
import shop.alien.mapper.StoreInfoMapper;
|
|
|
-import shop.alien.mapper.wechat.WechatStoreTableMapper;
|
|
|
+import shop.alien.mapper.StoreTableMapper;
|
|
|
import shop.alien.dining.util.TokenUtil;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
@@ -44,8 +44,8 @@ import java.util.stream.Collectors;
|
|
|
@RequiredArgsConstructor
|
|
|
public class CartServiceImpl implements CartService {
|
|
|
|
|
|
- private static final String CART_KEY_PREFIX = "wechat:cart:table:";
|
|
|
- private static final String COUPON_USED_KEY_PREFIX = "wechat:coupon:used:table:";
|
|
|
+ private static final String CART_KEY_PREFIX = "cart:table:";
|
|
|
+ private static final String COUPON_USED_KEY_PREFIX = "coupon:used:table:";
|
|
|
private static final int CART_EXPIRE_SECONDS = 24 * 60 * 60; // 24小时过期
|
|
|
|
|
|
// 异步写入数据库的线程池(专门用于购物车数据库写入)
|
|
|
@@ -56,23 +56,23 @@ public class CartServiceImpl implements CartService {
|
|
|
});
|
|
|
|
|
|
private final BaseRedisService baseRedisService;
|
|
|
- private final WechatStoreTableMapper storeTableMapper;
|
|
|
- private final WechatStoreCuisineMapper storeCuisineMapper;
|
|
|
- private final WechatStoreCartMapper storeCartMapper;
|
|
|
- private final WechatStoreCouponUsageMapper storeCouponUsageMapper;
|
|
|
+ private final StoreTableMapper storeTableMapper;
|
|
|
+ private final StoreCuisineMapper storeCuisineMapper;
|
|
|
+ private final StoreCartMapper storeCartMapper;
|
|
|
+ private final StoreCouponUsageMapper storeCouponUsageMapper;
|
|
|
private final StoreInfoMapper storeInfoMapper;
|
|
|
|
|
|
@Override
|
|
|
- public WechatCartDTO getCart(Integer tableId) {
|
|
|
+ public CartDTO getCart(Integer tableId) {
|
|
|
log.info("获取购物车, tableId={}", tableId);
|
|
|
String cartKey = CART_KEY_PREFIX + tableId;
|
|
|
String cartJson = baseRedisService.getString(cartKey);
|
|
|
|
|
|
- WechatCartDTO cart = new WechatCartDTO();
|
|
|
+ CartDTO cart = new CartDTO();
|
|
|
cart.setTableId(tableId);
|
|
|
|
|
|
// 查询桌号信息
|
|
|
- WechatStoreTable table = storeTableMapper.selectById(tableId);
|
|
|
+ StoreTable table = storeTableMapper.selectById(tableId);
|
|
|
if (table != null) {
|
|
|
cart.setTableNumber(table.getTableNumber());
|
|
|
cart.setStoreId(table.getStoreId());
|
|
|
@@ -81,15 +81,15 @@ public class CartServiceImpl implements CartService {
|
|
|
if (StringUtils.hasText(cartJson)) {
|
|
|
try {
|
|
|
JSONObject cartObj = JSON.parseObject(cartJson);
|
|
|
- List<WechatCartItemDTO> items = cartObj.getList("items", WechatCartItemDTO.class);
|
|
|
+ List<CartItemDTO> items = cartObj.getList("items", CartItemDTO.class);
|
|
|
if (items != null) {
|
|
|
cart.setItems(items);
|
|
|
// 计算总金额和总数量
|
|
|
BigDecimal totalAmount = items.stream()
|
|
|
- .map(WechatCartItemDTO::getSubtotalAmount)
|
|
|
+ .map(CartItemDTO::getSubtotalAmount)
|
|
|
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
Integer totalQuantity = items.stream()
|
|
|
- .mapToInt(WechatCartItemDTO::getQuantity)
|
|
|
+ .mapToInt(CartItemDTO::getQuantity)
|
|
|
.sum();
|
|
|
cart.setTotalAmount(totalAmount);
|
|
|
cart.setTotalQuantity(totalQuantity);
|
|
|
@@ -115,30 +115,30 @@ public class CartServiceImpl implements CartService {
|
|
|
/**
|
|
|
* 从数据库加载购物车
|
|
|
*/
|
|
|
- private WechatCartDTO loadCartFromDatabase(Integer tableId) {
|
|
|
+ private CartDTO loadCartFromDatabase(Integer tableId) {
|
|
|
log.info("从数据库加载购物车, tableId={}", tableId);
|
|
|
- WechatCartDTO cart = new WechatCartDTO();
|
|
|
+ CartDTO cart = new CartDTO();
|
|
|
cart.setTableId(tableId);
|
|
|
cart.setItems(new ArrayList<>());
|
|
|
cart.setTotalAmount(BigDecimal.ZERO);
|
|
|
cart.setTotalQuantity(0);
|
|
|
|
|
|
// 查询桌号信息
|
|
|
- WechatStoreTable table = storeTableMapper.selectById(tableId);
|
|
|
+ StoreTable table = storeTableMapper.selectById(tableId);
|
|
|
if (table != null) {
|
|
|
cart.setTableNumber(table.getTableNumber());
|
|
|
cart.setStoreId(table.getStoreId());
|
|
|
}
|
|
|
|
|
|
// 从数据库查询购物车数据
|
|
|
- LambdaQueryWrapper<WechatStoreCart> wrapper = new LambdaQueryWrapper<>();
|
|
|
- wrapper.eq(WechatStoreCart::getTableId, tableId);
|
|
|
- wrapper.eq(WechatStoreCart::getDeleteFlag, 0);
|
|
|
- List<WechatStoreCart> cartList = storeCartMapper.selectList(wrapper);
|
|
|
+ LambdaQueryWrapper<StoreCart> wrapper = new LambdaQueryWrapper<>();
|
|
|
+ wrapper.eq(StoreCart::getTableId, tableId);
|
|
|
+ wrapper.eq(StoreCart::getDeleteFlag, 0);
|
|
|
+ List<StoreCart> cartList = storeCartMapper.selectList(wrapper);
|
|
|
|
|
|
if (cartList != null && !cartList.isEmpty()) {
|
|
|
- List<WechatCartItemDTO> items = cartList.stream().map(cartItem -> {
|
|
|
- WechatCartItemDTO item = new WechatCartItemDTO();
|
|
|
+ List<CartItemDTO> items = cartList.stream().map(cartItem -> {
|
|
|
+ CartItemDTO item = new CartItemDTO();
|
|
|
item.setCuisineId(cartItem.getCuisineId());
|
|
|
item.setCuisineName(cartItem.getCuisineName());
|
|
|
item.setCuisineImage(cartItem.getCuisineImage());
|
|
|
@@ -154,10 +154,10 @@ public class CartServiceImpl implements CartService {
|
|
|
|
|
|
cart.setItems(items);
|
|
|
BigDecimal totalAmount = items.stream()
|
|
|
- .map(WechatCartItemDTO::getSubtotalAmount)
|
|
|
+ .map(CartItemDTO::getSubtotalAmount)
|
|
|
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
Integer totalQuantity = items.stream()
|
|
|
- .mapToInt(WechatCartItemDTO::getQuantity)
|
|
|
+ .mapToInt(CartItemDTO::getQuantity)
|
|
|
.sum();
|
|
|
cart.setTotalAmount(totalAmount);
|
|
|
cart.setTotalQuantity(totalQuantity);
|
|
|
@@ -170,16 +170,16 @@ public class CartServiceImpl implements CartService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public WechatCartDTO addItem(WechatAddCartItemDTO dto) {
|
|
|
+ public CartDTO addItem(AddCartItemDTO dto) {
|
|
|
log.info("添加商品到购物车, dto={}", dto);
|
|
|
// 验证桌号
|
|
|
- WechatStoreTable table = storeTableMapper.selectById(dto.getTableId());
|
|
|
+ StoreTable table = storeTableMapper.selectById(dto.getTableId());
|
|
|
if (table == null) {
|
|
|
throw new RuntimeException("桌号不存在");
|
|
|
}
|
|
|
|
|
|
// 验证菜品
|
|
|
- WechatStoreCuisine cuisine = storeCuisineMapper.selectById(dto.getCuisineId());
|
|
|
+ StoreCuisine cuisine = storeCuisineMapper.selectById(dto.getCuisineId());
|
|
|
if (cuisine == null) {
|
|
|
throw new RuntimeException("菜品不存在");
|
|
|
}
|
|
|
@@ -192,11 +192,11 @@ public class CartServiceImpl implements CartService {
|
|
|
String userPhone = TokenUtil.getCurrentUserPhone();
|
|
|
|
|
|
// 获取购物车
|
|
|
- WechatCartDTO cart = getCart(dto.getTableId());
|
|
|
+ CartDTO cart = getCart(dto.getTableId());
|
|
|
|
|
|
// 查找是否已存在该商品
|
|
|
- List<WechatCartItemDTO> items = cart.getItems();
|
|
|
- WechatCartItemDTO existingItem = items.stream()
|
|
|
+ List<CartItemDTO> items = cart.getItems();
|
|
|
+ CartItemDTO existingItem = items.stream()
|
|
|
.filter(item -> item.getCuisineId().equals(dto.getCuisineId()))
|
|
|
.findFirst()
|
|
|
.orElse(null);
|
|
|
@@ -220,7 +220,7 @@ public class CartServiceImpl implements CartService {
|
|
|
}
|
|
|
} else {
|
|
|
// 添加新商品
|
|
|
- WechatCartItemDTO newItem = new WechatCartItemDTO();
|
|
|
+ CartItemDTO newItem = new CartItemDTO();
|
|
|
newItem.setCuisineId(cuisine.getId());
|
|
|
newItem.setCuisineName(cuisine.getName());
|
|
|
newItem.setCuisineType(cuisine.getCuisineType());
|
|
|
@@ -237,10 +237,10 @@ public class CartServiceImpl implements CartService {
|
|
|
|
|
|
// 重新计算总金额和总数量
|
|
|
BigDecimal totalAmount = items.stream()
|
|
|
- .map(WechatCartItemDTO::getSubtotalAmount)
|
|
|
+ .map(CartItemDTO::getSubtotalAmount)
|
|
|
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
Integer totalQuantity = items.stream()
|
|
|
- .mapToInt(WechatCartItemDTO::getQuantity)
|
|
|
+ .mapToInt(CartItemDTO::getQuantity)
|
|
|
.sum();
|
|
|
cart.setTotalAmount(totalAmount);
|
|
|
cart.setTotalQuantity(totalQuantity);
|
|
|
@@ -252,7 +252,7 @@ public class CartServiceImpl implements CartService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public WechatCartDTO updateItemQuantity(Integer tableId, Integer cuisineId, Integer quantity) {
|
|
|
+ public CartDTO updateItemQuantity(Integer tableId, Integer cuisineId, Integer quantity) {
|
|
|
log.info("更新购物车商品数量, tableId={}, cuisineId={}, quantity={}", tableId, cuisineId, quantity);
|
|
|
|
|
|
// 如果数量为0或小于0,删除该商品
|
|
|
@@ -261,9 +261,9 @@ public class CartServiceImpl implements CartService {
|
|
|
return removeItem(tableId, cuisineId);
|
|
|
}
|
|
|
|
|
|
- WechatCartDTO cart = getCart(tableId);
|
|
|
- List<WechatCartItemDTO> items = cart.getItems();
|
|
|
- WechatCartItemDTO item = items.stream()
|
|
|
+ CartDTO cart = getCart(tableId);
|
|
|
+ List<CartItemDTO> items = cart.getItems();
|
|
|
+ CartItemDTO item = items.stream()
|
|
|
.filter(i -> i.getCuisineId().equals(cuisineId))
|
|
|
.findFirst()
|
|
|
.orElse(null);
|
|
|
@@ -284,10 +284,10 @@ public class CartServiceImpl implements CartService {
|
|
|
|
|
|
// 重新计算总金额和总数量
|
|
|
BigDecimal totalAmount = items.stream()
|
|
|
- .map(WechatCartItemDTO::getSubtotalAmount)
|
|
|
+ .map(CartItemDTO::getSubtotalAmount)
|
|
|
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
Integer totalQuantity = items.stream()
|
|
|
- .mapToInt(WechatCartItemDTO::getQuantity)
|
|
|
+ .mapToInt(CartItemDTO::getQuantity)
|
|
|
.sum();
|
|
|
cart.setTotalAmount(totalAmount);
|
|
|
cart.setTotalQuantity(totalQuantity);
|
|
|
@@ -298,7 +298,7 @@ public class CartServiceImpl implements CartService {
|
|
|
log.info("商品不在购物车中,自动添加, tableId={}, cuisineId={}, quantity={}", tableId, cuisineId, quantity);
|
|
|
|
|
|
// 验证菜品
|
|
|
- WechatStoreCuisine cuisine = storeCuisineMapper.selectById(cuisineId);
|
|
|
+ StoreCuisine cuisine = storeCuisineMapper.selectById(cuisineId);
|
|
|
if (cuisine == null) {
|
|
|
throw new RuntimeException("菜品不存在");
|
|
|
}
|
|
|
@@ -311,7 +311,7 @@ public class CartServiceImpl implements CartService {
|
|
|
String userPhone = TokenUtil.getCurrentUserPhone();
|
|
|
|
|
|
// 创建新的购物车商品项
|
|
|
- WechatCartItemDTO newItem = new WechatCartItemDTO();
|
|
|
+ CartItemDTO newItem = new CartItemDTO();
|
|
|
newItem.setCuisineId(cuisine.getId());
|
|
|
newItem.setCuisineName(cuisine.getName());
|
|
|
newItem.setCuisineType(cuisine.getCuisineType());
|
|
|
@@ -326,10 +326,10 @@ public class CartServiceImpl implements CartService {
|
|
|
|
|
|
// 重新计算总金额和总数量
|
|
|
BigDecimal totalAmount = items.stream()
|
|
|
- .map(WechatCartItemDTO::getSubtotalAmount)
|
|
|
+ .map(CartItemDTO::getSubtotalAmount)
|
|
|
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
Integer totalQuantity = items.stream()
|
|
|
- .mapToInt(WechatCartItemDTO::getQuantity)
|
|
|
+ .mapToInt(CartItemDTO::getQuantity)
|
|
|
.sum();
|
|
|
cart.setTotalAmount(totalAmount);
|
|
|
cart.setTotalQuantity(totalQuantity);
|
|
|
@@ -343,13 +343,13 @@ public class CartServiceImpl implements CartService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public WechatCartDTO removeItem(Integer tableId, Integer cuisineId) {
|
|
|
+ public CartDTO removeItem(Integer tableId, Integer cuisineId) {
|
|
|
log.info("删除购物车商品, tableId={}, cuisineId={}", tableId, cuisineId);
|
|
|
- WechatCartDTO cart = getCart(tableId);
|
|
|
- List<WechatCartItemDTO> items = cart.getItems();
|
|
|
+ CartDTO cart = getCart(tableId);
|
|
|
+ List<CartItemDTO> items = cart.getItems();
|
|
|
|
|
|
// 检查是否有已下单数量,如果有则不允许删除
|
|
|
- WechatCartItemDTO item = items.stream()
|
|
|
+ CartItemDTO item = items.stream()
|
|
|
.filter(i -> i.getCuisineId().equals(cuisineId))
|
|
|
.findFirst()
|
|
|
.orElse(null);
|
|
|
@@ -365,10 +365,10 @@ public class CartServiceImpl implements CartService {
|
|
|
|
|
|
// 重新计算总金额和总数量
|
|
|
BigDecimal totalAmount = items.stream()
|
|
|
- .map(WechatCartItemDTO::getSubtotalAmount)
|
|
|
+ .map(CartItemDTO::getSubtotalAmount)
|
|
|
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
Integer totalQuantity = items.stream()
|
|
|
- .mapToInt(WechatCartItemDTO::getQuantity)
|
|
|
+ .mapToInt(CartItemDTO::getQuantity)
|
|
|
.sum();
|
|
|
cart.setTotalAmount(totalAmount);
|
|
|
cart.setTotalQuantity(totalQuantity);
|
|
|
@@ -382,8 +382,8 @@ public class CartServiceImpl implements CartService {
|
|
|
log.info("清空购物车(保留已下单商品), tableId={}", tableId);
|
|
|
|
|
|
// 获取购物车
|
|
|
- WechatCartDTO cart = getCart(tableId);
|
|
|
- List<WechatCartItemDTO> items = cart.getItems();
|
|
|
+ CartDTO cart = getCart(tableId);
|
|
|
+ List<CartItemDTO> items = cart.getItems();
|
|
|
|
|
|
if (items == null || items.isEmpty()) {
|
|
|
log.info("购物车为空,无需清空, tableId={}", tableId);
|
|
|
@@ -391,13 +391,13 @@ public class CartServiceImpl implements CartService {
|
|
|
}
|
|
|
|
|
|
// 分离已下单的商品、未下单的商品和餐具
|
|
|
- List<WechatCartItemDTO> orderedItems = new ArrayList<>(); // 已下单的商品(保留,数量恢复为已下单数量)
|
|
|
+ List<CartItemDTO> orderedItems = new ArrayList<>(); // 已下单的商品(保留,数量恢复为已下单数量)
|
|
|
List<Integer> orderedCuisineIds = new ArrayList<>(); // 已下单的商品ID列表
|
|
|
- List<WechatCartItemDTO> unorderedItems = new ArrayList<>(); // 未下单的商品(删除)
|
|
|
- WechatCartItemDTO tablewareItem = null; // 餐具项(始终保留)
|
|
|
+ List<CartItemDTO> unorderedItems = new ArrayList<>(); // 未下单的商品(删除)
|
|
|
+ CartItemDTO tablewareItem = null; // 餐具项(始终保留)
|
|
|
boolean hasChanges = false; // 是否有变化(需要更新)
|
|
|
|
|
|
- for (WechatCartItemDTO item : items) {
|
|
|
+ for (CartItemDTO item : items) {
|
|
|
// 餐具始终保留,不清空
|
|
|
if (TABLEWARE_CUISINE_ID.equals(item.getCuisineId())) {
|
|
|
tablewareItem = item;
|
|
|
@@ -449,10 +449,10 @@ public class CartServiceImpl implements CartService {
|
|
|
cart.setItems(orderedItems);
|
|
|
// 重新计算总金额和总数量(只计算保留的商品,数量已恢复为已下单数量)
|
|
|
BigDecimal totalAmount = orderedItems.stream()
|
|
|
- .map(WechatCartItemDTO::getSubtotalAmount)
|
|
|
+ .map(CartItemDTO::getSubtotalAmount)
|
|
|
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
Integer totalQuantity = orderedItems.stream()
|
|
|
- .mapToInt(WechatCartItemDTO::getQuantity)
|
|
|
+ .mapToInt(CartItemDTO::getQuantity)
|
|
|
.sum();
|
|
|
cart.setTotalAmount(totalAmount);
|
|
|
cart.setTotalQuantity(totalQuantity);
|
|
|
@@ -469,19 +469,19 @@ public class CartServiceImpl implements CartService {
|
|
|
|
|
|
// 2. 从数据库中逻辑删除未下单的商品(排除餐具)
|
|
|
if (!unorderedItems.isEmpty()) {
|
|
|
- LambdaQueryWrapper<WechatStoreCart> wrapper = new LambdaQueryWrapper<>();
|
|
|
- wrapper.eq(WechatStoreCart::getTableId, tableId);
|
|
|
- wrapper.eq(WechatStoreCart::getDeleteFlag, 0);
|
|
|
+ LambdaQueryWrapper<StoreCart> wrapper = new LambdaQueryWrapper<>();
|
|
|
+ wrapper.eq(StoreCart::getTableId, tableId);
|
|
|
+ wrapper.eq(StoreCart::getDeleteFlag, 0);
|
|
|
// 排除餐具(cuisineId = -1)
|
|
|
- wrapper.ne(WechatStoreCart::getCuisineId, TABLEWARE_CUISINE_ID);
|
|
|
+ wrapper.ne(StoreCart::getCuisineId, TABLEWARE_CUISINE_ID);
|
|
|
if (!orderedCuisineIds.isEmpty()) {
|
|
|
// 排除已下单的商品ID(包括餐具)
|
|
|
- wrapper.notIn(WechatStoreCart::getCuisineId, orderedCuisineIds);
|
|
|
+ wrapper.notIn(StoreCart::getCuisineId, orderedCuisineIds);
|
|
|
}
|
|
|
- List<WechatStoreCart> cartListToDelete = storeCartMapper.selectList(wrapper);
|
|
|
+ List<StoreCart> cartListToDelete = storeCartMapper.selectList(wrapper);
|
|
|
if (cartListToDelete != null && !cartListToDelete.isEmpty()) {
|
|
|
List<Integer> cartIds = cartListToDelete.stream()
|
|
|
- .map(WechatStoreCart::getId)
|
|
|
+ .map(StoreCart::getId)
|
|
|
.collect(Collectors.toList());
|
|
|
// 使用 deleteBatchIds 进行逻辑删除(MyBatis-Plus 会自动处理 @TableLogic)
|
|
|
storeCartMapper.deleteBatchIds(cartIds);
|
|
|
@@ -496,7 +496,7 @@ public class CartServiceImpl implements CartService {
|
|
|
}
|
|
|
|
|
|
// 4. 更新桌号表的购物车统计
|
|
|
- WechatStoreTable table = storeTableMapper.selectById(tableId);
|
|
|
+ StoreTable table = storeTableMapper.selectById(tableId);
|
|
|
if (table != null) {
|
|
|
table.setCartItemCount(totalQuantity);
|
|
|
table.setCartTotalAmount(totalAmount);
|
|
|
@@ -511,24 +511,24 @@ public class CartServiceImpl implements CartService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public WechatCartDTO migrateCart(Integer fromTableId, Integer toTableId) {
|
|
|
+ public CartDTO migrateCart(Integer fromTableId, Integer toTableId) {
|
|
|
log.info("迁移购物车, fromTableId={}, toTableId={}", fromTableId, toTableId);
|
|
|
// 获取原购物车
|
|
|
- WechatCartDTO fromCart = getCart(fromTableId);
|
|
|
+ CartDTO fromCart = getCart(fromTableId);
|
|
|
|
|
|
// 验证目标桌号
|
|
|
- WechatStoreTable toTable = storeTableMapper.selectById(toTableId);
|
|
|
+ StoreTable toTable = storeTableMapper.selectById(toTableId);
|
|
|
if (toTable == null) {
|
|
|
throw new RuntimeException("目标桌号不存在");
|
|
|
}
|
|
|
|
|
|
// 获取目标购物车
|
|
|
- WechatCartDTO toCart = getCart(toTableId);
|
|
|
+ CartDTO toCart = getCart(toTableId);
|
|
|
|
|
|
// 合并购物车(如果目标桌号已有商品,则合并)
|
|
|
- List<WechatCartItemDTO> mergedItems = new ArrayList<>(toCart.getItems());
|
|
|
- for (WechatCartItemDTO fromItem : fromCart.getItems()) {
|
|
|
- WechatCartItemDTO existingItem = mergedItems.stream()
|
|
|
+ List<CartItemDTO> mergedItems = new ArrayList<>(toCart.getItems());
|
|
|
+ for (CartItemDTO fromItem : fromCart.getItems()) {
|
|
|
+ CartItemDTO existingItem = mergedItems.stream()
|
|
|
.filter(item -> item.getCuisineId().equals(fromItem.getCuisineId()))
|
|
|
.findFirst()
|
|
|
.orElse(null);
|
|
|
@@ -556,10 +556,10 @@ public class CartServiceImpl implements CartService {
|
|
|
|
|
|
// 重新计算总金额和总数量
|
|
|
BigDecimal totalAmount = mergedItems.stream()
|
|
|
- .map(WechatCartItemDTO::getSubtotalAmount)
|
|
|
+ .map(CartItemDTO::getSubtotalAmount)
|
|
|
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
Integer totalQuantity = mergedItems.stream()
|
|
|
- .mapToInt(WechatCartItemDTO::getQuantity)
|
|
|
+ .mapToInt(CartItemDTO::getQuantity)
|
|
|
.sum();
|
|
|
toCart.setTotalAmount(totalAmount);
|
|
|
toCart.setTotalQuantity(totalQuantity);
|
|
|
@@ -593,13 +593,13 @@ public class CartServiceImpl implements CartService {
|
|
|
}
|
|
|
|
|
|
// Redis中没有,查数据库
|
|
|
- LambdaQueryWrapper<WechatStoreCouponUsage> wrapper = new LambdaQueryWrapper<>();
|
|
|
- wrapper.eq(WechatStoreCouponUsage::getTableId, tableId);
|
|
|
- wrapper.eq(WechatStoreCouponUsage::getDeleteFlag, 0);
|
|
|
- wrapper.in(WechatStoreCouponUsage::getUsageStatus, 0, 1, 2); // 已标记使用、已下单、已支付
|
|
|
- wrapper.orderByDesc(WechatStoreCouponUsage::getCreatedTime);
|
|
|
+ LambdaQueryWrapper<StoreCouponUsage> wrapper = new LambdaQueryWrapper<>();
|
|
|
+ wrapper.eq(StoreCouponUsage::getTableId, tableId);
|
|
|
+ wrapper.eq(StoreCouponUsage::getDeleteFlag, 0);
|
|
|
+ wrapper.in(StoreCouponUsage::getUsageStatus, 0, 1, 2); // 已标记使用、已下单、已支付
|
|
|
+ wrapper.orderByDesc(StoreCouponUsage::getCreatedTime);
|
|
|
wrapper.last("LIMIT 1");
|
|
|
- WechatStoreCouponUsage usage = storeCouponUsageMapper.selectOne(wrapper);
|
|
|
+ StoreCouponUsage usage = storeCouponUsageMapper.selectOne(wrapper);
|
|
|
return usage != null;
|
|
|
}
|
|
|
|
|
|
@@ -610,22 +610,22 @@ public class CartServiceImpl implements CartService {
|
|
|
baseRedisService.setString(couponUsedKey, String.valueOf(couponId), (long) CART_EXPIRE_SECONDS);
|
|
|
|
|
|
// 保存到数据库
|
|
|
- WechatStoreTable table = storeTableMapper.selectById(tableId);
|
|
|
+ StoreTable table = storeTableMapper.selectById(tableId);
|
|
|
if (table == null) {
|
|
|
log.warn("桌号不存在, tableId={}", tableId);
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
// 检查是否已存在
|
|
|
- LambdaQueryWrapper<WechatStoreCouponUsage> wrapper = new LambdaQueryWrapper<>();
|
|
|
- wrapper.eq(WechatStoreCouponUsage::getTableId, tableId);
|
|
|
- wrapper.eq(WechatStoreCouponUsage::getCouponId, couponId);
|
|
|
- wrapper.eq(WechatStoreCouponUsage::getDeleteFlag, 0);
|
|
|
- WechatStoreCouponUsage existing = storeCouponUsageMapper.selectOne(wrapper);
|
|
|
+ LambdaQueryWrapper<StoreCouponUsage> wrapper = new LambdaQueryWrapper<>();
|
|
|
+ wrapper.eq(StoreCouponUsage::getTableId, tableId);
|
|
|
+ wrapper.eq(StoreCouponUsage::getCouponId, couponId);
|
|
|
+ wrapper.eq(StoreCouponUsage::getDeleteFlag, 0);
|
|
|
+ StoreCouponUsage existing = storeCouponUsageMapper.selectOne(wrapper);
|
|
|
|
|
|
if (existing == null) {
|
|
|
Date now = new Date();
|
|
|
- WechatStoreCouponUsage usage = new WechatStoreCouponUsage();
|
|
|
+ StoreCouponUsage usage = new StoreCouponUsage();
|
|
|
usage.setTableId(tableId);
|
|
|
usage.setStoreId(table.getStoreId());
|
|
|
usage.setCouponId(couponId);
|
|
|
@@ -651,21 +651,21 @@ public class CartServiceImpl implements CartService {
|
|
|
baseRedisService.delete(couponUsedKey);
|
|
|
|
|
|
// 更新数据库(逻辑删除未下单的记录,使用 MyBatis-Plus 的 deleteBatchIds)
|
|
|
- LambdaQueryWrapper<WechatStoreCouponUsage> wrapper = new LambdaQueryWrapper<>();
|
|
|
- wrapper.eq(WechatStoreCouponUsage::getTableId, tableId);
|
|
|
- wrapper.eq(WechatStoreCouponUsage::getDeleteFlag, 0);
|
|
|
- wrapper.eq(WechatStoreCouponUsage::getUsageStatus, 0); // 只删除已标记使用但未下单的
|
|
|
- List<WechatStoreCouponUsage> usageList = storeCouponUsageMapper.selectList(wrapper);
|
|
|
+ LambdaQueryWrapper<StoreCouponUsage> wrapper = new LambdaQueryWrapper<>();
|
|
|
+ wrapper.eq(StoreCouponUsage::getTableId, tableId);
|
|
|
+ wrapper.eq(StoreCouponUsage::getDeleteFlag, 0);
|
|
|
+ wrapper.eq(StoreCouponUsage::getUsageStatus, 0); // 只删除已标记使用但未下单的
|
|
|
+ List<StoreCouponUsage> usageList = storeCouponUsageMapper.selectList(wrapper);
|
|
|
if (usageList != null && !usageList.isEmpty()) {
|
|
|
List<Integer> usageIds = usageList.stream()
|
|
|
- .map(WechatStoreCouponUsage::getId)
|
|
|
+ .map(StoreCouponUsage::getId)
|
|
|
.collect(Collectors.toList());
|
|
|
// 使用 deleteBatchIds 进行逻辑删除(MyBatis-Plus 会自动处理 @TableLogic)
|
|
|
storeCouponUsageMapper.deleteBatchIds(usageIds);
|
|
|
}
|
|
|
|
|
|
// 更新桌号表的优惠券ID
|
|
|
- WechatStoreTable table = storeTableMapper.selectById(tableId);
|
|
|
+ StoreTable table = storeTableMapper.selectById(tableId);
|
|
|
if (table != null) {
|
|
|
table.setCurrentCouponId(null);
|
|
|
storeTableMapper.updateById(table);
|
|
|
@@ -703,7 +703,7 @@ public class CartServiceImpl implements CartService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public WechatCartDTO setDinerCount(Integer tableId, Integer dinerCount) {
|
|
|
+ public CartDTO setDinerCount(Integer tableId, Integer dinerCount) {
|
|
|
log.info("设置用餐人数, tableId={}, dinerCount={}", tableId, dinerCount);
|
|
|
|
|
|
if (dinerCount == null || dinerCount <= 0) {
|
|
|
@@ -711,14 +711,14 @@ public class CartServiceImpl implements CartService {
|
|
|
}
|
|
|
|
|
|
// 获取购物车
|
|
|
- WechatCartDTO cart = getCart(tableId);
|
|
|
- List<WechatCartItemDTO> items = cart.getItems();
|
|
|
+ CartDTO cart = getCart(tableId);
|
|
|
+ List<CartItemDTO> items = cart.getItems();
|
|
|
|
|
|
// 获取门店ID和餐具单价
|
|
|
Integer storeId = cart.getStoreId();
|
|
|
if (storeId == null) {
|
|
|
// 如果购物车中没有门店ID,从桌号获取
|
|
|
- WechatStoreTable table = storeTableMapper.selectById(tableId);
|
|
|
+ StoreTable table = storeTableMapper.selectById(tableId);
|
|
|
if (table != null) {
|
|
|
storeId = table.getStoreId();
|
|
|
}
|
|
|
@@ -728,7 +728,7 @@ public class CartServiceImpl implements CartService {
|
|
|
// 商铺未设置餐具费时,不往购物车加餐具;若已有餐具项则移除
|
|
|
if (tablewareUnitPrice == null || tablewareUnitPrice.compareTo(BigDecimal.ZERO) <= 0) {
|
|
|
log.info("门店未设置餐具费, storeId={},设置就餐人数时不添加餐具", storeId);
|
|
|
- WechatCartItemDTO existing = items.stream()
|
|
|
+ CartItemDTO existing = items.stream()
|
|
|
.filter(item -> TABLEWARE_CUISINE_ID.equals(item.getCuisineId()))
|
|
|
.findFirst()
|
|
|
.orElse(null);
|
|
|
@@ -737,7 +737,7 @@ public class CartServiceImpl implements CartService {
|
|
|
}
|
|
|
} else {
|
|
|
// 查找是否已存在餐具项
|
|
|
- WechatCartItemDTO tablewareItem = items.stream()
|
|
|
+ CartItemDTO tablewareItem = items.stream()
|
|
|
.filter(item -> TABLEWARE_CUISINE_ID.equals(item.getCuisineId()))
|
|
|
.findFirst()
|
|
|
.orElse(null);
|
|
|
@@ -754,7 +754,7 @@ public class CartServiceImpl implements CartService {
|
|
|
tablewareItem.setUnitPrice(tablewareUnitPrice);
|
|
|
tablewareItem.setSubtotalAmount(tablewareUnitPrice.multiply(BigDecimal.valueOf(dinerCount)));
|
|
|
} else {
|
|
|
- WechatCartItemDTO newTablewareItem = new WechatCartItemDTO();
|
|
|
+ CartItemDTO newTablewareItem = new CartItemDTO();
|
|
|
newTablewareItem.setCuisineId(TABLEWARE_CUISINE_ID);
|
|
|
newTablewareItem.setCuisineName(TABLEWARE_NAME);
|
|
|
newTablewareItem.setCuisineType(0);
|
|
|
@@ -770,10 +770,10 @@ public class CartServiceImpl implements CartService {
|
|
|
|
|
|
// 重新计算总金额和总数量
|
|
|
BigDecimal totalAmount = items.stream()
|
|
|
- .map(WechatCartItemDTO::getSubtotalAmount)
|
|
|
+ .map(CartItemDTO::getSubtotalAmount)
|
|
|
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
Integer totalQuantity = items.stream()
|
|
|
- .mapToInt(WechatCartItemDTO::getQuantity)
|
|
|
+ .mapToInt(CartItemDTO::getQuantity)
|
|
|
.sum();
|
|
|
cart.setTotalAmount(totalAmount);
|
|
|
cart.setTotalQuantity(totalQuantity);
|
|
|
@@ -785,7 +785,7 @@ public class CartServiceImpl implements CartService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public WechatCartDTO updateTablewareQuantity(Integer tableId, Integer quantity) {
|
|
|
+ public CartDTO updateTablewareQuantity(Integer tableId, Integer quantity) {
|
|
|
log.info("更新餐具数量, tableId={}, quantity={}", tableId, quantity);
|
|
|
|
|
|
if (quantity == null || quantity < 0) {
|
|
|
@@ -798,13 +798,13 @@ public class CartServiceImpl implements CartService {
|
|
|
}
|
|
|
|
|
|
// 获取购物车
|
|
|
- WechatCartDTO cart = getCart(tableId);
|
|
|
- List<WechatCartItemDTO> items = cart.getItems();
|
|
|
+ CartDTO cart = getCart(tableId);
|
|
|
+ List<CartItemDTO> items = cart.getItems();
|
|
|
|
|
|
// 获取门店ID和餐具单价
|
|
|
Integer storeId = cart.getStoreId();
|
|
|
if (storeId == null) {
|
|
|
- WechatStoreTable table = storeTableMapper.selectById(tableId);
|
|
|
+ StoreTable table = storeTableMapper.selectById(tableId);
|
|
|
if (table != null) {
|
|
|
storeId = table.getStoreId();
|
|
|
}
|
|
|
@@ -814,17 +814,17 @@ public class CartServiceImpl implements CartService {
|
|
|
// 商铺未设置餐具费(单价为0或未配置)时,不往购物车加餐具;若已有餐具项则移除
|
|
|
if (tablewareUnitPrice == null || tablewareUnitPrice.compareTo(BigDecimal.ZERO) <= 0) {
|
|
|
log.info("门店未设置餐具费, storeId={},不添加餐具到购物车", storeId);
|
|
|
- WechatCartItemDTO existing = items.stream()
|
|
|
+ CartItemDTO existing = items.stream()
|
|
|
.filter(item -> TABLEWARE_CUISINE_ID.equals(item.getCuisineId()))
|
|
|
.findFirst()
|
|
|
.orElse(null);
|
|
|
if (existing != null) {
|
|
|
items.remove(existing);
|
|
|
BigDecimal totalAmount = items.stream()
|
|
|
- .map(WechatCartItemDTO::getSubtotalAmount)
|
|
|
+ .map(CartItemDTO::getSubtotalAmount)
|
|
|
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
Integer totalQuantity = items.stream()
|
|
|
- .mapToInt(WechatCartItemDTO::getQuantity)
|
|
|
+ .mapToInt(CartItemDTO::getQuantity)
|
|
|
.sum();
|
|
|
cart.setTotalAmount(totalAmount);
|
|
|
cart.setTotalQuantity(totalQuantity);
|
|
|
@@ -834,7 +834,7 @@ public class CartServiceImpl implements CartService {
|
|
|
}
|
|
|
|
|
|
// 查找餐具项
|
|
|
- WechatCartItemDTO tablewareItem = items.stream()
|
|
|
+ CartItemDTO tablewareItem = items.stream()
|
|
|
.filter(item -> TABLEWARE_CUISINE_ID.equals(item.getCuisineId()))
|
|
|
.findFirst()
|
|
|
.orElse(null);
|
|
|
@@ -844,7 +844,7 @@ public class CartServiceImpl implements CartService {
|
|
|
Integer userId = TokenUtil.getCurrentUserId();
|
|
|
String userPhone = TokenUtil.getCurrentUserPhone();
|
|
|
|
|
|
- tablewareItem = new WechatCartItemDTO();
|
|
|
+ tablewareItem = new CartItemDTO();
|
|
|
tablewareItem.setCuisineId(TABLEWARE_CUISINE_ID);
|
|
|
tablewareItem.setCuisineName(TABLEWARE_NAME);
|
|
|
tablewareItem.setCuisineType(0); // 0表示餐具
|
|
|
@@ -869,10 +869,10 @@ public class CartServiceImpl implements CartService {
|
|
|
|
|
|
// 重新计算总金额和总数量
|
|
|
BigDecimal totalAmount = items.stream()
|
|
|
- .map(WechatCartItemDTO::getSubtotalAmount)
|
|
|
+ .map(CartItemDTO::getSubtotalAmount)
|
|
|
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
Integer totalQuantity = items.stream()
|
|
|
- .mapToInt(WechatCartItemDTO::getQuantity)
|
|
|
+ .mapToInt(CartItemDTO::getQuantity)
|
|
|
.sum();
|
|
|
cart.setTotalAmount(totalAmount);
|
|
|
cart.setTotalQuantity(totalQuantity);
|
|
|
@@ -884,12 +884,12 @@ public class CartServiceImpl implements CartService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public WechatCartDTO lockCartItems(Integer tableId) {
|
|
|
+ public CartDTO lockCartItems(Integer tableId) {
|
|
|
log.info("锁定购物车商品数量(设置已下单数量), tableId={}", tableId);
|
|
|
|
|
|
// 获取购物车
|
|
|
- WechatCartDTO cart = getCart(tableId);
|
|
|
- List<WechatCartItemDTO> items = cart.getItems();
|
|
|
+ CartDTO cart = getCart(tableId);
|
|
|
+ List<CartItemDTO> items = cart.getItems();
|
|
|
|
|
|
if (items == null || items.isEmpty()) {
|
|
|
log.warn("购物车为空,无需锁定, tableId={}", tableId);
|
|
|
@@ -898,7 +898,7 @@ public class CartServiceImpl implements CartService {
|
|
|
|
|
|
// 遍历所有商品,将当前数量设置为已下单数量
|
|
|
boolean hasChanges = false;
|
|
|
- for (WechatCartItemDTO item : items) {
|
|
|
+ for (CartItemDTO item : items) {
|
|
|
Integer currentQuantity = item.getQuantity();
|
|
|
Integer lockedQuantity = item.getLockedQuantity();
|
|
|
|
|
|
@@ -928,12 +928,12 @@ public class CartServiceImpl implements CartService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public WechatCartDTO unlockCartItems(Integer tableId) {
|
|
|
+ public CartDTO unlockCartItems(Integer tableId) {
|
|
|
log.info("解锁购物车商品数量(清除已下单数量), tableId={}", tableId);
|
|
|
|
|
|
// 获取购物车
|
|
|
- WechatCartDTO cart = getCart(tableId);
|
|
|
- List<WechatCartItemDTO> items = cart.getItems();
|
|
|
+ CartDTO cart = getCart(tableId);
|
|
|
+ List<CartItemDTO> items = cart.getItems();
|
|
|
|
|
|
if (items == null || items.isEmpty()) {
|
|
|
log.info("购物车为空,无需解锁, tableId={}", tableId);
|
|
|
@@ -942,7 +942,7 @@ public class CartServiceImpl implements CartService {
|
|
|
|
|
|
// 遍历所有商品,清除已下单数量(lockedQuantity)
|
|
|
boolean hasChanges = false;
|
|
|
- for (WechatCartItemDTO item : items) {
|
|
|
+ for (CartItemDTO item : items) {
|
|
|
if (item.getLockedQuantity() != null && item.getLockedQuantity() > 0) {
|
|
|
// 清除已下单数量,允许重新下单
|
|
|
item.setLockedQuantity(null);
|
|
|
@@ -966,7 +966,7 @@ public class CartServiceImpl implements CartService {
|
|
|
* 保存购物车到Redis和数据库(优化后的双写策略)
|
|
|
* Redis同步写入(保证实时性),数据库异步批量写入(提高性能)
|
|
|
*/
|
|
|
- private void saveCart(WechatCartDTO cart) {
|
|
|
+ private void saveCart(CartDTO cart) {
|
|
|
// 1. 同步保存到Redis(保证实时性)
|
|
|
saveCartToRedis(cart);
|
|
|
|
|
|
@@ -983,7 +983,7 @@ public class CartServiceImpl implements CartService {
|
|
|
/**
|
|
|
* 保存购物车到Redis
|
|
|
*/
|
|
|
- private void saveCartToRedis(WechatCartDTO cart) {
|
|
|
+ private void saveCartToRedis(CartDTO cart) {
|
|
|
String cartKey = CART_KEY_PREFIX + cart.getTableId();
|
|
|
String cartJson = JSON.toJSONString(cart);
|
|
|
baseRedisService.setString(cartKey, cartJson, (long) CART_EXPIRE_SECONDS);
|
|
|
@@ -993,19 +993,19 @@ public class CartServiceImpl implements CartService {
|
|
|
* 保存购物车到数据库(优化后的批量操作版本)
|
|
|
* 使用批量逻辑删除和批量插入,提高性能
|
|
|
*/
|
|
|
- private void saveCartToDatabase(WechatCartDTO cart) {
|
|
|
+ private void saveCartToDatabase(CartDTO cart) {
|
|
|
try {
|
|
|
Date now = new Date();
|
|
|
Integer userId = TokenUtil.getCurrentUserId();
|
|
|
|
|
|
// 1. 批量逻辑删除该桌号的所有购物车记录(使用 MyBatis-Plus 的 deleteBatchIds)
|
|
|
- LambdaQueryWrapper<WechatStoreCart> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
- queryWrapper.eq(WechatStoreCart::getTableId, cart.getTableId())
|
|
|
- .eq(WechatStoreCart::getDeleteFlag, 0);
|
|
|
- List<WechatStoreCart> existingCartList = storeCartMapper.selectList(queryWrapper);
|
|
|
+ LambdaQueryWrapper<StoreCart> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper.eq(StoreCart::getTableId, cart.getTableId())
|
|
|
+ .eq(StoreCart::getDeleteFlag, 0);
|
|
|
+ List<StoreCart> existingCartList = storeCartMapper.selectList(queryWrapper);
|
|
|
if (existingCartList != null && !existingCartList.isEmpty()) {
|
|
|
List<Integer> cartIds = existingCartList.stream()
|
|
|
- .map(WechatStoreCart::getId)
|
|
|
+ .map(StoreCart::getId)
|
|
|
.collect(Collectors.toList());
|
|
|
// 使用 deleteBatchIds 进行逻辑删除(MyBatis-Plus 会自动处理 @TableLogic)
|
|
|
storeCartMapper.deleteBatchIds(cartIds);
|
|
|
@@ -1013,9 +1013,9 @@ public class CartServiceImpl implements CartService {
|
|
|
|
|
|
// 2. 批量插入新的购物车记录
|
|
|
if (cart.getItems() != null && !cart.getItems().isEmpty()) {
|
|
|
- List<WechatStoreCart> cartList = new ArrayList<>(cart.getItems().size());
|
|
|
- for (WechatCartItemDTO item : cart.getItems()) {
|
|
|
- WechatStoreCart storeCart = new WechatStoreCart();
|
|
|
+ List<StoreCart> cartList = new ArrayList<>(cart.getItems().size());
|
|
|
+ for (CartItemDTO item : cart.getItems()) {
|
|
|
+ StoreCart storeCart = new StoreCart();
|
|
|
storeCart.setTableId(cart.getTableId());
|
|
|
storeCart.setStoreId(cart.getStoreId());
|
|
|
storeCart.setCuisineId(item.getCuisineId());
|
|
|
@@ -1038,7 +1038,7 @@ public class CartServiceImpl implements CartService {
|
|
|
// 批量插入(如果数量较少,直接循环插入;如果数量较多,可以考虑分批插入)
|
|
|
if (cartList.size() <= 50) {
|
|
|
// 小批量直接插入
|
|
|
- for (WechatStoreCart storeCart : cartList) {
|
|
|
+ for (StoreCart storeCart : cartList) {
|
|
|
storeCartMapper.insert(storeCart);
|
|
|
}
|
|
|
} else {
|
|
|
@@ -1046,8 +1046,8 @@ public class CartServiceImpl implements CartService {
|
|
|
int batchSize = 50;
|
|
|
for (int i = 0; i < cartList.size(); i += batchSize) {
|
|
|
int end = Math.min(i + batchSize, cartList.size());
|
|
|
- List<WechatStoreCart> batch = cartList.subList(i, end);
|
|
|
- for (WechatStoreCart storeCart : batch) {
|
|
|
+ List<StoreCart> batch = cartList.subList(i, end);
|
|
|
+ for (StoreCart storeCart : batch) {
|
|
|
storeCartMapper.insert(storeCart);
|
|
|
}
|
|
|
}
|
|
|
@@ -1055,7 +1055,7 @@ public class CartServiceImpl implements CartService {
|
|
|
}
|
|
|
|
|
|
// 3. 更新桌号表的购物车统计
|
|
|
- WechatStoreTable table = storeTableMapper.selectById(cart.getTableId());
|
|
|
+ StoreTable table = storeTableMapper.selectById(cart.getTableId());
|
|
|
if (table != null) {
|
|
|
table.setCartItemCount(cart.getTotalQuantity());
|
|
|
table.setCartTotalAmount(cart.getTotalAmount());
|