| 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;
|
- |
|
| 49 |
import com.spice.profitmandi.dao.repository.GenericRepository;
|
48 |
import com.spice.profitmandi.dao.repository.GenericRepository;
|
| 50 |
import com.spice.profitmandi.dao.repository.catalog.ItemRepository;
|
49 |
import com.spice.profitmandi.dao.repository.catalog.ItemRepository;
|
| 51 |
import com.spice.profitmandi.dao.repository.catalog.SchemeRepository;
|
50 |
import com.spice.profitmandi.dao.repository.catalog.SchemeRepository;
|
| 52 |
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
|
51 |
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
|
| 53 |
import com.spice.profitmandi.dao.repository.fofo.CurrentInventorySnapshotRepository;
|
52 |
import com.spice.profitmandi.dao.repository.fofo.CurrentInventorySnapshotRepository;
|
| Line 139... |
Line 138... |
| 139 |
@Autowired
|
138 |
@Autowired
|
| 140 |
private OrderService orderService;
|
139 |
private OrderService orderService;
|
| 141 |
|
140 |
|
| 142 |
@Autowired
|
141 |
@Autowired
|
| 143 |
private SchemeRepository schemeRepository;
|
142 |
private SchemeRepository schemeRepository;
|
| 144 |
|
143 |
|
| 145 |
@Autowired
|
144 |
@Autowired
|
| 146 |
private ScheduledTasks scheduledTasks;
|
145 |
private ScheduledTasks scheduledTasks;
|
| 147 |
|
146 |
|
| 148 |
@Autowired
|
147 |
@Autowired
|
| 149 |
private SchemeItemRepository schemeItemRepository;
|
148 |
private SchemeItemRepository schemeItemRepository;
|
| Line 606... |
Line 605... |
| 606 |
// throw new Exception();
|
605 |
// throw new Exception();
|
| 607 |
}
|
606 |
}
|
| 608 |
|
607 |
|
| 609 |
public void fixSchemePayouts() throws Exception {
|
608 |
public void fixSchemePayouts() throws Exception {
|
| 610 |
|
609 |
|
| 611 |
LocalDateTime startDate = LocalDateTime.of(2019, 9, 9, 16,45, 53);
|
610 |
LocalDateTime startDate = LocalDateTime.of(2019, 9, 9, 16, 45, 50);
|
| 612 |
LocalDateTime endDate = LocalDateTime.of(2019, 9, 9, 16, 46, 32);
|
611 |
LocalDateTime endDate = LocalDateTime.of(2019, 9, 9, 16, 46, 35);
|
| - |
|
612 |
float totalSchemeAmount = 0;
|
| - |
|
613 |
float totalWalletAmount = 0;
|
| 613 |
List<SchemeInOut> sios = schemeInOutRepository.selectAllByCreateDate(startDate, endDate);
|
614 |
List<SchemeInOut> sios = schemeInOutRepository.selectAllByCreateDate(startDate, endDate);
|
| 614 |
|
- |
|
| 615 |
for (SchemeInOut sio : sios) {
|
615 |
for (SchemeInOut sio : sios) {
|
| - |
|
616 |
totalSchemeAmount += sio.getAmount();
|
| 616 |
genericRepository.delete(sio);
|
617 |
genericRepository.delete(sio);
|
| 617 |
InventoryItem ii = inventoryItemRepository.selectById(sio.getInventoryItemId());
|
- |
|
| 618 |
UserWallet userWallet = userWalletRepository.selectByRetailerId(ii.getFofoId());
|
- |
|
| 619 |
Scheme scheme = schemeRepository.selectById(sio.getSchemeId());
|
- |
|
| 620 |
if (scheme.getType().equals(SchemeType.IN)) {
|
- |
|
| 621 |
List<UserWalletHistory> historyList = userWalletHistoryRepository
|
- |
|
| 622 |
.selectAllByreferenceIdandreferenceType(ii.getPurchaseId(), WalletReferenceType.SCHEME_IN);
|
- |
|
| 623 |
for (UserWalletHistory uwh : historyList) {
|
- |
|
| 624 |
if(uwh.getTimestamp().isAfter(startDate)) {
|
- |
|
| 625 |
genericRepository.delete(uwh);
|
- |
|
| 626 |
userWallet.setAmount(userWallet.getAmount() - uwh.getAmount());
|
- |
|
| 627 |
}
|
- |
|
| 628 |
}
|
- |
|
| 629 |
} else {
|
- |
|
| 630 |
List<ScanRecord> scanRecords = scanRecordRepository.selectByInventoryItemId(ii.getId());
|
- |
|
| 631 |
int orderId = scanRecords.get(0).getOrderId();
|
- |
|
| 632 |
List<UserWalletHistory> historyList = userWalletHistoryRepository
|
- |
|
| 633 |
.selectAllByreferenceIdandreferenceType(orderId, WalletReferenceType.SCHEME_OUT);
|
- |
|
| 634 |
for (UserWalletHistory uwh : historyList) {
|
- |
|
| 635 |
if(uwh.getTimestamp().isAfter(startDate)) {
|
- |
|
| 636 |
userWallet.setAmount(userWallet.getAmount() - uwh.getAmount());
|
- |
|
| 637 |
genericRepository.delete(uwh);
|
- |
|
| 638 |
}
|
- |
|
| 639 |
}
|
- |
|
| 640 |
List<UserWalletHistory> historyListBroken = userWalletHistoryRepository
|
- |
|
| 641 |
.selectAllByreferenceIdandreferenceType(ii.getPurchaseId(), WalletReferenceType.SCHEME_OUT);
|
- |
|
| 642 |
for (UserWalletHistory uwh : historyListBroken) {
|
- |
|
| 643 |
if(uwh.getTimestamp().isAfter(startDate)) {
|
- |
|
| 644 |
genericRepository.delete(uwh);
|
- |
|
| 645 |
userWallet.setAmount(userWallet.getAmount() - uwh.getAmount());
|
- |
|
| 646 |
}
|
- |
|
| 647 |
}
|
- |
|
| 648 |
}
|
- |
|
| 649 |
|
- |
|
| 650 |
//System.out.println("Total Amount Rolled Back is " + totalRollbackAmount);
|
- |
|
| 651 |
}
|
618 |
}
|
| - |
|
619 |
List<UserWalletHistory> uwh = userWalletHistoryRepository.selectAllByDateType(startDate, endDate,
|
| - |
|
620 |
Arrays.asList(WalletReferenceType.SCHEME_IN, WalletReferenceType.SCHEME_OUT));
|
| - |
|
621 |
for (UserWalletHistory userWalletHistory : uwh) {
|
| - |
|
622 |
UserWallet userWallet = userWalletRepository.selectById(userWalletHistory.getWalletId());
|
| - |
|
623 |
userWallet.setAmount(userWallet.getAmount() - userWalletHistory.getAmount());
|
| - |
|
624 |
totalWalletAmount += userWallet.getAmount();
|
| - |
|
625 |
}
|
| - |
|
626 |
|
| - |
|
627 |
System.out.println("Total Amount Rolled Back is " + totalWalletAmount);
|
| - |
|
628 |
System.out.println("Total Scheme Deleted " + totalSchemeAmount);
|
| 652 |
//scheduledTasks.processScheme(startDate, startDate.plusDays(10));
|
629 |
// scheduledTasks.processScheme(startDate, startDate.plusDays(10));
|
| 653 |
//throw new Exception();
|
630 |
throw new Exception();
|
| 654 |
}
|
631 |
}
|
| 655 |
}
|
632 |
}
|
| 656 |
|
633 |
|
| 657 |
//7015845171
|
634 |
//7015845171
|
| 658 |
|
635 |
|