From 30d8e227e8d823b6c38c3b9c90ac2df03b63befe Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期二, 25 二月 2025 16:41:22 +0800 Subject: [PATCH] 淘宝转链接口更新 --- fanli/src/main/java/com/yeshi/fanli/controller/client/v2/CommonContentControllerV2.java | 441 ++++++++++++++++++++++++++++-------------------------- 1 files changed, 228 insertions(+), 213 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 95be3ef..b0da38a 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 @@ -6,6 +6,10 @@ import javax.annotation.Resource; +import com.yeshi.fanli.entity.goods.CommonGoods; +import com.yeshi.fanli.lijin.manager.GoodsLijinMnager; +import com.yeshi.fanli.util.CommonGoodsUtil; +import com.yeshi.fanli.util.factory.CommonGoodsFactory; import org.springframework.cache.annotation.Cacheable; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; @@ -47,256 +51,267 @@ /** * 閫氱敤妯℃澘 - * - * @author Administrator * + * @author Administrator */ @Controller @RequestMapping("api/v2/commoncontent") public class CommonContentControllerV2 { - @Resource - private SwiperPictureService swiperPictureService; + @Resource + private SwiperPictureService swiperPictureService; - @Resource - private OrderHongBaoMoneyComputeService orderHongBaoMoneyComputeService; + @Resource + private OrderHongBaoMoneyComputeService orderHongBaoMoneyComputeService; - @Resource - private CommonTemplateContentService commonTemplateContentService; + @Resource + private CommonTemplateContentService commonTemplateContentService; - @Resource - private JDCommonTemplateContentService jdCommonTemplateContentService; + @Resource + private JDCommonTemplateContentService jdCommonTemplateContentService; - @Resource - private PDDCommonTemplateContentService pddCommonTemplateContentService; + @Resource + private PDDCommonTemplateContentService pddCommonTemplateContentService; - /** - * 閫氱敤妯℃澘瀵艰埅 - * - * @param acceptData - * @param key - * @param out - */ - @RequestMapping(value = "getNavList", method = RequestMethod.POST) - public void getNavList(AcceptData acceptData, String key, Integer type, PrintWriter out) { - if (StringUtil.isNullOrEmpty(key)) { - out.print(JsonUtil.loadFalseResult(1, "璇蜂紶鍏ey")); - return; - } + @Resource + private GoodsLijinMnager goodsLijinMnager; - List<CommonContentNav> list = null; - if (type == null || type == Constant.SOURCE_TYPE_TAOBAO) { - list = commonTemplateContentService.getNavList(CommonContentTypeEnum.valueOf(key),acceptData.getSystem()); - } else if (type == Constant.SOURCE_TYPE_JD) { - // 鏆傛棤鍒嗙被 - } else if (type == Constant.SOURCE_TYPE_PDD) { - list = pddCommonTemplateContentService.getNavList(PDDCommonContentTypeEnum.valueOf(key)); - } + /** + * 閫氱敤妯℃澘瀵艰埅 + * + * @param acceptData + * @param key + * @param out + */ + @RequestMapping(value = "getNavList", method = RequestMethod.POST) + public void getNavList(AcceptData acceptData, String key, Integer type, PrintWriter out) { + if (StringUtil.isNullOrEmpty(key)) { + out.print(JsonUtil.loadFalseResult(1, "璇蜂紶鍏ey")); + return; + } - if (list == null) { - list = new ArrayList<CommonContentNav>(); - } + List<CommonContentNav> list = null; + if (type == null || type == Constant.SOURCE_TYPE_TAOBAO) { + list = commonTemplateContentService.getNavList(CommonContentTypeEnum.valueOf(key), acceptData.getSystem()); + } else if (type == Constant.SOURCE_TYPE_JD) { + // 鏆傛棤鍒嗙被 + } else if (type == Constant.SOURCE_TYPE_PDD) { + list = pddCommonTemplateContentService.getNavList(PDDCommonContentTypeEnum.valueOf(key)); + } - out.print(JsonUtil.loadTrueResult(new Gson().toJson(list))); - } + if (list == null) { + list = new ArrayList<CommonContentNav>(); + } - /** - * 鑾峰彇鍐呭 - * - * @param acceptData - * @param key - * @param page-椤电爜 - * @param navId-瀵艰埅ID - * @param out - */ - @RequestMapping(value = "getNavGoodsList", method = RequestMethod.POST) - 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; - } + out.print(JsonUtil.loadTrueResult(new Gson().toJson(list))); + } - if (page == null || page < 1) { - out.print(JsonUtil.loadFalseResult(1, "璇蜂紶鍏ユ纭殑page")); - return; - } + /** + * 鑾峰彇鍐呭 + * + * @param acceptData + * @param uid + * @param key + * @param type + * @param page + * @param cid + * @param out + */ + @RequestMapping(value = "getNavGoodsList", method = RequestMethod.POST) + public void getNavContent(AcceptData acceptData, Long uid, String key, Integer type, Integer page, String cid, + PrintWriter out) { + if (StringUtil.isNullOrEmpty(key)) { + out.print(JsonUtil.loadFalseResult(1, "璇蜂紶鍏ey")); + return; + } - if (type == null || type == Constant.SOURCE_TYPE_TAOBAO) { - getListTB(acceptData, key, page, cid, out); - return; - } + if (page == null || page < 1) { + out.print(JsonUtil.loadFalseResult(1, "璇蜂紶鍏ユ纭殑page")); + return; + } - if (type == Constant.SOURCE_TYPE_JD) { - getListJD(acceptData, key, page, cid, out); - return; - } + if (type == null || type == Constant.SOURCE_TYPE_TAOBAO) { + getListTB(acceptData, uid, key, page, cid, out); + return; + } - if (type == Constant.SOURCE_TYPE_PDD) { - getListPDD(acceptData, key, page, cid, out); - return; - } - out.print(JsonUtil.loadFalseResult("goodsType鍙傛暟涓嶆纭�")); - } + if (type == Constant.SOURCE_TYPE_JD) { + getListJD(acceptData, uid, key, page, cid, out); + return; + } - private void getListTB(AcceptData acceptData, String key, Integer page, String cid, PrintWriter out) { - 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,acceptData.getSystem()); - } + if (type == Constant.SOURCE_TYPE_PDD) { + getListPDD(acceptData, uid, key, page, cid, out); + return; + } + out.print(JsonUtil.loadFalseResult("goodsType鍙傛暟涓嶆纭�")); + } - JSONObject root = new JSONObject(); - if (page == 1) { - // 淇濈暀鏆傛椂涓嶅紑鍚紝寰呭悗缁紑鍚� - List<SwiperPicture> bannerList = new ArrayList<>(); - root.put("bannerList", new Gson().toJson(bannerList)); - } + private void getListTB(AcceptData acceptData, Long uid, String key, Integer page, String cid, PrintWriter out) { + 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, acceptData.getSystem()); + } - JSONArray array = new JSONArray(); - Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder()).create(); - List<TaoBaoGoodsBrief> goodsList = new ArrayList<>(); - if (result != null) - goodsList = result.getGoodsList(); + JSONObject root = new JSONObject(); + if (page == 1) { + // 淇濈暀鏆傛椂涓嶅紑鍚紝寰呭悗缁紑鍚� + List<SwiperPicture> bannerList = new ArrayList<>(); + root.put("bannerList", new Gson().toJson(bannerList)); + } - GoodsMoneyConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate(acceptData.getPlatform(), - acceptData.getVersion(),acceptData.getSystem()); - for (TaoBaoGoodsBrief taoBaoGoodsBrief : goodsList) { - GoodsDetailVO vo = GoodsDetailVOFactory.convertTaoBao(taoBaoGoodsBrief, paramsDTO); - if (type == CommonContentTypeEnum.mianDan)// 鍏嶅崟鍟嗗搧 - { - vo.getMoneyInfo().setFanliMoney("楼" + TaoBaoUtil.getCouponPrice(taoBaoGoodsBrief)); - vo.getMoneyInfo().setShareMoney("楼" + TaoBaoUtil.getCouponPrice(taoBaoGoodsBrief)); - vo.getMoneyInfo().setMaxMoney(null); - } - array.add(gson.toJson(vo)); - } + JSONArray array = new JSONArray(); + Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder()).create(); + List<CommonGoods> goodsList = new ArrayList<>(); + if (result != null) + goodsList = result.getGoodsList(); - root.put("list", array); - root.put("count", result != null ? result.getCount() : 0); - out.print(JsonUtil.loadTrueResult(root)); - } + GoodsMoneyConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate(acceptData.getPlatform(), + acceptData.getVersion(), acceptData.getSystem()); - /** - * 浜笢閫氱敤涓撻妯℃澘 - * - * @param acceptData - * @param key - * @param page - * @param cid - * @param out - */ - public void getListJD(AcceptData acceptData, String key, Integer page, String cid, PrintWriter out) { - JSONObject data = new JSONObject(); - if (page == 1) { - List<SwiperPicture> bannerList = new ArrayList<>(); - data.put("bannerList", new Gson().toJson(bannerList)); - } + List<GoodsDetailVO> goodsDetailVOList = goodsLijinMnager.loadCommonGoodsMoneyInfo(acceptData.getSystem(), uid, goodsList, paramsDTO); + int p = 0; + for (GoodsDetailVO vo : goodsDetailVOList) { + vo.setCreatetime(null); + if (type == CommonContentTypeEnum.mianDan)// 鍏嶅崟鍟嗗搧 + { + vo.getMoneyInfo().setFanliMoney("楼" + CommonGoodsUtil.getAfterUseCouplePrice(goodsList.get(p))); + vo.getMoneyInfo().setShareMoney("楼" + CommonGoodsUtil.getAfterUseCouplePrice(goodsList.get(p))); + vo.getMoneyInfo().setMaxMoney(null); + } + array.add(gson.toJson(vo)); + p++; + } - JDSearchResult result = jdCommonTemplateContentService.getContentList(JDCommonContentTypeEnum.valueOf(key), cid, - page, Constant.PAGE_SIZE); - JSONArray array = new JSONArray(); + root.put("list", array); + root.put("count", result != null ? result.getCount() : 0); + out.print(JsonUtil.loadTrueResult(root)); + } - long count = 0; - if (result != null) { - PageEntity pageEntity = result.getPageEntity(); - if (pageEntity != null) { - count = pageEntity.getTotalCount(); - } + /** + * 浜笢閫氱敤涓撻妯℃澘 + * + * @param acceptData + * @param key + * @param page + * @param cid + * @param out + */ + public void getListJD(AcceptData acceptData, Long uid, String key, Integer page, String cid, PrintWriter out) { + JSONObject data = new JSONObject(); + if (page == 1) { + List<SwiperPicture> bannerList = new ArrayList<>(); + data.put("bannerList", new Gson().toJson(bannerList)); + } - List<JDGoods> goodsList = result.getGoodsList(); - if (goodsList != null && goodsList.size() > 0) { - Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder()) - .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create(); - GoodsMoneyConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate(acceptData.getPlatform(), - acceptData.getVersion(),acceptData.getSystem()); + JDSearchResult result = jdCommonTemplateContentService.getContentList(JDCommonContentTypeEnum.valueOf(key), cid, + page, Constant.PAGE_SIZE); + JSONArray array = new JSONArray(); - for (JDGoods goods : goodsList) { - array.add(gson.toJson(GoodsDetailVOFactory.convertJDGoods(goods, paramsDTO))); - } - } - } + long count = 0; + if (result != null) { + PageEntity pageEntity = result.getPageEntity(); + if (pageEntity != null) { + count = pageEntity.getTotalCount(); + } - data.put("list", array); - data.put("count", count); - out.print(JsonUtil.loadTrueResult(data)); - } + List<JDGoods> goodsList = result.getGoodsList(); + if (goodsList != null && goodsList.size() > 0) { + Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder()) + .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create(); + GoodsMoneyConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate(acceptData.getPlatform(), + acceptData.getVersion(), acceptData.getSystem()); - /** - * 鎷煎澶氶�氱敤涓撻妯℃澘 - * - * @param acceptData - * @param key - * @param page - * @param cid - * @param out - */ - public void getListPDD(AcceptData acceptData, String key, Integer page, String cid, PrintWriter out) { - JSONObject data = new JSONObject(); - if (page == 1) { - // 2銆侀《閮ㄨ疆鎾浘 - List<BannerVO> bannerList = null; - if (Constant.IS_TEST) { - bannerList = swiperPictureService.getByBannerCardAndVersion("index_top", acceptData.getPlatform(), - Integer.parseInt(acceptData.getVersion()),acceptData.getSystem()); - } + List<GoodsDetailVO> voList = goodsLijinMnager.loadOtherMoneyInfo(acceptData.getSystem(), uid, goodsList, paramsDTO); + for (GoodsDetailVO goods : voList) { + array.add(gson.toJson(goods)); + } + } + } - if (bannerList == null) { - bannerList = new ArrayList<BannerVO>(); - } + data.put("list", array); + data.put("count", count); + out.print(JsonUtil.loadTrueResult(data)); + } - data.put("bannerList", new Gson().toJson(bannerList)); - } + /** + * 鎷煎澶氶�氱敤涓撻妯℃澘 + * + * @param acceptData + * @param key + * @param page + * @param cid + * @param out + */ + public void getListPDD(AcceptData acceptData, Long uid, String key, Integer page, String cid, PrintWriter out) { + JSONObject data = new JSONObject(); + if (page == 1) { + // 2銆侀《閮ㄨ疆鎾浘 + List<BannerVO> bannerList = null; + if (Constant.IS_TEST) { + bannerList = swiperPictureService.getByBannerCardAndVersion("index_top", acceptData.getPlatform(), + Integer.parseInt(acceptData.getVersion()), acceptData.getSystem()); + } - 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(); + if (bannerList == null) { + bannerList = new ArrayList<BannerVO>(); + } - List<PDDGoodsDetail> goodsList = result.getGoodsList(); - if (goodsList != null && goodsList.size() > 0) { - Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder()) - .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create(); - GoodsMoneyConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate(acceptData.getPlatform(), - acceptData.getVersion(),acceptData.getSystem()); + data.put("bannerList", new Gson().toJson(bannerList)); + } - for (PDDGoodsDetail goods : goodsList) { - array.add(gson.toJson(GoodsDetailVOFactory.convertPDDGoods(goods, paramsDTO))); - } - } - } + 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(); - data.put("list", array); - data.put("count", count); - out.print(JsonUtil.loadTrueResult(data)); - } + List<PDDGoodsDetail> goodsList = result.getGoodsList(); + if (goodsList != null && goodsList.size() > 0) { + Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder()) + .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create(); + GoodsMoneyConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate(acceptData.getPlatform(), + acceptData.getVersion(), acceptData.getSystem()); - /** - * 鐚滀綘鍠滄-娣樺疂璁惧鎺ㄨ崘 - * - * @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; - } + List<GoodsDetailVO> voList = goodsLijinMnager.loadOtherMoneyInfo(acceptData.getSystem(), uid, goodsList, paramsDTO); + for (GoodsDetailVO goods : voList) { + array.add(gson.toJson(goods)); + } + } + } + + data.put("list", array); + data.put("count", count); + out.print(JsonUtil.loadTrueResult(data)); + } + + /** + * 鐚滀綘鍠滄-娣樺疂璁惧鎺ㄨ崘 + * + * @param idfa + * @param imei + * @param utdid + * @param page + * @return + */ + 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(CommonGoodsFactory.createTaoBaoList(searchResult.getTaoBaoGoodsBriefs())); + return result; + } + return null; + } } -- Gitblit v1.8.0