Subversion Repositories SmartDukaan

Rev

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

Rev 28313 Rev 28314
Line 115... Line 115...
115
	private static final int DEFAULT_STORE = 171912487;
115
	private static final int DEFAULT_STORE = 171912487;
116
 
116
 
117
	@Autowired
117
	@Autowired
118
	CustomerAddressRepository customerAddressRepository;
118
	CustomerAddressRepository customerAddressRepository;
119
 
119
 
120
	@Autowired
120
	@Value("${solr.url}")
121
	SolrService solrService;
121
	private String solrUrl;
122
 
122
	
123
	@Autowired
123
	@Autowired
124
	InventoryService inventoryService;
124
	InventoryService inventoryService;
125
 
125
 
126
	@Autowired
126
	@Autowired
127
	UserAccountRepository userAccountRepository;
127
	UserAccountRepository userAccountRepository;
Line 136... Line 136...
136
	private int port;
136
	private int port;
137
 
137
 
138
	@Autowired
138
	@Autowired
139
	private SaholicInventoryService saholicInventoryService;
139
	private SaholicInventoryService saholicInventoryService;
140
 
140
 
141
	// This is now unused as we are not supporting multiple companies.
-
 
142
	@Value("${gadgetCops.invoice.cc}")
-
 
143
	private String[] ccGadgetCopInvoiceTo;
-
 
144
 
-
 
145
	@Autowired
141
	@Autowired
146
	private PincodePartnerRepository pincodePartnerRepository;
142
	private PincodePartnerRepository pincodePartnerRepository;
147
 
143
 
148
	@Autowired
144
	@Autowired
149
	private FofoStoreRepository fofoStoreRepository;
145
	private FofoStoreRepository fofoStoreRepository;
Line 227... Line 223...
227
			params.put("fl", "*, [child parentFilter=id:catalog*]");
223
			params.put("fl", "*, [child parentFilter=id:catalog*]");
228
			params.put("sort", "rank_i asc, create_s desc");
224
			params.put("sort", "rank_i asc, create_s desc");
229
			params.put("wt", "json");
225
			params.put("wt", "json");
230
			String response = null;
226
			String response = null;
231
			try {
227
			try {
232
				response = rc.get(SchemeType.HTTP, "50.116.10.120", 8984, "solr/demo/select", params);
228
				response = rc.get(solrUrl, params, new HashMap<>());
233
			} catch (HttpHostConnectException e) {
229
			} catch (HttpHostConnectException e) {
234
				throw new ProfitMandiBusinessException("", "", "Could not connect to host");
230
				throw new ProfitMandiBusinessException("", "", "Could not connect to host");
235
			}
231
			}
236
			JSONObject solrResponseJSONObj = new JSONObject(response).getJSONObject("response");
232
			JSONObject solrResponseJSONObj = new JSONObject(response).getJSONObject("response");
237
			JSONArray docs = solrResponseJSONObj.getJSONArray("docs");
233
			JSONArray docs = solrResponseJSONObj.getJSONArray("docs");
Line 616... Line 612...
616
		List<FofoCatalogResponse> dealResponse = new ArrayList<>();
612
		List<FofoCatalogResponse> dealResponse = new ArrayList<>();
617
		UserInfo userInfo = (UserInfo) request.getAttribute("userInfo");
613
		UserInfo userInfo = (UserInfo) request.getAttribute("userInfo");
618
		FofoStore fs = fofoStoreRepository.selectByRetailerId(userInfo.getRetailerId());
614
		FofoStore fs = fofoStoreRepository.selectByRetailerId(userInfo.getRetailerId());
619
		sort = "w" + fs.getWarehouseId() + "_i desc";
615
		sort = "w" + fs.getWarehouseId() + "_i desc";
620
		dealResponse = this.getCatalogResponse(
616
		dealResponse = this.getCatalogResponse(
621
				solrService.getSolrDocs(queryTerm, categoryId, offset, limit, sort, brand, subCategoryId, false), false,
617
				commonSolrService.getSolrDocs(queryTerm, categoryId, offset, limit, sort, brand, subCategoryId, false),
622
				userInfo.getRetailerId());
618
				false, userInfo.getRetailerId());
623
		return responseSender.ok(dealResponse);
619
		return responseSender.ok(dealResponse);
624
	}
620
	}
625
 
621
 
626
	private List<FofoCatalogResponse> getCatalogResponse(JSONArray docs, boolean hotDeal, int fofoId)
622
	private List<FofoCatalogResponse> getCatalogResponse(JSONArray docs, boolean hotDeal, int fofoId)
627
			throws ProfitMandiBusinessException {
623
			throws ProfitMandiBusinessException {
Line 705... Line 701...
705
								.thenComparingInt(y -> -y.getAvailability()))
701
								.thenComparingInt(y -> -y.getAvailability()))
706
						.collect(Collectors.toList()));
702
						.collect(Collectors.toList()));
707
				dealResponse.add(ffdr);
703
				dealResponse.add(ffdr);
708
			}
704
			}
709
		}
705
		}
710
		return dealResponse.stream().sorted((x, y) -> {
706
		return dealResponse.stream()
-
 
707
				.sorted(Comparator
-
 
708
						.comparing(FofoCatalogResponse::getItems,
711
			return Math.min(y.getItems().get(0).getAvailability(), 1)
709
								(s1, s2) -> (s2.get(0).isActive() ? 1 : 0) - (s1.get(0).isActive() ? 1 : 0))
-
 
710
						.thenComparing(FofoCatalogResponse::getItems,
712
					- Math.min(x.getItems().get(0).getAvailability(), 1);
711
								(x, y) -> y.get(0).getAvailability() - x.get(0).getAvailability()))
713
		}).collect(Collectors.toList());
712
				.collect(Collectors.toList());
714
 
-
 
715
	}
713
	}
716
 
714
 
717
	@GetMapping(value = "store/order-status/{pendingOrderId}")
715
	@GetMapping(value = "store/order-status/{pendingOrderId}")
718
	public ResponseEntity<?> orderStatus(HttpServletRequest request, @PathVariable int pendingOrderId)
716
	public ResponseEntity<?> orderStatus(HttpServletRequest request, @PathVariable int pendingOrderId)
719
			throws Exception {
717
			throws Exception {