| Line 25... |
Line 25... |
| 25 |
import com.spice.profitmandi.dao.cart.CartService;
|
25 |
import com.spice.profitmandi.dao.cart.CartService;
|
| 26 |
import com.spice.profitmandi.dao.cart.SmartCartService;
|
26 |
import com.spice.profitmandi.dao.cart.SmartCartService;
|
| 27 |
import com.spice.profitmandi.dao.entity.auth.AuthUser;
|
27 |
import com.spice.profitmandi.dao.entity.auth.AuthUser;
|
| 28 |
import com.spice.profitmandi.dao.entity.auth.PartnerCollectionRemark;
|
28 |
import com.spice.profitmandi.dao.entity.auth.PartnerCollectionRemark;
|
| 29 |
import com.spice.profitmandi.dao.entity.catalog.*;
|
29 |
import com.spice.profitmandi.dao.entity.catalog.*;
|
| - |
|
30 |
import com.spice.profitmandi.dao.entity.catalog.Offer;
|
| 30 |
import com.spice.profitmandi.dao.entity.cs.NonSdBuying;
|
31 |
import com.spice.profitmandi.dao.entity.cs.NonSdBuying;
|
| 31 |
import com.spice.profitmandi.dao.entity.cs.Position;
|
32 |
import com.spice.profitmandi.dao.entity.cs.Position;
|
| 32 |
import com.spice.profitmandi.dao.entity.cs.Ticket;
|
33 |
import com.spice.profitmandi.dao.entity.cs.Ticket;
|
| 33 |
import com.spice.profitmandi.dao.entity.dtr.*;
|
34 |
import com.spice.profitmandi.dao.entity.dtr.*;
|
| 34 |
import com.spice.profitmandi.dao.entity.dtr.User;
|
35 |
import com.spice.profitmandi.dao.entity.dtr.User;
|
| Line 84... |
Line 85... |
| 84 |
import com.spice.profitmandi.service.integrations.CCAvenuePaymentService;
|
85 |
import com.spice.profitmandi.service.integrations.CCAvenuePaymentService;
|
| 85 |
import com.spice.profitmandi.service.integrations.RazorpayPaymentService;
|
86 |
import com.spice.profitmandi.service.integrations.RazorpayPaymentService;
|
| 86 |
import com.spice.profitmandi.service.integrations.bharti.model.BAGInsuranceModel;
|
87 |
import com.spice.profitmandi.service.integrations.bharti.model.BAGInsuranceModel;
|
| 87 |
import com.spice.profitmandi.service.integrations.gstpro.GstProAuthService;
|
88 |
import com.spice.profitmandi.service.integrations.gstpro.GstProAuthService;
|
| 88 |
import com.spice.profitmandi.service.integrations.gstpro.GstProService;
|
89 |
import com.spice.profitmandi.service.integrations.gstpro.GstProService;
|
| - |
|
90 |
import com.spice.profitmandi.service.integrations.pinelabs.dto.*;
|
| 89 |
import com.spice.profitmandi.service.integrations.psismart.PsiSmartService;
|
91 |
import com.spice.profitmandi.service.integrations.psismart.PsiSmartService;
|
| 90 |
import com.spice.profitmandi.service.integrations.smartping.SmartPingService;
|
92 |
import com.spice.profitmandi.service.integrations.smartping.SmartPingService;
|
| 91 |
import com.spice.profitmandi.service.integrations.toffee.ToffeeService;
|
93 |
import com.spice.profitmandi.service.integrations.toffee.ToffeeService;
|
| 92 |
import com.spice.profitmandi.service.inventory.*;
|
94 |
import com.spice.profitmandi.service.inventory.*;
|
| 93 |
import com.spice.profitmandi.service.offers.OfferService;
|
95 |
import com.spice.profitmandi.service.offers.OfferService;
|
| Line 1155... |
Line 1157... |
| 1155 |
CreditBlockedExceptionPartnersRepository creditBlockedExceptionPartnersRepository;
|
1157 |
CreditBlockedExceptionPartnersRepository creditBlockedExceptionPartnersRepository;
|
| 1156 |
|
1158 |
|
| 1157 |
@Autowired
|
1159 |
@Autowired
|
| 1158 |
SDCreditService sdCreditService;
|
1160 |
SDCreditService sdCreditService;
|
| 1159 |
|
1161 |
|
| - |
|
1162 |
@Autowired
|
| - |
|
1163 |
com.spice.profitmandi.service.integrations.pinelabs.PinelabsAffordabilityService pinelabsAffordabilityService;
|
| - |
|
1164 |
|
| - |
|
1165 |
@Autowired
|
| - |
|
1166 |
com.spice.profitmandi.service.integrations.pinelabs.PinelabsAuthService pinelabsAuthService;
|
| - |
|
1167 |
public void testAffordability() {
|
| - |
|
1168 |
Money orderAmount = new Money("1000000", "INR");
|
| - |
|
1169 |
Money discountAmount = new Money("0", "INR");
|
| - |
|
1170 |
List<ProductDetails> productDetails = Arrays.asList(new ProductDetails(orderAmount, discountAmount, "Alpha_2"));
|
| - |
|
1171 |
OfferDiscoveryRequest offerDiscoveryRequest = new com.spice.profitmandi.service.integrations.pinelabs.dto.OfferDiscoveryRequest(orderAmount, productDetails, new AffordabilityIssuer("12345678"));
|
| - |
|
1172 |
OfferDiscoveryResponse offerDiscoveryResponse = pinelabsAffordabilityService.discoverOffers(offerDiscoveryRequest);
|
| - |
|
1173 |
System.out.println(offerDiscoveryResponse);
|
| - |
|
1174 |
}
|
| 1160 |
public void test() throws Exception {
|
1175 |
public void test() throws Exception {
|
| - |
|
1176 |
|
| - |
|
1177 |
System.out.println(pinelabsAuthService.getAccessToken());
|
| - |
|
1178 |
testAffordability();
|
| - |
|
1179 |
|
| 1161 |
//System.out.println(trialFormRepository.selectByEmailOrMobile("9990381568"));
|
1180 |
//System.out.println(trialFormRepository.selectByEmailOrMobile("9990381568"));
|
| 1162 |
/*CreditBlockedExceptionPartner creditBlockedExceptionPartner = creditBlockedExceptionPartnersRepository.select(175139430);
|
1181 |
/*CreditBlockedExceptionPartner creditBlockedExceptionPartner = creditBlockedExceptionPartnersRepository.select(175139430);
|
| 1163 |
System.out.println(creditBlockedExceptionPartner);*/
|
1182 |
System.out.println(creditBlockedExceptionPartner);*/
|
| 1164 |
//this.updatePartnerLimit(175139595);
|
1183 |
//this.updatePartnerLimit(175139595);
|
| 1165 |
this.releaseBlockedLimit();
|
1184 |
//this.releaseBlockedLimit();
|
| 1166 |
//sdCreditService.resetHardLimit();
|
1185 |
//sdCreditService.resetHardLimit();
|
| 1167 |
//migrations.migrateSerialInvoiceMap();
|
1186 |
//migrations.migrateSerialInvoiceMap();
|
| 1168 |
//runOnceTasks.checkRewardsEligibility();
|
1187 |
//runOnceTasks.checkRewardsEligibility();
|
| 1169 |
//hybridEncryptor.getJwt();
|
1188 |
//hybridEncryptor.getJwt();
|
| 1170 |
/*System.out.printf("Date|Transaction Id|Serial Number|Sale Amount|Swipe Payout|Discount Payout%n");
|
1189 |
/*System.out.printf("Date|Transaction Id|Serial Number|Sale Amount|Swipe Payout|Discount Payout%n");
|
| Line 2929... |
Line 2948... |
| 2929 |
public void sendUnscheduledFollowUpMail() throws Exception {
|
2948 |
public void sendUnscheduledFollowUpMail() throws Exception {
|
| 2930 |
List<Lead> missedScheduleLeads = leadRepository.selectLeadsScheduledBetweenDate(null, LocalDate.now().atStartOfDay().minusDays(30), LocalDateTime.now().toLocalDate().atStartOfDay());
|
2949 |
List<Lead> missedScheduleLeads = leadRepository.selectLeadsScheduledBetweenDate(null, LocalDate.now().atStartOfDay().minusDays(30), LocalDateTime.now().toLocalDate().atStartOfDay());
|
| 2931 |
List<Lead> leadsScheduledForToday = leadRepository.selectLeadsScheduledBetweenDate(null, LocalDate.now().atStartOfDay(), LocalDate.now().atTime(LocalTime.MAX));
|
2950 |
List<Lead> leadsScheduledForToday = leadRepository.selectLeadsScheduledBetweenDate(null, LocalDate.now().atStartOfDay(), LocalDate.now().atTime(LocalTime.MAX));
|
| 2932 |
List<Integer> authIds = missedScheduleLeads.stream().map(x -> x.getAssignTo()).distinct().collect(Collectors.toList());
|
2951 |
List<Integer> authIds = missedScheduleLeads.stream().map(x -> x.getAssignTo()).distinct().collect(Collectors.toList());
|
| 2933 |
LOGGER.info(authIds.size());
|
2952 |
LOGGER.info(authIds.size());
|
| 2934 |
Map<Integer, AuthUser> authUserMap = authRepository.selectAllAuthUserByIds(authIds).stream().collect(Collectors.toMap(x -> x.getId(), x -> x));
|
2953 |
Map<Integer, AuthUser> authUserMap = authRepository.selectByIds(authIds).stream().collect(Collectors.toMap(x -> x.getId(), x -> x));
|
| 2935 |
LOGGER.info(authUserMap.size());
|
2954 |
LOGGER.info(authUserMap.size());
|
| 2936 |
//if(true) return;
|
2955 |
//if(true) return;
|
| 2937 |
|
2956 |
|
| 2938 |
missedScheduleLeads = missedScheduleLeads.stream().sorted(Comparator.comparing(Lead::getState, String.CASE_INSENSITIVE_ORDER).thenComparing(Lead::getAssignTo).thenComparing(Lead::getScheduledTimestamp)).collect(Collectors.toList());
|
2957 |
missedScheduleLeads = missedScheduleLeads.stream().sorted(Comparator.comparing(Lead::getState, String.CASE_INSENSITIVE_ORDER).thenComparing(Lead::getAssignTo).thenComparing(Lead::getScheduledTimestamp)).collect(Collectors.toList());
|
| 2939 |
//leadsScheduledForToday
|
2958 |
//leadsScheduledForToday
|
| Line 3279... |
Line 3298... |
| 3279 |
|
3298 |
|
| 3280 |
Map<Integer, CustomRetailer> customRetailers = retailerService.getAllFofoRetailers();
|
3299 |
Map<Integer, CustomRetailer> customRetailers = retailerService.getAllFofoRetailers();
|
| 3281 |
|
3300 |
|
| 3282 |
List<Integer> assignTo = Arrays.asList(15, 9, 54, 53);
|
3301 |
List<Integer> assignTo = Arrays.asList(15, 9, 54, 53);
|
| 3283 |
|
3302 |
|
| 3284 |
Map<Integer, AuthUser> assignAuthUserMap = authRepository.selectAllAuthUserByIds(assignTo).stream().collect(Collectors.toMap(x -> x.getId(), x -> x));
|
3303 |
Map<Integer, AuthUser> assignAuthUserMap = authRepository.selectByIds(assignTo).stream().collect(Collectors.toMap(x -> x.getId(), x -> x));
|
| 3285 |
|
3304 |
|
| 3286 |
List<String> sendTo = Arrays.asList("kamini.sharma@smartdukaan.com", "tarun.verma@smartdukaan.com", "sm@smartdukaan.com");
|
3305 |
List<String> sendTo = Arrays.asList("kamini.sharma@smartdukaan.com", "tarun.verma@smartdukaan.com", "sm@smartdukaan.com");
|
| 3287 |
LOGGER.info("partnerProblem" + partnerProblems);
|
3306 |
LOGGER.info("partnerProblem" + partnerProblems);
|
| 3288 |
StringBuilder sb = new StringBuilder();
|
3307 |
StringBuilder sb = new StringBuilder();
|
| 3289 |
sb.append("<htl><body>");
|
3308 |
sb.append("<htl><body>");
|
| Line 3776... |
Line 3795... |
| 3776 |
}
|
3795 |
}
|
| 3777 |
public void updatePartnerLimit(int fofoId) throws ProfitMandiBusinessException {
|
3796 |
public void updatePartnerLimit(int fofoId) throws ProfitMandiBusinessException {
|
| 3778 |
LocalDateTime firstBillingDate = transactionRepository.getFirstBillingDate(fofoId);
|
3797 |
LocalDateTime firstBillingDate = transactionRepository.getFirstBillingDate(fofoId);
|
| 3779 |
|
3798 |
|
| 3780 |
CreditAccount creditAccount = creditAccountRepository.selectByFofoIdAndGateway(fofoId, Gateway.SDDIRECT);
|
3799 |
CreditAccount creditAccount = creditAccountRepository.selectByFofoIdAndGateway(fofoId, Gateway.SDDIRECT);
|
| 3781 |
long utilizationAmount = sdCreditService.getUtilizationAmount(fofoId);
|
3800 |
BigDecimal utilizationAmount = sdCreditService.getUtilizationAmount(fofoId);
|
| 3782 |
PartnerDailyInvestment partnerDailyInvestment = partnerInvestmentService.getInvestment(fofoId, 0);
|
3801 |
PartnerDailyInvestment partnerDailyInvestment = partnerInvestmentService.getInvestment(fofoId, 0);
|
| 3783 |
BigDecimal suggestedAmount = this.getSuggestedAmount(creditAccount, partnerDailyInvestment, utilizationAmount, null);
|
3802 |
BigDecimal suggestedAmount = this.getSuggestedAmount(creditAccount, partnerDailyInvestment, utilizationAmount, null);
|
| 3784 |
SDCreditRequirement sdCreditRequirement = sdCreditRequirementRepository.selectByFofoId(fofoId);
|
3803 |
SDCreditRequirement sdCreditRequirement = sdCreditRequirementRepository.selectByFofoId(fofoId);
|
| 3785 |
|
3804 |
|
| 3786 |
LOGGER.info("suggestedAmount {} ", suggestedAmount);
|
3805 |
LOGGER.info("suggestedAmount {} ", suggestedAmount);
|
| Line 3803... |
Line 3822... |
| 3803 |
LOGGER.info("Suggested Amount - {}", suggestedAmount);
|
3822 |
LOGGER.info("Suggested Amount - {}", suggestedAmount);
|
| 3804 |
sdCreditRequirement.setSuggestedLimit(suggestedAmount);
|
3823 |
sdCreditRequirement.setSuggestedLimit(suggestedAmount);
|
| 3805 |
if (!sdCreditRequirement.isHardLimit()) {
|
3824 |
if (!sdCreditRequirement.isHardLimit()) {
|
| 3806 |
sdCreditRequirement.setLimit(suggestedAmount);
|
3825 |
sdCreditRequirement.setLimit(suggestedAmount);
|
| 3807 |
}
|
3826 |
}
|
| 3808 |
BigDecimal utilizedLimit = new BigDecimal(sdCreditService.getUtilizationAmount(fofoId));
|
3827 |
BigDecimal utilizedLimit = sdCreditService.getUtilizationAmount(fofoId);
|
| 3809 |
|
3828 |
|
| 3810 |
BigDecimal availableLimit = sdCreditRequirement.getLimit().subtract(utilizedLimit);
|
3829 |
BigDecimal availableLimit = sdCreditRequirement.getLimit().subtract(utilizedLimit);
|
| 3811 |
|
3830 |
|
| 3812 |
LOGGER.info("utilizedLimit {} ", utilizedLimit);
|
3831 |
LOGGER.info("utilizedLimit {} ", utilizedLimit);
|
| 3813 |
|
3832 |
|
| Line 3836... |
Line 3855... |
| 3836 |
for (Entry<Integer, CustomRetailer> customRetailerEntry : customRetailerMap.entrySet()) {
|
3855 |
for (Entry<Integer, CustomRetailer> customRetailerEntry : customRetailerMap.entrySet()) {
|
| 3837 |
int fofoId = customRetailerEntry.getKey();
|
3856 |
int fofoId = customRetailerEntry.getKey();
|
| 3838 |
LocalDateTime firstBillingDate = transactionRepository.getFirstBillingDate(fofoId);
|
3857 |
LocalDateTime firstBillingDate = transactionRepository.getFirstBillingDate(fofoId);
|
| 3839 |
|
3858 |
|
| 3840 |
CreditAccount creditAccount = creditAccountMap.get(fofoId);
|
3859 |
CreditAccount creditAccount = creditAccountMap.get(fofoId);
|
| 3841 |
long utilizationAmount = sdCreditService.getUtilizationAmount(fofoId);
|
3860 |
BigDecimal utilizationAmount = sdCreditService.getUtilizationAmount(fofoId);
|
| 3842 |
PartnerDailyInvestment partnerDailyInvestment = partnerInvestmentService.getInvestment(fofoId, 0);
|
3861 |
PartnerDailyInvestment partnerDailyInvestment = partnerInvestmentService.getInvestment(fofoId, 0);
|
| 3843 |
BigDecimal suggestedAmount = this.getSuggestedAmount(creditAccount, partnerDailyInvestment, utilizationAmount, fofoSidbiLimitMap.get(fofoId));
|
3862 |
BigDecimal suggestedAmount = this.getSuggestedAmount(creditAccount, partnerDailyInvestment, utilizationAmount, fofoSidbiLimitMap.get(fofoId));
|
| 3844 |
SDCreditRequirement sdCreditRequirement = sdCreditRequirementMap.get(fofoId);
|
3863 |
SDCreditRequirement sdCreditRequirement = sdCreditRequirementMap.get(fofoId);
|
| 3845 |
|
3864 |
|
| 3846 |
LOGGER.info("suggestedAmount {} ", suggestedAmount);
|
3865 |
LOGGER.info("suggestedAmount {} ", suggestedAmount);
|
| Line 3863... |
Line 3882... |
| 3863 |
|
3882 |
|
| 3864 |
sdCreditRequirement.setSuggestedLimit(suggestedAmount);
|
3883 |
sdCreditRequirement.setSuggestedLimit(suggestedAmount);
|
| 3865 |
if (!sdCreditRequirement.isHardLimit()) {
|
3884 |
if (!sdCreditRequirement.isHardLimit()) {
|
| 3866 |
sdCreditRequirement.setLimit(suggestedAmount);
|
3885 |
sdCreditRequirement.setLimit(suggestedAmount);
|
| 3867 |
}
|
3886 |
}
|
| 3868 |
BigDecimal utilizedLimit = new BigDecimal(sdCreditService.getUtilizationAmount(fofoId));
|
3887 |
BigDecimal utilizedLimit = sdCreditService.getUtilizationAmount(fofoId);
|
| 3869 |
|
3888 |
|
| 3870 |
BigDecimal availableLimit = sdCreditRequirement.getLimit().subtract(utilizedLimit);
|
3889 |
BigDecimal availableLimit = sdCreditRequirement.getLimit().subtract(utilizedLimit);
|
| 3871 |
|
3890 |
|
| 3872 |
LOGGER.info("utilizedLimit {} ", utilizedLimit);
|
3891 |
LOGGER.info("utilizedLimit {} ", utilizedLimit);
|
| 3873 |
|
3892 |
|
| Line 3916... |
Line 3935... |
| 3916 |
);*/
|
3935 |
);*/
|
| 3917 |
|
3936 |
|
| 3918 |
private static List<Integer> hundredPercentLimitPartnerIds = Arrays.asList();
|
3937 |
private static List<Integer> hundredPercentLimitPartnerIds = Arrays.asList();
|
| 3919 |
|
3938 |
|
| 3920 |
private BigDecimal getSuggestedAmount(CreditAccount creditAccount, PartnerDailyInvestment
|
3939 |
private BigDecimal getSuggestedAmount(CreditAccount creditAccount, PartnerDailyInvestment
|
| 3921 |
partnerDailyInvestment, long utilizationAmount, BigDecimal sidbiLimit) {
|
3940 |
partnerDailyInvestment, BigDecimal utilizationAmount, BigDecimal sidbiLimit) {
|
| 3922 |
BigDecimal suggestedAmount = BigDecimal.ZERO;
|
3941 |
BigDecimal suggestedAmount = BigDecimal.ZERO;
|
| - |
|
3942 |
double utilization = utilizationAmount != null ? utilizationAmount.doubleValue() : 0;
|
| 3923 |
//1 LAC
|
3943 |
//1 LAC
|
| 3924 |
if (creditAccount == null || creditAccount.getGateway().equals(Gateway.SDDIRECT)) {
|
3944 |
if (creditAccount == null || creditAccount.getGateway().equals(Gateway.SDDIRECT)) {
|
| 3925 |
|
3945 |
|
| 3926 |
if (partnerDailyInvestment != null) {
|
3946 |
if (partnerDailyInvestment != null) {
|
| 3927 |
if (hundredPercentLimitPartnerIds.contains(partnerDailyInvestment.getFofoId())) {
|
3947 |
if (hundredPercentLimitPartnerIds.contains(partnerDailyInvestment.getFofoId())) {
|
| 3928 |
suggestedAmount = getSuggestedAmount(partnerDailyInvestment.getTotalInvestment() - utilizationAmount, 1);
|
3948 |
suggestedAmount = getSuggestedAmount(partnerDailyInvestment.getTotalInvestment() - utilization, 1);
|
| 3929 |
suggestedAmount = suggestedAmount.min(BigDecimal.valueOf(1500000));
|
3949 |
suggestedAmount = suggestedAmount.min(BigDecimal.valueOf(1500000));
|
| 3930 |
} else {
|
3950 |
} else {
|
| 3931 |
suggestedAmount = getSuggestedLimit(partnerDailyInvestment.getTotalInvestment() - utilizationAmount);
|
3951 |
suggestedAmount = getSuggestedLimit(partnerDailyInvestment.getTotalInvestment() - utilization);
|
| 3932 |
}
|
3952 |
}
|
| 3933 |
}
|
3953 |
}
|
| 3934 |
if (suggestedAmount.doubleValue() < 0) {
|
3954 |
if (suggestedAmount.doubleValue() < 0) {
|
| 3935 |
suggestedAmount = BigDecimal.ZERO;
|
3955 |
suggestedAmount = BigDecimal.ZERO;
|
| 3936 |
}
|
3956 |
}
|
| 3937 |
} else if (creditAccount.getGateway().equals(Gateway.SIDBI) && sidbiLimit != null) {
|
3957 |
} else if (creditAccount.getGateway().equals(Gateway.SIDBI) && sidbiLimit != null) {
|
| 3938 |
suggestedAmount = getSuggestedLimit(partnerDailyInvestment.getTotalInvestment() - utilizationAmount);
|
3958 |
suggestedAmount = getSuggestedLimit(partnerDailyInvestment.getTotalInvestment() - utilization);
|
| 3939 |
suggestedAmount = suggestedAmount.max(sidbiLimit);
|
3959 |
suggestedAmount = suggestedAmount.max(sidbiLimit);
|
| 3940 |
|
3960 |
|
| 3941 |
|
3961 |
|
| 3942 |
}
|
3962 |
}
|
| 3943 |
return suggestedAmount;
|
3963 |
return suggestedAmount;
|