| Line 21... |
Line 21... |
| 21 |
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
|
21 |
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
|
| 22 |
import com.spice.profitmandi.dao.entity.fofo.SuggestedPo;
|
22 |
import com.spice.profitmandi.dao.entity.fofo.SuggestedPo;
|
| 23 |
import com.spice.profitmandi.dao.entity.fofo.SuggestedPoDetail;
|
23 |
import com.spice.profitmandi.dao.entity.fofo.SuggestedPoDetail;
|
| 24 |
import com.spice.profitmandi.dao.entity.inventory.SaholicCIS;
|
24 |
import com.spice.profitmandi.dao.entity.inventory.SaholicCIS;
|
| 25 |
import com.spice.profitmandi.dao.entity.inventory.SaholicPOItem;
|
25 |
import com.spice.profitmandi.dao.entity.inventory.SaholicPOItem;
|
| - |
|
26 |
import com.spice.profitmandi.dao.model.CreateOfferRequest;
|
| 26 |
import com.spice.profitmandi.dao.model.UserCart;
|
27 |
import com.spice.profitmandi.dao.model.UserCart;
|
| 27 |
import com.spice.profitmandi.dao.repository.catalog.CategoryRepository;
|
28 |
import com.spice.profitmandi.dao.repository.catalog.CategoryRepository;
|
| 28 |
import com.spice.profitmandi.dao.repository.catalog.ItemRepository;
|
29 |
import com.spice.profitmandi.dao.repository.catalog.ItemRepository;
|
| 29 |
import com.spice.profitmandi.dao.repository.catalog.TagListingRepository;
|
30 |
import com.spice.profitmandi.dao.repository.catalog.TagListingRepository;
|
| 30 |
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
|
31 |
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
|
| Line 540... |
Line 541... |
| 540 |
for (int i = 0; i < docs.length(); i++) {
|
541 |
for (int i = 0; i < docs.length(); i++) {
|
| 541 |
Map<Integer, FofoAvailabilityInfo> fofoAvailabilityInfoMap = new HashMap<>();
|
542 |
Map<Integer, FofoAvailabilityInfo> fofoAvailabilityInfoMap = new HashMap<>();
|
| 542 |
JSONObject doc = docs.getJSONObject(i);
|
543 |
JSONObject doc = docs.getJSONObject(i);
|
| 543 |
catalogIds.add(doc.getInt("catalogId_i"));
|
544 |
catalogIds.add(doc.getInt("catalogId_i"));
|
| 544 |
}
|
545 |
}
|
| - |
|
546 |
List<CreateOfferRequest> allSchemOffers = null;
|
| 545 |
Map<Integer, PriceCircularItemModel> priceCircularItemModelMap = new HashMap<>();
|
547 |
Map<Integer, PriceCircularItemModel> priceCircularItemModelMap = new HashMap<>();
|
| 546 |
if (catalogIds.size() > 0) {
|
548 |
if (catalogIds.size() > 0) {
|
| 547 |
PriceCircularModel priceCircularModel = priceCircularService.getPriceCircularByOffer(fofoId, catalogIds);
|
549 |
PriceCircularModel priceCircularModel = priceCircularService.getPriceCircularByOffer(fofoId, catalogIds);
|
| - |
|
550 |
allSchemOffers = priceCircularModel.getOffers();
|
| 548 |
|
551 |
|
| 549 |
List<PriceCircularItemModel> priceCircularItemModels = priceCircularModel.getPriceCircularItemModels();
|
552 |
List<PriceCircularItemModel> priceCircularItemModels = priceCircularModel.getPriceCircularItemModels();
|
| 550 |
if (priceCircularItemModels != null) {
|
553 |
if (priceCircularItemModels != null) {
|
| 551 |
priceCircularItemModelMap = priceCircularItemModels.stream().collect(Collectors.toMap(x -> x.getCatalogId(), x -> x));
|
554 |
priceCircularItemModelMap = priceCircularItemModels.stream().collect(Collectors.toMap(x -> x.getCatalogId(), x -> x));
|
| 552 |
}
|
555 |
}
|
| 553 |
}
|
556 |
}
|
| - |
|
557 |
|
| 554 |
for (int i = 0; i < docs.length(); i++) {
|
558 |
for (int i = 0; i < docs.length(); i++) {
|
| 555 |
Map<Integer, FofoAvailabilityInfo> fofoAvailabilityInfoMap = new HashMap<>();
|
559 |
Map<Integer, FofoAvailabilityInfo> fofoAvailabilityInfoMap = new HashMap<>();
|
| 556 |
JSONObject doc = docs.getJSONObject(i);
|
560 |
JSONObject doc = docs.getJSONObject(i);
|
| 557 |
FofoCatalogResponse ffdr = new FofoCatalogResponse();
|
561 |
FofoCatalogResponse fofoCatalogResponse = new FofoCatalogResponse();
|
| 558 |
ffdr.setCatalogId(doc.getInt("catalogId_i"));
|
562 |
fofoCatalogResponse.setCatalogId(doc.getInt("catalogId_i"));
|
| 559 |
ffdr.setImageUrl(doc.getString("imageUrl_s"));
|
563 |
fofoCatalogResponse.setImageUrl(doc.getString("imageUrl_s"));
|
| 560 |
ffdr.setTitle(doc.getString("title_s"));
|
564 |
fofoCatalogResponse.setTitle(doc.getString("title_s"));
|
| 561 |
try {
|
565 |
try {
|
| 562 |
ffdr.setFeature(doc.getString("feature_s"));
|
566 |
fofoCatalogResponse.setFeature(doc.getString("feature_s"));
|
| 563 |
} catch (Exception e) {
|
567 |
} catch (Exception e) {
|
| 564 |
ffdr.setFeature(null);
|
568 |
fofoCatalogResponse.setFeature(null);
|
| 565 |
logger.info("Could not find Feature_s for {}", ffdr.getCatalogId());
|
569 |
logger.info("Could not find Feature_s for {}", fofoCatalogResponse.getCatalogId());
|
| 566 |
}
|
570 |
}
|
| 567 |
ffdr.setBrand(doc.getJSONArray("brand_ss").getString(0));
|
571 |
fofoCatalogResponse.setBrand(doc.getJSONArray("brand_ss").getString(0));
|
| 568 |
if (doc.has("_childDocuments_")) {
|
572 |
if (doc.has("_childDocuments_")) {
|
| 569 |
String modelColorClass = "grey";
|
573 |
String modelColorClass = "grey";
|
| 570 |
FofoAvailabilityInfo fdiAnyColour = null;
|
574 |
FofoAvailabilityInfo fdiAnyColour = null;
|
| 571 |
int allColorNetAvailability = 0;
|
575 |
int allColorNetAvailability = 0;
|
| 572 |
for (int j = 0; j < doc.getJSONArray("_childDocuments_").length(); j++) {
|
576 |
for (int j = 0; j < doc.getJSONArray("_childDocuments_").length(); j++) {
|
| 573 |
PriceCircularItemModel priceCircularItemModel = priceCircularItemModelMap.get(ffdr.getCatalogId());
|
577 |
PriceCircularItemModel priceCircularItemModel = priceCircularItemModelMap.get(fofoCatalogResponse.getCatalogId());
|
| 574 |
JSONObject childItem = doc.getJSONArray("_childDocuments_").getJSONObject(j);
|
578 |
JSONObject childItem = doc.getJSONArray("_childDocuments_").getJSONObject(j);
|
| 575 |
int itemId = childItem.getInt("itemId_i");
|
579 |
int itemId = childItem.getInt("itemId_i");
|
| 576 |
float sellingPrice = (float) childItem.getDouble("sellingPrice_f");
|
580 |
float sellingPrice = (float) childItem.getDouble("sellingPrice_f");
|
| 577 |
if (fofoAvailabilityInfoMap.containsKey(itemId)) {
|
581 |
if (fofoAvailabilityInfoMap.containsKey(itemId)) {
|
| 578 |
if (fofoAvailabilityInfoMap.get(itemId).getSellingPrice() > sellingPrice) {
|
582 |
if (fofoAvailabilityInfoMap.get(itemId).getSellingPrice() > sellingPrice) {
|
| Line 672... |
Line 676... |
| 672 |
if (fdi.getColor().equalsIgnoreCase("any colour")) {
|
676 |
if (fdi.getColor().equalsIgnoreCase("any colour")) {
|
| 673 |
fdiAnyColour = fdi;
|
677 |
fdiAnyColour = fdi;
|
| 674 |
}
|
678 |
}
|
| 675 |
fdi.setTagId(childItem.getInt("tagId_i"));
|
679 |
fdi.setTagId(childItem.getInt("tagId_i"));
|
| 676 |
fdi.setItem_id(itemId);
|
680 |
fdi.setItem_id(itemId);
|
| 677 |
Float cashBack = schemeService.getCatalogSchemeCashBack().get(ffdr.getCatalogId());
|
681 |
Float cashBack = schemeService.getCatalogSchemeCashBack().get(fofoCatalogResponse.getCatalogId());
|
| 678 |
cashBack = cashBack == null ? 0 : cashBack;
|
682 |
cashBack = cashBack == null ? 0 : cashBack;
|
| 679 |
fdi.setCashback(cashBack);
|
683 |
fdi.setCashback(cashBack);
|
| 680 |
fdi.setMinBuyQuantity(1);
|
684 |
fdi.setMinBuyQuantity(1);
|
| 681 |
if (hotDeal) {
|
685 |
if (hotDeal) {
|
| 682 |
if (currentAvailability != null) {
|
686 |
if (currentAvailability != null) {
|
| Line 717... |
Line 721... |
| 717 |
}
|
721 |
}
|
| 718 |
if (fofoAvailabilityInfoMap.values().size() > 0) {
|
722 |
if (fofoAvailabilityInfoMap.values().size() > 0) {
|
| 719 |
List<FofoAvailabilityInfo> availabilityList = fofoAvailabilityInfoMap.values().stream()
|
723 |
List<FofoAvailabilityInfo> availabilityList = fofoAvailabilityInfoMap.values().stream()
|
| 720 |
.sorted(Comparator.comparing(FofoAvailabilityInfo::getAvailability).reversed())
|
724 |
.sorted(Comparator.comparing(FofoAvailabilityInfo::getAvailability).reversed())
|
| 721 |
.collect(Collectors.toList());
|
725 |
.collect(Collectors.toList());
|
| 722 |
ffdr.setItems(availabilityList);
|
726 |
fofoCatalogResponse.setItems(availabilityList);
|
| - |
|
727 |
if (priceCircularItemModelMap.containsKey(fofoCatalogResponse.getCatalogId())) {
|
| - |
|
728 |
PriceCircularItemModel priceCircularItemModel = priceCircularItemModelMap.get(fofoCatalogResponse.getCatalogId());
|
| - |
|
729 |
List<CreateOfferRequest> schemeOffers = new ArrayList<>();
|
| - |
|
730 |
for (int j = 0; j < priceCircularItemModel.getSlabPayouts().size(); j++) {
|
| - |
|
731 |
if (priceCircularItemModel.getSlabPayouts().get(i) != null) {
|
| - |
|
732 |
schemeOffers.add(allSchemOffers.get(i));
|
| - |
|
733 |
}
|
| - |
|
734 |
}
|
| - |
|
735 |
fofoCatalogResponse.setSchemeOffers(schemeOffers);
|
| - |
|
736 |
fofoCatalogResponse.setPriceCircularItemModel(priceCircularItemModel);
|
| - |
|
737 |
|
| - |
|
738 |
}
|
| 723 |
dealResponse.add(ffdr);
|
739 |
dealResponse.add(fofoCatalogResponse);
|
| 724 |
}
|
740 |
}
|
| 725 |
}
|
741 |
}
|
| 726 |
return dealResponse;
|
742 |
return dealResponse;
|
| 727 |
|
743 |
|
| 728 |
}
|
744 |
}
|