| Line 423... |
Line 423... |
| 423 |
}
|
423 |
}
|
| 424 |
|
424 |
|
| 425 |
@RequestMapping(value = "/updatePriceDropImeis", method = RequestMethod.POST)
|
425 |
@RequestMapping(value = "/updatePriceDropImeis", method = RequestMethod.POST)
|
| 426 |
public String updatePriceDropImeis(HttpServletRequest request, @RequestBody PriceDropImeisModel priceDropImeisModel,
|
426 |
public String updatePriceDropImeis(HttpServletRequest request, @RequestBody PriceDropImeisModel priceDropImeisModel,
|
| 427 |
Model model) throws ProfitMandiBusinessException, Exception {
|
427 |
Model model) throws ProfitMandiBusinessException, Exception {
|
| 428 |
PriceDropImeiStatus status = PriceDropImeiStatus.PENDING;
|
428 |
final PriceDropImeiStatus status;
|
| 429 |
|
429 |
|
| 430 |
switch (priceDropImeisModel.getUpdatedStatus()) {
|
430 |
switch (priceDropImeisModel.getUpdatedStatus()) {
|
| 431 |
case "approved": {
|
431 |
case "approved": {
|
| 432 |
status = PriceDropImeiStatus.APPROVED;
|
432 |
status = PriceDropImeiStatus.APPROVED;
|
| 433 |
break;
|
433 |
break;
|
| 434 |
}
|
434 |
}
|
| 435 |
case "hold": {
|
435 |
case "pending": {
|
| 436 |
status = PriceDropImeiStatus.HOLD;
|
436 |
status = PriceDropImeiStatus.PENDING;
|
| 437 |
break;
|
437 |
break;
|
| 438 |
}
|
438 |
}
|
| 439 |
case "rejected": {
|
439 |
case "rejected": {
|
| 440 |
status = PriceDropImeiStatus.REJECTED;
|
440 |
status = PriceDropImeiStatus.REJECTED;
|
| 441 |
break;
|
441 |
break;
|
| 442 |
}
|
442 |
}
|
| - |
|
443 |
case "hold": {
|
| - |
|
444 |
status = PriceDropImeiStatus.HOLD;
|
| - |
|
445 |
break;
|
| - |
|
446 |
}
|
| - |
|
447 |
default:
|
| - |
|
448 |
throw new IllegalStateException("Unexpected value: " + priceDropImeisModel.getUpdatedStatus());
|
| 443 |
}
|
449 |
}
|
| 444 |
PriceDropImeiStatus finalStatus = status;
|
- |
|
| 445 |
|
450 |
|
| 446 |
if (PriceDropImeiStatus.PENDING.equals(status)) {
|
451 |
if (PriceDropImeiStatus.PENDING.equals(status)) {
|
| 447 |
|
- |
|
| 448 |
List<PriceDropIMEI> priceDropIMEIsToHolds = new ArrayList<>();
|
452 |
List<PriceDropIMEI> priceDropIMEIsToPending = new ArrayList<>();
|
| 449 |
List<PriceDropIMEI> priceDropIMEIs = priceDropIMEIRepository.selectByIdAndStatus(PriceDropImeiStatus.HOLD,
|
453 |
List<PriceDropIMEI> priceDropIMEIs = priceDropIMEIRepository.selectByStatuses(Arrays.asList(PriceDropImeiStatus.REJECTED, PriceDropImeiStatus.HOLD),
|
| 450 |
priceDropImeisModel.getPriceDropId());
|
454 |
priceDropImeisModel.getPriceDropId());
|
| 451 |
LOGGER.info("hello" + priceDropIMEIs);
|
455 |
LOGGER.info("hello" + priceDropIMEIs);
|
| 452 |
for (PriceDropIMEI priceDropHoldIMEI : priceDropIMEIs) {
|
456 |
for (PriceDropIMEI priceDropIMEI : priceDropIMEIs) {
|
| 453 |
if (priceDropHoldIMEI.getStatus().equals(PriceDropImeiStatus.HOLD)) {
|
- |
|
| 454 |
if (!priceDropImeisModel.getUpdatedImeis().contains(priceDropHoldIMEI.getImei())
|
457 |
if (priceDropIMEI.getStatus().equals(status) || !priceDropImeisModel.getUpdatedImeis().contains(priceDropIMEI.getImei())) {
|
| 455 |
|| priceDropHoldIMEI.getStatus().equals(status)) {
|
- |
|
| 456 |
continue;
|
458 |
continue;
|
| 457 |
}
|
- |
|
| 458 |
priceDropIMEIsToHolds.add(priceDropHoldIMEI);
|
- |
|
| 459 |
priceDropHoldIMEI.setStatus(PriceDropImeiStatus.PENDING);
|
- |
|
| 460 |
//priceDropHoldIMEI.setUpdateTimestamp(LocalDateTime.now());
|
- |
|
| 461 |
} else {
|
- |
|
| 462 |
throw new ProfitMandiBusinessException("INVALID STATUS", "PENDING",
|
- |
|
| 463 |
"Pending Status is allowed only for Hold IMIEs");
|
- |
|
| 464 |
}
|
459 |
}
|
| - |
|
460 |
priceDropIMEIsToPending.add(priceDropIMEI);
|
| - |
|
461 |
priceDropIMEI.setStatus(PriceDropImeiStatus.PENDING);
|
| 465 |
}
|
462 |
}
|
| 466 |
model.addAttribute("response1", mvcResponseSender.createResponseString(true));
|
463 |
model.addAttribute("response1", mvcResponseSender.createResponseString(true));
|
| 467 |
return "response";
|
464 |
return "response";
|
| 468 |
}
|
465 |
}
|
| 469 |
|
466 |
|
| 470 |
// TODO:PD
|
- |
|
| 471 |
List<PriceDropIMEI> priceDropIMEIs = priceDropIMEIRepository
|
- |
|
| 472 |
.selectByPriceDropId(priceDropImeisModel.getPriceDropId());
|
- |
|
| 473 |
|
- |
|
| 474 |
List<PriceDropIMEI> priceDropIMEIsToProcess = priceDropIMEIs.stream()
|
- |
|
| 475 |
.filter(x -> priceDropImeisModel.getUpdatedImeis().contains(x.getImei()))
|
- |
|
| 476 |
.filter(x -> !x.getStatus().equals(finalStatus)).collect(Collectors.toList());
|
- |
|
| 477 |
|
- |
|
| 478 |
/*for (PriceDropIMEI priceDropIMEI : priceDropIMEIsToProcess) {
|
- |
|
| 479 |
priceDropIMEI.setUpdateTimestamp(LocalDateTime.now());
|
- |
|
| 480 |
}*/
|
- |
|
| 481 |
|
- |
|
| 482 |
if (status.equals(PriceDropImeiStatus.APPROVED)) {
|
467 |
if (status.equals(PriceDropImeiStatus.APPROVED)) {
|
| 483 |
priceDropService.processPriceDrop(priceDropImeisModel.getPriceDropId(),
|
468 |
priceDropService.processPriceDrop(priceDropImeisModel.getPriceDropId(),
|
| 484 |
priceDropImeisModel.getUpdatedImeis());
|
469 |
priceDropImeisModel.getUpdatedImeis());
|
| 485 |
}
|
470 |
}
|
| - |
|
471 |
|
| - |
|
472 |
List<PriceDropIMEI> priceDropIMEIs = priceDropIMEIRepository
|
| - |
|
473 |
.selectByPriceDropId(priceDropImeisModel.getPriceDropId());
|
| - |
|
474 |
List<PriceDropIMEI> priceDropIMEIsToProcess = priceDropIMEIs.stream()
|
| - |
|
475 |
.filter(x -> priceDropImeisModel.getUpdatedImeis().contains(x.getImei()))
|
| - |
|
476 |
.filter(x -> !x.getStatus().equals(status)).collect(Collectors.toList());
|
| 486 |
for (PriceDropIMEI priceDropImei : priceDropIMEIsToProcess) {
|
477 |
for (PriceDropIMEI priceDropImei : priceDropIMEIsToProcess) {
|
| 487 |
if (status.equals(PriceDropImeiStatus.REJECTED)
|
478 |
if (status.equals(PriceDropImeiStatus.REJECTED)
|
| 488 |
&& priceDropImei.getStatus().equals(PriceDropImeiStatus.PENDING)) {
|
479 |
&& priceDropImei.getStatus().equals(PriceDropImeiStatus.PENDING)) {
|
| 489 |
priceDropImei.setStatus(PriceDropImeiStatus.REJECTED);
|
480 |
priceDropImei.setStatus(PriceDropImeiStatus.REJECTED);
|
| 490 |
priceDropImei.setRejectionReason(priceDropImeisModel.getRejectionReason());
|
481 |
priceDropImei.setRejectionReason(priceDropImeisModel.getRejectionReason());
|