| Line 43... |
Line 43... |
| 43 |
import com.spice.profitmandi.dao.entity.transaction.Order;
|
43 |
import com.spice.profitmandi.dao.entity.transaction.Order;
|
| 44 |
import com.spice.profitmandi.dao.entity.transaction.SellerWarehouse;
|
44 |
import com.spice.profitmandi.dao.entity.transaction.SellerWarehouse;
|
| 45 |
import com.spice.profitmandi.dao.entity.transaction.UserWallet;
|
45 |
import com.spice.profitmandi.dao.entity.transaction.UserWallet;
|
| 46 |
import com.spice.profitmandi.dao.entity.transaction.UserWalletHistory;
|
46 |
import com.spice.profitmandi.dao.entity.transaction.UserWalletHistory;
|
| 47 |
import com.spice.profitmandi.dao.enumuration.catalog.AmountType;
|
47 |
import com.spice.profitmandi.dao.enumuration.catalog.AmountType;
|
| - |
|
48 |
import com.spice.profitmandi.dao.enumuration.catalog.SchemeType;
|
| 48 |
import com.spice.profitmandi.dao.repository.GenericRepository;
|
49 |
import com.spice.profitmandi.dao.repository.GenericRepository;
|
| 49 |
import com.spice.profitmandi.dao.repository.catalog.ItemRepository;
|
50 |
import com.spice.profitmandi.dao.repository.catalog.ItemRepository;
|
| 50 |
import com.spice.profitmandi.dao.repository.catalog.SchemeRepository;
|
51 |
import com.spice.profitmandi.dao.repository.catalog.SchemeRepository;
|
| 51 |
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
|
52 |
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
|
| 52 |
import com.spice.profitmandi.dao.repository.fofo.CurrentInventorySnapshotRepository;
|
53 |
import com.spice.profitmandi.dao.repository.fofo.CurrentInventorySnapshotRepository;
|
| Line 605... |
Line 606... |
| 605 |
// throw new Exception();
|
606 |
// throw new Exception();
|
| 606 |
}
|
607 |
}
|
| 607 |
|
608 |
|
| 608 |
public void fixSchemePayouts() throws Exception {
|
609 |
public void fixSchemePayouts() throws Exception {
|
| 609 |
|
610 |
|
| 610 |
LocalDateTime startDate = LocalDateTime.of(2019, 9, 1, 0,0,0);
|
611 |
LocalDateTime startDate = LocalDate.of(2019, 9, 1).atStartOfDay();
|
| 611 |
LocalDateTime endDate = LocalDateTime.of(2019, 9, 10, 0,0,0);
|
- |
|
| 612 |
/* float totalSchemeAmount = 0;
|
- |
|
| 613 |
float totalWalletAmount = 0;
|
- |
|
| 614 |
List<SchemeInOut> sios = schemeInOutRepository.selectAllByCreateDate(startDate, endDate);
|
612 |
List<SchemeInOut> sios = schemeInOutRepository.selectAllByCreateDate(startDate, LocalDateTime.now());
|
| - |
|
613 |
|
| 615 |
for (SchemeInOut sio : sios) {
|
614 |
for (SchemeInOut sio : sios) {
|
| 616 |
totalSchemeAmount += sio.getAmount();
|
615 |
if(sio.getSchemeId()<348) {
|
| - |
|
616 |
continue;
|
| - |
|
617 |
}
|
| 617 |
genericRepository.delete(sio);
|
618 |
genericRepository.delete(sio);
|
| - |
|
619 |
InventoryItem ii = inventoryItemRepository.selectById(sio.getInventoryItemId());
|
| - |
|
620 |
UserWallet userWallet = userWalletRepository.selectByRetailerId(ii.getFofoId());
|
| - |
|
621 |
Scheme scheme = schemeRepository.selectById(sio.getSchemeId());
|
| - |
|
622 |
if (scheme.getType().equals(SchemeType.IN)) {
|
| - |
|
623 |
List<UserWalletHistory> historyList = userWalletHistoryRepository
|
| - |
|
624 |
.selectAllByreferenceIdandreferenceType(ii.getPurchaseId(), WalletReferenceType.SCHEME_IN);
|
| - |
|
625 |
for (UserWalletHistory uwh : historyList) {
|
| - |
|
626 |
if(uwh.getTimestamp().isAfter(startDate)) {
|
| - |
|
627 |
genericRepository.delete(uwh);
|
| - |
|
628 |
userWallet.setAmount(userWallet.getAmount() - uwh.getAmount());
|
| - |
|
629 |
}
|
| 618 |
}
|
630 |
}
|
| - |
|
631 |
} else {
|
| - |
|
632 |
List<ScanRecord> scanRecords = scanRecordRepository.selectByInventoryItemId(ii.getId());
|
| - |
|
633 |
int orderId = scanRecords.get(0).getOrderId();
|
| 619 |
List<UserWalletHistory> uwh = userWalletHistoryRepository.selectAllByDateType(startDate, endDate,
|
634 |
List<UserWalletHistory> historyList = userWalletHistoryRepository
|
| 620 |
Arrays.asList(WalletReferenceType.SCHEME_IN, WalletReferenceType.SCHEME_OUT));
|
635 |
.selectAllByreferenceIdandreferenceType(orderId, WalletReferenceType.SCHEME_OUT);
|
| 621 |
for (UserWalletHistory userWalletHistory : uwh) {
|
636 |
for (UserWalletHistory uwh : historyList) {
|
| 622 |
UserWallet userWallet = userWalletRepository.selectById(userWalletHistory.getWalletId());
|
637 |
if(uwh.getTimestamp().isAfter(startDate)) {
|
| 623 |
userWallet.setAmount(userWallet.getAmount() - userWalletHistory.getAmount());
|
638 |
userWallet.setAmount(userWallet.getAmount() - uwh.getAmount());
|
| - |
|
639 |
genericRepository.delete(uwh);
|
| - |
|
640 |
}
|
| - |
|
641 |
}
|
| - |
|
642 |
List<UserWalletHistory> historyListBroken = userWalletHistoryRepository
|
| - |
|
643 |
.selectAllByreferenceIdandreferenceType(ii.getPurchaseId(), WalletReferenceType.SCHEME_OUT);
|
| - |
|
644 |
for (UserWalletHistory uwh : historyListBroken) {
|
| - |
|
645 |
if(uwh.getTimestamp().isAfter(startDate)) {
|
| - |
|
646 |
genericRepository.delete(uwh);
|
| 624 |
totalWalletAmount += userWallet.getAmount();
|
647 |
userWallet.setAmount(userWallet.getAmount() - uwh.getAmount());
|
| - |
|
648 |
}
|
| - |
|
649 |
}
|
| 625 |
}
|
650 |
}
|
| 626 |
|
651 |
|
| 627 |
System.out.println("Total Amount Rolled Back is " + totalWalletAmount);
|
652 |
//System.out.println("Total Amount Rolled Back is " + totalRollbackAmount);
|
| 628 |
System.out.println("Total Scheme Deleted " + totalSchemeAmount);*/
|
- |
|
| - |
|
653 |
}
|
| 629 |
scheduledTasks.processScheme(startDate, startDate.plusDays(11));
|
654 |
scheduledTasks.processScheme(startDate, startDate.plusDays(10));
|
| - |
|
655 |
|
| 630 |
//throw new Exception();
|
656 |
throw new Exception();
|
| 631 |
}
|
657 |
}
|
| 632 |
}
|
658 |
}
|
| 633 |
|
659 |
|
| 634 |
//7015845171
|
660 |
//7015845171
|
| 635 |
|
661 |
|