From 626d711cb15896055c13fe344eb7fcc824589715 Mon Sep 17 00:00:00 2001 From: yujian <yujian@163.com> Date: 星期四, 19 十二月 2019 15:38:42 +0800 Subject: [PATCH] 帮助中心 --- fanli/src/main/java/com/yeshi/fanli/controller/client/v2/GoodsControllerV2.java | 191 ++++++++++++++++++++++++++++++++++++++++------- 1 files changed, 162 insertions(+), 29 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 fc791f2..68a35ad 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 @@ -3,7 +3,9 @@ import java.io.PrintWriter; import java.math.BigDecimal; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Map; import javax.annotation.Resource; @@ -15,6 +17,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; @@ -26,6 +29,7 @@ import com.yeshi.fanli.entity.bus.user.ShamUser; import com.yeshi.fanli.entity.bus.user.UserInfo; 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; @@ -65,6 +69,7 @@ import com.yeshi.fanli.service.inter.user.UserInfoExtraService; import com.yeshi.fanli.service.inter.user.UserInfoService; import com.yeshi.fanli.service.inter.user.integral.IntegralGetService; +import com.yeshi.fanli.service.inter.user.vip.UserVIPInfoService; import com.yeshi.fanli.util.Constant; import com.yeshi.fanli.util.MoneyBigDecimalUtil; import com.yeshi.fanli.util.RedisManager; @@ -179,12 +184,15 @@ @Resource private JDGoodsClassService jdGoodsClassService; - + @Resource private TLJFreeBuyGoodsService tljFreeBuyGoodsService; - + @Resource private UserTaoLiJinNewbiesService userTaoLiJinNewbiesService; + + @Resource + private UserVIPInfoService userVIPInfoService; /** * 娣樺疂鍟嗗搧璇︽儏 @@ -348,8 +356,14 @@ 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, + hongBaoManageService.getVIPFanLiRate()); GoodsDetailVO goodsDetail = GoodsDetailVOFactory.convertTaoBao(goods, paramsDTO); + if (goodsDetail != null && goodsDetail.getMoneyInfo() != null && userVIPInfoService.isVIP(uid)) { + goodsDetail.getMoneyInfo().setFanliMoney(goodsDetail.getMoneyInfo().getMaxMoney()); + goodsDetail.getMoneyInfo().setShareMoney( + "楼" + TaoBaoUtil.getGoodsHongBaoMoney(goods, hongBaoManageService.getVIPShareRate())); + } if (TaoBaoUtil.isYUShou(goods)) { if (!StringUtil.isNullOrEmpty(goods.getPresaleDiscountFeeText())) { @@ -429,7 +443,7 @@ } catch (Exception e) { extraVO.setH5Url(h5Url); } - + String helpLink = null; boolean fanliValid = true; boolean shareValid = true; @@ -471,7 +485,8 @@ goodsDetail.setZkPrice(goodsDetail.getZkPrice().subtract(tljHongBao)); } } else if (from != null && from.equals("taolijin_free_buy")) { - TLJFreeBuyGoods freeGoods = tljFreeBuyGoodsService.selectByAuctionIdAndDay(id, TimeUtil.getGernalTime(System.currentTimeMillis(), "yyyy-MM-dd")); + TLJFreeBuyGoods freeGoods = tljFreeBuyGoodsService.selectByAuctionIdAndDay(id, + TimeUtil.getGernalTime(System.currentTimeMillis(), "yyyy-MM-dd")); if (freeGoods == null) { out.print(JsonUtil.loadFalseResult(2, "鍏嶅崟鍟嗗搧宸蹭笅鏋�")); return; @@ -480,9 +495,9 @@ fanliValid = true; shareValid = false; BigDecimal couponPrice = goodsDetail.getCouponPrice(); - if (couponPrice == null) + if (couponPrice == null) couponPrice = goodsDetail.getZkPrice(); - + NewUserHongBao newUserHongBao = new NewUserHongBao(); newUserHongBao.setMoney(couponPrice.setScale(2).toString()); newUserHongBao.setName("鏂颁汉绾㈠寘 "); @@ -493,16 +508,24 @@ OtherInfo otherInfo = new OtherInfo(); otherInfo.setReduceHongBao(newUserHongBao); goodsDetail.setOtherInfo(otherInfo); - + + // 涓撳睘鏍囩 + List<ClientTextStyleVO> labels = new ArrayList<ClientTextStyleVO>(); + labels.add(new ClientTextStyleVO("鏂颁汉涓撳睘", "#FE0014")); + labels.add(new ClientTextStyleVO("瀹炰粯0鍏�", "#FF9600")); + goodsDetail.setLabels(labels); + } else {// 鏅�氳喘涔� OtherInfo otherInfo = new OtherInfo(); RewardCouponVO rewardCoupon = new RewardCouponVO(); rewardCoupon.setJumpDetail(jumpDetailV2Service.getByTypeCache("web")); JSONObject params1 = new JSONObject(); - params1.put("url", configService.get("special_guide_reward_coupon_link")); - - rewardCoupon.setMaxMoney("楼" + TaoBaoUtil.getGoodsHongBaoMoney(goods, fanLiRate).add(MoneyBigDecimalUtil - .mul(TaoBaoUtil.getGoodsHongBaoMoney(goods, fanLiRate), Constant.MAX_REWARD_RATE))); + if (!VersionUtil.greaterThan_2_1(acceptData.getPlatform(), acceptData.getVersion())) + params1.put("url", configService.get("special_guide_reward_coupon_link")); + else + params1.put("url", configService.get("vip_link")); + rewardCoupon + .setMaxMoney("楼" + TaoBaoUtil.getGoodsHongBaoMoney(goods, hongBaoManageService.getVIPFanLiRate())); if (VersionUtil.greaterThan_2_1(acceptData.getPlatform(), acceptData.getVersion())) { rewardCoupon.setDesc("杩�"); params1.put("url", configService.get("vip_link")); @@ -590,8 +613,14 @@ 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, + hongBaoManageService.getVIPFanLiRate()); GoodsDetailVO goodsDetail = GoodsDetailVOFactory.convertJDGoods(jdGoods, paramsDTO); + if (goodsDetail != null && goodsDetail.getMoneyInfo() != null && userVIPInfoService.isVIP(uid)) { + goodsDetail.getMoneyInfo().setFanliMoney(goodsDetail.getMoneyInfo().getMaxMoney()); + goodsDetail.getMoneyInfo() + .setShareMoney("楼" + JDUtil.getGoodsFanLiMoney(jdGoods, hongBaoManageService.getVIPShareRate())); + } // 闄勫姞淇℃伅 OtherInfo otherInfo = new OtherInfo(); @@ -610,14 +639,14 @@ jdGoods.setCommissionPlus(threeClass.getSelfComm()); // plus杩斿埄 BigDecimal fanliMoneyPlus = JDUtil.getGoodsFanLiMoneyPlus(jdGoods, fanLiRate); - otherInfo.setFanliMoneyPlus("浜笢plus浼氬憳杩斅�" + fanliMoneyPlus); + otherInfo.setFanliMoneyPlus("浜笢plus杩斅�" + fanliMoneyPlus); // 浣跨敤濂栧姳鍒告渶楂樿繑 if (VersionUtil.greaterThan_2_1(acceptData.getPlatform(), acceptData.getVersion())) { maxMoneyPlus = "锛堜含涓減lus杩斅�" + fanliMoneyPlus.add(MoneyBigDecimalUtil.mul(fanliMoneyPlus, Constant.MAX_REWARD_RATE)) + "锛�"; } else - maxMoneyPlus = "锛堜含涓減lus浼氬憳鏈�楂樿繑楼" + maxMoneyPlus = "锛堜含涓減lus鏈�楂樿繑楼" + fanliMoneyPlus.add(MoneyBigDecimalUtil.mul(fanliMoneyPlus, Constant.MAX_REWARD_RATE)) + "锛�"; } @@ -629,10 +658,12 @@ rewardCoupon.setMaxMoneyPlus(maxMoneyPlus); rewardCoupon.setJumpDetail(jumpDetailV2Service.getByTypeCache("web")); JSONObject params1 = new JSONObject(); - params1.put("url", configService.get("special_guide_reward_coupon_link")); + if (!VersionUtil.greaterThan_2_1(acceptData.getPlatform(), acceptData.getVersion())) + params1.put("url", configService.get("special_guide_reward_coupon_link")); + else + params1.put("url", configService.get("vip_link")); - rewardCoupon.setMaxMoney("楼" + JDUtil.getGoodsFanLiMoney(jdGoods, fanLiRate) - .add(MoneyBigDecimalUtil.mul(JDUtil.getGoodsFanLiMoney(jdGoods, fanLiRate), Constant.MAX_REWARD_RATE))); + rewardCoupon.setMaxMoney("楼" + JDUtil.getGoodsFanLiMoney(jdGoods, hongBaoManageService.getVIPFanLiRate())); if (VersionUtil.greaterThan_2_1(acceptData.getPlatform(), acceptData.getVersion())) { rewardCoupon.setDesc("杩�"); params1.put("url", configService.get("vip_link")); @@ -648,7 +679,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); } @@ -777,18 +809,27 @@ 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, + hongBaoManageService.getVIPFanLiRate()); GoodsDetailVO goodsDetail = GoodsDetailVOFactory.convertPDDGoods(pddGoods, paramsDTO); + if (goodsDetail != null && goodsDetail.getMoneyInfo() != null && userVIPInfoService.isVIP(uid)) { + goodsDetail.getMoneyInfo().setFanliMoney(goodsDetail.getMoneyInfo().getMaxMoney()); + goodsDetail.getMoneyInfo().setShareMoney( + "楼" + PinDuoDuoUtil.getGoodsFanLiMoney(pddGoods, hongBaoManageService.getVIPShareRate())); + } // 闄勫姞淇℃伅 OtherInfo otherInfo = new OtherInfo(); RewardCouponVO rewardCoupon = new RewardCouponVO(); rewardCoupon.setJumpDetail(jumpDetailV2Service.getByTypeCache("web")); JSONObject params1 = new JSONObject(); - params1.put("url", configService.get("special_guide_reward_coupon_link")); + if (!VersionUtil.greaterThan_2_1(acceptData.getPlatform(), acceptData.getVersion())) + params1.put("url", configService.get("special_guide_reward_coupon_link")); + else + params1.put("url", configService.get("vip_link")); - rewardCoupon.setMaxMoney("楼" + PinDuoDuoUtil.getGoodsFanLiMoney(pddGoods, fanLiRate).add(MoneyBigDecimalUtil - .mul(PinDuoDuoUtil.getGoodsFanLiMoney(pddGoods, fanLiRate), Constant.MAX_REWARD_RATE))); + rewardCoupon + .setMaxMoney("楼" + PinDuoDuoUtil.getGoodsFanLiMoney(pddGoods, hongBaoManageService.getVIPFanLiRate())); if (VersionUtil.greaterThan_2_1(acceptData.getPlatform(), acceptData.getVersion())) { rewardCoupon.setDesc("杩�"); params1.put("url", configService.get("vip_link")); @@ -942,7 +983,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, + hongBaoManageService.getVIPFanLiRate()); List<GoodsDetailVO> listDetailVO = new ArrayList<GoodsDetailVO>(); for (JDGoods goods : list) { @@ -986,7 +1028,7 @@ BigDecimal fanLiRate = hongBaoManageService.getFanLiRate(); BigDecimal shareRate = hongBaoManageService.getShareRate(); ConfigParamsDTO paramsDTO = new ConfigParamsDTO(fanLiRate, shareRate, - Constant.MAX_REWARD_RATE); + Constant.MAX_REWARD_RATE, hongBaoManageService.getVIPFanLiRate()); for (PDDGoodsDetail goods : goodsList) { listDetailVO.add(GoodsDetailVOFactory.convertPDDGoods(goods, paramsDTO)); } @@ -1031,7 +1073,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, + hongBaoManageService.getVIPFanLiRate()); goodsList.parallelStream().forEach(goods -> { if (goods != null) { @@ -1123,9 +1166,11 @@ if (couponInfo != null) { couponUrl = couponInfo.getLink(); } - jumpLink = JDApiUtil.convertLink(materialId, couponUrl, JDApiUtil.POSITION_FANLI + "", uid + ""); + jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, couponUrl, JDApiUtil.POSITION_FANLI + "", + uid + ""); } else { - jumpLink = JDApiUtil.convertLink(materialId, couponUrl, JDApiUtil.POSITION_FANLI + "", uid + ""); + jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, couponUrl, JDApiUtil.POSITION_FANLI + "", + uid + ""); } JSONObject data = new JSONObject(); @@ -1151,7 +1196,7 @@ String jumpLink = null; String materialId = "https://item.jd.com/" + id + ".html"; - jumpLink = JDApiUtil.convertLink(materialId, couponUrl, JDApiUtil.POSITION_FANLI + "", null + ""); + jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, couponUrl, JDApiUtil.POSITION_FANLI + "", null); JSONObject data = new JSONObject(); data.put("native", true); @@ -1260,4 +1305,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), hongBaoManageService.getVIPFanLiRate()); + + 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_JD, + 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_PDD, + 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