From ad1c19461fee4c7c4a26795bef75d26f9738faf1 Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期二, 03 十二月 2019 12:26:05 +0800 Subject: [PATCH] 多图分享修改 --- fanli/src/main/java/com/yeshi/fanli/controller/client/v2/GoodsControllerV2.java | 192 ++++++++++++++++++++++++++++++++++++++++++----- 1 files changed, 170 insertions(+), 22 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 89b75a2..17d190b 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 @@ -4,7 +4,9 @@ import java.math.BigDecimal; import java.util.ArrayList; import java.util.Date; +import java.util.HashMap; import java.util.List; +import java.util.Map; import javax.annotation.Resource; @@ -16,6 +18,7 @@ import org.yeshi.utils.JsonUtil; import org.yeshi.utils.taobao.TbImgUtil; +import com.google.gson.Gson; import com.yeshi.fanli.dto.ConfigParamsDTO; import com.yeshi.fanli.dto.jd.JDCategoryInfo; import com.yeshi.fanli.dto.jd.JDCouponInfo; @@ -28,6 +31,7 @@ import com.yeshi.fanli.entity.bus.user.UserInfo; import com.yeshi.fanli.entity.bus.user.UserMoneyExtra; import com.yeshi.fanli.entity.goods.CollectionGoodsV2; +import com.yeshi.fanli.entity.goods.CommonGoods; import com.yeshi.fanli.entity.jd.JDGoods; import com.yeshi.fanli.entity.jd.JDGoodsClass; import com.yeshi.fanli.entity.system.BusinessSystem; @@ -73,6 +77,7 @@ import com.yeshi.fanli.util.TaoBaoConstant; import com.yeshi.fanli.util.ThreadUtil; import com.yeshi.fanli.util.TimeUtil; +import com.yeshi.fanli.util.VersionUtil; import com.yeshi.fanli.util.cache.JDGoodsCacheUtil; import com.yeshi.fanli.util.cache.PinDuoDuoCacheUtil; import com.yeshi.fanli.util.cache.TaoBaoGoodsCacheUtil; @@ -97,6 +102,7 @@ import com.yeshi.fanli.vo.tlj.ReduceHongBao; import com.yeshi.fanli.vo.tlj.SpreadHongBao; +import net.sf.json.JSON; import net.sf.json.JSONObject; @Controller @@ -557,10 +563,16 @@ rewardCoupon.setJumpDetail(jumpDetailV2Service.getByTypeCache("web")); JSONObject params1 = new JSONObject(); params1.put("url", configService.get("special_guide_reward_coupon_link")); - rewardCoupon.setParams(params1.toString()); + rewardCoupon.setMaxMoney("楼" + TaoBaoUtil.getGoodsHongBaoMoney(goods, fanLiRate).add(MoneyBigDecimalUtil .mul(TaoBaoUtil.getGoodsHongBaoMoney(goods, fanLiRate), Constant.MAX_REWARD_RATE))); - rewardCoupon.setDesc("鐢ㄨ繑鍒╁鍔卞埜鏈�楂樿繑"); + if (VersionUtil.greaterThan_2_1(acceptData.getPlatform(), acceptData.getVersion())) { + rewardCoupon.setDesc("杩�"); + params1.put("url", configService.get("vip_link")); + rewardCoupon.getJumpDetail().setNeedLogin(true); + } else + rewardCoupon.setDesc("鐢ㄨ繑鍒╁鍔卞埜鏈�楂樿繑"); + rewardCoupon.setParams(params1.toString()); otherInfo.setRewardCoupon(rewardCoupon); goodsDetail.setOtherInfo(otherInfo); } @@ -663,9 +675,14 @@ BigDecimal fanliMoneyPlus = JDUtil.getGoodsFanLiMoneyPlus(jdGoods, fanLiRate); otherInfo.setFanliMoneyPlus("浜笢plus浼氬憳杩斅�" + fanliMoneyPlus); // 浣跨敤濂栧姳鍒告渶楂樿繑 - maxMoneyPlus = "锛堜含涓減lus浼氬憳鏈�楂樿繑楼" - + fanliMoneyPlus.add(MoneyBigDecimalUtil.mul(fanliMoneyPlus, Constant.MAX_REWARD_RATE)) - + "锛�"; + if (VersionUtil.greaterThan_2_1(acceptData.getPlatform(), acceptData.getVersion())) { + maxMoneyPlus = "锛堜含涓減lus杩斅�" + + fanliMoneyPlus.add(MoneyBigDecimalUtil.mul(fanliMoneyPlus, Constant.MAX_REWARD_RATE)) + + "锛�"; + } else + maxMoneyPlus = "锛堜含涓減lus浼氬憳鏈�楂樿繑楼" + + fanliMoneyPlus.add(MoneyBigDecimalUtil.mul(fanliMoneyPlus, Constant.MAX_REWARD_RATE)) + + "锛�"; } } } @@ -676,10 +693,17 @@ rewardCoupon.setJumpDetail(jumpDetailV2Service.getByTypeCache("web")); JSONObject params1 = new JSONObject(); params1.put("url", configService.get("special_guide_reward_coupon_link")); - rewardCoupon.setParams(params1.toString()); + rewardCoupon.setMaxMoney("楼" + JDUtil.getGoodsFanLiMoney(jdGoods, fanLiRate) .add(MoneyBigDecimalUtil.mul(JDUtil.getGoodsFanLiMoney(jdGoods, fanLiRate), Constant.MAX_REWARD_RATE))); - rewardCoupon.setDesc("鐢ㄨ繑鍒╁鍔卞埜鏈�楂樿繑"); + if (VersionUtil.greaterThan_2_1(acceptData.getPlatform(), acceptData.getVersion())) { + rewardCoupon.setDesc("杩�"); + params1.put("url", configService.get("vip_link")); + rewardCoupon.getJumpDetail().setNeedLogin(true); + } else { + rewardCoupon.setDesc("鐢ㄨ繑鍒╁鍔卞埜鏈�楂樿繑"); + } + rewardCoupon.setParams(params1.toString()); otherInfo.setRewardCoupon(rewardCoupon); goodsDetail.setOtherInfo(otherInfo); @@ -687,7 +711,8 @@ if (couponInfo != null) { // 鍒搁摼鎺ュ鐞� String materialId = "https://item.jd.com/" + id + ".html"; - String url = JDApiUtil.convertLink(materialId, couponInfo.getLink(), JDApiUtil.POSITION_COUPON + "", null); + String url = JDApiUtil.convertLinkWithSubUnionId(materialId, couponInfo.getLink(), + JDApiUtil.POSITION_COUPON + "", null); couponInfo.setLink(url); } @@ -825,10 +850,16 @@ rewardCoupon.setJumpDetail(jumpDetailV2Service.getByTypeCache("web")); JSONObject params1 = new JSONObject(); params1.put("url", configService.get("special_guide_reward_coupon_link")); - rewardCoupon.setParams(params1.toString()); + rewardCoupon.setMaxMoney("楼" + PinDuoDuoUtil.getGoodsFanLiMoney(pddGoods, fanLiRate).add(MoneyBigDecimalUtil .mul(PinDuoDuoUtil.getGoodsFanLiMoney(pddGoods, fanLiRate), Constant.MAX_REWARD_RATE))); - rewardCoupon.setDesc("鐢ㄨ繑鍒╁鍔卞埜鏈�楂樿繑"); + if (VersionUtil.greaterThan_2_1(acceptData.getPlatform(), acceptData.getVersion())) { + rewardCoupon.setDesc("杩�"); + params1.put("url", configService.get("vip_link")); + rewardCoupon.getJumpDetail().setNeedLogin(true); + } else + rewardCoupon.setDesc("鐢ㄨ繑鍒╁鍔卞埜鏈�楂樿繑"); + rewardCoupon.setParams(params1.toString()); otherInfo.setRewardCoupon(rewardCoupon); goodsDetail.setOtherInfo(otherInfo); @@ -1018,7 +1049,8 @@ BigDecimal fanLiRate = hongBaoManageService.getFanLiRate(); BigDecimal shareRate = hongBaoManageService.getShareRate(); - ConfigParamsDTO paramsDTO = new ConfigParamsDTO(fanLiRate, shareRate, Constant.MAX_REWARD_RATE); + ConfigParamsDTO paramsDTO = new ConfigParamsDTO(fanLiRate, shareRate, + Constant.MAX_REWARD_RATE); for (PDDGoodsDetail goods : goodsList) { listDetailVO.add(GoodsDetailVOFactory.convertPDDGoods(goods, paramsDTO)); } @@ -1036,7 +1068,7 @@ return; } - List<TaoBaoGoodsBrief> goodsList = TaoKeApiUtil.getRelationGoodsRecommend(id, 10); + List<TaoBaoGoodsBrief> goodsList = TaoKeApiUtil.guessLikeByAuctionId(id, 10); // 鍒濆鍖� if (goodsList == null) { goodsList = new ArrayList<TaoBaoGoodsBrief>(); @@ -1064,7 +1096,7 @@ BigDecimal fanLiRate = hongBaoManageService.getFanLiRate(); BigDecimal shareRate = hongBaoManageService.getShareRate(); ConfigParamsDTO paramsDTO = new ConfigParamsDTO(fanLiRate, shareRate, Constant.MAX_REWARD_RATE); - + goodsList.parallelStream().forEach(goods -> { if (goods != null) { // 鑾峰彇璇︽儏 @@ -1084,8 +1116,7 @@ } if (taoBaoGoodsBrief != null) { - listExtra.add( - GoodsDetailVOFactory.convertTaoBao(taoBaoGoodsBrief, paramsDTO)); + listExtra.add(GoodsDetailVOFactory.convertTaoBao(taoBaoGoodsBrief, paramsDTO)); } } }); @@ -1120,12 +1151,13 @@ * @param acceptData * @param uid * @param id + * @param couponUrl + * -浼樻儬鍒搁摼鎺� * @param source - * @param request * @param out */ @RequestMapping(value = "getJDLink") - public void getJDLink(AcceptData acceptData, Long uid, Long id, String source, PrintWriter out) { + public void getJDLink(AcceptData acceptData, Long uid, Long id, String couponUrl, String source, PrintWriter out) { if (uid == null || uid <= 0) { out.print(JsonUtil.loadFalseResult(1, "鐢ㄦ埛ID涓嶈兘涓虹┖")); return; @@ -1148,13 +1180,19 @@ return; } - String couponUrl = null; + String jumpLink = null; String materialId = "https://item.jd.com/" + id + ".html"; - JDCouponInfo couponInfo = goods.getCouponInfo(); - if (couponInfo != null) { - couponUrl = couponInfo.getLink(); + if (StringUtil.isNullOrEmpty(couponUrl)) { + JDCouponInfo couponInfo = JDUtil.getShowCouponInfo(goods.getCouponInfoList(), goods.getPrice()); + if (couponInfo != null) { + couponUrl = couponInfo.getLink(); + } + jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, couponUrl, JDApiUtil.POSITION_FANLI + "", + uid + ""); + } else { + jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, couponUrl, JDApiUtil.POSITION_FANLI + "", + uid + ""); } - String jumpLink = JDApiUtil.convertLink(materialId, couponUrl, JDApiUtil.POSITION_FANLI + "", uid + ""); JSONObject data = new JSONObject(); data.put("native", true); @@ -1163,6 +1201,28 @@ // 鑾峰緱閲戝竵 integralGetService.addCouponRebate(uid); + } + + @RequestMapping(value = "getJDCouponLink") + public void getJDCouponLink(AcceptData acceptData, Long id, String couponUrl, PrintWriter out) { + if (StringUtil.isNullOrEmpty(couponUrl)) { + out.print(JsonUtil.loadFalseResult(1, "鍒搁摼鎺ヤ笉鑳戒负绌�")); + return; + } + if (id == null || id <= 0) { + out.print(JsonUtil.loadFalseResult(1, "鍟嗗搧ID涓嶈兘涓虹┖")); + return; + } + + String jumpLink = null; + String materialId = "https://item.jd.com/" + id + ".html"; + + jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, couponUrl, JDApiUtil.POSITION_FANLI + "", null); + + JSONObject data = new JSONObject(); + data.put("native", true); + data.put("jumpLink", jumpLink); + out.print(JsonUtil.loadTrueResult(data)); } /** @@ -1266,4 +1326,92 @@ } out.print(JsonUtil.loadTrueResult(data)); } + + @RequestMapping(value = "listSimpleGoods", method = RequestMethod.POST) + public void listSimpleGoods(AcceptData acceptData, String goodsInfo, PrintWriter out) { + if (StringUtil.isNullOrEmpty(goodsInfo)) { + out.print(JsonUtil.loadFalseResult(1, "鍟嗗搧淇℃伅涓虹┖")); + return; + } + + net.sf.json.JSONArray array = net.sf.json.JSONArray.fromObject(goodsInfo); + + List<CommonGoods> commonGoodsList = new ArrayList<>(); + + for (int i = 0; i < array.size(); i++) { + JSONObject obj = array.optJSONObject(i); + CommonGoods cg = new CommonGoods(); + cg.setGoodsId(obj.optLong("goodsId")); + cg.setGoodsType(obj.optInt("goodsType")); + commonGoodsList.add(cg); + } + + if (commonGoodsList.size() > 9) { + out.print(JsonUtil.loadFalseResult(1, "鏈�澶氬悓鏃惰幏鍙�9鏉℃暟鎹�")); + return; + } + + // 鍒嗙鍚勪釜骞冲彴鐨勫晢鍝佷俊鎭� + List<Long> tbGoodsList = new ArrayList<>(); + List<Long> jdGoodsList = new ArrayList<>(); + List<Long> pddGoodsList = new ArrayList<>(); + + List<String> keyList = new ArrayList<>(); + + for (CommonGoods cg : commonGoodsList) { + keyList.add(cg.getGoodsId() + "-" + cg.getGoodsType()); + if (cg.getGoodsType() == Constant.SOURCE_TYPE_TAOBAO) { + tbGoodsList.add(cg.getGoodsId()); + } else if (cg.getGoodsType() == Constant.SOURCE_TYPE_JD) { + jdGoodsList.add(cg.getGoodsId()); + } else if (cg.getGoodsType() == Constant.SOURCE_TYPE_PDD) { + pddGoodsList.add(cg.getGoodsId()); + } + } + + Map<String, GoodsDetailVO> tempGoodsList = new HashMap<>(); + + ConfigParamsDTO params = new ConfigParamsDTO(hongBaoManageService.getFanLiRate(), + hongBaoManageService.getShareRate(), new BigDecimal(80)); + + if (tbGoodsList.size() > 0) { + List<TaoBaoGoodsBrief> goodsList = null; + try { + goodsList = TaoKeApiUtil.getBatchGoodsInfo(tbGoodsList); + } catch (TaobaoGoodsDownException e) { + e.printStackTrace(); + } catch (TaoKeApiException e) { + e.printStackTrace(); + } + if (goodsList != null) + for (TaoBaoGoodsBrief goods : goodsList) { + goods.setTkRate(new BigDecimal(0)); + tempGoodsList.put(goods.getAuctionId() + "-" + Constant.SOURCE_TYPE_TAOBAO, + GoodsDetailVOFactory.convertTaoBao(goods, params)); + } + } + if (jdGoodsList.size() > 0) { + List<JDGoods> goodsList = JDApiUtil.getGoodsDetail(jdGoodsList); + for (JDGoods goods : goodsList) { + tempGoodsList.put(goods.getSkuId() + "-" + Constant.SOURCE_TYPE_TAOBAO, + GoodsDetailVOFactory.convertJDGoods(goods, params)); + } + } + if (pddGoodsList.size() > 0) { + List<PDDGoodsDetail> goodsList = PinDuoDuoApiUtil.listGoodsDetail(pddGoodsList); + for (PDDGoodsDetail goods : goodsList) { + tempGoodsList.put(goods.getGoodsId() + "-" + Constant.SOURCE_TYPE_TAOBAO, + GoodsDetailVOFactory.convertPDDGoods(goods, params)); + } + } + List<GoodsDetailVO> voList = new ArrayList<>(); + Gson gson = JsonUtil.getApiCommonGson(); + for (String key : keyList) { + GoodsDetailVO vo = tempGoodsList.get(key); + if (vo != null) { + voList.add(vo); + } + } + out.print(JsonUtil.loadTrueResult(gson.toJson(voList))); + } } -- Gitblit v1.8.0