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

add order restoration

parent cc7a7b26
Branches
1 requête de fusion!122MS-99/add order restoration
Pipeline #16426 réussi avec les étapes
in 1 minute et 32 secondes
## [1.0.77-RELEASE]
### Added
- add order restoration
### Changed
- Changes in existing functionality.
### Deprecated
- Soon-to-be removed features.
### Removed
- Features that have been removed.
### Fixed
- Any bug fixes.
### Security
- Any security improvements.
## [1.0.76-RELEASE] ## [1.0.76-RELEASE]
### Added ### Added
- add isExpired condition to cart pagination - add isExpired condition to cart pagination
......
...@@ -31,4 +31,9 @@ public class Paths { ...@@ -31,4 +31,9 @@ public class Paths {
public static final String COUNT_TYPE_SALE_SESSION = "/count-type"; public static final String COUNT_TYPE_SALE_SESSION = "/count-type";
public static final String DELETED_SALE_SESSION_PAGE = "/deleted/page"; public static final String DELETED_SALE_SESSION_PAGE = "/deleted/page";
public static final String DELETED_COUNT_TYPE_SALE_SESSION = "/deleted/count-type"; public static final String DELETED_COUNT_TYPE_SALE_SESSION = "/deleted/count-type";
public static final String RESTORE_ORDER = "/restore/{orderId}";
} }
...@@ -9,6 +9,7 @@ import com.marketingconfort.mydressin.exceptions.ProductOutOfStockException; ...@@ -9,6 +9,7 @@ import com.marketingconfort.mydressin.exceptions.ProductOutOfStockException;
import com.marketingconfort.mydressin.exceptions.SaleSessionExpiredException; import com.marketingconfort.mydressin.exceptions.SaleSessionExpiredException;
import com.marketingconfort.mydressin.exceptions.SaleSessionNotFoundException; import com.marketingconfort.mydressin.exceptions.SaleSessionNotFoundException;
import com.marketingconfort.mydressin.services.SaleSessionService; import com.marketingconfort.mydressin.services.SaleSessionService;
import com.marketingconfort.starter.core.exceptions.FunctionalException;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import org.springframework.format.annotation.DateTimeFormat; import org.springframework.format.annotation.DateTimeFormat;
...@@ -66,6 +67,8 @@ public class SaleSessionController { ...@@ -66,6 +67,8 @@ public class SaleSessionController {
} }
@PostMapping("/addProductToUnregisteredCartFromLive") @PostMapping("/addProductToUnregisteredCartFromLive")
@PreAuthorize("@securityCustomExpressions.isClientTrusted(#requestAuthorization)") @PreAuthorize("@securityCustomExpressions.isClientTrusted(#requestAuthorization)")
public CompletableFuture<ResponseEntity<?>> addProductToUnregisteredCartFromLive( public CompletableFuture<ResponseEntity<?>> addProductToUnregisteredCartFromLive(
...@@ -205,5 +208,12 @@ public class SaleSessionController { ...@@ -205,5 +208,12 @@ public class SaleSessionController {
return saleSessionService.getDeletedTypeCount(name, type, startDate, endDate); return saleSessionService.getDeletedTypeCount(name, type, startDate, endDate);
} }
@PutMapping(Paths.RESTORE_ORDER)
public ResponseEntity<CompletableFuture<SessionOrderDTO>> restoreOrder(@PathVariable Long orderId) throws FunctionalException {
return ResponseEntity.ok(saleSessionService.restoreSaleSessionDetails(orderId));
}
} }
...@@ -6,6 +6,7 @@ import com.marketingconfort.mydressin.dtos.SaleSessionDTO; ...@@ -6,6 +6,7 @@ import com.marketingconfort.mydressin.dtos.SaleSessionDTO;
import com.marketingconfort.mydressin.dtos.SessionOrderDTO; import com.marketingconfort.mydressin.dtos.SessionOrderDTO;
import com.marketingconfort.mydressin.dtos.ItemRequestDTO; import com.marketingconfort.mydressin.dtos.ItemRequestDTO;
import com.marketingconfort.mydressin.exceptions.SaleSessionExpiredException; import com.marketingconfort.mydressin.exceptions.SaleSessionExpiredException;
import com.marketingconfort.starter.core.exceptions.FunctionalException;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
...@@ -41,4 +42,5 @@ public interface SaleSessionService { ...@@ -41,4 +42,5 @@ public interface SaleSessionService {
List<String[]> getDeletedTypeCount(String name , String type, Date startDate, Date endDate); List<String[]> getDeletedTypeCount(String name , String type, Date startDate, Date endDate);
void exportYesterdaySaleSessions(); void exportYesterdaySaleSessions();
CompletableFuture<SessionOrderDTO> restoreSaleSessionDetails(Long oderId) throws FunctionalException;
} }
package com.marketingconfort.mydressin.services.impl; package com.marketingconfort.mydressin.services.impl;
import com.marketingconfort.mydressin.common.cart.dtos.GiftCardDTO;
import com.marketingconfort.mydressin.common.cart.dtos.ProductStockDTO; import com.marketingconfort.mydressin.common.cart.dtos.ProductStockDTO;
import com.marketingconfort.mydressin.common.cart.dtos.ProductStockRequestDTO; import com.marketingconfort.mydressin.common.cart.dtos.ProductStockRequestDTO;
import com.marketingconfort.mydressin.common.cart.enumurations.ItemCartStatus; import com.marketingconfort.mydressin.common.cart.enumurations.ItemCartStatus;
import com.marketingconfort.mydressin.common.cart.enumurations.ItemSource; import com.marketingconfort.mydressin.common.cart.enumurations.ItemSource;
import com.marketingconfort.mydressin.common.cart.enumurations.OrderStatus; import com.marketingconfort.mydressin.common.cart.enumurations.OrderStatus;
import com.marketingconfort.mydressin.common.cart.models.*; import com.marketingconfort.mydressin.common.cart.models.*;
import com.marketingconfort.mydressin.common.stockmanagement.enumurations.ProductType;
import com.marketingconfort.mydressin.config.FTPConfig; import com.marketingconfort.mydressin.config.FTPConfig;
import com.marketingconfort.mydressin.dtos.SaleSessionDTO; import com.marketingconfort.mydressin.dtos.SaleSessionDTO;
import com.marketingconfort.mydressin.dtos.SessionOrderDTO; import com.marketingconfort.mydressin.dtos.SessionOrderDTO;
...@@ -18,6 +20,7 @@ import com.marketingconfort.mydressin.mappers.SaleSessionMapper; ...@@ -18,6 +20,7 @@ import com.marketingconfort.mydressin.mappers.SaleSessionMapper;
import com.marketingconfort.mydressin.repositories.SaleSessionRepository; import com.marketingconfort.mydressin.repositories.SaleSessionRepository;
import com.marketingconfort.mydressin.repositories.SessionOrderRepository; import com.marketingconfort.mydressin.repositories.SessionOrderRepository;
import com.marketingconfort.mydressin.services.*; import com.marketingconfort.mydressin.services.*;
import com.marketingconfort.starter.core.exceptions.FunctionalException;
import com.opencsv.CSVWriter; import com.opencsv.CSVWriter;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
...@@ -61,6 +64,7 @@ public class SaleSessionServiceImp implements SaleSessionService { ...@@ -61,6 +64,7 @@ public class SaleSessionServiceImp implements SaleSessionService {
private final SessionOrderService sessionOrderService; private final SessionOrderService sessionOrderService;
private final UnregisteredCartService unregisteredCartService; private final UnregisteredCartService unregisteredCartService;
private final SessionOrderRepository sessionOrderRepository; private final SessionOrderRepository sessionOrderRepository;
private final ExternalApiService externalApiService;
private FTPConfig ftpConfig; private FTPConfig ftpConfig;
...@@ -325,7 +329,7 @@ public class SaleSessionServiceImp implements SaleSessionService { ...@@ -325,7 +329,7 @@ public class SaleSessionServiceImp implements SaleSessionService {
return stringList; return stringList;
} }
@Scheduled(cron = "0 0 7 * * ?") @Scheduled(cron = "0 0 * * * ?")
@Override @Override
public void exportYesterdaySaleSessions() { public void exportYesterdaySaleSessions() {
LocalDate yesterday = LocalDate.now().minusDays(1); LocalDate yesterday = LocalDate.now().minusDays(1);
...@@ -403,6 +407,37 @@ public class SaleSessionServiceImp implements SaleSessionService { ...@@ -403,6 +407,37 @@ public class SaleSessionServiceImp implements SaleSessionService {
} }
} }
@Override
@Transactional
public CompletableFuture<SessionOrderDTO> restoreSaleSessionDetails(Long orderId) throws FunctionalException {
SessionOrder sessionOrder = orderRepository.findById(orderId)
.orElseThrow(() -> new FunctionalException("Order not found"));
ItemRequestDTO itemRequestDTO = new ItemRequestDTO();
itemRequestDTO.setClientId(sessionOrder.getClientId());
itemRequestDTO.setSessionId(sessionOrder.getSaleSession() != null ? sessionOrder.getSaleSession().getId() : null);
itemRequestDTO.setProductId(sessionOrder.getItemCart().getProductId());
itemRequestDTO.setQuantity(sessionOrder.getItemCart().getQuantity());
itemRequestDTO.setType(sessionOrder.getItemCart().getProductType());
itemRequestDTO.setUgs(sessionOrder.getItemCart().getUgs());
itemRequestDTO.setUseWebStockForLive(true);
if (sessionOrder.getItemCart().getProductType() != null && sessionOrder.getItemCart().getProductType().equals(ProductType.GIFT_CARD)) {
itemRequestDTO.setGiftCardDTO(externalApiService.getGiftCardById(sessionOrder.getItemCart().getProductId()));
itemRequestDTO.setUseWebStockForLive(false);
}
itemRequestDTO.setLiveId(sessionOrder.getSaleSession().getLive());
CompletableFuture<SessionOrderDTO> sessionOrderDTO = (sessionOrder.isRegisteredClient()) ? addProductToCartFromLive(itemRequestDTO) : addProductToUnregisteredCartFromLive(itemRequestDTO);
orderRepository.deleteById(orderId);
return sessionOrderDTO;
}
private void uploadFileToFTPServer(String fileName, byte[] fileData) { private void uploadFileToFTPServer(String fileName, byte[] fileData) {
FTPClient ftpClient = new FTPClient(); FTPClient ftpClient = new FTPClient();
try { try {
......
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