| | |
| | | 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); |
| | |
| | | |
| | | @Override |
| | | @Async("asyncExecutor") |
| | | public void remove(String userId, String 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()); |
| | | } |
| | |
| | | |
| | | @Override |
| | | @Async("asyncExecutor") |
| | | public void clear(String userId, String 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()); |
| | | } |