| Line 37... |
Line 37... |
| 37 |
import com.spice.profitmandi.dao.repository.fofo.*;
|
37 |
import com.spice.profitmandi.dao.repository.fofo.*;
|
| 38 |
import com.spice.profitmandi.dao.repository.inventory.StateRepository;
|
38 |
import com.spice.profitmandi.dao.repository.inventory.StateRepository;
|
| 39 |
import com.spice.profitmandi.dao.repository.transaction.*;
|
39 |
import com.spice.profitmandi.dao.repository.transaction.*;
|
| 40 |
import com.spice.profitmandi.dao.repository.user.AddressRepository;
|
40 |
import com.spice.profitmandi.dao.repository.user.AddressRepository;
|
| 41 |
import com.spice.profitmandi.dao.repository.user.CartRepository;
|
41 |
import com.spice.profitmandi.dao.repository.user.CartRepository;
|
| - |
|
42 |
import com.spice.profitmandi.dao.service.ScratchService;
|
| 42 |
import com.spice.profitmandi.service.EmailService;
|
43 |
import com.spice.profitmandi.service.EmailService;
|
| 43 |
import com.spice.profitmandi.service.NotificationService;
|
44 |
import com.spice.profitmandi.service.NotificationService;
|
| 44 |
import com.spice.profitmandi.service.authentication.RoleManager;
|
45 |
import com.spice.profitmandi.service.authentication.RoleManager;
|
| 45 |
import com.spice.profitmandi.service.integrations.zest.InsuranceService;
|
46 |
import com.spice.profitmandi.service.integrations.zest.InsuranceService;
|
| 46 |
import com.spice.profitmandi.service.integrations.zest.MobileInsurancePlan;
|
47 |
import com.spice.profitmandi.service.integrations.zest.MobileInsurancePlan;
|
| Line 208... |
Line 209... |
| 208 |
PartnerOnBoardingPanelRepository partnerOnBoardingPanelRepository;
|
209 |
PartnerOnBoardingPanelRepository partnerOnBoardingPanelRepository;
|
| 209 |
|
210 |
|
| 210 |
@Autowired
|
211 |
@Autowired
|
| 211 |
SDCreditService sdCreditService;
|
212 |
SDCreditService sdCreditService;
|
| 212 |
|
213 |
|
| - |
|
214 |
@Autowired
|
| - |
|
215 |
ScratchService scratchService;
|
| - |
|
216 |
|
| 213 |
@RequestMapping(value = "/wa-send-invoice", method = RequestMethod.GET)
|
217 |
@RequestMapping(value = "/wa-send-invoice", method = RequestMethod.GET)
|
| 214 |
public String sendWhatsappMessage(HttpServletRequest request, @RequestParam(name = ProfitMandiConstants.ORDER_ID) int orderId, Model model) {
|
218 |
public String sendWhatsappMessage(HttpServletRequest request, @RequestParam(name = ProfitMandiConstants.ORDER_ID) int orderId, Model model) {
|
| 215 |
try {
|
219 |
try {
|
| 216 |
this.sendWhatsappInvoice(fofoOrderRepository.selectByOrderId(orderId));
|
220 |
this.sendWhatsappInvoice(fofoOrderRepository.selectByOrderId(orderId));
|
| 217 |
} catch (Exception e) {
|
221 |
} catch (Exception e) {
|
| Line 419... |
Line 423... |
| 419 |
public String getSearchOrderDetails(HttpServletRequest request,
|
423 |
public String getSearchOrderDetails(HttpServletRequest request,
|
| 420 |
@RequestParam(name = ProfitMandiConstants.INVOICE_NUMBER) String invoiceNumber, Model model)
|
424 |
@RequestParam(name = ProfitMandiConstants.INVOICE_NUMBER) String invoiceNumber, Model model)
|
| 421 |
throws Exception {
|
425 |
throws Exception {
|
| 422 |
|
426 |
|
| 423 |
FofoOrder fofoOrder = fofoOrderRepository.selectByInvoiceNumber(invoiceNumber);
|
427 |
FofoOrder fofoOrder = fofoOrderRepository.selectByInvoiceNumber(invoiceNumber);
|
| 424 |
if(fofoOrder==null){
|
428 |
if (fofoOrder == null) {
|
| 425 |
throw new ProfitMandiBusinessException("invalid invoice number","invoice - "+invoiceNumber, "Please enter valid invoice number");
|
429 |
throw new ProfitMandiBusinessException("invalid invoice number", "invoice - " + invoiceNumber, "Please enter valid invoice number");
|
| 426 |
}
|
430 |
}
|
| 427 |
|
431 |
|
| 428 |
List<FofoOrderItem> fofoOrderItems = fofoOrderItemRepository.selectByOrderId(fofoOrder.getId());
|
432 |
List<FofoOrderItem> fofoOrderItems = fofoOrderItemRepository.selectByOrderId(fofoOrder.getId());
|
| 429 |
Customer customer = customerRepository.selectById(fofoOrder.getCustomerId());
|
433 |
Customer customer = customerRepository.selectById(fofoOrder.getCustomerId());
|
| 430 |
CustomerAddress customerAddress = customerAddressRepository.selectById(fofoOrder.getCustomerAddressId());
|
434 |
CustomerAddress customerAddress = customerAddressRepository.selectById(fofoOrder.getCustomerAddressId());
|
| Line 550... |
Line 554... |
| 550 |
return this.sendWhatsappInvoice(fofoOrder, "");
|
554 |
return this.sendWhatsappInvoice(fofoOrder, "");
|
| 551 |
}
|
555 |
}
|
| 552 |
|
556 |
|
| 553 |
private boolean sendWhatsappInvoice(FofoOrder fofoOrder, String whatsAppNo) throws Exception {
|
557 |
private boolean sendWhatsappInvoice(FofoOrder fofoOrder, String whatsAppNo) throws Exception {
|
| 554 |
boolean shouldSendWhatsappMessage = notificationService.shouldSendWhatsappMessage(whatsAppNo);
|
558 |
boolean shouldSendWhatsappMessage = notificationService.shouldSendWhatsappMessage(whatsAppNo);
|
| 555 |
boolean isSend=false;
|
559 |
boolean isSend = false;
|
| 556 |
if (shouldSendWhatsappMessage) {
|
560 |
if (shouldSendWhatsappMessage) {
|
| 557 |
Customer customer = customerRepository.selectById(fofoOrder.getCustomerId());
|
561 |
Customer customer = customerRepository.selectById(fofoOrder.getCustomerId());
|
| 558 |
String mobileNumber;
|
562 |
String mobileNumber;
|
| 559 |
if (!whatsAppNo.isEmpty()) {
|
563 |
if (!whatsAppNo.isEmpty()) {
|
| 560 |
mobileNumber = whatsAppNo;
|
564 |
mobileNumber = whatsAppNo;
|
| 561 |
} else {
|
565 |
} else {
|
| 562 |
mobileNumber = customer.getMobileNumber();
|
566 |
mobileNumber = customer.getMobileNumber();
|
| 563 |
}
|
567 |
}
|
| 564 |
CustomRetailer retailer = retailerService.getFofoRetailer(fofoOrder.getFofoId());
|
568 |
CustomRetailer retailer = retailerService.getFofoRetailer(fofoOrder.getFofoId());
|
| 565 |
String message = String.format("Dear %s,\n" +
|
569 |
String message = String.format("Dear %s,\n" +
|
| 566 |
"Thank you for your purchase from SmartDukaan store - %s, %s.\n" +
|
570 |
"Thank you for your purchase from SmartDukaan store - %s, %s.\n" +
|
| 567 |
"Your purchase invoice is attached for your reference.\n" +
|
571 |
"Your purchase invoice is attached for your reference.\n" +
|
| 568 |
"\n" +
|
572 |
"\n" +
|
| 569 |
"Download our app for offers and updates on new products.\n" +
|
573 |
"Download our app for offers and updates on new products.\n" +
|
| 570 |
"https://www.smartdukaan.com/b2c\n" +
|
574 |
"https://www.smartdukaan.com/b2c\n" +
|
| 571 |
"\n" +
|
575 |
"\n" +
|
| 572 |
"Best Regards\n" +
|
576 |
"Best Regards\n" +
|
| 573 |
"SmartDukaan", customer.getFirstName(), retailer.getBusinessName(), retailer.getAddress().getCity());
|
577 |
"SmartDukaan", customer.getFirstName(), retailer.getBusinessName(), retailer.getAddress().getCity());
|
| 574 |
|
578 |
|
| 575 |
isSend =notificationService.sendWhatsappMediaMessage(message, mobileNumber, this.getPublicInvoiceUrl(fofoOrder.getInvoiceNumber()),
|
579 |
isSend = notificationService.sendWhatsappMediaMessage(message, mobileNumber, this.getPublicInvoiceUrl(fofoOrder.getInvoiceNumber()),
|
| 576 |
this.getFileName(fofoOrder.getInvoiceNumber()), WhatsappMessageType.DOCUMENT);
|
580 |
this.getFileName(fofoOrder.getInvoiceNumber()), WhatsappMessageType.DOCUMENT);
|
| 577 |
}
|
581 |
}
|
| 578 |
return isSend;
|
582 |
return isSend;
|
| 579 |
}
|
583 |
}
|
| 580 |
|
584 |
|
| Line 1175... |
Line 1179... |
| 1175 |
// "Billing is on hold temporarily", "Billing is on hold temporarily");
|
1179 |
// "Billing is on hold temporarily", "Billing is on hold temporarily");
|
| 1176 |
LOGGER.info("request at uri {}", request.getRequestURI());
|
1180 |
LOGGER.info("request at uri {}", request.getRequestURI());
|
| 1177 |
LOGGER.info("request body {}", createOrderRequest);
|
1181 |
LOGGER.info("request body {}", createOrderRequest);
|
| 1178 |
LoginDetails fofoDetails = cookiesProcessor.getCookiesObject(request);
|
1182 |
LoginDetails fofoDetails = cookiesProcessor.getCookiesObject(request);
|
| 1179 |
int fofoOrderId = orderService.createOrder(createOrderRequest, fofoDetails.getFofoId(), accessoriesDeals);
|
1183 |
int fofoOrderId = orderService.createOrder(createOrderRequest, fofoDetails.getFofoId(), accessoriesDeals);
|
| - |
|
1184 |
try {
|
| - |
|
1185 |
scratchService.processScratchOffer(fofoOrderId, createOrderRequest.getPaymentOptions(), createOrderRequest.getFofoOrderItems());
|
| - |
|
1186 |
} catch (Exception e) {
|
| - |
|
1187 |
LOGGER.info("Exception during processScratchOffer - " + e.getMessage());
|
| - |
|
1188 |
}
|
| 1180 |
LOGGER.info("Order has been created successfully...");
|
1189 |
LOGGER.info("Order has been created successfully...");
|
| 1181 |
|
- |
|
| 1182 |
return "redirect:/get-order/?orderId=" + fofoOrderId;
|
1190 |
return "redirect:/get-order/?orderId=" + fofoOrderId;
|
| 1183 |
}
|
1191 |
}
|
| 1184 |
|
1192 |
|
| 1185 |
@GetMapping("/billedOrders")
|
1193 |
@GetMapping("/billedOrders")
|
| 1186 |
public String getBilledOrders(HttpServletRequest request, Model model) throws ProfitMandiBusinessException {
|
1194 |
public String getBilledOrders(HttpServletRequest request, Model model) throws ProfitMandiBusinessException {
|
| Line 1739... |
Line 1747... |
| 1739 |
});
|
1747 |
});
|
| 1740 |
model.addAttribute("response1", mvcResponseSender.createResponseString(true));
|
1748 |
model.addAttribute("response1", mvcResponseSender.createResponseString(true));
|
| 1741 |
return "response";
|
1749 |
return "response";
|
| 1742 |
}
|
1750 |
}
|
| 1743 |
|
1751 |
|
| 1744 |
@PutMapping (value = "/sendInvoiceOnWhatsApp")
|
1752 |
@PutMapping(value = "/sendInvoiceOnWhatsApp")
|
| 1745 |
public String sendInvoiceOnWhatsApp(HttpServletRequest request ,@RequestParam int orderId,@RequestParam String whatsAppMobile, Model model) throws Exception {
|
1753 |
public String sendInvoiceOnWhatsApp(HttpServletRequest request, @RequestParam int orderId, @RequestParam String whatsAppMobile, Model model) throws Exception {
|
| 1746 |
boolean isSend=this.sendWhatsappInvoice(fofoOrderRepository.selectByOrderId(orderId),whatsAppMobile);
|
1754 |
boolean isSend = this.sendWhatsappInvoice(fofoOrderRepository.selectByOrderId(orderId), whatsAppMobile);
|
| 1747 |
model.addAttribute("response1", isSend);
|
1755 |
model.addAttribute("response1", isSend);
|
| 1748 |
return "response";
|
1756 |
return "response";
|
| 1749 |
}
|
1757 |
}
|
| 1750 |
|
1758 |
|
| 1751 |
|
1759 |
|
| 1752 |
}
|
1760 |
}
|