| Line 217... |
Line 217... |
| 217 |
return responseSender.ok(dealResponse);
|
217 |
return responseSender.ok(dealResponse);
|
| 218 |
}
|
218 |
}
|
| 219 |
|
219 |
|
| 220 |
@RequestMapping(value = "/suggestedPo/status", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
|
220 |
@RequestMapping(value = "/suggestedPo/status", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
|
| 221 |
@ApiImplicitParams({
|
221 |
@ApiImplicitParams({
|
| 222 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
|
222 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header")})
|
| 223 |
@ApiOperation(value = "")
|
223 |
@ApiOperation(value = "")
|
| 224 |
public ResponseEntity<?> changeSuggestedPoStatus(HttpServletRequest request, @RequestParam int id)
|
224 |
public ResponseEntity<?> changeSuggestedPoStatus(HttpServletRequest request, @RequestParam int id)
|
| 225 |
throws ProfitMandiBusinessException {
|
225 |
throws ProfitMandiBusinessException {
|
| 226 |
SuggestedPo suggestedPo = suggestedPoRepository.selectById(id);
|
226 |
SuggestedPo suggestedPo = suggestedPoRepository.selectById(id);
|
| 227 |
suggestedPo.setStatus("closed");
|
227 |
suggestedPo.setStatus("closed");
|
| Line 238... |
Line 238... |
| 238 |
}
|
238 |
}
|
| 239 |
return String.join(",", strTagIds);
|
239 |
return String.join(",", strTagIds);
|
| 240 |
}
|
240 |
}
|
| 241 |
|
241 |
|
| 242 |
@ApiImplicitParams({
|
242 |
@ApiImplicitParams({
|
| 243 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
|
243 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header")})
|
| 244 |
@RequestMapping(value = "/fofo", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
244 |
@RequestMapping(value = "/fofo", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
| 245 |
public ResponseEntity<?> getFofo(HttpServletRequest request,
|
245 |
public ResponseEntity<?> getFofo(HttpServletRequest request,
|
| 246 |
@RequestParam(value = "categoryId", required = false, defaultValue = "3") String categoryId,
|
246 |
@RequestParam(value = "categoryId", required = false, defaultValue = "3") String categoryId,
|
| 247 |
@RequestParam(value = "offset") String offset, @RequestParam(value = "limit") String limit,
|
247 |
@RequestParam(value = "offset") String offset, @RequestParam(value = "limit") String limit,
|
| 248 |
@RequestParam(value = "sort", required = false) String sort,
|
248 |
@RequestParam(value = "sort", required = false) String sort,
|
| 249 |
@RequestParam(value = "brand", required = false) String brand,
|
249 |
@RequestParam(value = "brand", required = false) String brand,
|
| 250 |
@RequestParam(value = "subCategoryId", required = false) int subCategoryId,
|
250 |
@RequestParam(value = "subCategoryId", required = false) int subCategoryId,
|
| 251 |
@RequestParam(value = "q", required = false) String queryTerm,
|
251 |
@RequestParam(value = "q", required = false) String queryTerm,
|
| 252 |
@RequestParam(value = "hotDeal", required = false) boolean hotDeal) throws Throwable {
|
252 |
@RequestParam(value = "hotDeal", required = false) boolean hotDeal) throws Throwable {
|
| 253 |
List<FofoCatalogResponse> dealResponse = new ArrayList<>();
|
253 |
List<FofoCatalogResponse> dealResponse = new ArrayList<>();
|
| 254 |
UserInfo userInfo = (UserInfo) request.getAttribute("userInfo");
|
254 |
UserInfo userInfo = (UserInfo) request.getAttribute("userInfo");
|
| 255 |
FofoStore fs = fofoStoreRepository.selectByRetailerId(userInfo.getRetailerId());
|
255 |
FofoStore fs = fofoStoreRepository.selectByRetailerId(userInfo.getRetailerId());
|
| 256 |
sort = "w" + fs.getWarehouseId() + "_i desc";
|
256 |
sort = "w" + fs.getWarehouseId() + "_i desc";
|
| 257 |
dealResponse = this.getCatalogResponse(
|
257 |
dealResponse = this.getCatalogResponse(
|
| Line 261... |
Line 261... |
| 261 |
return responseSender.ok(dealResponse);
|
261 |
return responseSender.ok(dealResponse);
|
| 262 |
}
|
262 |
}
|
| 263 |
|
263 |
|
| 264 |
@RequestMapping(value = "/online-deals", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
264 |
@RequestMapping(value = "/online-deals", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
| 265 |
@ApiImplicitParams({
|
265 |
@ApiImplicitParams({
|
| 266 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
|
266 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header")})
|
| 267 |
@ApiOperation(value = "Get online deals")
|
267 |
@ApiOperation(value = "Get online deals")
|
| 268 |
public ResponseEntity<?> getOnlineDeals(HttpServletRequest request,
|
268 |
public ResponseEntity<?> getOnlineDeals(HttpServletRequest request,
|
| 269 |
@RequestParam(value = "categoryId") String categoryId, @RequestParam(value = "offset") String offset,
|
269 |
@RequestParam(value = "categoryId") String categoryId, @RequestParam(value = "offset") String offset,
|
| 270 |
@RequestParam(value = "limit") String limit, @RequestParam(value = "sort", required = false) String sort,
|
270 |
@RequestParam(value = "limit") String limit, @RequestParam(value = "sort", required = false) String sort,
|
| 271 |
@RequestParam(value = "direction", required = false) String direction,
|
271 |
@RequestParam(value = "direction", required = false) String direction,
|
| 272 |
@RequestParam(value = "filterData", required = false) String filterData) throws Throwable {
|
272 |
@RequestParam(value = "filterData", required = false) String filterData) throws Throwable {
|
| 273 |
logger.info("Request " + request.getParameterMap());
|
273 |
logger.info("Request " + request.getParameterMap());
|
| 274 |
String response = null;
|
274 |
String response = null;
|
| 275 |
int userId = (int) request.getAttribute("userId");
|
275 |
int userId = (int) request.getAttribute("userId");
|
| 276 |
|
276 |
|
| 277 |
String uri = "/deals/" + userId;
|
277 |
String uri = "/deals/" + userId;
|
| Line 316... |
Line 316... |
| 316 |
return new Gson().fromJson(jsonObject.toString(), DealsResponse.class);
|
316 |
return new Gson().fromJson(jsonObject.toString(), DealsResponse.class);
|
| 317 |
}
|
317 |
}
|
| 318 |
|
318 |
|
| 319 |
@RequestMapping(value = ProfitMandiConstants.URL_BRANDS, method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
319 |
@RequestMapping(value = ProfitMandiConstants.URL_BRANDS, method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
| 320 |
@ApiImplicitParams({
|
320 |
@ApiImplicitParams({
|
| 321 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
|
321 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header")})
|
| 322 |
@ApiOperation(value = "Get brand list and count for category")
|
322 |
@ApiOperation(value = "Get brand list and count for category")
|
| 323 |
public ResponseEntity<?> getBrands(HttpServletRequest request,
|
323 |
public ResponseEntity<?> getBrands(HttpServletRequest request,
|
| 324 |
@RequestParam(value = "category_id") String category_id) throws ProfitMandiBusinessException {
|
324 |
@RequestParam(value = "category_id") String category_id) throws ProfitMandiBusinessException {
|
| 325 |
logger.info("Request " + request.getParameterMap());
|
325 |
logger.info("Request " + request.getParameterMap());
|
| 326 |
String response = null;
|
326 |
String response = null;
|
| 327 |
// TODO: move to properties
|
327 |
// TODO: move to properties
|
| 328 |
String uri = ProfitMandiConstants.URL_BRANDS;
|
328 |
String uri = ProfitMandiConstants.URL_BRANDS;
|
| 329 |
RestClient rc = new RestClient();
|
329 |
RestClient rc = new RestClient();
|
| Line 342... |
Line 342... |
| 342 |
return responseSender.ok(dealBrandsResponse);
|
342 |
return responseSender.ok(dealBrandsResponse);
|
| 343 |
}
|
343 |
}
|
| 344 |
|
344 |
|
| 345 |
@RequestMapping(value = ProfitMandiConstants.URL_UNIT_DEAL, method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
345 |
@RequestMapping(value = ProfitMandiConstants.URL_UNIT_DEAL, method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
| 346 |
@ApiImplicitParams({
|
346 |
@ApiImplicitParams({
|
| 347 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
|
347 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header")})
|
| 348 |
@ApiOperation(value = "Get unit deal object")
|
348 |
@ApiOperation(value = "Get unit deal object")
|
| 349 |
public ResponseEntity<?> getUnitDeal(HttpServletRequest request, @PathVariable(value = "id") long id)
|
349 |
public ResponseEntity<?> getUnitDeal(HttpServletRequest request, @PathVariable(value = "id") long id)
|
| 350 |
throws ProfitMandiBusinessException {
|
350 |
throws ProfitMandiBusinessException {
|
| 351 |
String response = null;
|
351 |
String response = null;
|
| 352 |
// TODO: move to properties
|
352 |
// TODO: move to properties
|
| Line 374... |
Line 374... |
| 374 |
return responseSender.ok(dealsResponse);
|
374 |
return responseSender.ok(dealsResponse);
|
| 375 |
}
|
375 |
}
|
| 376 |
|
376 |
|
| 377 |
@RequestMapping(value = "/partnerdeals/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
377 |
@RequestMapping(value = "/partnerdeals/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
| 378 |
@ApiImplicitParams({
|
378 |
@ApiImplicitParams({
|
| 379 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
|
379 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header")})
|
| 380 |
@ApiOperation(value = "Get unit deal object")
|
380 |
@ApiOperation(value = "Get unit deal object")
|
| 381 |
public ResponseEntity<?> getUnitFocoDeal(HttpServletRequest request, @PathVariable(value = "id") long id)
|
381 |
public ResponseEntity<?> getUnitFocoDeal(HttpServletRequest request, @PathVariable(value = "id") long id)
|
| 382 |
throws Exception {
|
382 |
throws Exception {
|
| 383 |
List<FofoCatalogResponse> dealResponse = new ArrayList<>();
|
383 |
List<FofoCatalogResponse> dealResponse = new ArrayList<>();
|
| 384 |
List<Integer> tagIds = Arrays.asList(4);
|
384 |
List<Integer> tagIds = Arrays.asList(4);
|
| Line 414... |
Line 414... |
| 414 |
return responseSender.ok(dealResponse.get(0));
|
414 |
return responseSender.ok(dealResponse.get(0));
|
| 415 |
}
|
415 |
}
|
| 416 |
|
416 |
|
| 417 |
@RequestMapping(value = "/fofo/brands", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
417 |
@RequestMapping(value = "/fofo/brands", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
| 418 |
public ResponseEntity<?> getBrandsToDisplay(HttpServletRequest request,
|
418 |
public ResponseEntity<?> getBrandsToDisplay(HttpServletRequest request,
|
| 419 |
@RequestParam(required = false, defaultValue = "0") int categoryId) throws Exception {
|
419 |
@RequestParam(required = false, defaultValue = "0") int categoryId) throws Exception {
|
| 420 |
UserInfo userInfo = (UserInfo) request.getAttribute("userInfo");
|
420 |
UserInfo userInfo = (UserInfo) request.getAttribute("userInfo");
|
| 421 |
logger.info("userInfo [{}]", userInfo);
|
421 |
logger.info("userInfo [{}]", userInfo);
|
| 422 |
List<DBObject> brandsDisplay = mongoClient.getMongoBrands(userInfo.getRetailerId(), userInfo.getEmail(),
|
422 |
List<DBObject> brandsDisplay = mongoClient.getMongoBrands(userInfo.getRetailerId(), userInfo.getEmail(),
|
| 423 |
categoryId);
|
423 |
categoryId);
|
| 424 |
return new ResponseEntity<>(brandsDisplay, HttpStatus.OK);
|
424 |
return new ResponseEntity<>(brandsDisplay, HttpStatus.OK);
|
| Line 483... |
Line 483... |
| 483 |
public ResponseEntity<?> getSubcategoriesToDisplay() {
|
483 |
public ResponseEntity<?> getSubcategoriesToDisplay() {
|
| 484 |
return new ResponseEntity<>(mongoClient.getSubcategoriesToDisplay(), HttpStatus.OK);
|
484 |
return new ResponseEntity<>(mongoClient.getSubcategoriesToDisplay(), HttpStatus.OK);
|
| 485 |
}
|
485 |
}
|
| 486 |
|
486 |
|
| 487 |
@ApiImplicitParams({
|
487 |
@ApiImplicitParams({
|
| 488 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
|
488 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header")})
|
| 489 |
@RequestMapping(value = "/deals/skus/{skus}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
489 |
@RequestMapping(value = "/deals/skus/{skus}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
| 490 |
public ResponseEntity<?> getDealsBySkus(@PathVariable String skus) throws ProfitMandiBusinessException {
|
490 |
public ResponseEntity<?> getDealsBySkus(@PathVariable String skus) throws ProfitMandiBusinessException {
|
| 491 |
StringBuffer sb = new StringBuffer("/getDealsForNotification/");
|
491 |
StringBuffer sb = new StringBuffer("/getDealsForNotification/");
|
| 492 |
String uri = sb.append(skus).toString();
|
492 |
String uri = sb.append(skus).toString();
|
| 493 |
RestClient rc = new RestClient();
|
493 |
RestClient rc = new RestClient();
|
| Line 566... |
Line 566... |
| 566 |
if (doc.has("_childDocuments_")) {
|
566 |
if (doc.has("_childDocuments_")) {
|
| 567 |
String modelColorClass = "grey";
|
567 |
String modelColorClass = "grey";
|
| 568 |
FofoAvailabilityInfo fdiAnyColour = null;
|
568 |
FofoAvailabilityInfo fdiAnyColour = null;
|
| 569 |
int allColorNetAvailability = 0;
|
569 |
int allColorNetAvailability = 0;
|
| 570 |
for (int j = 0; j < doc.getJSONArray("_childDocuments_").length(); j++) {
|
570 |
for (int j = 0; j < doc.getJSONArray("_childDocuments_").length(); j++) {
|
| - |
|
571 |
PriceCircularItemModel priceCircularItemModel = priceCircularItemModelMap.get(ffdr.getCatalogId());
|
| 571 |
JSONObject childItem = doc.getJSONArray("_childDocuments_").getJSONObject(j);
|
572 |
JSONObject childItem = doc.getJSONArray("_childDocuments_").getJSONObject(j);
|
| 572 |
int itemId = childItem.getInt("itemId_i");
|
573 |
int itemId = childItem.getInt("itemId_i");
|
| 573 |
float sellingPrice = (float) childItem.getDouble("sellingPrice_f");
|
574 |
float sellingPrice = (float) childItem.getDouble("sellingPrice_f");
|
| 574 |
if (fofoAvailabilityInfoMap.containsKey(itemId)) {
|
575 |
if (fofoAvailabilityInfoMap.containsKey(itemId)) {
|
| 575 |
if (fofoAvailabilityInfoMap.get(itemId).getSellingPrice() > sellingPrice) {
|
576 |
if (fofoAvailabilityInfoMap.get(itemId).getSellingPrice() > sellingPrice) {
|
| 576 |
fofoAvailabilityInfoMap.get(itemId).setSellingPrice(sellingPrice);
|
577 |
fofoAvailabilityInfoMap.get(itemId).setSellingPrice(sellingPrice);
|
| 577 |
fofoAvailabilityInfoMap.get(itemId).setMop((float) childItem.getDouble("mop_f"));
|
578 |
fofoAvailabilityInfoMap.get(itemId).setMop((float) childItem.getDouble("mop_f"));
|
| 578 |
PriceCircularItemModel priceCircularItemModel = priceCircularItemModelMap.get(ffdr.getCatalogId());
|
- |
|
| 579 |
fofoAvailabilityInfoMap.get(itemId).setNlc(priceCircularItemModel == null ? 0 : priceCircularItemModel.getNetPrice2());
|
579 |
fofoAvailabilityInfoMap.get(itemId).setNlc(priceCircularItemModel == null ? 0 : priceCircularItemModel.getNetPrice2());
|
| 580 |
}
|
580 |
}
|
| 581 |
} else {
|
581 |
} else {
|
| 582 |
FofoAvailabilityInfo fdi = new FofoAvailabilityInfo();
|
582 |
FofoAvailabilityInfo fdi = new FofoAvailabilityInfo();
|
| 583 |
List<SaholicCIS> currentAvailability = itemAvailabilityMap.get(itemId);
|
583 |
List<SaholicCIS> currentAvailability = itemAvailabilityMap.get(itemId);
|
| 584 |
List<SaholicPOItem> poItemAvailability = null;
|
584 |
List<SaholicPOItem> poItemAvailability = null;
|
| 585 |
if (poItemAvailabilityMap != null) {
|
585 |
if (poItemAvailabilityMap != null) {
|
| 586 |
poItemAvailability = poItemAvailabilityMap.get(itemId);
|
586 |
poItemAvailability = poItemAvailabilityMap.get(itemId);
|
| 587 |
}
|
587 |
}
|
| - |
|
588 |
fofoAvailabilityInfoMap.get(itemId).setNlc(priceCircularItemModel == null ? 0 : priceCircularItemModel.getNetPrice2());
|
| 588 |
if (currentAvailability != null) {
|
589 |
if (currentAvailability != null) {
|
| 589 |
allColorNetAvailability += currentAvailability.stream()
|
590 |
allColorNetAvailability += currentAvailability.stream()
|
| 590 |
.collect(Collectors.summingInt(SaholicCIS::getNetavailability));
|
591 |
.collect(Collectors.summingInt(SaholicCIS::getNetavailability));
|
| 591 |
}
|
592 |
}
|
| 592 |
if (poItemAvailability != null) {
|
593 |
if (poItemAvailability != null) {
|
| Line 649... |
Line 650... |
| 649 |
} else if (poItemAvailability != null && poItemAvailability.stream()
|
650 |
} else if (poItemAvailability != null && poItemAvailability.stream()
|
| 650 |
.collect(Collectors.summingInt(SaholicPOItem::getUnfulfilledQty)) > 0) {
|
651 |
.collect(Collectors.summingInt(SaholicPOItem::getUnfulfilledQty)) > 0) {
|
| 651 |
if (currentAvailability != null && poItemAvailability.stream()
|
652 |
if (currentAvailability != null && poItemAvailability.stream()
|
| 652 |
.collect(Collectors.summingInt(SaholicPOItem::getUnfulfilledQty))
|
653 |
.collect(Collectors.summingInt(SaholicPOItem::getUnfulfilledQty))
|
| 653 |
+ currentAvailability.stream()
|
654 |
+ currentAvailability.stream()
|
| 654 |
.collect(Collectors.summingInt(SaholicCIS::getNetavailability)) <= 0) {
|
655 |
.collect(Collectors.summingInt(SaholicCIS::getNetavailability)) <= 0) {
|
| 655 |
poColor = "grey";
|
656 |
poColor = "grey";
|
| 656 |
} else {
|
657 |
} else {
|
| 657 |
poColor = "yellow";
|
658 |
poColor = "yellow";
|
| 658 |
if (modelColorClass != "green") {
|
659 |
if (modelColorClass != "green") {
|
| 659 |
modelColorClass = poColor;
|
660 |
modelColorClass = poColor;
|
| Line 684... |
Line 685... |
| 684 |
}
|
685 |
}
|
| 685 |
} else {
|
686 |
} else {
|
| 686 |
//Lets consider that its out of stock
|
687 |
//Lets consider that its out of stock
|
| 687 |
fdi.setAvailability(100);
|
688 |
fdi.setAvailability(100);
|
| 688 |
Item item = null;
|
689 |
Item item = null;
|
| 689 |
try {
|
690 |
try {
|
| 690 |
item = itemRepository.selectById(itemId);
|
691 |
item = itemRepository.selectById(itemId);
|
| 691 |
} catch(Exception e) {
|
692 |
} catch (Exception e) {
|
| 692 |
e.printStackTrace();
|
693 |
e.printStackTrace();
|
| 693 |
continue;
|
694 |
continue;
|
| 694 |
}
|
695 |
}
|
| 695 |
// In case its tampered glass moq should be 5
|
696 |
// In case its tampered glass moq should be 5
|
| 696 |
if (item.getCategoryId() == 10020) {
|
697 |
if (item.getCategoryId() == 10020) {
|
| Line 723... |
Line 724... |
| 723 |
return dealResponse;
|
724 |
return dealResponse;
|
| 724 |
|
725 |
|
| 725 |
}
|
726 |
}
|
| 726 |
|
727 |
|
| 727 |
private List<FofoCatalogResponse> getCatalogSingleSkuResponse(JSONArray docs, Map<Integer, Integer> itemFilter,
|
728 |
private List<FofoCatalogResponse> getCatalogSingleSkuResponse(JSONArray docs, Map<Integer, Integer> itemFilter,
|
| 728 |
boolean hotDeal) throws ProfitMandiBusinessException {
|
729 |
boolean hotDeal) throws ProfitMandiBusinessException {
|
| 729 |
Map<Integer, TagListing> itemTagListingMap = null;
|
730 |
Map<Integer, TagListing> itemTagListingMap = null;
|
| 730 |
List<FofoCatalogResponse> dealResponse = new ArrayList<>();
|
731 |
List<FofoCatalogResponse> dealResponse = new ArrayList<>();
|
| 731 |
List<Integer> tagIds = Arrays.asList(4);
|
732 |
List<Integer> tagIds = Arrays.asList(4);
|
| 732 |
|
733 |
|
| 733 |
itemTagListingMap = tagListingRepository.selectByItemIdsAndTagIds(itemFilter.keySet(), new HashSet<>(tagIds))
|
734 |
itemTagListingMap = tagListingRepository.selectByItemIdsAndTagIds(itemFilter.keySet(), new HashSet<>(tagIds))
|