| Line 1... |
Line 1... |
| 1 |
package com.spice.profitmandi.dao.service;
|
1 |
package com.spice.profitmandi.dao.service;
|
| 2 |
|
2 |
|
| 3 |
import com.fasterxml.jackson.annotation.JsonProperty;
|
3 |
import com.fasterxml.jackson.annotation.JsonProperty;
|
| 4 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
4 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
| - |
|
5 |
import com.spice.profitmandi.common.util.Utils;
|
| 5 |
import com.spice.profitmandi.common.web.client.RestClient;
|
6 |
import com.spice.profitmandi.common.web.client.RestClient;
|
| 6 |
import com.spice.profitmandi.dao.entity.dtr.Otp;
|
7 |
import com.spice.profitmandi.dao.entity.dtr.Otp;
|
| 7 |
import com.spice.profitmandi.dao.entity.onBoarding.LoiForm;
|
8 |
import com.spice.profitmandi.dao.entity.onBoarding.LoiForm;
|
| 8 |
import com.spice.profitmandi.dao.enumuration.dtr.OtpType;
|
9 |
import com.spice.profitmandi.dao.enumuration.dtr.OtpType;
|
| 9 |
import com.spice.profitmandi.dao.repository.dtr.OtpRepository;
|
10 |
import com.spice.profitmandi.dao.repository.dtr.OtpRepository;
|
| Line 26... |
Line 27... |
| 26 |
|
27 |
|
| 27 |
public static final String SELF_CANCELLED_TEMPLATE = "Order Cancelled PO%s: Dear Customer, your order with SmartDukaan of %s has been cancelled on %s as per your request. Team SmartDukaan";
|
28 |
public static final String SELF_CANCELLED_TEMPLATE = "Order Cancelled PO%s: Dear Customer, your order with SmartDukaan of %s has been cancelled on %s as per your request. Team SmartDukaan";
|
| 28 |
public static final String SELF_CANCELLED_TEMPLATE_ID = "1507161943392646481";
|
29 |
public static final String SELF_CANCELLED_TEMPLATE_ID = "1507161943392646481";
|
| 29 |
public static final String TEMPLATE_ORDER_CREATED = "Order Placed PO%d: Dear Customer, your order with SmartDukaan of %s worth Rs.%.0f has been placed successfully. Our team will get in touch with you soon. Team SmartDukaan";
|
30 |
public static final String TEMPLATE_ORDER_CREATED = "Order Placed PO%d: Dear Customer, your order with SmartDukaan of %s worth Rs.%.0f has been placed successfully. Our team will get in touch with you soon. Team SmartDukaan";
|
| 30 |
public static final String TEMPLATE_ORDER_CREATED_ID = "1507162021138742118";
|
31 |
public static final String TEMPLATE_ORDER_CREATED_ID = "1507162021138742118";
|
| 31 |
public static final String LOI_ACCEPTANCE_OTP_TEMPLATE_ID = "1707171687739961361";
|
- |
|
| 32 |
public static final String DLT_PRINCIPLE_ENTITY_ID = "1501589330000013091";
|
- |
|
| 33 |
public static final String LOI_ACCEPTANCE_OTP_TEMPLATE = "Dear %s,\nThank you for showing your interest in the SmartDukaan franchise.\n%s is the OTP for your LOI acceptance.\nPlease read the LOI and provide your consent by sharing OTP with the SmartDukaan team.\nBest Regards,\nSmartDukaan Team.";
|
- |
|
| 34 |
private static final Logger LOGGER = LogManager.getLogger(OtpProcessor.class);
|
32 |
private static final Logger LOGGER = LogManager.getLogger(OtpProcessor.class);
|
| 35 |
private static final String SMS_GATEWAY = "http://sms.speqtrainnov.com/api/v4/?api_key=A7897cd4627a8781e176fd31710b057a9";
|
33 |
private static final String SMS_GATEWAY = "http://sms.speqtrainnov.com/api/v4/?api_key=A7897cd4627a8781e176fd31710b057a9";
|
| 36 |
private static final int len = 5;
|
34 |
private static final int len = 5;
|
| 37 |
private static final String SENDER = "SMTDKN";
|
35 |
private static final String SENDER = "SMTDKN";
|
| 38 |
private static final String numbers = "0123456789";
|
36 |
private static final String numbers = "0123456789";
|
| 39 |
private static final String OTP_TEMPLATE = "Dear Customer, %s is the OTP that you have requested to login into SmartDukaan. Don't share your OTP with anyone";
|
37 |
private static final String OTP_TEMPLATE = "Dear Customer, %s is the OTP that you have requested to login into SmartDukaan. Don't share your OTP with anyone";
|
| 40 |
private static final String OTP_TEMPLATE_ID = "1507161889822750240";
|
38 |
private static final String OTP_TEMPLATE_ID = "1507161889822750240";
|
| - |
|
39 |
//LOI OTP
|
| - |
|
40 |
public static final String LOI_ACCEPTANCE_OTP_TEMPLATE_ID = "1707171687739961361";
|
| - |
|
41 |
public static final String DLT_PRINCIPLE_ENTITY_ID = "1501589330000013091";
|
| 41 |
//TODO LOI OTP
|
42 |
public static final String LOI_ACCEPTANCE_OTP_TEMPLATE = "Dear %s,\nThank you for showing your interest in the SmartDukaan franchise.\n%s is the OTP for your LOI acceptance.\nPlease read the LOI and provide your consent by sharing OTP with the SmartDukaan team.\nBest Regards,\nSmartDukaan Team.";
|
| 42 |
private static final String USER = "smartdukaanOTP";
|
43 |
private static final String USER = "smartdukaanOTP";
|
| 43 |
private static final String PASS1 = "Amit@Smart123";
|
44 |
private static final String PASS = "Amit@Smart123";
|
| 44 |
private static String NEXG_API_ENDPOINT = "https://api2.nexgplatforms.com/sms/1/text/query";
|
45 |
private static String NEXG_API_ENDPOINT = "https://api2.nexgplatforms.com/sms/1/text/query";
|
| 45 |
|
46 |
|
| 46 |
@Autowired
|
47 |
@Autowired
|
| 47 |
OtpRepository otpRepository;
|
48 |
OtpRepository otpRepository;
|
| 48 |
|
49 |
|
| Line 171... |
Line 172... |
| 171 |
String otp = otp1.getOtp();
|
172 |
String otp = otp1.getOtp();
|
| 172 |
LoiForm pod = partnerOnBoardingDataRepository.selectByEmailOrMobile(otp1.getMobile());
|
173 |
LoiForm pod = partnerOnBoardingDataRepository.selectByEmailOrMobile(otp1.getMobile());
|
| 173 |
String ownerName = pod.getFirstName();
|
174 |
String ownerName = pod.getFirstName();
|
| 174 |
String message = String.format(LOI_ACCEPTANCE_OTP_TEMPLATE, ownerName, otp);
|
175 |
String message = String.format(LOI_ACCEPTANCE_OTP_TEMPLATE, ownerName, otp);
|
| 175 |
this.sendSms(LOI_ACCEPTANCE_OTP_TEMPLATE_ID, message, otp1.getMobile());
|
176 |
this.sendSms(LOI_ACCEPTANCE_OTP_TEMPLATE_ID, message, otp1.getMobile());
|
| - |
|
177 |
String emailTo[] = {pod.getEmail()};
|
| - |
|
178 |
String body = String.format(LOI_ACCEPTANCE_OTP_TEMPLATE, pod.getFirstName(), otp);
|
| - |
|
179 |
Utils.sendMailWithAttachments(mailSender, emailTo, null, "LOI ACCEPTANCE OTP", body);
|
| - |
|
180 |
|
| 176 |
}
|
181 |
}
|
| 177 |
|
182 |
|
| 178 |
public String sendSms(String dltTemplateId, String message, String mobileNumber) throws Exception {
|
183 |
public String sendSms(String dltTemplateId, String message, String mobileNumber) throws Exception {
|
| 179 |
Map<String, String> queryParams = new HashMap<>();
|
184 |
Map<String, String> queryParams = new HashMap<>();
|
| 180 |
queryParams.put("from", SENDER);
|
185 |
queryParams.put("from", SENDER);
|
| 181 |
queryParams.put("indiaDltContentTemplateId", dltTemplateId);
|
186 |
queryParams.put("indiaDltContentTemplateId", dltTemplateId);
|
| 182 |
queryParams.put("indiaDltPrincipalEntityId", DLT_PRINCIPLE_ENTITY_ID);
|
187 |
queryParams.put("indiaDltPrincipalEntityId", DLT_PRINCIPLE_ENTITY_ID);
|
| 183 |
queryParams.put("to", "91" + mobileNumber);
|
188 |
queryParams.put("to", "91" + mobileNumber);
|
| 184 |
queryParams.put("text", message);
|
189 |
queryParams.put("text", message);
|
| 185 |
queryParams.put("password", PASS1);
|
190 |
queryParams.put("password", PASS);
|
| 186 |
queryParams.put("username", USER);
|
191 |
queryParams.put("username", USER);
|
| 187 |
//OTP Message Template
|
192 |
//OTP Message Template
|
| 188 |
|
193 |
|
| 189 |
String response = restClient.post(NEXG_API_ENDPOINT, queryParams, new HashMap<>(), new HashMap<>());
|
194 |
String response = restClient.post(NEXG_API_ENDPOINT, queryParams, new HashMap<>(), new HashMap<>());
|
| 190 |
LOGGER.info(response);
|
195 |
LOGGER.info(response);
|