| Line 142... |
Line 142... |
| 142 |
@Autowired
|
142 |
@Autowired
|
| 143 |
private FofoStoreRepository fofoStoreRepository;
|
143 |
private FofoStoreRepository fofoStoreRepository;
|
| 144 |
|
144 |
|
| 145 |
@RequestMapping(value = "/getItemDescription", method = RequestMethod.GET)
|
145 |
@RequestMapping(value = "/getItemDescription", method = RequestMethod.GET)
|
| 146 |
public String getItemDescription(HttpServletRequest request, Model model) throws Throwable {
|
146 |
public String getItemDescription(HttpServletRequest request, Model model) throws Throwable {
|
| 147 |
List<PriceDrop> priceDrops = priceDropRepository.selectAll();
|
147 |
List<PriceDrop> priceDrops = priceDropRepository.selectAllIncomplete();
|
| 148 |
Set<Integer> catalogIds = priceDrops.stream().map(x -> x.getCatalogItemId()).collect(Collectors.toSet());
|
148 |
Set<Integer> catalogIds = priceDrops.stream().map(x -> x.getCatalogItemId()).collect(Collectors.toSet());
|
| - |
|
149 |
|
| 149 |
List<Item> items = itemRepository.selectAllByCatalogIds(catalogIds);
|
150 |
List<Item> items = itemRepository.selectAllByCatalogIds(catalogIds);
|
| 150 |
Map<Integer, String> catalogDescription = items.stream().collect(Collectors.toMap(x -> x.getCatalogItemId(),
|
151 |
Map<Integer, String> catalogDescription = items.stream().collect(Collectors.toMap(x -> x.getCatalogItemId(),
|
| 151 |
x -> x.getItemDescriptionNoColor(), (description1, description2) -> description1));
|
152 |
x -> x.getItemDescriptionNoColor(), (description1, description2) -> description1));
|
| 152 |
model.addAttribute("priceDrops", priceDrops);
|
153 |
model.addAttribute("priceDrops", priceDrops);
|
| 153 |
model.addAttribute("catalogDescription", catalogDescription);
|
154 |
model.addAttribute("catalogDescription", catalogDescription);
|
| 154 |
return "price-drop";
|
155 |
return "price-drop";
|
| 155 |
}
|
156 |
}
|
| 156 |
|
157 |
|
| - |
|
158 |
@RequestMapping(value = "/getClosedPricedropItemDescription", method = RequestMethod.GET)
|
| - |
|
159 |
public String getClosedPricedropItemDescription(HttpServletRequest request, Model model) throws Throwable {
|
| - |
|
160 |
List<PriceDrop> priceDrops = priceDropRepository.selectAllComplete();
|
| - |
|
161 |
|
| - |
|
162 |
List<PriceDrop> completePriceDrops = priceDrops.stream().filter(x -> x.getCompleteTimestamp() != null)
|
| - |
|
163 |
.collect(Collectors.toList());
|
| - |
|
164 |
|
| - |
|
165 |
Set<Integer> catalogIds = completePriceDrops.stream().map(x -> x.getCatalogItemId())
|
| - |
|
166 |
.collect(Collectors.toSet());
|
| - |
|
167 |
List<Item> items = itemRepository.selectAllByCatalogIds(catalogIds);
|
| - |
|
168 |
LOGGER.info("catalogIds" + catalogIds);
|
| - |
|
169 |
|
| - |
|
170 |
Map<Integer, String> catalogDescription = items.stream().collect(Collectors.toMap(x -> x.getCatalogItemId(),
|
| - |
|
171 |
x -> x.getItemDescriptionNoColor(), (description1, description2) -> description1));
|
| - |
|
172 |
model.addAttribute("priceDrops", completePriceDrops);
|
| - |
|
173 |
model.addAttribute("catalogDescription", catalogDescription);
|
| - |
|
174 |
return "price-drop";
|
| - |
|
175 |
}
|
| - |
|
176 |
|
| 157 |
@RequestMapping(value = "/item-pricing/{itemId}", method = RequestMethod.GET)
|
177 |
@RequestMapping(value = "/item-pricing/{itemId}", method = RequestMethod.GET)
|
| 158 |
public String getItemPricing(HttpServletRequest request, Model model, @PathVariable int itemId) throws Throwable {
|
178 |
public String getItemPricing(HttpServletRequest request, Model model, @PathVariable int itemId) throws Throwable {
|
| 159 |
|
179 |
|
| 160 |
TagListing tagListing;
|
180 |
TagListing tagListing;
|
| 161 |
PriceDropModel pm = new PriceDropModel();
|
181 |
PriceDropModel pm = new PriceDropModel();
|
| Line 236... |
Line 256... |
| 236 |
// priceDropService.priceDropStatus(priceDropId);
|
256 |
// priceDropService.priceDropStatus(priceDropId);
|
| 237 |
|
257 |
|
| 238 |
List<String> pendingImeis = new ArrayList<>();
|
258 |
List<String> pendingImeis = new ArrayList<>();
|
| 239 |
List<String> approvedImeis = new ArrayList<>();
|
259 |
List<String> approvedImeis = new ArrayList<>();
|
| 240 |
List<String> rejectedImeis = new ArrayList<>();
|
260 |
List<String> rejectedImeis = new ArrayList<>();
|
| - |
|
261 |
List<String> holdImeis = new ArrayList<>();
|
| 241 |
List<PriceDropIMEI> priceDropImeis = priceDropIMEIRepository.selectByPriceDropId(priceDropId);
|
262 |
List<PriceDropIMEI> priceDropImeis = priceDropIMEIRepository.selectByPriceDropId(priceDropId);
|
| 242 |
for (PriceDropIMEI priceDropIMEI : priceDropImeis) {
|
263 |
for (PriceDropIMEI priceDropIMEI : priceDropImeis) {
|
| 243 |
if (priceDropIMEI.getStatus().equals(PriceDropImeiStatus.PENDING)) {
|
264 |
if (priceDropIMEI.getStatus().equals(PriceDropImeiStatus.PENDING)) {
|
| 244 |
pendingImeis.add(priceDropIMEI.getImei());
|
265 |
pendingImeis.add(priceDropIMEI.getImei());
|
| 245 |
} else if (priceDropIMEI.getStatus().equals(PriceDropImeiStatus.APPROVED)) {
|
266 |
} else if (priceDropIMEI.getStatus().equals(PriceDropImeiStatus.APPROVED)) {
|
| 246 |
approvedImeis.add(priceDropIMEI.getImei());
|
267 |
approvedImeis.add(priceDropIMEI.getImei());
|
| 247 |
}
|
268 |
}
|
| 248 |
if (priceDropIMEI.getStatus().equals(PriceDropImeiStatus.REJECTED)) {
|
269 |
if (priceDropIMEI.getStatus().equals(PriceDropImeiStatus.REJECTED)) {
|
| 249 |
rejectedImeis.add(priceDropIMEI.getImei());
|
270 |
rejectedImeis.add(priceDropIMEI.getImei());
|
| - |
|
271 |
} else if (priceDropIMEI.getStatus().equals(PriceDropImeiStatus.HOLD)) {
|
| - |
|
272 |
holdImeis.add(priceDropIMEI.getImei());
|
| - |
|
273 |
|
| 250 |
}
|
274 |
}
|
| 251 |
}
|
275 |
}
|
| - |
|
276 |
LOGGER.info("pendingImeis" + pendingImeis);
|
| - |
|
277 |
LOGGER.info("approvedImeis" + approvedImeis);
|
| - |
|
278 |
LOGGER.info("rejectedImeis" + rejectedImeis);
|
| - |
|
279 |
LOGGER.info("priceDropImeis" + priceDropImeis);
|
| - |
|
280 |
|
| 252 |
priceDropImeisModel.setPendingImeis(pendingImeis);
|
281 |
priceDropImeisModel.setPendingImeis(pendingImeis);
|
| 253 |
priceDropImeisModel.setPriceDropId(priceDropId);
|
282 |
priceDropImeisModel.setPriceDropId(priceDropId);
|
| 254 |
priceDropImeisModel.setApprovedImeis(approvedImeis);
|
283 |
priceDropImeisModel.setApprovedImeis(approvedImeis);
|
| - |
|
284 |
priceDropImeisModel.setHoldImeis(holdImeis);
|
| 255 |
priceDropImeisModel.setRejectedImeis(rejectedImeis);
|
285 |
priceDropImeisModel.setRejectedImeis(rejectedImeis);
|
| 256 |
model.addAttribute("response", mvcResponseSender.createResponseString(priceDropImeisModel));
|
286 |
model.addAttribute("response", mvcResponseSender.createResponseString(priceDropImeisModel));
|
| 257 |
return "response";
|
287 |
return "response";
|
| 258 |
}
|
288 |
}
|
| 259 |
|
289 |
|
| Line 372... |
Line 402... |
| 372 |
headers.setContentLength(byteArray.length);
|
402 |
headers.setContentLength(byteArray.length);
|
| 373 |
return new ResponseEntity<ByteArrayResource>(new ByteArrayResource(byteArray), headers, HttpStatus.OK);
|
403 |
return new ResponseEntity<ByteArrayResource>(new ByteArrayResource(byteArray), headers, HttpStatus.OK);
|
| 374 |
|
404 |
|
| 375 |
}
|
405 |
}
|
| 376 |
|
406 |
|
| 377 |
@RequestMapping(value = "/updatePriceDropImeis-DNC", method = RequestMethod.POST)
|
407 |
@RequestMapping(value = "/updatePriceDropImeis", method = RequestMethod.POST)
|
| 378 |
public String updatePriceDropImeis(HttpServletRequest request, @RequestBody PriceDropImeisModel priceDropImeisModel,
|
408 |
public String updatePriceDropImeis(HttpServletRequest request, @RequestBody PriceDropImeisModel priceDropImeisModel,
|
| 379 |
Model model) throws ProfitMandiBusinessException, Exception {
|
409 |
Model model) throws ProfitMandiBusinessException, Exception {
|
| 380 |
PriceDropImeiStatus status = PriceDropImeiStatus.PENDING;
|
410 |
PriceDropImeiStatus status = PriceDropImeiStatus.PENDING;
|
| 381 |
|
- |
|
| - |
|
411 |
PriceDropImeiStatus statusHold = PriceDropImeiStatus.HOLD;
|
| - |
|
412 |
PriceDropImeiStatus statusPriceDrop = PriceDropImeiStatus.PENDING;
|
| 382 |
switch (priceDropImeisModel.getUpdatedStatus()) {
|
413 |
switch (priceDropImeisModel.getUpdatedStatus()) {
|
| 383 |
case "approved": {
|
414 |
case "approved": {
|
| 384 |
status = PriceDropImeiStatus.APPROVED_OURS;
|
415 |
status = PriceDropImeiStatus.APPROVED;
|
| - |
|
416 |
break;
|
| - |
|
417 |
}
|
| - |
|
418 |
case "hold": {
|
| - |
|
419 |
status = PriceDropImeiStatus.HOLD;
|
| 385 |
break;
|
420 |
break;
|
| 386 |
}
|
421 |
}
|
| 387 |
case "rejected": {
|
422 |
case "rejected": {
|
| 388 |
status = PriceDropImeiStatus.REJECTED;
|
423 |
status = PriceDropImeiStatus.REJECTED;
|
| 389 |
break;
|
424 |
break;
|
| 390 |
}
|
425 |
}
|
| 391 |
}
|
426 |
}
|
| 392 |
|
427 |
|
| 393 |
if (PriceDropImeiStatus.PENDING.equals(status)) {
|
428 |
if (PriceDropImeiStatus.PENDING.equals(status)) {
|
| - |
|
429 |
|
| - |
|
430 |
List<PriceDropIMEI> priceDropIMEIsToHolds = new ArrayList<>();
|
| - |
|
431 |
List<PriceDropIMEI> priceDropIMEIs = priceDropIMEIRepository.selectByIdAndStatus(statusHold,
|
| - |
|
432 |
priceDropImeisModel.getPriceDropId());
|
| - |
|
433 |
LOGGER.info("hello" + priceDropIMEIs);
|
| - |
|
434 |
for (PriceDropIMEI priceDropHoldIMEI : priceDropIMEIs) {
|
| - |
|
435 |
if (priceDropHoldIMEI.getStatus().equals(PriceDropImeiStatus.HOLD)) {
|
| - |
|
436 |
if (!priceDropImeisModel.getUpdatedImeis().contains(priceDropHoldIMEI.getImei())
|
| - |
|
437 |
|| priceDropHoldIMEI.getStatus().equals(status)) {
|
| - |
|
438 |
continue;
|
| - |
|
439 |
}
|
| - |
|
440 |
priceDropIMEIsToHolds.add(priceDropHoldIMEI);
|
| - |
|
441 |
priceDropHoldIMEI.setStatus(PriceDropImeiStatus.PENDING);
|
| - |
|
442 |
priceDropHoldIMEI.setUpdateTimestamp(LocalDateTime.now());
|
| - |
|
443 |
} else {
|
| 394 |
throw new ProfitMandiBusinessException("INVALID STATUS", "PENDING",
|
444 |
throw new ProfitMandiBusinessException("INVALID STATUS", "PENDING",
|
| 395 |
"only approved and rejected is allowed");
|
445 |
"Pending Status is allowed only for Hold IMIEs");
|
| - |
|
446 |
}
|
| - |
|
447 |
}
|
| - |
|
448 |
|
| 396 |
}
|
449 |
}
|
| 397 |
|
450 |
|
| 398 |
// TODO:PD
|
451 |
// TODO:PD
|
| 399 |
List<PriceDropIMEI> priceDropIMEIs = priceDropIMEIRepository
|
452 |
List<PriceDropIMEI> priceDropIMEIs = priceDropIMEIRepository
|
| 400 |
.selectByPriceDropId(priceDropImeisModel.getPriceDropId());
|
453 |
.selectByPriceDropId(priceDropImeisModel.getPriceDropId());
|
| 401 |
|
454 |
|
| 402 |
List<PriceDropIMEI> priceDropIMEIsToProcess = new ArrayList<>();
|
455 |
List<PriceDropIMEI> priceDropIMEIsToProcess = new ArrayList<>();
|
| 403 |
for (PriceDropIMEI priceDropIMEI : priceDropIMEIs) {
|
456 |
for (PriceDropIMEI priceDropIMEI : priceDropIMEIs) {
|
| - |
|
457 |
|
| 404 |
if (!priceDropImeisModel.getUpdatedImeis().contains(priceDropIMEI.getImei())
|
458 |
if (!priceDropImeisModel.getUpdatedImeis().contains(priceDropIMEI.getImei())
|
| 405 |
|| priceDropIMEI.getStatus().equals(status)) {
|
459 |
|| priceDropIMEI.getStatus().equals(status)) {
|
| 406 |
continue;
|
460 |
continue;
|
| 407 |
}
|
461 |
}
|
| - |
|
462 |
|
| 408 |
priceDropIMEIsToProcess.add(priceDropIMEI);
|
463 |
priceDropIMEIsToProcess.add(priceDropIMEI);
|
| 409 |
if (status.equals(PriceDropImeiStatus.REJECTED)) {
|
- |
|
| 410 |
priceDropIMEI.setRejectionReason(priceDropImeisModel.getRejectionReason());
|
- |
|
| 411 |
}
|
464 |
|
| 412 |
priceDropIMEI.setUpdateTimestamp(LocalDateTime.now());
|
465 |
priceDropIMEI.setUpdateTimestamp(LocalDateTime.now());
|
| 413 |
}
|
466 |
}
|
| - |
|
467 |
|
| - |
|
468 |
for (PriceDropIMEI PriceDropIMEIByStatus : priceDropIMEIsToProcess) {
|
| - |
|
469 |
|
| - |
|
470 |
if (status.equals(PriceDropImeiStatus.APPROVED)
|
| - |
|
471 |
&& PriceDropIMEIByStatus.getStatus().equals(PriceDropImeiStatus.PENDING)) {
|
| - |
|
472 |
|
| - |
|
473 |
PriceDropIMEIByStatus.setStatus(PriceDropImeiStatus.APPROVED);
|
| - |
|
474 |
} else if (status.equals(PriceDropImeiStatus.REJECTED)
|
| - |
|
475 |
&& PriceDropIMEIByStatus.getStatus().equals(PriceDropImeiStatus.PENDING)) {
|
| - |
|
476 |
PriceDropIMEIByStatus.setStatus(PriceDropImeiStatus.REJECTED);
|
| - |
|
477 |
PriceDropIMEIByStatus.setRejectionReason(priceDropImeisModel.getRejectionReason());
|
| - |
|
478 |
|
| - |
|
479 |
} else {
|
| - |
|
480 |
if (status.equals(PriceDropImeiStatus.HOLD)
|
| - |
|
481 |
&& PriceDropIMEIByStatus.getStatus().equals(PriceDropImeiStatus.PENDING)) {
|
| - |
|
482 |
|
| - |
|
483 |
PriceDropIMEIByStatus.setStatus(PriceDropImeiStatus.HOLD);
|
| - |
|
484 |
}
|
| - |
|
485 |
|
| - |
|
486 |
else {
|
| - |
|
487 |
throw new ProfitMandiBusinessException("INVALID STATUS", status, "only allowed For PENDING IMEIs");
|
| - |
|
488 |
}
|
| - |
|
489 |
|
| - |
|
490 |
}
|
| - |
|
491 |
|
| - |
|
492 |
}
|
| - |
|
493 |
List<PriceDropIMEI> priceDropIMEIHoldAndPending = priceDropIMEIRepository
|
| - |
|
494 |
.selectByIdAndPendingHoldStatus(statusHold, statusPriceDrop, priceDropImeisModel.getPriceDropId());
|
| - |
|
495 |
|
| - |
|
496 |
LOGGER.info("priceDropIMEIholdandPending" + priceDropIMEIHoldAndPending);
|
| - |
|
497 |
|
| - |
|
498 |
if (priceDropIMEIHoldAndPending == null || priceDropIMEIHoldAndPending.isEmpty()) {
|
| - |
|
499 |
|
| - |
|
500 |
PriceDrop priceDrop = priceDropRepository.selectById(priceDropImeisModel.getPriceDropId());
|
| - |
|
501 |
|
| - |
|
502 |
LOGGER.info("priceDrop" + priceDrop);
|
| - |
|
503 |
|
| - |
|
504 |
priceDrop.setCompleteTimestamp(LocalDateTime.now());
|
| - |
|
505 |
|
| - |
|
506 |
PriceDrop priceDropVal = priceDropRepository.selectById(priceDropImeisModel.getPriceDropId());
|
| - |
|
507 |
LOGGER.info("priceDropsVal" + priceDropVal);
|
| - |
|
508 |
}
|
| 414 |
/*
|
509 |
/*
|
| 415 |
* if (priceDropIMEIsToProcess.size() > 0) {
|
510 |
* if (priceDropIMEIsToProcess.size() > 0) {
|
| 416 |
* priceDropService.processManualPriceDrop(priceDropImeisModel.getPriceDropId(),
|
511 |
* priceDropService.processManualPriceDrop(priceDropImeisModel.getPriceDropId(),
|
| 417 |
* priceDropIMEIsToProcess, status); }
|
512 |
* priceDropIMEIsToProcess, status); }
|
| 418 |
*/
|
513 |
*/
|
| Line 581... |
Line 676... |
| 581 |
model.addAttribute("priceCircular", priceCircular);
|
676 |
model.addAttribute("priceCircular", priceCircular);
|
| 582 |
model.addAttribute("partnerCode", fs.getCode());
|
677 |
model.addAttribute("partnerCode", fs.getCode());
|
| 583 |
return "price-circular-detail";
|
678 |
return "price-circular-detail";
|
| 584 |
}
|
679 |
}
|
| 585 |
|
680 |
|
| - |
|
681 |
@RequestMapping(value = "/selectPriceDropStatus", method = RequestMethod.GET)
|
| - |
|
682 |
public String selectPriceDropStatus(HttpServletRequest request,
|
| - |
|
683 |
@RequestParam(name = "selectedStatus", required = true, defaultValue = "") String selectedStatus,
|
| - |
|
684 |
Model model) throws Exception {
|
| - |
|
685 |
|
| - |
|
686 |
model.addAttribute("selectedStatus", selectedStatus);
|
| - |
|
687 |
|
| - |
|
688 |
return "pricedrop-status-change";
|
| - |
|
689 |
|
| - |
|
690 |
}
|
| - |
|
691 |
|
| 586 |
}
|
692 |
}
|