Subversion Repositories SmartDukaan

Rev

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

Rev 31557 Rev 31572
Line 21... Line 21...
21
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
21
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
22
import com.spice.profitmandi.dao.entity.fofo.SuggestedPo;
22
import com.spice.profitmandi.dao.entity.fofo.SuggestedPo;
23
import com.spice.profitmandi.dao.entity.fofo.SuggestedPoDetail;
23
import com.spice.profitmandi.dao.entity.fofo.SuggestedPoDetail;
24
import com.spice.profitmandi.dao.entity.inventory.SaholicCISTable;
24
import com.spice.profitmandi.dao.entity.inventory.SaholicCISTable;
25
import com.spice.profitmandi.dao.entity.inventory.SaholicPOItem;
25
import com.spice.profitmandi.dao.entity.inventory.SaholicPOItem;
-
 
26
import com.spice.profitmandi.dao.enumuration.dtr.WebListingSource;
26
import com.spice.profitmandi.dao.enumuration.dtr.WebListingType;
27
import com.spice.profitmandi.dao.enumuration.dtr.WebListingType;
27
import com.spice.profitmandi.dao.model.CreateOfferRequest;
28
import com.spice.profitmandi.dao.model.CreateOfferRequest;
28
import com.spice.profitmandi.dao.model.UserCart;
29
import com.spice.profitmandi.dao.model.UserCart;
29
import com.spice.profitmandi.dao.repository.catalog.*;
30
import com.spice.profitmandi.dao.repository.catalog.*;
30
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
31
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
Line 559... Line 560...
559
	}
560
	}
560
 
561
 
561
	@RequestMapping(value = "/partner/listing", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
562
	@RequestMapping(value = "/partner/listing", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
562
	public ResponseEntity<?> getPartnersListing(HttpServletRequest request) throws Exception {
563
	public ResponseEntity<?> getPartnersListing(HttpServletRequest request) throws Exception {
563
		List<WebListing> webListings = webListingRepository.selectAllWebListingByType(Optional.of(true),
564
		List<WebListing> webListings = webListingRepository.selectAllWebListingByType(Optional.of(true),
564
				WebListingType.partner);
565
				WebListingSource.partner);
565
		UserInfo userInfo = (UserInfo) request.getAttribute("userInfo");
566
		UserInfo userInfo = (UserInfo) request.getAttribute("userInfo");
566
		for (WebListing webListing : webListings) {
567
		for (WebListing webListing : webListings) {
567
			webListing.setFofoCatalogResponses(getDealResponses(userInfo, webListing, "0", "10"));
568
			webListing.setFofoCatalogResponses(getDealResponses(userInfo, webListing, "0", "10"));
568
		}
569
		}
569
		return responseSender.ok(webListings);
570
		return responseSender.ok(webListings);
570
	}
571
	}
571
 
572
 
572
	private List<FofoCatalogResponse> getDealResponses(UserInfo userInfo, WebListing webListing, String offset,
573
	private List<FofoCatalogResponse> getDealResponses(UserInfo userInfo, WebListing webListing, String offset,
573
			String limit) throws Exception {
574
			String limit) throws Exception {
574
		List<Integer> webProducts = webProductListingRepository
-
 
575
				.selectAllByWebListingId(webListing.getId(), Integer.parseInt(offset), Integer.parseInt(limit)).stream()
-
 
576
				.filter(x -> x.getRank() > 0).map(x -> x.getEntityId()).collect(Collectors.toList());
-
 
577
		if (webProducts.size() == 0) {
-
 
578
			return new ArrayList<>();
-
 
579
		}
575
 
580
		RestClient rc = new RestClient();
576
		RestClient rc = new RestClient();
581
		Map<String, String> params = new HashMap<>();
577
		Map<String, String> params = new HashMap<>();
582
		List<String> mandatoryQ = new ArrayList<>();
578
		List<String> mandatoryQ = new ArrayList<>();
-
 
579
 
-
 
580
		if (webListing.getType().equals(WebListingType.solr)) {
-
 
581
			mandatoryQ.add(String.format("+{!parent which=\"" + webListing.getSolrQuery() + "\"} tagId_i:(%s)",
-
 
582
					StringUtils.join(TAG_IDS, " ")));
-
 
583
 
-
 
584
		} else {
-
 
585
			List<Integer> webProducts = webProductListingRepository
-
 
586
					.selectAllByWebListingId(webListing.getId(), Integer.parseInt(offset), Integer.parseInt(limit))
-
 
587
					.stream().filter(x -> x.getRank() > 0).map(x -> x.getEntityId()).collect(Collectors.toList());
-
 
588
			if (webProducts.size() == 0) {
-
 
589
				return new ArrayList<>();
-
 
590
			}
-
 
591
 
583
		mandatoryQ.add(String.format(
592
			mandatoryQ.add(String.format(
584
				"+{!parent which=\"catalogId_i:" + StringUtils.join(webProducts, " ") + "\"} tagId_i:(%s)",
593
					"+{!parent which=\"catalogId_i:" + StringUtils.join(webProducts, " ") + "\"} tagId_i:(%s)",
585
				StringUtils.join(TAG_IDS, " ")));
594
					StringUtils.join(TAG_IDS, " ")));
-
 
595
 
-
 
596
		}
586
		params.put("q", StringUtils.join(mandatoryQ, " "));
597
		params.put("q", StringUtils.join(mandatoryQ, " "));
587
		params.put("fl", "*, [child parentFilter=id:catalog*]");
598
		params.put("fl", "*, [child parentFilter=id:catalog*]");
588
		// params.put("sort", "create_s desc");
599
		// params.put("sort", "create_s desc");
589
		params.put("start", String.valueOf(offset));
600
		params.put("start", String.valueOf(offset));
590
		params.put("rows", String.valueOf(limit));
601
		params.put("rows", String.valueOf(limit));