From 5e8907f1797a0f2028ab0731755941cf9ff7fc08 Mon Sep 17 00:00:00 2001
From: admin <2780501319@qq.com>
Date: 星期六, 02 十一月 2019 00:29:27 +0800
Subject: [PATCH] RocketMQ消息实体改造
---
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/CommonContentControllerV2.java | 141 +++++++++++++++++++++++++++++++++--------------
1 files changed, 99 insertions(+), 42 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 24d6b30..ddee89a 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,14 +28,19 @@
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;
-import com.yeshi.fanli.service.inter.hongbao.HongBaoManageService;
+import com.yeshi.fanli.service.inter.homemodule.SwiperPictureService;
+import com.yeshi.fanli.service.inter.order.config.HongBaoManageService;
import com.yeshi.fanli.tag.PageEntity;
import com.yeshi.fanli.util.Constant;
import com.yeshi.fanli.util.StringUtil;
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;
import net.sf.json.JSONObject;
@@ -48,6 +55,8 @@
@RequestMapping("api/v2/commoncontent")
public class CommonContentControllerV2 {
+ @Resource
+ private SwiperPictureService swiperPictureService;
@Resource
private HongBaoManageService hongBaoManageService;
@@ -61,7 +70,6 @@
@Resource
private PDDCommonTemplateContentService pddCommonTemplateContentService;
-
/**
* 閫氱敤妯℃澘瀵艰埅
*
@@ -70,28 +78,28 @@
* @param out
*/
@RequestMapping(value = "getNavList", method = RequestMethod.POST)
- public void getNavList(AcceptData acceptData, String key, Integer goodsType, PrintWriter out) {
+ public void getNavList(AcceptData acceptData, String key, Integer type, PrintWriter out) {
if (StringUtil.isNullOrEmpty(key)) {
out.print(JsonUtil.loadFalseResult(1, "璇蜂紶鍏ey"));
return;
}
-
+
List<CommonContentNav> list = null;
- if (goodsType == null || goodsType == Constant.SOURCE_TYPE_TAOBAO) {
+ if (type == null || type == Constant.SOURCE_TYPE_TAOBAO) {
list = commonTemplateContentService.getNavList(CommonContentTypeEnum.valueOf(key));
- } else if (goodsType == Constant.SOURCE_TYPE_JD) {
+ } else if (type == Constant.SOURCE_TYPE_JD) {
// 鏆傛棤鍒嗙被
- } else if (goodsType == Constant.SOURCE_TYPE_PDD) {
- // 鏆傛棤鍒嗙被
+ } else if (type == Constant.SOURCE_TYPE_PDD) {
+ list = pddCommonTemplateContentService.getNavList(PDDCommonContentTypeEnum.valueOf(key));
}
-
+
if (list == null) {
list = new ArrayList<CommonContentNav>();
}
-
+
out.print(JsonUtil.loadTrueResult(new Gson().toJson(list)));
}
-
+
/**
* 鑾峰彇鍐呭
*
@@ -102,7 +110,8 @@
* @param out
*/
@RequestMapping(value = "getNavGoodsList", method = RequestMethod.POST)
- public void getNavContent(AcceptData acceptData, String key, Integer goodsType, Integer page, String cid, PrintWriter out) {
+ public void getNavContent(AcceptData acceptData, String key, Integer type, Integer page, String cid,
+ PrintWriter out) {
if (StringUtil.isNullOrEmpty(key)) {
out.print(JsonUtil.loadFalseResult(1, "璇蜂紶鍏ey"));
return;
@@ -113,52 +122,67 @@
return;
}
- if (goodsType == null || goodsType == Constant.SOURCE_TYPE_TAOBAO) {
+ if (type == null || type == Constant.SOURCE_TYPE_TAOBAO) {
getListTB(acceptData, key, page, cid, out);
return;
}
-
- if (goodsType == Constant.SOURCE_TYPE_JD) {
+
+ if (type == Constant.SOURCE_TYPE_JD) {
getListJD(acceptData, key, page, cid, out);
return;
}
-
- if (goodsType == Constant.SOURCE_TYPE_PDD) {
+
+ if (type == Constant.SOURCE_TYPE_PDD) {
getListPDD(acceptData, key, page, cid, out);
return;
}
out.print(JsonUtil.loadFalseResult("goodsType鍙傛暟涓嶆纭�"));
}
-
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, 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();
+ ConfigParamsDTO paramsDTO = new ConfigParamsDTO(fanLiRate, shareRate, Constant.MAX_REWARD_RATE);
for (TaoBaoGoodsBrief taoBaoGoodsBrief : goodsList) {
- array.add(gson.toJson(GoodsDetailVOFactory.convertTaoBao(taoBaoGoodsBrief, null, fanLiRate, shareRate)));
+ GoodsDetailVO vo = GoodsDetailVOFactory.convertTaoBao(taoBaoGoodsBrief, paramsDTO);
+ if (type == CommonContentTypeEnum.mianDan)// 鍏嶅崟鍟嗗搧
+ {
+ vo.getMoneyInfo().setFanliMoney("楼" + TaoBaoUtil.getAfterUseCouplePrice(taoBaoGoodsBrief));
+ vo.getMoneyInfo().setShareMoney("楼" + TaoBaoUtil.getAfterUseCouplePrice(taoBaoGoodsBrief));
+ }
+ array.add(gson.toJson(vo));
}
-
+
root.put("list", array);
root.put("count", result.getCount());
out.print(JsonUtil.loadTrueResult(root));
}
-
-
+
/**
* 浜笢閫氱敤涓撻妯℃澘
+ *
* @param acceptData
* @param key
* @param page
@@ -172,36 +196,38 @@
data.put("bannerList", new Gson().toJson(bannerList));
}
- JDSearchResult result = jdCommonTemplateContentService.getContentList(JDCommonContentTypeEnum.valueOf(key), cid, page, Constant.PAGE_SIZE);
+ JDSearchResult result = jdCommonTemplateContentService.getContentList(JDCommonContentTypeEnum.valueOf(key), cid,
+ page, Constant.PAGE_SIZE);
JSONArray array = new JSONArray();
-
+
long count = 0;
if (result != null) {
PageEntity pageEntity = result.getPageEntity();
if (pageEntity != null) {
count = pageEntity.getTotalCount();
}
-
+
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 = new ConfigParamsDTO(fanLiRate, shareRate, Constant.MAX_REWARD_RATE);
for (JDGoods goods : goodsList) {
- array.add(gson.toJson(GoodsDetailVOFactory.convertJDGoods(goods, null, fanLiRate, shareRate)));
+ array.add(gson.toJson(GoodsDetailVOFactory.convertJDGoods(goods, paramsDTO)));
}
}
}
-
+
data.put("list", array);
data.put("count", count);
out.print(JsonUtil.loadTrueResult(data));
}
-
-
+
/**
- * 鎷煎澶氶�氱敤涓撻妯℃澘
+ * 鎷煎澶氶�氱敤涓撻妯℃澘
+ *
* @param acceptData
* @param key
* @param page
@@ -211,31 +237,62 @@
public void getListPDD(AcceptData acceptData, String key, Integer page, String cid, PrintWriter out) {
JSONObject data = new JSONObject();
if (page == 1) {
- List<SwiperPicture> bannerList = new ArrayList<>();
+ // 2銆侀《閮ㄨ疆鎾浘
+ List<SwiperPicture> bannerList = null;
+ if (Constant.IS_TEST) {
+ bannerList = swiperPictureService.getByBannerCard("index_top");
+ }
+
+ if (bannerList == null) {
+ bannerList = new ArrayList<SwiperPicture>();
+ }
+
data.put("bannerList", new Gson().toJson(bannerList));
}
-
- PDDGoodsResult result = pddCommonTemplateContentService.getContentList(PDDCommonContentTypeEnum.valueOf(key), cid, page, Constant.PAGE_SIZE);
+
+ PDDGoodsResult result = pddCommonTemplateContentService.getContentList(PDDCommonContentTypeEnum.valueOf(key),
+ cid, page, Constant.PAGE_SIZE);
JSONArray array = new JSONArray();
long count = 0;
if (result != null) {
count = result.getTotalCount();
-
+
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 = new ConfigParamsDTO(fanLiRate, shareRate, Constant.MAX_REWARD_RATE);
for (PDDGoodsDetail goods : goodsList) {
- array.add(gson.toJson(GoodsDetailVOFactory.convertPDDGoods(goods, null, fanLiRate, shareRate)));
+ array.add(gson.toJson(GoodsDetailVOFactory.convertPDDGoods(goods, paramsDTO)));
}
}
}
-
+
data.put("list", array);
data.put("count", count);
out.print(JsonUtil.loadTrueResult(data));
}
+ /**
+ * 鐚滀綘鍠滄-娣樺疂璁惧鎺ㄨ崘
+ *
+ * @param acceptData
+ * @param page
+ * @return
+ */
+ @Cacheable(value = "commonContentCache", key = "#idfa+'-'+#imei+'-'+#page")
+ private CommonContentResult guessLikeDeviceTB(String idfa, String imei, Integer page) {
+ TaoBaoSearchResult searchResult = TaoKeApiUtil.guessDeviceLike(page, Constant.PAGE_SIZE, imei, idfa);
+ 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