| Line 513... |
Line 513... |
| 513 |
}
|
513 |
}
|
| 514 |
cis.setReserved(value);
|
514 |
cis.setReserved(value);
|
| 515 |
});
|
515 |
});
|
| 516 |
}
|
516 |
}
|
| 517 |
|
517 |
|
| 518 |
public void fixSchemePayouts() throws Exception {
|
- |
|
| 519 |
LOGGER.info("In fix scheme Payouts");
|
- |
|
| 520 |
LocalDateTime startDate = LocalDate.of(2019, 9, 1).atStartOfDay();
|
- |
|
| 521 |
List<SchemeInOut> sios = schemeInOutRepository.selectAllByCreateDate(startDate, LocalDateTime.now());
|
- |
|
| 522 |
|
- |
|
| 523 |
for (SchemeInOut sio : sios) {
|
- |
|
| 524 |
if (sio.getSchemeId() != 347) {
|
- |
|
| 525 |
LOGGER.info("Skipping {}", sio.getSchemeId());
|
- |
|
| 526 |
continue;
|
- |
|
| 527 |
}
|
- |
|
| 528 |
genericRepository.delete(sio);
|
- |
|
| 529 |
InventoryItem ii = inventoryItemRepository.selectById(sio.getInventoryItemId());
|
- |
|
| 530 |
UserWallet userWallet = userWalletRepository.selectByRetailerId(ii.getFofoId());
|
- |
|
| 531 |
Scheme scheme = schemeRepository.selectById(sio.getSchemeId());
|
- |
|
| 532 |
if (scheme.getType().equals(SchemeType.IN)) {
|
- |
|
| 533 |
List<UserWalletHistory> historyList = userWalletHistoryRepository
|
- |
|
| 534 |
.selectAllByreferenceIdandreferenceType(ii.getPurchaseId(), WalletReferenceType.SCHEME_IN);
|
- |
|
| 535 |
for (UserWalletHistory uwh : historyList) {
|
- |
|
| 536 |
if (uwh.getTimestamp().isAfter(startDate)) {
|
- |
|
| 537 |
genericRepository.delete(uwh);
|
- |
|
| 538 |
userWallet.setAmount(userWallet.getAmount() - uwh.getAmount());
|
- |
|
| 539 |
}
|
- |
|
| 540 |
}
|
- |
|
| 541 |
} else {
|
- |
|
| 542 |
List<ScanRecord> scanRecords = scanRecordRepository.selectByInventoryItemId(ii.getId());
|
- |
|
| 543 |
int orderId = scanRecords.get(0).getOrderId();
|
- |
|
| 544 |
List<UserWalletHistory> historyList = userWalletHistoryRepository
|
- |
|
| 545 |
.selectAllByreferenceIdandreferenceType(orderId, WalletReferenceType.SCHEME_OUT);
|
- |
|
| 546 |
for (UserWalletHistory uwh : historyList) {
|
- |
|
| 547 |
if (uwh.getTimestamp().isAfter(startDate)) {
|
- |
|
| 548 |
userWallet.setAmount(userWallet.getAmount() - uwh.getAmount());
|
- |
|
| 549 |
genericRepository.delete(uwh);
|
- |
|
| 550 |
}
|
- |
|
| 551 |
}
|
- |
|
| 552 |
List<UserWalletHistory> historyListBroken = userWalletHistoryRepository
|
- |
|
| 553 |
.selectAllByreferenceIdandreferenceType(ii.getPurchaseId(), WalletReferenceType.SCHEME_OUT);
|
- |
|
| 554 |
for (UserWalletHistory uwh : historyListBroken) {
|
- |
|
| 555 |
if (uwh.getTimestamp().isAfter(startDate)) {
|
- |
|
| 556 |
genericRepository.delete(uwh);
|
- |
|
| 557 |
userWallet.setAmount(userWallet.getAmount() - uwh.getAmount());
|
- |
|
| 558 |
}
|
- |
|
| 559 |
}
|
- |
|
| 560 |
}
|
- |
|
| 561 |
|
- |
|
| 562 |
// System.out.println("Total Amount Rolled Back is " + totalRollbackAmount);
|
- |
|
| 563 |
}
|
- |
|
| 564 |
scheduledTasks.processScheme(startDate, startDate.plusDays(10), true);
|
- |
|
| 565 |
}
|
- |
|
| 566 |
|
518 |
|
| 567 |
public void fixWallet() throws Exception {
|
519 |
public void fixWallet() throws Exception {
|
| 568 |
List<FofoStore> fofoStores = fofoStoreRepository.selectAll();
|
520 |
List<FofoStore> fofoStores = fofoStoreRepository.selectAll();
|
| 569 |
System.out.println("id\tcode\tactive\tname\tcity\tstate\twallet amount\tsum\twallet amount-sum");
|
521 |
System.out.println("id\tcode\tactive\tname\tcity\tstate\twallet amount\tsum\twallet amount-sum");
|
| 570 |
for (FofoStore fofoStore : fofoStores) {
|
522 |
for (FofoStore fofoStore : fofoStores) {
|