Subversion Repositories SmartDukaan

Rev

Rev 30972 | Rev 30983 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 30972 Rev 30982
Line 1820... Line 1820...
1820
		}
1820
		}
1821
 
1821
 
1822
		Map<Integer, FofoReportingModel> partnerSalesHeadersMap = this.getPartnerIdSalesHeaders();
1822
		Map<Integer, FofoReportingModel> partnerSalesHeadersMap = this.getPartnerIdSalesHeaders();
1823
		for (Integer fofoId : fofoIds) {
1823
		for (Integer fofoId : fofoIds) {
1824
			SaleTargetReportModel model = saleTargetReportModelMap.get(fofoId);
1824
			SaleTargetReportModel model = saleTargetReportModelMap.get(fofoId);
-
 
1825
 
-
 
1826
			com.spice.profitmandi.dao.entity.user.User user = userUserRepository.selectById(fofoId);
-
 
1827
 
-
 
1828
			Address address = addressRepository.selectById(user.getAddressId());
-
 
1829
 
-
 
1830
			String title = "Sale Update";
-
 
1831
			String messageTemplate = String.format("Smartphones Rs.%.0f, Insurance Rs.%.0f, Total Rs.%.0f till %s.",
-
 
1832
					model.getSmartphoneSale(), model.getInsuranceSale(), model.getTotalSale(),
-
 
1833
					String.format(timeString, now.format(timeFormatter)));
1825
			SendNotificationModel sendNotificationModel = new SendNotificationModel();
1834
			SendNotificationModel sendNotificationModel = new SendNotificationModel();
1826
			sendNotificationModel.setCampaignName("Sales update alert");
1835
			sendNotificationModel.setCampaignName("Sales update alert");
1827
			sendNotificationModel.setTitle("Sale Update");
1836
			sendNotificationModel.setTitle(title);
1828
			sendNotificationModel
1837
			sendNotificationModel.setMessage(messageTemplate);
1829
					.setMessage(String.format("Smartphones Rs.%.0f, Insurance Rs.%.0f, Total Rs.%.0f till %s.",
-
 
1830
							model.getSmartphoneSale(), model.getInsuranceSale(), model.getTotalSale(),
-
 
1831
							String.format(timeString, now.format(timeFormatter))));
-
 
1832
			sendNotificationModel.setType("url");
1838
			sendNotificationModel.setType("url");
1833
			sendNotificationModel.setUrl("https://app.smartdukaan.com/pages/home/notifications");
1839
			sendNotificationModel.setUrl("https://app.smartdukaan.com/pages/home/notifications");
1834
			sendNotificationModel.setExpiresat(LocalDateTime.now().plusDays(1));
1840
			sendNotificationModel.setExpiresat(LocalDateTime.now().plusDays(1));
1835
			sendNotificationModel.setMessageType(MessageType.notification);
1841
			sendNotificationModel.setMessageType(MessageType.notification);
1836
			int userId = userAccountRepository.selectUserIdByRetailerId(fofoId);
1842
			int userId = userAccountRepository.selectUserIdByRetailerId(fofoId);
1837
			sendNotificationModel.setUserIds(Arrays.asList(userId));
1843
			sendNotificationModel.setUserIds(Arrays.asList(userId));
1838
			notificationService.sendNotification(sendNotificationModel);
1844
			notificationService.sendNotification(sendNotificationModel);
-
 
1845
 
-
 
1846
			//notificationService.sendWhatsappMessage(messageTemplate, title, address.getPhoneNumber());
-
 
1847
 
1839
		}
1848
		}
1840
		// String saleReport = this.getDailySalesReportHtml(partnerSalesHeadersMap,
1849
		// String saleReport = this.getDailySalesReportHtml(partnerSalesHeadersMap,
1841
		// saleTargetReportModelMap);
1850
		// saleTargetReportModelMap);
1842
		String statewiseSaleReport = this.getStateWiseSales(saleTargetReportModelMap, partnerSalesHeadersMap);
1851
		String statewiseSaleReport = this.getStateWiseSales(saleTargetReportModelMap, partnerSalesHeadersMap);
1843
		String cc[] = { "tarun.verma@smartdukaan.com", "kamini.sharma@smartdukaan.com", "niranjan.kala@smartdukaan.com",
1852
		String cc[] = { "tarun.verma@smartdukaan.com", "kamini.sharma@smartdukaan.com", "niranjan.kala@smartdukaan.com",
Line 2629... Line 2638...
2629
		for (Lead lead : leadsToNotify) {
2638
		for (Lead lead : leadsToNotify) {
2630
			if (authUserKeyMap.get(lead.getAssignTo()) == null) {
2639
			if (authUserKeyMap.get(lead.getAssignTo()) == null) {
2631
				LOGGER.info("Assignee no longer part of system {}", lead.getAssignTo());
2640
				LOGGER.info("Assignee no longer part of system {}", lead.getAssignTo());
2632
				continue;
2641
				continue;
2633
			}
2642
			}
-
 
2643
			String title = "Leads followup Reminder";
2634
			String notificationMessage = String.format(templateMessage, lead.getFirstName(), lead.getLastName(),
2644
			String notificationMessage = String.format(templateMessage, lead.getFirstName(), lead.getLastName(),
2635
					lead.getAddress(), lead.getLeadMobile(), leadTimeFormatter.format(lead.getScheduledTimestamp()));
2645
					lead.getAddress(), lead.getLeadMobile(), leadTimeFormatter.format(lead.getScheduledTimestamp()));
-
 
2646
			String url = "https://app.smartdukaan.com/pages/home/leadUpdate?leadId=" + lead.getId();
2636
			SendNotificationModel sendNotificationModel = new SendNotificationModel();
2647
			SendNotificationModel sendNotificationModel = new SendNotificationModel();
2637
			sendNotificationModel.setCampaignName("Lead Reminder");
2648
			sendNotificationModel.setCampaignName("Lead Reminder");
2638
			sendNotificationModel.setTitle("Leads followup Reminder");
2649
			sendNotificationModel.setTitle(title);
2639
			sendNotificationModel.setMessage(notificationMessage);
2650
			sendNotificationModel.setMessage(notificationMessage);
2640
			sendNotificationModel.setType("url");
2651
			sendNotificationModel.setType("url");
2641
			sendNotificationModel.setUrl("https://app.smartdukaan.com/pages/home/leadUpdate?leadId=" + lead.getId());
2652
			sendNotificationModel.setUrl(url);
2642
			sendNotificationModel.setExpiresat(LocalDateTime.now().plusDays(2));
2653
			sendNotificationModel.setExpiresat(LocalDateTime.now().plusDays(2));
2643
			sendNotificationModel.setMessageType(MessageType.reminder);
2654
			sendNotificationModel.setMessageType(MessageType.reminder);
2644
			sendNotificationModel.setUserIds(Arrays.asList(authUserKeyMap.get(lead.getAssignTo())));
2655
			sendNotificationModel.setUserIds(Arrays.asList(authUserKeyMap.get(lead.getAssignTo())));
2645
			System.out.println(sendNotificationModel);
2656
			System.out.println(sendNotificationModel);
2646
			notificationService.sendNotification(sendNotificationModel);
2657
			notificationService.sendNotification(sendNotificationModel);
-
 
2658
			AuthUser authUser = authRepository.selectById(lead.getAssignTo());
-
 
2659
			// notificationService.sendWhatsappMessage(notificationMessage, title, authUser.getMobileNumber());
2647
		}
2660
		}
2648
	}
2661
	}
2649
 
2662
 
2650
	public void notifyVisits() throws Exception {
2663
	public void notifyVisits() throws Exception {
2651
		List<FranchiseeVisit> franchiseeVisits = franchiseeVisitRepository
2664
		List<FranchiseeVisit> franchiseeVisits = franchiseeVisitRepository
Line 3221... Line 3234...
3221
						dlo.setStatus(OrderStatus.DELIVERY_SUCCESS);
3234
						dlo.setStatus(OrderStatus.DELIVERY_SUCCESS);
3222
						dlo.setStatusDescription("Order Delivered");
3235
						dlo.setStatusDescription("Order Delivered");
3223
						dlo.setDeliveryTimestamp(LocalDateTime.now());
3236
						dlo.setDeliveryTimestamp(LocalDateTime.now());
3224
					}
3237
					}
3225
 
3238
 
-
 
3239
					com.spice.profitmandi.dao.entity.user.User user = userUserRepository
-
 
3240
							.selectById(orders.get(0).getRetailerId());
-
 
3241
 
-
 
3242
					Address address = addressRepository.selectById(user.getAddressId());
-
 
3243
 
-
 
3244
					String title = "Order Delivered";
-
 
3245
 
-
 
3246
					String message = String.format("Dear partner, our SmartDukaan Order " + aws
-
 
3247
							+ " has been delivered to you in a safe sealed bag.");
-
 
3248
 
3226
					SendNotificationModel sendNotificationModel = new SendNotificationModel();
3249
					SendNotificationModel sendNotificationModel = new SendNotificationModel();
3227
					sendNotificationModel.setCampaignName("Order Delivered");
3250
					sendNotificationModel.setCampaignName("Order Delivered");
3228
					sendNotificationModel.setTitle("Order Delivered");
3251
					sendNotificationModel.setTitle(title);
3229
					sendNotificationModel.setMessage(String.format("Dear partner, your SmartDukaan Order " + aws
3252
					sendNotificationModel.setMessage(message);
3230
							+ "has been delivered to you in a safe sealed bag" + "."));
-
 
3231
					sendNotificationModel.setType("url");
3253
					sendNotificationModel.setType("url");
3232
					sendNotificationModel.setUrl("https://app.smartdukaan.com/pages/home/notifications");
3254
					sendNotificationModel.setUrl("https://app.smartdukaan.com/pages/home/notifications");
3233
					sendNotificationModel.setExpiresat(LocalDateTime.now().plusDays(1));
3255
					sendNotificationModel.setExpiresat(LocalDateTime.now().plusDays(1));
3234
					sendNotificationModel.setMessageType(MessageType.notification);
3256
					sendNotificationModel.setMessageType(MessageType.notification);
3235
					int userId = userAccountRepository.selectUserIdByRetailerId(orders.get(0).getRetailerId());
3257
					int userId = userAccountRepository.selectUserIdByRetailerId(orders.get(0).getRetailerId());
3236
					sendNotificationModel.setUserIds(Arrays.asList(userId));
3258
					sendNotificationModel.setUserIds(Arrays.asList(userId));
3237
					notificationService.sendNotification(sendNotificationModel);
3259
					notificationService.sendNotification(sendNotificationModel);
3238
 
3260
 
-
 
3261
					//notificationService.sendWhatsappMessage(message, title, address.getPhoneNumber());
-
 
3262
 
3239
				}
3263
				}
3240
			}
3264
			}
3241
 
3265
 
3242
		}
3266
		}
3243
	}
3267
	}
Line 3589... Line 3613...
3589
				String url = "http://app.smartdukaan.com/pages/home/credit";
3613
				String url = "http://app.smartdukaan.com/pages/home/credit";
3590
				String message = "Your total pending Loan amount is Rs. "
3614
				String message = "Your total pending Loan amount is Rs. "
3591
						+ FormattingUtils.formatDecimal(Math.abs(partnerLoanAmountEnrty.getValue()));
3615
						+ FormattingUtils.formatDecimal(Math.abs(partnerLoanAmountEnrty.getValue()));
3592
				notificationService.sendNotification(fofoId, title, MessageType.notification, title, message, url);
3616
				notificationService.sendNotification(fofoId, title, MessageType.notification, title, message, url);
3593
 
3617
 
3594
				// notificationService.sendWhatsappMessage(message, title,
3618
				//notificationService.sendWhatsappMessage(message, title, address.getPhoneNumber());
3595
				// address.getPhoneNumber());
-
 
3596
 
3619
 
3597
			}
3620
			}
3598
 
3621
 
3599
		}
3622
		}
3600
 
3623
 
Line 3733... Line 3756...
3733
			List<LoanStatement> loanStatements = loanStatementRepository.selectByLoanId(defaultLoan.getId());
3756
			List<LoanStatement> loanStatements = loanStatementRepository.selectByLoanId(defaultLoan.getId());
3734
 
3757
 
3735
			double amount = loanStatements.stream().map(x -> x.getAmount())
3758
			double amount = loanStatements.stream().map(x -> x.getAmount())
3736
					.collect(Collectors.summingDouble(x -> x.doubleValue()));
3759
					.collect(Collectors.summingDouble(x -> x.doubleValue()));
3737
 
3760
 
-
 
3761
			com.spice.profitmandi.dao.entity.user.User user = userUserRepository.selectById(defaultLoan.getFofoId());
-
 
3762
 
-
 
3763
			Address address = addressRepository.selectById(user.getAddressId());
-
 
3764
 
3738
			String title = "Loan amount overdue!";
3765
			String title = "Loan amount overdue!";
3739
			String url = "http://app.smartdukaan.com/pages/home/credit";
3766
			String url = "http://app.smartdukaan.com/pages/home/credit";
3740
			String message = "Your loan due date ("
3767
			String message = "Your loan due date ("
3741
					+ defaultLoan.getDueDate().toLocalDate().format(DateTimeFormatter.ofPattern("dd-MM-yyyy"))
3768
					+ defaultLoan.getDueDate().toLocalDate().format(DateTimeFormatter.ofPattern("dd-MM-yyyy"))
3742
					+ ") has been exceeded. Additional penal interest of " + defaultLoan.getInterestRate()
3769
					+ ") has been exceeded. Additional penal interest of " + defaultLoan.getInterestRate()
3743
					+ "%  + and Rs.100 shall be levied on daily basis. " + "Your total pending Loan amount is Rs."
3770
					+ "%  + and Rs.100 shall be levied on daily basis. " + "Your total pending Loan amount is Rs."
3744
					+ FormattingUtils.formatDecimal(Math.abs(amount)) + ". !!Pay Now!!";
3771
					+ FormattingUtils.formatDecimal(Math.abs(amount)) + ". !!Pay Now!!";
3745
			notificationService.sendNotification(defaultLoan.getFofoId(), title, MessageType.notification, title,
3772
			notificationService.sendNotification(defaultLoan.getFofoId(), title, MessageType.notification, title,
3746
					message, url);
3773
					message, url);
3747
 
3774
 
-
 
3775
			//notificationService.sendWhatsappMessage(message, title, address.getPhoneNumber());
-
 
3776
 
3748
		}
3777
		}
3749
	}
3778
	}
3750
 
3779
 
3751
	private String getMessageForDueDateExtend(List<Loan> loans) throws ProfitMandiBusinessException {
3780
	private String getMessageForDueDateExtend(List<Loan> loans) throws ProfitMandiBusinessException {
3752
		StringBuilder sb = new StringBuilder();
3781
		StringBuilder sb = new StringBuilder();
Line 3797... Line 3826...
3797
		if (!loans.isEmpty()) {
3826
		if (!loans.isEmpty()) {
3798
			for (Loan loan : loans) {
3827
			for (Loan loan : loans) {
3799
 
3828
 
3800
				long noOfdaysBetween = ChronoUnit.DAYS.between(loan.getDueDate().toLocalDate(), LocalDate.now());
3829
				long noOfdaysBetween = ChronoUnit.DAYS.between(loan.getDueDate().toLocalDate(), LocalDate.now());
3801
 
3830
 
-
 
3831
				com.spice.profitmandi.dao.entity.user.User user = userUserRepository.selectById(loan.getFofoId());
-
 
3832
 
-
 
3833
				Address address = addressRepository.selectById(user.getAddressId());
-
 
3834
 
3802
				LOGGER.info("noOfdaysBetween {} ", noOfdaysBetween);
3835
				LOGGER.info("noOfdaysBetween {} ", noOfdaysBetween);
3803
 
3836
 
3804
				if (noOfdaysBetween <= 15 && noOfdaysBetween >= 0) {
3837
				if (noOfdaysBetween <= 15 && noOfdaysBetween >= 0) {
3805
					List<LoanStatement> loanStatements = loanStatementRepository.selectByLoanId(loan.getId());
3838
					List<LoanStatement> loanStatements = loanStatementRepository.selectByLoanId(loan.getId());
3806
 
3839
 
3807
					double amount = loanStatements.stream().map(x -> x.getAmount())
3840
					double amount = loanStatements.stream().map(x -> x.getAmount())
3808
							.collect(Collectors.summingDouble(x -> x.doubleValue()));
3841
							.collect(Collectors.summingDouble(x -> x.doubleValue()));
3809
 
3842
 
3810
					String title = "Alert! Credit o/s";
3843
					String title = "Alert!";
3811
					String url = "http://app.smartdukaan.com/pages/home/credit";
3844
					String url = "http://app.smartdukaan.com/pages/home/credit";
3812
					String message = "Your loan due date ("
3845
					String message = "Your loan due date ("
3813
							+ loan.getDueDate().toLocalDate().format(DateTimeFormatter.ofPattern("dd-MM-yyyy"))
3846
							+ loan.getDueDate().toLocalDate().format(DateTimeFormatter.ofPattern("dd-MM-yyyy"))
3814
							+ ") has been exceeded. Additional penal interest of " + loan.getInterestRate()
3847
							+ ") has been exceeded. Additional penal interest of " + loan.getInterestRate()
3815
							+ "% shall be levied on daily basis. Your total pending Loan amount is Rs."
3848
							+ "% shall be levied on daily basis. Your total pending Loan amount is Rs."
3816
							+ FormattingUtils.formatDecimal(Math.abs(amount)) + ". !!Pay Now!!";
3849
							+ FormattingUtils.formatDecimal(Math.abs(amount)) + ". !!Pay Now!!";
3817
					notificationService.sendNotification(loan.getFofoId(), title, MessageType.notification, title,
3850
					notificationService.sendNotification(loan.getFofoId(), title, MessageType.notification, title,
3818
							message, url);
3851
							message, url);
-
 
3852
 
-
 
3853
					//notificationService.sendWhatsappMessage(message, title, address.getPhoneNumber());
-
 
3854
 
3819
				}
3855
				}
3820
			}
3856
			}
3821
		}
3857
		}
3822
 
3858
 
3823
	}
3859
	}
Line 3827... Line 3863...
3827
		List<Loan> loans = loanRepository.selectAllActiveLoan();
3863
		List<Loan> loans = loanRepository.selectAllActiveLoan();
3828
 
3864
 
3829
		if (!loans.isEmpty()) {
3865
		if (!loans.isEmpty()) {
3830
			for (Loan loan : loans) {
3866
			for (Loan loan : loans) {
3831
 
3867
 
-
 
3868
				com.spice.profitmandi.dao.entity.user.User user = userUserRepository.selectById(loan.getFofoId());
-
 
3869
 
-
 
3870
				Address address = addressRepository.selectById(user.getAddressId());
-
 
3871
 
3832
				long noOfdaysBetween = ChronoUnit.DAYS.between(LocalDate.now(), loan.getDueDate().toLocalDate());
3872
				long noOfdaysBetween = ChronoUnit.DAYS.between(LocalDate.now(), loan.getDueDate().toLocalDate());
3833
 
3873
 
3834
				LOGGER.info("noOfdaysBetween {} ", noOfdaysBetween);
3874
				LOGGER.info("noOfdaysBetween {} ", noOfdaysBetween);
3835
 
3875
 
3836
				if (noOfdaysBetween <= 4 && noOfdaysBetween >= 0) {
3876
				if (noOfdaysBetween <= 4 && noOfdaysBetween >= 0) {
Line 3854... Line 3894...
3854
								+ ", Pay Now!!";
3894
								+ ", Pay Now!!";
3855
 
3895
 
3856
					}
3896
					}
3857
					notificationService.sendNotification(loan.getFofoId(), title, MessageType.notification, title,
3897
					notificationService.sendNotification(loan.getFofoId(), title, MessageType.notification, title,
3858
							message, url);
3898
							message, url);
-
 
3899
					//notificationService.sendWhatsappMessage(message, title, address.getPhoneNumber());
-
 
3900
 
3859
				}
3901
				}
3860
			}
3902
			}
3861
		}
3903
		}
3862
 
3904
 
3863
	}
3905
	}
3864
 
3906
 
-
 
3907
	public void userMobileNumberOptIn() throws HttpHostConnectException, ProfitMandiBusinessException {
-
 
3908
 
-
 
3909
		List<FofoStore> fofoStores = fofoStoreRepository.selectActiveStores();
-
 
3910
 
-
 
3911
		List<com.spice.profitmandi.dao.entity.user.User> users = userUserRepository
-
 
3912
				.selectByIds(fofoStores.stream().map(x -> x.getId()).collect(Collectors.toList()));
-
 
3913
 
-
 
3914
		List<Address> addresses = addressRepository
-
 
3915
				.selectByIds(users.stream().map(x -> x.getAddressId()).collect(Collectors.toList()));
-
 
3916
 
-
 
3917
		for (Address address : addresses) {
-
 
3918
			Map<String, String> requestheaders = new HashMap<>();
-
 
3919
			requestheaders.put("Content-Type", "application/x-www-form-urlencoded");
-
 
3920
			Map<String, String> requestParams = new HashMap<>();
-
 
3921
			requestParams.put("userid", String.valueOf(2000215976));
-
 
3922
			requestParams.put("password", "MFRd!BBL");
-
 
3923
			requestParams.put("send_to", address.getPhoneNumber());
-
 
3924
			requestParams.put("auth_scheme", "plain");
-
 
3925
			requestParams.put("v", "1.1");
-
 
3926
			requestParams.put("format", "");
-
 
3927
 
-
 
3928
			requestParams.put("method", "OPT_IN");
-
 
3929
 
-
 
3930
			requestParams.put("channel", "WHATSAPP");
-
 
3931
			String response = restClient.get("https://media.smsgupshup.com/GatewayAPI/rest", requestParams,
-
 
3932
					requestheaders);
-
 
3933
			LOGGER.info("response" + response);
-
 
3934
		}
-
 
3935
 
-
 
3936
	}
-
 
3937
 
-
 
3938
	public void authUserMobileNumberOptIn() throws HttpHostConnectException, ProfitMandiBusinessException {
-
 
3939
 
-
 
3940
		List<AuthUser> authUsers = authRepository.selectAllActiveUser();
-
 
3941
		for (AuthUser authUser : authUsers) {
-
 
3942
			Map<String, String> requestheaders = new HashMap<>();
-
 
3943
			requestheaders.put("Content-Type", "application/x-www-form-urlencoded");
-
 
3944
			Map<String, String> requestParams = new HashMap<>();
-
 
3945
			requestParams.put("userid", String.valueOf(2000215976));
-
 
3946
			requestParams.put("password", "MFRd!BBL");
-
 
3947
			requestParams.put("send_to", authUser.getMobileNumber());
-
 
3948
			requestParams.put("auth_scheme", "plain");
-
 
3949
			requestParams.put("v", "1.1");
-
 
3950
			requestParams.put("format", "");
-
 
3951
 
-
 
3952
			requestParams.put("method", "OPT_IN");
-
 
3953
 
-
 
3954
			requestParams.put("channel", "WHATSAPP");
-
 
3955
			String response = restClient.get("https://media.smsgupshup.com/GatewayAPI/rest", requestParams,
-
 
3956
					requestheaders);
-
 
3957
			LOGGER.info("response" + response);
-
 
3958
		}
-
 
3959
 
-
 
3960
	}
-
 
3961
 
3865
}
3962
}
3866
 
3963
 
3867
//2284
3964
//2284
3868
3965