| Line 6... |
Line 6... |
| 6 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
6 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
| 7 |
import com.spice.profitmandi.common.model.SendNotificationModel;
|
7 |
import com.spice.profitmandi.common.model.SendNotificationModel;
|
| 8 |
import com.spice.profitmandi.common.web.client.RestClient;
|
8 |
import com.spice.profitmandi.common.web.client.RestClient;
|
| 9 |
import com.spice.profitmandi.dao.entity.auth.AuthUser;
|
9 |
import com.spice.profitmandi.dao.entity.auth.AuthUser;
|
| 10 |
import com.spice.profitmandi.dao.entity.dtr.*;
|
10 |
import com.spice.profitmandi.dao.entity.dtr.*;
|
| - |
|
11 |
import com.spice.profitmandi.dao.entity.fofo.Customer;
|
| 11 |
import com.spice.profitmandi.dao.entity.user.Device;
|
12 |
import com.spice.profitmandi.dao.entity.user.Device;
|
| 12 |
import com.spice.profitmandi.dao.entity.whatsapp.WhatsappMessage;
|
13 |
import com.spice.profitmandi.dao.entity.whatsapp.WhatsappMessage;
|
| 13 |
import com.spice.profitmandi.dao.model.SimpleCampaign;
|
14 |
import com.spice.profitmandi.dao.model.SimpleCampaign;
|
| 14 |
import com.spice.profitmandi.dao.model.SimpleCampaignParams;
|
15 |
import com.spice.profitmandi.dao.model.SimpleCampaignParams;
|
| 15 |
import com.spice.profitmandi.dao.repository.catalog.DeviceRepository;
|
16 |
import com.spice.profitmandi.dao.repository.catalog.DeviceRepository;
|
| 16 |
import com.spice.profitmandi.dao.repository.cs.CsService;
|
17 |
import com.spice.profitmandi.dao.repository.cs.CsService;
|
| 17 |
import com.spice.profitmandi.dao.repository.cs.PartnerRegionRepository;
|
18 |
import com.spice.profitmandi.dao.repository.cs.PartnerRegionRepository;
|
| 18 |
import com.spice.profitmandi.dao.repository.dtr.*;
|
19 |
import com.spice.profitmandi.dao.repository.dtr.*;
|
| - |
|
20 |
import com.spice.profitmandi.dao.repository.fofo.CustomerRepository;
|
| 19 |
import com.spice.profitmandi.dao.repository.whatsapp.WhatsappMessageRepository;
|
21 |
import com.spice.profitmandi.dao.repository.whatsapp.WhatsappMessageRepository;
|
| 20 |
import com.spice.profitmandi.service.user.RetailerService;
|
22 |
import com.spice.profitmandi.service.user.RetailerService;
|
| 21 |
import com.spice.profitmandi.service.whatsapp.WhatsappMessageService;
|
23 |
import com.spice.profitmandi.service.whatsapp.WhatsappMessageService;
|
| 22 |
import com.spice.profitmandi.service.whatsapp.WhatsappMessageType;
|
24 |
import com.spice.profitmandi.service.whatsapp.WhatsappMessageType;
|
| 23 |
import org.apache.logging.log4j.LogManager;
|
25 |
import org.apache.logging.log4j.LogManager;
|
| Line 65... |
Line 67... |
| 65 |
@Autowired
|
67 |
@Autowired
|
| 66 |
OptinRepository optinRepository;
|
68 |
OptinRepository optinRepository;
|
| 67 |
@Autowired
|
69 |
@Autowired
|
| 68 |
RetailerService retailerService;
|
70 |
RetailerService retailerService;
|
| 69 |
@Autowired
|
71 |
@Autowired
|
| - |
|
72 |
CustomerRepository customerRepository;
|
| - |
|
73 |
@Autowired
|
| 70 |
PushNotificationRepository pushNotificationRepository;
|
74 |
PushNotificationRepository pushNotificationRepository;
|
| 71 |
@Autowired
|
75 |
@Autowired
|
| 72 |
private Gson gson;
|
76 |
private Gson gson;
|
| 73 |
@Autowired
|
77 |
@Autowired
|
| 74 |
private RestClient restClient;
|
78 |
private RestClient restClient;
|
| Line 244... |
Line 248... |
| 244 |
this.sendWhatsappMessage(WhatsappMessageType.TEXT, message, title, mobile, null, null);
|
248 |
this.sendWhatsappMessage(WhatsappMessageType.TEXT, message, title, mobile, null, null);
|
| 245 |
}
|
249 |
}
|
| 246 |
}
|
250 |
}
|
| 247 |
|
251 |
|
| 248 |
@Override
|
252 |
@Override
|
| - |
|
253 |
public boolean sendWhatsappInvoice(int customerId, int fofoId, String invoiceNumber, String whatsAppNo) throws Exception {
|
| - |
|
254 |
boolean shouldSend = shouldSendWhatsappMessage(whatsAppNo);
|
| - |
|
255 |
if (!shouldSend) return false;
|
| - |
|
256 |
|
| - |
|
257 |
Customer customer = customerRepository.selectById(customerId);
|
| - |
|
258 |
String mobileNumber = (whatsAppNo != null && !whatsAppNo.isEmpty()) ? whatsAppNo : customer.getMobileNumber();
|
| - |
|
259 |
|
| - |
|
260 |
String message = "*SmartDukaan's One-Time Offer Unlocked!*\n" +
|
| - |
|
261 |
" Thank you for your purchase.\n" +
|
| - |
|
262 |
"\n" +
|
| - |
|
263 |
" Abhi-abhi naya phone liya hai...\n" +
|
| - |
|
264 |
" Par kya aapne uski poori suraksha li hai?\n" +
|
| - |
|
265 |
" SmartDukaan par sabse kam daam mein plans available hain:\n" +
|
| - |
|
266 |
"\n" +
|
| - |
|
267 |
" \uD83D\uDEE1\uFE0F*Complete Protection Plan* (Accidental & Liquid Damage) - Starting ₹199\n" +
|
| - |
|
268 |
"\n" +
|
| - |
|
269 |
" ⏳ *Extended 1 Year Warranty* - ₹199 se shuru\n" +
|
| - |
|
270 |
"\n" +
|
| - |
|
271 |
" Abhi store par iski jaankari lein.\n" +
|
| - |
|
272 |
"\n" +
|
| - |
|
273 |
" ⚠\uFE0F *Ye offer phone ki kharidari ke sirf 24 hours tak hi valid hai!*";
|
| - |
|
274 |
|
| - |
|
275 |
String mediaUrl = "https://partners.smartdukaan.com/wa-invoice-send/"
|
| - |
|
276 |
+ Base64.getMimeEncoder().encodeToString(invoiceNumber.getBytes(StandardCharsets.UTF_8)) + ".pdf";
|
| - |
|
277 |
String fileName = "INV-" + invoiceNumber.replace("/", "-") + ".pdf";
|
| - |
|
278 |
|
| - |
|
279 |
LOGGER.info("sendWhatsappInvoice: mobile={} mediaUrl={}", mobileNumber, mediaUrl);
|
| - |
|
280 |
return sendWhatsappMediaMessage(message, mobileNumber, mediaUrl, fileName, WhatsappMessageType.DOCUMENT);
|
| - |
|
281 |
}
|
| - |
|
282 |
|
| - |
|
283 |
@Override
|
| 249 |
public boolean sendWhatsappMediaMessage(String message, String mobile, String mediaUrl, String fileName, WhatsappMessageType whatsappMessageType) throws Exception {
|
284 |
public boolean sendWhatsappMediaMessage(String message, String mobile, String mediaUrl, String fileName, WhatsappMessageType whatsappMessageType) throws Exception {
|
| 250 |
boolean isSend=false;
|
285 |
boolean isSend=false;
|
| 251 |
if (isProd) {
|
286 |
// if (isProd) {
|
| 252 |
isSend=this.sendWhatsappMessage(whatsappMessageType, message, null, mobile, mediaUrl, fileName);
|
287 |
// isSend=this.sendWhatsappMessage(whatsappMessageType, message, null, mobile, mediaUrl, fileName);
|
| 253 |
}
|
288 |
// }
|
| - |
|
289 |
isSend = this.sendWhatsappMessage(whatsappMessageType, message, null, mobile, mediaUrl, fileName);
|
| 254 |
return isSend;
|
290 |
return isSend;
|
| 255 |
}
|
291 |
}
|
| 256 |
|
292 |
|
| 257 |
@Override
|
293 |
@Override
|
| 258 |
public void optIn(String phoneNumber) throws Exception {
|
294 |
public void optIn(String phoneNumber) throws Exception {
|