| Line 180... |
Line 180... |
| 180 |
}
|
180 |
}
|
| 181 |
date = date.plusDays(1);
|
181 |
date = date.plusDays(1);
|
| 182 |
}
|
182 |
}
|
| 183 |
rechargeProviderRepository.persist(x);
|
183 |
rechargeProviderRepository.persist(x);
|
| 184 |
});
|
184 |
});
|
| 185 |
LOGGER.info("executio");
|
185 |
LOGGER.info("finished generating daily recharge");
|
| 186 |
}
|
186 |
}
|
| 187 |
|
187 |
|
| 188 |
public void reconcileRecharge() throws Exception {
|
188 |
public void reconcileRecharge() throws Exception {
|
| 189 |
LocalDateTime fromDate = LocalDateTime.now().truncatedTo(ChronoUnit.DAYS).minusDays(30);
|
189 |
LocalDateTime fromDate = LocalDateTime.now().truncatedTo(ChronoUnit.DAYS).minusDays(30);
|
| 190 |
LocalDateTime toDate = LocalDateTime.now().truncatedTo(ChronoUnit.DAYS);
|
190 |
LocalDateTime toDate = LocalDateTime.now().truncatedTo(ChronoUnit.DAYS);
|
| Line 245... |
Line 245... |
| 245 |
}
|
245 |
}
|
| 246 |
LOGGER.info("Schemes process successfully.");
|
246 |
LOGGER.info("Schemes process successfully.");
|
| 247 |
}
|
247 |
}
|
| 248 |
|
248 |
|
| 249 |
public void processRechargeCashback() throws Throwable {
|
249 |
public void processRechargeCashback() throws Throwable {
|
| - |
|
250 |
LocalDateTime cashbackTime = LocalDateTime.now();
|
| 250 |
int referenceId = (int)Timestamp.valueOf(LocalDateTime.now()).getTime()/1000;
|
251 |
int referenceId = (int)Timestamp.valueOf(cashbackTime).getTime()/1000;
|
| 251 |
List<RechargeTransaction> pendingTransactions = rechargeTransactionRepository.getPendingCashBackRehargeTransactions();
|
252 |
List<RechargeTransaction> pendingTransactions = rechargeTransactionRepository.getPendingCashBackRehargeTransactions();
|
| 252 |
Map<Object, Double> totalRetailerCashbacks = pendingTransactions.stream().collect(Collectors.groupingBy(x->x.getId(), Collectors.summingDouble(x->x.getCommission())));
|
253 |
Map<Object, Double> totalRetailerCashbacks = pendingTransactions.stream().collect(Collectors.groupingBy(x->x.getRetailerId(), Collectors.summingDouble(x->x.getCommission())));
|
| 253 |
for (Map.Entry<Object, Double>totalRetailerCashback : totalRetailerCashbacks.entrySet()) {
|
254 |
for (Map.Entry<Object, Double>totalRetailerCashback : totalRetailerCashbacks.entrySet()) {
|
| 254 |
int retailerId = (Integer)totalRetailerCashback.getKey();
|
255 |
int retailerId = (Integer)totalRetailerCashback.getKey();
|
| 255 |
float amount = totalRetailerCashback.getValue().floatValue();
|
256 |
float amount = totalRetailerCashback.getValue().floatValue();
|
| 256 |
walletService.addAmountToWallet(retailerId, referenceId, WalletReferenceType.CASHBACK, "Recharge Cashback", Math.round(amount));
|
257 |
walletService.addAmountToWallet(retailerId, referenceId, WalletReferenceType.CASHBACK, "Recharge Cashback", Math.round(amount));
|
| 257 |
}
|
258 |
}
|
| 258 |
pendingTransactions.forEach(x-> {
|
259 |
for(RechargeTransaction rt : pendingTransactions) {
|
| 259 |
x.setCashbackTimestamp(LocalDateTime.now());
|
260 |
rt.setCashbackTimestamp(cashbackTime);
|
| 260 |
x.setCashbackReference(referenceId);
|
261 |
rt.setCashbackReference(referenceId);
|
| 261 |
rechargeTransactionRepository.persist(x);
|
262 |
rechargeTransactionRepository.persist(rt);
|
| 262 |
});
|
263 |
}
|
| 263 |
LOGGER.info("Cashbacks for Recharge processed Successfully");
|
264 |
LOGGER.info("Cashbacks for Recharge processed Successfully");
|
| 264 |
}
|
265 |
}
|
| 265 |
|
266 |
|
| 266 |
}
|
267 |
}
|