Subversion Repositories SmartDukaan

Rev

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

Rev 31724 Rev 31733
Line 4725... Line 4725...
4725
 
4725
 
4726
        }
4726
        }
4727
 
4727
 
4728
    }
4728
    }
4729
 
4729
 
4730
    @Autowired
-
 
4731
    private WebListingRepository webListingRepository;
-
 
4732
 
-
 
4733
    @Autowired
-
 
4734
    private WebProductListingRepository webProductListingRepository;
-
 
4735
 
-
 
4736
    public void pushDataToSolr() throws Exception {
-
 
4737
        fofoSolr.pushData();
-
 
4738
    }
-
 
4739
 
-
 
4740
    public void getBestSeller() throws ProfitMandiBusinessException {
-
 
4741
        WebListing webListing = webListingRepository.selectByUrl("partner-best-sellers");
-
 
4742
 
-
 
4743
        List<WebProductListing> webProductListings = webProductListingRepository
-
 
4744
                .selectAllByWebListingId(webListing.getId());
-
 
4745
 
-
 
4746
        List<Integer> catalogItemIds = orderRepository.selectAllOrderWeight(LocalDateTime.now().minusDays(30),
-
 
4747
                LocalDateTime.now(), OrderStatus.DELIVERY_SUCCESS);
-
 
4748
 
-
 
4749
        LOGGER.info("catalogItemIds {}", catalogItemIds);
-
 
4750
        if (!catalogItemIds.isEmpty()) {
-
 
4751
            webProductListingRepository.deleteByEqual(webListing.getId());
-
 
4752
            int count = 0;
-
 
4753
            for (Integer catalogItemId : catalogItemIds) {
-
 
4754
 
-
 
4755
                WebProductListing webProductListing = new WebProductListing();
-
 
4756
                webProductListing.setEntityId(catalogItemId);
-
 
4757
                webProductListing.setWebListingId(webListing.getId());
-
 
4758
                count = count + 1;
-
 
4759
 
-
 
4760
                webProductListing.setRank(count + 1);
-
 
4761
                webProductListingRepository.persist(webProductListing);
-
 
4762
 
-
 
4763
            }
-
 
4764
 
-
 
4765
        }
-
 
4766
    }
-
 
4767
 
-
 
4768
    public void getPriceDrop() throws ProfitMandiBusinessException {
-
 
4769
        WebListing webListing = webListingRepository.selectByUrl("partner-price-drop");
-
 
4770
 
-
 
4771
        List<WebProductListing> webProductListings = webProductListingRepository
-
 
4772
                .selectAllByWebListingId(webListing.getId());
-
 
4773
 
-
 
4774
        Set<Integer> catalogItemIds = priceDropRepository
-
 
4775
                .selectAllByDatesBetweenSortByDate(LocalDateTime.now().minusDays(30), LocalDateTime.now()).stream()
-
 
4776
              .filter(x->x.getAmount()>0).map(x -> x.getCatalogItemId()).collect(Collectors.toSet());
-
 
4777
 
-
 
4778
        LOGGER.info("catalogItemIds {}", catalogItemIds);
-
 
4779
        if (!catalogItemIds.isEmpty()) {
-
 
4780
            webProductListingRepository.deleteByEqual(webListing.getId());
-
 
4781
            int count = 0;
-
 
4782
            for (Integer catalogItemId : catalogItemIds) {
-
 
4783
 
-
 
4784
                WebProductListing webProductListing = new WebProductListing();
-
 
4785
                webProductListing.setEntityId(catalogItemId);
-
 
4786
                webProductListing.setWebListingId(webListing.getId());
-
 
4787
                count = count + 1;
-
 
4788
                webProductListing.setRank(count);
-
 
4789
                webProductListingRepository.persist(webProductListing);
-
 
4790
 
-
 
4791
            }
-
 
4792
 
-
 
4793
        }
-
 
4794
    }
-
 
4795
 
-
 
4796
    public void getNewLaunches() throws ProfitMandiBusinessException {
-
 
4797
        WebListing webListing = webListingRepository.selectByUrl("new-launches");
-
 
4798
 
-
 
4799
        Set<Integer> itemIds = tagListingRepository
-
 
4800
                .selectAllByDatesBetweenSortByDate(LocalDateTime.now().minusDays(30), LocalDateTime.now()).stream()
-
 
4801
                .map(x -> x.getItemId()).collect(Collectors.toSet());
-
 
4802
 
-
 
4803
        Set<Integer> catalogItemIds = itemRepository.selectByIds(itemIds).stream().map(x -> x.getCatalogItemId())
-
 
4804
                .collect(Collectors.toSet());
-
 
4805
 
-
 
4806
        LOGGER.info("catalogItemIds {}", catalogItemIds);
-
 
4807
        if (!catalogItemIds.isEmpty()) {
-
 
4808
            webProductListingRepository.deleteByEqual(webListing.getId());
-
 
4809
            int count = 0;
-
 
4810
            for (Integer catalogItemId : catalogItemIds) {
-
 
4811
 
-
 
4812
                WebProductListing webProductListing = new WebProductListing();
-
 
4813
                webProductListing.setEntityId(catalogItemId);
-
 
4814
                webProductListing.setWebListingId(webListing.getId());
-
 
4815
                count = count + 1;
-
 
4816
                webProductListing.setRank(count);
-
 
4817
                webProductListingRepository.persist(webProductListing);
-
 
4818
 
-
 
4819
            }
-
 
4820
 
-
 
4821
        }
-
 
4822
    }
-
 
4823
 
-
 
4824
    public void getSpecialSupport() throws ProfitMandiBusinessException {
-
 
4825
        WebListing webListing = webListingRepository.selectByUrl("special-support");
-
 
4826
 
-
 
4827
        List<Integer> catalogItemIds = schemeRepository.getActiveScheme(SchemeType.SPECIAL_SUPPORT,
-
 
4828
                LocalDate.now().plusDays(1));
-
 
4829
 
-
 
4830
        LOGGER.info("catalogItemIds {}", catalogItemIds);
-
 
4831
        if (!catalogItemIds.isEmpty()) {
-
 
4832
            webProductListingRepository.deleteByEqual(webListing.getId());
-
 
4833
            int count = 0;
-
 
4834
            for (Integer catalogItemId : catalogItemIds) {
-
 
4835
 
-
 
4836
                WebProductListing webProductListing = new WebProductListing();
-
 
4837
                webProductListing.setEntityId(catalogItemId);
-
 
4838
                webProductListing.setWebListingId(webListing.getId());
-
 
4839
                count = count + 1;
-
 
4840
                webProductListing.setRank(count);
-
 
4841
                webProductListingRepository.persist(webProductListing);
-
 
4842
 
-
 
4843
            }
-
 
4844
 
-
 
4845
        }
-
 
4846
    }
-
 
4847
 
-
 
4848
    public void getUpgradeOffer() throws ProfitMandiBusinessException {
-
 
4849
        WebListing webListing = webListingRepository.selectByUrl("upgrade-offer");
-
 
4850
        webProductListingRepository.deleteByEqual(webListing.getId());
-
 
4851
 
-
 
4852
        List<Integer> customerOfferIds = customerOfferRepository.selectOffers(LocalDate.now()).stream()
-
 
4853
                .map(x -> x.getId()).collect(Collectors.toList());
-
 
4854
 
-
 
4855
        List<Integer> catalogItemIds = customerOfferItemRepository
-
 
4856
                .selectByOfferIdsRange(customerOfferIds, LocalDate.now()).stream().map(x -> x.getCatalogId()).distinct()
-
 
4857
                .collect(Collectors.toList());
-
 
4858
 
-
 
4859
        LOGGER.info("catalogItemIds {}", catalogItemIds);
-
 
4860
        if (!catalogItemIds.isEmpty()) {
-
 
4861
            int count = 0;
-
 
4862
            for (Integer catalogItemId : catalogItemIds) {
-
 
4863
 
-
 
4864
                WebProductListing webProductListing = new WebProductListing();
-
 
4865
                webProductListing.setEntityId(catalogItemId);
-
 
4866
                webProductListing.setWebListingId(webListing.getId());
-
 
4867
                count = count + 1;
-
 
4868
                webProductListing.setRank(count);
-
 
4869
                webProductListingRepository.persist(webProductListing);
-
 
4870
 
-
 
4871
            }
-
 
4872
 
-
 
4873
        }
-
 
4874
    }
-
 
4875
 
-
 
4876
}
4730
}
4877
// 2284'
4731
// 2284'
4878
4732