| Line 43... |
Line 43... |
| 43 |
import com.mongodb.DBObject;
|
43 |
import com.mongodb.DBObject;
|
| 44 |
import com.spice.profitmandi.common.enumuration.SchemeType;
|
44 |
import com.spice.profitmandi.common.enumuration.SchemeType;
|
| 45 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
45 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
| 46 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
46 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
| 47 |
import com.spice.profitmandi.common.model.UserInfo;
|
47 |
import com.spice.profitmandi.common.model.UserInfo;
|
| - |
|
48 |
import com.spice.profitmandi.common.solr.SolrService;
|
| 48 |
import com.spice.profitmandi.common.web.client.RestClient;
|
49 |
import com.spice.profitmandi.common.web.client.RestClient;
|
| 49 |
import com.spice.profitmandi.common.web.util.ResponseSender;
|
50 |
import com.spice.profitmandi.common.web.util.ResponseSender;
|
| 50 |
import com.spice.profitmandi.dao.entity.catalog.Category;
|
51 |
import com.spice.profitmandi.dao.entity.catalog.Category;
|
| 51 |
import com.spice.profitmandi.dao.entity.catalog.Item;
|
52 |
import com.spice.profitmandi.dao.entity.catalog.Item;
|
| 52 |
import com.spice.profitmandi.dao.entity.catalog.TagListing;
|
53 |
import com.spice.profitmandi.dao.entity.catalog.TagListing;
|
| 53 |
import com.spice.profitmandi.dao.entity.fofo.SuggestedPo;
|
54 |
import com.spice.profitmandi.dao.entity.fofo.SuggestedPo;
|
| 54 |
import com.spice.profitmandi.dao.entity.fofo.SuggestedPoDetail;
|
55 |
import com.spice.profitmandi.dao.entity.fofo.SuggestedPoDetail;
|
| - |
|
56 |
import com.spice.profitmandi.dao.entity.inventory.SaholicCIS;
|
| 55 |
import com.spice.profitmandi.dao.model.UserCart;
|
57 |
import com.spice.profitmandi.dao.model.UserCart;
|
| 56 |
import com.spice.profitmandi.dao.repository.catalog.CategoryRepository;
|
58 |
import com.spice.profitmandi.dao.repository.catalog.CategoryRepository;
|
| 57 |
import com.spice.profitmandi.dao.repository.catalog.ItemRepository;
|
59 |
import com.spice.profitmandi.dao.repository.catalog.ItemRepository;
|
| 58 |
import com.spice.profitmandi.dao.repository.catalog.TagListingRepository;
|
60 |
import com.spice.profitmandi.dao.repository.catalog.TagListingRepository;
|
| - |
|
61 |
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
|
| 59 |
import com.spice.profitmandi.dao.repository.dtr.Mongo;
|
62 |
import com.spice.profitmandi.dao.repository.dtr.Mongo;
|
| 60 |
import com.spice.profitmandi.dao.repository.dtr.UserAccountRepository;
|
63 |
import com.spice.profitmandi.dao.repository.dtr.UserAccountRepository;
|
| 61 |
import com.spice.profitmandi.dao.repository.fofo.CurrentInventorySnapshotRepository;
|
64 |
import com.spice.profitmandi.dao.repository.fofo.CurrentInventorySnapshotRepository;
|
| 62 |
import com.spice.profitmandi.dao.repository.fofo.SuggestedPoDetailRepository;
|
65 |
import com.spice.profitmandi.dao.repository.fofo.SuggestedPoDetailRepository;
|
| 63 |
import com.spice.profitmandi.dao.repository.fofo.SuggestedPoRepository;
|
66 |
import com.spice.profitmandi.dao.repository.fofo.SuggestedPoRepository;
|
| 64 |
import com.spice.profitmandi.dao.repository.inventory.ItemAvailabilityCacheRepository;
|
- |
|
| 65 |
import com.spice.profitmandi.service.authentication.RoleManager;
|
67 |
import com.spice.profitmandi.service.authentication.RoleManager;
|
| 66 |
import com.spice.profitmandi.service.inventory.AvailabilityInfo;
|
68 |
import com.spice.profitmandi.service.inventory.AvailabilityInfo;
|
| 67 |
import com.spice.profitmandi.service.inventory.AvailabilityModel;
|
- |
|
| 68 |
import com.spice.profitmandi.service.inventory.Bucket;
|
69 |
import com.spice.profitmandi.service.inventory.Bucket;
|
| 69 |
import com.spice.profitmandi.service.inventory.FofoAvailabilityInfo;
|
70 |
import com.spice.profitmandi.service.inventory.FofoAvailabilityInfo;
|
| 70 |
import com.spice.profitmandi.service.inventory.FofoCatalogResponse;
|
71 |
import com.spice.profitmandi.service.inventory.FofoCatalogResponse;
|
| 71 |
import com.spice.profitmandi.service.inventory.InventoryService;
|
72 |
import com.spice.profitmandi.service.inventory.InventoryService;
|
| 72 |
import com.spice.profitmandi.service.inventory.ItemBucketService;
|
73 |
import com.spice.profitmandi.service.inventory.ItemBucketService;
|
| Line 97... |
Line 98... |
| 97 |
@Value("${python.api.port}")
|
98 |
@Value("${python.api.port}")
|
| 98 |
private int port;
|
99 |
private int port;
|
| 99 |
|
100 |
|
| 100 |
@Autowired
|
101 |
@Autowired
|
| 101 |
RestClient restClient;
|
102 |
RestClient restClient;
|
| - |
|
103 |
|
| - |
|
104 |
@Autowired
|
| - |
|
105 |
SolrService solrService;
|
| 102 |
|
106 |
|
| 103 |
@Autowired
|
107 |
@Autowired
|
| 104 |
InventoryService inventoryService;
|
108 |
InventoryService inventoryService;
|
| 105 |
|
109 |
|
| 106 |
// This is now unused as we are not supporting multiple companies.
|
110 |
// This is now unused as we are not supporting multiple companies.
|
| Line 128... |
Line 132... |
| 128 |
@Autowired
|
132 |
@Autowired
|
| 129 |
private ItemBucketService itemBucketService;
|
133 |
private ItemBucketService itemBucketService;
|
| 130 |
|
134 |
|
| 131 |
@Autowired
|
135 |
@Autowired
|
| 132 |
private UserAccountRepository userAccountRepository;
|
136 |
private UserAccountRepository userAccountRepository;
|
| 133 |
|
137 |
|
| 134 |
@Autowired
|
138 |
@Autowired
|
| 135 |
private ResponseSender<?> responseSender;
|
139 |
private FofoStoreRepository fofoStoreRepository;
|
| 136 |
|
140 |
|
| 137 |
@Autowired
|
141 |
@Autowired
|
| 138 |
private CategoryRepository repository;
|
142 |
private ResponseSender<?> responseSender;
|
| 139 |
|
143 |
|
| 140 |
@Autowired
|
144 |
@Autowired
|
| 141 |
private TagListingRepository tagListingRepository;
|
145 |
private TagListingRepository tagListingRepository;
|
| 142 |
|
146 |
|
| 143 |
@Autowired
|
147 |
@Autowired
|
| 144 |
private ItemRepository itemRepository;
|
148 |
private ItemRepository itemRepository;
|
| 145 |
|
149 |
|
| 146 |
@Autowired
|
150 |
@Autowired
|
| 147 |
private ItemAvailabilityCacheRepository itemAvailabilityCacheRepository;
|
- |
|
| 148 |
|
- |
|
| 149 |
@Autowired
|
- |
|
| 150 |
private RoleManager roleManagerService;
|
151 |
private RoleManager roleManagerService;
|
| 151 |
|
152 |
|
| - |
|
153 |
|
| 152 |
@Autowired
|
154 |
@Autowired
|
| 153 |
private SuggestedPoDetailRepository monthlyPoDetailRepository;
|
155 |
private SuggestedPoDetailRepository monthlyPoDetailRepository;
|
| 154 |
|
156 |
|
| 155 |
@Autowired
|
157 |
@Autowired
|
| 156 |
private SuggestedPoRepository suggestedPoRepository;
|
158 |
private SuggestedPoRepository suggestedPoRepository;
|
| Line 265... |
Line 267... |
| 265 |
@RequestParam(value = "subCategoryId", required = false) int subCategoryId,
|
267 |
@RequestParam(value = "subCategoryId", required = false) int subCategoryId,
|
| 266 |
@RequestParam(value = "q", required = false) String queryTerm,
|
268 |
@RequestParam(value = "q", required = false) String queryTerm,
|
| 267 |
@RequestParam(value = "hotDeal", required = false) boolean hotDeal) throws Throwable {
|
269 |
@RequestParam(value = "hotDeal", required = false) boolean hotDeal) throws Throwable {
|
| 268 |
List<FofoCatalogResponse> dealResponse = new ArrayList<>();
|
270 |
List<FofoCatalogResponse> dealResponse = new ArrayList<>();
|
| 269 |
UserInfo userInfo = (UserInfo) request.getAttribute("userInfo");
|
271 |
UserInfo userInfo = (UserInfo) request.getAttribute("userInfo");
|
| 270 |
dealResponse = this.getCatalogResponse(this.getSolrDocs(userInfo.getRetailerId(), queryTerm, categoryId, offset,
|
272 |
dealResponse = this.getCatalogResponse(solrService.getSolrDocs(queryTerm, categoryId, offset,
|
| 271 |
limit, sort, brand, subCategoryId, hotDeal), hotDeal, 0);
|
273 |
limit, sort, brand, subCategoryId, hotDeal), hotDeal, userInfo.getRetailerId());
|
| 272 |
return responseSender.ok(dealResponse);
|
274 |
return responseSender.ok(dealResponse);
|
| 273 |
}
|
275 |
}
|
| 274 |
|
276 |
|
| 275 |
private JSONArray getSolrDocs(int fofoId, String queryTerm, String categoryId, String offset, String limit,
|
277 |
/*private JSONArray getSolrDocs(int fofoId, String queryTerm, String categoryId, String offset, String limit,
|
| 276 |
String sort, String brand, int subCategoryId, boolean hotDeal) throws Throwable {
|
278 |
String sort, String brand, int subCategoryId, boolean hotDeal) throws Throwable {
|
| 277 |
List<Integer> tagIds = pricingService.getTagsIdsByRetailerId(fofoId);
|
279 |
List<Integer> tagIds = pricingService.getTagsIdsByRetailerId(fofoId);
|
| 278 |
List<String> parentFilter = new ArrayList<>();
|
280 |
List<String> parentFilter = new ArrayList<>();
|
| 279 |
parentFilter.add("categoryId_i:" + categoryId);
|
281 |
parentFilter.add("categoryId_i:" + categoryId);
|
| 280 |
|
282 |
|
| Line 282... |
Line 284... |
| 282 |
childFilter.add("itemId_i:*");
|
284 |
childFilter.add("itemId_i:*");
|
| 283 |
|
285 |
|
| 284 |
Map<String, String> params = new HashMap<>();
|
286 |
Map<String, String> params = new HashMap<>();
|
| 285 |
if (queryTerm == null || queryTerm.equals("null")) {
|
287 |
if (queryTerm == null || queryTerm.equals("null")) {
|
| 286 |
queryTerm = "";
|
288 |
queryTerm = "";
|
| - |
|
289 |
} else {
|
| - |
|
290 |
queryTerm = "(" + queryTerm + ")";
|
| 287 |
}
|
291 |
}
|
| 288 |
if (hotDeal) {
|
292 |
if (hotDeal) {
|
| 289 |
childFilter.add("hot_deal_b:true");
|
293 |
childFilter.add("hot_deal_b:true");
|
| 290 |
} else {
|
294 |
} else {
|
| 291 |
childFilter.add("active_b:true");
|
295 |
childFilter.add("active_b:true");
|
| Line 317... |
Line 321... |
| 317 |
throw new ProfitMandiBusinessException("", "", "Could not connect to host");
|
321 |
throw new ProfitMandiBusinessException("", "", "Could not connect to host");
|
| 318 |
}
|
322 |
}
|
| 319 |
JSONObject solrResponseJSONObj = new JSONObject(response).getJSONObject("response");
|
323 |
JSONObject solrResponseJSONObj = new JSONObject(response).getJSONObject("response");
|
| 320 |
JSONArray docs = solrResponseJSONObj.getJSONArray("docs");
|
324 |
JSONArray docs = solrResponseJSONObj.getJSONArray("docs");
|
| 321 |
return docs;
|
325 |
return docs;
|
| 322 |
}
|
326 |
}*/
|
| 323 |
|
327 |
|
| 324 |
@ApiImplicitParams({
|
328 |
@ApiImplicitParams({
|
| 325 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
|
329 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
|
| 326 |
@RequestMapping(value = "/partnerStock", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
330 |
@RequestMapping(value = "/partnerStock", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
| 327 |
public ResponseEntity<?> partnerStock(HttpServletRequest request,
|
331 |
public ResponseEntity<?> partnerStock(HttpServletRequest request,
|
| Line 334... |
Line 338... |
| 334 |
@RequestParam(value = " ", required = false, defaultValue = "true") boolean partnerStockOnly)
|
338 |
@RequestParam(value = " ", required = false, defaultValue = "true") boolean partnerStockOnly)
|
| 335 |
throws Throwable {
|
339 |
throws Throwable {
|
| 336 |
List<FofoCatalogResponse> dealResponse = new ArrayList<>();
|
340 |
List<FofoCatalogResponse> dealResponse = new ArrayList<>();
|
| 337 |
UserInfo userInfo = (UserInfo) request.getAttribute("userInfo");
|
341 |
UserInfo userInfo = (UserInfo) request.getAttribute("userInfo");
|
| 338 |
UserCart uc = userAccountRepository.getUserCart(userInfo.getUserId());
|
342 |
UserCart uc = userAccountRepository.getUserCart(userInfo.getUserId());
|
| 339 |
dealResponse = this.getCatalogResponse(this.getSolrDocs(uc.getUserId(), queryTerm, categoryId, offset, limit,
|
343 |
dealResponse = this.getCatalogResponse(solrService.getSolrDocs(queryTerm, categoryId, offset, limit,
|
| 340 |
sort, brand, subCategoryId, false), false, userInfo.getRetailerId());
|
344 |
sort, brand, subCategoryId, false), false, userInfo.getRetailerId());
|
| 341 |
return responseSender.ok(dealResponse);
|
345 |
return responseSender.ok(dealResponse);
|
| 342 |
}
|
346 |
}
|
| 343 |
|
347 |
|
| 344 |
@RequestMapping(value = "/online-deals", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
348 |
@RequestMapping(value = "/online-deals", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
| Line 457... |
Line 461... |
| 457 |
@RequestMapping(value = "/partnerdeals/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
461 |
@RequestMapping(value = "/partnerdeals/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
| 458 |
@ApiImplicitParams({
|
462 |
@ApiImplicitParams({
|
| 459 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
|
463 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
|
| 460 |
@ApiOperation(value = "Get unit deal object")
|
464 |
@ApiOperation(value = "Get unit deal object")
|
| 461 |
public ResponseEntity<?> getUnitFocoDeal(HttpServletRequest request, @PathVariable(value = "id") long id)
|
465 |
public ResponseEntity<?> getUnitFocoDeal(HttpServletRequest request, @PathVariable(value = "id") long id)
|
| 462 |
throws ProfitMandiBusinessException {
|
466 |
throws Exception {
|
| 463 |
List<FofoCatalogResponse> dealResponse = new ArrayList<>();
|
467 |
List<FofoCatalogResponse> dealResponse = new ArrayList<>();
|
| 464 |
List<Integer> tagIds = Arrays.asList(4);
|
468 |
List<Integer> tagIds = Arrays.asList(4);
|
| 465 |
UserInfo userInfo = (UserInfo) request.getAttribute("userInfo");
|
469 |
UserInfo userInfo = (UserInfo) request.getAttribute("userInfo");
|
| 466 |
if (roleManagerService.isPartner(userInfo.getRoleIds())) {
|
470 |
if (roleManagerService.isPartner(userInfo.getRoleIds())) {
|
| 467 |
String categoryId = "(3 OR 6)";
|
471 |
String categoryId = "(3 OR 6)";
|
| Line 591... |
Line 595... |
| 591 |
}
|
595 |
}
|
| 592 |
return responseSender.ok(responseObject);
|
596 |
return responseSender.ok(responseObject);
|
| 593 |
}
|
597 |
}
|
| 594 |
|
598 |
|
| 595 |
private List<FofoCatalogResponse> getCatalogResponse(JSONArray docs, boolean hotDeal, int fofoId)
|
599 |
private List<FofoCatalogResponse> getCatalogResponse(JSONArray docs, boolean hotDeal, int fofoId)
|
| 596 |
throws ProfitMandiBusinessException {
|
600 |
throws Exception {
|
| 597 |
List<FofoCatalogResponse> dealResponse = new ArrayList<>();
|
601 |
List<FofoCatalogResponse> dealResponse = new ArrayList<>();
|
| 598 |
List<Integer> tagIds = Arrays.asList(4);
|
602 |
List<Integer> tagIds = Arrays.asList(4);
|
| 599 |
List<Integer> itemIds = new ArrayList<>();
|
603 |
List<Integer> itemIds = new ArrayList<>();
|
| 600 |
if (docs.length() > 0) {
|
604 |
if (docs.length() > 0) {
|
| 601 |
for (int i = 0; i < docs.length(); i++) {
|
605 |
for (int i = 0; i < docs.length(); i++) {
|
| Line 610... |
Line 614... |
| 610 |
}
|
614 |
}
|
| 611 |
if (itemIds.size() == 0) {
|
615 |
if (itemIds.size() == 0) {
|
| 612 |
return dealResponse;
|
616 |
return dealResponse;
|
| 613 |
}
|
617 |
}
|
| 614 |
}
|
618 |
}
|
| 615 |
|
619 |
//get warehouse Id
|
| - |
|
620 |
int warehouseId = fofoStoreRepository.selectByRetailerId(fofoId).getWarehouseId();
|
| 616 |
Map<Integer, AvailabilityModel> itemAvailabilityMap = inventoryService.getStoreAndOurStock(fofoId, itemIds);
|
621 |
Map<Integer, SaholicCIS> itemAvailabilityMap = saholicInventoryService.getSaholicStock().get(warehouseId);
|
| 617 |
|
622 |
|
| 618 |
for (int i = 0; i < docs.length(); i++) {
|
623 |
for (int i = 0; i < docs.length(); i++) {
|
| 619 |
Map<Integer, FofoAvailabilityInfo> fofoAvailabilityInfoMap = new HashMap<>();
|
624 |
Map<Integer, FofoAvailabilityInfo> fofoAvailabilityInfoMap = new HashMap<>();
|
| 620 |
JSONObject doc = docs.getJSONObject(i);
|
625 |
JSONObject doc = docs.getJSONObject(i);
|
| 621 |
FofoCatalogResponse ffdr = new FofoCatalogResponse();
|
626 |
FofoCatalogResponse ffdr = new FofoCatalogResponse();
|
| Line 639... |
Line 644... |
| 639 |
fofoAvailabilityInfoMap.get(itemId).setSellingPrice(sellingPrice);
|
644 |
fofoAvailabilityInfoMap.get(itemId).setSellingPrice(sellingPrice);
|
| 640 |
fofoAvailabilityInfoMap.get(itemId).setMop((float) childItem.getDouble("mop_f"));
|
645 |
fofoAvailabilityInfoMap.get(itemId).setMop((float) childItem.getDouble("mop_f"));
|
| 641 |
}
|
646 |
}
|
| 642 |
} else {
|
647 |
} else {
|
| 643 |
FofoAvailabilityInfo fdi = new FofoAvailabilityInfo();
|
648 |
FofoAvailabilityInfo fdi = new FofoAvailabilityInfo();
|
| 644 |
AvailabilityModel currentAvailability = itemAvailabilityMap.get(itemId);
|
649 |
SaholicCIS currentAvailability = itemAvailabilityMap.get(itemId);
|
| 645 |
fdi.setSellingPrice(sellingPrice);
|
650 |
fdi.setSellingPrice(sellingPrice);
|
| 646 |
fdi.setActive(childItem.getBoolean("active_b"));
|
651 |
fdi.setActive(currentAvailability.getNetavailability() > 0);
|
| 647 |
fdi.setMrp(childItem.getDouble("mrp_f"));
|
652 |
fdi.setMrp(childItem.getDouble("mrp_f"));
|
| 648 |
fdi.setMop((float) childItem.getDouble("mop_f"));
|
653 |
fdi.setMop((float) childItem.getDouble("mop_f"));
|
| 649 |
fdi.setColor(childItem.has("color_s") ? childItem.getString("color_s") : "");
|
654 |
fdi.setColor(childItem.has("color_s") ? childItem.getString("color_s") : "");
|
| 650 |
fdi.setTagId(childItem.getInt("tagId_i"));
|
655 |
fdi.setTagId(childItem.getInt("tagId_i"));
|
| 651 |
fdi.setItem_id(itemId);
|
656 |
fdi.setItem_id(itemId);
|
| 652 |
Float cashBack = schemeService.getItemSchemeCashBack().get(itemId);
|
657 |
Float cashBack = schemeService.getItemSchemeCashBack().get(itemId);
|
| 653 |
cashBack = cashBack == null ? 0 : cashBack;
|
658 |
cashBack = cashBack == null ? 0 : cashBack;
|
| 654 |
fdi.setCashback(cashBack);
|
659 |
fdi.setCashback(cashBack);
|
| 655 |
fdi.setMinBuyQuantity(1);
|
660 |
fdi.setMinBuyQuantity(1);
|
| 656 |
if (hotDeal) {
|
661 |
if (hotDeal) {
|
| 657 |
fdi.setAvailability(currentAvailability.getWarehouseAvailability());
|
662 |
fdi.setAvailability(currentAvailability.getNetavailability());
|
| 658 |
} else if (fofoId == 0) {
|
663 |
} else {
|
| 659 |
// For accessories item availability should at be ordered for Rs.1000
|
- |
|
| 660 |
fdi.setAvailability(100);
|
664 |
fdi.setAvailability(100);
|
| 661 |
Item item = itemRepository.selectById(itemId);
|
665 |
Item item = itemRepository.selectById(itemId);
|
| 662 |
// In case its tampered glass moq should be 5
|
666 |
// In case its tampered glass moq should be 5
|
| 663 |
if (item.getCategoryId() == 10020) {
|
667 |
if (item.getCategoryId() == 10020) {
|
| 664 |
fdi.setMinBuyQuantity(5);
|
668 |
fdi.setMinBuyQuantity(5);
|
| 665 |
}
|
669 |
}
|
| 666 |
} else {
|
- |
|
| 667 |
fdi.setAvailability(currentAvailability.getMaxAvailability());
|
- |
|
| 668 |
}
|
670 |
}
|
| 669 |
fdi.setQuantityStep(1);
|
671 |
fdi.setQuantityStep(1);
|
| 670 |
fdi.setMaxQuantity(Math.min(fdi.getAvailability(), 100));
|
672 |
fdi.setMaxQuantity(Math.min(fdi.getAvailability(), 100));
|
| 671 |
fofoAvailabilityInfoMap.put(itemId, fdi);
|
673 |
fofoAvailabilityInfoMap.put(itemId, fdi);
|
| 672 |
}
|
674 |
}
|