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