| Line 1... |
Line 1... |
| 1 |
package com.spice.profitmandi.web.controller;
|
1 |
package com.spice.profitmandi.web.controller;
|
| 2 |
|
2 |
|
| - |
|
3 |
import com.fasterxml.jackson.databind.JsonNode;
|
| - |
|
4 |
import com.fasterxml.jackson.databind.ObjectMapper;
|
| 3 |
import com.google.gson.Gson;
|
5 |
import com.google.gson.Gson;
|
| - |
|
6 |
import com.opencsv.CSVWriter;
|
| 4 |
import com.spice.profitmandi.common.enumuration.SearchType;
|
7 |
import com.spice.profitmandi.common.enumuration.SearchType;
|
| 5 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
8 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
| 6 |
import com.spice.profitmandi.common.model.*;
|
9 |
import com.spice.profitmandi.common.model.*;
|
| 7 |
import com.spice.profitmandi.common.solr.SolrService;
|
10 |
import com.spice.profitmandi.common.solr.SolrService;
|
| 8 |
import com.spice.profitmandi.common.util.FileUtil;
|
11 |
import com.spice.profitmandi.common.util.FileUtil;
|
| Line 15... |
Line 18... |
| 15 |
import com.spice.profitmandi.dao.entity.dtr.InsurancePolicy;
|
18 |
import com.spice.profitmandi.dao.entity.dtr.InsurancePolicy;
|
| 16 |
import com.spice.profitmandi.dao.entity.dtr.InsuranceProvider;
|
19 |
import com.spice.profitmandi.dao.entity.dtr.InsuranceProvider;
|
| 17 |
import com.spice.profitmandi.dao.entity.dtr.PaymentOptionTransaction;
|
20 |
import com.spice.profitmandi.dao.entity.dtr.PaymentOptionTransaction;
|
| 18 |
import com.spice.profitmandi.dao.entity.fofo.*;
|
21 |
import com.spice.profitmandi.dao.entity.fofo.*;
|
| 19 |
import com.spice.profitmandi.dao.entity.user.Address;
|
22 |
import com.spice.profitmandi.dao.entity.user.Address;
|
| - |
|
23 |
import com.spice.profitmandi.dao.entity.whatsapp.WhatsappMessage;
|
| 20 |
import com.spice.profitmandi.dao.enumuration.dtr.PaymentOptionReferenceType;
|
24 |
import com.spice.profitmandi.dao.enumuration.dtr.PaymentOptionReferenceType;
|
| 21 |
import com.spice.profitmandi.dao.enumuration.transaction.OrderStatus;
|
25 |
import com.spice.profitmandi.dao.enumuration.transaction.OrderStatus;
|
| 22 |
import com.spice.profitmandi.dao.model.*;
|
26 |
import com.spice.profitmandi.dao.model.*;
|
| 23 |
import com.spice.profitmandi.dao.repository.catalog.ItemRepository;
|
27 |
import com.spice.profitmandi.dao.repository.catalog.ItemRepository;
|
| 24 |
import com.spice.profitmandi.dao.repository.catalog.TagListingRepository;
|
28 |
import com.spice.profitmandi.dao.repository.catalog.TagListingRepository;
|
| 25 |
import com.spice.profitmandi.dao.repository.dtr.*;
|
29 |
import com.spice.profitmandi.dao.repository.dtr.*;
|
| 26 |
import com.spice.profitmandi.dao.repository.fofo.*;
|
30 |
import com.spice.profitmandi.dao.repository.fofo.*;
|
| 27 |
import com.spice.profitmandi.dao.repository.inventory.StateRepository;
|
31 |
import com.spice.profitmandi.dao.repository.inventory.StateRepository;
|
| 28 |
import com.spice.profitmandi.dao.repository.transaction.OrderRepository;
|
32 |
import com.spice.profitmandi.dao.repository.transaction.OrderRepository;
|
| 29 |
import com.spice.profitmandi.dao.repository.user.AddressRepository;
|
33 |
import com.spice.profitmandi.dao.repository.user.AddressRepository;
|
| - |
|
34 |
import com.spice.profitmandi.dao.repository.whatsapp.WhatsappMessageRepository;
|
| 30 |
import com.spice.profitmandi.service.EmailService;
|
35 |
import com.spice.profitmandi.service.EmailService;
|
| 31 |
import com.spice.profitmandi.service.NotificationService;
|
36 |
import com.spice.profitmandi.service.NotificationService;
|
| 32 |
import com.spice.profitmandi.service.authentication.RoleManager;
|
37 |
import com.spice.profitmandi.service.authentication.RoleManager;
|
| 33 |
import com.spice.profitmandi.service.integrations.zest.InsuranceService;
|
38 |
import com.spice.profitmandi.service.integrations.zest.InsuranceService;
|
| 34 |
import com.spice.profitmandi.service.integrations.zest.MobileInsurancePlan;
|
39 |
import com.spice.profitmandi.service.integrations.zest.MobileInsurancePlan;
|
| 35 |
import com.spice.profitmandi.service.order.OrderService;
|
40 |
import com.spice.profitmandi.service.order.OrderService;
|
| 36 |
import com.spice.profitmandi.service.pricing.PricingService;
|
41 |
import com.spice.profitmandi.service.pricing.PricingService;
|
| 37 |
import com.spice.profitmandi.service.user.RetailerService;
|
42 |
import com.spice.profitmandi.service.user.RetailerService;
|
| - |
|
43 |
import com.spice.profitmandi.service.whatsapp.WhatsappMessageService;
|
| 38 |
import com.spice.profitmandi.web.model.LoginDetails;
|
44 |
import com.spice.profitmandi.web.model.LoginDetails;
|
| 39 |
import com.spice.profitmandi.web.util.CookiesProcessor;
|
45 |
import com.spice.profitmandi.web.util.CookiesProcessor;
|
| 40 |
import com.spice.profitmandi.web.util.MVCResponseSender;
|
46 |
import com.spice.profitmandi.web.util.MVCResponseSender;
|
| - |
|
47 |
import org.apache.commons.csv.CSVRecord;
|
| 41 |
import org.apache.logging.log4j.LogManager;
|
48 |
import org.apache.logging.log4j.LogManager;
|
| 42 |
import org.apache.logging.log4j.Logger;
|
49 |
import org.apache.logging.log4j.Logger;
|
| - |
|
50 |
import org.json.JSONArray;
|
| - |
|
51 |
import org.json.JSONException;
|
| 43 |
import org.json.JSONObject;
|
52 |
import org.json.JSONObject;
|
| 44 |
import org.springframework.beans.factory.annotation.Autowired;
|
53 |
import org.springframework.beans.factory.annotation.Autowired;
|
| 45 |
import org.springframework.core.io.InputStreamResource;
|
54 |
import org.springframework.core.io.InputStreamResource;
|
| 46 |
import org.springframework.http.HttpHeaders;
|
55 |
import org.springframework.http.HttpHeaders;
|
| 47 |
import org.springframework.http.HttpStatus;
|
56 |
import org.springframework.http.HttpStatus;
|
| Line 52... |
Line 61... |
| 52 |
import org.springframework.ui.Model;
|
61 |
import org.springframework.ui.Model;
|
| 53 |
import org.springframework.web.bind.annotation.*;
|
62 |
import org.springframework.web.bind.annotation.*;
|
| 54 |
|
63 |
|
| 55 |
import javax.servlet.http.HttpServletRequest;
|
64 |
import javax.servlet.http.HttpServletRequest;
|
| 56 |
import javax.servlet.http.HttpServletResponse;
|
65 |
import javax.servlet.http.HttpServletResponse;
|
| 57 |
import java.io.ByteArrayInputStream;
|
- |
|
| 58 |
import java.io.ByteArrayOutputStream;
|
- |
|
| 59 |
import java.io.InputStream;
|
66 |
import java.io.*;
|
| 60 |
import java.nio.charset.StandardCharsets;
|
67 |
import java.nio.charset.StandardCharsets;
|
| - |
|
68 |
import java.nio.file.Files;
|
| - |
|
69 |
import java.nio.file.Paths;
|
| 61 |
import java.time.LocalDate;
|
70 |
import java.time.LocalDate;
|
| 62 |
import java.time.LocalDateTime;
|
71 |
import java.time.LocalDateTime;
|
| 63 |
import java.time.LocalTime;
|
72 |
import java.time.LocalTime;
|
| 64 |
import java.time.format.DateTimeFormatter;
|
73 |
import java.time.format.DateTimeFormatter;
|
| 65 |
import java.time.temporal.ChronoUnit;
|
74 |
import java.time.temporal.ChronoUnit;
|
| Line 142... |
Line 151... |
| 142 |
@Autowired
|
151 |
@Autowired
|
| 143 |
private SolrService commonSolrService;
|
152 |
private SolrService commonSolrService;
|
| 144 |
@Autowired
|
153 |
@Autowired
|
| 145 |
private MouRepository mouRepository;
|
154 |
private MouRepository mouRepository;
|
| 146 |
|
155 |
|
| - |
|
156 |
@Autowired
|
| - |
|
157 |
private WhatsappMessageService whatsappMessageService;
|
| - |
|
158 |
|
| 147 |
@RequestMapping(value = "/order")
|
159 |
@RequestMapping(value = "/order")
|
| 148 |
public String orderIndex(HttpServletRequest request, @RequestParam(name = "cartData") String cartData, Model model)
|
160 |
public String orderIndex(HttpServletRequest request, @RequestParam(name = "cartData") String cartData, Model model)
|
| 149 |
throws ProfitMandiBusinessException {
|
161 |
throws ProfitMandiBusinessException {
|
| 150 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
162 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 151 |
|
163 |
|
| Line 591... |
Line 603... |
| 591 |
.contentLength(contentLength)
|
603 |
.contentLength(contentLength)
|
| 592 |
.contentType(MediaType.parseMediaType("application/pdf"))
|
604 |
.contentType(MediaType.parseMediaType("application/pdf"))
|
| 593 |
.body(inputStreamResource);
|
605 |
.body(inputStreamResource);
|
| 594 |
}
|
606 |
}
|
| 595 |
|
607 |
|
| - |
|
608 |
@Autowired
|
| - |
|
609 |
private WhatsappMessageRepository messageRepository;
|
| - |
|
610 |
private final Map<String, Integer> destAddrFailedCountMap = new HashMap<>();
|
| 596 |
@RequestMapping(value = "/wa-listen", method = RequestMethod.POST)
|
611 |
@RequestMapping(value = "/wa-listen", method = RequestMethod.POST)
|
| 597 |
public ResponseEntity<?> listenWhatsappStatus(@RequestBody String whatsappJsonResponse) {
|
612 |
public ResponseEntity<?> listenWhatsappStatus(@RequestBody String whatsappJsonResponse) {
|
| 598 |
LOGGER.info("whatsappJsonResponse {}", whatsappJsonResponse);
|
613 |
LOGGER.info("whatsappJsonResponse {}", whatsappJsonResponse);
|
| - |
|
614 |
//jaihind
|
| - |
|
615 |
// String jsonString = "[{\"srcAddr\":\"TESTSM\",\"channel\":\"WHATSAPP\",\"externalId\":\"4977024756456780043-180044363908187691\",\"cause\":\"SUCCESS\",\"errorCode\":\"000\",\"destAddr\":\"919813272029\",\"eventType\":\"DELIVERED\",\"eventTs\":1692848106000}]";
|
| - |
|
616 |
JSONArray jsonArray = new JSONArray(whatsappJsonResponse);
|
| - |
|
617 |
for(int i = 0; i < jsonArray.length(); i++) {
|
| - |
|
618 |
|
| - |
|
619 |
JSONObject jsonObject = jsonArray.getJSONObject(i);
|
| - |
|
620 |
String externalId = jsonObject.getString("externalId");
|
| - |
|
621 |
String destAddr = jsonObject.getString("destAddr");
|
| - |
|
622 |
String eventType = jsonObject.getString("eventType");
|
| - |
|
623 |
whatsappMessageService.setWhatsappResponse(externalId,destAddr,eventType);
|
| - |
|
624 |
}
|
| - |
|
625 |
//jaihind
|
| 599 |
return responseSender.ok("Success");
|
626 |
return responseSender.ok("Success");
|
| 600 |
}
|
- |
|
| 601 |
|
627 |
|
| - |
|
628 |
}
|
| 602 |
@RequestMapping(value = "/generateInvoice")
|
629 |
@RequestMapping(value = "/generateInvoice")
|
| 603 |
public ResponseEntity<?> generateInvoice(HttpServletRequest request, HttpServletResponse response,
|
630 |
public ResponseEntity<?> generateInvoice(HttpServletRequest request, HttpServletResponse response,
|
| 604 |
@RequestParam(name = ProfitMandiConstants.ORDER_ID) int orderId) throws ProfitMandiBusinessException {
|
631 |
@RequestParam(name = ProfitMandiConstants.ORDER_ID) int orderId) throws ProfitMandiBusinessException {
|
| 605 |
LOGGER.info("Request received at url {} with params [{}={}] ", request.getRequestURI(),
|
632 |
LOGGER.info("Request received at url {} with params [{}={}] ", request.getRequestURI(),
|
| 606 |
ProfitMandiConstants.ORDER_ID, orderId);
|
633 |
ProfitMandiConstants.ORDER_ID, orderId);
|
| Line 1720... |
Line 1747... |
| 1720 |
model.addAttribute("partnerInventoryMap", map.get("partnerInventoryMap"));
|
1747 |
model.addAttribute("partnerInventoryMap", map.get("partnerInventoryMap"));
|
| 1721 |
model.addAttribute("date", date);
|
1748 |
model.addAttribute("date", date);
|
| 1722 |
model.addAttribute("isAdmin", isAdmin);
|
1749 |
model.addAttribute("isAdmin", isAdmin);
|
| 1723 |
return "online-all-order-item";
|
1750 |
return "online-all-order-item";
|
| 1724 |
}
|
1751 |
}
|
| - |
|
1752 |
}
|
| - |
|
1753 |
|
| - |
|
1754 |
|
| - |
|
1755 |
|
| 1725 |
}
|
1756 |
|
| - |
|
1757 |
|