Subversion Repositories SmartDukaan

Rev

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

Rev 23666 Rev 23667
Line 134... Line 134...
134
	public void executeDailRechargeGeneration() {
134
	public void executeDailRechargeGeneration() {
135
		List<RechargeProviderCreditWalletHistory> allCreditHistory = rechargeProviderCreditWalletHistoryRepository
135
		List<RechargeProviderCreditWalletHistory> allCreditHistory = rechargeProviderCreditWalletHistoryRepository
136
				.selectAll(0, 2000);
136
				.selectAll(0, 2000);
137
		List<RechargeProvider> rechargeProviders = rechargeProviderRepository.selectAll();
137
		List<RechargeProvider> rechargeProviders = rechargeProviderRepository.selectAll();
138
		rechargeProviders.stream().forEach(x -> x.setAmount(0));
138
		rechargeProviders.stream().forEach(x -> x.setAmount(0));
139
		LocalDate endDate = LocalDate.now().plusDays(1);
-
 
140
 
139
 
141
		Map<LocalDate, List<RechargeProviderCreditWalletHistory>> dateWiseProviderCreditsMap = allCreditHistory.stream()
140
		Map<LocalDate, List<RechargeProviderCreditWalletHistory>> dateWiseProviderCreditsMap = allCreditHistory.stream()
142
				.collect(Collectors.groupingBy(x -> x.getCreateTimestamp().toLocalDate()));
141
				.collect(Collectors.groupingBy(x -> x.getCreateTimestamp().toLocalDate()));
143
 
142
 
144
		float previousDayClosing = 0;
-
 
145
		rechargeProviders.stream().forEach(x -> {
143
		rechargeProviders.stream().forEach(x -> {
-
 
144
			LocalDate endDate = LocalDate.now().plusDays(1);
-
 
145
			float previousDayClosing = 0;
146
			LocalDate date = LocalDate.of(2018, 4, 6);
146
			LocalDate date = LocalDate.of(2018, 4, 6);
147
			while (date.isBefore(endDate)) {
147
			while (date.isBefore(endDate)) {
148
				List<RechargeTransaction> dateWiseRechargeTransactions = rechargeTransactionRepository
148
				List<RechargeTransaction> dateWiseRechargeTransactions = rechargeTransactionRepository
149
						.selectAllBetweenTimestamp(Arrays.asList(RechargeStatus.values()), date.atStartOfDay(),
149
						.selectAllBetweenTimestamp(Arrays.asList(RechargeStatus.values()), date.atStartOfDay(),
150
								date.plusDays(1).atStartOfDay());
150
								date.plusDays(1).atStartOfDay());
Line 190... Line 190...
190
					dailyRecharge.setClosingBalance(closingBalance);
190
					dailyRecharge.setClosingBalance(closingBalance);
191
					dailyRechargeRepository.persist(dailyRecharge);
191
					dailyRechargeRepository.persist(dailyRecharge);
192
					x.setAmount(x.getAmount() + dailyRecharge.getClosingBalance() - dailyRecharge.getOpeningBalance());
192
					x.setAmount(x.getAmount() + dailyRecharge.getClosingBalance() - dailyRecharge.getOpeningBalance());
193
				}
193
				}
194
				date = date.plusDays(1);
194
				date = date.plusDays(1);
-
 
195
				previousDayClosing = dailyRecharge.getClosingBalance();
195
			}
196
			}
196
			rechargeProviderRepository.persist(x);
197
			rechargeProviderRepository.persist(x);
197
		});
198
		});
198
	}
199
	}
199
 
200