| Line 28... |
Line 28... |
| 28 |
import com.spice.profitmandi.dao.model.UserCart;
|
28 |
import com.spice.profitmandi.dao.model.UserCart;
|
| 29 |
import com.spice.profitmandi.dao.repository.catalog.*;
|
29 |
import com.spice.profitmandi.dao.repository.catalog.*;
|
| 30 |
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
|
30 |
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
|
| 31 |
import com.spice.profitmandi.dao.repository.dtr.Mongo;
|
31 |
import com.spice.profitmandi.dao.repository.dtr.Mongo;
|
| 32 |
import com.spice.profitmandi.dao.repository.dtr.UserAccountRepository;
|
32 |
import com.spice.profitmandi.dao.repository.dtr.UserAccountRepository;
|
| - |
|
33 |
import com.spice.profitmandi.dao.repository.dtr.WebListingRepository;
|
| 33 |
import com.spice.profitmandi.dao.repository.dtr.WebOfferRepository;
|
34 |
import com.spice.profitmandi.dao.repository.dtr.WebOfferRepository;
|
| - |
|
35 |
import com.spice.profitmandi.dao.repository.dtr.WebProductListingRepository;
|
| 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.dao.repository.inventory.SaholicCISTableRepository;
|
38 |
import com.spice.profitmandi.dao.repository.inventory.SaholicCISTableRepository;
|
| 37 |
import com.spice.profitmandi.service.authentication.RoleManager;
|
39 |
import com.spice.profitmandi.service.authentication.RoleManager;
|
| 38 |
import com.spice.profitmandi.service.catalog.BrandsService;
|
40 |
import com.spice.profitmandi.service.catalog.BrandsService;
|
| Line 74... |
Line 76... |
| 74 |
@Controller
|
76 |
@Controller
|
| 75 |
@Transactional(rollbackFor = Throwable.class)
|
77 |
@Transactional(rollbackFor = Throwable.class)
|
| 76 |
public class DealsController {
|
78 |
public class DealsController {
|
| 77 |
|
79 |
|
| 78 |
private static final Logger logger = LogManager.getLogger(DealsController.class);
|
80 |
private static final Logger logger = LogManager.getLogger(DealsController.class);
|
| - |
|
81 |
private static final List<Integer> TAG_IDS = Arrays.asList(4);
|
| 79 |
|
82 |
|
| 80 |
@Value("${python.api.host}")
|
83 |
@Value("${python.api.host}")
|
| 81 |
private String host;
|
84 |
private String host;
|
| 82 |
|
85 |
|
| 83 |
@Value("${new.solr.url}")
|
86 |
@Value("${new.solr.url}")
|
| Line 152... |
Line 155... |
| 152 |
@Autowired
|
155 |
@Autowired
|
| 153 |
private ComboMappedModelRepository comboMappedModelRepository;
|
156 |
private ComboMappedModelRepository comboMappedModelRepository;
|
| 154 |
|
157 |
|
| 155 |
@Autowired
|
158 |
@Autowired
|
| 156 |
private BrandsService brandsService;
|
159 |
private BrandsService brandsService;
|
| - |
|
160 |
|
| - |
|
161 |
@Autowired
|
| - |
|
162 |
private WebListingRepository webListingRepository;
|
| - |
|
163 |
|
| - |
|
164 |
@Autowired
|
| - |
|
165 |
private WebProductListingRepository webProductListingRepository;
|
| - |
|
166 |
|
| 157 |
List<String> filterableParams = Arrays.asList("brand");
|
167 |
List<String> filterableParams = Arrays.asList("brand");
|
| 158 |
|
168 |
|
| 159 |
@RequestMapping(value = "/fofo/buckets", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
169 |
@RequestMapping(value = "/fofo/buckets", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
| 160 |
public ResponseEntity<?> getBuckets(HttpServletRequest request) throws ProfitMandiBusinessException {
|
170 |
public ResponseEntity<?> getBuckets(HttpServletRequest request) throws ProfitMandiBusinessException {
|
| 161 |
logger.info("Request " + request.getParameterMap());
|
171 |
logger.info("Request " + request.getParameterMap());
|
| Line 535... |
Line 545... |
| 535 |
}
|
545 |
}
|
| 536 |
}
|
546 |
}
|
| 537 |
return responseSender.ok(responseObject);
|
547 |
return responseSender.ok(responseObject);
|
| 538 |
}
|
548 |
}
|
| 539 |
|
549 |
|
| - |
|
550 |
@RequestMapping(value = "/partner/listing", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
| - |
|
551 |
public ResponseEntity<?> getPartnersListing(HttpServletRequest request) throws Exception {
|
| - |
|
552 |
List<WebListing> webListings = webListingRepository.selectAllWebListingByType(Optional.of(true),
|
| - |
|
553 |
WebListingType.partner);
|
| - |
|
554 |
UserInfo userInfo = (UserInfo) request.getAttribute("userInfo");
|
| - |
|
555 |
for (WebListing webListing : webListings) {
|
| - |
|
556 |
webListing.setFofoCatalogResponses(getDealResponses(userInfo, webListing));
|
| - |
|
557 |
}
|
| - |
|
558 |
return responseSender.ok(webListings);
|
| - |
|
559 |
}
|
| - |
|
560 |
|
| - |
|
561 |
private List<FofoCatalogResponse> getDealResponses(UserInfo userInfo, WebListing webListing)
|
| - |
|
562 |
throws Exception {
|
| - |
|
563 |
List<Integer> webProducts = webProductListingRepository.selectAllByWebListingId(webListing.getId()).stream()
|
| - |
|
564 |
.filter(x -> x.getRank() > 0).map(x -> x.getEntityId()).collect(Collectors.toList());
|
| - |
|
565 |
if (webProducts.size() == 0) {
|
| - |
|
566 |
return new ArrayList<>();
|
| - |
|
567 |
}
|
| - |
|
568 |
RestClient rc = new RestClient();
|
| - |
|
569 |
Map<String, String> params = new HashMap<>();
|
| - |
|
570 |
List<String> mandatoryQ = new ArrayList<>();
|
| - |
|
571 |
mandatoryQ.add(String.format(
|
| - |
|
572 |
"+{!parent which=\"catalogId_i:" + StringUtils.join(webProducts, " ") + "\"} tagId_i:(%s)",
|
| - |
|
573 |
StringUtils.join(TAG_IDS, " ")));
|
| - |
|
574 |
params.put("q", StringUtils.join(mandatoryQ, " "));
|
| - |
|
575 |
params.put("fl", "*, [child parentFilter=id:catalog*]");
|
| - |
|
576 |
// params.put("sort", "create_s desc");
|
| - |
|
577 |
params.put("start", String.valueOf(0));
|
| - |
|
578 |
params.put("rows", String.valueOf(100));
|
| - |
|
579 |
params.put("wt", "json");
|
| - |
|
580 |
String response = null;
|
| - |
|
581 |
try {
|
| - |
|
582 |
response = rc.get(SchemeType.HTTP, "50.116.10.120", 8984, "solr/demo/select", params);
|
| - |
|
583 |
} catch (HttpHostConnectException e) {
|
| - |
|
584 |
throw new ProfitMandiBusinessException("", "", "Could not connect to host");
|
| - |
|
585 |
}
|
| - |
|
586 |
JSONObject solrResponseJSONObj = new JSONObject(response).getJSONObject("response");
|
| - |
|
587 |
JSONArray docs = solrResponseJSONObj.getJSONArray("docs");
|
| - |
|
588 |
List<FofoCatalogResponse> dealResponse = getCatalogResponse(docs, false, userInfo.getRetailerId());
|
| - |
|
589 |
return dealResponse;
|
| - |
|
590 |
}
|
| - |
|
591 |
|
| 540 |
@Autowired
|
592 |
@Autowired
|
| 541 |
private SaholicCISTableRepository saholicCISTableRepository;
|
593 |
private SaholicCISTableRepository saholicCISTableRepository;
|
| 542 |
|
594 |
|
| 543 |
private List<FofoCatalogResponse> getCatalogResponse(JSONArray docs, boolean hotDeal, int fofoId) throws Exception {
|
595 |
private List<FofoCatalogResponse> getCatalogResponse(JSONArray docs, boolean hotDeal, int fofoId) throws Exception {
|
| 544 |
List<FofoCatalogResponse> dealResponse = new ArrayList<>();
|
596 |
List<FofoCatalogResponse> dealResponse = new ArrayList<>();
|