| Line 103... |
Line 103... |
| 103 |
if (sendNotificationModel.getUserIds() != null && sendNotificationModel.getUserIds().size() > 0) {
|
103 |
if (sendNotificationModel.getUserIds() != null && sendNotificationModel.getUserIds().size() > 0) {
|
| 104 |
userIds.addAll(sendNotificationModel.getUserIds());
|
104 |
userIds.addAll(sendNotificationModel.getUserIds());
|
| 105 |
}
|
105 |
}
|
| 106 |
|
106 |
|
| 107 |
if (sendNotificationModel.getStateIds() != null && sendNotificationModel.getStateIds().size() > 0) {
|
107 |
if (sendNotificationModel.getStateIds() != null && sendNotificationModel.getStateIds().size() > 0) {
|
| 108 |
userIds.addAll(fofoStoreRepository.selectByWarehouseIds(sendNotificationModel.getStateIds()).stream()
|
108 |
userIds.addAll(fofoStoreRepository.selectByWarehouseIds(sendNotificationModel.getStateIds()).stream().map(x -> x.getId()).collect(Collectors.toList()));
|
| 109 |
.map(x -> x.getId()).collect(Collectors.toList()));
|
- |
|
| 110 |
}
|
109 |
}
|
| 111 |
|
110 |
|
| 112 |
LOGGER.info("userIds" + userIds);
|
111 |
LOGGER.info("userIds" + userIds);
|
| 113 |
|
112 |
|
| 114 |
for (Integer userId : userIds) {
|
113 |
for (Integer userId : userIds) {
|
| Line 117... |
Line 116... |
| 117 |
uc.setUserId(userId);
|
116 |
uc.setUserId(userId);
|
| 118 |
uc.setPushTimestamp(LocalDateTime.now());
|
117 |
uc.setPushTimestamp(LocalDateTime.now());
|
| 119 |
userCampaignRepository.persist(uc);
|
118 |
userCampaignRepository.persist(uc);
|
| 120 |
}
|
119 |
}
|
| 121 |
|
120 |
|
| 122 |
List<Device> devices = deviceRepository.selectByUserIdAndModifiedTimestamp(new ArrayList<>(userIds),
|
121 |
List<Device> devices = deviceRepository.selectByUserIdAndModifiedTimestamp(new ArrayList<>(userIds), LocalDateTime.now().minusMonths(3), LocalDateTime.now());
|
| 123 |
LocalDateTime.now().minusMonths(3), LocalDateTime.now());
|
- |
|
| 124 |
|
122 |
|
| 125 |
LOGGER.info("devices" + devices);
|
123 |
LOGGER.info("devices" + devices);
|
| 126 |
pushNotification(nc.getId(), devices);
|
124 |
pushNotification(nc.getId(), devices);
|
| 127 |
|
125 |
|
| 128 |
}
|
126 |
}
|
| Line 135... |
Line 133... |
| 135 |
authUsers.addAll(csService.getAuthUserByCategoryId(ProfitMandiConstants.TICKET_CATEGORY_CATEGORY));
|
133 |
authUsers.addAll(csService.getAuthUserByCategoryId(ProfitMandiConstants.TICKET_CATEGORY_CATEGORY));
|
| 136 |
authUsers.addAll(csService.getAuthUserByCategoryId(ProfitMandiConstants.TICKET_CATEGORY_SALES));
|
134 |
authUsers.addAll(csService.getAuthUserByCategoryId(ProfitMandiConstants.TICKET_CATEGORY_SALES));
|
| 137 |
List<String> emailIds = authUsers.stream().map(x -> x.getEmailId()).collect(Collectors.toList());
|
135 |
List<String> emailIds = authUsers.stream().map(x -> x.getEmailId()).collect(Collectors.toList());
|
| 138 |
emailIds.add("devkinandan.lal@smartdukaan.com");
|
136 |
emailIds.add("devkinandan.lal@smartdukaan.com");
|
| 139 |
List<User> systemUsers = dtrUserRepository.selectAllByEmailIds(emailIds);
|
137 |
List<User> systemUsers = dtrUserRepository.selectAllByEmailIds(emailIds);
|
| 140 |
sendNotificationModel.getUserIds()
|
- |
|
| 141 |
.addAll(systemUsers.stream().map(x -> x.getId()).collect(Collectors.toList()));
|
138 |
sendNotificationModel.getUserIds().addAll(systemUsers.stream().map(x -> x.getId()).collect(Collectors.toList()));
|
| 142 |
this.sendNotification(sendNotificationModel);
|
139 |
this.sendNotification(sendNotificationModel);
|
| 143 |
}
|
140 |
}
|
| 144 |
|
141 |
|
| 145 |
@Override
|
142 |
@Override
|
| 146 |
public void sendNotification(int fofoId, String campaignName, MessageType messageType, String title, String message)
|
143 |
public void sendNotification(int fofoId, String campaignName, MessageType messageType, String title, String message) throws ProfitMandiBusinessException {
|
| 147 |
throws ProfitMandiBusinessException {
|
- |
|
| 148 |
SendNotificationModel sendNotificationModel = this.getDefaultNotificationModel();
|
144 |
SendNotificationModel sendNotificationModel = this.getDefaultNotificationModel();
|
| 149 |
sendNotificationModel.setCampaignName(campaignName);
|
145 |
sendNotificationModel.setCampaignName(campaignName);
|
| 150 |
sendNotificationModel.setMessageType(messageType);
|
146 |
sendNotificationModel.setMessageType(messageType);
|
| 151 |
sendNotificationModel.setTitle(title);
|
147 |
sendNotificationModel.setTitle(title);
|
| 152 |
sendNotificationModel.setMessage(message);
|
148 |
sendNotificationModel.setMessage(message);
|
| Line 176... |
Line 172... |
| 176 |
}
|
172 |
}
|
| 177 |
|
173 |
|
| 178 |
}
|
174 |
}
|
| 179 |
|
175 |
|
| 180 |
@Override
|
176 |
@Override
|
| 181 |
public void sendNotification(int fofoId, String campaignName, MessageType messageType, String title, String message,
|
177 |
public void sendNotification(int fofoId, String campaignName, MessageType messageType, String title, String message, String url) throws ProfitMandiBusinessException {
|
| 182 |
String url) throws ProfitMandiBusinessException {
|
- |
|
| 183 |
SendNotificationModel sendNotificationModel = this.getDefaultNotificationModel();
|
178 |
SendNotificationModel sendNotificationModel = this.getDefaultNotificationModel();
|
| 184 |
sendNotificationModel.setCampaignName(campaignName);
|
179 |
sendNotificationModel.setCampaignName(campaignName);
|
| 185 |
sendNotificationModel.setMessageType(messageType);
|
180 |
sendNotificationModel.setMessageType(messageType);
|
| 186 |
sendNotificationModel.setTitle(title);
|
181 |
sendNotificationModel.setTitle(title);
|
| 187 |
sendNotificationModel.setMessage(message);
|
182 |
sendNotificationModel.setMessage(message);
|
| Line 191... |
Line 186... |
| 191 |
sendNotificationModel.setUrl(url);
|
186 |
sendNotificationModel.setUrl(url);
|
| 192 |
this.sendNotification(sendNotificationModel);
|
187 |
this.sendNotification(sendNotificationModel);
|
| 193 |
}
|
188 |
}
|
| 194 |
|
189 |
|
| 195 |
@Override
|
190 |
@Override
|
| 196 |
public void sendWhatsappMessage(String message, String title, String mobile)
|
191 |
public void sendWhatsappMessage(String message, String title, String mobile) throws Exception {
|
| 197 |
throws Exception {
|
- |
|
| 198 |
this.sendWhatsappMessage(message, title, mobile, null, null);
|
192 |
this.sendWhatsappMessage(message, title, mobile, null, null);
|
| 199 |
}
|
193 |
}
|
| 200 |
|
194 |
|
| 201 |
@Override
|
195 |
@Override
|
| 202 |
public void sendWhatsappMediaMessage(String message, String mobile, String mediaUrl, String fileName)
|
196 |
public void sendWhatsappMediaMessage(String message, String mobile, String mediaUrl, String fileName) throws Exception {
|
| 203 |
throws Exception {
|
- |
|
| 204 |
this.sendWhatsappMessage(message, null, mobile, mediaUrl, fileName);
|
197 |
this.sendWhatsappMessage(message, null, mobile, mediaUrl, fileName);
|
| 205 |
}
|
198 |
}
|
| 206 |
|
199 |
|
| 207 |
@Override
|
200 |
@Override
|
| 208 |
public void optIn(String phoneNumber) throws Exception {
|
201 |
public void optIn(String phoneNumber) throws Exception {
|
| Line 221... |
Line 214... |
| 221 |
requestParams.put("channel", "WHATSAPP");
|
214 |
requestParams.put("channel", "WHATSAPP");
|
| 222 |
String response = restClient.get("https://media.smsgupshup.com/GatewayAPI/rest", requestParams, requestheaders);
|
215 |
String response = restClient.get("https://media.smsgupshup.com/GatewayAPI/rest", requestParams, requestheaders);
|
| 223 |
LOGGER.info("response" + response);
|
216 |
LOGGER.info("response" + response);
|
| 224 |
}
|
217 |
}
|
| 225 |
|
218 |
|
| 226 |
private void sendWhatsappMessage(String message, String title, String mobile, String mediaUrl, String fileName)
|
219 |
private void sendWhatsappMessage(String message, String title, String mobile, String mediaUrl, String fileName) throws Exception {
|
| 227 |
throws Exception {
|
- |
|
| 228 |
String sendTo = null;
|
220 |
String sendTo = null;
|
| 229 |
if (mobile.length() != 10) {
|
221 |
if (mobile.length() != 10) {
|
| 230 |
return;
|
222 |
return;
|
| 231 |
} else {
|
223 |
} else {
|
| 232 |
sendTo = 91 + mobile;
|
224 |
sendTo = 91 + mobile;
|
| Line 239... |
Line 231... |
| 239 |
requestParams.put("send_to", sendTo);
|
231 |
requestParams.put("send_to", sendTo);
|
| 240 |
requestParams.put("v", "1.1");
|
232 |
requestParams.put("v", "1.1");
|
| 241 |
requestParams.put("format", "json");
|
233 |
requestParams.put("format", "json");
|
| 242 |
requestParams.put("auth_scheme", "plain");
|
234 |
requestParams.put("auth_scheme", "plain");
|
| 243 |
if (mediaUrl == null) {
|
235 |
if (mediaUrl == null) {
|
| 244 |
requestParams.put("method", "SENDMESSAGE");
|
236 |
requestParams.put("method", "SENDMESSAGE");
|
| 245 |
/*requestParams.put("msg_type", "HSM");
|
237 |
/*requestParams.put("msg_type", "HSM");
|
| 246 |
requestParams.put("msg", message);
|
238 |
requestParams.put("msg", message);
|
| 247 |
requestParams.put("isTemplate", "true");
|
239 |
requestParams.put("isTemplate", "true");
|
| 248 |
requestParams.put("header", title);*/
|
240 |
requestParams.put("header", title);*/
|
| 249 |
//} else if(isProd && mediaUrl !=null) {
|
241 |
//} else if(isProd && mediaUrl !=null) {
|
| Line 263... |
Line 255... |
| 263 |
requestParams.put("msg_type", "DOCUMENT");
|
255 |
requestParams.put("msg_type", "DOCUMENT");
|
| 264 |
requestParams.put("caption", message);
|
256 |
requestParams.put("caption", message);
|
| 265 |
//requestParams.put("msg", message);
|
257 |
//requestParams.put("msg", message);
|
| 266 |
requestParams.put("media_url", mediaUrl);
|
258 |
requestParams.put("media_url", mediaUrl);
|
| 267 |
requestParams.put("filename", fileName);
|
259 |
requestParams.put("filename", fileName);
|
| 268 |
String response =
|
- |
|
| 269 |
restClient.post("https://media.smsgupshup.com/GatewayAPI/rest",
|
260 |
String response = restClient.post("https://media.smsgupshup.com/GatewayAPI/rest", requestParams, requestheaders);
|
| 270 |
requestParams,
|
- |
|
| 271 |
requestheaders);
|
- |
|
| 272 |
LOGGER.info("response" + response);
|
261 |
LOGGER.info("response" + response);
|
| 273 |
|
- |
|
| 274 |
JSONObject jsonObject = new JSONObject(response);
|
- |
|
| 275 |
|
262 |
|
| - |
|
263 |
JSONObject jsonObject = new JSONObject(response);
|
| 276 |
LOGGER.info("jsonObject" + jsonObject);
|
264 |
LOGGER.info("jsonObject" + jsonObject);
|
| - |
|
265 |
|
| - |
|
266 |
JSONObject jo = (JSONObject) jsonObject.get("response");
|
| - |
|
267 |
LOGGER.info("jo" + jo);
|
| - |
|
268 |
|
| - |
|
269 |
String externalId = jo.getString("id");
|
| - |
|
270 |
LOGGER.info("externalId" + externalId);
|
| - |
|
271 |
|
| - |
|
272 |
|
| 277 |
}
|
273 |
}
|
| 278 |
|
274 |
|
| 279 |
}
|
275 |
}
|
| 280 |
|
276 |
|
| 281 |
|
277 |
|