| Line 1... |
Line 1... |
| 1 |
package com.spice.profitmandi.web.controller;
|
1 |
package com.spice.profitmandi.web.controller;
|
| 2 |
|
2 |
|
| 3 |
import java.io.ByteArrayInputStream;
|
- |
|
| 4 |
import java.io.ByteArrayOutputStream;
|
- |
|
| 5 |
import java.io.IOException;
|
- |
|
| 6 |
import java.io.InputStream;
|
- |
|
| 7 |
import java.time.LocalDateTime;
|
- |
|
| 8 |
import java.time.LocalTime;
|
- |
|
| 9 |
import java.time.format.DateTimeFormatter;
|
- |
|
| 10 |
import java.util.ArrayList;
|
- |
|
| 11 |
import java.util.Arrays;
|
- |
|
| 12 |
import java.util.Comparator;
|
- |
|
| 13 |
import java.util.HashMap;
|
- |
|
| 14 |
import java.util.HashSet;
|
- |
|
| 15 |
import java.util.List;
|
- |
|
| 16 |
import java.util.Map;
|
- |
|
| 17 |
import java.util.Optional;
|
- |
|
| 18 |
import java.util.Set;
|
- |
|
| 19 |
import java.util.stream.Collectors;
|
- |
|
| 20 |
|
- |
|
| 21 |
import javax.servlet.http.HttpServletRequest;
|
- |
|
| 22 |
import javax.servlet.http.HttpServletResponse;
|
- |
|
| 23 |
|
- |
|
| 24 |
import org.apache.commons.lang3.StringUtils;
|
- |
|
| 25 |
import org.apache.http.conn.HttpHostConnectException;
|
- |
|
| 26 |
import org.apache.logging.log4j.LogManager;
|
- |
|
| 27 |
import org.apache.logging.log4j.Logger;
|
- |
|
| 28 |
import org.json.JSONArray;
|
- |
|
| 29 |
import org.json.JSONObject;
|
- |
|
| 30 |
import org.springframework.beans.factory.annotation.Autowired;
|
- |
|
| 31 |
import org.springframework.beans.factory.annotation.Value;
|
- |
|
| 32 |
import org.springframework.core.io.InputStreamResource;
|
- |
|
| 33 |
import org.springframework.http.HttpHeaders;
|
- |
|
| 34 |
import org.springframework.http.HttpStatus;
|
- |
|
| 35 |
import org.springframework.http.MediaType;
|
- |
|
| 36 |
import org.springframework.http.ResponseEntity;
|
- |
|
| 37 |
import org.springframework.stereotype.Controller;
|
- |
|
| 38 |
import org.springframework.transaction.annotation.Transactional;
|
- |
|
| 39 |
import org.springframework.web.bind.annotation.GetMapping;
|
- |
|
| 40 |
import org.springframework.web.bind.annotation.PathVariable;
|
- |
|
| 41 |
import org.springframework.web.bind.annotation.RequestBody;
|
- |
|
| 42 |
import org.springframework.web.bind.annotation.RequestMapping;
|
- |
|
| 43 |
import org.springframework.web.bind.annotation.RequestMethod;
|
- |
|
| 44 |
import org.springframework.web.bind.annotation.RequestParam;
|
- |
|
| 45 |
|
- |
|
| 46 |
import com.eclipsesource.json.JsonObject;
|
3 |
import com.eclipsesource.json.JsonObject;
|
| 47 |
import com.google.gson.Gson;
|
4 |
import com.google.gson.Gson;
|
| 48 |
import com.google.gson.reflect.TypeToken;
|
5 |
import com.google.gson.reflect.TypeToken;
|
| 49 |
import com.spice.profitmandi.common.enumuration.MessageType;
|
6 |
import com.spice.profitmandi.common.enumuration.MessageType;
|
| 50 |
import com.spice.profitmandi.common.enumuration.SchemeType;
|
7 |
import com.spice.profitmandi.common.enumuration.SchemeType;
|
| 51 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
8 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
| 52 |
import com.spice.profitmandi.common.model.CreatePendingOrderItem;
|
- |
|
| 53 |
import com.spice.profitmandi.common.model.CreatePendingOrderRequest;
|
- |
|
| 54 |
import com.spice.profitmandi.common.model.CustomRetailer;
|
- |
|
| 55 |
import com.spice.profitmandi.common.model.PdfModel;
|
9 |
import com.spice.profitmandi.common.model.*;
|
| 56 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
- |
|
| 57 |
import com.spice.profitmandi.common.model.SendNotificationModel;
|
- |
|
| 58 |
import com.spice.profitmandi.common.model.UserInfo;
|
- |
|
| 59 |
import com.spice.profitmandi.common.solr.SolrService;
|
10 |
import com.spice.profitmandi.common.solr.SolrService;
|
| 60 |
import com.spice.profitmandi.common.util.FormattingUtils;
|
11 |
import com.spice.profitmandi.common.util.FormattingUtils;
|
| 61 |
import com.spice.profitmandi.common.util.PdfUtils;
|
12 |
import com.spice.profitmandi.common.util.PdfUtils;
|
| 62 |
import com.spice.profitmandi.common.util.Utils;
|
13 |
import com.spice.profitmandi.common.util.Utils;
|
| 63 |
import com.spice.profitmandi.common.web.client.RestClient;
|
14 |
import com.spice.profitmandi.common.web.client.RestClient;
|
| Line 66... |
Line 17... |
| 66 |
import com.spice.profitmandi.dao.entity.catalog.TagListing;
|
17 |
import com.spice.profitmandi.dao.entity.catalog.TagListing;
|
| 67 |
import com.spice.profitmandi.dao.entity.dtr.ScratchOffer;
|
18 |
import com.spice.profitmandi.dao.entity.dtr.ScratchOffer;
|
| 68 |
import com.spice.profitmandi.dao.entity.dtr.User;
|
19 |
import com.spice.profitmandi.dao.entity.dtr.User;
|
| 69 |
import com.spice.profitmandi.dao.entity.dtr.WebListing;
|
20 |
import com.spice.profitmandi.dao.entity.dtr.WebListing;
|
| 70 |
import com.spice.profitmandi.dao.entity.dtr.WebOffer;
|
21 |
import com.spice.profitmandi.dao.entity.dtr.WebOffer;
|
| 71 |
import com.spice.profitmandi.dao.entity.fofo.Customer;
|
22 |
import com.spice.profitmandi.dao.entity.fofo.*;
|
| 72 |
import com.spice.profitmandi.dao.entity.fofo.CustomerAddress;
|
- |
|
| 73 |
import com.spice.profitmandi.dao.entity.fofo.FofoOrder;
|
- |
|
| 74 |
import com.spice.profitmandi.dao.entity.fofo.FofoOrderItem;
|
- |
|
| 75 |
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
|
- |
|
| 76 |
import com.spice.profitmandi.dao.entity.fofo.PendingOrder;
|
- |
|
| 77 |
import com.spice.profitmandi.dao.entity.fofo.PendingOrderItem;
|
- |
|
| 78 |
import com.spice.profitmandi.dao.entity.fofo.PincodePartner;
|
- |
|
| 79 |
import com.spice.profitmandi.dao.enumuration.dtr.OtpType;
|
23 |
import com.spice.profitmandi.dao.enumuration.dtr.OtpType;
|
| 80 |
import com.spice.profitmandi.dao.enumuration.inventory.ScratchedGift;
|
24 |
import com.spice.profitmandi.dao.enumuration.inventory.ScratchedGift;
|
| 81 |
import com.spice.profitmandi.dao.enumuration.transaction.OrderStatus;
|
25 |
import com.spice.profitmandi.dao.enumuration.transaction.OrderStatus;
|
| 82 |
import com.spice.profitmandi.dao.model.AddCartRequest;
|
- |
|
| 83 |
import com.spice.profitmandi.dao.model.CartItem;
|
26 |
import com.spice.profitmandi.dao.model.*;
|
| 84 |
import com.spice.profitmandi.dao.model.CartItemResponseModel;
|
- |
|
| 85 |
import com.spice.profitmandi.dao.model.CartResponse;
|
- |
|
| 86 |
import com.spice.profitmandi.dao.model.CustomerOrderDetail;
|
- |
|
| 87 |
import com.spice.profitmandi.dao.model.DateRangeModel;
|
- |
|
| 88 |
import com.spice.profitmandi.dao.repository.catalog.ItemRepository;
|
27 |
import com.spice.profitmandi.dao.repository.catalog.ItemRepository;
|
| 89 |
import com.spice.profitmandi.dao.repository.catalog.TagListingRepository;
|
28 |
import com.spice.profitmandi.dao.repository.catalog.TagListingRepository;
|
| 90 |
import com.spice.profitmandi.dao.repository.cs.CsService;
|
29 |
import com.spice.profitmandi.dao.repository.cs.CsService;
|
| 91 |
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
|
- |
|
| 92 |
import com.spice.profitmandi.dao.repository.dtr.ScratchOfferRepository;
|
- |
|
| 93 |
import com.spice.profitmandi.dao.repository.dtr.UserAccountRepository;
|
- |
|
| 94 |
import com.spice.profitmandi.dao.repository.dtr.WebListingRepository;
|
- |
|
| 95 |
import com.spice.profitmandi.dao.repository.dtr.WebOfferRepository;
|
30 |
import com.spice.profitmandi.dao.repository.dtr.*;
|
| 96 |
import com.spice.profitmandi.dao.repository.dtr.WebProductListingRepository;
|
- |
|
| 97 |
import com.spice.profitmandi.dao.repository.fofo.CurrentInventorySnapshotRepository;
|
- |
|
| 98 |
import com.spice.profitmandi.dao.repository.fofo.CustomerAddressRepository;
|
- |
|
| 99 |
import com.spice.profitmandi.dao.repository.fofo.CustomerRepository;
|
31 |
import com.spice.profitmandi.dao.repository.fofo.*;
|
| 100 |
import com.spice.profitmandi.dao.repository.fofo.FofoOrderItemRepository;
|
- |
|
| 101 |
import com.spice.profitmandi.dao.repository.fofo.FofoOrderRepository;
|
- |
|
| 102 |
import com.spice.profitmandi.dao.repository.fofo.PendingOrderItemRepository;
|
- |
|
| 103 |
import com.spice.profitmandi.dao.repository.fofo.PendingOrderRepository;
|
- |
|
| 104 |
import com.spice.profitmandi.dao.repository.fofo.PendingOrderService;
|
- |
|
| 105 |
import com.spice.profitmandi.dao.repository.fofo.PincodePartnerRepository;
|
- |
|
| 106 |
import com.spice.profitmandi.dao.repository.inventory.ItemAvailabilityCacheRepository;
|
32 |
import com.spice.profitmandi.dao.repository.inventory.ItemAvailabilityCacheRepository;
|
| 107 |
import com.spice.profitmandi.dao.repository.user.UserRepository;
|
33 |
import com.spice.profitmandi.dao.repository.user.UserRepository;
|
| 108 |
import com.spice.profitmandi.service.CustomerService;
|
34 |
import com.spice.profitmandi.service.CustomerService;
|
| 109 |
import com.spice.profitmandi.service.EmailService;
|
35 |
import com.spice.profitmandi.service.EmailService;
|
| 110 |
import com.spice.profitmandi.service.NotificationService;
|
36 |
import com.spice.profitmandi.service.NotificationService;
|
| 111 |
import com.spice.profitmandi.service.authentication.RoleManager;
|
37 |
import com.spice.profitmandi.service.authentication.RoleManager;
|
| 112 |
import com.spice.profitmandi.service.inventory.AvailabilityModel;
|
- |
|
| 113 |
import com.spice.profitmandi.service.inventory.FofoAvailabilityInfo;
|
- |
|
| 114 |
import com.spice.profitmandi.service.inventory.FofoCatalogResponse;
|
- |
|
| 115 |
import com.spice.profitmandi.service.inventory.InventoryService;
|
38 |
import com.spice.profitmandi.service.inventory.*;
|
| 116 |
import com.spice.profitmandi.service.inventory.SaholicInventoryService;
|
- |
|
| 117 |
import com.spice.profitmandi.service.order.OrderService;
|
39 |
import com.spice.profitmandi.service.order.OrderService;
|
| 118 |
import com.spice.profitmandi.service.scheme.SchemeService;
|
40 |
import com.spice.profitmandi.service.scheme.SchemeService;
|
| 119 |
import com.spice.profitmandi.service.user.RetailerService;
|
41 |
import com.spice.profitmandi.service.user.RetailerService;
|
| 120 |
import com.spice.profitmandi.web.processor.OtpProcessor;
|
42 |
import com.spice.profitmandi.web.processor.OtpProcessor;
|
| 121 |
import com.spice.profitmandi.web.res.DealBrands;
|
43 |
import com.spice.profitmandi.web.res.DealBrands;
|
| 122 |
import com.spice.profitmandi.web.res.DealObjectResponse;
|
44 |
import com.spice.profitmandi.web.res.DealObjectResponse;
|
| 123 |
import com.spice.profitmandi.web.res.DealsResponse;
|
45 |
import com.spice.profitmandi.web.res.DealsResponse;
|
| 124 |
import com.spice.profitmandi.web.res.ValidateCartResponse;
|
46 |
import com.spice.profitmandi.web.res.ValidateCartResponse;
|
| 125 |
import com.spice.profitmandi.web.services.PartnerIndexService;
|
47 |
import com.spice.profitmandi.web.services.PartnerIndexService;
|
| 126 |
|
- |
|
| 127 |
import io.swagger.annotations.ApiImplicitParam;
|
48 |
import io.swagger.annotations.ApiImplicitParam;
|
| 128 |
import io.swagger.annotations.ApiImplicitParams;
|
49 |
import io.swagger.annotations.ApiImplicitParams;
|
| 129 |
import io.swagger.annotations.ApiOperation;
|
50 |
import io.swagger.annotations.ApiOperation;
|
| - |
|
51 |
import org.apache.commons.lang3.StringUtils;
|
| - |
|
52 |
import org.apache.http.conn.HttpHostConnectException;
|
| - |
|
53 |
import org.apache.logging.log4j.LogManager;
|
| - |
|
54 |
import org.apache.logging.log4j.Logger;
|
| - |
|
55 |
import org.json.JSONArray;
|
| - |
|
56 |
import org.json.JSONObject;
|
| - |
|
57 |
import org.springframework.beans.factory.annotation.Autowired;
|
| - |
|
58 |
import org.springframework.beans.factory.annotation.Value;
|
| - |
|
59 |
import org.springframework.core.io.InputStreamResource;
|
| - |
|
60 |
import org.springframework.http.HttpHeaders;
|
| - |
|
61 |
import org.springframework.http.HttpStatus;
|
| - |
|
62 |
import org.springframework.http.MediaType;
|
| - |
|
63 |
import org.springframework.http.ResponseEntity;
|
| - |
|
64 |
import org.springframework.stereotype.Controller;
|
| - |
|
65 |
import org.springframework.transaction.annotation.Transactional;
|
| - |
|
66 |
import org.springframework.web.bind.annotation.*;
|
| - |
|
67 |
|
| - |
|
68 |
import javax.servlet.http.HttpServletRequest;
|
| - |
|
69 |
import javax.servlet.http.HttpServletResponse;
|
| - |
|
70 |
import java.io.ByteArrayInputStream;
|
| - |
|
71 |
import java.io.ByteArrayOutputStream;
|
| - |
|
72 |
import java.io.IOException;
|
| - |
|
73 |
import java.io.InputStream;
|
| - |
|
74 |
import java.time.LocalDateTime;
|
| - |
|
75 |
import java.time.LocalTime;
|
| - |
|
76 |
import java.time.format.DateTimeFormatter;
|
| - |
|
77 |
import java.util.*;
|
| - |
|
78 |
import java.util.stream.Collectors;
|
| 130 |
|
79 |
|
| 131 |
@Controller
|
80 |
@Controller
|
| 132 |
@Transactional(rollbackFor = Throwable.class)
|
81 |
@Transactional(rollbackFor = Throwable.class)
|
| 133 |
public class StoreController {
|
82 |
public class StoreController {
|
| 134 |
|
83 |
|
| Line 809... |
Line 758... |
| 809 |
int totalAmount = 0;
|
758 |
int totalAmount = 0;
|
| 810 |
int totalQty = 0;
|
759 |
int totalQty = 0;
|
| 811 |
for (CartItem cartItem : cartItems) {
|
760 |
for (CartItem cartItem : cartItems) {
|
| 812 |
Item item = itemsMap.get(cartItem.getItemId());
|
761 |
Item item = itemsMap.get(cartItem.getItemId());
|
| 813 |
TagListing tagListing = tagListingMap.get(cartItem.getItemId());
|
762 |
TagListing tagListing = tagListingMap.get(cartItem.getItemId());
|
| 814 |
Float cashback = schemeService.getItemSchemeCashBack().get(cartItem.getItemId());
|
763 |
Float cashback = schemeService.getCatalogSchemeCashBack().get(itemsMap.get(cartItem.getItemId()).getCatalogItemId());
|
| 815 |
cashback = cashback == null ? 0 : cashback;
|
764 |
cashback = cashback == null ? 0 : cashback;
|
| 816 |
float itemSellingPrice = tagListing.getMop() - cashback;
|
765 |
float itemSellingPrice = tagListing.getMop() - cashback;
|
| 817 |
CartItemResponseModel cartItemResponseModel = new CartItemResponseModel();
|
766 |
CartItemResponseModel cartItemResponseModel = new CartItemResponseModel();
|
| 818 |
cartItemResponseModel.setSellingPrice(cartItem.getSellingPrice());
|
767 |
cartItemResponseModel.setSellingPrice(cartItem.getSellingPrice());
|
| 819 |
if (itemSellingPrice != cartItem.getSellingPrice()) {
|
768 |
if (itemSellingPrice != cartItem.getSellingPrice()) {
|
| Line 954... |
Line 903... |
| 954 |
fdi.setMrp(childItem.getDouble("mrp_f"));
|
903 |
fdi.setMrp(childItem.getDouble("mrp_f"));
|
| 955 |
fdi.setMop((float) childItem.getDouble("mop_f"));
|
904 |
fdi.setMop((float) childItem.getDouble("mop_f"));
|
| 956 |
fdi.setColor(childItem.has("color_s") ? childItem.getString("color_s") : "");
|
905 |
fdi.setColor(childItem.has("color_s") ? childItem.getString("color_s") : "");
|
| 957 |
fdi.setTagId(childItem.getInt("tagId_i"));
|
906 |
fdi.setTagId(childItem.getInt("tagId_i"));
|
| 958 |
fdi.setItem_id(itemId);
|
907 |
fdi.setItem_id(itemId);
|
| 959 |
Float cashBack = schemeService.getItemSchemeCashBack().get(itemId);
|
908 |
Float cashBack = schemeService.getCatalogSchemeCashBack().get(ffdr.getCatalogId());
|
| 960 |
cashBack = cashBack == null ? 0 : cashBack;
|
909 |
cashBack = cashBack == null ? 0 : cashBack;
|
| 961 |
// TODO:Dont commit
|
910 |
// TODO:Dont commit
|
| 962 |
// fdi.setCashback(Math.min(100, fdi.getMop()));
|
911 |
// fdi.setCashback(Math.min(100, fdi.getMop()));
|
| 963 |
fdi.setCashback(cashBack);
|
912 |
fdi.setCashback(cashBack);
|
| 964 |
fdi.setMinBuyQuantity(1);
|
913 |
fdi.setMinBuyQuantity(1);
|