| Line 1316... |
Line 1316... |
| 1316 |
public void sendDailySalesNotificationToPartner(Integer fofoIdInt)
|
1316 |
public void sendDailySalesNotificationToPartner(Integer fofoIdInt)
|
| 1317 |
throws ProfitMandiBusinessException, MessagingException, IOException {
|
1317 |
throws ProfitMandiBusinessException, MessagingException, IOException {
|
| 1318 |
|
1318 |
|
| 1319 |
LocalDateTime now = LocalDateTime.now();
|
1319 |
LocalDateTime now = LocalDateTime.now();
|
| 1320 |
LocalDateTime from = now.with(LocalTime.MIN);
|
1320 |
LocalDateTime from = now.with(LocalTime.MIN);
|
| - |
|
1321 |
String timeString = "Today {}";
|
| 1321 |
//Send yesterday's report
|
1322 |
//Send yesterday's report
|
| 1322 |
if(now.getHour() < 12) {
|
1323 |
if(now.getHour() < 12) {
|
| - |
|
1324 |
timeString = "Yesterday {}";
|
| 1323 |
from = now.minusDays(1);
|
1325 |
from = now.minusDays(1);
|
| 1324 |
now = from.with(LocalTime.MAX);
|
1326 |
now = from.with(LocalTime.MAX);
|
| 1325 |
|
1327 |
|
| 1326 |
}
|
1328 |
}
|
| 1327 |
List<Integer> fofoIds = null;
|
1329 |
List<Integer> fofoIds = null;
|
| Line 1329... |
Line 1331... |
| 1329 |
fofoIds = fofoStoreRepository.selectAll().stream().filter(x -> x.isActive()).map(x -> x.getId())
|
1331 |
fofoIds = fofoStoreRepository.selectAll().stream().filter(x -> x.isActive()).map(x -> x.getId())
|
| 1330 |
.collect(Collectors.toList());
|
1332 |
.collect(Collectors.toList());
|
| 1331 |
} else {
|
1333 |
} else {
|
| 1332 |
fofoIds = Arrays.asList(fofoIdInt);
|
1334 |
fofoIds = Arrays.asList(fofoIdInt);
|
| 1333 |
}
|
1335 |
}
|
| 1334 |
DateTimeFormatter timeFormatter = DateTimeFormatter.ofPattern("h a");
|
1336 |
DateTimeFormatter timeFormatter = DateTimeFormatter.ofPattern("h:m a");
|
| 1335 |
|
1337 |
|
| 1336 |
Map<Integer, Double> salesByFofoIdMap = new HashMap<>();
|
1338 |
Map<Integer, Double> salesByFofoIdMap = new HashMap<>();
|
| 1337 |
Map<Integer, Float> partnerPolicyAmountMap = insurancePolicyRepository.selectAmountSumGroupByRetailerId(now,
|
1339 |
Map<Integer, Float> partnerPolicyAmountMap = insurancePolicyRepository.selectAmountSumGroupByRetailerId(now,
|
| 1338 |
null);
|
1340 |
null);
|
| 1339 |
Map<Integer, Long> partnerPolicyQtyMap = insurancePolicyRepository.selectQtyGroupByRetailerId(now, null);
|
1341 |
Map<Integer, Long> partnerPolicyQtyMap = insurancePolicyRepository.selectQtyGroupByRetailerId(now, null);
|
| Line 1358... |
Line 1360... |
| 1358 |
SendNotificationModel sendNotificationModel = new SendNotificationModel();
|
1360 |
SendNotificationModel sendNotificationModel = new SendNotificationModel();
|
| 1359 |
sendNotificationModel.setCampaignName("Sales update alert");
|
1361 |
sendNotificationModel.setCampaignName("Sales update alert");
|
| 1360 |
sendNotificationModel.setTitle("Sale Update");
|
1362 |
sendNotificationModel.setTitle("Sale Update");
|
| 1361 |
sendNotificationModel.setMessage(String.format(
|
1363 |
sendNotificationModel.setMessage(String.format(
|
| 1362 |
"Smartphones Rs.%.0f, Insurance Rs.%.0f, Total Rs.%.0f till %s.", model.getSmartphoneSale(),
|
1364 |
"Smartphones Rs.%.0f, Insurance Rs.%.0f, Total Rs.%.0f till %s.", model.getSmartphoneSale(),
|
| 1363 |
model.getInsuranceSale(), model.getTotalSale(), now.format(timeFormatter)));
|
1365 |
model.getInsuranceSale(), model.getTotalSale(), String.format(timeString, now.format(timeFormatter))));
|
| 1364 |
sendNotificationModel.setType("url");
|
1366 |
sendNotificationModel.setType("url");
|
| 1365 |
sendNotificationModel.setUrl("http://app.profitmandi.com/pages/home/notifications");
|
1367 |
sendNotificationModel.setUrl("http://app.profitmandi.com/pages/home/notifications");
|
| 1366 |
sendNotificationModel.setExpiresat(LocalDateTime.now().plusDays(1));
|
1368 |
sendNotificationModel.setExpiresat(LocalDateTime.now().plusDays(1));
|
| 1367 |
sendNotificationModel.setMessageType(MessageType.notification);
|
1369 |
sendNotificationModel.setMessageType(MessageType.notification);
|
| 1368 |
int userId = userAccountRepository.selectUserIdByRetailerId(fofoId);
|
1370 |
int userId = userAccountRepository.selectUserIdByRetailerId(fofoId);
|
| Line 1372... |
Line 1374... |
| 1372 |
String saleReport = this.getDailySalesReportHtml(partnerSalesHeadersMap, saleTargetReportModelMap);
|
1374 |
String saleReport = this.getDailySalesReportHtml(partnerSalesHeadersMap, saleTargetReportModelMap);
|
| 1373 |
LOGGER.info(saleReport);
|
1375 |
LOGGER.info(saleReport);
|
| 1374 |
String cc[] = { "tarun.verma@smartdukaan.com", "kamini.sharma@smartdukaan.com", "prakash.rai@smartdukaan.com",
|
1376 |
String cc[] = { "tarun.verma@smartdukaan.com", "kamini.sharma@smartdukaan.com", "prakash.rai@smartdukaan.com",
|
| 1375 |
"chaitnaya.vats@smartdukaan.com" };
|
1377 |
"chaitnaya.vats@smartdukaan.com" };
|
| 1376 |
|
1378 |
|
| 1377 |
String subject = String.format("Sale till %s", now.format(timeFormatter));
|
1379 |
String subject = String.format("Sale till %s", String.format(timeString, now.format(timeFormatter)));
|
| 1378 |
this.sendMailOfHtmlFomat("amit.gupta@shop2020.in", saleReport, cc, subject);
|
1380 |
this.sendMailOfHtmlFomat("amit.gupta@shop2020.in", saleReport, cc, subject);
|
| 1379 |
}
|
1381 |
}
|
| 1380 |
|
1382 |
|
| 1381 |
public static class SaleTargetReportModel {
|
1383 |
public static class SaleTargetReportModel {
|
| 1382 |
private double totalSale;
|
1384 |
private double totalSale;
|