| Line 3732... |
Line 3732... |
| 3732 |
String[] emailTo = authUserEmail.toArray(new String[authUserEmail.size()]);
|
3732 |
String[] emailTo = authUserEmail.toArray(new String[authUserEmail.size()]);
|
| 3733 |
|
3733 |
|
| 3734 |
String[] ccTo = { "tarun.verma@smartdukaan.com", "kamini.sharma@smartdukaan.com" };
|
3734 |
String[] ccTo = { "tarun.verma@smartdukaan.com", "kamini.sharma@smartdukaan.com" };
|
| 3735 |
|
3735 |
|
| 3736 |
String subject = "Dispatched " + (orders.get(0).getRetailerName());
|
3736 |
String subject = "Dispatched " + (orders.get(0).getRetailerName());
|
| 3737 |
String message = String.format("Dear Team, \n" + "kindly note the meterial for the "
|
3737 |
String message = String.format("Dear Team, \n" + "kindly note the material for the "
|
| 3738 |
+ orders.get(0).getRetailerName() + "of Rs." + totalAmount + "is dispatched.");
|
3738 |
+ orders.get(0).getRetailerName() + "of Rs." + totalAmount + "is dispatched.");
|
| 3739 |
|
3739 |
|
| 3740 |
Utils.sendMailWithAttachments(mailSender, emailTo, ccTo, subject, message);
|
3740 |
Utils.sendMailWithAttachments(mailSender, emailTo, ccTo, subject, message);
|
| 3741 |
|
3741 |
|
| 3742 |
}
|
3742 |
}
|
| Line 3913... |
Line 3913... |
| 3913 |
|
3913 |
|
| 3914 |
public void sendDefaultLoanAlert(List<Loan> defaultLoans)
|
3914 |
public void sendDefaultLoanAlert(List<Loan> defaultLoans)
|
| 3915 |
throws ProfitMandiBusinessException, MessagingException, IOException {
|
3915 |
throws ProfitMandiBusinessException, MessagingException, IOException {
|
| 3916 |
String subject = "Default Partners";
|
3916 |
String subject = "Default Partners";
|
| 3917 |
|
3917 |
|
| - |
|
3918 |
List<Integer> categoryIds = Arrays.asList(ProfitMandiConstants.TICKET_CATEGORY_CATEGORY,
|
| - |
|
3919 |
ProfitMandiConstants.TICKET_CATEGORY_RBM, ProfitMandiConstants.TICKET_CATEGORY_SALES,
|
| 3918 |
List<AuthUser> authUsers = csService
|
3920 |
ProfitMandiConstants.TICKET_CATEGORY_ACCOUNTS,
|
| 3919 |
.getAuthUserByCategoryId(ProfitMandiConstants.TICKET_CATEGORY_FINANCIAL_SERVICES);
|
3921 |
ProfitMandiConstants.TICKET_CATEGORY_BUSINESSINTELLIGENT);
|
| 3920 |
|
3922 |
|
| 3921 |
authUsers.addAll(csService.getAuthUserByCategoryId(ProfitMandiConstants.TICKET_CATEGORY_ACCOUNTS));
|
- |
|
| 3922 |
if (!authUsers.isEmpty()) {
|
- |
|
| 3923 |
List<String> financeEmails = authUsers.stream().map(x -> x.getEmailId()).collect(Collectors.toList());
|
- |
|
| 3924 |
String messageText = this.getMessageForDueDateExtend(defaultLoans);
|
3923 |
for (Map.Entry<String, Set<Integer>> storeGuyEntry : csService
|
| 3925 |
|
- |
|
| 3926 |
String[] email = financeEmails.toArray(new String[financeEmails.size()]);
|
- |
|
| 3927 |
|
- |
|
| 3928 |
this.sendMailHtmlFormat(email, messageText, null, subject);
|
- |
|
| 3929 |
|
- |
|
| 3930 |
}
|
- |
|
| 3931 |
|
- |
|
| 3932 |
for (Map.Entry<String, Set<Integer>> storeGuyEntry : csService.getAuthUserPartnerIdMapping().entrySet()) {
|
3924 |
.getAuthUserPartnerIdMappingByCategoryIds(categoryIds).entrySet()) {
|
| 3933 |
List<Loan> filteredRows = new ArrayList<>();
|
3925 |
List<Loan> filteredRows = new ArrayList<>();
|
| 3934 |
for (Loan loan : defaultLoans) {
|
3926 |
for (Loan loan : defaultLoans) {
|
| 3935 |
|
3927 |
|
| 3936 |
if (storeGuyEntry.getValue().contains(loan.getFofoId())) {
|
3928 |
if (storeGuyEntry.getValue().contains(loan.getFofoId())) {
|
| 3937 |
|
3929 |
|
| Line 4421... |
Line 4413... |
| 4421 |
sb.append("</tbody></table></body></html>");
|
4413 |
sb.append("</tbody></table></body></html>");
|
| 4422 |
|
4414 |
|
| 4423 |
return sb.toString();
|
4415 |
return sb.toString();
|
| 4424 |
}
|
4416 |
}
|
| 4425 |
|
4417 |
|
| - |
|
4418 |
@Autowired
|
| - |
|
4419 |
private MonthlyTargetRepository monthlyTargetRepository;
|
| - |
|
4420 |
|
| - |
|
4421 |
public void monthlyTargetForPartner() throws MessagingException, ProfitMandiBusinessException, IOException {
|
| - |
|
4422 |
|
| - |
|
4423 |
LocalDateTime curDate = LocalDateTime.now();
|
| - |
|
4424 |
List<MonthlyTarget> monthlyTargets = monthlyTargetRepository.selectByDate(YearMonth.now());
|
| - |
|
4425 |
|
| - |
|
4426 |
Map<Integer, MonthlyTarget> partnersMonthlyTarget = monthlyTargets.stream()
|
| - |
|
4427 |
.collect(Collectors.toMap(x -> x.getFofoId(), x -> x));
|
| - |
|
4428 |
|
| - |
|
4429 |
Map<Integer, Double> secondaryMtd = orderRepository
|
| - |
|
4430 |
.selectBillingDatesBetweenSumGroupByRetailerId(curDate.withDayOfMonth(1), curDate.with(LocalTime.MAX));
|
| - |
|
4431 |
Map<Integer, Double> todaytertiary = fofoOrderItemRepository.selectSumMopGroupByRetailer(curDate,
|
| - |
|
4432 |
curDate.with(LocalTime.MAX), 0, false);
|
| - |
|
4433 |
|
| - |
|
4434 |
String subject = "";
|
| - |
|
4435 |
|
| - |
|
4436 |
for (Entry<Integer, MonthlyTarget> partnerMonthlyTargetEntry : partnersMonthlyTarget.entrySet()) {
|
| - |
|
4437 |
|
| - |
|
4438 |
int fofoId = partnerMonthlyTargetEntry.getKey();
|
| - |
|
4439 |
|
| - |
|
4440 |
CustomRetailer customRetailer = retailerService.getFofoRetailer(fofoId);
|
| - |
|
4441 |
|
| - |
|
4442 |
Double purchaseTarget = partnerMonthlyTargetEntry.getValue().getPurchaseTarget();
|
| - |
|
4443 |
|
| - |
|
4444 |
Double saleTarget = partnerMonthlyTargetEntry.getValue().getSaleTarget();
|
| - |
|
4445 |
|
| - |
|
4446 |
if (purchaseTarget > 0) {
|
| - |
|
4447 |
Double purchase = secondaryMtd.get(fofoId);
|
| - |
|
4448 |
|
| - |
|
4449 |
StringBuilder sb = new StringBuilder();
|
| - |
|
4450 |
sb.append("<html><body><p>Hi,");
|
| - |
|
4451 |
|
| - |
|
4452 |
this.sendMailOfHtmlFormat(customRetailer.getEmail(), sb.toString(), null, subject);
|
| - |
|
4453 |
|
| - |
|
4454 |
}
|
| - |
|
4455 |
|
| - |
|
4456 |
}
|
| - |
|
4457 |
|
| - |
|
4458 |
}
|
| - |
|
4459 |
|
| - |
|
4460 |
public void monthlyTargetForInternalTeam() throws MessagingException, ProfitMandiBusinessException, IOException {
|
| - |
|
4461 |
|
| - |
|
4462 |
LocalDateTime curDate = LocalDateTime.now();
|
| - |
|
4463 |
|
| - |
|
4464 |
List<Integer> categoryIds = Arrays.asList(ProfitMandiConstants.TICKET_CATEGORY_CATEGORY,
|
| - |
|
4465 |
ProfitMandiConstants.TICKET_CATEGORY_RBM, ProfitMandiConstants.TICKET_CATEGORY_SALES,
|
| - |
|
4466 |
ProfitMandiConstants.TICKET_CATEGORY_MARKETING, ProfitMandiConstants.TICKET_CATEGORY_ACCOUNTS,
|
| - |
|
4467 |
ProfitMandiConstants.TICKET_CATEGORY_BUSINESSINTELLIGENT);
|
| - |
|
4468 |
|
| - |
|
4469 |
Map<String, Set<Integer>> storeGuyMap = csService.getAuthUserPartnerIdMappingByCategoryIds(categoryIds);
|
| - |
|
4470 |
|
| - |
|
4471 |
List<MonthlyTarget> monthlyTargets = monthlyTargetRepository.selectByDate(YearMonth.now());
|
| - |
|
4472 |
|
| - |
|
4473 |
Map<Integer, CustomRetailer> customeRetailerMap = retailerService.getAllFofoRetailers();
|
| - |
|
4474 |
|
| - |
|
4475 |
Map<Integer, MonthlyTarget> partnersMonthlyTarget = monthlyTargets.stream()
|
| - |
|
4476 |
.collect(Collectors.toMap(x -> x.getFofoId(), x -> x));
|
| - |
|
4477 |
|
| - |
|
4478 |
Map<Integer, Double> secondaryMtd = orderRepository
|
| - |
|
4479 |
.selectBillingDatesBetweenSumGroupByRetailerId(curDate.withDayOfMonth(1), curDate.with(LocalTime.MAX));
|
| - |
|
4480 |
Map<Integer, Double> todaytertiary = fofoOrderItemRepository.selectSumMopGroupByRetailer(curDate,
|
| - |
|
4481 |
curDate.with(LocalTime.MAX), 0, false);
|
| - |
|
4482 |
|
| - |
|
4483 |
String subject = "";
|
| - |
|
4484 |
|
| - |
|
4485 |
for (Entry<String, Set<Integer>> storeGuyEntry : storeGuyMap.entrySet()) {
|
| - |
|
4486 |
|
| - |
|
4487 |
String email = storeGuyEntry.getKey();
|
| - |
|
4488 |
|
| - |
|
4489 |
List<Integer> fofoIds = new ArrayList<>(storeGuyEntry.getValue());
|
| - |
|
4490 |
Map<Integer, MonthlyTarget> monthlyTargetAchievement = new HashMap<>();
|
| - |
|
4491 |
for (Integer fofoId : fofoIds) {
|
| - |
|
4492 |
|
| - |
|
4493 |
MonthlyTarget monthlyTarget = partnersMonthlyTarget.get(fofoId);
|
| - |
|
4494 |
Double purchaseTarget = monthlyTarget.getPurchaseTarget();
|
| - |
|
4495 |
|
| - |
|
4496 |
Double saleTarget = monthlyTarget.getSaleTarget();
|
| - |
|
4497 |
|
| - |
|
4498 |
if (purchaseTarget > 0) {
|
| - |
|
4499 |
Double purchase = secondaryMtd.get(fofoId);
|
| - |
|
4500 |
monthlyTarget.setPurchaseAchievement(purchase);
|
| - |
|
4501 |
monthlyTargetAchievement.put(fofoId, monthlyTarget);
|
| - |
|
4502 |
|
| - |
|
4503 |
}
|
| - |
|
4504 |
}
|
| - |
|
4505 |
|
| - |
|
4506 |
if (!monthlyTargetAchievement.isEmpty()) {
|
| - |
|
4507 |
|
| - |
|
4508 |
StringBuilder sb = new StringBuilder();
|
| - |
|
4509 |
|
| - |
|
4510 |
sb.append("<html><body><p>Hi,\n" + "<table style='border:1px solid black ;padding: 5px';>");
|
| - |
|
4511 |
sb.append("<tbody>\n" + " " + " " + "<tr>\n");
|
| - |
|
4512 |
sb.append("<th style='border:1px solid black;padding: 5px'>Partner Name</th>\n");
|
| - |
|
4513 |
|
| - |
|
4514 |
sb.append("<th style='border:1px solid black;padding: 5px'>Purchase Target</th>\n");
|
| - |
|
4515 |
|
| - |
|
4516 |
sb.append("<th style='border:1px solid black;padding: 5px'>Purchase Achievement</th>\n");
|
| - |
|
4517 |
sb.append("</tr>\n");
|
| - |
|
4518 |
|
| - |
|
4519 |
for (Entry<Integer, MonthlyTarget> monthlyTargetAchievementEntry : monthlyTargetAchievement
|
| - |
|
4520 |
.entrySet()) {
|
| - |
|
4521 |
sb.append("<tr>");
|
| - |
|
4522 |
int fofoId = monthlyTargetAchievementEntry.getKey();
|
| - |
|
4523 |
|
| - |
|
4524 |
MonthlyTarget monthlyTarget = monthlyTargetAchievementEntry.getValue();
|
| - |
|
4525 |
sb.append("<td style='border:1px solid black;padding: 5px'>"
|
| - |
|
4526 |
+ customeRetailerMap.get(fofoId).getBusinessName() + "</td>\n");
|
| - |
|
4527 |
|
| - |
|
4528 |
sb.append("<td style='border:1px solid black;padding: 5px'>" + monthlyTarget.getPurchaseTarget()
|
| - |
|
4529 |
+ "</td>\n");
|
| - |
|
4530 |
|
| - |
|
4531 |
sb.append("<td style='border:1px solid black;padding: 5px'>"
|
| - |
|
4532 |
+ monthlyTarget.getPurchaseAchievement() + "</td>\n");
|
| - |
|
4533 |
|
| - |
|
4534 |
sb.append("</tr>\n");
|
| - |
|
4535 |
|
| - |
|
4536 |
}
|
| - |
|
4537 |
|
| - |
|
4538 |
this.sendMailOfHtmlFormat(email, sb.toString(), null, subject);
|
| - |
|
4539 |
|
| - |
|
4540 |
}
|
| - |
|
4541 |
|
| - |
|
4542 |
}
|
| - |
|
4543 |
|
| - |
|
4544 |
}
|
| - |
|
4545 |
|
| 4426 |
}
|
4546 |
}
|
| 4427 |
// 2284'
|
4547 |
// 2284'
|
| 4428 |
|
4548 |
|