Subversion Repositories SmartDukaan

Rev

Rev 34191 | Rev 34260 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
21339 kshitij.so 1
package com.spice.profitmandi.web.controller;
2
 
3
import com.eclipsesource.json.Json;
4
import com.eclipsesource.json.JsonArray;
5
import com.eclipsesource.json.JsonObject;
6
import com.eclipsesource.json.JsonValue;
7
import com.google.gson.Gson;
21356 kshitij.so 8
import com.google.gson.reflect.TypeToken;
25010 amit.gupta 9
import com.mongodb.BasicDBObject;
24163 amit.gupta 10
import com.mongodb.DBObject;
21643 ashik.ali 11
import com.spice.profitmandi.common.enumuration.SchemeType;
21339 kshitij.so 12
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
33929 tejus.loha 13
import com.spice.profitmandi.common.model.BrandAndAddToCartEligibleModel;
21339 kshitij.so 14
import com.spice.profitmandi.common.model.ProfitMandiConstants;
22289 amit.gupta 15
import com.spice.profitmandi.common.model.UserInfo;
27030 amit.gupta 16
import com.spice.profitmandi.common.solr.SolrService;
21643 ashik.ali 17
import com.spice.profitmandi.common.web.client.RestClient;
22319 amit.gupta 18
import com.spice.profitmandi.common.web.util.ResponseSender;
30686 amit.gupta 19
import com.spice.profitmandi.dao.entity.catalog.*;
31507 tejbeer 20
import com.spice.profitmandi.dao.entity.dtr.WebListing;
30595 tejbeer 21
import com.spice.profitmandi.dao.entity.dtr.WebOffer;
33929 tejus.loha 22
import com.spice.profitmandi.dao.entity.fofo.*;
30669 amit.gupta 23
import com.spice.profitmandi.dao.entity.inventory.SaholicCISTable;
27032 amit.gupta 24
import com.spice.profitmandi.dao.entity.inventory.SaholicPOItem;
31572 tejbeer 25
import com.spice.profitmandi.dao.enumuration.dtr.WebListingSource;
31507 tejbeer 26
import com.spice.profitmandi.dao.enumuration.dtr.WebListingType;
31954 amit.gupta 27
import com.spice.profitmandi.dao.model.AmountModel;
30188 amit.gupta 28
import com.spice.profitmandi.dao.model.CreateOfferRequest;
22361 amit.gupta 29
import com.spice.profitmandi.dao.model.UserCart;
30686 amit.gupta 30
import com.spice.profitmandi.dao.repository.catalog.*;
32978 amit.gupta 31
import com.spice.profitmandi.dao.repository.dtr.*;
31625 tejbeer 32
import com.spice.profitmandi.dao.repository.fofo.CatalogFavouriteRepository;
26846 tejbeer 33
import com.spice.profitmandi.dao.repository.fofo.SuggestedPoDetailRepository;
26847 tejbeer 34
import com.spice.profitmandi.dao.repository.fofo.SuggestedPoRepository;
30669 amit.gupta 35
import com.spice.profitmandi.dao.repository.inventory.SaholicCISTableRepository;
33929 tejus.loha 36
import com.spice.profitmandi.dao.repository.onboarding.BrandCommitRepository;
23798 amit.gupta 37
import com.spice.profitmandi.service.authentication.RoleManager;
31507 tejbeer 38
import com.spice.profitmandi.service.catalog.BrandsService;
30686 amit.gupta 39
import com.spice.profitmandi.service.inventory.*;
31954 amit.gupta 40
import com.spice.profitmandi.service.pricecircular.PriceCircularItemModelNew;
30123 amit.gupta 41
import com.spice.profitmandi.service.pricecircular.PriceCircularModel;
42
import com.spice.profitmandi.service.pricecircular.PriceCircularService;
22287 amit.gupta 43
import com.spice.profitmandi.service.pricing.PricingService;
26695 amit.gupta 44
import com.spice.profitmandi.service.scheme.SchemeService;
21356 kshitij.so 45
import com.spice.profitmandi.web.res.DealBrands;
21339 kshitij.so 46
import com.spice.profitmandi.web.res.DealObjectResponse;
47
import com.spice.profitmandi.web.res.DealsResponse;
48
import io.swagger.annotations.ApiImplicitParam;
49
import io.swagger.annotations.ApiImplicitParams;
50
import io.swagger.annotations.ApiOperation;
30686 amit.gupta 51
import org.apache.commons.lang3.StringUtils;
52
import org.apache.http.conn.HttpHostConnectException;
53
import org.apache.logging.log4j.LogManager;
54
import org.apache.logging.log4j.Logger;
55
import org.json.JSONArray;
56
import org.json.JSONObject;
57
import org.springframework.beans.factory.annotation.Autowired;
58
import org.springframework.beans.factory.annotation.Value;
59
import org.springframework.http.HttpStatus;
60
import org.springframework.http.MediaType;
61
import org.springframework.http.ResponseEntity;
62
import org.springframework.stereotype.Controller;
63
import org.springframework.transaction.annotation.Transactional;
33929 tejus.loha 64
import org.springframework.web.bind.annotation.*;
21339 kshitij.so 65
 
30686 amit.gupta 66
import javax.servlet.http.HttpServletRequest;
31954 amit.gupta 67
import java.time.LocalDate;
31625 tejbeer 68
import java.time.LocalDateTime;
30686 amit.gupta 69
import java.util.*;
70
import java.util.concurrent.atomic.AtomicInteger;
71
import java.util.stream.Collectors;
72
 
21339 kshitij.so 73
@Controller
22319 amit.gupta 74
@Transactional(rollbackFor = Throwable.class)
21339 kshitij.so 75
public class DealsController {
76
 
32339 tejbeer 77
    private static final Logger logger = LogManager.getLogger(DealsController.class);
78
    private static final List<Integer> TAG_IDS = Arrays.asList(4);
21339 kshitij.so 79
 
32339 tejbeer 80
    @Value("${python.api.host}")
81
    private String host;
23816 amit.gupta 82
 
32339 tejbeer 83
    @Value("${new.solr.url}")
84
    private String solrUrl;
26889 amit.gupta 85
 
32339 tejbeer 86
    @Value("${python.api.port}")
87
    private int port;
23816 amit.gupta 88
 
32339 tejbeer 89
    @Autowired
90
    RestClient restClient;
27051 amit.gupta 91
 
32339 tejbeer 92
    @Autowired
93
    SolrService solrService;
26889 amit.gupta 94
 
32339 tejbeer 95
    @Autowired
33873 ranu 96
    com.spice.profitmandi.web.services.SolrService webSolrService;
97
 
98
    @Autowired
32339 tejbeer 99
    InventoryService inventoryService;
26924 amit.gupta 100
 
32339 tejbeer 101
    // This is now unused as we are not supporting multiple companies.
102
    @Value("${gadgetCops.invoice.cc}")
103
    private String[] ccGadgetCopInvoiceTo;
22319 amit.gupta 104
 
32339 tejbeer 105
    @Autowired
106
    private PricingService pricingService;
23816 amit.gupta 107
 
32339 tejbeer 108
    @Autowired
109
    private CategoryRepository categoryRepository;
25010 amit.gupta 110
 
32339 tejbeer 111
    @Autowired
112
    private SchemeService schemeService;
26695 amit.gupta 113
 
32339 tejbeer 114
    @Autowired
115
    private SaholicInventoryService saholicInventoryService;
26889 amit.gupta 116
 
32339 tejbeer 117
    @Autowired
118
    private Mongo mongoClient;
25879 amit.gupta 119
 
32339 tejbeer 120
    @Autowired
121
    private ItemBucketService itemBucketService;
23816 amit.gupta 122
 
32339 tejbeer 123
    @Autowired
124
    private UserAccountRepository userAccountRepository;
27051 amit.gupta 125
 
32339 tejbeer 126
    @Autowired
127
    private FofoStoreRepository fofoStoreRepository;
23816 amit.gupta 128
 
32339 tejbeer 129
    @Autowired
130
    private ResponseSender<?> responseSender;
23816 amit.gupta 131
 
32339 tejbeer 132
    @Autowired
133
    private TagListingRepository tagListingRepository;
23816 amit.gupta 134
 
32339 tejbeer 135
    @Autowired
136
    private ItemRepository itemRepository;
137
    @Autowired
138
    private PriceCircularService priceCircularService;
23816 amit.gupta 139
 
32339 tejbeer 140
    @Autowired
141
    private RoleManager roleManagerService;
23816 amit.gupta 142
 
32339 tejbeer 143
    @Autowired
32978 amit.gupta 144
    private SuggestedPoDetailRepository suggestedPoDetailRepository;
26846 tejbeer 145
 
32339 tejbeer 146
    @Autowired
147
    private SuggestedPoRepository suggestedPoRepository;
26847 tejbeer 148
 
32339 tejbeer 149
    @Autowired
150
    private WebOfferRepository webOfferRepository;
30595 tejbeer 151
 
32339 tejbeer 152
    @Autowired
153
    private ComboModelRepository comboModelRepository;
30683 tejbeer 154
 
32339 tejbeer 155
    @Autowired
156
    private ComboMappedModelRepository comboMappedModelRepository;
30683 tejbeer 157
 
32339 tejbeer 158
    @Autowired
159
    private BrandsService brandsService;
31547 tejbeer 160
 
32339 tejbeer 161
    @Autowired
162
    private WebListingRepository webListingRepository;
31547 tejbeer 163
 
32339 tejbeer 164
    @Autowired
165
    private WebProductListingRepository webProductListingRepository;
31547 tejbeer 166
 
32339 tejbeer 167
    @Autowired
168
    private CatalogFavouriteRepository catalogFavouriteRepository;
31625 tejbeer 169
 
33929 tejus.loha 170
    @Autowired
171
    PartnerOnBoardingPanelRepository partnerOnBoardingPanelRepository;
172
 
173
    @Autowired
174
    PartnerDealerRepository partnerDealerRepository;
175
 
176
    @Autowired
177
    BrandCommitRepository brandCommitRepository;
178
 
179
    @Autowired
180
    CatalogRepository catalogRepository;
181
 
32339 tejbeer 182
    List<String> filterableParams = Arrays.asList("brand");
24949 amit.gupta 183
 
32339 tejbeer 184
    @RequestMapping(value = "/fofo/buckets", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
185
    public ResponseEntity<?> getBuckets(HttpServletRequest request) throws ProfitMandiBusinessException {
186
        logger.info("Request " + request.getParameterMap());
187
        return responseSender.ok(itemBucketService.getBuckets(Optional.of(true)));
188
    }
25879 amit.gupta 189
 
32339 tejbeer 190
    @RequestMapping(value = "/fofo/bucket", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
191
    public ResponseEntity<?> getBucketDetails(HttpServletRequest request, @RequestParam int id) throws ProfitMandiBusinessException {
192
        List<ItemQuantityPojo> iqPojo = itemBucketService.getBucketDetails(id);
193
        Map<Integer, Integer> itemIdsQtyMap = iqPojo.stream().collect(Collectors.toMap(x -> x.getItemId(), x -> x.getQuantity()));
194
        Set<Integer> catalogIds = itemRepository.selectByIds(itemIdsQtyMap.keySet()).stream().map(x -> x.getCatalogItemId()).collect(Collectors.toSet());
195
        RestClient rc = new RestClient();
196
        Map<String, String> params = new HashMap<>();
197
        List<String> mandatoryQ = new ArrayList<>();
198
        mandatoryQ.add(
199
                String.format("+catalogId_i:(%s) +{!parent which=\"id:catalog*\"}", StringUtils.join(catalogIds, " ")));
200
        params.put("start", "0");
201
        params.put("rows", "100");
202
        params.put("q", StringUtils.join(mandatoryQ, " "));
203
        params.put("fl", "*, [child parentFilter=id:catalog*]");
25879 amit.gupta 204
 
32339 tejbeer 205
        params.put("wt", "json");
206
        String response = null;
207
        try {
208
            response = rc.get(SchemeType.HTTP, solrUrl, 8984, "solr/demo/select", params);
209
        } catch (HttpHostConnectException e) {
210
            throw new ProfitMandiBusinessException("", "", "Could not connect to host");
211
        }
212
        JSONObject solrResponseJSONObj = new JSONObject(response).getJSONObject("response");
213
        JSONArray docs = solrResponseJSONObj.getJSONArray("docs");
214
        List<FofoCatalogResponse> dealResponse = getCatalogSingleSkuResponse(docs, itemIdsQtyMap, false);
26051 amit.gupta 215
 
32339 tejbeer 216
        Bucket bucket = itemBucketService.getBuckets(Optional.of(true)).stream().filter(x -> x.getId() == id).collect(Collectors.toList()).get(0);
217
        bucket.setFofoCatalogResponses(dealResponse);
218
        return responseSender.ok(bucket);
219
    }
25879 amit.gupta 220
 
32339 tejbeer 221
    @RequestMapping(value = "/fofo/suggestedPo", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
222
    public ResponseEntity<?> getSuggestedPo(HttpServletRequest request, @RequestParam int id) throws ProfitMandiBusinessException {
26846 tejbeer 223
 
32978 amit.gupta 224
        List<SuggestedPoDetail> mpd = suggestedPoDetailRepository.selectByPoId(id);
32339 tejbeer 225
        Map<Integer, Integer> itemIdsQtyMap = mpd.stream().collect(Collectors.toMap(x -> x.getItemId(), x -> x.getQuantity()));
26846 tejbeer 226
 
32339 tejbeer 227
        Set<Integer> catalogIds = itemRepository.selectByIds(itemIdsQtyMap.keySet()).stream().map(x -> x.getCatalogItemId()).collect(Collectors.toSet());
228
        RestClient rc = new RestClient();
229
        Map<String, String> params = new HashMap<>();
230
        List<String> mandatoryQ = new ArrayList<>();
231
        mandatoryQ.add(
232
                String.format("+catalogId_i:(%s) +{!parent which=\"id:catalog*\"}", StringUtils.join(catalogIds, " ")));
233
        params.put("start", "0");
234
        params.put("rows", "100");
235
        params.put("q", StringUtils.join(mandatoryQ, " "));
236
        params.put("fl", "*, [child parentFilter=id:catalog*]");
26846 tejbeer 237
 
32339 tejbeer 238
        params.put("wt", "json");
239
        String response = null;
240
        try {
241
            response = rc.get(SchemeType.HTTP, solrUrl, 8984, "solr/demo/select", params);
242
        } catch (HttpHostConnectException e) {
243
            throw new ProfitMandiBusinessException("", "", "Could not connect to host");
244
        }
245
        JSONObject solrResponseJSONObj = new JSONObject(response).getJSONObject("response");
246
        JSONArray docs = solrResponseJSONObj.getJSONArray("docs");
247
        List<FofoCatalogResponse> dealResponse = getCatalogSingleSkuResponse(docs, itemIdsQtyMap, false);
26846 tejbeer 248
 
32339 tejbeer 249
        return responseSender.ok(dealResponse);
250
    }
26846 tejbeer 251
 
32339 tejbeer 252
    @RequestMapping(value = "/suggestedPo/status", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
253
    @ApiImplicitParams({@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header")})
254
    @ApiOperation(value = "")
255
    public ResponseEntity<?> changeSuggestedPoStatus(HttpServletRequest request, @RequestParam int id) throws ProfitMandiBusinessException {
256
        SuggestedPo suggestedPo = suggestedPoRepository.selectById(id);
257
        suggestedPo.setStatus("closed");
33873 ranu 258
        //suggestedPo.setStatus(SuggestedPoStatus.valueOf("closed"));
26847 tejbeer 259
 
32339 tejbeer 260
        return responseSender.ok(true);
261
    }
26847 tejbeer 262
 
32339 tejbeer 263
    @RequestMapping(value = "/fofo/fovourites", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
264
    public ResponseEntity<?> getFavourites(HttpServletRequest request) throws Exception {
31625 tejbeer 265
 
32339 tejbeer 266
        int userId = (int) request.getAttribute("userId");
267
        UserCart uc = userAccountRepository.getUserCart(userId);
268
        int fofoId = uc.getUserId();
269
        List<FofoCatalogResponse> dealResponse = new ArrayList<>();
270
        Set<Integer> catalogIds = catalogFavouriteRepository.selectBypartnerId(fofoId).stream().map(x -> x.getCatalogId()).collect(Collectors.toSet());
271
        if (!catalogIds.isEmpty()) {
33929 tejus.loha 272
            dealResponse = webSolrService.dealResponse(catalogIds, fofoId);
32339 tejbeer 273
        }
274
        return responseSender.ok(dealResponse);
275
    }
31625 tejbeer 276
 
32339 tejbeer 277
    @RequestMapping(value = "/favourites/manage", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
278
    @ApiImplicitParams({@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header")})
279
    @ApiOperation(value = "")
280
    public ResponseEntity<?> mangeFavourites(HttpServletRequest request, @RequestParam int catalogId) throws ProfitMandiBusinessException {
31625 tejbeer 281
 
32339 tejbeer 282
        int userId = (int) request.getAttribute("userId");
283
        UserCart uc = userAccountRepository.getUserCart(userId);
284
        int fofoId = uc.getUserId();
31625 tejbeer 285
 
32339 tejbeer 286
        CatalogFavourite catalogFavourite = catalogFavouriteRepository.selectBypartnerAndCatalogId(fofoId, catalogId);
31625 tejbeer 287
 
32339 tejbeer 288
        if (catalogFavourite == null) {
289
            catalogFavourite = new CatalogFavourite();
290
            catalogFavourite.setCatalogId(catalogId);
291
            catalogFavourite.setFofoId(fofoId);
292
            catalogFavourite.setCreatedTimestamp(LocalDateTime.now());
293
            catalogFavouriteRepository.persist(catalogFavourite);
31625 tejbeer 294
 
32978 amit.gupta 295
        } else {
32339 tejbeer 296
            catalogFavouriteRepository.deleteByPartnerAndCatalogId(fofoId, catalogId);
297
        }
298
        return responseSender.ok(true);
299
    }
31625 tejbeer 300
 
33249 ranu 301
    private String getCommaSeparateTags(int userId) throws ProfitMandiBusinessException {
32339 tejbeer 302
        UserCart uc = userAccountRepository.getUserCart(userId);
303
        List<Integer> tagIds = pricingService.getTagsIdsByRetailerId(uc.getUserId());
304
        List<String> strTagIds = new ArrayList<>();
305
        for (Integer tagId : tagIds) {
306
            strTagIds.add(String.valueOf(tagId));
307
        }
308
        return String.join(",", strTagIds);
309
    }
22273 amit.gupta 310
 
33575 amit.gupta 311
    @RequestMapping(value = "/fofo/similar-models/{modelId}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
312
    public ResponseEntity<?> similarModels(HttpServletRequest httpServletRequest, @PathVariable int modelId) throws Throwable {
313
        UserInfo userInfo = (UserInfo) httpServletRequest.getAttribute("userInfo");
314
        //FofoStore fs = fofoStoreRepository.selectByRetailerId(userInfo.getRetailerId());
315
 
316
        JSONObject jsonObject = solrService.getContentByCatalogIds(Arrays.asList(modelId)).get(modelId);
317
 
318
        JSONArray similarModelsArray = jsonObject.getJSONArray("similarModels_ii");
319
        List<Integer> similarCatalogIds = new ArrayList<>();
320
        for (int j = 0; j < similarModelsArray.length(); j++) {
321
            similarCatalogIds.add(similarModelsArray.getInt(j));
322
        }
323
 
324
        Map<String, String> params = new HashMap<>();
325
        List<String> mandatoryQ = new ArrayList<>();
326
 
327
        mandatoryQ.add(String.format(
328
                "+{!parent which=\"catalogId_i:(" + StringUtils.join(similarCatalogIds, " ") + ")\"} AND active_b:true AND show_default_b:true"));
329
 
330
        params.put("q", StringUtils.join(mandatoryQ, " "));
331
        params.put("fl", "*, [child parentFilter=id:catalog* childFilter=active_b:true ]");
332
        params.put("wt", "json");
333
        params.put("rows", similarCatalogIds.size() + "");
334
        try {
335
            String response = restClient.get(SchemeType.HTTP, solrUrl, 8984, "solr/demo/select", params);
336
            JSONObject solrResponseJSONObj = new JSONObject(response).getJSONObject("response");
337
            JSONArray docs = solrResponseJSONObj.getJSONArray("docs");
33576 amit.gupta 338
            return responseSender.ok(this.getCatalogResponse(docs, false, userInfo.getRetailerId()).stream().filter(x -> x.isInStock()).collect(Collectors.toList()));
33575 amit.gupta 339
        } catch (HttpHostConnectException e) {
340
            throw new ProfitMandiBusinessException("", "", "Could not connect to host");
341
        }
342
    }
343
 
32339 tejbeer 344
    @ApiImplicitParams({@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header")})
345
    @RequestMapping(value = "/fofo", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
33573 amit.gupta 346
    public ResponseEntity<?> getFofo(HttpServletRequest request, @RequestParam(value = "categoryId", required = false, defaultValue = "3") String categoryId, @RequestParam(value = "offset") int offset,
34024 vikas.jang 347
                                     @RequestParam(value = "limit") int limit, @RequestParam(value = "sort", required = false) String sort, @RequestParam(value = "brand", required = false) String brand, @RequestParam(value = "subCategoryId", required = false) int subCategoryId, @RequestParam(value = "q", required = false) String queryTerm, @RequestParam(value = "hotDeal", required = false) boolean hotDeal, @RequestParam(value = "endPoint", required = false) String endPoint,@RequestParam(value = "group", required = false) boolean group) throws Throwable {
33543 amit.gupta 348
        List<FofoCatalogResponse> dealResponse;
32339 tejbeer 349
        UserInfo userInfo = (UserInfo) request.getAttribute("userInfo");
350
        FofoStore fs = fofoStoreRepository.selectByRetailerId(userInfo.getRetailerId());
351
        sort = "w" + fs.getWarehouseId() + "_i desc";
31548 tejbeer 352
 
32339 tejbeer 353
        logger.info("endPoint {}", endPoint);
34024 vikas.jang 354
        logger.info("group Column {}", group);
31552 tejbeer 355
 
32339 tejbeer 356
        if (endPoint != null && !endPoint.trim().isEmpty()) {
357
            WebListing webListing = webListingRepository.selectByUrl(endPoint);
358
            dealResponse = this.getDealResponses(userInfo, webListing, offset, limit);
31552 tejbeer 359
 
32339 tejbeer 360
        } else {
31552 tejbeer 361
 
32339 tejbeer 362
            dealResponse = this.getCatalogResponse(
34024 vikas.jang 363
                    solrService.getSolrDocs(queryTerm, categoryId, offset, limit, sort, brand, subCategoryId, hotDeal, group), hotDeal, userInfo.getRetailerId());
32339 tejbeer 364
        }
33573 amit.gupta 365
 
366
        Map<Integer, List<Integer>> similarModelMap = dealResponse.stream().filter(x -> x.getSimilarModelIds() != null && x.getSimilarModelIds().size() > 0)
367
                .collect(Collectors.toMap(x -> x.getCatalogId(), x -> x.getSimilarModelIds()));
368
        Set<Integer> similarModelIds = similarModelMap.values().stream().flatMap(x -> x.stream()).collect(Collectors.toSet());
369
        logger.info("similarModelIds - {}", similarModelIds);
33575 amit.gupta 370
        if (similarModelIds.size() > 0) {
33573 amit.gupta 371
 
33576 amit.gupta 372
            Map<Integer, FofoCatalogResponse> similarCatalogResponsesMap = this.getSimpleDocs(fs, similarModelIds).stream().collect(Collectors.toMap(x -> x.getCatalogId(), x -> x));
33573 amit.gupta 373
            logger.info("Similar Catalog ResponseMap - {}", similarCatalogResponsesMap.keySet());
374
 
375
            for (FofoCatalogResponse deal : dealResponse) {
376
                if (similarModelMap.containsKey(deal.getCatalogId())) {
377
                    List<Integer> similarCatalogIds = similarModelMap.get(deal.getCatalogId());
378
                    logger.info("Similar Catalog Ids - {}", similarCatalogIds);
33575 amit.gupta 379
                    List<FofoCatalogResponse> similarModels = similarCatalogIds.stream().filter(x -> similarCatalogResponsesMap.containsKey(x)).map(x -> similarCatalogResponsesMap.get(x)).collect(Collectors.toList());
33573 amit.gupta 380
                    deal.setSimilarModels(similarModels);
381
                }
382
            }
383
        }
32339 tejbeer 384
        return responseSender.ok(dealResponse);
385
    }
25015 amit.gupta 386
 
33576 amit.gupta 387
    private List<FofoCatalogResponse> getSimpleDocs(FofoStore fofoStore, Set<Integer> catalogIds) throws Exception {
33575 amit.gupta 388
        List<FofoCatalogResponse> fofoCatalogResponses = new ArrayList<>();
389
 
390
 
391
        Map<String, String> params = new HashMap<>();
392
        List<String> mandatoryQ = new ArrayList<>();
393
 
394
        mandatoryQ.add(String.format(
395
                "+{!parent which=\"catalogId_i:(" + StringUtils.join(catalogIds, " ") + ")\"} AND active_b:true AND show_default_b:true"));
396
 
397
        params.put("q", StringUtils.join(mandatoryQ, " "));
398
        params.put("fl", "*, [child parentFilter=id:catalog* childFilter=active_b:true ]");
399
        params.put("wt", "json");
400
        params.put("rows", catalogIds.size() + "");
401
 
33576 amit.gupta 402
        String response = restClient.get(SchemeType.HTTP, solrUrl, 8984, "solr/demo/select", params);
403
        JSONObject solrResponseJSONObj = new JSONObject(response).getJSONObject("response");
404
        JSONArray docs = solrResponseJSONObj.getJSONArray("docs");
405
        int warehouseId = fofoStoreRepository.selectByRetailerId(fofoStore.getId()).getWarehouseId();
406
        Map<Integer, List<SaholicPOItem>> poItemAvailabilityMap = saholicInventoryService.getSaholicPOItems().get(warehouseId);
407
        for (int i = 0; i < docs.length(); i++) {
408
            JSONObject doc = docs.getJSONObject(i);
409
            FofoCatalogResponse fofoCatalogResponse = this.toFofoCatalogResponse(doc);
410
            if (doc.has("_childDocuments_")) {
411
                String modelColorClass = "grey";
412
                FofoAvailabilityInfo fdiAnyColour = null;
413
                // Iterating itemIds
414
                for (int j = 0; j < doc.getJSONArray("_childDocuments_").length(); j++) {
415
                    JSONObject childItem = doc.getJSONArray("_childDocuments_").getJSONObject(j);
416
                    int itemId = childItem.getInt("itemId_i");
417
 
418
                    List<SaholicCISTable> currentAvailability = saholicCISTableRepository.selectByItemWarehouse(itemId, warehouseId);
419
                    List<SaholicPOItem> poItemAvailability = null;
420
                    if (poItemAvailabilityMap != null) {
421
                        poItemAvailability = poItemAvailabilityMap.get(itemId);
422
                    }
423
 
424
                    for (SaholicCISTable saholicCISTable : currentAvailability) {
425
                        saholicCISTable.setWarehouseName(
426
                                ProfitMandiConstants.WAREHOUSE_MAP.get(saholicCISTable.getWarehouseFrom()));
427
                    }
428
 
429
 
430
                    String poColor = "grey";
431
                    boolean active = false;
432
                    if (currentAvailability != null && currentAvailability.stream().collect(Collectors.summingInt(SaholicCISTable::getNetAvailability)) > 0) {
433
                        poColor = "green";
434
                        modelColorClass = "green";
435
                    } else if (poItemAvailability != null && poItemAvailability.stream().collect(Collectors.summingInt(SaholicPOItem::getUnfulfilledQty)) > 0) {
436
                        if (currentAvailability != null && poItemAvailability.stream().collect(Collectors.summingInt(SaholicPOItem::getUnfulfilledQty)) + currentAvailability.stream().collect(Collectors.summingInt(SaholicCISTable::getNetAvailability)) <= 0) {
437
                            poColor = "grey";
438
                        } else {
439
                            poColor = "yellow";
440
                            if (!modelColorClass.equals("green")) {
441
                                modelColorClass = poColor;
442
                            }
443
                        }
444
                    }
445
 
446
                }
447
                fofoCatalogResponse.setInStock(!modelColorClass.equals("grey"));
33575 amit.gupta 448
            }
33576 amit.gupta 449
 
450
            fofoCatalogResponses.add(fofoCatalogResponse);
33575 amit.gupta 451
        }
33576 amit.gupta 452
 
33575 amit.gupta 453
        return fofoCatalogResponses;
454
    }
455
 
456
    private FofoCatalogResponse toFofoCatalogResponse(JSONObject doc) {
457
        FofoCatalogResponse fofoCatalogResponse = new FofoCatalogResponse();
458
        fofoCatalogResponse.setCatalogId(doc.getInt("catalogId_i"));
459
        fofoCatalogResponse.setImageUrl(doc.getString("imageUrl_s"));
460
        fofoCatalogResponse.setTitle(doc.getString("title_s"));
461
        fofoCatalogResponse.setMop(doc.getFloat("mop_f"));
462
        fofoCatalogResponse.setDp(doc.getFloat("dp_f"));
463
        fofoCatalogResponse.setBrand(doc.getJSONArray("brand_ss").getString(0));
464
        return fofoCatalogResponse;
465
    }
466
 
32339 tejbeer 467
    @RequestMapping(value = "/online-deals", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
468
    @ApiImplicitParams({@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header")})
469
    @ApiOperation(value = "Get online deals")
33575 amit.gupta 470
    public ResponseEntity<?> getOnlineDeals(HttpServletRequest request, @RequestParam(value = "categoryId") String
471
            categoryId, @RequestParam(value = "offset") String offset, @RequestParam(value = "limit") String
472
                                                    limit, @RequestParam(value = "sort", required = false) String
473
                                                    sort, @RequestParam(value = "direction", required = false) String
474
                                                    direction, @RequestParam(value = "filterData", required = false) String filterData) throws Throwable {
32339 tejbeer 475
        logger.info("Request " + request.getParameterMap());
476
        String response = null;
477
        int userId = (int) request.getAttribute("userId");
22289 amit.gupta 478
 
32339 tejbeer 479
        String uri = "/deals/" + userId;
480
        RestClient rc = new RestClient();
481
        Map<String, String> params = new HashMap<>();
482
        params.put("offset", offset);
483
        params.put("limit", limit);
484
        params.put("categoryId", categoryId);
485
        params.put("direction", direction);
486
        params.put("sort", sort);
487
        params.put("source", "online");
488
        params.put("filterData", filterData);
489
        /*
490
         * if (userInfo.getRoleNames().contains(RoleType.FOFO.toString())) {
491
         * params.put("tag_ids", getCommaSeparateTags(userId)); }
492
         */
493
        List<Object> responseObject = new ArrayList<>();
494
        try {
495
            response = rc.get(SchemeType.HTTP, host, port, uri, params);
496
        } catch (HttpHostConnectException e) {
497
            throw new ProfitMandiBusinessException("", "", "Could not connect to host");
498
        }
22931 ashik.ali 499
 
32339 tejbeer 500
        JsonArray result_json = Json.parse(response).asArray();
501
        for (JsonValue j : result_json) {
502
            // logger.info("res " + j.asArray());
503
            List<Object> innerObject = new ArrayList<>();
504
            for (JsonValue jsonObject : j.asArray()) {
505
                innerObject.add(toDealObject(jsonObject.asObject()));
506
            }
507
            if (innerObject.size() > 0) {
508
                responseObject.add(innerObject);
509
            }
510
        }
511
        return responseSender.ok(responseObject);
512
    }
22272 amit.gupta 513
 
32339 tejbeer 514
    private Object toDealObject(JsonObject jsonObject) {
515
        if (jsonObject.get("dealObject") != null && jsonObject.get("dealObject").asInt() == 1) {
516
            return new Gson().fromJson(jsonObject.toString(), DealObjectResponse.class);
517
        }
518
        return new Gson().fromJson(jsonObject.toString(), DealsResponse.class);
519
    }
22319 amit.gupta 520
 
32339 tejbeer 521
    @RequestMapping(value = ProfitMandiConstants.URL_BRANDS, method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
522
    @ApiImplicitParams({@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header")})
523
    @ApiOperation(value = "Get brand list and count for category")
33575 amit.gupta 524
    public ResponseEntity<?> getBrands(HttpServletRequest request, @RequestParam(value = "category_id") String
525
            category_id) throws ProfitMandiBusinessException {
32339 tejbeer 526
        logger.info("Request " + request.getParameterMap());
527
        String response = null;
528
        // TODO: move to properties
529
        String uri = ProfitMandiConstants.URL_BRANDS;
530
        RestClient rc = new RestClient();
531
        Map<String, String> params = new HashMap<>();
532
        params.put("category_id", category_id);
533
        List<DealBrands> dealBrandsResponse = null;
534
        try {
535
            response = rc.get(SchemeType.HTTP, host, port, uri, params);
536
        } catch (HttpHostConnectException e) {
537
            throw new ProfitMandiBusinessException("", "", "Could not connect to host");
538
        }
23816 amit.gupta 539
 
32339 tejbeer 540
        dealBrandsResponse = new Gson().fromJson(response, new TypeToken<List<DealBrands>>() {
541
        }.getType());
23022 ashik.ali 542
 
32339 tejbeer 543
        return responseSender.ok(dealBrandsResponse);
544
    }
22319 amit.gupta 545
 
32339 tejbeer 546
    @RequestMapping(value = ProfitMandiConstants.URL_UNIT_DEAL, method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
547
    @ApiImplicitParams({@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header")})
548
    @ApiOperation(value = "Get unit deal object")
33575 amit.gupta 549
    public ResponseEntity<?> getUnitDeal(HttpServletRequest request, @PathVariable(value = "id") long id) throws
550
            ProfitMandiBusinessException {
32339 tejbeer 551
        String response = null;
552
        // TODO: move to properties
553
        String uri = "getDealById/" + id;
554
        System.out.println("Unit deal " + uri);
555
        RestClient rc = new RestClient();
556
        Map<String, String> params = new HashMap<>();
557
        DealsResponse dealsResponse = null;
558
        try {
559
            response = rc.get(SchemeType.HTTP, host, port, uri, params);
560
        } catch (HttpHostConnectException e) {
561
            throw new ProfitMandiBusinessException("", "", "Could not connect to host");
562
        }
23816 amit.gupta 563
 
32339 tejbeer 564
        JsonObject result_json = Json.parse(response).asObject();
565
        if (!result_json.isEmpty()) {
566
            dealsResponse = new Gson().fromJson(response, DealsResponse.class);
567
            Iterator<AvailabilityInfo> iter = dealsResponse.getAvailabilityInfo().iterator();
568
            while (iter.hasNext()) {
569
                AvailabilityInfo ai = iter.next();
570
                if (ai.getAvailability() <= 0)
571
                    iter.remove();
572
            }
573
        }
574
        return responseSender.ok(dealsResponse);
575
    }
23816 amit.gupta 576
 
32339 tejbeer 577
    @RequestMapping(value = "/partnerdeals/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
578
    @ApiImplicitParams({@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header")})
579
    @ApiOperation(value = "Get unit deal object")
33575 amit.gupta 580
    public ResponseEntity<?> getUnitFocoDeal(HttpServletRequest request, @PathVariable(value = "id") long id) throws
581
            Exception {
32339 tejbeer 582
        List<FofoCatalogResponse> dealResponse = new ArrayList<>();
583
        List<Integer> tagIds = Arrays.asList(4);
584
        UserInfo userInfo = (UserInfo) request.getAttribute("userInfo");
585
        if (roleManagerService.isPartner(userInfo.getRoleIds())) {
586
            String categoryId = "(3 OR 6)";
587
            UserCart uc = userAccountRepository.getUserCart(userInfo.getUserId());
588
            RestClient rc = new RestClient();
589
            Map<String, String> params = new HashMap<>();
590
            List<String> mandatoryQ = new ArrayList<>();
591
            String catalogString = "catalog" + id;
24091 tejbeer 592
 
32339 tejbeer 593
            mandatoryQ.add(String.format("+(categoryId_i:%s) +(id:%s) +{!parent which=\"id:%s\"} tagId_i:(%s)", categoryId, catalogString, catalogString, StringUtils.join(tagIds, " ")));
24149 amit.gupta 594
 
32339 tejbeer 595
            params.put("q", StringUtils.join(mandatoryQ, " "));
596
            params.put("fl", "*, [child parentFilter=id:catalog*]");
597
            params.put("sort", "rank_i asc, create_s desc");
598
            params.put("wt", "json");
599
            String response = null;
600
            try {
33487 amit.gupta 601
                response = rc.get(SchemeType.HTTP, solrUrl, 8984, "solr/demo/select", params);
32339 tejbeer 602
            } catch (HttpHostConnectException e) {
603
                throw new ProfitMandiBusinessException("", "", "Could not connect to host");
604
            }
605
            JSONObject solrResponseJSONObj = new JSONObject(response).getJSONObject("response");
606
            JSONArray docs = solrResponseJSONObj.getJSONArray("docs");
607
            dealResponse = getCatalogResponse(docs, false, userInfo.getRetailerId());
608
        } else {
609
            return responseSender.badRequest(
610
                    new ProfitMandiBusinessException("Retailer id", userInfo.getUserId(), "NOT_FOFO_RETAILER"));
611
        }
612
        return responseSender.ok(dealResponse.get(0));
613
    }
24091 tejbeer 614
 
32339 tejbeer 615
    @RequestMapping(value = "/fofo/brands", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
33575 amit.gupta 616
    public ResponseEntity<?> getBrandsToDisplay(HttpServletRequest request,
617
                                                @RequestParam(required = false, defaultValue = "0") int categoryId) throws Exception {
32339 tejbeer 618
        UserInfo userInfo = (UserInfo) request.getAttribute("userInfo");
619
        logger.info("userInfo [{}]", userInfo);
32717 ranu 620
        List<BrandCatalog> brandsDisplay = brandsService.getBrandsToDisplay(categoryId);
621
        //List<DBObject> brandsDisplay = mongoClient.getMongoBrands(userInfo.getRetailerId(), userInfo.getEmail(), categoryId);
32339 tejbeer 622
        return new ResponseEntity<>(brandsDisplay, HttpStatus.OK);
623
    }
25879 amit.gupta 624
 
32339 tejbeer 625
    @RequestMapping(value = "/fofo/brandCatalog", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
33575 amit.gupta 626
    public ResponseEntity<?> getBrands(HttpServletRequest request,
627
                                       @RequestParam(required = false, defaultValue = "0") int categoryId) throws Exception {
32339 tejbeer 628
        UserInfo userInfo = (UserInfo) request.getAttribute("userInfo");
629
        logger.info("userInfo [{}]", userInfo);
31507 tejbeer 630
 
32339 tejbeer 631
        List<BrandCatalog> brandsDisplay = brandsService.getBrands(userInfo.getRetailerId(), userInfo.getEmail(), categoryId);
632
        return new ResponseEntity<>(brandsDisplay, HttpStatus.OK);
633
    }
31507 tejbeer 634
 
32339 tejbeer 635
    @RequestMapping(value = "/fofo/accessory/all-categories", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
636
    public ResponseEntity<?> getSubCategoriesToDisplay(HttpServletRequest request) throws Exception {
637
        UserInfo userInfo = (UserInfo) request.getAttribute("userInfo");
638
        logger.info("userInfo [{}]", userInfo);
639
        List<DBObject> subCategoriesDisplay = this.getSubCategoriesToDisplay();
640
        return new ResponseEntity<>(subCategoriesDisplay, HttpStatus.OK);
641
    }
23816 amit.gupta 642
 
32339 tejbeer 643
    private List<DBObject> getSubCategoriesToDisplay() throws Exception {
644
        List<DBObject> subCategories = new ArrayList<>();
645
        RestClient rc = new RestClient();
646
        Map<String, String> params = new HashMap<>();
647
        params.put("q", "categoryId_i:6");
648
        params.put("group", "true");
649
        params.put("group.field", "subCategoryId_i");
650
        params.put("wt", "json");
651
        params.put("rows", "50");
652
        params.put("fl", "subCategoryId_i");
653
        String response = null;
654
        try {
33487 amit.gupta 655
            response = rc.get(SchemeType.HTTP, solrUrl, 8984, "solr/demo/select", params);
32339 tejbeer 656
        } catch (HttpHostConnectException e) {
657
            throw new ProfitMandiBusinessException("", "", "Could not connect to host");
658
        }
659
        JSONObject solrResponseJSONObj = new JSONObject(response).getJSONObject("grouped");
660
        JSONArray groups = solrResponseJSONObj.getJSONObject("subCategoryId_i").getJSONArray("groups");
661
        List<Integer> categoryIds = new ArrayList<>();
662
        for (int i = 0; i < groups.length(); i++) {
663
            JSONObject groupObject = groups.getJSONObject(i);
664
            int subCategoryId = groupObject.getInt("groupValue");
665
            int quantity = groupObject.getJSONObject("doclist").getInt("numFound");
666
            categoryIds.add(subCategoryId);
667
        }
25015 amit.gupta 668
 
32339 tejbeer 669
        List<Category> categories = categoryRepository.selectByIds(categoryIds);
670
        AtomicInteger i = new AtomicInteger(0);
671
        categories.forEach(x -> {
672
            DBObject dbObject = new BasicDBObject();
673
            dbObject.put("name", x.getLabel());
674
            dbObject.put("subCategoryId", x.getId());
675
            dbObject.put("rank", i.incrementAndGet());
676
            dbObject.put("categoryId", 6);
677
            dbObject.put("url", "https://images.smartdukaan.com/uploads/campaigns/" + x.getId() + ".png");
678
            subCategories.add(dbObject);
679
        });
25015 amit.gupta 680
 
32339 tejbeer 681
        return subCategories;
25015 amit.gupta 682
 
32339 tejbeer 683
    }
25010 amit.gupta 684
 
32339 tejbeer 685
    @RequestMapping(value = "/banners/{bannerType}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
686
    public ResponseEntity<?> getBanners(@PathVariable String bannerType) {
687
        return new ResponseEntity<>(mongoClient.getBannersByType(bannerType), HttpStatus.OK);
688
    }
23816 amit.gupta 689
 
32339 tejbeer 690
    @RequestMapping(value = "/deals/subCategories", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
691
    public ResponseEntity<?> getSubcategoriesToDisplay() {
692
        return new ResponseEntity<>(mongoClient.getSubcategoriesToDisplay(), HttpStatus.OK);
693
    }
23816 amit.gupta 694
 
32339 tejbeer 695
    @ApiImplicitParams({@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header")})
696
    @RequestMapping(value = "/deals/skus/{skus}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
697
    public ResponseEntity<?> getDealsBySkus(@PathVariable String skus) throws ProfitMandiBusinessException {
698
        StringBuffer sb = new StringBuffer("/getDealsForNotification/");
699
        String uri = sb.append(skus).toString();
700
        RestClient rc = new RestClient();
701
        String response;
702
        try {
703
            response = rc.get(SchemeType.HTTP, host, port, uri, new HashMap<>());
704
        } catch (HttpHostConnectException e) {
705
            throw new ProfitMandiBusinessException("", "", "Could not connect to host");
706
        }
707
        JsonArray result_json = Json.parse(response).asArray();
708
        List<Object> responseObject = new ArrayList<>();
709
        for (JsonValue j : result_json) {
710
            // logger.info("res " + j.asArray());
711
            List<Object> innerObject = new ArrayList<>();
712
            for (JsonValue jsonObject : j.asArray()) {
713
                innerObject.add(toDealObject(jsonObject.asObject()));
714
            }
715
            if (innerObject.size() > 0) {
716
                responseObject.add(innerObject);
717
            }
718
        }
719
        return responseSender.ok(responseObject);
720
    }
21339 kshitij.so 721
 
32339 tejbeer 722
    @RequestMapping(value = "/partner/listing", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
723
    public ResponseEntity<?> getPartnersListing(HttpServletRequest request) throws Exception {
724
        List<WebListing> webListings = webListingRepository.selectAllWebListingByType(Optional.of(true), WebListingSource.partner);
725
        UserInfo userInfo = (UserInfo) request.getAttribute("userInfo");
726
        for (WebListing webListing : webListings) {
31642 tejbeer 727
 
33573 amit.gupta 728
            webListing.setFofoCatalogResponses(getDealResponses(userInfo, webListing, 0, 20));
32339 tejbeer 729
        }
730
        return responseSender.ok(webListings);
731
    }
31547 tejbeer 732
 
33576 amit.gupta 733
    private List<FofoCatalogResponse> getDealResponses(UserInfo userInfo, WebListing webListing, int offset,
734
                                                       int limit) throws Exception {
31572 tejbeer 735
 
32339 tejbeer 736
        RestClient rc = new RestClient();
737
        Map<String, String> params = new HashMap<>();
738
        List<String> mandatoryQ = new ArrayList<>();
31670 tejbeer 739
 
32339 tejbeer 740
        FofoStore fs = fofoStoreRepository.selectByRetailerId(userInfo.getRetailerId());
31670 tejbeer 741
 
32339 tejbeer 742
        params.put("sort", "w" + fs.getWarehouseId() + "_i desc");
31576 tejbeer 743
 
32339 tejbeer 744
        List<Integer> webProducts = null;
745
        if (webListing.getType().equals(WebListingType.solr)) {
746
            logger.info("solrtype {}", webListing.getSolrQuery());
747
            mandatoryQ.add(String.format("+{!parent which=\"" + webListing.getSolrQuery() + "\"} AND active_b:true AND show_default_b:true"));
748
        } else {
749
            logger.info("solrtype2 {}", webListing.getSolrQuery());
31675 tejbeer 750
 
33573 amit.gupta 751
            webProducts = webProductListingRepository.selectAllByWebListingId(webListing.getId(), offset, limit).stream().filter(x -> x.getRank() > 0).map(x -> x.getEntityId()).collect(Collectors.toList());
31572 tejbeer 752
 
32339 tejbeer 753
            if (webProducts.size() == 0) {
754
                return new ArrayList<>();
755
            }
31572 tejbeer 756
 
32339 tejbeer 757
            mandatoryQ.add(String.format(
33575 amit.gupta 758
                    "+{!parent which=\"catalogId_i:(" + StringUtils.join(webProducts, " ") + ")\"} AND active_b:true AND show_default_b:true"));
31642 tejbeer 759
 
32339 tejbeer 760
        }
761
        params.put("q", StringUtils.join(mandatoryQ, " "));
762
        params.put("fl", "*, [child parentFilter=id:catalog* childFilter=active_b:true ]");
31612 tejbeer 763
 
32339 tejbeer 764
        params.put("start", String.valueOf(offset));
765
        params.put("rows", String.valueOf(limit));
766
        params.put("wt", "json");
767
        String response = null;
768
        try {
769
            response = rc.get(SchemeType.HTTP, solrUrl, 8984, "solr/demo/select", params);
770
        } catch (HttpHostConnectException e) {
771
            throw new ProfitMandiBusinessException("", "", "Could not connect to host");
772
        }
773
        JSONObject solrResponseJSONObj = new JSONObject(response).getJSONObject("response");
774
        JSONArray docs = solrResponseJSONObj.getJSONArray("docs");
775
        List<FofoCatalogResponse> dealResponse = getCatalogResponse(docs, false, userInfo.getRetailerId());
31671 tejbeer 776
 
32339 tejbeer 777
        if (webProducts != null && webListing.getUrl().equals("new-launches")) {
778
            List<Integer> webProductsFinal = webProducts;
779
            dealResponse = dealResponse.stream().sorted(Comparator.comparing(x -> webProductsFinal.indexOf(x.getCatalogId()))).collect(Collectors.toList());
31671 tejbeer 780
 
32339 tejbeer 781
        }
31547 tejbeer 782
 
32339 tejbeer 783
        return dealResponse;
784
    }
30669 amit.gupta 785
 
32339 tejbeer 786
    @Autowired
787
    private SaholicCISTableRepository saholicCISTableRepository;
27053 amit.gupta 788
 
33575 amit.gupta 789
    private List<FofoCatalogResponse> getCatalogResponse(JSONArray docs, boolean hotDeal, int fofoId) throws
790
            Exception {
32339 tejbeer 791
        List<FofoCatalogResponse> dealResponse = new ArrayList<>();
792
        List<Integer> tagIds = Arrays.asList(4);
793
        List<Integer> itemIds = new ArrayList<>();
794
        if (docs.length() > 0) {
795
            for (int i = 0; i < docs.length(); i++) {
796
                JSONObject doc = docs.getJSONObject(i);
797
                if (doc.has("_childDocuments_")) {
798
                    for (int j = 0; j < doc.getJSONArray("_childDocuments_").length(); j++) {
799
                        JSONObject childItem = doc.getJSONArray("_childDocuments_").getJSONObject(j);
800
                        int itemId = childItem.getInt("itemId_i");
801
                        itemIds.add(itemId);
802
                    }
803
                }
804
            }
805
            if (itemIds.size() == 0) {
806
                return dealResponse;
807
            }
808
        }
809
        // get warehouse Id
810
        int warehouseId = fofoStoreRepository.selectByRetailerId(fofoId).getWarehouseId();
811
        Map<Integer, List<SaholicPOItem>> poItemAvailabilityMap = saholicInventoryService.getSaholicPOItems().get(warehouseId);
812
        List<Integer> catalogIds = new ArrayList<>();
813
        for (int i = 0; i < docs.length(); i++) {
814
            Map<Integer, FofoAvailabilityInfo> fofoAvailabilityInfoMap = new HashMap<>();
815
            JSONObject doc = docs.getJSONObject(i);
816
            catalogIds.add(doc.getInt("catalogId_i"));
817
        }
818
        List<CreateOfferRequest> allSchemOffers = null;
819
        Map<Integer, PriceCircularItemModelNew> priceCircularItemModelMap = new HashMap<>();
820
        if (catalogIds.size() > 0) {
821
            PriceCircularModel priceCircularModel = priceCircularService.getPriceCircularByOffer(fofoId, catalogIds, LocalDate.now());
822
            allSchemOffers = priceCircularModel.getOffers();
30188 amit.gupta 823
 
32339 tejbeer 824
            List<PriceCircularItemModelNew> priceCircularItemModelNews = priceCircularModel.getPriceCircularItemModelNews();
825
            if (priceCircularItemModelNews != null) {
826
                priceCircularItemModelMap = priceCircularItemModelNews.stream().collect(Collectors.toMap(x -> x.getCatalogId(), x -> x));
827
            }
828
        }
31629 tejbeer 829
 
33575 amit.gupta 830
        /*List<CatalogFavourite> catalogFavourites = catalogFavouriteRepository.selectBypartnerId(fofoId);
32339 tejbeer 831
        List<Integer> catalogFavouriteIds = new ArrayList<>();
832
        if (!catalogFavourites.isEmpty()) {
833
            catalogFavouriteIds = catalogFavourites.stream().map(x -> x.getCatalogId()).collect(Collectors.toList());
834
        }
31629 tejbeer 835
 
32339 tejbeer 836
        if (!catalogFavourites.isEmpty()) {
837
            catalogFavourites.stream().collect(Collectors.toMap(x -> x.getCatalogId(), x -> x));
33575 amit.gupta 838
        }*/
30595 tejbeer 839
 
32339 tejbeer 840
        for (int i = 0; i < docs.length(); i++) {
841
            Map<Integer, FofoAvailabilityInfo> fofoAvailabilityInfoMap = new HashMap<>();
842
            JSONObject doc = docs.getJSONObject(i);
843
            FofoCatalogResponse fofoCatalogResponse = new FofoCatalogResponse();
844
            fofoCatalogResponse.setCatalogId(doc.getInt("catalogId_i"));
845
            fofoCatalogResponse.setImageUrl(doc.getString("imageUrl_s"));
846
            fofoCatalogResponse.setTitle(doc.getString("title_s"));
33975 tejus.loha 847
            fofoCatalogResponse.setSuperCatalogTitle(doc.getString("superCatalog_s"));
848
            fofoCatalogResponse.setSuperCatalogId(doc.getInt("superCatalog_i"));
849
            fofoCatalogResponse.setSuperCatalogVariants(doc.getString("superCatalogVariants_s"));
31629 tejbeer 850
 
33575 amit.gupta 851
            /*if (catalogFavouriteIds.contains(fofoCatalogResponse.getCatalogId())) {
32339 tejbeer 852
                fofoCatalogResponse.setFavourite(true);
33575 amit.gupta 853
            }*/
30683 tejbeer 854
 
32339 tejbeer 855
            List<WebOffer> webOffers = webOfferRepository.selectAllActiveOffers().get(fofoCatalogResponse.getCatalogId());
31612 tejbeer 856
 
33573 amit.gupta 857
            //logger.info("webOffers {}", webOffers);
32339 tejbeer 858
            if (webOffers != null && webOffers.size() > 0) {
859
                fofoCatalogResponse.setWebOffers(webOffers);
860
                fofoCatalogResponse.setOffers(webOffers.stream().map(x -> x.getTitle()).collect(Collectors.toList()));
30683 tejbeer 861
 
32339 tejbeer 862
            }
30683 tejbeer 863
 
32339 tejbeer 864
            List<ComboModel> comboModels = comboModelRepository.selectByWarehouseId(warehouseId).stream().filter(x -> x.getCatalogId() == fofoCatalogResponse.getCatalogId()).collect(Collectors.toList());
30683 tejbeer 865
 
33573 amit.gupta 866
            //logger.info("comboModels {}", comboModels);
32344 tejbeer 867
 
32339 tejbeer 868
            if (comboModels != null && comboModels.size() > 0) {
869
                fofoCatalogResponse.setComboModels(comboModels);
870
            }
30683 tejbeer 871
 
32339 tejbeer 872
            try {
873
                fofoCatalogResponse.setFeature(doc.getString("feature_s"));
874
            } catch (Exception e) {
875
                fofoCatalogResponse.setFeature(null);
876
                logger.info("Could not find Feature_s for {}", fofoCatalogResponse.getCatalogId());
877
            }
30683 tejbeer 878
 
32339 tejbeer 879
            fofoCatalogResponse.setBrand(doc.getJSONArray("brand_ss").getString(0));
880
            logger.info("labelss {}", doc.has("label_ss"));
30683 tejbeer 881
 
32339 tejbeer 882
            if (doc.has("label_ss")) {
883
                logger.info("label {}", doc.getJSONArray("label_ss"));
30683 tejbeer 884
 
32339 tejbeer 885
                JSONArray arr = doc.getJSONArray("label_ss");
886
                Set<String> labels = new HashSet<String>();
887
                for (int j = 0; j < arr.length(); j++) {
888
                    labels.add(arr.getString(j));
889
                }
31612 tejbeer 890
 
32339 tejbeer 891
                fofoCatalogResponse.setLabels(new ArrayList<>(labels));
31612 tejbeer 892
 
32339 tejbeer 893
            }
33573 amit.gupta 894
            if (doc.has("similarModels_ii")) {
895
                JSONArray similarModelsArray = doc.getJSONArray("similarModels_ii");
896
                List<Integer> similarCatalogIds = new ArrayList<>();
897
                for (int j = 0; j < similarModelsArray.length(); j++) {
898
                    similarCatalogIds.add(similarModelsArray.getInt(j));
899
                }
900
                fofoCatalogResponse.setSimilarModelIds(similarCatalogIds);
901
            }
31612 tejbeer 902
 
32339 tejbeer 903
            if (doc.has("_childDocuments_")) {
904
                String modelColorClass = "grey";
905
                FofoAvailabilityInfo fdiAnyColour = null;
906
                // Iterating itemIds
907
                for (int j = 0; j < doc.getJSONArray("_childDocuments_").length(); j++) {
908
                    PriceCircularItemModelNew priceCircularItemModel = priceCircularItemModelMap.get(fofoCatalogResponse.getCatalogId());
909
                    JSONObject childItem = doc.getJSONArray("_childDocuments_").getJSONObject(j);
910
                    int itemId = childItem.getInt("itemId_i");
911
                    float sellingPrice = (float) childItem.getDouble("sellingPrice_f");
912
                    if (!fofoAvailabilityInfoMap.containsKey(itemId)) {
913
                        FofoAvailabilityInfo fdi = new FofoAvailabilityInfo();
914
                        List<SaholicCISTable> currentAvailability = saholicCISTableRepository.selectByItemWarehouse(itemId, warehouseId);
915
                        List<SaholicPOItem> poItemAvailability = null;
916
                        if (poItemAvailabilityMap != null) {
917
                            poItemAvailability = poItemAvailabilityMap.get(itemId);
918
                        }
31612 tejbeer 919
 
32339 tejbeer 920
                        if (priceCircularItemModel != null) {
33410 ranu 921
                            fdi.setNlc((float) priceCircularItemModel.getNetNlc());
32339 tejbeer 922
                        }
31612 tejbeer 923
 
32339 tejbeer 924
                        for (SaholicCISTable saholicCISTable : currentAvailability) {
925
                            saholicCISTable.setWarehouseName(
926
                                    ProfitMandiConstants.WAREHOUSE_MAP.get(saholicCISTable.getWarehouseFrom()));
927
                        }
31612 tejbeer 928
 
32339 tejbeer 929
                        Map<Integer, SaholicCISTable> map = currentAvailability.stream().collect(Collectors.toMap(SaholicCISTable::getWarehouseFrom, x -> x));
930
                        if (poItemAvailability != null) {
931
                            for (SaholicPOItem saholicPOItem : poItemAvailability) {
932
                                if (map.containsKey(saholicPOItem.getWarehouseFrom())) {
933
                                    map.get(saholicPOItem.getWarehouseFrom()).setPopendingQty(saholicPOItem.getUnfulfilledQty());
934
                                } else {
935
                                    SaholicCISTable saholicCISTable = new SaholicCISTable();
936
                                    saholicCISTable.setAvailability(0);
937
                                    saholicCISTable.setReserved(0);
938
                                    saholicCISTable.setItemId(itemId);
939
                                    saholicCISTable.setWarehouseId(warehouseId);
940
                                    saholicCISTable.setPopendingQty(saholicPOItem.getUnfulfilledQty());
941
                                    saholicCISTable.setWarehouseFrom(saholicPOItem.getWarehouseFrom());
942
                                    saholicCISTable.setWarehouseName(
943
                                            ProfitMandiConstants.WAREHOUSE_MAP.get(saholicPOItem.getWarehouseFrom()));
944
                                    map.put(saholicPOItem.getWarehouseFrom(), saholicCISTable);
945
                                }
946
                            }
947
                        }
948
                        fdi.setSaholicCISTableList(new ArrayList<>(map.values()));
949
                        String poColor = "grey";
950
                        boolean active = false;
951
                        if (currentAvailability != null && currentAvailability.stream().collect(Collectors.summingInt(SaholicCISTable::getNetAvailability)) > 0) {
952
                            poColor = "green";
953
                            modelColorClass = "green";
32978 amit.gupta 954
                        } else if (poItemAvailability != null && poItemAvailability.stream().collect(Collectors.summingInt(SaholicPOItem::getUnfulfilledQty)) > 0) {
955
                            if (currentAvailability != null && poItemAvailability.stream().collect(Collectors.summingInt(SaholicPOItem::getUnfulfilledQty)) + currentAvailability.stream().collect(Collectors.summingInt(SaholicCISTable::getNetAvailability)) <= 0) {
956
                                poColor = "grey";
957
                            } else {
958
                                poColor = "yellow";
959
                                if (modelColorClass != "green") {
960
                                    modelColorClass = poColor;
32339 tejbeer 961
                                }
962
                            }
32978 amit.gupta 963
                        }
32339 tejbeer 964
                        fdi.setColorClass(poColor);
965
                        fdi.setSellingPrice(sellingPrice);
966
                        fdi.setActive(active);
967
                        fdi.setMrp(childItem.getDouble("mrp_f"));
968
                        fdi.setMop((float) childItem.getDouble("mop_f"));
969
                        fdi.setColor(childItem.has("color_s") ? childItem.getString("color_s") : "");
970
                        if (fdi.getColor().equalsIgnoreCase("any colour")) {
971
                            fdiAnyColour = fdi;
972
                        }
33929 tejus.loha 973
                        fdi.setBrand((String) doc.getJSONArray("brand_ss").get(0));
974
                        fdi.setCategoryId(doc.getInt("subCategoryId_i"));
32339 tejbeer 975
                        fdi.setTagId(childItem.getInt("tagId_i"));
976
                        fdi.setItem_id(itemId);
34196 ranu 977
                        fdi.setCatalog_id(doc.getInt("catalogId_i"));
32978 amit.gupta 978
                        Float cashBack = schemeService.getCatalogSchemeCashBack(fofoId, Arrays.asList(fofoCatalogResponse.getCatalogId())).get(fofoCatalogResponse.getCatalogId());
32339 tejbeer 979
                        cashBack = cashBack == null ? 0 : cashBack;
980
                        fdi.setCashback(cashBack);
981
                        fdi.setMinBuyQuantity(1);
982
                        if (hotDeal) {
983
                            if (currentAvailability != null) {
984
                                fdi.setAvailability(currentAvailability.stream().collect(Collectors.summingInt(SaholicCISTable::getNetAvailability)));
985
                            } else {
986
                                fdi.setAvailability(0);
987
                            }
988
                        } else {
989
                            // Lets consider that its out of stock
32591 amit.gupta 990
                            fdi.setAvailability(400);
32339 tejbeer 991
                            Item item = null;
992
                            try {
993
                                item = itemRepository.selectById(itemId);
994
                            } catch (Exception e) {
995
                                e.printStackTrace();
996
                                continue;
997
                            }
998
                            // In case its tampered glass moq should be
999
                            if (item.getCategoryId() == 10020) {
1000
                                fdi.setMinBuyQuantity(5);
1001
                            }
1002
                        }
1003
                        fdi.setQuantityStep(1);
32590 amit.gupta 1004
                        fdi.setMaxQuantity(Math.min(fdi.getAvailability(), 400));
32339 tejbeer 1005
                        fofoAvailabilityInfoMap.put(itemId, fdi);
1006
                    }
1007
                }
1008
                if (fdiAnyColour != null) {
1009
                    fdiAnyColour.setColorClass(modelColorClass);
1010
                }
33576 amit.gupta 1011
                fofoCatalogResponse.setInStock(!modelColorClass.equals("grey"));
32339 tejbeer 1012
            }
1013
            if (fofoAvailabilityInfoMap.values().size() > 0) {
1014
                List<FofoAvailabilityInfo> availabilityList = fofoAvailabilityInfoMap.values().stream().sorted(Comparator.comparing(FofoAvailabilityInfo::getAvailability).reversed()).collect(Collectors.toList());
1015
                fofoCatalogResponse.setItems(availabilityList);
1016
                if (priceCircularItemModelMap.containsKey(fofoCatalogResponse.getCatalogId())) {
1017
                    PriceCircularItemModelNew priceCircularItemModel = priceCircularItemModelMap.get(fofoCatalogResponse.getCatalogId());
1018
                    if (priceCircularItemModel.getSlabPayouts() != null) {
1019
                        List<CreateOfferRequest> schemeOffers = new ArrayList<>();
1020
                        List<Map<Integer, AmountModel>> slabPayouts = priceCircularItemModel.getSlabPayouts();
1021
                        Iterator<Map<Integer, AmountModel>> iterator = slabPayouts.iterator();
1022
                        int iteratorCount = 0;
1023
                        while (iterator.hasNext()) {
1024
                            Map<Integer, AmountModel> slabPayoutMap = iterator.next();
1025
                            if (slabPayoutMap != null) {
1026
                                schemeOffers.add(allSchemOffers.get(iteratorCount));
1027
                            } else {
1028
                                iterator.remove();
1029
                            }
1030
                            iteratorCount++;
1031
                        }
1032
                        fofoCatalogResponse.setSchemeOffers(schemeOffers);
1033
                    }
1034
                    fofoCatalogResponse.setPriceCircularItemModel(priceCircularItemModel);
1035
                }
1036
                dealResponse.add(fofoCatalogResponse);
1037
            }
1038
        }
1039
        return dealResponse;
30686 amit.gupta 1040
 
32339 tejbeer 1041
    }
30693 amit.gupta 1042
 
33575 amit.gupta 1043
    private List<FofoCatalogResponse> getCatalogSingleSkuResponse(JSONArray
1044
                                                                          docs, Map<Integer, Integer> itemFilter, boolean hotDeal) throws ProfitMandiBusinessException {
32339 tejbeer 1045
        List<FofoCatalogResponse> dealResponse = new ArrayList<>();
1046
        List<Integer> tagIds = Arrays.asList(4);
24091 tejbeer 1047
 
33873 ranu 1048
        Map<Integer, TagListing> itemTagListingMap = tagListingRepository.selectByItemIdsAndTagIds(itemFilter.keySet(), new HashSet<>(tagIds)).stream().collect(Collectors.toMap(x -> x.getItemId(), x -> x));
24091 tejbeer 1049
 
32339 tejbeer 1050
        for (int i = 0; i < docs.length(); i++) {
1051
            Map<Integer, FofoAvailabilityInfo> fofoAvailabilityInfoMap = new HashMap<>();
1052
            JSONObject doc = docs.getJSONObject(i);
26589 amit.gupta 1053
 
32339 tejbeer 1054
            for (int j = 0; j < doc.getJSONArray("_childDocuments_").length(); j++) {
1055
                JSONObject childItem = doc.getJSONArray("_childDocuments_").getJSONObject(j);
1056
                int itemId = childItem.getInt("itemId_i");
1057
                TagListing tl = itemTagListingMap.get(itemId);
1058
                if (tl == null) {
1059
                    continue;
1060
                }
1061
                if (hotDeal) {
1062
                    if (!tl.isHotDeals()) {
1063
                        continue;
1064
                    }
1065
                }
1066
                float sellingPrice = (float) childItem.getDouble("sellingPrice_f");
1067
                if (fofoAvailabilityInfoMap.containsKey(itemId)) {
1068
                    if (fofoAvailabilityInfoMap.get(itemId).getSellingPrice() > sellingPrice) {
1069
                        fofoAvailabilityInfoMap.get(itemId).setSellingPrice(sellingPrice);
1070
                        fofoAvailabilityInfoMap.get(itemId).setMop((float) childItem.getDouble("mop_f"));
1071
                    }
1072
                } else {
1073
                    FofoAvailabilityInfo fdi = new FofoAvailabilityInfo();
1074
                    fdi.setSellingPrice((float) childItem.getDouble("sellingPrice_f"));
1075
                    fdi.setMop((float) childItem.getDouble("mop_f"));
1076
                    fdi.setMop((float) tl.getMrp());
1077
                    fdi.setColor(childItem.has("color_s") ? childItem.getString("color_s") : "");
1078
                    fdi.setTagId(childItem.getInt("tagId_i"));
1079
                    fdi.setItem_id(itemId);
34196 ranu 1080
                    fdi.setCatalog_id(doc.getInt("catalogId_i"));
32339 tejbeer 1081
                    Item item = itemRepository.selectById(itemId);
1082
                    // In case its tampered glass moq should be 5
1083
                    if (item.getCategoryId() == 10020) {
1084
                        fdi.setMinBuyQuantity(10);
1085
                    } else {
1086
                        fdi.setMinBuyQuantity(1);
1087
                    }
1088
                    fdi.setAvailability(itemFilter.get(itemId));
1089
                    fdi.setQuantityStep(1);
1090
                    fdi.setMaxQuantity(Math.min(fdi.getAvailability(), 100));
1091
                    fofoAvailabilityInfoMap.put(itemId, fdi);
1092
                }
1093
            }
1094
            if (fofoAvailabilityInfoMap.values().size() > 0) {
1095
                for (FofoAvailabilityInfo fofoAvailabilityInfo : fofoAvailabilityInfoMap.values()) {
1096
                    FofoCatalogResponse ffdr = new FofoCatalogResponse();
1097
                    ffdr.setCatalogId(doc.getInt("catalogId_i"));
1098
                    ffdr.setImageUrl(doc.getString("imageUrl_s"));
1099
                    ffdr.setTitle(doc.getString("title_s"));
1100
                    try {
1101
                        ffdr.setFeature(doc.getString("feature_s"));
1102
                    } catch (Exception e) {
1103
                        ffdr.setFeature(null);
1104
                        logger.info("Could not find Feature_s for {}", ffdr.getCatalogId());
1105
                    }
1106
                    ffdr.setBrand(doc.getJSONArray("brand_ss").getString(0));
1107
                    ffdr.setItems(Arrays.asList(fofoAvailabilityInfo));
1108
                    dealResponse.add(ffdr);
1109
                }
1110
            }
1111
        }
1112
        return dealResponse;
25880 amit.gupta 1113
 
32339 tejbeer 1114
    }
25880 amit.gupta 1115
 
32339 tejbeer 1116
    @RequestMapping(value = "/combo", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
1117
    public ResponseEntity<?> getBanners(@RequestParam int catalogId, @RequestParam int warehouseId) {
1118
        List<ComboModel> comboModels = comboModelRepository.selectByCatalogIdAndWarehouseId(catalogId, warehouseId);
1119
        return responseSender.ok(comboModels);
1120
    }
32344 tejbeer 1121
 
1122
    @RequestMapping(value = "/checkCombo", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
33575 amit.gupta 1123
    public ResponseEntity<?> checkCombo(HttpServletRequest request, @RequestParam int catalogId,
1124
                                        @RequestParam int warehouseId, @RequestParam int qty) throws Exception {
32344 tejbeer 1125
        boolean isCombo = false;
1126
        ComboModel comboModel = comboModelRepository.selectByCatalogIdWarehouseIdAndQty(catalogId, warehouseId, qty);
1127
        if (comboModel != null) {
1128
            isCombo = true;
1129
        }
1130
 
1131
        return responseSender.ok(isCombo);
1132
    }
1133
 
1134
 
33929 tejus.loha 1135
    @GetMapping(value = "/partner/wodCompleteBrands", produces = MediaType.APPLICATION_JSON_VALUE)
1136
    public ResponseEntity<?> getWodcompletBrands(HttpServletRequest request) throws Exception {
1137
        UserInfo userInfo = (UserInfo) request.getAttribute("userInfo");
1138
        FofoStore fofoStore = fofoStoreRepository.selectByRetailerId(userInfo.getRetailerId());
1139
        PartnerOnBoardingPanel partnerOnBoardingPanel = partnerOnBoardingPanelRepository.selectByCode(fofoStore.getCode());
34008 tejus.loha 1140
        List<PartnerDealerMapping> partnerDealerMappingList = new ArrayList<>();
1141
        List<String> wodCompletedBrands = new ArrayList<>();
1142
        if (partnerOnBoardingPanel != null) {
1143
            partnerDealerMappingList = partnerDealerRepository.selectByOnboardingId(partnerOnBoardingPanel.getId());
1144
            if (partnerDealerMappingList != null && partnerDealerMappingList.size() > 0) {
1145
                //working brands -> Partner only work with brands that having 'Dealer Code'
1146
                wodCompletedBrands = partnerDealerMappingList.stream().filter(x -> x.getBrandCode().trim().length() > 0).map(x -> x.getBrand()).collect(Collectors.toList());
1147
            }
1148
        }
33929 tejus.loha 1149
        BrandAndAddToCartEligibleModel partnerWorkingBrandMappingModel = new BrandAndAddToCartEligibleModel();
1150
        partnerWorkingBrandMappingModel.setWodCompleteBrands(wodCompletedBrands);
1151
        //brandsToBeCheck
1152
        List<String> wodRequiredBrand = brandCommitRepository.selectAllActiveBrand().stream().filter(x -> x.isNocRequired()).map(x -> x.getBrand()).collect(Collectors.toList());
1153
        partnerWorkingBrandMappingModel.setWodRequiredBrands(wodRequiredBrand);
1154
        return responseSender.ok(partnerWorkingBrandMappingModel);
1155
 
1156
    }
1157
 
25967 amit.gupta 1158
}