Subversion Repositories SmartDukaan

Rev

Rev 27052 | Rev 27058 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 27052 Rev 27053
Line 273... Line 273...
273
				solrService.getSolrDocs(queryTerm, categoryId, offset, limit, sort, brand, subCategoryId, hotDeal),
273
				solrService.getSolrDocs(queryTerm, categoryId, offset, limit, sort, brand, subCategoryId, hotDeal),
274
				hotDeal, userInfo.getRetailerId());
274
				hotDeal, userInfo.getRetailerId());
275
		return responseSender.ok(dealResponse);
275
		return responseSender.ok(dealResponse);
276
	}
276
	}
277
 
277
 
278
 
-
 
279
	@ApiImplicitParams({
278
	@ApiImplicitParams({
280
			@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
279
			@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
281
	@RequestMapping(value = "/partnerStock", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
280
	@RequestMapping(value = "/partnerStock", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
282
	public ResponseEntity<?> partnerStock(HttpServletRequest request,
281
	public ResponseEntity<?> partnerStock(HttpServletRequest request,
283
			@RequestParam(value = "categoryId", required = false, defaultValue = "3") String categoryId,
282
			@RequestParam(value = "categoryId", required = false, defaultValue = "3") String categoryId,
Line 546... Line 545...
546
			}
545
			}
547
		}
546
		}
548
		return responseSender.ok(responseObject);
547
		return responseSender.ok(responseObject);
549
	}
548
	}
550
 
549
 
551
	private List<FofoCatalogResponse> getCatalogResponse(JSONArray docs, boolean hotDeal, int fofoId)
550
	private List<FofoCatalogResponse> getCatalogResponse(JSONArray docs, boolean hotDeal, int fofoId) throws Exception {
552
			throws Exception {
-
 
553
		List<FofoCatalogResponse> dealResponse = new ArrayList<>();
551
		List<FofoCatalogResponse> dealResponse = new ArrayList<>();
554
		List<Integer> tagIds = Arrays.asList(4);
552
		List<Integer> tagIds = Arrays.asList(4);
555
		List<Integer> itemIds = new ArrayList<>();
553
		List<Integer> itemIds = new ArrayList<>();
556
		if (docs.length() > 0) {
554
		if (docs.length() > 0) {
557
			for (int i = 0; i < docs.length(); i++) {
555
			for (int i = 0; i < docs.length(); i++) {
Line 566... Line 564...
566
			}
564
			}
567
			if (itemIds.size() == 0) {
565
			if (itemIds.size() == 0) {
568
				return dealResponse;
566
				return dealResponse;
569
			}
567
			}
570
		}
568
		}
571
		//get warehouse Id
569
		// get warehouse Id
572
		int warehouseId = fofoStoreRepository.selectByRetailerId(fofoId).getWarehouseId();
570
		int warehouseId = fofoStoreRepository.selectByRetailerId(fofoId).getWarehouseId();
573
		Map<Integer, List<SaholicCIS>> itemAvailabilityMap = saholicInventoryService.getSaholicStock().get(warehouseId); 
571
		Map<Integer, List<SaholicCIS>> itemAvailabilityMap = saholicInventoryService.getSaholicStock().get(warehouseId);
574
		Map<Integer, List<SaholicPOItem>> poItemAvailabilityMap = saholicInventoryService.getSaholicPOItems().get(warehouseId); 
572
		Map<Integer, List<SaholicPOItem>> poItemAvailabilityMap = saholicInventoryService.getSaholicPOItems()
-
 
573
				.get(warehouseId);
575
		
574
 
576
		for (int i = 0; i < docs.length(); i++) {
575
		for (int i = 0; i < docs.length(); i++) {
577
			Map<Integer, FofoAvailabilityInfo> fofoAvailabilityInfoMap = new HashMap<>();
576
			Map<Integer, FofoAvailabilityInfo> fofoAvailabilityInfoMap = new HashMap<>();
578
			JSONObject doc = docs.getJSONObject(i);
577
			JSONObject doc = docs.getJSONObject(i);
579
			FofoCatalogResponse ffdr = new FofoCatalogResponse();
578
			FofoCatalogResponse ffdr = new FofoCatalogResponse();
580
			ffdr.setCatalogId(doc.getInt("catalogId_i"));
579
			ffdr.setCatalogId(doc.getInt("catalogId_i"));
Line 600... Line 599...
600
							fofoAvailabilityInfoMap.get(itemId).setMop((float) childItem.getDouble("mop_f"));
599
							fofoAvailabilityInfoMap.get(itemId).setMop((float) childItem.getDouble("mop_f"));
601
						}
600
						}
602
					} else {
601
					} else {
603
						FofoAvailabilityInfo fdi = new FofoAvailabilityInfo();
602
						FofoAvailabilityInfo fdi = new FofoAvailabilityInfo();
604
						List<SaholicCIS> currentAvailability = itemAvailabilityMap.get(itemId);
603
						List<SaholicCIS> currentAvailability = itemAvailabilityMap.get(itemId);
605
						List<SaholicPOItem> poItemAvailability = poItemAvailabilityMap.get(itemId); 
604
						List<SaholicPOItem> poItemAvailability = poItemAvailabilityMap.get(itemId);
-
 
605
						Map<Integer, SaholicCIS> map = null;
-
 
606
						if (currentAvailability != null) {
-
 
607
							map = currentAvailability.stream()
-
 
608
									.collect(Collectors.toMap(SaholicCIS::getWarehouseFrom, x -> x));
-
 
609
							if (poItemAvailability != null) {
-
 
610
								for (SaholicPOItem saholicPOItem : poItemAvailability) {
-
 
611
									if (map.containsKey(saholicPOItem.getWarehouseFrom())) {
-
 
612
										map.get(saholicPOItem.getWarehouseFrom())
-
 
613
												.setPopendingQty(saholicPOItem.getUnfulfilledQty());
-
 
614
									} else {
-
 
615
										SaholicCIS saholicCIS = new SaholicCIS();
-
 
616
										saholicCIS.setAvailability(0);
-
 
617
										saholicCIS.setReserved(0);
-
 
618
										saholicCIS.setItemId(itemId);
-
 
619
										saholicCIS.setPopendingQty(saholicPOItem.getUnfulfilledQty());
-
 
620
										saholicCIS.setWarehouseFrom(saholicPOItem.getWarehouseFrom());
-
 
621
										map.put(saholicPOItem.getWarehouseFrom(), saholicCIS);
-
 
622
									}
-
 
623
								}
-
 
624
							}
-
 
625
						} else {
-
 
626
							map = new HashMap<>();
-
 
627
							if (poItemAvailability != null) {
-
 
628
								for (SaholicPOItem saholicPOItem : poItemAvailability) {
-
 
629
									SaholicCIS saholicCIS = new SaholicCIS();
-
 
630
									saholicCIS.setAvailability(0);
-
 
631
									saholicCIS.setReserved(0);
-
 
632
									saholicCIS.setItemId(itemId);
-
 
633
									saholicCIS.setPopendingQty(saholicPOItem.getUnfulfilledQty());
-
 
634
									saholicCIS.setWarehouseFrom(saholicPOItem.getWarehouseFrom());
-
 
635
									map.put(saholicPOItem.getWarehouseFrom(), saholicCIS);
-
 
636
								}
-
 
637
							}
-
 
638
 
-
 
639
						}
-
 
640
						fdi.setSaholicCISList(new ArrayList<>(map.values()));
606
						String poColor = "grey";
641
						String poColor = "grey";
607
						boolean active = false;
642
						boolean active = false;
-
 
643
						if (currentAvailability != null && currentAvailability.stream()
608
						if(currentAvailability != null && currentAvailability.stream().collect(Collectors.summingInt(SaholicCIS::getNetavailability)) > 0) {
644
								.collect(Collectors.summingInt(SaholicCIS::getNetavailability)) > 0) {
609
								poColor = "green";
645
							poColor = "green";
610
								modelColorClass = "green";
646
							modelColorClass = "green";
-
 
647
						} else if (poItemAvailability != null && poItemAvailability.stream()
611
						} else if (poItemAvailability != null && poItemAvailability.stream().collect(Collectors.summingInt(SaholicPOItem::getUnfulfilledQty)) > 0) {
648
								.collect(Collectors.summingInt(SaholicPOItem::getUnfulfilledQty)) > 0) {
612
							if(currentAvailability != null 
649
							if (currentAvailability != null && poItemAvailability.stream()
613
							&& poItemAvailability.stream().collect(Collectors.summingInt(SaholicPOItem::getUnfulfilledQty)) 
650
									.collect(Collectors.summingInt(SaholicPOItem::getUnfulfilledQty))
-
 
651
									+ currentAvailability.stream()
614
								+ currentAvailability.stream().collect(Collectors.summingInt(SaholicCIS::getNetavailability))
652
											.collect(Collectors.summingInt(SaholicCIS::getNetavailability)) <= 0) {
615
							<= 0) {
-
 
616
								poColor = "grey";
653
								poColor = "grey";
617
							} else {
654
							} else {
618
								poColor = "yellow";
655
								poColor = "yellow";
619
								if(modelColorClass!="green") {
656
								if (modelColorClass != "green") {
620
									modelColorClass = poColor;
657
									modelColorClass = poColor;
621
								}
658
								}
622
							}
659
							}
623
						}
660
						}
624
						fdi.setColorClass(poColor);
661
						fdi.setColorClass(poColor);
Line 626... Line 663...
626
						fdi.setActive(active);
663
						fdi.setActive(active);
627
						fdi.setMrp(childItem.getDouble("mrp_f"));
664
						fdi.setMrp(childItem.getDouble("mrp_f"));
628
						fdi.setMop((float) childItem.getDouble("mop_f"));
665
						fdi.setMop((float) childItem.getDouble("mop_f"));
629
						fdi.setColor(childItem.has("color_s") ? childItem.getString("color_s") : "");
666
						fdi.setColor(childItem.has("color_s") ? childItem.getString("color_s") : "");
630
						if (fdi.getColor().equalsIgnoreCase("any colour")) {
667
						if (fdi.getColor().equalsIgnoreCase("any colour")) {
631
							fdiAnyColour = fdi; 
668
							fdiAnyColour = fdi;
632
						}
669
						}
633
						fdi.setTagId(childItem.getInt("tagId_i"));
670
						fdi.setTagId(childItem.getInt("tagId_i"));
634
						fdi.setItem_id(itemId);
671
						fdi.setItem_id(itemId);
635
						Float cashBack = schemeService.getItemSchemeCashBack().get(itemId);
672
						Float cashBack = schemeService.getItemSchemeCashBack().get(itemId);
636
						cashBack = cashBack == null ? 0 : cashBack;
673
						cashBack = cashBack == null ? 0 : cashBack;
637
						fdi.setCashback(cashBack);
674
						fdi.setCashback(cashBack);
638
						fdi.setMinBuyQuantity(1);
675
						fdi.setMinBuyQuantity(1);
639
						if (hotDeal) {
676
						if (hotDeal) {
640
							if(currentAvailability != null ) {
677
							if (currentAvailability != null) {
-
 
678
								fdi.setAvailability(currentAvailability.stream()
641
								fdi.setAvailability(currentAvailability.stream().collect(Collectors.summingInt(SaholicCIS::getNetavailability)));
679
										.collect(Collectors.summingInt(SaholicCIS::getNetavailability)));
642
							} else {
680
							} else {
643
								fdi.setAvailability(0);
681
								fdi.setAvailability(0);
644
							}
682
							}
645
						} else {
683
						} else {
646
							fdi.setAvailability(100);
684
							fdi.setAvailability(100);
Line 653... Line 691...
653
						fdi.setQuantityStep(1);
691
						fdi.setQuantityStep(1);
654
						fdi.setMaxQuantity(Math.min(fdi.getAvailability(), 100));
692
						fdi.setMaxQuantity(Math.min(fdi.getAvailability(), 100));
655
						fofoAvailabilityInfoMap.put(itemId, fdi);
693
						fofoAvailabilityInfoMap.put(itemId, fdi);
656
					}
694
					}
657
				}
695
				}
658
				if(fdiAnyColour != null) {
696
				if (fdiAnyColour != null) {
659
					fdiAnyColour.setColorClass(modelColorClass);
697
					fdiAnyColour.setColorClass(modelColorClass);
660
				}
698
				}
661
			}
699
			}
662
			if (fofoAvailabilityInfoMap.values().size() > 0) {
700
			if (fofoAvailabilityInfoMap.values().size() > 0) {
663
				List<FofoAvailabilityInfo> availabilityList = fofoAvailabilityInfoMap.values()
701
				List<FofoAvailabilityInfo> availabilityList = fofoAvailabilityInfoMap.values().stream()
664
				.stream().sorted(Comparator.comparing(FofoAvailabilityInfo::getAvailability).reversed()).collect(Collectors.toList());
702
						.sorted(Comparator.comparing(FofoAvailabilityInfo::getAvailability).reversed())
-
 
703
						.collect(Collectors.toList());
665
				ffdr.setItems(availabilityList);
704
				ffdr.setItems(availabilityList);
666
				dealResponse.add(ffdr);
705
				dealResponse.add(ffdr);
667
			}
706
			}
-
 
707
		}
668
		}return dealResponse;
708
		return dealResponse;
669
 
709
 
670
	}
710
	}
671
 
711
 
672
	private List<FofoCatalogResponse> getCatalogSingleSkuResponse(JSONArray docs, Map<Integer, Integer> itemFilter,
712
	private List<FofoCatalogResponse> getCatalogSingleSkuResponse(JSONArray docs, Map<Integer, Integer> itemFilter,
673
			boolean hotDeal) throws ProfitMandiBusinessException {
713
			boolean hotDeal) throws ProfitMandiBusinessException {