Browse Source

Changes in Street Vendor Whatsapp message API

master
Hariprasath S 2 months ago
parent
commit
d61cce16b8
  1. 12
      src/main/java/in/gov/chennaicorporation/gccoffice/vendor/controller/CreateEventAPIController.java
  2. 125
      src/main/java/in/gov/chennaicorporation/gccoffice/vendor/service/createventService.java
  3. 4
      src/main/resources/templates/modules/vendors/certificate.html

12
src/main/java/in/gov/chennaicorporation/gccoffice/vendor/controller/CreateEventAPIController.java

@ -235,19 +235,15 @@ public class CreateEventAPIController {
@RequestParam String ward, @RequestParam String ward,
@RequestParam String street_id, @RequestParam String street_id,
@RequestParam String street_name, @RequestParam String street_name,
@RequestParam String cby) {
@RequestParam String cby,
@RequestParam String mob_no,
@RequestParam String vendor_req_id) {
Map<String, Object> response = new HashMap<>(); Map<String, Object> response = new HashMap<>();
try { try {
boolean status = createventservices.giveCertificate(
vdid,
zone,
ward,
street_id,
street_name,
cby);
boolean status = createventservices.giveCertificate(vdid,zone,ward, street_id,street_name,cby,mob_no,vendor_req_id);
if (status) { if (status) {

125
src/main/java/in/gov/chennaicorporation/gccoffice/vendor/service/createventService.java

@ -2,6 +2,8 @@ package in.gov.chennaicorporation.gccoffice.vendor.service;
import java.net.HttpURLConnection; import java.net.HttpURLConnection;
import java.net.URL; import java.net.URL;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.Statement; import java.sql.Statement;
import java.time.LocalDate; import java.time.LocalDate;
@ -235,21 +237,35 @@ public class createventService {
private String sendWhatsappMsg(String mob_no, String status, String vendor_req_number) { private String sendWhatsappMsg(String mob_no, String status, String vendor_req_number) {
String urlString = ""; String urlString = "";
if ("Approved".equals(status)) {
urlString = "https://media.smsgupshup.com/GatewayAPI/rest?userid=2000233507&password=h2YjFNcJ&send_to="
+ mob_no
+ "&v=1.1&format=json&msg_type=TEXT&method=SENDMESSAGE&msg=You+are+recognized+as+a+roadside+vendor.+Registration+number%3A+"
+ vendor_req_number + ".&isTemplate=true&footer=GCC+-+IT+Cell";
} else {
urlString = "https://media.smsgupshup.com/GatewayAPI/rest?userid=2000233507&password=h2YjFNcJ&send_to="
+ mob_no
+ "&v=1.1&format=json&msg_type=TEXT&method=SENDMESSAGE&msg=Your+application+is+rejected+because+your+roadside+vendor+details+are+incorrect.+%0A%0ARegistration+Number%3A+"
+ vendor_req_number + ".";
try {
String placeholders =
URLEncoder.encode(
vendor_req_number,
StandardCharsets.UTF_8.toString());
String mobile =
URLEncoder.encode(
mob_no,
StandardCharsets.UTF_8.toString());
if ("Approved".equals(status)) {
urlString = "https://sendapiv1.pinbot.ai/pinwa/sendMessage?apikey=5c995535-6244-11f0-98fc-02c8a5e042bd&from=919445061913&to="+mobile+"&templateid=3636390&type=template&placeholders="+placeholders;
} else {
urlString = "https://sendapiv1.pinbot.ai/pinwa/sendMessage?apikey=5c995535-6244-11f0-98fc-02c8a5e042bd&from=919445061913&to="+mobile+"&templateid=3636392&type=template&placeholders="+placeholders;
}
String res = hitURL(urlString);
return res;
} catch (Exception e) {
e.printStackTrace();
return "";
} }
String res = hitURL(urlString);
return res;
} }
private String hitURL(String urlString) { private String hitURL(String urlString) {
@ -513,12 +529,17 @@ public class createventService {
* ============================================================ * ============================================================
*/ */
if ("Approved".equalsIgnoreCase(status)) { if ("Approved".equalsIgnoreCase(status)) {
Integer expiryYears = jdbcTemplate.queryForObject(
"SELECT idcard_expire_year FROM info_details WHERE isactive = 1 AND isdelete=0 LIMIT 1",
Integer.class
);
String uidNo = zone + "_" + ward + "_" + currentYear + "_" + generatedId; String uidNo = zone + "_" + ward + "_" + currentYear + "_" + generatedId;
jdbcTemplate.update( jdbcTemplate.update(
"UPDATE vendor_request_list SET uid_no=? WHERE id=?",
uidNo, generatedId);
"UPDATE vendor_request_list SET uid_no=?,expire_date = DATE_ADD(CURDATE(), INTERVAL ? YEAR) WHERE id=?",
uidNo,expiryYears, generatedId);
} }
/* /*
@ -817,12 +838,7 @@ public class createventService {
} }
public boolean giveCertificate(Integer vdid,
String zone,
String ward,
String street_id,
String street_name,
String cby) {
public boolean giveCertificate(Integer vdid,String zone,String ward, String street_id,String street_name,String cby,String mob_no,String vendor_req_id) {
Integer expiryYears = jdbcTemplate.queryForObject( Integer expiryYears = jdbcTemplate.queryForObject(
"SELECT certificate_expire_year FROM info_details WHERE isactive = 1 AND isdelete=0 LIMIT 1", "SELECT certificate_expire_year FROM info_details WHERE isactive = 1 AND isdelete=0 LIMIT 1",
@ -837,18 +853,25 @@ public class createventService {
try { try {
int rows = jdbcTemplate.update(
sql,
vdid,
zone,
ward,
street_id,
street_name,
cby,
expiryYears
);
return rows > 0;
int rows = jdbcTemplate.update(sql,vdid,zone,ward,street_id,street_name,cby,expiryYears);
if(rows > 0) {
String result=sendWhstsappMsgForCertificate(mob_no,vendor_req_id);
if(result.equals("200")) {
System.out.println(" Whatsapp Message Triggered "+vendor_req_id);
return true;
}
else {
System.out.println("Whatsapp Message Failed for "+vendor_req_id);
return true;
}
}
else {
return false;
}
//return rows > 0;
} catch (Exception e) { } catch (Exception e) {
@ -859,6 +882,40 @@ public class createventService {
} }
private String sendWhstsappMsgForCertificate(String mob_no, String vendor_req_id) {
String urlString = "";
try {
String placeholders =
URLEncoder.encode(
vendor_req_id,
StandardCharsets.UTF_8.toString());
// String buttonPlaceholder =
// URLEncoder.encode(
// complaintNumber+ "|~|" +complaintNumber,
// StandardCharsets.UTF_8.toString());
String mobile =
URLEncoder.encode(
mob_no,
StandardCharsets.UTF_8.toString());
urlString="https://sendapiv1.pinbot.ai/pinwa/sendMessage?apikey=5c995535-6244-11f0-98fc-02c8a5e042bd&from=919445061913&to="+mobile+"&templateid=3636407&type=template&placeholders="+placeholders+"&button_placeholder=https://gccservices.in/streetvendorlicense";
String res = hitURL(urlString);
return res;
} catch (Exception e) {
e.printStackTrace();
return "";
}
}
public List<Map<String, Object>> getapprovedcertificates(String zone, String ward, String street_id) { public List<Map<String, Object>> getapprovedcertificates(String zone, String ward, String street_id) {
StringBuilder sql = new StringBuilder( StringBuilder sql = new StringBuilder(

4
src/main/resources/templates/modules/vendors/certificate.html

@ -1326,7 +1326,9 @@
zone: zone, zone: zone,
ward: ward, ward: ward,
street_id: street_id, street_id: street_id,
street_name: street_name
street_name: street_name,
mob_no: details.mob_no,
vendor_req_id:details.vendor_req_id
}, },
success: function (response) { success: function (response) {
$('#certificate_btn').prop('disabled', false); $('#certificate_btn').prop('disabled', false);

Loading…
Cancel
Save