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 { @@ -34,4 +34,6 @@ public interface ProductSearchConstants {
34 String SUGGEST_URL = "/yohosearch/ufo/suggest.json"; 34 String SUGGEST_URL = "/yohosearch/ufo/suggest.json";
35 35
36 String PRODUCT_RECOMMEND_BY_SERIESBRAND_LIST_URL = "/yohosearch/ufo/recommendBySeriesBrandList.json"; 36 String PRODUCT_RECOMMEND_BY_SERIESBRAND_LIST_URL = "/yohosearch/ufo/recommendBySeriesBrandList.json";
  37 +
  38 + String SECONDHAND_SKUP_QUERY_URL = "/yohosearch/ufo/secondHand/skupList.json";
37 } 39 }
@@ -353,4 +353,17 @@ public class ProductSearchController { @@ -353,4 +353,17 @@ public class ProductSearchController {
353 return new ApiResponse.ApiResponseBuilder().code(200).message("product.data.search.recommendBySeriesBrand").data(resp).build(); 353 return new ApiResponse.ApiResponseBuilder().code(200).message("product.data.search.recommendBySeriesBrand").data(resp).build();
354 } 354 }
355 355
  356 + @ApiOperation(name = "ufo.product.search.secondhand.skupList", desc="二手商品搜索列表")
  357 + @RequestMapping(params = "method=ufo.product.search.secondhand.skupList")
  358 + @IgnoreSession
  359 + @Cachable(expire = 600)
  360 + public ApiResponse searchSecondhandSkupList(@RequestParam(value = "preSale_flag", required = false)Integer preSaleFlag,
  361 + @RequestParam(value = "limit", required = false)Integer limit,
  362 + @RequestParam(value = "page", required = false)Integer page) {
  363 + LOG.info("in method=ufo.product.search.secondhand.skupList preSale_flag={}", preSaleFlag);
  364 + ProductSearchReq req = new ProductSearchReq().setViewNum(limit).setPage(page).setPreSaleFlag(preSaleFlag);
  365 + JSONObject resp = productSearchService.searchSecondhandSkupList(req);
  366 + return new ApiResponse.ApiResponseBuilder().code(200).message("secondhand skupList.").data(resp).build();
  367 + }
  368 +
356 } 369 }
@@ -28,10 +28,8 @@ public class ProductSearchReq { @@ -28,10 +28,8 @@ public class ProductSearchReq {
28 private String couponToken; 28 private String couponToken;
29 private String excludeLimit; // 过滤限售的商品 29 private String excludeLimit; // 过滤限售的商品
30 private String not_brand; 30 private String not_brand;
31 -  
32 -  
33 -  
34 private String businessClient; 31 private String businessClient;
  32 + private Integer preSaleFlag;
35 33
36 @Override 34 @Override
37 public String toString() { 35 public String toString() {
@@ -56,6 +54,7 @@ public class ProductSearchReq { @@ -56,6 +54,7 @@ public class ProductSearchReq {
56 .append("endTime",endTime) 54 .append("endTime",endTime)
57 .append("contain_yoho",containYoho) 55 .append("contain_yoho",containYoho)
58 .append("businessClient",businessClient) 56 .append("businessClient",businessClient)
  57 + .append("preSaleFlag", preSaleFlag)
59 .toString(); 58 .toString();
60 } 59 }
61 60
@@ -287,4 +286,16 @@ public class ProductSearchReq { @@ -287,4 +286,16 @@ public class ProductSearchReq {
287 this.businessClient = businessClient; 286 this.businessClient = businessClient;
288 return this; 287 return this;
289 } 288 }
  289 +
  290 +
  291 + public Integer getPreSaleFlag() {
  292 + return preSaleFlag;
  293 + }
  294 +
  295 +
  296 + public ProductSearchReq setPreSaleFlag(Integer preSaleFlag) {
  297 + this.preSaleFlag = preSaleFlag;
  298 + return this;
  299 + }
  300 +
290 } 301 }
@@ -3,9 +3,7 @@ package com.yohoufo.product.service; @@ -3,9 +3,7 @@ package com.yohoufo.product.service;
3 3
4 import java.util.List; 4 import java.util.List;
5 5
6 -import com.alibaba.fastjson.JSONArray;  
7 import com.alibaba.fastjson.JSONObject; 6 import com.alibaba.fastjson.JSONObject;
8 -import com.yohoufo.common.cache.Cachable;  
9 import com.yohoufo.product.request.ProductSearchReq; 7 import com.yohoufo.product.request.ProductSearchReq;
10 import com.yohoufo.product.request.SortIdLevel; 8 import com.yohoufo.product.request.SortIdLevel;
11 import com.yohoufo.product.response.ProductBrandSeriesResp; 9 import com.yohoufo.product.response.ProductBrandSeriesResp;
@@ -45,4 +43,6 @@ public interface ProductSearchService { @@ -45,4 +43,6 @@ public interface ProductSearchService {
45 43
46 SearchProductRecommendResp searchProductRecommendByIdAndSeriesBrand(Integer productId, String businessClient); 44 SearchProductRecommendResp searchProductRecommendByIdAndSeriesBrand(Integer productId, String businessClient);
47 45
  46 + JSONObject searchSecondhandSkupList(ProductSearchReq req);
  47 +
48 } 48 }
@@ -8,7 +8,6 @@ import java.util.Comparator; @@ -8,7 +8,6 @@ import java.util.Comparator;
8 import java.util.Date; 8 import java.util.Date;
9 import java.util.List; 9 import java.util.List;
10 import java.util.Map; 10 import java.util.Map;
11 -import java.util.function.Function;  
12 import java.util.stream.Collectors; 11 import java.util.stream.Collectors;
13 12
14 import com.yoho.core.config.ConfigReader; 13 import com.yoho.core.config.ConfigReader;
@@ -31,17 +30,19 @@ import com.alibaba.fastjson.JSONArray; @@ -31,17 +30,19 @@ import com.alibaba.fastjson.JSONArray;
31 import com.alibaba.fastjson.JSONObject; 30 import com.alibaba.fastjson.JSONObject;
32 import com.google.common.collect.Lists; 31 import com.google.common.collect.Lists;
33 import com.yoho.core.common.utils.DateUtil; 32 import com.yoho.core.common.utils.DateUtil;
  33 +import com.yoho.core.config.ConfigReader;
34 import com.yoho.core.rest.client.ServiceCaller; 34 import com.yoho.core.rest.client.ServiceCaller;
35 import com.yoho.core.rest.exception.ServiceNotAvaibleException; 35 import com.yoho.core.rest.exception.ServiceNotAvaibleException;
  36 +import com.yohobuy.ufo.model.promotion.response.CouponInfo;
  37 +import com.yohoufo.common.ApiResponse;
36 import com.yohoufo.common.cache.Cachable; 38 import com.yohoufo.common.cache.Cachable;
37 import com.yohoufo.common.caller.UfoServiceCaller; 39 import com.yohoufo.common.caller.UfoServiceCaller;
38 import com.yohoufo.common.helper.ImageUrlAssist; 40 import com.yohoufo.common.helper.ImageUrlAssist;
39 import com.yohoufo.common.utils.UfoStringUtils; 41 import com.yohoufo.common.utils.UfoStringUtils;
  42 +import com.yohoufo.dal.product.BrandMapper;
40 import com.yohoufo.dal.product.ProductMapper; 43 import com.yohoufo.dal.product.ProductMapper;
41 -import com.yohoufo.dal.product.ProductSalesMapper;  
42 import com.yohoufo.dal.product.ProductSortMapper; 44 import com.yohoufo.dal.product.ProductSortMapper;
43 import com.yohoufo.dal.product.model.Product; 45 import com.yohoufo.dal.product.model.Product;
44 -import com.yohoufo.dal.product.model.ProductSales;  
45 import com.yohoufo.dal.product.model.ProductSort; 46 import com.yohoufo.dal.product.model.ProductSort;
46 import com.yohoufo.product.helper.SearchParam; 47 import com.yohoufo.product.helper.SearchParam;
47 import com.yohoufo.product.model.FilterItem; 48 import com.yohoufo.product.model.FilterItem;
@@ -93,9 +94,6 @@ public class ProductSearchServiceImpl implements ProductSearchService { @@ -93,9 +94,6 @@ public class ProductSearchServiceImpl implements ProductSearchService {
93 @Autowired 94 @Autowired
94 private ProductSearchAssistService productSearchAssistService; 95 private ProductSearchAssistService productSearchAssistService;
95 96
96 -  
97 -  
98 -  
99 private JSONObject search(Map<String, Object> searchParams, String url) { 97 private JSONObject search(Map<String, Object> searchParams, String url) {
100 logger.info("begin invoke search.productList, param is:{}, url is :{}", searchParams, url); 98 logger.info("begin invoke search.productList, param is:{}, url is :{}", searchParams, url);
101 String resultJsonStr = null; 99 String resultJsonStr = null;
@@ -226,6 +224,26 @@ public class ProductSearchServiceImpl implements ProductSearchService { @@ -226,6 +224,26 @@ public class ProductSearchServiceImpl implements ProductSearchService {
226 } 224 }
227 } 225 }
228 226
  227 + /**
  228 + * 对二手商品列表的信息进行修改,商品图片地址URL补全
  229 + *
  230 + */
  231 + protected void processSecondhandSkupList(JSONArray skupList) {
  232 + if(CollectionUtils.isEmpty(skupList)){
  233 + return;
  234 + }
  235 + // 遍历商品列表
  236 + for (int i = 0; i < skupList.size(); i++) {
  237 + JSONObject product = skupList.getJSONObject(i);
  238 + if(null == product){
  239 + continue;
  240 + }
  241 + // 处理图片,封面图设置
  242 + String secondhand_image = fillProductImgUrl(MapUtils.getString(product, "secondhand_image", ""));
  243 + product.replace("secondhand_image", secondhand_image);
  244 + }
  245 + }
  246 +
229 public static void main(String[] args) { 247 public static void main(String[] args) {
230 System.out.println(fillProductImgUrl("https://img12.static.yhbimg.com/goodsimg/2019/04/17/17/021560b1bd437ded9a66dd15c29c81c53d.jpg")); 248 System.out.println(fillProductImgUrl("https://img12.static.yhbimg.com/goodsimg/2019/04/17/17/021560b1bd437ded9a66dd15c29c81c53d.jpg"));
231 } 249 }
@@ -744,6 +762,19 @@ public class ProductSearchServiceImpl implements ProductSearchService { @@ -744,6 +762,19 @@ public class ProductSearchServiceImpl implements ProductSearchService {
744 return resp; 762 return resp;
745 } 763 }
746 764
  765 + @Override
  766 + public JSONObject searchSecondhandSkupList(ProductSearchReq req) {
  767 + SearchParam searchParam = new SearchParam().buildPageSearchParam(req);
  768 + String url = ProductSearchConstants.SECONDHAND_SKUP_QUERY_URL;
  769 + JSONObject data = search(searchParam.getParam(), url);
  770 + // 将图片的相对路径转成绝对路径
  771 + if (null != data) {
  772 + processSecondhandSkupList(data.getJSONArray("skup_list"));
  773 + }
  774 +
  775 + return data;
  776 + }
  777 +
747 // NFC详情分享页列表要保证 3的倍数,这里做最后的保证 778 // NFC详情分享页列表要保证 3的倍数,这里做最后的保证
748 private void regularize(JSONArray productList) { 779 private void regularize(JSONArray productList) {
749 if(CollectionUtils.isEmpty(productList)){ 780 if(CollectionUtils.isEmpty(productList)){