From 20d1a38a0f8049873f1fbbaef96c22e971ea9d77 Mon Sep 17 00:00:00 2001 From: yujian <yujian@123.com> Date: 星期三, 17 七月 2019 15:50:09 +0800 Subject: [PATCH] 搜索词 --- fanli/src/main/java/com/yeshi/fanli/controller/client/v2/GoodsControllerV2.java | 140 +++++++++++++++++++++++++++++++++++++++++----- 1 files changed, 124 insertions(+), 16 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/controller/client/v2/GoodsControllerV2.java b/fanli/src/main/java/com/yeshi/fanli/controller/client/v2/GoodsControllerV2.java index 3cfb1ec..cb35924 100644 --- a/fanli/src/main/java/com/yeshi/fanli/controller/client/v2/GoodsControllerV2.java +++ b/fanli/src/main/java/com/yeshi/fanli/controller/client/v2/GoodsControllerV2.java @@ -28,6 +28,7 @@ import com.yeshi.fanli.entity.taobao.TaoBaoShop; import com.yeshi.fanli.entity.taobao.TaoBaoUnionConfig; import com.yeshi.fanli.entity.taobao.TaoKeAppInfo; +import com.yeshi.fanli.exception.taobao.TaoKeApiException; import com.yeshi.fanli.exception.taobao.TaobaoGoodsDownException; import com.yeshi.fanli.exception.taobao.TaobaoGoodsUpdateException; import com.yeshi.fanli.log.LogHelper; @@ -69,7 +70,7 @@ import com.yeshi.fanli.vo.goods.GoodsDetailVO; import com.yeshi.fanli.vo.goods.MoneyInfoVO; import com.yeshi.fanli.vo.goods.OtherInfo; -import com.yeshi.fanli.vo.goods.ShareInfoVO; +import com.yeshi.fanli.vo.goods.ShareVO; import com.yeshi.fanli.vo.msg.ClientTextStyleVO; import com.yeshi.fanli.vo.tlj.ReduceHongBao; import com.yeshi.fanli.vo.tlj.SpreadHongBao; @@ -159,13 +160,13 @@ */ @RequestMapping(value = "getDetail", method = RequestMethod.POST) public void getDetail(AcceptData acceptData, Long id, Integer goodsType, Long uid, String from, PrintWriter out) { - if (id == null || goodsType == null) { - out.print(JsonUtil.loadFalseResult(1, "鍟嗗搧id鍜屽晢鍝佸钩鍙颁笉鑳戒负绌�")); + if (id == null) { + out.print(JsonUtil.loadFalseResult(1, "鍟嗗搧id涓嶈兘涓虹┖")); return; } - + // 娣樺疂鍟嗗搧 - if (Constant.SOURCE_TYPE_TAOBAO == goodsType) { + if (goodsType == null || Constant.SOURCE_TYPE_TAOBAO == goodsType) { getTaoBaoGoodsDetial(acceptData, id, uid, from, out); return; } @@ -346,10 +347,10 @@ BigDecimal fanLiRate = hongBaoManageService.getFanLiRate(); BigDecimal shareRate = hongBaoManageService.getShareRate(); - GoodsDetailVO goodsDetail = GoodsDetailVOFactory.convertTaoBao(tb, null, fanLiRate, shareRate); + GoodsDetailVO goodsDetail = GoodsDetailVOFactory.convertTaoBao(goods, null, fanLiRate, shareRate); // 搴楅摵淇℃伅 - TaoBaoShop shop = taoBaoShopService.getTaoBaoShop(goods.getAuctionId(), goods.getSellerId()); + TaoBaoShop shop = taoBaoShopService.getTaoBaoShop(id, goods.getSellerId()); if (shop != null) { String shopLink = shop.getShopLink(); if (StringUtil.isNullOrEmpty(shopLink)) { @@ -450,11 +451,11 @@ SpreadHongBao spreadHongBao = new SpreadHongBao(); if (isNewUser) { - spreadHongBao.setMoney("楼1"); + spreadHongBao.setMoney("1"); } else { moneyType = 2; fanliValid = false; - spreadHongBao.setMoney("楼" + spreadMoney.toString()); + spreadHongBao.setMoney(spreadMoney.toString()); ClientTextStyleVO textStyleVO1 = new ClientTextStyleVO(); textStyleVO1.setContent("鍒嗕韩"); @@ -511,7 +512,7 @@ ReduceHongBao reduceHongBao = new ReduceHongBao(); reduceHongBao.setLeft(buyGoods.getLeftHongBaoCount()); reduceHongBao.setMoney(tljHongBao); - reduceHongBao.setName("浠樻绔嬪噺 楼" + tljHongBao); + reduceHongBao.setName("浠樻绔嬪噺 "); reduceHongBao.setTip("褰撴棩棰嗗彇锛屽綋鏃ュ唴浣跨敤锛岃繃鏈熷け鏁�"); reduceHongBao.setTotal(buyGoods.getTotalHongBaoCount()); @@ -536,10 +537,10 @@ // 鍒嗕韩璺緞 String shareUrl = String.format("%s?id=" + id, Constant.systemCommonConfig.getAppShareInfoUrl()); - ShareInfoVO shareInfoVO = new ShareInfoVO(); + ShareVO shareInfoVO = new ShareVO(); shareInfoVO.setUrl(shareUrl); shareInfoVO.setHelpLink(helpLink); - extraVO.setShareInfo(shareInfoVO); + extraVO.setShare(shareInfoVO); JSONObject object = new JSONObject(); object.put("extra", JsonUtil.getApiCommonGson().toJson(extraVO)); @@ -664,10 +665,10 @@ // 鍒嗕韩璺緞 String shareUrl = String.format("%s?id=" + jdGoods.getSkuId(), Constant.systemCommonConfig.getAppShareInfoUrl()); - ShareInfoVO shareInfoVO = new ShareInfoVO(); + ShareVO shareInfoVO = new ShareVO(); shareInfoVO.setUrl(shareUrl); shareInfoVO.setHelpLink(helpLink); - extraVO.setShareInfo(shareInfoVO); + extraVO.setShare(shareInfoVO); JSONObject object = new JSONObject(); object.put("extra", JsonUtil.getApiCommonGson().toJson(extraVO)); @@ -776,10 +777,10 @@ } // 鍒嗕韩璺緞 String shareUrl = String.format("%s?id=" + id, Constant.systemCommonConfig.getAppShareInfoUrl()); - ShareInfoVO shareInfoVO = new ShareInfoVO(); + ShareVO shareInfoVO = new ShareVO(); shareInfoVO.setUrl(shareUrl); shareInfoVO.setHelpLink(helpLink); - extraVO.setShareInfo(shareInfoVO); + extraVO.setShare(shareInfoVO); JSONObject object = new JSONObject(); object.put("extra", JsonUtil.getApiCommonGson().toJson(extraVO)); @@ -797,5 +798,112 @@ } }); } + + + /** + * 鍟嗗搧璇︽儏鎺ㄨ崘锛堢寽浣犲枩娆� + 鎺ㄨ崘锛� + * + * @param acceptData + * @param id + * @param out + */ + @RequestMapping(value = "getRecommendGoods", method = RequestMethod.POST) + public void getRecommendGoods(AcceptData acceptData, long id, Integer goodsType, PrintWriter out) { + if (goodsType == null) { + goodsType = Constant.SOURCE_TYPE_TAOBAO; + } + + // 浜笢 + if (goodsType == Constant.SOURCE_TYPE_JD) { + JSONObject data = new JSONObject(); + data.put("listQuality", JsonUtil.getApiCommonGson().toJson(new ArrayList<GoodsDetailVO>())); + data.put("listGuess", JsonUtil.getApiCommonGson().toJson(new ArrayList<GoodsDetailVO>())); + out.print(JsonUtil.loadTrueResult(data)); + return; + } + + // 鎷煎澶� + if (goodsType == Constant.SOURCE_TYPE_PDD) { + JSONObject data = new JSONObject(); + data.put("listQuality", JsonUtil.getApiCommonGson().toJson(new ArrayList<GoodsDetailVO>())); + data.put("listGuess", JsonUtil.getApiCommonGson().toJson(new ArrayList<GoodsDetailVO>())); + out.print(JsonUtil.loadTrueResult(data)); + return; + } + + + List<TaoBaoGoodsBrief> goodsList = TaoKeApiUtil.getRelationGoodsRecommend(id, 10); + // 鍒濆鍖� + if (goodsList == null) { + goodsList = new ArrayList<TaoBaoGoodsBrief>(); + } + + + List<GoodsDetailVO> listExtra = new ArrayList<GoodsDetailVO>(); + TaoKeAppInfo app = new TaoKeAppInfo(); + app.setAppKey(TaoBaoConstant.TAOBAO_AUTH_APPKEY); + app.setAppSecret(TaoBaoConstant.TAOBAO_AUTH_APPSECRET); + app.setAdzoneId(TaoBaoConstant.TAOBAO_SPECIAL_PID_DEFAULT.split("_")[3]); + app.setPid(TaoBaoConstant.TAOBAO_SPECIAL_PID_DEFAULT); + + List<Long> ids = new ArrayList<>(); + for (TaoBaoGoodsBrief goods : goodsList) + ids.add(goods.getAuctionId()); + + try { + goodsList = TaoKeApiUtil.getBatchGoodsInfo(ids); + } catch (TaoKeApiException e1) { + e1.printStackTrace(); + } catch (TaobaoGoodsDownException e1) { + e1.printStackTrace(); + } + + if (goodsList != null && goodsList.size() > 0) { + + BigDecimal fanLiRate = hongBaoManageService.getFanLiRate(); + BigDecimal shareRate = hongBaoManageService.getShareRate(); + + goodsList.parallelStream().forEach(goods -> { + if (goods != null) { + // 鑾峰彇璇︽儏 + TaoBaoGoodsBrief taoBaoGoodsBrief = null; + try { + taoBaoGoodsBrief = taoBaoGoodsCacheUtil.getCommonTaoBaoGoodsInfo(goods.getAuctionId()); + } catch (Exception e) { + e.printStackTrace(); + } + + if (taoBaoGoodsBrief == null) { + TaoBaoGoodsBrief newGoods = TaoKeApiUtil.specialConvertCoupon(goods.getAuctionId(), app); + goods.setCouponInfo(newGoods.getCouponInfo()); + goods.setCouponLink(newGoods.getCouponLink()); + goods.setTkRate(newGoods.getTkRate()); + taoBaoGoodsBrief = goods; + } + + if (taoBaoGoodsBrief != null) { + listExtra.add(GoodsDetailVOFactory.convertTaoBao(taoBaoGoodsBrief, null, fanLiRate, shareRate)); + } + } + }); + } + + + List<GoodsDetailVO> listQuality = new ArrayList<GoodsDetailVO>(); + // 鍙栧伓鏁颁釜鏁版嵁 + if (listExtra.size() % 2 != 0) { + listExtra.remove(listExtra.size() - 1); + } + + if (listQuality.size() % 2 != 0) { + listQuality.remove(listQuality.size() - 1); + } + + JSONObject data = new JSONObject(); + data.put("listQuality", JsonUtil.getApiCommonGson().toJson(listExtra)); + data.put("listGuess", JsonUtil.getApiCommonGson().toJson(listQuality)); + out.print(JsonUtil.loadTrueResult(data)); + } + } -- Gitblit v1.8.0