| Line 170... |
Line 170... |
| 170 |
}
|
170 |
}
|
| 171 |
|
171 |
|
| 172 |
@ApiImplicitParams({
|
172 |
@ApiImplicitParams({
|
| 173 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
|
173 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
|
| 174 |
@RequestMapping(value = "/fofo", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
174 |
@RequestMapping(value = "/fofo", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
| 175 |
public ResponseEntity<?> getFofo(HttpServletRequest request,
|
175 |
public ResponseEntity<?> getFofo(HttpServletRequest request,
|
| 176 |
@RequestParam(value = "categoryId", required=false, defaultValue="(3 OR 6)") String categoryId,
|
176 |
@RequestParam(value = "categoryId", required = false, defaultValue = "(3 OR 6)") String categoryId,
|
| 177 |
@RequestParam(value = "offset") String offset, @RequestParam(value = "limit") String limit,
|
177 |
@RequestParam(value = "offset") String offset, @RequestParam(value = "limit") String limit,
|
| 178 |
@RequestParam(value = "sort", required = false) String sort,
|
178 |
@RequestParam(value = "sort", required = false) String sort,
|
| 179 |
@RequestParam(value = "brand", required = false) String brand,
|
179 |
@RequestParam(value = "brand", required = false) String brand,
|
| 180 |
@RequestParam(value = "hotDeal", required = false) boolean hotDeal)
|
180 |
@RequestParam(value = "hotDeal", required = false) boolean hotDeal) throws Throwable {
|
| 181 |
throws Throwable {
|
- |
|
| 182 |
List<FofoCatalogResponse> dealResponse = new ArrayList<>();
|
181 |
List<FofoCatalogResponse> dealResponse = new ArrayList<>();
|
| 183 |
UserInfo userInfo = (UserInfo) request.getAttribute("userInfo");
|
182 |
UserInfo userInfo = (UserInfo) request.getAttribute("userInfo");
|
| 184 |
if (roleManagerService.isPartner(userInfo.getRoleIds())) {
|
183 |
if (roleManagerService.isPartner(userInfo.getRoleIds())) {
|
| 185 |
categoryId = "(3 OR 6)";
|
184 |
categoryId = "(3 OR 6)";
|
| 186 |
UserCart uc = userAccountRepository.getUserCart(userInfo.getUserId());
|
185 |
UserCart uc = userAccountRepository.getUserCart(userInfo.getUserId());
|
| Line 188... |
Line 187... |
| 188 |
RestClient rc = new RestClient();
|
187 |
RestClient rc = new RestClient();
|
| 189 |
Map<String, String> params = new HashMap<>();
|
188 |
Map<String, String> params = new HashMap<>();
|
| 190 |
List<String> mandatoryQ = new ArrayList<>();
|
189 |
List<String> mandatoryQ = new ArrayList<>();
|
| 191 |
if (brand != null) {
|
190 |
if (brand != null) {
|
| 192 |
|
191 |
|
| - |
|
192 |
mandatoryQ.add(
|
| 193 |
mandatoryQ.add(String.format("+(categoryId_i:%s) +(brand_ss:%s) +{!parent which=\"brand_ss:%s\"} tagId_i:(%s)", categoryId, brand, brand,
|
193 |
String.format("+(categoryId_i:%s) +(brand_ss:%s) +{!parent which=\"brand_ss:%s\"} tagId_i:(%s)",
|
| 194 |
StringUtils.join(tagIds, " ")));
|
194 |
categoryId, brand, brand, StringUtils.join(tagIds, " ")));
|
| 195 |
} else if (hotDeal) {
|
195 |
} else if (hotDeal) {
|
| 196 |
mandatoryQ.add(String.format("+{!parent which=\"hot_deals_b=true\"} tagId_i:(%s)",
|
196 |
mandatoryQ.add(String.format("+{!parent which=\"hot_deals_b=true\"} tagId_i:(%s)",
|
| 197 |
StringUtils.join(tagIds, " ")));
|
197 |
StringUtils.join(tagIds, " ")));
|
| 198 |
} else {
|
198 |
} else {
|
| 199 |
mandatoryQ.add(
|
199 |
mandatoryQ.add(
|
| 200 |
String.format("+{!parent which=\"id:catalog*\"} tagId_i:(%s)", StringUtils.join(tagIds, " ")));
|
200 |
String.format("+{!parent which=\"id:catalog*\"} tagId_i:(%s)", StringUtils.join(tagIds, " ")));
|
| - |
|
201 |
|
| - |
|
202 |
|
| 201 |
}
|
203 |
}
|
| 202 |
params.put("q", StringUtils.join(mandatoryQ, " "));
|
204 |
params.put("q", StringUtils.join(mandatoryQ, " "));
|
| 203 |
params.put("fl", "*, [child parentFilter=id:catalog*]");
|
205 |
params.put("fl", "*, [child parentFilter=id:catalog*]");
|
| 204 |
params.put("sort", "rank_i asc, create_s desc");
|
206 |
params.put("sort", "rank_i asc, create_s desc");
|
| 205 |
params.put("start", String.valueOf(offset));
|
207 |
params.put("start", String.valueOf(offset));
|
| Line 211... |
Line 213... |
| 211 |
} catch (HttpHostConnectException e) {
|
213 |
} catch (HttpHostConnectException e) {
|
| 212 |
throw new ProfitMandiBusinessException("", "", "Could not connect to host");
|
214 |
throw new ProfitMandiBusinessException("", "", "Could not connect to host");
|
| 213 |
}
|
215 |
}
|
| 214 |
JSONObject solrResponseJSONObj = new JSONObject(response).getJSONObject("response");
|
216 |
JSONObject solrResponseJSONObj = new JSONObject(response).getJSONObject("response");
|
| 215 |
JSONArray docs = solrResponseJSONObj.getJSONArray("docs");
|
217 |
JSONArray docs = solrResponseJSONObj.getJSONArray("docs");
|
| 216 |
Map<Integer, TagListing> itemTagListingMap = null;
|
- |
|
| 217 |
if (docs.length() > 0) {
|
- |
|
| 218 |
HashSet<Integer> itemsSet = new HashSet<>();
|
- |
|
| 219 |
for (int i = 0; i < docs.length(); i++) {
|
- |
|
| 220 |
JSONObject doc = docs.getJSONObject(i);
|
- |
|
| 221 |
for (int j = 0; j < doc.getJSONArray("_childDocuments_").length(); j++) {
|
- |
|
| 222 |
JSONObject childItem = doc.getJSONArray("_childDocuments_").getJSONObject(j);
|
- |
|
| 223 |
int itemId = childItem.getInt("itemId_i");
|
- |
|
| 224 |
itemsSet.add(itemId);
|
- |
|
| 225 |
}
|
- |
|
| 226 |
}
|
- |
|
| 227 |
itemTagListingMap = tagListingRepository.selectByItemIdsAndTagIds(itemsSet, new HashSet<>(tagIds))
|
- |
|
| 228 |
.stream().collect(Collectors.toMap(x -> x.getItemId(), x -> x));
|
- |
|
| 229 |
}
|
- |
|
| 230 |
|
- |
|
| 231 |
for (int i = 0; i < docs.length(); i++) {
|
- |
|
| 232 |
Map<Integer, FofoAvailabilityInfo> fofoAvailabilityInfoMap = new HashMap<>();
|
- |
|
| 233 |
JSONObject doc = docs.getJSONObject(i);
|
- |
|
| 234 |
FofoCatalogResponse ffdr = new FofoCatalogResponse();
|
218 |
dealResponse=getCatalogResponse(docs,hotDeal);
|
| 235 |
ffdr.setCatalogId(doc.getInt("catalogId_i"));
|
- |
|
| 236 |
ffdr.setImageUrl(doc.getString("imageUrl_s"));
|
- |
|
| 237 |
ffdr.setTitle(doc.getString("title_s"));
|
- |
|
| 238 |
if(brand != null) {
|
- |
|
| 239 |
ffdr.setBrand(brand);
|
- |
|
| 240 |
} else {
|
- |
|
| 241 |
ffdr.setBrand(doc.getJSONArray("brand_ss").getString(0));
|
- |
|
| 242 |
}
|
- |
|
| 243 |
|
- |
|
| 244 |
for (int j = 0; j < doc.getJSONArray("_childDocuments_").length(); j++) {
|
- |
|
| 245 |
JSONObject childItem = doc.getJSONArray("_childDocuments_").getJSONObject(j);
|
- |
|
| 246 |
int itemId = childItem.getInt("itemId_i");
|
- |
|
| 247 |
TagListing tl = itemTagListingMap.get(itemId);
|
- |
|
| 248 |
if (hotDeal) {
|
- |
|
| 249 |
if (!tl.isHotDeals()) {
|
- |
|
| 250 |
continue;
|
- |
|
| 251 |
}
|
- |
|
| 252 |
}
|
- |
|
| 253 |
float sellingPrice = (float) childItem.getDouble("sellingPrice_f");
|
- |
|
| 254 |
if (fofoAvailabilityInfoMap.containsKey(itemId)) {
|
- |
|
| 255 |
if (fofoAvailabilityInfoMap.get(itemId).getSellingPrice() > sellingPrice) {
|
- |
|
| 256 |
fofoAvailabilityInfoMap.get(itemId).setSellingPrice(sellingPrice);
|
- |
|
| 257 |
fofoAvailabilityInfoMap.get(itemId).setMop((float) childItem.getDouble("mop_f"));
|
- |
|
| 258 |
}
|
- |
|
| 259 |
} else {
|
- |
|
| 260 |
FofoAvailabilityInfo fdi = new FofoAvailabilityInfo();
|
- |
|
| 261 |
fdi.setSellingPrice((float) childItem.getDouble("sellingPrice_f"));
|
- |
|
| 262 |
fdi.setMop((float) childItem.getDouble("mop_f"));
|
- |
|
| 263 |
fdi.setColor(childItem.has("color_s") ? childItem.getString("color_s") : "");
|
- |
|
| 264 |
fdi.setTagId(childItem.getInt("tagId_i"));
|
- |
|
| 265 |
fdi.setItem_id(itemId);
|
- |
|
| 266 |
Item item = itemRepository.selectById(itemId);
|
- |
|
| 267 |
// In case its tampered glass moq should be 5
|
- |
|
| 268 |
if (item.getCategoryId() == 10020) {
|
- |
|
| 269 |
fdi.setMinBuyQuantity(10);
|
- |
|
| 270 |
} else {
|
- |
|
| 271 |
fdi.setMinBuyQuantity(1);
|
- |
|
| 272 |
}
|
- |
|
| 273 |
if (hotDeal || !tl.isActive()) {
|
- |
|
| 274 |
|
- |
|
| 275 |
int totalAvailability = 0; // Using item availability cache for now but can be changed to
|
- |
|
| 276 |
// use caching later.
|
- |
|
| 277 |
try {
|
- |
|
| 278 |
ItemAvailabilityCache iac = itemAvailabilityCacheRepository.selectByItemId(itemId);
|
- |
|
| 279 |
totalAvailability = iac.getTotalAvailability();
|
- |
|
| 280 |
fdi.setAvailability(totalAvailability);
|
- |
|
| 281 |
} catch (Exception e) {
|
- |
|
| 282 |
continue;
|
- |
|
| 283 |
}
|
- |
|
| 284 |
if (totalAvailability <= 0) {
|
- |
|
| 285 |
continue;
|
- |
|
| 286 |
}
|
- |
|
| 287 |
} else {
|
- |
|
| 288 |
fdi.setAvailability(10);
|
- |
|
| 289 |
}
|
- |
|
| 290 |
fdi.setQuantityStep(1);
|
- |
|
| 291 |
fdi.setMaxQuantity(Math.min(fdi.getAvailability(), 100));
|
- |
|
| 292 |
fofoAvailabilityInfoMap.put(itemId, fdi);
|
- |
|
| 293 |
}
|
- |
|
| 294 |
}
|
- |
|
| 295 |
if (fofoAvailabilityInfoMap.values().size() > 0) {
|
- |
|
| 296 |
ffdr.setItems(new ArrayList<FofoAvailabilityInfo>(fofoAvailabilityInfoMap.values()));
|
- |
|
| 297 |
dealResponse.add(ffdr);
|
- |
|
| 298 |
}
|
- |
|
| 299 |
}
|
- |
|
| 300 |
|
- |
|
| 301 |
} else {
|
219 |
} else {
|
| 302 |
return responseSender.badRequest(
|
220 |
return responseSender.badRequest(
|
| 303 |
new ProfitMandiBusinessException("Retailer id", userInfo.getUserId(), "NOT_FOFO_RETAILER"));
|
221 |
new ProfitMandiBusinessException("Retailer id", userInfo.getUserId(), "NOT_FOFO_RETAILER"));
|
| 304 |
}
|
222 |
}
|
| 305 |
return responseSender.ok(dealResponse);
|
223 |
return responseSender.ok(dealResponse);
|
| Line 352... |
Line 270... |
| 352 |
}
|
270 |
}
|
| 353 |
return responseSender.ok(responseObject);
|
271 |
return responseSender.ok(responseObject);
|
| 354 |
}
|
272 |
}
|
| 355 |
|
273 |
|
| 356 |
/*
|
274 |
/*
|
| 357 |
* @RequestMapping(value = "/direct-deals", method=RequestMethod.GET,produces =
|
275 |
* @RequestMapping(value = "/direct-deals",
|
| 358 |
* MediaType.APPLICATION_JSON_VALUE)
|
276 |
* method=RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE)
|
| 359 |
*
|
277 |
*
|
| 360 |
* @ApiImplicitParams({
|
278 |
* @ApiImplicitParams({
|
| 361 |
*
|
279 |
*
|
| 362 |
* @ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true,
|
280 |
* @ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required =
|
| 363 |
* dataType = "string", paramType = "header") }) public ResponseEntity<?>
|
281 |
* true, dataType = "string", paramType = "header") }) public
|
| - |
|
282 |
* ResponseEntity<?> getDirectDeals(HttpServletRequest
|
| 364 |
* getDirectDeals(HttpServletRequest request, @RequestParam(value="categoryId")
|
283 |
* request, @RequestParam(value="categoryId") String
|
| 365 |
* String categoryId,@RequestParam(value="offset") String offset,
|
284 |
* categoryId,@RequestParam(value="offset") String offset,
|
| 366 |
*
|
285 |
*
|
| 367 |
* @RequestParam(value="limit") String limit, @RequestParam(value="sort",
|
286 |
* @RequestParam(value="limit") String limit, @RequestParam(value="sort",
|
| 368 |
* required=false) String sort, @RequestParam(value="direction", required=false)
|
287 |
* required=false) String sort, @RequestParam(value="direction",
|
| 369 |
* String direction,
|
288 |
* required=false) String direction,
|
| 370 |
*
|
289 |
*
|
| 371 |
* @RequestParam(value="filterData", required=false) String filterData ){
|
290 |
* @RequestParam(value="filterData", required=false) String filterData ){
|
| 372 |
*
|
291 |
*
|
| 373 |
* return new ResponseEntity<>(profitMandiResponse,HttpStatus.OK); }
|
292 |
* return new ResponseEntity<>(profitMandiResponse,HttpStatus.OK); }
|
| 374 |
*/
|
293 |
*/
|
| Line 436... |
Line 355... |
| 436 |
}
|
355 |
}
|
| 437 |
}
|
356 |
}
|
| 438 |
/*
|
357 |
/*
|
| 439 |
* final ProfitMandiResponse<?> profitMandiResponse = new
|
358 |
* final ProfitMandiResponse<?> profitMandiResponse = new
|
| 440 |
* ProfitMandiResponse<>(LocalDateTime.now(),
|
359 |
* ProfitMandiResponse<>(LocalDateTime.now(),
|
| 441 |
* request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK,
|
360 |
* request.getRequestURL().toString(), HttpStatus.OK.toString(),
|
| 442 |
* ResponseStatus.SUCCESS, dealsResponse);
|
361 |
* HttpStatus.OK, ResponseStatus.SUCCESS, dealsResponse);
|
| 443 |
*/
|
362 |
*/
|
| 444 |
return responseSender.ok(dealsResponse);
|
363 |
return responseSender.ok(dealsResponse);
|
| 445 |
}
|
364 |
}
|
| 446 |
|
365 |
|
| - |
|
366 |
@RequestMapping(value = "/partnerdeals/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
| - |
|
367 |
@ApiImplicitParams({
|
| - |
|
368 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
|
| - |
|
369 |
@ApiOperation(value = "Get unit deal object")
|
| - |
|
370 |
public ResponseEntity<?> getUnitFocoDeal(HttpServletRequest request, @PathVariable(value = "id") long id)
|
| - |
|
371 |
throws ProfitMandiBusinessException {
|
| - |
|
372 |
List<FofoCatalogResponse> dealResponse = new ArrayList<>();
|
| - |
|
373 |
List<Integer> tagIds = Arrays.asList(4);
|
| - |
|
374 |
UserInfo userInfo = (UserInfo) request.getAttribute("userInfo");
|
| - |
|
375 |
if (roleManagerService.isPartner(userInfo.getRoleIds())) {
|
| - |
|
376 |
String categoryId = "(3 OR 6)";
|
| - |
|
377 |
UserCart uc = userAccountRepository.getUserCart(userInfo.getUserId());
|
| - |
|
378 |
RestClient rc = new RestClient();
|
| - |
|
379 |
Map<String, String> params = new HashMap<>();
|
| - |
|
380 |
List<String> mandatoryQ = new ArrayList<>();
|
| - |
|
381 |
String catalogString = "catalog" + id;
|
| - |
|
382 |
|
| - |
|
383 |
mandatoryQ.add(
|
| - |
|
384 |
String.format("+(categoryId_i:%s) +(id:%s) +{!parent which=\"id:%s\"} tagId_i:(%s)",
|
| - |
|
385 |
categoryId, catalogString, catalogString, StringUtils.join(tagIds, " ")));
|
| - |
|
386 |
|
| - |
|
387 |
params.put("q", StringUtils.join(mandatoryQ, " "));
|
| - |
|
388 |
params.put("fl", "*, [child parentFilter=id:catalog*]");
|
| - |
|
389 |
params.put("sort", "rank_i asc, create_s desc");
|
| - |
|
390 |
params.put("wt", "json");
|
| - |
|
391 |
String response = null;
|
| - |
|
392 |
try {
|
| - |
|
393 |
response = rc.get(SchemeType.HTTP, "dtr", 8984, "solr/demo/select", params);
|
| - |
|
394 |
} catch (HttpHostConnectException e) {
|
| - |
|
395 |
throw new ProfitMandiBusinessException("", "", "Could not connect to host");
|
| - |
|
396 |
}
|
| - |
|
397 |
JSONObject solrResponseJSONObj = new JSONObject(response).getJSONObject("response");
|
| - |
|
398 |
JSONArray docs = solrResponseJSONObj.getJSONArray("docs");
|
| - |
|
399 |
dealResponse=getCatalogResponse(docs,false);
|
| - |
|
400 |
} else {
|
| - |
|
401 |
return responseSender.badRequest(
|
| - |
|
402 |
new ProfitMandiBusinessException("Retailer id", userInfo.getUserId(), "NOT_FOFO_RETAILER"));
|
| - |
|
403 |
}
|
| - |
|
404 |
return responseSender.ok(dealResponse.get(0));
|
| - |
|
405 |
}
|
| - |
|
406 |
|
| - |
|
407 |
|
| 447 |
@RequestMapping(value = "/fofo/brands", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
408 |
@RequestMapping(value = "/fofo/brands", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
| 448 |
public ResponseEntity<?> getBrandsToDisplay(@RequestParam(required=false, defaultValue="0") int categoryId) {
|
409 |
public ResponseEntity<?> getBrandsToDisplay(@RequestParam(required = false, defaultValue = "0") int categoryId) {
|
| 449 |
return new ResponseEntity<>(mongoClient.getBrandsToDisplay(categoryId), HttpStatus.OK);
|
410 |
return new ResponseEntity<>(mongoClient.getBrandsToDisplay(categoryId), HttpStatus.OK);
|
| 450 |
}
|
411 |
}
|
| 451 |
|
412 |
|
| 452 |
@RequestMapping(value = "/banners/{bannerType}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
413 |
@RequestMapping(value = "/banners/{bannerType}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
| 453 |
public ResponseEntity<?> getBanners(@PathVariable String bannerType) {
|
414 |
public ResponseEntity<?> getBanners(@PathVariable String bannerType) {
|
| Line 485... |
Line 446... |
| 485 |
}
|
446 |
}
|
| 486 |
}
|
447 |
}
|
| 487 |
return responseSender.ok(responseObject);
|
448 |
return responseSender.ok(responseObject);
|
| 488 |
}
|
449 |
}
|
| 489 |
|
450 |
|
| - |
|
451 |
private List<FofoCatalogResponse> getCatalogResponse(JSONArray docs, boolean hotDeal) throws ProfitMandiBusinessException {
|
| - |
|
452 |
Map<Integer, TagListing> itemTagListingMap = null;
|
| - |
|
453 |
List<FofoCatalogResponse> dealResponse = new ArrayList<>();
|
| - |
|
454 |
List<Integer> tagIds = Arrays.asList(4);
|
| - |
|
455 |
if (docs.length() > 0) {
|
| - |
|
456 |
HashSet<Integer> itemsSet = new HashSet<>();
|
| - |
|
457 |
for (int i = 0; i < docs.length(); i++) {
|
| - |
|
458 |
JSONObject doc = docs.getJSONObject(i);
|
| - |
|
459 |
for (int j = 0; j < doc.getJSONArray("_childDocuments_").length(); j++) {
|
| - |
|
460 |
JSONObject childItem = doc.getJSONArray("_childDocuments_").getJSONObject(j);
|
| - |
|
461 |
int itemId = childItem.getInt("itemId_i");
|
| - |
|
462 |
itemsSet.add(itemId);
|
| - |
|
463 |
}
|
| - |
|
464 |
}
|
| - |
|
465 |
itemTagListingMap = tagListingRepository.selectByItemIdsAndTagIds(itemsSet, new HashSet<>(tagIds)).stream()
|
| - |
|
466 |
.collect(Collectors.toMap(x -> x.getItemId(), x -> x));
|
| - |
|
467 |
}
|
| - |
|
468 |
|
| - |
|
469 |
for (int i = 0; i < docs.length(); i++) {
|
| - |
|
470 |
Map<Integer, FofoAvailabilityInfo> fofoAvailabilityInfoMap = new HashMap<>();
|
| - |
|
471 |
JSONObject doc = docs.getJSONObject(i);
|
| - |
|
472 |
FofoCatalogResponse ffdr = new FofoCatalogResponse();
|
| - |
|
473 |
ffdr.setCatalogId(doc.getInt("catalogId_i"));
|
| - |
|
474 |
ffdr.setImageUrl(doc.getString("imageUrl_s"));
|
| - |
|
475 |
ffdr.setTitle(doc.getString("title_s"));
|
| - |
|
476 |
|
| - |
|
477 |
ffdr.setBrand(doc.getJSONArray("brand_ss").getString(0));
|
| - |
|
478 |
|
| - |
|
479 |
for (int j = 0; j < doc.getJSONArray("_childDocuments_").length(); j++) {
|
| - |
|
480 |
JSONObject childItem = doc.getJSONArray("_childDocuments_").getJSONObject(j);
|
| - |
|
481 |
int itemId = childItem.getInt("itemId_i");
|
| - |
|
482 |
TagListing tl = itemTagListingMap.get(itemId);
|
| - |
|
483 |
if (hotDeal) {
|
| - |
|
484 |
if (!tl.isHotDeals()) {
|
| - |
|
485 |
continue;
|
| - |
|
486 |
}
|
| - |
|
487 |
}
|
| - |
|
488 |
float sellingPrice = (float) childItem.getDouble("sellingPrice_f");
|
| - |
|
489 |
if (fofoAvailabilityInfoMap.containsKey(itemId)) {
|
| - |
|
490 |
if (fofoAvailabilityInfoMap.get(itemId).getSellingPrice() > sellingPrice) {
|
| - |
|
491 |
fofoAvailabilityInfoMap.get(itemId).setSellingPrice(sellingPrice);
|
| - |
|
492 |
fofoAvailabilityInfoMap.get(itemId).setMop((float) childItem.getDouble("mop_f"));
|
| - |
|
493 |
}
|
| - |
|
494 |
} else {
|
| - |
|
495 |
FofoAvailabilityInfo fdi = new FofoAvailabilityInfo();
|
| - |
|
496 |
fdi.setSellingPrice((float) childItem.getDouble("sellingPrice_f"));
|
| - |
|
497 |
fdi.setMop((float) childItem.getDouble("mop_f"));
|
| - |
|
498 |
fdi.setColor(childItem.has("color_s") ? childItem.getString("color_s") : "");
|
| - |
|
499 |
fdi.setTagId(childItem.getInt("tagId_i"));
|
| - |
|
500 |
fdi.setItem_id(itemId);
|
| - |
|
501 |
Item item = itemRepository.selectById(itemId);
|
| - |
|
502 |
// In case its tampered glass moq should be 5
|
| - |
|
503 |
if (item.getCategoryId() == 10020) {
|
| - |
|
504 |
fdi.setMinBuyQuantity(10);
|
| - |
|
505 |
} else {
|
| - |
|
506 |
fdi.setMinBuyQuantity(1);
|
| - |
|
507 |
}
|
| - |
|
508 |
if (hotDeal || !tl.isActive()) {
|
| - |
|
509 |
|
| - |
|
510 |
int totalAvailability = 0; // Using item availability
|
| - |
|
511 |
// cache for now but can be
|
| - |
|
512 |
// changed to
|
| - |
|
513 |
// use caching later.
|
| - |
|
514 |
try {
|
| - |
|
515 |
ItemAvailabilityCache iac = itemAvailabilityCacheRepository.selectByItemId(itemId);
|
| - |
|
516 |
totalAvailability = iac.getTotalAvailability();
|
| - |
|
517 |
fdi.setAvailability(totalAvailability);
|
| - |
|
518 |
} catch (Exception e) {
|
| - |
|
519 |
continue;
|
| - |
|
520 |
}
|
| - |
|
521 |
if (totalAvailability <= 0) {
|
| - |
|
522 |
continue;
|
| - |
|
523 |
}
|
| - |
|
524 |
} else {
|
| - |
|
525 |
fdi.setAvailability(10);
|
| - |
|
526 |
}
|
| - |
|
527 |
fdi.setQuantityStep(1);
|
| - |
|
528 |
fdi.setMaxQuantity(Math.min(fdi.getAvailability(), 100));
|
| - |
|
529 |
fofoAvailabilityInfoMap.put(itemId, fdi);
|
| - |
|
530 |
}
|
| - |
|
531 |
}
|
| - |
|
532 |
if (fofoAvailabilityInfoMap.values().size() > 0) {
|
| - |
|
533 |
ffdr.setItems(new ArrayList<FofoAvailabilityInfo>(fofoAvailabilityInfoMap.values()));
|
| - |
|
534 |
dealResponse.add(ffdr);
|
| - |
|
535 |
}
|
| - |
|
536 |
}
|
| - |
|
537 |
return dealResponse;
|
| - |
|
538 |
|
| - |
|
539 |
}
|
| - |
|
540 |
|
| 490 |
}
|
541 |
}
|