From ac918503bb5e8fad007348e7e39ba7275b75f334 Mon Sep 17 00:00:00 2001 From: p-honggang.li <p-honggang.li@pcitc.com> Date: 星期一, 08 九月 2025 23:33:32 +0800 Subject: [PATCH] 修改取消订单,修改状态为已取消 --- 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