| Line 28... |
Line 28... |
| 28 |
import com.spice.profitmandi.common.util.Utils;
|
28 |
import com.spice.profitmandi.common.util.Utils;
|
| 29 |
import com.spice.profitmandi.dao.entity.catalog.Scheme;
|
29 |
import com.spice.profitmandi.dao.entity.catalog.Scheme;
|
| 30 |
import com.spice.profitmandi.dao.entity.fofo.CurrentInventorySnapshot;
|
30 |
import com.spice.profitmandi.dao.entity.fofo.CurrentInventorySnapshot;
|
| 31 |
import com.spice.profitmandi.dao.entity.fofo.FofoOrder;
|
31 |
import com.spice.profitmandi.dao.entity.fofo.FofoOrder;
|
| 32 |
import com.spice.profitmandi.dao.entity.fofo.FofoOrderItem;
|
32 |
import com.spice.profitmandi.dao.entity.fofo.FofoOrderItem;
|
| - |
|
33 |
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
|
| 33 |
import com.spice.profitmandi.dao.entity.fofo.InventoryItem;
|
34 |
import com.spice.profitmandi.dao.entity.fofo.InventoryItem;
|
| 34 |
import com.spice.profitmandi.dao.entity.fofo.PartnerTargetDetails;
|
35 |
import com.spice.profitmandi.dao.entity.fofo.PartnerTargetDetails;
|
| 35 |
import com.spice.profitmandi.dao.entity.fofo.Purchase;
|
36 |
import com.spice.profitmandi.dao.entity.fofo.Purchase;
|
| 36 |
import com.spice.profitmandi.dao.entity.fofo.ScanRecord;
|
37 |
import com.spice.profitmandi.dao.entity.fofo.ScanRecord;
|
| 37 |
import com.spice.profitmandi.dao.entity.fofo.SchemeInOut;
|
38 |
import com.spice.profitmandi.dao.entity.fofo.SchemeInOut;
|
| Line 42... |
Line 43... |
| 42 |
import com.spice.profitmandi.dao.entity.transaction.LineItemImei;
|
43 |
import com.spice.profitmandi.dao.entity.transaction.LineItemImei;
|
| 43 |
import com.spice.profitmandi.dao.entity.transaction.Order;
|
44 |
import com.spice.profitmandi.dao.entity.transaction.Order;
|
| 44 |
import com.spice.profitmandi.dao.entity.transaction.SellerWarehouse;
|
45 |
import com.spice.profitmandi.dao.entity.transaction.SellerWarehouse;
|
| 45 |
import com.spice.profitmandi.dao.entity.transaction.UserWallet;
|
46 |
import com.spice.profitmandi.dao.entity.transaction.UserWallet;
|
| 46 |
import com.spice.profitmandi.dao.entity.transaction.UserWalletHistory;
|
47 |
import com.spice.profitmandi.dao.entity.transaction.UserWalletHistory;
|
| - |
|
48 |
import com.spice.profitmandi.dao.entity.user.Address;
|
| - |
|
49 |
import com.spice.profitmandi.dao.entity.user.User;
|
| 47 |
import com.spice.profitmandi.dao.enumuration.catalog.AmountType;
|
50 |
import com.spice.profitmandi.dao.enumuration.catalog.AmountType;
|
| 48 |
import com.spice.profitmandi.dao.enumuration.catalog.SchemeType;
|
51 |
import com.spice.profitmandi.dao.enumuration.catalog.SchemeType;
|
| 49 |
import com.spice.profitmandi.dao.repository.GenericRepository;
|
52 |
import com.spice.profitmandi.dao.repository.GenericRepository;
|
| 50 |
import com.spice.profitmandi.dao.repository.catalog.ItemRepository;
|
53 |
import com.spice.profitmandi.dao.repository.catalog.ItemRepository;
|
| 51 |
import com.spice.profitmandi.dao.repository.catalog.SchemeRepository;
|
54 |
import com.spice.profitmandi.dao.repository.catalog.SchemeRepository;
|
| Line 70... |
Line 73... |
| 70 |
import com.spice.profitmandi.dao.repository.transaction.OrderRepository;
|
73 |
import com.spice.profitmandi.dao.repository.transaction.OrderRepository;
|
| 71 |
import com.spice.profitmandi.dao.repository.transaction.ReturnOrderRepository;
|
74 |
import com.spice.profitmandi.dao.repository.transaction.ReturnOrderRepository;
|
| 72 |
import com.spice.profitmandi.dao.repository.transaction.SellerWarehouseRepository;
|
75 |
import com.spice.profitmandi.dao.repository.transaction.SellerWarehouseRepository;
|
| 73 |
import com.spice.profitmandi.dao.repository.transaction.UserWalletHistoryRepository;
|
76 |
import com.spice.profitmandi.dao.repository.transaction.UserWalletHistoryRepository;
|
| 74 |
import com.spice.profitmandi.dao.repository.transaction.UserWalletRepository;
|
77 |
import com.spice.profitmandi.dao.repository.transaction.UserWalletRepository;
|
| - |
|
78 |
import com.spice.profitmandi.dao.repository.user.AddressRepository;
|
| 75 |
import com.spice.profitmandi.dao.repository.user.UserRepository;
|
79 |
import com.spice.profitmandi.dao.repository.user.UserRepository;
|
| 76 |
import com.spice.profitmandi.service.inventory.InventoryService;
|
80 |
import com.spice.profitmandi.service.inventory.InventoryService;
|
| 77 |
import com.spice.profitmandi.service.order.OrderService;
|
81 |
import com.spice.profitmandi.service.order.OrderService;
|
| 78 |
import com.spice.profitmandi.service.pricing.PriceDropService;
|
82 |
import com.spice.profitmandi.service.pricing.PriceDropService;
|
| 79 |
import com.spice.profitmandi.service.scheme.SchemeService;
|
83 |
import com.spice.profitmandi.service.scheme.SchemeService;
|
| Line 141... |
Line 145... |
| 141 |
|
145 |
|
| 142 |
@Autowired
|
146 |
@Autowired
|
| 143 |
private SchemeRepository schemeRepository;
|
147 |
private SchemeRepository schemeRepository;
|
| 144 |
|
148 |
|
| 145 |
@Autowired
|
149 |
@Autowired
|
| - |
|
150 |
private AddressRepository addressRepository;
|
| - |
|
151 |
|
| - |
|
152 |
@Autowired
|
| 146 |
private ScheduledTasks scheduledTasks;
|
153 |
private ScheduledTasks scheduledTasks;
|
| 147 |
|
154 |
|
| 148 |
@Autowired
|
155 |
@Autowired
|
| 149 |
private SchemeItemRepository schemeItemRepository;
|
156 |
private SchemeItemRepository schemeItemRepository;
|
| 150 |
|
157 |
|
| Line 608... |
Line 615... |
| 608 |
|
615 |
|
| 609 |
public void fixSchemePayouts() throws Exception {
|
616 |
public void fixSchemePayouts() throws Exception {
|
| 610 |
LOGGER.info("In fix scheme Payouts");
|
617 |
LOGGER.info("In fix scheme Payouts");
|
| 611 |
LocalDateTime startDate = LocalDate.of(2019, 9, 1).atStartOfDay();
|
618 |
LocalDateTime startDate = LocalDate.of(2019, 9, 1).atStartOfDay();
|
| 612 |
List<SchemeInOut> sios = schemeInOutRepository.selectAllByCreateDate(startDate, LocalDateTime.now());
|
619 |
List<SchemeInOut> sios = schemeInOutRepository.selectAllByCreateDate(startDate, LocalDateTime.now());
|
| 613 |
|
620 |
|
| 614 |
for (SchemeInOut sio : sios) {
|
621 |
for (SchemeInOut sio : sios) {
|
| 615 |
if(sio.getSchemeId()!=347) {
|
622 |
if (sio.getSchemeId() != 347) {
|
| 616 |
LOGGER.info("Skipping {}", sio.getSchemeId());
|
623 |
LOGGER.info("Skipping {}", sio.getSchemeId());
|
| 617 |
continue;
|
624 |
continue;
|
| 618 |
}
|
625 |
}
|
| 619 |
genericRepository.delete(sio);
|
626 |
genericRepository.delete(sio);
|
| 620 |
InventoryItem ii = inventoryItemRepository.selectById(sio.getInventoryItemId());
|
627 |
InventoryItem ii = inventoryItemRepository.selectById(sio.getInventoryItemId());
|
| Line 622... |
Line 629... |
| 622 |
Scheme scheme = schemeRepository.selectById(sio.getSchemeId());
|
629 |
Scheme scheme = schemeRepository.selectById(sio.getSchemeId());
|
| 623 |
if (scheme.getType().equals(SchemeType.IN)) {
|
630 |
if (scheme.getType().equals(SchemeType.IN)) {
|
| 624 |
List<UserWalletHistory> historyList = userWalletHistoryRepository
|
631 |
List<UserWalletHistory> historyList = userWalletHistoryRepository
|
| 625 |
.selectAllByreferenceIdandreferenceType(ii.getPurchaseId(), WalletReferenceType.SCHEME_IN);
|
632 |
.selectAllByreferenceIdandreferenceType(ii.getPurchaseId(), WalletReferenceType.SCHEME_IN);
|
| 626 |
for (UserWalletHistory uwh : historyList) {
|
633 |
for (UserWalletHistory uwh : historyList) {
|
| 627 |
if(uwh.getTimestamp().isAfter(startDate)) {
|
634 |
if (uwh.getTimestamp().isAfter(startDate)) {
|
| 628 |
genericRepository.delete(uwh);
|
635 |
genericRepository.delete(uwh);
|
| 629 |
userWallet.setAmount(userWallet.getAmount() - uwh.getAmount());
|
636 |
userWallet.setAmount(userWallet.getAmount() - uwh.getAmount());
|
| 630 |
}
|
637 |
}
|
| 631 |
}
|
638 |
}
|
| 632 |
} else {
|
639 |
} else {
|
| 633 |
List<ScanRecord> scanRecords = scanRecordRepository.selectByInventoryItemId(ii.getId());
|
640 |
List<ScanRecord> scanRecords = scanRecordRepository.selectByInventoryItemId(ii.getId());
|
| 634 |
int orderId = scanRecords.get(0).getOrderId();
|
641 |
int orderId = scanRecords.get(0).getOrderId();
|
| 635 |
List<UserWalletHistory> historyList = userWalletHistoryRepository
|
642 |
List<UserWalletHistory> historyList = userWalletHistoryRepository
|
| 636 |
.selectAllByreferenceIdandreferenceType(orderId, WalletReferenceType.SCHEME_OUT);
|
643 |
.selectAllByreferenceIdandreferenceType(orderId, WalletReferenceType.SCHEME_OUT);
|
| 637 |
for (UserWalletHistory uwh : historyList) {
|
644 |
for (UserWalletHistory uwh : historyList) {
|
| 638 |
if(uwh.getTimestamp().isAfter(startDate)) {
|
645 |
if (uwh.getTimestamp().isAfter(startDate)) {
|
| 639 |
userWallet.setAmount(userWallet.getAmount() - uwh.getAmount());
|
646 |
userWallet.setAmount(userWallet.getAmount() - uwh.getAmount());
|
| 640 |
genericRepository.delete(uwh);
|
647 |
genericRepository.delete(uwh);
|
| 641 |
}
|
648 |
}
|
| 642 |
}
|
649 |
}
|
| 643 |
List<UserWalletHistory> historyListBroken = userWalletHistoryRepository
|
650 |
List<UserWalletHistory> historyListBroken = userWalletHistoryRepository
|
| 644 |
.selectAllByreferenceIdandreferenceType(ii.getPurchaseId(), WalletReferenceType.SCHEME_OUT);
|
651 |
.selectAllByreferenceIdandreferenceType(ii.getPurchaseId(), WalletReferenceType.SCHEME_OUT);
|
| 645 |
for (UserWalletHistory uwh : historyListBroken) {
|
652 |
for (UserWalletHistory uwh : historyListBroken) {
|
| 646 |
if(uwh.getTimestamp().isAfter(startDate)) {
|
653 |
if (uwh.getTimestamp().isAfter(startDate)) {
|
| 647 |
genericRepository.delete(uwh);
|
654 |
genericRepository.delete(uwh);
|
| 648 |
userWallet.setAmount(userWallet.getAmount() - uwh.getAmount());
|
655 |
userWallet.setAmount(userWallet.getAmount() - uwh.getAmount());
|
| 649 |
}
|
656 |
}
|
| 650 |
}
|
657 |
}
|
| 651 |
}
|
658 |
}
|
| 652 |
|
659 |
|
| 653 |
//System.out.println("Total Amount Rolled Back is " + totalRollbackAmount);
|
660 |
// System.out.println("Total Amount Rolled Back is " + totalRollbackAmount);
|
| 654 |
}
|
661 |
}
|
| 655 |
scheduledTasks.processScheme(startDate, startDate.plusDays(10));
|
662 |
scheduledTasks.processScheme(startDate, startDate.plusDays(10));
|
| 656 |
|
663 |
|
| 657 |
//throw new Exception();
|
664 |
// throw new Exception();
|
| - |
|
665 |
}
|
| - |
|
666 |
|
| - |
|
667 |
public void fixWallet() throws Exception {
|
| - |
|
668 |
List<FofoStore> fofoStores = fofoStoreRepository.selectAll();
|
| - |
|
669 |
System.out.println("id\tcode\tname\tcity\tstate\tsaved wallet\tcalculated wallet\tdifference");
|
| - |
|
670 |
for (FofoStore fofoStore : fofoStores) {
|
| - |
|
671 |
UserWallet uw = userWalletRepository.selectByRetailerId(fofoStore.getId());
|
| - |
|
672 |
User user = userRepository.selectById(fofoStore.getId());
|
| - |
|
673 |
Address address = addressRepository.selectById(user.getAddressId());
|
| - |
|
674 |
double calculated = (int)userWalletHistoryRepository.selectSumByWallet(uw.getId());
|
| - |
|
675 |
System.out.printf("%d\t%s\t%s\t%s\t%s\t%f\t%f\t%f\t%s", fofoStore.getId(), fofoStore.getCode(),
|
| - |
|
676 |
address.getCity(), address.getName(), address.getState(), uw.getAmount(), calculated,
|
| - |
|
677 |
calculated - uw.getAmount());
|
| - |
|
678 |
}
|
| 658 |
}
|
679 |
}
|
| 659 |
}
|
680 |
}
|
| 660 |
|
681 |
|
| 661 |
//7015845171
|
682 |
//7015845171
|
| 662 |
|
683 |
|