From 554de444b87aab5f93cb1593a8095612cf9479a7 Mon Sep 17 00:00:00 2001 From: yujian <yujian@163.com> Date: 星期二, 09 六月 2020 17:34:30 +0800 Subject: [PATCH] 订单 --- fanli/src/main/java/com/yeshi/fanli/controller/client/v2/ShareControllerV2.java | 254 ++++++++++++++++++++++++++++++++++++++------------ 1 files changed, 192 insertions(+), 62 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/controller/client/v2/ShareControllerV2.java b/fanli/src/main/java/com/yeshi/fanli/controller/client/v2/ShareControllerV2.java index 56be522..6ecab83 100644 --- a/fanli/src/main/java/com/yeshi/fanli/controller/client/v2/ShareControllerV2.java +++ b/fanli/src/main/java/com/yeshi/fanli/controller/client/v2/ShareControllerV2.java @@ -233,14 +233,14 @@ return; } - if (goodsId == null ) { + if (goodsId == null) { out.print(JsonUtil.loadFalseResult(2, "鍟嗗搧ID涓嶈兘涓虹┖")); return; } // 娣樺疂 if (goodsType == null || goodsType == Constant.SOURCE_TYPE_TAOBAO) { - createTaoBaoShare(acceptData, uid,Long.parseLong(goodsId), totalNum, source, needGoods, request, out); + createTaoBaoShare(acceptData, uid, Long.parseLong(goodsId), totalNum, source, needGoods, request, out); return; } @@ -684,7 +684,7 @@ // 璁剧疆璇勮鏂囨湰閫夐」 shareInfo.setCommentTextChoiceList( getCommentChoiceList(shareInfo.getCommentText(), null, inviteCode, TaoBaoUtil.getGoodsHongBaoMoney( - taoBaoLink.getGoods(), hongBaoManageService.getFanLiRate(UserLevelEnum.superVIP),false))); + taoBaoLink.getGoods(), hongBaoManageService.getFanLiRate(UserLevelEnum.superVIP), false))); out.print(JsonUtil.loadTrueResult( JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder()).create().toJson(shareInfo))); @@ -752,8 +752,10 @@ couponUrl = couponInfo.getLink(); } String materialId = "https://item.jd.com/" + goodsId + ".html"; - String jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, couponUrl, JDApiUtil.POSITION_SHARE + "", - uid + ""); + String jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, couponUrl, JDApiUtil.POSITION_SHARE + "", uid + ""); + if (StringUtil.isNullOrEmpty(jumpLink)) { + jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, null, JDApiUtil.POSITION_SHARE + "", uid + ""); + } ShareInfoVO shareInfo = new ShareInfoVO(); shareInfo.setClickUrl(jumpLink); @@ -858,6 +860,9 @@ out.print(JsonUtil.loadTrueResult( JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder()).create().toJson(shareInfo))); + + final String jumpLinkNew=jumpLink; + // 寮傛鎿嶄綔 final JDGoods goods = jdGoods; com.yeshi.fanli.util.ThreadUtil.run(new Runnable() { @@ -874,7 +879,7 @@ history.setQuanLink(null); history.setGoodsId(goodsId); history.setPostPicture(goods.getPicUrl()); - history.setShareImg(jumpLink); + history.setShareImg(jumpLinkNew); List<String> imgList = goods.getImageList(); if (imgList == null) { @@ -1106,18 +1111,12 @@ shareInfo.setDescText(descText); // - String imgs = configService.getByVersion(ConfigKeyEnum.goodsShareNotifyImgs.getKey(), acceptData.getPlatform(), + String imgs = configService.getByVersion(ConfigKeyEnum.goodsShareNotifyImgsVIP.getKey(), acceptData.getPlatform(), Integer.parseInt(acceptData.getVersion())); - JSONArray array = JSONArray.fromObject(imgs); + shareInfo.setNotifyPicture(imgs); + shareInfo.setNotifyPictureNew(imgs); - shareInfo.setNotifyPicture(array.size() > 1 ? array.optString(1) : array.optString(0)); - - // 2.0.7鐗堟湰鍚庣殑鎻愮ず鍥剧墖 - imgs = configService.get(ConfigKeyEnum.goodsShareNotifyImgs207.getKey()); - array = JSONArray.fromObject(imgs); - shareInfo.setNotifyPictureNew(array.size() > 1 ? array.optString(1) : array.optString(0)); - - shareInfo.setNotifyDesc(configService.get(ConfigKeyEnum.goodsShareNotifyPDD.getKey())); + shareInfo.setNotifyDesc(configService.get(ConfigKeyEnum.goodsShareNotifyVIP.getKey())); // 娣诲姞鍒嗕韩璁板綍 BigDecimal shareRate = hongBaoManageService.getShareRate(); @@ -1142,17 +1141,15 @@ String recommendText = ""; String qtemplate = configService.get(ConfigKeyEnum.quickShareGoodsText.getKey()); recommendText = qtemplate.replace("[鍟嗗搧鏍囬]", goods.getGoodsName()); - + recommendText = recommendText.replace("閿�閲�:[閿�閲廬", ""); recommendText = recommendText.replace("鎺ㄨ崘鐞嗙敱:[鎺ㄨ崘璇璢", ""); - - String quickCommentText = configService.get(ConfigKeyEnum.quickSharePDDCommentText.getKey()); - commentText = quickCommentText.replace("[鍘熶环]", goods.getMarketPrice()); - commentText = commentText.replace("[閾炬帴]", jumpLink.getUrl()); - - commentText = commentText.replace("棰嗗埜鎶㈣喘", "鎶㈣喘"); - commentText = commentText.replace("銆愬埜鍚庝环銆慬鍒稿悗浠穄鍏�", ""); recommendText = recommendText.replace("浼樻儬鍒�:[鍒搁潰棰漖鍏�", ""); + String quickCommentText = configService.get(ConfigKeyEnum.quickShareVIPCommentText.getKey()); + commentText = quickCommentText.replace("[鍦ㄥ敭浠穄", BigDecimalUtil.getWithNoZera(new BigDecimal(goods.getMarketPrice())).toString()); + commentText = commentText.replace("[閾炬帴]", jumpLink.getUrl()); + commentText = commentText.replace("[鎶樻墸浠穄", "" +MoneyBigDecimalUtil.getWithNoZera(new BigDecimal(goods.getVipPrice()))); + shareInfo.setRecommendText(deleteBlankLine(recommendText)); shareInfo.setCommentText(deleteBlankLine(commentText)); @@ -1183,6 +1180,11 @@ if (imgList == null) { imgList = new ArrayList<>(); } + + if (imgList.size() > 10) { + imgList = imgList.subList(0, 9); + } + history.setPictures(JsonUtil.getGson().toJson(imgList)); shareGoodsService.addShareGoodsHistory(history); } @@ -1231,8 +1233,10 @@ hongBaoManageService.getFanLiRate(UserLevelEnum.superVIP)))); } - String template = shareGoodsTextTemplateService.getTextTemplateByVIP(uid); - String shareText = shareGoodsTextTemplateService.createContentSuning(template, goods, jumpLink); + String template = shareGoodsTextTemplateService.getTextTemplateBySuNing(uid); + //String shareText = shareGoodsTextTemplateService.createQuickShareTextSuNing(template, goods, jumpLink); + + String shareText = shareGoodsTextTemplateService.createCommonShareTextSuNing(template, goods, jumpLink); shareInfo.setShareText(shareText); String descText = shareText.replace(goods.getCommodityInfo().getCommodityName(), "").trim(); @@ -1274,6 +1278,11 @@ String inviteCode = userInfoExtraService.getInviteCodeByUid(uid); + String commodityPrice = goods.getCommodityInfo().getCommodityPrice(); + if (StringUtil.isNullOrEmpty(commodityPrice)) { + commodityPrice = goods.getCommodityInfo().getSnPrice(); + } + String commentText = ""; String recommendText = ""; String qtemplate = configService.get(ConfigKeyEnum.quickShareGoodsText.getKey()); @@ -1281,14 +1290,45 @@ recommendText = recommendText.replace("鎺ㄨ崘鐞嗙敱:[鎺ㄨ崘璇璢", ""); - String quickCommentText = configService.get(ConfigKeyEnum.quickSharePDDCommentText.getKey()); - commentText = quickCommentText.replace("[鍘熶环]", goods.getCommodityInfo().getCommodityPrice()); + + String quickCommentText = configService.get(ConfigKeyEnum.quickShareSuNingCommentText.getKey()); + commentText = quickCommentText.replace("[鍘熶环]", BigDecimalUtil.getWithNoZera(new BigDecimal(commodityPrice)).toString()); commentText = commentText.replace("[閾炬帴]", jumpLink); + - commentText = commentText.replace("棰嗗埜鎶㈣喘", "鎶㈣喘"); - commentText = commentText.replace("銆愬埜鍚庝环銆慬鍒稿悗浠穄鍏�", ""); - recommendText = recommendText.replace("浼樻儬鍒�:[鍒搁潰棰漖鍏�", ""); - + String salesCountMidea = ""; + Integer count = Integer.parseInt(goods.getCommodityInfo().getMonthSales()); + if (count < 10000) { + salesCountMidea = count + ""; + } else { + double sales = count; + salesCountMidea = String.format("%.1f", sales / 10000); + salesCountMidea = salesCountMidea + "涓�"; + } + if (StringUtil.isNullOrEmpty(salesCountMidea) || salesCountMidea.equals("0")) { + recommendText = recommendText.replace("閿�閲�:[閿�閲廬", ""); + } else { + recommendText = recommendText.replace("[閿�閲廬", salesCountMidea.replace("涓�", "w")); + } + + + if (goods.getCouponInfo() != null && !StringUtil.isNullOrEmpty(goods.getCouponInfo().getCouponUrl())) {// 鏈夊埜 + BigDecimal amount = new BigDecimal(goods.getCouponInfo().getCouponValue()); + BigDecimal startFee = new BigDecimal(goods.getCouponInfo().getBounsLimit()); + BigDecimal zkPrice = new BigDecimal(commodityPrice); + BigDecimal couponPrice = zkPrice; + if (zkPrice.compareTo(startFee) >= 0) { + couponPrice = zkPrice.subtract(amount); + } + recommendText = recommendText.replace("[鍒搁潰棰漖", + BigDecimalUtil.getWithNoZera(new BigDecimal(goods.getCouponInfo().getCouponValue())).toString()); + commentText = commentText.replace("[鍒稿悗浠穄",BigDecimalUtil.getWithNoZera(couponPrice).toString()); + } else { + commentText = commentText.replace("棰嗗埜鎶㈣喘", "鎶㈣喘"); + commentText = commentText.replace("銆愬埜鍚庝环銆慬鍒稿悗浠穄鍏�", ""); + recommendText = recommendText.replace("浼樻儬鍒�:[鍒搁潰棰漖鍏�", ""); + } + shareInfo.setRecommendText(deleteBlankLine(recommendText)); shareInfo.setCommentText(deleteBlankLine(commentText)); @@ -1340,7 +1380,7 @@ * @param out */ @RequestMapping(value = "viewShareTextTemplate", method = RequestMethod.POST) - public void viewShareTextTemplate(AcceptData acceptData, Long uid, String template, Integer goodsType, Long goodsId, + public void viewShareTextTemplate(AcceptData acceptData, Long uid, String template, Integer goodsType, String goodsId, Long tljId, Boolean hasCoupon, PrintWriter out) { if (uid == null) { out.print(JsonUtil.loadFalseResult(1, "鐢ㄦ埛鏈櫥褰�")); @@ -1352,23 +1392,28 @@ return; } - if (goodsType == null || goodsType > 3 || goodsType < 1) { - out.print(JsonUtil.loadFalseResult(3, "骞冲彴绫诲瀷涓嶆纭�")); - return; - } - if (goodsType == Constant.SOURCE_TYPE_TAOBAO) { - createTaoBaoViewText(goodsType, uid, template, goodsId, tljId, hasCoupon, out); + createTaoBaoViewText(goodsType, uid, template,Long.parseLong(goodsId) , tljId, hasCoupon, out); return; } if (goodsType == Constant.SOURCE_TYPE_JD) { - createJDViewText(goodsType, uid, template, goodsId, hasCoupon, out); + createJDViewText(goodsType, uid, template, Long.parseLong(goodsId), hasCoupon, out); return; } if (goodsType == Constant.SOURCE_TYPE_PDD) { - createPDDViewText(goodsType, uid, template, goodsId, hasCoupon, out); + createPDDViewText(goodsType, uid, template, Long.parseLong(goodsId), hasCoupon, out); + return; + } + + if (goodsType == Constant.SOURCE_TYPE_VIP) { + createVIPViewText(goodsType, uid, template, Long.parseLong(goodsId), hasCoupon, out); + return; + } + + if (goodsType == Constant.SOURCE_TYPE_SUNING) { + createSuNingViewText(goodsType, uid, template, goodsId, hasCoupon, out); return; } } @@ -1535,6 +1580,79 @@ } /** + * 鍞搧浼氬垎浜� + * @param goodsType + * @param uid + * @param template + * @param goodsId + * @param hasCoupon + * @param out + */ + private void createVIPViewText(Integer goodsType, Long uid, String template, Long goodsId, Boolean hasCoupon, + PrintWriter out) { + VIPGoodsInfo goods = VipShopApiUtil.getGoodsDetail(goodsId + ""); + if (goods == null) { + out.print(JsonUtil.loadFalseResult(4, "鍟嗗搧宸蹭笅鏋�")); + return; + } + + if (StringUtil.isNullOrEmpty(template)) { + template = getShareTemplate(goodsType, uid, hasCoupon, null); + } + + // 鏍¢獙鍒告ā鏉挎槸鍚︽纭� + try { + shareGoodsTextTemplateService.verifyRightVIP(template); + } catch (ShareGoodsTextTemplateException e) { + out.print(JsonUtil.loadFalseResult(5, e.getMsg())); + return; + } + + VIPConvertResultDTO jumpLink = VipShopApiUtil.convertLink(goodsId + "", VipShopUtil.getShareChanTag(uid)); + + // 鐢熸垚鍒嗕韩鍐呭 + String content = shareGoodsTextTemplateService.createContentVIP(template, goods, jumpLink.getUrl()); + + JSONObject data = new JSONObject(); + data.put("content", content); + out.print(JsonUtil.loadTrueResult(data)); + } + + + + private void createSuNingViewText(Integer goodsType, Long uid, String template, String goodsId, Boolean hasCoupon, + PrintWriter out) { + String[] ids = SuningUtil.getGoodsIdDetail(goodsId); + SuningGoodsInfo goods = SuningApiUtil.getGoodsDetail(ids[1], ids[0]); + if (goods == null) { + out.print(JsonUtil.loadFalseResult(4, "鍟嗗搧宸蹭笅鏋�")); + return; + } + + if (StringUtil.isNullOrEmpty(template)) { + template = getShareTemplate(goodsType, uid, hasCoupon, null); + } + + // 鏍¢獙鍒告ā鏉挎槸鍚︽纭� + try { + shareGoodsTextTemplateService.verifyRightSuNing(template); + } catch (ShareGoodsTextTemplateException e) { + out.print(JsonUtil.loadFalseResult(5, e.getMsg())); + return; + } + + String couponLink = goods.getCouponInfo().getCouponUrl(); + String jumpLink = SuningApiUtil.convertLink(SuningUtil.getProductUrl(ids[0], ids[1]), + StringUtil.isNullOrEmpty(couponLink) ? null : couponLink, SuningApiUtil.PID_SHARE, uid + ""); + + // 鐢熸垚鏅�氬垎浜唴瀹� + String content = shareGoodsTextTemplateService.createCommonShareTextSuNing(template, goods, jumpLink); + + JSONObject data = new JSONObject(); + data.put("content", content); + out.print(JsonUtil.loadTrueResult(data)); + } + /** * 鑾峰彇鍒嗕韩妯℃澘 * * @param uid @@ -1550,6 +1668,10 @@ template = shareGoodsTextTemplateService.getTextTemplateByJD(uid); } else if (goodsType == Constant.SOURCE_TYPE_PDD) { template = shareGoodsTextTemplateService.getTextTemplateByPDD(uid); + } else if (goodsType == Constant.SOURCE_TYPE_VIP) { + template = shareGoodsTextTemplateService.getTextTemplateByVIP(uid); + } else if (goodsType == Constant.SOURCE_TYPE_SUNING) { + template = shareGoodsTextTemplateService.getTextTemplateBySuNing(uid); } return template; } @@ -1588,11 +1710,6 @@ */ @RequestMapping(value = "getShareTextTemplateRules", method = RequestMethod.POST) public void getShareTextTemplateRules(AcceptData acceptData, Integer goodsType, Long tljId, PrintWriter out) { - if (goodsType == null || goodsType > 3 || goodsType < 1) { - out.print(JsonUtil.loadFalseResult(3, "骞冲彴绫诲瀷涓嶆纭�")); - return; - } - if (goodsType == Constant.SOURCE_TYPE_TAOBAO) { if (tljId != null) { out.print( @@ -1604,6 +1721,10 @@ out.print(JsonUtil.loadTrueResult(configService.get(ConfigKeyEnum.shareGoodsTemplateRulesJD.getKey()))); } else if (goodsType == Constant.SOURCE_TYPE_PDD) { out.print(JsonUtil.loadTrueResult(configService.get(ConfigKeyEnum.shareGoodsTemplateRulesPDD.getKey()))); + } else if (goodsType == Constant.SOURCE_TYPE_VIP) { + out.print(JsonUtil.loadTrueResult(configService.get(ConfigKeyEnum.shareGoodsTemplateRulesVIP.getKey()))); + } else if (goodsType == Constant.SOURCE_TYPE_SUNING) { + out.print(JsonUtil.loadTrueResult(configService.get(ConfigKeyEnum.shareGoodsTemplateRulesSuNing.getKey()))); } } @@ -1624,11 +1745,6 @@ return; } - if (goodsType == null || goodsType > 3 || goodsType < 1) { - out.print(JsonUtil.loadFalseResult(3, "骞冲彴绫诲瀷涓嶆纭�")); - return; - } - try { if (goodsType == Constant.SOURCE_TYPE_TAOBAO) { shareGoodsTextTemplateService.saveTemplateTB(uid, template); @@ -1636,6 +1752,10 @@ shareGoodsTextTemplateService.saveTemplateJD(uid, template); } else if (goodsType == Constant.SOURCE_TYPE_PDD) { shareGoodsTextTemplateService.saveTemplatePDD(uid, template); + } else if (goodsType == Constant.SOURCE_TYPE_VIP) { + shareGoodsTextTemplateService.saveTemplateVIP(uid, template); + } else if (goodsType == Constant.SOURCE_TYPE_SUNING) { + shareGoodsTextTemplateService.saveTemplateSuNing(uid, template); } } catch (ShareGoodsTextTemplateException e) { out.print(JsonUtil.loadFalseResult(5, e.getMsg())); @@ -1654,15 +1774,10 @@ * @param out */ @RequestMapping(value = "resetShareTextTemplate", method = RequestMethod.POST) - public void resetShareTextTemplate(AcceptData acceptData, Long uid, Long goodsId, Long tljId, Boolean hasCoupon, + public void resetShareTextTemplate(AcceptData acceptData, Long uid, String goodsId, Long tljId, Boolean hasCoupon, Integer goodsType, PrintWriter out) { if (uid == null) { out.print(JsonUtil.loadFalseResult(1, "鐢ㄦ埛鏈櫥褰�")); - return; - } - - if (goodsType == null || goodsType > 3 || goodsType < 1) { - out.print(JsonUtil.loadFalseResult(3, "骞冲彴绫诲瀷涓嶆纭�")); return; } @@ -1672,6 +1787,10 @@ shareGoodsTextTemplateService.resetCommonTemplateJD(uid); } else if (goodsType == Constant.SOURCE_TYPE_PDD) { shareGoodsTextTemplateService.resetCommonTemplatePDD(uid); + } else if (goodsType == Constant.SOURCE_TYPE_VIP) { + shareGoodsTextTemplateService.resetCommonTemplateVIP(uid); + } else if (goodsType == Constant.SOURCE_TYPE_SUNING) { + shareGoodsTextTemplateService.resetCommonTemplateSuNing(uid); } if (goodsId != null) { @@ -1796,7 +1915,7 @@ } @RequestMapping(value = "getShareTextQuick", method = RequestMethod.POST) - public void getShareTextQuick(AcceptData acceptData, Long goodsId, Integer goodsType, Long uid, PrintWriter out) { + public void getShareTextQuick(AcceptData acceptData, String goodsId, Integer goodsType, Long uid, PrintWriter out) { if (uid == null) { out.print(JsonUtil.loadFalseResult(1, "鐢ㄦ埛鏈櫥褰�")); return; @@ -1813,10 +1932,10 @@ paramsDTO.setBaseFanliRate(hongBaoManageService.getBaseFanliRate()); if (goodsType == Constant.SOURCE_TYPE_TAOBAO) { - TaoBaoGoodsBrief goods = taoBaoGoodsCacheUtil.getCommonTaoBaoGoodsInfo(goodsId); + TaoBaoGoodsBrief goods = taoBaoGoodsCacheUtil.getCommonTaoBaoGoodsInfo(Long.parseLong(goodsId)); if (goods == null) { try { - goods = redisManager.getTaoBaoGoodsBrief(goodsId); + goods = redisManager.getTaoBaoGoodsBrief(Long.parseLong(goodsId)); } catch (TaobaoGoodsDownException e) { goods = null; } @@ -1825,15 +1944,26 @@ goodsDetail = GoodsDetailVOFactory.convertTaoBao(goods, paramsDTO); } } else if (goodsType == Constant.SOURCE_TYPE_JD) { - JDGoods goods = jdGoodsCacheUtil.getGoodsInfo(goodsId); + JDGoods goods = jdGoodsCacheUtil.getGoodsInfo(Long.parseLong(goodsId)); if (goods != null) { goodsDetail = GoodsDetailVOFactory.convertJDGoods(goods, paramsDTO); } } else if (goodsType == Constant.SOURCE_TYPE_PDD) { - PDDGoodsDetail goods = pinDuoDuoCacheUtil.getGoodsInfo(goodsId); + PDDGoodsDetail goods = pinDuoDuoCacheUtil.getGoodsInfo(Long.parseLong(goodsId)); if (goods != null) { goodsDetail = GoodsDetailVOFactory.convertPDDGoods(goods, paramsDTO); } + } else if (goodsType == Constant.SOURCE_TYPE_VIP) { + VIPGoodsInfo goods = VipShopApiUtil.getGoodsDetail(goodsId + ""); + if (goods == null) { + goodsDetail = GoodsDetailVOFactory.convertVIPGoods(goods, paramsDTO); + } + } else if (goodsType == Constant.SOURCE_TYPE_SUNING) { + String[] ids = SuningUtil.getGoodsIdDetail(goodsId); + SuningGoodsInfo goods = SuningApiUtil.getGoodsDetail(ids[1], ids[0]); + if (goods != null) { + goodsDetail = GoodsDetailVOFactory.convertSuningGoods(goods, paramsDTO); + } } if (goodsDetail == null) { -- Gitblit v1.8.0