| Line 256... |
Line 256... |
| 256 |
private ServiceConfigRepository serviceConfigRepository;
|
256 |
private ServiceConfigRepository serviceConfigRepository;
|
| 257 |
|
257 |
|
| 258 |
@Value("${delhivery.tracking.token}")
|
258 |
@Value("${delhivery.tracking.token}")
|
| 259 |
private String token;
|
259 |
private String token;
|
| 260 |
|
260 |
|
| 261 |
private static final String[] STOCK_AGEING_MAIL_LIST = new String[]{"uday.singh@smartudkaan.com",
|
261 |
private static final String[] STOCK_AGEING_MAIL_LIST = new String[]{"uday.singh@smartudkaan.com", "mohinder.mutreja@smartdukaan.com", "ankit.bhatia@smartdukaan.com", "tarun.verma@smartdukaan.com", "kuldeep.kumar@smartdukaan.com", "manish.gupta@smartdukaan.com"};
|
| 262 |
"mohinder.mutreja@smartdukaan.com", "ankit.bhatia@smartdukaan.com", "tarun.verma@smartdukaan.com",
|
- |
|
| 263 |
"kuldeep.kumar@smartdukaan.com", "manish.gupta@smartdukaan.com"};
|
- |
|
| 264 |
|
- |
|
| 265 |
private static final String[] ITEMWISE_PENDING_INDENT_MAIL_LIST = new String[]{"kamini.sharma@smartdukaan.com",
|
- |
|
| 266 |
"tarun.verma@smartdukaan.com", "uday.singh@smartdukaan.com", "kuldeep.kumar@smartdukaan.com",
|
- |
|
| 267 |
"niranjan.kala@smartdukaan.com"};
|
- |
|
| 268 |
|
262 |
|
| 269 |
private static final String[] INDENT_TERTIARY_MAIL_LIST = new String[]{"uday.singh@smartdukaan.com",
|
263 |
private static final String[] ITEMWISE_PENDING_INDENT_MAIL_LIST = new String[]{"kamini.sharma@smartdukaan.com", "tarun.verma@smartdukaan.com", "uday.singh@smartdukaan.com", "kuldeep.kumar@smartdukaan.com", "niranjan.kala@smartdukaan.com"};
|
| 270 |
"kuldeep.kumar@smartdukaan.com"};
|
- |
|
| 271 |
|
264 |
|
| 272 |
private static final String[] EMPLOYEE_ATTENDANCE_MAIL_LIST = new String[]{"sm@smartdukaan.com",
|
265 |
private static final String[] INDENT_TERTIARY_MAIL_LIST = new String[]{"uday.singh@smartdukaan.com", "kuldeep.kumar@smartdukaan.com"};
|
| - |
|
266 |
|
| 273 |
"sm@smartdukaan.com"};
|
267 |
private static final String[] EMPLOYEE_ATTENDANCE_MAIL_LIST = new String[]{"sm@smartdukaan.com", "sm@smartdukaan.com"};
|
| 274 |
|
268 |
|
| 275 |
private List<OrderStatus> orderStatusList = Arrays.asList(OrderStatus.SUBMITTED_FOR_PROCESSING);
|
269 |
private List<OrderStatus> orderStatusList = Arrays.asList(OrderStatus.SUBMITTED_FOR_PROCESSING);
|
| 276 |
|
270 |
|
| 277 |
@Autowired
|
271 |
@Autowired
|
| 278 |
private ReporticoService reporticoService;
|
272 |
private ReporticoService reporticoService;
|
| Line 477... |
Line 471... |
| 477 |
|
471 |
|
| 478 |
@Autowired
|
472 |
@Autowired
|
| 479 |
private TagListingRepository tagListingRepository;
|
473 |
private TagListingRepository tagListingRepository;
|
| 480 |
|
474 |
|
| 481 |
public void generateDailyRecharge() {
|
475 |
public void generateDailyRecharge() {
|
| 482 |
List<RechargeProviderCreditWalletHistory> allCreditHistory = rechargeProviderCreditWalletHistoryRepository
|
476 |
List<RechargeProviderCreditWalletHistory> allCreditHistory = rechargeProviderCreditWalletHistoryRepository.selectAll(0, 2000);
|
| 483 |
.selectAll(0, 2000);
|
- |
|
| 484 |
List<RechargeProvider> rechargeProviders = rechargeProviderRepository.selectAll();
|
477 |
List<RechargeProvider> rechargeProviders = rechargeProviderRepository.selectAll();
|
| 485 |
rechargeProviders.stream().forEach(x -> x.setAmount(0));
|
478 |
rechargeProviders.stream().forEach(x -> x.setAmount(0));
|
| 486 |
|
479 |
|
| 487 |
rechargeProviders.stream().forEach(x -> {
|
480 |
rechargeProviders.stream().forEach(x -> {
|
| 488 |
Map<LocalDate, List<RechargeProviderCreditWalletHistory>> dateWiseProviderCreditsMap = allCreditHistory
|
481 |
Map<LocalDate, List<RechargeProviderCreditWalletHistory>> dateWiseProviderCreditsMap = allCreditHistory.stream().filter(z -> z.getProviderId() == x.getId()).collect(groupingBy(x1 -> x1.getReceiveTimestamp().toLocalDate()));
|
| 489 |
.stream().filter(z -> z.getProviderId() == x.getId())
|
- |
|
| 490 |
.collect(groupingBy(x1 -> x1.getReceiveTimestamp().toLocalDate()));
|
- |
|
| 491 |
|
482 |
|
| 492 |
LOGGER.info("dateWiseProviderCreditsMap -{}", dateWiseProviderCreditsMap);
|
483 |
LOGGER.info("dateWiseProviderCreditsMap -{}", dateWiseProviderCreditsMap);
|
| 493 |
LocalDate endDate = LocalDate.now().plusDays(1);
|
484 |
LocalDate endDate = LocalDate.now().plusDays(1);
|
| 494 |
float previousDayClosing = 0;
|
485 |
float previousDayClosing = 0;
|
| 495 |
LocalDate date = LocalDate.of(2018, 4, 6);
|
486 |
LocalDate date = LocalDate.of(2018, 4, 6);
|
| 496 |
while (date.isBefore(endDate)) {
|
487 |
while (date.isBefore(endDate)) {
|
| 497 |
List<RechargeTransaction> dateWiseRechargeTransactions = rechargeTransactionRepository
|
- |
|
| 498 |
.selectAllBetweenTimestamp(Arrays.asList(RechargeStatus.values()), date.atStartOfDay(),
|
488 |
List<RechargeTransaction> dateWiseRechargeTransactions = rechargeTransactionRepository.selectAllBetweenTimestamp(Arrays.asList(RechargeStatus.values()), date.atStartOfDay(), date.plusDays(1).atStartOfDay());
|
| 499 |
date.plusDays(1).atStartOfDay());
|
- |
|
| 500 |
|
489 |
|
| 501 |
List<RechargeTransaction> successfulTransactions = dateWiseRechargeTransactions.stream()
|
- |
|
| 502 |
.filter(y -> y.getStatus().equals(RechargeStatus.SUCCESS)).collect(Collectors.toList());
|
490 |
List<RechargeTransaction> successfulTransactions = dateWiseRechargeTransactions.stream().filter(y -> y.getStatus().equals(RechargeStatus.SUCCESS)).collect(Collectors.toList());
|
| 503 |
|
491 |
|
| 504 |
float dailyAmount = 0;
|
492 |
float dailyAmount = 0;
|
| 505 |
float totalCommission = 0;
|
493 |
float totalCommission = 0;
|
| 506 |
for (RechargeTransaction rechargeTransaction : successfulTransactions) {
|
494 |
for (RechargeTransaction rechargeTransaction : successfulTransactions) {
|
| 507 |
if (rechargeTransaction.getProviderId() == x.getId()) {
|
495 |
if (rechargeTransaction.getProviderId() == x.getId()) {
|
| Line 559... |
Line 547... |
| 559 |
thinkWalnutDigitalRechargeEnquiryCredential.setRechargeUrl(thinkWalnutDigitalRechargeEnquiryUrl);
|
547 |
thinkWalnutDigitalRechargeEnquiryCredential.setRechargeUrl(thinkWalnutDigitalRechargeEnquiryUrl);
|
| 560 |
thinkWalnutDigitalRechargeEnquiryCredential.setRechargeUserName(thinkWalnutDigitalRechargeUserName);
|
548 |
thinkWalnutDigitalRechargeEnquiryCredential.setRechargeUserName(thinkWalnutDigitalRechargeUserName);
|
| 561 |
thinkWalnutDigitalRechargeEnquiryCredential.setRechargePassword(thinkWalnutDigitalRechargePassword);
|
549 |
thinkWalnutDigitalRechargeEnquiryCredential.setRechargePassword(thinkWalnutDigitalRechargePassword);
|
| 562 |
thinkWalnutDigitalRechargeEnquiryCredential.setRechargeAuthKey(thinkWalnutDigitalRechargeAuthKey);
|
550 |
thinkWalnutDigitalRechargeEnquiryCredential.setRechargeAuthKey(thinkWalnutDigitalRechargeAuthKey);
|
| 563 |
Map<String, RechargeStatus> requestRechargeStatusChanged = new HashMap<>();
|
551 |
Map<String, RechargeStatus> requestRechargeStatusChanged = new HashMap<>();
|
| 564 |
List<RechargeTransaction> rechargeTransactions = rechargeTransactionRepository
|
552 |
List<RechargeTransaction> rechargeTransactions = rechargeTransactionRepository.selectAllBetweenTimestamp(nonSuccessRechargeStatuses, fromDate, toDate);
|
| 565 |
.selectAllBetweenTimestamp(nonSuccessRechargeStatuses, fromDate, toDate);
|
- |
|
| 566 |
for (RechargeTransaction rechargeTransaction : rechargeTransactions) {
|
553 |
for (RechargeTransaction rechargeTransaction : rechargeTransactions) {
|
| 567 |
try {
|
554 |
try {
|
| 568 |
int providerId = rechargeTransaction.getProviderId();
|
555 |
int providerId = rechargeTransaction.getProviderId();
|
| 569 |
if (providerId == 1) {
|
556 |
if (providerId == 1) {
|
| 570 |
oxigenRechargeProviderService.doCheckStatusRequest(oxigenRechargeEnquiryUrl, oxigenRechargeAuthKey,
|
557 |
oxigenRechargeProviderService.doCheckStatusRequest(oxigenRechargeEnquiryUrl, oxigenRechargeAuthKey, rechargeTransaction);
|
| 571 |
rechargeTransaction);
|
- |
|
| 572 |
} else if (providerId == 2) {
|
558 |
} else if (providerId == 2) {
|
| 573 |
thinkWalnutDigitalRechargeProviderService
|
- |
|
| 574 |
.doCheckStatusRequest(thinkWalnutDigitalRechargeEnquiryCredential, rechargeTransaction);
|
559 |
thinkWalnutDigitalRechargeProviderService.doCheckStatusRequest(thinkWalnutDigitalRechargeEnquiryCredential, rechargeTransaction);
|
| 575 |
}
|
560 |
}
|
| 576 |
if (rechargeTransaction.getStatus().equals(RechargeStatus.SUCCESS)
|
- |
|
| 577 |
|| rechargeTransaction.getStatus().equals(RechargeStatus.FAILED)) {
|
561 |
if (rechargeTransaction.getStatus().equals(RechargeStatus.SUCCESS) || rechargeTransaction.getStatus().equals(RechargeStatus.FAILED)) {
|
| 578 |
requestRechargeStatusChanged.put(rechargeTransaction.getRequestId(),
|
562 |
requestRechargeStatusChanged.put(rechargeTransaction.getRequestId(), rechargeTransaction.getStatus());
|
| 579 |
rechargeTransaction.getStatus());
|
- |
|
| 580 |
}
|
563 |
}
|
| 581 |
} catch (Exception e) {
|
564 |
} catch (Exception e) {
|
| 582 |
LOGGER.info("Could not check status for Request {}", rechargeTransaction.getRequestId());
|
565 |
LOGGER.info("Could not check status for Request {}", rechargeTransaction.getRequestId());
|
| 583 |
}
|
566 |
}
|
| 584 |
}
|
567 |
}
|
| Line 591... |
Line 574... |
| 591 |
|
574 |
|
| 592 |
// TemporaryMethod
|
575 |
// TemporaryMethod
|
| 593 |
public void migrateInvoice() {
|
576 |
public void migrateInvoice() {
|
| 594 |
List<FofoOrder> fofoOrders = fofoOrderRepository.selectFromSaleDate(LocalDateTime.now().minusDays(3));
|
577 |
List<FofoOrder> fofoOrders = fofoOrderRepository.selectFromSaleDate(LocalDateTime.now().minusDays(3));
|
| 595 |
Map<Integer, List<FofoOrder>> partnerOrdersMap = new HashMap<>();
|
578 |
Map<Integer, List<FofoOrder>> partnerOrdersMap = new HashMap<>();
|
| 596 |
partnerOrdersMap = fofoOrders.stream()
|
- |
|
| 597 |
.collect(groupingBy(FofoOrder::getFofoId, Collectors.toList()));
|
579 |
partnerOrdersMap = fofoOrders.stream().collect(groupingBy(FofoOrder::getFofoId, Collectors.toList()));
|
| 598 |
for (List<FofoOrder> orderList : partnerOrdersMap.values()) {
|
580 |
for (List<FofoOrder> orderList : partnerOrdersMap.values()) {
|
| 599 |
int sequence = 0;
|
581 |
int sequence = 0;
|
| 600 |
String prefix = "";
|
582 |
String prefix = "";
|
| 601 |
List<FofoOrder> sortedList = orderList.stream().sorted((x1, x2) -> x1.getId() - x2.getId())
|
583 |
List<FofoOrder> sortedList = orderList.stream().sorted((x1, x2) -> x1.getId() - x2.getId()).collect(Collectors.toList());
|
| 602 |
.collect(Collectors.toList());
|
- |
|
| 603 |
for (FofoOrder order : sortedList) {
|
584 |
for (FofoOrder order : sortedList) {
|
| 604 |
|
585 |
|
| 605 |
LOGGER.info("Order Id is {}, partner Id is {}", order.getId(), order.getFofoId());
|
586 |
LOGGER.info("Order Id is {}, partner Id is {}", order.getId(), order.getFofoId());
|
| 606 |
if (!order.getInvoiceNumber().contains("SEC")) {
|
587 |
if (!order.getInvoiceNumber().contains("SEC")) {
|
| 607 |
sequence = Integer.parseInt(order.getInvoiceNumber().split("/")[1]);
|
588 |
sequence = Integer.parseInt(order.getInvoiceNumber().split("/")[1]);
|
| Line 670... |
Line 651... |
| 670 |
}
|
651 |
}
|
| 671 |
} catch (Exception e) {
|
652 |
} catch (Exception e) {
|
| 672 |
e.printStackTrace();
|
653 |
e.printStackTrace();
|
| 673 |
throw e;
|
654 |
throw e;
|
| 674 |
}
|
655 |
}
|
| 675 |
List<UserWalletHistory> uwhs = userWalletHistoryRepository.selectAllByDateType(LocalDate.now().atStartOfDay(),
|
656 |
List<UserWalletHistory> uwhs = userWalletHistoryRepository.selectAllByDateType(LocalDate.now().atStartOfDay(), endDate, Arrays.asList(WalletReferenceType.SCHEME_IN, WalletReferenceType.SCHEME_OUT));
|
| 676 |
endDate, Arrays.asList(WalletReferenceType.SCHEME_IN, WalletReferenceType.SCHEME_OUT));
|
- |
|
| 677 |
System.out.println("Amount\tReference\tReferenceType\tTimestamp\tDescription");
|
657 |
System.out.println("Amount\tReference\tReferenceType\tTimestamp\tDescription");
|
| 678 |
for (UserWalletHistory uwh : uwhs) {
|
658 |
for (UserWalletHistory uwh : uwhs) {
|
| 679 |
System.out.println(String.format("%d\t%d\t%s\t%s\t%s", uwh.getAmount(), uwh.getReference(),
|
659 |
System.out.println(String.format("%d\t%d\t%s\t%s\t%s", uwh.getAmount(), uwh.getReference(), uwh.getReferenceType(), uwh.getTimestamp().toString(), uwh.getDescription()));
|
| 680 |
uwh.getReferenceType(), uwh.getTimestamp().toString(), uwh.getDescription()));
|
- |
|
| 681 |
}
|
660 |
}
|
| 682 |
LOGGER.info("Schemes processed successfully.");
|
661 |
LOGGER.info("Schemes processed successfully.");
|
| 683 |
if (dryRun) {
|
662 |
if (dryRun) {
|
| 684 |
throw new Exception();
|
663 |
throw new Exception();
|
| 685 |
}
|
664 |
}
|
| 686 |
}
|
665 |
}
|
| 687 |
|
666 |
|
| 688 |
public void processRechargeCashback() throws Throwable {
|
667 |
public void processRechargeCashback() throws Throwable {
|
| 689 |
LocalDateTime cashbackTime = LocalDateTime.now();
|
668 |
LocalDateTime cashbackTime = LocalDateTime.now();
|
| 690 |
int referenceId = (int) Timestamp.valueOf(cashbackTime).getTime() / 1000;
|
669 |
int referenceId = (int) Timestamp.valueOf(cashbackTime).getTime() / 1000;
|
| 691 |
List<RechargeTransaction> pendingTransactions = rechargeTransactionRepository
|
670 |
List<RechargeTransaction> pendingTransactions = rechargeTransactionRepository.getPendingCashBackRehargeTransactions();
|
| 692 |
.getPendingCashBackRehargeTransactions();
|
- |
|
| 693 |
Map<Object, Double> totalRetailerCashbacks = pendingTransactions.stream().collect(
|
671 |
Map<Object, Double> totalRetailerCashbacks = pendingTransactions.stream().collect(
|
| 694 |
groupingBy(x -> x.getRetailerId(), Collectors.summingDouble(x -> x.getCommission())));
|
672 |
groupingBy(x -> x.getRetailerId(), Collectors.summingDouble(x -> x.getCommission())));
|
| 695 |
for (Map.Entry<Object, Double> totalRetailerCashback : totalRetailerCashbacks.entrySet()) {
|
673 |
for (Map.Entry<Object, Double> totalRetailerCashback : totalRetailerCashbacks.entrySet()) {
|
| 696 |
int retailerId = (Integer) totalRetailerCashback.getKey();
|
674 |
int retailerId = (Integer) totalRetailerCashback.getKey();
|
| 697 |
float amount = totalRetailerCashback.getValue().floatValue();
|
675 |
float amount = totalRetailerCashback.getValue().floatValue();
|
| 698 |
if (Math.round(amount) > 0) {
|
676 |
if (Math.round(amount) > 0) {
|
| 699 |
walletService.addAmountToWallet(retailerId, referenceId, WalletReferenceType.CASHBACK,
|
677 |
walletService.addAmountToWallet(retailerId, referenceId, WalletReferenceType.CASHBACK, "Recharge Cashback", Math.round(amount), LocalDateTime.now());
|
| 700 |
"Recharge Cashback", Math.round(amount), LocalDateTime.now());
|
- |
|
| 701 |
}
|
678 |
}
|
| 702 |
}
|
679 |
}
|
| 703 |
for (RechargeTransaction rt : pendingTransactions) {
|
680 |
for (RechargeTransaction rt : pendingTransactions) {
|
| 704 |
rt.setCashbackTimestamp(cashbackTime);
|
681 |
rt.setCashbackTimestamp(cashbackTime);
|
| 705 |
rt.setCashbackReference(referenceId);
|
682 |
rt.setCashbackReference(referenceId);
|
| Line 713... |
Line 690... |
| 713 |
|
690 |
|
| 714 |
List<FofoStore> stores = fofoStoreRepository.selectActiveStores();
|
691 |
List<FofoStore> stores = fofoStoreRepository.selectActiveStores();
|
| 715 |
for (FofoStore store : stores) {
|
692 |
for (FofoStore store : stores) {
|
| 716 |
int fofoId = store.getId();
|
693 |
int fofoId = store.getId();
|
| 717 |
|
694 |
|
| 718 |
PartnerType startOfPreviousMonthPartnerType = partnerTypeChangeService.getTypeOnDate(fofoId,
|
695 |
PartnerType startOfPreviousMonthPartnerType = partnerTypeChangeService.getTypeOnDate(fofoId, startOfPreviousMonth);
|
| 719 |
startOfPreviousMonth);
|
- |
|
| 720 |
PartnerType todayPartnerType = partnerTypeChangeService.getTypeOnMonth(fofoId,
|
696 |
PartnerType todayPartnerType = partnerTypeChangeService.getTypeOnMonth(fofoId, YearMonth.from(startOfPreviousMonth.atStartOfDay()));
|
| 721 |
YearMonth.from(startOfPreviousMonth.atStartOfDay()));
|
- |
|
| 722 |
if (!startOfPreviousMonthPartnerType.nextPartnerTypes().contains(todayPartnerType)) {
|
697 |
if (!startOfPreviousMonthPartnerType.nextPartnerTypes().contains(todayPartnerType)) {
|
| 723 |
continue;
|
698 |
continue;
|
| 724 |
}
|
699 |
}
|
| 725 |
if (!startOfPreviousMonthPartnerType.equals(todayPartnerType)) {
|
700 |
if (!startOfPreviousMonthPartnerType.equals(todayPartnerType)) {
|
| 726 |
LOGGER.info("Partner Type has been changed for code {} from {} to {}", store.getCode(),
|
701 |
LOGGER.info("Partner Type has been changed for code {} from {} to {}", store.getCode(), startOfPreviousMonthPartnerType, todayPartnerType);
|
| 727 |
startOfPreviousMonthPartnerType, todayPartnerType);
|
- |
|
| 728 |
List<FofoOrder> fofoOrders = fofoOrderRepository.selectByFofoId(fofoId,
|
- |
|
| 729 |
startOfPreviousMonth.atStartOfDay(), startOfPreviousMonth.plusMonths(1).atStartOfDay(), 0, 0);
|
702 |
List<FofoOrder> fofoOrders = fofoOrderRepository.selectByFofoId(fofoId, startOfPreviousMonth.atStartOfDay(), startOfPreviousMonth.plusMonths(1).atStartOfDay(), 0, 0);
|
| 730 |
for (FofoOrder fofoOrder : fofoOrders) {
|
703 |
for (FofoOrder fofoOrder : fofoOrders) {
|
| 731 |
schemeService.processSchemeOut(fofoOrder.getId(), fofoId);
|
704 |
schemeService.processSchemeOut(fofoOrder.getId(), fofoId);
|
| 732 |
}
|
705 |
}
|
| 733 |
|
706 |
|
| 734 |
}
|
707 |
}
|
| Line 749... |
Line 722... |
| 749 |
if (!yesterdayPartnerType.nextPartnerTypes().contains(todayPartnerType)) {
|
722 |
if (!yesterdayPartnerType.nextPartnerTypes().contains(todayPartnerType)) {
|
| 750 |
continue;
|
723 |
continue;
|
| 751 |
}
|
724 |
}
|
| 752 |
if (!yesterdayPartnerType.equals(todayPartnerType)) {
|
725 |
if (!yesterdayPartnerType.equals(todayPartnerType)) {
|
| 753 |
upgradedCount++;
|
726 |
upgradedCount++;
|
| 754 |
sb.append(String.format("Partner Type has been changed for code %s from %s to %s", store.getCode(),
|
727 |
sb.append(String.format("Partner Type has been changed for code %s from %s to %s", store.getCode(), yesterdayPartnerType.toString(), todayPartnerType.toString()));
|
| 755 |
yesterdayPartnerType.toString(), todayPartnerType.toString()));
|
- |
|
| 756 |
sb.append("<br>");
|
728 |
sb.append("<br>");
|
| 757 |
LOGGER.info("Partner Type has been changed for code {} from {} to {}", store.getCode(),
|
729 |
LOGGER.info("Partner Type has been changed for code {} from {} to {}", store.getCode(), yesterdayPartnerType, todayPartnerType);
|
| 758 |
yesterdayPartnerType, todayPartnerType);
|
- |
|
| 759 |
List<FofoOrder> fofoOrders = fofoOrderRepository.selectByFofoId(fofoId,
|
- |
|
| 760 |
yesterday.withDayOfMonth(1).atStartOfDay(), yesterday.atStartOfDay(), 0, 0);
|
730 |
List<FofoOrder> fofoOrders = fofoOrderRepository.selectByFofoId(fofoId, yesterday.withDayOfMonth(1).atStartOfDay(), yesterday.atStartOfDay(), 0, 0);
|
| 761 |
for (FofoOrder fofoOrder : fofoOrders) {
|
731 |
for (FofoOrder fofoOrder : fofoOrders) {
|
| 762 |
schemeService.processSchemeOut(fofoOrder.getId(), fofoId);
|
732 |
schemeService.processSchemeOut(fofoOrder.getId(), fofoId);
|
| 763 |
}
|
733 |
}
|
| 764 |
|
734 |
|
| 765 |
}
|
735 |
}
|
| 766 |
}
|
736 |
}
|
| 767 |
if (upgradedCount > 0) {
|
737 |
if (upgradedCount > 0) {
|
| 768 |
sendMailHtmlFormat(
|
738 |
sendMailHtmlFormat(
|
| 769 |
new String[]{"amit.gupta@smartdukaan.com", "tarun.verma@smartdukaan.com",
|
739 |
new String[]{"amit.gupta@smartdukaan.com", "tarun.verma@smartdukaan.com", "neeraj.gupta@smartdukaan.com"}, sb.toString(), null, "Few Partners Category have been Upgraded");
|
| 770 |
"neeraj.gupta@smartdukaan.com"},
|
- |
|
| 771 |
sb.toString(), null, "Few Partners Category have been Upgraded");
|
- |
|
| 772 |
} else {
|
740 |
} else {
|
| 773 |
sendMailHtmlFormat(
|
741 |
sendMailHtmlFormat(
|
| 774 |
new String[]{"amit.gupta@smartdukaan.com", "tarun.verma@smartdukaan.com",
|
742 |
new String[]{"amit.gupta@smartdukaan.com", "tarun.verma@smartdukaan.com", "neeraj.gupta@smartdukaan.com"}, sb.toString(), null, "No partners Category have been upgraded today");
|
| 775 |
"neeraj.gupta@smartdukaan.com"},
|
- |
|
| 776 |
sb.toString(), null, "No partners Category have been upgraded today");
|
- |
|
| 777 |
}
|
743 |
}
|
| 778 |
}
|
744 |
}
|
| 779 |
|
745 |
|
| 780 |
@Autowired
|
746 |
@Autowired
|
| 781 |
private PartnerStatsService partnerStatsService;
|
747 |
private PartnerStatsService partnerStatsService;
|
| Line 784... |
Line 750... |
| 784 |
public void evaluateExcessSchemeOut() throws Exception {
|
750 |
public void evaluateExcessSchemeOut() throws Exception {
|
| 785 |
Map<Integer, String> userNameMap = retailerService.getAllFofoRetailerIdNameMap();
|
751 |
Map<Integer, String> userNameMap = retailerService.getAllFofoRetailerIdNameMap();
|
| 786 |
Map<Integer, Float> userAmountMap = new HashMap<>();
|
752 |
Map<Integer, Float> userAmountMap = new HashMap<>();
|
| 787 |
|
753 |
|
| 788 |
List<List<?>> rows = new ArrayList<>();
|
754 |
List<List<?>> rows = new ArrayList<>();
|
| 789 |
List<String> headers = Arrays.asList("Scheme", "Item", "Partner", "Amount", "Credited On", "Invoice Number",
|
755 |
List<String> headers = Arrays.asList("Scheme", "Item", "Partner", "Amount", "Credited On", "Invoice Number", "Sale On", "Scheme Start", "Scheme End", "Active On", "Expired On");
|
| 790 |
"Sale On", "Scheme Start", "Scheme End", "Active On", "Expired On");
|
- |
|
| 791 |
schemeRepository.selectAll().stream().forEach(x -> {
|
756 |
schemeRepository.selectAll().stream().forEach(x -> {
|
| 792 |
if (x.getType().equals(SchemeType.OUT)) {
|
757 |
if (x.getType().equals(SchemeType.OUT)) {
|
| 793 |
List<SchemeInOut> sioList = schemeInOutRepository
|
- |
|
| 794 |
.selectBySchemeIds(new HashSet<>(Arrays.asList(x.getId())));
|
758 |
List<SchemeInOut> sioList = schemeInOutRepository.selectBySchemeIds(new HashSet<>(Arrays.asList(x.getId())));
|
| 795 |
if (x.getActiveTimestamp() != null) {
|
759 |
if (x.getActiveTimestamp() != null) {
|
| 796 |
LocalDateTime endDateTime = x.getEndDateTime();
|
760 |
LocalDateTime endDateTime = x.getEndDateTime();
|
| 797 |
if (x.getExpireTimestamp() != null && x.getExpireTimestamp().isBefore(x.getEndDateTime())) {
|
761 |
if (x.getExpireTimestamp() != null && x.getExpireTimestamp().isBefore(x.getEndDateTime())) {
|
| 798 |
endDateTime = x.getExpireTimestamp();
|
762 |
endDateTime = x.getExpireTimestamp();
|
| 799 |
}
|
763 |
}
|
| 800 |
for (SchemeInOut sio : sioList) {
|
764 |
for (SchemeInOut sio : sioList) {
|
| 801 |
InventoryItem inventoryItem = null;
|
765 |
InventoryItem inventoryItem = null;
|
| 802 |
inventoryItem = inventoryItemRepository.selectById(sio.getInventoryItemId());
|
766 |
inventoryItem = inventoryItemRepository.selectById(sio.getInventoryItemId());
|
| 803 |
FofoOrder fofoOrder = fofoOrderRepository.selectByFofoIdAndSerialNumber(
|
767 |
FofoOrder fofoOrder = fofoOrderRepository.selectByFofoIdAndSerialNumber(
|
| 804 |
inventoryItem.getFofoId(), inventoryItem.getSerialNumber(), null, null, 0, 1).get(0);
|
768 |
inventoryItem.getFofoId(), inventoryItem.getSerialNumber(), null, null, 0, 1).get(0);
|
| 805 |
Optional<ScanRecord> record = scanRecordRepository
|
- |
|
| 806 |
.selectByInventoryItemId(sio.getInventoryItemId()).stream()
|
- |
|
| 807 |
.filter(y -> y.getType().equals(ScanType.SALE)).findFirst();
|
769 |
Optional<ScanRecord> record = scanRecordRepository.selectByInventoryItemId(sio.getInventoryItemId()).stream().filter(y -> y.getType().equals(ScanType.SALE)).findFirst();
|
| 808 |
if (record.isPresent()) {
|
770 |
if (record.isPresent()) {
|
| 809 |
int fofoId = record.get().getFofoId();
|
771 |
int fofoId = record.get().getFofoId();
|
| 810 |
if (record.get().getCreateTimestamp().isAfter(endDateTime)
|
- |
|
| 811 |
|| record.get().getCreateTimestamp().isBefore(x.getStartDateTime())) {
|
772 |
if (record.get().getCreateTimestamp().isAfter(endDateTime) || record.get().getCreateTimestamp().isBefore(x.getStartDateTime())) {
|
| 812 |
if (!userAmountMap.containsKey(fofoId)) {
|
773 |
if (!userAmountMap.containsKey(fofoId)) {
|
| 813 |
userAmountMap.put(fofoId, 0f);
|
774 |
userAmountMap.put(fofoId, 0f);
|
| 814 |
}
|
775 |
}
|
| 815 |
userAmountMap.put(fofoId, sio.getAmount() + userAmountMap.get(fofoId));
|
776 |
userAmountMap.put(fofoId, sio.getAmount() + userAmountMap.get(fofoId));
|
| 816 |
try {
|
777 |
try {
|
| 817 |
rows.add(Arrays.asList(x.getDescription(),
|
778 |
rows.add(Arrays.asList(x.getDescription(), itemRepository.selectById(inventoryItem.getItemId()).getItemDescription(), userNameMap.get(fofoId), sio.getAmount(), FormattingUtils.formatDate(sio.getCreateTimestamp()), fofoOrder.getInvoiceNumber(), FormattingUtils.formatDate(record.get().getCreateTimestamp()), FormattingUtils.formatDate(x.getStartDateTime()), FormattingUtils.formatDate(x.getEndDateTime()), FormattingUtils.formatDate(x.getActiveTimestamp()), FormattingUtils.formatDate(x.getExpireTimestamp())));
|
| 818 |
itemRepository.selectById(inventoryItem.getItemId()).getItemDescription(),
|
- |
|
| 819 |
userNameMap.get(fofoId), sio.getAmount(),
|
- |
|
| 820 |
FormattingUtils.formatDate(sio.getCreateTimestamp()),
|
- |
|
| 821 |
fofoOrder.getInvoiceNumber(),
|
- |
|
| 822 |
FormattingUtils.formatDate(record.get().getCreateTimestamp()),
|
- |
|
| 823 |
FormattingUtils.formatDate(x.getStartDateTime()),
|
- |
|
| 824 |
FormattingUtils.formatDate(x.getEndDateTime()),
|
- |
|
| 825 |
FormattingUtils.formatDate(x.getActiveTimestamp()),
|
- |
|
| 826 |
FormattingUtils.formatDate(x.getExpireTimestamp())));
|
- |
|
| 827 |
} catch (Exception e) {
|
779 |
} catch (Exception e) {
|
| 828 |
e.printStackTrace();
|
780 |
e.printStackTrace();
|
| 829 |
}
|
781 |
}
|
| 830 |
}
|
782 |
}
|
| 831 |
}
|
783 |
}
|
| 832 |
}
|
784 |
}
|
| 833 |
}
|
785 |
}
|
| 834 |
}
|
786 |
}
|
| 835 |
});
|
787 |
});
|
| 836 |
userAmountMap.entrySet().stream()
|
- |
|
| 837 |
.forEach(x -> LOGGER.info("{} to be deducted from {}({}) for wrongly disbursed due to technical error.",
|
788 |
userAmountMap.entrySet().stream().forEach(x -> LOGGER.info("{} to be deducted from {}({}) for wrongly disbursed due to technical error.", x.getValue(), userNameMap.get(x.getKey())));
|
| 838 |
x.getValue(), userNameMap.get(x.getKey())));
|
- |
|
| 839 |
|
789 |
|
| 840 |
ByteArrayOutputStream baos = FileUtil.getCSVByteStream(headers, rows);
|
790 |
ByteArrayOutputStream baos = FileUtil.getCSVByteStream(headers, rows);
|
| 841 |
Utils.sendMailWithAttachment(googleMailSender,
|
- |
|
| 842 |
new String[]{"amit.gupta@shop2020.in"}, null,
|
- |
|
| 843 |
"Partner Excess Amount", "PFA", "ListofSchemes.csv", new ByteArrayResource(baos.toByteArray()));
|
791 |
Utils.sendMailWithAttachment(googleMailSender, new String[]{"amit.gupta@shop2020.in"}, null, "Partner Excess Amount", "PFA", "ListofSchemes.csv", new ByteArrayResource(baos.toByteArray()));
|
| 844 |
|
792 |
|
| 845 |
}
|
793 |
}
|
| 846 |
|
794 |
|
| 847 |
public void fetchParnterStats() throws Exception {
|
795 |
public void fetchParnterStats() throws Exception {
|
| 848 |
Map<Integer, PartnerDetailModel> partnerStats = partnerStatsService.getAllPartnerStats();
|
796 |
Map<Integer, PartnerDetailModel> partnerStats = partnerStatsService.getAllPartnerStats();
|
| Line 870... |
Line 818... |
| 870 |
rct.setLastCreatedTimestamp(LocalDateTime.now());
|
818 |
rct.setLastCreatedTimestamp(LocalDateTime.now());
|
| 871 |
}
|
819 |
}
|
| 872 |
}
|
820 |
}
|
| 873 |
|
821 |
|
| 874 |
public void processPriceDrop() throws Exception {
|
822 |
public void processPriceDrop() throws Exception {
|
| 875 |
List<PriceDrop> priceDrops = priceDropRepository.selectAllByDatesBetween(LocalDateTime.now(),
|
823 |
List<PriceDrop> priceDrops = priceDropRepository.selectAllByDatesBetween(LocalDateTime.now(), LocalDateTime.now().minusYears(1));
|
| 876 |
LocalDateTime.now().minusYears(1));
|
- |
|
| 877 |
for (PriceDrop priceDrop : priceDrops) {
|
824 |
for (PriceDrop priceDrop : priceDrops) {
|
| 878 |
if (priceDrop.getDropAmount() > 0) {
|
825 |
if (priceDrop.getDropAmount() > 0) {
|
| 879 |
priceDropService.processPriceDrop(priceDrop.getId(), true);
|
826 |
priceDropService.processPriceDrop(priceDrop.getId(), true);
|
| 880 |
}
|
827 |
}
|
| 881 |
}
|
828 |
}
|
| Line 952... |
Line 899... |
| 952 |
return ScheduledTasks.this;
|
899 |
return ScheduledTasks.this;
|
| 953 |
}
|
900 |
}
|
| 954 |
|
901 |
|
| 955 |
@Override
|
902 |
@Override
|
| 956 |
public String toString() {
|
903 |
public String toString() {
|
| 957 |
return "FofoReportingModel{" +
|
- |
|
| 958 |
"code='" + code + '\'' +
|
- |
|
| 959 |
", fofoId=" + fofoId +
|
- |
|
| 960 |
", businessName='" + businessName + '\'' +
|
- |
|
| 961 |
", territoryManager='" + territoryManager + '\'' +
|
904 |
return "FofoReportingModel{" + "code='" + code + '\'' + ", fofoId=" + fofoId + ", businessName='" + businessName + '\'' + ", territoryManager='" + territoryManager + '\'' + ", regionalManager='" + regionalManager + '\'' + ", businessManager='" + businessManager + '\'' + '}';
|
| 962 |
", regionalManager='" + regionalManager + '\'' +
|
- |
|
| 963 |
", businessManager='" + businessManager + '\'' +
|
- |
|
| 964 |
'}';
|
- |
|
| 965 |
}
|
905 |
}
|
| 966 |
|
906 |
|
| 967 |
@Override
|
907 |
@Override
|
| 968 |
public boolean equals(Object o) {
|
908 |
public boolean equals(Object o) {
|
| 969 |
if (this == o) return true;
|
909 |
if (this == o) return true;
|
| Line 1021... |
Line 961... |
| 1021 |
samsungModels = samsungModels.stream().sorted(Comparator.comparing(x -> x.getPcmDate() == null ? -1 : 1)).collect(Collectors.toList());
|
961 |
samsungModels = samsungModels.stream().sorted(Comparator.comparing(x -> x.getPcmDate() == null ? -1 : 1)).collect(Collectors.toList());
|
| 1022 |
if (samsungModels.size() > 0) {
|
962 |
if (samsungModels.size() > 0) {
|
| 1023 |
List<String> headers = Arrays.asList("Partner Id", "Code", "Name", "City", "Brand", "Model Name", "Model Number", "Color", "Serial Number", "Remarks");
|
963 |
List<String> headers = Arrays.asList("Partner Id", "Code", "Name", "City", "Brand", "Model Name", "Model Number", "Color", "Serial Number", "Remarks");
|
| 1024 |
List<List<?>> rows = new ArrayList<>();
|
964 |
List<List<?>> rows = new ArrayList<>();
|
| 1025 |
for (BilledImeiModel billedImeiModel : samsungModels) {
|
965 |
for (BilledImeiModel billedImeiModel : samsungModels) {
|
| 1026 |
List<Serializable> row = Arrays.asList(billedImeiModel.getFofoId(), billedImeiModel.getStoreCode(), billedImeiModel.getStoreName(),
|
966 |
List<Serializable> row = Arrays.asList(billedImeiModel.getFofoId(), billedImeiModel.getStoreCode(), billedImeiModel.getStoreName(), billedImeiModel.getStoreCity(), billedImeiModel.getBrand(), billedImeiModel.getModelName(), billedImeiModel.getModelNumber(), billedImeiModel.getColor(), billedImeiModel.getSerialNumber(), billedImeiModel.getPcmDate() == null ? "PCM date Missing" : "Rebill Imeis");
|
| 1027 |
billedImeiModel.getStoreCity(), billedImeiModel.getBrand(), billedImeiModel.getModelName(), billedImeiModel.getModelNumber(),
|
- |
|
| 1028 |
billedImeiModel.getColor(), billedImeiModel.getSerialNumber(), billedImeiModel.getPcmDate() == null ? "PCM date Missing" : "Rebill Imeis");
|
- |
|
| 1029 |
rows.add(row);
|
967 |
rows.add(row);
|
| 1030 |
}
|
968 |
}
|
| 1031 |
ByteArrayOutputStream baos = FileUtil.getCSVByteStream(headers, rows);
|
969 |
ByteArrayOutputStream baos = FileUtil.getCSVByteStream(headers, rows);
|
| 1032 |
String[] sendToArray = new String[]{"kamini.sharma@smartdukaan.com", "praveen.sharma@smartdukaan.com"};
|
970 |
String[] sendToArray = new String[]{"kamini.sharma@smartdukaan.com", "praveen.sharma@smartdukaan.com"};
|
| 1033 |
String fileName = "Imeis need Rebilling -" + FormattingUtils.formatDate(LocalDateTime.now()) + ".csv";
|
971 |
String fileName = "Imeis need Rebilling -" + FormattingUtils.formatDate(LocalDateTime.now()) + ".csv";
|
| 1034 |
Utils.sendMailWithAttachment(googleMailSender, sendToArray, new String[]{"tarun.verma@smartdukaan.com"}, "Samsung Rebilling IMEI Summary", "PFA",
|
972 |
Utils.sendMailWithAttachment(googleMailSender, sendToArray, new String[]{"tarun.verma@smartdukaan.com"}, "Samsung Rebilling IMEI Summary", "PFA", fileName, new ByteArrayResource(baos.toByteArray()));
|
| 1035 |
fileName, new ByteArrayResource(baos.toByteArray()));
|
- |
|
| 1036 |
}
|
973 |
}
|
| 1037 |
}
|
974 |
}
|
| 1038 |
|
975 |
|
| 1039 |
public void sendPartnerInvestmentDetails(List<String> sendTo) throws Exception {
|
976 |
public void sendPartnerInvestmentDetails(List<String> sendTo) throws Exception {
|
| 1040 |
LocalDate yesterDay = LocalDate.now().minusDays(1);
|
977 |
LocalDate yesterDay = LocalDate.now().minusDays(1);
|
| 1041 |
List<FofoStore> fofoStores = fofoStoreRepository.selectActiveStores();
|
978 |
List<FofoStore> fofoStores = fofoStoreRepository.selectActiveStores();
|
| 1042 |
Map<Integer, CustomRetailer> customRetailerMap = retailerService
|
- |
|
| 1043 |
.getFofoRetailers(fofoStores.stream().map(x -> x.getId()).collect(Collectors.toList()));
|
979 |
Map<Integer, CustomRetailer> customRetailerMap = retailerService.getFofoRetailers(fofoStores.stream().map(x -> x.getId()).collect(Collectors.toList()));
|
| 1044 |
|
980 |
|
| 1045 |
List<String> headers = Arrays.asList("Code", "Outlet name", "State Manager", "Teritory/Team Lead",
|
981 |
List<String> headers = Arrays.asList("Code", "Outlet name", "State Manager", "Teritory/Team Lead", "Wallet Amount", "In Stock Amount", "Activated Stock", "Return In Transit Stock", "Unbilled Amount", "Grn Pending Amount", "Min Investment", "Investment Amount", "Investment Short", "Unbilled Qty", "Short Days");
|
| 1046 |
"Wallet Amount", "In Stock Amount", "Activated Stock", "Return In Transit Stock", "Unbilled Amount",
|
- |
|
| 1047 |
"Grn Pending Amount", "Min Investment", "Investment Amount", "Investment Short", "Unbilled Qty",
|
- |
|
| 1048 |
"Short Days");
|
- |
|
| 1049 |
List<List<?>> rows = new ArrayList<>();
|
982 |
List<List<?>> rows = new ArrayList<>();
|
| 1050 |
Map<Integer, List<?>> partnerRowsMap = new HashMap<>();
|
983 |
Map<Integer, List<?>> partnerRowsMap = new HashMap<>();
|
| 1051 |
|
984 |
|
| 1052 |
Map<Integer, FofoReportingModel> partnerIdSalesHeaderMap = this.getPartnerIdSalesHeaders();
|
985 |
Map<Integer, FofoReportingModel> partnerIdSalesHeaderMap = this.getPartnerIdSalesHeaders();
|
| 1053 |
|
986 |
|
| 1054 |
Map<Integer, Integer> shortDaysMap = partnerDailyInvestmentRepository
|
- |
|
| 1055 |
.selectAll(LocalDate.now().withDayOfMonth(1), LocalDate.now()).stream().collect(groupingBy(
|
987 |
Map<Integer, Integer> shortDaysMap = partnerDailyInvestmentRepository.selectAll(LocalDate.now().withDayOfMonth(1), LocalDate.now()).stream().collect(groupingBy(
|
| 1056 |
x -> x.getFofoId(), Collectors.summingInt(x -> x.getShortPercentage() > 10 ? 1 : 0)));
|
988 |
x -> x.getFofoId(), Collectors.summingInt(x -> x.getShortPercentage() > 10 ? 1 : 0)));
|
| 1057 |
|
989 |
|
| 1058 |
for (FofoStore fofoStore : fofoStores) {
|
990 |
for (FofoStore fofoStore : fofoStores) {
|
| 1059 |
LOGGER.info("Fofo Store {}, {}", fofoStore.getId(), fofoStore.getCode());
|
991 |
LOGGER.info("Fofo Store {}, {}", fofoStore.getId(), fofoStore.getCode());
|
| 1060 |
int fofoId = fofoStore.getId();
|
992 |
int fofoId = fofoStore.getId();
|
| 1061 |
PartnerDailyInvestment partnerDailyInvestment = partnerInvestmentService.getInvestment(fofoId, 1);
|
993 |
PartnerDailyInvestment partnerDailyInvestment = partnerInvestmentService.getInvestment(fofoId, 1);
|
| 1062 |
partnerDailyInvestment.setDate(yesterDay);
|
994 |
partnerDailyInvestment.setDate(yesterDay);
|
| 1063 |
|
995 |
|
| 1064 |
try {
|
996 |
try {
|
| 1065 |
partnerDailyInvestmentRepository.persist(partnerDailyInvestment);
|
997 |
partnerDailyInvestmentRepository.persist(partnerDailyInvestment);
|
| 1066 |
shortDaysMap.put(fofoId,
|
- |
|
| 1067 |
shortDaysMap.get(fofoId) + (partnerDailyInvestment.getShortPercentage() > 10 ? 1 : 0));
|
998 |
shortDaysMap.put(fofoId, shortDaysMap.get(fofoId) + (partnerDailyInvestment.getShortPercentage() > 10 ? 1 : 0));
|
| 1068 |
} catch (Exception e) {
|
999 |
} catch (Exception e) {
|
| 1069 |
// ignore the exceptions during persist
|
1000 |
// ignore the exceptions during persist
|
| 1070 |
}
|
1001 |
}
|
| 1071 |
|
1002 |
|
| 1072 |
CustomRetailer retailer = customRetailerMap.get(fofoStore.getId());
|
1003 |
CustomRetailer retailer = customRetailerMap.get(fofoStore.getId());
|
| Line 1074... |
Line 1005... |
| 1074 |
LOGGER.info("Could not find retailer with retailer Id {}", fofoStore.getId());
|
1005 |
LOGGER.info("Could not find retailer with retailer Id {}", fofoStore.getId());
|
| 1075 |
continue;
|
1006 |
continue;
|
| 1076 |
}
|
1007 |
}
|
| 1077 |
FofoReportingModel reportingModel = partnerIdSalesHeaderMap.get(fofoStore.getId());
|
1008 |
FofoReportingModel reportingModel = partnerIdSalesHeaderMap.get(fofoStore.getId());
|
| 1078 |
List<Serializable> row = new ArrayList<>();
|
1009 |
List<Serializable> row = new ArrayList<>();
|
| 1079 |
row.addAll(Arrays.asList(reportingModel.getCode(), reportingModel.getBusinessName(),
|
1010 |
row.addAll(Arrays.asList(reportingModel.getCode(), reportingModel.getBusinessName(), reportingModel.getRegionalManager(), reportingModel.getTerritoryManager()));
|
| 1080 |
reportingModel.getRegionalManager(), reportingModel.getTerritoryManager()));
|
- |
|
| 1081 |
row.addAll(
|
1011 |
row.addAll(
|
| 1082 |
Arrays.asList(partnerDailyInvestment.getWalletAmount(), partnerDailyInvestment.getInStockAmount(),
|
1012 |
Arrays.asList(partnerDailyInvestment.getWalletAmount(), partnerDailyInvestment.getInStockAmount(), partnerDailyInvestment.getActivatedStockAmount() == 0 ? "-" : "(" + partnerDailyInvestment.getActivatedStockAmount() + ")", 0, partnerDailyInvestment.getUnbilledAmount(), partnerDailyInvestment.getGrnPendingAmount(), partnerDailyInvestment.getMinInvestment(), partnerDailyInvestment.getTotalInvestment(), partnerDailyInvestment.getShortInvestment(), partnerDailyInvestment.getUnbilledQty(), shortDaysMap.get(fofoId)));
|
| 1083 |
partnerDailyInvestment.getActivatedStockAmount() == 0 ? "-"
|
- |
|
| 1084 |
: "(" + partnerDailyInvestment.getActivatedStockAmount() + ")",
|
- |
|
| 1085 |
0, partnerDailyInvestment.getUnbilledAmount(), partnerDailyInvestment.getGrnPendingAmount(),
|
- |
|
| 1086 |
partnerDailyInvestment.getMinInvestment(), partnerDailyInvestment.getTotalInvestment(),
|
- |
|
| 1087 |
partnerDailyInvestment.getShortInvestment(), partnerDailyInvestment.getUnbilledQty(),
|
- |
|
| 1088 |
shortDaysMap.get(fofoId)));
|
- |
|
| 1089 |
partnerRowsMap.put(fofoStore.getId(), row);
|
1013 |
partnerRowsMap.put(fofoStore.getId(), row);
|
| 1090 |
rows.add(row);
|
1014 |
rows.add(row);
|
| 1091 |
|
1015 |
|
| 1092 |
}
|
1016 |
}
|
| 1093 |
|
1017 |
|
| 1094 |
String fileName = "InvestmentSummary-" + FormattingUtils.formatDate(LocalDateTime.now()) + ".csv";
|
1018 |
String fileName = "InvestmentSummary-" + FormattingUtils.formatDate(LocalDateTime.now()) + ".csv";
|
| 1095 |
|
1019 |
|
| 1096 |
if (sendTo == null) {
|
1020 |
if (sendTo == null) {
|
| 1097 |
for (Map.Entry<String, Set<Integer>> storeGuyEntry : csService.getAuthUserPartnerIdMapping().entrySet()) {
|
1021 |
for (Map.Entry<String, Set<Integer>> storeGuyEntry : csService.getAuthUserPartnerIdMapping().entrySet()) {
|
| 1098 |
List<List<?>> filteredRows = storeGuyEntry.getValue().stream().map(x -> partnerRowsMap.get(x))
|
1022 |
List<List<?>> filteredRows = storeGuyEntry.getValue().stream().map(x -> partnerRowsMap.get(x)).filter(x -> x != null).collect(Collectors.toList());
|
| 1099 |
.filter(x -> x != null).collect(Collectors.toList());
|
- |
|
| 1100 |
ByteArrayOutputStream baos = FileUtil.getCSVByteStream(headers, filteredRows);
|
1023 |
ByteArrayOutputStream baos = FileUtil.getCSVByteStream(headers, filteredRows);
|
| 1101 |
String[] sendToArray = new String[]{storeGuyEntry.getKey()};
|
1024 |
String[] sendToArray = new String[]{storeGuyEntry.getKey()};
|
| 1102 |
Utils.sendMailWithAttachment(googleMailSender, sendToArray, null, "Franchise Investment Summary", "PFA",
|
1025 |
Utils.sendMailWithAttachment(googleMailSender, sendToArray, null, "Franchise Investment Summary", "PFA", fileName, new ByteArrayResource(baos.toByteArray()));
|
| 1103 |
fileName, new ByteArrayResource(baos.toByteArray()));
|
- |
|
| 1104 |
}
|
1026 |
}
|
| 1105 |
sendTo = Arrays.asList("tarun.verma@smartdukaan.com", "kamini.sharma@smartdukaan.com",
|
- |
|
| 1106 |
"neeraj.gupta@smartdukaan.com", "amit.gupta@shop2020.in", "manish.gupta@smartdukaan.com",
|
1027 |
sendTo = Arrays.asList("tarun.verma@smartdukaan.com", "kamini.sharma@smartdukaan.com", "neeraj.gupta@smartdukaan.com", "amit.gupta@shop2020.in", "manish.gupta@smartdukaan.com", "niranjan.kala@smartdukaan.com");
|
| 1107 |
"niranjan.kala@smartdukaan.com");
|
- |
|
| 1108 |
}
|
1028 |
}
|
| 1109 |
|
1029 |
|
| 1110 |
ByteArrayOutputStream baos = FileUtil.getCSVByteStream(headers, rows);
|
1030 |
ByteArrayOutputStream baos = FileUtil.getCSVByteStream(headers, rows);
|
| 1111 |
String[] sendToArray = sendTo.toArray(new String[sendTo.size()]);
|
1031 |
String[] sendToArray = sendTo.toArray(new String[sendTo.size()]);
|
| 1112 |
Utils.sendMailWithAttachment(googleMailSender, sendToArray, null, "Franchise Investment Summary", "PFA",
|
1032 |
Utils.sendMailWithAttachment(googleMailSender, sendToArray, null, "Franchise Investment Summary", "PFA", fileName, new ByteArrayResource(baos.toByteArray()));
|
| 1113 |
fileName, new ByteArrayResource(baos.toByteArray()));
|
- |
|
| 1114 |
|
1033 |
|
| 1115 |
}
|
1034 |
}
|
| 1116 |
|
1035 |
|
| 1117 |
private Map<Integer, FofoReportingModel> getPartnerIdSalesHeaders() {
|
1036 |
private Map<Integer, FofoReportingModel> getPartnerIdSalesHeaders() {
|
| 1118 |
Map<String, SaleRoles> partnerEmailSalesMap = new HashMap<>();
|
1037 |
Map<String, SaleRoles> partnerEmailSalesMap = new HashMap<>();
|
| 1119 |
Map<String, SaleRoles> partnerEmailRBMMap = new HashMap<>();
|
1038 |
Map<String, SaleRoles> partnerEmailRBMMap = new HashMap<>();
|
| 1120 |
|
1039 |
|
| 1121 |
List<Position> positions = positionRepository
|
- |
|
| 1122 |
.selectPositionByCategoryIds(Arrays.asList(ProfitMandiConstants.TICKET_CATEGORY_SALES, ProfitMandiConstants.TICKET_CATEGORY_RBM));
|
1040 |
List<Position> positions = positionRepository.selectPositionByCategoryIds(Arrays.asList(ProfitMandiConstants.TICKET_CATEGORY_SALES, ProfitMandiConstants.TICKET_CATEGORY_RBM));
|
| 1123 |
Map<Integer, AuthUser> authUsersMap = authRepository.selectAllActiveUser().stream()
|
1041 |
Map<Integer, AuthUser> authUsersMap = authRepository.selectAllActiveUser().stream().collect(Collectors.toMap(x -> x.getId(), x -> x));
|
| 1124 |
.collect(Collectors.toMap(x -> x.getId(), x -> x));
|
- |
|
| 1125 |
Map<Integer, List<CustomRetailer>> positionIdRetailerMap = csService.getPositionCustomRetailerMap(positions);
|
1042 |
Map<Integer, List<CustomRetailer>> positionIdRetailerMap = csService.getPositionCustomRetailerMap(positions);
|
| 1126 |
for (Position position : positions) {
|
1043 |
for (Position position : positions) {
|
| 1127 |
List<CustomRetailer> crList = positionIdRetailerMap.get(position.getId());
|
1044 |
List<CustomRetailer> crList = positionIdRetailerMap.get(position.getId());
|
| 1128 |
if (crList == null)
|
1045 |
if (crList == null)
|
| 1129 |
continue;
|
1046 |
continue;
|
| Line 1170... |
Line 1087... |
| 1170 |
Set<CustomRetailer> allCrList = new HashSet<>();
|
1087 |
Set<CustomRetailer> allCrList = new HashSet<>();
|
| 1171 |
for (List<CustomRetailer> cr : positionIdRetailerMap.values()) {
|
1088 |
for (List<CustomRetailer> cr : positionIdRetailerMap.values()) {
|
| 1172 |
allCrList.addAll(cr);
|
1089 |
allCrList.addAll(cr);
|
| 1173 |
}
|
1090 |
}
|
| 1174 |
|
1091 |
|
| 1175 |
Map<Integer, FofoStore> fofoStoresMap = fofoStoreRepository.selectActiveStores().stream()
|
1092 |
Map<Integer, FofoStore> fofoStoresMap = fofoStoreRepository.selectActiveStores().stream().collect(Collectors.toMap(x -> x.getId(), x -> x));
|
| 1176 |
.collect(Collectors.toMap(x -> x.getId(), x -> x));
|
- |
|
| 1177 |
|
1093 |
|
| 1178 |
Map<Integer, FofoReportingModel> partnerIdSalesHeadersMap = new HashMap<>();
|
1094 |
Map<Integer, FofoReportingModel> partnerIdSalesHeadersMap = new HashMap<>();
|
| 1179 |
|
1095 |
|
| 1180 |
for (CustomRetailer cr : allCrList) {
|
1096 |
for (CustomRetailer cr : allCrList) {
|
| 1181 |
FofoStore fofoStore = fofoStoresMap.get(cr.getPartnerId());
|
1097 |
FofoStore fofoStore = fofoStoresMap.get(cr.getPartnerId());
|
| Line 1211... |
Line 1127... |
| 1211 |
this.sendPartnerInvestmentDetails(null);
|
1127 |
this.sendPartnerInvestmentDetails(null);
|
| 1212 |
}
|
1128 |
}
|
| 1213 |
|
1129 |
|
| 1214 |
public void sendAgeingReport(String... sendTo) throws Exception {
|
1130 |
public void sendAgeingReport(String... sendTo) throws Exception {
|
| 1215 |
|
1131 |
|
| 1216 |
InputStreamSource isr = reporticoService.getReportInputStreamSource(ReporticoProject.WAREHOUSENEW,
|
1132 |
InputStreamSource isr = reporticoService.getReportInputStreamSource(ReporticoProject.WAREHOUSENEW, "itemstockageing.xml");
|
| 1217 |
"itemstockageing.xml");
|
- |
|
| 1218 |
InputStreamSource isr1 = reporticoService.getReportInputStreamSource(ReporticoProject.FOCO,
|
1133 |
InputStreamSource isr1 = reporticoService.getReportInputStreamSource(ReporticoProject.FOCO, "ItemwiseOverallPendingIndent.xml");
|
| 1219 |
"ItemwiseOverallPendingIndent.xml");
|
- |
|
| 1220 |
Attachment attachment = new Attachment(
|
1134 |
Attachment attachment = new Attachment(
|
| 1221 |
"ageing-report-" + FormattingUtils.formatDate(LocalDateTime.now().minusDays(1)) + ".csv", isr);
|
1135 |
"ageing-report-" + FormattingUtils.formatDate(LocalDateTime.now().minusDays(1)) + ".csv", isr);
|
| 1222 |
Attachment attachment1 = new Attachment(
|
1136 |
Attachment attachment1 = new Attachment(
|
| 1223 |
"pending-indent-" + FormattingUtils.formatDate(LocalDateTime.now().minusDays(1)) + ".csv", isr1);
|
1137 |
"pending-indent-" + FormattingUtils.formatDate(LocalDateTime.now().minusDays(1)) + ".csv", isr1);
|
| 1224 |
|
1138 |
|
| 1225 |
Utils.sendMailWithAttachments(googleMailSender, STOCK_AGEING_MAIL_LIST, null, "Stock Ageing Report", "PFA",
|
1139 |
Utils.sendMailWithAttachments(googleMailSender, STOCK_AGEING_MAIL_LIST, null, "Stock Ageing Report", "PFA", attachment);
|
| 1226 |
attachment);
|
- |
|
| 1227 |
Utils.sendMailWithAttachments(googleMailSender, ITEMWISE_PENDING_INDENT_MAIL_LIST, null,
|
1140 |
Utils.sendMailWithAttachments(googleMailSender, ITEMWISE_PENDING_INDENT_MAIL_LIST, null, "Itemwise Pending indent", "PFA", attachment1);
|
| 1228 |
"Itemwise Pending indent", "PFA", attachment1);
|
- |
|
| 1229 |
|
1141 |
|
| 1230 |
// Reports to be sent to mapped partners
|
1142 |
// Reports to be sent to mapped partners
|
| 1231 |
Map<String, Set<String>> storeGuysMap = csService.getAuthUserPartnerEmailMapping();
|
1143 |
Map<String, Set<String>> storeGuysMap = csService.getAuthUserPartnerEmailMapping();
|
| 1232 |
|
1144 |
|
| 1233 |
for (Map.Entry<String, Set<String>> storeGuyEntry : storeGuysMap.entrySet()) {
|
1145 |
for (Map.Entry<String, Set<String>> storeGuyEntry : storeGuysMap.entrySet()) {
|
| 1234 |
Map<String, String> params = new HashMap<>();
|
1146 |
Map<String, String> params = new HashMap<>();
|
| 1235 |
if (storeGuyEntry.getValue().size() == 0)
|
1147 |
if (storeGuyEntry.getValue().size() == 0)
|
| 1236 |
continue;
|
1148 |
continue;
|
| 1237 |
params.put("MANUAL_email", String.join(",", storeGuyEntry.getValue()));
|
1149 |
params.put("MANUAL_email", String.join(",", storeGuyEntry.getValue()));
|
| 1238 |
InputStreamSource isr3 = reporticoService.getReportInputStreamSource(ReporticoProject.FOCO,
|
1150 |
InputStreamSource isr3 = reporticoService.getReportInputStreamSource(ReporticoProject.FOCO, "focostockreport.xml", params);
|
| 1239 |
"focostockreport.xml", params);
|
- |
|
| 1240 |
Attachment attache = new Attachment(
|
1151 |
Attachment attache = new Attachment(
|
| 1241 |
"Franchise-stock-report" + FormattingUtils.formatDate(LocalDateTime.now()) + ".csv", isr3);
|
1152 |
"Franchise-stock-report" + FormattingUtils.formatDate(LocalDateTime.now()) + ".csv", isr3);
|
| 1242 |
System.out.println(storeGuyEntry.getValue());
|
1153 |
System.out.println(storeGuyEntry.getValue());
|
| 1243 |
Utils.sendMailWithAttachments(googleMailSender, new String[]{storeGuyEntry.getKey()}, null,
|
1154 |
Utils.sendMailWithAttachments(googleMailSender, new String[]{storeGuyEntry.getKey()}, null, "Franchise Stock Report", "PFA", attache);
|
| 1244 |
"Franchise Stock Report", "PFA", attache);
|
- |
|
| 1245 |
}
|
1155 |
}
|
| 1246 |
|
1156 |
|
| 1247 |
}
|
1157 |
}
|
| 1248 |
|
1158 |
|
| 1249 |
public void sendIndentTertiary() throws Exception {
|
1159 |
public void sendIndentTertiary() throws Exception {
|
| 1250 |
|
1160 |
|
| 1251 |
InputStreamSource isr = reporticoService.getReportInputStreamSource(ReporticoProject.FOCO,
|
1161 |
InputStreamSource isr = reporticoService.getReportInputStreamSource(ReporticoProject.FOCO, "indentandtertiary.xml");
|
| 1252 |
"indentandtertiary.xml");
|
- |
|
| 1253 |
Attachment attachment = new Attachment(
|
1162 |
Attachment attachment = new Attachment(
|
| 1254 |
"indentandtertiary-report-" + FormattingUtils.formatDate(LocalDateTime.now()) + ".csv", isr);
|
1163 |
"indentandtertiary-report-" + FormattingUtils.formatDate(LocalDateTime.now()) + ".csv", isr);
|
| 1255 |
Utils.sendMailWithAttachments(googleMailSender, INDENT_TERTIARY_MAIL_LIST, null, "Indent Tertiary Report",
|
1164 |
Utils.sendMailWithAttachments(googleMailSender, INDENT_TERTIARY_MAIL_LIST, null, "Indent Tertiary Report", "PFA", attachment);
|
| 1256 |
"PFA", attachment);
|
- |
|
| 1257 |
|
1165 |
|
| 1258 |
}
|
1166 |
}
|
| 1259 |
|
1167 |
|
| 1260 |
public void sendAttendanceMorningAlert() throws Exception {
|
1168 |
public void sendAttendanceMorningAlert() throws Exception {
|
| 1261 |
LocalDateTime moriningTime = LocalDate.now().atTime(10, 31);
|
1169 |
LocalDateTime moriningTime = LocalDate.now().atTime(10, 31);
|
| 1262 |
List<AuthUser> authUsers = authRepository.selectAllActiveUser();
|
1170 |
List<AuthUser> authUsers = authRepository.selectAllActiveUser();
|
| 1263 |
Map<String, AuthUser> authUserEmailMap = authUsers.stream().filter(x -> x.isActive())
|
1171 |
Map<String, AuthUser> authUserEmailMap = authUsers.stream().filter(x -> x.isActive()).collect(Collectors.toMap(x -> x.getEmailId(), x -> x));
|
| 1264 |
.collect(Collectors.toMap(x -> x.getEmailId(), x -> x));
|
- |
|
| 1265 |
|
1172 |
|
| 1266 |
List<User> users = dtrUserRepository.selectAllByEmailIds(new ArrayList<>(authUserEmailMap.keySet()));
|
1173 |
List<User> users = dtrUserRepository.selectAllByEmailIds(new ArrayList<>(authUserEmailMap.keySet()));
|
| 1267 |
Map<String, User> userMap = users.stream().collect(Collectors.toMap(x -> x.getEmailId(), x -> x));
|
1174 |
Map<String, User> userMap = users.stream().collect(Collectors.toMap(x -> x.getEmailId(), x -> x));
|
| 1268 |
|
1175 |
|
| 1269 |
List<EmployeeAttendance> employeeAttendances = employeeAttendanceRepository
|
- |
|
| 1270 |
.selectAllByDatesBetween(LocalDate.now().atStartOfDay(), LocalDateTime.now());
|
1176 |
List<EmployeeAttendance> employeeAttendances = employeeAttendanceRepository.selectAllByDatesBetween(LocalDate.now().atStartOfDay(), LocalDateTime.now());
|
| 1271 |
|
1177 |
|
| 1272 |
Map<Integer, Optional<EmployeeAttendance>> employeeMorningAttendance = employeeAttendances.stream()
|
1178 |
Map<Integer, Optional<EmployeeAttendance>> employeeMorningAttendance = employeeAttendances.stream().collect(groupingBy(EmployeeAttendance::getUserId, Collectors.minBy(Comparator.comparing(EmployeeAttendance::getCreateTimestamp))));
|
| 1273 |
.collect(groupingBy(EmployeeAttendance::getUserId,
|
- |
|
| 1274 |
Collectors.minBy(Comparator.comparing(EmployeeAttendance::getCreateTimestamp))));
|
- |
|
| 1275 |
for (AuthUser authUser : authUsers) {
|
1179 |
for (AuthUser authUser : authUsers) {
|
| 1276 |
User user = userMap.get(authUser.getEmailId());
|
1180 |
User user = userMap.get(authUser.getEmailId());
|
| 1277 |
Optional<EmployeeAttendance> employeeAttendanceOptional = employeeMorningAttendance.get(user.getId());
|
1181 |
Optional<EmployeeAttendance> employeeAttendanceOptional = employeeMorningAttendance.get(user.getId());
|
| 1278 |
LOGGER.info("AuthUser - {}, employeeAttendanceOptional {}", authUser.getName(), employeeAttendanceOptional);
|
1182 |
LOGGER.info("AuthUser - {}, employeeAttendanceOptional {}", authUser.getName(), employeeAttendanceOptional);
|
| 1279 |
if (employeeAttendanceOptional != null) {
|
1183 |
if (employeeAttendanceOptional != null) {
|
| 1280 |
LOGGER.info("employeeAttendanceOptional.orElse {}", employeeAttendanceOptional.orElse(null));
|
1184 |
LOGGER.info("employeeAttendanceOptional.orElse {}", employeeAttendanceOptional.orElse(null));
|
| 1281 |
if (employeeAttendanceOptional.orElse(null) != null) {
|
1185 |
if (employeeAttendanceOptional.orElse(null) != null) {
|
| 1282 |
LOGGER.info("employeeAttendanceOptional.get().getCreateTimestamp() {}",
|
1186 |
LOGGER.info("employeeAttendanceOptional.get().getCreateTimestamp() {}", employeeAttendanceOptional.get().getCreateTimestamp());
|
| 1283 |
employeeAttendanceOptional.get().getCreateTimestamp());
|
- |
|
| 1284 |
}
|
1187 |
}
|
| 1285 |
}
|
1188 |
}
|
| 1286 |
if (employeeAttendanceOptional == null || employeeAttendanceOptional.orElse(null) == null
|
- |
|
| 1287 |
|| employeeAttendanceOptional.get().getCreateTimestamp().isAfter(moriningTime)) {
|
1189 |
if (employeeAttendanceOptional == null || employeeAttendanceOptional.orElse(null) == null || employeeAttendanceOptional.get().getCreateTimestamp().isAfter(moriningTime)) {
|
| 1288 |
LOGGER.info("Will Send Email to {}", authUser.getFullName());
|
1190 |
LOGGER.info("Will Send Email to {}", authUser.getFullName());
|
| 1289 |
String body = String.format(
|
1191 |
String body = String.format(
|
| 1290 |
"Dear %s,\n Pls note that you haven't punched your attendance by 10:30am%s. You have been marked absent for half the day.\n\nRegards\nHR Team",
|
1192 |
"Dear %s,\n Pls note that you haven't punched your attendance by 10:30am%s. You have been marked absent for half the day.\n\nRegards\nHR Team", authUser.getFullName(), (employeeAttendanceOptional == null || employeeAttendanceOptional.orElse(null) == null) ? "" : "(Punched at " + FormattingUtils.format(employeeAttendanceOptional.get().getCreateTimestamp()) + ")");
|
| 1291 |
authUser.getFullName(),
|
- |
|
| 1292 |
(employeeAttendanceOptional == null || employeeAttendanceOptional.orElse(null) == null) ? ""
|
- |
|
| 1293 |
: "(Punched at "
|
- |
|
| 1294 |
+ FormattingUtils.format(employeeAttendanceOptional.get().getCreateTimestamp())
|
- |
|
| 1295 |
+ ")");
|
- |
|
| 1296 |
|
1193 |
|
| 1297 |
Utils.sendMailWithAttachments(googleMailSender, new String[]{authUser.getEmailId()},
|
1194 |
Utils.sendMailWithAttachments(googleMailSender, new String[]{authUser.getEmailId()}, new String[]{"kangan.monga@smartdukaan.com"}, "Attendance Alert", body);
|
| 1298 |
new String[]{"kangan.monga@smartdukaan.com"}, "Attendance Alert", body);
|
- |
|
| 1299 |
|
1195 |
|
| 1300 |
}
|
1196 |
}
|
| 1301 |
}
|
1197 |
}
|
| 1302 |
|
1198 |
|
| 1303 |
}
|
1199 |
}
|
| 1304 |
|
1200 |
|
| 1305 |
public void sendAttendanceEveningAlert() throws Exception {
|
1201 |
public void sendAttendanceEveningAlert() throws Exception {
|
| 1306 |
List<AuthUser> authUsers = authRepository.selectAllActiveUser();
|
1202 |
List<AuthUser> authUsers = authRepository.selectAllActiveUser();
|
| 1307 |
Map<String, AuthUser> authUserEmailMap = authUsers.stream().filter(x -> x.isActive())
|
1203 |
Map<String, AuthUser> authUserEmailMap = authUsers.stream().filter(x -> x.isActive()).collect(Collectors.toMap(x -> x.getEmailId(), x -> x));
|
| 1308 |
.collect(Collectors.toMap(x -> x.getEmailId(), x -> x));
|
- |
|
| 1309 |
|
1204 |
|
| 1310 |
List<User> users = dtrUserRepository.selectAllByEmailIds(new ArrayList<>(authUserEmailMap.keySet()));
|
1205 |
List<User> users = dtrUserRepository.selectAllByEmailIds(new ArrayList<>(authUserEmailMap.keySet()));
|
| 1311 |
Map<String, User> userMap = users.stream().collect(Collectors.toMap(x -> x.getEmailId(), x -> x));
|
1206 |
Map<String, User> userMap = users.stream().collect(Collectors.toMap(x -> x.getEmailId(), x -> x));
|
| 1312 |
|
1207 |
|
| 1313 |
Map<Integer, List<EmployeeAttendance>> employeeAttendancesMap = employeeAttendanceRepository
|
1208 |
Map<Integer, List<EmployeeAttendance>> employeeAttendancesMap = employeeAttendanceRepository.selectAllByDatesBetween(LocalDate.now().atStartOfDay(), LocalDateTime.now()).stream().collect(groupingBy(x -> x.getUserId()));
|
| 1314 |
.selectAllByDatesBetween(LocalDate.now().atStartOfDay(), LocalDateTime.now()).stream()
|
- |
|
| 1315 |
.collect(groupingBy(x -> x.getUserId()));
|
- |
|
| 1316 |
|
1209 |
|
| 1317 |
for (AuthUser authUser : authUsers) {
|
1210 |
for (AuthUser authUser : authUsers) {
|
| 1318 |
User user = userMap.get(authUser.getEmailId());
|
1211 |
User user = userMap.get(authUser.getEmailId());
|
| 1319 |
String body = null;
|
1212 |
String body = null;
|
| 1320 |
List<EmployeeAttendance> employeeAttendances = employeeAttendancesMap.get(user.getId());
|
1213 |
List<EmployeeAttendance> employeeAttendances = employeeAttendancesMap.get(user.getId());
|
| 1321 |
if (employeeAttendances == null) {
|
1214 |
if (employeeAttendances == null) {
|
| 1322 |
body = String.format(
|
1215 |
body = String.format(
|
| 1323 |
"Dear %s,\n No attendance has been registered by you today. You have been marked absent for the day.\n\nRegards\nHR Team",
|
1216 |
"Dear %s,\n No attendance has been registered by you today. You have been marked absent for the day.\n\nRegards\nHR Team", authUser.getFullName());
|
| 1324 |
authUser.getFullName());
|
- |
|
| 1325 |
} else {
|
1217 |
} else {
|
| 1326 |
List<LocalDateTime> punchTimes = employeeAttendances.stream()
|
- |
|
| 1327 |
.sorted(Comparator.comparing(EmployeeAttendance::getCreateTimestamp))
|
1218 |
List<LocalDateTime> punchTimes = employeeAttendances.stream().sorted(Comparator.comparing(EmployeeAttendance::getCreateTimestamp)).map(x -> x.getCreateTimestamp()).collect(Collectors.toList());
|
| 1328 |
.map(x -> x.getCreateTimestamp()).collect(Collectors.toList());
|
- |
|
| 1329 |
if (punchTimes.size() == 1) {
|
1219 |
if (punchTimes.size() == 1) {
|
| 1330 |
// body = String.format("Dear %s,\n Pls note that you haven't punched out yet.
|
1220 |
// body = String.format("Dear %s,\n Pls note that you haven't punched out yet.
|
| 1331 |
// You have been marked absent for half the day. You may contact your manager
|
1221 |
// You have been marked absent for half the day. You may contact your manager
|
| 1332 |
// and get it regularise.\n\nRegards\nHR Team", authUser.getFullName());
|
1222 |
// and get it regularise.\n\nRegards\nHR Team", authUser.getFullName());
|
| 1333 |
} else {
|
1223 |
} else {
|
| Line 1335... |
Line 1225... |
| 1335 |
LocalDateTime lastPunch = punchTimes.get(punchTimes.size() - 1);
|
1225 |
LocalDateTime lastPunch = punchTimes.get(punchTimes.size() - 1);
|
| 1336 |
Duration duration = Duration.between(firstPunch, lastPunch);
|
1226 |
Duration duration = Duration.between(firstPunch, lastPunch);
|
| 1337 |
boolean hoursCompleted = lastPunch.isAfter(firstPunch.plusHours(8).plusMinutes(30));
|
1227 |
boolean hoursCompleted = lastPunch.isAfter(firstPunch.plusHours(8).plusMinutes(30));
|
| 1338 |
if (!hoursCompleted) {
|
1228 |
if (!hoursCompleted) {
|
| 1339 |
body = String.format(
|
1229 |
body = String.format(
|
| 1340 |
"Dear %s,\n Pls note that you haven't completed 8.30 Hrs (%d.%d Hrs). You have been marked absent for half the day.\n\nRegards\nHR Team",
|
1230 |
"Dear %s,\n Pls note that you haven't completed 8.30 Hrs (%d.%d Hrs). You have been marked absent for half the day.\n\nRegards\nHR Team", authUser.getFullName(), duration.toHours(), duration.toMinutes() - duration.toHours() * 60);
|
| 1341 |
authUser.getFullName(), duration.toHours(),
|
- |
|
| 1342 |
duration.toMinutes() - duration.toHours() * 60);
|
- |
|
| 1343 |
}
|
1231 |
}
|
| 1344 |
}
|
1232 |
}
|
| 1345 |
|
1233 |
|
| 1346 |
}
|
1234 |
}
|
| 1347 |
if (body != null) {
|
1235 |
if (body != null) {
|
| 1348 |
Utils.sendMailWithAttachments(googleMailSender, new String[]{authUser.getEmailId()},
|
1236 |
Utils.sendMailWithAttachments(googleMailSender, new String[]{authUser.getEmailId()}, new String[]{"kangan.monga@smartdukaan.com"}, "Attendance Alert", body);
|
| 1349 |
new String[]{"kangan.monga@smartdukaan.com"}, "Attendance Alert", body);
|
- |
|
| 1350 |
}
|
1237 |
}
|
| 1351 |
}
|
1238 |
}
|
| 1352 |
|
1239 |
|
| 1353 |
this.sendMailToHR();
|
1240 |
this.sendMailToHR();
|
| 1354 |
|
1241 |
|
| Line 1357... |
Line 1244... |
| 1357 |
private void sendMailToHR() throws Exception {
|
1244 |
private void sendMailToHR() throws Exception {
|
| 1358 |
Map<String, String> map = new HashMap<>();
|
1245 |
Map<String, String> map = new HashMap<>();
|
| 1359 |
String reporticoDate = FormattingUtils.formatReporitcoDate(LocalDateTime.now());
|
1246 |
String reporticoDate = FormattingUtils.formatReporitcoDate(LocalDateTime.now());
|
| 1360 |
map.put("MANUAL_datesBetween_FROMDATE", reporticoDate);
|
1247 |
map.put("MANUAL_datesBetween_FROMDATE", reporticoDate);
|
| 1361 |
map.put("MANUAL_datesBetween_FROMDATE", reporticoDate);
|
1248 |
map.put("MANUAL_datesBetween_FROMDATE", reporticoDate);
|
| 1362 |
InputStreamSource isr = reporticoService.getReportInputStreamSource(ReporticoProject.FOCO,
|
1249 |
InputStreamSource isr = reporticoService.getReportInputStreamSource(ReporticoProject.FOCO, "employeeattendance.xml");
|
| 1363 |
"employeeattendance.xml");
|
- |
|
| 1364 |
Attachment attachment = new Attachment("attendance-" + FormattingUtils.formatDate(LocalDateTime.now()) + ".csv",
|
1250 |
Attachment attachment = new Attachment("attendance-" + FormattingUtils.formatDate(LocalDateTime.now()) + ".csv", isr);
|
| 1365 |
isr);
|
- |
|
| 1366 |
Utils.sendMailWithAttachments(googleMailSender, EMPLOYEE_ATTENDANCE_MAIL_LIST, null,
|
- |
|
| 1367 |
"Attendance - " + FormattingUtils.formatDate(LocalDateTime.now()), "PFA Attendance", attachment);
|
1251 |
Utils.sendMailWithAttachments(googleMailSender, EMPLOYEE_ATTENDANCE_MAIL_LIST, null, "Attendance - " + FormattingUtils.formatDate(LocalDateTime.now()), "PFA Attendance", attachment);
|
| 1368 |
}
|
1252 |
}
|
| 1369 |
|
1253 |
|
| 1370 |
public void checkPartnerActiveStore() throws Exception {
|
1254 |
public void checkPartnerActiveStore() throws Exception {
|
| 1371 |
|
1255 |
|
| 1372 |
List<FofoStore> fofoStores = fofoStoreRepository.selectByStatus(true);
|
1256 |
List<FofoStore> fofoStores = fofoStoreRepository.selectByStatus(true);
|
| Line 1392... |
Line 1276... |
| 1392 |
}
|
1276 |
}
|
| 1393 |
|
1277 |
|
| 1394 |
}
|
1278 |
}
|
| 1395 |
|
1279 |
|
| 1396 |
public void sendAgeingReport() throws Exception {
|
1280 |
public void sendAgeingReport() throws Exception {
|
| 1397 |
sendAgeingReport("kamini.sharma@smartdukaan.com", "tarun.verma@smartdukaan.com",
|
- |
|
| 1398 |
"niranjan.kala@smartdukaan.com", "manish.gupta@smartdukaan.com", "kuldeep.kumar@smartdukaan.com");
|
1281 |
sendAgeingReport("kamini.sharma@smartdukaan.com", "tarun.verma@smartdukaan.com", "niranjan.kala@smartdukaan.com", "manish.gupta@smartdukaan.com", "kuldeep.kumar@smartdukaan.com");
|
| 1399 |
}
|
1282 |
}
|
| 1400 |
|
1283 |
|
| 1401 |
public void moveImeisToPriceDropImeis() throws Exception {
|
1284 |
public void moveImeisToPriceDropImeis() throws Exception {
|
| 1402 |
List<PriceDrop> priceDrops = priceDropRepository.selectAll();
|
1285 |
List<PriceDrop> priceDrops = priceDropRepository.selectAll();
|
| 1403 |
for (PriceDrop priceDrop : priceDrops) {
|
1286 |
for (PriceDrop priceDrop : priceDrops) {
|
| Line 1409... |
Line 1292... |
| 1409 |
LocalDate curDate = LocalDate.now();
|
1292 |
LocalDate curDate = LocalDate.now();
|
| 1410 |
List<PartnerDailyInvestment> pdis = partnerDailyInvestmentRepository.selectAll(curDate.minusDays(2));
|
1293 |
List<PartnerDailyInvestment> pdis = partnerDailyInvestmentRepository.selectAll(curDate.minusDays(2));
|
| 1411 |
System.out.println(pdis.size());
|
1294 |
System.out.println(pdis.size());
|
| 1412 |
for (PartnerDailyInvestment pdi : pdis) {
|
1295 |
for (PartnerDailyInvestment pdi : pdis) {
|
| 1413 |
int fofoId = pdi.getFofoId();
|
1296 |
int fofoId = pdi.getFofoId();
|
| 1414 |
for (PartnerDailyInvestment investment : Lists
|
- |
|
| 1415 |
.reverse(partnerDailyInvestmentRepository.selectAll(fofoId, null, null))) {
|
1297 |
for (PartnerDailyInvestment investment : Lists.reverse(partnerDailyInvestmentRepository.selectAll(fofoId, null, null))) {
|
| 1416 |
float statementAmount = walletService.getOpeningTill(fofoId,
|
- |
|
| 1417 |
investment.getDate().plusDays(1).atTime(LocalTime.of(4, 0)));
|
1298 |
float statementAmount = walletService.getOpeningTill(fofoId, investment.getDate().plusDays(1).atTime(LocalTime.of(4, 0)));
|
| 1418 |
CustomRetailer retailer = retailerService.getFofoRetailer(fofoId);
|
1299 |
CustomRetailer retailer = retailerService.getFofoRetailer(fofoId);
|
| 1419 |
LOGGER.info("{}\t{}\t{}\t{}\t{}", fofoId, retailer.getBusinessName(), retailer.getMobileNumber(),
|
1300 |
LOGGER.info("{}\t{}\t{}\t{}\t{}", fofoId, retailer.getBusinessName(), retailer.getMobileNumber(), investment.getDate().toString(), investment.getWalletAmount(), statementAmount);
|
| 1420 |
investment.getDate().toString(), investment.getWalletAmount(), statementAmount);
|
- |
|
| 1421 |
|
1301 |
|
| 1422 |
}
|
1302 |
}
|
| 1423 |
}
|
1303 |
}
|
| 1424 |
|
1304 |
|
| 1425 |
}
|
1305 |
}
|
| 1426 |
|
1306 |
|
| 1427 |
@Autowired
|
1307 |
@Autowired
|
| 1428 |
StateRepository stateRepository;
|
1308 |
StateRepository stateRepository;
|
| 1429 |
|
1309 |
|
| 1430 |
public void gst() throws Exception {
|
1310 |
public void gst() throws Exception {
|
| 1431 |
List<FofoOrder> fofoOrders = fofoOrderRepository.selectBetweenSaleDate(LocalDate.of(2021, 8, 16).atStartOfDay(),
|
1311 |
List<FofoOrder> fofoOrders = fofoOrderRepository.selectBetweenSaleDate(LocalDate.of(2021, 8, 16).atStartOfDay(), LocalDateTime.now());
|
| 1432 |
LocalDateTime.now());
|
- |
|
| 1433 |
for (FofoOrder fofoOrder : fofoOrders) {
|
1312 |
for (FofoOrder fofoOrder : fofoOrders) {
|
| 1434 |
int retailerAddressId = retailerRegisteredAddressRepository
|
1313 |
int retailerAddressId = retailerRegisteredAddressRepository.selectAddressIdByRetailerId(fofoOrder.getFofoId());
|
| 1435 |
.selectAddressIdByRetailerId(fofoOrder.getFofoId());
|
- |
|
| 1436 |
|
1314 |
|
| 1437 |
Address retailerAddress = addressRepository.selectById(retailerAddressId);
|
1315 |
Address retailerAddress = addressRepository.selectById(retailerAddressId);
|
| 1438 |
CustomerAddress customerAddress = customerAddressRepository.selectById(fofoOrder.getCustomerAddressId());
|
1316 |
CustomerAddress customerAddress = customerAddressRepository.selectById(fofoOrder.getCustomerAddressId());
|
| 1439 |
Integer stateId = null;
|
1317 |
Integer stateId = null;
|
| 1440 |
if (customerAddress.getState().equals(retailerAddress.getState())) {
|
1318 |
if (customerAddress.getState().equals(retailerAddress.getState())) {
|
| Line 1465... |
Line 1343... |
| 1465 |
foi.setSgstRate(0);
|
1343 |
foi.setSgstRate(0);
|
| 1466 |
foi.setCgstRate(0);
|
1344 |
foi.setCgstRate(0);
|
| 1467 |
foi.setIgstRate(itemIdIgstTaxRateMap.get(foi.getItemId()));
|
1345 |
foi.setIgstRate(itemIdIgstTaxRateMap.get(foi.getItemId()));
|
| 1468 |
|
1346 |
|
| 1469 |
LOGGER.info("Invoice {}, Date {}", fofoOrder.getInvoiceNumber(), fofoOrder.getCreateTimestamp());
|
1347 |
LOGGER.info("Invoice {}, Date {}", fofoOrder.getInvoiceNumber(), fofoOrder.getCreateTimestamp());
|
| 1470 |
LOGGER.info("customerAddress.getState() {}, retailerAddress.getState() {}",
|
1348 |
LOGGER.info("customerAddress.getState() {}, retailerAddress.getState() {}", customerAddress.getState(), retailerAddress.getState());
|
| 1471 |
customerAddress.getState(), retailerAddress.getState());
|
- |
|
| 1472 |
LOGGER.info("Rates getIgstRate() {}", itemIdIgstTaxRateMap.get(foi.getItemId()));
|
1349 |
LOGGER.info("Rates getIgstRate() {}", itemIdIgstTaxRateMap.get(foi.getItemId()));
|
| 1473 |
|
1350 |
|
| 1474 |
} else if (stateId != null && sgstRate == 0 && cgstRate == 0) {
|
1351 |
} else if (stateId != null && sgstRate == 0 && cgstRate == 0) {
|
| 1475 |
|
1352 |
|
| 1476 |
foi.setIgstRate(0);
|
1353 |
foi.setIgstRate(0);
|
| 1477 |
foi.setCgstRate(itemIdStateTaxRateMap.get(foi.getItemId()).getCgstRate());
|
1354 |
foi.setCgstRate(itemIdStateTaxRateMap.get(foi.getItemId()).getCgstRate());
|
| 1478 |
foi.setSgstRate(itemIdStateTaxRateMap.get(foi.getItemId()).getSgstRate());
|
1355 |
foi.setSgstRate(itemIdStateTaxRateMap.get(foi.getItemId()).getSgstRate());
|
| 1479 |
|
1356 |
|
| 1480 |
LOGGER.info("Invoice {}, Date {}", fofoOrder.getInvoiceNumber(), fofoOrder.getCreateTimestamp());
|
1357 |
LOGGER.info("Invoice {}, Date {}", fofoOrder.getInvoiceNumber(), fofoOrder.getCreateTimestamp());
|
| 1481 |
LOGGER.info("customerAddress.getState() {}, retailerAddress.getState() {}",
|
1358 |
LOGGER.info("customerAddress.getState() {}, retailerAddress.getState() {}", customerAddress.getState(), retailerAddress.getState());
|
| 1482 |
customerAddress.getState(), retailerAddress.getState());
|
- |
|
| 1483 |
LOGGER.info("Rates getCgstRate() {}, getSgstRate() {}",
|
- |
|
| 1484 |
itemIdStateTaxRateMap.get(foi.getItemId()).getCgstRate(),
|
- |
|
| 1485 |
itemIdStateTaxRateMap.get(foi.getItemId()).getSgstRate());
|
1359 |
LOGGER.info("Rates getCgstRate() {}, getSgstRate() {}", itemIdStateTaxRateMap.get(foi.getItemId()).getCgstRate(), itemIdStateTaxRateMap.get(foi.getItemId()).getSgstRate());
|
| 1486 |
}
|
1360 |
}
|
| 1487 |
}
|
1361 |
}
|
| 1488 |
}
|
1362 |
}
|
| 1489 |
|
1363 |
|
| 1490 |
}
|
1364 |
}
|
| Line 1505... |
Line 1379... |
| 1505 |
List<SchemeInOut> siosCreated = schemeInOutRepository.selectAllByCreateDate(startDate, endDate);
|
1379 |
List<SchemeInOut> siosCreated = schemeInOutRepository.selectAllByCreateDate(startDate, endDate);
|
| 1506 |
List<SchemeInOut> siosRefunded = schemeInOutRepository.selectAllByRefundDate(startDate, endDate);
|
1380 |
List<SchemeInOut> siosRefunded = schemeInOutRepository.selectAllByRefundDate(startDate, endDate);
|
| 1507 |
double totalSchemeDisbursed = siosCreated.stream().mapToDouble(x -> x.getAmount()).sum();
|
1381 |
double totalSchemeDisbursed = siosCreated.stream().mapToDouble(x -> x.getAmount()).sum();
|
| 1508 |
double totalSchemeRolledback = siosRefunded.stream().mapToDouble(x -> x.getAmount()).sum();
|
1382 |
double totalSchemeRolledback = siosRefunded.stream().mapToDouble(x -> x.getAmount()).sum();
|
| 1509 |
double netSchemeDisbursed = totalSchemeDisbursed - totalSchemeRolledback;
|
1383 |
double netSchemeDisbursed = totalSchemeDisbursed - totalSchemeRolledback;
|
| 1510 |
List<WalletReferenceType> walletReferenceTypes = Arrays.asList(WalletReferenceType.SCHEME_IN,
|
1384 |
List<WalletReferenceType> walletReferenceTypes = Arrays.asList(WalletReferenceType.SCHEME_IN, WalletReferenceType.SCHEME_OUT);
|
| 1511 |
WalletReferenceType.SCHEME_OUT);
|
- |
|
| 1512 |
List<UserWalletHistory> history = userWalletHistoryRepository.selectAllByDateType(startDate, endDate,
|
1385 |
List<UserWalletHistory> history = userWalletHistoryRepository.selectAllByDateType(startDate, endDate, walletReferenceTypes);
|
| 1513 |
walletReferenceTypes);
|
- |
|
| 1514 |
double schemeAmountWalletTotal = history.stream().mapToDouble(x -> x.getAmount()).sum();
|
1386 |
double schemeAmountWalletTotal = history.stream().mapToDouble(x -> x.getAmount()).sum();
|
| 1515 |
if (Math.abs(netSchemeDisbursed - schemeAmountWalletTotal) > 10d) {
|
1387 |
if (Math.abs(netSchemeDisbursed - schemeAmountWalletTotal) > 10d) {
|
| 1516 |
LOGGER.info("Scheme Amount mismatched for Date {}", date);
|
1388 |
LOGGER.info("Scheme Amount mismatched for Date {}", date);
|
| 1517 |
|
1389 |
|
| 1518 |
Map<Integer, Double> inventoryItemSchemeIO = siosCreated.stream().collect(groupingBy(x -> x.getInventoryItemId(), Collectors.summingDouble(SchemeInOut::getAmount)));
|
1390 |
Map<Integer, Double> inventoryItemSchemeIO = siosCreated.stream().collect(groupingBy(x -> x.getInventoryItemId(), Collectors.summingDouble(SchemeInOut::getAmount)));
|
| 1519 |
|
1391 |
|
| 1520 |
Map<Integer, Double> userSchemeMap = inventoryItemRepository.selectByIds(inventoryItemSchemeIO.keySet())
|
1392 |
Map<Integer, Double> userSchemeMap = inventoryItemRepository.selectByIds(inventoryItemSchemeIO.keySet()).stream().collect(groupingBy(x -> x.getFofoId(), Collectors.summingDouble(x -> inventoryItemSchemeIO.get(x.getId()))));
|
| 1521 |
.stream().collect(groupingBy(x -> x.getFofoId(),
|
- |
|
| 1522 |
Collectors.summingDouble(x -> inventoryItemSchemeIO.get(x.getId()))));
|
- |
|
| 1523 |
|
1393 |
|
| 1524 |
Map<Integer, Double> inventoryItemSchemeIORefunded = siosRefunded.stream().collect(groupingBy(x -> x.getInventoryItemId(), Collectors.summingDouble(SchemeInOut::getAmount)));
|
1394 |
Map<Integer, Double> inventoryItemSchemeIORefunded = siosRefunded.stream().collect(groupingBy(x -> x.getInventoryItemId(), Collectors.summingDouble(SchemeInOut::getAmount)));
|
| 1525 |
|
1395 |
|
| 1526 |
Map<Integer, Double> userSchemeRefundedMap = inventoryItemRepository
|
1396 |
Map<Integer, Double> userSchemeRefundedMap = inventoryItemRepository.selectByIds(inventoryItemSchemeIORefunded.keySet()).stream().collect(groupingBy(x -> x.getFofoId(), Collectors.summingDouble(x -> inventoryItemSchemeIORefunded.get(x.getId()))));
|
| 1527 |
.selectByIds(inventoryItemSchemeIORefunded.keySet()).stream()
|
- |
|
| 1528 |
.collect(groupingBy(x -> x.getFofoId(),
|
- |
|
| 1529 |
Collectors.summingDouble(x -> inventoryItemSchemeIORefunded.get(x.getId()))));
|
- |
|
| 1530 |
|
1397 |
|
| 1531 |
Map<Integer, Double> finalUserSchemeAmountMap = new HashMap<>();
|
1398 |
Map<Integer, Double> finalUserSchemeAmountMap = new HashMap<>();
|
| 1532 |
|
1399 |
|
| 1533 |
for (Map.Entry<Integer, Double> schemeAmount : userSchemeRefundedMap.entrySet()) {
|
1400 |
for (Map.Entry<Integer, Double> schemeAmount : userSchemeRefundedMap.entrySet()) {
|
| 1534 |
if (!finalUserSchemeAmountMap.containsKey(schemeAmount.getKey())) {
|
1401 |
if (!finalUserSchemeAmountMap.containsKey(schemeAmount.getKey())) {
|
| 1535 |
finalUserSchemeAmountMap.put(schemeAmount.getKey(), schemeAmount.getValue());
|
1402 |
finalUserSchemeAmountMap.put(schemeAmount.getKey(), schemeAmount.getValue());
|
| 1536 |
} else {
|
1403 |
} else {
|
| 1537 |
finalUserSchemeAmountMap.put(schemeAmount.getKey(),
|
- |
|
| 1538 |
finalUserSchemeAmountMap.get(schemeAmount.getKey()) + schemeAmount.getValue());
|
1404 |
finalUserSchemeAmountMap.put(schemeAmount.getKey(), finalUserSchemeAmountMap.get(schemeAmount.getKey()) + schemeAmount.getValue());
|
| 1539 |
}
|
1405 |
}
|
| 1540 |
}
|
1406 |
}
|
| 1541 |
Map<Integer, Integer> userWalletMap = userWalletRepository
|
- |
|
| 1542 |
.selectByRetailerIds(finalUserSchemeAmountMap.keySet()).stream()
|
- |
|
| 1543 |
.collect(Collectors.toMap(UserWallet::getUserId, UserWallet::getId));
|
1407 |
Map<Integer, Integer> userWalletMap = userWalletRepository.selectByRetailerIds(finalUserSchemeAmountMap.keySet()).stream().collect(Collectors.toMap(UserWallet::getUserId, UserWallet::getId));
|
| 1544 |
|
1408 |
|
| 1545 |
Map<Integer, Double> walletAmountMap = history.stream().collect(groupingBy(
|
1409 |
Map<Integer, Double> walletAmountMap = history.stream().collect(groupingBy(
|
| 1546 |
UserWalletHistory::getWalletId, Collectors.summingDouble((UserWalletHistory::getAmount))));
|
1410 |
UserWalletHistory::getWalletId, Collectors.summingDouble((UserWalletHistory::getAmount))));
|
| 1547 |
for (Map.Entry<Integer, Double> userAmount : walletAmountMap.entrySet()) {
|
1411 |
for (Map.Entry<Integer, Double> userAmount : walletAmountMap.entrySet()) {
|
| 1548 |
double diff = Math.abs(finalUserSchemeAmountMap.get(userAmount.getKey()) - userAmount.getValue());
|
1412 |
double diff = Math.abs(finalUserSchemeAmountMap.get(userAmount.getKey()) - userAmount.getValue());
|
| Line 1553... |
Line 1417... |
| 1553 |
}
|
1417 |
}
|
| 1554 |
|
1418 |
|
| 1555 |
}
|
1419 |
}
|
| 1556 |
|
1420 |
|
| 1557 |
public void dryRunSchemeReco() throws Exception {
|
1421 |
public void dryRunSchemeReco() throws Exception {
|
| 1558 |
Map<Integer, Integer> userWalletMap = userWalletRepository.selectAll().stream()
|
1422 |
Map<Integer, Integer> userWalletMap = userWalletRepository.selectAll().stream().collect(Collectors.toMap(UserWallet::getUserId, UserWallet::getId));
|
| 1559 |
.collect(Collectors.toMap(UserWallet::getUserId, UserWallet::getId));
|
- |
|
| 1560 |
|
1423 |
|
| 1561 |
List<UserWalletHistory> userWalletHistory = new ArrayList<>();
|
1424 |
List<UserWalletHistory> userWalletHistory = new ArrayList<>();
|
| 1562 |
List<SchemeInOut> rolledbackSios = new ArrayList<>();
|
1425 |
List<SchemeInOut> rolledbackSios = new ArrayList<>();
|
| 1563 |
Map<Integer, SchemeType> schemeTypeMap = schemeRepository.selectAll().stream()
|
1426 |
Map<Integer, SchemeType> schemeTypeMap = schemeRepository.selectAll().stream().collect(Collectors.toMap(Scheme::getId, Scheme::getType));
|
| 1564 |
.collect(Collectors.toMap(Scheme::getId, Scheme::getType));
|
- |
|
| 1565 |
Set<String> serialNumbersConsidered = new HashSet<>();
|
1427 |
Set<String> serialNumbersConsidered = new HashSet<>();
|
| 1566 |
|
1428 |
|
| 1567 |
LocalDateTime startDate = LocalDate.of(2018, 3, 1).atStartOfDay();
|
1429 |
LocalDateTime startDate = LocalDate.of(2018, 3, 1).atStartOfDay();
|
| 1568 |
LocalDateTime endDate = LocalDate.now().atStartOfDay();
|
1430 |
LocalDateTime endDate = LocalDate.now().atStartOfDay();
|
| 1569 |
List<Purchase> purchases = purchaseRepository.selectAllBetweenPurchaseDate(startDate, endDate);
|
1431 |
List<Purchase> purchases = purchaseRepository.selectAllBetweenPurchaseDate(startDate, endDate);
|
| 1570 |
|
1432 |
|
| 1571 |
Map<Integer, String> storeNameMap = fofoStoreRepository.getStoresMap();
|
1433 |
Map<Integer, String> storeNameMap = fofoStoreRepository.getStoresMap();
|
| 1572 |
purchases.stream().forEach(purchase -> {
|
1434 |
purchases.stream().forEach(purchase -> {
|
| 1573 |
float amountToRollback = 0;
|
1435 |
float amountToRollback = 0;
|
| 1574 |
String description = "Adjustment of Duplicate Scheme for Purchase Invoice "
|
1436 |
String description = "Adjustment of Duplicate Scheme for Purchase Invoice " + purchase.getPurchaseReference();
|
| 1575 |
+ purchase.getPurchaseReference();
|
- |
|
| 1576 |
Map<Integer, String> inventorySerialNumberMap = inventoryItemRepository.selectByPurchaseId(purchase.getId())
|
1437 |
Map<Integer, String> inventorySerialNumberMap = inventoryItemRepository.selectByPurchaseId(purchase.getId()).stream().filter(ii -> ii.getSerialNumber() != null).collect(Collectors.toMap(InventoryItem::getId, InventoryItem::getSerialNumber));
|
| 1577 |
.stream().filter(ii -> ii.getSerialNumber() != null)
|
- |
|
| 1578 |
.collect(Collectors.toMap(InventoryItem::getId, InventoryItem::getSerialNumber));
|
- |
|
| 1579 |
if (inventorySerialNumberMap.size() > 0) {
|
1438 |
if (inventorySerialNumberMap.size() > 0) {
|
| 1580 |
for (Map.Entry<Integer, String> inventorySerialNumberEntry : inventorySerialNumberMap.entrySet()) {
|
1439 |
for (Map.Entry<Integer, String> inventorySerialNumberEntry : inventorySerialNumberMap.entrySet()) {
|
| 1581 |
String serialNumber = inventorySerialNumberEntry.getValue();
|
1440 |
String serialNumber = inventorySerialNumberEntry.getValue();
|
| 1582 |
int inventoryItemId = inventorySerialNumberEntry.getKey();
|
1441 |
int inventoryItemId = inventorySerialNumberEntry.getKey();
|
| 1583 |
if (serialNumbersConsidered.contains(serialNumber)) {
|
1442 |
if (serialNumbersConsidered.contains(serialNumber)) {
|
| 1584 |
// This will rollback scheme for differenct orders for same serial
|
1443 |
// This will rollback scheme for differenct orders for same serial
|
| 1585 |
List<SchemeInOut> sios = schemeInOutRepository
|
1444 |
List<SchemeInOut> sios = schemeInOutRepository.selectByInventoryItemIds(new HashSet<>(Arrays.asList(inventoryItemId))).stream().filter(x -> x.getRolledBackTimestamp() == null && schemeTypeMap.get(x.getSchemeId()).equals(SchemeType.IN)).collect(Collectors.toList());
|
| 1586 |
.selectByInventoryItemIds(new HashSet<>(Arrays.asList(inventoryItemId))).stream()
|
- |
|
| 1587 |
.filter(x -> x.getRolledBackTimestamp() == null
|
- |
|
| 1588 |
&& schemeTypeMap.get(x.getSchemeId()).equals(SchemeType.IN))
|
- |
|
| 1589 |
.collect(Collectors.toList());
|
- |
|
| 1590 |
Collections.reverse(sios);
|
1445 |
Collections.reverse(sios);
|
| 1591 |
for (SchemeInOut sio : sios) {
|
1446 |
for (SchemeInOut sio : sios) {
|
| 1592 |
sio.setRolledBackTimestamp(LocalDateTime.now());
|
1447 |
sio.setRolledBackTimestamp(LocalDateTime.now());
|
| 1593 |
amountToRollback += sio.getAmount();
|
1448 |
amountToRollback += sio.getAmount();
|
| 1594 |
// sio.setSchemeType(SchemeType.OUT);
|
1449 |
// sio.setSchemeType(SchemeType.OUT);
|
| Line 1597... |
Line 1452... |
| 1597 |
}
|
1452 |
}
|
| 1598 |
description = description.concat(" " + serialNumber + " ");
|
1453 |
description = description.concat(" " + serialNumber + " ");
|
| 1599 |
} else {
|
1454 |
} else {
|
| 1600 |
serialNumbersConsidered.add(serialNumber);
|
1455 |
serialNumbersConsidered.add(serialNumber);
|
| 1601 |
List<Integer> schemesConsidered = new ArrayList<>();
|
1456 |
List<Integer> schemesConsidered = new ArrayList<>();
|
| 1602 |
List<SchemeInOut> sios = schemeInOutRepository
|
1457 |
List<SchemeInOut> sios = schemeInOutRepository.selectByInventoryItemIds(new HashSet<>(Arrays.asList(inventoryItemId))).stream().filter(x -> x.getRolledBackTimestamp() == null && schemeTypeMap.get(x.getSchemeId()).equals(SchemeType.IN)).collect(Collectors.toList());
|
| 1603 |
.selectByInventoryItemIds(new HashSet<>(Arrays.asList(inventoryItemId))).stream()
|
- |
|
| 1604 |
.filter(x -> x.getRolledBackTimestamp() == null
|
- |
|
| 1605 |
&& schemeTypeMap.get(x.getSchemeId()).equals(SchemeType.IN))
|
- |
|
| 1606 |
.collect(Collectors.toList());
|
- |
|
| 1607 |
Collections.reverse(sios);
|
1458 |
Collections.reverse(sios);
|
| 1608 |
for (SchemeInOut sio : sios) {
|
1459 |
for (SchemeInOut sio : sios) {
|
| 1609 |
if (!schemesConsidered.contains(sio.getSchemeId())) {
|
1460 |
if (!schemesConsidered.contains(sio.getSchemeId())) {
|
| 1610 |
schemesConsidered.add(sio.getSchemeId());
|
1461 |
schemesConsidered.add(sio.getSchemeId());
|
| 1611 |
continue;
|
1462 |
continue;
|
| Line 1636... |
Line 1487... |
| 1636 |
uwh.setStoreCode(storeNameMap.get(purchase.getFofoId()));
|
1487 |
uwh.setStoreCode(storeNameMap.get(purchase.getFofoId()));
|
| 1637 |
userWalletHistory.add(uwh);
|
1488 |
userWalletHistory.add(uwh);
|
| 1638 |
}
|
1489 |
}
|
| 1639 |
});
|
1490 |
});
|
| 1640 |
ByteArrayOutputStream baos = FileUtil.getCSVByteStream(
|
1491 |
ByteArrayOutputStream baos = FileUtil.getCSVByteStream(
|
| 1641 |
Arrays.asList("User Id", "Store Code", "Reference Type", "Reference", "Amount", "Description",
|
1492 |
Arrays.asList("User Id", "Store Code", "Reference Type", "Reference", "Amount", "Description", "Timestamp"), userWalletHistory.stream().map(x -> Arrays.asList(x.getWalletId(), x.getStoreCode(), x.getReferenceType(), x.getReference(), x.getAmount(), x.getDescription(), x.getTimestamp())).collect(Collectors.toList()));
|
| 1642 |
"Timestamp"),
|
- |
|
| 1643 |
userWalletHistory.stream()
|
- |
|
| 1644 |
.map(x -> Arrays.asList(x.getWalletId(), x.getStoreCode(), x.getReferenceType(),
|
- |
|
| 1645 |
x.getReference(), x.getAmount(), x.getDescription(), x.getTimestamp()))
|
- |
|
| 1646 |
.collect(Collectors.toList()));
|
- |
|
| 1647 |
|
1493 |
|
| 1648 |
ByteArrayOutputStream baosOuts = FileUtil.getCSVByteStream(
|
1494 |
ByteArrayOutputStream baosOuts = FileUtil.getCSVByteStream(
|
| 1649 |
Arrays.asList("Scheme ID", "SchemeType", "Reference", "Store Code", "Serial Number", "Amount",
|
1495 |
Arrays.asList("Scheme ID", "SchemeType", "Reference", "Store Code", "Serial Number", "Amount", "Created", "Rolledback"), rolledbackSios.stream().map(x -> Arrays.asList(x.getSchemeId(), x.getSchemeType(), x.getReference(), x.getStoreCode(), x.getSerialNumber(), x.getAmount(), x.getCreateTimestamp(), x.getRolledBackTimestamp())).collect(Collectors.toList()));
|
| 1650 |
"Created", "Rolledback"),
|
- |
|
| 1651 |
rolledbackSios.stream()
|
- |
|
| 1652 |
.map(x -> Arrays.asList(x.getSchemeId(), x.getSchemeType(), x.getReference(), x.getStoreCode(),
|
- |
|
| 1653 |
x.getSerialNumber(), x.getAmount(), x.getCreateTimestamp(), x.getRolledBackTimestamp()))
|
- |
|
| 1654 |
.collect(Collectors.toList()));
|
- |
|
| 1655 |
|
1496 |
|
| 1656 |
Utils.sendMailWithAttachments(googleMailSender, new String[]{"amit.gupta@shop2020.in"}, null,
|
1497 |
Utils.sendMailWithAttachments(googleMailSender, new String[]{"amit.gupta@shop2020.in"}, null, "Partner Excess Amount Scheme In", "PFA", new Attachment[]{new Attachment("WalletSummary.csv", new ByteArrayResource(baos.toByteArray())), new Attachment("SchemeInRolledback.csv", new ByteArrayResource(baosOuts.toByteArray()))});
|
| 1657 |
"Partner Excess Amount Scheme In", "PFA",
|
- |
|
| 1658 |
new Attachment[]{new Attachment("WalletSummary.csv", new ByteArrayResource(baos.toByteArray())),
|
- |
|
| 1659 |
new Attachment("SchemeInRolledback.csv", new ByteArrayResource(baosOuts.toByteArray()))});
|
- |
|
| 1660 |
|
1498 |
|
| 1661 |
throw new Exception();
|
1499 |
throw new Exception();
|
| 1662 |
|
1500 |
|
| 1663 |
}
|
1501 |
}
|
| 1664 |
|
1502 |
|
| 1665 |
public void dryRunOutSchemeReco() throws Exception {
|
1503 |
public void dryRunOutSchemeReco() throws Exception {
|
| 1666 |
List<UserWalletHistory> userWalletHistory = new ArrayList<>();
|
1504 |
List<UserWalletHistory> userWalletHistory = new ArrayList<>();
|
| 1667 |
List<SchemeInOut> rolledbackSios = new ArrayList<>();
|
1505 |
List<SchemeInOut> rolledbackSios = new ArrayList<>();
|
| 1668 |
Map<Integer, Integer> userWalletMap = userWalletRepository.selectAll().stream()
|
1506 |
Map<Integer, Integer> userWalletMap = userWalletRepository.selectAll().stream().collect(Collectors.toMap(UserWallet::getUserId, UserWallet::getId));
|
| 1669 |
.collect(Collectors.toMap(UserWallet::getUserId, UserWallet::getId));
|
- |
|
| 1670 |
Map<Integer, SchemeType> schemeTypeMap = schemeRepository.selectAll().stream()
|
1507 |
Map<Integer, SchemeType> schemeTypeMap = schemeRepository.selectAll().stream().collect(Collectors.toMap(Scheme::getId, Scheme::getType));
|
| 1671 |
.collect(Collectors.toMap(Scheme::getId, Scheme::getType));
|
- |
|
| 1672 |
LocalDateTime startDate = LocalDate.of(2019, 5, 1).atStartOfDay();
|
1508 |
LocalDateTime startDate = LocalDate.of(2019, 5, 1).atStartOfDay();
|
| 1673 |
LocalDateTime endDate = LocalDate.now().atStartOfDay();
|
1509 |
LocalDateTime endDate = LocalDate.now().atStartOfDay();
|
| 1674 |
List<FofoOrder> allOrders = fofoOrderRepository.selectBetweenSaleDate(startDate, endDate);
|
1510 |
List<FofoOrder> allOrders = fofoOrderRepository.selectBetweenSaleDate(startDate, endDate);
|
| 1675 |
// Collections.reverse(allOrders);
|
1511 |
// Collections.reverse(allOrders);
|
| 1676 |
// List<FofoOrder> allOrders =
|
1512 |
// List<FofoOrder> allOrders =
|
| Line 1681... |
Line 1517... |
| 1681 |
String description = "Adjustment of Duplicate Scheme for Sale Invoice " + fofoOrder.getInvoiceNumber();
|
1517 |
String description = "Adjustment of Duplicate Scheme for Sale Invoice " + fofoOrder.getInvoiceNumber();
|
| 1682 |
Map<Integer, String> inventorySerialNumberMap = new HashMap<>();
|
1518 |
Map<Integer, String> inventorySerialNumberMap = new HashMap<>();
|
| 1683 |
float amountToRollback = 0;
|
1519 |
float amountToRollback = 0;
|
| 1684 |
List<FofoOrderItem> orderItems = fofoOrderItemRepository.selectByOrderId(fofoOrder.getId());
|
1520 |
List<FofoOrderItem> orderItems = fofoOrderItemRepository.selectByOrderId(fofoOrder.getId());
|
| 1685 |
orderItems.forEach(x -> {
|
1521 |
orderItems.forEach(x -> {
|
| 1686 |
inventorySerialNumberMap.putAll(x.getFofoLineItems().stream().filter(li -> li.getSerialNumber() != null)
|
1522 |
inventorySerialNumberMap.putAll(x.getFofoLineItems().stream().filter(li -> li.getSerialNumber() != null).collect(Collectors.toMap(FofoLineItem::getInventoryItemId, FofoLineItem::getSerialNumber)));
|
| 1687 |
.collect(Collectors.toMap(FofoLineItem::getInventoryItemId, FofoLineItem::getSerialNumber)));
|
- |
|
| 1688 |
});
|
1523 |
});
|
| 1689 |
if (inventorySerialNumberMap.size() > 0) {
|
1524 |
if (inventorySerialNumberMap.size() > 0) {
|
| 1690 |
for (Map.Entry<Integer, String> inventorySerialNumberEntry : inventorySerialNumberMap.entrySet()) {
|
1525 |
for (Map.Entry<Integer, String> inventorySerialNumberEntry : inventorySerialNumberMap.entrySet()) {
|
| 1691 |
String serialNumber = inventorySerialNumberEntry.getValue();
|
1526 |
String serialNumber = inventorySerialNumberEntry.getValue();
|
| 1692 |
int inventoryItemId = inventorySerialNumberEntry.getKey();
|
1527 |
int inventoryItemId = inventorySerialNumberEntry.getKey();
|
| 1693 |
if (serialNumbersConsidered.contains(serialNumber)) {
|
1528 |
if (serialNumbersConsidered.contains(serialNumber)) {
|
| 1694 |
// This will rollback scheme for differenct orders for same serial
|
1529 |
// This will rollback scheme for differenct orders for same serial
|
| 1695 |
List<SchemeInOut> sios = schemeInOutRepository
|
1530 |
List<SchemeInOut> sios = schemeInOutRepository.selectByInventoryItemIds(new HashSet<>(Arrays.asList(inventoryItemId))).stream().filter(x -> x.getRolledBackTimestamp() == null && schemeTypeMap.get(x.getSchemeId()).equals(SchemeType.OUT)).collect(Collectors.toList());
|
| 1696 |
.selectByInventoryItemIds(new HashSet<>(Arrays.asList(inventoryItemId))).stream()
|
- |
|
| 1697 |
.filter(x -> x.getRolledBackTimestamp() == null
|
- |
|
| 1698 |
&& schemeTypeMap.get(x.getSchemeId()).equals(SchemeType.OUT))
|
- |
|
| 1699 |
.collect(Collectors.toList());
|
- |
|
| 1700 |
Collections.reverse(sios);
|
1531 |
Collections.reverse(sios);
|
| 1701 |
for (SchemeInOut sio : sios) {
|
1532 |
for (SchemeInOut sio : sios) {
|
| 1702 |
sio.setRolledBackTimestamp(LocalDateTime.now());
|
1533 |
sio.setRolledBackTimestamp(LocalDateTime.now());
|
| 1703 |
amountToRollback += sio.getAmount();
|
1534 |
amountToRollback += sio.getAmount();
|
| 1704 |
// sio.setSchemeType(SchemeType.OUT);
|
1535 |
// sio.setSchemeType(SchemeType.OUT);
|
| Line 1709... |
Line 1540... |
| 1709 |
}
|
1540 |
}
|
| 1710 |
description = description.concat(" " + serialNumber + " ");
|
1541 |
description = description.concat(" " + serialNumber + " ");
|
| 1711 |
} else {
|
1542 |
} else {
|
| 1712 |
serialNumbersConsidered.add(serialNumber);
|
1543 |
serialNumbersConsidered.add(serialNumber);
|
| 1713 |
List<Integer> schemesConsidered = new ArrayList<>();
|
1544 |
List<Integer> schemesConsidered = new ArrayList<>();
|
| 1714 |
List<SchemeInOut> sios = schemeInOutRepository
|
1545 |
List<SchemeInOut> sios = schemeInOutRepository.selectByInventoryItemIds(new HashSet<>(Arrays.asList(inventoryItemId))).stream().filter(x -> x.getRolledBackTimestamp() == null && schemeTypeMap.get(x.getSchemeId()).equals(SchemeType.OUT)).collect(Collectors.toList());
|
| 1715 |
.selectByInventoryItemIds(new HashSet<>(Arrays.asList(inventoryItemId))).stream()
|
- |
|
| 1716 |
.filter(x -> x.getRolledBackTimestamp() == null
|
- |
|
| 1717 |
&& schemeTypeMap.get(x.getSchemeId()).equals(SchemeType.OUT))
|
- |
|
| 1718 |
.collect(Collectors.toList());
|
- |
|
| 1719 |
Collections.reverse(sios);
|
1546 |
Collections.reverse(sios);
|
| 1720 |
for (SchemeInOut sio : sios) {
|
1547 |
for (SchemeInOut sio : sios) {
|
| 1721 |
if (!schemesConsidered.contains(sio.getSchemeId())) {
|
1548 |
if (!schemesConsidered.contains(sio.getSchemeId())) {
|
| 1722 |
schemesConsidered.add(sio.getSchemeId());
|
1549 |
schemesConsidered.add(sio.getSchemeId());
|
| 1723 |
continue;
|
1550 |
continue;
|
| Line 1747... |
Line 1574... |
| 1747 |
userWalletHistory.add(uwh);
|
1574 |
userWalletHistory.add(uwh);
|
| 1748 |
}
|
1575 |
}
|
| 1749 |
});
|
1576 |
});
|
| 1750 |
|
1577 |
|
| 1751 |
ByteArrayOutputStream baos = FileUtil.getCSVByteStream(
|
1578 |
ByteArrayOutputStream baos = FileUtil.getCSVByteStream(
|
| 1752 |
Arrays.asList("Wallet Id", "Store Code", "Reference Type", "Reference", "Amount", "Description",
|
1579 |
Arrays.asList("Wallet Id", "Store Code", "Reference Type", "Reference", "Amount", "Description", "Timestamp"), userWalletHistory.stream().map(x -> Arrays.asList(x.getWalletId(), x.getStoreCode(), x.getReferenceType(), x.getReference(), x.getAmount(), x.getDescription(), x.getTimestamp())).collect(Collectors.toList()));
|
| 1753 |
"Timestamp"),
|
- |
|
| 1754 |
userWalletHistory.stream()
|
- |
|
| 1755 |
.map(x -> Arrays.asList(x.getWalletId(), x.getStoreCode(), x.getReferenceType(),
|
- |
|
| 1756 |
x.getReference(), x.getAmount(), x.getDescription(), x.getTimestamp()))
|
- |
|
| 1757 |
.collect(Collectors.toList()));
|
- |
|
| 1758 |
|
1580 |
|
| 1759 |
ByteArrayOutputStream baosOuts = FileUtil.getCSVByteStream(
|
1581 |
ByteArrayOutputStream baosOuts = FileUtil.getCSVByteStream(
|
| 1760 |
Arrays.asList("Scheme ID", "SchemeType", "Store Code", "Serial Number", "Amount", "Created",
|
1582 |
Arrays.asList("Scheme ID", "SchemeType", "Store Code", "Serial Number", "Amount", "Created", "Rolledback"), rolledbackSios.stream().map(x -> Arrays.asList(x.getSchemeId(), x.getSchemeType(), x.getStoreCode(), x.getSerialNumber(), x.getAmount(), x.getCreateTimestamp(), x.getRolledBackTimestamp())).collect(Collectors.toList()));
|
| 1761 |
"Rolledback"),
|
- |
|
| 1762 |
rolledbackSios.stream()
|
- |
|
| 1763 |
.map(x -> Arrays.asList(x.getSchemeId(), x.getSchemeType(), x.getStoreCode(),
|
- |
|
| 1764 |
x.getSerialNumber(), x.getAmount(), x.getCreateTimestamp(), x.getRolledBackTimestamp()))
|
- |
|
| 1765 |
.collect(Collectors.toList()));
|
- |
|
| 1766 |
|
1583 |
|
| 1767 |
Utils.sendMailWithAttachments(googleMailSender, new String[]{"amit.gupta@shop2020.in"}, null,
|
1584 |
Utils.sendMailWithAttachments(googleMailSender, new String[]{"amit.gupta@shop2020.in"}, null, "Partner Excess Amount Scheme Out", "PFA", new Attachment[]{new Attachment("WalletSummary.csv", new ByteArrayResource(baos.toByteArray())), new Attachment("SchemeOutRolledback.csv", new ByteArrayResource(baosOuts.toByteArray()))});
|
| 1768 |
"Partner Excess Amount Scheme Out", "PFA",
|
- |
|
| 1769 |
new Attachment[]{new Attachment("WalletSummary.csv", new ByteArrayResource(baos.toByteArray())),
|
- |
|
| 1770 |
new Attachment("SchemeOutRolledback.csv", new ByteArrayResource(baosOuts.toByteArray()))});
|
- |
|
| 1771 |
|
1585 |
|
| 1772 |
throw new Exception();
|
1586 |
throw new Exception();
|
| 1773 |
}
|
1587 |
}
|
| 1774 |
|
1588 |
|
| 1775 |
public void dryRunSchemeOutReco1() throws Exception {
|
1589 |
public void dryRunSchemeOutReco1() throws Exception {
|
| 1776 |
List<Integer> references = Arrays.asList(6744, 7347, 8320, 8891, 9124, 9217, 9263, 9379);
|
1590 |
List<Integer> references = Arrays.asList(6744, 7347, 8320, 8891, 9124, 9217, 9263, 9379);
|
| 1777 |
List<UserWalletHistory> userWalletHistory = new ArrayList<>();
|
1591 |
List<UserWalletHistory> userWalletHistory = new ArrayList<>();
|
| 1778 |
List<SchemeInOut> rolledbackSios = new ArrayList<>();
|
1592 |
List<SchemeInOut> rolledbackSios = new ArrayList<>();
|
| 1779 |
Map<Integer, Integer> userWalletMap = userWalletRepository.selectAll().stream()
|
1593 |
Map<Integer, Integer> userWalletMap = userWalletRepository.selectAll().stream().collect(Collectors.toMap(UserWallet::getUserId, UserWallet::getId));
|
| 1780 |
.collect(Collectors.toMap(UserWallet::getUserId, UserWallet::getId));
|
- |
|
| 1781 |
Map<Integer, SchemeType> schemeTypeMap = schemeRepository.selectAll().stream()
|
1594 |
Map<Integer, SchemeType> schemeTypeMap = schemeRepository.selectAll().stream().collect(Collectors.toMap(Scheme::getId, Scheme::getType));
|
| 1782 |
.collect(Collectors.toMap(Scheme::getId, Scheme::getType));
|
- |
|
| 1783 |
references.stream().forEach(reference -> {
|
1595 |
references.stream().forEach(reference -> {
|
| 1784 |
FofoOrder fofoOrder = null;
|
1596 |
FofoOrder fofoOrder = null;
|
| 1785 |
try {
|
1597 |
try {
|
| 1786 |
fofoOrder = fofoOrderRepository.selectByOrderId(reference);
|
1598 |
fofoOrder = fofoOrderRepository.selectByOrderId(reference);
|
| 1787 |
} catch (Exception e) {
|
1599 |
} catch (Exception e) {
|
| Line 1790... |
Line 1602... |
| 1790 |
String description = "Adjustment of Duplicate Scheme for Sale Invoice " + fofoOrder.getInvoiceNumber();
|
1602 |
String description = "Adjustment of Duplicate Scheme for Sale Invoice " + fofoOrder.getInvoiceNumber();
|
| 1791 |
Map<Integer, String> inventorySerialNumberMap = new HashMap<>();
|
1603 |
Map<Integer, String> inventorySerialNumberMap = new HashMap<>();
|
| 1792 |
float amountToRollback = 0;
|
1604 |
float amountToRollback = 0;
|
| 1793 |
List<FofoOrderItem> orderItems = fofoOrderItemRepository.selectByOrderId(fofoOrder.getId());
|
1605 |
List<FofoOrderItem> orderItems = fofoOrderItemRepository.selectByOrderId(fofoOrder.getId());
|
| 1794 |
orderItems.forEach(x -> {
|
1606 |
orderItems.forEach(x -> {
|
| 1795 |
inventorySerialNumberMap.putAll(x.getFofoLineItems().stream().filter(li -> li.getSerialNumber() != null)
|
1607 |
inventorySerialNumberMap.putAll(x.getFofoLineItems().stream().filter(li -> li.getSerialNumber() != null).collect(Collectors.toMap(FofoLineItem::getInventoryItemId, FofoLineItem::getSerialNumber)));
|
| 1796 |
.collect(Collectors.toMap(FofoLineItem::getInventoryItemId, FofoLineItem::getSerialNumber)));
|
- |
|
| 1797 |
});
|
1608 |
});
|
| 1798 |
if (inventorySerialNumberMap.size() > 0) {
|
1609 |
if (inventorySerialNumberMap.size() > 0) {
|
| 1799 |
List<SchemeInOut> sios = schemeInOutRepository
|
- |
|
| 1800 |
.selectByInventoryItemIds(inventorySerialNumberMap.keySet()).stream()
|
- |
|
| 1801 |
.filter(x -> schemeTypeMap.get(x.getSchemeId()).equals(SchemeType.OUT))
|
1610 |
List<SchemeInOut> sios = schemeInOutRepository.selectByInventoryItemIds(inventorySerialNumberMap.keySet()).stream().filter(x -> schemeTypeMap.get(x.getSchemeId()).equals(SchemeType.OUT)).collect(Collectors.toList());
|
| 1802 |
.collect(Collectors.toList());
|
- |
|
| 1803 |
LOGGER.info("Found {} duplicate schemeouts for Orderid {}", sios.size(), fofoOrder.getId());
|
1611 |
LOGGER.info("Found {} duplicate schemeouts for Orderid {}", sios.size(), fofoOrder.getId());
|
| 1804 |
UserWalletHistory uwh = new UserWalletHistory();
|
1612 |
UserWalletHistory uwh = new UserWalletHistory();
|
| 1805 |
Map<Integer, List<SchemeInOut>> inventoryIdSouts = sios.stream()
|
- |
|
| 1806 |
.collect(groupingBy(SchemeInOut::getInventoryItemId, Collectors.toList()));
|
1613 |
Map<Integer, List<SchemeInOut>> inventoryIdSouts = sios.stream().collect(groupingBy(SchemeInOut::getInventoryItemId, Collectors.toList()));
|
| 1807 |
for (Map.Entry<Integer, List<SchemeInOut>> inventorySioEntry : inventoryIdSouts.entrySet()) {
|
1614 |
for (Map.Entry<Integer, List<SchemeInOut>> inventorySioEntry : inventoryIdSouts.entrySet()) {
|
| 1808 |
List<SchemeInOut> outList = inventorySioEntry.getValue();
|
1615 |
List<SchemeInOut> outList = inventorySioEntry.getValue();
|
| 1809 |
if (outList.size() > 1) {
|
1616 |
if (outList.size() > 1) {
|
| 1810 |
|
1617 |
|
| 1811 |
}
|
1618 |
}
|
| Line 1821... |
Line 1628... |
| 1821 |
userWalletHistory.add(uwh);
|
1628 |
userWalletHistory.add(uwh);
|
| 1822 |
}
|
1629 |
}
|
| 1823 |
});
|
1630 |
});
|
| 1824 |
|
1631 |
|
| 1825 |
ByteArrayOutputStream baos = FileUtil.getCSVByteStream(
|
1632 |
ByteArrayOutputStream baos = FileUtil.getCSVByteStream(
|
| 1826 |
Arrays.asList("User Id", "Reference Type", "Reference", "Amount", "Description", "Timestamp"),
|
1633 |
Arrays.asList("User Id", "Reference Type", "Reference", "Amount", "Description", "Timestamp"), userWalletHistory.stream().map(x -> Arrays.asList(x.getWalletId(), x.getReferenceType(), x.getReference(), x.getAmount(), x.getDescription(), x.getTimestamp())).collect(Collectors.toList()));
|
| 1827 |
userWalletHistory.stream().map(x -> Arrays.asList(x.getWalletId(), x.getReferenceType(),
|
- |
|
| 1828 |
x.getReference(), x.getAmount(), x.getDescription(), x.getTimestamp()))
|
- |
|
| 1829 |
.collect(Collectors.toList()));
|
- |
|
| 1830 |
|
1634 |
|
| 1831 |
ByteArrayOutputStream baosOuts = FileUtil.getCSVByteStream(
|
1635 |
ByteArrayOutputStream baosOuts = FileUtil.getCSVByteStream(
|
| 1832 |
Arrays.asList("Scheme ID", "SchemeType", "Store Code", "Serial Number", "Amount", "Created",
|
1636 |
Arrays.asList("Scheme ID", "SchemeType", "Store Code", "Serial Number", "Amount", "Created", "Rolledback"), rolledbackSios.stream().map(x -> Arrays.asList(x.getSchemeId(), x.getSchemeType(), x.getStoreCode(), x.getSerialNumber(), x.getAmount(), x.getCreateTimestamp(), x.getRolledBackTimestamp())).collect(Collectors.toList()));
|
| 1833 |
"Rolledback"),
|
- |
|
| 1834 |
rolledbackSios.stream()
|
- |
|
| 1835 |
.map(x -> Arrays.asList(x.getSchemeId(), x.getSchemeType(), x.getStoreCode(),
|
- |
|
| 1836 |
x.getSerialNumber(), x.getAmount(), x.getCreateTimestamp(), x.getRolledBackTimestamp()))
|
- |
|
| 1837 |
.collect(Collectors.toList()));
|
- |
|
| 1838 |
|
1637 |
|
| 1839 |
Utils.sendMailWithAttachments(googleMailSender,
|
1638 |
Utils.sendMailWithAttachments(googleMailSender, new String[]{"amit.gupta@shop2020.in", "neeraj.gupta@smartdukaan.com"}, null, "Partner Excess Amount", "PFA", new Attachment[]{new Attachment("WalletSummary.csv", new ByteArrayResource(baos.toByteArray())), new Attachment("SchemeOutRolledback.csv", new ByteArrayResource(baosOuts.toByteArray()))});
|
| 1840 |
new String[]{"amit.gupta@shop2020.in", "neeraj.gupta@smartdukaan.com"}, null,
|
- |
|
| 1841 |
"Partner Excess Amount", "PFA",
|
- |
|
| 1842 |
new Attachment[]{new Attachment("WalletSummary.csv", new ByteArrayResource(baos.toByteArray())),
|
- |
|
| 1843 |
new Attachment("SchemeOutRolledback.csv", new ByteArrayResource(baosOuts.toByteArray()))});
|
- |
|
| 1844 |
|
1639 |
|
| 1845 |
throw new Exception();
|
1640 |
throw new Exception();
|
| 1846 |
|
1641 |
|
| 1847 |
}
|
1642 |
}
|
| 1848 |
|
1643 |
|
| Line 1858... |
Line 1653... |
| 1858 |
*
|
1653 |
*
|
| 1859 |
* }
|
1654 |
* }
|
| 1860 |
*/
|
1655 |
*/
|
| 1861 |
|
1656 |
|
| 1862 |
List<Integer> fofoIds = null;
|
1657 |
List<Integer> fofoIds = null;
|
| 1863 |
Map<Integer, FofoStore> fofoStoreMap = fofoStoreRepository.selectAll().stream().filter(x -> x.isActive())
|
1658 |
Map<Integer, FofoStore> fofoStoreMap = fofoStoreRepository.selectAll().stream().filter(x -> x.isActive()).collect(Collectors.toMap(x -> x.getId(), x -> x));
|
| 1864 |
.collect(Collectors.toMap(x -> x.getId(), x -> x));
|
- |
|
| 1865 |
|
1659 |
|
| 1866 |
|
1660 |
|
| 1867 |
if (fofoIdInt == null) {
|
1661 |
if (fofoIdInt == null) {
|
| 1868 |
fofoIds = new ArrayList<>(fofoStoreMap.keySet());
|
1662 |
fofoIds = new ArrayList<>(fofoStoreMap.keySet());
|
| 1869 |
} else {
|
1663 |
} else {
|
| 1870 |
fofoIds = Arrays.asList(fofoIdInt);
|
1664 |
fofoIds = Arrays.asList(fofoIdInt);
|
| 1871 |
}
|
1665 |
}
|
| 1872 |
DateTimeFormatter timeFormatter = DateTimeFormatter.ofPattern("h:m a");
|
1666 |
DateTimeFormatter timeFormatter = DateTimeFormatter.ofPattern("h:m a");
|
| 1873 |
|
1667 |
|
| 1874 |
Map<Integer, Float> partnerPolicyAmountMap = insurancePolicyRepository.selectAmountSumGroupByRetailerId(now,
|
1668 |
Map<Integer, Float> partnerPolicyAmountMap = insurancePolicyRepository.selectAmountSumGroupByRetailerId(now, null);
|
| 1875 |
null);
|
- |
|
| 1876 |
Map<Integer, Long> partnerPolicyQtyMap = insurancePolicyRepository.selectQtyGroupByRetailerId(now, null);
|
1669 |
Map<Integer, Long> partnerPolicyQtyMap = insurancePolicyRepository.selectQtyGroupByRetailerId(now, null);
|
| 1877 |
|
1670 |
|
| 1878 |
Map<Integer, Double> spPartnerOrderValMap = fofoOrderItemRepository.selectSumAmountGroupByRetailer(from, now, 0,
|
1671 |
Map<Integer, Double> spPartnerOrderValMap = fofoOrderItemRepository.selectSumAmountGroupByRetailer(from, now, 0, true);
|
| 1879 |
true);
|
- |
|
| 1880 |
|
1672 |
|
| 1881 |
Map<Integer, Double> spPartner3DaysOrderValMap = fofoOrderItemRepository
|
1673 |
Map<Integer, Double> spPartner3DaysOrderValMap = fofoOrderItemRepository.selectSumAmountGroupByRetailer(from.minusDays(3), now, 0, true);
|
| 1882 |
.selectSumAmountGroupByRetailer(from.minusDays(3), now, 0, true);
|
- |
|
| 1883 |
Map<Integer, Long> spPartnerOrderQtyMap = fofoOrderItemRepository.selectQtyGroupByRetailer(from, now, 0, true);
|
1674 |
Map<Integer, Long> spPartnerOrderQtyMap = fofoOrderItemRepository.selectQtyGroupByRetailer(from, now, 0, true);
|
| 1884 |
|
1675 |
|
| 1885 |
Map<Integer, Double> partnerOrderValMap = fofoOrderItemRepository.selectSumAmountGroupByRetailer(from, now, 0,
|
1676 |
Map<Integer, Double> partnerOrderValMap = fofoOrderItemRepository.selectSumAmountGroupByRetailer(from, now, 0, false);
|
| 1886 |
false);
|
- |
|
| 1887 |
Map<Integer, Long> partnerOrderQtyMap = fofoOrderItemRepository.selectQtyGroupByRetailer(from, now, 0, false);
|
1677 |
Map<Integer, Long> partnerOrderQtyMap = fofoOrderItemRepository.selectQtyGroupByRetailer(from, now, 0, false);
|
| 1888 |
|
1678 |
|
| 1889 |
//4 days + current day running
|
1679 |
//4 days + current day running
|
| 1890 |
Map<Integer, Double> partnerBilledValueMap = orderRepository.selectBillingDatesBetweenSumGroupByRetailerId(from.minusDays(4), now);
|
1680 |
Map<Integer, Double> partnerBilledValueMap = orderRepository.selectBillingDatesBetweenSumGroupByRetailerId(from.minusDays(4), now);
|
| 1891 |
|
1681 |
|
| Line 1916... |
Line 1706... |
| 1916 |
// userUserRepository.selectById(fofoId);
|
1706 |
// userUserRepository.selectById(fofoId);
|
| 1917 |
|
1707 |
|
| 1918 |
// Address address = addressRepository.selectById(user.getAddressId());
|
1708 |
// Address address = addressRepository.selectById(user.getAddressId());
|
| 1919 |
|
1709 |
|
| 1920 |
String title = "Sale Update";
|
1710 |
String title = "Sale Update";
|
| 1921 |
String messageTemplate = String.format("Smartphones Rs.%.0f, Insurance Rs.%.0f, Total Rs.%.0f till %s.",
|
1711 |
String messageTemplate = String.format("Smartphones Rs.%.0f, Insurance Rs.%.0f, Total Rs.%.0f till %s.", model.getSmartphoneSale(), model.getInsuranceSale(), model.getTotalSale(), String.format(timeString, now.format(timeFormatter)));
|
| 1922 |
model.getSmartphoneSale(), model.getInsuranceSale(), model.getTotalSale(),
|
- |
|
| 1923 |
String.format(timeString, now.format(timeFormatter)));
|
- |
|
| 1924 |
SendNotificationModel sendNotificationModel = new SendNotificationModel();
|
1712 |
SendNotificationModel sendNotificationModel = new SendNotificationModel();
|
| 1925 |
sendNotificationModel.setCampaignName("Sales update alert");
|
1713 |
sendNotificationModel.setCampaignName("Sales update alert");
|
| 1926 |
sendNotificationModel.setTitle(title);
|
1714 |
sendNotificationModel.setTitle(title);
|
| 1927 |
sendNotificationModel.setMessage(messageTemplate);
|
1715 |
sendNotificationModel.setMessage(messageTemplate);
|
| 1928 |
sendNotificationModel.setType("url");
|
1716 |
sendNotificationModel.setType("url");
|
| Line 1931... |
Line 1719... |
| 1931 |
sendNotificationModel.setMessageType(MessageType.notification);
|
1719 |
sendNotificationModel.setMessageType(MessageType.notification);
|
| 1932 |
int userId = userAccountRepository.selectUserIdByRetailerId(fofoId);
|
1720 |
int userId = userAccountRepository.selectUserIdByRetailerId(fofoId);
|
| 1933 |
sendNotificationModel.setUserIds(Arrays.asList(userId));
|
1721 |
sendNotificationModel.setUserIds(Arrays.asList(userId));
|
| 1934 |
notificationService.sendNotification(sendNotificationModel);
|
1722 |
notificationService.sendNotification(sendNotificationModel);
|
| 1935 |
String whatsappMessageTemplate = String.format(
|
1723 |
String whatsappMessageTemplate = String.format(
|
| 1936 |
"Dear Partner, Your sale update is Smartphones Rs.%.0f, Insurance Rs.%.0f, Total Rs.%.0f till %s.",
|
1724 |
"Dear Partner, Your sale update is Smartphones Rs.%.0f, Insurance Rs.%.0f, Total Rs.%.0f till %s.", model.getSmartphoneSale(), model.getInsuranceSale(), model.getTotalSale(), String.format(timeString, now.format(timeFormatter)));
|
| 1937 |
model.getSmartphoneSale(), model.getInsuranceSale(), model.getTotalSale(),
|
- |
|
| 1938 |
String.format(timeString, now.format(timeFormatter)));
|
- |
|
| 1939 |
// notificationService.sendWhatsappMessage(whatsappMessageTemplate, title,
|
1725 |
// notificationService.sendWhatsappMessage(whatsappMessageTemplate, title,
|
| 1940 |
// address.getPhoneNumber());
|
1726 |
// address.getPhoneNumber());
|
| 1941 |
|
1727 |
|
| 1942 |
}
|
1728 |
}
|
| 1943 |
// String saleReport = this.getDailySalesReportHtml(partnerSalesHeadersMap,
|
1729 |
// String saleReport = this.getDailySalesReportHtml(partnerSalesHeadersMap,
|
| 1944 |
// saleTargetReportModelMap);
|
1730 |
// saleTargetReportModelMap);
|
| 1945 |
this.getStateWiseSales(saleTargetReportModelMap, partnerSalesHeadersMap);
|
1731 |
this.getStateWiseSales(saleTargetReportModelMap, partnerSalesHeadersMap);
|
| 1946 |
}
|
1732 |
}
|
| 1947 |
|
1733 |
|
| 1948 |
public void checkRazorPayPaymentStatus() throws Exception {
|
1734 |
public void checkRazorPayPaymentStatus() throws Exception {
|
| 1949 |
List<PendingOrder> pendingOrder = pendingOrderRepository
|
- |
|
| 1950 |
.selectAllByStatus(com.spice.profitmandi.dao.enumuration.transaction.OrderStatus.PENDING);
|
1735 |
List<PendingOrder> pendingOrder = pendingOrderRepository.selectAllByStatus(com.spice.profitmandi.dao.enumuration.transaction.OrderStatus.PENDING);
|
| 1951 |
|
1736 |
|
| 1952 |
for (PendingOrder po : pendingOrder) {
|
1737 |
for (PendingOrder po : pendingOrder) {
|
| 1953 |
RazorPay razorPay = razorPayRepository.selectByOrdeId(po.getId());
|
1738 |
RazorPay razorPay = razorPayRepository.selectByOrdeId(po.getId());
|
| 1954 |
List<PendingOrderItem> poItems = pendingOrderItemRepository.selectByOrderId(po.getId());
|
1739 |
List<PendingOrderItem> poItems = pendingOrderItemRepository.selectByOrderId(po.getId());
|
| 1955 |
|
1740 |
|
| Line 1982... |
Line 1767... |
| 1982 |
Customer customer = customerRepository.selectById(po.getCustomerId());
|
1767 |
Customer customer = customerRepository.selectById(po.getCustomerId());
|
| 1983 |
String[] customerEmail = null;
|
1768 |
String[] customerEmail = null;
|
| 1984 |
if (customer.getEmailId() != null) {
|
1769 |
if (customer.getEmailId() != null) {
|
| 1985 |
customerEmail = new String[]{customer.getEmailId()};
|
1770 |
customerEmail = new String[]{customer.getEmailId()};
|
| 1986 |
}
|
1771 |
}
|
| 1987 |
List<String> bccTo = Arrays.asList("kamini.sharma@smartdukaan.com",
|
- |
|
| 1988 |
"tarun.verma@smartdukaan.com", "niranjan.kala@smartdukaan.com", "sm@smartdukaan.com",
|
1772 |
List<String> bccTo = Arrays.asList("kamini.sharma@smartdukaan.com", "tarun.verma@smartdukaan.com", "niranjan.kala@smartdukaan.com", "sm@smartdukaan.com", "tejbeer.kaur@shop2020.in", customRetailer.getEmail());
|
| 1989 |
"tejbeer.kaur@shop2020.in", customRetailer.getEmail());
|
- |
|
| 1990 |
List<String> authUserEmails = csService.getAuthUserByPartnerId(customRetailer.getPartnerId());
|
1773 |
List<String> authUserEmails = csService.getAuthUserByPartnerId(customRetailer.getPartnerId());
|
| 1991 |
if (authUserEmails != null) {
|
1774 |
if (authUserEmails != null) {
|
| 1992 |
authUserEmails = new ArrayList<>();
|
1775 |
authUserEmails = new ArrayList<>();
|
| 1993 |
}
|
1776 |
}
|
| 1994 |
authUserEmails.addAll(bccTo);
|
1777 |
authUserEmails.addAll(bccTo);
|
| Line 2056... |
Line 1839... |
| 2056 |
return fofoId;
|
1839 |
return fofoId;
|
| 2057 |
}
|
1840 |
}
|
| 2058 |
|
1841 |
|
| 2059 |
@Override
|
1842 |
@Override
|
| 2060 |
public String toString() {
|
1843 |
public String toString() {
|
| 2061 |
return "SaleTargetReportModel{" +
|
- |
|
| 2062 |
"totalSale=" + totalSale +
|
- |
|
| 2063 |
", totalQty=" + totalQty +
|
- |
|
| 2064 |
", past3daysSale=" + past3daysSale +
|
- |
|
| 2065 |
", fofoId=" + fofoId +
|
- |
|
| 2066 |
", code='" + code + '\'' +
|
1844 |
return "SaleTargetReportModel{" + "totalSale=" + totalSale + ", totalQty=" + totalQty + ", past3daysSale=" + past3daysSale + ", fofoId=" + fofoId + ", code='" + code + '\'' + ", secondary=" + secondary + ", smartphoneSale=" + smartphoneSale + ", smartphoneQty=" + smartphoneQty + ", insuranceSale=" + insuranceSale + ", insruanceQty=" + insruanceQty + '}';
|
| 2067 |
", secondary=" + secondary +
|
- |
|
| 2068 |
", smartphoneSale=" + smartphoneSale +
|
- |
|
| 2069 |
", smartphoneQty=" + smartphoneQty +
|
- |
|
| 2070 |
", insuranceSale=" + insuranceSale +
|
- |
|
| 2071 |
", insruanceQty=" + insruanceQty +
|
- |
|
| 2072 |
'}';
|
- |
|
| 2073 |
}
|
1845 |
}
|
| 2074 |
|
1846 |
|
| 2075 |
public String getCode() {
|
1847 |
public String getCode() {
|
| 2076 |
return code;
|
1848 |
return code;
|
| 2077 |
}
|
1849 |
}
|
| Line 2145... |
Line 1917... |
| 2145 |
this.insruanceQty = insruanceQty;
|
1917 |
this.insruanceQty = insruanceQty;
|
| 2146 |
}
|
1918 |
}
|
| 2147 |
|
1919 |
|
| 2148 |
}
|
1920 |
}
|
| 2149 |
|
1921 |
|
| 2150 |
private void getStateWiseSales(Map<Integer, SaleTargetReportModel> saleTargetReportModelMap,
|
1922 |
private void getStateWiseSales(Map<Integer, SaleTargetReportModel> saleTargetReportModelMap, Map<Integer, FofoReportingModel> partnerSalesHeadersMap) throws Exception {
|
| 2151 |
Map<Integer, FofoReportingModel> partnerSalesHeadersMap) throws Exception {
|
- |
|
| 2152 |
String timeString = "Today %s";
|
1923 |
String timeString = "Today %s";
|
| 2153 |
LocalDateTime now = LocalDateTime.now();
|
1924 |
LocalDateTime now = LocalDateTime.now();
|
| 2154 |
|
1925 |
|
| 2155 |
DateTimeFormatter timeFormatter = DateTimeFormatter.ofPattern("h:m a");
|
1926 |
DateTimeFormatter timeFormatter = DateTimeFormatter.ofPattern("h:m a");
|
| 2156 |
List<Integer> categoryIds = Arrays.asList(ProfitMandiConstants.TICKET_CATEGORY_LOGISTICS,
|
1927 |
List<Integer> categoryIds = Arrays.asList(ProfitMandiConstants.TICKET_CATEGORY_LOGISTICS, ProfitMandiConstants.TICKET_CATEGORY_FINANCIAL_SERVICES, ProfitMandiConstants.TICKET_CATEGORY_CATEGORY, ProfitMandiConstants.TICKET_CATEGORY_RBM, ProfitMandiConstants.TICKET_CATEGORY_SALES, ProfitMandiConstants.TICKET_CATEGORY_MARKETING, ProfitMandiConstants.TICKET_CATEGORY_ACCOUNTS, ProfitMandiConstants.TICKET_CATEGORY_BUSINESSINTELLIGENT, ProfitMandiConstants.TICKET_CATEGORY_TECHNOLOGY);
|
| 2157 |
ProfitMandiConstants.TICKET_CATEGORY_FINANCIAL_SERVICES, ProfitMandiConstants.TICKET_CATEGORY_CATEGORY,
|
- |
|
| 2158 |
ProfitMandiConstants.TICKET_CATEGORY_RBM, ProfitMandiConstants.TICKET_CATEGORY_SALES,
|
- |
|
| 2159 |
ProfitMandiConstants.TICKET_CATEGORY_MARKETING, ProfitMandiConstants.TICKET_CATEGORY_ACCOUNTS,
|
- |
|
| 2160 |
ProfitMandiConstants.TICKET_CATEGORY_BUSINESSINTELLIGENT,
|
- |
|
| 2161 |
ProfitMandiConstants.TICKET_CATEGORY_TECHNOLOGY);
|
- |
|
| 2162 |
|
1928 |
|
| 2163 |
Map<String, Set<Integer>> storeGuyMap = csService.getAuthUserPartnerIdMappingByCategoryIds(categoryIds, false);
|
1929 |
Map<String, Set<Integer>> storeGuyMap = csService.getAuthUserPartnerIdMappingByCategoryIds(categoryIds, false);
|
| 2164 |
|
1930 |
|
| 2165 |
for (Entry<String, Set<Integer>> storeGuyEntry : storeGuyMap.entrySet()) {
|
1931 |
for (Entry<String, Set<Integer>> storeGuyEntry : storeGuyMap.entrySet()) {
|
| 2166 |
String email = storeGuyEntry.getKey();
|
1932 |
String email = storeGuyEntry.getKey();
|
| 2167 |
Set<Integer> fofoIds = storeGuyEntry.getValue();
|
1933 |
Set<Integer> fofoIds = storeGuyEntry.getValue();
|
| 2168 |
LOGGER.info("fofoIds {}", fofoIds);
|
1934 |
LOGGER.info("fofoIds {}", fofoIds);
|
| 2169 |
|
1935 |
|
| 2170 |
if (!fofoIds.isEmpty()) {
|
1936 |
if (!fofoIds.isEmpty()) {
|
| 2171 |
List<FofoStore> stores = fofoStoreRepository
|
- |
|
| 2172 |
.selectActivePartnersByRetailerIds(new ArrayList<>(fofoIds));
|
1937 |
List<FofoStore> stores = fofoStoreRepository.selectActivePartnersByRetailerIds(new ArrayList<>(fofoIds));
|
| 2173 |
|
1938 |
|
| 2174 |
Map<String, List<Integer>> stateMap = stores.stream().collect(groupingBy(
|
1939 |
Map<String, List<Integer>> stateMap = stores.stream().collect(groupingBy(
|
| 2175 |
x -> x.getCode().substring(0, 2), mapping(x -> x.getId(), Collectors.toList())));
|
1940 |
x -> x.getCode().substring(0, 2), mapping(x -> x.getId(), Collectors.toList())));
|
| 2176 |
List<List<Serializable>> stateWiseSales = new ArrayList<>();
|
1941 |
List<List<Serializable>> stateWiseSales = new ArrayList<>();
|
| 2177 |
for (Map.Entry<String, List<Integer>> stateMapEntry : stateMap.entrySet()) {
|
1942 |
for (Map.Entry<String, List<Integer>> stateMapEntry : stateMap.entrySet()) {
|
| 2178 |
long totalQty = stateMapEntry.getValue().stream()
|
- |
|
| 2179 |
.collect(Collectors.summingLong(x -> saleTargetReportModelMap.get(x).getTotalQty()));
|
1943 |
long totalQty = stateMapEntry.getValue().stream().collect(Collectors.summingLong(x -> saleTargetReportModelMap.get(x).getTotalQty()));
|
| 2180 |
double totalSale = stateMapEntry.getValue().stream()
|
- |
|
| 2181 |
.collect(Collectors.summingDouble(x -> saleTargetReportModelMap.get(x).getTotalSale()));
|
1944 |
double totalSale = stateMapEntry.getValue().stream().collect(Collectors.summingDouble(x -> saleTargetReportModelMap.get(x).getTotalSale()));
|
| 2182 |
long smartPhoneQty = stateMapEntry.getValue().stream()
|
- |
|
| 2183 |
.collect(Collectors.summingLong(x -> saleTargetReportModelMap.get(x).getSmartphoneQty()));
|
1945 |
long smartPhoneQty = stateMapEntry.getValue().stream().collect(Collectors.summingLong(x -> saleTargetReportModelMap.get(x).getSmartphoneQty()));
|
| 2184 |
double smartPhoneSale = stateMapEntry.getValue().stream().collect(
|
1946 |
double smartPhoneSale = stateMapEntry.getValue().stream().collect(
|
| 2185 |
Collectors.summingDouble(x -> saleTargetReportModelMap.get(x).getSmartphoneSale()));
|
1947 |
Collectors.summingDouble(x -> saleTargetReportModelMap.get(x).getSmartphoneSale()));
|
| 2186 |
stateWiseSales.add(
|
1948 |
stateWiseSales.add(
|
| 2187 |
Arrays.asList(stateMapEntry.getKey(), smartPhoneQty, smartPhoneSale, totalQty, totalSale));
|
1949 |
Arrays.asList(stateMapEntry.getKey(), smartPhoneQty, smartPhoneSale, totalQty, totalSale));
|
| 2188 |
}
|
1950 |
}
|
| 2189 |
StringBuilder sb = new StringBuilder();
|
1951 |
StringBuilder sb = new StringBuilder();
|
| 2190 |
sb.append("<html><body>");
|
1952 |
sb.append("<html><body>");
|
| 2191 |
sb.append("<p>Statewise Sale Report:</p><br/><table style=\"border-collapse: collapse;\">");
|
1953 |
sb.append("<p>Statewise Sale Report:</p><br/><table style=\"border-collapse: collapse;\">");
|
| 2192 |
sb.append("<tbody>\n" + " <tr>"
|
- |
|
| 2193 |
+ " <th style='border:1px solid black;padding: 5px'>State</th>"
|
- |
|
| 2194 |
+ " <th style='border:1px solid black;padding: 5px'>SmartPhone Qty</th>"
|
- |
|
| 2195 |
+ " <th style='border:1px solid black;padding: 5px'>SmartPhone Value</th>"
|
1954 |
sb.append("<tbody>\n" + " <tr>" + " <th style='border:1px solid black;padding: 5px'>State</th>" + " <th style='border:1px solid black;padding: 5px'>SmartPhone Qty</th>" + " <th style='border:1px solid black;padding: 5px'>SmartPhone Value</th>" + " <th style='border:1px solid black;padding: 5px'>Total Qty</th>" + " <th style='border:1px solid black;padding: 5px'>Total Value</th>" + " </tr>");
|
| 2196 |
+ " <th style='border:1px solid black;padding: 5px'>Total Qty</th>"
|
- |
|
| 2197 |
+ " <th style='border:1px solid black;padding: 5px'>Total Value</th>"
|
- |
|
| 2198 |
+ " </tr>");
|
- |
|
| 2199 |
for (List<Serializable> stateSale : stateWiseSales) {
|
1955 |
for (List<Serializable> stateSale : stateWiseSales) {
|
| 2200 |
sb.append("<tr>");
|
1956 |
sb.append("<tr>");
|
| 2201 |
sb.append("<td style='border:1px solid black;padding: 5px'>" + stateSale.get(0) + "</td>");
|
1957 |
sb.append("<td style='border:1px solid black;padding: 5px'>" + stateSale.get(0) + "</td>");
|
| 2202 |
sb.append("<td style='border:1px solid black;padding: 5px'>" + stateSale.get(1) + "</td>");
|
1958 |
sb.append("<td style='border:1px solid black;padding: 5px'>" + stateSale.get(1) + "</td>");
|
| 2203 |
sb.append("<td style='border:1px solid black;padding: 5px'>" + stateSale.get(2) + "</td>");
|
1959 |
sb.append("<td style='border:1px solid black;padding: 5px'>" + stateSale.get(2) + "</td>");
|
| Line 2206... |
Line 1962... |
| 2206 |
sb.append("</tr>");
|
1962 |
sb.append("</tr>");
|
| 2207 |
}
|
1963 |
}
|
| 2208 |
sb.append("</tbody></table><br><br>");
|
1964 |
sb.append("</tbody></table><br><br>");
|
| 2209 |
|
1965 |
|
| 2210 |
sb.append("<p>Partnerwise Report:</p><br/><table style=\"border-collapse: collapse;\">");
|
1966 |
sb.append("<p>Partnerwise Report:</p><br/><table style=\"border-collapse: collapse;\">");
|
| 2211 |
sb.append("<tbody>\n" + " <tr>\n"
|
- |
|
| 2212 |
+ " <th style='border:1px solid black;padding: 5px'>Code</th>"
|
- |
|
| 2213 |
+ " <th style='border:1px solid black;padding: 5px'>Business Name</th>"
|
- |
|
| 2214 |
+ " <th style='border:1px solid black;padding: 5px'>BDM Name</th>"
|
- |
|
| 2215 |
+ " <th style='border:1px solid black;padding: 5px'>Regional Manager</th>"
|
- |
|
| 2216 |
+ " <th style='border:1px solid black;padding: 5px'>Territory Manager</th>"
|
1967 |
sb.append("<tbody>\n" + " <tr>\n" + " <th style='border:1px solid black;padding: 5px'>Code</th>" + " <th style='border:1px solid black;padding: 5px'>Business Name</th>" + " <th style='border:1px solid black;padding: 5px'>BDM Name</th>" + " <th style='border:1px solid black;padding: 5px'>Regional Manager</th>" + " <th style='border:1px solid black;padding: 5px'>Territory Manager</th>" + " <th style='border:1px solid black;padding: 5px'>Billed(4 days)</th>" + " <th style='border:1px solid black;padding: 5px'>Sale</th>" + " <th style='border:1px solid black;padding: 5px'>Smartphone Sale</th>" + " <th style='border:1px solid black;padding: 5px'>SmartPhone Qty</th>" + " </tr>");
|
| 2217 |
+ " <th style='border:1px solid black;padding: 5px'>Billed(4 days)</th>"
|
- |
|
| 2218 |
+ " <th style='border:1px solid black;padding: 5px'>Sale</th>"
|
- |
|
| 2219 |
+ " <th style='border:1px solid black;padding: 5px'>Smartphone Sale</th>"
|
- |
|
| 2220 |
+ " <th style='border:1px solid black;padding: 5px'>SmartPhone Qty</th>"
|
- |
|
| 2221 |
+ " </tr>");
|
- |
|
| 2222 |
|
1968 |
|
| 2223 |
|
1969 |
|
| 2224 |
List<Integer> sortedSaleTargetReport = saleTargetReportModelMap.values().stream()
|
1970 |
List<Integer> sortedSaleTargetReport = saleTargetReportModelMap.values().stream().filter(x -> fofoIds.contains(x.getFofoId())).sorted(Comparator.comparing(SaleTargetReportModel::getCode).thenComparing(SaleTargetReportModel::getSecondary)).map(SaleTargetReportModel::getFofoId).collect(Collectors.toList());
|
| 2225 |
.filter(x -> fofoIds.contains(x.getFofoId()))
|
- |
|
| 2226 |
.sorted(Comparator.comparing(SaleTargetReportModel::getCode).thenComparing(SaleTargetReportModel::getSecondary))
|
- |
|
| 2227 |
.map(SaleTargetReportModel::getFofoId).collect(Collectors.toList());
|
- |
|
| 2228 |
|
1971 |
|
| 2229 |
String subject = String.format("Sale till %s", String.format(timeString, now.format(timeFormatter)));
|
1972 |
String subject = String.format("Sale till %s", String.format(timeString, now.format(timeFormatter)));
|
| 2230 |
|
1973 |
|
| 2231 |
List<String> headers = Arrays.asList("Store Id", "Store Code", "Store Name", "Activation Type", "BDM Name", "Regional Manager", "Territory Manager",
|
1974 |
List<String> headers = Arrays.asList("Store Id", "Store Code", "Store Name", "Activation Type", "BDM Name", "Regional Manager", "Territory Manager", "Secondary(4 days)", "Sale", "Smartphone Value", "Smartphone Qty");
|
| 2232 |
"Secondary(4 days)", "Sale", "Smartphone Value", "Smartphone Qty");
|
- |
|
| 2233 |
List<List<?>> rows = new ArrayList<>();
|
1975 |
List<List<?>> rows = new ArrayList<>();
|
| 2234 |
for (Integer fofoId : sortedSaleTargetReport) {
|
1976 |
for (Integer fofoId : sortedSaleTargetReport) {
|
| 2235 |
FofoReportingModel fofoReportingModel = partnerSalesHeadersMap.get(fofoId);
|
1977 |
FofoReportingModel fofoReportingModel = partnerSalesHeadersMap.get(fofoId);
|
| 2236 |
rows.add(Arrays.asList(fofoId, fofoReportingModel.getCode(), fofoReportingModel.getBusinessName(), saleTargetReportModelMap.get(fofoId).getActivationType(),
|
1978 |
rows.add(Arrays.asList(fofoId, fofoReportingModel.getCode(), fofoReportingModel.getBusinessName(), saleTargetReportModelMap.get(fofoId).getActivationType(), fofoReportingModel.getBusinessManager(), fofoReportingModel.getRegionalManager(), fofoReportingModel.getTerritoryManager(), saleTargetReportModelMap.get(fofoId).getSecondary(), saleTargetReportModelMap.get(fofoId).getTotalSale(), saleTargetReportModelMap.get(fofoId).getSmartphoneSale(), saleTargetReportModelMap.get(fofoId).getSmartphoneQty()
|
| 2237 |
fofoReportingModel.getBusinessManager(), fofoReportingModel.getRegionalManager(), fofoReportingModel.getTerritoryManager(),
|
- |
|
| 2238 |
saleTargetReportModelMap.get(fofoId).getSecondary(), saleTargetReportModelMap.get(fofoId).getTotalSale(),
|
- |
|
| 2239 |
saleTargetReportModelMap.get(fofoId).getSmartphoneSale(), saleTargetReportModelMap.get(fofoId).getSmartphoneQty()
|
- |
|
| 2240 |
));
|
1979 |
));
|
| 2241 |
|
1980 |
|
| 2242 |
//Now try to populate html rows
|
1981 |
//Now try to populate html rows
|
| 2243 |
if (!saleTargetReportModelMap.get(fofoId).getActivationType().equals(ActivationType.ACTIVE)) {
|
1982 |
if (!saleTargetReportModelMap.get(fofoId).getActivationType().equals(ActivationType.ACTIVE)) {
|
| 2244 |
continue;
|
1983 |
continue;
|
| Line 2246... |
Line 1985... |
| 2246 |
if (saleTargetReportModelMap.get(fofoId).getSecondary() == 0) {
|
1985 |
if (saleTargetReportModelMap.get(fofoId).getSecondary() == 0) {
|
| 2247 |
sb.append("<tr style='background-color:#D21F3C;color:white'>");
|
1986 |
sb.append("<tr style='background-color:#D21F3C;color:white'>");
|
| 2248 |
} else {
|
1987 |
} else {
|
| 2249 |
sb.append("<tr>");
|
1988 |
sb.append("<tr>");
|
| 2250 |
}
|
1989 |
}
|
| 2251 |
sb.append("<td style='border:1px solid black;padding: 5px'>"
|
- |
|
| 2252 |
+ partnerSalesHeadersMap.get(fofoId).getCode() + "</td>");
|
1990 |
sb.append("<td style='border:1px solid black;padding: 5px'>" + partnerSalesHeadersMap.get(fofoId).getCode() + "</td>");
|
| 2253 |
sb.append("<td style='border:1px solid black;padding: 5px'>"
|
- |
|
| 2254 |
+ partnerSalesHeadersMap.get(fofoId).getBusinessName() + "</td>");
|
1991 |
sb.append("<td style='border:1px solid black;padding: 5px'>" + partnerSalesHeadersMap.get(fofoId).getBusinessName() + "</td>");
|
| 2255 |
sb.append("<td style='border:1px solid black;padding: 5px'>"
|
- |
|
| 2256 |
+ partnerSalesHeadersMap.get(fofoId).getBusinessManager() + "</td>");
|
1992 |
sb.append("<td style='border:1px solid black;padding: 5px'>" + partnerSalesHeadersMap.get(fofoId).getBusinessManager() + "</td>");
|
| 2257 |
sb.append("<td style='border:1px solid black;padding: 5px'>"
|
- |
|
| 2258 |
+ partnerSalesHeadersMap.get(fofoId).getRegionalManager() + "</td>");
|
1993 |
sb.append("<td style='border:1px solid black;padding: 5px'>" + partnerSalesHeadersMap.get(fofoId).getRegionalManager() + "</td>");
|
| 2259 |
sb.append("<td style='border:1px solid black;padding: 5px'>"
|
- |
|
| 2260 |
+ partnerSalesHeadersMap.get(fofoId).getTerritoryManager() + "</td>");
|
1994 |
sb.append("<td style='border:1px solid black;padding: 5px'>" + partnerSalesHeadersMap.get(fofoId).getTerritoryManager() + "</td>");
|
| 2261 |
sb.append("<td style='border:1px solid black;padding: 5px'>"
|
- |
|
| 2262 |
+ saleTargetReportModelMap.get(fofoId).getSecondary() + "</td>");
|
1995 |
sb.append("<td style='border:1px solid black;padding: 5px'>" + saleTargetReportModelMap.get(fofoId).getSecondary() + "</td>");
|
| 2263 |
sb.append("<td style='border:1px solid black;padding: 5px'>"
|
- |
|
| 2264 |
+ saleTargetReportModelMap.get(fofoId).getTotalSale() + "</td>");
|
1996 |
sb.append("<td style='border:1px solid black;padding: 5px'>" + saleTargetReportModelMap.get(fofoId).getTotalSale() + "</td>");
|
| 2265 |
sb.append("<td style='border:1px solid black;padding: 5px'>"
|
- |
|
| 2266 |
+ saleTargetReportModelMap.get(fofoId).getSmartphoneSale() + "</td>");
|
1997 |
sb.append("<td style='border:1px solid black;padding: 5px'>" + saleTargetReportModelMap.get(fofoId).getSmartphoneSale() + "</td>");
|
| 2267 |
sb.append("<td style='border:1px solid black;padding: 5px'>"
|
- |
|
| 2268 |
+ saleTargetReportModelMap.get(fofoId).getSmartphoneQty() + "</td>");
|
1998 |
sb.append("<td style='border:1px solid black;padding: 5px'>" + saleTargetReportModelMap.get(fofoId).getSmartphoneQty() + "</td>");
|
| 2269 |
sb.append("</tr>");
|
1999 |
sb.append("</tr>");
|
| 2270 |
|
2000 |
|
| 2271 |
|
2001 |
|
| 2272 |
}
|
2002 |
}
|
| 2273 |
sb.append("</tr>");
|
2003 |
sb.append("</tr>");
|
| Line 2285... |
Line 2015... |
| 2285 |
Utils.sendHtmlMailWithAttachments(googleMailSender, new String[]{email}, null, "Statewise " + subject, statewiseSaleReport, attachment);
|
2015 |
Utils.sendHtmlMailWithAttachments(googleMailSender, new String[]{email}, null, "Statewise " + subject, statewiseSaleReport, attachment);
|
| 2286 |
}
|
2016 |
}
|
| 2287 |
}
|
2017 |
}
|
| 2288 |
}
|
2018 |
}
|
| 2289 |
|
2019 |
|
| 2290 |
private void sendMailOfHtmlFormat(String email, String body, String cc[], String subject)
|
2020 |
private void sendMailOfHtmlFormat(String email, String body, String cc[], String subject) throws MessagingException, ProfitMandiBusinessException, IOException {
|
| 2291 |
throws MessagingException, ProfitMandiBusinessException, IOException {
|
- |
|
| 2292 |
MimeMessage message = mailSender.createMimeMessage();
|
2021 |
MimeMessage message = mailSender.createMimeMessage();
|
| 2293 |
MimeMessageHelper helper = new MimeMessageHelper(message);
|
2022 |
MimeMessageHelper helper = new MimeMessageHelper(message);
|
| 2294 |
helper.setSubject(subject);
|
2023 |
helper.setSubject(subject);
|
| 2295 |
helper.setText(body, true);
|
2024 |
helper.setText(body, true);
|
| 2296 |
helper.setTo(email);
|
2025 |
helper.setTo(email);
|
| Line 2305... |
Line 2034... |
| 2305 |
public void sendNotification() throws Exception {
|
2034 |
public void sendNotification() throws Exception {
|
| 2306 |
List<PushNotifications> pushNotifications = pushNotificationRepository.selectAllByTimestamp();
|
2035 |
List<PushNotifications> pushNotifications = pushNotificationRepository.selectAllByTimestamp();
|
| 2307 |
if (!pushNotifications.isEmpty()) {
|
2036 |
if (!pushNotifications.isEmpty()) {
|
| 2308 |
for (PushNotifications pushNotification : pushNotifications) {
|
2037 |
for (PushNotifications pushNotification : pushNotifications) {
|
| 2309 |
Device device = deviceRepository.selectById(pushNotification.getDeviceId());
|
2038 |
Device device = deviceRepository.selectById(pushNotification.getDeviceId());
|
| 2310 |
NotificationCampaign notificationCampaign = notificationCampaignRepository
|
2039 |
NotificationCampaign notificationCampaign = notificationCampaignRepository.selectById(pushNotification.getNotificationCampaignid());
|
| 2311 |
.selectById(pushNotification.getNotificationCampaignid());
|
- |
|
| 2312 |
SimpleCampaignParams scp = gson.fromJson(notificationCampaign.getImplementationParams(),
|
2040 |
SimpleCampaignParams scp = gson.fromJson(notificationCampaign.getImplementationParams(), SimpleCampaignParams.class);
|
| 2313 |
SimpleCampaignParams.class);
|
- |
|
| 2314 |
Campaign campaign = new SimpleCampaign(scp);
|
2041 |
Campaign campaign = new SimpleCampaign(scp);
|
| 2315 |
String result_url = campaign.getUrl() + "&user_id=" + device.getUser_id();
|
2042 |
String result_url = campaign.getUrl() + "&user_id=" + device.getUser_id();
|
| 2316 |
JSONObject json = new JSONObject();
|
2043 |
JSONObject json = new JSONObject();
|
| 2317 |
json.put("to", device.getFcmId());
|
2044 |
json.put("to", device.getFcmId());
|
| 2318 |
JSONObject jsonObj = new JSONObject();
|
2045 |
JSONObject jsonObj = new JSONObject();
|
| Line 2357... |
Line 2084... |
| 2357 |
}
|
2084 |
}
|
| 2358 |
|
2085 |
|
| 2359 |
public void grouping() throws Exception {
|
2086 |
public void grouping() throws Exception {
|
| 2360 |
DateTimeFormatter dtf = DateTimeFormatter.ofPattern("MM-dd-yyyy hh:mm");
|
2087 |
DateTimeFormatter dtf = DateTimeFormatter.ofPattern("MM-dd-yyyy hh:mm");
|
| 2361 |
List<PriceDropIMEI> priceDropImeis = priceDropIMEIRepository.selectByStatus(PriceDropImeiStatus.APPROVED);
|
2088 |
List<PriceDropIMEI> priceDropImeis = priceDropIMEIRepository.selectByStatus(PriceDropImeiStatus.APPROVED);
|
| 2362 |
System.out.println(String.join("\t",
|
- |
|
| 2363 |
Arrays.asList("IMEI", "ItemId", "Brand", "Model Name", "Model Number", "Franchise Id", "Franchise Name",
|
2089 |
System.out.println(String.join("\t", Arrays.asList("IMEI", "ItemId", "Brand", "Model Name", "Model Number", "Franchise Id", "Franchise Name", "Grn On", "Price Dropped On", "Approved On", "Returned On", "Price Drop Paid", "Is Doa")));
|
| 2364 |
"Grn On", "Price Dropped On", "Approved On", "Returned On", "Price Drop Paid", "Is Doa")));
|
- |
|
| 2365 |
Map<Integer, CustomRetailer> retailersMap = retailerService.getFofoRetailers(false);
|
2090 |
Map<Integer, CustomRetailer> retailersMap = retailerService.getFofoRetailers(false);
|
| 2366 |
for (PriceDropIMEI priceDropIMEI : priceDropImeis) {
|
2091 |
for (PriceDropIMEI priceDropIMEI : priceDropImeis) {
|
| 2367 |
if (priceDropIMEI.getPartnerId() == 0)
|
2092 |
if (priceDropIMEI.getPartnerId() == 0)
|
| 2368 |
continue;
|
2093 |
continue;
|
| 2369 |
HashSet<String> imeis = new HashSet<>();
|
2094 |
HashSet<String> imeis = new HashSet<>();
|
| 2370 |
PriceDrop priceDrop = priceDropRepository.selectById(priceDropIMEI.getPriceDropId());
|
2095 |
PriceDrop priceDrop = priceDropRepository.selectById(priceDropIMEI.getPriceDropId());
|
| 2371 |
imeis.add(priceDropIMEI.getImei());
|
2096 |
imeis.add(priceDropIMEI.getImei());
|
| 2372 |
List<InventoryItem> inventoryItems = inventoryItemRepository
|
- |
|
| 2373 |
.selectByFofoIdSerialNumbers(priceDropIMEI.getPartnerId(), imeis, false);
|
2097 |
List<InventoryItem> inventoryItems = inventoryItemRepository.selectByFofoIdSerialNumbers(priceDropIMEI.getPartnerId(), imeis, false);
|
| 2374 |
if (inventoryItems.size() == 0) {
|
2098 |
if (inventoryItems.size() == 0) {
|
| 2375 |
LOGGER.info("Need to investigate partnerId - {} imeis - {}", priceDropIMEI.getPartnerId(), imeis);
|
2099 |
LOGGER.info("Need to investigate partnerId - {} imeis - {}", priceDropIMEI.getPartnerId(), imeis);
|
| 2376 |
continue;
|
2100 |
continue;
|
| 2377 |
}
|
2101 |
}
|
| 2378 |
InventoryItem inventoryItem = inventoryItems.get(0);
|
2102 |
InventoryItem inventoryItem = inventoryItems.get(0);
|
| 2379 |
CustomRetailer customRetailer = retailersMap.get(inventoryItem.getFofoId());
|
2103 |
CustomRetailer customRetailer = retailersMap.get(inventoryItem.getFofoId());
|
| 2380 |
if (inventoryItem.getLastScanType().equals(ScanType.DOA_OUT)
|
- |
|
| 2381 |
|| inventoryItem.getLastScanType().equals(ScanType.PURCHASE_RET)) {
|
2104 |
if (inventoryItem.getLastScanType().equals(ScanType.DOA_OUT) || inventoryItem.getLastScanType().equals(ScanType.PURCHASE_RET)) {
|
| 2382 |
// check if pricedrop has been rolled out
|
2105 |
// check if pricedrop has been rolled out
|
| 2383 |
List<UserWalletHistory> uwh = walletService.getAllByReference(inventoryItem.getFofoId(),
|
2106 |
List<UserWalletHistory> uwh = walletService.getAllByReference(inventoryItem.getFofoId(), priceDropIMEI.getPriceDropId(), WalletReferenceType.PRICE_DROP);
|
| 2384 |
priceDropIMEI.getPriceDropId(), WalletReferenceType.PRICE_DROP);
|
- |
|
| 2385 |
if (uwh.size() > 0) {
|
2107 |
if (uwh.size() > 0) {
|
| 2386 |
Item item = itemRepository.selectById(inventoryItem.getItemId());
|
2108 |
Item item = itemRepository.selectById(inventoryItem.getItemId());
|
| 2387 |
System.out.println(String.join("\t",
|
2109 |
System.out.println(String.join("\t", Arrays.asList(priceDropIMEI.getImei(), inventoryItem.getItemId() + "", item.getBrand(), item.getModelName(), item.getModelNumber(), inventoryItem.getFofoId() + "", customRetailer.getBusinessName(), inventoryItem.getCreateTimestamp().format(dtf), priceDrop.getAffectedOn().format(dtf), priceDropIMEI.getUpdateTimestamp().format(dtf), inventoryItem.getUpdateTimestamp().format(dtf), priceDrop.getAutoPartnerPayout(inventoryItem.getUpdateTimestamp()) + "", inventoryItem.getLastScanType().equals(ScanType.DOA_OUT) + "")));
|
| 2388 |
Arrays.asList(priceDropIMEI.getImei(), inventoryItem.getItemId() + "", item.getBrand(),
|
- |
|
| 2389 |
item.getModelName(), item.getModelNumber(), inventoryItem.getFofoId() + "",
|
- |
|
| 2390 |
customRetailer.getBusinessName(), inventoryItem.getCreateTimestamp().format(dtf),
|
- |
|
| 2391 |
priceDrop.getAffectedOn().format(dtf),
|
- |
|
| 2392 |
priceDropIMEI.getUpdateTimestamp().format(dtf),
|
- |
|
| 2393 |
inventoryItem.getUpdateTimestamp().format(dtf),
|
- |
|
| 2394 |
priceDrop.getAutoPartnerPayout(inventoryItem.getUpdateTimestamp()) + "",
|
- |
|
| 2395 |
inventoryItem.getLastScanType().equals(ScanType.DOA_OUT) + "")));
|
- |
|
| 2396 |
}
|
2110 |
}
|
| 2397 |
}
|
2111 |
}
|
| 2398 |
}
|
2112 |
}
|
| 2399 |
}
|
2113 |
}
|
| 2400 |
|
2114 |
|
| Line 2402... |
Line 2116... |
| 2402 |
toffeeService.cancelPolicyCopy("110143521986");
|
2116 |
toffeeService.cancelPolicyCopy("110143521986");
|
| 2403 |
toffeeService.getOrderId("110143521986");
|
2117 |
toffeeService.getOrderId("110143521986");
|
| 2404 |
}
|
2118 |
}
|
| 2405 |
|
2119 |
|
| 2406 |
public void attachToffeeInvoices() throws Exception {
|
2120 |
public void attachToffeeInvoices() throws Exception {
|
| 2407 |
List<InsurancePolicy> insurancePolicies = insurancePolicyRepository.selectAllByProviderId(3,
|
2121 |
List<InsurancePolicy> insurancePolicies = insurancePolicyRepository.selectAllByProviderId(3, Optional.of(false));
|
| 2408 |
Optional.of(false));
|
- |
|
| 2409 |
for (InsurancePolicy insurancePolicy : insurancePolicies) {
|
2122 |
for (InsurancePolicy insurancePolicy : insurancePolicies) {
|
| 2410 |
String invoiceNumber = insurancePolicy.getInvoiceNumber();
|
2123 |
String invoiceNumber = insurancePolicy.getInvoiceNumber();
|
| 2411 |
FofoOrder fofoOrder = fofoOrderRepository.selectByInvoiceNumber(invoiceNumber);
|
2124 |
FofoOrder fofoOrder = fofoOrderRepository.selectByInvoiceNumber(invoiceNumber);
|
| 2412 |
InvoicePdfModel pdfModel = orderService.getInvoicePdfModel(fofoOrder.getId());
|
2125 |
InvoicePdfModel pdfModel = orderService.getInvoicePdfModel(fofoOrder.getId());
|
| 2413 |
java.io.ByteArrayOutputStream byteArrayOutputStream = new java.io.ByteArrayOutputStream();
|
2126 |
java.io.ByteArrayOutputStream byteArrayOutputStream = new java.io.ByteArrayOutputStream();
|
| 2414 |
PdfUtils.generateAndWrite(Arrays.asList(pdfModel), byteArrayOutputStream);
|
2127 |
PdfUtils.generateAndWrite(Arrays.asList(pdfModel), byteArrayOutputStream);
|
| 2415 |
String pdfInvoiceString = "data:application/pdf;base64,"
|
- |
|
| 2416 |
+ Base64.getEncoder().encodeToString(byteArrayOutputStream.toByteArray());
|
2128 |
String pdfInvoiceString = "data:application/pdf;base64," + Base64.getEncoder().encodeToString(byteArrayOutputStream.toByteArray());
|
| 2417 |
boolean attached = toffeeService.attachInvoice(insurancePolicy.getPolicyNumber().split("#")[1],
|
2129 |
boolean attached = toffeeService.attachInvoice(insurancePolicy.getPolicyNumber().split("#")[1], pdfInvoiceString);
|
| 2418 |
pdfInvoiceString);
|
- |
|
| 2419 |
if (attached) {
|
2130 |
if (attached) {
|
| 2420 |
insurancePolicy.setPosted(true);
|
2131 |
insurancePolicy.setPosted(true);
|
| 2421 |
}
|
2132 |
}
|
| 2422 |
}
|
2133 |
}
|
| 2423 |
}
|
2134 |
}
|
| 2424 |
|
2135 |
|
| 2425 |
public void sendBAGPendingPolicies() throws Exception {
|
2136 |
public void sendBAGPendingPolicies() throws Exception {
|
| 2426 |
List<InsurancePolicy> insurancePolicies = insurancePolicyRepository.selectAllByProviderId(4,
|
2137 |
List<InsurancePolicy> insurancePolicies = insurancePolicyRepository.selectAllByProviderId(4, Optional.of(false));
|
| 2427 |
Optional.of(false));
|
- |
|
| 2428 |
for (InsurancePolicy insurancePolicy : insurancePolicies) {
|
2138 |
for (InsurancePolicy insurancePolicy : insurancePolicies) {
|
| 2429 |
String invoiceNumber = insurancePolicy.getInvoiceNumber();
|
2139 |
String invoiceNumber = insurancePolicy.getInvoiceNumber();
|
| 2430 |
FofoOrder fofoOrder = fofoOrderRepository.selectByInvoiceNumber(invoiceNumber);
|
2140 |
FofoOrder fofoOrder = fofoOrderRepository.selectByInvoiceNumber(invoiceNumber);
|
| 2431 |
FofoOrderItem fofoOrderItem = fofoOrderItemRepository.selectByOrderId(fofoOrder.getId()).get(0);
|
2141 |
FofoOrderItem fofoOrderItem = fofoOrderItemRepository.selectByOrderId(fofoOrder.getId()).get(0);
|
| 2432 |
CustomerAddress customerAddress = customerAddressRepository.selectById(fofoOrder.getCustomerAddressId());
|
2142 |
CustomerAddress customerAddress = customerAddressRepository.selectById(fofoOrder.getCustomerAddressId());
|
| Line 2450... |
Line 2160... |
| 2450 |
}
|
2160 |
}
|
| 2451 |
}
|
2161 |
}
|
| 2452 |
|
2162 |
|
| 2453 |
public void schemeRollback(List<String> schemeIds) throws Exception {
|
2163 |
public void schemeRollback(List<String> schemeIds) throws Exception {
|
| 2454 |
List<Integer> schemeIdsInt = schemeIds.stream().map(x -> Integer.parseInt(x)).collect(Collectors.toList());
|
2164 |
List<Integer> schemeIdsInt = schemeIds.stream().map(x -> Integer.parseInt(x)).collect(Collectors.toList());
|
| 2455 |
Map<Integer, Scheme> schemesMap = schemeRepository.selectBySchemeIds(schemeIdsInt, 0, schemeIds.size()).stream()
|
2165 |
Map<Integer, Scheme> schemesMap = schemeRepository.selectBySchemeIds(schemeIdsInt, 0, schemeIds.size()).stream().collect(Collectors.toMap(x -> x.getId(), x -> x));
|
| 2456 |
.collect(Collectors.toMap(x -> x.getId(), x -> x));
|
- |
|
| 2457 |
List<SchemeInOut> schemeInOuts = schemeInOutRepository.selectBySchemeIds(new HashSet<>(schemeIdsInt));
|
2166 |
List<SchemeInOut> schemeInOuts = schemeInOutRepository.selectBySchemeIds(new HashSet<>(schemeIdsInt));
|
| 2458 |
for (SchemeInOut sio : schemeInOuts) {
|
2167 |
for (SchemeInOut sio : schemeInOuts) {
|
| 2459 |
Scheme scheme = schemesMap.get(sio.getSchemeId());
|
2168 |
Scheme scheme = schemesMap.get(sio.getSchemeId());
|
| 2460 |
if (scheme.getType().equals(SchemeType.IN)) {
|
2169 |
if (scheme.getType().equals(SchemeType.IN)) {
|
| 2461 |
|
2170 |
|
| 2462 |
} else if (scheme.getType().equals(SchemeType.OUT)) {
|
2171 |
} else if (scheme.getType().equals(SchemeType.OUT)) {
|
| 2463 |
InventoryItem inventoryItem = inventoryItemRepository.selectById(sio.getInventoryItemId());
|
2172 |
InventoryItem inventoryItem = inventoryItemRepository.selectById(sio.getInventoryItemId());
|
| 2464 |
List<ScanRecord> sr = scanRecordRepository.selectByInventoryItemId(sio.getInventoryItemId());
|
2173 |
List<ScanRecord> sr = scanRecordRepository.selectByInventoryItemId(sio.getInventoryItemId());
|
| 2465 |
ScanRecord scanRecord = sr.stream().filter(x -> x.getType().equals(ScanType.SALE))
|
- |
|
| 2466 |
.max((x1, x2) -> x1.getCreateTimestamp().compareTo(x2.getCreateTimestamp())).get();
|
2174 |
ScanRecord scanRecord = sr.stream().filter(x -> x.getType().equals(ScanType.SALE)).max((x1, x2) -> x1.getCreateTimestamp().compareTo(x2.getCreateTimestamp())).get();
|
| 2467 |
if (scanRecord.getCreateTimestamp().isAfter(scheme.getEndDateTime())
|
- |
|
| 2468 |
|| scanRecord.getCreateTimestamp().isBefore(scheme.getStartDateTime())) {
|
2175 |
if (scanRecord.getCreateTimestamp().isAfter(scheme.getEndDateTime()) || scanRecord.getCreateTimestamp().isBefore(scheme.getStartDateTime())) {
|
| 2469 |
sio.setRolledBackTimestamp(LocalDateTime.now());
|
2176 |
sio.setRolledBackTimestamp(LocalDateTime.now());
|
| 2470 |
FofoOrder fofoOrder = fofoOrderRepository.selectByOrderId(scanRecord.getOrderId());
|
2177 |
FofoOrder fofoOrder = fofoOrderRepository.selectByOrderId(scanRecord.getOrderId());
|
| 2471 |
String rollbackReason = "Scheme reversed for "
|
- |
|
| 2472 |
+ itemRepository.selectById(inventoryItem.getItemId()).getItemDescription() + "/Inv - "
|
2178 |
String rollbackReason = "Scheme reversed for " + itemRepository.selectById(inventoryItem.getItemId()).getItemDescription() + "/Inv - " + fofoOrder.getInvoiceNumber();
|
| 2473 |
+ fofoOrder.getInvoiceNumber();
|
- |
|
| 2474 |
walletService.rollbackAmountFromWallet(scanRecord.getFofoId(), sio.getAmount(),
|
2179 |
walletService.rollbackAmountFromWallet(scanRecord.getFofoId(), sio.getAmount(), scanRecord.getOrderId(), WalletReferenceType.SCHEME_OUT, rollbackReason, LocalDateTime.now());
|
| 2475 |
scanRecord.getOrderId(), WalletReferenceType.SCHEME_OUT, rollbackReason,
|
- |
|
| 2476 |
LocalDateTime.now());
|
- |
|
| 2477 |
System.out.printf("Amount %f,SchemeId %d,Reason %s\n", sio.getAmount(), sio.getSchemeId(),
|
2180 |
System.out.printf("Amount %f,SchemeId %d,Reason %s\n", sio.getAmount(), sio.getSchemeId(), rollbackReason);
|
| 2478 |
rollbackReason);
|
- |
|
| 2479 |
}
|
2181 |
}
|
| 2480 |
}
|
2182 |
}
|
| 2481 |
}
|
2183 |
}
|
| 2482 |
// throw new Exception();
|
2184 |
// throw new Exception();
|
| 2483 |
}
|
2185 |
}
|
| 2484 |
|
2186 |
|
| 2485 |
public void checkfocusedModelInPartnerStock() throws Exception {
|
2187 |
public void checkfocusedModelInPartnerStock() throws Exception {
|
| 2486 |
|
2188 |
|
| 2487 |
List<Integer> fofoIds = fofoStoreRepository.selectAll().stream().filter(x -> x.isActive()).map(x -> x.getId())
|
2189 |
List<Integer> fofoIds = fofoStoreRepository.selectAll().stream().filter(x -> x.isActive()).map(x -> x.getId()).collect(Collectors.toList());
|
| 2488 |
.collect(Collectors.toList());
|
- |
|
| 2489 |
Map<Integer, Map<Integer, List<SaholicCIS>>> warehouseItemAvailabilityMap = saholicInventoryService
|
2190 |
Map<Integer, Map<Integer, List<SaholicCIS>>> warehouseItemAvailabilityMap = saholicInventoryService.getSaholicStock();
|
| 2490 |
.getSaholicStock();
|
- |
|
| 2491 |
Map<Integer, String> warehouseMap = ProfitMandiConstants.WAREHOUSE_MAP;
|
2191 |
Map<Integer, String> warehouseMap = ProfitMandiConstants.WAREHOUSE_MAP;
|
| 2492 |
Map<Integer, FofoReportingModel> partnerIdSalesHeadersMap = this.getPartnerIdSalesHeaders();
|
2192 |
Map<Integer, FofoReportingModel> partnerIdSalesHeadersMap = this.getPartnerIdSalesHeaders();
|
| 2493 |
|
2193 |
|
| 2494 |
Map<Integer, Map<Integer, List<SaholicPOItem>>> warehousePoItemAvailabilityMap = saholicInventoryService
|
2194 |
Map<Integer, Map<Integer, List<SaholicPOItem>>> warehousePoItemAvailabilityMap = saholicInventoryService.getSaholicPOItems();
|
| 2495 |
.getSaholicPOItems();
|
- |
|
| 2496 |
Map<Integer, List<FocusedModelShortageModel>> focusedModelShortageReportMap = new HashMap<>();
|
2195 |
Map<Integer, List<FocusedModelShortageModel>> focusedModelShortageReportMap = new HashMap<>();
|
| 2497 |
for (Integer fofoId : fofoIds) {
|
2196 |
for (Integer fofoId : fofoIds) {
|
| 2498 |
List<FocusedModelShortageModel> focusedModelShortageList = new ArrayList<>();
|
2197 |
List<FocusedModelShortageModel> focusedModelShortageList = new ArrayList<>();
|
| 2499 |
focusedModelShortageReportMap.put(fofoId, focusedModelShortageList);
|
2198 |
focusedModelShortageReportMap.put(fofoId, focusedModelShortageList);
|
| 2500 |
CustomRetailer customRetailer = retailerService.getFofoRetailer(fofoId);
|
2199 |
CustomRetailer customRetailer = retailerService.getFofoRetailer(fofoId);
|
| 2501 |
Map<Integer, Integer> processingOrderMap = null;
|
2200 |
Map<Integer, Integer> processingOrderMap = null;
|
| 2502 |
Map<Integer, Integer> catalogIdAndQtyMap = null;
|
2201 |
Map<Integer, Integer> catalogIdAndQtyMap = null;
|
| 2503 |
Map<Integer, Integer> grnPendingOrdersMap = null;
|
2202 |
Map<Integer, Integer> grnPendingOrdersMap = null;
|
| 2504 |
|
2203 |
|
| 2505 |
Map<Integer, Integer> currentInventorySnapshot = currentInventorySnapshotRepository.selectByFofoId(fofoId)
|
2204 |
Map<Integer, Integer> currentInventorySnapshot = currentInventorySnapshotRepository.selectByFofoId(fofoId).stream().collect(Collectors.toMap(x -> x.getItemId(), x -> x.getAvailability()));
|
| 2506 |
.stream().collect(Collectors.toMap(x -> x.getItemId(), x -> x.getAvailability()));
|
- |
|
| 2507 |
|
2205 |
|
| 2508 |
if (!currentInventorySnapshot.isEmpty()) {
|
2206 |
if (!currentInventorySnapshot.isEmpty()) {
|
| 2509 |
catalogIdAndQtyMap = itemRepository.selectByIds(currentInventorySnapshot.keySet()).stream()
|
2207 |
catalogIdAndQtyMap = itemRepository.selectByIds(currentInventorySnapshot.keySet()).stream().collect(groupingBy(x -> x.getCatalogItemId(), Collectors.summingInt(x -> currentInventorySnapshot.get(x.getId()))));
|
| 2510 |
.collect(groupingBy(x -> x.getCatalogItemId(),
|
- |
|
| 2511 |
Collectors.summingInt(x -> currentInventorySnapshot.get(x.getId()))));
|
- |
|
| 2512 |
|
2208 |
|
| 2513 |
}
|
2209 |
}
|
| 2514 |
|
2210 |
|
| 2515 |
Map<Integer, Integer> grnPendingOrders = orderRepository.selectPendingGrnOrders(fofoId).stream()
|
2211 |
Map<Integer, Integer> grnPendingOrders = orderRepository.selectPendingGrnOrders(fofoId).stream().collect(groupingBy(x -> x.getLineItem().getItemId(), Collectors.summingInt(x -> x.getLineItem().getQuantity())));
|
| 2516 |
.collect(groupingBy(x -> x.getLineItem().getItemId(),
|
- |
|
| 2517 |
Collectors.summingInt(x -> x.getLineItem().getQuantity())));
|
- |
|
| 2518 |
if (!grnPendingOrders.isEmpty()) {
|
2212 |
if (!grnPendingOrders.isEmpty()) {
|
| 2519 |
grnPendingOrdersMap = itemRepository.selectByIds(grnPendingOrders.keySet()).stream()
|
2213 |
grnPendingOrdersMap = itemRepository.selectByIds(grnPendingOrders.keySet()).stream().collect(groupingBy(x -> x.getCatalogItemId(), Collectors.summingInt(x -> grnPendingOrders.get(x.getId()))));
|
| 2520 |
.collect(groupingBy(x -> x.getCatalogItemId(),
|
- |
|
| 2521 |
Collectors.summingInt(x -> grnPendingOrders.get(x.getId()))));
|
- |
|
| 2522 |
|
2214 |
|
| 2523 |
}
|
2215 |
}
|
| 2524 |
|
2216 |
|
| 2525 |
Map<Integer, Integer> processingOrder = orderRepository.selectOrders(fofoId, orderStatusList).stream()
|
2217 |
Map<Integer, Integer> processingOrder = orderRepository.selectOrders(fofoId, orderStatusList).stream().collect(groupingBy(x -> x.getLineItem().getItemId(), Collectors.summingInt(x -> x.getLineItem().getQuantity())));
|
| 2526 |
.collect(groupingBy(x -> x.getLineItem().getItemId(),
|
- |
|
| 2527 |
Collectors.summingInt(x -> x.getLineItem().getQuantity())));
|
- |
|
| 2528 |
if (!processingOrder.isEmpty()) {
|
2218 |
if (!processingOrder.isEmpty()) {
|
| 2529 |
processingOrderMap = itemRepository.selectByIds(processingOrder.keySet()).stream()
|
2219 |
processingOrderMap = itemRepository.selectByIds(processingOrder.keySet()).stream().collect(groupingBy(x -> x.getCatalogItemId(), Collectors.summingInt(x -> processingOrder.get(x.getId()))));
|
| 2530 |
.collect(groupingBy(x -> x.getCatalogItemId(),
|
- |
|
| 2531 |
Collectors.summingInt(x -> processingOrder.get(x.getId()))));
|
- |
|
| 2532 |
|
2220 |
|
| 2533 |
}
|
2221 |
}
|
| 2534 |
|
2222 |
|
| 2535 |
List<String> brands = mongoClient.getMongoBrands(fofoId, null, 3).stream().map(x -> (String) x.get("name"))
|
2223 |
List<String> brands = mongoClient.getMongoBrands(fofoId, null, 3).stream().map(x -> (String) x.get("name")).collect(Collectors.toList());
|
| 2536 |
.collect(Collectors.toList());
|
- |
|
| 2537 |
|
2224 |
|
| 2538 |
List<Integer> regionIds = partnerRegionRepository.selectByfofoId(fofoId).stream().map(x -> x.getRegionId())
|
2225 |
List<Integer> regionIds = partnerRegionRepository.selectByfofoId(fofoId).stream().map(x -> x.getRegionId()).collect(Collectors.toList());
|
| 2539 |
.collect(Collectors.toList());
|
- |
|
| 2540 |
LOGGER.info("regionIds" + regionIds);
|
2226 |
LOGGER.info("regionIds" + regionIds);
|
| 2541 |
if (regionIds.size() == 0) {
|
2227 |
if (regionIds.size() == 0) {
|
| 2542 |
LOGGER.info("No region found for partner {}", fofoId);
|
2228 |
LOGGER.info("No region found for partner {}", fofoId);
|
| 2543 |
continue;
|
2229 |
continue;
|
| 2544 |
}
|
2230 |
}
|
| 2545 |
Map<Integer, Optional<Integer>> focusedCatalogIdAndQtyMap = focusedModelRepository
|
2231 |
Map<Integer, Optional<Integer>> focusedCatalogIdAndQtyMap = focusedModelRepository.selectAllByRegionIds(regionIds).stream().collect(groupingBy(FocusedModel::getCatalogId, mapping(FocusedModel::getObsMinimumQty, Collectors.maxBy(Integer::compareTo))));
|
| 2546 |
.selectAllByRegionIds(regionIds).stream().collect(groupingBy(FocusedModel::getCatalogId,
|
- |
|
| 2547 |
mapping(FocusedModel::getObsMinimumQty, Collectors.maxBy(Integer::compareTo))));
|
- |
|
| 2548 |
|
2232 |
|
| 2549 |
LOGGER.info("focusedCatalogIdAndQtyMap" + focusedCatalogIdAndQtyMap);
|
2233 |
LOGGER.info("focusedCatalogIdAndQtyMap" + focusedCatalogIdAndQtyMap);
|
| 2550 |
|
2234 |
|
| 2551 |
for (Map.Entry<Integer, Optional<Integer>> entry : focusedCatalogIdAndQtyMap.entrySet()) {
|
2235 |
for (Map.Entry<Integer, Optional<Integer>> entry : focusedCatalogIdAndQtyMap.entrySet()) {
|
| 2552 |
int minQty = entry.getValue().get();
|
2236 |
int minQty = entry.getValue().get();
|
| Line 2554... |
Line 2238... |
| 2554 |
int processingQty = 0;
|
2238 |
int processingQty = 0;
|
| 2555 |
int grnPendingQty = 0;
|
2239 |
int grnPendingQty = 0;
|
| 2556 |
int allColorNetAvailability = 0;
|
2240 |
int allColorNetAvailability = 0;
|
| 2557 |
int allColorPoAvailability = 0;
|
2241 |
int allColorPoAvailability = 0;
|
| 2558 |
if (processingOrderMap != null) {
|
2242 |
if (processingOrderMap != null) {
|
| 2559 |
processingQty = (processingOrderMap.get(entry.getKey()) == null) ? 0
|
2243 |
processingQty = (processingOrderMap.get(entry.getKey()) == null) ? 0 : processingOrderMap.get(entry.getKey());
|
| 2560 |
: processingOrderMap.get(entry.getKey());
|
- |
|
| 2561 |
|
2244 |
|
| 2562 |
}
|
2245 |
}
|
| 2563 |
if (grnPendingOrdersMap != null) {
|
2246 |
if (grnPendingOrdersMap != null) {
|
| 2564 |
grnPendingQty = (grnPendingOrdersMap.get(entry.getKey()) == null) ? 0
|
2247 |
grnPendingQty = (grnPendingOrdersMap.get(entry.getKey()) == null) ? 0 : grnPendingOrdersMap.get(entry.getKey());
|
| 2565 |
: grnPendingOrdersMap.get(entry.getKey());
|
- |
|
| 2566 |
|
2248 |
|
| 2567 |
}
|
2249 |
}
|
| 2568 |
if (catalogIdAndQtyMap != null) {
|
2250 |
if (catalogIdAndQtyMap != null) {
|
| 2569 |
inStockQty = (catalogIdAndQtyMap.get(entry.getKey()) == null) ? 0
|
2251 |
inStockQty = (catalogIdAndQtyMap.get(entry.getKey()) == null) ? 0 : catalogIdAndQtyMap.get(entry.getKey());
|
| 2570 |
: catalogIdAndQtyMap.get(entry.getKey());
|
- |
|
| 2571 |
|
2252 |
|
| 2572 |
}
|
2253 |
}
|
| 2573 |
|
2254 |
|
| 2574 |
int grnStockQty = grnPendingQty + inStockQty;
|
2255 |
int grnStockQty = grnPendingQty + inStockQty;
|
| 2575 |
int totalQty = processingQty + grnPendingQty + inStockQty;
|
2256 |
int totalQty = processingQty + grnPendingQty + inStockQty;
|
| Line 2579... |
Line 2260... |
| 2579 |
|
2260 |
|
| 2580 |
TagListing tagListing = tagListingRepository.selectByCatalogId(entry.getKey());
|
2261 |
TagListing tagListing = tagListingRepository.selectByCatalogId(entry.getKey());
|
| 2581 |
|
2262 |
|
| 2582 |
FofoStore fofoStore = fofoStoreRepository.selectByRetailerId(fofoId);
|
2263 |
FofoStore fofoStore = fofoStoreRepository.selectByRetailerId(fofoId);
|
| 2583 |
|
2264 |
|
| 2584 |
Map<Integer, List<SaholicCIS>> itemAvailabilityMap = warehouseItemAvailabilityMap
|
2265 |
Map<Integer, List<SaholicCIS>> itemAvailabilityMap = warehouseItemAvailabilityMap.get(fofoStore.getWarehouseId());
|
| 2585 |
.get(fofoStore.getWarehouseId());
|
- |
|
| 2586 |
|
2266 |
|
| 2587 |
Map<Integer, List<SaholicPOItem>> poItemAvailabilityMap = warehousePoItemAvailabilityMap
|
2267 |
Map<Integer, List<SaholicPOItem>> poItemAvailabilityMap = warehousePoItemAvailabilityMap.get(fofoStore.getWarehouseId());
|
| 2588 |
.get(fofoStore.getWarehouseId());
|
- |
|
| 2589 |
|
2268 |
|
| 2590 |
for (Item item : items) {
|
2269 |
for (Item item : items) {
|
| 2591 |
List<SaholicCIS> currentAvailability = null;
|
2270 |
List<SaholicCIS> currentAvailability = null;
|
| 2592 |
List<SaholicPOItem> poItemAvailability = null;
|
2271 |
List<SaholicPOItem> poItemAvailability = null;
|
| 2593 |
if (itemAvailabilityMap != null) {
|
2272 |
if (itemAvailabilityMap != null) {
|
| Line 2596... |
Line 2275... |
| 2596 |
|
2275 |
|
| 2597 |
if (poItemAvailabilityMap != null) {
|
2276 |
if (poItemAvailabilityMap != null) {
|
| 2598 |
poItemAvailability = poItemAvailabilityMap.get(item.getId());
|
2277 |
poItemAvailability = poItemAvailabilityMap.get(item.getId());
|
| 2599 |
}
|
2278 |
}
|
| 2600 |
if (currentAvailability != null) {
|
2279 |
if (currentAvailability != null) {
|
| 2601 |
allColorNetAvailability += currentAvailability.stream()
|
- |
|
| 2602 |
.collect(Collectors.summingInt(SaholicCIS::getNetavailability));
|
2280 |
allColorNetAvailability += currentAvailability.stream().collect(Collectors.summingInt(SaholicCIS::getNetavailability));
|
| 2603 |
}
|
2281 |
}
|
| 2604 |
|
2282 |
|
| 2605 |
if (poItemAvailability != null) {
|
2283 |
if (poItemAvailability != null) {
|
| 2606 |
allColorPoAvailability += poItemAvailability.stream()
|
- |
|
| 2607 |
.collect(Collectors.summingInt(SaholicPOItem::getUnfulfilledQty));
|
2284 |
allColorPoAvailability += poItemAvailability.stream().collect(Collectors.summingInt(SaholicPOItem::getUnfulfilledQty));
|
| 2608 |
}
|
2285 |
}
|
| 2609 |
|
2286 |
|
| 2610 |
}
|
2287 |
}
|
| 2611 |
|
2288 |
|
| 2612 |
FocusedModelShortageModel fm = new FocusedModelShortageModel();
|
2289 |
FocusedModelShortageModel fm = new FocusedModelShortageModel();
|
| Line 2641... |
Line 2318... |
| 2641 |
|
2318 |
|
| 2642 |
if (y.getValue().contains(x.getKey())) {
|
2319 |
if (y.getValue().contains(x.getKey())) {
|
| 2643 |
if (!emailRowsMap.containsKey(y.getKey())) {
|
2320 |
if (!emailRowsMap.containsKey(y.getKey())) {
|
| 2644 |
emailRowsMap.put(y.getKey(), new ArrayList<>());
|
2321 |
emailRowsMap.put(y.getKey(), new ArrayList<>());
|
| 2645 |
}
|
2322 |
}
|
| 2646 |
List<List<? extends Serializable>> fms = x.getValue().stream()
|
2323 |
List<List<? extends Serializable>> fms = x.getValue().stream().map(r -> Arrays.asList(r.getStoreCode(), r.getStoreName(), r.getBrandName(), r.getModelName(), r.getModelNumber(), r.getDp(), r.getWarehouseName(), r.getStateManager(), r.getTerritoryManager(), r.getPendingIndentQty(), r.getGrnStockQty(), r.getShortageQty(), r.getAvailability())).collect(Collectors.toList());
|
| 2647 |
.map(r -> Arrays.asList(r.getStoreCode(), r.getStoreName(), r.getBrandName(),
|
- |
|
| 2648 |
r.getModelName(), r.getModelNumber(), r.getDp(), r.getWarehouseName(),
|
- |
|
| 2649 |
r.getStateManager(), r.getTerritoryManager(), r.getPendingIndentQty(),
|
- |
|
| 2650 |
r.getGrnStockQty(), r.getShortageQty(), r.getAvailability()))
|
- |
|
| 2651 |
.collect(Collectors.toList());
|
- |
|
| 2652 |
emailRowsMap.get(y.getKey()).addAll(fms);
|
2324 |
emailRowsMap.get(y.getKey()).addAll(fms);
|
| 2653 |
|
2325 |
|
| 2654 |
}
|
2326 |
}
|
| 2655 |
|
2327 |
|
| 2656 |
});
|
2328 |
});
|
| 2657 |
|
2329 |
|
| 2658 |
});
|
2330 |
});
|
| 2659 |
|
2331 |
|
| 2660 |
List<String> headers = Arrays.asList("Store Code", "Store Name", "Brand", "Model Name", "Model Number",
|
2332 |
List<String> headers = Arrays.asList("Store Code", "Store Name", "Brand", "Model Name", "Model Number", "DP", "Warehouse Name", "State Manager", "Territory Manager", "Pending Indent", "InStock", "Shortage Qty", "Availability");
|
| 2661 |
"DP", "Warehouse Name", "State Manager", "Territory Manager", "Pending Indent", "InStock",
|
- |
|
| 2662 |
"Shortage Qty", "Availability");
|
- |
|
| 2663 |
emailRowsMap.entrySet().forEach(entry -> {
|
2333 |
emailRowsMap.entrySet().forEach(entry -> {
|
| 2664 |
|
2334 |
|
| 2665 |
ByteArrayOutputStream baos = null;
|
2335 |
ByteArrayOutputStream baos = null;
|
| 2666 |
try {
|
2336 |
try {
|
| 2667 |
baos = FileUtil.getCSVByteStream(headers, entry.getValue());
|
2337 |
baos = FileUtil.getCSVByteStream(headers, entry.getValue());
|
| 2668 |
} catch (Exception e2) {
|
2338 |
} catch (Exception e2) {
|
| 2669 |
e2.printStackTrace();
|
2339 |
e2.printStackTrace();
|
| 2670 |
}
|
2340 |
}
|
| 2671 |
String[] sendToArray = new String[]{
|
2341 |
String[] sendToArray = new String[]{
|
| 2672 |
|
2342 |
|
| 2673 |
entry.getKey()
|
2343 |
entry.getKey(), "apurve.shrivastava@smartdukaan.com", "puneet.bisht@smartdukaan.com"
|
| 2674 |
|
2344 |
|
| 2675 |
};
|
2345 |
};
|
| 2676 |
|
2346 |
|
| - |
|
2347 |
|
| 2677 |
try {
|
2348 |
try {
|
| 2678 |
Utils.sendMailWithAttachment(googleMailSender, sendToArray, null, "Stock Alert", "PFA", fileName,
|
2349 |
Utils.sendMailWithAttachment(googleMailSender, sendToArray, null, "Stock Alert", "PFA", fileName, new ByteArrayResource(baos.toByteArray()));
|
| 2679 |
new ByteArrayResource(baos.toByteArray()));
|
- |
|
| 2680 |
} catch (Exception e1) { // TODO Auto-generated catch block
|
2350 |
} catch (Exception e1) { // TODO Auto-generated catch block
|
| 2681 |
e1.printStackTrace();
|
2351 |
e1.printStackTrace();
|
| 2682 |
}
|
2352 |
}
|
| 2683 |
|
2353 |
|
| 2684 |
});
|
2354 |
});
|
| Line 2709... |
Line 2379... |
| 2709 |
|
2379 |
|
| 2710 |
}
|
2380 |
}
|
| 2711 |
|
2381 |
|
| 2712 |
private String getMessage(List<FocusedModelShortageModel> focusedModelShortageModel) {
|
2382 |
private String getMessage(List<FocusedModelShortageModel> focusedModelShortageModel) {
|
| 2713 |
StringBuilder sb = new StringBuilder();
|
2383 |
StringBuilder sb = new StringBuilder();
|
| 2714 |
sb.append("<html><body><p>Alert</p><p>Focused Model Shortage in Your Stock:-</p>"
|
2384 |
sb.append("<html><body><p>Alert</p><p>Focused Model Shortage in Your Stock:-</p>" + "<br/><table style='border:1px solid black ;padding: 5px';>");
|
| 2715 |
+ "<br/><table style='border:1px solid black ;padding: 5px';>");
|
- |
|
| 2716 |
sb.append("<tbody>\n" + " <tr>\n"
|
- |
|
| 2717 |
+ " <th style='border:1px solid black;padding: 5px'>Item</th>\n"
|
- |
|
| 2718 |
+ " <th style='border:1px solid black;padding: 5px'>Shortage Qty</th>\n"
|
2385 |
sb.append("<tbody>\n" + " <tr>\n" + " <th style='border:1px solid black;padding: 5px'>Item</th>\n" + " <th style='border:1px solid black;padding: 5px'>Shortage Qty</th>\n" + " </tr>");
|
| 2719 |
+ " </tr>");
|
- |
|
| 2720 |
for (FocusedModelShortageModel entry : focusedModelShortageModel) {
|
2386 |
for (FocusedModelShortageModel entry : focusedModelShortageModel) {
|
| 2721 |
|
2387 |
|
| 2722 |
sb.append("<tr>");
|
2388 |
sb.append("<tr>");
|
| 2723 |
sb.append("<td style='border:1px solid black;padding: 5px'>" + entry.getItemName() + "</td>");
|
2389 |
sb.append("<td style='border:1px solid black;padding: 5px'>" + entry.getItemName() + "</td>");
|
| 2724 |
|
2390 |
|
| Line 2732... |
Line 2398... |
| 2732 |
|
2398 |
|
| 2733 |
return sb.toString();
|
2399 |
return sb.toString();
|
| 2734 |
}
|
2400 |
}
|
| 2735 |
|
2401 |
|
| 2736 |
public void notifyLead() throws Exception {
|
2402 |
public void notifyLead() throws Exception {
|
| 2737 |
List<Lead> leadsToNotify = leadRepository.selectLeadsScheduledBetweenDate(null,
|
2403 |
List<Lead> leadsToNotify = leadRepository.selectLeadsScheduledBetweenDate(null, LocalDateTime.now().minusDays(15), LocalDateTime.now().plusHours(4));
|
| 2738 |
LocalDateTime.now().minusDays(15), LocalDateTime.now().plusHours(4));
|
- |
|
| 2739 |
Map<Integer, String> authUserEmailMap = authRepository.selectAllActiveUser().stream()
|
2404 |
Map<Integer, String> authUserEmailMap = authRepository.selectAllActiveUser().stream().collect(Collectors.toMap(x -> x.getId(), x -> x.getEmailId()));
|
| 2740 |
.collect(Collectors.toMap(x -> x.getId(), x -> x.getEmailId()));
|
- |
|
| 2741 |
LOGGER.info("authUserEmailMap {}", authUserEmailMap);
|
2405 |
LOGGER.info("authUserEmailMap {}", authUserEmailMap);
|
| 2742 |
Map<String, Integer> dtrEmailMap = dtrUserRepository
|
- |
|
| 2743 |
.selectAllByEmailIds(new ArrayList<>(authUserEmailMap.values())).stream()
|
2406 |
Map<String, Integer> dtrEmailMap = dtrUserRepository.selectAllByEmailIds(new ArrayList<>(authUserEmailMap.values())).stream().collect(Collectors.toMap(x -> x.getEmailId(), x -> x.getId()));
|
| 2744 |
.collect(Collectors.toMap(x -> x.getEmailId(), x -> x.getId()));
|
- |
|
| 2745 |
|
2407 |
|
| 2746 |
LOGGER.info("dtrEmailMap {}", dtrEmailMap);
|
2408 |
LOGGER.info("dtrEmailMap {}", dtrEmailMap);
|
| 2747 |
|
2409 |
|
| 2748 |
Map<Integer, Integer> authUserKeyMap = new HashMap<>();
|
2410 |
Map<Integer, Integer> authUserKeyMap = new HashMap<>();
|
| 2749 |
|
2411 |
|
| Line 2760... |
Line 2422... |
| 2760 |
if (authUserKeyMap.get(lead.getAssignTo()) == null) {
|
2422 |
if (authUserKeyMap.get(lead.getAssignTo()) == null) {
|
| 2761 |
LOGGER.info("Assignee no longer part of system {}", lead.getAssignTo());
|
2423 |
LOGGER.info("Assignee no longer part of system {}", lead.getAssignTo());
|
| 2762 |
continue;
|
2424 |
continue;
|
| 2763 |
}
|
2425 |
}
|
| 2764 |
String title = "Leads followup Reminder";
|
2426 |
String title = "Leads followup Reminder";
|
| 2765 |
String notificationMessage = String.format(templateMessage, lead.getFirstName(), lead.getLastName(),
|
- |
|
| 2766 |
lead.getAddress(), lead.getLeadMobile(), leadTimeFormatter.format(lead.getScheduledTimestamp()));
|
2427 |
String notificationMessage = String.format(templateMessage, lead.getFirstName(), lead.getLastName(), lead.getAddress(), lead.getLeadMobile(), leadTimeFormatter.format(lead.getScheduledTimestamp()));
|
| 2767 |
String url = "https://app.smartdukaan.com/pages/home/leadUpdate?leadId=" + lead.getId();
|
2428 |
String url = "https://app.smartdukaan.com/pages/home/leadUpdate?leadId=" + lead.getId();
|
| 2768 |
SendNotificationModel sendNotificationModel = new SendNotificationModel();
|
2429 |
SendNotificationModel sendNotificationModel = new SendNotificationModel();
|
| 2769 |
sendNotificationModel.setCampaignName("Lead Reminder");
|
2430 |
sendNotificationModel.setCampaignName("Lead Reminder");
|
| 2770 |
sendNotificationModel.setTitle(title);
|
2431 |
sendNotificationModel.setTitle(title);
|
| 2771 |
sendNotificationModel.setMessage(notificationMessage);
|
2432 |
sendNotificationModel.setMessage(notificationMessage);
|
| Line 2781... |
Line 2442... |
| 2781 |
// authUser.getMobileNumber());
|
2442 |
// authUser.getMobileNumber());
|
| 2782 |
}
|
2443 |
}
|
| 2783 |
}
|
2444 |
}
|
| 2784 |
|
2445 |
|
| 2785 |
public void notifyVisits() throws Exception {
|
2446 |
public void notifyVisits() throws Exception {
|
| 2786 |
List<FranchiseeVisit> franchiseeVisits = franchiseeVisitRepository
|
- |
|
| 2787 |
.selectVisitsScheduledBetweenDate(LocalDateTime.now().minusDays(15), LocalDateTime.now().plusHours(4));
|
2447 |
List<FranchiseeVisit> franchiseeVisits = franchiseeVisitRepository.selectVisitsScheduledBetweenDate(LocalDateTime.now().minusDays(15), LocalDateTime.now().plusHours(4));
|
| 2788 |
Map<Integer, String> authUserEmailMap = authRepository.selectAllActiveUser().stream()
|
2448 |
Map<Integer, String> authUserEmailMap = authRepository.selectAllActiveUser().stream().collect(Collectors.toMap(x -> x.getId(), x -> x.getEmailId()));
|
| 2789 |
.collect(Collectors.toMap(x -> x.getId(), x -> x.getEmailId()));
|
- |
|
| 2790 |
Map<String, Integer> dtrEmailMap = dtrUserRepository
|
- |
|
| 2791 |
.selectAllByEmailIds(new ArrayList<>(authUserEmailMap.values())).stream()
|
2449 |
Map<String, Integer> dtrEmailMap = dtrUserRepository.selectAllByEmailIds(new ArrayList<>(authUserEmailMap.values())).stream().collect(Collectors.toMap(x -> x.getEmailId(), x -> x.getId()));
|
| 2792 |
.collect(Collectors.toMap(x -> x.getEmailId(), x -> x.getId()));
|
- |
|
| 2793 |
Map<Integer, Integer> authUserKeyMap = new HashMap<>();
|
2450 |
Map<Integer, Integer> authUserKeyMap = new HashMap<>();
|
| 2794 |
|
2451 |
|
| 2795 |
for (Map.Entry<Integer, String> authUserEmail : authUserEmailMap.entrySet()) {
|
2452 |
for (Map.Entry<Integer, String> authUserEmail : authUserEmailMap.entrySet()) {
|
| 2796 |
int authId = authUserEmail.getKey();
|
2453 |
int authId = authUserEmail.getKey();
|
| 2797 |
String email = authUserEmail.getValue();
|
2454 |
String email = authUserEmail.getValue();
|
| Line 2805... |
Line 2462... |
| 2805 |
continue;
|
2462 |
continue;
|
| 2806 |
}
|
2463 |
}
|
| 2807 |
SendNotificationModel sendNotificationModel = new SendNotificationModel();
|
2464 |
SendNotificationModel sendNotificationModel = new SendNotificationModel();
|
| 2808 |
String message = null;
|
2465 |
String message = null;
|
| 2809 |
if (visit.getFranchiseActivityId() == 0) {
|
2466 |
if (visit.getFranchiseActivityId() == 0) {
|
| 2810 |
message = String.format(visitTemplate, visit.getPartnerName(),
|
2467 |
message = String.format(visitTemplate, visit.getPartnerName(), timeFormatter.format(visit.getScheduleTimestamp()));
|
| 2811 |
timeFormatter.format(visit.getScheduleTimestamp()));
|
- |
|
| 2812 |
sendNotificationModel.setCampaignName("Franchisee visit Reminder");
|
2468 |
sendNotificationModel.setCampaignName("Franchisee visit Reminder");
|
| 2813 |
} else {
|
2469 |
} else {
|
| 2814 |
message = String.format(followupTemplate, visit.getPartnerName(),
|
2470 |
message = String.format(followupTemplate, visit.getPartnerName(), timeFormatter.format(visit.getScheduleTimestamp()));
|
| 2815 |
timeFormatter.format(visit.getScheduleTimestamp()));
|
- |
|
| 2816 |
sendNotificationModel.setCampaignName("Franchisee followup Reminder");
|
2471 |
sendNotificationModel.setCampaignName("Franchisee followup Reminder");
|
| 2817 |
}
|
2472 |
}
|
| 2818 |
sendNotificationModel.setMessage(message);
|
2473 |
sendNotificationModel.setMessage(message);
|
| 2819 |
sendNotificationModel.setType("url");
|
2474 |
sendNotificationModel.setType("url");
|
| 2820 |
sendNotificationModel.setUrl("https://app.smartdukaan.com/pages/home/notifications");
|
2475 |
sendNotificationModel.setUrl("https://app.smartdukaan.com/pages/home/notifications");
|
| Line 2860... |
Line 2515... |
| 2860 |
}
|
2515 |
}
|
| 2861 |
}
|
2516 |
}
|
| 2862 |
|
2517 |
|
| 2863 |
private String getMessageForReferral(List<Refferal> referrals) {
|
2518 |
private String getMessageForReferral(List<Refferal> referrals) {
|
| 2864 |
StringBuilder sb = new StringBuilder();
|
2519 |
StringBuilder sb = new StringBuilder();
|
| 2865 |
sb.append("<html><body><p>Alert</p><p>Pending Referrals:-</p>"
|
- |
|
| 2866 |
+ "<br/><table style='border:1px solid black ;padding: 5px';>");
|
2520 |
sb.append("<html><body><p>Alert</p><p>Pending Referrals:-</p>" + "<br/><table style='border:1px solid black ;padding: 5px';>");
|
| 2867 |
sb.append("<tbody>\n" + " <tr>\n"
|
- |
|
| 2868 |
+ " <th style='border:1px solid black;padding: 5px'>RefereeName</th>\n"
|
- |
|
| 2869 |
+ " <th style='border:1px solid black;padding: 5px'>Referee Email</th>\n"
|
- |
|
| 2870 |
+ " <th style='border:1px solid black;padding: 5px'>Referral Name</th>\n"
|
- |
|
| 2871 |
+ " <th style='border:1px solid black;padding: 5px'>Refferal Mobile</th>\n"
|
2521 |
sb.append("<tbody>\n" + " <tr>\n" + " <th style='border:1px solid black;padding: 5px'>RefereeName</th>\n" + " <th style='border:1px solid black;padding: 5px'>Referee Email</th>\n" + " <th style='border:1px solid black;padding: 5px'>Referral Name</th>\n" + " <th style='border:1px solid black;padding: 5px'>Refferal Mobile</th>\n" + " <th style='border:1px solid black;padding: 5px'>city</th>\n" + " <th style='border:1px solid black;padding: 5px'>state</th>\n" + " </tr>");
|
| 2872 |
+ " <th style='border:1px solid black;padding: 5px'>city</th>\n"
|
- |
|
| 2873 |
+ " <th style='border:1px solid black;padding: 5px'>state</th>\n"
|
- |
|
| 2874 |
+ " </tr>");
|
- |
|
| 2875 |
for (Refferal entry : referrals) {
|
2522 |
for (Refferal entry : referrals) {
|
| 2876 |
|
2523 |
|
| 2877 |
sb.append("<tr>");
|
2524 |
sb.append("<tr>");
|
| 2878 |
sb.append("<td style='border:1px solid black;padding: 5px'>" + entry.getRefereeName() + "</td>");
|
2525 |
sb.append("<td style='border:1px solid black;padding: 5px'>" + entry.getRefereeName() + "</td>");
|
| 2879 |
|
2526 |
|
| Line 2890... |
Line 2537... |
| 2890 |
sb.append("</tbody></table></body></html>");
|
2537 |
sb.append("</tbody></table></body></html>");
|
| 2891 |
|
2538 |
|
| 2892 |
return sb.toString();
|
2539 |
return sb.toString();
|
| 2893 |
}
|
2540 |
}
|
| 2894 |
|
2541 |
|
| 2895 |
private String getMessageForUncontacblePartner(List<PartnerCollectionRemark> pcrs)
|
2542 |
private String getMessageForUncontacblePartner(List<PartnerCollectionRemark> pcrs) throws ProfitMandiBusinessException {
|
| 2896 |
throws ProfitMandiBusinessException {
|
- |
|
| 2897 |
StringBuilder sb = new StringBuilder();
|
2543 |
StringBuilder sb = new StringBuilder();
|
| 2898 |
sb.append("<html><body><p>Alert</p><p>Not Responding Partner:-</p>"
|
- |
|
| 2899 |
+ "<br/><table style='border:1px solid black ;padding: 5px';>");
|
2544 |
sb.append("<html><body><p>Alert</p><p>Not Responding Partner:-</p>" + "<br/><table style='border:1px solid black ;padding: 5px';>");
|
| 2900 |
sb.append("<tbody>\n" + " <tr>\n"
|
- |
|
| 2901 |
+ " <th style='border:1px solid black;padding: 5px'>PartnerName</th>\n"
|
2545 |
sb.append("<tbody>\n" + " <tr>\n" + " <th style='border:1px solid black;padding: 5px'>PartnerName</th>\n" + " <th style='border:1px solid black;padding: 5px'>from</th>\n"
|
| 2902 |
+ " <th style='border:1px solid black;padding: 5px'>from</th>\n"
|
- |
|
| 2903 |
|
2546 |
|
| 2904 |
+ " </tr>");
|
2547 |
+ " </tr>");
|
| 2905 |
for (PartnerCollectionRemark entry : pcrs) {
|
2548 |
for (PartnerCollectionRemark entry : pcrs) {
|
| 2906 |
|
2549 |
|
| 2907 |
CustomRetailer customRetailer = retailerService.getFofoRetailer(entry.getFofoId());
|
2550 |
CustomRetailer customRetailer = retailerService.getFofoRetailer(entry.getFofoId());
|
| 2908 |
|
2551 |
|
| 2909 |
sb.append("<tr>");
|
2552 |
sb.append("<tr>");
|
| 2910 |
sb.append("<td style='border:1px solid black;padding: 5px'>" + customRetailer.getBusinessName() + "("
|
2553 |
sb.append("<td style='border:1px solid black;padding: 5px'>" + customRetailer.getBusinessName() + "(" + customRetailer.getCode() + ")" + "</td>");
|
| 2911 |
+ customRetailer.getCode() + ")" + "</td>");
|
- |
|
| 2912 |
|
2554 |
|
| 2913 |
sb.append("<td style='border:1px solid black;padding: 5px'>"
|
- |
|
| 2914 |
+ entry.getCreateTimestamp().format(DateTimeFormatter.ofPattern("dd/MM/yyyy")) + "</td>");
|
2555 |
sb.append("<td style='border:1px solid black;padding: 5px'>" + entry.getCreateTimestamp().format(DateTimeFormatter.ofPattern("dd/MM/yyyy")) + "</td>");
|
| 2915 |
|
2556 |
|
| 2916 |
sb.append("</tr>");
|
2557 |
sb.append("</tr>");
|
| 2917 |
|
2558 |
|
| 2918 |
}
|
2559 |
}
|
| 2919 |
|
2560 |
|
| Line 2922... |
Line 2563... |
| 2922 |
return sb.toString();
|
2563 |
return sb.toString();
|
| 2923 |
}
|
2564 |
}
|
| 2924 |
|
2565 |
|
| 2925 |
public void reverseWallet() throws Exception {
|
2566 |
public void reverseWallet() throws Exception {
|
| 2926 |
LocalDate localDate = LocalDate.of(2020, 10, 28);
|
2567 |
LocalDate localDate = LocalDate.of(2020, 10, 28);
|
| 2927 |
List<UserWalletHistory> uwhList = userWalletHistoryRepository.selectAllByDateType(localDate.atStartOfDay(),
|
2568 |
List<UserWalletHistory> uwhList = userWalletHistoryRepository.selectAllByDateType(localDate.atStartOfDay(), localDate.plusDays(1).atStartOfDay(), Arrays.asList(WalletReferenceType.SCHEME_IN, WalletReferenceType.SCHEME_OUT));
|
| 2928 |
localDate.plusDays(1).atStartOfDay(),
|
- |
|
| 2929 |
Arrays.asList(WalletReferenceType.SCHEME_IN, WalletReferenceType.SCHEME_OUT));
|
- |
|
| 2930 |
for (UserWalletHistory uwh : uwhList) {
|
2569 |
for (UserWalletHistory uwh : uwhList) {
|
| 2931 |
if (uwh.getBusinessTimestamp().getMonth().equals(Month.SEPTEMBER)) {
|
2570 |
if (uwh.getBusinessTimestamp().getMonth().equals(Month.SEPTEMBER)) {
|
| 2932 |
UserWallet uw = userWalletRepository.selectById(uwh.getWalletId());
|
2571 |
UserWallet uw = userWalletRepository.selectById(uwh.getWalletId());
|
| 2933 |
// LOGGER.info("UWH - {}", uwh);
|
2572 |
// LOGGER.info("UWH - {}", uwh);
|
| 2934 |
// amount += uwh.getAmount();
|
2573 |
// amount += uwh.getAmount();
|
| Line 2972... |
Line 2611... |
| 2972 |
|
2611 |
|
| 2973 |
public void partnerProblemAlert() throws Exception {
|
2612 |
public void partnerProblemAlert() throws Exception {
|
| 2974 |
LocalDateTime curDate = LocalDate.now().atStartOfDay();
|
2613 |
LocalDateTime curDate = LocalDate.now().atStartOfDay();
|
| 2975 |
Map<Integer, Double> lmtdSale = fofoOrderItemRepository.selectSumMopGroupByRetailer(
|
2614 |
Map<Integer, Double> lmtdSale = fofoOrderItemRepository.selectSumMopGroupByRetailer(
|
| 2976 |
curDate.withDayOfMonth(1).minusMonths(1), curDate.with(LocalTime.MAX).minusMonths(1), 0, false);
|
2615 |
curDate.withDayOfMonth(1).minusMonths(1), curDate.with(LocalTime.MAX).minusMonths(1), 0, false);
|
| 2977 |
Map<Integer, Double> mtdSales = fofoOrderItemRepository.selectSumMopGroupByRetailer(curDate.withDayOfMonth(1),
|
2616 |
Map<Integer, Double> mtdSales = fofoOrderItemRepository.selectSumMopGroupByRetailer(curDate.withDayOfMonth(1), curDate.with(LocalTime.MAX), 0, false);
|
| 2978 |
curDate.with(LocalTime.MAX), 0, false);
|
- |
|
| 2979 |
Map<Integer, PartnerDailyInvestment> pdi = partnerDailyInvestmentRepository.selectAll(LocalDate.now()).stream()
|
2617 |
Map<Integer, PartnerDailyInvestment> pdi = partnerDailyInvestmentRepository.selectAll(LocalDate.now()).stream().collect(Collectors.toMap(x -> x.getFofoId(), x -> x));
|
| 2980 |
.collect(Collectors.toMap(x -> x.getFofoId(), x -> x));
|
- |
|
| 2981 |
|
2618 |
|
| 2982 |
for (Entry<Integer, Double> ls : lmtdSale.entrySet()) {
|
2619 |
for (Entry<Integer, Double> ls : lmtdSale.entrySet()) {
|
| 2983 |
|
2620 |
|
| 2984 |
double lmtdTwentyPercentSale = ls.getValue() * 0.2;
|
2621 |
double lmtdTwentyPercentSale = ls.getValue() * 0.2;
|
| 2985 |
|
2622 |
|
| Line 2987... |
Line 2624... |
| 2987 |
|
2624 |
|
| 2988 |
double mtdSale = mtdSales.get(ls.getKey()) == null ? 0 : mtdSales.get(ls.getKey());
|
2625 |
double mtdSale = mtdSales.get(ls.getKey()) == null ? 0 : mtdSales.get(ls.getKey());
|
| 2989 |
|
2626 |
|
| 2990 |
LOGGER.info("mtdSale" + mtdSale);
|
2627 |
LOGGER.info("mtdSale" + mtdSale);
|
| 2991 |
|
2628 |
|
| 2992 |
double totalSixtyPercentInvestment = pdi.get(ls.getKey()) == null ? 0
|
2629 |
double totalSixtyPercentInvestment = pdi.get(ls.getKey()) == null ? 0 : pdi.get(ls.getKey()).getTotalInvestment() * 0.6;
|
| 2993 |
: pdi.get(ls.getKey()).getTotalInvestment() * 0.6;
|
- |
|
| 2994 |
|
2630 |
|
| 2995 |
LOGGER.info("totalSixtyPercentInvestment" + totalSixtyPercentInvestment);
|
2631 |
LOGGER.info("totalSixtyPercentInvestment" + totalSixtyPercentInvestment);
|
| 2996 |
|
2632 |
|
| 2997 |
double stockInvestment = pdi.get(ls.getKey()) == null ? 0 : pdi.get(ls.getKey()).getInStockAmount();
|
2633 |
double stockInvestment = pdi.get(ls.getKey()) == null ? 0 : pdi.get(ls.getKey()).getInStockAmount();
|
| 2998 |
|
2634 |
|
| Line 3039... |
Line 2675... |
| 3039 |
|
2675 |
|
| 3040 |
}
|
2676 |
}
|
| 3041 |
|
2677 |
|
| 3042 |
}
|
2678 |
}
|
| 3043 |
|
2679 |
|
| 3044 |
List<PartnerProblem> partnerProblems = partnerProblemRepository.selectAll().stream()
|
- |
|
| 3045 |
.filter(x -> x.getMtd() + x.getInvestment() + x.getStockInvestment() > 0).collect(Collectors.toList());
|
2680 |
List<PartnerProblem> partnerProblems = partnerProblemRepository.selectAll().stream().filter(x -> x.getMtd() + x.getInvestment() + x.getStockInvestment() > 0).collect(Collectors.toList());
|
| 3046 |
|
2681 |
|
| 3047 |
partnerProblems = partnerProblems.stream().sorted((x1, x2) -> {
|
2682 |
partnerProblems = partnerProblems.stream().sorted((x1, x2) -> {
|
| 3048 |
return x1.getMtd() + x1.getInvestment() + x1.getStockInvestment() < x2.getMtd() + x2.getInvestment()
|
2683 |
return x1.getMtd() + x1.getInvestment() + x1.getStockInvestment() < x2.getMtd() + x2.getInvestment() + x2.getStockInvestment() ? 1 : -1;
|
| 3049 |
+ x2.getStockInvestment() ? 1 : -1;
|
- |
|
| 3050 |
}).collect(Collectors.toList());
|
2684 |
}).collect(Collectors.toList());
|
| 3051 |
|
2685 |
|
| 3052 |
Map<Integer, PartnerProblem> partnerProblemMap = partnerProblems.stream().sorted((x1, x2) -> {
|
2686 |
Map<Integer, PartnerProblem> partnerProblemMap = partnerProblems.stream().sorted((x1, x2) -> {
|
| 3053 |
return x1.getMtd() + x1.getInvestment() + x1.getStockInvestment() < x2.getMtd() + x2.getInvestment()
|
2687 |
return x1.getMtd() + x1.getInvestment() + x1.getStockInvestment() < x2.getMtd() + x2.getInvestment() + x2.getStockInvestment() ? 1 : -1;
|
| 3054 |
+ x2.getStockInvestment() ? 1 : -1;
|
- |
|
| 3055 |
}).collect(Collectors.toMap(x -> x.getFofoId(), x -> x));
|
2688 |
}).collect(Collectors.toMap(x -> x.getFofoId(), x -> x));
|
| 3056 |
|
2689 |
|
| 3057 |
Map<Integer, CustomRetailer> customRetailers = retailerService.getAllFofoRetailers();
|
2690 |
Map<Integer, CustomRetailer> customRetailers = retailerService.getAllFofoRetailers();
|
| 3058 |
|
2691 |
|
| 3059 |
List<Integer> assignTo = Arrays.asList(15, 9, 54, 53);
|
2692 |
List<Integer> assignTo = Arrays.asList(15, 9, 54, 53);
|
| 3060 |
|
2693 |
|
| 3061 |
Map<Integer, AuthUser> assignAuthUserMap = authRepository.selectAllAuthUserByIds(assignTo).stream()
|
2694 |
Map<Integer, AuthUser> assignAuthUserMap = authRepository.selectAllAuthUserByIds(assignTo).stream().collect(Collectors.toMap(x -> x.getId(), x -> x));
|
| 3062 |
.collect(Collectors.toMap(x -> x.getId(), x -> x));
|
- |
|
| 3063 |
|
2695 |
|
| 3064 |
List<String> sendTo = Arrays.asList("kamini.sharma@smartdukaan.com", "tarun.verma@smartdukaan.com",
|
2696 |
List<String> sendTo = Arrays.asList("kamini.sharma@smartdukaan.com", "tarun.verma@smartdukaan.com", "sm@smartdukaan.com");
|
| 3065 |
"sm@smartdukaan.com");
|
- |
|
| 3066 |
LOGGER.info("partnerProblem" + partnerProblems);
|
2697 |
LOGGER.info("partnerProblem" + partnerProblems);
|
| 3067 |
StringBuilder sb = new StringBuilder();
|
2698 |
StringBuilder sb = new StringBuilder();
|
| 3068 |
sb.append("<htl><body>");
|
2699 |
sb.append("<htl><body>");
|
| 3069 |
sb.append(
|
2700 |
sb.append(
|
| 3070 |
"<p>Number against MTD or Investment are the count of days the MTD is low VS LMTD OR Investment is below 75%.</p><br/><p>These partners needs immediate attention.</p><br/><table style='border:1px solid black';cellspacing=0>");
|
2701 |
"<p>Number against MTD or Investment are the count of days the MTD is low VS LMTD OR Investment is below 75%.</p><br/><p>These partners needs immediate attention.</p><br/><table style='border:1px solid black';cellspacing=0>");
|
| 3071 |
sb.append("<tbody>\n" + " <tr>"
|
- |
|
| 3072 |
+ " <th style='border:1px solid black;padding: 5px'>Partner Name</th>"
|
- |
|
| 3073 |
+ " <th style='border:1px solid black;padding: 5px'>Assign TO</th>"
|
2702 |
sb.append("<tbody>\n" + " <tr>" + " <th style='border:1px solid black;padding: 5px'>Partner Name</th>" + " <th style='border:1px solid black;padding: 5px'>Assign TO</th>" + " <th style='border:1px solid black;padding: 5px'>Mtd</th>" + " <th style='border:1px solid black;padding: 5px'>Investment</th>" + " <th style='border:1px solid black;padding: 5px'>Stock</th>" + " <th style='border:1px solid black;padding: 5px'>Manager</th>"
|
| 3074 |
+ " <th style='border:1px solid black;padding: 5px'>Mtd</th>"
|
- |
|
| 3075 |
+ " <th style='border:1px solid black;padding: 5px'>Investment</th>"
|
- |
|
| 3076 |
+ " <th style='border:1px solid black;padding: 5px'>Stock</th>"
|
- |
|
| 3077 |
+ " <th style='border:1px solid black;padding: 5px'>Manager</th>"
|
- |
|
| 3078 |
|
2703 |
|
| 3079 |
+ " </tr>");
|
2704 |
+ " </tr>");
|
| 3080 |
|
2705 |
|
| 3081 |
for (PartnerProblem pp : partnerProblems) {
|
2706 |
for (PartnerProblem pp : partnerProblems) {
|
| 3082 |
int value = pp.getFofoId() % 4;
|
2707 |
int value = pp.getFofoId() % 4;
|
| 3083 |
|
2708 |
|
| 3084 |
Map<EscalationType, AuthUser> authUserMap = csService.getAuthUserAndEsclationByPartnerId(pp.getFofoId());
|
2709 |
Map<EscalationType, AuthUser> authUserMap = csService.getAuthUserAndEsclationByPartnerId(pp.getFofoId());
|
| 3085 |
LOGGER.info("authUserMap" + authUserMap);
|
2710 |
LOGGER.info("authUserMap" + authUserMap);
|
| 3086 |
sb.append("<tr>");
|
2711 |
sb.append("<tr>");
|
| 3087 |
sb.append("<td style='border:1px solid black;padding: 5px'>"
|
- |
|
| 3088 |
+ customRetailers.get(pp.getFofoId()).getBusinessName() + "</td>");
|
2712 |
sb.append("<td style='border:1px solid black;padding: 5px'>" + customRetailers.get(pp.getFofoId()).getBusinessName() + "</td>");
|
| 3089 |
sb.append("<td style='border:1px solid black;padding: 5px'>"
|
- |
|
| 3090 |
+ assignAuthUserMap.get(assignTo.get(value)).getName() + "</td>");
|
2713 |
sb.append("<td style='border:1px solid black;padding: 5px'>" + assignAuthUserMap.get(assignTo.get(value)).getName() + "</td>");
|
| 3091 |
sb.append("<td style='border:1px solid black;padding: 5px'>" + pp.getMtd() + "</td>");
|
2714 |
sb.append("<td style='border:1px solid black;padding: 5px'>" + pp.getMtd() + "</td>");
|
| 3092 |
sb.append("<td style='border:1px solid black;padding: 5px'>" + pp.getInvestment() + "</td>");
|
2715 |
sb.append("<td style='border:1px solid black;padding: 5px'>" + pp.getInvestment() + "</td>");
|
| 3093 |
sb.append("<td style='border:1px solid black;padding: 5px'>" + pp.getStockInvestment() + "</td>");
|
2716 |
sb.append("<td style='border:1px solid black;padding: 5px'>" + pp.getStockInvestment() + "</td>");
|
| 3094 |
sb.append("<td style='border:1px solid black;padding: 5px'>"
|
2717 |
sb.append("<td style='border:1px solid black;padding: 5px'>" + (authUserMap.get(EscalationType.L1) == null ? "N/A" : authUserMap.get(EscalationType.L1).getFirstName()) + " ," + (authUserMap.get(EscalationType.L2) == null ? "N/A" : authUserMap.get(EscalationType.L2).getFirstName()) + "</td>");
|
| 3095 |
+ (authUserMap.get(EscalationType.L1) == null ? "N/A"
|
- |
|
| 3096 |
: authUserMap.get(EscalationType.L1).getFirstName())
|
- |
|
| 3097 |
+ " ," + (authUserMap.get(EscalationType.L2) == null ? "N/A"
|
- |
|
| 3098 |
: authUserMap.get(EscalationType.L2).getFirstName())
|
- |
|
| 3099 |
+ "</td>");
|
- |
|
| 3100 |
|
2718 |
|
| 3101 |
sb.append("</tr>");
|
2719 |
sb.append("</tr>");
|
| 3102 |
}
|
2720 |
}
|
| 3103 |
sb.append("</tbody></table><br><br>");
|
2721 |
sb.append("</tbody></table><br><br>");
|
| 3104 |
String subject = "Partner Problem Alert!";
|
2722 |
String subject = "Partner Problem Alert!";
|
| Line 3115... |
Line 2733... |
| 3115 |
|
2733 |
|
| 3116 |
StringBuilder sbbuilder = new StringBuilder();
|
2734 |
StringBuilder sbbuilder = new StringBuilder();
|
| 3117 |
sbbuilder.append("<hml><body>");
|
2735 |
sbbuilder.append("<hml><body>");
|
| 3118 |
sb.append(
|
2736 |
sb.append(
|
| 3119 |
"<p>Number against MTD or Investment are the count of days the MTD is low VS LMTD OR Investment is below 75%.</p><br/><p>These partners needs immediate attention.</p><br/><table style='border:1px solid black';cellspacing=0>");
|
2737 |
"<p>Number against MTD or Investment are the count of days the MTD is low VS LMTD OR Investment is below 75%.</p><br/><p>These partners needs immediate attention.</p><br/><table style='border:1px solid black';cellspacing=0>");
|
| 3120 |
sbbuilder.append("<tbody>\n" + " <tr>"
|
- |
|
| 3121 |
+ " <th style='border:1px solid black;padding: 5px'>Partner Name</th>"
|
- |
|
| 3122 |
+ " <th style='border:1px solid black;padding: 5px'>Mtd</th>"
|
- |
|
| 3123 |
+ " <th style='border:1px solid black;padding: 5px'>Investment</th>"
|
2738 |
sbbuilder.append("<tbody>\n" + " <tr>" + " <th style='border:1px solid black;padding: 5px'>Partner Name</th>" + " <th style='border:1px solid black;padding: 5px'>Mtd</th>" + " <th style='border:1px solid black;padding: 5px'>Investment</th>" + " <th style='border:1px solid black;padding: 5px'>Stock</th>"
|
| 3124 |
+ " <th style='border:1px solid black;padding: 5px'>Stock</th>"
|
- |
|
| 3125 |
|
2739 |
|
| 3126 |
+ " </tr>");
|
2740 |
+ " </tr>");
|
| 3127 |
|
2741 |
|
| 3128 |
for (Integer partnerId : authUserPartner.getValue()) {
|
2742 |
for (Integer partnerId : authUserPartner.getValue()) {
|
| 3129 |
if (partnerProblemMap.get(partnerId) != null) {
|
2743 |
if (partnerProblemMap.get(partnerId) != null) {
|
| 3130 |
PartnerProblem pp = partnerProblemMap.get(partnerId);
|
2744 |
PartnerProblem pp = partnerProblemMap.get(partnerId);
|
| 3131 |
sbbuilder.append("<tr>");
|
2745 |
sbbuilder.append("<tr>");
|
| 3132 |
sbbuilder.append("<td style='border:1px solid black;padding: 5px'>"
|
- |
|
| 3133 |
+ customRetailers.get(pp.getFofoId()).getBusinessName() + "</td>");
|
2746 |
sbbuilder.append("<td style='border:1px solid black;padding: 5px'>" + customRetailers.get(pp.getFofoId()).getBusinessName() + "</td>");
|
| 3134 |
sbbuilder
|
- |
|
| 3135 |
.append("<td style='border:1px solid black;padding: 5px'>" + pp.getMtd() + "</td>");
|
2747 |
sbbuilder.append("<td style='border:1px solid black;padding: 5px'>" + pp.getMtd() + "</td>");
|
| 3136 |
sbbuilder.append(
|
2748 |
sbbuilder.append(
|
| 3137 |
"<td style='border:1px solid black;padding: 5px'>" + pp.getInvestment() + "</td>");
|
2749 |
"<td style='border:1px solid black;padding: 5px'>" + pp.getInvestment() + "</td>");
|
| 3138 |
sbbuilder.append("<td style='border:1px solid black;padding: 5px'>"
|
2750 |
sbbuilder.append("<td style='border:1px solid black;padding: 5px'>" + pp.getStockInvestment() + "</td>");
|
| 3139 |
+ pp.getStockInvestment() + "</td>");
|
- |
|
| 3140 |
|
2751 |
|
| 3141 |
sbbuilder.append("</tr>");
|
2752 |
sbbuilder.append("</tr>");
|
| 3142 |
}
|
2753 |
}
|
| 3143 |
|
2754 |
|
| 3144 |
}
|
2755 |
}
|
| Line 3149... |
Line 2760... |
| 3149 |
|
2760 |
|
| 3150 |
}
|
2761 |
}
|
| 3151 |
}
|
2762 |
}
|
| 3152 |
}
|
2763 |
}
|
| 3153 |
|
2764 |
|
| 3154 |
private void sendMailHtmlFormat(String email[], String body, String cc[], String subject)
|
2765 |
private void sendMailHtmlFormat(String email[], String body, String cc[], String subject) throws MessagingException, ProfitMandiBusinessException, IOException {
|
| 3155 |
throws MessagingException, ProfitMandiBusinessException, IOException {
|
- |
|
| 3156 |
MimeMessage message = mailSender.createMimeMessage();
|
2766 |
MimeMessage message = mailSender.createMimeMessage();
|
| 3157 |
MimeMessageHelper helper = new MimeMessageHelper(message);
|
2767 |
MimeMessageHelper helper = new MimeMessageHelper(message);
|
| 3158 |
helper.setSubject(subject);
|
2768 |
helper.setSubject(subject);
|
| 3159 |
helper.setText(body, true);
|
2769 |
helper.setText(body, true);
|
| 3160 |
helper.setTo(email);
|
2770 |
helper.setTo(email);
|
| Line 3207... |
Line 2817... |
| 3207 |
e.printStackTrace();
|
2817 |
e.printStackTrace();
|
| 3208 |
}
|
2818 |
}
|
| 3209 |
|
2819 |
|
| 3210 |
}
|
2820 |
}
|
| 3211 |
|
2821 |
|
| 3212 |
public void selectFinServiceFollowUpDateByCurrDate(LocalDate currentDate)
|
- |
|
| 3213 |
throws MessagingException, ProfitMandiBusinessException, IOException {
|
2822 |
public void selectFinServiceFollowUpDateByCurrDate(LocalDate currentDate) throws MessagingException, ProfitMandiBusinessException, IOException {
|
| 3214 |
LOGGER.info("selectfinServiceFollow - {}", "selectfinServiceFollowUpDateByCurrDate");
|
2823 |
LOGGER.info("selectfinServiceFollow - {}", "selectfinServiceFollowUpDateByCurrDate");
|
| 3215 |
|
2824 |
|
| 3216 |
serviceConfigService.selectFinServicePartnerfollowUpDateByCurrentDate(currentDate);
|
2825 |
serviceConfigService.selectFinServicePartnerfollowUpDateByCurrentDate(currentDate);
|
| 3217 |
|
2826 |
|
| 3218 |
}
|
2827 |
}
|
| Line 3238... |
Line 2847... |
| 3238 |
public void checkCancellationMargin() throws Exception {
|
2847 |
public void checkCancellationMargin() throws Exception {
|
| 3239 |
LocalDateTime startDate = LocalDate.of(2021, 4, 1).atStartOfDay();
|
2848 |
LocalDateTime startDate = LocalDate.of(2021, 4, 1).atStartOfDay();
|
| 3240 |
List<FofoOrder> fofoOrders = fofoOrderRepository.selectCancelledBetweenSaleDate(startDate, LocalDateTime.now());
|
2849 |
List<FofoOrder> fofoOrders = fofoOrderRepository.selectCancelledBetweenSaleDate(startDate, LocalDateTime.now());
|
| 3241 |
LOGGER.info("Total Orders = {}", fofoOrders.size());
|
2850 |
LOGGER.info("Total Orders = {}", fofoOrders.size());
|
| 3242 |
for (FofoOrder fofoOrder : fofoOrders) {
|
2851 |
for (FofoOrder fofoOrder : fofoOrders) {
|
| 3243 |
List<UserWalletHistory> history = userWalletHistoryRepository
|
- |
|
| 3244 |
.selectAllByreferenceIdandreferenceType(fofoOrder.getId(), WalletReferenceType.SCHEME_OUT);
|
2852 |
List<UserWalletHistory> history = userWalletHistoryRepository.selectAllByreferenceIdandreferenceType(fofoOrder.getId(), WalletReferenceType.SCHEME_OUT);
|
| 3245 |
history.addAll(userWalletHistoryRepository.selectAllByreferenceIdandreferenceType(fofoOrder.getId(),
|
2853 |
history.addAll(userWalletHistoryRepository.selectAllByreferenceIdandreferenceType(fofoOrder.getId(), WalletReferenceType.ACTIVATION_SCHEME));
|
| 3246 |
WalletReferenceType.ACTIVATION_SCHEME));
|
- |
|
| 3247 |
int walletSum = history.stream().mapToInt(x -> x.getAmount()).sum();
|
2854 |
int walletSum = history.stream().mapToInt(x -> x.getAmount()).sum();
|
| 3248 |
if (Math.abs(walletSum) > 1) {
|
2855 |
if (Math.abs(walletSum) > 1) {
|
| 3249 |
// LOGGER.info("Cancelled invoice {}, Order Id = {}, = havent rolledback, Value
|
2856 |
// LOGGER.info("Cancelled invoice {}, Order Id = {}, = havent rolledback, Value
|
| 3250 |
// = {}", fofoOrder.getInvoiceNumber(), fofoOrder.getId(), walletSum);
|
2857 |
// = {}", fofoOrder.getInvoiceNumber(), fofoOrder.getId(), walletSum);
|
| 3251 |
List<FofoOrderItem> fofoOrderItems = fofoOrderItemRepository.selectByOrderId(fofoOrder.getId());
|
2858 |
List<FofoOrderItem> fofoOrderItems = fofoOrderItemRepository.selectByOrderId(fofoOrder.getId());
|
| 3252 |
List<FofoLineItem> flis = fofoLineItemRepository.selectByFofoOrderItemId(fofoOrderItems.get(0).getId());
|
2859 |
List<FofoLineItem> flis = fofoLineItemRepository.selectByFofoOrderItemId(fofoOrderItems.get(0).getId());
|
| 3253 |
FofoLineItem fli = flis.get(0);
|
2860 |
FofoLineItem fli = flis.get(0);
|
| 3254 |
if (StringUtils.isEmpty(fli.getSerialNumber()))
|
2861 |
if (StringUtils.isEmpty(fli.getSerialNumber()))
|
| 3255 |
continue;
|
2862 |
continue;
|
| 3256 |
List<SchemeInOut> schemeInOuts = schemeInOutRepository
|
- |
|
| 3257 |
.selectByInventoryItemIds(new HashSet<>(Arrays.asList(fli.getInventoryItemId())));
|
2863 |
List<SchemeInOut> schemeInOuts = schemeInOutRepository.selectByInventoryItemIds(new HashSet<>(Arrays.asList(fli.getInventoryItemId())));
|
| 3258 |
InventoryItem inventoryItem = inventoryItemRepository.selectById(fli.getInventoryItemId());
|
2864 |
InventoryItem inventoryItem = inventoryItemRepository.selectById(fli.getInventoryItemId());
|
| 3259 |
double schemeSum = schemeInOuts.stream().filter(x -> x.getRolledBackTimestamp() == null)
|
2865 |
double schemeSum = schemeInOuts.stream().filter(x -> x.getRolledBackTimestamp() == null).mapToDouble(x -> x.getAmount()).sum();
|
| 3260 |
.mapToDouble(x -> x.getAmount()).sum();
|
- |
|
| 3261 |
/*
|
2866 |
/*
|
| 3262 |
* if(inventoryItem.getGoodQuantity()==1) {
|
2867 |
* if(inventoryItem.getGoodQuantity()==1) {
|
| 3263 |
* LOGGER.info("GoodQty, Serial Number {}, InventoryItem = {}, Billed on {}",
|
2868 |
* LOGGER.info("GoodQty, Serial Number {}, InventoryItem = {}, Billed on {}",
|
| 3264 |
* inventoryItem.getSerialNumber(), inventoryItem.getId(),
|
2869 |
* inventoryItem.getSerialNumber(), inventoryItem.getId(),
|
| 3265 |
* inventoryItem.getUpdateTimestamp()); } else
|
2870 |
* inventoryItem.getUpdateTimestamp()); } else
|
| Line 3270... |
Line 2875... |
| 3270 |
* (inventoryItem.getLastScanType().equals(ScanType.SALE)) { LOGGER.
|
2875 |
* (inventoryItem.getLastScanType().equals(ScanType.SALE)) { LOGGER.
|
| 3271 |
* info("Problem Sold, Serial Number {}, InventoryItem = {}, Billed on {}",
|
2876 |
* info("Problem Sold, Serial Number {}, InventoryItem = {}, Billed on {}",
|
| 3272 |
* inventoryItem.getSerialNumber(), inventoryItem.getId(),
|
2877 |
* inventoryItem.getSerialNumber(), inventoryItem.getId(),
|
| 3273 |
* inventoryItem.getUpdateTimestamp()); }
|
2878 |
* inventoryItem.getUpdateTimestamp()); }
|
| 3274 |
*/
|
2879 |
*/
|
| 3275 |
if (inventoryItem.getLastScanType().equals(ScanType.SALE)
|
- |
|
| 3276 |
|| inventoryItem.getLastScanType().equals(ScanType.SALE_RET)) {
|
2880 |
if (inventoryItem.getLastScanType().equals(ScanType.SALE) || inventoryItem.getLastScanType().equals(ScanType.SALE_RET)) {
|
| 3277 |
Map<String, Double> map = schemeInOuts.stream()
|
2881 |
Map<String, Double> map = schemeInOuts.stream().collect(
|
| 3278 |
.collect(
|
- |
|
| 3279 |
groupingBy(
|
2882 |
groupingBy(
|
| 3280 |
x -> DateTimeFormatter.ofPattern("yyyyMMddHH")
|
- |
|
| 3281 |
.format(x.getCreateTimestamp()) + "- " + x.getSchemeId(),
|
2883 |
x -> DateTimeFormatter.ofPattern("yyyyMMddHH").format(x.getCreateTimestamp()) + "- " + x.getSchemeId(), Collectors.summingDouble(x -> x.getAmount())));
|
| 3282 |
Collectors.summingDouble(x -> x.getAmount())));
|
- |
|
| 3283 |
for (Map.Entry<String, Double> entry : map.entrySet()) {
|
2884 |
for (Map.Entry<String, Double> entry : map.entrySet()) {
|
| 3284 |
LOGGER.info("{} = {}", entry.getKey(), entry.getValue());
|
2885 |
LOGGER.info("{} = {}", entry.getKey(), entry.getValue());
|
| 3285 |
}
|
2886 |
}
|
| 3286 |
LOGGER.info("id- {}, imei- {}, lastScan = {}, Scheme sum - {}", inventoryItem.getId(),
|
2887 |
LOGGER.info("id- {}, imei- {}, lastScan = {}, Scheme sum - {}", inventoryItem.getId(), inventoryItem.getSerialNumber(), inventoryItem.getLastScanType(), schemeSum);
|
| 3287 |
inventoryItem.getSerialNumber(), inventoryItem.getLastScanType(), schemeSum);
|
- |
|
| 3288 |
}
|
2888 |
}
|
| 3289 |
}
|
2889 |
}
|
| 3290 |
}
|
2890 |
}
|
| 3291 |
|
2891 |
|
| 3292 |
}
|
2892 |
}
|
| Line 3296... |
Line 2896... |
| 3296 |
data = new String(Files.readAllBytes(Paths.get(file)));
|
2896 |
data = new String(Files.readAllBytes(Paths.get(file)));
|
| 3297 |
return data;
|
2897 |
return data;
|
| 3298 |
}
|
2898 |
}
|
| 3299 |
|
2899 |
|
| 3300 |
public void markDelhiveryOrderDelivered() throws ProfitMandiBusinessException, IOException {
|
2900 |
public void markDelhiveryOrderDelivered() throws ProfitMandiBusinessException, IOException {
|
| 3301 |
List<Order> orders = orderRepository.selectOrderByProviderIdAndStatus(ProfitMandiConstants.DELHIVERY_PROVIDERID,
|
2901 |
List<Order> orders = orderRepository.selectOrderByProviderIdAndStatus(ProfitMandiConstants.DELHIVERY_PROVIDERID, OrderStatus.SHIPPED_FROM_WH);
|
| 3302 |
OrderStatus.SHIPPED_FROM_WH);
|
- |
|
| 3303 |
|
2902 |
|
| 3304 |
if (!orders.isEmpty()) {
|
2903 |
if (!orders.isEmpty()) {
|
| 3305 |
Set<String> airwayBill = orders.stream().map(x -> x.getAirwayBillNumber()).collect(Collectors.toSet());
|
2904 |
Set<String> airwayBill = orders.stream().map(x -> x.getAirwayBillNumber()).collect(Collectors.toSet());
|
| 3306 |
|
2905 |
|
| 3307 |
int arraylength = airwayBill.size();
|
2906 |
int arraylength = airwayBill.size();
|
| Line 3313... |
Line 2912... |
| 3313 |
LOGGER.info("airwayBill" + airwayBill);
|
2912 |
LOGGER.info("airwayBill" + airwayBill);
|
| 3314 |
String url = "https://track.delhivery.com/api/v1/packages/json/";
|
2913 |
String url = "https://track.delhivery.com/api/v1/packages/json/";
|
| 3315 |
|
2914 |
|
| 3316 |
OkHttpClient client = new OkHttpClient();
|
2915 |
OkHttpClient client = new OkHttpClient();
|
| 3317 |
|
2916 |
|
| 3318 |
Request request1 = new Request.Builder()
|
- |
|
| 3319 |
.url(url + "?waybill=" + String.join(",", airwayBill) + "&token=" + token).get().build();
|
2917 |
Request request1 = new Request.Builder().url(url + "?waybill=" + String.join(",", airwayBill) + "&token=" + token).get().build();
|
| 3320 |
|
2918 |
|
| 3321 |
LOGGER.info("request1" + request1);
|
2919 |
LOGGER.info("request1" + request1);
|
| 3322 |
|
2920 |
|
| 3323 |
Response response = client.newCall(request1).execute();
|
2921 |
Response response = client.newCall(request1).execute();
|
| 3324 |
|
2922 |
|
| Line 3355... |
Line 2953... |
| 3355 |
|
2953 |
|
| 3356 |
String loginId = "DEL81122";
|
2954 |
String loginId = "DEL81122";
|
| 3357 |
|
2955 |
|
| 3358 |
String licencekey = "uhfhlg2jpmnqfhfrlsgzfr1nhu1qfvel";
|
2956 |
String licencekey = "uhfhlg2jpmnqfhfrlsgzfr1nhu1qfvel";
|
| 3359 |
|
2957 |
|
| 3360 |
List<Order> orders = orderRepository.selectOrderByProviderIdAndStatus(ProfitMandiConstants.BLUEDART_PROVIDERID,
|
2958 |
List<Order> orders = orderRepository.selectOrderByProviderIdAndStatus(ProfitMandiConstants.BLUEDART_PROVIDERID, OrderStatus.SHIPPED_FROM_WH);
|
| 3361 |
OrderStatus.SHIPPED_FROM_WH);
|
- |
|
| 3362 |
|
2959 |
|
| 3363 |
if (!orders.isEmpty()) {
|
2960 |
if (!orders.isEmpty()) {
|
| 3364 |
|
2961 |
|
| 3365 |
Set<String> airwayBillNo = orders.stream().map(x -> x.getAirwayBillNumber()).collect(Collectors.toSet());
|
2962 |
Set<String> airwayBillNo = orders.stream().map(x -> x.getAirwayBillNumber()).collect(Collectors.toSet());
|
| 3366 |
|
2963 |
|
| 3367 |
LOGGER.info("airwayBill" + airwayBillNo);
|
2964 |
LOGGER.info("airwayBill" + airwayBillNo);
|
| 3368 |
String url = "https://api.bluedart.com/servlet/RoutingServlet?handler=tnt&action=custawbquery";
|
2965 |
String url = "https://api.bluedart.com/servlet/RoutingServlet?handler=tnt&action=custawbquery";
|
| 3369 |
|
2966 |
|
| 3370 |
String response = restClient.get(url + "&loginid=" + loginId + "&awb=awb&numbers="
|
- |
|
| 3371 |
+ String.join(",", airwayBillNo) + "&format=xml&lickey=" + licencekey + "&verno=1.3&scan=1", null,
|
2967 |
String response = restClient.get(url + "&loginid=" + loginId + "&awb=awb&numbers=" + String.join(",", airwayBillNo) + "&format=xml&lickey=" + licencekey + "&verno=1.3&scan=1", null, null);
|
| 3372 |
null);
|
- |
|
| 3373 |
|
2968 |
|
| 3374 |
JSONObject updateJson = XML.toJSONObject(response);
|
2969 |
JSONObject updateJson = XML.toJSONObject(response);
|
| 3375 |
|
2970 |
|
| 3376 |
JSONObject shipmentData = updateJson.getJSONObject("ShipmentData");
|
2971 |
JSONObject shipmentData = updateJson.getJSONObject("ShipmentData");
|
| 3377 |
Object shipmentObject = shipmentData.get("Shipment");
|
2972 |
Object shipmentObject = shipmentData.get("Shipment");
|
| Line 3407... |
Line 3002... |
| 3407 |
markOrderDelivered(airwaybillStatus);
|
3002 |
markOrderDelivered(airwaybillStatus);
|
| 3408 |
}
|
3003 |
}
|
| 3409 |
|
3004 |
|
| 3410 |
}
|
3005 |
}
|
| 3411 |
|
3006 |
|
| 3412 |
private void markOrderDelivered(Set<String> airwaybillStatus)
|
- |
|
| 3413 |
throws ProfitMandiBusinessException, HttpHostConnectException {
|
3007 |
private void markOrderDelivered(Set<String> airwaybillStatus) throws ProfitMandiBusinessException, HttpHostConnectException {
|
| 3414 |
if (!airwaybillStatus.isEmpty()) {
|
3008 |
if (!airwaybillStatus.isEmpty()) {
|
| 3415 |
for (String aws : airwaybillStatus) {
|
3009 |
for (String aws : airwaybillStatus) {
|
| 3416 |
|
3010 |
|
| 3417 |
List<Order> deliverdOrders = orderRepository.selectByAirwayBillNumber(aws);
|
3011 |
List<Order> deliverdOrders = orderRepository.selectByAirwayBillNumber(aws);
|
| 3418 |
|
3012 |
|
| Line 3427... |
Line 3021... |
| 3427 |
|
3021 |
|
| 3428 |
Address address = addressRepository.selectById(user.getAddressId());
|
3022 |
Address address = addressRepository.selectById(user.getAddressId());
|
| 3429 |
|
3023 |
|
| 3430 |
String title = "Order Delivered";
|
3024 |
String title = "Order Delivered";
|
| 3431 |
|
3025 |
|
| 3432 |
String message = String.format("Dear partner, Your SmartDukaan Order " + aws
|
3026 |
String message = String.format("Dear partner, Your SmartDukaan Order " + aws + " has been delivered to you in a safe sealed bag.");
|
| 3433 |
+ " has been delivered to you in a safe sealed bag.");
|
- |
|
| 3434 |
|
3027 |
|
| 3435 |
SendNotificationModel sendNotificationModel = new SendNotificationModel();
|
3028 |
SendNotificationModel sendNotificationModel = new SendNotificationModel();
|
| 3436 |
sendNotificationModel.setCampaignName("Order Delivered");
|
3029 |
sendNotificationModel.setCampaignName("Order Delivered");
|
| 3437 |
sendNotificationModel.setTitle(title);
|
3030 |
sendNotificationModel.setTitle(title);
|
| 3438 |
sendNotificationModel.setMessage(message);
|
3031 |
sendNotificationModel.setMessage(message);
|
| Line 3458... |
Line 3051... |
| 3458 |
|
3051 |
|
| 3459 |
if (fs.getPan() != null) {
|
3052 |
if (fs.getPan() != null) {
|
| 3460 |
AccountStatusResponseOut accountStatusResponseOut = mandiiService.getStatus(fs.getPan());
|
3053 |
AccountStatusResponseOut accountStatusResponseOut = mandiiService.getStatus(fs.getPan());
|
| 3461 |
|
3054 |
|
| 3462 |
LOGGER.info("accountStatusResponseOut" + accountStatusResponseOut);
|
3055 |
LOGGER.info("accountStatusResponseOut" + accountStatusResponseOut);
|
| 3463 |
CreditAccount creditAccount = creditAccountRepository.selectByFofoIdAndGateway(fs.getId(),
|
3056 |
CreditAccount creditAccount = creditAccountRepository.selectByFofoIdAndGateway(fs.getId(), Gateway.MANDII);
|
| 3464 |
Gateway.MANDII);
|
- |
|
| 3465 |
|
3057 |
|
| 3466 |
if (creditAccount == null) {
|
3058 |
if (creditAccount == null) {
|
| 3467 |
|
3059 |
|
| 3468 |
creditAccount = new CreditAccount();
|
3060 |
creditAccount = new CreditAccount();
|
| 3469 |
|
3061 |
|
| Line 3510... |
Line 3102... |
| 3510 |
}
|
3102 |
}
|
| 3511 |
|
3103 |
|
| 3512 |
@Autowired
|
3104 |
@Autowired
|
| 3513 |
private PartnerCollectionRemarkRepository partnerCollectionRemarkRepository;
|
3105 |
private PartnerCollectionRemarkRepository partnerCollectionRemarkRepository;
|
| 3514 |
|
3106 |
|
| 3515 |
public void reviewUncontactablePartner()
|
- |
|
| 3516 |
throws ProfitMandiBusinessException, MessagingException, UnsupportedEncodingException {
|
3107 |
public void reviewUncontactablePartner() throws ProfitMandiBusinessException, MessagingException, UnsupportedEncodingException {
|
| 3517 |
|
3108 |
|
| 3518 |
Map<Integer, CustomRetailer> customRetailerMap = retailerService.getFofoRetailers(true);
|
3109 |
Map<Integer, CustomRetailer> customRetailerMap = retailerService.getFofoRetailers(true);
|
| 3519 |
|
3110 |
|
| 3520 |
List<Integer> pcrms = partnerCollectionRemarkRepository
|
- |
|
| 3521 |
.selectMaxRemarkId(new ArrayList<>(customRetailerMap.keySet()));
|
3111 |
List<Integer> pcrms = partnerCollectionRemarkRepository.selectMaxRemarkId(new ArrayList<>(customRetailerMap.keySet()));
|
| 3522 |
|
3112 |
|
| 3523 |
if (!pcrms.isEmpty()) {
|
3113 |
if (!pcrms.isEmpty()) {
|
| 3524 |
Map<Integer, PartnerCollectionRemark> partnerCollectionRemarksMap = partnerCollectionRemarkRepository
|
3114 |
Map<Integer, PartnerCollectionRemark> partnerCollectionRemarksMap = partnerCollectionRemarkRepository.selectByIds(pcrms).stream().filter(x -> x.getRemark().equals(CollectionRemark.NOT_RESPONDING)).collect(Collectors.toMap(x -> x.getFofoId(), x -> x));
|
| 3525 |
.selectByIds(pcrms).stream().filter(x -> x.getRemark().equals(CollectionRemark.NOT_RESPONDING))
|
- |
|
| 3526 |
.collect(Collectors.toMap(x -> x.getFofoId(), x -> x));
|
- |
|
| 3527 |
|
3115 |
|
| 3528 |
if (!partnerCollectionRemarksMap.isEmpty()) {
|
3116 |
if (!partnerCollectionRemarksMap.isEmpty()) {
|
| 3529 |
for (Map.Entry<String, Set<Integer>> storeGuyEntry : csService.getAuthUserPartnerIdMapping()
|
3117 |
for (Map.Entry<String, Set<Integer>> storeGuyEntry : csService.getAuthUserPartnerIdMapping().entrySet()) {
|
| 3530 |
.entrySet()) {
|
- |
|
| 3531 |
List<PartnerCollectionRemark> filteredRows = storeGuyEntry.getValue().stream()
|
3118 |
List<PartnerCollectionRemark> filteredRows = storeGuyEntry.getValue().stream().map(x -> partnerCollectionRemarksMap.get(x)).filter(x -> x != null).collect(Collectors.toList());
|
| 3532 |
.map(x -> partnerCollectionRemarksMap.get(x)).filter(x -> x != null)
|
- |
|
| 3533 |
.collect(Collectors.toList());
|
- |
|
| 3534 |
String subject = "UNCONTACTABLE PARTNERS";
|
3119 |
String subject = "UNCONTACTABLE PARTNERS";
|
| 3535 |
String messageText = this.getMessageForUncontacblePartner(filteredRows);
|
3120 |
String messageText = this.getMessageForUncontacblePartner(filteredRows);
|
| 3536 |
|
3121 |
|
| 3537 |
MimeMessage message = mailSender.createMimeMessage();
|
3122 |
MimeMessage message = mailSender.createMimeMessage();
|
| 3538 |
MimeMessageHelper helper = new MimeMessageHelper(message, true);
|
3123 |
MimeMessageHelper helper = new MimeMessageHelper(message, true);
|
| 3539 |
String[] email = new String[]{storeGuyEntry.getKey()};
|
3124 |
String[] email = new String[]{storeGuyEntry.getKey()};
|
| 3540 |
|
3125 |
|
| 3541 |
helper.setSubject(subject);
|
3126 |
helper.setSubject(subject);
|
| 3542 |
helper.setText(messageText, true);
|
3127 |
helper.setText(messageText, true);
|
| 3543 |
helper.setTo(email);
|
3128 |
helper.setTo(email);
|
| 3544 |
InternetAddress senderAddress = new InternetAddress("noreply@smartdukaan.com",
|
3129 |
InternetAddress senderAddress = new InternetAddress("noreply@smartdukaan.com", "Smartdukaan Alerts");
|
| 3545 |
"Smartdukaan Alerts");
|
- |
|
| 3546 |
helper.setFrom(senderAddress);
|
3130 |
helper.setFrom(senderAddress);
|
| 3547 |
mailSender.send(message);
|
3131 |
mailSender.send(message);
|
| 3548 |
|
3132 |
|
| 3549 |
LOGGER.info("filteredRows {}", filteredRows);
|
3133 |
LOGGER.info("filteredRows {}", filteredRows);
|
| 3550 |
|
3134 |
|
| Line 3591... |
Line 3175... |
| 3591 |
if (loan.getFreeDays() > 0) {
|
3175 |
if (loan.getFreeDays() > 0) {
|
| 3592 |
LocalDateTime freeDaysLimitDate = loan.getCreatedOn().plusDays(loan.getFreeDays() - 1);
|
3176 |
LocalDateTime freeDaysLimitDate = loan.getCreatedOn().plusDays(loan.getFreeDays() - 1);
|
| 3593 |
|
3177 |
|
| 3594 |
LOGGER.info("freeDaysLimitDate {}", freeDaysLimitDate);
|
3178 |
LOGGER.info("freeDaysLimitDate {}", freeDaysLimitDate);
|
| 3595 |
if (LocalDateTime.now().isAfter(freeDaysLimitDate)) {
|
3179 |
if (LocalDateTime.now().isAfter(freeDaysLimitDate)) {
|
| 3596 |
int loanStatementId = loanStatementRepository.selectLatestLoanSatement(loan.getFofoId(),
|
3180 |
int loanStatementId = loanStatementRepository.selectLatestLoanSatement(loan.getFofoId(), loan.getId());
|
| 3597 |
loan.getId());
|
- |
|
| 3598 |
LOGGER.info("loanStatementId {}", loanStatementId);
|
3181 |
LOGGER.info("loanStatementId {}", loanStatementId);
|
| 3599 |
|
3182 |
|
| 3600 |
if (loanStatementId != 0) {
|
3183 |
if (loanStatementId != 0) {
|
| 3601 |
|
3184 |
|
| 3602 |
this.calculateInterest(loan, loanStatusAmount, loanStatementId);
|
3185 |
this.calculateInterest(loan, loanStatusAmount, loanStatementId);
|
| 3603 |
|
3186 |
|
| 3604 |
} else {
|
3187 |
} else {
|
| 3605 |
sdCreditService.addInterest(freeDaysLimitDate.toLocalDate(), LocalDate.now(), loan,
|
3188 |
sdCreditService.addInterest(freeDaysLimitDate.toLocalDate(), LocalDate.now(), loan, loanStatusAmount);
|
| 3606 |
loanStatusAmount);
|
- |
|
| 3607 |
}
|
3189 |
}
|
| 3608 |
|
3190 |
|
| 3609 |
}
|
3191 |
}
|
| 3610 |
} else {
|
3192 |
} else {
|
| 3611 |
|
3193 |
|
| 3612 |
int loanStatementId = loanStatementRepository.selectLatestLoanSatement(loan.getFofoId(),
|
3194 |
int loanStatementId = loanStatementRepository.selectLatestLoanSatement(loan.getFofoId(), loan.getId());
|
| 3613 |
loan.getId());
|
- |
|
| 3614 |
LOGGER.info("loanStatementId2 {}", loanStatementId);
|
3195 |
LOGGER.info("loanStatementId2 {}", loanStatementId);
|
| 3615 |
|
3196 |
|
| 3616 |
this.calculateInterest(loan, loanStatusAmount, loanStatementId);
|
3197 |
this.calculateInterest(loan, loanStatusAmount, loanStatementId);
|
| 3617 |
|
3198 |
|
| 3618 |
}
|
3199 |
}
|
| Line 3627... |
Line 3208... |
| 3627 |
|
3208 |
|
| 3628 |
@Autowired
|
3209 |
@Autowired
|
| 3629 |
CCAvenuePaymentService ccAvenuePaymentService;
|
3210 |
CCAvenuePaymentService ccAvenuePaymentService;
|
| 3630 |
|
3211 |
|
| 3631 |
public void settleCCAvePayments() throws Exception {
|
3212 |
public void settleCCAvePayments() throws Exception {
|
| 3632 |
List<FofoPayment> fofoPayments = fofoPaymentRepository
|
- |
|
| 3633 |
.selectAllByGatewayStatus(Gateway.CCAVENUE, PaymentStatus.INIT).stream()
|
- |
|
| 3634 |
.filter(x -> x.getCreateTimestamp().isBefore(LocalDateTime.now().minusMinutes(30l)))
|
3213 |
List<FofoPayment> fofoPayments = fofoPaymentRepository.selectAllByGatewayStatus(Gateway.CCAVENUE, PaymentStatus.INIT).stream().filter(x -> x.getCreateTimestamp().isBefore(LocalDateTime.now().minusMinutes(30l))).collect(Collectors.toList());
|
| 3635 |
.collect(Collectors.toList());
|
- |
|
| 3636 |
for (FofoPayment fofoPayment : fofoPayments) {
|
3214 |
for (FofoPayment fofoPayment : fofoPayments) {
|
| 3637 |
ccAvenuePaymentService.updatePayment(fofoPayment);
|
3215 |
ccAvenuePaymentService.updatePayment(fofoPayment);
|
| 3638 |
}
|
3216 |
}
|
| 3639 |
}
|
3217 |
}
|
| 3640 |
|
3218 |
|
| Line 3642... |
Line 3220... |
| 3642 |
* public void getCCAvenuePendingOrderStatus(int pendingOrderId) { PendingOrder
|
3220 |
* public void getCCAvenuePendingOrderStatus(int pendingOrderId) { PendingOrder
|
| 3643 |
* pendingOrder = pendingOrderRepository.selectById(pendingOrderId);
|
3221 |
* pendingOrder = pendingOrderRepository.selectById(pendingOrderId);
|
| 3644 |
* ccAvenuePaymentService.getPaymentStatusMap(pendingOrder); }
|
3222 |
* ccAvenuePaymentService.getPaymentStatusMap(pendingOrder); }
|
| 3645 |
*/
|
3223 |
*/
|
| 3646 |
|
3224 |
|
| 3647 |
private void calculateInterest(Loan loan, Map<LoanReferenceType, Double> loanStatusAmount, int loanStatementId)
|
3225 |
private void calculateInterest(Loan loan, Map<LoanReferenceType, Double> loanStatusAmount, int loanStatementId) throws ProfitMandiBusinessException {
|
| 3648 |
throws ProfitMandiBusinessException {
|
- |
|
| 3649 |
LoanStatement loanStatement = loanStatementRepository.selectById(loanStatementId);
|
3226 |
LoanStatement loanStatement = loanStatementRepository.selectById(loanStatementId);
|
| 3650 |
|
3227 |
|
| 3651 |
if (loanStatement.getLoanId() == loan.getId()) {
|
3228 |
if (loanStatement.getLoanId() == loan.getId()) {
|
| 3652 |
|
3229 |
|
| 3653 |
sdCreditService.addInterest(loanStatement.getCreatedAt().toLocalDate(), LocalDate.now(), loan,
|
3230 |
sdCreditService.addInterest(loanStatement.getCreatedAt().toLocalDate(), LocalDate.now(), loan, loanStatusAmount);
|
| 3654 |
loanStatusAmount);
|
- |
|
| 3655 |
|
3231 |
|
| 3656 |
} else {
|
3232 |
} else {
|
| 3657 |
throw new ProfitMandiBusinessException("loanstament", loanStatement.getLoanId(), "Invalid LoanId");
|
3233 |
throw new ProfitMandiBusinessException("loanstament", loanStatement.getLoanId(), "Invalid LoanId");
|
| 3658 |
}
|
3234 |
}
|
| 3659 |
}
|
3235 |
}
|
| Line 3664... |
Line 3240... |
| 3664 |
if (!loans.isEmpty()) {
|
3240 |
if (!loans.isEmpty()) {
|
| 3665 |
|
3241 |
|
| 3666 |
for (Loan loan : loans) {
|
3242 |
for (Loan loan : loans) {
|
| 3667 |
|
3243 |
|
| 3668 |
UserWallet userWallet = userWalletRepository.selectByRetailerId(loan.getFofoId());
|
3244 |
UserWallet userWallet = userWalletRepository.selectByRetailerId(loan.getFofoId());
|
| 3669 |
SDCreditRequirement sdCreditRequirement = sdCreditRequirementRepository
|
3245 |
SDCreditRequirement sdCreditRequirement = sdCreditRequirementRepository.selectByFofoId(loan.getFofoId());
|
| 3670 |
.selectByFofoId(loan.getFofoId());
|
- |
|
| 3671 |
|
3246 |
|
| 3672 |
if (userWallet.getAmount() >= 100) {
|
3247 |
if (userWallet.getAmount() >= 100) {
|
| 3673 |
List<LoanStatement> loanStatements = loanStatementRepository.selectByLoanId(loan.getId());
|
3248 |
List<LoanStatement> loanStatements = loanStatementRepository.selectByLoanId(loan.getId());
|
| 3674 |
|
3249 |
|
| 3675 |
LOGGER.info("loanStatements {}", loanStatements);
|
3250 |
LOGGER.info("loanStatements {}", loanStatements);
|
| 3676 |
|
3251 |
|
| 3677 |
Map<LoanReferenceType, Double> loanStatusAmount = loanStatements.stream()
|
- |
|
| 3678 |
.collect(groupingBy(x -> x.getLoanReferenceType(),
|
- |
|
| 3679 |
Collectors.summingDouble(x -> FormattingUtils.serialize(x.getAmount()))));
|
3252 |
Map<LoanReferenceType, Double> loanStatusAmount = loanStatements.stream().collect(groupingBy(x -> x.getLoanReferenceType(), Collectors.summingDouble(x -> FormattingUtils.serialize(x.getAmount()))));
|
| 3680 |
|
3253 |
|
| 3681 |
LOGGER.info("loanStatusAmount {}", loanStatusAmount);
|
3254 |
LOGGER.info("loanStatusAmount {}", loanStatusAmount);
|
| 3682 |
Double interestAmount = loanStatusAmount.get(LoanReferenceType.INTEREST);
|
3255 |
Double interestAmount = loanStatusAmount.get(LoanReferenceType.INTEREST);
|
| 3683 |
|
3256 |
|
| 3684 |
if (interestAmount == null) {
|
3257 |
if (interestAmount == null) {
|
| Line 3692... |
Line 3265... |
| 3692 |
LOGGER.info("interestAmount b {}", interestAmount);
|
3265 |
LOGGER.info("interestAmount b {}", interestAmount);
|
| 3693 |
|
3266 |
|
| 3694 |
if (interestAmount < 0) {
|
3267 |
if (interestAmount < 0) {
|
| 3695 |
LOGGER.info("interestAmount a {}", interestAmount);
|
3268 |
LOGGER.info("interestAmount a {}", interestAmount);
|
| 3696 |
|
3269 |
|
| 3697 |
settledLoanStatement(LoanReferenceType.INTEREST, BigDecimal.valueOf(interestAmount),
|
3270 |
settledLoanStatement(LoanReferenceType.INTEREST, BigDecimal.valueOf(interestAmount), loan.getFofoId(), loan.getId(), "Amount adjusted against loan", LocalDateTime.now());
|
| 3698 |
loan.getFofoId(), loan.getId(), "Amount adjusted against loan",
|
- |
|
| 3699 |
LocalDateTime.now());
|
- |
|
| 3700 |
loan.setInterestPaid(loan.getInterestPaid().add(BigDecimal.valueOf(interestAmount).abs()));
|
3271 |
loan.setInterestPaid(loan.getInterestPaid().add(BigDecimal.valueOf(interestAmount).abs()));
|
| 3701 |
|
3272 |
|
| 3702 |
paidAmount += Math.abs(interestAmount);
|
3273 |
paidAmount += Math.abs(interestAmount);
|
| 3703 |
}
|
3274 |
}
|
| 3704 |
|
3275 |
|
| 3705 |
double userWalletAmount = userWallet.getAmount() - Math.abs(interestAmount);
|
3276 |
double userWalletAmount = userWallet.getAmount() - Math.abs(interestAmount);
|
| 3706 |
|
3277 |
|
| 3707 |
if (userWalletAmount > Math.abs(principalAmount) && principalAmount < 0) {
|
3278 |
if (userWalletAmount > Math.abs(principalAmount) && principalAmount < 0) {
|
| 3708 |
|
3279 |
|
| 3709 |
settledLoanStatement(LoanReferenceType.PRINCIPAL, BigDecimal.valueOf(principalAmount),
|
3280 |
settledLoanStatement(LoanReferenceType.PRINCIPAL, BigDecimal.valueOf(principalAmount), loan.getFofoId(), loan.getId(), "Amount adjusted against loan", LocalDateTime.now());
|
| 3710 |
loan.getFofoId(), loan.getId(), "Amount adjusted against loan",
|
- |
|
| 3711 |
LocalDateTime.now());
|
- |
|
| 3712 |
double amount = userWalletAmount - Math.abs(principalAmount);
|
3281 |
double amount = userWalletAmount - Math.abs(principalAmount);
|
| 3713 |
|
3282 |
|
| 3714 |
paidAmount += Math.abs(principalAmount);
|
3283 |
paidAmount += Math.abs(principalAmount);
|
| 3715 |
|
3284 |
|
| 3716 |
userWallet.setAmount((int) amount);
|
3285 |
userWallet.setAmount((int) amount);
|
| 3717 |
|
3286 |
|
| 3718 |
BigDecimal utilizationAmount = sdCreditRequirement.getUtilizedAmount()
|
3287 |
BigDecimal utilizationAmount = sdCreditRequirement.getUtilizedAmount().subtract(BigDecimal.valueOf(principalAmount).abs());
|
| 3719 |
.subtract(BigDecimal.valueOf(principalAmount).abs());
|
- |
|
| 3720 |
|
3288 |
|
| 3721 |
sdCreditRequirement.setUtilizedAmount(utilizationAmount);
|
3289 |
sdCreditRequirement.setUtilizedAmount(utilizationAmount);
|
| 3722 |
|
3290 |
|
| 3723 |
CreditAccount creditAccount = creditAccountRepository
|
- |
|
| 3724 |
.selectByFofoIdAndGateway(loan.getFofoId(), Gateway.SDDIRECT);
|
3291 |
CreditAccount creditAccount = creditAccountRepository.selectByFofoIdAndGateway(loan.getFofoId(), Gateway.SDDIRECT);
|
| 3725 |
|
3292 |
|
| 3726 |
creditAccount.setAvailableAmount(sdCreditRequirement.getAvailableLimit().floatValue());
|
3293 |
creditAccount.setAvailableAmount(sdCreditRequirement.getAvailableLimit().floatValue());
|
| 3727 |
creditAccount.setUpdatedOn(LocalDateTime.now());
|
3294 |
creditAccount.setUpdatedOn(LocalDateTime.now());
|
| 3728 |
|
3295 |
|
| 3729 |
loan.setPendingAmount(BigDecimal.ZERO);
|
3296 |
loan.setPendingAmount(BigDecimal.ZERO);
|
| 3730 |
|
3297 |
|
| 3731 |
} else if (principalAmount < 0) {
|
3298 |
} else if (principalAmount < 0) {
|
| 3732 |
|
3299 |
|
| 3733 |
settledLoanStatement(LoanReferenceType.PRINCIPAL, BigDecimal.valueOf(userWalletAmount),
|
3300 |
settledLoanStatement(LoanReferenceType.PRINCIPAL, BigDecimal.valueOf(userWalletAmount), loan.getFofoId(), loan.getId(), "Amount adjusted against loan", LocalDateTime.now());
|
| 3734 |
loan.getFofoId(), loan.getId(), "Amount adjusted against loan",
|
- |
|
| 3735 |
LocalDateTime.now());
|
- |
|
| 3736 |
|
3301 |
|
| 3737 |
paidAmount += Math.abs(userWalletAmount);
|
3302 |
paidAmount += Math.abs(userWalletAmount);
|
| 3738 |
|
3303 |
|
| 3739 |
BigDecimal availableLimit = sdCreditRequirement.getAvailableLimit()
|
3304 |
BigDecimal availableLimit = sdCreditRequirement.getAvailableLimit().add(BigDecimal.valueOf(userWalletAmount)).abs();
|
| 3740 |
.add(BigDecimal.valueOf(userWalletAmount)).abs();
|
- |
|
| 3741 |
|
3305 |
|
| 3742 |
BigDecimal utilizationAmount = sdCreditRequirement.getUtilizedAmount()
|
3306 |
BigDecimal utilizationAmount = sdCreditRequirement.getUtilizedAmount().subtract(BigDecimal.valueOf(userWalletAmount)).abs();
|
| 3743 |
.subtract(BigDecimal.valueOf(userWalletAmount)).abs();
|
- |
|
| 3744 |
|
3307 |
|
| 3745 |
sdCreditRequirement.setUtilizedAmount(utilizationAmount);
|
3308 |
sdCreditRequirement.setUtilizedAmount(utilizationAmount);
|
| 3746 |
|
3309 |
|
| 3747 |
CreditAccount creditAccount = creditAccountRepository
|
- |
|
| 3748 |
.selectByFofoIdAndGateway(loan.getFofoId(), Gateway.SDDIRECT);
|
3310 |
CreditAccount creditAccount = creditAccountRepository.selectByFofoIdAndGateway(loan.getFofoId(), Gateway.SDDIRECT);
|
| 3749 |
|
3311 |
|
| 3750 |
creditAccount.setAvailableAmount(sdCreditRequirement.getAvailableLimit().floatValue());
|
3312 |
creditAccount.setAvailableAmount(sdCreditRequirement.getAvailableLimit().floatValue());
|
| 3751 |
creditAccount.setUpdatedOn(LocalDateTime.now());
|
3313 |
creditAccount.setUpdatedOn(LocalDateTime.now());
|
| 3752 |
userWallet.setAmount(0);
|
3314 |
userWallet.setAmount(0);
|
| 3753 |
|
3315 |
|
| 3754 |
loan.setPendingAmount(
|
3316 |
loan.setPendingAmount(
|
| 3755 |
loan.getPendingAmount().subtract(BigDecimal.valueOf(userWalletAmount)));
|
3317 |
loan.getPendingAmount().subtract(BigDecimal.valueOf(userWalletAmount)));
|
| 3756 |
|
3318 |
|
| 3757 |
}
|
3319 |
}
|
| 3758 |
|
3320 |
|
| 3759 |
createUserWalletHistory(userWallet.getId(), userWallet.getUserId(),
|
- |
|
| 3760 |
WalletReferenceType.LOAN_REPAYMENT, loan.getId(), Math.abs(paidAmount));
|
3321 |
createUserWalletHistory(userWallet.getId(), userWallet.getUserId(), WalletReferenceType.LOAN_REPAYMENT, loan.getId(), Math.abs(paidAmount));
|
| 3761 |
|
3322 |
|
| 3762 |
} else {
|
3323 |
} else {
|
| 3763 |
|
3324 |
|
| 3764 |
settledLoanStatement(LoanReferenceType.INTEREST, BigDecimal.valueOf(userWallet.getAmount()),
|
3325 |
settledLoanStatement(LoanReferenceType.INTEREST, BigDecimal.valueOf(userWallet.getAmount()), loan.getFofoId(), loan.getId(), "Amount adjusted against loan", LocalDateTime.now());
|
| 3765 |
loan.getFofoId(), loan.getId(), "Amount adjusted against loan", LocalDateTime.now());
|
- |
|
| 3766 |
|
3326 |
|
| 3767 |
paidAmount += Math.abs(userWallet.getAmount());
|
3327 |
paidAmount += Math.abs(userWallet.getAmount());
|
| 3768 |
|
3328 |
|
| 3769 |
createUserWalletHistory(userWallet.getId(), userWallet.getUserId(),
|
- |
|
| 3770 |
WalletReferenceType.LOAN_REPAYMENT, loan.getId(), Math.abs(paidAmount));
|
3329 |
createUserWalletHistory(userWallet.getId(), userWallet.getUserId(), WalletReferenceType.LOAN_REPAYMENT, loan.getId(), Math.abs(paidAmount));
|
| 3771 |
|
3330 |
|
| 3772 |
loan.setInterestPaid(
|
3331 |
loan.setInterestPaid(
|
| 3773 |
loan.getInterestPaid().add(BigDecimal.valueOf(userWallet.getAmount()).abs()));
|
3332 |
loan.getInterestPaid().add(BigDecimal.valueOf(userWallet.getAmount()).abs()));
|
| 3774 |
|
3333 |
|
| 3775 |
userWallet.setAmount(0);
|
3334 |
userWallet.setAmount(0);
|
| Line 3781... |
Line 3340... |
| 3781 |
List<Order> allOrders = orderRepository.selectHoldOrder();
|
3340 |
List<Order> allOrders = orderRepository.selectHoldOrder();
|
| 3782 |
|
3341 |
|
| 3783 |
LOGGER.info("allOrders {}", allOrders);
|
3342 |
LOGGER.info("allOrders {}", allOrders);
|
| 3784 |
|
3343 |
|
| 3785 |
if (!allOrders.isEmpty()) {
|
3344 |
if (!allOrders.isEmpty()) {
|
| 3786 |
Map<Integer, List<Order>> transactionOrdersMap = allOrders.stream()
|
- |
|
| 3787 |
.collect(groupingBy(Order::getTransactionId, Collectors.toList()));
|
3345 |
Map<Integer, List<Order>> transactionOrdersMap = allOrders.stream().collect(groupingBy(Order::getTransactionId, Collectors.toList()));
|
| 3788 |
LinkedHashMap<Integer, List<Order>> sortedTransactionOrdersMap = new LinkedHashMap<>();
|
3346 |
LinkedHashMap<Integer, List<Order>> sortedTransactionOrdersMap = new LinkedHashMap<>();
|
| 3789 |
transactionOrdersMap.entrySet().stream().sorted(Map.Entry.comparingByKey())
|
- |
|
| 3790 |
.forEachOrdered(x -> sortedTransactionOrdersMap.put(x.getKey(), x.getValue()));
|
3347 |
transactionOrdersMap.entrySet().stream().sorted(Map.Entry.comparingByKey()).forEachOrdered(x -> sortedTransactionOrdersMap.put(x.getKey(), x.getValue()));
|
| 3791 |
LOGGER.info("sortedTransactionOrdersMap {}", sortedTransactionOrdersMap);
|
3348 |
LOGGER.info("sortedTransactionOrdersMap {}", sortedTransactionOrdersMap);
|
| 3792 |
|
3349 |
|
| 3793 |
for (Entry<Integer, List<Order>> transactionOrdersEntry : sortedTransactionOrdersMap.entrySet()) {
|
3350 |
for (Entry<Integer, List<Order>> transactionOrdersEntry : sortedTransactionOrdersMap.entrySet()) {
|
| 3794 |
|
3351 |
|
| 3795 |
List<Order> orders = transactionOrdersEntry.getValue();
|
3352 |
List<Order> orders = transactionOrdersEntry.getValue();
|
| Line 3802... |
Line 3359... |
| 3802 |
|
3359 |
|
| 3803 |
int transactionId = transactionOrdersEntry.getKey();
|
3360 |
int transactionId = transactionOrdersEntry.getKey();
|
| 3804 |
|
3361 |
|
| 3805 |
SanctionRequest sanctionRequest = sanctionRequestRepository.selectByTransactionId(transactionId);
|
3362 |
SanctionRequest sanctionRequest = sanctionRequestRepository.selectByTransactionId(transactionId);
|
| 3806 |
|
3363 |
|
| 3807 |
double loanSettleAmount = loanStatementRepository.selectByDateAndFofoId(createDate, fofoId).stream()
|
3364 |
double loanSettleAmount = loanStatementRepository.selectByDateAndFofoId(createDate, fofoId).stream().filter(x -> x.getAmount().doubleValue() > 0).collect(Collectors.summingDouble(x -> x.getAmount().doubleValue()));
|
| 3808 |
.filter(x -> x.getAmount().doubleValue() > 0)
|
- |
|
| 3809 |
.collect(Collectors.summingDouble(x -> x.getAmount().doubleValue()));
|
- |
|
| 3810 |
|
3365 |
|
| 3811 |
LOGGER.info("loanSettleAmount {}", loanSettleAmount);
|
3366 |
LOGGER.info("loanSettleAmount {}", loanSettleAmount);
|
| 3812 |
|
3367 |
|
| 3813 |
LOGGER.info("totalAmount {}", totalAmount);
|
3368 |
LOGGER.info("totalAmount {}", totalAmount);
|
| 3814 |
if (loanSettleAmount >= sanctionRequest.getUtilizationAmount().doubleValue()) {
|
3369 |
if (loanSettleAmount >= sanctionRequest.getUtilizationAmount().doubleValue()) {
|
| 3815 |
|
3370 |
|
| 3816 |
LOGGER.info("totalAmount {}", totalAmount);
|
3371 |
LOGGER.info("totalAmount {}", totalAmount);
|
| 3817 |
|
3372 |
|
| 3818 |
orders.forEach(x -> x.setShipmentHold(false));
|
3373 |
orders.forEach(x -> x.setShipmentHold(false));
|
| 3819 |
|
3374 |
|
| 3820 |
List<String> authUserEmail = csService.getAuthUserIdByPartnerId(orders.get(0).getRetailerId())
|
3375 |
List<String> authUserEmail = csService.getAuthUserIdByPartnerId(orders.get(0).getRetailerId()).stream().map(x -> x.getEmailId()).collect(Collectors.toList());
|
| 3821 |
.stream().map(x -> x.getEmailId()).collect(Collectors.toList());
|
- |
|
| 3822 |
authUserEmail.add("vinay.p@smartdukaan.com");
|
3376 |
authUserEmail.add("vinay.p@smartdukaan.com");
|
| 3823 |
authUserEmail.add("shivam.gupta@smartdukaan.com");
|
3377 |
authUserEmail.add("shivam.gupta@smartdukaan.com");
|
| 3824 |
|
3378 |
|
| 3825 |
String[] emailTo = authUserEmail.toArray(new String[authUserEmail.size()]);
|
3379 |
String[] emailTo = authUserEmail.toArray(new String[authUserEmail.size()]);
|
| 3826 |
|
3380 |
|
| 3827 |
String[] ccTo = {"tarun.verma@smartdukaan.com", "kamini.sharma@smartdukaan.com"};
|
3381 |
String[] ccTo = {"tarun.verma@smartdukaan.com", "kamini.sharma@smartdukaan.com"};
|
| 3828 |
|
3382 |
|
| 3829 |
String subject = "Dispatched " + (orders.get(0).getRetailerName());
|
3383 |
String subject = "Dispatched " + (orders.get(0).getRetailerName());
|
| 3830 |
String message = String.format("Dear Team, \n" + "kindly note the material for the "
|
- |
|
| 3831 |
+ orders.get(0).getRetailerName() + "of Rs." + totalAmount + "is dispatched.");
|
3384 |
String message = String.format("Dear Team, \n" + "kindly note the material for the " + orders.get(0).getRetailerName() + "of Rs." + totalAmount + "is dispatched.");
|
| 3832 |
|
3385 |
|
| 3833 |
Utils.sendMailWithAttachments(mailSender, emailTo, ccTo, subject, message);
|
3386 |
Utils.sendMailWithAttachments(mailSender, emailTo, ccTo, subject, message);
|
| 3834 |
|
3387 |
|
| 3835 |
}
|
3388 |
}
|
| 3836 |
|
3389 |
|
| Line 3839... |
Line 3392... |
| 3839 |
|
3392 |
|
| 3840 |
}
|
3393 |
}
|
| 3841 |
|
3394 |
|
| 3842 |
}
|
3395 |
}
|
| 3843 |
|
3396 |
|
| 3844 |
private void settledLoanStatement(LoanReferenceType loanReferneceType, BigDecimal amount, int fofoId, int loanId,
|
3397 |
private void settledLoanStatement(LoanReferenceType loanReferneceType, BigDecimal amount, int fofoId, int loanId, String description, LocalDateTime now) {
|
| 3845 |
String description, LocalDateTime now) {
|
- |
|
| 3846 |
|
3398 |
|
| 3847 |
sdCreditService.createLoanStatement(loanReferneceType, amount.abs(), fofoId, loanId, description,
|
3399 |
sdCreditService.createLoanStatement(loanReferneceType, amount.abs(), fofoId, loanId, description, LocalDateTime.now());
|
| 3848 |
LocalDateTime.now());
|
- |
|
| 3849 |
|
3400 |
|
| 3850 |
}
|
3401 |
}
|
| 3851 |
|
3402 |
|
| 3852 |
private void createUserWalletHistory(int walletId, int userId, WalletReferenceType referenceType, int loanId,
|
3403 |
private void createUserWalletHistory(int walletId, int userId, WalletReferenceType referenceType, int loanId, double interestAmount) {
|
| 3853 |
double interestAmount) {
|
- |
|
| 3854 |
UserWalletHistory uwh = new UserWalletHistory();
|
3404 |
UserWalletHistory uwh = new UserWalletHistory();
|
| 3855 |
uwh.setWalletId(walletId);
|
3405 |
uwh.setWalletId(walletId);
|
| 3856 |
uwh.setFofoId(userId);
|
3406 |
uwh.setFofoId(userId);
|
| 3857 |
uwh.setBusinessTimestamp(LocalDateTime.now());
|
3407 |
uwh.setBusinessTimestamp(LocalDateTime.now());
|
| 3858 |
uwh.setReferenceType(referenceType);
|
3408 |
uwh.setReferenceType(referenceType);
|
| Line 3862... |
Line 3412... |
| 3862 |
uwh.setDescription("Amount adjusted against loan");
|
3412 |
uwh.setDescription("Amount adjusted against loan");
|
| 3863 |
userWalletHistoryRepository.persist(uwh);
|
3413 |
userWalletHistoryRepository.persist(uwh);
|
| 3864 |
|
3414 |
|
| 3865 |
}
|
3415 |
}
|
| 3866 |
|
3416 |
|
| 3867 |
public void dailyLoanAlert()
|
- |
|
| 3868 |
throws ProfitMandiBusinessException, HttpHostConnectException, UnsupportedEncodingException {
|
3417 |
public void dailyLoanAlert() throws ProfitMandiBusinessException, HttpHostConnectException, UnsupportedEncodingException {
|
| 3869 |
List<Loan> loans = loanRepository.selectAllActiveLoan();
|
3418 |
List<Loan> loans = loanRepository.selectAllActiveLoan();
|
| 3870 |
|
3419 |
|
| 3871 |
Map<Integer, Double> partnerLoanAmount = new HashMap<>();
|
3420 |
Map<Integer, Double> partnerLoanAmount = new HashMap<>();
|
| 3872 |
|
3421 |
|
| 3873 |
if (!loans.isEmpty()) {
|
3422 |
if (!loans.isEmpty()) {
|
| 3874 |
|
3423 |
|
| 3875 |
for (Loan loan : loans) {
|
3424 |
for (Loan loan : loans) {
|
| 3876 |
|
3425 |
|
| 3877 |
List<LoanStatement> loanStatements = loanStatementRepository.selectByLoanId(loan.getId());
|
3426 |
List<LoanStatement> loanStatements = loanStatementRepository.selectByLoanId(loan.getId());
|
| 3878 |
|
3427 |
|
| 3879 |
double amount = loanStatements.stream().map(x -> x.getAmount())
|
3428 |
double amount = loanStatements.stream().map(x -> x.getAmount()).collect(Collectors.summingDouble(x -> x.doubleValue()));
|
| 3880 |
.collect(Collectors.summingDouble(x -> x.doubleValue()));
|
- |
|
| 3881 |
if (partnerLoanAmount.get(loan.getFofoId()) != null) {
|
3429 |
if (partnerLoanAmount.get(loan.getFofoId()) != null) {
|
| 3882 |
amount += partnerLoanAmount.get(loan.getFofoId());
|
3430 |
amount += partnerLoanAmount.get(loan.getFofoId());
|
| 3883 |
partnerLoanAmount.put(loan.getFofoId(), amount);
|
3431 |
partnerLoanAmount.put(loan.getFofoId(), amount);
|
| 3884 |
} else {
|
3432 |
} else {
|
| 3885 |
partnerLoanAmount.put(loan.getFofoId(), amount);
|
3433 |
partnerLoanAmount.put(loan.getFofoId(), amount);
|
| Line 3899... |
Line 3447... |
| 3899 |
|
3447 |
|
| 3900 |
Address address = addressRepository.selectById(user.getAddressId());
|
3448 |
Address address = addressRepository.selectById(user.getAddressId());
|
| 3901 |
|
3449 |
|
| 3902 |
String title = "Alert Credit Outstanding!";
|
3450 |
String title = "Alert Credit Outstanding!";
|
| 3903 |
String url = "http://app.smartdukaan.com/pages/home/credit";
|
3451 |
String url = "http://app.smartdukaan.com/pages/home/credit";
|
| 3904 |
String message = "Your total pending Loan amount is Rs."
|
- |
|
| 3905 |
+ FormattingUtils.formatDecimal(Math.abs(partnerLoanAmountEnrty.getValue())) + ".";
|
3452 |
String message = "Your total pending Loan amount is Rs." + FormattingUtils.formatDecimal(Math.abs(partnerLoanAmountEnrty.getValue())) + ".";
|
| 3906 |
notificationService.sendNotification(fofoId, title, MessageType.notification, title, message, url);
|
3453 |
notificationService.sendNotification(fofoId, title, MessageType.notification, title, message, url);
|
| 3907 |
|
3454 |
|
| 3908 |
notificationService.sendWhatsappMessage(message, title, address.getPhoneNumber());
|
3455 |
notificationService.sendWhatsappMessage(message, title, address.getPhoneNumber());
|
| 3909 |
|
3456 |
|
| 3910 |
}
|
3457 |
}
|
| Line 3918... |
Line 3465... |
| 3918 |
}
|
3465 |
}
|
| 3919 |
|
3466 |
|
| 3920 |
public void updatePartnerLimit() throws ProfitMandiBusinessException {
|
3467 |
public void updatePartnerLimit() throws ProfitMandiBusinessException {
|
| 3921 |
Map<Integer, CustomRetailer> customRetailerMap = retailerService.getFofoRetailers(true);
|
3468 |
Map<Integer, CustomRetailer> customRetailerMap = retailerService.getFofoRetailers(true);
|
| 3922 |
|
3469 |
|
| 3923 |
Map<Integer, SDCreditRequirement> sdCreditRequirementMap = sdCreditRequirementRepository.selectAll().stream()
|
3470 |
Map<Integer, SDCreditRequirement> sdCreditRequirementMap = sdCreditRequirementRepository.selectAll().stream().collect(Collectors.toMap(x -> x.getFofoId(), x -> x));
|
| 3924 |
.collect(Collectors.toMap(x -> x.getFofoId(), x -> x));
|
- |
|
| 3925 |
Map<Integer, CurrentPartnerDailyInvestment> currentPartnerDailyInvestmentMap = currentPartnerDailyInvestmentRepository
|
3471 |
Map<Integer, CurrentPartnerDailyInvestment> currentPartnerDailyInvestmentMap = currentPartnerDailyInvestmentRepository.selectAll().stream().collect(Collectors.toMap(x -> x.getFofoId(), x -> x));
|
| 3926 |
.selectAll().stream().collect(Collectors.toMap(x -> x.getFofoId(), x -> x));
|
- |
|
| 3927 |
double limitValue = 100000;
|
3472 |
double limitValue = 100000;
|
| 3928 |
for (Entry<Integer, CustomRetailer> customRetailerEntry : customRetailerMap.entrySet()) {
|
3473 |
for (Entry<Integer, CustomRetailer> customRetailerEntry : customRetailerMap.entrySet()) {
|
| 3929 |
int fofoId = customRetailerEntry.getKey();
|
3474 |
int fofoId = customRetailerEntry.getKey();
|
| 3930 |
SDCreditRequirement sdCreditRequirement = sdCreditRequirementMap.get(customRetailerEntry.getKey());
|
3475 |
SDCreditRequirement sdCreditRequirement = sdCreditRequirementMap.get(customRetailerEntry.getKey());
|
| 3931 |
LocalDateTime firstBillingDate = transactionRepository.getFirstBillingDate(fofoId);
|
3476 |
LocalDateTime firstBillingDate = transactionRepository.getFirstBillingDate(fofoId);
|
| Line 3977... |
Line 3522... |
| 3977 |
|
3522 |
|
| 3978 |
sdCreditRequirement.setUtilizedAmount(utilizedLimit);
|
3523 |
sdCreditRequirement.setUtilizedAmount(utilizedLimit);
|
| 3979 |
|
3524 |
|
| 3980 |
sdCreditRequirement.setUpdateTimestamp(LocalDateTime.now());
|
3525 |
sdCreditRequirement.setUpdateTimestamp(LocalDateTime.now());
|
| 3981 |
|
3526 |
|
| 3982 |
CreditAccount creditAccount = creditAccountRepository
|
- |
|
| 3983 |
.selectByFofoIdAndGateway(sdCreditRequirement.getFofoId(), Gateway.SDDIRECT);
|
3527 |
CreditAccount creditAccount = creditAccountRepository.selectByFofoIdAndGateway(sdCreditRequirement.getFofoId(), Gateway.SDDIRECT);
|
| 3984 |
if (creditAccount != null) {
|
3528 |
if (creditAccount != null) {
|
| 3985 |
|
3529 |
|
| 3986 |
creditAccount.setInterestRate(sdCreditRequirement.getInterestRate().floatValue());
|
3530 |
creditAccount.setInterestRate(sdCreditRequirement.getInterestRate().floatValue());
|
| 3987 |
creditAccount.setSanctionedAmount(sdCreditRequirement.getLimit().floatValue());
|
3531 |
creditAccount.setSanctionedAmount(sdCreditRequirement.getLimit().floatValue());
|
| 3988 |
creditAccount.setAvailableAmount(availableLimit.floatValue());
|
3532 |
creditAccount.setAvailableAmount(availableLimit.floatValue());
|
| Line 4002... |
Line 3546... |
| 4002 |
this.sendDefaultLoanAlert(defaultLoans);
|
3546 |
this.sendDefaultLoanAlert(defaultLoans);
|
| 4003 |
}
|
3547 |
}
|
| 4004 |
|
3548 |
|
| 4005 |
}
|
3549 |
}
|
| 4006 |
|
3550 |
|
| 4007 |
public void sendDefaultLoanAlert(List<Loan> defaultLoans)
|
- |
|
| 4008 |
throws ProfitMandiBusinessException, MessagingException, IOException {
|
3551 |
public void sendDefaultLoanAlert(List<Loan> defaultLoans) throws ProfitMandiBusinessException, MessagingException, IOException {
|
| 4009 |
String subject = "Default Partners";
|
3552 |
String subject = "Default Partners";
|
| 4010 |
|
3553 |
|
| 4011 |
List<Integer> categoryIds = Arrays.asList(ProfitMandiConstants.TICKET_CATEGORY_CATEGORY,
|
3554 |
List<Integer> categoryIds = Arrays.asList(ProfitMandiConstants.TICKET_CATEGORY_CATEGORY, ProfitMandiConstants.TICKET_CATEGORY_RBM, ProfitMandiConstants.TICKET_CATEGORY_SALES, ProfitMandiConstants.TICKET_CATEGORY_ACCOUNTS, ProfitMandiConstants.TICKET_CATEGORY_BUSINESSINTELLIGENT);
|
| 4012 |
ProfitMandiConstants.TICKET_CATEGORY_RBM, ProfitMandiConstants.TICKET_CATEGORY_SALES,
|
- |
|
| 4013 |
ProfitMandiConstants.TICKET_CATEGORY_ACCOUNTS,
|
- |
|
| 4014 |
ProfitMandiConstants.TICKET_CATEGORY_BUSINESSINTELLIGENT);
|
- |
|
| 4015 |
|
3555 |
|
| 4016 |
for (Map.Entry<String, Set<Integer>> storeGuyEntry : csService
|
- |
|
| 4017 |
.getAuthUserPartnerIdMappingByCategoryIds(categoryIds, false).entrySet()) {
|
3556 |
for (Map.Entry<String, Set<Integer>> storeGuyEntry : csService.getAuthUserPartnerIdMappingByCategoryIds(categoryIds, false).entrySet()) {
|
| 4018 |
List<Loan> filteredRows = new ArrayList<>();
|
3557 |
List<Loan> filteredRows = new ArrayList<>();
|
| 4019 |
for (Loan loan : defaultLoans) {
|
3558 |
for (Loan loan : defaultLoans) {
|
| 4020 |
|
3559 |
|
| 4021 |
if (storeGuyEntry.getValue().contains(loan.getFofoId())) {
|
3560 |
if (storeGuyEntry.getValue().contains(loan.getFofoId())) {
|
| 4022 |
|
3561 |
|
| Line 4034... |
Line 3573... |
| 4034 |
}
|
3573 |
}
|
| 4035 |
|
3574 |
|
| 4036 |
for (Loan defaultLoan : defaultLoans) {
|
3575 |
for (Loan defaultLoan : defaultLoans) {
|
| 4037 |
List<LoanStatement> loanStatements = loanStatementRepository.selectByLoanId(defaultLoan.getId());
|
3576 |
List<LoanStatement> loanStatements = loanStatementRepository.selectByLoanId(defaultLoan.getId());
|
| 4038 |
|
3577 |
|
| 4039 |
double amount = loanStatements.stream().map(x -> x.getAmount())
|
3578 |
double amount = loanStatements.stream().map(x -> x.getAmount()).collect(Collectors.summingDouble(x -> x.doubleValue()));
|
| 4040 |
.collect(Collectors.summingDouble(x -> x.doubleValue()));
|
- |
|
| 4041 |
|
3579 |
|
| 4042 |
com.spice.profitmandi.dao.entity.user.User user = userUserRepository.selectById(defaultLoan.getFofoId());
|
3580 |
com.spice.profitmandi.dao.entity.user.User user = userUserRepository.selectById(defaultLoan.getFofoId());
|
| 4043 |
|
3581 |
|
| 4044 |
Address address = addressRepository.selectById(user.getAddressId());
|
3582 |
Address address = addressRepository.selectById(user.getAddressId());
|
| 4045 |
|
3583 |
|
| 4046 |
String title = "Loan Amount Overdue!";
|
3584 |
String title = "Loan Amount Overdue!";
|
| 4047 |
String url = "http://app.smartdukaan.com/pages/home/credit";
|
3585 |
String url = "http://app.smartdukaan.com/pages/home/credit";
|
| 4048 |
String message = "Your loan due date "
|
- |
|
| 4049 |
+ defaultLoan.getDueDate().toLocalDate().format(DateTimeFormatter.ofPattern("dd-MM-yyyy"))
|
- |
|
| 4050 |
+ " has been exceeded. Additional penal interest of "
|
- |
|
| 4051 |
+ defaultLoan.getInterestRate().setScale(2, RoundingMode.HALF_UP)
|
- |
|
| 4052 |
+ "% and Rs.100 shall be levied on daily basis." + " Your total pending Loan amount is Rs."
|
3586 |
String message = "Your loan due date " + defaultLoan.getDueDate().toLocalDate().format(DateTimeFormatter.ofPattern("dd-MM-yyyy")) + " has been exceeded. Additional penal interest of " + defaultLoan.getInterestRate().setScale(2, RoundingMode.HALF_UP) + "% and Rs.100 shall be levied on daily basis." + " Your total pending Loan amount is Rs." + FormattingUtils.formatDecimal(Math.abs(amount)) + ". !!Pay Now!!";
|
| 4053 |
+ FormattingUtils.formatDecimal(Math.abs(amount)) + ". !!Pay Now!!";
|
- |
|
| 4054 |
notificationService.sendNotification(defaultLoan.getFofoId(), title, MessageType.notification, title,
|
3587 |
notificationService.sendNotification(defaultLoan.getFofoId(), title, MessageType.notification, title, message, url);
|
| 4055 |
message, url);
|
- |
|
| 4056 |
|
3588 |
|
| 4057 |
// notificationService.sendWhatsappMessage(message, title,
|
3589 |
// notificationService.sendWhatsappMessage(message, title,
|
| 4058 |
// address.getPhoneNumber());
|
3590 |
// address.getPhoneNumber());
|
| 4059 |
|
3591 |
|
| 4060 |
}
|
3592 |
}
|
| 4061 |
}
|
3593 |
}
|
| 4062 |
|
3594 |
|
| 4063 |
private String getMessageForDueDateExtend(List<Loan> loans) throws ProfitMandiBusinessException {
|
3595 |
private String getMessageForDueDateExtend(List<Loan> loans) throws ProfitMandiBusinessException {
|
| 4064 |
StringBuilder sb = new StringBuilder();
|
3596 |
StringBuilder sb = new StringBuilder();
|
| 4065 |
sb.append(
|
3597 |
sb.append(
|
| 4066 |
"<html><body><p>Alert</p><p>Default Partners :-</p>" + "<br/><p>EveryDay Rs.100 charged as Penalty</p>"
|
3598 |
"<html><body><p>Alert</p><p>Default Partners :-</p>" + "<br/><p>EveryDay Rs.100 charged as Penalty</p>" + "<br/><table style='border:1px solid black ;padding: 5px';>");
|
| 4067 |
+ "<br/><table style='border:1px solid black ;padding: 5px';>");
|
- |
|
| 4068 |
sb.append("<tbody>\n" + " <tr>\n"
|
- |
|
| 4069 |
+ " <th style='border:1px solid black;padding: 5px'>PartnerName</th>\n"
|
- |
|
| 4070 |
+ " <th style='border:1px solid black;padding: 5px'>due date</th>\n"
|
- |
|
| 4071 |
+ " <th style='border:1px solid black;padding: 5px'>Days</th>\n"
|
- |
|
| 4072 |
+ " <th style='border:1px solid black;padding: 5px'>Pending Amount</th>\n"
|
3599 |
sb.append("<tbody>\n" + " <tr>\n" + " <th style='border:1px solid black;padding: 5px'>PartnerName</th>\n" + " <th style='border:1px solid black;padding: 5px'>due date</th>\n" + " <th style='border:1px solid black;padding: 5px'>Days</th>\n" + " <th style='border:1px solid black;padding: 5px'>Pending Amount</th>\n"
|
| 4073 |
|
3600 |
|
| 4074 |
+ " </tr>");
|
3601 |
+ " </tr>");
|
| 4075 |
for (Loan entry : loans) {
|
3602 |
for (Loan entry : loans) {
|
| 4076 |
|
3603 |
|
| 4077 |
List<LoanStatement> loanStatements = loanStatementRepository.selectByLoanId(entry.getId());
|
3604 |
List<LoanStatement> loanStatements = loanStatementRepository.selectByLoanId(entry.getId());
|
| 4078 |
|
3605 |
|
| 4079 |
double amount = loanStatements.stream().map(x -> x.getAmount())
|
3606 |
double amount = loanStatements.stream().map(x -> x.getAmount()).collect(Collectors.summingDouble(x -> x.doubleValue()));
|
| 4080 |
.collect(Collectors.summingDouble(x -> x.doubleValue()));
|
- |
|
| 4081 |
|
3607 |
|
| 4082 |
long noOfdaysBetween = ChronoUnit.DAYS.between(entry.getDueDate().toLocalDate(), LocalDateTime.now());
|
3608 |
long noOfdaysBetween = ChronoUnit.DAYS.between(entry.getDueDate().toLocalDate(), LocalDateTime.now());
|
| 4083 |
|
3609 |
|
| 4084 |
CustomRetailer customRetailer = retailerService.getFofoRetailer(entry.getFofoId());
|
3610 |
CustomRetailer customRetailer = retailerService.getFofoRetailer(entry.getFofoId());
|
| 4085 |
|
3611 |
|
| 4086 |
sb.append("<tr>");
|
3612 |
sb.append("<tr>");
|
| 4087 |
sb.append("<td style='border:1px solid black;padding: 5px'>" + customRetailer.getBusinessName() + "("
|
3613 |
sb.append("<td style='border:1px solid black;padding: 5px'>" + customRetailer.getBusinessName() + "(" + customRetailer.getCode() + ")" + "</td>");
|
| 4088 |
+ customRetailer.getCode() + ")" + "</td>");
|
- |
|
| 4089 |
|
3614 |
|
| 4090 |
sb.append("<td style='border:1px solid black;padding: 5px'>"
|
- |
|
| 4091 |
+ entry.getDueDate().format(DateTimeFormatter.ofPattern("dd/MM/yyyy")) + "</td>");
|
3615 |
sb.append("<td style='border:1px solid black;padding: 5px'>" + entry.getDueDate().format(DateTimeFormatter.ofPattern("dd/MM/yyyy")) + "</td>");
|
| 4092 |
sb.append("<td style='border:1px solid black;padding: 5px'>" + noOfdaysBetween + "</td>");
|
3616 |
sb.append("<td style='border:1px solid black;padding: 5px'>" + noOfdaysBetween + "</td>");
|
| 4093 |
sb.append("<td style='border:1px solid black;padding: 5px'>"
|
- |
|
| 4094 |
+ new DecimalFormat("#.##").format(Math.abs(amount)) + "</td>");
|
3617 |
sb.append("<td style='border:1px solid black;padding: 5px'>" + new DecimalFormat("#.##").format(Math.abs(amount)) + "</td>");
|
| 4095 |
|
3618 |
|
| 4096 |
sb.append("</tr>");
|
3619 |
sb.append("</tr>");
|
| 4097 |
|
3620 |
|
| 4098 |
}
|
3621 |
}
|
| 4099 |
|
3622 |
|
| Line 4102... |
Line 3625... |
| 4102 |
return sb.toString();
|
3625 |
return sb.toString();
|
| 4103 |
}
|
3626 |
}
|
| 4104 |
|
3627 |
|
| 4105 |
private String getMessageForDueDateCross(List<Loan> loans) throws ProfitMandiBusinessException {
|
3628 |
private String getMessageForDueDateCross(List<Loan> loans) throws ProfitMandiBusinessException {
|
| 4106 |
StringBuilder sb = new StringBuilder();
|
3629 |
StringBuilder sb = new StringBuilder();
|
| 4107 |
sb.append("<html><body><p>Alert</p><p>Due Date Cross Partners :-</p>"
|
- |
|
| 4108 |
+ "<br/><p>Additional penal interest of shall be levied on daily basis.</p>"
|
3630 |
sb.append("<html><body><p>Alert</p><p>Due Date Cross Partners :-</p>" + "<br/><p>Additional penal interest of shall be levied on daily basis.</p>" + "<br/><table style='border:1px solid black ;padding: 5px';>");
|
| 4109 |
+ "<br/><table style='border:1px solid black ;padding: 5px';>");
|
- |
|
| 4110 |
sb.append("<tbody>\n" + " <tr>\n"
|
- |
|
| 4111 |
+ " <th style='border:1px solid black;padding: 5px'>PartnerName</th>\n"
|
- |
|
| 4112 |
+ " <th style='border:1px solid black;padding: 5px'>due date</th>\n"
|
- |
|
| 4113 |
+ " <th style='border:1px solid black;padding: 5px'>Days</th>\n"
|
- |
|
| 4114 |
+ " <th style='border:1px solid black;padding: 5px'>Pending Amount</th>\n"
|
3631 |
sb.append("<tbody>\n" + " <tr>\n" + " <th style='border:1px solid black;padding: 5px'>PartnerName</th>\n" + " <th style='border:1px solid black;padding: 5px'>due date</th>\n" + " <th style='border:1px solid black;padding: 5px'>Days</th>\n" + " <th style='border:1px solid black;padding: 5px'>Pending Amount</th>\n"
|
| 4115 |
|
3632 |
|
| 4116 |
+ " </tr>");
|
3633 |
+ " </tr>");
|
| 4117 |
for (Loan entry : loans) {
|
3634 |
for (Loan entry : loans) {
|
| 4118 |
|
3635 |
|
| 4119 |
List<LoanStatement> loanStatements = loanStatementRepository.selectByLoanId(entry.getId());
|
3636 |
List<LoanStatement> loanStatements = loanStatementRepository.selectByLoanId(entry.getId());
|
| 4120 |
|
3637 |
|
| 4121 |
double amount = loanStatements.stream().map(x -> x.getAmount())
|
3638 |
double amount = loanStatements.stream().map(x -> x.getAmount()).collect(Collectors.summingDouble(x -> x.doubleValue()));
|
| 4122 |
.collect(Collectors.summingDouble(x -> x.doubleValue()));
|
- |
|
| 4123 |
|
3639 |
|
| 4124 |
long noOfdaysBetween = ChronoUnit.DAYS.between(entry.getDueDate().toLocalDate(), LocalDateTime.now());
|
3640 |
long noOfdaysBetween = ChronoUnit.DAYS.between(entry.getDueDate().toLocalDate(), LocalDateTime.now());
|
| 4125 |
|
3641 |
|
| 4126 |
CustomRetailer customRetailer = retailerService.getFofoRetailer(entry.getFofoId());
|
3642 |
CustomRetailer customRetailer = retailerService.getFofoRetailer(entry.getFofoId());
|
| 4127 |
|
3643 |
|
| 4128 |
sb.append("<tr>");
|
3644 |
sb.append("<tr>");
|
| 4129 |
sb.append("<td style='border:1px solid black;padding: 5px'>" + customRetailer.getBusinessName() + "("
|
3645 |
sb.append("<td style='border:1px solid black;padding: 5px'>" + customRetailer.getBusinessName() + "(" + customRetailer.getCode() + ")" + "</td>");
|
| 4130 |
+ customRetailer.getCode() + ")" + "</td>");
|
- |
|
| 4131 |
|
3646 |
|
| 4132 |
sb.append("<td style='border:1px solid black;padding: 5px'>"
|
- |
|
| 4133 |
+ entry.getDueDate().format(DateTimeFormatter.ofPattern("dd/MM/yyyy")) + "</td>");
|
3647 |
sb.append("<td style='border:1px solid black;padding: 5px'>" + entry.getDueDate().format(DateTimeFormatter.ofPattern("dd/MM/yyyy")) + "</td>");
|
| 4134 |
sb.append("<td style='border:1px solid black;padding: 5px'>" + noOfdaysBetween + "</td>");
|
3648 |
sb.append("<td style='border:1px solid black;padding: 5px'>" + noOfdaysBetween + "</td>");
|
| 4135 |
sb.append("<td style='border:1px solid black;padding: 5px'>"
|
- |
|
| 4136 |
+ new DecimalFormat("#.##").format(Math.abs(amount)) + "</td>");
|
3649 |
sb.append("<td style='border:1px solid black;padding: 5px'>" + new DecimalFormat("#.##").format(Math.abs(amount)) + "</td>");
|
| 4137 |
|
3650 |
|
| 4138 |
sb.append("</tr>");
|
3651 |
sb.append("</tr>");
|
| 4139 |
|
3652 |
|
| 4140 |
}
|
3653 |
}
|
| 4141 |
|
3654 |
|
| Line 4151... |
Line 3664... |
| 4151 |
this.sendDueDateCrossLoanAlert(dueDateCrossLoans);
|
3664 |
this.sendDueDateCrossLoanAlert(dueDateCrossLoans);
|
| 4152 |
}
|
3665 |
}
|
| 4153 |
|
3666 |
|
| 4154 |
}
|
3667 |
}
|
| 4155 |
|
3668 |
|
| 4156 |
private void sendDueDateCrossLoanAlert(List<Loan> dueDateCrossLoans)
|
- |
|
| 4157 |
throws ProfitMandiBusinessException, MessagingException, IOException {
|
3669 |
private void sendDueDateCrossLoanAlert(List<Loan> dueDateCrossLoans) throws ProfitMandiBusinessException, MessagingException, IOException {
|
| 4158 |
List<Integer> categoryIds = Arrays.asList(ProfitMandiConstants.TICKET_CATEGORY_CATEGORY,
|
3670 |
List<Integer> categoryIds = Arrays.asList(ProfitMandiConstants.TICKET_CATEGORY_CATEGORY, ProfitMandiConstants.TICKET_CATEGORY_RBM, ProfitMandiConstants.TICKET_CATEGORY_SALES, ProfitMandiConstants.TICKET_CATEGORY_ACCOUNTS, ProfitMandiConstants.TICKET_CATEGORY_BUSINESSINTELLIGENT);
|
| 4159 |
ProfitMandiConstants.TICKET_CATEGORY_RBM, ProfitMandiConstants.TICKET_CATEGORY_SALES,
|
- |
|
| 4160 |
ProfitMandiConstants.TICKET_CATEGORY_ACCOUNTS,
|
- |
|
| 4161 |
ProfitMandiConstants.TICKET_CATEGORY_BUSINESSINTELLIGENT);
|
- |
|
| 4162 |
|
3671 |
|
| 4163 |
for (Map.Entry<String, Set<Integer>> storeGuyEntry : csService
|
- |
|
| 4164 |
.getAuthUserPartnerIdMappingByCategoryIds(categoryIds, false).entrySet()) {
|
3672 |
for (Map.Entry<String, Set<Integer>> storeGuyEntry : csService.getAuthUserPartnerIdMappingByCategoryIds(categoryIds, false).entrySet()) {
|
| 4165 |
List<Loan> filteredRows = new ArrayList<>();
|
3673 |
List<Loan> filteredRows = new ArrayList<>();
|
| 4166 |
for (Loan loan : dueDateCrossLoans) {
|
3674 |
for (Loan loan : dueDateCrossLoans) {
|
| 4167 |
|
3675 |
|
| 4168 |
if (storeGuyEntry.getValue().contains(loan.getFofoId())) {
|
3676 |
if (storeGuyEntry.getValue().contains(loan.getFofoId())) {
|
| 4169 |
|
3677 |
|
| Line 4190... |
Line 3698... |
| 4190 |
|
3698 |
|
| 4191 |
LOGGER.info("noOfdaysBetween {} ", noOfdaysBetween);
|
3699 |
LOGGER.info("noOfdaysBetween {} ", noOfdaysBetween);
|
| 4192 |
|
3700 |
|
| 4193 |
List<LoanStatement> loanStatements = loanStatementRepository.selectByLoanId(loan.getId());
|
3701 |
List<LoanStatement> loanStatements = loanStatementRepository.selectByLoanId(loan.getId());
|
| 4194 |
|
3702 |
|
| 4195 |
double amount = loanStatements.stream().map(x -> x.getAmount())
|
3703 |
double amount = loanStatements.stream().map(x -> x.getAmount()).collect(Collectors.summingDouble(x -> x.doubleValue()));
|
| 4196 |
.collect(Collectors.summingDouble(x -> x.doubleValue()));
|
- |
|
| 4197 |
|
3704 |
|
| 4198 |
String url = "http://app.smartdukaan.com/pages/home/credit";
|
3705 |
String url = "http://app.smartdukaan.com/pages/home/credit";
|
| 4199 |
|
3706 |
|
| 4200 |
String title = "Alert!";
|
3707 |
String title = "Alert!";
|
| 4201 |
String message = "Your loan due date "
|
- |
|
| 4202 |
+ loan.getDueDate().toLocalDate().format(DateTimeFormatter.ofPattern("dd-MM-yyyy"))
|
- |
|
| 4203 |
+ " has been exceeded. Additional penal interest of "
|
- |
|
| 4204 |
+ loan.getInterestRate().setScale(2, RoundingMode.HALF_UP)
|
- |
|
| 4205 |
+ "% shall be levied on daily basis. Your total pending loan amount is Rs."
|
3708 |
String message = "Your loan due date " + loan.getDueDate().toLocalDate().format(DateTimeFormatter.ofPattern("dd-MM-yyyy")) + " has been exceeded. Additional penal interest of " + loan.getInterestRate().setScale(2, RoundingMode.HALF_UP) + "% shall be levied on daily basis. Your total pending loan amount is Rs." + FormattingUtils.formatDecimal(Math.abs(amount)) + ". !!Pay Now!!";
|
| 4206 |
+ FormattingUtils.formatDecimal(Math.abs(amount)) + ". !!Pay Now!!";
|
- |
|
| 4207 |
|
3709 |
|
| 4208 |
notificationService.sendNotification(loan.getFofoId(), title, MessageType.notification, title, message,
|
3710 |
notificationService.sendNotification(loan.getFofoId(), title, MessageType.notification, title, message, url);
|
| 4209 |
url);
|
- |
|
| 4210 |
|
3711 |
|
| 4211 |
notificationService.sendWhatsappMessage(message, title, address.getPhoneNumber());
|
3712 |
notificationService.sendWhatsappMessage(message, title, address.getPhoneNumber());
|
| 4212 |
|
3713 |
|
| 4213 |
}
|
3714 |
}
|
| 4214 |
}
|
3715 |
}
|
| Line 4230... |
Line 3731... |
| 4230 |
|
3731 |
|
| 4231 |
LOGGER.info("noOfdaysBetween {} ", noOfdaysBetween);
|
3732 |
LOGGER.info("noOfdaysBetween {} ", noOfdaysBetween);
|
| 4232 |
|
3733 |
|
| 4233 |
if (noOfdaysBetween <= 4 && noOfdaysBetween >= 0) {
|
3734 |
if (noOfdaysBetween <= 4 && noOfdaysBetween >= 0) {
|
| 4234 |
List<LoanStatement> loanStatements = loanStatementRepository.selectByLoanId(loan.getId());
|
3735 |
List<LoanStatement> loanStatements = loanStatementRepository.selectByLoanId(loan.getId());
|
| 4235 |
double amount = loanStatements.stream().map(x -> x.getAmount())
|
3736 |
double amount = loanStatements.stream().map(x -> x.getAmount()).collect(Collectors.summingDouble(x -> x.doubleValue()));
|
| 4236 |
.collect(Collectors.summingDouble(x -> x.doubleValue()));
|
- |
|
| 4237 |
|
3737 |
|
| 4238 |
String title = "Alert!";
|
3738 |
String title = "Alert!";
|
| 4239 |
String url = "http://app.smartdukaan.com/pages/home/credit";
|
3739 |
String url = "http://app.smartdukaan.com/pages/home/credit";
|
| 4240 |
String message = null;
|
3740 |
String message = null;
|
| 4241 |
if (noOfdaysBetween == 0) {
|
3741 |
if (noOfdaysBetween == 0) {
|
| 4242 |
|
3742 |
|
| 4243 |
message = "Your total pending Loan amount is Rs."
|
- |
|
| 4244 |
+ FormattingUtils.formatDecimal(Math.abs(amount)) + " is due for Today, Pay Now!!";
|
3743 |
message = "Your total pending Loan amount is Rs." + FormattingUtils.formatDecimal(Math.abs(amount)) + " is due for Today, Pay Now!!";
|
| 4245 |
|
3744 |
|
| 4246 |
} else {
|
3745 |
} else {
|
| 4247 |
|
3746 |
|
| 4248 |
message = "Your total pending Loan amount is Rs."
|
- |
|
| 4249 |
+ FormattingUtils.formatDecimal(Math.abs(amount)) + " is due by "
|
- |
|
| 4250 |
+ loan.getDueDate().toLocalDate().format(DateTimeFormatter.ofPattern("dd-MM-yyyy"))
|
3747 |
message = "Your total pending Loan amount is Rs." + FormattingUtils.formatDecimal(Math.abs(amount)) + " is due by " + loan.getDueDate().toLocalDate().format(DateTimeFormatter.ofPattern("dd-MM-yyyy")) + " , Pay Now!!";
|
| 4251 |
+ " , Pay Now!!";
|
- |
|
| 4252 |
|
3748 |
|
| 4253 |
}
|
3749 |
}
|
| 4254 |
notificationService.sendNotification(loan.getFofoId(), title, MessageType.notification, title,
|
3750 |
notificationService.sendNotification(loan.getFofoId(), title, MessageType.notification, title, message, url);
|
| 4255 |
message, url);
|
- |
|
| 4256 |
notificationService.sendWhatsappMessage(message, title, address.getPhoneNumber());
|
3751 |
notificationService.sendWhatsappMessage(message, title, address.getPhoneNumber());
|
| 4257 |
|
3752 |
|
| 4258 |
}
|
3753 |
}
|
| 4259 |
}
|
3754 |
}
|
| 4260 |
}
|
3755 |
}
|
| Line 4263... |
Line 3758... |
| 4263 |
|
3758 |
|
| 4264 |
public void userMobileNumberOptIn() throws HttpHostConnectException, ProfitMandiBusinessException {
|
3759 |
public void userMobileNumberOptIn() throws HttpHostConnectException, ProfitMandiBusinessException {
|
| 4265 |
|
3760 |
|
| 4266 |
List<FofoStore> fofoStores = fofoStoreRepository.selectActiveStores();
|
3761 |
List<FofoStore> fofoStores = fofoStoreRepository.selectActiveStores();
|
| 4267 |
|
3762 |
|
| 4268 |
List<com.spice.profitmandi.dao.entity.user.User> users = userUserRepository
|
- |
|
| 4269 |
.selectByIds(fofoStores.stream().map(x -> x.getId()).collect(Collectors.toList()));
|
3763 |
List<com.spice.profitmandi.dao.entity.user.User> users = userUserRepository.selectByIds(fofoStores.stream().map(x -> x.getId()).collect(Collectors.toList()));
|
| 4270 |
|
3764 |
|
| 4271 |
List<Address> addresses = addressRepository
|
- |
|
| 4272 |
.selectByIds(users.stream().map(x -> x.getAddressId()).collect(Collectors.toList()));
|
3765 |
List<Address> addresses = addressRepository.selectByIds(users.stream().map(x -> x.getAddressId()).collect(Collectors.toList()));
|
| 4273 |
|
3766 |
|
| 4274 |
LOGGER.info("addresses" + addresses);
|
3767 |
LOGGER.info("addresses" + addresses);
|
| 4275 |
|
3768 |
|
| 4276 |
for (Address address : addresses) {
|
3769 |
for (Address address : addresses) {
|
| 4277 |
Map<String, String> requestheaders = new HashMap<>();
|
3770 |
Map<String, String> requestheaders = new HashMap<>();
|
| Line 4285... |
Line 3778... |
| 4285 |
requestParams.put("format", "json");
|
3778 |
requestParams.put("format", "json");
|
| 4286 |
|
3779 |
|
| 4287 |
requestParams.put("method", "OPT_IN");
|
3780 |
requestParams.put("method", "OPT_IN");
|
| 4288 |
|
3781 |
|
| 4289 |
requestParams.put("channel", "WHATSAPP");
|
3782 |
requestParams.put("channel", "WHATSAPP");
|
| 4290 |
String response = restClient.get("https://media.smsgupshup.com/GatewayAPI/rest", requestParams,
|
3783 |
String response = restClient.get("https://media.smsgupshup.com/GatewayAPI/rest", requestParams, requestheaders);
|
| 4291 |
requestheaders);
|
- |
|
| 4292 |
LOGGER.info("response" + response);
|
3784 |
LOGGER.info("response" + response);
|
| 4293 |
}
|
3785 |
}
|
| 4294 |
|
3786 |
|
| 4295 |
}
|
3787 |
}
|
| 4296 |
|
3788 |
|
| Line 4311... |
Line 3803... |
| 4311 |
requestParams.put("format", "json");
|
3803 |
requestParams.put("format", "json");
|
| 4312 |
|
3804 |
|
| 4313 |
requestParams.put("method", "OPT_IN");
|
3805 |
requestParams.put("method", "OPT_IN");
|
| 4314 |
|
3806 |
|
| 4315 |
requestParams.put("channel", "WHATSAPP");
|
3807 |
requestParams.put("channel", "WHATSAPP");
|
| 4316 |
String response = restClient.get("https://media.smsgupshup.com/GatewayAPI/rest", requestParams,
|
3808 |
String response = restClient.get("https://media.smsgupshup.com/GatewayAPI/rest", requestParams, requestheaders);
|
| 4317 |
requestheaders);
|
- |
|
| 4318 |
LOGGER.info("response" + response);
|
3809 |
LOGGER.info("response" + response);
|
| 4319 |
}
|
3810 |
}
|
| 4320 |
|
3811 |
|
| 4321 |
}
|
3812 |
}
|
| 4322 |
|
3813 |
|
| Line 4327... |
Line 3818... |
| 4327 |
|
3818 |
|
| 4328 |
List<String> remarks = new ArrayList<>();
|
3819 |
List<String> remarks = new ArrayList<>();
|
| 4329 |
remarks.add("Out of Service");
|
3820 |
remarks.add("Out of Service");
|
| 4330 |
remarks.add("Duplicate number");
|
3821 |
remarks.add("Duplicate number");
|
| 4331 |
remarks.add("Partner number");
|
3822 |
remarks.add("Partner number");
|
| 4332 |
List<HygieneData> hygieneData = hygieneDataRepository.selectAllByDisposedDateAndRemark(LocalDate.now(),
|
3823 |
List<HygieneData> hygieneData = hygieneDataRepository.selectAllByDisposedDateAndRemark(LocalDate.now(), remarks);
|
| 4333 |
remarks);
|
- |
|
| 4334 |
|
3824 |
|
| 4335 |
if (!hygieneData.isEmpty()) {
|
3825 |
if (!hygieneData.isEmpty()) {
|
| 4336 |
|
3826 |
|
| 4337 |
Map<Integer, List<HygieneData>> partnerHygieneDataMap = hygieneData.stream()
|
3827 |
Map<Integer, List<HygieneData>> partnerHygieneDataMap = hygieneData.stream().collect(groupingBy(x -> x.getFofoId()));
|
| 4338 |
.collect(groupingBy(x -> x.getFofoId()));
|
- |
|
| 4339 |
|
3828 |
|
| 4340 |
for (Entry<Integer, List<HygieneData>> partnerHygieneDataMapEntry : partnerHygieneDataMap.entrySet()) {
|
3829 |
for (Entry<Integer, List<HygieneData>> partnerHygieneDataMapEntry : partnerHygieneDataMap.entrySet()) {
|
| 4341 |
|
3830 |
|
| 4342 |
CustomRetailer customRetailer = retailerService.getFofoRetailer(partnerHygieneDataMapEntry.getKey());
|
3831 |
CustomRetailer customRetailer = retailerService.getFofoRetailer(partnerHygieneDataMapEntry.getKey());
|
| 4343 |
|
3832 |
|
| 4344 |
StringBuilder sb = new StringBuilder();
|
3833 |
StringBuilder sb = new StringBuilder();
|
| 4345 |
sb.append("<html><body><p>Dear Partner,"
|
- |
|
| 4346 |
+ "</p><br/><p>It has been observed in our calls to the respective customers that the contact no is either not correct or does not have incoming calls.\n"
|
3834 |
sb.append("<html><body><p>Dear Partner," + "</p><br/><p>It has been observed in our calls to the respective customers that the contact no is either not correct or does not have incoming calls.\n"
|
| 4347 |
|
3835 |
|
| 4348 |
+ " </p>"
|
- |
|
| 4349 |
+ "<p>We would like to inform you that this will hinder all our marketing initiatives to bring this customer back to our smartdukaan or cross sell any product from your inventory."
|
3836 |
+ " </p>" + "<p>We would like to inform you that this will hinder all our marketing initiatives to bring this customer back to our smartdukaan or cross sell any product from your inventory." + "</p><p>Kindly ensure going forward that the details are correct so to avoid 1% margin loss.\n" + "</p><p>In case the data is found to be incorrect there is a loss of 1% margin on this sales under SmartDukaan hygiene guidelines.\n" + " " + "</p>"
|
| 4350 |
+ "</p><p>Kindly ensure going forward that the details are correct so to avoid 1% margin loss.\n"
|
- |
|
| 4351 |
+ "</p><p>In case the data is found to be incorrect there is a loss of 1% margin on this sales under SmartDukaan hygiene guidelines.\n"
|
- |
|
| 4352 |
+ " " + "</p>"
|
- |
|
| 4353 |
|
3837 |
|
| 4354 |
+ "<br/><table style='border:1px solid black ;padding: 5px';>");
|
3838 |
+ "<br/><table style='border:1px solid black ;padding: 5px';>");
|
| 4355 |
sb.append("<tbody>\n" + " " + " " + "<tr>\n");
|
3839 |
sb.append("<tbody>\n" + " " + " " + "<tr>\n");
|
| 4356 |
sb.append("<th style='border:1px solid black;padding: 5px'>Invoice Number</th>\n");
|
3840 |
sb.append("<th style='border:1px solid black;padding: 5px'>Invoice Number</th>\n");
|
| 4357 |
sb.append("<th style='border:1px solid black;padding: 5px'>Customer Name</th>\n");
|
3841 |
sb.append("<th style='border:1px solid black;padding: 5px'>Customer Name</th>\n");
|
| Line 4365... |
Line 3849... |
| 4365 |
List<FofoOrder> fofoOrders = fofoOrderRepository.selectAllByOrderIds(orderIds);
|
3849 |
List<FofoOrder> fofoOrders = fofoOrderRepository.selectAllByOrderIds(orderIds);
|
| 4366 |
|
3850 |
|
| 4367 |
for (FofoOrder fofoOrder : fofoOrders) {
|
3851 |
for (FofoOrder fofoOrder : fofoOrders) {
|
| 4368 |
Customer customer = customerRepository.selectById(fofoOrder.getCustomerId());
|
3852 |
Customer customer = customerRepository.selectById(fofoOrder.getCustomerId());
|
| 4369 |
sb.append("<tr>");
|
3853 |
sb.append("<tr>");
|
| 4370 |
sb.append("<td style='border:1px solid black;padding: 5px'>" + fofoOrder.getInvoiceNumber()
|
3854 |
sb.append("<td style='border:1px solid black;padding: 5px'>" + fofoOrder.getInvoiceNumber() + "</td>\n");
|
| 4371 |
+ "</td>\n");
|
- |
|
| 4372 |
sb.append("<td style='border:1px solid black;padding: 5px'>" + customer.getFirstName() + ""
|
3855 |
sb.append("<td style='border:1px solid black;padding: 5px'>" + customer.getFirstName() + "" + customer.getLastName() + "</td>\n");
|
| 4373 |
+ customer.getLastName() + "</td>\n");
|
- |
|
| 4374 |
sb.append("<td style='border:1px solid black;padding: 5px'>" + customer.getMobileNumber()
|
3856 |
sb.append("<td style='border:1px solid black;padding: 5px'>" + customer.getMobileNumber() + "</td>\n");
|
| 4375 |
+ "</td>\n");
|
- |
|
| 4376 |
|
3857 |
|
| 4377 |
sb.append("</tr>\n");
|
3858 |
sb.append("</tr>\n");
|
| 4378 |
}
|
3859 |
}
|
| 4379 |
|
3860 |
|
| 4380 |
sb.append("</tbody></table></body></html>");
|
3861 |
sb.append("</tbody></table></body></html>");
|
| Line 4392... |
Line 3873... |
| 4392 |
|
3873 |
|
| 4393 |
List<String> remarks = new ArrayList<>();
|
3874 |
List<String> remarks = new ArrayList<>();
|
| 4394 |
remarks.add("Out of Service");
|
3875 |
remarks.add("Out of Service");
|
| 4395 |
remarks.add("Duplicate number");
|
3876 |
remarks.add("Duplicate number");
|
| 4396 |
remarks.add("Partner number");
|
3877 |
remarks.add("Partner number");
|
| 4397 |
List<HygieneData> hygieneDataLastThreeMonth = hygieneDataRepository
|
3878 |
List<HygieneData> hygieneDataLastThreeMonth = hygieneDataRepository.selectDisposedDateAndRemarks(
|
| 4398 |
.selectDisposedDateAndRemarks(
|
- |
|
| 4399 |
LocalDate.now().withDayOfMonth(1).minusMonths(3).atStartOfDay(), LocalDate.now().minusMonths(1)
|
3879 |
LocalDate.now().withDayOfMonth(1).minusMonths(3).atStartOfDay(), LocalDate.now().minusMonths(1).withDayOfMonth(LocalDate.now().minusMonths(1).lengthOfMonth()).atTime(LocalTime.MAX), remarks);
|
| 4400 |
.withDayOfMonth(LocalDate.now().minusMonths(1).lengthOfMonth()).atTime(LocalTime.MAX),
|
- |
|
| 4401 |
remarks);
|
- |
|
| 4402 |
|
3880 |
|
| 4403 |
List<HygieneData> hygieneDataRecentMonth = hygieneDataRepository
|
- |
|
| 4404 |
.selectDisposedDateAndRemarks(LocalDate.now().withDayOfMonth(1), remarks);
|
3881 |
List<HygieneData> hygieneDataRecentMonth = hygieneDataRepository.selectDisposedDateAndRemarks(LocalDate.now().withDayOfMonth(1), remarks);
|
| 4405 |
Map<String, Set<Integer>> storeGuyMap = csService.getAuthUserPartnerIdMapping();
|
3882 |
Map<String, Set<Integer>> storeGuyMap = csService.getAuthUserPartnerIdMapping();
|
| 4406 |
Map<Integer, List<HygieneData>> partnerHygieneLastThreeMonthMap = null;
|
3883 |
Map<Integer, List<HygieneData>> partnerHygieneLastThreeMonthMap = null;
|
| 4407 |
|
3884 |
|
| 4408 |
Map<Integer, List<HygieneData>> partnerHygieneDataRecentMonth = null;
|
3885 |
Map<Integer, List<HygieneData>> partnerHygieneDataRecentMonth = null;
|
| 4409 |
|
3886 |
|
| 4410 |
if (!hygieneDataLastThreeMonth.isEmpty()) {
|
3887 |
if (!hygieneDataLastThreeMonth.isEmpty()) {
|
| 4411 |
partnerHygieneLastThreeMonthMap = hygieneDataLastThreeMonth.stream()
|
3888 |
partnerHygieneLastThreeMonthMap = hygieneDataLastThreeMonth.stream().collect(groupingBy(x -> x.getFofoId()));
|
| 4412 |
.collect(groupingBy(x -> x.getFofoId()));
|
- |
|
| 4413 |
|
3889 |
|
| 4414 |
}
|
3890 |
}
|
| 4415 |
|
3891 |
|
| 4416 |
if (!hygieneDataRecentMonth.isEmpty()) {
|
3892 |
if (!hygieneDataRecentMonth.isEmpty()) {
|
| 4417 |
partnerHygieneDataRecentMonth = hygieneDataRecentMonth.stream()
|
3893 |
partnerHygieneDataRecentMonth = hygieneDataRecentMonth.stream().collect(groupingBy(x -> x.getFofoId()));
|
| 4418 |
.collect(groupingBy(x -> x.getFofoId()));
|
- |
|
| 4419 |
}
|
3894 |
}
|
| 4420 |
|
3895 |
|
| 4421 |
for (Entry<String, Set<Integer>> storeGuyEntry : storeGuyMap.entrySet()) {
|
3896 |
for (Entry<String, Set<Integer>> storeGuyEntry : storeGuyMap.entrySet()) {
|
| 4422 |
|
3897 |
|
| 4423 |
String email = storeGuyEntry.getKey();
|
3898 |
String email = storeGuyEntry.getKey();
|
| Line 4432... |
Line 3907... |
| 4432 |
partnerDateWiseData.put(fofoId, null);
|
3907 |
partnerDateWiseData.put(fofoId, null);
|
| 4433 |
if (!partnerHygieneLastThreeMonthMap.isEmpty()) {
|
3908 |
if (!partnerHygieneLastThreeMonthMap.isEmpty()) {
|
| 4434 |
List<HygieneData> hygienes = partnerHygieneLastThreeMonthMap.get(fofoId);
|
3909 |
List<HygieneData> hygienes = partnerHygieneLastThreeMonthMap.get(fofoId);
|
| 4435 |
|
3910 |
|
| 4436 |
if (hygienes != null) {
|
3911 |
if (hygienes != null) {
|
| 4437 |
Map<YearMonth, List<HygieneData>> yearMonthData = hygienes.stream()
|
- |
|
| 4438 |
.collect(groupingBy(x -> YearMonth.from(x.getDisposedTimestamp())));
|
3912 |
Map<YearMonth, List<HygieneData>> yearMonthData = hygienes.stream().collect(groupingBy(x -> YearMonth.from(x.getDisposedTimestamp())));
|
| 4439 |
|
3913 |
|
| 4440 |
partnerYearMonthData.put(fofoId, yearMonthData);
|
3914 |
partnerYearMonthData.put(fofoId, yearMonthData);
|
| 4441 |
|
3915 |
|
| 4442 |
}
|
3916 |
}
|
| 4443 |
List<HygieneData> dateWiseHygienes = partnerHygieneDataRecentMonth.get(fofoId);
|
3917 |
List<HygieneData> dateWiseHygienes = partnerHygieneDataRecentMonth.get(fofoId);
|
| 4444 |
|
3918 |
|
| 4445 |
if (dateWiseHygienes != null) {
|
3919 |
if (dateWiseHygienes != null) {
|
| 4446 |
|
3920 |
|
| 4447 |
Map<LocalDate, List<HygieneData>> dateWiseData = hygienes.stream()
|
- |
|
| 4448 |
.collect(groupingBy(x -> (x.getDisposedTimestamp()).toLocalDate()));
|
3921 |
Map<LocalDate, List<HygieneData>> dateWiseData = hygienes.stream().collect(groupingBy(x -> (x.getDisposedTimestamp()).toLocalDate()));
|
| 4449 |
|
3922 |
|
| 4450 |
partnerDateWiseData.put(fofoId, dateWiseData);
|
3923 |
partnerDateWiseData.put(fofoId, dateWiseData);
|
| 4451 |
|
3924 |
|
| 4452 |
}
|
3925 |
}
|
| 4453 |
|
3926 |
|
| Line 4471... |
Line 3944... |
| 4471 |
}
|
3944 |
}
|
| 4472 |
|
3945 |
|
| 4473 |
}
|
3946 |
}
|
| 4474 |
|
3947 |
|
| 4475 |
private String getMessageHygieneAlertForPartner(
|
3948 |
private String getMessageHygieneAlertForPartner(
|
| 4476 |
Map<Integer, Map<YearMonth, List<HygieneData>>> partnerYearMonthData,
|
- |
|
| 4477 |
Map<Integer, Map<LocalDate, List<HygieneData>>> partnerDateWiseData) {
|
3949 |
Map<Integer, Map<YearMonth, List<HygieneData>>> partnerYearMonthData, Map<Integer, Map<LocalDate, List<HygieneData>>> partnerDateWiseData) {
|
| 4478 |
|
3950 |
|
| 4479 |
Map<Integer, CustomRetailer> customeRetailerMap = retailerService.getAllFofoRetailers();
|
3951 |
Map<Integer, CustomRetailer> customeRetailerMap = retailerService.getAllFofoRetailers();
|
| 4480 |
|
3952 |
|
| 4481 |
LocalDateTime startDate = LocalDate.now().withDayOfMonth(1).atStartOfDay();
|
3953 |
LocalDateTime startDate = LocalDate.now().withDayOfMonth(1).atStartOfDay();
|
| 4482 |
LocalDateTime endDate = LocalDateTime.now();
|
3954 |
LocalDateTime endDate = LocalDateTime.now();
|
| 4483 |
|
3955 |
|
| 4484 |
LocalDateTime startYearMonth = LocalDate.now().withDayOfMonth(1).minusMonths(3).atStartOfDay();
|
3956 |
LocalDateTime startYearMonth = LocalDate.now().withDayOfMonth(1).minusMonths(3).atStartOfDay();
|
| 4485 |
LocalDateTime endYearMonth = LocalDate.now().minusMonths(1)
|
- |
|
| 4486 |
.withDayOfMonth(LocalDate.now().minusMonths(1).lengthOfMonth()).atTime(LocalTime.MAX);
|
3957 |
LocalDateTime endYearMonth = LocalDate.now().minusMonths(1).withDayOfMonth(LocalDate.now().minusMonths(1).lengthOfMonth()).atTime(LocalTime.MAX);
|
| 4487 |
|
3958 |
|
| 4488 |
DateTimeFormatter dateYearMonthFormatter = DateTimeFormatter.ofPattern("MMM''uu");
|
3959 |
DateTimeFormatter dateYearMonthFormatter = DateTimeFormatter.ofPattern("MMM''uu");
|
| 4489 |
|
3960 |
|
| 4490 |
List<YearMonth> yearMonthRange = new ArrayList<>();
|
3961 |
List<YearMonth> yearMonthRange = new ArrayList<>();
|
| 4491 |
yearMonthRange.add(YearMonth.from(startYearMonth));
|
3962 |
yearMonthRange.add(YearMonth.from(startYearMonth));
|
| Line 4494... |
Line 3965... |
| 4494 |
|
3965 |
|
| 4495 |
yearMonthRange.add(YearMonth.from(endYearMonth));
|
3966 |
yearMonthRange.add(YearMonth.from(endYearMonth));
|
| 4496 |
|
3967 |
|
| 4497 |
long noOfDaysBetween = ChronoUnit.DAYS.between(startDate, endDate.plusDays(1));
|
3968 |
long noOfDaysBetween = ChronoUnit.DAYS.between(startDate, endDate.plusDays(1));
|
| 4498 |
|
3969 |
|
| 4499 |
List<LocalDate> dateRange = Stream.iterate(startDate.toLocalDate(), date -> date.plusDays(1))
|
3970 |
List<LocalDate> dateRange = Stream.iterate(startDate.toLocalDate(), date -> date.plusDays(1)).limit(noOfDaysBetween).collect(Collectors.toList());
|
| 4500 |
.limit(noOfDaysBetween).collect(Collectors.toList());
|
- |
|
| 4501 |
|
3971 |
|
| 4502 |
StringBuilder sb = new StringBuilder();
|
3972 |
StringBuilder sb = new StringBuilder();
|
| 4503 |
sb.append("<html><body><p>Hi,"
|
- |
|
| 4504 |
+ "</p><br/><p>Kindly advise below mentioned partner to input correct details in the system else this will hinder all our marketing initiatives to bring this customer back to our smartdukaan or cross sell any product from partner's inventory.\n"
|
3973 |
sb.append("<html><body><p>Hi," + "</p><br/><p>Kindly advise below mentioned partner to input correct details in the system else this will hinder all our marketing initiatives to bring this customer back to our smartdukaan or cross sell any product from partner's inventory.\n" + " </p>" + "<p>Kindly ensure going forward that the details are correct so to avoid 1% margin loss.\n" + "</p><p>In case the data is found to be incorrect there is a loss of 1% margin on this sales under SmartDukaan hygiene guidelines.\n</p>"
|
| 4505 |
+ " </p>" + "<p>Kindly ensure going forward that the details are correct so to avoid 1% margin loss.\n"
|
- |
|
| 4506 |
+ "</p><p>In case the data is found to be incorrect there is a loss of 1% margin on this sales under SmartDukaan hygiene guidelines.\n</p>"
|
- |
|
| 4507 |
|
3974 |
|
| 4508 |
+ "<table style='border:1px solid black ;padding: 5px';>");
|
3975 |
+ "<table style='border:1px solid black ;padding: 5px';>");
|
| 4509 |
sb.append("<tbody>\n" + " " + " " + "<tr>\n");
|
3976 |
sb.append("<tbody>\n" + " " + " " + "<tr>\n");
|
| 4510 |
sb.append("<th style='border:1px solid black;padding: 5px'>Partner Name</th>\n");
|
3977 |
sb.append("<th style='border:1px solid black;padding: 5px'>Partner Name</th>\n");
|
| 4511 |
|
3978 |
|
| 4512 |
for (YearMonth yearMonth : yearMonthRange) {
|
3979 |
for (YearMonth yearMonth : yearMonthRange) {
|
| 4513 |
sb.append("<th style='border:1px solid black;padding: 5px'>" + yearMonth.format(dateYearMonthFormatter)
|
3980 |
sb.append("<th style='border:1px solid black;padding: 5px'>" + yearMonth.format(dateYearMonthFormatter) + "</th>\n");
|
| 4514 |
+ "</th>\n");
|
- |
|
| 4515 |
}
|
3981 |
}
|
| 4516 |
|
3982 |
|
| 4517 |
for (LocalDate localDate : dateRange) {
|
3983 |
for (LocalDate localDate : dateRange) {
|
| 4518 |
sb.append("<th style='border:1px solid black;padding: 5px'>" + localDate + "</th>\n");
|
3984 |
sb.append("<th style='border:1px solid black;padding: 5px'>" + localDate + "</th>\n");
|
| 4519 |
}
|
3985 |
}
|
| 4520 |
|
3986 |
|
| 4521 |
sb.append("</tr>\n");
|
3987 |
sb.append("</tr>\n");
|
| 4522 |
|
3988 |
|
| 4523 |
for (Entry<Integer, Map<YearMonth, List<HygieneData>>> partnerYearMonthEntry : partnerYearMonthData
|
3989 |
for (Entry<Integer, Map<YearMonth, List<HygieneData>>> partnerYearMonthEntry : partnerYearMonthData.entrySet()) {
|
| 4524 |
.entrySet()) {
|
- |
|
| 4525 |
|
3990 |
|
| 4526 |
int fofoId = partnerYearMonthEntry.getKey();
|
3991 |
int fofoId = partnerYearMonthEntry.getKey();
|
| 4527 |
|
3992 |
|
| 4528 |
Map<YearMonth, List<HygieneData>> yearMonthData = partnerYearMonthEntry.getValue();
|
3993 |
Map<YearMonth, List<HygieneData>> yearMonthData = partnerYearMonthEntry.getValue();
|
| 4529 |
|
3994 |
|
| Line 4532... |
Line 3997... |
| 4532 |
if (yearMonthData == null && dateWiseData == null) {
|
3997 |
if (yearMonthData == null && dateWiseData == null) {
|
| 4533 |
continue;
|
3998 |
continue;
|
| 4534 |
}
|
3999 |
}
|
| 4535 |
|
4000 |
|
| 4536 |
sb.append("<tr>");
|
4001 |
sb.append("<tr>");
|
| 4537 |
sb.append("<td style='border:1px solid black;padding: 5px'>"
|
- |
|
| 4538 |
+ customeRetailerMap.get(fofoId).getBusinessName() + "</td>\n");
|
4002 |
sb.append("<td style='border:1px solid black;padding: 5px'>" + customeRetailerMap.get(fofoId).getBusinessName() + "</td>\n");
|
| 4539 |
for (YearMonth yearMonth : yearMonthRange) {
|
4003 |
for (YearMonth yearMonth : yearMonthRange) {
|
| 4540 |
|
4004 |
|
| 4541 |
if (yearMonthData == null) {
|
4005 |
if (yearMonthData == null) {
|
| 4542 |
sb.append("<td style='border:1px solid black;padding: 5px'>-</td>\n");
|
4006 |
sb.append("<td style='border:1px solid black;padding: 5px'>-</td>\n");
|
| 4543 |
|
4007 |
|
| Line 4586... |
Line 4050... |
| 4586 |
public void monthlyTargetForPartner() throws MessagingException, ProfitMandiBusinessException, IOException {
|
4050 |
public void monthlyTargetForPartner() throws MessagingException, ProfitMandiBusinessException, IOException {
|
| 4587 |
|
4051 |
|
| 4588 |
LocalDateTime curDate = LocalDateTime.now();
|
4052 |
LocalDateTime curDate = LocalDateTime.now();
|
| 4589 |
List<MonthlyTarget> monthlyTargets = monthlyTargetRepository.selectByDate(YearMonth.now());
|
4053 |
List<MonthlyTarget> monthlyTargets = monthlyTargetRepository.selectByDate(YearMonth.now());
|
| 4590 |
|
4054 |
|
| 4591 |
Map<Integer, MonthlyTarget> partnersMonthlyTarget = monthlyTargets.stream()
|
4055 |
Map<Integer, MonthlyTarget> partnersMonthlyTarget = monthlyTargets.stream().collect(Collectors.toMap(x -> x.getFofoId(), x -> x));
|
| 4592 |
.collect(Collectors.toMap(x -> x.getFofoId(), x -> x));
|
- |
|
| 4593 |
|
4056 |
|
| 4594 |
Map<Integer, Double> secondaryMtd = orderRepository
|
- |
|
| 4595 |
.selectBillingDatesBetweenSumGroupByRetailerId(curDate.withDayOfMonth(1), curDate.with(LocalTime.MAX));
|
4057 |
Map<Integer, Double> secondaryMtd = orderRepository.selectBillingDatesBetweenSumGroupByRetailerId(curDate.withDayOfMonth(1), curDate.with(LocalTime.MAX));
|
| 4596 |
Map<Integer, Double> todaytertiary = fofoOrderItemRepository.selectSumMopGroupByRetailer(curDate,
|
4058 |
Map<Integer, Double> todaytertiary = fofoOrderItemRepository.selectSumMopGroupByRetailer(curDate, curDate.with(LocalTime.MAX), 0, false);
|
| 4597 |
curDate.with(LocalTime.MAX), 0, false);
|
- |
|
| 4598 |
|
4059 |
|
| 4599 |
String subject = "Monthly Target Vs Achievement";
|
4060 |
String subject = "Monthly Target Vs Achievement";
|
| 4600 |
|
4061 |
|
| 4601 |
for (Entry<Integer, MonthlyTarget> partnerMonthlyTargetEntry : partnersMonthlyTarget.entrySet()) {
|
4062 |
for (Entry<Integer, MonthlyTarget> partnerMonthlyTargetEntry : partnersMonthlyTarget.entrySet()) {
|
| 4602 |
|
4063 |
|
| Line 4621... |
Line 4082... |
| 4621 |
balanceTarget = 0.0;
|
4082 |
balanceTarget = 0.0;
|
| 4622 |
}
|
4083 |
}
|
| 4623 |
|
4084 |
|
| 4624 |
StringBuilder sb = new StringBuilder();
|
4085 |
StringBuilder sb = new StringBuilder();
|
| 4625 |
sb.append("<html><body><p>Dear Partner,\n");
|
4086 |
sb.append("<html><body><p>Dear Partner,\n");
|
| 4626 |
sb.append("<p>Pls note your agreed monthly target is Rs." + purchaseTarget
|
4087 |
sb.append("<p>Pls note your agreed monthly target is Rs." + purchaseTarget + " and your achievement till date is Rs." + purchase + "</p>");
|
| 4627 |
+ " and your achievement till date is Rs." + purchase + "</p>");
|
- |
|
| 4628 |
sb.append("<p>Pls note that your balance target is Rs." + balanceTarget + "</p>\n");
|
4088 |
sb.append("<p>Pls note that your balance target is Rs." + balanceTarget + "</p>\n");
|
| 4629 |
sb.append(
|
4089 |
sb.append(
|
| 4630 |
"<p>We wish you all the best and we are confident that this focussed approach towards our outlet sales will help us take our outlet to the best SmartDukaan in your city.\n"
|
4090 |
"<p>We wish you all the best and we are confident that this focussed approach towards our outlet sales will help us take our outlet to the best SmartDukaan in your city.\n" + "</p>\n");
|
| 4631 |
+ "</p>\n");
|
- |
|
| 4632 |
|
4091 |
|
| 4633 |
this.sendMailOfHtmlFormat(customRetailer.getEmail(), sb.toString(), null, subject);
|
4092 |
this.sendMailOfHtmlFormat(customRetailer.getEmail(), sb.toString(), null, subject);
|
| 4634 |
|
4093 |
|
| 4635 |
// this.sendMailOfHtmlFormat("tejbeer.kaur@smartdukaan.com", sb.toString(),
|
4094 |
// this.sendMailOfHtmlFormat("tejbeer.kaur@smartdukaan.com", sb.toString(),
|
| 4636 |
// null, subject);
|
4095 |
// null, subject);
|
| Line 4643... |
Line 4102... |
| 4643 |
|
4102 |
|
| 4644 |
public void monthlyTargetForInternalTeam() throws MessagingException, ProfitMandiBusinessException, IOException {
|
4103 |
public void monthlyTargetForInternalTeam() throws MessagingException, ProfitMandiBusinessException, IOException {
|
| 4645 |
|
4104 |
|
| 4646 |
LocalDateTime curDate = LocalDateTime.now();
|
4105 |
LocalDateTime curDate = LocalDateTime.now();
|
| 4647 |
|
4106 |
|
| 4648 |
List<Integer> categoryIds = Arrays.asList(ProfitMandiConstants.TICKET_CATEGORY_CATEGORY,
|
4107 |
List<Integer> categoryIds = Arrays.asList(ProfitMandiConstants.TICKET_CATEGORY_CATEGORY, ProfitMandiConstants.TICKET_CATEGORY_RBM, ProfitMandiConstants.TICKET_CATEGORY_SALES, ProfitMandiConstants.TICKET_CATEGORY_MARKETING, ProfitMandiConstants.TICKET_CATEGORY_ACCOUNTS, ProfitMandiConstants.TICKET_CATEGORY_BUSINESSINTELLIGENT);
|
| 4649 |
ProfitMandiConstants.TICKET_CATEGORY_RBM, ProfitMandiConstants.TICKET_CATEGORY_SALES,
|
- |
|
| 4650 |
ProfitMandiConstants.TICKET_CATEGORY_MARKETING, ProfitMandiConstants.TICKET_CATEGORY_ACCOUNTS,
|
- |
|
| 4651 |
ProfitMandiConstants.TICKET_CATEGORY_BUSINESSINTELLIGENT);
|
- |
|
| 4652 |
|
4108 |
|
| 4653 |
Map<String, Set<Integer>> storeGuyMap = csService.getAuthUserPartnerIdMappingByCategoryIds(categoryIds, false);
|
4109 |
Map<String, Set<Integer>> storeGuyMap = csService.getAuthUserPartnerIdMappingByCategoryIds(categoryIds, false);
|
| 4654 |
|
4110 |
|
| 4655 |
List<MonthlyTarget> monthlyTargets = monthlyTargetRepository.selectByDate(YearMonth.now());
|
4111 |
List<MonthlyTarget> monthlyTargets = monthlyTargetRepository.selectByDate(YearMonth.now());
|
| 4656 |
|
4112 |
|
| 4657 |
Map<Integer, CustomRetailer> customeRetailerMap = retailerService.getAllFofoRetailers();
|
4113 |
Map<Integer, CustomRetailer> customeRetailerMap = retailerService.getAllFofoRetailers();
|
| 4658 |
|
4114 |
|
| 4659 |
Map<Integer, MonthlyTarget> partnersMonthlyTarget = monthlyTargets.stream()
|
4115 |
Map<Integer, MonthlyTarget> partnersMonthlyTarget = monthlyTargets.stream().collect(Collectors.toMap(x -> x.getFofoId(), x -> x));
|
| 4660 |
.collect(Collectors.toMap(x -> x.getFofoId(), x -> x));
|
- |
|
| 4661 |
|
4116 |
|
| 4662 |
Map<Integer, Double> secondaryMtd = orderRepository
|
- |
|
| 4663 |
.selectBillingDatesBetweenSumGroupByRetailerId(curDate.withDayOfMonth(1), curDate.with(LocalTime.MAX));
|
4117 |
Map<Integer, Double> secondaryMtd = orderRepository.selectBillingDatesBetweenSumGroupByRetailerId(curDate.withDayOfMonth(1), curDate.with(LocalTime.MAX));
|
| 4664 |
Map<Integer, Double> todaytertiary = fofoOrderItemRepository.selectSumMopGroupByRetailer(curDate,
|
4118 |
Map<Integer, Double> todaytertiary = fofoOrderItemRepository.selectSumMopGroupByRetailer(curDate, curDate.with(LocalTime.MAX), 0, false);
|
| 4665 |
curDate.with(LocalTime.MAX), 0, false);
|
- |
|
| 4666 |
|
4119 |
|
| 4667 |
String subject = "Monthly Target Vs Achievement";
|
4120 |
String subject = "Monthly Target Vs Achievement";
|
| 4668 |
|
4121 |
|
| 4669 |
for (Entry<String, Set<Integer>> storeGuyEntry : storeGuyMap.entrySet()) {
|
4122 |
for (Entry<String, Set<Integer>> storeGuyEntry : storeGuyMap.entrySet()) {
|
| 4670 |
|
4123 |
|
| Line 4695... |
Line 4148... |
| 4695 |
if (!monthlyTargetAchievement.isEmpty()) {
|
4148 |
if (!monthlyTargetAchievement.isEmpty()) {
|
| 4696 |
|
4149 |
|
| 4697 |
StringBuilder sb = new StringBuilder();
|
4150 |
StringBuilder sb = new StringBuilder();
|
| 4698 |
|
4151 |
|
| 4699 |
sb.append("<html><body><p>Hi,\n");
|
4152 |
sb.append("<html><body><p>Hi,\n");
|
| 4700 |
sb.append("<p>Pls note your Partners agreed monthly target foolowing are :</p>\n"
|
4153 |
sb.append("<p>Pls note your Partners agreed monthly target foolowing are :</p>\n" + " <table style='border:1px solid black ;padding: 5px';>");
|
| 4701 |
+ " <table style='border:1px solid black ;padding: 5px';>");
|
- |
|
| 4702 |
sb.append("<tbody>\n" + " " + " " + "<tr>\n");
|
4154 |
sb.append("<tbody>\n" + " " + " " + "<tr>\n");
|
| 4703 |
sb.append("<th style='border:1px solid black;padding: 5px'>Partner Name</th>\n");
|
4155 |
sb.append("<th style='border:1px solid black;padding: 5px'>Partner Name</th>\n");
|
| 4704 |
|
4156 |
|
| 4705 |
sb.append("<th style='border:1px solid black;padding: 5px'>Purchase Target</th>\n");
|
4157 |
sb.append("<th style='border:1px solid black;padding: 5px'>Purchase Target</th>\n");
|
| 4706 |
|
4158 |
|
| 4707 |
sb.append("<th style='border:1px solid black;padding: 5px'>Purchase Achievement</th>\n");
|
4159 |
sb.append("<th style='border:1px solid black;padding: 5px'>Purchase Achievement</th>\n");
|
| 4708 |
sb.append("</tr>\n");
|
4160 |
sb.append("</tr>\n");
|
| 4709 |
|
4161 |
|
| 4710 |
for (Entry<Integer, MonthlyTarget> monthlyTargetAchievementEntry : monthlyTargetAchievement
|
4162 |
for (Entry<Integer, MonthlyTarget> monthlyTargetAchievementEntry : monthlyTargetAchievement.entrySet()) {
|
| 4711 |
.entrySet()) {
|
- |
|
| 4712 |
sb.append("<tr>");
|
4163 |
sb.append("<tr>");
|
| 4713 |
int fofoId = monthlyTargetAchievementEntry.getKey();
|
4164 |
int fofoId = monthlyTargetAchievementEntry.getKey();
|
| 4714 |
|
4165 |
|
| 4715 |
MonthlyTarget monthlyTarget = monthlyTargetAchievementEntry.getValue();
|
4166 |
MonthlyTarget monthlyTarget = monthlyTargetAchievementEntry.getValue();
|
| 4716 |
sb.append("<td style='border:1px solid black;padding: 5px'>"
|
- |
|
| 4717 |
+ customeRetailerMap.get(fofoId).getBusinessName() + "</td>\n");
|
4167 |
sb.append("<td style='border:1px solid black;padding: 5px'>" + customeRetailerMap.get(fofoId).getBusinessName() + "</td>\n");
|
| 4718 |
|
4168 |
|
| 4719 |
sb.append("<td style='border:1px solid black;padding: 5px'>" + monthlyTarget.getPurchaseTarget()
|
4169 |
sb.append("<td style='border:1px solid black;padding: 5px'>" + monthlyTarget.getPurchaseTarget() + "</td>\n");
|
| 4720 |
+ "</td>\n");
|
- |
|
| 4721 |
|
4170 |
|
| 4722 |
sb.append("<td style='border:1px solid black;padding: 5px'>"
|
4171 |
sb.append("<td style='border:1px solid black;padding: 5px'>" + monthlyTarget.getPurchaseAchievement() + "</td>\n");
|
| 4723 |
+ monthlyTarget.getPurchaseAchievement() + "</td>\n");
|
- |
|
| 4724 |
|
4172 |
|
| 4725 |
sb.append("</tr>\n");
|
4173 |
sb.append("</tr>\n");
|
| 4726 |
|
4174 |
|
| 4727 |
}
|
4175 |
}
|
| 4728 |
|
4176 |
|