Skip to content
Extraits de code Groupes Projets
Valider 057e4ac8 rédigé par anas elhaddad's avatar anas elhaddad
Parcourir les fichiers

fix search by client.

parent 1d642809
Branches
1 requête de fusion!110Fix/search by client.
Pipeline #11354 réussi avec les étapes
in 59 secondes
......@@ -11,6 +11,22 @@
### Removed
- Features that have been removed.
### Fixed
- fix search by client.
- ## [1.0.70-RELEASE]
### Added
- Added a method to verify cart consistency with the database.
### Changed
- change common version
### Deprecated
- Soon-to-be removed features.
### Removed
- Features that have been removed.
### Fixed
- Fix save promo code usage history.
......
......@@ -2,6 +2,8 @@ package com.marketingconfort.mydressin.mappers;
import com.marketingconfort.mydressin.common.cart.enumurations.ItemCartStatus;
import com.marketingconfort.mydressin.common.cart.models.Cart;
import com.marketingconfort.mydressin.common.cart.models.ItemCart;
import com.marketingconfort.mydressin.common.stockmanagement.enumurations.ProductType;
import com.marketingconfort.mydressin.dtos.CartDTO;
import com.marketingconfort.mydressin.dtos.ClientCartDTO;
import com.marketingconfort.mydressin.services.ExternalApiService;
......@@ -11,6 +13,7 @@ import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.List;
import java.util.stream.Collectors;
@Service
......@@ -57,10 +60,14 @@ public class CartMapper {
public ClientCartDTO cartToClientCartDTO(Cart cart)
{
List<ItemCart> itemCarts = cart.getItems()
.stream()
.filter(itemCart -> itemCart.getStatus()!=ItemCartStatus.DELETED_SITE && itemCart.getStatus()!=ItemCartStatus.DELETED_BO )
.toList();
ClientCartDTO clientCartDTO = new ClientCartDTO();
clientCartDTO.setId(cart.getId());
clientCartDTO.setItemsCount(cart.getItemsCount());
clientCartDTO.setSubTotalPrice(cart.getSubTotalPrice());
clientCartDTO.setItemsCount(itemCarts.size());
return clientCartDTO;
}
......
......@@ -78,10 +78,10 @@ public interface CartRepository extends JpaRepository<Cart, Long>, JpaSpecificat
ItemSource source);
@Query("SELECT c FROM Cart c " +
"WHERE EXISTS (SELECT ic1 FROM c.items ic1 WHERE ic1.status != 'DELETED_SITE' ) " +
"WHERE EXISTS (SELECT ic1 FROM c.items ic1 WHERE ic1.status != 'DELETED_SITE' AND ic1.status != 'DELETED_BO' ) " +
" AND LOWER(c.status) = 'open' " +
" AND (0L in :clientIds OR c.clientId IN :clientIds) " +
" AND (0L in :productIds OR EXISTS (SELECT ic2 FROM c.items ic2 WHERE ic2.productId IN :productIds))")
" AND ((-1L) in :clientIds OR c.clientId IN :clientIds) " +
" AND ((-1L) in :productIds OR EXISTS (SELECT ic2 FROM c.items ic2 WHERE ic2.productId IN :productIds))")
Page<Cart> getCartClientPage(@Param("clientIds") List<Long> clientIds,
@Param("productIds") List<Long> productIds,
Pageable pageable);
......
......@@ -994,10 +994,10 @@ public class CartServiceImp implements CartService {
.filter(Objects::nonNull)
.collect(Collectors.toList());
if (clientIds.isEmpty()) {
clientIds = List.of(0L);
clientIds = List.of(-1L);
}
if (productIds.isEmpty()) {
productIds = List.of(0L);
productIds = List.of(-1L);
}
Map<Long, ClientDTO> clientMap = clients.stream()
.collect(Collectors.toMap(ClientDTO::getUid, Function.identity(), (a, b) -> a));
......@@ -1035,7 +1035,11 @@ public class CartServiceImp implements CartService {
List<ProductDetailsCartDTO> productDetailsCartDTOS = cart.getItems().stream()
.map(item -> mapItemToProductDetails(item, productMap))
.filter(Objects::nonNull)
.collect(Collectors.toList());
.toList();
cartDTO.setSubTotalPrice(productDetailsCartDTOS.stream()
.mapToDouble(ProductDetailsCartDTO::getTotalPrice)
.sum());
cartDTO.setClientDTO(clientDTO);
cartDTO.setProductDetailsCartDTOS(productDetailsCartDTOS);
return cartDTO;
......
0% ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter