| Line 16... |
Line 16... |
| 16 |
import com.spice.profitmandi.common.web.client.RestClient;
|
16 |
import com.spice.profitmandi.common.web.client.RestClient;
|
| 17 |
import com.spice.profitmandi.common.web.util.ResponseSender;
|
17 |
import com.spice.profitmandi.common.web.util.ResponseSender;
|
| 18 |
import com.spice.profitmandi.dao.entity.catalog.Category;
|
18 |
import com.spice.profitmandi.dao.entity.catalog.Category;
|
| 19 |
import com.spice.profitmandi.dao.entity.catalog.Item;
|
19 |
import com.spice.profitmandi.dao.entity.catalog.Item;
|
| 20 |
import com.spice.profitmandi.dao.entity.catalog.TagListing;
|
20 |
import com.spice.profitmandi.dao.entity.catalog.TagListing;
|
| - |
|
21 |
import com.spice.profitmandi.dao.entity.dtr.WebOffer;
|
| 21 |
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
|
22 |
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
|
| 22 |
import com.spice.profitmandi.dao.entity.fofo.SuggestedPo;
|
23 |
import com.spice.profitmandi.dao.entity.fofo.SuggestedPo;
|
| 23 |
import com.spice.profitmandi.dao.entity.fofo.SuggestedPoDetail;
|
24 |
import com.spice.profitmandi.dao.entity.fofo.SuggestedPoDetail;
|
| 24 |
import com.spice.profitmandi.dao.entity.inventory.SaholicCIS;
|
25 |
import com.spice.profitmandi.dao.entity.inventory.SaholicCIS;
|
| 25 |
import com.spice.profitmandi.dao.entity.inventory.SaholicPOItem;
|
26 |
import com.spice.profitmandi.dao.entity.inventory.SaholicPOItem;
|
| Line 29... |
Line 30... |
| 29 |
import com.spice.profitmandi.dao.repository.catalog.ItemRepository;
|
30 |
import com.spice.profitmandi.dao.repository.catalog.ItemRepository;
|
| 30 |
import com.spice.profitmandi.dao.repository.catalog.TagListingRepository;
|
31 |
import com.spice.profitmandi.dao.repository.catalog.TagListingRepository;
|
| 31 |
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
|
32 |
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
|
| 32 |
import com.spice.profitmandi.dao.repository.dtr.Mongo;
|
33 |
import com.spice.profitmandi.dao.repository.dtr.Mongo;
|
| 33 |
import com.spice.profitmandi.dao.repository.dtr.UserAccountRepository;
|
34 |
import com.spice.profitmandi.dao.repository.dtr.UserAccountRepository;
|
| - |
|
35 |
import com.spice.profitmandi.dao.repository.dtr.WebOfferRepository;
|
| 34 |
import com.spice.profitmandi.dao.repository.fofo.SuggestedPoDetailRepository;
|
36 |
import com.spice.profitmandi.dao.repository.fofo.SuggestedPoDetailRepository;
|
| 35 |
import com.spice.profitmandi.dao.repository.fofo.SuggestedPoRepository;
|
37 |
import com.spice.profitmandi.dao.repository.fofo.SuggestedPoRepository;
|
| 36 |
import com.spice.profitmandi.service.authentication.RoleManager;
|
38 |
import com.spice.profitmandi.service.authentication.RoleManager;
|
| 37 |
import com.spice.profitmandi.service.inventory.*;
|
39 |
import com.spice.profitmandi.service.inventory.*;
|
| 38 |
import com.spice.profitmandi.service.pricecircular.PriceCircularItemModel;
|
40 |
import com.spice.profitmandi.service.pricecircular.PriceCircularItemModel;
|
| Line 139... |
Line 141... |
| 139 |
private SuggestedPoDetailRepository monthlyPoDetailRepository;
|
141 |
private SuggestedPoDetailRepository monthlyPoDetailRepository;
|
| 140 |
|
142 |
|
| 141 |
@Autowired
|
143 |
@Autowired
|
| 142 |
private SuggestedPoRepository suggestedPoRepository;
|
144 |
private SuggestedPoRepository suggestedPoRepository;
|
| 143 |
|
145 |
|
| - |
|
146 |
@Autowired
|
| - |
|
147 |
private WebOfferRepository webOfferRepository;
|
| - |
|
148 |
|
| 144 |
List<String> filterableParams = Arrays.asList("brand");
|
149 |
List<String> filterableParams = Arrays.asList("brand");
|
| 145 |
|
150 |
|
| 146 |
@RequestMapping(value = "/fofo/buckets", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
151 |
@RequestMapping(value = "/fofo/buckets", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
| 147 |
public ResponseEntity<?> getBuckets(HttpServletRequest request) throws ProfitMandiBusinessException {
|
152 |
public ResponseEntity<?> getBuckets(HttpServletRequest request) throws ProfitMandiBusinessException {
|
| 148 |
logger.info("Request " + request.getParameterMap());
|
153 |
logger.info("Request " + request.getParameterMap());
|
| Line 218... |
Line 223... |
| 218 |
return responseSender.ok(dealResponse);
|
223 |
return responseSender.ok(dealResponse);
|
| 219 |
}
|
224 |
}
|
| 220 |
|
225 |
|
| 221 |
@RequestMapping(value = "/suggestedPo/status", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
|
226 |
@RequestMapping(value = "/suggestedPo/status", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
|
| 222 |
@ApiImplicitParams({
|
227 |
@ApiImplicitParams({
|
| 223 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header")})
|
228 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
|
| 224 |
@ApiOperation(value = "")
|
229 |
@ApiOperation(value = "")
|
| 225 |
public ResponseEntity<?> changeSuggestedPoStatus(HttpServletRequest request, @RequestParam int id)
|
230 |
public ResponseEntity<?> changeSuggestedPoStatus(HttpServletRequest request, @RequestParam int id)
|
| 226 |
throws ProfitMandiBusinessException {
|
231 |
throws ProfitMandiBusinessException {
|
| 227 |
SuggestedPo suggestedPo = suggestedPoRepository.selectById(id);
|
232 |
SuggestedPo suggestedPo = suggestedPoRepository.selectById(id);
|
| 228 |
suggestedPo.setStatus("closed");
|
233 |
suggestedPo.setStatus("closed");
|
| Line 239... |
Line 244... |
| 239 |
}
|
244 |
}
|
| 240 |
return String.join(",", strTagIds);
|
245 |
return String.join(",", strTagIds);
|
| 241 |
}
|
246 |
}
|
| 242 |
|
247 |
|
| 243 |
@ApiImplicitParams({
|
248 |
@ApiImplicitParams({
|
| 244 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header")})
|
249 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
|
| 245 |
@RequestMapping(value = "/fofo", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
250 |
@RequestMapping(value = "/fofo", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
| 246 |
public ResponseEntity<?> getFofo(HttpServletRequest request,
|
251 |
public ResponseEntity<?> getFofo(HttpServletRequest request,
|
| 247 |
@RequestParam(value = "categoryId", required = false, defaultValue = "3") String categoryId,
|
252 |
@RequestParam(value = "categoryId", required = false, defaultValue = "3") String categoryId,
|
| 248 |
@RequestParam(value = "offset") String offset, @RequestParam(value = "limit") String limit,
|
253 |
@RequestParam(value = "offset") String offset, @RequestParam(value = "limit") String limit,
|
| 249 |
@RequestParam(value = "sort", required = false) String sort,
|
254 |
@RequestParam(value = "sort", required = false) String sort,
|
| 250 |
@RequestParam(value = "brand", required = false) String brand,
|
255 |
@RequestParam(value = "brand", required = false) String brand,
|
| 251 |
@RequestParam(value = "subCategoryId", required = false) int subCategoryId,
|
256 |
@RequestParam(value = "subCategoryId", required = false) int subCategoryId,
|
| 252 |
@RequestParam(value = "q", required = false) String queryTerm,
|
257 |
@RequestParam(value = "q", required = false) String queryTerm,
|
| 253 |
@RequestParam(value = "hotDeal", required = false) boolean hotDeal) throws Throwable {
|
258 |
@RequestParam(value = "hotDeal", required = false) boolean hotDeal) throws Throwable {
|
| 254 |
List<FofoCatalogResponse> dealResponse = new ArrayList<>();
|
259 |
List<FofoCatalogResponse> dealResponse = new ArrayList<>();
|
| 255 |
UserInfo userInfo = (UserInfo) request.getAttribute("userInfo");
|
260 |
UserInfo userInfo = (UserInfo) request.getAttribute("userInfo");
|
| 256 |
FofoStore fs = fofoStoreRepository.selectByRetailerId(userInfo.getRetailerId());
|
261 |
FofoStore fs = fofoStoreRepository.selectByRetailerId(userInfo.getRetailerId());
|
| 257 |
sort = "w" + fs.getWarehouseId() + "_i desc";
|
262 |
sort = "w" + fs.getWarehouseId() + "_i desc";
|
| 258 |
dealResponse = this.getCatalogResponse(
|
263 |
dealResponse = this.getCatalogResponse(
|
| Line 262... |
Line 267... |
| 262 |
return responseSender.ok(dealResponse);
|
267 |
return responseSender.ok(dealResponse);
|
| 263 |
}
|
268 |
}
|
| 264 |
|
269 |
|
| 265 |
@RequestMapping(value = "/online-deals", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
270 |
@RequestMapping(value = "/online-deals", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
| 266 |
@ApiImplicitParams({
|
271 |
@ApiImplicitParams({
|
| 267 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header")})
|
272 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
|
| 268 |
@ApiOperation(value = "Get online deals")
|
273 |
@ApiOperation(value = "Get online deals")
|
| 269 |
public ResponseEntity<?> getOnlineDeals(HttpServletRequest request,
|
274 |
public ResponseEntity<?> getOnlineDeals(HttpServletRequest request,
|
| 270 |
@RequestParam(value = "categoryId") String categoryId, @RequestParam(value = "offset") String offset,
|
275 |
@RequestParam(value = "categoryId") String categoryId, @RequestParam(value = "offset") String offset,
|
| 271 |
@RequestParam(value = "limit") String limit, @RequestParam(value = "sort", required = false) String sort,
|
276 |
@RequestParam(value = "limit") String limit, @RequestParam(value = "sort", required = false) String sort,
|
| 272 |
@RequestParam(value = "direction", required = false) String direction,
|
277 |
@RequestParam(value = "direction", required = false) String direction,
|
| 273 |
@RequestParam(value = "filterData", required = false) String filterData) throws Throwable {
|
278 |
@RequestParam(value = "filterData", required = false) String filterData) throws Throwable {
|
| 274 |
logger.info("Request " + request.getParameterMap());
|
279 |
logger.info("Request " + request.getParameterMap());
|
| 275 |
String response = null;
|
280 |
String response = null;
|
| 276 |
int userId = (int) request.getAttribute("userId");
|
281 |
int userId = (int) request.getAttribute("userId");
|
| 277 |
|
282 |
|
| 278 |
String uri = "/deals/" + userId;
|
283 |
String uri = "/deals/" + userId;
|
| Line 317... |
Line 322... |
| 317 |
return new Gson().fromJson(jsonObject.toString(), DealsResponse.class);
|
322 |
return new Gson().fromJson(jsonObject.toString(), DealsResponse.class);
|
| 318 |
}
|
323 |
}
|
| 319 |
|
324 |
|
| 320 |
@RequestMapping(value = ProfitMandiConstants.URL_BRANDS, method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
325 |
@RequestMapping(value = ProfitMandiConstants.URL_BRANDS, method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
| 321 |
@ApiImplicitParams({
|
326 |
@ApiImplicitParams({
|
| 322 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header")})
|
327 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
|
| 323 |
@ApiOperation(value = "Get brand list and count for category")
|
328 |
@ApiOperation(value = "Get brand list and count for category")
|
| 324 |
public ResponseEntity<?> getBrands(HttpServletRequest request,
|
329 |
public ResponseEntity<?> getBrands(HttpServletRequest request,
|
| 325 |
@RequestParam(value = "category_id") String category_id) throws ProfitMandiBusinessException {
|
330 |
@RequestParam(value = "category_id") String category_id) throws ProfitMandiBusinessException {
|
| 326 |
logger.info("Request " + request.getParameterMap());
|
331 |
logger.info("Request " + request.getParameterMap());
|
| 327 |
String response = null;
|
332 |
String response = null;
|
| 328 |
// TODO: move to properties
|
333 |
// TODO: move to properties
|
| 329 |
String uri = ProfitMandiConstants.URL_BRANDS;
|
334 |
String uri = ProfitMandiConstants.URL_BRANDS;
|
| 330 |
RestClient rc = new RestClient();
|
335 |
RestClient rc = new RestClient();
|
| Line 343... |
Line 348... |
| 343 |
return responseSender.ok(dealBrandsResponse);
|
348 |
return responseSender.ok(dealBrandsResponse);
|
| 344 |
}
|
349 |
}
|
| 345 |
|
350 |
|
| 346 |
@RequestMapping(value = ProfitMandiConstants.URL_UNIT_DEAL, method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
351 |
@RequestMapping(value = ProfitMandiConstants.URL_UNIT_DEAL, method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
| 347 |
@ApiImplicitParams({
|
352 |
@ApiImplicitParams({
|
| 348 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header")})
|
353 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
|
| 349 |
@ApiOperation(value = "Get unit deal object")
|
354 |
@ApiOperation(value = "Get unit deal object")
|
| 350 |
public ResponseEntity<?> getUnitDeal(HttpServletRequest request, @PathVariable(value = "id") long id)
|
355 |
public ResponseEntity<?> getUnitDeal(HttpServletRequest request, @PathVariable(value = "id") long id)
|
| 351 |
throws ProfitMandiBusinessException {
|
356 |
throws ProfitMandiBusinessException {
|
| 352 |
String response = null;
|
357 |
String response = null;
|
| 353 |
// TODO: move to properties
|
358 |
// TODO: move to properties
|
| Line 375... |
Line 380... |
| 375 |
return responseSender.ok(dealsResponse);
|
380 |
return responseSender.ok(dealsResponse);
|
| 376 |
}
|
381 |
}
|
| 377 |
|
382 |
|
| 378 |
@RequestMapping(value = "/partnerdeals/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
383 |
@RequestMapping(value = "/partnerdeals/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
| 379 |
@ApiImplicitParams({
|
384 |
@ApiImplicitParams({
|
| 380 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header")})
|
385 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
|
| 381 |
@ApiOperation(value = "Get unit deal object")
|
386 |
@ApiOperation(value = "Get unit deal object")
|
| 382 |
public ResponseEntity<?> getUnitFocoDeal(HttpServletRequest request, @PathVariable(value = "id") long id)
|
387 |
public ResponseEntity<?> getUnitFocoDeal(HttpServletRequest request, @PathVariable(value = "id") long id)
|
| 383 |
throws Exception {
|
388 |
throws Exception {
|
| 384 |
List<FofoCatalogResponse> dealResponse = new ArrayList<>();
|
389 |
List<FofoCatalogResponse> dealResponse = new ArrayList<>();
|
| 385 |
List<Integer> tagIds = Arrays.asList(4);
|
390 |
List<Integer> tagIds = Arrays.asList(4);
|
| Line 415... |
Line 420... |
| 415 |
return responseSender.ok(dealResponse.get(0));
|
420 |
return responseSender.ok(dealResponse.get(0));
|
| 416 |
}
|
421 |
}
|
| 417 |
|
422 |
|
| 418 |
@RequestMapping(value = "/fofo/brands", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
423 |
@RequestMapping(value = "/fofo/brands", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
| 419 |
public ResponseEntity<?> getBrandsToDisplay(HttpServletRequest request,
|
424 |
public ResponseEntity<?> getBrandsToDisplay(HttpServletRequest request,
|
| 420 |
@RequestParam(required = false, defaultValue = "0") int categoryId) throws Exception {
|
425 |
@RequestParam(required = false, defaultValue = "0") int categoryId) throws Exception {
|
| 421 |
UserInfo userInfo = (UserInfo) request.getAttribute("userInfo");
|
426 |
UserInfo userInfo = (UserInfo) request.getAttribute("userInfo");
|
| 422 |
logger.info("userInfo [{}]", userInfo);
|
427 |
logger.info("userInfo [{}]", userInfo);
|
| 423 |
List<DBObject> brandsDisplay = mongoClient.getMongoBrands(userInfo.getRetailerId(), userInfo.getEmail(),
|
428 |
List<DBObject> brandsDisplay = mongoClient.getMongoBrands(userInfo.getRetailerId(), userInfo.getEmail(),
|
| 424 |
categoryId);
|
429 |
categoryId);
|
| 425 |
return new ResponseEntity<>(brandsDisplay, HttpStatus.OK);
|
430 |
return new ResponseEntity<>(brandsDisplay, HttpStatus.OK);
|
| Line 484... |
Line 489... |
| 484 |
public ResponseEntity<?> getSubcategoriesToDisplay() {
|
489 |
public ResponseEntity<?> getSubcategoriesToDisplay() {
|
| 485 |
return new ResponseEntity<>(mongoClient.getSubcategoriesToDisplay(), HttpStatus.OK);
|
490 |
return new ResponseEntity<>(mongoClient.getSubcategoriesToDisplay(), HttpStatus.OK);
|
| 486 |
}
|
491 |
}
|
| 487 |
|
492 |
|
| 488 |
@ApiImplicitParams({
|
493 |
@ApiImplicitParams({
|
| 489 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header")})
|
494 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
|
| 490 |
@RequestMapping(value = "/deals/skus/{skus}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
495 |
@RequestMapping(value = "/deals/skus/{skus}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
| 491 |
public ResponseEntity<?> getDealsBySkus(@PathVariable String skus) throws ProfitMandiBusinessException {
|
496 |
public ResponseEntity<?> getDealsBySkus(@PathVariable String skus) throws ProfitMandiBusinessException {
|
| 492 |
StringBuffer sb = new StringBuffer("/getDealsForNotification/");
|
497 |
StringBuffer sb = new StringBuffer("/getDealsForNotification/");
|
| 493 |
String uri = sb.append(skus).toString();
|
498 |
String uri = sb.append(skus).toString();
|
| 494 |
RestClient rc = new RestClient();
|
499 |
RestClient rc = new RestClient();
|
| Line 549... |
Line 554... |
| 549 |
PriceCircularModel priceCircularModel = priceCircularService.getPriceCircularByOffer(fofoId, catalogIds);
|
554 |
PriceCircularModel priceCircularModel = priceCircularService.getPriceCircularByOffer(fofoId, catalogIds);
|
| 550 |
allSchemOffers = priceCircularModel.getOffers();
|
555 |
allSchemOffers = priceCircularModel.getOffers();
|
| 551 |
|
556 |
|
| 552 |
List<PriceCircularItemModel> priceCircularItemModels = priceCircularModel.getPriceCircularItemModels();
|
557 |
List<PriceCircularItemModel> priceCircularItemModels = priceCircularModel.getPriceCircularItemModels();
|
| 553 |
if (priceCircularItemModels != null) {
|
558 |
if (priceCircularItemModels != null) {
|
| 554 |
priceCircularItemModelMap = priceCircularItemModels.stream().collect(Collectors.toMap(x -> x.getCatalogId(), x -> x));
|
559 |
priceCircularItemModelMap = priceCircularItemModels.stream()
|
| - |
|
560 |
.collect(Collectors.toMap(x -> x.getCatalogId(), x -> x));
|
| 555 |
}
|
561 |
}
|
| 556 |
}
|
562 |
}
|
| 557 |
|
563 |
|
| 558 |
for (int i = 0; i < docs.length(); i++) {
|
564 |
for (int i = 0; i < docs.length(); i++) {
|
| 559 |
Map<Integer, FofoAvailabilityInfo> fofoAvailabilityInfoMap = new HashMap<>();
|
565 |
Map<Integer, FofoAvailabilityInfo> fofoAvailabilityInfoMap = new HashMap<>();
|
| 560 |
JSONObject doc = docs.getJSONObject(i);
|
566 |
JSONObject doc = docs.getJSONObject(i);
|
| 561 |
FofoCatalogResponse fofoCatalogResponse = new FofoCatalogResponse();
|
567 |
FofoCatalogResponse fofoCatalogResponse = new FofoCatalogResponse();
|
| 562 |
fofoCatalogResponse.setCatalogId(doc.getInt("catalogId_i"));
|
568 |
fofoCatalogResponse.setCatalogId(doc.getInt("catalogId_i"));
|
| 563 |
fofoCatalogResponse.setImageUrl(doc.getString("imageUrl_s"));
|
569 |
fofoCatalogResponse.setImageUrl(doc.getString("imageUrl_s"));
|
| 564 |
fofoCatalogResponse.setTitle(doc.getString("title_s"));
|
570 |
fofoCatalogResponse.setTitle(doc.getString("title_s"));
|
| - |
|
571 |
|
| - |
|
572 |
List<WebOffer> webOffers = webOfferRepository.selectAllActiveOffers()
|
| - |
|
573 |
.get(fofoCatalogResponse.getCatalogId());
|
| - |
|
574 |
if (webOffers != null && webOffers.size() > 0) {
|
| - |
|
575 |
fofoCatalogResponse.setOffers(webOffers.stream().map(x -> x.getTitle()).collect(Collectors.toList()));
|
| - |
|
576 |
}
|
| 565 |
try {
|
577 |
try {
|
| 566 |
fofoCatalogResponse.setFeature(doc.getString("feature_s"));
|
578 |
fofoCatalogResponse.setFeature(doc.getString("feature_s"));
|
| 567 |
} catch (Exception e) {
|
579 |
} catch (Exception e) {
|
| 568 |
fofoCatalogResponse.setFeature(null);
|
580 |
fofoCatalogResponse.setFeature(null);
|
| 569 |
logger.info("Could not find Feature_s for {}", fofoCatalogResponse.getCatalogId());
|
581 |
logger.info("Could not find Feature_s for {}", fofoCatalogResponse.getCatalogId());
|
| Line 572... |
Line 584... |
| 572 |
if (doc.has("_childDocuments_")) {
|
584 |
if (doc.has("_childDocuments_")) {
|
| 573 |
String modelColorClass = "grey";
|
585 |
String modelColorClass = "grey";
|
| 574 |
FofoAvailabilityInfo fdiAnyColour = null;
|
586 |
FofoAvailabilityInfo fdiAnyColour = null;
|
| 575 |
int allColorNetAvailability = 0;
|
587 |
int allColorNetAvailability = 0;
|
| 576 |
for (int j = 0; j < doc.getJSONArray("_childDocuments_").length(); j++) {
|
588 |
for (int j = 0; j < doc.getJSONArray("_childDocuments_").length(); j++) {
|
| 577 |
PriceCircularItemModel priceCircularItemModel = priceCircularItemModelMap.get(fofoCatalogResponse.getCatalogId());
|
589 |
PriceCircularItemModel priceCircularItemModel = priceCircularItemModelMap
|
| - |
|
590 |
.get(fofoCatalogResponse.getCatalogId());
|
| 578 |
JSONObject childItem = doc.getJSONArray("_childDocuments_").getJSONObject(j);
|
591 |
JSONObject childItem = doc.getJSONArray("_childDocuments_").getJSONObject(j);
|
| 579 |
int itemId = childItem.getInt("itemId_i");
|
592 |
int itemId = childItem.getInt("itemId_i");
|
| 580 |
float sellingPrice = (float) childItem.getDouble("sellingPrice_f");
|
593 |
float sellingPrice = (float) childItem.getDouble("sellingPrice_f");
|
| 581 |
if (fofoAvailabilityInfoMap.containsKey(itemId)) {
|
594 |
if (fofoAvailabilityInfoMap.containsKey(itemId)) {
|
| 582 |
if (fofoAvailabilityInfoMap.get(itemId).getSellingPrice() > sellingPrice) {
|
595 |
if (fofoAvailabilityInfoMap.get(itemId).getSellingPrice() > sellingPrice) {
|
| 583 |
fofoAvailabilityInfoMap.get(itemId).setSellingPrice(sellingPrice);
|
596 |
fofoAvailabilityInfoMap.get(itemId).setSellingPrice(sellingPrice);
|
| 584 |
fofoAvailabilityInfoMap.get(itemId).setMop((float) childItem.getDouble("mop_f"));
|
597 |
fofoAvailabilityInfoMap.get(itemId).setMop((float) childItem.getDouble("mop_f"));
|
| - |
|
598 |
fofoAvailabilityInfoMap.get(itemId)
|
| 585 |
fofoAvailabilityInfoMap.get(itemId).setNlc(priceCircularItemModel == null ? 0 : priceCircularItemModel.getNetPrice());
|
599 |
.setNlc(priceCircularItemModel == null ? 0 : priceCircularItemModel.getNetPrice());
|
| 586 |
}
|
600 |
}
|
| 587 |
} else {
|
601 |
} else {
|
| 588 |
FofoAvailabilityInfo fdi = new FofoAvailabilityInfo();
|
602 |
FofoAvailabilityInfo fdi = new FofoAvailabilityInfo();
|
| 589 |
List<SaholicCIS> currentAvailability = itemAvailabilityMap.get(itemId);
|
603 |
List<SaholicCIS> currentAvailability = itemAvailabilityMap.get(itemId);
|
| 590 |
List<SaholicPOItem> poItemAvailability = null;
|
604 |
List<SaholicPOItem> poItemAvailability = null;
|
| Line 656... |
Line 670... |
| 656 |
} else if (poItemAvailability != null && poItemAvailability.stream()
|
670 |
} else if (poItemAvailability != null && poItemAvailability.stream()
|
| 657 |
.collect(Collectors.summingInt(SaholicPOItem::getUnfulfilledQty)) > 0) {
|
671 |
.collect(Collectors.summingInt(SaholicPOItem::getUnfulfilledQty)) > 0) {
|
| 658 |
if (currentAvailability != null && poItemAvailability.stream()
|
672 |
if (currentAvailability != null && poItemAvailability.stream()
|
| 659 |
.collect(Collectors.summingInt(SaholicPOItem::getUnfulfilledQty))
|
673 |
.collect(Collectors.summingInt(SaholicPOItem::getUnfulfilledQty))
|
| 660 |
+ currentAvailability.stream()
|
674 |
+ currentAvailability.stream()
|
| 661 |
.collect(Collectors.summingInt(SaholicCIS::getNetavailability)) <= 0) {
|
675 |
.collect(Collectors.summingInt(SaholicCIS::getNetavailability)) <= 0) {
|
| 662 |
poColor = "grey";
|
676 |
poColor = "grey";
|
| 663 |
} else {
|
677 |
} else {
|
| 664 |
poColor = "yellow";
|
678 |
poColor = "yellow";
|
| 665 |
if (modelColorClass != "green") {
|
679 |
if (modelColorClass != "green") {
|
| 666 |
modelColorClass = poColor;
|
680 |
modelColorClass = poColor;
|
| Line 676... |
Line 690... |
| 676 |
if (fdi.getColor().equalsIgnoreCase("any colour")) {
|
690 |
if (fdi.getColor().equalsIgnoreCase("any colour")) {
|
| 677 |
fdiAnyColour = fdi;
|
691 |
fdiAnyColour = fdi;
|
| 678 |
}
|
692 |
}
|
| 679 |
fdi.setTagId(childItem.getInt("tagId_i"));
|
693 |
fdi.setTagId(childItem.getInt("tagId_i"));
|
| 680 |
fdi.setItem_id(itemId);
|
694 |
fdi.setItem_id(itemId);
|
| 681 |
Float cashBack = schemeService.getCatalogSchemeCashBack().get(fofoCatalogResponse.getCatalogId());
|
695 |
Float cashBack = schemeService.getCatalogSchemeCashBack()
|
| - |
|
696 |
.get(fofoCatalogResponse.getCatalogId());
|
| 682 |
cashBack = cashBack == null ? 0 : cashBack;
|
697 |
cashBack = cashBack == null ? 0 : cashBack;
|
| 683 |
fdi.setCashback(cashBack);
|
698 |
fdi.setCashback(cashBack);
|
| 684 |
fdi.setMinBuyQuantity(1);
|
699 |
fdi.setMinBuyQuantity(1);
|
| 685 |
if (hotDeal) {
|
700 |
if (hotDeal) {
|
| 686 |
if (currentAvailability != null) {
|
701 |
if (currentAvailability != null) {
|
| Line 688... |
Line 703... |
| 688 |
.collect(Collectors.summingInt(SaholicCIS::getNetavailability)));
|
703 |
.collect(Collectors.summingInt(SaholicCIS::getNetavailability)));
|
| 689 |
} else {
|
704 |
} else {
|
| 690 |
fdi.setAvailability(0);
|
705 |
fdi.setAvailability(0);
|
| 691 |
}
|
706 |
}
|
| 692 |
} else {
|
707 |
} else {
|
| 693 |
//Lets consider that its out of stock
|
708 |
// Lets consider that its out of stock
|
| 694 |
fdi.setAvailability(100);
|
709 |
fdi.setAvailability(100);
|
| 695 |
Item item = null;
|
710 |
Item item = null;
|
| 696 |
try {
|
711 |
try {
|
| 697 |
item = itemRepository.selectById(itemId);
|
712 |
item = itemRepository.selectById(itemId);
|
| 698 |
} catch (Exception e) {
|
713 |
} catch (Exception e) {
|
| Line 708... |
Line 723... |
| 708 |
fdi.setMaxQuantity(Math.min(fdi.getAvailability(), 100));
|
723 |
fdi.setMaxQuantity(Math.min(fdi.getAvailability(), 100));
|
| 709 |
fofoAvailabilityInfoMap.put(itemId, fdi);
|
724 |
fofoAvailabilityInfoMap.put(itemId, fdi);
|
| 710 |
}
|
725 |
}
|
| 711 |
}
|
726 |
}
|
| 712 |
if (fdiAnyColour != null) {
|
727 |
if (fdiAnyColour != null) {
|
| - |
|
728 |
/*
|
| 713 |
/*if (allColorNetAvailability <= 0) {
|
729 |
* if (allColorNetAvailability <= 0) { for (Map.Entry<Integer,
|
| 714 |
for (Map.Entry<Integer, FofoAvailabilityInfo> entry : fofoAvailabilityInfoMap.entrySet()) {
|
730 |
* FofoAvailabilityInfo> entry : fofoAvailabilityInfoMap.entrySet()) {
|
| 715 |
entry.getValue().setColorClass("grey");
|
731 |
* entry.getValue().setColorClass("grey"); } } else {
|
| 716 |
}
|
732 |
*
|
| 717 |
} else {
|
733 |
* }
|
| 718 |
|
- |
|
| 719 |
}*/
|
734 |
*/
|
| 720 |
fdiAnyColour.setColorClass(modelColorClass);
|
735 |
fdiAnyColour.setColorClass(modelColorClass);
|
| 721 |
}
|
736 |
}
|
| 722 |
}
|
737 |
}
|
| 723 |
if (fofoAvailabilityInfoMap.values().size() > 0) {
|
738 |
if (fofoAvailabilityInfoMap.values().size() > 0) {
|
| 724 |
List<FofoAvailabilityInfo> availabilityList = fofoAvailabilityInfoMap.values().stream()
|
739 |
List<FofoAvailabilityInfo> availabilityList = fofoAvailabilityInfoMap.values().stream()
|
| 725 |
.sorted(Comparator.comparing(FofoAvailabilityInfo::getAvailability).reversed())
|
740 |
.sorted(Comparator.comparing(FofoAvailabilityInfo::getAvailability).reversed())
|
| 726 |
.collect(Collectors.toList());
|
741 |
.collect(Collectors.toList());
|
| 727 |
fofoCatalogResponse.setItems(availabilityList);
|
742 |
fofoCatalogResponse.setItems(availabilityList);
|
| 728 |
if (priceCircularItemModelMap.containsKey(fofoCatalogResponse.getCatalogId())) {
|
743 |
if (priceCircularItemModelMap.containsKey(fofoCatalogResponse.getCatalogId())) {
|
| 729 |
PriceCircularItemModel priceCircularItemModel = priceCircularItemModelMap.get(fofoCatalogResponse.getCatalogId());
|
744 |
PriceCircularItemModel priceCircularItemModel = priceCircularItemModelMap
|
| - |
|
745 |
.get(fofoCatalogResponse.getCatalogId());
|
| 730 |
if (priceCircularItemModel.getSlabPayouts() != null) {
|
746 |
if (priceCircularItemModel.getSlabPayouts() != null) {
|
| 731 |
List<CreateOfferRequest> schemeOffers = new ArrayList<>();
|
747 |
List<CreateOfferRequest> schemeOffers = new ArrayList<>();
|
| 732 |
List<Map<Integer, Long>> slabPayouts = priceCircularItemModel.getSlabPayouts();
|
748 |
List<Map<Integer, Long>> slabPayouts = priceCircularItemModel.getSlabPayouts();
|
| 733 |
Iterator<Map<Integer, Long>> iterator = slabPayouts.iterator();
|
749 |
Iterator<Map<Integer, Long>> iterator = slabPayouts.iterator();
|
| 734 |
int iteratorCount = 0;
|
750 |
int iteratorCount = 0;
|
| Line 751... |
Line 767... |
| 751 |
return dealResponse;
|
767 |
return dealResponse;
|
| 752 |
|
768 |
|
| 753 |
}
|
769 |
}
|
| 754 |
|
770 |
|
| 755 |
private List<FofoCatalogResponse> getCatalogSingleSkuResponse(JSONArray docs, Map<Integer, Integer> itemFilter,
|
771 |
private List<FofoCatalogResponse> getCatalogSingleSkuResponse(JSONArray docs, Map<Integer, Integer> itemFilter,
|
| 756 |
boolean hotDeal) throws ProfitMandiBusinessException {
|
772 |
boolean hotDeal) throws ProfitMandiBusinessException {
|
| 757 |
Map<Integer, TagListing> itemTagListingMap = null;
|
773 |
Map<Integer, TagListing> itemTagListingMap = null;
|
| 758 |
List<FofoCatalogResponse> dealResponse = new ArrayList<>();
|
774 |
List<FofoCatalogResponse> dealResponse = new ArrayList<>();
|
| 759 |
List<Integer> tagIds = Arrays.asList(4);
|
775 |
List<Integer> tagIds = Arrays.asList(4);
|
| 760 |
|
776 |
|
| 761 |
itemTagListingMap = tagListingRepository.selectByItemIdsAndTagIds(itemFilter.keySet(), new HashSet<>(tagIds))
|
777 |
itemTagListingMap = tagListingRepository.selectByItemIdsAndTagIds(itemFilter.keySet(), new HashSet<>(tagIds))
|