| Line 49... |
Line 49... |
| 49 |
import com.spice.profitmandi.dao.enumuration.dtr.OtpType;
|
49 |
import com.spice.profitmandi.dao.enumuration.dtr.OtpType;
|
| 50 |
import com.spice.profitmandi.dao.model.AddCartRequest;
|
50 |
import com.spice.profitmandi.dao.model.AddCartRequest;
|
| 51 |
import com.spice.profitmandi.dao.model.CartItem;
|
51 |
import com.spice.profitmandi.dao.model.CartItem;
|
| 52 |
import com.spice.profitmandi.dao.model.CartItemResponseModel;
|
52 |
import com.spice.profitmandi.dao.model.CartItemResponseModel;
|
| 53 |
import com.spice.profitmandi.dao.model.CartResponse;
|
53 |
import com.spice.profitmandi.dao.model.CartResponse;
|
| - |
|
54 |
import com.spice.profitmandi.dao.model.UserCart;
|
| 54 |
import com.spice.profitmandi.dao.repository.catalog.CategoryRepository;
|
55 |
import com.spice.profitmandi.dao.repository.catalog.CategoryRepository;
|
| 55 |
import com.spice.profitmandi.dao.repository.catalog.ItemRepository;
|
56 |
import com.spice.profitmandi.dao.repository.catalog.ItemRepository;
|
| 56 |
import com.spice.profitmandi.dao.repository.catalog.TagListingRepository;
|
57 |
import com.spice.profitmandi.dao.repository.catalog.TagListingRepository;
|
| 57 |
import com.spice.profitmandi.dao.repository.dtr.Mongo;
|
58 |
import com.spice.profitmandi.dao.repository.dtr.Mongo;
|
| 58 |
import com.spice.profitmandi.dao.repository.dtr.UserAccountRepository;
|
59 |
import com.spice.profitmandi.dao.repository.dtr.UserAccountRepository;
|
| Line 211... |
Line 212... |
| 211 |
return responseSender.badRequest(
|
212 |
return responseSender.badRequest(
|
| 212 |
new ProfitMandiBusinessException("Retailer id", userInfo.getUserId(), "NOT_FOFO_RETAILER"));
|
213 |
new ProfitMandiBusinessException("Retailer id", userInfo.getUserId(), "NOT_FOFO_RETAILER"));
|
| 213 |
}
|
214 |
}
|
| 214 |
return responseSender.ok(dealResponse);
|
215 |
return responseSender.ok(dealResponse);
|
| 215 |
}
|
216 |
}
|
| - |
|
217 |
|
| - |
|
218 |
|
| - |
|
219 |
@RequestMapping(value = "/store/entity/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
| - |
|
220 |
@ApiImplicitParams({
|
| - |
|
221 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
|
| - |
|
222 |
@ApiOperation(value = "Get unit deal object")
|
| - |
|
223 |
public ResponseEntity<?> getUnitFocoDeal(HttpServletRequest request, @PathVariable(value = "id") long id)
|
| - |
|
224 |
throws ProfitMandiBusinessException {
|
| - |
|
225 |
List<FofoCatalogResponse> dealResponse = new ArrayList<>();
|
| - |
|
226 |
List<Integer> tagIds = Arrays.asList(4);
|
| - |
|
227 |
UserInfo userInfo = (UserInfo) request.getAttribute("userInfo");
|
| - |
|
228 |
if (roleManagerService.isPartner(userInfo.getRoleIds())) {
|
| - |
|
229 |
String categoryId = "(3 OR 6)";
|
| - |
|
230 |
UserCart uc = userAccountRepository.getUserCart(userInfo.getUserId());
|
| - |
|
231 |
RestClient rc = new RestClient();
|
| - |
|
232 |
Map<String, String> params = new HashMap<>();
|
| - |
|
233 |
List<String> mandatoryQ = new ArrayList<>();
|
| - |
|
234 |
String catalogString = "catalog" + id;
|
| - |
|
235 |
|
| - |
|
236 |
mandatoryQ.add(String.format("+(categoryId_i:%s) +(id:%s) +{!parent which=\"id:%s\"} tagId_i:(%s)",
|
| - |
|
237 |
categoryId, catalogString, catalogString, StringUtils.join(tagIds, " ")));
|
| - |
|
238 |
|
| - |
|
239 |
params.put("q", StringUtils.join(mandatoryQ, " "));
|
| - |
|
240 |
params.put("fl", "*, [child parentFilter=id:catalog*]");
|
| - |
|
241 |
params.put("sort", "rank_i asc, create_s desc");
|
| - |
|
242 |
params.put("wt", "json");
|
| - |
|
243 |
String response = null;
|
| - |
|
244 |
try {
|
| - |
|
245 |
response = rc.get(SchemeType.HTTP, "50.116.10.120", 8984, "solr/demo/select", params);
|
| - |
|
246 |
} catch (HttpHostConnectException e) {
|
| - |
|
247 |
throw new ProfitMandiBusinessException("", "", "Could not connect to host");
|
| - |
|
248 |
}
|
| - |
|
249 |
JSONObject solrResponseJSONObj = new JSONObject(response).getJSONObject("response");
|
| - |
|
250 |
JSONArray docs = solrResponseJSONObj.getJSONArray("docs");
|
| - |
|
251 |
dealResponse = getCatalogResponse(docs, false);
|
| - |
|
252 |
} else {
|
| - |
|
253 |
return responseSender.badRequest(
|
| - |
|
254 |
new ProfitMandiBusinessException("Retailer id", userInfo.getUserId(), "NOT_FOFO_RETAILER"));
|
| - |
|
255 |
}
|
| - |
|
256 |
return responseSender.ok(dealResponse.get(0));
|
| - |
|
257 |
}
|
| 216 |
|
258 |
|
| 217 |
private Object toDealObject(JsonObject jsonObject) {
|
259 |
private Object toDealObject(JsonObject jsonObject) {
|
| 218 |
if (jsonObject.get("dealObject") != null && jsonObject.get("dealObject").asInt() == 1) {
|
260 |
if (jsonObject.get("dealObject") != null && jsonObject.get("dealObject").asInt() == 1) {
|
| 219 |
return new Gson().fromJson(jsonObject.toString(), DealObjectResponse.class);
|
261 |
return new Gson().fromJson(jsonObject.toString(), DealObjectResponse.class);
|
| 220 |
}
|
262 |
}
|
| Line 326... |
Line 368... |
| 326 |
UserInfo userInfo = (UserInfo) request.getAttribute("userInfo");
|
368 |
UserInfo userInfo = (UserInfo) request.getAttribute("userInfo");
|
| 327 |
Integer storeId = userInfo.getRetailerId();
|
369 |
Integer storeId = userInfo.getRetailerId();
|
| 328 |
List<Integer> itemIds = cartRequest.getCartItems().stream().map(x -> x.getItemId())
|
370 |
List<Integer> itemIds = cartRequest.getCartItems().stream().map(x -> x.getItemId())
|
| 329 |
.collect(Collectors.toList());
|
371 |
.collect(Collectors.toList());
|
| 330 |
Set<Integer> itemsIdsSet = new HashSet<>(itemIds);
|
372 |
Set<Integer> itemsIdsSet = new HashSet<>(itemIds);
|
| - |
|
373 |
logger.info("Store Id {}, Item Ids {}", storeId, itemsIdsSet);
|
| 331 |
List<CurrentInventorySnapshot> currentInventorySnapshot = currentInventorySnapshotRepository
|
374 |
List<CurrentInventorySnapshot> currentInventorySnapshot = currentInventorySnapshotRepository
|
| 332 |
.selectByFofoItemIds(storeId, itemsIdsSet);
|
375 |
.selectByFofoItemIds(storeId, itemsIdsSet);
|
| 333 |
Map<Integer, Integer> storeItemAvailabilityMap = currentInventorySnapshot.stream()
|
376 |
Map<Integer, Integer> storeItemAvailabilityMap = currentInventorySnapshot.stream()
|
| 334 |
.filter(x -> x.getAvailability() > 0)
|
377 |
.filter(x -> x.getAvailability() > 0)
|
| 335 |
.collect(Collectors.toMap(x -> x.getItemId(), x -> x.getAvailability()));
|
378 |
.collect(Collectors.toMap(x -> x.getItemId(), x -> x.getAvailability()));
|