Authored by wangnan

免运费凑单商品列表接口

  1 +package com.yoho.search.restapi.scene;
  2 +
  3 +import com.yoho.search.common.downgrade.persional.PersionalRateLimit;
  4 +import com.yoho.search.common.utils.HttpServletRequestUtils;
  5 +import com.yoho.search.models.SearchApiResult;
  6 +import com.yoho.search.service.scene.FreeShippingOrderSceneService;
  7 +import org.springframework.beans.factory.annotation.Autowired;
  8 +import org.springframework.stereotype.Controller;
  9 +import org.springframework.web.bind.annotation.RequestMapping;
  10 +import org.springframework.web.bind.annotation.RequestMethod;
  11 +import org.springframework.web.bind.annotation.ResponseBody;
  12 +
  13 +import javax.servlet.http.HttpServletRequest;
  14 +import java.util.Map;
  15 +
  16 +/**
  17 + * Created by wangnan on 2017/11/21.
  18 + * 免运费凑单商品列表接口
  19 + */
  20 +@Controller
  21 +public class FreeShippingOrderSceneController {
  22 +
  23 + @Autowired
  24 + private FreeShippingOrderSceneService freeShippingOrderSceneService;
  25 +
  26 + /**
  27 + * 免运费凑单商品列表
  28 + */
  29 + @PersionalRateLimit(isOrderUseable = true)
  30 + @RequestMapping(method = RequestMethod.GET, value = "/freeShipping/productList")
  31 + @ResponseBody
  32 + public SearchApiResult freeShippingProductList(HttpServletRequest request) {
  33 + Map<String, String> paramMap = HttpServletRequestUtils.transParamType(request);
  34 + return freeShippingOrderSceneService.productList(paramMap);
  35 + }
  36 +
  37 +}
  1 +package com.yoho.search.service.scene;
  2 +
  3 +import com.yoho.search.base.utils.SearchPageIdDefine;
  4 +import com.yoho.search.common.utils.SearchApiResultUtils;
  5 +import com.yoho.search.models.SearchApiResult;
  6 +import com.yoho.search.service.base.SearchRequestParams;
  7 +import com.yoho.search.service.scene.common.AbstractSceneService;
  8 +import com.yoho.search.service.scene.common.CommonSceneProductListService;
  9 +import org.slf4j.Logger;
  10 +import org.slf4j.LoggerFactory;
  11 +import org.springframework.beans.factory.annotation.Autowired;
  12 +import org.springframework.stereotype.Service;
  13 +
  14 +import java.util.Map;
  15 +
  16 +/**
  17 + * Created by wangnan on 2017/11/21.
  18 + */
  19 +@Service
  20 +public class FreeShippingOrderSceneService extends AbstractSceneService {
  21 +
  22 + private final Logger logger = LoggerFactory.getLogger(this.getClass());
  23 +
  24 + @Autowired
  25 + private CommonSceneProductListService sceneProductListService;
  26 +
  27 + @Override
  28 + public void addParamsToParamMap(Map<String, String> paramMap) {
  29 + super.addDefaultParamsToParamMap(paramMap);
  30 + paramMap.put(SearchRequestParams.PARAM_SEARCH_ISLIMITED, "N");// 不支持限定
  31 + paramMap.put(SearchRequestParams.PARAM_SEARCH_CONTAIN_SECKILL, "N");// 不支持秒杀
  32 + paramMap.put(SearchRequestParams.PARAM_SEARCH_ISADVANCE, "N");// 不支持预售
  33 + paramMap.put(SearchRequestParams.PARAM_SEARCH_BUNDLETYPE, "0");// 不支持套餐
  34 + paramMap.put(SearchRequestParams.PARAM_SEARCH_ISLIMITEDBUY, "N");// 不支持限购
  35 + paramMap.put(SearchRequestParams.PARAM_SEARCH_ISDESPOSITADVANCE, "N");// 不支持定金预售
  36 + paramMap.put(SearchRequestParams.PARAM_SEARCH_ISLIMITTIMEADVANCE, "N");// 不支持定金促销
  37 + }
  38 +
  39 + @Override
  40 + public String pageId() {
  41 + return SearchPageIdDefine.PAGE_ID_DEFAULT;
  42 + }
  43 +
  44 + @Override
  45 + public SearchApiResult productList(Map<String, String> paramMap) {
  46 + try {
  47 + // 1、添加默认参数
  48 + this.addParamsToParamMap(paramMap);
  49 + // 2、返回商品列表
  50 + return sceneProductListService.productList(paramMap);
  51 + } catch (Exception e) {
  52 + logger.error("[func=FreeShippingOrderSceneProductList][params=" + paramMap + "]", e);
  53 + return SearchApiResultUtils.errorSearchApiResult("FreeShippingOrderSceneProductList", paramMap, e);
  54 + }
  55 + }
  56 +
  57 + @Override
  58 + public SearchApiResult aggregations(Map<String, String> paramMap) {
  59 + return null;
  60 + }
  61 +}