Authored by Lixiaodi

详情页极速发货

... ... @@ -8,6 +8,8 @@ import com.yoho.tools.docs.ApiOperation;
import com.yoho.tools.docs.ApiParam;
import com.yoho.tools.docs.ApiResp;
import com.yoho.tools.docs.ApiRespCode;
import com.yohobuy.ufo.model.GoodsBO;
import com.yohobuy.ufo.model.GoodsSize;
import com.yohobuy.ufo.model.ProductInfo;
import com.yohobuy.ufo.model.request.SeekToBuyStorageBo;
import com.yohobuy.ufo.model.request.StoragePriceBo;
... ... @@ -23,6 +25,7 @@ import com.yohoufo.common.cache.Cachable;
import com.yohoufo.common.cache.ControllerCacheAop;
import com.yohoufo.common.caller.UfoServiceCaller;
import com.yohoufo.common.utils.StringUtil;
import com.yohoufo.dal.product.model.Goods;
import com.yohoufo.dal.product.model.StoragePrice;
import com.yohoufo.product.model.SkupInfo;
import com.yohoufo.product.response.*;
... ... @@ -34,6 +37,7 @@ import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
... ... @@ -101,6 +105,22 @@ public class ProductController {
return new ApiResponse.ApiResponseBuilder().data(resp).code(200).message("product data").build();
}
@ApiOperation(name = "ufo.product.data2", desc = "商品详情分tab")
@IgnoreSignature
@IgnoreSession
@RequestMapping(params = "method=ufo.product.data2")
@Cachable(expire = 120)
public ApiResponse queryProductDetailTabsById(
@RequestParam(value = "product_id") Integer productId) {
ApiResponse response = queryProductDetailById(productId);
if (response.getCode() == 200) {
ProductDetailResp resp = (ProductDetailResp) response.getData();
productService.tabsGoods(resp);
}
return response;
}
@ApiOperation(name = "ufo.product.intro", desc = "商品详情页下半部分")
@ApiParam(name="product_id",required = true,desc="商品id",type=Integer.class)
@ApiResp(dataClazz=ModelAndView.class, desc="商品详情")
... ... @@ -929,4 +949,5 @@ public class ProductController {
LOG.info("queryProductResource poolIds is {}.", poolIds);
return ufoServiceCaller.call("ufo.resource.product", ApiResponse.class, StringUtils.join(poolIds, ","), clientType);
}
}
\ No newline at end of file
... ...
... ... @@ -318,5 +318,26 @@ public class ProductSearchController {
return null;
}
}
@ApiOperation(name = "ufo.product.search.appraise.list", desc="首页商品推荐")
@RequestMapping(params = "method=ufo.product.appraise.list")
@IgnoreSession
@Cachable(expire = 180)
public ApiResponse searchAppraiseProductList(
@RequestParam(value = "query", required = false)String query,
@RequestParam(value = "limit", required = false)Integer limit,
@RequestParam(value = "page", required = false)Integer page,
@RequestParam(value = "app_version", required = false)String appVersion
) {
ProductSearchReq req = new ProductSearchReq().setViewNum(limit).setPage(page).setExcludeLimit("true");
searchHelpService.setQuery(query, req);
//设置是否包含有货商品
LOG.info("in method=ufo.product.search.appraise.list req={}", req.toString());
JSONObject resp = productSearchService.searchAppraiseProductList(req);
if (resp != null) {
resp.put("rec_id", UUID.randomUUID());
}
return new ApiResponse.ApiResponseBuilder().code(200).message("Product List.").data(resp).build();
}
}
\ No newline at end of file
... ...
... ... @@ -95,6 +95,8 @@ public final class SearchConstants {
String RANK_TYPE = "rankType";
String TYPE = "product_type";
String EXCLUDE_LIMIT = "exclude_limit";
}
}
... ...
... ... @@ -56,7 +56,8 @@ public class SearchParam {
.setEndTime(req.getEndTime())
.setContainYoho(req.getContainYoho())
.setRankType(req.getRankType())
.setNotId(req.getNot_id());
.setNotId(req.getNot_id())
.setExcludeLimit(req.getExcludeLimit());
return this;
}
... ... @@ -69,7 +70,7 @@ public class SearchParam {
.setStartTime(req.getStartTime())
.setEndTime(req.getEndTime())
.setContainYoho(req.getContainYoho())
.setRankType(req.getRankType()).setId(req.getId()).setNotId(req.getNot_id());
.setRankType(req.getRankType()).setId(req.getId()).setNotId(req.getNot_id()).setExcludeLimit(req.getExcludeLimit());;
return this;
}
... ... @@ -277,6 +278,13 @@ public class SearchParam {
return this;
}
public SearchParam setExcludeLimit(String excludeLimit) {
if (StringUtils.isNotBlank(excludeLimit)) {
param.put(SearchConstants.IndexNameConstant.EXCLUDE_LIMIT, excludeLimit);
}
return this;
}
public Map<String, Object> getParam() {
return param;
}
... ...
... ... @@ -26,6 +26,7 @@ public class ProductSearchReq {
private String containYoho;//是否包含有货商品
private String rankType;
private String couponToken;
private String excludeLimit;
@Override
public String toString() {
... ... @@ -250,6 +251,15 @@ public class ProductSearchReq {
return this;
}
public ProductSearchReq setExcludeLimit(String excludeLimit) {
this.excludeLimit = excludeLimit;
return this;
}
public String getExcludeLimit() {
return excludeLimit;
}
public String getCouponToken() {
return couponToken;
}
... ...
... ... @@ -41,4 +41,6 @@ public interface ProductSearchService {
JSONObject searchSuggest(ProductSearchReq req);
JSONObject searchAppraiseProductList(ProductSearchReq req);
}
... ...
... ... @@ -134,4 +134,5 @@ public interface ProductService {
List<StorageDataResp> queryStorageListInfo(List<Integer> storageIdList);
List<StorageInfoResp> queryLeastOnSalePrice(String productCode);
void tabsGoods(ProductDetailResp resp);
}
... ...
... ... @@ -179,6 +179,20 @@ public class ProductSearchServiceImpl implements ProductSearchService {
}
@Override
public JSONObject searchAppraiseProductList(ProductSearchReq req) {
SearchParam searchParam = new SearchParam().buildPageSearchParam(req);
String url = PRODUCT_SEARCH_QUERY_URL;
JSONObject data = search(searchParam.getParam(), url);
// 将图片的相对路径转成绝对路径
if (null != data) {
processProductList(data.getJSONArray("product_list"));
processProductSales(data.getJSONArray("product_list"));
}
return data;
}
@Override
public JSONObject searchSuggest(ProductSearchReq req) {
SearchParam searchParam = new SearchParam().buildPageSearchParam(req);
JSONObject data = search(searchParam.getParam(), SUGGEST_URL);
... ...
... ... @@ -1986,6 +1986,48 @@ public class ProductServiceImpl implements ProductService {
return resp;
}
public void tabsGoods(ProductDetailResp resp) {
ProductInfo product_info = resp.getProduct_info();
List<GoodsBO> goodsList = product_info.getGoodsList();
if (!goodsList.isEmpty()) {
GoodsBO allGoodsBO = goodsList.get(0);
List<GoodsSize> allSizeList = allGoodsBO.getSizeList();
List<GoodsSize> sizeList = new ArrayList<>();
List<GoodsSize> preSaleSizeList = new ArrayList<>();
List<GoodsSize> secondsSizeList = new ArrayList<>();
for (GoodsSize size : allSizeList) {
// 1.现货 9极速 3闪购 海外直邮
if (notAllNull(size.getSkup(), size.getQuickDeliverySkup(), size.getFlashSkup(), size.getHkSkup())) {
sizeList.add(size);
} else if (notAllNull(size.getPreSaleSkup())) {
preSaleSizeList.add(size);
} else if (notAllNull(size.getSecondHandSkup())) {
secondsSizeList.add(size);
}
}
allGoodsBO.setSizeList(null);
GoodsBO goodsBO = new GoodsBO();
BeanUtils.copyProperties(allGoodsBO, goodsBO);
goodsBO.setSizeList(sizeList);
GoodsBO preSaleGoodsBO = new GoodsBO();
BeanUtils.copyProperties(allGoodsBO, preSaleGoodsBO);
preSaleGoodsBO.setSizeList(preSaleSizeList);
GoodsBO secondsGoodsBO = new GoodsBO();
BeanUtils.copyProperties(allGoodsBO, secondsGoodsBO);
secondsGoodsBO.setSizeList(secondsSizeList);
Map<String, List<GoodsBO>> tabs = new HashMap<>();
tabs.put("goods_list", Arrays.asList(goodsBO));
tabs.put("pre_sale_goods_list", Arrays.asList(preSaleGoodsBO));
tabs.put("seconds_goods_list", Arrays.asList(goodsBO));
product_info.setGoodsListTabs(tabs);
product_info.setGoodsList(null);
}
}
public List<StorageDataResp> queryStorageListInfo(List<Integer> storageIdList) {
List<Storage> storageList = storageMapper.selectByIds(storageIdList);
... ... @@ -2087,4 +2129,13 @@ public class ProductServiceImpl implements ProductService {
}
return sp2;
}
private boolean notAllNull(Object... obj) {
for (Object o : obj) {
if (o != null) {
return true;
}
}
return false;
}
}
... ...