Authored by mali

Merge branch 'test6.9.16' of http://git.yoho.cn/ufo/yohoufo-fore into test6.9.16

Conflicts:
	product/src/main/java/com/yohoufo/product/service/ProductSearchService.java
	product/src/main/java/com/yohoufo/product/service/impl/ProductSearchServiceImpl.java
... ... @@ -34,4 +34,6 @@ public interface ProductSearchConstants {
String SUGGEST_URL = "/yohosearch/ufo/suggest.json";
String PRODUCT_RECOMMEND_BY_SERIESBRAND_LIST_URL = "/yohosearch/ufo/recommendBySeriesBrandList.json";
String SECONDHAND_SKUP_QUERY_URL = "/yohosearch/ufo/secondHand/skupList.json";
}
... ...
... ... @@ -353,4 +353,17 @@ public class ProductSearchController {
return new ApiResponse.ApiResponseBuilder().code(200).message("product.data.search.recommendBySeriesBrand").data(resp).build();
}
@ApiOperation(name = "ufo.product.search.secondhand.skupList", desc="二手商品搜索列表")
@RequestMapping(params = "method=ufo.product.search.secondhand.skupList")
@IgnoreSession
@Cachable(expire = 600)
public ApiResponse searchSecondhandSkupList(@RequestParam(value = "preSale_flag", required = false)Integer preSaleFlag,
@RequestParam(value = "limit", required = false)Integer limit,
@RequestParam(value = "page", required = false)Integer page) {
LOG.info("in method=ufo.product.search.secondhand.skupList preSale_flag={}", preSaleFlag);
ProductSearchReq req = new ProductSearchReq().setViewNum(limit).setPage(page).setPreSaleFlag(preSaleFlag);
JSONObject resp = productSearchService.searchSecondhandSkupList(req);
return new ApiResponse.ApiResponseBuilder().code(200).message("secondhand skupList.").data(resp).build();
}
}
\ No newline at end of file
... ...
... ... @@ -28,10 +28,8 @@ public class ProductSearchReq {
private String couponToken;
private String excludeLimit; // 过滤限售的商品
private String not_brand;
private String businessClient;
private Integer preSaleFlag;
@Override
public String toString() {
... ... @@ -56,6 +54,7 @@ public class ProductSearchReq {
.append("endTime",endTime)
.append("contain_yoho",containYoho)
.append("businessClient",businessClient)
.append("preSaleFlag", preSaleFlag)
.toString();
}
... ... @@ -287,4 +286,16 @@ public class ProductSearchReq {
this.businessClient = businessClient;
return this;
}
public Integer getPreSaleFlag() {
return preSaleFlag;
}
public ProductSearchReq setPreSaleFlag(Integer preSaleFlag) {
this.preSaleFlag = preSaleFlag;
return this;
}
}
... ...
... ... @@ -3,9 +3,7 @@ package com.yohoufo.product.service;
import java.util.List;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yohoufo.common.cache.Cachable;
import com.yohoufo.product.request.ProductSearchReq;
import com.yohoufo.product.request.SortIdLevel;
import com.yohoufo.product.response.ProductBrandSeriesResp;
... ... @@ -45,4 +43,6 @@ public interface ProductSearchService {
SearchProductRecommendResp searchProductRecommendByIdAndSeriesBrand(Integer productId, String businessClient);
JSONObject searchSecondhandSkupList(ProductSearchReq req);
}
... ...
... ... @@ -8,7 +8,6 @@ import java.util.Comparator;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;
import com.yoho.core.config.ConfigReader;
... ... @@ -31,17 +30,19 @@ import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.google.common.collect.Lists;
import com.yoho.core.common.utils.DateUtil;
import com.yoho.core.config.ConfigReader;
import com.yoho.core.rest.client.ServiceCaller;
import com.yoho.core.rest.exception.ServiceNotAvaibleException;
import com.yohobuy.ufo.model.promotion.response.CouponInfo;
import com.yohoufo.common.ApiResponse;
import com.yohoufo.common.cache.Cachable;
import com.yohoufo.common.caller.UfoServiceCaller;
import com.yohoufo.common.helper.ImageUrlAssist;
import com.yohoufo.common.utils.UfoStringUtils;
import com.yohoufo.dal.product.BrandMapper;
import com.yohoufo.dal.product.ProductMapper;
import com.yohoufo.dal.product.ProductSalesMapper;
import com.yohoufo.dal.product.ProductSortMapper;
import com.yohoufo.dal.product.model.Product;
import com.yohoufo.dal.product.model.ProductSales;
import com.yohoufo.dal.product.model.ProductSort;
import com.yohoufo.product.helper.SearchParam;
import com.yohoufo.product.model.FilterItem;
... ... @@ -93,9 +94,6 @@ public class ProductSearchServiceImpl implements ProductSearchService {
@Autowired
private ProductSearchAssistService productSearchAssistService;
private JSONObject search(Map<String, Object> searchParams, String url) {
logger.info("begin invoke search.productList, param is:{}, url is :{}", searchParams, url);
String resultJsonStr = null;
... ... @@ -225,6 +223,26 @@ public class ProductSearchServiceImpl implements ProductSearchService {
}
}
}
/**
* 对二手商品列表的信息进行修改,商品图片地址URL补全
*
*/
protected void processSecondhandSkupList(JSONArray skupList) {
if(CollectionUtils.isEmpty(skupList)){
return;
}
// 遍历商品列表
for (int i = 0; i < skupList.size(); i++) {
JSONObject product = skupList.getJSONObject(i);
if(null == product){
continue;
}
// 处理图片,封面图设置
String secondhand_image = fillProductImgUrl(MapUtils.getString(product, "secondhand_image", ""));
product.replace("secondhand_image", secondhand_image);
}
}
public static void main(String[] args) {
System.out.println(fillProductImgUrl("https://img12.static.yhbimg.com/goodsimg/2019/04/17/17/021560b1bd437ded9a66dd15c29c81c53d.jpg"));
... ... @@ -743,6 +761,19 @@ public class ProductSearchServiceImpl implements ProductSearchService {
}
return resp;
}
@Override
public JSONObject searchSecondhandSkupList(ProductSearchReq req) {
SearchParam searchParam = new SearchParam().buildPageSearchParam(req);
String url = ProductSearchConstants.SECONDHAND_SKUP_QUERY_URL;
JSONObject data = search(searchParam.getParam(), url);
// 将图片的相对路径转成绝对路径
if (null != data) {
processSecondhandSkupList(data.getJSONArray("skup_list"));
}
return data;
}
// NFC详情分享页列表要保证 3的倍数,这里做最后的保证
private void regularize(JSONArray productList) {
... ...