| Line 23... |
Line 23... |
| 23 |
|
23 |
|
| 24 |
import org.apache.commons.io.output.ByteArrayOutputStream;
|
24 |
import org.apache.commons.io.output.ByteArrayOutputStream;
|
| 25 |
import org.apache.commons.lang.StringUtils;
|
25 |
import org.apache.commons.lang.StringUtils;
|
| 26 |
import org.apache.logging.log4j.LogManager;
|
26 |
import org.apache.logging.log4j.LogManager;
|
| 27 |
import org.apache.logging.log4j.Logger;
|
27 |
import org.apache.logging.log4j.Logger;
|
| - |
|
28 |
import org.apache.solr.common.util.Hash;
|
| 28 |
import org.json.JSONArray;
|
29 |
import org.json.JSONArray;
|
| 29 |
import org.json.JSONObject;
|
30 |
import org.json.JSONObject;
|
| 30 |
import org.openqa.selenium.Dimension;
|
31 |
import org.openqa.selenium.Dimension;
|
| 31 |
import org.openqa.selenium.OutputType;
|
32 |
import org.openqa.selenium.OutputType;
|
| 32 |
import org.openqa.selenium.TakesScreenshot;
|
33 |
import org.openqa.selenium.TakesScreenshot;
|
| Line 789... |
Line 790... |
| 789 |
body.toString(), emailSnapshotMap);
|
790 |
body.toString(), emailSnapshotMap);
|
| 790 |
LOGGER.info("Sent mail to {}", email);
|
791 |
LOGGER.info("Sent mail to {}", email);
|
| 791 |
}
|
792 |
}
|
| 792 |
driver.quit();
|
793 |
driver.quit();
|
| 793 |
}
|
794 |
}
|
| 794 |
|
795 |
|
| 795 |
// Rollout prebooking orders amount in case the order is grned.
|
796 |
// Rollout prebooking orders amount in case the order is grned.
|
| 796 |
public void pbfix() throws ProfitMandiBusinessException {
|
797 |
public void pbfix() throws ProfitMandiBusinessException {
|
| - |
|
798 |
List<PrebookingOrder> prebookingOrders = prebookingOrderRepository.selectAll();
|
| - |
|
799 |
Map<Integer, Boolean> prebookingCleared = new HashMap<>();
|
| 797 |
List<Item> items = itemRepository.selectAllByCatalogItemId(1022304);
|
800 |
prebookingOrders = prebookingOrders.stream().collect(Collectors.toList());
|
| - |
|
801 |
Map<Integer, List<PrebookingOrder>> catalogPrebookingMap = new HashMap<>();
|
| - |
|
802 |
for(PrebookingOrder prebookingOrder : prebookingOrders) {
|
| - |
|
803 |
if(!catalogPrebookingMap.containsKey(prebookingOrder.getCatalogId())) {
|
| - |
|
804 |
catalogPrebookingMap.put(prebookingOrder.getCatalogId(), new ArrayList<>());
|
| - |
|
805 |
}
|
| - |
|
806 |
catalogPrebookingMap.get(prebookingOrder.getCatalogId()).add(prebookingOrder);
|
| - |
|
807 |
int prebookingId = prebookingOrder.getId();
|
| - |
|
808 |
List<UserWalletHistory> history = walletService.getAllByReference(prebookingOrder.getFofoId(), prebookingId, WalletReferenceType.PREBOOKING_ORDER);
|
| - |
|
809 |
long totalAmount = history.stream().collect(Collectors.summingLong(x->x.getAmount()));
|
| - |
|
810 |
//Refund is pending
|
| - |
|
811 |
if(history.size() > 0) {
|
| 798 |
for (Item item : items) {
|
812 |
if(totalAmount < 0) {
|
| - |
|
813 |
prebookingCleared.put(prebookingId, false);
|
| - |
|
814 |
LOGGER.info("Amount pending for prebooking id " + prebookingId + " amount is " + -totalAmount + " catalog id - {}", prebookingOrder.getCatalogId());
|
| - |
|
815 |
} else {
|
| - |
|
816 |
prebookingCleared.put(prebookingId, true);
|
| - |
|
817 |
}
|
| - |
|
818 |
} else {
|
| - |
|
819 |
prebookingCleared.put(prebookingId, true);
|
| - |
|
820 |
LOGGER.info("No entry in wallet for prebooking Id " + prebookingId);
|
| - |
|
821 |
}
|
| - |
|
822 |
}
|
| - |
|
823 |
for(Map.Entry<Integer, List<PrebookingOrder>> entrySet : catalogPrebookingMap.entrySet()) {
|
| - |
|
824 |
LOGGER.info("Catalog id {}, Size {}", entrySet.getKey(), entrySet.getValue().size());
|
| - |
|
825 |
Set<Integer> itemIds = itemRepository.selectAllByCatalogItemId(entrySet.getKey()).stream().map(x->x.getId()).collect(Collectors.toSet());
|
| - |
|
826 |
List<PrebookingOrder> prebookings = entrySet.getValue();
|
| - |
|
827 |
Map<Integer, List<PrebookingOrder>>fofoMap = prebookings.stream().collect(Collectors.groupingBy(x->x.getFofoId(), Collectors.toList()));
|
| - |
|
828 |
for (Map.Entry<Integer, List<PrebookingOrder>> fofoMapEntry : fofoMap.entrySet()) {
|
| - |
|
829 |
int fofoId = fofoMapEntry.getKey();
|
| 799 |
List<InventoryItem> inventoryItems = inventoryItemRepository.selectByItemId(item.getId(), 0, 500);
|
830 |
int totalGrnCount = inventoryItemRepository.selectByFofoIdItemIds(fofoId, itemIds).size();
|
| 800 |
for (InventoryItem inventoryItem : inventoryItems) {
|
831 |
List<PrebookingOrder> partnerBookings = fofoMapEntry.getValue();
|
| 801 |
List<PrebookingOrder> prebookingOrders = prebookingOrderRepository
|
832 |
for (PrebookingOrder partnerBooking : partnerBookings) {
|
| 802 |
.selectByFofoIdAndCatalogIds(inventoryItem.getFofoId(), item.getCatalogItemId()).stream()
|
833 |
if(prebookingCleared.get(partnerBooking.getId())) {
|
| 803 |
.collect(Collectors.toList());
|
834 |
totalGrnCount--;
|
| 804 |
if (prebookingOrders.size() > 0) {
|
835 |
if(totalGrnCount < 0) {
|
| - |
|
836 |
totalGrnCount=0;
|
| 805 |
purchaseService.sendPrebookingNotifyMessage(prebookingOrders.get(0));
|
837 |
LOGGER.info("FofoId {}, No Grn But Refunded prebooking id {}", fofoId, partnerBooking.getId());
|
| - |
|
838 |
break;
|
| - |
|
839 |
}
|
| - |
|
840 |
}
|
| 806 |
}
|
841 |
}
|
| - |
|
842 |
|
| - |
|
843 |
long toBeRefunded = partnerBookings.stream().filter(x->!prebookingCleared.get(x.getId())).limit(totalGrnCount).count();
|
| - |
|
844 |
LOGGER.info("FofoId {}, Remaining Grn {}, toBeRefunded Prebooking {}", fofoId, totalGrnCount, toBeRefunded);
|
| - |
|
845 |
partnerBookings.stream().filter(x->!prebookingCleared.get(x.getId()))
|
| - |
|
846 |
.filter(x->x.getCreateTimestamp().getYear()==2022).limit(totalGrnCount).forEach(x->{
|
| - |
|
847 |
try {
|
| - |
|
848 |
purchaseService.sendPrebookingNotifyMessage(x);
|
| 807 |
// inventoryItem.getFofoId()
|
849 |
} catch(Exception e) {
|
| - |
|
850 |
LOGGER.info("could not notify");
|
| - |
|
851 |
}
|
| - |
|
852 |
});
|
| - |
|
853 |
|
| - |
|
854 |
|
| 808 |
}
|
855 |
}
|
| 809 |
}
|
856 |
}
|
| 810 |
// throw new ProfitMandiBusinessException("", "", "");
|
- |
|
| 811 |
// prebookingOrderRepository.select
|
- |
|
| 812 |
// TODO Auto-generated method stub
|
- |
|
| 813 |
|
- |
|
| 814 |
}
|
857 |
}
|
| 815 |
|
858 |
|
| 816 |
public void fixGrn() throws Exception {
|
859 |
public void fixGrn() throws Exception {
|
| 817 |
List<Purchase> incompletePurchases = purchaseRepository.selectIncompletePurchase();
|
860 |
List<Purchase> incompletePurchases = purchaseRepository.selectIncompletePurchase();
|
| 818 |
for (Purchase incompletePurchase : incompletePurchases) {
|
861 |
for (Purchase incompletePurchase : incompletePurchases) {
|
| Line 1564... |
Line 1607... |
| 1564 |
}
|
1607 |
}
|
| 1565 |
mandiiUser.setGender(Gender.valueOf(gender));
|
1608 |
mandiiUser.setGender(Gender.valueOf(gender));
|
| 1566 |
mandiiService.createAccount(cr.getBusinessName(), mandiiUser);
|
1609 |
mandiiService.createAccount(cr.getBusinessName(), mandiiUser);
|
| 1567 |
}
|
1610 |
}
|
| 1568 |
|
1611 |
|
| - |
|
1612 |
|
| 1569 |
public void mandiiUsers(String pan) throws Exception {
|
1613 |
public void mandiiUsers(String pan) throws Exception {
|
| 1570 |
FofoStore fs = fofoStoreRepository.selectByPan(pan);
|
1614 |
FofoStore fs = fofoStoreRepository.selectByPan(pan);
|
| 1571 |
|
1615 |
|
| 1572 |
PartnerOnBoardingPanel pob = partnerOnBoardingPanelRepository.selectByCode(fs.getCode());
|
1616 |
PartnerOnBoardingPanel pob = partnerOnBoardingPanelRepository.selectByCode(fs.getCode());
|
| 1573 |
List<FofoKyc> fofoKycs = fofoKycRepository.selectByPartnerOnBoardingId(pob.getId());
|
1617 |
List<FofoKyc> fofoKycs = fofoKycRepository.selectByPartnerOnBoardingId(pob.getId());
|