Authored by Lixiaodi

详情页极速发货

@@ -8,6 +8,8 @@ import com.yoho.tools.docs.ApiOperation; @@ -8,6 +8,8 @@ import com.yoho.tools.docs.ApiOperation;
8 import com.yoho.tools.docs.ApiParam; 8 import com.yoho.tools.docs.ApiParam;
9 import com.yoho.tools.docs.ApiResp; 9 import com.yoho.tools.docs.ApiResp;
10 import com.yoho.tools.docs.ApiRespCode; 10 import com.yoho.tools.docs.ApiRespCode;
  11 +import com.yohobuy.ufo.model.GoodsBO;
  12 +import com.yohobuy.ufo.model.GoodsSize;
11 import com.yohobuy.ufo.model.ProductInfo; 13 import com.yohobuy.ufo.model.ProductInfo;
12 import com.yohobuy.ufo.model.request.SeekToBuyStorageBo; 14 import com.yohobuy.ufo.model.request.SeekToBuyStorageBo;
13 import com.yohobuy.ufo.model.request.StoragePriceBo; 15 import com.yohobuy.ufo.model.request.StoragePriceBo;
@@ -23,6 +25,7 @@ import com.yohoufo.common.cache.Cachable; @@ -23,6 +25,7 @@ import com.yohoufo.common.cache.Cachable;
23 import com.yohoufo.common.cache.ControllerCacheAop; 25 import com.yohoufo.common.cache.ControllerCacheAop;
24 import com.yohoufo.common.caller.UfoServiceCaller; 26 import com.yohoufo.common.caller.UfoServiceCaller;
25 import com.yohoufo.common.utils.StringUtil; 27 import com.yohoufo.common.utils.StringUtil;
  28 +import com.yohoufo.dal.product.model.Goods;
26 import com.yohoufo.dal.product.model.StoragePrice; 29 import com.yohoufo.dal.product.model.StoragePrice;
27 import com.yohoufo.product.model.SkupInfo; 30 import com.yohoufo.product.model.SkupInfo;
28 import com.yohoufo.product.response.*; 31 import com.yohoufo.product.response.*;
@@ -34,6 +37,7 @@ import org.apache.commons.collections.CollectionUtils; @@ -34,6 +37,7 @@ import org.apache.commons.collections.CollectionUtils;
34 import org.apache.commons.lang3.StringUtils; 37 import org.apache.commons.lang3.StringUtils;
35 import org.slf4j.Logger; 38 import org.slf4j.Logger;
36 import org.slf4j.LoggerFactory; 39 import org.slf4j.LoggerFactory;
  40 +import org.springframework.beans.BeanUtils;
37 import org.springframework.beans.factory.annotation.Autowired; 41 import org.springframework.beans.factory.annotation.Autowired;
38 import org.springframework.web.bind.annotation.RequestBody; 42 import org.springframework.web.bind.annotation.RequestBody;
39 import org.springframework.web.bind.annotation.RequestMapping; 43 import org.springframework.web.bind.annotation.RequestMapping;
@@ -101,6 +105,22 @@ public class ProductController { @@ -101,6 +105,22 @@ public class ProductController {
101 return new ApiResponse.ApiResponseBuilder().data(resp).code(200).message("product data").build(); 105 return new ApiResponse.ApiResponseBuilder().data(resp).code(200).message("product data").build();
102 } 106 }
103 107
  108 + @ApiOperation(name = "ufo.product.data2", desc = "商品详情分tab")
  109 + @IgnoreSignature
  110 + @IgnoreSession
  111 + @RequestMapping(params = "method=ufo.product.data2")
  112 + @Cachable(expire = 120)
  113 + public ApiResponse queryProductDetailTabsById(
  114 + @RequestParam(value = "product_id") Integer productId) {
  115 + ApiResponse response = queryProductDetailById(productId);
  116 + if (response.getCode() == 200) {
  117 + ProductDetailResp resp = (ProductDetailResp) response.getData();
  118 + productService.tabsGoods(resp);
  119 + }
  120 + return response;
  121 + }
  122 +
  123 +
104 @ApiOperation(name = "ufo.product.intro", desc = "商品详情页下半部分") 124 @ApiOperation(name = "ufo.product.intro", desc = "商品详情页下半部分")
105 @ApiParam(name="product_id",required = true,desc="商品id",type=Integer.class) 125 @ApiParam(name="product_id",required = true,desc="商品id",type=Integer.class)
106 @ApiResp(dataClazz=ModelAndView.class, desc="商品详情") 126 @ApiResp(dataClazz=ModelAndView.class, desc="商品详情")
@@ -929,4 +949,5 @@ public class ProductController { @@ -929,4 +949,5 @@ public class ProductController {
929 LOG.info("queryProductResource poolIds is {}.", poolIds); 949 LOG.info("queryProductResource poolIds is {}.", poolIds);
930 return ufoServiceCaller.call("ufo.resource.product", ApiResponse.class, StringUtils.join(poolIds, ","), clientType); 950 return ufoServiceCaller.call("ufo.resource.product", ApiResponse.class, StringUtils.join(poolIds, ","), clientType);
931 } 951 }
  952 +
932 } 953 }
@@ -318,5 +318,26 @@ public class ProductSearchController { @@ -318,5 +318,26 @@ public class ProductSearchController {
318 return null; 318 return null;
319 } 319 }
320 } 320 }
  321 +
  322 + @ApiOperation(name = "ufo.product.search.appraise.list", desc="首页商品推荐")
  323 + @RequestMapping(params = "method=ufo.product.appraise.list")
  324 + @IgnoreSession
  325 + @Cachable(expire = 180)
  326 + public ApiResponse searchAppraiseProductList(
  327 + @RequestParam(value = "query", required = false)String query,
  328 + @RequestParam(value = "limit", required = false)Integer limit,
  329 + @RequestParam(value = "page", required = false)Integer page,
  330 + @RequestParam(value = "app_version", required = false)String appVersion
  331 + ) {
  332 + ProductSearchReq req = new ProductSearchReq().setViewNum(limit).setPage(page).setExcludeLimit("true");
  333 + searchHelpService.setQuery(query, req);
  334 + //设置是否包含有货商品
  335 + LOG.info("in method=ufo.product.search.appraise.list req={}", req.toString());
  336 + JSONObject resp = productSearchService.searchAppraiseProductList(req);
  337 + if (resp != null) {
  338 + resp.put("rec_id", UUID.randomUUID());
  339 + }
  340 + return new ApiResponse.ApiResponseBuilder().code(200).message("Product List.").data(resp).build();
  341 + }
321 342
322 } 343 }
@@ -95,6 +95,8 @@ public final class SearchConstants { @@ -95,6 +95,8 @@ public final class SearchConstants {
95 String RANK_TYPE = "rankType"; 95 String RANK_TYPE = "rankType";
96 String TYPE = "product_type"; 96 String TYPE = "product_type";
97 97
  98 + String EXCLUDE_LIMIT = "exclude_limit";
  99 +
98 } 100 }
99 101
100 } 102 }
@@ -56,7 +56,8 @@ public class SearchParam { @@ -56,7 +56,8 @@ public class SearchParam {
56 .setEndTime(req.getEndTime()) 56 .setEndTime(req.getEndTime())
57 .setContainYoho(req.getContainYoho()) 57 .setContainYoho(req.getContainYoho())
58 .setRankType(req.getRankType()) 58 .setRankType(req.getRankType())
59 - .setNotId(req.getNot_id()); 59 + .setNotId(req.getNot_id())
  60 + .setExcludeLimit(req.getExcludeLimit());
60 return this; 61 return this;
61 } 62 }
62 63
@@ -69,7 +70,7 @@ public class SearchParam { @@ -69,7 +70,7 @@ public class SearchParam {
69 .setStartTime(req.getStartTime()) 70 .setStartTime(req.getStartTime())
70 .setEndTime(req.getEndTime()) 71 .setEndTime(req.getEndTime())
71 .setContainYoho(req.getContainYoho()) 72 .setContainYoho(req.getContainYoho())
72 - .setRankType(req.getRankType()).setId(req.getId()).setNotId(req.getNot_id()); 73 + .setRankType(req.getRankType()).setId(req.getId()).setNotId(req.getNot_id()).setExcludeLimit(req.getExcludeLimit());;
73 return this; 74 return this;
74 } 75 }
75 76
@@ -277,6 +278,13 @@ public class SearchParam { @@ -277,6 +278,13 @@ public class SearchParam {
277 return this; 278 return this;
278 } 279 }
279 280
  281 + public SearchParam setExcludeLimit(String excludeLimit) {
  282 + if (StringUtils.isNotBlank(excludeLimit)) {
  283 + param.put(SearchConstants.IndexNameConstant.EXCLUDE_LIMIT, excludeLimit);
  284 + }
  285 + return this;
  286 + }
  287 +
280 public Map<String, Object> getParam() { 288 public Map<String, Object> getParam() {
281 return param; 289 return param;
282 } 290 }
@@ -26,6 +26,7 @@ public class ProductSearchReq { @@ -26,6 +26,7 @@ public class ProductSearchReq {
26 private String containYoho;//是否包含有货商品 26 private String containYoho;//是否包含有货商品
27 private String rankType; 27 private String rankType;
28 private String couponToken; 28 private String couponToken;
  29 + private String excludeLimit;
29 30
30 @Override 31 @Override
31 public String toString() { 32 public String toString() {
@@ -250,6 +251,15 @@ public class ProductSearchReq { @@ -250,6 +251,15 @@ public class ProductSearchReq {
250 return this; 251 return this;
251 } 252 }
252 253
  254 + public ProductSearchReq setExcludeLimit(String excludeLimit) {
  255 + this.excludeLimit = excludeLimit;
  256 + return this;
  257 + }
  258 +
  259 + public String getExcludeLimit() {
  260 + return excludeLimit;
  261 + }
  262 +
253 public String getCouponToken() { 263 public String getCouponToken() {
254 return couponToken; 264 return couponToken;
255 } 265 }
@@ -41,4 +41,6 @@ public interface ProductSearchService { @@ -41,4 +41,6 @@ public interface ProductSearchService {
41 41
42 JSONObject searchSuggest(ProductSearchReq req); 42 JSONObject searchSuggest(ProductSearchReq req);
43 43
  44 + JSONObject searchAppraiseProductList(ProductSearchReq req);
  45 +
44 } 46 }
@@ -134,4 +134,5 @@ public interface ProductService { @@ -134,4 +134,5 @@ public interface ProductService {
134 List<StorageDataResp> queryStorageListInfo(List<Integer> storageIdList); 134 List<StorageDataResp> queryStorageListInfo(List<Integer> storageIdList);
135 135
136 List<StorageInfoResp> queryLeastOnSalePrice(String productCode); 136 List<StorageInfoResp> queryLeastOnSalePrice(String productCode);
  137 + void tabsGoods(ProductDetailResp resp);
137 } 138 }
@@ -179,6 +179,20 @@ public class ProductSearchServiceImpl implements ProductSearchService { @@ -179,6 +179,20 @@ public class ProductSearchServiceImpl implements ProductSearchService {
179 } 179 }
180 180
181 @Override 181 @Override
  182 + public JSONObject searchAppraiseProductList(ProductSearchReq req) {
  183 + SearchParam searchParam = new SearchParam().buildPageSearchParam(req);
  184 + String url = PRODUCT_SEARCH_QUERY_URL;
  185 + JSONObject data = search(searchParam.getParam(), url);
  186 + // 将图片的相对路径转成绝对路径
  187 + if (null != data) {
  188 + processProductList(data.getJSONArray("product_list"));
  189 + processProductSales(data.getJSONArray("product_list"));
  190 + }
  191 +
  192 + return data;
  193 + }
  194 +
  195 + @Override
182 public JSONObject searchSuggest(ProductSearchReq req) { 196 public JSONObject searchSuggest(ProductSearchReq req) {
183 SearchParam searchParam = new SearchParam().buildPageSearchParam(req); 197 SearchParam searchParam = new SearchParam().buildPageSearchParam(req);
184 JSONObject data = search(searchParam.getParam(), SUGGEST_URL); 198 JSONObject data = search(searchParam.getParam(), SUGGEST_URL);
@@ -1986,6 +1986,48 @@ public class ProductServiceImpl implements ProductService { @@ -1986,6 +1986,48 @@ public class ProductServiceImpl implements ProductService {
1986 return resp; 1986 return resp;
1987 } 1987 }
1988 1988
  1989 + public void tabsGoods(ProductDetailResp resp) {
  1990 + ProductInfo product_info = resp.getProduct_info();
  1991 + List<GoodsBO> goodsList = product_info.getGoodsList();
  1992 + if (!goodsList.isEmpty()) {
  1993 + GoodsBO allGoodsBO = goodsList.get(0);
  1994 + List<GoodsSize> allSizeList = allGoodsBO.getSizeList();
  1995 + List<GoodsSize> sizeList = new ArrayList<>();
  1996 + List<GoodsSize> preSaleSizeList = new ArrayList<>();
  1997 + List<GoodsSize> secondsSizeList = new ArrayList<>();
  1998 + for (GoodsSize size : allSizeList) {
  1999 + // 1.现货 9极速 3闪购 海外直邮
  2000 + if (notAllNull(size.getSkup(), size.getQuickDeliverySkup(), size.getFlashSkup(), size.getHkSkup())) {
  2001 + sizeList.add(size);
  2002 + } else if (notAllNull(size.getPreSaleSkup())) {
  2003 + preSaleSizeList.add(size);
  2004 + } else if (notAllNull(size.getSecondHandSkup())) {
  2005 + secondsSizeList.add(size);
  2006 + }
  2007 + }
  2008 + allGoodsBO.setSizeList(null);
  2009 +
  2010 + GoodsBO goodsBO = new GoodsBO();
  2011 + BeanUtils.copyProperties(allGoodsBO, goodsBO);
  2012 + goodsBO.setSizeList(sizeList);
  2013 +
  2014 + GoodsBO preSaleGoodsBO = new GoodsBO();
  2015 + BeanUtils.copyProperties(allGoodsBO, preSaleGoodsBO);
  2016 + preSaleGoodsBO.setSizeList(preSaleSizeList);
  2017 +
  2018 + GoodsBO secondsGoodsBO = new GoodsBO();
  2019 + BeanUtils.copyProperties(allGoodsBO, secondsGoodsBO);
  2020 + secondsGoodsBO.setSizeList(secondsSizeList);
  2021 +
  2022 + Map<String, List<GoodsBO>> tabs = new HashMap<>();
  2023 + tabs.put("goods_list", Arrays.asList(goodsBO));
  2024 + tabs.put("pre_sale_goods_list", Arrays.asList(preSaleGoodsBO));
  2025 + tabs.put("seconds_goods_list", Arrays.asList(goodsBO));
  2026 + product_info.setGoodsListTabs(tabs);
  2027 + product_info.setGoodsList(null);
  2028 + }
  2029 + }
  2030 +
1989 public List<StorageDataResp> queryStorageListInfo(List<Integer> storageIdList) { 2031 public List<StorageDataResp> queryStorageListInfo(List<Integer> storageIdList) {
1990 2032
1991 List<Storage> storageList = storageMapper.selectByIds(storageIdList); 2033 List<Storage> storageList = storageMapper.selectByIds(storageIdList);
@@ -2087,4 +2129,13 @@ public class ProductServiceImpl implements ProductService { @@ -2087,4 +2129,13 @@ public class ProductServiceImpl implements ProductService {
2087 } 2129 }
2088 return sp2; 2130 return sp2;
2089 } 2131 }
  2132 + private boolean notAllNull(Object... obj) {
  2133 + for (Object o : obj) {
  2134 + if (o != null) {
  2135 + return true;
  2136 + }
  2137 + }
  2138 + return false;
  2139 + }
  2140 +
2090 } 2141 }