| Line 1... |
Line 1... |
| 1 |
package com.spice.profitmandi.service.order;
|
1 |
package com.spice.profitmandi.service.order;
|
| 2 |
|
2 |
|
| 3 |
import java.time.LocalDate;
|
- |
|
| 4 |
import java.time.LocalDateTime;
|
- |
|
| 5 |
import java.time.LocalTime;
|
- |
|
| 6 |
import java.util.AbstractMap.SimpleEntry;
|
- |
|
| 7 |
import java.util.ArrayList;
|
- |
|
| 8 |
import java.util.Arrays;
|
- |
|
| 9 |
import java.util.HashMap;
|
- |
|
| 10 |
import java.util.HashSet;
|
- |
|
| 11 |
import java.util.Iterator;
|
- |
|
| 12 |
import java.util.List;
|
- |
|
| 13 |
import java.util.Map;
|
- |
|
| 14 |
import java.util.Optional;
|
- |
|
| 15 |
import java.util.Random;
|
- |
|
| 16 |
import java.util.Set;
|
- |
|
| 17 |
import java.util.function.Function;
|
- |
|
| 18 |
import java.util.stream.Collectors;
|
- |
|
| 19 |
|
- |
|
| 20 |
import javax.persistence.criteria.CriteriaBuilder;
|
- |
|
| 21 |
import javax.persistence.criteria.CriteriaQuery;
|
- |
|
| 22 |
import javax.persistence.criteria.Predicate;
|
- |
|
| 23 |
import javax.persistence.criteria.Root;
|
- |
|
| 24 |
|
- |
|
| 25 |
import org.apache.logging.log4j.LogManager;
|
- |
|
| 26 |
import org.apache.logging.log4j.Logger;
|
- |
|
| 27 |
import org.hibernate.Session;
|
- |
|
| 28 |
import org.hibernate.SessionFactory;
|
- |
|
| 29 |
import org.json.JSONObject;
|
- |
|
| 30 |
import org.springframework.beans.factory.annotation.Autowired;
|
- |
|
| 31 |
import org.springframework.beans.factory.annotation.Qualifier;
|
- |
|
| 32 |
import org.springframework.beans.factory.annotation.Value;
|
- |
|
| 33 |
import org.springframework.cache.annotation.Cacheable;
|
- |
|
| 34 |
import org.springframework.stereotype.Component;
|
- |
|
| 35 |
|
- |
|
| 36 |
import com.spice.profitmandi.common.enumuration.ItemType;
|
3 |
import com.spice.profitmandi.common.enumuration.ItemType;
|
| 37 |
import com.spice.profitmandi.common.enumuration.SearchType;
|
4 |
import com.spice.profitmandi.common.enumuration.SearchType;
|
| 38 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
5 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
| 39 |
import com.spice.profitmandi.common.model.BadReturnRequest;
|
- |
|
| 40 |
import com.spice.profitmandi.common.model.CartFofo;
|
- |
|
| 41 |
import com.spice.profitmandi.common.model.CreateOrderRequest;
|
- |
|
| 42 |
import com.spice.profitmandi.common.model.CreditNotePdfModel;
|
- |
|
| 43 |
import com.spice.profitmandi.common.model.CustomAddress;
|
- |
|
| 44 |
import com.spice.profitmandi.common.model.CustomCustomer;
|
- |
|
| 45 |
import com.spice.profitmandi.common.model.CustomFofoOrderItem;
|
- |
|
| 46 |
import com.spice.profitmandi.common.model.CustomInsurancePolicy;
|
- |
|
| 47 |
import com.spice.profitmandi.common.model.CustomOrderItem;
|
- |
|
| 48 |
import com.spice.profitmandi.common.model.CustomPaymentOption;
|
- |
|
| 49 |
import com.spice.profitmandi.common.model.CustomRetailer;
|
- |
|
| 50 |
import com.spice.profitmandi.common.model.FoiBadReturnRequest;
|
- |
|
| 51 |
import com.spice.profitmandi.common.model.GstRate;
|
6 |
import com.spice.profitmandi.common.model.*;
|
| 52 |
import com.spice.profitmandi.common.model.InsuranceModel;
|
- |
|
| 53 |
import com.spice.profitmandi.common.model.ItemDescriptionModel;
|
- |
|
| 54 |
import com.spice.profitmandi.common.model.ItemIdQuantityAvailability;
|
- |
|
| 55 |
import com.spice.profitmandi.common.model.PdfModel;
|
- |
|
| 56 |
import com.spice.profitmandi.common.model.PriceModel;
|
- |
|
| 57 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
- |
|
| 58 |
import com.spice.profitmandi.common.model.Quantity;
|
- |
|
| 59 |
import com.spice.profitmandi.common.model.SerialNumberDetail;
|
- |
|
| 60 |
import com.spice.profitmandi.common.util.FormattingUtils;
|
7 |
import com.spice.profitmandi.common.util.FormattingUtils;
|
| 61 |
import com.spice.profitmandi.common.util.StringUtils;
|
8 |
import com.spice.profitmandi.common.util.StringUtils;
|
| 62 |
import com.spice.profitmandi.common.util.Utils;
|
9 |
import com.spice.profitmandi.common.util.Utils;
|
| 63 |
import com.spice.profitmandi.common.web.client.RestClient;
|
10 |
import com.spice.profitmandi.common.web.client.RestClient;
|
| 64 |
import com.spice.profitmandi.dao.entity.catalog.Item;
|
11 |
import com.spice.profitmandi.dao.entity.catalog.Item;
|
| 65 |
import com.spice.profitmandi.dao.entity.catalog.TagListing;
|
12 |
import com.spice.profitmandi.dao.entity.catalog.TagListing;
|
| 66 |
import com.spice.profitmandi.dao.entity.dtr.InsurancePolicy;
|
- |
|
| 67 |
import com.spice.profitmandi.dao.entity.dtr.PaymentOptionTransaction;
|
- |
|
| 68 |
import com.spice.profitmandi.dao.entity.dtr.Retailer;
|
- |
|
| 69 |
import com.spice.profitmandi.dao.entity.dtr.ScratchOffer;
|
- |
|
| 70 |
import com.spice.profitmandi.dao.entity.dtr.User;
|
13 |
import com.spice.profitmandi.dao.entity.dtr.*;
|
| 71 |
import com.spice.profitmandi.dao.entity.fofo.CurrentInventorySnapshot;
|
- |
|
| 72 |
import com.spice.profitmandi.dao.entity.fofo.Customer;
|
14 |
import com.spice.profitmandi.dao.entity.fofo.*;
|
| 73 |
import com.spice.profitmandi.dao.entity.fofo.CustomerAddress;
|
- |
|
| 74 |
import com.spice.profitmandi.dao.entity.fofo.CustomerCreditNote;
|
- |
|
| 75 |
import com.spice.profitmandi.dao.entity.fofo.CustomerReturnItem;
|
- |
|
| 76 |
import com.spice.profitmandi.dao.entity.fofo.FofoLineItem;
|
- |
|
| 77 |
import com.spice.profitmandi.dao.entity.fofo.FofoOrder;
|
- |
|
| 78 |
import com.spice.profitmandi.dao.entity.fofo.FofoOrderItem;
|
- |
|
| 79 |
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
|
- |
|
| 80 |
import com.spice.profitmandi.dao.entity.fofo.HygieneData;
|
- |
|
| 81 |
import com.spice.profitmandi.dao.entity.fofo.InventoryItem;
|
- |
|
| 82 |
import com.spice.profitmandi.dao.entity.fofo.InvoiceNumberGenerationSequence;
|
- |
|
| 83 |
import com.spice.profitmandi.dao.entity.fofo.LiveDemoSerialNumber;
|
- |
|
| 84 |
import com.spice.profitmandi.dao.entity.fofo.PendingOrder;
|
- |
|
| 85 |
import com.spice.profitmandi.dao.entity.fofo.PendingOrderItem;
|
- |
|
| 86 |
import com.spice.profitmandi.dao.entity.fofo.ScanRecord;
|
- |
|
| 87 |
import com.spice.profitmandi.dao.entity.inventory.State;
|
15 |
import com.spice.profitmandi.dao.entity.inventory.State;
|
| 88 |
import com.spice.profitmandi.dao.entity.transaction.Order;
|
16 |
import com.spice.profitmandi.dao.entity.transaction.Order;
|
| 89 |
import com.spice.profitmandi.dao.entity.user.Address;
|
17 |
import com.spice.profitmandi.dao.entity.user.Address;
|
| 90 |
import com.spice.profitmandi.dao.entity.user.Counter;
|
18 |
import com.spice.profitmandi.dao.entity.user.Counter;
|
| 91 |
import com.spice.profitmandi.dao.entity.user.PrivateDealUser;
|
19 |
import com.spice.profitmandi.dao.entity.user.PrivateDealUser;
|
| Line 98... |
Line 26... |
| 98 |
import com.spice.profitmandi.dao.enumuration.inventory.ScratchedGift;
|
26 |
import com.spice.profitmandi.dao.enumuration.inventory.ScratchedGift;
|
| 99 |
import com.spice.profitmandi.dao.enumuration.transaction.OrderStatus;
|
27 |
import com.spice.profitmandi.dao.enumuration.transaction.OrderStatus;
|
| 100 |
import com.spice.profitmandi.dao.repository.catalog.ItemRepository;
|
28 |
import com.spice.profitmandi.dao.repository.catalog.ItemRepository;
|
| 101 |
import com.spice.profitmandi.dao.repository.catalog.StateGstRateRepository;
|
29 |
import com.spice.profitmandi.dao.repository.catalog.StateGstRateRepository;
|
| 102 |
import com.spice.profitmandi.dao.repository.catalog.TagListingRepository;
|
30 |
import com.spice.profitmandi.dao.repository.catalog.TagListingRepository;
|
| 103 |
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
|
- |
|
| 104 |
import com.spice.profitmandi.dao.repository.dtr.InsurancePolicyRepository;
|
- |
|
| 105 |
import com.spice.profitmandi.dao.repository.dtr.InsuranceProviderRepository;
|
- |
|
| 106 |
import com.spice.profitmandi.dao.repository.dtr.Mongo;
|
31 |
import com.spice.profitmandi.dao.repository.dtr.*;
|
| 107 |
import com.spice.profitmandi.dao.repository.dtr.PaymentOptionTransactionRepository;
|
- |
|
| 108 |
import com.spice.profitmandi.dao.repository.dtr.PolicyNumberGenerationSequenceRepository;
|
- |
|
| 109 |
import com.spice.profitmandi.dao.repository.dtr.RetailerRegisteredAddressRepository;
|
- |
|
| 110 |
import com.spice.profitmandi.dao.repository.dtr.RetailerRepository;
|
- |
|
| 111 |
import com.spice.profitmandi.dao.repository.dtr.ScratchOfferRepository;
|
- |
|
| 112 |
import com.spice.profitmandi.dao.repository.dtr.UserAccountRepository;
|
- |
|
| 113 |
import com.spice.profitmandi.dao.repository.dtr.UserRepository;
|
32 |
import com.spice.profitmandi.dao.repository.fofo.*;
|
| 114 |
import com.spice.profitmandi.dao.repository.fofo.CurrentInventorySnapshotRepository;
|
- |
|
| 115 |
import com.spice.profitmandi.dao.repository.fofo.CustomerAddressRepository;
|
- |
|
| 116 |
import com.spice.profitmandi.dao.repository.fofo.CustomerCreditNoteRepository;
|
- |
|
| 117 |
import com.spice.profitmandi.dao.repository.fofo.CustomerRepository;
|
- |
|
| 118 |
import com.spice.profitmandi.dao.repository.fofo.CustomerReturnItemRepository;
|
- |
|
| 119 |
import com.spice.profitmandi.dao.repository.fofo.FofoLineItemRepository;
|
- |
|
| 120 |
import com.spice.profitmandi.dao.repository.fofo.FofoOrderItemRepository;
|
- |
|
| 121 |
import com.spice.profitmandi.dao.repository.fofo.FofoOrderRepository;
|
- |
|
| 122 |
import com.spice.profitmandi.dao.repository.fofo.HygieneDataRepository;
|
- |
|
| 123 |
import com.spice.profitmandi.dao.repository.fofo.InventoryItemRepository;
|
- |
|
| 124 |
import com.spice.profitmandi.dao.repository.fofo.InvoiceNumberGenerationSequenceRepository;
|
- |
|
| 125 |
import com.spice.profitmandi.dao.repository.fofo.LiveDemoBillingRespository;
|
- |
|
| 126 |
import com.spice.profitmandi.dao.repository.fofo.PaymentOptionRepository;
|
- |
|
| 127 |
import com.spice.profitmandi.dao.repository.fofo.PendingOrderItemRepository;
|
- |
|
| 128 |
import com.spice.profitmandi.dao.repository.fofo.PendingOrderRepository;
|
- |
|
| 129 |
import com.spice.profitmandi.dao.repository.fofo.PurchaseReturnItemRepository;
|
- |
|
| 130 |
import com.spice.profitmandi.dao.repository.fofo.ScanRecordRepository;
|
- |
|
| 131 |
import com.spice.profitmandi.dao.repository.inventory.StateRepository;
|
33 |
import com.spice.profitmandi.dao.repository.inventory.StateRepository;
|
| 132 |
import com.spice.profitmandi.dao.repository.transaction.OrderRepository;
|
34 |
import com.spice.profitmandi.dao.repository.transaction.OrderRepository;
|
| 133 |
import com.spice.profitmandi.dao.repository.user.AddressRepository;
|
35 |
import com.spice.profitmandi.dao.repository.user.AddressRepository;
|
| 134 |
import com.spice.profitmandi.dao.repository.user.CounterRepository;
|
36 |
import com.spice.profitmandi.dao.repository.user.CounterRepository;
|
| 135 |
import com.spice.profitmandi.dao.repository.user.PrivateDealUserRepository;
|
37 |
import com.spice.profitmandi.dao.repository.user.PrivateDealUserRepository;
|
| Line 141... |
Line 43... |
| 141 |
import com.spice.profitmandi.service.offers.ItemCriteria;
|
43 |
import com.spice.profitmandi.service.offers.ItemCriteria;
|
| 142 |
import com.spice.profitmandi.service.pricing.PricingService;
|
44 |
import com.spice.profitmandi.service.pricing.PricingService;
|
| 143 |
import com.spice.profitmandi.service.scheme.SchemeService;
|
45 |
import com.spice.profitmandi.service.scheme.SchemeService;
|
| 144 |
import com.spice.profitmandi.service.user.RetailerService;
|
46 |
import com.spice.profitmandi.service.user.RetailerService;
|
| 145 |
import com.spice.profitmandi.service.wallet.WalletService;
|
47 |
import com.spice.profitmandi.service.wallet.WalletService;
|
| - |
|
48 |
import org.apache.logging.log4j.LogManager;
|
| - |
|
49 |
import org.apache.logging.log4j.Logger;
|
| - |
|
50 |
import org.hibernate.Session;
|
| - |
|
51 |
import org.hibernate.SessionFactory;
|
| - |
|
52 |
import org.json.JSONObject;
|
| - |
|
53 |
import org.springframework.beans.factory.annotation.Autowired;
|
| - |
|
54 |
import org.springframework.beans.factory.annotation.Qualifier;
|
| - |
|
55 |
import org.springframework.beans.factory.annotation.Value;
|
| - |
|
56 |
import org.springframework.cache.annotation.Cacheable;
|
| - |
|
57 |
import org.springframework.stereotype.Component;
|
| - |
|
58 |
|
| - |
|
59 |
import javax.persistence.criteria.CriteriaBuilder;
|
| - |
|
60 |
import javax.persistence.criteria.CriteriaQuery;
|
| - |
|
61 |
import javax.persistence.criteria.Predicate;
|
| - |
|
62 |
import javax.persistence.criteria.Root;
|
| - |
|
63 |
import java.time.LocalDate;
|
| - |
|
64 |
import java.time.LocalDateTime;
|
| - |
|
65 |
import java.time.LocalTime;
|
| - |
|
66 |
import java.util.AbstractMap.SimpleEntry;
|
| - |
|
67 |
import java.util.*;
|
| - |
|
68 |
import java.util.function.Function;
|
| - |
|
69 |
import java.util.stream.Collectors;
|
| 146 |
|
70 |
|
| 147 |
@Component
|
71 |
@Component
|
| 148 |
public class OrderServiceImpl implements OrderService {
|
72 |
public class OrderServiceImpl implements OrderService {
|
| 149 |
|
73 |
|
| 150 |
private static final Logger LOGGER = LogManager.getLogger(OrderServiceImpl.class);
|
74 |
private static final Logger LOGGER = LogManager.getLogger(OrderServiceImpl.class);
|
| Line 2066... |
Line 1990... |
| 2066 |
itemCriteria.setEndPrice(0);
|
1990 |
itemCriteria.setEndPrice(0);
|
| 2067 |
itemCriteria.setFeaturedPhone(false);
|
1991 |
itemCriteria.setFeaturedPhone(false);
|
| 2068 |
itemCriteria.setSmartPhone(true);
|
1992 |
itemCriteria.setSmartPhone(true);
|
| 2069 |
itemCriteria.setCatalogIds(new ArrayList<>());
|
1993 |
itemCriteria.setCatalogIds(new ArrayList<>());
|
| 2070 |
itemCriteria.setExcludeCatalogIds(new ArrayList<>());
|
1994 |
itemCriteria.setExcludeCatalogIds(new ArrayList<>());
|
| 2071 |
Predicate itemPredicate = itemRepository.getItemPredicate(itemCriteria, query, cb, fofoOrderItem, "dp");
|
1995 |
Predicate itemPredicate = itemRepository.getItemPredicate(itemCriteria, query, cb, fofoOrderItem);
|
| 2072 |
Predicate finalPredicate = cb.and(itemPredicate, p2, p3, p4, p5);
|
1996 |
Predicate finalPredicate = cb.and(itemPredicate, p2, p3, p4, p5);
|
| 2073 |
query = query.multiselect(fofoOrder.get(ProfitMandiConstants.FOFO_ID), cb.count(fofoOrder))
|
1997 |
query = query.multiselect(fofoOrder.get(ProfitMandiConstants.FOFO_ID), cb.count(fofoOrder))
|
| 2074 |
.where(finalPredicate).groupBy(fofoOrder.get(ProfitMandiConstants.FOFO_ID));
|
1998 |
.where(finalPredicate).groupBy(fofoOrder.get(ProfitMandiConstants.FOFO_ID));
|
| 2075 |
List<SimpleEntry> simpleEntries = session.createQuery(query).getResultList();
|
1999 |
List<SimpleEntry> simpleEntries = session.createQuery(query).getResultList();
|
| 2076 |
Map<Integer, Long> returnMap = new HashMap<>();
|
2000 |
Map<Integer, Long> returnMap = new HashMap<>();
|