| Line 199... |
Line 199... |
| 199 |
@Autowired
|
199 |
@Autowired
|
| 200 |
EmailService emailService;
|
200 |
EmailService emailService;
|
| 201 |
|
201 |
|
| 202 |
@Autowired
|
202 |
@Autowired
|
| 203 |
CsService csService;
|
203 |
CsService csService;
|
| - |
|
204 |
|
| - |
|
205 |
private static final List<String> offlineOrders = Arrays.asList("EMIOD", "POD");
|
| - |
|
206 |
|
| 204 |
List<String> filterableParams = Arrays.asList("brand");
|
207 |
List<String> filterableParams = Arrays.asList("brand");
|
| 205 |
|
208 |
|
| 206 |
@RequestMapping(value = "/store/entity/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
209 |
@RequestMapping(value = "/store/entity/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
| 207 |
@ApiImplicitParams({
|
210 |
@ApiImplicitParams({
|
| 208 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
|
211 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
|
| Line 350... |
Line 353... |
| 350 |
return responseSender.badRequest("Invalid request");
|
353 |
return responseSender.badRequest("Invalid request");
|
| 351 |
}
|
354 |
}
|
| 352 |
|
355 |
|
| 353 |
Map<String, String> returnMap = this.pendingOrderService.createPendingOrder(createPendingOrderRequest, cr);
|
356 |
Map<String, String> returnMap = this.pendingOrderService.createPendingOrder(createPendingOrderRequest, cr);
|
| 354 |
|
357 |
|
| - |
|
358 |
PendingOrder pendingOrder = pendingOrderRepository.selectById(Integer.parseInt(returnMap.get("poId")));
|
| - |
|
359 |
if (offlineOrders.contains(pendingOrder.getPayMethod())) {
|
| - |
|
360 |
|
| - |
|
361 |
Map<String, Object> emailModel = pendingOrderService.sendCreateOrderMail(pendingOrder);
|
| - |
|
362 |
|
| - |
|
363 |
CustomRetailer customRetailer = retailerService.getFofoRetailer(pendingOrder.getFofoId());
|
| - |
|
364 |
Customer customer = customerRepository.selectById(pendingOrder.getCustomerId());
|
| - |
|
365 |
String[] customerEmail = null;
|
| - |
|
366 |
if (customer.getEmailId() != null) {
|
| - |
|
367 |
customerEmail = new String[] { customer.getEmailId() };
|
| - |
|
368 |
}
|
| - |
|
369 |
List<String> bccTo = Arrays.asList("kamini.sharma@smartdukaan.com", "tarun.verma@smartdukaan.com",
|
| - |
|
370 |
"hemant.kaura@smartdukaan.com", "niranjan.kala@smartdukaan.com", "sm@smartdukaan.com",
|
| - |
|
371 |
"tejbeer.kaur@shop2020.in", customRetailer.getEmail());
|
| - |
|
372 |
List<String> authUserEmails = csService.getAuthUserByPartnerId(customRetailer.getPartnerId());
|
| - |
|
373 |
if (authUserEmails != null) {
|
| - |
|
374 |
authUserEmails = new ArrayList<>();
|
| - |
|
375 |
}
|
| - |
|
376 |
logger.info("authUserEmails {}", authUserEmails);
|
| - |
|
377 |
authUserEmails.addAll(bccTo);
|
| - |
|
378 |
|
| - |
|
379 |
emailService.sendMailWithAttachments("Order Created with SmartDukaan", "order-confirm.vm", emailModel,
|
| - |
|
380 |
customerEmail, null, authUserEmails.toArray(new String[0]));
|
| - |
|
381 |
}
|
| 355 |
return responseSender.ok(returnMap);
|
382 |
return responseSender.ok(returnMap);
|
| 356 |
|
383 |
|
| 357 |
}
|
384 |
}
|
| 358 |
|
385 |
|
| 359 |
@RequestMapping(value = "/store/address", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
386 |
@RequestMapping(value = "/store/address", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
| Line 733... |
Line 760... |
| 733 |
JSONObject jsonObj = contentMap.get(item.getCatalogItemId());
|
760 |
JSONObject jsonObj = contentMap.get(item.getCatalogItemId());
|
| 734 |
pendingOrderItem.setImgUrl(jsonObj.getString("imageUrl_s"));
|
761 |
pendingOrderItem.setImgUrl(jsonObj.getString("imageUrl_s"));
|
| 735 |
}
|
762 |
}
|
| 736 |
pendingOrder.setPendingOrderItems(pendingOrderItems);
|
763 |
pendingOrder.setPendingOrderItems(pendingOrderItems);
|
| 737 |
|
764 |
|
| 738 |
CustomerAddress customerAddress = customerAddressRepository.selectById(pendingOrder.getCustomerAddressId());
|
- |
|
| 739 |
|
- |
|
| 740 |
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("dd/MM/yyyy h:mm a");
|
- |
|
| 741 |
|
- |
|
| 742 |
Map<String, Object> emailModel = new HashMap<>();
|
- |
|
| 743 |
emailModel.put("customer", customerAddress);
|
- |
|
| 744 |
emailModel.put("pendingOrder", pendingOrder);
|
- |
|
| 745 |
emailModel.put("date", dateTimeFormatter);
|
- |
|
| 746 |
|
- |
|
| 747 |
CustomRetailer customRetailer = retailerService.getFofoRetailer(pendingOrder.getFofoId());
|
- |
|
| 748 |
Customer customer = customerRepository.selectById(pendingOrder.getCustomerId());
|
- |
|
| 749 |
String[] customerEmail = null;
|
- |
|
| 750 |
if (customer.getEmailId() != null) {
|
- |
|
| 751 |
customerEmail = new String[] { customer.getEmailId() };
|
- |
|
| 752 |
}
|
- |
|
| 753 |
List<String> bccTo = Arrays.asList("kamini.sharma@smartdukaan.com", "tarun.verma@smartdukaan.com",
|
- |
|
| 754 |
"hemant.kaura@smartdukaan.com", "niranjan.kala@smartdukaan.com", "sm@smartdukaan.com",
|
- |
|
| 755 |
"tejbeer.kaur@shop2020.in", customRetailer.getEmail());
|
- |
|
| 756 |
List<String> authUserEmails = csService.getAuthUserByPartnerId(customRetailer.getPartnerId());
|
- |
|
| 757 |
if (authUserEmails != null) {
|
- |
|
| 758 |
authUserEmails = new ArrayList<>();
|
- |
|
| 759 |
}
|
- |
|
| 760 |
logger.info("authUserEmails {}", authUserEmails);
|
- |
|
| 761 |
authUserEmails.addAll(bccTo);
|
- |
|
| 762 |
|
- |
|
| 763 |
emailService.sendMailWithAttachments("Order Created with SmartDukaan", "order-confirm.vm", emailModel,
|
- |
|
| 764 |
customerEmail, null, authUserEmails.toArray(new String[0]));
|
- |
|
| 765 |
return responseSender.ok(pendingOrder);
|
765 |
return responseSender.ok(pendingOrder);
|
| 766 |
}
|
766 |
}
|
| 767 |
|
767 |
|
| 768 |
@RequestMapping(value = "/store/addresses/{customerId}", method = RequestMethod.GET)
|
768 |
@RequestMapping(value = "/store/addresses/{customerId}", method = RequestMethod.GET)
|
| 769 |
public ResponseEntity<?> getAll(HttpServletRequest request, @PathVariable int customerId) throws Throwable {
|
769 |
public ResponseEntity<?> getAll(HttpServletRequest request, @PathVariable int customerId) throws Throwable {
|
| Line 822... |
Line 822... |
| 822 |
pendingOrderItem.setStatusDescription(statusDescription);
|
822 |
pendingOrderItem.setStatusDescription(statusDescription);
|
| 823 |
pendingOrderItem.setCancelledTimestamp(LocalDateTime.now());
|
823 |
pendingOrderItem.setCancelledTimestamp(LocalDateTime.now());
|
| 824 |
List<OrderStatus> status = pendingOrderItemRepository.selectByOrderId(pendingOrderItem.getOrderId())
|
824 |
List<OrderStatus> status = pendingOrderItemRepository.selectByOrderId(pendingOrderItem.getOrderId())
|
| 825 |
.stream().map(x -> x.getStatus()).collect(Collectors.toList());
|
825 |
.stream().map(x -> x.getStatus()).collect(Collectors.toList());
|
| 826 |
|
826 |
|
| 827 |
if (!status.contains(OrderStatus.PENDING)) {
|
827 |
if (!status.contains(OrderStatus.PENDING) && !status.contains(OrderStatus.BILLED)
|
| - |
|
828 |
&& !status.contains(OrderStatus.UNSETTLED) && !status.contains(OrderStatus.CLAIMED)) {
|
| 828 |
pendingOrder.setStatus(OrderStatus.CLOSED);
|
829 |
pendingOrder.setStatus(OrderStatus.CLOSED);
|
| 829 |
}
|
830 |
}
|
| 830 |
|
831 |
|
| 831 |
pendingOrderItemRepository.persist(pendingOrderItem);
|
832 |
pendingOrderItemRepository.persist(pendingOrderItem);
|
| 832 |
String itemDescription = itemRepository.selectById(pendingOrderItem.getItemId()).getItemDescription();
|
833 |
String itemDescription = itemRepository.selectById(pendingOrderItem.getItemId()).getItemDescription();
|
| 833 |
otpProcessor.sendSms(OtpProcessor.SELF_CANCELLED_TEMPLATE_ID,
|
834 |
otpProcessor.sendSms(OtpProcessor.SELF_CANCELLED_TEMPLATE_ID,
|
| 834 |
String.format(OtpProcessor.SELF_CANCELLED_TEMPLATE, pendingOrder.getId(),
|
835 |
String.format(OtpProcessor.SELF_CANCELLED_TEMPLATE, pendingOrder.getId(),
|
| 835 |
StringUtils.abbreviate(itemDescription, 30),
|
836 |
StringUtils.abbreviate(itemDescription, 30),
|
| 836 |
FormattingUtils.format(pendingOrderItem.getCancelledTimestamp())),
|
837 |
FormattingUtils.format(pendingOrderItem.getCancelledTimestamp())),
|
| 837 |
customer.getMobileNumber());
|
838 |
customer.getMobileNumber());
|
| - |
|
839 |
|
| - |
|
840 |
List<Integer> catalogIds = new ArrayList<>();
|
| - |
|
841 |
|
| - |
|
842 |
Item item = itemRepository.selectById(pendingOrderItem.getItemId());
|
| - |
|
843 |
pendingOrderItem.setItemName(item.getItemDescription());
|
| - |
|
844 |
catalogIds.add(item.getCatalogItemId());
|
| - |
|
845 |
|
| - |
|
846 |
Map<Integer, JSONObject> contentMap = commonSolrService.getContentByCatalogIds(catalogIds);
|
| - |
|
847 |
JSONObject jsonObj = contentMap.get(item.getCatalogItemId());
|
| - |
|
848 |
pendingOrderItem.setImgUrl(jsonObj.getString("imageUrl_s"));
|
| - |
|
849 |
pendingOrder.setPendingOrderItems(Arrays.asList(pendingOrderItem));
|
| - |
|
850 |
CustomerAddress customerAddress = customerAddressRepository.selectById(pendingOrder.getCustomerAddressId());
|
| - |
|
851 |
|
| - |
|
852 |
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("dd/MM/yyyy h:mm a");
|
| - |
|
853 |
|
| - |
|
854 |
Map<String, Object> emailModel = new HashMap<>();
|
| - |
|
855 |
emailModel.put("customer", customerAddress);
|
| - |
|
856 |
emailModel.put("pendingOrder", pendingOrder);
|
| - |
|
857 |
emailModel.put("date", dateTimeFormatter);
|
| - |
|
858 |
|
| - |
|
859 |
String[] customerEmail = null;
|
| - |
|
860 |
if (customer.getEmailId() != null) {
|
| - |
|
861 |
customerEmail = new String[] { customer.getEmailId(), "tejbeer.kaur@smartdukaan.com" };
|
| - |
|
862 |
|
| - |
|
863 |
emailService.sendMailWithAttachments("Order Cancellation", "order-cancellation.vm", emailModel,
|
| - |
|
864 |
customerEmail, null, null);
|
| - |
|
865 |
|
| - |
|
866 |
}
|
| 838 |
}
|
867 |
}
|
| 839 |
|
868 |
|
| 840 |
return responseSender.ok(true);
|
869 |
return responseSender.ok(true);
|
| 841 |
|
870 |
|
| 842 |
}
|
871 |
}
|