Subversion Repositories SmartDukaan

Rev

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

Rev 26441 Rev 26515
Line 555... Line 555...
555
		List<Integer> tagIds = Arrays.asList(4);
555
		List<Integer> tagIds = Arrays.asList(4);
556
		if (docs.length() > 0) {
556
		if (docs.length() > 0) {
557
			HashSet<Integer> itemsSet = new HashSet<>();
557
			HashSet<Integer> itemsSet = new HashSet<>();
558
			for (int i = 0; i < docs.length(); i++) {
558
			for (int i = 0; i < docs.length(); i++) {
559
				JSONObject doc = docs.getJSONObject(i);
559
				JSONObject doc = docs.getJSONObject(i);
-
 
560
				if(doc.has("_childDocuments_")) {
560
				for (int j = 0; j < doc.getJSONArray("_childDocuments_").length(); j++) {
561
					for (int j = 0; j < doc.getJSONArray("_childDocuments_").length(); j++) {
561
					JSONObject childItem = doc.getJSONArray("_childDocuments_").getJSONObject(j);
562
						JSONObject childItem = doc.getJSONArray("_childDocuments_").getJSONObject(j);
562
					int itemId = childItem.getInt("itemId_i");
563
						int itemId = childItem.getInt("itemId_i");
563
					itemsSet.add(itemId);
564
						itemsSet.add(itemId);
-
 
565
					}
564
				}
566
				}
565
			}
567
			}
566
			itemTagListingMap = tagListingRepository.selectByItemIdsAndTagIds(itemsSet, new HashSet<>(tagIds)).stream()
568
			itemTagListingMap = tagListingRepository.selectByItemIdsAndTagIds(itemsSet, new HashSet<>(tagIds)).stream()
567
					.collect(Collectors.toMap(x -> x.getItemId(), x -> x));
569
					.collect(Collectors.toMap(x -> x.getItemId(), x -> x));
568
		}
570
		}
Line 579... Line 581...
579
			} catch (Exception e) {
581
			} catch (Exception e) {
580
				ffdr.setFeature(null);
582
				ffdr.setFeature(null);
581
				logger.info("Could not find Feature_s for {}", ffdr.getCatalogId());
583
				logger.info("Could not find Feature_s for {}", ffdr.getCatalogId());
582
			}
584
			}
583
			ffdr.setBrand(doc.getJSONArray("brand_ss").getString(0));
585
			ffdr.setBrand(doc.getJSONArray("brand_ss").getString(0));
584
 
-
 
-
 
586
			if(doc.has("_childDocuments_")) {
585
			for (int j = 0; j < doc.getJSONArray("_childDocuments_").length(); j++) {
587
				for (int j = 0; j < doc.getJSONArray("_childDocuments_").length(); j++) {
586
				JSONObject childItem = doc.getJSONArray("_childDocuments_").getJSONObject(j);
588
					JSONObject childItem = doc.getJSONArray("_childDocuments_").getJSONObject(j);
587
				int itemId = childItem.getInt("itemId_i");
589
					int itemId = childItem.getInt("itemId_i");
588
				TagListing tl = itemTagListingMap.get(itemId);
590
					TagListing tl = itemTagListingMap.get(itemId);
589
				if (tl == null) {
591
					if (tl == null) {
590
					logger.warn("Could not find item id {}", itemId);
592
						logger.warn("Could not find item id {}", itemId);
591
					continue;
-
 
592
				}
-
 
593
				if (hotDeal) {
-
 
594
					if (!tl.isHotDeals()) {
-
 
595
						continue;
593
						continue;
596
					}
594
					}
597
				}
-
 
598
				float sellingPrice = (float) childItem.getDouble("sellingPrice_f");
-
 
599
				if (fofoAvailabilityInfoMap.containsKey(itemId)) {
-
 
600
					if (fofoAvailabilityInfoMap.get(itemId).getSellingPrice() > sellingPrice) {
-
 
601
						fofoAvailabilityInfoMap.get(itemId).setSellingPrice(sellingPrice);
-
 
602
						fofoAvailabilityInfoMap.get(itemId).setMop((float) childItem.getDouble("mop_f"));
-
 
603
					}
-
 
604
				} else {
-
 
605
					FofoAvailabilityInfo fdi = new FofoAvailabilityInfo();
-
 
606
					fdi.setSellingPrice((float) childItem.getDouble("sellingPrice_f"));
-
 
607
					fdi.setMop((float) childItem.getDouble("mop_f"));
-
 
608
					fdi.setColor(childItem.has("color_s") ? childItem.getString("color_s") : "");
-
 
609
					fdi.setTagId(childItem.getInt("tagId_i"));
-
 
610
					fdi.setItem_id(itemId);
-
 
611
					Item item = itemRepository.selectById(itemId);
-
 
612
					// In case its tampered glass moq should be 5
-
 
613
					if (item.getCategoryId() == 10020) {
-
 
614
						fdi.setMinBuyQuantity(10);
-
 
615
					} else {
595
					if (hotDeal) {
616
						fdi.setMinBuyQuantity(1);
-
 
617
					}
-
 
618
					if (hotDeal || !tl.isActive()) {
596
						if (!tl.isHotDeals()) {
619
 
-
 
620
						int totalAvailability = 0; // Using item availability
-
 
621
													// cache for now but can be
-
 
622
													// changed to
-
 
623
													// use caching later.
-
 
624
						try {
-
 
625
							ItemAvailabilityCache iac = itemAvailabilityCacheRepository.selectByItemId(itemId);
-
 
626
							totalAvailability = iac.getTotalAvailability();
-
 
627
							fdi.setAvailability(totalAvailability);
-
 
628
						} catch (Exception e) {
-
 
629
							continue;
597
							continue;
630
						}
598
						}
-
 
599
					}
-
 
600
					float sellingPrice = (float) childItem.getDouble("sellingPrice_f");
631
						if (totalAvailability <= 0) {
601
					if (fofoAvailabilityInfoMap.containsKey(itemId)) {
-
 
602
						if (fofoAvailabilityInfoMap.get(itemId).getSellingPrice() > sellingPrice) {
632
							continue;
603
							fofoAvailabilityInfoMap.get(itemId).setSellingPrice(sellingPrice);
-
 
604
							fofoAvailabilityInfoMap.get(itemId).setMop((float) childItem.getDouble("mop_f"));
633
						}
605
						}
634
					} else {
606
					} else {
-
 
607
						FofoAvailabilityInfo fdi = new FofoAvailabilityInfo();
-
 
608
						fdi.setSellingPrice((float) childItem.getDouble("sellingPrice_f"));
-
 
609
						fdi.setMop((float) childItem.getDouble("mop_f"));
-
 
610
						fdi.setColor(childItem.has("color_s") ? childItem.getString("color_s") : "");
-
 
611
						fdi.setTagId(childItem.getInt("tagId_i"));
-
 
612
						fdi.setItem_id(itemId);
-
 
613
						Item item = itemRepository.selectById(itemId);
-
 
614
						// In case its tampered glass moq should be 5
-
 
615
						if (item.getCategoryId() == 10020) {
-
 
616
							fdi.setMinBuyQuantity(10);
-
 
617
						} else {
-
 
618
							fdi.setMinBuyQuantity(1);
-
 
619
						}
-
 
620
						if (hotDeal || !tl.isActive()) {
-
 
621
							
-
 
622
							int totalAvailability = 0; // Using item availability
-
 
623
							// cache for now but can be
-
 
624
							// changed to
-
 
625
							// use caching later.
-
 
626
							try {
-
 
627
								ItemAvailabilityCache iac = itemAvailabilityCacheRepository.selectByItemId(itemId);
-
 
628
								totalAvailability = iac.getTotalAvailability();
-
 
629
								fdi.setAvailability(totalAvailability);
-
 
630
							} catch (Exception e) {
-
 
631
								continue;
-
 
632
							}
-
 
633
							if (totalAvailability <= 0) {
-
 
634
								continue;
-
 
635
							}
-
 
636
						} else {
635
						// For accessories item availability should at be ordered for Rs.1000
637
							// For accessories item availability should at be ordered for Rs.1000
636
						fdi.setAvailability(100);
638
							fdi.setAvailability(100);
-
 
639
						}
-
 
640
						fdi.setQuantityStep(1);
-
 
641
						fdi.setMaxQuantity(Math.min(fdi.getAvailability(), 100));
-
 
642
						fofoAvailabilityInfoMap.put(itemId, fdi);
637
					}
643
					}
638
					fdi.setQuantityStep(1);
-
 
639
					fdi.setMaxQuantity(Math.min(fdi.getAvailability(), 100));
-
 
640
					fofoAvailabilityInfoMap.put(itemId, fdi);
-
 
641
				}
644
				}
642
			}
645
			}
643
			if (fofoAvailabilityInfoMap.values().size() > 0) {
646
			if (fofoAvailabilityInfoMap.values().size() > 0) {
644
				ffdr.setItems(new ArrayList<FofoAvailabilityInfo>(fofoAvailabilityInfoMap.values()));
647
				ffdr.setItems(new ArrayList<FofoAvailabilityInfo>(fofoAvailabilityInfoMap.values()));
645
				dealResponse.add(ffdr);
648
				dealResponse.add(ffdr);