From dcfd801ea435c1c87ed47f2ee24cdabaaf230d6f Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期二, 31 三月 2020 12:15:56 +0800
Subject: [PATCH] 大淘客商品过滤修改
---
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/CommonContentControllerV2.java | 78 +++++++++++++++++++++++++++++---------
1 files changed, 59 insertions(+), 19 deletions(-)
diff --git a/fanli/src/main/java/com/yeshi/fanli/controller/client/v2/CommonContentControllerV2.java b/fanli/src/main/java/com/yeshi/fanli/controller/client/v2/CommonContentControllerV2.java
index 652b9dc..8bc6b7a 100644
--- a/fanli/src/main/java/com/yeshi/fanli/controller/client/v2/CommonContentControllerV2.java
+++ b/fanli/src/main/java/com/yeshi/fanli/controller/client/v2/CommonContentControllerV2.java
@@ -7,6 +7,7 @@
import javax.annotation.Resource;
+import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
@@ -14,6 +15,7 @@
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
+import com.yeshi.fanli.dto.ConfigParamsDTO;
import com.yeshi.fanli.dto.common.CommonContentNav;
import com.yeshi.fanli.dto.common.CommonContentResult;
import com.yeshi.fanli.dto.common.CommonContentTypeEnum;
@@ -26,6 +28,7 @@
import com.yeshi.fanli.entity.bus.homemodule.SwiperPicture;
import com.yeshi.fanli.entity.jd.JDGoods;
import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
+import com.yeshi.fanli.entity.taobao.TaoBaoSearchResult;
import com.yeshi.fanli.service.inter.goods.CommonTemplateContentService;
import com.yeshi.fanli.service.inter.goods.JDCommonTemplateContentService;
import com.yeshi.fanli.service.inter.goods.PDDCommonTemplateContentService;
@@ -34,8 +37,10 @@
import com.yeshi.fanli.tag.PageEntity;
import com.yeshi.fanli.util.Constant;
import com.yeshi.fanli.util.StringUtil;
+import com.yeshi.fanli.util.VersionUtil;
import com.yeshi.fanli.util.factory.goods.GoodsDetailVOFactory;
import com.yeshi.fanli.util.taobao.TaoBaoUtil;
+import com.yeshi.fanli.util.taobao.TaoKeApiUtil;
import com.yeshi.fanli.vo.goods.GoodsDetailVO;
import net.sf.json.JSONArray;
@@ -136,34 +141,46 @@
}
private void getListTB(AcceptData acceptData, String key, Integer page, String cid, PrintWriter out) {
- CommonContentResult result = commonTemplateContentService.getContentList(CommonContentTypeEnum.valueOf(key),
- cid, page, Constant.PAGE_SIZE);
-
- // 淇濈暀鏆傛椂涓嶅紑鍚紝寰呭悗缁紑鍚�
- List<SwiperPicture> bannerList = new ArrayList<>();
+ CommonContentResult result = null;
+ CommonContentTypeEnum type = CommonContentTypeEnum.valueOf(key);
+ if (type == CommonContentTypeEnum.guessLikeDevice) {
+ // 鐚滀綘鍠滄
+ String idfa = acceptData.getIdfa();
+ String imei = acceptData.getImei();
+ result = guessLikeDeviceTB(idfa, imei, acceptData.getUtdid(), page);
+ } else {
+ // 澶ф窐瀹㈤〉鐮佸彧鑳戒负10,50,100,200
+ result = commonTemplateContentService.getContentList(type, cid, page, 10);
+ }
JSONObject root = new JSONObject();
- if (page == 1)
+ if (page == 1) {
+ // 淇濈暀鏆傛椂涓嶅紑鍚紝寰呭悗缁紑鍚�
+ List<SwiperPicture> bannerList = new ArrayList<>();
root.put("bannerList", new Gson().toJson(bannerList));
+ }
JSONArray array = new JSONArray();
Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder()).create();
- List<TaoBaoGoodsBrief> goodsList = result.getGoodsList();
- BigDecimal fanLiRate = hongBaoManageService.getFanLiRate();
- BigDecimal shareRate = hongBaoManageService.getShareRate();
+ List<TaoBaoGoodsBrief> goodsList = new ArrayList<>();
+ if (result != null)
+ goodsList = result.getGoodsList();
+ ConfigParamsDTO paramsDTO = hongBaoManageService.getShowComputeRate(acceptData.getPlatform(),
+ acceptData.getVersion());
for (TaoBaoGoodsBrief taoBaoGoodsBrief : goodsList) {
- GoodsDetailVO vo = GoodsDetailVOFactory.convertTaoBao(taoBaoGoodsBrief, null, fanLiRate, shareRate);
- if (CommonContentTypeEnum.valueOf(key) == CommonContentTypeEnum.mianDan)// 鍏嶅崟鍟嗗搧
+ GoodsDetailVO vo = GoodsDetailVOFactory.convertTaoBao(taoBaoGoodsBrief, paramsDTO);
+ if (type == CommonContentTypeEnum.mianDan)// 鍏嶅崟鍟嗗搧
{
vo.getMoneyInfo().setFanliMoney("楼" + TaoBaoUtil.getAfterUseCouplePrice(taoBaoGoodsBrief));
vo.getMoneyInfo().setShareMoney("楼" + TaoBaoUtil.getAfterUseCouplePrice(taoBaoGoodsBrief));
+ vo.getMoneyInfo().setMaxMoney(null);
}
array.add(gson.toJson(vo));
}
root.put("list", array);
- root.put("count", result.getCount());
+ root.put("count", result != null ? result.getCount() : 0);
out.print(JsonUtil.loadTrueResult(root));
}
@@ -196,12 +213,13 @@
List<JDGoods> goodsList = result.getGoodsList();
if (goodsList != null && goodsList.size() > 0) {
- BigDecimal fanLiRate = hongBaoManageService.getFanLiRate();
- BigDecimal shareRate = hongBaoManageService.getShareRate();
Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
.excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
+ ConfigParamsDTO paramsDTO = hongBaoManageService.getShowComputeRate(acceptData.getPlatform(),
+ acceptData.getVersion());
+
for (JDGoods goods : goodsList) {
- array.add(gson.toJson(GoodsDetailVOFactory.convertJDGoods(goods, fanLiRate, shareRate)));
+ array.add(gson.toJson(GoodsDetailVOFactory.convertJDGoods(goods, paramsDTO)));
}
}
}
@@ -226,7 +244,8 @@
// 2銆侀《閮ㄨ疆鎾浘
List<SwiperPicture> bannerList = null;
if (Constant.IS_TEST) {
- bannerList = swiperPictureService.getByBannerCard("index_top");
+ bannerList = swiperPictureService.getByBannerCardAndVersion("index_top", acceptData.getPlatform(),
+ Integer.parseInt(acceptData.getVersion()));
}
if (bannerList == null) {
@@ -245,12 +264,13 @@
List<PDDGoodsDetail> goodsList = result.getGoodsList();
if (goodsList != null && goodsList.size() > 0) {
- BigDecimal fanLiRate = hongBaoManageService.getFanLiRate();
- BigDecimal shareRate = hongBaoManageService.getShareRate();
Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
.excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
+ ConfigParamsDTO paramsDTO = hongBaoManageService.getShowComputeRate(acceptData.getPlatform(),
+ acceptData.getVersion());
+
for (PDDGoodsDetail goods : goodsList) {
- array.add(gson.toJson(GoodsDetailVOFactory.convertPDDGoods(goods, fanLiRate, shareRate)));
+ array.add(gson.toJson(GoodsDetailVOFactory.convertPDDGoods(goods, paramsDTO)));
}
}
}
@@ -260,4 +280,24 @@
out.print(JsonUtil.loadTrueResult(data));
}
+ /**
+ * 鐚滀綘鍠滄-娣樺疂璁惧鎺ㄨ崘
+ *
+ * @param acceptData
+ * @param page
+ * @return
+ */
+ @Cacheable(value = "commonContentCache", key = "#idfa+'-'+#imei+'-'+#page")
+ private CommonContentResult guessLikeDeviceTB(String idfa, String imei, String utdid, Integer page) {
+ TaoBaoSearchResult searchResult = TaoKeApiUtil.guessDeviceLike(page, Constant.PAGE_SIZE, imei, idfa, utdid);
+ if (searchResult != null && searchResult.getTaoBaoGoodsBriefs() != null
+ && searchResult.getTaoBaoGoodsBriefs().size() > 0) {
+ CommonContentResult result = new CommonContentResult();
+ result.setCount(searchResult.getPageEntity().getTotalCount());
+ result.setGoodsList(searchResult.getTaoBaoGoodsBriefs());
+ return result;
+ }
+ return null;
+ }
+
}
--
Gitblit v1.8.0