seatonwan9
2025-08-24 5fd8f535ef44ef055d91673740491b9c9177aa89
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
package com.webmanage.service;
 
import com.webmanage.dto.CartItemDTO;
import com.webmanage.dto.CartQueryDTO;
import com.webmanage.vo.CartVO;
import com.webmanage.vo.CartItemVO;
 
import java.util.List;
 
/**
 * 购物车服务接口
 */
public interface CartService {
    /**
     * 添加商品到购物车(Redis + 数据库)
     */
    boolean addToCart(Long userId, Long unitId, CartItemDTO cartItemDTO);
    
    /**
     * 从购物车移除商品(Redis + 数据库)
     */
    boolean removeFromCart(Long userId, Long unitId, Long pricingId);
    
    /**
     * 更新购物车商品数量(Redis + 数据库)
     */
    boolean updateCartItemQuantity(Long userId, Long unitId, Long pricingId, Integer quantity);
    
    /**
     * 清空购物车(Redis + 数据库)
     */
    boolean clearCart(Long userId, Long unitId);
    
    /**
     * 获取购物车信息(优先Redis,失败则从数据库加载)
     */
    CartVO getCart(Long userId, Long unitId);
    
    /**
     * 获取购物车商品列表(优先Redis,失败则从数据库加载)
     */
    List<CartItemVO> getCartItems(Long userId, Long unitId);
    
    /**
     * 检查购物车商品库存
     */
    boolean checkCartItemStock(Long userId, Long unitId, Long pricingId);
    
    /**
     * 批量删除购物车商品(Redis + 数据库)
     */
    boolean batchRemoveFromCart(Long userId, Long unitId, List<Long> pricingIds);
    
    /**
     * 获取购物车商品数量(优先Redis,失败则从数据库加载)
     */
    Integer getCartItemCount(Long userId, Long unitId);
    
    /**
     * 从数据库加载购物车数据到Redis
     */
    boolean loadCartFromDatabase(Long userId, Long unitId);
    
    /**
     * 同步Redis数据到数据库
     */
    boolean syncCartToDatabase(Long userId, Long unitId);
    
    /**
     * 检查购物车数据一致性
     */
    boolean checkCartConsistency(Long userId, Long unitId);
}