Subversion Repositories SmartDukaan

Rev

Rev 37276 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 37276 Rev 37640
Line 299... Line 299...
299
        eolSet.addAll(eolWithBadQty);
299
        eolSet.addAll(eolWithBadQty);
300
 
300
 
301
        // Flagship models active as of today (catalog.model_flagship start_date/end_date)
301
        // Flagship models active as of today (catalog.model_flagship start_date/end_date)
302
        Set<Integer> flagshipSet = modelFlagshipRepository.selectActiveFlagshipCatalogIds();
302
        Set<Integer> flagshipSet = modelFlagshipRepository.selectActiveFlagshipCatalogIds();
303
 
303
 
304
        // Hot deal models active as of today (catalog.model_hot_deal start_date/end_date).
304
        // Hot deal membership IS brand membership (catalog.brand = 'Hot Deal'). There is no
-
 
305
        // date window any more; model_hot_deal supplies only the pill attributes and the
-
 
306
        // pre-move brand, which is pushed separately as oem_brand_s.
-
 
307
        Set<Integer> hotDealSet = catalogRepository
-
 
308
                .selectCatalogIdsByBrand(ProfitMandiConstants.HOT_DEAL_BRAND);
-
 
309
 
305
        // This table is the only source of hot_deal_b - tag_listing.hot_deals is not read.
310
        // oem_brand_s drives the brand chips INSIDE the hot-deal listing. It is kept out of
-
 
311
        // brand_ss on purpose: brand_ss feeds SolrService.brandExclusionFq, so an OEM value
-
 
312
        // there would hide the SKU from a partner blocked on that OEM.
-
 
313
        Map<Integer, String> oemBrandByCatalog = new HashMap<>();
-
 
314
        for (com.spice.profitmandi.dao.entity.catalog.ModelHotDeal hotDealRow : modelHotDealRepository
-
 
315
                .selectByCatalogItemIds(new ArrayList<>(hotDealSet))) {
-
 
316
            if (hotDealRow.getOemBrand() != null) {
306
        Set<Integer> hotDealSet = modelHotDealRepository.selectActiveCatalogIds(java.time.LocalDate.now());
317
                oemBrandByCatalog.put(hotDealRow.getCatalogItemId(), hotDealRow.getOemBrand());
-
 
318
            }
-
 
319
        }
307
 
320
 
308
        // Flagship is surfaced as a label (prepended so it shows first, ahead of all other flags)
321
        // Flagship is surfaced as a label (prepended so it shows first, ahead of all other flags)
309
        for (Integer flagshipCatalogId : flagshipSet) {
322
        for (Integer flagshipCatalogId : flagshipSet) {
310
            catalogLabelMap.computeIfAbsent(flagshipCatalogId, k -> new ArrayList<>()).add(0, "flagship");
323
            catalogLabelMap.computeIfAbsent(flagshipCatalogId, k -> new ArrayList<>()).add(0, "flagship");
311
        }
324
        }
Line 484... Line 497...
484
                    itemObj.setField("mrp_f", tagListing.getMrp());
497
                    itemObj.setField("mrp_f", tagListing.getMrp());
485
                    itemObj.setField("mop_f", tagListing.getMop());
498
                    itemObj.setField("mop_f", tagListing.getMop());
486
                    itemObj.setField("sellingPrice_f", tagListing.getSellingPrice());
499
                    itemObj.setField("sellingPrice_f", tagListing.getSellingPrice());
487
                    itemObj.setField("active_b", tagListing.isActive());
500
                    itemObj.setField("active_b", tagListing.isActive());
488
                    itemObj.setField("hot_deal_b", hotDealSet.contains(catalogId));
501
                    itemObj.setField("hot_deal_b", hotDealSet.contains(catalogId));
-
 
502
                    if (oemBrandByCatalog.containsKey(catalogId)) {
-
 
503
                        itemObj.setField("oem_brand_s", oemBrandByCatalog.get(catalogId));
-
 
504
                    }
489
                    mop = tagListing.getMop();
505
                    mop = tagListing.getMop();
490
                    dp = tagListing.getSellingPrice();
506
                    dp = tagListing.getSellingPrice();
491
                }
507
                }
492
                itemObjs.add(itemObj);
508
                itemObjs.add(itemObj);
493
            }
509
            }
Line 570... Line 586...
570
            }else {
586
            }else {
571
                catalogSolrObj.setField("eol_no_stock_b", false);
587
                catalogSolrObj.setField("eol_no_stock_b", false);
572
            }
588
            }
573
            catalogSolrObj.setField("flagship_b", flagshipSet.contains(catalogId));
589
            catalogSolrObj.setField("flagship_b", flagshipSet.contains(catalogId));
574
            catalogSolrObj.setField("hot_deal_b", hotDealSet.contains(catalogId));
590
            catalogSolrObj.setField("hot_deal_b", hotDealSet.contains(catalogId));
-
 
591
            if (oemBrandByCatalog.containsKey(catalogId)) {
-
 
592
                catalogSolrObj.setField("oem_brand_s", oemBrandByCatalog.get(catalogId));
-
 
593
            }
575
            catalogSolrObjs.add(catalogSolrObj);
594
            catalogSolrObjs.add(catalogSolrObj);
576
        }
595
        }
577
 
596
 
578
        String solrPath = "http://" + solrUrl + ":8984/solr/demo";
597
        String solrPath = "http://" + solrUrl + ":8984/solr/demo";
579
        SolrClient solr = new HttpSolrClient.Builder(solrPath).build();
598
        SolrClient solr = new HttpSolrClient.Builder(solrPath).build();
Line 600... Line 619...
600
        logger.info("Updating single catalog in Solr: catalogId={}", catalogId);
619
        logger.info("Updating single catalog in Solr: catalogId={}", catalogId);
601
 
620
 
602
        List<status> statuses = Arrays.asList(status.ACTIVE, status.PAUSED_BY_RISK, status.PARTIALLY_ACTIVE);
621
        List<status> statuses = Arrays.asList(status.ACTIVE, status.PAUSED_BY_RISK, status.PARTIALLY_ACTIVE);
603
        boolean flagship = !modelFlagshipRepository
622
        boolean flagship = !modelFlagshipRepository
604
                .selectActiveFlagshipCatalogIds(Collections.singletonList(catalogId)).isEmpty();
623
                .selectActiveFlagshipCatalogIds(Collections.singletonList(catalogId)).isEmpty();
-
 
624
        // Membership from the brand; oem_brand_s from the attributes row, which may be
-
 
625
        // absent on a freshly migrated SKU whose pills ops has not filled in yet.
-
 
626
        // Fully qualified: this package has its own Catalog class, which shadows the entity.
-
 
627
        com.spice.profitmandi.dao.entity.catalog.Catalog hotDealCatalog =
-
 
628
                catalogRepository.selectCatalogById(catalogId);
605
        boolean hotDeal = !modelHotDealRepository
629
        boolean hotDeal = hotDealCatalog != null
-
 
630
                && ProfitMandiConstants.HOT_DEAL_BRAND.equals(hotDealCatalog.getBrand());
-
 
631
        com.spice.profitmandi.dao.entity.catalog.ModelHotDeal hotDealRow =
606
                .selectActiveByCatalogItemIds(Collections.singletonList(catalogId), java.time.LocalDate.now())
632
                hotDeal ? modelHotDealRepository.selectByCatalogItemId(catalogId) : null;
607
                .isEmpty();
633
        String oemBrand = hotDealRow == null ? null : hotDealRow.getOemBrand();
608
 
634
 
609
        // Get all TagListings for this catalog
635
        // Get all TagListings for this catalog
610
        List<ItemTagModel> itemTagModels = tagListingRepository.getItemTagByCatalogIdAndStatus(catalogId, statuses);
636
        List<ItemTagModel> itemTagModels = tagListingRepository.getItemTagByCatalogIdAndStatus(catalogId, statuses);
611
 
637
 
612
        if (itemTagModels.isEmpty()) {
638
        if (itemTagModels.isEmpty()) {
Line 670... Line 696...
670
            itemObj.setField("mrp_f", tagListing.getMrp());
696
            itemObj.setField("mrp_f", tagListing.getMrp());
671
            itemObj.setField("mop_f", tagListing.getMop());
697
            itemObj.setField("mop_f", tagListing.getMop());
672
            itemObj.setField("sellingPrice_f", tagListing.getSellingPrice());
698
            itemObj.setField("sellingPrice_f", tagListing.getSellingPrice());
673
            itemObj.setField("active_b", tagListing.isActive());
699
            itemObj.setField("active_b", tagListing.isActive());
674
            itemObj.setField("hot_deal_b", hotDeal);
700
            itemObj.setField("hot_deal_b", hotDeal);
-
 
701
            if (oemBrand != null) {
-
 
702
                itemObj.setField("oem_brand_s", oemBrand);
-
 
703
            }
675
            mop = tagListing.getMop();
704
            mop = tagListing.getMop();
676
            dp = tagListing.getSellingPrice();
705
            dp = tagListing.getSellingPrice();
677
            itemObjs.add(itemObj);
706
            itemObjs.add(itemObj);
678
 
707
 
679
            // Calculate availability color
708
            // Calculate availability color
Line 805... Line 834...
805
 
834
 
806
        catalogSolrObj.setField("active_b", active);
835
        catalogSolrObj.setField("active_b", active);
807
        catalogSolrObj.setField("eol_no_stock_b", eolSet.contains(catalogId));
836
        catalogSolrObj.setField("eol_no_stock_b", eolSet.contains(catalogId));
808
        catalogSolrObj.setField("flagship_b", flagship);
837
        catalogSolrObj.setField("flagship_b", flagship);
809
        catalogSolrObj.setField("hot_deal_b", hotDeal);
838
        catalogSolrObj.setField("hot_deal_b", hotDeal);
-
 
839
        if (oemBrand != null) {
-
 
840
            catalogSolrObj.setField("oem_brand_s", oemBrand);
-
 
841
        }
810
 
842
 
811
        // Push to Solr
843
        // Push to Solr
812
        String solrPath = "http://" + solrUrl + ":8984/solr/demo";
844
        String solrPath = "http://" + solrUrl + ":8984/solr/demo";
813
        SolrClient solr = new HttpSolrClient.Builder(solrPath).build();
845
        SolrClient solr = new HttpSolrClient.Builder(solrPath).build();
814
 
846