| Line 4... |
Line 4... |
| 4 |
import java.io.IOException;
|
4 |
import java.io.IOException;
|
| 5 |
|
5 |
|
| 6 |
import java.io.InputStream;
|
6 |
import java.io.InputStream;
|
| 7 |
import java.net.URISyntaxException;
|
7 |
import java.net.URISyntaxException;
|
| 8 |
import java.net.URL;
|
8 |
import java.net.URL;
|
| - |
|
9 |
import java.time.LocalDate;
|
| - |
|
10 |
import java.util.*;
|
| - |
|
11 |
import java.util.stream.Collectors;
|
| 9 |
|
12 |
|
| - |
|
13 |
import com.spice.profitmandi.common.enumuration.SchemeType;
|
| - |
|
14 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
| - |
|
15 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
| - |
|
16 |
import com.spice.profitmandi.common.web.client.RestClient;
|
| - |
|
17 |
import com.spice.profitmandi.dao.entity.catalog.ComboModel;
|
| - |
|
18 |
import com.spice.profitmandi.dao.entity.catalog.Item;
|
| - |
|
19 |
import com.spice.profitmandi.dao.entity.dtr.WebOffer;
|
| - |
|
20 |
import com.spice.profitmandi.dao.entity.inventory.SaholicCISTable;
|
| - |
|
21 |
import com.spice.profitmandi.dao.entity.inventory.SaholicPOItem;
|
| - |
|
22 |
import com.spice.profitmandi.dao.model.AmountModel;
|
| - |
|
23 |
import com.spice.profitmandi.dao.model.CreateOfferRequest;
|
| - |
|
24 |
import com.spice.profitmandi.dao.repository.catalog.ComboModelRepository;
|
| - |
|
25 |
import com.spice.profitmandi.dao.repository.catalog.ItemRepository;
|
| - |
|
26 |
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
|
| - |
|
27 |
import com.spice.profitmandi.dao.repository.dtr.WebOfferRepository;
|
| - |
|
28 |
import com.spice.profitmandi.dao.repository.inventory.SaholicCISTableRepository;
|
| - |
|
29 |
import com.spice.profitmandi.service.inventory.FofoAvailabilityInfo;
|
| - |
|
30 |
import com.spice.profitmandi.service.inventory.FofoCatalogResponse;
|
| - |
|
31 |
import com.spice.profitmandi.service.inventory.SaholicInventoryService;
|
| - |
|
32 |
import com.spice.profitmandi.service.pricecircular.PriceCircularItemModelNew;
|
| - |
|
33 |
import com.spice.profitmandi.service.pricecircular.PriceCircularModel;
|
| - |
|
34 |
import com.spice.profitmandi.service.pricecircular.PriceCircularService;
|
| - |
|
35 |
import com.spice.profitmandi.service.scheme.SchemeService;
|
| 10 |
import org.apache.commons.io.IOUtils;
|
36 |
import org.apache.commons.io.IOUtils;
|
| - |
|
37 |
import org.apache.commons.lang3.StringUtils;
|
| 11 |
import org.apache.http.client.utils.URIBuilder;
|
38 |
import org.apache.http.client.utils.URIBuilder;
|
| - |
|
39 |
import org.apache.http.conn.HttpHostConnectException;
|
| 12 |
import org.apache.logging.log4j.Logger;
|
40 |
import org.apache.logging.log4j.Logger;
|
| 13 |
import org.apache.logging.log4j.LogManager;
|
41 |
import org.apache.logging.log4j.LogManager;
|
| - |
|
42 |
import org.json.JSONArray;
|
| - |
|
43 |
import org.json.JSONObject;
|
| - |
|
44 |
import org.springframework.beans.factory.annotation.Autowired;
|
| 14 |
import org.springframework.beans.factory.annotation.Value;
|
45 |
import org.springframework.beans.factory.annotation.Value;
|
| 15 |
import org.springframework.stereotype.Component;
|
46 |
import org.springframework.stereotype.Component;
|
| 16 |
|
47 |
|
| 17 |
|
48 |
|
| 18 |
@Component("solrService")
|
49 |
@Component("solrService")
|
| Line 20... |
Line 51... |
| 20 |
|
51 |
|
| 21 |
private static final Logger logger=LogManager.getLogger(SolrService.class);
|
52 |
private static final Logger logger=LogManager.getLogger(SolrService.class);
|
| 22 |
|
53 |
|
| 23 |
@Value("${solr.url}")
|
54 |
@Value("${solr.url}")
|
| 24 |
private String SOLR_URL;
|
55 |
private String SOLR_URL;
|
| - |
|
56 |
|
| - |
|
57 |
@Value("${new.solr.url}")
|
| - |
|
58 |
private String solrUrl;
|
| - |
|
59 |
|
| - |
|
60 |
@Autowired
|
| - |
|
61 |
private FofoStoreRepository fofoStoreRepository;
|
| - |
|
62 |
|
| - |
|
63 |
@Autowired
|
| - |
|
64 |
private PriceCircularService priceCircularService;
|
| - |
|
65 |
|
| - |
|
66 |
@Autowired
|
| - |
|
67 |
private SaholicInventoryService saholicInventoryService;
|
| - |
|
68 |
|
| - |
|
69 |
@Autowired
|
| - |
|
70 |
private WebOfferRepository webOfferRepository;
|
| - |
|
71 |
|
| - |
|
72 |
@Autowired
|
| - |
|
73 |
private ComboModelRepository comboModelRepository;
|
| - |
|
74 |
|
| - |
|
75 |
@Autowired
|
| - |
|
76 |
private SchemeService schemeService;
|
| - |
|
77 |
|
| - |
|
78 |
@Autowired
|
| - |
|
79 |
private ItemRepository itemRepository;
|
| - |
|
80 |
|
| - |
|
81 |
@Autowired
|
| - |
|
82 |
private SaholicCISTableRepository saholicCISTableRepository;
|
| - |
|
83 |
|
| 25 |
private static final String limit ="20";
|
84 |
private static final String limit ="20";
|
| 26 |
private static final String groupLimit = "10";
|
85 |
private static final String groupLimit = "10";
|
| 27 |
private static final String autoSuggestField = "title,subCategoryId,category_id,category,subCategory,score";
|
86 |
private static final String autoSuggestField = "title,subCategoryId,category_id,category,subCategory,score";
|
| 28 |
private static final String searchResultsField = "title,skuBundleId,id,thumbnail,ids";
|
87 |
private static final String searchResultsField = "title,skuBundleId,id,thumbnail,ids";
|
| 29 |
private static final String outputFormat = "json";
|
88 |
private static final String outputFormat = "json";
|
| Line 72... |
Line 131... |
| 72 |
is.close();
|
131 |
is.close();
|
| 73 |
}
|
132 |
}
|
| 74 |
return jsonString;
|
133 |
return jsonString;
|
| 75 |
}
|
134 |
}
|
| 76 |
|
135 |
|
| - |
|
136 |
public List<FofoCatalogResponse> dealResponse (Set<Integer> catalogIds, int fofoId) throws Exception {
|
| - |
|
137 |
List<FofoCatalogResponse> dealResponse = new ArrayList<>();
|
| - |
|
138 |
RestClient rc = new RestClient();
|
| - |
|
139 |
Map<String, String> params = new HashMap<>();
|
| - |
|
140 |
List<String> mandatoryQ = new ArrayList<>();
|
| - |
|
141 |
mandatoryQ.add(String.format("+catalogId_i:(%s) +{!parent which=\"id:catalog*\"}", StringUtils.join(catalogIds, " ")));
|
| - |
|
142 |
params.put("start", "0");
|
| - |
|
143 |
params.put("rows", "100");
|
| - |
|
144 |
params.put("q", StringUtils.join(mandatoryQ, " "));
|
| - |
|
145 |
params.put("fl", "*, [child parentFilter=id:catalog*]");
|
| - |
|
146 |
|
| - |
|
147 |
params.put("wt", "json");
|
| - |
|
148 |
String response = null;
|
| - |
|
149 |
try {
|
| - |
|
150 |
response = rc.get(SchemeType.HTTP, solrUrl, 8984, "solr/demo/select", params);
|
| - |
|
151 |
} catch (HttpHostConnectException e) {
|
| - |
|
152 |
throw new ProfitMandiBusinessException("", "", "Could not connect to host");
|
| - |
|
153 |
}
|
| - |
|
154 |
JSONObject solrResponseJSONObj = new JSONObject(response).getJSONObject("response");
|
| - |
|
155 |
JSONArray docs = solrResponseJSONObj.getJSONArray("docs");
|
| - |
|
156 |
dealResponse = getCatalogResponse(docs, false, fofoId);
|
| - |
|
157 |
|
| - |
|
158 |
return dealResponse;
|
| - |
|
159 |
|
| - |
|
160 |
}
|
| - |
|
161 |
|
| - |
|
162 |
|
| - |
|
163 |
private List<FofoCatalogResponse> getCatalogResponse(JSONArray docs, boolean hotDeal, int fofoId) throws
|
| - |
|
164 |
Exception {
|
| - |
|
165 |
List<FofoCatalogResponse> dealResponse = new ArrayList<>();
|
| - |
|
166 |
List<Integer> tagIds = Arrays.asList(4);
|
| - |
|
167 |
List<Integer> itemIds = new ArrayList<>();
|
| - |
|
168 |
if (docs.length() > 0) {
|
| - |
|
169 |
for (int i = 0; i < docs.length(); i++) {
|
| - |
|
170 |
JSONObject doc = docs.getJSONObject(i);
|
| - |
|
171 |
if (doc.has("_childDocuments_")) {
|
| - |
|
172 |
for (int j = 0; j < doc.getJSONArray("_childDocuments_").length(); j++) {
|
| - |
|
173 |
JSONObject childItem = doc.getJSONArray("_childDocuments_").getJSONObject(j);
|
| - |
|
174 |
int itemId = childItem.getInt("itemId_i");
|
| - |
|
175 |
itemIds.add(itemId);
|
| - |
|
176 |
}
|
| - |
|
177 |
}
|
| - |
|
178 |
}
|
| - |
|
179 |
if (itemIds.size() == 0) {
|
| - |
|
180 |
return dealResponse;
|
| - |
|
181 |
}
|
| - |
|
182 |
}
|
| - |
|
183 |
// get warehouse Id
|
| - |
|
184 |
int warehouseId = fofoStoreRepository.selectByRetailerId(fofoId).getWarehouseId();
|
| - |
|
185 |
Map<Integer, List<SaholicPOItem>> poItemAvailabilityMap = saholicInventoryService.getSaholicPOItems().get(warehouseId);
|
| - |
|
186 |
List<Integer> catalogIds = new ArrayList<>();
|
| - |
|
187 |
for (int i = 0; i < docs.length(); i++) {
|
| - |
|
188 |
Map<Integer, FofoAvailabilityInfo> fofoAvailabilityInfoMap = new HashMap<>();
|
| - |
|
189 |
JSONObject doc = docs.getJSONObject(i);
|
| - |
|
190 |
catalogIds.add(doc.getInt("catalogId_i"));
|
| - |
|
191 |
}
|
| - |
|
192 |
List<CreateOfferRequest> allSchemOffers = null;
|
| - |
|
193 |
Map<Integer, PriceCircularItemModelNew> priceCircularItemModelMap = new HashMap<>();
|
| - |
|
194 |
if (catalogIds.size() > 0) {
|
| - |
|
195 |
PriceCircularModel priceCircularModel = priceCircularService.getPriceCircularByOffer(fofoId, catalogIds, LocalDate.now());
|
| - |
|
196 |
allSchemOffers = priceCircularModel.getOffers();
|
| - |
|
197 |
|
| - |
|
198 |
List<PriceCircularItemModelNew> priceCircularItemModelNews = priceCircularModel.getPriceCircularItemModelNews();
|
| - |
|
199 |
if (priceCircularItemModelNews != null) {
|
| - |
|
200 |
priceCircularItemModelMap = priceCircularItemModelNews.stream().collect(Collectors.toMap(x -> x.getCatalogId(), x -> x));
|
| - |
|
201 |
}
|
| - |
|
202 |
}
|
| - |
|
203 |
|
| - |
|
204 |
/*List<CatalogFavourite> catalogFavourites = catalogFavouriteRepository.selectBypartnerId(fofoId);
|
| - |
|
205 |
List<Integer> catalogFavouriteIds = new ArrayList<>();
|
| - |
|
206 |
if (!catalogFavourites.isEmpty()) {
|
| - |
|
207 |
catalogFavouriteIds = catalogFavourites.stream().map(x -> x.getCatalogId()).collect(Collectors.toList());
|
| - |
|
208 |
}
|
| - |
|
209 |
|
| - |
|
210 |
if (!catalogFavourites.isEmpty()) {
|
| - |
|
211 |
catalogFavourites.stream().collect(Collectors.toMap(x -> x.getCatalogId(), x -> x));
|
| - |
|
212 |
}*/
|
| - |
|
213 |
|
| - |
|
214 |
for (int i = 0; i < docs.length(); i++) {
|
| - |
|
215 |
Map<Integer, FofoAvailabilityInfo> fofoAvailabilityInfoMap = new HashMap<>();
|
| - |
|
216 |
JSONObject doc = docs.getJSONObject(i);
|
| - |
|
217 |
FofoCatalogResponse fofoCatalogResponse = new FofoCatalogResponse();
|
| - |
|
218 |
fofoCatalogResponse.setCatalogId(doc.getInt("catalogId_i"));
|
| - |
|
219 |
fofoCatalogResponse.setImageUrl(doc.getString("imageUrl_s"));
|
| - |
|
220 |
fofoCatalogResponse.setTitle(doc.getString("title_s"));
|
| - |
|
221 |
|
| - |
|
222 |
/*if (catalogFavouriteIds.contains(fofoCatalogResponse.getCatalogId())) {
|
| - |
|
223 |
fofoCatalogResponse.setFavourite(true);
|
| - |
|
224 |
}*/
|
| - |
|
225 |
|
| - |
|
226 |
List<WebOffer> webOffers = webOfferRepository.selectAllActiveOffers().get(fofoCatalogResponse.getCatalogId());
|
| - |
|
227 |
|
| - |
|
228 |
//logger.info("webOffers {}", webOffers);
|
| - |
|
229 |
if (webOffers != null && webOffers.size() > 0) {
|
| - |
|
230 |
fofoCatalogResponse.setWebOffers(webOffers);
|
| - |
|
231 |
fofoCatalogResponse.setOffers(webOffers.stream().map(x -> x.getTitle()).collect(Collectors.toList()));
|
| - |
|
232 |
|
| - |
|
233 |
}
|
| - |
|
234 |
|
| - |
|
235 |
List<ComboModel> comboModels = comboModelRepository.selectByWarehouseId(warehouseId).stream().filter(x -> x.getCatalogId() == fofoCatalogResponse.getCatalogId()).collect(Collectors.toList());
|
| - |
|
236 |
|
| - |
|
237 |
//logger.info("comboModels {}", comboModels);
|
| - |
|
238 |
|
| - |
|
239 |
if (comboModels != null && comboModels.size() > 0) {
|
| - |
|
240 |
fofoCatalogResponse.setComboModels(comboModels);
|
| - |
|
241 |
}
|
| - |
|
242 |
|
| - |
|
243 |
try {
|
| - |
|
244 |
fofoCatalogResponse.setFeature(doc.getString("feature_s"));
|
| - |
|
245 |
} catch (Exception e) {
|
| - |
|
246 |
fofoCatalogResponse.setFeature(null);
|
| - |
|
247 |
logger.info("Could not find Feature_s for {}", fofoCatalogResponse.getCatalogId());
|
| - |
|
248 |
}
|
| - |
|
249 |
|
| - |
|
250 |
fofoCatalogResponse.setBrand(doc.getJSONArray("brand_ss").getString(0));
|
| - |
|
251 |
logger.info("labelss {}", doc.has("label_ss"));
|
| - |
|
252 |
|
| - |
|
253 |
if (doc.has("label_ss")) {
|
| - |
|
254 |
logger.info("label {}", doc.getJSONArray("label_ss"));
|
| - |
|
255 |
|
| - |
|
256 |
JSONArray arr = doc.getJSONArray("label_ss");
|
| - |
|
257 |
Set<String> labels = new HashSet<String>();
|
| - |
|
258 |
for (int j = 0; j < arr.length(); j++) {
|
| - |
|
259 |
labels.add(arr.getString(j));
|
| - |
|
260 |
}
|
| - |
|
261 |
|
| - |
|
262 |
fofoCatalogResponse.setLabels(new ArrayList<>(labels));
|
| - |
|
263 |
|
| - |
|
264 |
}
|
| - |
|
265 |
if (doc.has("similarModels_ii")) {
|
| - |
|
266 |
JSONArray similarModelsArray = doc.getJSONArray("similarModels_ii");
|
| - |
|
267 |
List<Integer> similarCatalogIds = new ArrayList<>();
|
| - |
|
268 |
for (int j = 0; j < similarModelsArray.length(); j++) {
|
| - |
|
269 |
similarCatalogIds.add(similarModelsArray.getInt(j));
|
| - |
|
270 |
}
|
| - |
|
271 |
fofoCatalogResponse.setSimilarModelIds(similarCatalogIds);
|
| - |
|
272 |
}
|
| - |
|
273 |
|
| - |
|
274 |
if (doc.has("_childDocuments_")) {
|
| - |
|
275 |
String modelColorClass = "grey";
|
| - |
|
276 |
FofoAvailabilityInfo fdiAnyColour = null;
|
| - |
|
277 |
// Iterating itemIds
|
| - |
|
278 |
for (int j = 0; j < doc.getJSONArray("_childDocuments_").length(); j++) {
|
| - |
|
279 |
PriceCircularItemModelNew priceCircularItemModel = priceCircularItemModelMap.get(fofoCatalogResponse.getCatalogId());
|
| - |
|
280 |
JSONObject childItem = doc.getJSONArray("_childDocuments_").getJSONObject(j);
|
| - |
|
281 |
int itemId = childItem.getInt("itemId_i");
|
| - |
|
282 |
float sellingPrice = (float) childItem.getDouble("sellingPrice_f");
|
| - |
|
283 |
if (!fofoAvailabilityInfoMap.containsKey(itemId)) {
|
| - |
|
284 |
FofoAvailabilityInfo fdi = new FofoAvailabilityInfo();
|
| - |
|
285 |
List<SaholicCISTable> currentAvailability = saholicCISTableRepository.selectByItemWarehouse(itemId, warehouseId);
|
| - |
|
286 |
List<SaholicPOItem> poItemAvailability = null;
|
| - |
|
287 |
if (poItemAvailabilityMap != null) {
|
| - |
|
288 |
poItemAvailability = poItemAvailabilityMap.get(itemId);
|
| - |
|
289 |
}
|
| - |
|
290 |
|
| - |
|
291 |
if (priceCircularItemModel != null) {
|
| - |
|
292 |
fdi.setNlc((float) priceCircularItemModel.getNetNlc());
|
| - |
|
293 |
}
|
| - |
|
294 |
|
| - |
|
295 |
for (SaholicCISTable saholicCISTable : currentAvailability) {
|
| - |
|
296 |
saholicCISTable.setWarehouseName(
|
| - |
|
297 |
ProfitMandiConstants.WAREHOUSE_MAP.get(saholicCISTable.getWarehouseFrom()));
|
| - |
|
298 |
}
|
| - |
|
299 |
|
| - |
|
300 |
Map<Integer, SaholicCISTable> map = currentAvailability.stream().collect(Collectors.toMap(SaholicCISTable::getWarehouseFrom, x -> x));
|
| - |
|
301 |
if (poItemAvailability != null) {
|
| - |
|
302 |
for (SaholicPOItem saholicPOItem : poItemAvailability) {
|
| - |
|
303 |
if (map.containsKey(saholicPOItem.getWarehouseFrom())) {
|
| - |
|
304 |
map.get(saholicPOItem.getWarehouseFrom()).setPopendingQty(saholicPOItem.getUnfulfilledQty());
|
| - |
|
305 |
} else {
|
| - |
|
306 |
SaholicCISTable saholicCISTable = new SaholicCISTable();
|
| - |
|
307 |
saholicCISTable.setAvailability(0);
|
| - |
|
308 |
saholicCISTable.setReserved(0);
|
| - |
|
309 |
saholicCISTable.setItemId(itemId);
|
| - |
|
310 |
saholicCISTable.setWarehouseId(warehouseId);
|
| - |
|
311 |
saholicCISTable.setPopendingQty(saholicPOItem.getUnfulfilledQty());
|
| - |
|
312 |
saholicCISTable.setWarehouseFrom(saholicPOItem.getWarehouseFrom());
|
| - |
|
313 |
saholicCISTable.setWarehouseName(
|
| - |
|
314 |
ProfitMandiConstants.WAREHOUSE_MAP.get(saholicPOItem.getWarehouseFrom()));
|
| - |
|
315 |
map.put(saholicPOItem.getWarehouseFrom(), saholicCISTable);
|
| - |
|
316 |
}
|
| - |
|
317 |
}
|
| - |
|
318 |
}
|
| - |
|
319 |
fdi.setSaholicCISTableList(new ArrayList<>(map.values()));
|
| - |
|
320 |
String poColor = "grey";
|
| - |
|
321 |
boolean active = false;
|
| - |
|
322 |
if (currentAvailability != null && currentAvailability.stream().collect(Collectors.summingInt(SaholicCISTable::getNetAvailability)) > 0) {
|
| - |
|
323 |
poColor = "green";
|
| - |
|
324 |
modelColorClass = "green";
|
| - |
|
325 |
} else if (poItemAvailability != null && poItemAvailability.stream().collect(Collectors.summingInt(SaholicPOItem::getUnfulfilledQty)) > 0) {
|
| - |
|
326 |
if (currentAvailability != null && poItemAvailability.stream().collect(Collectors.summingInt(SaholicPOItem::getUnfulfilledQty)) + currentAvailability.stream().collect(Collectors.summingInt(SaholicCISTable::getNetAvailability)) <= 0) {
|
| - |
|
327 |
poColor = "grey";
|
| - |
|
328 |
} else {
|
| - |
|
329 |
poColor = "yellow";
|
| - |
|
330 |
if (modelColorClass != "green") {
|
| - |
|
331 |
modelColorClass = poColor;
|
| - |
|
332 |
}
|
| - |
|
333 |
}
|
| - |
|
334 |
}
|
| - |
|
335 |
fdi.setColorClass(poColor);
|
| - |
|
336 |
fdi.setSellingPrice(sellingPrice);
|
| - |
|
337 |
fdi.setActive(active);
|
| - |
|
338 |
fdi.setMrp(childItem.getDouble("mrp_f"));
|
| - |
|
339 |
fdi.setMop((float) childItem.getDouble("mop_f"));
|
| - |
|
340 |
fdi.setColor(childItem.has("color_s") ? childItem.getString("color_s") : "");
|
| - |
|
341 |
if (fdi.getColor().equalsIgnoreCase("any colour")) {
|
| - |
|
342 |
fdiAnyColour = fdi;
|
| - |
|
343 |
}
|
| - |
|
344 |
fdi.setTagId(childItem.getInt("tagId_i"));
|
| - |
|
345 |
fdi.setItem_id(itemId);
|
| - |
|
346 |
Float cashBack = schemeService.getCatalogSchemeCashBack(fofoId, Arrays.asList(fofoCatalogResponse.getCatalogId())).get(fofoCatalogResponse.getCatalogId());
|
| - |
|
347 |
cashBack = cashBack == null ? 0 : cashBack;
|
| - |
|
348 |
fdi.setCashback(cashBack);
|
| - |
|
349 |
fdi.setMinBuyQuantity(1);
|
| - |
|
350 |
if (hotDeal) {
|
| - |
|
351 |
if (currentAvailability != null) {
|
| - |
|
352 |
fdi.setAvailability(currentAvailability.stream().collect(Collectors.summingInt(SaholicCISTable::getNetAvailability)));
|
| - |
|
353 |
} else {
|
| - |
|
354 |
fdi.setAvailability(0);
|
| - |
|
355 |
}
|
| - |
|
356 |
} else {
|
| - |
|
357 |
// Lets consider that its out of stock
|
| - |
|
358 |
fdi.setAvailability(400);
|
| - |
|
359 |
Item item = null;
|
| - |
|
360 |
try {
|
| - |
|
361 |
item = itemRepository.selectById(itemId);
|
| - |
|
362 |
} catch (Exception e) {
|
| - |
|
363 |
e.printStackTrace();
|
| - |
|
364 |
continue;
|
| - |
|
365 |
}
|
| - |
|
366 |
// In case its tampered glass moq should be
|
| - |
|
367 |
if (item.getCategoryId() == 10020) {
|
| - |
|
368 |
fdi.setMinBuyQuantity(5);
|
| - |
|
369 |
}
|
| - |
|
370 |
}
|
| - |
|
371 |
fdi.setQuantityStep(1);
|
| - |
|
372 |
fdi.setMaxQuantity(Math.min(fdi.getAvailability(), 400));
|
| - |
|
373 |
fofoAvailabilityInfoMap.put(itemId, fdi);
|
| - |
|
374 |
}
|
| - |
|
375 |
}
|
| - |
|
376 |
if (fdiAnyColour != null) {
|
| - |
|
377 |
fdiAnyColour.setColorClass(modelColorClass);
|
| - |
|
378 |
}
|
| - |
|
379 |
fofoCatalogResponse.setInStock(!modelColorClass.equals("grey"));
|
| - |
|
380 |
}
|
| - |
|
381 |
if (fofoAvailabilityInfoMap.values().size() > 0) {
|
| - |
|
382 |
List<FofoAvailabilityInfo> availabilityList = fofoAvailabilityInfoMap.values().stream().sorted(Comparator.comparing(FofoAvailabilityInfo::getAvailability).reversed()).collect(Collectors.toList());
|
| - |
|
383 |
fofoCatalogResponse.setItems(availabilityList);
|
| - |
|
384 |
if (priceCircularItemModelMap.containsKey(fofoCatalogResponse.getCatalogId())) {
|
| - |
|
385 |
PriceCircularItemModelNew priceCircularItemModel = priceCircularItemModelMap.get(fofoCatalogResponse.getCatalogId());
|
| - |
|
386 |
if (priceCircularItemModel.getSlabPayouts() != null) {
|
| - |
|
387 |
List<CreateOfferRequest> schemeOffers = new ArrayList<>();
|
| - |
|
388 |
List<Map<Integer, AmountModel>> slabPayouts = priceCircularItemModel.getSlabPayouts();
|
| - |
|
389 |
Iterator<Map<Integer, AmountModel>> iterator = slabPayouts.iterator();
|
| - |
|
390 |
int iteratorCount = 0;
|
| - |
|
391 |
while (iterator.hasNext()) {
|
| - |
|
392 |
Map<Integer, AmountModel> slabPayoutMap = iterator.next();
|
| - |
|
393 |
if (slabPayoutMap != null) {
|
| - |
|
394 |
schemeOffers.add(allSchemOffers.get(iteratorCount));
|
| - |
|
395 |
} else {
|
| - |
|
396 |
iterator.remove();
|
| - |
|
397 |
}
|
| - |
|
398 |
iteratorCount++;
|
| - |
|
399 |
}
|
| - |
|
400 |
fofoCatalogResponse.setSchemeOffers(schemeOffers);
|
| - |
|
401 |
}
|
| - |
|
402 |
fofoCatalogResponse.setPriceCircularItemModel(priceCircularItemModel);
|
| - |
|
403 |
}
|
| - |
|
404 |
dealResponse.add(fofoCatalogResponse);
|
| - |
|
405 |
}
|
| - |
|
406 |
}
|
| - |
|
407 |
return dealResponse;
|
| - |
|
408 |
|
| - |
|
409 |
}
|
| - |
|
410 |
|
| 77 |
}
|
411 |
}
|
| 78 |
|
412 |
|