| Line 1... |
Line 1... |
| 1 |
package com.smartdukaan.cron.migrations;
|
1 |
package com.smartdukaan.cron.migrations;
|
| 2 |
|
2 |
|
| 3 |
import java.io.File;
|
3 |
import java.io.File;
|
| 4 |
import java.io.Serializable;
|
- |
|
| 5 |
import java.time.LocalDate;
|
4 |
import java.time.LocalDate;
|
| 6 |
import java.time.LocalDateTime;
|
5 |
import java.time.LocalDateTime;
|
| 7 |
import java.time.LocalTime;
|
6 |
import java.time.LocalTime;
|
| 8 |
import java.util.ArrayList;
|
7 |
import java.util.ArrayList;
|
| 9 |
import java.util.Arrays;
|
8 |
import java.util.Arrays;
|
| Line 31... |
Line 30... |
| 31 |
import org.springframework.mail.javamail.JavaMailSender;
|
30 |
import org.springframework.mail.javamail.JavaMailSender;
|
| 32 |
import org.springframework.stereotype.Component;
|
31 |
import org.springframework.stereotype.Component;
|
| 33 |
import org.springframework.transaction.annotation.Transactional;
|
32 |
import org.springframework.transaction.annotation.Transactional;
|
| 34 |
|
33 |
|
| 35 |
import com.smartdukaan.cron.scheduled.ScheduledTasks;
|
34 |
import com.smartdukaan.cron.scheduled.ScheduledTasks;
|
| - |
|
35 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
| 36 |
import com.spice.profitmandi.common.util.FileUtil;
|
36 |
import com.spice.profitmandi.common.util.FileUtil;
|
| 37 |
import com.spice.profitmandi.common.util.FormattingUtils;
|
37 |
import com.spice.profitmandi.common.util.FormattingUtils;
|
| 38 |
import com.spice.profitmandi.common.util.Utils;
|
38 |
import com.spice.profitmandi.common.util.Utils;
|
| - |
|
39 |
import com.spice.profitmandi.dao.entity.catalog.Item;
|
| 39 |
import com.spice.profitmandi.dao.entity.catalog.Scheme;
|
40 |
import com.spice.profitmandi.dao.entity.catalog.Scheme;
|
| 40 |
import com.spice.profitmandi.dao.entity.fofo.CurrentInventorySnapshot;
|
41 |
import com.spice.profitmandi.dao.entity.fofo.CurrentInventorySnapshot;
|
| 41 |
import com.spice.profitmandi.dao.entity.fofo.FofoOrder;
|
42 |
import com.spice.profitmandi.dao.entity.fofo.FofoOrder;
|
| 42 |
import com.spice.profitmandi.dao.entity.fofo.FofoOrderItem;
|
43 |
import com.spice.profitmandi.dao.entity.fofo.FofoOrderItem;
|
| 43 |
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
|
44 |
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
|
| 44 |
import com.spice.profitmandi.dao.entity.fofo.InventoryItem;
|
45 |
import com.spice.profitmandi.dao.entity.fofo.InventoryItem;
|
| 45 |
import com.spice.profitmandi.dao.entity.fofo.PartnerTargetDetails;
|
46 |
import com.spice.profitmandi.dao.entity.fofo.PartnerTargetDetails;
|
| - |
|
47 |
import com.spice.profitmandi.dao.entity.fofo.PrebookingOrder;
|
| 46 |
import com.spice.profitmandi.dao.entity.fofo.Purchase;
|
48 |
import com.spice.profitmandi.dao.entity.fofo.Purchase;
|
| 47 |
import com.spice.profitmandi.dao.entity.fofo.ScanRecord;
|
49 |
import com.spice.profitmandi.dao.entity.fofo.ScanRecord;
|
| 48 |
import com.spice.profitmandi.dao.entity.fofo.SchemeInOut;
|
50 |
import com.spice.profitmandi.dao.entity.fofo.SchemeInOut;
|
| 49 |
import com.spice.profitmandi.dao.entity.fofo.SchemeItem;
|
51 |
import com.spice.profitmandi.dao.entity.fofo.SchemeItem;
|
| 50 |
import com.spice.profitmandi.dao.entity.fofo.TargetSlab;
|
52 |
import com.spice.profitmandi.dao.entity.fofo.TargetSlab;
|
| Line 69... |
Line 71... |
| 69 |
import com.spice.profitmandi.dao.repository.fofo.FofoOrderItemRepository;
|
71 |
import com.spice.profitmandi.dao.repository.fofo.FofoOrderItemRepository;
|
| 70 |
import com.spice.profitmandi.dao.repository.fofo.FofoOrderRepository;
|
72 |
import com.spice.profitmandi.dao.repository.fofo.FofoOrderRepository;
|
| 71 |
import com.spice.profitmandi.dao.repository.fofo.InventoryItemRepository;
|
73 |
import com.spice.profitmandi.dao.repository.fofo.InventoryItemRepository;
|
| 72 |
import com.spice.profitmandi.dao.repository.fofo.InvoiceNumberGenerationSequenceRepository;
|
74 |
import com.spice.profitmandi.dao.repository.fofo.InvoiceNumberGenerationSequenceRepository;
|
| 73 |
import com.spice.profitmandi.dao.repository.fofo.PartnerTargetRepository;
|
75 |
import com.spice.profitmandi.dao.repository.fofo.PartnerTargetRepository;
|
| - |
|
76 |
import com.spice.profitmandi.dao.repository.fofo.PrebookingOrderRepository;
|
| 74 |
import com.spice.profitmandi.dao.repository.fofo.PurchaseRepository;
|
77 |
import com.spice.profitmandi.dao.repository.fofo.PurchaseRepository;
|
| 75 |
import com.spice.profitmandi.dao.repository.fofo.ScanRecordRepository;
|
78 |
import com.spice.profitmandi.dao.repository.fofo.ScanRecordRepository;
|
| 76 |
import com.spice.profitmandi.dao.repository.fofo.SchemeInOutRepository;
|
79 |
import com.spice.profitmandi.dao.repository.fofo.SchemeInOutRepository;
|
| 77 |
import com.spice.profitmandi.dao.repository.fofo.SchemeItemRepository;
|
80 |
import com.spice.profitmandi.dao.repository.fofo.SchemeItemRepository;
|
| 78 |
import com.spice.profitmandi.dao.repository.fofo.TargetSlabRepository;
|
81 |
import com.spice.profitmandi.dao.repository.fofo.TargetSlabRepository;
|
| Line 87... |
Line 90... |
| 87 |
import com.spice.profitmandi.dao.repository.transaction.UserWalletHistoryRepository;
|
90 |
import com.spice.profitmandi.dao.repository.transaction.UserWalletHistoryRepository;
|
| 88 |
import com.spice.profitmandi.dao.repository.transaction.UserWalletRepository;
|
91 |
import com.spice.profitmandi.dao.repository.transaction.UserWalletRepository;
|
| 89 |
import com.spice.profitmandi.dao.repository.user.AddressRepository;
|
92 |
import com.spice.profitmandi.dao.repository.user.AddressRepository;
|
| 90 |
import com.spice.profitmandi.dao.repository.user.UserRepository;
|
93 |
import com.spice.profitmandi.dao.repository.user.UserRepository;
|
| 91 |
import com.spice.profitmandi.service.inventory.InventoryService;
|
94 |
import com.spice.profitmandi.service.inventory.InventoryService;
|
| - |
|
95 |
import com.spice.profitmandi.service.inventory.PurchaseService;
|
| 92 |
import com.spice.profitmandi.service.order.OrderService;
|
96 |
import com.spice.profitmandi.service.order.OrderService;
|
| 93 |
import com.spice.profitmandi.service.pricing.PriceDropService;
|
97 |
import com.spice.profitmandi.service.pricing.PriceDropService;
|
| 94 |
import com.spice.profitmandi.service.scheme.SchemeService;
|
98 |
import com.spice.profitmandi.service.scheme.SchemeService;
|
| 95 |
import com.spice.profitmandi.service.transaction.TransactionService;
|
99 |
import com.spice.profitmandi.service.transaction.TransactionService;
|
| 96 |
import com.spice.profitmandi.service.user.RetailerService;
|
100 |
import com.spice.profitmandi.service.user.RetailerService;
|
| Line 111... |
Line 115... |
| 111 |
@Autowired
|
115 |
@Autowired
|
| 112 |
private SaholicInventorySnapshotRepository saholicInventorySnapshotRepository;
|
116 |
private SaholicInventorySnapshotRepository saholicInventorySnapshotRepository;
|
| 113 |
|
117 |
|
| 114 |
@Autowired
|
118 |
@Autowired
|
| 115 |
private CsService csService;
|
119 |
private CsService csService;
|
| - |
|
120 |
|
| - |
|
121 |
@Autowired
|
| - |
|
122 |
private PrebookingOrderRepository prebookingOrderRepository;
|
| 116 |
|
123 |
|
| 117 |
@Autowired
|
124 |
@Autowired
|
| 118 |
private SaholicReservationInventorySnapshotRepository saholicReservationInventorySnapshotRepository;
|
125 |
private SaholicReservationInventorySnapshotRepository saholicReservationInventorySnapshotRepository;
|
| 119 |
|
126 |
|
| 120 |
@Autowired
|
127 |
@Autowired
|
| Line 150... |
Line 157... |
| 150 |
@Autowired
|
157 |
@Autowired
|
| 151 |
private InventoryService inventoryService;
|
158 |
private InventoryService inventoryService;
|
| 152 |
|
159 |
|
| 153 |
@Autowired
|
160 |
@Autowired
|
| 154 |
private TransactionService transactionService;
|
161 |
private TransactionService transactionService;
|
| - |
|
162 |
|
| - |
|
163 |
@Autowired
|
| - |
|
164 |
private PurchaseService purchaseService;
|
| - |
|
165 |
|
| 155 |
|
166 |
|
| 156 |
// Service for Tertiary/Partner Orders
|
167 |
// Service for Tertiary/Partner Orders
|
| 157 |
@Autowired
|
168 |
@Autowired
|
| 158 |
private OrderService orderService;
|
169 |
private OrderService orderService;
|
| 159 |
|
170 |
|
| Line 686... |
Line 697... |
| 686 |
Set<Integer> partnerIds = entry.getValue();
|
697 |
Set<Integer> partnerIds = entry.getValue();
|
| 687 |
StringBuffer body = new StringBuffer();
|
698 |
StringBuffer body = new StringBuffer();
|
| 688 |
Map<Integer, File> emailSnapshotMap = new HashMap<>();
|
699 |
Map<Integer, File> emailSnapshotMap = new HashMap<>();
|
| 689 |
for (int fofoId : partnerIds) {
|
700 |
for (int fofoId : partnerIds) {
|
| 690 |
body.append(String.format("<br/><img src=\"cid:%d\"/>", fofoId));
|
701 |
body.append(String.format("<br/><img src=\"cid:%d\"/>", fofoId));
|
| 691 |
LOGGER.info("partnerSnapshotMap.get(fofoId) {}", partnerSnapshotMap.get(fofoId));
|
- |
|
| 692 |
emailSnapshotMap.put(fofoId, partnerSnapshotMap.get(fofoId));
|
702 |
emailSnapshotMap.put(fofoId, partnerSnapshotMap.get(fofoId));
|
| 693 |
}
|
703 |
}
|
| 694 |
Utils.sendEmbeddedHtmlMail(mailSender, new String[] { email }, new String[] {},
|
704 |
Utils.sendEmbeddedHtmlMail(mailSender, new String[] { email }, new String[] {},
|
| 695 |
String.format("Franchise Screenshots - %s", FormattingUtils.formatDate(LocalDateTime.now())),
|
705 |
String.format("Franchise Screenshots - %s", FormattingUtils.formatDate(LocalDateTime.now())),
|
| 696 |
body.toString(), emailSnapshotMap);
|
706 |
body.toString(), emailSnapshotMap);
|
| 697 |
LOGGER.info("Sent mail to {}", email);
|
707 |
LOGGER.info("Sent mail to {}", email);
|
| 698 |
}
|
708 |
}
|
| 699 |
driver.quit();
|
709 |
driver.quit();
|
| 700 |
}
|
710 |
}
|
| - |
|
711 |
|
| - |
|
712 |
//Rollout prebooking orders amount in case the order is grned.
|
| - |
|
713 |
public void pbfix() throws ProfitMandiBusinessException {
|
| - |
|
714 |
List<Item> items = itemRepository.selectAllByCatalogItemId(1022304);
|
| - |
|
715 |
for(Item item : items) {
|
| - |
|
716 |
List<InventoryItem> inventoryItems = inventoryItemRepository.selectByItemId(item.getId(), 0, 500);
|
| - |
|
717 |
for(InventoryItem inventoryItem : inventoryItems) {
|
| - |
|
718 |
List<PrebookingOrder> prebookingOrders = prebookingOrderRepository
|
| - |
|
719 |
.selectByFofoIdAndCatalogIds(inventoryItem.getFofoId(), item.getCatalogItemId())
|
| - |
|
720 |
.stream().filter(x->x.getNotifyTimeStamp()==null).collect(Collectors.toList());
|
| - |
|
721 |
if(prebookingOrders.size() > 0) {
|
| - |
|
722 |
purchaseService.sendPrebookingNotifyMessage(prebookingOrders.get(0));
|
| - |
|
723 |
}
|
| - |
|
724 |
//inventoryItem.getFofoId()
|
| - |
|
725 |
}
|
| - |
|
726 |
}
|
| - |
|
727 |
throw new ProfitMandiBusinessException("", "", "");
|
| - |
|
728 |
//prebookingOrderRepository.select
|
| - |
|
729 |
// TODO Auto-generated method stub
|
| - |
|
730 |
|
| - |
|
731 |
}
|
| 701 |
}
|
732 |
}
|
| 702 |
|
733 |
|
| 703 |
//7015845171
|
734 |
//7015845171
|
| 704 |
|
735 |
|