| Line 2... |
Line 2... |
| 2 |
|
2 |
|
| 3 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
3 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
| 4 |
import com.spice.profitmandi.common.util.Utils;
|
4 |
import com.spice.profitmandi.common.util.Utils;
|
| 5 |
import com.spice.profitmandi.dao.entity.catalog.BrandCatalog;
|
5 |
import com.spice.profitmandi.dao.entity.catalog.BrandCatalog;
|
| 6 |
import com.spice.profitmandi.dao.entity.catalog.BrandCategory;
|
6 |
import com.spice.profitmandi.dao.entity.catalog.BrandCategory;
|
| - |
|
7 |
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
|
| - |
|
8 |
import com.spice.profitmandi.dao.entity.fofo.PartnerDealerMapping;
|
| - |
|
9 |
import com.spice.profitmandi.dao.entity.fofo.PartnerOnBoardingPanel;
|
| 7 |
import com.spice.profitmandi.dao.repository.catalog.BrandCategoryRepository;
|
10 |
import com.spice.profitmandi.dao.repository.catalog.BrandCategoryRepository;
|
| 8 |
import com.spice.profitmandi.dao.repository.catalog.BrandsRepository;
|
11 |
import com.spice.profitmandi.dao.repository.catalog.BrandsRepository;
|
| - |
|
12 |
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
|
| - |
|
13 |
import com.spice.profitmandi.dao.repository.dtr.PartnerDealerRepository;
|
| - |
|
14 |
import com.spice.profitmandi.dao.repository.dtr.PartnerOnBoardingPanelRepository;
|
| 9 |
import com.spice.profitmandi.dao.repository.dtr.RetailerBlockBrandsRepository;
|
15 |
import com.spice.profitmandi.dao.repository.dtr.RetailerBlockBrandsRepository;
|
| - |
|
16 |
import com.spice.profitmandi.dao.repository.onboarding.BrandCommitRepository;
|
| 10 |
import org.springframework.beans.factory.annotation.Autowired;
|
17 |
import org.springframework.beans.factory.annotation.Autowired;
|
| 11 |
import org.springframework.stereotype.Component;
|
18 |
import org.springframework.stereotype.Component;
|
| 12 |
|
19 |
|
| - |
|
20 |
import java.util.ArrayList;
|
| 13 |
import java.util.List;
|
21 |
import java.util.List;
|
| 14 |
import java.util.Map;
|
22 |
import java.util.Map;
|
| 15 |
import java.util.stream.Collectors;
|
23 |
import java.util.stream.Collectors;
|
| 16 |
|
24 |
|
| 17 |
@Component
|
25 |
@Component
|
| Line 24... |
Line 32... |
| 24 |
private BrandsRepository brandCatalogRepository;
|
32 |
private BrandsRepository brandCatalogRepository;
|
| 25 |
|
33 |
|
| 26 |
@Autowired
|
34 |
@Autowired
|
| 27 |
private RetailerBlockBrandsRepository retailerBlockBrandsRepository;
|
35 |
private RetailerBlockBrandsRepository retailerBlockBrandsRepository;
|
| 28 |
|
36 |
|
| - |
|
37 |
@Autowired
|
| - |
|
38 |
private FofoStoreRepository fofoStoreRepository;
|
| - |
|
39 |
|
| - |
|
40 |
@Autowired
|
| - |
|
41 |
private PartnerOnBoardingPanelRepository partnerOnBoardingPanelRepository;
|
| - |
|
42 |
|
| - |
|
43 |
@Autowired
|
| - |
|
44 |
private PartnerDealerRepository partnerDealerRepository;
|
| - |
|
45 |
|
| - |
|
46 |
@Autowired
|
| - |
|
47 |
private BrandCommitRepository brandCommitRepository;
|
| - |
|
48 |
|
| 29 |
@Override
|
49 |
@Override
|
| 30 |
public List<BrandCatalog> getBrands(int fofoId, String email, int categoryId) throws ProfitMandiBusinessException {
|
50 |
public List<BrandCatalog> getBrands(int fofoId, String email, int categoryId) throws ProfitMandiBusinessException {
|
| 31 |
List<BrandCatalog> brandsDisplay = this.getBrandsToDisplay(categoryId);
|
51 |
List<BrandCatalog> brandsDisplay = this.getBrandsToDisplay(categoryId);
|
| 32 |
if (fofoId == Utils.SYSTEM_PARTNER_ID) {
|
52 |
if (fofoId == Utils.SYSTEM_PARTNER_ID) {
|
| 33 |
return brandsDisplay;
|
53 |
return brandsDisplay;
|
| Line 56... |
Line 76... |
| 56 |
brand.setBrandCategory(brandCategoryMap.get(brand.getId()));
|
76 |
brand.setBrandCategory(brandCategoryMap.get(brand.getId()));
|
| 57 |
}
|
77 |
}
|
| 58 |
return brands;
|
78 |
return brands;
|
| 59 |
}
|
79 |
}
|
| 60 |
|
80 |
|
| - |
|
81 |
@Override
|
| - |
|
82 |
public List<String> partnerIneligibleBrands(int fofoId) throws ProfitMandiBusinessException {
|
| - |
|
83 |
|
| - |
|
84 |
FofoStore fofoStore = fofoStoreRepository.selectByRetailerId(fofoId);
|
| - |
|
85 |
PartnerOnBoardingPanel partnerOnBoardingPanel = partnerOnBoardingPanelRepository.selectByCode(fofoStore.getCode());
|
| - |
|
86 |
List<PartnerDealerMapping> partnerDealerMappingList = new ArrayList<>();
|
| - |
|
87 |
List<String> wodRequiredBrands = new ArrayList<>();
|
| - |
|
88 |
if (partnerOnBoardingPanel != null) {
|
| - |
|
89 |
partnerDealerMappingList = partnerDealerRepository.selectByOnboardingId(partnerOnBoardingPanel.getId());
|
| - |
|
90 |
if (partnerDealerMappingList != null && partnerDealerMappingList.size() > 0) {
|
| - |
|
91 |
//working brands -> Partner only work with brands that having 'Dealer Code'
|
| - |
|
92 |
wodRequiredBrands = partnerDealerMappingList.stream().filter(x -> x.getBrandCode().trim().length() == 0).map(x -> x.getBrand()).collect(Collectors.toList());
|
| - |
|
93 |
}
|
| - |
|
94 |
}
|
| - |
|
95 |
|
| - |
|
96 |
//brandsToBeCheck
|
| - |
|
97 |
List<String> nocRequiredBrand = brandCommitRepository.selectAllActiveBrand().stream().filter(x -> x.isNocRequired()).map(x -> x.getBrand()).collect(Collectors.toList());
|
| - |
|
98 |
List<String> ineligibleBrands = nocRequiredBrand.stream()
|
| - |
|
99 |
.filter(wodRequiredBrands::contains)
|
| - |
|
100 |
.collect(Collectors.toList());
|
| - |
|
101 |
|
| - |
|
102 |
return ineligibleBrands;
|
| - |
|
103 |
}
|
| - |
|
104 |
|
| 61 |
}
|
105 |
}
|