| Line 28... |
Line 28... |
| 28 |
import com.spice.profitmandi.dao.model.CreateOfferRequest;
|
28 |
import com.spice.profitmandi.dao.model.CreateOfferRequest;
|
| 29 |
import com.spice.profitmandi.dao.model.UserCart;
|
29 |
import com.spice.profitmandi.dao.model.UserCart;
|
| 30 |
import com.spice.profitmandi.dao.repository.catalog.*;
|
30 |
import com.spice.profitmandi.dao.repository.catalog.*;
|
| 31 |
import com.spice.profitmandi.dao.repository.dtr.*;
|
31 |
import com.spice.profitmandi.dao.repository.dtr.*;
|
| 32 |
import com.spice.profitmandi.dao.repository.fofo.CatalogFavouriteRepository;
|
32 |
import com.spice.profitmandi.dao.repository.fofo.CatalogFavouriteRepository;
|
| - |
|
33 |
import com.spice.profitmandi.dao.repository.fofo.CurrentInventorySnapshotRepository;
|
| 33 |
import com.spice.profitmandi.dao.repository.fofo.SuggestedPoDetailRepository;
|
34 |
import com.spice.profitmandi.dao.repository.fofo.SuggestedPoDetailRepository;
|
| 34 |
import com.spice.profitmandi.dao.repository.fofo.SuggestedPoRepository;
|
35 |
import com.spice.profitmandi.dao.repository.fofo.SuggestedPoRepository;
|
| 35 |
import com.spice.profitmandi.dao.repository.inventory.SaholicCISTableRepository;
|
36 |
import com.spice.profitmandi.dao.repository.inventory.SaholicCISTableRepository;
|
| 36 |
import com.spice.profitmandi.dao.repository.onboarding.BrandCommitRepository;
|
37 |
import com.spice.profitmandi.dao.repository.onboarding.BrandCommitRepository;
|
| 37 |
import com.spice.profitmandi.service.authentication.RoleManager;
|
38 |
import com.spice.profitmandi.service.authentication.RoleManager;
|
| Line 177... |
Line 178... |
| 177 |
BrandCommitRepository brandCommitRepository;
|
178 |
BrandCommitRepository brandCommitRepository;
|
| 178 |
|
179 |
|
| 179 |
@Autowired
|
180 |
@Autowired
|
| 180 |
CatalogRepository catalogRepository;
|
181 |
CatalogRepository catalogRepository;
|
| 181 |
|
182 |
|
| - |
|
183 |
@Autowired
|
| - |
|
184 |
private CurrentInventorySnapshotRepository currentInventorySnapshotRepository;
|
| - |
|
185 |
|
| 182 |
List<String> filterableParams = Arrays.asList("brand");
|
186 |
List<String> filterableParams = Arrays.asList("brand");
|
| 183 |
|
187 |
|
| 184 |
@RequestMapping(value = "/fofo/buckets", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
188 |
@RequestMapping(value = "/fofo/buckets", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
| 185 |
public ResponseEntity<?> getBuckets(HttpServletRequest request) throws ProfitMandiBusinessException {
|
189 |
public ResponseEntity<?> getBuckets(HttpServletRequest request) throws ProfitMandiBusinessException {
|
| 186 |
logger.info("Request " + request.getParameterMap());
|
190 |
logger.info("Request " + request.getParameterMap());
|
| Line 789... |
Line 793... |
| 789 |
private List<FofoCatalogResponse> getCatalogResponse(JSONArray docs, boolean hotDeal, int fofoId) throws
|
793 |
private List<FofoCatalogResponse> getCatalogResponse(JSONArray docs, boolean hotDeal, int fofoId) throws
|
| 790 |
Exception {
|
794 |
Exception {
|
| 791 |
List<FofoCatalogResponse> dealResponse = new ArrayList<>();
|
795 |
List<FofoCatalogResponse> dealResponse = new ArrayList<>();
|
| 792 |
List<Integer> tagIds = Arrays.asList(4);
|
796 |
List<Integer> tagIds = Arrays.asList(4);
|
| 793 |
List<Integer> itemIds = new ArrayList<>();
|
797 |
List<Integer> itemIds = new ArrayList<>();
|
| - |
|
798 |
Map<Integer, Integer> partnerStockAvailabilityMap = null;
|
| 794 |
if (docs.length() > 0) {
|
799 |
if (docs.length() > 0) {
|
| 795 |
for (int i = 0; i < docs.length(); i++) {
|
800 |
for (int i = 0; i < docs.length(); i++) {
|
| 796 |
JSONObject doc = docs.getJSONObject(i);
|
801 |
JSONObject doc = docs.getJSONObject(i);
|
| 797 |
if (doc.has("_childDocuments_")) {
|
802 |
if (doc.has("_childDocuments_")) {
|
| 798 |
for (int j = 0; j < doc.getJSONArray("_childDocuments_").length(); j++) {
|
803 |
for (int j = 0; j < doc.getJSONArray("_childDocuments_").length(); j++) {
|
| Line 809... |
Line 814... |
| 809 |
// get warehouse Id
|
814 |
// get warehouse Id
|
| 810 |
int warehouseId = fofoStoreRepository.selectByRetailerId(fofoId).getWarehouseId();
|
815 |
int warehouseId = fofoStoreRepository.selectByRetailerId(fofoId).getWarehouseId();
|
| 811 |
Map<Integer, List<SaholicPOItem>> poItemAvailabilityMap = saholicInventoryService.getSaholicPOItems().get(warehouseId);
|
816 |
Map<Integer, List<SaholicPOItem>> poItemAvailabilityMap = saholicInventoryService.getSaholicPOItems().get(warehouseId);
|
| 812 |
List<Integer> catalogIds = new ArrayList<>();
|
817 |
List<Integer> catalogIds = new ArrayList<>();
|
| 813 |
for (int i = 0; i < docs.length(); i++) {
|
818 |
for (int i = 0; i < docs.length(); i++) {
|
| 814 |
Map<Integer, FofoAvailabilityInfo> fofoAvailabilityInfoMap = new HashMap<>();
|
- |
|
| 815 |
JSONObject doc = docs.getJSONObject(i);
|
819 |
JSONObject doc = docs.getJSONObject(i);
|
| 816 |
catalogIds.add(doc.getInt("catalogId_i"));
|
820 |
catalogIds.add(doc.getInt("catalogId_i"));
|
| 817 |
}
|
821 |
}
|
| 818 |
List<CreateOfferRequest> allSchemOffers = null;
|
822 |
List<CreateOfferRequest> allSchemOffers = null;
|
| 819 |
Map<Integer, PriceCircularItemModelNew> priceCircularItemModelMap = new HashMap<>();
|
823 |
Map<Integer, PriceCircularItemModelNew> priceCircularItemModelMap = new HashMap<>();
|
| Line 835... |
Line 839... |
| 835 |
|
839 |
|
| 836 |
if (!catalogFavourites.isEmpty()) {
|
840 |
if (!catalogFavourites.isEmpty()) {
|
| 837 |
catalogFavourites.stream().collect(Collectors.toMap(x -> x.getCatalogId(), x -> x));
|
841 |
catalogFavourites.stream().collect(Collectors.toMap(x -> x.getCatalogId(), x -> x));
|
| 838 |
}*/
|
842 |
}*/
|
| 839 |
|
843 |
|
| - |
|
844 |
if (fofoId > 0) {
|
| - |
|
845 |
partnerStockAvailabilityMap = currentInventorySnapshotRepository.selectItemsStock(fofoId).stream().collect(Collectors.toMap(x -> x.getItemId(), x -> x.getAvailability()));
|
| - |
|
846 |
logger.info("partnerStockAvailabilityMap: {}",partnerStockAvailabilityMap);
|
| - |
|
847 |
}
|
| - |
|
848 |
|
| 840 |
for (int i = 0; i < docs.length(); i++) {
|
849 |
for (int i = 0; i < docs.length(); i++) {
|
| 841 |
Map<Integer, FofoAvailabilityInfo> fofoAvailabilityInfoMap = new HashMap<>();
|
850 |
Map<Integer, FofoAvailabilityInfo> fofoAvailabilityInfoMap = new HashMap<>();
|
| 842 |
JSONObject doc = docs.getJSONObject(i);
|
851 |
JSONObject doc = docs.getJSONObject(i);
|
| 843 |
FofoCatalogResponse fofoCatalogResponse = new FofoCatalogResponse();
|
852 |
FofoCatalogResponse fofoCatalogResponse = new FofoCatalogResponse();
|
| 844 |
fofoCatalogResponse.setCatalogId(doc.getInt("catalogId_i"));
|
853 |
fofoCatalogResponse.setCatalogId(doc.getInt("catalogId_i"));
|
| Line 907... |
Line 916... |
| 907 |
for (int j = 0; j < doc.getJSONArray("_childDocuments_").length(); j++) {
|
916 |
for (int j = 0; j < doc.getJSONArray("_childDocuments_").length(); j++) {
|
| 908 |
PriceCircularItemModelNew priceCircularItemModel = priceCircularItemModelMap.get(fofoCatalogResponse.getCatalogId());
|
917 |
PriceCircularItemModelNew priceCircularItemModel = priceCircularItemModelMap.get(fofoCatalogResponse.getCatalogId());
|
| 909 |
JSONObject childItem = doc.getJSONArray("_childDocuments_").getJSONObject(j);
|
918 |
JSONObject childItem = doc.getJSONArray("_childDocuments_").getJSONObject(j);
|
| 910 |
int itemId = childItem.getInt("itemId_i");
|
919 |
int itemId = childItem.getInt("itemId_i");
|
| 911 |
float sellingPrice = (float) childItem.getDouble("sellingPrice_f");
|
920 |
float sellingPrice = (float) childItem.getDouble("sellingPrice_f");
|
| - |
|
921 |
int partnerAvailability = partnerStockAvailabilityMap.get(itemId) == null ? 0 : partnerStockAvailabilityMap.get(itemId);
|
| 912 |
if (!fofoAvailabilityInfoMap.containsKey(itemId)) {
|
922 |
if (!fofoAvailabilityInfoMap.containsKey(itemId)) {
|
| 913 |
FofoAvailabilityInfo fdi = new FofoAvailabilityInfo();
|
923 |
FofoAvailabilityInfo fdi = new FofoAvailabilityInfo();
|
| 914 |
List<SaholicCISTable> currentAvailability = saholicCISTableRepository.selectByItemWarehouse(itemId, warehouseId);
|
924 |
List<SaholicCISTable> currentAvailability = saholicCISTableRepository.selectByItemWarehouse(itemId, warehouseId);
|
| 915 |
List<SaholicPOItem> poItemAvailability = null;
|
925 |
List<SaholicPOItem> poItemAvailability = null;
|
| 916 |
if (poItemAvailabilityMap != null) {
|
926 |
if (poItemAvailabilityMap != null) {
|
| Line 983... |
Line 993... |
| 983 |
if (currentAvailability != null) {
|
993 |
if (currentAvailability != null) {
|
| 984 |
fdi.setAvailability(currentAvailability.stream().collect(Collectors.summingInt(SaholicCISTable::getNetAvailability)));
|
994 |
fdi.setAvailability(currentAvailability.stream().collect(Collectors.summingInt(SaholicCISTable::getNetAvailability)));
|
| 985 |
} else {
|
995 |
} else {
|
| 986 |
fdi.setAvailability(0);
|
996 |
fdi.setAvailability(0);
|
| 987 |
}
|
997 |
}
|
| - |
|
998 |
fdi.setPartnerAvailability(partnerAvailability);
|
| 988 |
} else {
|
999 |
} else {
|
| 989 |
// Lets consider that its out of stock
|
1000 |
// Lets consider that its out of stock
|
| 990 |
fdi.setAvailability(400);
|
1001 |
fdi.setAvailability(400);
|
| 991 |
Item item = null;
|
1002 |
Item item = null;
|
| 992 |
try {
|
1003 |
try {
|