From f386341ce2bb205bd056a7611d3ae678ca106e65 Mon Sep 17 00:00:00 2001
From: p-honggang.li <p-honggang.li@pcitc.com>
Date: 星期一, 08 九月 2025 16:26:09 +0800
Subject: [PATCH] 修改token参数类型问题

---
 src/main/java/com/webmanage/service/impl/CartPersistenceServiceImpl.java |   17 ++++++++++-------
 1 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/src/main/java/com/webmanage/service/impl/CartPersistenceServiceImpl.java b/src/main/java/com/webmanage/service/impl/CartPersistenceServiceImpl.java
index cdbe2c2..ccb18c0 100644
--- a/src/main/java/com/webmanage/service/impl/CartPersistenceServiceImpl.java
+++ b/src/main/java/com/webmanage/service/impl/CartPersistenceServiceImpl.java
@@ -8,6 +8,7 @@
 import org.springframework.scheduling.annotation.Async;
 import org.springframework.scheduling.annotation.AsyncConfigurer;
 import org.springframework.stereotype.Service;
+import org.springframework.util.StringUtils;
 
 import javax.annotation.Resource;
 import java.time.LocalDateTime;
@@ -20,14 +21,16 @@
 
     @Override
     @Async("asyncExecutor")
-    public void saveOrUpdate(Long userId, Long unitId, CartItemVO item) {
+    public void saveOrUpdate(String userId, String unitId, CartItemVO item) {
         try {
             Cart cart = new Cart();
             BeanUtils.copyProperties(item, cart);
             cart.setUserId(userId);
-            cart.setUnitId(unitId);
+            if(StringUtils.hasText(unitId)){
+                cart.setUnitId(unitId);
+            }
             cart.setUpdateTime(LocalDateTime.now());
-            Cart existing = cartMapper.selectByUserIdUnitIdAndPricingId(userId, unitId, item.getPricingId());
+            Cart existing = cartMapper.selectByUserIdUnitIdAndPricingId(userId, unitId,item.getProductId(), item.getPricingId());
             if (existing != null) {
                 cart.setId(existing.getId());
                 cartMapper.updateById(cart);
@@ -40,9 +43,9 @@
 
     @Override
     @Async("asyncExecutor")
-    public void remove(Long userId, Long unitId, Long pricingId) {
+    public void remove(String userId, String unitId, String productId,Long pricingId) {
         try {
-            Cart existing = cartMapper.selectByUserIdUnitIdAndPricingId(userId, unitId, pricingId);
+            Cart existing = cartMapper.selectByUserIdUnitIdAndPricingId(userId, unitId, productId,pricingId);
             if (existing != null) {
                 cartMapper.deleteById(existing.getId());
             }
@@ -51,9 +54,9 @@
 
     @Override
     @Async("asyncExecutor")
-    public void clear(Long userId, Long unitId) {
+    public void clear(String userId, String unitId,String productId) {
         try {
-            java.util.List<Cart> cartItems = cartMapper.selectByUserIdAndUnitId(userId, unitId);
+            java.util.List<Cart> cartItems = cartMapper.selectByUserIdAndUnitId(userId, unitId, productId);
             for (Cart item : cartItems) {
                 cartMapper.deleteById(item.getId());
             }

--
Gitblit v1.8.0