| Line 1... |
Line 1... |
| 1 |
package com.spice.profitmandi.web.controller;
|
1 |
package com.spice.profitmandi.web.controller;
|
| 2 |
|
2 |
|
| 3 |
import java.util.ArrayList;
|
- |
|
| 4 |
import java.util.Arrays;
|
- |
|
| 5 |
import java.util.Comparator;
|
- |
|
| 6 |
import java.util.HashMap;
|
- |
|
| 7 |
import java.util.HashSet;
|
- |
|
| 8 |
import java.util.Iterator;
|
- |
|
| 9 |
import java.util.List;
|
- |
|
| 10 |
import java.util.Map;
|
- |
|
| 11 |
import java.util.Optional;
|
- |
|
| 12 |
import java.util.Set;
|
- |
|
| 13 |
import java.util.concurrent.atomic.AtomicInteger;
|
- |
|
| 14 |
import java.util.stream.Collectors;
|
- |
|
| 15 |
|
- |
|
| 16 |
import javax.servlet.http.HttpServletRequest;
|
- |
|
| 17 |
|
- |
|
| 18 |
import org.apache.commons.lang3.StringUtils;
|
- |
|
| 19 |
import org.apache.http.conn.HttpHostConnectException;
|
- |
|
| 20 |
import org.apache.logging.log4j.LogManager;
|
- |
|
| 21 |
import org.apache.logging.log4j.Logger;
|
- |
|
| 22 |
import org.json.JSONArray;
|
- |
|
| 23 |
import org.json.JSONObject;
|
- |
|
| 24 |
import org.springframework.beans.factory.annotation.Autowired;
|
- |
|
| 25 |
import org.springframework.beans.factory.annotation.Value;
|
- |
|
| 26 |
import org.springframework.http.HttpStatus;
|
- |
|
| 27 |
import org.springframework.http.MediaType;
|
- |
|
| 28 |
import org.springframework.http.ResponseEntity;
|
- |
|
| 29 |
import org.springframework.stereotype.Controller;
|
- |
|
| 30 |
import org.springframework.transaction.annotation.Transactional;
|
- |
|
| 31 |
import org.springframework.web.bind.annotation.PathVariable;
|
- |
|
| 32 |
import org.springframework.web.bind.annotation.RequestMapping;
|
- |
|
| 33 |
import org.springframework.web.bind.annotation.RequestMethod;
|
- |
|
| 34 |
import org.springframework.web.bind.annotation.RequestParam;
|
- |
|
| 35 |
|
- |
|
| 36 |
import com.eclipsesource.json.Json;
|
3 |
import com.eclipsesource.json.Json;
|
| 37 |
import com.eclipsesource.json.JsonArray;
|
4 |
import com.eclipsesource.json.JsonArray;
|
| 38 |
import com.eclipsesource.json.JsonObject;
|
5 |
import com.eclipsesource.json.JsonObject;
|
| 39 |
import com.eclipsesource.json.JsonValue;
|
6 |
import com.eclipsesource.json.JsonValue;
|
| 40 |
import com.google.gson.Gson;
|
7 |
import com.google.gson.Gson;
|
| Line 65... |
Line 32... |
| 65 |
import com.spice.profitmandi.dao.repository.dtr.UserAccountRepository;
|
32 |
import com.spice.profitmandi.dao.repository.dtr.UserAccountRepository;
|
| 66 |
import com.spice.profitmandi.dao.repository.fofo.CurrentInventorySnapshotRepository;
|
33 |
import com.spice.profitmandi.dao.repository.fofo.CurrentInventorySnapshotRepository;
|
| 67 |
import com.spice.profitmandi.dao.repository.fofo.SuggestedPoDetailRepository;
|
34 |
import com.spice.profitmandi.dao.repository.fofo.SuggestedPoDetailRepository;
|
| 68 |
import com.spice.profitmandi.dao.repository.fofo.SuggestedPoRepository;
|
35 |
import com.spice.profitmandi.dao.repository.fofo.SuggestedPoRepository;
|
| 69 |
import com.spice.profitmandi.service.authentication.RoleManager;
|
36 |
import com.spice.profitmandi.service.authentication.RoleManager;
|
| 70 |
import com.spice.profitmandi.service.inventory.AvailabilityInfo;
|
- |
|
| 71 |
import com.spice.profitmandi.service.inventory.Bucket;
|
37 |
import com.spice.profitmandi.service.inventory.*;
|
| 72 |
import com.spice.profitmandi.service.inventory.FofoAvailabilityInfo;
|
- |
|
| 73 |
import com.spice.profitmandi.service.inventory.FofoCatalogResponse;
|
38 |
import com.spice.profitmandi.service.pricecircular.PriceCircularItemModel;
|
| 74 |
import com.spice.profitmandi.service.inventory.InventoryService;
|
39 |
import com.spice.profitmandi.service.pricecircular.PriceCircularModel;
|
| 75 |
import com.spice.profitmandi.service.inventory.ItemBucketService;
|
- |
|
| 76 |
import com.spice.profitmandi.service.inventory.ItemQuantityPojo;
|
- |
|
| 77 |
import com.spice.profitmandi.service.inventory.SaholicInventoryService;
|
40 |
import com.spice.profitmandi.service.pricecircular.PriceCircularService;
|
| 78 |
import com.spice.profitmandi.service.pricing.PricingService;
|
41 |
import com.spice.profitmandi.service.pricing.PricingService;
|
| 79 |
import com.spice.profitmandi.service.scheme.SchemeService;
|
42 |
import com.spice.profitmandi.service.scheme.SchemeService;
|
| 80 |
import com.spice.profitmandi.web.res.DealBrands;
|
43 |
import com.spice.profitmandi.web.res.DealBrands;
|
| 81 |
import com.spice.profitmandi.web.res.DealObjectResponse;
|
44 |
import com.spice.profitmandi.web.res.DealObjectResponse;
|
| 82 |
import com.spice.profitmandi.web.res.DealsResponse;
|
45 |
import com.spice.profitmandi.web.res.DealsResponse;
|
| 83 |
|
- |
|
| 84 |
import io.swagger.annotations.ApiImplicitParam;
|
46 |
import io.swagger.annotations.ApiImplicitParam;
|
| 85 |
import io.swagger.annotations.ApiImplicitParams;
|
47 |
import io.swagger.annotations.ApiImplicitParams;
|
| 86 |
import io.swagger.annotations.ApiOperation;
|
48 |
import io.swagger.annotations.ApiOperation;
|
| - |
|
49 |
import org.apache.commons.lang3.StringUtils;
|
| - |
|
50 |
import org.apache.http.conn.HttpHostConnectException;
|
| - |
|
51 |
import org.apache.logging.log4j.LogManager;
|
| - |
|
52 |
import org.apache.logging.log4j.Logger;
|
| - |
|
53 |
import org.json.JSONArray;
|
| - |
|
54 |
import org.json.JSONObject;
|
| - |
|
55 |
import org.springframework.beans.factory.annotation.Autowired;
|
| - |
|
56 |
import org.springframework.beans.factory.annotation.Value;
|
| - |
|
57 |
import org.springframework.http.HttpStatus;
|
| - |
|
58 |
import org.springframework.http.MediaType;
|
| - |
|
59 |
import org.springframework.http.ResponseEntity;
|
| - |
|
60 |
import org.springframework.stereotype.Controller;
|
| - |
|
61 |
import org.springframework.transaction.annotation.Transactional;
|
| - |
|
62 |
import org.springframework.web.bind.annotation.PathVariable;
|
| - |
|
63 |
import org.springframework.web.bind.annotation.RequestMapping;
|
| - |
|
64 |
import org.springframework.web.bind.annotation.RequestMethod;
|
| - |
|
65 |
import org.springframework.web.bind.annotation.RequestParam;
|
| - |
|
66 |
|
| - |
|
67 |
import javax.servlet.http.HttpServletRequest;
|
| - |
|
68 |
import java.util.*;
|
| - |
|
69 |
import java.util.concurrent.atomic.AtomicInteger;
|
| - |
|
70 |
import java.util.stream.Collectors;
|
| 87 |
|
71 |
|
| 88 |
@Controller
|
72 |
@Controller
|
| 89 |
@Transactional(rollbackFor = Throwable.class)
|
73 |
@Transactional(rollbackFor = Throwable.class)
|
| 90 |
public class DealsController {
|
74 |
public class DealsController {
|
| 91 |
|
75 |
|
| Line 124... |
Line 108... |
| 124 |
|
108 |
|
| 125 |
@Autowired
|
109 |
@Autowired
|
| 126 |
private SchemeService schemeService;
|
110 |
private SchemeService schemeService;
|
| 127 |
|
111 |
|
| 128 |
@Autowired
|
112 |
@Autowired
|
| - |
|
113 |
PriceCircularModel priceCircularModel;
|
| - |
|
114 |
|
| - |
|
115 |
@Autowired
|
| 129 |
private SaholicInventoryService saholicInventoryService;
|
116 |
private SaholicInventoryService saholicInventoryService;
|
| 130 |
|
117 |
|
| 131 |
@Autowired
|
118 |
@Autowired
|
| 132 |
private Mongo mongoClient;
|
119 |
private Mongo mongoClient;
|
| 133 |
|
120 |
|
| Line 146... |
Line 133... |
| 146 |
@Autowired
|
133 |
@Autowired
|
| 147 |
private TagListingRepository tagListingRepository;
|
134 |
private TagListingRepository tagListingRepository;
|
| 148 |
|
135 |
|
| 149 |
@Autowired
|
136 |
@Autowired
|
| 150 |
private ItemRepository itemRepository;
|
137 |
private ItemRepository itemRepository;
|
| - |
|
138 |
@Autowired
|
| - |
|
139 |
private PriceCircularService priceCircularService;
|
| 151 |
|
140 |
|
| 152 |
@Autowired
|
141 |
@Autowired
|
| 153 |
private RoleManager roleManagerService;
|
142 |
private RoleManager roleManagerService;
|
| 154 |
|
143 |
|
| 155 |
@Autowired
|
144 |
@Autowired
|
| Line 552... |
Line 541... |
| 552 |
// get warehouse Id
|
541 |
// get warehouse Id
|
| 553 |
int warehouseId = fofoStoreRepository.selectByRetailerId(fofoId).getWarehouseId();
|
542 |
int warehouseId = fofoStoreRepository.selectByRetailerId(fofoId).getWarehouseId();
|
| 554 |
Map<Integer, List<SaholicCIS>> itemAvailabilityMap = saholicInventoryService.getSaholicStock().get(warehouseId);
|
543 |
Map<Integer, List<SaholicCIS>> itemAvailabilityMap = saholicInventoryService.getSaholicStock().get(warehouseId);
|
| 555 |
Map<Integer, List<SaholicPOItem>> poItemAvailabilityMap = saholicInventoryService.getSaholicPOItems()
|
544 |
Map<Integer, List<SaholicPOItem>> poItemAvailabilityMap = saholicInventoryService.getSaholicPOItems()
|
| 556 |
.get(warehouseId);
|
545 |
.get(warehouseId);
|
| - |
|
546 |
List<Integer> catalogIds = new ArrayList<>();
|
| - |
|
547 |
for (int i = 0; i < docs.length(); i++) {
|
| - |
|
548 |
Map<Integer, FofoAvailabilityInfo> fofoAvailabilityInfoMap = new HashMap<>();
|
| - |
|
549 |
JSONObject doc = docs.getJSONObject(i);
|
| - |
|
550 |
catalogIds.add(doc.getInt("catalogId_i"));
|
| - |
|
551 |
}
|
| - |
|
552 |
PriceCircularModel priceCircularModel = priceCircularService.getPriceCircularByOffer(fofoId, catalogIds);
|
| 557 |
|
553 |
|
| - |
|
554 |
List<PriceCircularItemModel> priceCircularItemModels = priceCircularModel.getPriceCircularItemModels();
|
| - |
|
555 |
Map<Integer, PriceCircularItemModel> priceCircularItemModelMap = new HashMap<>();
|
| - |
|
556 |
if (priceCircularItemModels != null) {
|
| - |
|
557 |
priceCircularItemModels.stream().collect(Collectors.toMap(x -> x.getCatalogId(), x -> x));
|
| - |
|
558 |
}
|
| 558 |
for (int i = 0; i < docs.length(); i++) {
|
559 |
for (int i = 0; i < docs.length(); i++) {
|
| 559 |
Map<Integer, FofoAvailabilityInfo> fofoAvailabilityInfoMap = new HashMap<>();
|
560 |
Map<Integer, FofoAvailabilityInfo> fofoAvailabilityInfoMap = new HashMap<>();
|
| 560 |
JSONObject doc = docs.getJSONObject(i);
|
561 |
JSONObject doc = docs.getJSONObject(i);
|
| 561 |
FofoCatalogResponse ffdr = new FofoCatalogResponse();
|
562 |
FofoCatalogResponse ffdr = new FofoCatalogResponse();
|
| 562 |
ffdr.setCatalogId(doc.getInt("catalogId_i"));
|
563 |
ffdr.setCatalogId(doc.getInt("catalogId_i"));
|
| Line 579... |
Line 580... |
| 579 |
float sellingPrice = (float) childItem.getDouble("sellingPrice_f");
|
580 |
float sellingPrice = (float) childItem.getDouble("sellingPrice_f");
|
| 580 |
if (fofoAvailabilityInfoMap.containsKey(itemId)) {
|
581 |
if (fofoAvailabilityInfoMap.containsKey(itemId)) {
|
| 581 |
if (fofoAvailabilityInfoMap.get(itemId).getSellingPrice() > sellingPrice) {
|
582 |
if (fofoAvailabilityInfoMap.get(itemId).getSellingPrice() > sellingPrice) {
|
| 582 |
fofoAvailabilityInfoMap.get(itemId).setSellingPrice(sellingPrice);
|
583 |
fofoAvailabilityInfoMap.get(itemId).setSellingPrice(sellingPrice);
|
| 583 |
fofoAvailabilityInfoMap.get(itemId).setMop((float) childItem.getDouble("mop_f"));
|
584 |
fofoAvailabilityInfoMap.get(itemId).setMop((float) childItem.getDouble("mop_f"));
|
| - |
|
585 |
PriceCircularItemModel priceCircularItemModel = priceCircularItemModels.get(ffdr.getCatalogId());
|
| - |
|
586 |
fofoAvailabilityInfoMap.get(itemId).setNlc(priceCircularItemModel == null ? 0 : priceCircularItemModel.getNetPrice2());
|
| 584 |
}
|
587 |
}
|
| 585 |
} else {
|
588 |
} else {
|
| 586 |
FofoAvailabilityInfo fdi = new FofoAvailabilityInfo();
|
589 |
FofoAvailabilityInfo fdi = new FofoAvailabilityInfo();
|
| 587 |
List<SaholicCIS> currentAvailability = itemAvailabilityMap.get(itemId);
|
590 |
List<SaholicCIS> currentAvailability = itemAvailabilityMap.get(itemId);
|
| 588 |
List<SaholicPOItem> poItemAvailability = null;
|
591 |
List<SaholicPOItem> poItemAvailability = null;
|
| Line 673... |
Line 676... |
| 673 |
if (fdi.getColor().equalsIgnoreCase("any colour")) {
|
676 |
if (fdi.getColor().equalsIgnoreCase("any colour")) {
|
| 674 |
fdiAnyColour = fdi;
|
677 |
fdiAnyColour = fdi;
|
| 675 |
}
|
678 |
}
|
| 676 |
fdi.setTagId(childItem.getInt("tagId_i"));
|
679 |
fdi.setTagId(childItem.getInt("tagId_i"));
|
| 677 |
fdi.setItem_id(itemId);
|
680 |
fdi.setItem_id(itemId);
|
| 678 |
Float cashBack = schemeService.getItemSchemeCashBack().get(itemId);
|
681 |
Float cashBack = schemeService.getCatalogSchemeCashBack().get(ffdr.getCatalogId());
|
| 679 |
cashBack = cashBack == null ? 0 : cashBack;
|
682 |
cashBack = cashBack == null ? 0 : cashBack;
|
| 680 |
fdi.setCashback(cashBack);
|
683 |
fdi.setCashback(cashBack);
|
| 681 |
fdi.setMinBuyQuantity(1);
|
684 |
fdi.setMinBuyQuantity(1);
|
| 682 |
if (hotDeal) {
|
685 |
if (hotDeal) {
|
| 683 |
if (currentAvailability != null) {
|
686 |
if (currentAvailability != null) {
|