| Line 50... |
Line 50... |
| 50 |
import com.spice.profitmandi.common.model.InventoryItemAgingModel;
|
50 |
import com.spice.profitmandi.common.model.InventoryItemAgingModel;
|
| 51 |
import com.spice.profitmandi.common.model.ItemFeatureDataModel;
|
51 |
import com.spice.profitmandi.common.model.ItemFeatureDataModel;
|
| 52 |
import com.spice.profitmandi.common.model.NotifyItemIdModel;
|
52 |
import com.spice.profitmandi.common.model.NotifyItemIdModel;
|
| 53 |
import com.spice.profitmandi.common.model.NotifyOrderIdModel;
|
53 |
import com.spice.profitmandi.common.model.NotifyOrderIdModel;
|
| 54 |
import com.spice.profitmandi.common.model.NotifyOrderModel;
|
54 |
import com.spice.profitmandi.common.model.NotifyOrderModel;
|
| - |
|
55 |
import com.spice.profitmandi.common.model.OrderCancellationModel;
|
| 55 |
import com.spice.profitmandi.common.model.PdfModel;
|
56 |
import com.spice.profitmandi.common.model.PdfModel;
|
| 56 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
57 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
| 57 |
import com.spice.profitmandi.common.util.ExcelUtils;
|
58 |
import com.spice.profitmandi.common.util.ExcelUtils;
|
| 58 |
import com.spice.profitmandi.common.util.PdfUtils;
|
59 |
import com.spice.profitmandi.common.util.PdfUtils;
|
| 59 |
import com.spice.profitmandi.common.util.Utils;
|
60 |
import com.spice.profitmandi.common.util.Utils;
|
| Line 593... |
Line 594... |
| 593 |
retailerIds.add(order.getRetailerId());
|
594 |
retailerIds.add(order.getRetailerId());
|
| 594 |
orderIds.add(order.getId());
|
595 |
orderIds.add(order.getId());
|
| 595 |
|
596 |
|
| 596 |
}
|
597 |
}
|
| 597 |
|
598 |
|
| 598 |
|
- |
|
| 599 |
List<NotifyOrder> notify = notifyOrderRespository.selectByorderIds(orderIds);
|
599 |
List<NotifyOrder> notify = notifyOrderRespository.selectByorderIds(orderIds);
|
| 600 |
for (NotifyOrder notifyOrder : notify) {
|
600 |
for (NotifyOrder notifyOrder : notify) {
|
| 601 |
|
601 |
|
| 602 |
Order orderdetail = orderRepository.selectById(notifyOrder.getOrderId());
|
602 |
Order orderdetail = orderRepository.selectById(notifyOrder.getOrderId());
|
| 603 |
if (!orderdetail.getStatus().equals(OrderStatus.SUBMITTED_FOR_PROCESSING)) {
|
603 |
if (!orderdetail.getStatus().equals(OrderStatus.SUBMITTED_FOR_PROCESSING)) {
|
| 604 |
notifyOrder.setStatus(NotifyStatus.rejected);
|
604 |
notifyOrder.setStatus(NotifyStatus.rejected);
|
| 605 |
}
|
605 |
}
|
| 606 |
}
|
606 |
}
|
| - |
|
607 |
/*
|
| 607 |
/* for (NotifyOrder notifyOrder : notify) { List<NotifyItem> notifyItems =
|
608 |
* for (NotifyOrder notifyOrder : notify) { List<NotifyItem> notifyItems =
|
| 608 |
* notifyItemRepository.selectByNotifyId(notifyOrder.getNotifyId());
|
609 |
* notifyItemRepository.selectByNotifyId(notifyOrder.getNotifyId());
|
| 609 |
* Iterator<NotifyItem> notifyItemsIterator = notifyItems.iterator();
|
610 |
* Iterator<NotifyItem> notifyItemsIterator = notifyItems.iterator();
|
| 610 |
*
|
611 |
*
|
| 611 |
* while (notifyItemsIterator.hasNext()) { NotifyItem notifyItem =
|
612 |
* while (notifyItemsIterator.hasNext()) { NotifyItem notifyItem =
|
| 612 |
* notifyItemsIterator.next(); if
|
613 |
* notifyItemsIterator.next(); if
|
| Line 667... |
Line 668... |
| 667 |
|
668 |
|
| 668 |
}
|
669 |
}
|
| 669 |
return "response";
|
670 |
return "response";
|
| 670 |
}
|
671 |
}
|
| 671 |
|
672 |
|
| - |
|
673 |
@RequestMapping(value = "/getcancelOrderItems", method = RequestMethod.GET)
|
| - |
|
674 |
public String getcancelOrderItems(HttpServletRequest request, @RequestParam int itemId, Model model)
|
| - |
|
675 |
throws Exception {
|
| - |
|
676 |
|
| - |
|
677 |
List<Order> inProcessselectedOrder = orderRepository.selectByItemIdOrderStatus(itemId,
|
| - |
|
678 |
OrderStatus.SUBMITTED_FOR_PROCESSING);
|
| - |
|
679 |
|
| - |
|
680 |
List<Integer> retailerIds = new ArrayList<>();
|
| - |
|
681 |
for (com.spice.profitmandi.dao.entity.transaction.Order order : inProcessselectedOrder) {
|
| - |
|
682 |
retailerIds.add(order.getRetailerId());
|
| - |
|
683 |
|
| - |
|
684 |
}
|
| - |
|
685 |
|
| - |
|
686 |
Map<Integer, String> storeIdAndFofoIdMap = fofoStoreRepository.selectByRetailerIds(retailerIds).stream()
|
| - |
|
687 |
.collect(Collectors.toMap(FofoStore::getId, FofoStore::getCode));
|
| - |
|
688 |
|
| - |
|
689 |
model.addAttribute("inProcessCancelOrder", inProcessselectedOrder);
|
| - |
|
690 |
model.addAttribute("storeIdAndFofoIdMap", storeIdAndFofoIdMap);
|
| - |
|
691 |
|
| - |
|
692 |
return "cancel-order-modal";
|
| - |
|
693 |
}
|
| - |
|
694 |
|
| 672 |
@RequestMapping(value = "/cancelOrder", method = RequestMethod.POST)
|
695 |
@RequestMapping(value = "/cancelOrder", method = RequestMethod.POST)
|
| 673 |
public String cancelOrder(HttpServletRequest request, @RequestParam int orderId, @RequestParam String reason,
|
696 |
public String cancelOrder(HttpServletRequest request, @RequestBody OrderCancellationModel orderCancellationModel,
|
| 674 |
@RequestParam OrderStatus orderStatus, Model model) throws Exception {
|
697 |
Model model) throws Exception {
|
| 675 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
698 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 676 |
// User userInfo = saholicUserRepository.selectById(loginDetails.getFofoId());
|
- |
|
| 677 |
LOGGER.info("status" + orderStatus);
|
699 |
LOGGER.info("orderId" + orderCancellationModel.getOrderIds());
|
| - |
|
700 |
|
| 678 |
try {
|
701 |
try {
|
| 679 |
Order order = orderRepository.selectById(orderId);
|
702 |
List<Order> orders = orderRepository.selectByOrderIds(orderCancellationModel.getOrderIds());
|
| - |
|
703 |
|
| - |
|
704 |
for (Order order : orders) {
|
| - |
|
705 |
|
| 680 |
orderRepository.refundOrder(orderId, loginDetails.getEmailId(), reason, orderStatus);
|
706 |
orderRepository.refundOrder(order.getId(), loginDetails.getEmailId(),
|
| - |
|
707 |
orderCancellationModel.getReason(), OrderStatus.CANCELLED_DUE_TO_LOW_INVENTORY);
|
| 681 |
List<NotifyOrder> notifyOrders = notifyOrderRespository.selectByOrder(orderId);
|
708 |
List<NotifyOrder> notifyOrders = notifyOrderRespository.selectByOrder(order.getId());
|
| 682 |
for (NotifyOrder notifyOrder : notifyOrders) {
|
709 |
for (NotifyOrder notifyOrder : notifyOrders) {
|
| 683 |
if (notifyOrder.getStatus() == NotifyStatus.pending) {
|
710 |
if (notifyOrder.getStatus() == NotifyStatus.pending) {
|
| 684 |
notifyOrder.setStatus(NotifyStatus.rejected);
|
711 |
notifyOrder.setStatus(NotifyStatus.rejected);
|
| 685 |
}
|
- |
|
| 686 |
}
|
712 |
}
|
| - |
|
713 |
}
|
| 687 |
sendCancellationNotificationToPartner(order, reason);
|
714 |
sendCancellationNotificationToPartner(order, orderCancellationModel.getReason());
|
| 688 |
model.addAttribute("response", mvcResponseSender.createResponseString(true));
|
715 |
model.addAttribute("response", mvcResponseSender.createResponseString(true));
|
| - |
|
716 |
|
| - |
|
717 |
}
|
| 689 |
|
718 |
|
| 690 |
} catch (TransactionServiceException | TException e) {
|
719 |
} catch (TransactionServiceException | TException e) {
|
| 691 |
model.addAttribute("response", mvcResponseSender.createResponseString(false));
|
720 |
model.addAttribute("response", mvcResponseSender.createResponseString(false));
|
| 692 |
|
721 |
|
| 693 |
}
|
722 |
}
|
| - |
|
723 |
|
| 694 |
return "response";
|
724 |
return "response";
|
| 695 |
}
|
725 |
}
|
| 696 |
|
726 |
|
| 697 |
private void sendCancellationNotificationToPartner(Order order, String reason) throws Exception {
|
727 |
private void sendCancellationNotificationToPartner(Order order, String reason) throws Exception {
|
| 698 |
Item item = itemRepository.selectById(order.getLineItem().getItemId());
|
728 |
Item item = itemRepository.selectById(order.getLineItem().getItemId());
|