| Line 518... |
Line 518... |
| 518 |
}
|
518 |
}
|
| 519 |
|
519 |
|
| 520 |
List<FofoOrderItem> fofoItems = fofoOrderItemRepository.selectByOrderId(fofoOrder.getId());
|
520 |
List<FofoOrderItem> fofoItems = fofoOrderItemRepository.selectByOrderId(fofoOrder.getId());
|
| 521 |
|
521 |
|
| 522 |
boolean smartPhone = false;
|
522 |
boolean smartPhone = false;
|
| 523 |
float purchaseAmount = 0;
|
- |
|
| 524 |
|
- |
|
| 525 |
for (FofoOrderItem fofoOrderItem : fofoItems) {
|
523 |
for (FofoOrderItem fofoOrderItem : fofoItems) {
|
| 526 |
Item item = itemRepository.selectById(fofoOrderItem.getItemId());
|
524 |
Item item = itemRepository.selectById(fofoOrderItem.getItemId());
|
| 527 |
|
525 |
|
| 528 |
if (item.isSmartPhone()) {
|
526 |
if (item.isSmartPhone()) {
|
| 529 |
LOGGER.info("fofoItem {}", fofoOrderItem);
|
527 |
LOGGER.info("fofoItem {}", fofoOrderItem);
|
| 530 |
smartPhone = true;
|
528 |
smartPhone = true;
|
| 531 |
purchaseAmount = Math.max(fofoOrderItem.getSellingPrice(), purchaseAmount);
|
- |
|
| 532 |
|
- |
|
| 533 |
}
|
529 |
}
|
| 534 |
}
|
530 |
}
|
| 535 |
|
531 |
|
| 536 |
if (!smartPhone) {
|
532 |
if (!smartPhone) {
|
| 537 |
LOGGER.warn("No smartphones found in fofoItems.");
|
533 |
LOGGER.warn("No smartphones found in fofoItems.");
|
| Line 561... |
Line 557... |
| 561 |
po.setBilledAmount(po.getBilledAmount() + totalAmount);
|
557 |
po.setBilledAmount(po.getBilledAmount() + totalAmount);
|
| 562 |
PendingOrderItem poi = pendingOrderItemRepository.selectById(createOrderRequest.getPoItemId());
|
558 |
PendingOrderItem poi = pendingOrderItemRepository.selectById(createOrderRequest.getPoItemId());
|
| 563 |
poi.setStatus(OrderStatus.BILLED);
|
559 |
poi.setStatus(OrderStatus.BILLED);
|
| 564 |
poi.setBilledTimestamp(LocalDateTime.now());
|
560 |
poi.setBilledTimestamp(LocalDateTime.now());
|
| 565 |
}
|
561 |
}
|
| - |
|
562 |
//Process scratch
|
| - |
|
563 |
this.processScratchOffer(fofoOrder);
|
| - |
|
564 |
|
| - |
|
565 |
return fofoOrder.getId();
|
| - |
|
566 |
}
|
| - |
|
567 |
|
| - |
|
568 |
@Override
|
| - |
|
569 |
public void processScratchOffer(FofoOrder fofoOrder) throws ProfitMandiBusinessException {
|
| - |
|
570 |
boolean isSmartPhonePurchased = false;
|
| - |
|
571 |
float maxPurchaseValue = 0;
|
| - |
|
572 |
List<FofoOrderItem> fofoOrderItems = fofoOrderItemRepository.selectByOrderId(fofoOrder.getId());
|
| - |
|
573 |
for (FofoOrderItem fofoOrderItem : fofoOrderItems) {
|
| - |
|
574 |
Item item = itemRepository.selectById(fofoOrderItem.getItemId());
|
| - |
|
575 |
|
| - |
|
576 |
if (item.isSmartPhone()) {
|
| - |
|
577 |
LOGGER.info("fofoItem {}", fofoOrderItem);
|
| - |
|
578 |
isSmartPhonePurchased = true;
|
| - |
|
579 |
maxPurchaseValue = Math.max(fofoOrderItem.getSellingPrice(), maxPurchaseValue);
|
| 566 |
|
580 |
|
| - |
|
581 |
}
|
| - |
|
582 |
}
|
| 567 |
LocalDate startDate = ProfitMandiConstants.SCRATCH_OFFER_START_DATE;
|
583 |
LocalDate startDate = ProfitMandiConstants.SCRATCH_OFFER_START_DATE;
|
| 568 |
LocalDate endDate = ProfitMandiConstants.SCRATCH_OFFER_END_DATE;
|
584 |
LocalDate endDate = ProfitMandiConstants.SCRATCH_OFFER_END_DATE;
|
| 569 |
boolean specificPriceOffer = ProfitMandiConstants.SPECIFIC_PRICE_OFFER;
|
585 |
boolean specificPriceOffer = ProfitMandiConstants.SPECIFIC_PRICE_OFFER;
|
| 570 |
|
586 |
|
| 571 |
if (smartPhone) {
|
587 |
if (isSmartPhonePurchased) {
|
| 572 |
if (LocalDateTime.now().isAfter(startDate.atStartOfDay()) && LocalDateTime.now().isBefore(endDate.atTime(Utils.MAX_TIME))) {
|
588 |
if (LocalDateTime.now().isAfter(startDate.atStartOfDay()) && LocalDateTime.now().isBefore(endDate.atTime(Utils.MAX_TIME))) {
|
| 573 |
|
- |
|
| - |
|
589 |
Customer customer = customerRepository.selectById(fofoOrder.getCustomerId());
|
| 574 |
try {
|
590 |
try {
|
| 575 |
this.sendAppDownloadBillingOffer(customer.getMobileNumber());
|
591 |
this.sendAppDownloadBillingOffer(customer.getMobileNumber());
|
| 576 |
} catch (Exception e) {
|
592 |
} catch (Exception e) {
|
| 577 |
// TODO Auto-generated catch block
|
593 |
// TODO Auto-generated catch block
|
| 578 |
e.printStackTrace();
|
594 |
e.printStackTrace();
|
| 579 |
}
|
595 |
}
|
| 580 |
if (specificPriceOffer) {
|
596 |
if (specificPriceOffer) {
|
| 581 |
this.createSpecificPriceScratchOffer(fofoOrder.getInvoiceNumber(), fofoOrder.getCustomerId(), purchaseAmount);
|
597 |
this.createSpecificPriceScratchOffer(fofoOrder.getInvoiceNumber(), fofoOrder.getCustomerId(), maxPurchaseValue);
|
| 582 |
} else {
|
598 |
} else {
|
| 583 |
this.createScratchOffer(fofoId, fofoOrder.getInvoiceNumber(), fofoOrder.getCustomerId());
|
599 |
this.createScratchOffer(fofoOrder.getFofoId(), fofoOrder.getInvoiceNumber(), fofoOrder.getCustomerId());
|
| 584 |
}
|
600 |
}
|
| 585 |
|
601 |
|
| 586 |
}
|
602 |
}
|
| 587 |
}
|
603 |
}
|
| 588 |
|
- |
|
| 589 |
return fofoOrder.getId();
|
- |
|
| 590 |
}
|
604 |
}
|
| 591 |
|
605 |
|
| 592 |
private void persistNonSerializedWithCustomSerialNumber(CustomFofoOrderItem customFofoOrderItem, int orderItemId) {
|
606 |
private void persistNonSerializedWithCustomSerialNumber(CustomFofoOrderItem customFofoOrderItem, int orderItemId) {
|
| 593 |
// Create a new instance of FofoNonSerializeSerial
|
607 |
// Create a new instance of FofoNonSerializeSerial
|
| 594 |
for (String accSerialNumber : customFofoOrderItem.getCustomSerialNumbers()) {
|
608 |
for (String accSerialNumber : customFofoOrderItem.getCustomSerialNumbers()) {
|