| Line 153... |
Line 153... |
| 153 |
}
|
153 |
}
|
| 154 |
|
154 |
|
| 155 |
@RequestMapping(value = "/getClosedPricedropItemDescription", method = RequestMethod.GET)
|
155 |
@RequestMapping(value = "/getClosedPricedropItemDescription", method = RequestMethod.GET)
|
| 156 |
public String getClosedPricedropItemDescription(HttpServletRequest request, Model model) throws Throwable {
|
156 |
public String getClosedPricedropItemDescription(HttpServletRequest request, Model model) throws Throwable {
|
| 157 |
List<PriceDrop> priceDrops = priceDropRepository.selectAllComplete();
|
157 |
List<PriceDrop> priceDrops = priceDropRepository.selectAllComplete();
|
| 158 |
int processOn =1;
|
158 |
int processOn = 1;
|
| 159 |
|
- |
|
| 160 |
|
159 |
|
| 161 |
List<PriceDrop> completePriceDrops = priceDrops.stream().filter(x -> x.getCompleteTimestamp() != null)
|
160 |
List<PriceDrop> completePriceDrops = priceDrops.stream().filter(x -> x.getCompleteTimestamp() != null)
|
| 162 |
.collect(Collectors.toList());
|
161 |
.collect(Collectors.toList());
|
| 163 |
|
162 |
|
| 164 |
Set<Integer> catalogIds = completePriceDrops.stream().map(x -> x.getCatalogItemId())
|
163 |
Set<Integer> catalogIds = completePriceDrops.stream().map(x -> x.getCatalogItemId())
|
| Line 406... |
Line 405... |
| 406 |
|
405 |
|
| 407 |
@RequestMapping(value = "/updatePriceDropImeis", method = RequestMethod.POST)
|
406 |
@RequestMapping(value = "/updatePriceDropImeis", method = RequestMethod.POST)
|
| 408 |
public String updatePriceDropImeis(HttpServletRequest request, @RequestBody PriceDropImeisModel priceDropImeisModel,
|
407 |
public String updatePriceDropImeis(HttpServletRequest request, @RequestBody PriceDropImeisModel priceDropImeisModel,
|
| 409 |
Model model) throws ProfitMandiBusinessException, Exception {
|
408 |
Model model) throws ProfitMandiBusinessException, Exception {
|
| 410 |
PriceDropImeiStatus status = PriceDropImeiStatus.PENDING;
|
409 |
PriceDropImeiStatus status = PriceDropImeiStatus.PENDING;
|
| 411 |
|
- |
|
| 412 |
List<PriceDropImeiStatus>priceDropImeiStatuses = new ArrayList<>();
|
- |
|
| 413 |
|
- |
|
| 414 |
priceDropImeiStatuses.add(PriceDropImeiStatus.PENDING);
|
- |
|
| 415 |
priceDropImeiStatuses.add(PriceDropImeiStatus.HOLD);
|
- |
|
| 416 |
|
410 |
|
| 417 |
switch (priceDropImeisModel.getUpdatedStatus()) {
|
411 |
switch (priceDropImeisModel.getUpdatedStatus()) {
|
| 418 |
case "approved": {
|
412 |
case "approved": {
|
| 419 |
status = PriceDropImeiStatus.APPROVED;
|
413 |
status = PriceDropImeiStatus.APPROVED;
|
| 420 |
break;
|
414 |
break;
|
| 421 |
}
|
415 |
}
|
| Line 426... |
Line 420... |
| 426 |
case "rejected": {
|
420 |
case "rejected": {
|
| 427 |
status = PriceDropImeiStatus.REJECTED;
|
421 |
status = PriceDropImeiStatus.REJECTED;
|
| 428 |
break;
|
422 |
break;
|
| 429 |
}
|
423 |
}
|
| 430 |
}
|
424 |
}
|
| - |
|
425 |
PriceDropImeiStatus finalStatus = status;
|
| 431 |
|
426 |
|
| 432 |
if (PriceDropImeiStatus.PENDING.equals(status)) {
|
427 |
if (PriceDropImeiStatus.PENDING.equals(status)) {
|
| 433 |
|
428 |
|
| 434 |
List<PriceDropIMEI> priceDropIMEIsToHolds = new ArrayList<>();
|
429 |
List<PriceDropIMEI> priceDropIMEIsToHolds = new ArrayList<>();
|
| 435 |
List<PriceDropIMEI> priceDropIMEIs = priceDropIMEIRepository.selectByIdAndStatus(PriceDropImeiStatus.HOLD,
|
430 |
List<PriceDropIMEI> priceDropIMEIs = priceDropIMEIRepository.selectByIdAndStatus(PriceDropImeiStatus.HOLD,
|
| Line 447... |
Line 442... |
| 447 |
} else {
|
442 |
} else {
|
| 448 |
throw new ProfitMandiBusinessException("INVALID STATUS", "PENDING",
|
443 |
throw new ProfitMandiBusinessException("INVALID STATUS", "PENDING",
|
| 449 |
"Pending Status is allowed only for Hold IMIEs");
|
444 |
"Pending Status is allowed only for Hold IMIEs");
|
| 450 |
}
|
445 |
}
|
| 451 |
}
|
446 |
}
|
| 452 |
|
- |
|
| - |
|
447 |
model.addAttribute("response", mvcResponseSender.createResponseString(true));
|
| - |
|
448 |
return "response";
|
| 453 |
}
|
449 |
}
|
| 454 |
|
450 |
|
| 455 |
// TODO:PD
|
451 |
// TODO:PD
|
| 456 |
List<PriceDropIMEI> priceDropIMEIs = priceDropIMEIRepository
|
452 |
List<PriceDropIMEI> priceDropIMEIs = priceDropIMEIRepository
|
| 457 |
.selectByPriceDropId(priceDropImeisModel.getPriceDropId());
|
453 |
.selectByPriceDropId(priceDropImeisModel.getPriceDropId());
|
| 458 |
|
454 |
|
| 459 |
List<PriceDropIMEI> priceDropIMEIsToProcess = new ArrayList<>();
|
455 |
List<PriceDropIMEI> priceDropIMEIsToProcess = priceDropIMEIs.stream()
|
| 460 |
for (PriceDropIMEI priceDropIMEI : priceDropIMEIs) {
|
- |
|
| 461 |
|
- |
|
| 462 |
if (!priceDropImeisModel.getUpdatedImeis().contains(priceDropIMEI.getImei())
|
456 |
.filter(x -> priceDropImeisModel.getUpdatedImeis().contains(x.getImei()))
|
| 463 |
|| priceDropIMEI.getStatus().equals(status)) {
|
457 |
.filter(x -> x.getStatus().equals(finalStatus))
|
| 464 |
continue;
|
- |
|
| 465 |
}
|
- |
|
| 466 |
|
- |
|
| 467 |
priceDropIMEIsToProcess.add(priceDropIMEI);
|
458 |
.collect(Collectors.toList());
|
| 468 |
|
459 |
|
| - |
|
460 |
for (PriceDropIMEI priceDropIMEI : priceDropIMEIsToProcess) {
|
| 469 |
priceDropIMEI.setUpdateTimestamp(LocalDateTime.now());
|
461 |
priceDropIMEI.setUpdateTimestamp(LocalDateTime.now());
|
| 470 |
}
|
462 |
}
|
| 471 |
|
463 |
|
| 472 |
for (PriceDropIMEI PriceDropIMEIByStatus : priceDropIMEIsToProcess) {
|
464 |
if (status.equals(PriceDropImeiStatus.APPROVED)) {
|
| 473 |
|
- |
|
| 474 |
if (status.equals(PriceDropImeiStatus.APPROVED)
|
465 |
priceDropService.processPriceDrop(priceDropImeisModel.getPriceDropId(),
|
| 475 |
&& PriceDropIMEIByStatus.getStatus().equals(PriceDropImeiStatus.PENDING)) {
|
466 |
priceDropImeisModel.getUpdatedImeis());
|
| 476 |
|
467 |
}
|
| 477 |
PriceDropIMEIByStatus.setStatus(PriceDropImeiStatus.APPROVED);
|
468 |
for (PriceDropIMEI priceDropImei : priceDropIMEIsToProcess) {
|
| 478 |
} else if (status.equals(PriceDropImeiStatus.REJECTED)
|
469 |
if (status.equals(PriceDropImeiStatus.REJECTED)
|
| 479 |
&& PriceDropIMEIByStatus.getStatus().equals(PriceDropImeiStatus.PENDING)) {
|
470 |
&& priceDropImei.getStatus().equals(PriceDropImeiStatus.PENDING)) {
|
| 480 |
PriceDropIMEIByStatus.setStatus(PriceDropImeiStatus.REJECTED);
|
471 |
priceDropImei.setStatus(PriceDropImeiStatus.REJECTED);
|
| 481 |
PriceDropIMEIByStatus.setRejectionReason(priceDropImeisModel.getRejectionReason());
|
472 |
priceDropImei.setRejectionReason(priceDropImeisModel.getRejectionReason());
|
| 482 |
|
- |
|
| 483 |
} else {
|
- |
|
| 484 |
if (status.equals(PriceDropImeiStatus.HOLD)
|
473 |
} else if (status.equals(PriceDropImeiStatus.HOLD)) {
|
| 485 |
&& PriceDropIMEIByStatus.getStatus().equals(PriceDropImeiStatus.PENDING)) {
|
474 |
if (priceDropImei.getStatus().equals(PriceDropImeiStatus.PENDING)) {
|
| 486 |
|
- |
|
| 487 |
PriceDropIMEIByStatus.setStatus(PriceDropImeiStatus.HOLD);
|
475 |
priceDropImei.setStatus(PriceDropImeiStatus.HOLD);
|
| 488 |
}
|
- |
|
| 489 |
|
- |
|
| 490 |
else {
|
476 |
} else {
|
| 491 |
throw new ProfitMandiBusinessException("INVALID STATUS", status, "only allowed For PENDING IMEIs");
|
477 |
throw new ProfitMandiBusinessException("INVALID STATUS", status, "only allowed For PENDING IMEIs");
|
| 492 |
}
|
478 |
}
|
| 493 |
|
479 |
|
| 494 |
}
|
480 |
}
|
| 495 |
|
481 |
|
| 496 |
}
|
482 |
}
|
| 497 |
List<PriceDropIMEI> priceDropIMEIHoldAndPending = priceDropIMEIRepository
|
- |
|
| 498 |
.selectByIdAndPendingHoldStatus(priceDropImeiStatuses, priceDropImeisModel.getPriceDropId());
|
- |
|
| 499 |
|
- |
|
| 500 |
LOGGER.info("priceDropIMEIholdandPending" + priceDropIMEIHoldAndPending);
|
- |
|
| 501 |
|
- |
|
| 502 |
if (priceDropIMEIHoldAndPending == null || priceDropIMEIHoldAndPending.isEmpty()) {
|
- |
|
| 503 |
|
- |
|
| 504 |
PriceDrop priceDrop = priceDropRepository.selectById(priceDropImeisModel.getPriceDropId());
|
- |
|
| 505 |
|
- |
|
| 506 |
LOGGER.info("priceDrop" + priceDrop);
|
- |
|
| 507 |
|
- |
|
| 508 |
priceDrop.setCompleteTimestamp(LocalDateTime.now());
|
- |
|
| 509 |
|
- |
|
| 510 |
PriceDrop priceDropVal = priceDropRepository.selectById(priceDropImeisModel.getPriceDropId());
|
- |
|
| 511 |
LOGGER.info("priceDropsVal" + priceDropVal);
|
- |
|
| 512 |
}
|
- |
|
| 513 |
/*
|
- |
|
| 514 |
* if (priceDropIMEIsToProcess.size() > 0) {
|
- |
|
| 515 |
* priceDropService.processManualPriceDrop(priceDropImeisModel.getPriceDropId(),
|
- |
|
| 516 |
* priceDropIMEIsToProcess, status); }
|
- |
|
| 517 |
*/
|
- |
|
| 518 |
|
483 |
|
| 519 |
model.addAttribute("response", mvcResponseSender.createResponseString(true));
|
484 |
model.addAttribute("response", mvcResponseSender.createResponseString(true));
|
| 520 |
return "response";
|
485 |
return "response";
|
| 521 |
|
486 |
|
| 522 |
}
|
487 |
}
|