From d61cce16b8c4fd903fea9788b441e2865ab6f758 Mon Sep 17 00:00:00 2001 From: Hariprasath S <113695067+Hariprasath4022@users.noreply.github.com> Date: Fri, 7 Aug 2026 17:36:04 +0530 Subject: [PATCH] Changes in Street Vendor Whatsapp message API --- .../controller/CreateEventAPIController.java | 12 +- .../vendor/service/createventService.java | 125 +++++++++++++----- .../modules/vendors/certificate.html | 4 +- 3 files changed, 98 insertions(+), 43 deletions(-) diff --git a/src/main/java/in/gov/chennaicorporation/gccoffice/vendor/controller/CreateEventAPIController.java b/src/main/java/in/gov/chennaicorporation/gccoffice/vendor/controller/CreateEventAPIController.java index 315f262..83114a7 100644 --- a/src/main/java/in/gov/chennaicorporation/gccoffice/vendor/controller/CreateEventAPIController.java +++ b/src/main/java/in/gov/chennaicorporation/gccoffice/vendor/controller/CreateEventAPIController.java @@ -235,19 +235,15 @@ public class CreateEventAPIController { @RequestParam String ward, @RequestParam String street_id, @RequestParam String street_name, - @RequestParam String cby) { + @RequestParam String cby, + @RequestParam String mob_no, + @RequestParam String vendor_req_id) { Map response = new HashMap<>(); 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) { diff --git a/src/main/java/in/gov/chennaicorporation/gccoffice/vendor/service/createventService.java b/src/main/java/in/gov/chennaicorporation/gccoffice/vendor/service/createventService.java index 0a35699..d4afb26 100644 --- a/src/main/java/in/gov/chennaicorporation/gccoffice/vendor/service/createventService.java +++ b/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.URL; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; import java.sql.PreparedStatement; import java.sql.Statement; import java.time.LocalDate; @@ -235,21 +237,35 @@ public class createventService { private String sendWhatsappMsg(String mob_no, String status, String vendor_req_number) { 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) { @@ -513,12 +529,17 @@ public class createventService { * ============================================================ */ 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; 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( "SELECT certificate_expire_year FROM info_details WHERE isactive = 1 AND isdelete=0 LIMIT 1", @@ -837,18 +853,25 @@ public class createventService { 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) { @@ -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> getapprovedcertificates(String zone, String ward, String street_id) { StringBuilder sql = new StringBuilder( diff --git a/src/main/resources/templates/modules/vendors/certificate.html b/src/main/resources/templates/modules/vendors/certificate.html index 3b0e933..637c3b4 100644 --- a/src/main/resources/templates/modules/vendors/certificate.html +++ b/src/main/resources/templates/modules/vendors/certificate.html @@ -1326,7 +1326,9 @@ zone: zone, ward: ward, 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) { $('#certificate_btn').prop('disabled', false);