| Line 17... |
Line 17... |
| 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.*;
|
18 |
import com.spice.profitmandi.dao.entity.catalog.*;
|
| 19 |
import com.spice.profitmandi.dao.entity.dtr.WebListing;
|
19 |
import com.spice.profitmandi.dao.entity.dtr.WebListing;
|
| 20 |
import com.spice.profitmandi.dao.entity.dtr.WebOffer;
|
20 |
import com.spice.profitmandi.dao.entity.dtr.WebOffer;
|
| 21 |
import com.spice.profitmandi.dao.entity.dtr.WebProductListing;
|
21 |
import com.spice.profitmandi.dao.entity.dtr.WebProductListing;
|
| - |
|
22 |
import com.spice.profitmandi.dao.entity.fofo.CatalogFavourite;
|
| 22 |
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
|
23 |
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
|
| 23 |
import com.spice.profitmandi.dao.entity.fofo.SuggestedPo;
|
24 |
import com.spice.profitmandi.dao.entity.fofo.SuggestedPo;
|
| 24 |
import com.spice.profitmandi.dao.entity.fofo.SuggestedPoDetail;
|
25 |
import com.spice.profitmandi.dao.entity.fofo.SuggestedPoDetail;
|
| 25 |
import com.spice.profitmandi.dao.entity.inventory.SaholicCISTable;
|
26 |
import com.spice.profitmandi.dao.entity.inventory.SaholicCISTable;
|
| 26 |
import com.spice.profitmandi.dao.entity.inventory.SaholicPOItem;
|
27 |
import com.spice.profitmandi.dao.entity.inventory.SaholicPOItem;
|
| Line 33... |
Line 34... |
| 33 |
import com.spice.profitmandi.dao.repository.dtr.Mongo;
|
34 |
import com.spice.profitmandi.dao.repository.dtr.Mongo;
|
| 34 |
import com.spice.profitmandi.dao.repository.dtr.UserAccountRepository;
|
35 |
import com.spice.profitmandi.dao.repository.dtr.UserAccountRepository;
|
| 35 |
import com.spice.profitmandi.dao.repository.dtr.WebListingRepository;
|
36 |
import com.spice.profitmandi.dao.repository.dtr.WebListingRepository;
|
| 36 |
import com.spice.profitmandi.dao.repository.dtr.WebOfferRepository;
|
37 |
import com.spice.profitmandi.dao.repository.dtr.WebOfferRepository;
|
| 37 |
import com.spice.profitmandi.dao.repository.dtr.WebProductListingRepository;
|
38 |
import com.spice.profitmandi.dao.repository.dtr.WebProductListingRepository;
|
| - |
|
39 |
import com.spice.profitmandi.dao.repository.fofo.CatalogFavouriteRepository;
|
| 38 |
import com.spice.profitmandi.dao.repository.fofo.SuggestedPoDetailRepository;
|
40 |
import com.spice.profitmandi.dao.repository.fofo.SuggestedPoDetailRepository;
|
| 39 |
import com.spice.profitmandi.dao.repository.fofo.SuggestedPoRepository;
|
41 |
import com.spice.profitmandi.dao.repository.fofo.SuggestedPoRepository;
|
| 40 |
import com.spice.profitmandi.dao.repository.inventory.SaholicCISTableRepository;
|
42 |
import com.spice.profitmandi.dao.repository.inventory.SaholicCISTableRepository;
|
| 41 |
import com.spice.profitmandi.service.authentication.RoleManager;
|
43 |
import com.spice.profitmandi.service.authentication.RoleManager;
|
| 42 |
import com.spice.profitmandi.service.catalog.BrandsService;
|
44 |
import com.spice.profitmandi.service.catalog.BrandsService;
|
| Line 69... |
Line 71... |
| 69 |
import org.springframework.web.bind.annotation.RequestMapping;
|
71 |
import org.springframework.web.bind.annotation.RequestMapping;
|
| 70 |
import org.springframework.web.bind.annotation.RequestMethod;
|
72 |
import org.springframework.web.bind.annotation.RequestMethod;
|
| 71 |
import org.springframework.web.bind.annotation.RequestParam;
|
73 |
import org.springframework.web.bind.annotation.RequestParam;
|
| 72 |
|
74 |
|
| 73 |
import javax.servlet.http.HttpServletRequest;
|
75 |
import javax.servlet.http.HttpServletRequest;
|
| - |
|
76 |
|
| - |
|
77 |
import java.time.LocalDateTime;
|
| 74 |
import java.util.*;
|
78 |
import java.util.*;
|
| 75 |
import java.util.concurrent.atomic.AtomicInteger;
|
79 |
import java.util.concurrent.atomic.AtomicInteger;
|
| 76 |
import java.util.stream.Collectors;
|
80 |
import java.util.stream.Collectors;
|
| 77 |
|
81 |
|
| 78 |
@Controller
|
82 |
@Controller
|
| Line 164... |
Line 168... |
| 164 |
private WebListingRepository webListingRepository;
|
168 |
private WebListingRepository webListingRepository;
|
| 165 |
|
169 |
|
| 166 |
@Autowired
|
170 |
@Autowired
|
| 167 |
private WebProductListingRepository webProductListingRepository;
|
171 |
private WebProductListingRepository webProductListingRepository;
|
| 168 |
|
172 |
|
| - |
|
173 |
@Autowired
|
| - |
|
174 |
private CatalogFavouriteRepository catalogFavouriteRepository;
|
| - |
|
175 |
|
| 169 |
List<String> filterableParams = Arrays.asList("brand");
|
176 |
List<String> filterableParams = Arrays.asList("brand");
|
| 170 |
|
177 |
|
| 171 |
@RequestMapping(value = "/fofo/buckets", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
178 |
@RequestMapping(value = "/fofo/buckets", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
| 172 |
public ResponseEntity<?> getBuckets(HttpServletRequest request) throws ProfitMandiBusinessException {
|
179 |
public ResponseEntity<?> getBuckets(HttpServletRequest request) throws ProfitMandiBusinessException {
|
| 173 |
logger.info("Request " + request.getParameterMap());
|
180 |
logger.info("Request " + request.getParameterMap());
|
| Line 253... |
Line 260... |
| 253 |
suggestedPo.setStatus("closed");
|
260 |
suggestedPo.setStatus("closed");
|
| 254 |
|
261 |
|
| 255 |
return responseSender.ok(true);
|
262 |
return responseSender.ok(true);
|
| 256 |
}
|
263 |
}
|
| 257 |
|
264 |
|
| - |
|
265 |
@RequestMapping(value = "/fofo/fovourites", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
| - |
|
266 |
public ResponseEntity<?> getFavourites(HttpServletRequest request, @RequestParam int fofoId) throws Exception {
|
| - |
|
267 |
|
| - |
|
268 |
Set<Integer> catalogIds = catalogFavouriteRepository.selectBypartnerId(fofoId).stream()
|
| - |
|
269 |
.map(x -> x.getCatatlogId()).collect(Collectors.toSet());
|
| - |
|
270 |
RestClient rc = new RestClient();
|
| - |
|
271 |
Map<String, String> params = new HashMap<>();
|
| - |
|
272 |
List<String> mandatoryQ = new ArrayList<>();
|
| - |
|
273 |
mandatoryQ.add(
|
| - |
|
274 |
String.format("+catalogId_i:(%s) +{!parent which=\"id:catalog*\"}", StringUtils.join(catalogIds, " ")));
|
| - |
|
275 |
params.put("start", "0");
|
| - |
|
276 |
params.put("rows", "100");
|
| - |
|
277 |
params.put("q", StringUtils.join(mandatoryQ, " "));
|
| - |
|
278 |
params.put("fl", "*, [child parentFilter=id:catalog*]");
|
| - |
|
279 |
|
| - |
|
280 |
params.put("wt", "json");
|
| - |
|
281 |
String response = null;
|
| - |
|
282 |
try {
|
| - |
|
283 |
response = rc.get(SchemeType.HTTP, solrUrl, 8984, "solr/demo/select", params);
|
| - |
|
284 |
} catch (HttpHostConnectException e) {
|
| - |
|
285 |
throw new ProfitMandiBusinessException("", "", "Could not connect to host");
|
| - |
|
286 |
}
|
| - |
|
287 |
JSONObject solrResponseJSONObj = new JSONObject(response).getJSONObject("response");
|
| - |
|
288 |
JSONArray docs = solrResponseJSONObj.getJSONArray("docs");
|
| - |
|
289 |
List<FofoCatalogResponse> dealResponse = getCatalogResponse(docs, false, fofoId);
|
| - |
|
290 |
|
| - |
|
291 |
return responseSender.ok(dealResponse);
|
| - |
|
292 |
}
|
| - |
|
293 |
|
| - |
|
294 |
@RequestMapping(value = "/favourites/manage", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
|
| - |
|
295 |
@ApiImplicitParams({
|
| - |
|
296 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
|
| - |
|
297 |
@ApiOperation(value = "")
|
| - |
|
298 |
public ResponseEntity<?> mangeFavourites(HttpServletRequest request, @RequestParam int catalogId)
|
| - |
|
299 |
throws ProfitMandiBusinessException {
|
| - |
|
300 |
|
| - |
|
301 |
int userId = (int) request.getAttribute("userId");
|
| - |
|
302 |
UserCart uc = userAccountRepository.getUserCart(userId);
|
| - |
|
303 |
int fofoId = uc.getUserId();
|
| - |
|
304 |
|
| - |
|
305 |
CatalogFavourite catalogFavourite = catalogFavouriteRepository.selectBypartnerAndCatalogId(fofoId, catalogId);
|
| - |
|
306 |
|
| - |
|
307 |
if (catalogFavourite == null) {
|
| - |
|
308 |
catalogFavourite = new CatalogFavourite();
|
| - |
|
309 |
catalogFavourite.setCatatlogId(catalogId);
|
| - |
|
310 |
catalogFavourite.setFofoId(fofoId);
|
| - |
|
311 |
catalogFavourite.setCreatedTimestamp(LocalDateTime.now());
|
| - |
|
312 |
catalogFavouriteRepository.persist(catalogFavourite);
|
| - |
|
313 |
|
| - |
|
314 |
}
|
| - |
|
315 |
|
| - |
|
316 |
else {
|
| - |
|
317 |
catalogFavouriteRepository.deleteByPartnerAndCatalogId(fofoId, catalogId);
|
| - |
|
318 |
}
|
| - |
|
319 |
return responseSender.ok(true);
|
| - |
|
320 |
}
|
| - |
|
321 |
|
| 258 |
private String getCommaSeparateTags(int userId) {
|
322 |
private String getCommaSeparateTags(int userId) {
|
| 259 |
UserCart uc = userAccountRepository.getUserCart(userId);
|
323 |
UserCart uc = userAccountRepository.getUserCart(userId);
|
| 260 |
List<Integer> tagIds = pricingService.getTagsIdsByRetailerId(uc.getUserId());
|
324 |
List<Integer> tagIds = pricingService.getTagsIdsByRetailerId(uc.getUserId());
|
| 261 |
List<String> strTagIds = new ArrayList<>();
|
325 |
List<String> strTagIds = new ArrayList<>();
|
| 262 |
for (Integer tagId : tagIds) {
|
326 |
for (Integer tagId : tagIds) {
|
| Line 576... |
Line 640... |
| 576 |
|
640 |
|
| 577 |
RestClient rc = new RestClient();
|
641 |
RestClient rc = new RestClient();
|
| 578 |
Map<String, String> params = new HashMap<>();
|
642 |
Map<String, String> params = new HashMap<>();
|
| 579 |
List<String> mandatoryQ = new ArrayList<>();
|
643 |
List<String> mandatoryQ = new ArrayList<>();
|
| 580 |
mandatoryQ.add("show_default_b:true");
|
644 |
mandatoryQ.add("show_default_b:true");
|
| 581 |
|
645 |
|
| 582 |
List<Integer> webProducts = null;
|
646 |
List<Integer> webProducts = null;
|
| 583 |
if (webListing.getType().equals(WebListingType.solr)) {
|
647 |
if (webListing.getType().equals(WebListingType.solr)) {
|
| 584 |
logger.info("solrtype {}", webListing.getSolrQuery());
|
648 |
logger.info("solrtype {}", webListing.getSolrQuery());
|
| 585 |
mandatoryQ.add(String.format("+{!parent which=\"" + webListing.getSolrQuery() + "\"} AND active_b:true"));
|
649 |
mandatoryQ.add(String.format("+{!parent which=\"" + webListing.getSolrQuery() + "\"} AND active_b:true"));
|
| 586 |
|
650 |
|
| Line 742... |
Line 806... |
| 742 |
if (poItemAvailabilityMap != null) {
|
806 |
if (poItemAvailabilityMap != null) {
|
| 743 |
poItemAvailability = poItemAvailabilityMap.get(itemId);
|
807 |
poItemAvailability = poItemAvailabilityMap.get(itemId);
|
| 744 |
}
|
808 |
}
|
| 745 |
fdi.setNlc(priceCircularItemModel == null ? 0 : priceCircularItemModel.getNetPrice());
|
809 |
fdi.setNlc(priceCircularItemModel == null ? 0 : priceCircularItemModel.getNetPrice());
|
| 746 |
|
810 |
|
| - |
|
811 |
fdi.setNlc(fdi.getNlc() == 0 ? sellingPrice : priceCircularItemModel.getNetPrice());
|
| - |
|
812 |
|
| 747 |
for (SaholicCISTable saholicCISTable : currentAvailability) {
|
813 |
for (SaholicCISTable saholicCISTable : currentAvailability) {
|
| 748 |
saholicCISTable.setWarehouseName(
|
814 |
saholicCISTable.setWarehouseName(
|
| 749 |
ProfitMandiConstants.WAREHOUSE_MAP.get(saholicCISTable.getWarehouseFrom()));
|
815 |
ProfitMandiConstants.WAREHOUSE_MAP.get(saholicCISTable.getWarehouseFrom()));
|
| 750 |
}
|
816 |
}
|
| 751 |
|
817 |
|