| Line 40... |
Line 40... |
| 40 |
import com.spice.profitmandi.common.util.FormattingUtils;
|
40 |
import com.spice.profitmandi.common.util.FormattingUtils;
|
| 41 |
import com.spice.profitmandi.common.util.Utils;
|
41 |
import com.spice.profitmandi.common.util.Utils;
|
| 42 |
import com.spice.profitmandi.dao.entity.catalog.Item;
|
42 |
import com.spice.profitmandi.dao.entity.catalog.Item;
|
| 43 |
import com.spice.profitmandi.dao.entity.catalog.Scheme;
|
43 |
import com.spice.profitmandi.dao.entity.catalog.Scheme;
|
| 44 |
import com.spice.profitmandi.dao.entity.catalog.TagListing;
|
44 |
import com.spice.profitmandi.dao.entity.catalog.TagListing;
|
| - |
|
45 |
import com.spice.profitmandi.dao.entity.dtr.PaymentOptionTransaction;
|
| 45 |
import com.spice.profitmandi.dao.entity.fofo.CurrentInventorySnapshot;
|
46 |
import com.spice.profitmandi.dao.entity.fofo.CurrentInventorySnapshot;
|
| 46 |
import com.spice.profitmandi.dao.entity.fofo.DebitNote;
|
47 |
import com.spice.profitmandi.dao.entity.fofo.DebitNote;
|
| - |
|
48 |
import com.spice.profitmandi.dao.entity.fofo.FofoLineItem;
|
| 47 |
import com.spice.profitmandi.dao.entity.fofo.FofoOrder;
|
49 |
import com.spice.profitmandi.dao.entity.fofo.FofoOrder;
|
| 48 |
import com.spice.profitmandi.dao.entity.fofo.FofoOrderItem;
|
50 |
import com.spice.profitmandi.dao.entity.fofo.FofoOrderItem;
|
| 49 |
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
|
51 |
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
|
| 50 |
import com.spice.profitmandi.dao.entity.fofo.InventoryItem;
|
52 |
import com.spice.profitmandi.dao.entity.fofo.InventoryItem;
|
| 51 |
import com.spice.profitmandi.dao.entity.fofo.PartnerTargetDetails;
|
53 |
import com.spice.profitmandi.dao.entity.fofo.PartnerTargetDetails;
|
| Line 66... |
Line 68... |
| 66 |
import com.spice.profitmandi.dao.entity.transaction.UserWalletHistory;
|
68 |
import com.spice.profitmandi.dao.entity.transaction.UserWalletHistory;
|
| 67 |
import com.spice.profitmandi.dao.entity.user.Address;
|
69 |
import com.spice.profitmandi.dao.entity.user.Address;
|
| 68 |
import com.spice.profitmandi.dao.entity.user.User;
|
70 |
import com.spice.profitmandi.dao.entity.user.User;
|
| 69 |
import com.spice.profitmandi.dao.enumuration.catalog.AmountType;
|
71 |
import com.spice.profitmandi.dao.enumuration.catalog.AmountType;
|
| 70 |
import com.spice.profitmandi.dao.enumuration.catalog.SchemeType;
|
72 |
import com.spice.profitmandi.dao.enumuration.catalog.SchemeType;
|
| - |
|
73 |
import com.spice.profitmandi.dao.enumuration.dtr.PaymentOptionReferenceType;
|
| 71 |
import com.spice.profitmandi.dao.enumuration.fofo.ScanType;
|
74 |
import com.spice.profitmandi.dao.enumuration.fofo.ScanType;
|
| 72 |
import com.spice.profitmandi.dao.model.ContentPojo;
|
75 |
import com.spice.profitmandi.dao.model.ContentPojo;
|
| 73 |
import com.spice.profitmandi.dao.model.MediaPojo;
|
76 |
import com.spice.profitmandi.dao.model.MediaPojo;
|
| 74 |
import com.spice.profitmandi.dao.repository.GenericRepository;
|
77 |
import com.spice.profitmandi.dao.repository.GenericRepository;
|
| 75 |
import com.spice.profitmandi.dao.repository.catalog.ItemRepository;
|
78 |
import com.spice.profitmandi.dao.repository.catalog.ItemRepository;
|
| Line 77... |
Line 80... |
| 77 |
import com.spice.profitmandi.dao.repository.catalog.TagListingRepository;
|
80 |
import com.spice.profitmandi.dao.repository.catalog.TagListingRepository;
|
| 78 |
import com.spice.profitmandi.dao.repository.cs.CsService;
|
81 |
import com.spice.profitmandi.dao.repository.cs.CsService;
|
| 79 |
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
|
82 |
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
|
| 80 |
import com.spice.profitmandi.dao.repository.dtr.LeadRepository;
|
83 |
import com.spice.profitmandi.dao.repository.dtr.LeadRepository;
|
| 81 |
import com.spice.profitmandi.dao.repository.dtr.Mongo;
|
84 |
import com.spice.profitmandi.dao.repository.dtr.Mongo;
|
| - |
|
85 |
import com.spice.profitmandi.dao.repository.dtr.PaymentOptionTransactionRepository;
|
| 82 |
import com.spice.profitmandi.dao.repository.fofo.CurrentInventorySnapshotRepository;
|
86 |
import com.spice.profitmandi.dao.repository.fofo.CurrentInventorySnapshotRepository;
|
| 83 |
import com.spice.profitmandi.dao.repository.fofo.DebitNoteRepository;
|
87 |
import com.spice.profitmandi.dao.repository.fofo.DebitNoteRepository;
|
| - |
|
88 |
import com.spice.profitmandi.dao.repository.fofo.FofoLineItemRepository;
|
| 84 |
import com.spice.profitmandi.dao.repository.fofo.FofoOrderItemRepository;
|
89 |
import com.spice.profitmandi.dao.repository.fofo.FofoOrderItemRepository;
|
| 85 |
import com.spice.profitmandi.dao.repository.fofo.FofoOrderRepository;
|
90 |
import com.spice.profitmandi.dao.repository.fofo.FofoOrderRepository;
|
| 86 |
import com.spice.profitmandi.dao.repository.fofo.InventoryItemRepository;
|
91 |
import com.spice.profitmandi.dao.repository.fofo.InventoryItemRepository;
|
| 87 |
import com.spice.profitmandi.dao.repository.fofo.InvoiceNumberGenerationSequenceRepository;
|
92 |
import com.spice.profitmandi.dao.repository.fofo.InvoiceNumberGenerationSequenceRepository;
|
| 88 |
import com.spice.profitmandi.dao.repository.fofo.PartnerTargetRepository;
|
93 |
import com.spice.profitmandi.dao.repository.fofo.PartnerTargetRepository;
|
| Line 138... |
Line 143... |
| 138 |
@Autowired
|
143 |
@Autowired
|
| 139 |
private CsService csService;
|
144 |
private CsService csService;
|
| 140 |
|
145 |
|
| 141 |
@Autowired
|
146 |
@Autowired
|
| 142 |
private Mongo mongoClient;
|
147 |
private Mongo mongoClient;
|
| - |
|
148 |
|
| - |
|
149 |
@Autowired
|
| - |
|
150 |
private PaymentOptionTransactionRepository paymentOptionTransactionRepository;
|
| 143 |
|
151 |
|
| 144 |
@Autowired
|
152 |
@Autowired
|
| 145 |
private SamsungIMEIActivationService samsungActivationService;
|
153 |
private SamsungIMEIActivationService samsungActivationService;
|
| 146 |
|
154 |
|
| 147 |
@Autowired
|
155 |
@Autowired
|
| Line 159... |
Line 167... |
| 159 |
@Autowired
|
167 |
@Autowired
|
| 160 |
private SellerWarehouseRepository sellerWarehouseRepository;
|
168 |
private SellerWarehouseRepository sellerWarehouseRepository;
|
| 161 |
|
169 |
|
| 162 |
@Autowired
|
170 |
@Autowired
|
| 163 |
private FofoOrderItemRepository fofoOrderItemRepository;
|
171 |
private FofoOrderItemRepository fofoOrderItemRepository;
|
| - |
|
172 |
|
| - |
|
173 |
@Autowired
|
| - |
|
174 |
private FofoLineItemRepository fofoLineItemRepository;
|
| 164 |
|
175 |
|
| 165 |
@Autowired
|
176 |
@Autowired
|
| 166 |
private FofoOrderRepository fofoOrderRepository;
|
177 |
private FofoOrderRepository fofoOrderRepository;
|
| 167 |
|
178 |
|
| 168 |
@Autowired
|
179 |
@Autowired
|
| Line 961... |
Line 972... |
| 961 |
public void printPendingLeads() {
|
972 |
public void printPendingLeads() {
|
| 962 |
LOGGER.info("PENDING LEADES {}", leadRepository
|
973 |
LOGGER.info("PENDING LEADES {}", leadRepository
|
| 963 |
.selectLeadsScheduledBetweenDate(LocalDateTime.now().minusDays(15), LocalDateTime.now().plusHours(4)));
|
974 |
.selectLeadsScheduledBetweenDate(LocalDateTime.now().minusDays(15), LocalDateTime.now().plusHours(4)));
|
| 964 |
}
|
975 |
}
|
| 965 |
|
976 |
|
| 966 |
public void removeDuplicateOrders() {
|
977 |
public void removeDuplicateOrders() throws Exception {
|
| 967 |
List<String> invoiceNumbers = Arrays.asList("DLWE066/1108", "DLWE066/299", "DLWE066/348", "HRFB004/242",
|
978 |
List<String> invoiceNumbers = Arrays.asList("DLWE066/1108", "DLWE066/299", "DLWE066/348", "HRFB004/242",
|
| 968 |
"HRFB004/243", "HRFB004/514", "HRFTB155/29", "HRJND076/1146", "HRJND076/966", "HRKA134/295",
|
979 |
"HRFB004/243", "HRFB004/514", "HRFTB155/29", "HRJND076/1146", "HRJND076/966", "HRKA134/295",
|
| 969 |
"HRKA134/421", "HRKK091/381", "HRMGH106/576", "HRSP056/139", "HRYN030/103", "UPGZ019/395",
|
980 |
"HRKA134/421", "HRKK091/381", "HRMGH106/576", "HRSP056/139", "HRYN030/103", "UPGZ019/395",
|
| 970 |
"UPHRD130/1299", "UPHRD130/456", "UPHRD130/634", "UPLKO063/897", "UPMRT149/54", "UPSJP119/748",
|
981 |
"UPHRD130/1299", "UPHRD130/456", "UPHRD130/634", "UPLKO063/897", "UPMRT149/54", "UPSJP119/748",
|
| 971 |
"UPSJP119/980", "UPSTP065/1218", "UPSTP065/2039", "UPSTP090/437", "UPSTP120/164");
|
982 |
"UPSJP119/980", "UPSTP065/1218", "UPSTP065/2039", "UPSTP090/437", "UPSTP120/164");
|
| 972 |
|
983 |
|
| 973 |
for(String invoiceNumber : invoiceNumbers) {
|
984 |
for(String invoiceNumber : invoiceNumbers) {
|
| 974 |
int totalAmount = 0;
|
985 |
int totalAmount = 0;
|
| 975 |
List<FofoOrder> orders = fofoOrderRepository.selectByInvoiceNumberLike(invoiceNumber);
|
986 |
List<FofoOrder> orders = fofoOrderRepository.selectByInvoiceNumberLike(invoiceNumber);
|
| 976 |
orders = orders.stream().skip(1).collect(Collectors.toList());
|
987 |
orders = orders.stream().skip(1).collect(Collectors.toList());
|
| 977 |
for (FofoOrder x : orders) {
|
988 |
for (FofoOrder fofoOrder : orders) {
|
| - |
|
989 |
LOGGER.info("Invoice {}", invoiceNumber);
|
| - |
|
990 |
int inventoryItemId = 0;
|
| - |
|
991 |
//fofoOrderRepository.delete(fofoOrder);
|
| - |
|
992 |
List<FofoOrderItem> fofoOrderItems = fofoOrderItemRepository.selectByOrderId(fofoOrder.getId());
|
| 978 |
List<UserWalletHistory> userWalletHistory = userWalletHistoryRepository.selectAllByreferenceIdandreferenceType(x.getId(), WalletReferenceType.SCHEME_OUT);
|
993 |
List<PaymentOptionTransaction> paymentOptionTransactions = paymentOptionTransactionRepository.selectByReferenceIdAndType(fofoOrder.getId(), PaymentOptionReferenceType.ORDER);
|
| - |
|
994 |
for(PaymentOptionTransaction paymentOptionTransaction : paymentOptionTransactions) {
|
| - |
|
995 |
//paymentOptionTransactionRepository.delete(paymentOptionTransaction);
|
| - |
|
996 |
}
|
| - |
|
997 |
for(FofoOrderItem foi : fofoOrderItems) {
|
| - |
|
998 |
//fofoOrderItemRepository.delete(foi);
|
| 979 |
totalAmount += userWalletHistory.stream().collect(Collectors.summingInt(y->y.getAmount()));
|
999 |
List<FofoLineItem> flis = fofoLineItemRepository.selectByFofoOrderItemId(foi.getItemId());
|
| - |
|
1000 |
for(FofoLineItem fli : flis) {
|
| - |
|
1001 |
//fofoLineItemRepository.delete(fli);
|
| - |
|
1002 |
inventoryItemId = fli.getInventoryItemId();
|
| - |
|
1003 |
}
|
| - |
|
1004 |
}
|
| 980 |
//Rollback entry with reversal reason
|
1005 |
//Rollback entry with reversal reason
|
| - |
|
1006 |
if(fofoOrder.getCreateTimestamp().isAfter(LocalDate.of(2020, 4, 1).atStartOfDay())) {
|
| - |
|
1007 |
List<UserWalletHistory> userWalletHistory = userWalletHistoryRepository.selectAllByreferenceIdandreferenceType(fofoOrder.getId(), WalletReferenceType.SCHEME_OUT);
|
| - |
|
1008 |
totalAmount += userWalletHistory.stream().collect(Collectors.summingInt(y->y.getAmount()));
|
| - |
|
1009 |
/*walletService.rollbackAmountFromWallet(fofoOrder.getFofoId(), totalAmount, fofoOrder.getId(), WalletReferenceType.SCHEME_OUT,
|
| - |
|
1010 |
"Same order for Invoice-"+ invoiceNumber + "created twice, duplicate invoice rollback", fofoOrder.getCancelledTimestamp());*/
|
| - |
|
1011 |
List<SchemeInOut> schemeInOuts = schemeInOutRepository.selectByInventoryItemIds(new HashSet<>(Arrays.asList(inventoryItemId)));
|
| - |
|
1012 |
for(SchemeInOut sio : schemeInOuts) {
|
| - |
|
1013 |
LOGGER.info(sio);
|
| - |
|
1014 |
}
|
| - |
|
1015 |
|
| - |
|
1016 |
}
|
| 981 |
//Remove order id
|
1017 |
//Remove order id
|
| 982 |
//Remove order item Id
|
1018 |
//Remove order item Id
|
| 983 |
//Remove lineitem id
|
1019 |
//Remove lineitem id
|
| 984 |
}
|
1020 |
}
|
| 985 |
LOGGER.info("Invoice - {}, Amount {}", invoiceNumber, totalAmount);
|
1021 |
LOGGER.info("Invoice - {}, Amount {}", invoiceNumber, totalAmount);
|