Untitled
unknown
plain_text
a year ago
4.2 kB
2
Indexable
Never
public OrderFetchResponseVO FetchOrderLevelDataServiceImpl(OderFetchVO oderFetchVO) throws SQLException, com.tcs.ion.nf.util.SystemException, SystemException { String orderId = oderFetchVO.getParentOrderId(); OrderFetchResponseVO orderFetchResponseVO = new OrderFetchResponseVO(); List<CartDetailsVO> cartDetailsVOList = new ArrayList<CartDetailsVO>(); List<OrderDetails> orderDetailsList = nexarcOrderRepository.findOrderDataByorderId(orderId); if(orderDetailsList == null || orderDetailsList.isEmpty()) { throw new SystemException("No Record found for OrderId"); } if((oderFetchVO.getPaymentTransactionNo() !=null || oderFetchVO.getTransactionId() !=null || oderFetchVO.getItemIdentifier() != null) && oderFetchVO.getCartId() == null) { throw new SystemException("Please send CartId"); } if(oderFetchVO.getCartId() != null || oderFetchVO.getContextID() != null) { if(oderFetchVO.getCartId() != null && oderFetchVO.getContextID() != null) { throw new SystemException("Send either CartId or ContextId"); } if(oderFetchVO.getContextID() != null && oderFetchVO.getCartId() == null) { OrderCartDetails cartData = orderCartDetailsRepository.findByContextId(oderFetchVO.getContextID()); if(cartData == null){ throw new SystemException("No Record found for ContextId"); } for(OrderDetails orderDetails : orderDetailsList) { if(!(orderDetails.getCartId().contains(cartData.getCartId()))){ throw new SystemException("ContextId Does not belongs to the OrderId"); } } oderFetchVO.setCartId(cartData.getCartId()); } for(OrderDetails orderDetails : orderDetailsList) { if(!(orderDetails.getCartId().contains(oderFetchVO.getCartId()))){ throw new SystemException("CartId Does not belongs to the OrderId"); } } CartDetailsVO cartDetailsVO = new CartDetailsVO(); cartDetailsVO.setCartId(oderFetchVO.getCartId()); if(oderFetchVO.getPaymentTransactionNo() !=null || oderFetchVO.getTransactionId() !=null) { if(oderFetchVO.getPaymentTransactionNo() != null && oderFetchVO.getTransactionId() != null) { throw new SystemException("Send either PaymentTransactionNo or TransactionId"); } if(oderFetchVO.getPaymentTransactionNo() == null) { OrderTransactionForm paymentTransactionNo = orderTransactionRepository.findByTransactionId(oderFetchVO.getTransactionId()); if(paymentTransactionNo == null) { throw new SystemException("No Record found for TransactionId"); } oderFetchVO.setPaymentTransactionNo(paymentTransactionNo.getOtdPaymentTransactionNo()); } List<PaymentDetails> PaymentDetailsList = new ArrayList<PaymentDetails>(); PaymentDetails paymentDetails = new PaymentDetails(); paymentDetails.setPaymentId(oderFetchVO.getPaymentTransactionNo()); PaymentDetailsList.add(paymentDetails); cartDetailsVO.setPaymentDetails(PaymentDetailsList); } if(oderFetchVO.getItemIdentifier() != null) { List<CartItems> CartItemsList = new ArrayList<CartItems>(); CartItems cartItems = new CartItems(); cartItems.setItemIdentifier(oderFetchVO.getItemIdentifier()); CartItemsList.add(cartItems); cartDetailsVO.setCartItems(CartItemsList); } cartDetailsVOList.add(cartDetailsVO); }else { for (int i = 0 ; i<orderDetailsList.size(); i++) { CartDetailsVO cartDetailsVO = new CartDetailsVO(); OrderDetails orderDetailsMap = orderDetailsList.get(i); cartDetailsVO.setCartId(orderDetailsMap.getCartId()); cartDetailsVOList.add(cartDetailsVO); } } orderFetchResponseVO.setParentOrderId(orderDetailsList.get(0).getOrderId()); orderFetchResponseVO.setOfferingType(orderDetailsList.get(0).getProductTypeFk()); orderFetchResponseVO.setParentOrderStatus(orderDetailsList.get(0).getStatus()); orderFetchResponseVO.setBusinessID(orderDetailsList.get(0).getBusinessIdFk()); orderFetchResponseVO.setTotalPayableAmount(orderDetailsList.get(0).getTotalPaidAmount()); orderFetchResponseVO.setCartDetailsVO(cartDetailsVOList); return FetchCartDetailsServiceImpl(oderFetchVO,orderFetchResponseVO); }