Authored by mali

NFC分享页列表接口

... ... @@ -232,7 +232,16 @@ public class ProductSearchController {
return new ApiResponse.ApiResponseBuilder().code(200).message("product.search.hotSale").data(resp).build();
}
/**
* 首页 推荐商品最前面20个
* NFC分享后的页面 商品列表接口
* @param rankType
* @param limit
* @param page
* @param regulariz 如果传1 代表返回的商品列表 需要是3的倍数
* @return
*/
@ApiOperation(name = "ufo.product.search.uvscoreProductList", desc="首页商品推荐")
@RequestMapping(params = "method=ufo.product.search.uvscoreProductList")
@IgnoreSession
... ... @@ -240,12 +249,13 @@ public class ProductSearchController {
public ApiResponse searchUvscoreProductList(
@RequestParam(value = "rankType", required = false, defaultValue = "a") String rankType,
@RequestParam(value = "limit", required = false)Integer limit,
@RequestParam(value = "page", required = false)Integer page) {
@RequestParam(value = "page", required = false, defaultValue = "20")Integer page,
@RequestParam(value = "regularize", required = false)Integer regularize) {
ProductSearchReq req = new ProductSearchReq().setViewNum(limit).setPage(page).setRankType(rankType);
LOG.info("in method=ufo.product.search.uvscoreProductList req={}", req.toString());
JSONObject resp = productSearchService.searchUvscoreProductList(req);
JSONObject resp = productSearchService.searchUvscoreProductList(req, regularize);
if (resp != null) {
resp.put("rec_id", UUID.randomUUID());
}
... ...
... ... @@ -37,7 +37,7 @@ public interface ProductSearchService {
JSONObject getSaleCalendarCountData();
JSONObject getNewSaleCalendarCountData(String type);
JSONObject searchUvscoreProductList(ProductSearchReq req);
JSONObject searchUvscoreProductList(ProductSearchReq req, Integer regularize);
JSONObject searchSuggest(ProductSearchReq req);
... ...
... ... @@ -56,6 +56,9 @@ public class ProductSearchServiceImpl implements ProductSearchService {
private static Logger logger = LoggerFactory.getLogger(ProductSearchServiceImpl.class);
// 如果是NFC分享页面列表,则传1
private final static Integer REGULARIZE_NFC = 1;
@Value("${ip.port.search.server}")
private String searchServerIpAndPort;
... ... @@ -670,18 +673,36 @@ public class ProductSearchServiceImpl implements ProductSearchService {
}
@Override
public JSONObject searchUvscoreProductList(ProductSearchReq req) {
public JSONObject searchUvscoreProductList(ProductSearchReq req, Integer regularize) {
SearchParam searchParam = new SearchParam().buildPageSearchParam(req);
String url = PRODUCT_UVSCORE_LIST_URL;
JSONObject data = search(searchParam.getParam(), url);
// 将图片的相对路径转成绝对路径
if (null != data) {
processProductList(data.getJSONArray("product_list"));
processProductSales(data.getJSONArray("product_list"));
if (REGULARIZE_NFC.equals(regularize)) { // NFC分享页列表 需要返回 3的倍数的列表
regularize(data.getJSONArray("product_list"));
} else {
processProductSales(data.getJSONArray("product_list")); // NFC分享页列表不需要销量
}
}
return data;
}
private void regularize(JSONArray productList) {
if(CollectionUtils.isEmpty(productList)){
return;
}
if (productList.size() % 3 == 1) {
productList.remove(productList.size() - 1);
} else if (productList.size() % 3 == 2) {
productList.remove(productList.size() - 1);
productList.remove(productList.size() - 2);
}
}
private CouponInfo getCouponInfo(String token) {
ApiResponse resp = ufoServiceCaller.call("ufo.coupons.getProductIds", ApiResponse.class, token);
return (CouponInfo) resp.getData();
... ...