Subversion Repositories SmartDukaan

Rev

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

Rev 31655 Rev 31664
Line 4777... Line 4777...
4777
	}
4777
	}
4778
 
4778
 
4779
	public void getBestSeller() throws ProfitMandiBusinessException {
4779
	public void getBestSeller() throws ProfitMandiBusinessException {
4780
		WebListing webListing = webListingRepository.selectByUrl("partner-best-sellers");
4780
		WebListing webListing = webListingRepository.selectByUrl("partner-best-sellers");
4781
 
4781
 
4782
		List<WebProductListing> webProductListings = webProductListingRepository
-
 
4783
				.selectAllByWebListingId(webListing.getId());
-
 
4784
 
-
 
4785
		List<Integer> catalogItemIds = orderRepository.selectAllOrderWeight(LocalDateTime.now().minusDays(30),
4782
		List<Integer> catalogItemIds = orderRepository.selectAllOrderWeight(LocalDateTime.now().minusDays(30),
4786
				LocalDateTime.now(), OrderStatus.DELIVERY_SUCCESS);
4783
				LocalDateTime.now(), OrderStatus.DELIVERY_SUCCESS);
-
 
4784
		Map<Integer, List<Item>> catalogItemsMap = itemRepository.selectAllByCatalogIds(new HashSet<>(catalogItemIds))
-
 
4785
				.stream().collect(Collectors.groupingBy(x -> x.getCatalogItemId()));
-
 
4786
 
-
 
4787
		Map<String, Integer> brandCount = new HashMap<>();
4787
 
4788
 
4788
		LOGGER.info("catalogItemIds {}", catalogItemIds);
4789
		LOGGER.info("catalogItemIds {}", catalogItemIds);
4789
		if (!catalogItemIds.isEmpty()) {
4790
		if (!catalogItemIds.isEmpty()) {
4790
			webProductListingRepository.deleteByEqual(webListing.getId());
4791
			webProductListingRepository.deleteByEqual(webListing.getId());
4791
			int count = 0;
4792
			int count = 0;
4792
			for (Integer catalogItemId : catalogItemIds) {
4793
			for (Integer catalogItemId : catalogItemIds) {
4793
 
4794
 
-
 
4795
				List<Item> items = catalogItemsMap.get(catalogItemId);
-
 
4796
 
-
 
4797
				String brand = items.get(0).getBrand();
-
 
4798
				int brandItemCount = 0;
-
 
4799
 
-
 
4800
				if (brandCount.containsKey(items.get(0).getBrand())) {
-
 
4801
					brandItemCount = brandCount.get(brand);
-
 
4802
 
-
 
4803
				}
-
 
4804
 
-
 
4805
				brandCount.put(brand, brandItemCount + 1);
-
 
4806
 
-
 
4807
				if (brandCount.get(brand) > 3) {
-
 
4808
					continue;
-
 
4809
				}
-
 
4810
 
4794
				WebProductListing webProductListing = new WebProductListing();
4811
				WebProductListing webProductListing = new WebProductListing();
4795
				webProductListing.setEntityId(catalogItemId);
4812
				webProductListing.setEntityId(catalogItemId);
4796
				webProductListing.setWebListingId(webListing.getId());
4813
				webProductListing.setWebListingId(webListing.getId());
4797
				count = count + 1;
4814
				count = count + 1;
4798
 
4815