From 8ebf78f9d9a2663f53f09346abdd14c5964fdfeb Mon Sep 17 00:00:00 2001 From: yj <Administrator@192> Date: 星期二, 03 三月 2020 19:11:00 +0800 Subject: [PATCH] 发圈修改 --- fanli/src/main/java/com/yeshi/fanli/controller/client/v2/ShareControllerV2.java | 351 +++++++++++----------------------------------------------- 1 files changed, 69 insertions(+), 282 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 78bf5ab..0f63cda 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 @@ -536,42 +536,22 @@ } shareInfo.setCommentTexts(commentTexts); - String shareText = ""; - // 鏃犲埜 - String shopType = taoBaoLink.getGoods().getUserType() == 0 ? TaoBaoConstant.SHARE_PRICE_TAOBAO - : TaoBaoConstant.SHARE_PRICE_TM; - - if (StringUtil.isNullOrEmpty(taoBaoLink.getGoods().getCouponInfo())) { - String text = shareGoodsTextTemplateService.getCommonTemplate(uid); - if (StringUtil.isNullOrEmpty(text)) - text = configService.get(ConfigKeyEnum.goodsShareTextNoCoupon.getKey()); - shareText = text.replace("{鏍囬}", taoBaoLink.getGoods().getTitle()).replace("{鍟嗗搧鍘熶环}", - MoneyBigDecimalUtil.getWithNoZera(taoBaoLink.getGoods().getZkPrice()) + ""); - } else// 鏈夊埜 - { - String text = shareGoodsTextTemplateService.geteCouponTemplate(uid); - if (StringUtil.isNullOrEmpty(text)) - text = configService.get(ConfigKeyEnum.goodsShareTextCoupon.getKey()); - - shareText = text.replace("{鏍囬}", taoBaoLink.getGoods().getTitle()) - .replace("{鍟嗗搧鍘熶环}", MoneyBigDecimalUtil.getWithNoZera(taoBaoLink.getGoods().getZkPrice()) + "") - .replace("{浼樻儬鍒搁潰棰潁", - MoneyBigDecimalUtil.getWithNoZera(taoBaoLink.getGoods().getCouponAmount()).toString()) - .replace("{浼樻儬鍒镐环}", TaoBaoUtil.getAfterUseCouplePrice(taoBaoLink.getGoods()) + ""); + TaoBaoGoodsBrief goods = taoBaoLink.getGoods(); + + boolean coupon = false; + if (!StringUtil.isNullOrEmpty(taoBaoLink.getGoods().getCouponInfo())) { + coupon = true; } - - shareText = shareText.replace("{搴楅摵绫诲瀷}", shopType) - .replace("{鏈堥攢閲弣", TaoBaoUtil.getSaleCount(taoBaoLink.getGoods().getBiz30day())) - .replace("{棰嗗埜鐭摼}", shortLink).replace("{娣樺彛浠", TaoBaoUtil.filterTaoToken(taoBaoLink.getTaoToken())); - + + String template = shareGoodsTextTemplateService.getTextTemplateByTB(uid); + String shareText = shareGoodsTextTemplateService.createContentTB(template, goods, taoBaoLink.getTaoToken(), coupon); shareInfo.setShareText(shareText); - + String descText = shareText.replace(taoBaoLink.getGoods().getTitle(), "").trim(); if (descText.startsWith("\\r\\n")) { descText = descText.substring(0); } - shareInfo.setDescText(descText); - + shareInfo.setDescText(deleteBlankLine(descText)); // 娴嬭瘯 // 2.0.2涔嬪墠 @@ -623,14 +603,13 @@ e1.printStackTrace(); } } - + String commentText = ""; String recommendText = ""; if (VersionUtil.greaterThan_2_0_7(platform, version)) { - TaoBaoGoodsBrief goods = taoBaoLink.getGoods(); - String template = configService.get(ConfigKeyEnum.quickShareGoodsText.getKey()); - recommendText = template.replace("[鍟嗗搧鏍囬]", goods.getTitle()); - if (StringUtil.isNullOrEmpty(goods.getDescription())) { + String template2 = configService.get(ConfigKeyEnum.quickShareGoodsText.getKey()); + recommendText = template2.replace("[鍟嗗搧鏍囬]", goods.getTitle()); + if (!coupon) { recommendText = recommendText.replace("鎺ㄨ崘鐞嗙敱:[鎺ㄨ崘璇璢", ""); } else { recommendText = recommendText.replace("[鎺ㄨ崘璇璢", goods.getDescription()); @@ -649,16 +628,21 @@ if (StringUtil.isNullOrEmpty(taoBaoLink.getGoods().getCouponInfo())) { commentText = commentText.replace("棰嗗埜鎶㈣喘", "鎶㈣喘"); commentText = commentText.replace("銆愬埜鍚庝环銆慬鍒稿悗浠穄鍏�", ""); - recommendText = recommendText.replace("浼樻儬鍒�:[鍒搁潰棰漖鍏�", ""); } else { commentText = commentText.replace("[鍒稿悗浠穄", TaoBaoUtil.getAfterUseCouplePrice(taoBaoLink.getGoods()) + ""); + } + + + if (StringUtil.isNullOrEmpty(taoBaoLink.getGoods().getCouponInfo())) { + recommendText = recommendText.replace("浼樻儬鍒�:[鍒搁潰棰漖鍏�", ""); + } else { recommendText = recommendText.replace("[鍒搁潰棰漖", MoneyBigDecimalUtil.getWithNoZera(taoBaoLink.getGoods().getCouponAmount()).toString()); } } else { - recommendText = shareInfo.getDescText(); commentText = shareInfo.getShareText(); + recommendText = shareInfo.getDescText(); } shareInfo.setCommentText(deleteBlankLine(commentText)); shareInfo.setRecommendText(deleteBlankLine(recommendText)); @@ -747,27 +731,13 @@ shareInfo.setGoodsInfo(GoodsDetailVOFactory.convertJDGoods(jdGoods, hongBaoManageService.getShowComputeRate(acceptData.getPlatform(), acceptData.getVersion()))); - String shareText = ""; boolean hasCoupon = false; - - // 鍒嗕韩妯℃澘 - ShareGoodsTextTemplate textTemplate = shareGoodsTextTemplateService.getShareGoodsTextTemplate(uid); - if (couponInfo == null) { // 鏃犲埜妯℃澘 - if (textTemplate != null) - shareText = textTemplate.getShareJDTextTemplate(); - - if (StringUtil.isNullOrEmpty(shareText)) - shareText = configService.get(ConfigKeyEnum.goodsShareTextNoCouponJD.getKey()); - } else { // 鏈夊埜妯℃澘 + if (couponInfo != null) { hasCoupon = true; - if (textTemplate != null) - shareText = textTemplate.getShareJDTextTemplateCoupon(); - - if (StringUtil.isNullOrEmpty(shareText)) - shareText = configService.get(ConfigKeyEnum.goodsShareTextCouponJD.getKey()); } - shareText = shareGoodsTextTemplateService.createContentByTemplateJD(shareText, uid, jdGoods, jumpLink, - hasCoupon); + + String template = shareGoodsTextTemplateService.getTextTemplateByJD(uid); + String shareText = shareGoodsTextTemplateService.createContentJD(template, jdGoods, jumpLink, hasCoupon); shareInfo.setShareText(shareText); String descText = shareText.replace(jdGoods.getSkuName(), "").trim(); @@ -810,8 +780,8 @@ String commentText = ""; String recommendText = ""; if (VersionUtil.greaterThan_2_0_7(acceptData.getPlatform(), acceptData.getVersion())) { - String template = configService.get(ConfigKeyEnum.quickShareGoodsText.getKey()); - recommendText = template.replace("[鍟嗗搧鏍囬]", jdGoods.getSkuName()); + String template2 = configService.get(ConfigKeyEnum.quickShareGoodsText.getKey()); + recommendText = template2.replace("[鍟嗗搧鏍囬]", jdGoods.getSkuName()); // 鏃犳帹鑽愯 recommendText = recommendText.replace("鎺ㄨ崘鐞嗙敱:[鎺ㄨ崘璇璢", ""); @@ -820,20 +790,6 @@ recommendText = recommendText.replace("閿�閲�:[閿�閲廬", ""); } else { recommendText = recommendText.replace("[閿�閲廬", sales.replace("涓�", "w")); - } - - String quickCommentText = configService.get(ConfigKeyEnum.quickShareJDCommentText.getKey()); - commentText = quickCommentText.replace("[鍘熶环]", jdGoods.getPrice().toString()); - commentText = commentText.replace("[閾炬帴]", jumpLink); - if (couponInfo == null) { - commentText = commentText.replace("棰嗗埜鎶㈣喘", "鎶㈣喘"); - commentText = commentText.replace("銆愬埜鍚庝环銆慬鍒稿悗浠穄鍏�", ""); - recommendText = recommendText.replace("浼樻儬鍒�:[鍒搁潰棰漖鍏�", ""); - } else { - commentText = commentText.replace("[鍒稿悗浠穄", - BigDecimalUtil.getWithNoZera(JDUtil.getQuanPrice(jdGoods)).toString()); - recommendText = recommendText.replace("[鍒搁潰棰漖", - BigDecimalUtil.getWithNoZera(JDUtil.getShowCouponInfo(jdGoods).getDiscount()).toString()); } } else { commentText = shareInfo.getShareText(); @@ -922,30 +878,15 @@ hongBaoManageService.getVIPFanLiRate()))); } - String template = ""; - boolean hasCoupon = false; - ShareGoodsTextTemplate textTemplate = shareGoodsTextTemplateService.getShareGoodsTextTemplate(uid); - if (goods.getHasCoupon() == null || !goods.getHasCoupon()) { - if (textTemplate != null) - template = textTemplate.getSharePDDTextTemplate(); - - if (StringUtil.isNullOrEmpty(template)) - template = configService.get(ConfigKeyEnum.goodsShareTextNocouponPDD.getKey()); - } else { - hasCoupon = true; - if (textTemplate != null) - template = textTemplate.getSharePDDTextTemplateCoupon(); - - if (StringUtil.isNullOrEmpty(template)) - template = configService.get(ConfigKeyEnum.goodsShareTextCouponPDD.getKey()); - } - // 鍒涘缓鍙d护 - String token = PinDuoDuoApiUtil.createGenerate(goodsId); - - // 鐢熸垚鍒嗕韩鍐呭 - String shareText = shareGoodsTextTemplateService.createContentByTemplatePDD(template, uid, goods, jumpLink, - hasCoupon, token); +// String token = PinDuoDuoApiUtil.createGenerate(goodsId); + + boolean hasCoupon = true; + if (goods.getHasCoupon() == null || !goods.getHasCoupon()) { + hasCoupon = false; + } + String template = shareGoodsTextTemplateService.getTextTemplateByPDD(uid); + String shareText = shareGoodsTextTemplateService.createContentPDD(template, goods, jumpLink, hasCoupon); shareInfo.setShareText(shareText); String descText = shareText.replace(goods.getGoodsName(), "").trim(); @@ -1121,7 +1062,7 @@ * @param hasCoupon * @param out */ - public void createTaoBaoViewText(Integer goodsType, Long uid, String template, Long goodsId, Long tljId, + private void createTaoBaoViewText(Integer goodsType, Long uid, String template, Long goodsId, Long tljId, Boolean hasCoupon, PrintWriter out) { TaoBaoGoodsBrief goods = taoBaoGoodsCacheUtil.getCommonTaoBaoGoodsInfo(goodsId); if (goods == null) @@ -1140,50 +1081,14 @@ template = getShareTemplate(goodsType, uid, hasCoupon, tljId); } - // 鏍¢獙鍒告ā鏉挎槸鍚︽纭� - if (hasCoupon) { - // 鏈夊埜鍟嗗搧 - if (tljId != null) { - try { - shareGoodsTextTemplateService.isTaoLiJinTemplateRight(template); - } catch (ShareGoodsTextTemplateException e) { - out.print(JsonUtil.loadFalseResult(5, e.getMsg())); - return; - } - } else { - try { - shareGoodsTextTemplateService.isCouponTemplateRight(template); - } catch (ShareGoodsTextTemplateException e) { - out.print(JsonUtil.loadFalseResult(5, e.getMsg())); - return; - } - } - } else { - // 鏅�氬晢鍝� - try { - shareGoodsTextTemplateService.isCommonTemplateRight(template); - } catch (ShareGoodsTextTemplateException e) { - out.print(JsonUtil.loadFalseResult(5, e.getMsg())); - return; - } + // 鏍¢獙妯℃澘鏄惁姝g‘ + try { + shareGoodsTextTemplateService.verifyRightTB(template); + } catch (ShareGoodsTextTemplateException e) { + out.print(JsonUtil.loadFalseResult(5, e.getMsg())); + return; } - - String url = null; - if (tljId != null) { - UserTaoLiJinRecord userTaoLiJinRecord = userTaoLiJinRecordService.selectByPrimaryKey(tljId); - if (userTaoLiJinRecord == null) { - out.print(JsonUtil.loadFalseResult(5, "娣樼ぜ閲戦鍙栭摼鎺ヤ笉瀛樺湪")); - return; - } - url = userTaoLiJinRecord.getSendUrl(); - } else { - url = String.format("http://%s%s?uid=%s&id=%s&appType=flq", configService.getH5Host(), - Constant.systemCommonConfig.getShareGoodsPagePath(), AESUtil.encrypt(uid + "", Constant.UIDAESKEY), - goods.getAuctionId() + ""); - } - - String shortLink = HttpUtil.getShortLink(url); - + // 鏌ヨ鏄惁鏈夊垎浜� UserShareGoodsHistory userShareHistory = shareGoodsService.getShareGoodsHistory(uid, goods.getAuctionId()); String token = ""; @@ -1203,8 +1108,7 @@ StringUtil.isNullOrEmpty(goodsLink.getCouponLink()) ? goodsLink.getAuctionUrl() : goodsLink.getCouponLink()); } - String content = shareGoodsTextTemplateService.createContentByTemplate(template, uid, goods, token, shortLink, - hasCoupon, tljId); + String content = shareGoodsTextTemplateService.createContentTB(template, goods, token, hasCoupon); JSONObject data = new JSONObject(); data.put("content", content); out.print(JsonUtil.loadTrueResult(data)); @@ -1221,7 +1125,7 @@ * @param hasCoupon * @param out */ - public void createJDViewText(Integer goodsType, Long uid, String template, Long goodsId, Boolean hasCoupon, + private void createJDViewText(Integer goodsType, Long uid, String template, Long goodsId, Boolean hasCoupon, PrintWriter out) { JDGoods goods = jdGoodsCacheUtil.getGoodsInfo(goodsId); if (goods == null) { @@ -1234,23 +1138,11 @@ } // 鏍¢獙鍒告ā鏉挎槸鍚︽纭� - if (hasCoupon) { - // 鏈夊埜鍟嗗搧 - try { - shareGoodsTextTemplateService.isCouponTemplateRightJD(template); - } catch (ShareGoodsTextTemplateException e) { - out.print(JsonUtil.loadFalseResult(5, e.getMsg())); - return; - } - - } else { - // 鏅�氬晢鍝� - try { - shareGoodsTextTemplateService.isCommonTemplateRightJD(template); - } catch (ShareGoodsTextTemplateException e) { - out.print(JsonUtil.loadFalseResult(5, e.getMsg())); - return; - } + try { + shareGoodsTextTemplateService.verifyRightJD(template); + } catch (ShareGoodsTextTemplateException e) { + out.print(JsonUtil.loadFalseResult(5, e.getMsg())); + return; } String couponUrl = null; @@ -1262,8 +1154,7 @@ String shortLink = JDApiUtil.convertLinkWithSubUnionId(materialId, couponUrl, JDApiUtil.POSITION_SHARE + "", uid + ""); - String content = shareGoodsTextTemplateService.createContentByTemplateJD(template, uid, goods, shortLink, - hasCoupon); + String content = shareGoodsTextTemplateService.createContentJD(template, goods, shortLink, hasCoupon); JSONObject data = new JSONObject(); data.put("content", content); out.print(JsonUtil.loadTrueResult(data)); @@ -1280,7 +1171,7 @@ * @param hasCoupon * @param out */ - public void createPDDViewText(Integer goodsType, Long uid, String template, Long goodsId, Boolean hasCoupon, + private void createPDDViewText(Integer goodsType, Long uid, String template, Long goodsId, Boolean hasCoupon, PrintWriter out) { PDDGoodsDetail goods = pinDuoDuoCacheUtil.getGoodsInfo(goodsId); if (goods == null) { @@ -1293,23 +1184,11 @@ } // 鏍¢獙鍒告ā鏉挎槸鍚︽纭� - if (hasCoupon) { - // 鏈夊埜鍟嗗搧 - try { - shareGoodsTextTemplateService.isCouponTemplateRightPDD(template); - } catch (ShareGoodsTextTemplateException e) { - out.print(JsonUtil.loadFalseResult(5, e.getMsg())); - return; - } - - } else { - // 鏅�氬晢鍝� - try { - shareGoodsTextTemplateService.isCommonTemplateRightPDD(template); - } catch (ShareGoodsTextTemplateException e) { - out.print(JsonUtil.loadFalseResult(5, e.getMsg())); - return; - } + try { + shareGoodsTextTemplateService.verifyRightPDD(template); + } catch (ShareGoodsTextTemplateException e) { + out.print(JsonUtil.loadFalseResult(5, e.getMsg())); + return; } // // 鍒涘缓h5杩炴帴 @@ -1322,12 +1201,11 @@ String shortLink = PinDuoDuoApiUtil.getPromotionUrl(goodsId, PinDuoDuoApiUtil.PID_SHARE + "", uid + ""); - // 鍒涘缓鍙d护 - String token = PinDuoDuoApiUtil.createGenerate(goodsId); +// // 鍒涘缓鍙d护 +// String token = PinDuoDuoApiUtil.createGenerate(goodsId); // 鐢熸垚鍒嗕韩鍐呭 - String content = shareGoodsTextTemplateService.createContentByTemplatePDD(template, uid, goods, shortLink, - hasCoupon, token); + String content = shareGoodsTextTemplateService.createContentPDD(template, goods, shortLink, hasCoupon); JSONObject data = new JSONObject(); data.put("content", content); @@ -1345,58 +1223,11 @@ private String getShareTemplate(int goodsType, Long uid, boolean hasCoupon, Long tljId) { String template = ""; if (goodsType == Constant.SOURCE_TYPE_TAOBAO) { - if (hasCoupon) { - if (tljId != null) { - template = shareGoodsTextTemplateService.getTaoLiJinTemplate(uid); - if (StringUtil.isNullOrEmpty(template)) - template = configTaoLiJinService.getValueByKey("goods_share_text", new Date()); - } else { - template = shareGoodsTextTemplateService.geteCouponTemplate(uid); - if (StringUtil.isNullOrEmpty(template)) - template = configService.get(ConfigKeyEnum.goodsShareTextCoupon.getKey()); - } - - } else { - template = shareGoodsTextTemplateService.getCommonTemplate(uid); - if (StringUtil.isNullOrEmpty(template)) - template = configService.get(ConfigKeyEnum.goodsShareTextNoCoupon.getKey()); - } + template = shareGoodsTextTemplateService.getTextTemplateByTB(uid); } else if (goodsType == Constant.SOURCE_TYPE_JD) { - ShareGoodsTextTemplate textTemplate = shareGoodsTextTemplateService.getShareGoodsTextTemplate(uid); - if (hasCoupon) { - if (textTemplate != null) { - template = textTemplate.getShareJDTextTemplateCoupon(); - } - if (StringUtil.isNullOrEmpty(template)) { - template = configService.get(ConfigKeyEnum.goodsShareTextCouponJD.getKey()); - } - } else { - if (textTemplate != null) { - template = textTemplate.getShareJDTextTemplate(); - } - - if (StringUtil.isNullOrEmpty(template)) { - template = configService.get(ConfigKeyEnum.goodsShareTextNoCouponJD.getKey()); - } - } + template = shareGoodsTextTemplateService.getTextTemplateByJD(uid); } else if (goodsType == Constant.SOURCE_TYPE_PDD) { - ShareGoodsTextTemplate textTemplate = shareGoodsTextTemplateService.getShareGoodsTextTemplate(uid); - if (hasCoupon) { - if (textTemplate != null) { - template = textTemplate.getSharePDDTextTemplateCoupon(); - } - if (StringUtil.isNullOrEmpty(template)) { - template = configService.get(ConfigKeyEnum.goodsShareTextCouponPDD.getKey()); - } - } else { - if (textTemplate != null) { - template = textTemplate.getSharePDDTextTemplate(); - } - - if (StringUtil.isNullOrEmpty(template)) { - template = configService.get(ConfigKeyEnum.goodsShareTextNocouponPDD.getKey()); - } - } + template = shareGoodsTextTemplateService.getTextTemplateByPDD(uid); } return template; } @@ -1478,39 +1309,11 @@ try { if (goodsType == Constant.SOURCE_TYPE_TAOBAO) { - // 鏍¢獙鍒告ā鏉挎槸鍚︽纭� - if (hasCoupon) { - // 鏈夊埜鍟嗗搧 - if (tljId != null) { - shareGoodsTextTemplateService.isTaoLiJinTemplateRight(template); - shareGoodsTextTemplateService.saveTaoLiJinTemplate(uid, template); - } else { - shareGoodsTextTemplateService.isCouponTemplateRight(template); - shareGoodsTextTemplateService.saveCouponTemplate(uid, template); - } - } else { - // 鏅�氬晢鍝� - shareGoodsTextTemplateService.isCommonTemplateRight(template); - shareGoodsTextTemplateService.saveCommonTemplate(uid, template); - } + shareGoodsTextTemplateService.saveTemplateTB(uid, template); } else if (goodsType == Constant.SOURCE_TYPE_JD) { - if (hasCoupon) { - shareGoodsTextTemplateService.isCouponTemplateRightJD(template); - shareGoodsTextTemplateService.saveCouponTemplateJD(uid, template); - } else { - shareGoodsTextTemplateService.isCommonTemplateRightJD(template); - shareGoodsTextTemplateService.saveCommonTemplateJD(uid, template); - out.print(JsonUtil.loadTrueResult("")); - } + shareGoodsTextTemplateService.saveTemplateJD(uid, template); } else if (goodsType == Constant.SOURCE_TYPE_PDD) { - if (hasCoupon) { - shareGoodsTextTemplateService.isCouponTemplateRightPDD(template); - shareGoodsTextTemplateService.saveCouponTemplatePDD(uid, template); - } else { - shareGoodsTextTemplateService.isCommonTemplateRightPDD(template); - shareGoodsTextTemplateService.saveCommonTemplatePDD(uid, template); - out.print(JsonUtil.loadTrueResult("")); - } + shareGoodsTextTemplateService.saveTemplatePDD(uid, template); } } catch (ShareGoodsTextTemplateException e) { out.print(JsonUtil.loadFalseResult(5, e.getMsg())); @@ -1542,27 +1345,11 @@ } if (goodsType == Constant.SOURCE_TYPE_TAOBAO) { - if (hasCoupon) { - if (tljId != null) { - shareGoodsTextTemplateService.resetTaoLijinTemplate(uid); - } else { - shareGoodsTextTemplateService.resetCouponTemplate(uid); - } - } else { - shareGoodsTextTemplateService.resetCommonTemplate(uid); - } + shareGoodsTextTemplateService.resetCommonTemplate(uid); } else if (goodsType == Constant.SOURCE_TYPE_JD) { - if (hasCoupon) { - shareGoodsTextTemplateService.resetCouponTemplateJD(uid); - } else { - shareGoodsTextTemplateService.resetCommonTemplateJD(uid); - } + shareGoodsTextTemplateService.resetCommonTemplateJD(uid); } else if (goodsType == Constant.SOURCE_TYPE_PDD) { - if (hasCoupon) { - shareGoodsTextTemplateService.resetCouponTemplatePDD(uid); - } else { - shareGoodsTextTemplateService.resetCommonTemplatePDD(uid); - } + shareGoodsTextTemplateService.resetCommonTemplatePDD(uid); } if (goodsId != null) { -- Gitblit v1.8.0