| | |
| | | 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; |
| | |
| | | |
| | | @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()); |
| | | if (existing != null) { |
| | |
| | | |
| | | @Override |
| | | @Async("asyncExecutor") |
| | | public void remove(Long userId, Long unitId, Long pricingId) { |
| | | public void remove(String userId, String unitId, Long pricingId) { |
| | | try { |
| | | Cart existing = cartMapper.selectByUserIdUnitIdAndPricingId(userId, unitId, pricingId); |
| | | if (existing != null) { |
| | |
| | | |
| | | @Override |
| | | @Async("asyncExecutor") |
| | | public void clear(Long userId, Long unitId) { |
| | | public void clear(String userId, String unitId) { |
| | | try { |
| | | java.util.List<Cart> cartItems = cartMapper.selectByUserIdAndUnitId(userId, unitId); |
| | | for (Cart item : cartItems) { |