| Line 48... |
Line 48... |
| 48 |
import com.spice.profitmandi.dao.enumuration.transaction.CreditRisk;
|
48 |
import com.spice.profitmandi.dao.enumuration.transaction.CreditRisk;
|
| 49 |
import com.spice.profitmandi.dao.enumuration.transaction.LoanReferenceType;
|
49 |
import com.spice.profitmandi.dao.enumuration.transaction.LoanReferenceType;
|
| 50 |
import com.spice.profitmandi.dao.enumuration.transaction.PriceDropImeiStatus;
|
50 |
import com.spice.profitmandi.dao.enumuration.transaction.PriceDropImeiStatus;
|
| 51 |
import com.spice.profitmandi.dao.enumuration.transaction.SchemePayoutStatus;
|
51 |
import com.spice.profitmandi.dao.enumuration.transaction.SchemePayoutStatus;
|
| 52 |
import com.spice.profitmandi.dao.model.*;
|
52 |
import com.spice.profitmandi.dao.model.*;
|
| - |
|
53 |
import com.spice.profitmandi.dao.repository.GenericRepository;
|
| 53 |
import com.spice.profitmandi.dao.repository.auth.AuthRepository;
|
54 |
import com.spice.profitmandi.dao.repository.auth.AuthRepository;
|
| 54 |
import com.spice.profitmandi.dao.repository.auth.NonSdBuyingRepository;
|
55 |
import com.spice.profitmandi.dao.repository.auth.NonSdBuyingRepository;
|
| 55 |
import com.spice.profitmandi.dao.repository.auth.PartnerCollectionRemarkRepository;
|
56 |
import com.spice.profitmandi.dao.repository.auth.PartnerCollectionRemarkRepository;
|
| 56 |
import com.spice.profitmandi.dao.repository.catalog.*;
|
57 |
import com.spice.profitmandi.dao.repository.catalog.*;
|
| 57 |
import com.spice.profitmandi.dao.repository.cs.CsService;
|
58 |
import com.spice.profitmandi.dao.repository.cs.CsService;
|
| Line 77... |
Line 78... |
| 77 |
import com.spice.profitmandi.service.integrations.smartping.SmartPingService;
|
78 |
import com.spice.profitmandi.service.integrations.smartping.SmartPingService;
|
| 78 |
import com.spice.profitmandi.service.integrations.toffee.ToffeeService;
|
79 |
import com.spice.profitmandi.service.integrations.toffee.ToffeeService;
|
| 79 |
import com.spice.profitmandi.service.inventory.*;
|
80 |
import com.spice.profitmandi.service.inventory.*;
|
| 80 |
import com.spice.profitmandi.service.offers.OfferService;
|
81 |
import com.spice.profitmandi.service.offers.OfferService;
|
| 81 |
import com.spice.profitmandi.service.order.OrderService;
|
82 |
import com.spice.profitmandi.service.order.OrderService;
|
| - |
|
83 |
import com.spice.profitmandi.service.pricecircular.PriceCircularService;
|
| 82 |
import com.spice.profitmandi.service.pricing.PriceDropService;
|
84 |
import com.spice.profitmandi.service.pricing.PriceDropService;
|
| 83 |
import com.spice.profitmandi.service.recharge.provider.OxigenRechargeProviderService;
|
85 |
import com.spice.profitmandi.service.recharge.provider.OxigenRechargeProviderService;
|
| 84 |
import com.spice.profitmandi.service.recharge.provider.ThinkWalnutDigitalRechargeProviderService;
|
86 |
import com.spice.profitmandi.service.recharge.provider.ThinkWalnutDigitalRechargeProviderService;
|
| - |
|
87 |
import com.spice.profitmandi.service.scheme.InventoryPayoutModel;
|
| 85 |
import com.spice.profitmandi.service.scheme.SchemeService;
|
88 |
import com.spice.profitmandi.service.scheme.SchemeService;
|
| 86 |
import com.spice.profitmandi.service.serviceConfig.ServiceConfigService;
|
89 |
import com.spice.profitmandi.service.serviceConfig.ServiceConfigService;
|
| 87 |
import com.spice.profitmandi.service.transaction.CreditNoteService;
|
90 |
import com.spice.profitmandi.service.transaction.CreditNoteService;
|
| 88 |
import com.spice.profitmandi.service.transaction.SDCreditService;
|
91 |
import com.spice.profitmandi.service.transaction.SDCreditService;
|
| 89 |
import com.spice.profitmandi.service.transaction.TransactionService;
|
92 |
import com.spice.profitmandi.service.transaction.TransactionService;
|
| Line 606... |
Line 609... |
| 606 |
}
|
609 |
}
|
| 607 |
|
610 |
|
| 608 |
@Autowired
|
611 |
@Autowired
|
| 609 |
private ReporticoCacheTableRepository reporticoCacheTableRepository;
|
612 |
private ReporticoCacheTableRepository reporticoCacheTableRepository;
|
| 610 |
|
613 |
|
| 611 |
public void processScheme(int offset, boolean dryRun) throws Exception {
|
- |
|
| 612 |
LocalDateTime startDate = LocalDateTime.of(LocalDate.now(), LocalTime.MIDNIGHT).minusDays(offset);
|
- |
|
| 613 |
LocalDateTime endDate = startDate.plusDays(30);
|
- |
|
| 614 |
processScheme(startDate, endDate, dryRun);
|
- |
|
| 615 |
}
|
- |
|
| 616 |
|
- |
|
| 617 |
public void processSchemeOut(List<String> invoiceNumbers) throws Exception {
|
614 |
public void processSchemeOut(List<String> invoiceNumbers) throws Exception {
|
| 618 |
for (String invoiceNumber : invoiceNumbers) {
|
615 |
for (String invoiceNumber : invoiceNumbers) {
|
| 619 |
System.out.println("Invoice Number - " + invoiceNumber);
|
616 |
System.out.println("Invoice Number - " + invoiceNumber);
|
| 620 |
FofoOrder fofoOrder = fofoOrderRepository.selectByInvoiceNumber(invoiceNumber);
|
617 |
FofoOrder fofoOrder = fofoOrderRepository.selectByInvoiceNumber(invoiceNumber);
|
| 621 |
//orderService.reverseScheme(fofoOrder);
|
618 |
//orderService.reverseScheme(fofoOrder);
|
| Line 629... |
Line 626... |
| 629 |
Purchase purchase = purchaseRepository.selectByPurchaseReference(invoiceNumber);
|
626 |
Purchase purchase = purchaseRepository.selectByPurchaseReference(invoiceNumber);
|
| 630 |
schemeService.processSchemeIn(purchase.getId(), purchase.getFofoId());
|
627 |
schemeService.processSchemeIn(purchase.getId(), purchase.getFofoId());
|
| 631 |
}
|
628 |
}
|
| 632 |
}
|
629 |
}
|
| 633 |
|
630 |
|
| 634 |
public void processScheme(int offset, int durationDays, boolean dryRun) throws Exception {
|
- |
|
| 635 |
LocalDateTime startDate = LocalDateTime.of(LocalDate.now(), LocalTime.MIDNIGHT).minusDays(offset);
|
- |
|
| 636 |
LocalDateTime endDate = startDate.plusDays(durationDays);
|
- |
|
| 637 |
processScheme(startDate, endDate, dryRun);
|
- |
|
| 638 |
}
|
- |
|
| 639 |
|
- |
|
| 640 |
public void processScheme(boolean dryRun) throws Exception {
|
- |
|
| 641 |
LocalDateTime fromDate = LocalDateTime.now().minusDays(30);
|
- |
|
| 642 |
processScheme(fromDate, LocalDateTime.now(), dryRun);
|
- |
|
| 643 |
}
|
- |
|
| 644 |
|
- |
|
| 645 |
public void processScheme(LocalDateTime startDate, LocalDateTime endDate, boolean dryRun) throws Exception {
|
631 |
public void processScheme(LocalDateTime startDate, LocalDateTime endDate, boolean dryRun) throws Exception {
|
| 646 |
LOGGER.info("Started execution at {}", LocalDateTime.now());
|
632 |
LOGGER.info("Started execution at {}", LocalDateTime.now());
|
| 647 |
System.out.println(
|
633 |
System.out.println(
|
| 648 |
"InventoryId\tSerialNumber\tItem Id\tScheme Id\tScheme Name\tScheme Type\tAmount Type\tDP\tTaxable\tScheme Amount\tAmount Paid");
|
634 |
"InventoryId\tSerialNumber\tItem Id\tScheme Id\tScheme Name\tScheme Type\tAmount Type\tDP\tTaxable\tScheme Amount\tAmount Paid");
|
| 649 |
try {
|
635 |
try {
|
| Line 675... |
Line 661... |
| 675 |
LocalDateTime cashbackTime = LocalDateTime.now();
|
661 |
LocalDateTime cashbackTime = LocalDateTime.now();
|
| 676 |
int referenceId = (int) Timestamp.valueOf(cashbackTime).getTime() / 1000;
|
662 |
int referenceId = (int) Timestamp.valueOf(cashbackTime).getTime() / 1000;
|
| 677 |
List<RechargeTransaction> pendingTransactions = rechargeTransactionRepository.getPendingCashBackRehargeTransactions();
|
663 |
List<RechargeTransaction> pendingTransactions = rechargeTransactionRepository.getPendingCashBackRehargeTransactions();
|
| 678 |
Map<Object, Double> totalRetailerCashbacks = pendingTransactions.stream().collect(
|
664 |
Map<Object, Double> totalRetailerCashbacks = pendingTransactions.stream().collect(
|
| 679 |
groupingBy(x -> x.getRetailerId(), Collectors.summingDouble(x -> x.getCommission())));
|
665 |
groupingBy(x -> x.getRetailerId(), Collectors.summingDouble(x -> x.getCommission())));
|
| 680 |
for (Map.Entry<Object, Double> totalRetailerCashback : totalRetailerCashbacks.entrySet()) {
|
666 |
for (Entry<Object, Double> totalRetailerCashback : totalRetailerCashbacks.entrySet()) {
|
| 681 |
int retailerId = (Integer) totalRetailerCashback.getKey();
|
667 |
int retailerId = (Integer) totalRetailerCashback.getKey();
|
| 682 |
float amount = totalRetailerCashback.getValue().floatValue();
|
668 |
float amount = totalRetailerCashback.getValue().floatValue();
|
| 683 |
if (Math.round(amount) > 0) {
|
669 |
if (Math.round(amount) > 0) {
|
| 684 |
walletService.addAmountToWallet(retailerId, referenceId, WalletReferenceType.CASHBACK, "Recharge Cashback", Math.round(amount), LocalDateTime.now());
|
670 |
walletService.addAmountToWallet(retailerId, referenceId, WalletReferenceType.CASHBACK, "Recharge Cashback", Math.round(amount), LocalDateTime.now());
|
| 685 |
}
|
671 |
}
|
| Line 856... |
Line 842... |
| 856 |
|
842 |
|
| 857 |
System.out.println(ageingModelMap.size());
|
843 |
System.out.println(ageingModelMap.size());
|
| 858 |
List<PartnerAgeingModel> partnerAgeingModels = ageingService.getAllAgeingForTertiary();
|
844 |
List<PartnerAgeingModel> partnerAgeingModels = ageingService.getAllAgeingForTertiary();
|
| 859 |
|
845 |
|
| 860 |
|
846 |
|
| 861 |
org.apache.commons.io.output.ByteArrayOutputStream byteArrayOutputStream = FileUtil.getCSVByteStream(Arrays.asList("InventoryItemId", "Serial Number", "Item Id", "Brand", "Model Name", "ModelNumber", "Color", "Exceed Days", "Last ScanType", "Supplier Name", "Current Warehouse", "First Warehouse", "Invoice Number", "Invoice Date"), ageingModelMap.values().stream().map(x -> Arrays.asList(x.getInventoryItemId(), x.getSerialNumber(), x.getItemId(), x.getBrand(), x.getModelName(), x.getModelNumber(), x.getColor(), x.getExceedDays(), x.getLastScanType(), x.getSupplierName(), x.getCurrentWarehouse(), x.getFirstWarehouse(), x.getInvoiceNumber(), FormattingUtils.formatDate(x.getInvoiceDate()))).collect(Collectors.toList()));
|
847 |
ByteArrayOutputStream byteArrayOutputStream = FileUtil.getCSVByteStream(Arrays.asList("InventoryItemId", "Serial Number", "Item Id", "Brand", "Model Name", "ModelNumber", "Color", "Exceed Days", "Last ScanType", "Supplier Name", "Current Warehouse", "First Warehouse", "Invoice Number", "Invoice Date"), ageingModelMap.values().stream().map(x -> Arrays.asList(x.getInventoryItemId(), x.getSerialNumber(), x.getItemId(), x.getBrand(), x.getModelName(), x.getModelNumber(), x.getColor(), x.getExceedDays(), x.getLastScanType(), x.getSupplierName(), x.getCurrentWarehouse(), x.getFirstWarehouse(), x.getInvoiceNumber(), FormattingUtils.formatDate(x.getInvoiceDate()))).collect(Collectors.toList()));
|
| 862 |
|
848 |
|
| 863 |
org.apache.commons.io.output.ByteArrayOutputStream byteArrayOutputStream2 = FileUtil.getCSVByteStream(Arrays.asList("InventoryItemId", "Serial Number", "Item Id", "Brand", "Model Name", "ModelNumber", "Color", "Partner Id", "Partner Code", "Partner Name", "Activation Type", "City", "State", "Billing Date", "Exceed Days", "Max Ageing", "Activation Date"), partnerAgeingModels.stream().map(x -> Arrays.asList(x.getInventoryItemId(), x.getSerialNumber(), x.getItemId(), x.getBrand(), x.getModelName(), x.getModelNumber(), x.getColor(), x.getFofoId(), x.getFofoCode(), x.getFofoName(), x.getActivationType(), x.getFofoCity(), x.getFofoState(), FormattingUtils.formatDate(x.getBillingDate()), x.getExceedDays(), x.getMaxAgeingDays(), x.getActivationDate())).collect(Collectors.toList()));
|
849 |
ByteArrayOutputStream byteArrayOutputStream2 = FileUtil.getCSVByteStream(Arrays.asList("InventoryItemId", "Serial Number", "Item Id", "Brand", "Model Name", "ModelNumber", "Color", "Partner Id", "Partner Code", "Partner Name", "Activation Type", "City", "State", "Billing Date", "Exceed Days", "Max Ageing", "Activation Date"), partnerAgeingModels.stream().map(x -> Arrays.asList(x.getInventoryItemId(), x.getSerialNumber(), x.getItemId(), x.getBrand(), x.getModelName(), x.getModelNumber(), x.getColor(), x.getFofoId(), x.getFofoCode(), x.getFofoName(), x.getActivationType(), x.getFofoCity(), x.getFofoState(), FormattingUtils.formatDate(x.getBillingDate()), x.getExceedDays(), x.getMaxAgeingDays(), x.getActivationDate())).collect(Collectors.toList()));
|
| 864 |
Utils.Attachment attachment1 = new Utils.Attachment("secondary-alert.csv", new ByteArrayResource(byteArrayOutputStream.toByteArray()));
|
850 |
Attachment attachment1 = new Attachment("secondary-alert.csv", new ByteArrayResource(byteArrayOutputStream.toByteArray()));
|
| 865 |
Utils.Attachment attachment2 = new Utils.Attachment("tertiary-alert.csv", new ByteArrayResource(byteArrayOutputStream2.toByteArray()));
|
851 |
Attachment attachment2 = new Attachment("tertiary-alert.csv", new ByteArrayResource(byteArrayOutputStream2.toByteArray()));
|
| 866 |
|
852 |
|
| 867 |
String mailSubject = "Stock ageing Alert";
|
853 |
String mailSubject = "Stock ageing Alert";
|
| 868 |
Utils.sendMailWithAttachments(mailSender, new String[]{"deena.nath@smartdukaan.com"}, null, mailSubject, "PFA", attachment1, attachment2);
|
854 |
Utils.sendMailWithAttachments(mailSender, new String[]{"deena.nath@smartdukaan.com"}, null, mailSubject, "PFA", attachment1, attachment2);
|
| 869 |
}
|
855 |
}
|
| 870 |
|
856 |
|
| Line 1035... |
Line 1021... |
| 1035 |
InvoiceService invoiceService;
|
1021 |
InvoiceService invoiceService;
|
| 1036 |
|
1022 |
|
| 1037 |
@Autowired
|
1023 |
@Autowired
|
| 1038 |
WarehouseService warehouseService;
|
1024 |
WarehouseService warehouseService;
|
| 1039 |
|
1025 |
|
| - |
|
1026 |
@Autowired
|
| - |
|
1027 |
GenericRepository genericRepository;
|
| - |
|
1028 |
|
| - |
|
1029 |
@Autowired
|
| - |
|
1030 |
PriceCircularService priceCircularService;
|
| - |
|
1031 |
|
| 1040 |
public void test() throws Exception {
|
1032 |
public void test() throws Exception {
|
| - |
|
1033 |
LocalDate startDate = LocalDate.of(2024, Month.MAY, 1);
|
| - |
|
1034 |
List<PriceDropIMEI> priceDropIMEIList = priceDropIMEIRepository.selectAllByCreditedBetween(startDate.atStartOfDay(), startDate.plusMonths(1).atTime(Utils.MAX_TIME));
|
| - |
|
1035 |
Set<Integer> inventoryItemIds = priceDropIMEIList.stream().map(x -> x.getInventoryItemId()).collect(Collectors.toSet());
|
| - |
|
1036 |
List<InventoryItem> inventoryItems = inventoryItemRepository.selectByIds(inventoryItemIds);
|
| - |
|
1037 |
List<String> headers = Arrays.asList("FofoId", "Serial Number", "Original DP", "DP(Inc PDs)", "PDs credited", "Fixed amount", "Discount", "Percentage Amount", "Margins Calc.", "Margins credited", "SoldOut");
|
| - |
|
1038 |
|
| - |
|
1039 |
List<List<?>> rows = new ArrayList<>();
|
| - |
|
1040 |
for (InventoryItem inventoryItem : inventoryItems) {
|
| - |
|
1041 |
InventoryPayoutModel ipm = priceCircularService.getPayouts(inventoryItem);
|
| - |
|
1042 |
ipm.getActualRolloutAmount();
|
| - |
|
1043 |
rows.add(Arrays.asList(inventoryItem.getFofoId(), inventoryItem.getSerialNumber(), ipm.getDp() + ipm.getPriceDropAmount(), ipm.getDp(), 0d,//PDs credited
|
| - |
|
1044 |
ipm.getFixedAmount(), ipm.getDiscountAmount(), ipm.getPercentageAmount(), ipm.getActualRolloutAmount(), ipm.getPaidAmount(), inventoryItem.getLastScanType().equals(ScanType.SALE)));
|
| - |
|
1045 |
}
|
| - |
|
1046 |
ByteArrayOutputStream baos = FileUtil.getCSVByteStream(headers, rows);
|
| - |
|
1047 |
FileOutputStream fos = new FileOutputStream(new File("/Users/amit/data.csv"));
|
| - |
|
1048 |
baos.writeTo(fos);
|
| - |
|
1049 |
|
| - |
|
1050 |
|
| - |
|
1051 |
}
|
| - |
|
1052 |
|
| - |
|
1053 |
public void test4() throws Exception {
|
| - |
|
1054 |
List<Integer> offerIds = Arrays.asList(2882, 2881, 2880, 2879, 2878, 2877, 2876, 2875, 2874, 2873, 2872, 2871, 2870, 2869, 2868, 2867, 2866, 2865, 2864, 2863, 2862, 2861, 2860, 2859, 2858, 2857, 2856, 2855, 2854, 2853, 2852, 2851, 2850, 2849, 2847, 2846, 2845, 2844, 2843, 2842, 2841, 2840, 2839, 2838, 2837, 2836, 2835, 2834, 2833, 2832, 2831, 2830, 2829, 2828, 2827, 2826, 2825, 2824, 2823, 2822, 2821, 2820, 2819, 2818, 2817, 2816, 2815, 2814, 2813, 2812, 2811, 2810, 2809, 2808, 2807, 2806, 2805, 2804, 2803, 2802, 2801, 2800, 2799, 2798, 2797, 2796, 2795, 2794, 2793, 2792, 2791, 2790, 2789, 2788, 2787, 2786, 2785, 2784, 2783, 2782, 2781, 2780, 2777, 2776, 2775, 2774, 2773, 2772, 2771, 2770, 2769, 2768, 2767, 2766, 2765, 2764, 2763, 2762, 2761, 2760, 2759, 2758, 2757, 2756, 2755, 2754, 2753, 2752, 2751, 2750, 2749, 2748, 2747, 2746, 2745, 2744, 2723, 2722, 2721, 2720, 2719, 2718, 2717, 2716, 2715, 2714, 2713, 2712, 2711, 2710, 2709, 2708, 2707, 2706, 2705, 2704, 2703, 2702, 2701, 2700, 2699, 2698, 2697, 2696, 2695, 2694, 2693, 2692, 2691, 2690, 2494, 2493, 2492, 2491, 2490, 2489, 2488, 2487, 2486, 2485, 2484, 2483, 2482, 2481, 2480, 2479, 2478, 2477, 2476, 2475, 2474, 2473, 2472, 2471, 2470, 2469, 2466, 2465, 2464, 2463, 2462, 2461, 2460, 2459, 2458, 2457, 2456, 2455, 2454, 2453, 2452, 2451, 2450, 2449, 2448, 2447, 2446, 2445, 2444, 2443, 2442, 2441, 2440, 2439, 2407, 2406, 2405, 2404, 2403, 2402, 2401, 2400, 2399, 2398, 2397, 2396, 2395, 2394, 2393, 2392, 2391, 2390, 2389, 2388, 2387, 2386, 2385, 2384, 2383, 2382, 2381, 2117, 2116, 2115, 2114, 2113, 2112, 2111, 2110, 2109, 2108, 2107, 2106, 2105, 2104, 2103, 2102, 2101, 2100, 2099, 2098, 2077);
|
| - |
|
1055 |
for (Integer offerId : offerIds) {
|
| - |
|
1056 |
Offer fromOffer = offerRepository.selectById(offerId);
|
| - |
|
1057 |
CreateOfferRequest createOfferRequest = offerService.getCreateOfferRequest(fromOffer);
|
| - |
|
1058 |
System.out.println("Processing offer Id " + fromOffer);
|
| - |
|
1059 |
offerService.processActivationtOffer(createOfferRequest);
|
| - |
|
1060 |
}
|
| 1041 |
//sdCreditService.checkLoans();
|
1061 |
//sdCreditService.checkLoans();
|
| 1042 |
/*System.out.println(warehouseService.moveToBad(Arrays.asList("860374066889716",
|
1062 |
/*System.out.println(warehouseService.moveToBad(Arrays.asList("860374066889716",
|
| 1043 |
"863587077946699",
|
1063 |
"863587077946699",
|
| 1044 |
"865883067303639",
|
1064 |
"865883067303639",
|
| 1045 |
"868116066180113",
|
1065 |
"868116066180113",
|
| Line 1063... |
Line 1083... |
| 1063 |
}
|
1083 |
}
|
| 1064 |
|
1084 |
|
| 1065 |
public void test3() throws Exception {
|
1085 |
public void test3() throws Exception {
|
| 1066 |
List<Long> payoutIds = Arrays.asList();
|
1086 |
List<Long> payoutIds = Arrays.asList();
|
| 1067 |
List<OfferPayout> offerPayouts = offerPayoutRepository.selectAllByIds(payoutIds);
|
1087 |
List<OfferPayout> offerPayouts = offerPayoutRepository.selectAllByIds(payoutIds);
|
| 1068 |
Map<Integer, List<OfferPayout>> offerPayoutMap = offerPayouts.stream().collect(Collectors.groupingBy(x -> (int) x.getOfferId()));
|
1088 |
Map<Integer, List<OfferPayout>> offerPayoutMap = offerPayouts.stream().collect(groupingBy(x -> (int) x.getOfferId()));
|
| 1069 |
for (Map.Entry<Integer, List<OfferPayout>> offerPayoutEntry : offerPayoutMap.entrySet()) {
|
1089 |
for (Entry<Integer, List<OfferPayout>> offerPayoutEntry : offerPayoutMap.entrySet()) {
|
| 1070 |
int offerId = offerPayoutEntry.getKey();
|
1090 |
int offerId = offerPayoutEntry.getKey();
|
| 1071 |
List<OfferPayout> offerPayoutList = offerPayoutEntry.getValue();
|
1091 |
List<OfferPayout> offerPayoutList = offerPayoutEntry.getValue();
|
| 1072 |
Map<Integer, List<OfferPayout>> partnerOfferPayoutMap = offerPayoutList.stream().collect(Collectors.groupingBy(x -> (int) x.getFofoId()));
|
1092 |
Map<Integer, List<OfferPayout>> partnerOfferPayoutMap = offerPayoutList.stream().collect(groupingBy(x -> (int) x.getFofoId()));
|
| 1073 |
for (Entry<Integer, List<OfferPayout>> partnerOfferPayoutEntry : partnerOfferPayoutMap.entrySet()) {
|
1093 |
for (Entry<Integer, List<OfferPayout>> partnerOfferPayoutEntry : partnerOfferPayoutMap.entrySet()) {
|
| 1074 |
int fofoId = partnerOfferPayoutEntry.getKey();
|
1094 |
int fofoId = partnerOfferPayoutEntry.getKey();
|
| 1075 |
List<OfferPayout> partnerPayouts = partnerOfferPayoutEntry.getValue();
|
1095 |
List<OfferPayout> partnerPayouts = partnerOfferPayoutEntry.getValue();
|
| 1076 |
float amount = 0;
|
1096 |
float amount = 0;
|
| 1077 |
for (OfferPayout offerPayout : partnerPayouts) {
|
1097 |
for (OfferPayout offerPayout : partnerPayouts) {
|
| Line 1171... |
Line 1191... |
| 1171 |
fofoIdImeiReturnMap.put(175139412, new HashSet<>(Arrays.asList("351115165488595","351115165491318","351115165491359","351115165491458","351115165492332","355358278026573","355358278081610","861888063460717","861977073052018","863816078633919","865883069477035","866335074538870","866993071639594")));
|
1191 |
fofoIdImeiReturnMap.put(175139412, new HashSet<>(Arrays.asList("351115165488595","351115165491318","351115165491359","351115165491458","351115165492332","355358278026573","355358278081610","861888063460717","861977073052018","863816078633919","865883069477035","866335074538870","866993071639594")));
|
| 1172 |
fofoIdImeiReturnMap.put(175139504, new HashSet<>(Arrays.asList("862054072660792","862054075971873","862054076312374","862054077948630","863816075363171","863862075442334","864718075894230","868938062122017","868938065268932","869452071940632","869452073034897","869452073158233","869452073158498","869452074159735")));
|
1192 |
fofoIdImeiReturnMap.put(175139504, new HashSet<>(Arrays.asList("862054072660792","862054075971873","862054076312374","862054077948630","863816075363171","863862075442334","864718075894230","868938062122017","868938065268932","869452071940632","869452073034897","869452073158233","869452073158498","869452074159735")));
|
| 1173 |
fofoIdImeiReturnMap.put(175139201, new HashSet<>(Arrays.asList("863718061956671","863862075497734","863862075596915","864718076078510","864718076134834","866335070211639","866611060437032","866611061133812")));
|
1193 |
fofoIdImeiReturnMap.put(175139201, new HashSet<>(Arrays.asList("863718061956671","863862075497734","863862075596915","864718076078510","864718076134834","866335070211639","866611060437032","866611061133812")));
|
| 1174 |
fofoIdImeiReturnMap.put(175139362, new HashSet<>(Arrays.asList("350201087545646","350201087547048","350201087547709","350201087548764","350201087597043","350201087597167","350201087597464","350201087597787","350201087598165","350201087600789","863718062929271","865883069477191","865883069477530","866335071174133","866518078023870","866518078243072","868938061053494")));
|
1194 |
fofoIdImeiReturnMap.put(175139362, new HashSet<>(Arrays.asList("350201087545646","350201087547048","350201087547709","350201087548764","350201087597043","350201087597167","350201087597464","350201087597787","350201087598165","350201087600789","863718062929271","865883069477191","865883069477530","866335071174133","866518078023870","866518078243072","868938061053494")));
|
| 1175 |
fofoIdImeiReturnMap.put(175139661, new HashSet<>(Arrays.asList("860946077691031","861977074661155","862054073218855","866335070523694","867940069973476","868938062656477")));*/
|
1195 |
fofoIdImeiReturnMap.put(175139661, new HashSet<>(Arrays.asList("860946077691031","861977074661155","862054073218855","866335070523694","867940069973476","868938062656477")));*/
|
| 1176 |
fofoIdImeiReturnMap.put(175139556, new HashSet<>(Arrays.asList("863718063534013","866335072895173","866335073390810")));
|
1196 |
fofoIdImeiReturnMap.put(175139556, new HashSet<>(Arrays.asList("863718063534013", "866335072895173", "866335073390810")));
|
| 1177 |
fofoIdImeiReturnMap.put(175139721, new HashSet<>(Arrays.asList("358250294549067","865883067508138","866993072210619")));
|
1197 |
fofoIdImeiReturnMap.put(175139721, new HashSet<>(Arrays.asList("358250294549067", "865883067508138", "866993072210619")));
|
| 1178 |
/*fofoIdImeiReturnMap.put(175139455, new HashSet<>(Arrays.asList("358293804087913","866518078020694","866518078021650","866518078243676","866518078571936")));
|
1198 |
/*fofoIdImeiReturnMap.put(175139455, new HashSet<>(Arrays.asList("358293804087913","866518078020694","866518078021650","866518078243676","866518078571936")));
|
| 1179 |
fofoIdImeiReturnMap.put(175138674, new HashSet<>(Arrays.asList("351115165482275","359197386868583","862054074428875","862054077945693","862054078556879","863967070559535","863975068705671","863975068705770","864468076196124","866186064235971","866186066185117","866186066186917","866518073607370","866518079641514","868938060476456","868938060501535","868938060717990","868938062656931")));
|
1199 |
fofoIdImeiReturnMap.put(175138674, new HashSet<>(Arrays.asList("351115165482275","359197386868583","862054074428875","862054077945693","862054078556879","863967070559535","863975068705671","863975068705770","864468076196124","866186064235971","866186066185117","866186066186917","866518073607370","866518079641514","868938060476456","868938060501535","868938060717990","868938062656931")));
|
| 1180 |
fofoIdImeiReturnMap.put(175139559, new HashSet<>(Arrays.asList("863718069016890","863816078879256","864468075283881","866335073245436","866335073403571","866657074268327","868024065473853","868956065899993","869452070362895","869452074030274")));
|
1200 |
fofoIdImeiReturnMap.put(175139559, new HashSet<>(Arrays.asList("863718069016890","863816078879256","864468075283881","866335073245436","866335073403571","866657074268327","868024065473853","868956065899993","869452070362895","869452074030274")));
|
| 1181 |
fofoIdImeiReturnMap.put(175139575, new HashSet<>(Arrays.asList("354324786659199","860388067452035","861220078009919","863816078878134","863862075841154","865388070857498","867907071407116")));
|
1201 |
fofoIdImeiReturnMap.put(175139575, new HashSet<>(Arrays.asList("354324786659199","860388067452035","861220078009919","863816078878134","863862075841154","865388070857498","867907071407116")));
|
| 1182 |
fofoIdImeiReturnMap.put(175139686, new HashSet<>(Arrays.asList("866657078019106","866657078032869")));*/
|
1202 |
fofoIdImeiReturnMap.put(175139686, new HashSet<>(Arrays.asList("866657078019106","866657078032869")));*/
|
| Line 1215... |
Line 1235... |
| 1215 |
debitNote.setCreateTimestamp(debitNoteDate);
|
1235 |
debitNote.setCreateTimestamp(debitNoteDate);
|
| 1216 |
//Try to refund amount per debit note
|
1236 |
//Try to refund amount per debit note
|
| 1217 |
cartItems.addAll(this.refundDnAmount(debitNote));
|
1237 |
cartItems.addAll(this.refundDnAmount(debitNote));
|
| 1218 |
}
|
1238 |
}
|
| 1219 |
//If order created
|
1239 |
//If order created
|
| 1220 |
Map<Integer, List<CartItem>> warehouseCartItemsMap = cartItems.stream().collect(Collectors.groupingBy(x -> x.getWarehouseId()));
|
1240 |
Map<Integer, List<CartItem>> warehouseCartItemsMap = cartItems.stream().collect(groupingBy(x -> x.getWarehouseId()));
|
| 1221 |
for (Map.Entry<Integer, List<CartItem>> warehouseCartItemsEntry : warehouseCartItemsMap.entrySet()) {
|
1241 |
for (Entry<Integer, List<CartItem>> warehouseCartItemsEntry : warehouseCartItemsMap.entrySet()) {
|
| 1222 |
|
1242 |
|
| 1223 |
List<CartItem> warehouseCartItems = warehouseCartItemsEntry.getValue();
|
1243 |
List<CartItem> warehouseCartItems = warehouseCartItemsEntry.getValue();
|
| 1224 |
|
1244 |
|
| 1225 |
List<CartItem> mergedCartItems = warehouseCartItems.stream()
|
1245 |
List<CartItem> mergedCartItems = warehouseCartItems.stream()
|
| 1226 |
.collect(Collectors.collectingAndThen(
|
1246 |
.collect(Collectors.collectingAndThen(
|
| 1227 |
Collectors.groupingBy(x -> x.getItemId(), Collectors.collectingAndThen(
|
1247 |
groupingBy(x -> x.getItemId(), Collectors.collectingAndThen(
|
| 1228 |
Collectors.reducing((a, b) -> {
|
1248 |
Collectors.reducing((a, b) -> {
|
| 1229 |
a.setQuantity(a.getQuantity() + b.getQuantity());
|
1249 |
a.setQuantity(a.getQuantity() + b.getQuantity());
|
| 1230 |
return a;
|
1250 |
return a;
|
| 1231 |
}), Optional::get)),
|
1251 |
}), Optional::get)),
|
| 1232 |
m -> new ArrayList<>(m.values())));
|
1252 |
m -> new ArrayList<>(m.values())));
|
| Line 1267... |
Line 1287... |
| 1267 |
|
1287 |
|
| 1268 |
|
1288 |
|
| 1269 |
//Also create order
|
1289 |
//Also create order
|
| 1270 |
private List<CartItem> refundDnAmount(DebitNote debitNote) throws ProfitMandiBusinessException {
|
1290 |
private List<CartItem> refundDnAmount(DebitNote debitNote) throws ProfitMandiBusinessException {
|
| 1271 |
List<Integer> inventoryItemIds = purchaseReturnItemRepository.selectAllByDebitNoteId(debitNote.getId()).stream().map(x -> x.getInventoryItemId()).collect(Collectors.toList());
|
1291 |
List<Integer> inventoryItemIds = purchaseReturnItemRepository.selectAllByDebitNoteId(debitNote.getId()).stream().map(x -> x.getInventoryItemId()).collect(Collectors.toList());
|
| 1272 |
Map<Integer, Long> inventoryItemCountMap = inventoryItemIds.stream().collect(Collectors.groupingBy(x -> x, Collectors.counting()));
|
1292 |
Map<Integer, Long> inventoryItemCountMap = inventoryItemIds.stream().collect(groupingBy(x -> x, Collectors.counting()));
|
| 1273 |
List<InventoryItem> inventoryItems = inventoryItemRepository.selectAllByIds(new ArrayList<>(inventoryItemCountMap.keySet()));
|
1293 |
List<InventoryItem> inventoryItems = inventoryItemRepository.selectAllByIds(new ArrayList<>(inventoryItemCountMap.keySet()));
|
| 1274 |
Purchase purchase = purchaseRepository.selectById(inventoryItems.get(0).getPurchaseId());
|
1294 |
Purchase purchase = purchaseRepository.selectById(inventoryItems.get(0).getPurchaseId());
|
| 1275 |
String invoice = purchase.getPurchaseReference();
|
1295 |
String invoice = purchase.getPurchaseReference();
|
| 1276 |
List<Order> orders = orderRepository.selectByInvoiceNumber(invoice);
|
1296 |
List<Order> orders = orderRepository.selectByInvoiceNumber(invoice);
|
| 1277 |
Set<Integer> orderIds = orders.stream().map(x -> x.getId()).collect(Collectors.toSet());
|
1297 |
Set<Integer> orderIds = orders.stream().map(x -> x.getId()).collect(Collectors.toSet());
|
| Line 1505... |
Line 1525... |
| 1505 |
}
|
1525 |
}
|
| 1506 |
|
1526 |
|
| 1507 |
String fileName = "InvestmentSummary-" + FormattingUtils.formatDate(LocalDateTime.now()) + ".csv";
|
1527 |
String fileName = "InvestmentSummary-" + FormattingUtils.formatDate(LocalDateTime.now()) + ".csv";
|
| 1508 |
|
1528 |
|
| 1509 |
if (sendTo == null) {
|
1529 |
if (sendTo == null) {
|
| 1510 |
for (Map.Entry<String, Set<Integer>> storeGuyEntry : csService.getAuthUserPartnerIdMapping().entrySet()) {
|
1530 |
for (Entry<String, Set<Integer>> storeGuyEntry : csService.getAuthUserPartnerIdMapping().entrySet()) {
|
| 1511 |
List<List<?>> filteredRows = storeGuyEntry.getValue().stream().map(x -> partnerRowsMap.get(x)).filter(x -> x != null).collect(Collectors.toList());
|
1531 |
List<List<?>> filteredRows = storeGuyEntry.getValue().stream().map(x -> partnerRowsMap.get(x)).filter(x -> x != null).collect(Collectors.toList());
|
| 1512 |
ByteArrayOutputStream baos = FileUtil.getCSVByteStream(headers, filteredRows);
|
1532 |
ByteArrayOutputStream baos = FileUtil.getCSVByteStream(headers, filteredRows);
|
| 1513 |
String[] sendToArray = new String[]{storeGuyEntry.getKey()};
|
1533 |
String[] sendToArray = new String[]{storeGuyEntry.getKey()};
|
| 1514 |
Utils.sendMailWithAttachment(googleMailSender, sendToArray, null, "Franchise Investment Summary", "PFA", fileName, new ByteArrayResource(baos.toByteArray()));
|
1534 |
Utils.sendMailWithAttachment(googleMailSender, sendToArray, null, "Franchise Investment Summary", "PFA", fileName, new ByteArrayResource(baos.toByteArray()));
|
| 1515 |
}
|
1535 |
}
|
| Line 1629... |
Line 1649... |
| 1629 |
Utils.sendMailWithAttachments(googleMailSender, ITEMWISE_PENDING_INDENT_MAIL_LIST, null, "Itemwise Pending indent", "PFA", attachment1);
|
1649 |
Utils.sendMailWithAttachments(googleMailSender, ITEMWISE_PENDING_INDENT_MAIL_LIST, null, "Itemwise Pending indent", "PFA", attachment1);
|
| 1630 |
|
1650 |
|
| 1631 |
// Reports to be sent to mapped partners
|
1651 |
// Reports to be sent to mapped partners
|
| 1632 |
Map<String, Set<String>> storeGuysMap = csService.getAuthUserPartnerEmailMapping();
|
1652 |
Map<String, Set<String>> storeGuysMap = csService.getAuthUserPartnerEmailMapping();
|
| 1633 |
|
1653 |
|
| 1634 |
for (Map.Entry<String, Set<String>> storeGuyEntry : storeGuysMap.entrySet()) {
|
1654 |
for (Entry<String, Set<String>> storeGuyEntry : storeGuysMap.entrySet()) {
|
| 1635 |
Map<String, String> params = new HashMap<>();
|
1655 |
Map<String, String> params = new HashMap<>();
|
| 1636 |
if (storeGuyEntry.getValue().size() == 0)
|
1656 |
if (storeGuyEntry.getValue().size() == 0)
|
| 1637 |
continue;
|
1657 |
continue;
|
| 1638 |
params.put("MANUAL_email", String.join(",", storeGuyEntry.getValue()));
|
1658 |
params.put("MANUAL_email", String.join(",", storeGuyEntry.getValue()));
|
| 1639 |
InputStreamSource isr3 = reporticoService.getReportInputStreamSource(ReporticoProject.FOCO, "focostockreport.xml", params);
|
1659 |
InputStreamSource isr3 = reporticoService.getReportInputStreamSource(ReporticoProject.FOCO, "focostockreport.xml", params);
|
| Line 1873... |
Line 1893... |
| 1873 |
|
1893 |
|
| 1874 |
Map<Integer, Double> userSchemeRefundedMap = inventoryItemRepository.selectByIds(inventoryItemSchemeIORefunded.keySet()).stream().collect(groupingBy(x -> x.getFofoId(), Collectors.summingDouble(x -> inventoryItemSchemeIORefunded.get(x.getId()))));
|
1894 |
Map<Integer, Double> userSchemeRefundedMap = inventoryItemRepository.selectByIds(inventoryItemSchemeIORefunded.keySet()).stream().collect(groupingBy(x -> x.getFofoId(), Collectors.summingDouble(x -> inventoryItemSchemeIORefunded.get(x.getId()))));
|
| 1875 |
|
1895 |
|
| 1876 |
Map<Integer, Double> finalUserSchemeAmountMap = new HashMap<>();
|
1896 |
Map<Integer, Double> finalUserSchemeAmountMap = new HashMap<>();
|
| 1877 |
|
1897 |
|
| 1878 |
for (Map.Entry<Integer, Double> schemeAmount : userSchemeRefundedMap.entrySet()) {
|
1898 |
for (Entry<Integer, Double> schemeAmount : userSchemeRefundedMap.entrySet()) {
|
| 1879 |
if (!finalUserSchemeAmountMap.containsKey(schemeAmount.getKey())) {
|
1899 |
if (!finalUserSchemeAmountMap.containsKey(schemeAmount.getKey())) {
|
| 1880 |
finalUserSchemeAmountMap.put(schemeAmount.getKey(), schemeAmount.getValue());
|
1900 |
finalUserSchemeAmountMap.put(schemeAmount.getKey(), schemeAmount.getValue());
|
| 1881 |
} else {
|
1901 |
} else {
|
| 1882 |
finalUserSchemeAmountMap.put(schemeAmount.getKey(), finalUserSchemeAmountMap.get(schemeAmount.getKey()) + schemeAmount.getValue());
|
1902 |
finalUserSchemeAmountMap.put(schemeAmount.getKey(), finalUserSchemeAmountMap.get(schemeAmount.getKey()) + schemeAmount.getValue());
|
| 1883 |
}
|
1903 |
}
|
| 1884 |
}
|
1904 |
}
|
| 1885 |
Map<Integer, Integer> userWalletMap = userWalletRepository.selectByRetailerIds(finalUserSchemeAmountMap.keySet()).stream().collect(Collectors.toMap(UserWallet::getUserId, UserWallet::getId));
|
1905 |
Map<Integer, Integer> userWalletMap = userWalletRepository.selectByRetailerIds(finalUserSchemeAmountMap.keySet()).stream().collect(Collectors.toMap(UserWallet::getUserId, UserWallet::getId));
|
| 1886 |
|
1906 |
|
| 1887 |
Map<Integer, Double> walletAmountMap = history.stream().collect(groupingBy(
|
1907 |
Map<Integer, Double> walletAmountMap = history.stream().collect(groupingBy(
|
| 1888 |
UserWalletHistory::getWalletId, Collectors.summingDouble((UserWalletHistory::getAmount))));
|
1908 |
UserWalletHistory::getWalletId, Collectors.summingDouble((UserWalletHistory::getAmount))));
|
| 1889 |
for (Map.Entry<Integer, Double> userAmount : walletAmountMap.entrySet()) {
|
1909 |
for (Entry<Integer, Double> userAmount : walletAmountMap.entrySet()) {
|
| 1890 |
double diff = Math.abs(finalUserSchemeAmountMap.get(userAmount.getKey()) - userAmount.getValue());
|
1910 |
double diff = Math.abs(finalUserSchemeAmountMap.get(userAmount.getKey()) - userAmount.getValue());
|
| 1891 |
if (diff > 5) {
|
1911 |
if (diff > 5) {
|
| 1892 |
LOGGER.info("Partner scheme mismatched for Userid {}", userWalletMap.get(userAmount.getKey()));
|
1912 |
LOGGER.info("Partner scheme mismatched for Userid {}", userWalletMap.get(userAmount.getKey()));
|
| 1893 |
}
|
1913 |
}
|
| 1894 |
}
|
1914 |
}
|
| Line 2422... |
Line 2442... |
| 2422 |
List<FofoStore> stores = fofoStoreRepository.selectActivePartnersByRetailerIds(new ArrayList<>(fofoIds));
|
2442 |
List<FofoStore> stores = fofoStoreRepository.selectActivePartnersByRetailerIds(new ArrayList<>(fofoIds));
|
| 2423 |
|
2443 |
|
| 2424 |
Map<String, List<Integer>> stateMap = stores.stream().collect(groupingBy(
|
2444 |
Map<String, List<Integer>> stateMap = stores.stream().collect(groupingBy(
|
| 2425 |
x -> x.getCode().substring(0, 2), mapping(x -> x.getId(), Collectors.toList())));
|
2445 |
x -> x.getCode().substring(0, 2), mapping(x -> x.getId(), Collectors.toList())));
|
| 2426 |
List<List<Serializable>> stateWiseSales = new ArrayList<>();
|
2446 |
List<List<Serializable>> stateWiseSales = new ArrayList<>();
|
| 2427 |
for (Map.Entry<String, List<Integer>> stateMapEntry : stateMap.entrySet()) {
|
2447 |
for (Entry<String, List<Integer>> stateMapEntry : stateMap.entrySet()) {
|
| 2428 |
long totalQty = stateMapEntry.getValue().stream().collect(Collectors.summingLong(x -> saleTargetReportModelMap.get(x).getTotalQty()));
|
2448 |
long totalQty = stateMapEntry.getValue().stream().collect(Collectors.summingLong(x -> saleTargetReportModelMap.get(x).getTotalQty()));
|
| 2429 |
double totalSale = stateMapEntry.getValue().stream().collect(Collectors.summingDouble(x -> saleTargetReportModelMap.get(x).getTotalSale()));
|
2449 |
double totalSale = stateMapEntry.getValue().stream().collect(Collectors.summingDouble(x -> saleTargetReportModelMap.get(x).getTotalSale()));
|
| 2430 |
long smartPhoneQty = stateMapEntry.getValue().stream().collect(Collectors.summingLong(x -> saleTargetReportModelMap.get(x).getSmartphoneQty()));
|
2450 |
long smartPhoneQty = stateMapEntry.getValue().stream().collect(Collectors.summingLong(x -> saleTargetReportModelMap.get(x).getSmartphoneQty()));
|
| 2431 |
double smartPhoneSale = stateMapEntry.getValue().stream().collect(
|
2451 |
double smartPhoneSale = stateMapEntry.getValue().stream().collect(
|
| 2432 |
Collectors.summingDouble(x -> saleTargetReportModelMap.get(x).getSmartphoneSale()));
|
2452 |
Collectors.summingDouble(x -> saleTargetReportModelMap.get(x).getSmartphoneSale()));
|
| Line 2720... |
Line 2740... |
| 2720 |
LOGGER.info("focusedCatalogIdAndQtyMap" + focusedCatalogIdAndQtyMap);
|
2740 |
LOGGER.info("focusedCatalogIdAndQtyMap" + focusedCatalogIdAndQtyMap);
|
| 2721 |
|
2741 |
|
| 2722 |
Map<String, RetailerBlockBrands> retailerBlockBrands = retailerBlockBrandsRepository.selectAllByRetailer(fofoId).stream().collect(Collectors.toMap(x -> x.getBlockBrands(), x -> x));
|
2742 |
Map<String, RetailerBlockBrands> retailerBlockBrands = retailerBlockBrandsRepository.selectAllByRetailer(fofoId).stream().collect(Collectors.toMap(x -> x.getBlockBrands(), x -> x));
|
| 2723 |
|
2743 |
|
| 2724 |
|
2744 |
|
| 2725 |
for (Map.Entry<Integer, Optional<Integer>> entry : focusedCatalogIdAndQtyMap.entrySet()) {
|
2745 |
for (Entry<Integer, Optional<Integer>> entry : focusedCatalogIdAndQtyMap.entrySet()) {
|
| 2726 |
int minQty = entry.getValue().get();
|
2746 |
int minQty = entry.getValue().get();
|
| 2727 |
int inStockQty = 0;
|
2747 |
int inStockQty = 0;
|
| 2728 |
int processingQty = 0;
|
2748 |
int processingQty = 0;
|
| 2729 |
int grnPendingQty = 0;
|
2749 |
int grnPendingQty = 0;
|
| 2730 |
int allColorNetAvailability = 0;
|
2750 |
int allColorNetAvailability = 0;
|
| Line 2897... |
Line 2917... |
| 2897 |
|
2917 |
|
| 2898 |
LOGGER.info("dtrEmailMap {}", dtrEmailMap);
|
2918 |
LOGGER.info("dtrEmailMap {}", dtrEmailMap);
|
| 2899 |
|
2919 |
|
| 2900 |
Map<Integer, Integer> authUserKeyMap = new HashMap<>();
|
2920 |
Map<Integer, Integer> authUserKeyMap = new HashMap<>();
|
| 2901 |
|
2921 |
|
| 2902 |
for (Map.Entry<Integer, String> authUserEmail : authUserEmailMap.entrySet()) {
|
2922 |
for (Entry<Integer, String> authUserEmail : authUserEmailMap.entrySet()) {
|
| 2903 |
int authId = authUserEmail.getKey();
|
2923 |
int authId = authUserEmail.getKey();
|
| 2904 |
String email = authUserEmail.getValue();
|
2924 |
String email = authUserEmail.getValue();
|
| 2905 |
authUserKeyMap.put(authId, dtrEmailMap.get(email));
|
2925 |
authUserKeyMap.put(authId, dtrEmailMap.get(email));
|
| 2906 |
}
|
2926 |
}
|
| 2907 |
LOGGER.info("authUserKeyMap", authUserKeyMap);
|
2927 |
LOGGER.info("authUserKeyMap", authUserKeyMap);
|
| Line 2983... |
Line 3003... |
| 2983 |
List<FranchiseeVisit> franchiseeVisits = franchiseeVisitRepository.selectVisitsScheduledBetweenDate(LocalDateTime.now().minusDays(15), LocalDateTime.now().plusHours(4));
|
3003 |
List<FranchiseeVisit> franchiseeVisits = franchiseeVisitRepository.selectVisitsScheduledBetweenDate(LocalDateTime.now().minusDays(15), LocalDateTime.now().plusHours(4));
|
| 2984 |
Map<Integer, String> authUserEmailMap = authRepository.selectAllActiveUser().stream().collect(Collectors.toMap(x -> x.getId(), x -> x.getEmailId()));
|
3004 |
Map<Integer, String> authUserEmailMap = authRepository.selectAllActiveUser().stream().collect(Collectors.toMap(x -> x.getId(), x -> x.getEmailId()));
|
| 2985 |
Map<String, Integer> dtrEmailMap = dtrUserRepository.selectAllByEmailIds(new ArrayList<>(authUserEmailMap.values())).stream().collect(Collectors.toMap(x -> x.getEmailId(), x -> x.getId()));
|
3005 |
Map<String, Integer> dtrEmailMap = dtrUserRepository.selectAllByEmailIds(new ArrayList<>(authUserEmailMap.values())).stream().collect(Collectors.toMap(x -> x.getEmailId(), x -> x.getId()));
|
| 2986 |
Map<Integer, Integer> authUserKeyMap = new HashMap<>();
|
3006 |
Map<Integer, Integer> authUserKeyMap = new HashMap<>();
|
| 2987 |
|
3007 |
|
| 2988 |
for (Map.Entry<Integer, String> authUserEmail : authUserEmailMap.entrySet()) {
|
3008 |
for (Entry<Integer, String> authUserEmail : authUserEmailMap.entrySet()) {
|
| 2989 |
int authId = authUserEmail.getKey();
|
3009 |
int authId = authUserEmail.getKey();
|
| 2990 |
String email = authUserEmail.getValue();
|
3010 |
String email = authUserEmail.getValue();
|
| 2991 |
authUserKeyMap.put(authId, dtrEmailMap.get(email));
|
3011 |
authUserKeyMap.put(authId, dtrEmailMap.get(email));
|
| 2992 |
}
|
3012 |
}
|
| 2993 |
String visitTemplate = "Planned visit to franchisee %s is due by %s";
|
3013 |
String visitTemplate = "Planned visit to franchisee %s is due by %s";
|
| Line 3191... |
Line 3211... |
| 3191 |
// fofoLineItemRepository.delete(fli);
|
3211 |
// fofoLineItemRepository.delete(fli);
|
| 3192 |
inventoryItemId = fli.getInventoryItemId();
|
3212 |
inventoryItemId = fli.getInventoryItemId();
|
| 3193 |
}
|
3213 |
}
|
| 3194 |
}
|
3214 |
}
|
| 3195 |
List<SchemeInOut> schemeInOuts = schemeInOutRepository.selectByInventoryItemIds(
|
3215 |
List<SchemeInOut> schemeInOuts = schemeInOutRepository.selectByInventoryItemIds(
|
| 3196 |
java.util.stream.Stream.of(inventoryItemId).collect(Collectors.toSet()));
|
3216 |
Stream.of(inventoryItemId).collect(Collectors.toSet()));
|
| 3197 |
for (SchemeInOut sio : schemeInOuts) {
|
3217 |
for (SchemeInOut sio : schemeInOuts) {
|
| 3198 |
if (sio.getCreateTimestamp().toLocalDate().equals(localDate)) {
|
3218 |
if (sio.getCreateTimestamp().toLocalDate().equals(localDate)) {
|
| 3199 |
LOGGER.info("SIO - {}", sio);
|
3219 |
LOGGER.info("SIO - {}", sio);
|
| 3200 |
sio.setRolledBackTimestamp(LocalDateTime.now());
|
3220 |
sio.setRolledBackTimestamp(LocalDateTime.now());
|
| 3201 |
}
|
3221 |
}
|
| Line 3463... |
Line 3483... |
| 3463 |
*/
|
3483 |
*/
|
| 3464 |
if (inventoryItem.getLastScanType().equals(ScanType.SALE) || inventoryItem.getLastScanType().equals(ScanType.SALE_RET)) {
|
3484 |
if (inventoryItem.getLastScanType().equals(ScanType.SALE) || inventoryItem.getLastScanType().equals(ScanType.SALE_RET)) {
|
| 3465 |
Map<String, Double> map = schemeInOuts.stream().collect(
|
3485 |
Map<String, Double> map = schemeInOuts.stream().collect(
|
| 3466 |
groupingBy(
|
3486 |
groupingBy(
|
| 3467 |
x -> DateTimeFormatter.ofPattern("yyyyMMddHH").format(x.getCreateTimestamp()) + "- " + x.getSchemeId(), Collectors.summingDouble(x -> x.getAmount())));
|
3487 |
x -> DateTimeFormatter.ofPattern("yyyyMMddHH").format(x.getCreateTimestamp()) + "- " + x.getSchemeId(), Collectors.summingDouble(x -> x.getAmount())));
|
| 3468 |
for (Map.Entry<String, Double> entry : map.entrySet()) {
|
3488 |
for (Entry<String, Double> entry : map.entrySet()) {
|
| 3469 |
LOGGER.info("{} = {}", entry.getKey(), entry.getValue());
|
3489 |
LOGGER.info("{} = {}", entry.getKey(), entry.getValue());
|
| 3470 |
}
|
3490 |
}
|
| 3471 |
LOGGER.info("id- {}, imei- {}, lastScan = {}, Scheme sum - {}", inventoryItem.getId(), inventoryItem.getSerialNumber(), inventoryItem.getLastScanType(), schemeSum);
|
3491 |
LOGGER.info("id- {}, imei- {}, lastScan = {}, Scheme sum - {}", inventoryItem.getId(), inventoryItem.getSerialNumber(), inventoryItem.getLastScanType(), schemeSum);
|
| 3472 |
}
|
3492 |
}
|
| 3473 |
}
|
3493 |
}
|
| Line 3558... |
Line 3578... |
| 3558 |
Map<Integer, PartnerCollectionRemark> salesEscalatedRemarksMap = partnerCollectionRemarks.stream().filter(x -> x.getRemark().equals(CollectionRemark.SALES_ESCALATION)).collect(Collectors.toMap(x -> x.getFofoId(), x -> x));
|
3578 |
Map<Integer, PartnerCollectionRemark> salesEscalatedRemarksMap = partnerCollectionRemarks.stream().filter(x -> x.getRemark().equals(CollectionRemark.SALES_ESCALATION)).collect(Collectors.toMap(x -> x.getFofoId(), x -> x));
|
| 3559 |
|
3579 |
|
| 3560 |
|
3580 |
|
| 3561 |
if (!rbmEscalatedRemarksMap.isEmpty()) {
|
3581 |
if (!rbmEscalatedRemarksMap.isEmpty()) {
|
| 3562 |
//
|
3582 |
//
|
| 3563 |
for (Map.Entry<String, Set<Integer>> storeGuyEntry : csService.getAuthUserPartnerIdMappingByCategoryIds(Arrays.asList(ProfitMandiConstants.TICKET_CATEGORY_RBM), true).entrySet()) {
|
3583 |
for (Entry<String, Set<Integer>> storeGuyEntry : csService.getAuthUserPartnerIdMappingByCategoryIds(Arrays.asList(ProfitMandiConstants.TICKET_CATEGORY_RBM), true).entrySet()) {
|
| 3564 |
List<PartnerCollectionRemark> filteredRows = storeGuyEntry.getValue().stream()
|
3584 |
List<PartnerCollectionRemark> filteredRows = storeGuyEntry.getValue().stream()
|
| 3565 |
.map(x -> rbmEscalatedRemarksMap.get(x)).filter(x -> x != null).collect(Collectors.toList());
|
3585 |
.map(x -> rbmEscalatedRemarksMap.get(x)).filter(x -> x != null).collect(Collectors.toList());
|
| 3566 |
String subject = "Partners escalated to RBM-L2";
|
3586 |
String subject = "Partners escalated to RBM-L2";
|
| 3567 |
String messageText = this.getMessageForRBMEscalatedPartners(filteredRows);
|
3587 |
String messageText = this.getMessageForRBMEscalatedPartners(filteredRows);
|
| 3568 |
|
3588 |
|
| Line 3581... |
Line 3601... |
| 3581 |
|
3601 |
|
| 3582 |
}
|
3602 |
}
|
| 3583 |
}
|
3603 |
}
|
| 3584 |
if (!salesEscalatedRemarksMap.isEmpty()) {
|
3604 |
if (!salesEscalatedRemarksMap.isEmpty()) {
|
| 3585 |
//
|
3605 |
//
|
| 3586 |
for (Map.Entry<String, Set<Integer>> storeGuyEntry : csService.getAuthUserPartnerIdMappingByCategoryIds(Arrays.asList(ProfitMandiConstants.TICKET_CATEGORY_SALES, ProfitMandiConstants.TICKET_CATEGORY_RBM), true).entrySet()) {
|
3606 |
for (Entry<String, Set<Integer>> storeGuyEntry : csService.getAuthUserPartnerIdMappingByCategoryIds(Arrays.asList(ProfitMandiConstants.TICKET_CATEGORY_SALES, ProfitMandiConstants.TICKET_CATEGORY_RBM), true).entrySet()) {
|
| 3587 |
List<PartnerCollectionRemark> filteredRows = storeGuyEntry.getValue().stream()
|
3607 |
List<PartnerCollectionRemark> filteredRows = storeGuyEntry.getValue().stream()
|
| 3588 |
.map(x -> salesEscalatedRemarksMap.get(x)).filter(x -> x != null).collect(Collectors.toList());
|
3608 |
.map(x -> salesEscalatedRemarksMap.get(x)).filter(x -> x != null).collect(Collectors.toList());
|
| 3589 |
String subject = "Partners escalated to Sales";
|
3609 |
String subject = "Partners escalated to Sales";
|
| 3590 |
String messageText = this.getMessageForSalesEscalatedPartners(filteredRows);
|
3610 |
String messageText = this.getMessageForSalesEscalatedPartners(filteredRows);
|
| 3591 |
|
3611 |
|
| Line 3617... |
Line 3637... |
| 3617 |
ProfitMandiBusinessException, MessagingException, UnsupportedEncodingException {
|
3637 |
ProfitMandiBusinessException, MessagingException, UnsupportedEncodingException {
|
| 3618 |
List<NonSdBuying> nonSdByuingActiveList = nonSdBuyingRepository.selectAllActiveNonSDBuyingList(true);
|
3638 |
List<NonSdBuying> nonSdByuingActiveList = nonSdBuyingRepository.selectAllActiveNonSDBuyingList(true);
|
| 3619 |
Map<Integer, NonSdBuying> unAuthorizedBuyingMap = nonSdByuingActiveList.stream().collect(Collectors.toMap(x -> x.getFofoId(), x -> x));
|
3639 |
Map<Integer, NonSdBuying> unAuthorizedBuyingMap = nonSdByuingActiveList.stream().collect(Collectors.toMap(x -> x.getFofoId(), x -> x));
|
| 3620 |
|
3640 |
|
| 3621 |
if (!unAuthorizedBuyingMap.isEmpty()) {
|
3641 |
if (!unAuthorizedBuyingMap.isEmpty()) {
|
| 3622 |
for (Map.Entry<String, Set<Integer>> storeGuyEntry : csService.getAuthUserPartnerIdMappingByCategoryIds(Arrays.asList(ProfitMandiConstants.TICKET_CATEGORY_RBM, ProfitMandiConstants.TICKET_CATEGORY_SALES), true).entrySet()) {
|
3642 |
for (Entry<String, Set<Integer>> storeGuyEntry : csService.getAuthUserPartnerIdMappingByCategoryIds(Arrays.asList(ProfitMandiConstants.TICKET_CATEGORY_RBM, ProfitMandiConstants.TICKET_CATEGORY_SALES), true).entrySet()) {
|
| 3623 |
List<NonSdBuying> unAuthorizedfilteredRows = storeGuyEntry.getValue().stream()
|
3643 |
List<NonSdBuying> unAuthorizedfilteredRows = storeGuyEntry.getValue().stream()
|
| 3624 |
.map(x -> unAuthorizedBuyingMap.get(x)).filter(x -> x != null).collect(Collectors.toList());
|
3644 |
.map(x -> unAuthorizedBuyingMap.get(x)).filter(x -> x != null).collect(Collectors.toList());
|
| 3625 |
if (!unAuthorizedfilteredRows.isEmpty()) {
|
3645 |
if (!unAuthorizedfilteredRows.isEmpty()) {
|
| 3626 |
String subject = "Unauthorized Buying";
|
3646 |
String subject = "Unauthorized Buying";
|
| 3627 |
String messageText = this.getMessageForUnauthorizedBuying(unAuthorizedfilteredRows);
|
3647 |
String messageText = this.getMessageForUnauthorizedBuying(unAuthorizedfilteredRows);
|
| Line 3848... |
Line 3868... |
| 3848 |
|
3868 |
|
| 3849 |
private void sendUnholdEmail(List<Order> orders) throws Exception {
|
3869 |
private void sendUnholdEmail(List<Order> orders) throws Exception {
|
| 3850 |
|
3870 |
|
| 3851 |
|
3871 |
|
| 3852 |
orders.forEach(x -> x.setShipmentHold(false));
|
3872 |
orders.forEach(x -> x.setShipmentHold(false));
|
| 3853 |
orders = orders.stream().filter(x->x.getRefundTimestamp()!= null).collect(Collectors.toList());
|
3873 |
orders = orders.stream().filter(x -> x.getRefundTimestamp() != null).collect(Collectors.toList());
|
| 3854 |
|
3874 |
|
| 3855 |
double totalAmount = orders.stream().collect(Collectors.summingDouble(x -> x.getTotalAmount()));
|
3875 |
double totalAmount = orders.stream().collect(Collectors.summingDouble(x -> x.getTotalAmount()));
|
| 3856 |
|
3876 |
|
| 3857 |
List<String> authUserEmail = csService.getAuthUserIdByPartnerId(orders.get(0).getRetailerId()).stream().map(x -> x.getEmailId()).collect(Collectors.toList());
|
3877 |
List<String> authUserEmail = csService.getAuthUserIdByPartnerId(orders.get(0).getRetailerId()).stream().map(x -> x.getEmailId()).collect(Collectors.toList());
|
| 3858 |
authUserEmail.add("vinay.p@smartdukaan.com");
|
3878 |
authUserEmail.add("vinay.p@smartdukaan.com");
|
| Line 3970... |
Line 3990... |
| 3970 |
|
3990 |
|
| 3971 |
if (sdCreditRequirement == null) {
|
3991 |
if (sdCreditRequirement == null) {
|
| 3972 |
sdCreditRequirement = new SDCreditRequirement();
|
3992 |
sdCreditRequirement = new SDCreditRequirement();
|
| 3973 |
sdCreditRequirement.setFofoId(fofoId);
|
3993 |
sdCreditRequirement.setFofoId(fofoId);
|
| 3974 |
sdCreditRequirement.setCreditDays(15);
|
3994 |
sdCreditRequirement.setCreditDays(15);
|
| 3975 |
sdCreditRequirement.setInterestRate(BigDecimal.valueOf(0.05));
|
3995 |
sdCreditRequirement.setInterestRate(ProfitMandiConstants.NEW_INTEREST_RATE);
|
| 3976 |
sdCreditRequirement.setRisk(CreditRisk.HIGH_RISK);
|
3996 |
sdCreditRequirement.setRisk(CreditRisk.HIGH_RISK);
|
| 3977 |
sdCreditRequirement.setUtilizedAmount(BigDecimal.ZERO);
|
3997 |
sdCreditRequirement.setUtilizedAmount(BigDecimal.ZERO);
|
| 3978 |
sdCreditRequirement.setCreateTimestamp(LocalDateTime.now());
|
3998 |
sdCreditRequirement.setCreateTimestamp(LocalDateTime.now());
|
| 3979 |
sdCreditRequirement.setUpdateTimestamp(LocalDateTime.now());
|
3999 |
sdCreditRequirement.setUpdateTimestamp(LocalDateTime.now());
|
| 3980 |
sdCreditRequirementRepository.persist(sdCreditRequirement);
|
4000 |
sdCreditRequirementRepository.persist(sdCreditRequirement);
|
| Line 4044... |
Line 4064... |
| 4044 |
ProfitMandiBusinessException, MessagingException, IOException {
|
4064 |
ProfitMandiBusinessException, MessagingException, IOException {
|
| 4045 |
String subject = "Default Partners";
|
4065 |
String subject = "Default Partners";
|
| 4046 |
|
4066 |
|
| 4047 |
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);
|
4067 |
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);
|
| 4048 |
|
4068 |
|
| 4049 |
for (Map.Entry<String, Set<Integer>> storeGuyEntry : csService.getAuthUserPartnerIdMappingByCategoryIds(categoryIds, false).entrySet()) {
|
4069 |
for (Entry<String, Set<Integer>> storeGuyEntry : csService.getAuthUserPartnerIdMappingByCategoryIds(categoryIds, false).entrySet()) {
|
| 4050 |
List<Loan> filteredRows = new ArrayList<>();
|
4070 |
List<Loan> filteredRows = new ArrayList<>();
|
| 4051 |
for (Loan loan : defaultLoans) {
|
4071 |
for (Loan loan : defaultLoans) {
|
| 4052 |
|
4072 |
|
| 4053 |
if (storeGuyEntry.getValue().contains(loan.getFofoId())) {
|
4073 |
if (storeGuyEntry.getValue().contains(loan.getFofoId())) {
|
| 4054 |
|
4074 |
|
| Line 4118... |
Line 4138... |
| 4118 |
return sb.toString();
|
4138 |
return sb.toString();
|
| 4119 |
}
|
4139 |
}
|
| 4120 |
|
4140 |
|
| 4121 |
private String getMessageForDueDateCross(List<Loan> loans) throws ProfitMandiBusinessException {
|
4141 |
private String getMessageForDueDateCross(List<Loan> loans) throws ProfitMandiBusinessException {
|
| 4122 |
Map<Integer, com.spice.profitmandi.dao.model.FofoReportingModel> fofoReportingModelMap = csService.getPartnerIdSalesHeaders();
|
4142 |
Map<Integer, com.spice.profitmandi.dao.model.FofoReportingModel> fofoReportingModelMap = csService.getPartnerIdSalesHeaders();
|
| 4123 |
Map<Integer, com.spice.profitmandi.dao.model.FofoRBMReportingModel> fofoRbmReportingModelMap = csService.getPartnerIdRBMHeaders();
|
4143 |
Map<Integer, FofoRBMReportingModel> fofoRbmReportingModelMap = csService.getPartnerIdRBMHeaders();
|
| 4124 |
StringBuilder sb = new StringBuilder();
|
4144 |
StringBuilder sb = new StringBuilder();
|
| 4125 |
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/>" +
|
4145 |
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/>" +
|
| 4126 |
"<table style='border:1px solid black ;padding: 5px';>");
|
4146 |
"<table style='border:1px solid black ;padding: 5px';>");
|
| 4127 |
sb.append("<tbody>\n" + "<tr>\n" +
|
4147 |
sb.append("<tbody>\n" + "<tr>\n" +
|
| 4128 |
"<th style='border:1px solid black;padding: 5px'>PartnerName</th>\n" +
|
4148 |
"<th style='border:1px solid black;padding: 5px'>PartnerName</th>\n" +
|
| Line 4175... |
Line 4195... |
| 4175 |
}
|
4195 |
}
|
| 4176 |
|
4196 |
|
| 4177 |
private void sendDueDateCrossLoanAlert(List<Loan> dueDateCrossLoans) throws Exception {
|
4197 |
private void sendDueDateCrossLoanAlert(List<Loan> dueDateCrossLoans) throws Exception {
|
| 4178 |
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);
|
4198 |
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);
|
| 4179 |
|
4199 |
|
| 4180 |
for (Map.Entry<String, Set<Integer>> storeGuyEntry : csService.getAuthUserPartnerIdMappingByCategoryIds(categoryIds, false).entrySet()) {
|
4200 |
for (Entry<String, Set<Integer>> storeGuyEntry : csService.getAuthUserPartnerIdMappingByCategoryIds(categoryIds, false).entrySet()) {
|
| 4181 |
List<Loan> filteredRows = new ArrayList<>();
|
4201 |
List<Loan> filteredRows = new ArrayList<>();
|
| 4182 |
for (Loan loan : dueDateCrossLoans) {
|
4202 |
for (Loan loan : dueDateCrossLoans) {
|
| 4183 |
|
4203 |
|
| 4184 |
if (storeGuyEntry.getValue().contains(loan.getFofoId())) {
|
4204 |
if (storeGuyEntry.getValue().contains(loan.getFofoId())) {
|
| 4185 |
|
4205 |
|