yj
2020-03-03 8ebf78f9d9a2663f53f09346abdd14c5964fdfeb
发圈修改
6个文件已修改
639 ■■■■■ 已修改文件
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/DynamicControllerV2.java 23 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/ShareControllerV2.java 351 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/entity/system/ConfigKeyEnum.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/dynamic/GoodsEvaluateServiceImpl.java 39 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/goods/ShareGoodsTextTemplateServiceImpl.java 196 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/goods/ShareGoodsTextTemplateService.java 26 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/DynamicControllerV2.java
@@ -70,6 +70,7 @@
import com.yeshi.fanli.vo.goods.GoodsDetailVO;
import com.yeshi.fanli.vo.msg.ClientTextStyleVO;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
/**
@@ -669,10 +670,28 @@
            });
            Gson gson = gsonBuilder.create();
            long count = goodsEvaluateService.countValidMaterials(type);
            String listStr = gson.toJson(list);
            JSONArray array = JSONArray.fromObject(listStr);
            for (int i = 0; i< array.size() ; i++) {
                Object object = array.get(i);
                JSONObject json = JSONObject.fromObject(object);
                Object shareNum = json.get("shareNum");
                if (shareNum != null) {
                    int num = Integer.parseInt(shareNum.toString());
                    if (num >= 10000) {
                        double sales = num;
                        String salesCountMidea = String.format("%.1f", sales / 10000);
                        json.put("shareNum", salesCountMidea + "万");
                    }
                }
//                array.add(json);
            }
            JSONObject data = new JSONObject();
            data.put("count", count);
            data.put("list", gson.toJson(list));
            data.put("list", array);
            out.print(JsonUtil.loadTrueResult(data));
        } catch (Exception e) {
            e.printStackTrace();
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());
        }
        // 创建口令
        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;
            }
        // 校验模板是否正确
        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 + "");
        // 创建口令
        String token = PinDuoDuoApiUtil.createGenerate(goodsId);
//        // 创建口令
//        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) {
fanli/src/main/java/com/yeshi/fanli/entity/system/ConfigKeyEnum.java
@@ -174,6 +174,10 @@
    quickShareTBCommentText("quick_share_tb_comment_text", "快捷分享商品文本"),
    quickShareJDCommentText("quick_share_jd_comment_text", "快捷分享商品文本"),
    quickSharePDDCommentText("quick_share_pdd_comment_text", "快捷分享商品文本"),
    shareCommentTextTB("share_comment_text_tb", "淘宝单图多图分享商品文本"),
    shareCommentTextJD("share_comment_text_jd", "京东单图多图分享商品文本"),
    shareCommentTextPDD("share_comment_text_pdd", "拼多多单图多图分享商品文本"),
    ;
    private final String key;
fanli/src/main/java/com/yeshi/fanli/service/impl/dynamic/GoodsEvaluateServiceImpl.java
@@ -20,6 +20,7 @@
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import org.yeshi.utils.DateUtil;
import org.yeshi.utils.JsonUtil;
import org.yeshi.utils.tencentcloud.COSManager;
import com.yeshi.fanli.dao.dynamic.GoodsEvaluateDao;
@@ -49,6 +50,7 @@
import com.yeshi.fanli.service.inter.dynamic.GoodsEvaluateService;
import com.yeshi.fanli.service.inter.goods.ShareGoodsService;
import com.yeshi.fanli.service.inter.order.config.HongBaoManageService;
import com.yeshi.fanli.service.manger.goods.ConvertLinkManager;
import com.yeshi.fanli.util.Constant;
import com.yeshi.fanli.util.FilePathEnum;
import com.yeshi.fanli.util.RedisManager;
@@ -94,6 +96,9 @@
    @Resource
    private ShareGoodsService shareGoodsService;
    
    @Resource
    private ConvertLinkManager convertLinkManager;
    
    @Override
@@ -107,7 +112,7 @@
        if (StringUtil.isNullOrEmpty(tilte)) {
            throw new GoodsEvaluateException(1, "推荐语不能为空");
        }
        try {
            ActivityUser activityUser = activityUserService.getActivityUserByNickName(record.getUser(), file);
            if (activityUser == null)
@@ -734,7 +739,39 @@
        if (StringUtil.isNullOrEmpty(pid)) {
            throw new GoodsEvaluateException(1, "请保存第一部分信息");
        }
        if (StringUtil.isNullOrEmpty(commentInfo.getCoupon())) {
            throw new GoodsEvaluateException(1, "券面额不能为空");
        }
        if (StringUtil.isNullOrEmpty(commentInfo.getTagDesc())) {
            throw new GoodsEvaluateException(1, "描述语不能为空");
        }
        String tagUrl = commentInfo.getTagUrl();
        String content = commentInfo.getContent();
        if (StringUtil.isNullOrEmpty(tagUrl) && StringUtil.isNullOrEmpty(content) ) {
            throw new GoodsEvaluateException(1, "评论语和链接不能同时为空");
        }
        String endTime = commentInfo.getEndTime();
        if (!StringUtil.isNullOrEmpty(endTime)) {
            try {
                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
                sdf.parse(endTime);
            } catch (Exception e) {
                throw new GoodsEvaluateException(1, "请填写正确的时间格式:2020-03-05");
            }
        }
        if(!StringUtil.isNullOrEmpty(content)) {
            try {
                convertLinkManager.convertLinkFromText(content, 1L, true);
            } catch (Exception e) {
                throw new GoodsEvaluateException(1, "转链失败");
            }
        }
        GoodsEvaluate resultObj = goodsEvaluateDao.getById(pid);
        if (resultObj == null)
            throw new GoodsEvaluateException(1, "第一部分信息缺失");
fanli/src/main/java/com/yeshi/fanli/service/impl/goods/ShareGoodsTextTemplateServiceImpl.java
@@ -14,6 +14,7 @@
import com.yeshi.fanli.dto.pdd.PDDGoodsDetail;
import com.yeshi.fanli.entity.goods.ShareGoodsTextTemplate;
import com.yeshi.fanli.entity.jd.JDGoods;
import com.yeshi.fanli.entity.system.ConfigKeyEnum;
import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
import com.yeshi.fanli.exception.goods.ShareGoodsTextTemplateException;
import com.yeshi.fanli.service.inter.config.ConfigService;
@@ -221,6 +222,195 @@
    }
    @Override
    public String getTextTemplateByTB(Long uid) {
        String template = "";
        ShareGoodsTextTemplate objct = shareGoodsTextTemplateMapper.selectByUid(uid);
        if (objct != null && !StringUtil.isNullOrEmpty(objct.getShareTextTemplate())) {
            template = objct.getShareTextTemplate();
            if (template.contains("{原价}")|| template.contains("{口令}") || template.contains("{券后价}")) {
                template = ""; // 老板分享
            }
        }
        if (StringUtil.isNullOrEmpty(template)) {
            template = configService.get(ConfigKeyEnum.shareCommentTextTB.getKey());
        }
        return template;
    }
    @Override
    public String getTextTemplateByJD(Long uid) {
        String template = "";
        ShareGoodsTextTemplate objct = shareGoodsTextTemplateMapper.selectByUid(uid);
        if (objct != null && !StringUtil.isNullOrEmpty(objct.getShareJDTextTemplate())) {
            template = objct.getShareJDTextTemplate();
            if (template.contains("{原价}")|| template.contains("{券后价}") || template.contains("{链接}")) {
                template = ""; // 老板分享
            }
        }
        if (StringUtil.isNullOrEmpty(template)) {
            template = configService.get(ConfigKeyEnum.shareCommentTextJD.getKey());
        }
        return template;
    }
    @Override
    public String getTextTemplateByPDD(Long uid) {
        String template = "";
        ShareGoodsTextTemplate objct = shareGoodsTextTemplateMapper.selectByUid(uid);
        if (objct != null && !StringUtil.isNullOrEmpty(objct.getSharePDDTextTemplate())) {
            template = objct.getSharePDDTextTemplate();
            if (!template.contains("{原价}") && !template.contains("{券后价}") && !template.contains("{链接}")) {
                template = ""; // 老板分享
            }
        }
        if (StringUtil.isNullOrEmpty(template)) {
            template = configService.get(ConfigKeyEnum.shareCommentTextPDD.getKey());
        }
        return template;
    }
    @Override
    public void saveTemplateTB(Long uid, String template) throws ShareGoodsTextTemplateException {
        verifyRightTB(template);
        ShareGoodsTextTemplate old = shareGoodsTextTemplateMapper.selectByUid(uid);
        if (old != null) {
            ShareGoodsTextTemplate update = new ShareGoodsTextTemplate();
            update.setId(old.getId());
            update.setShareTextTemplate(template);
            update.setUpdateTime(new Date());
            shareGoodsTextTemplateMapper.updateByPrimaryKeySelective(update);
        } else {
            ShareGoodsTextTemplate textTemplate = new ShareGoodsTextTemplate();
            textTemplate.setCreateTime(new Date());
            textTemplate.setShareTextTemplate(template);
            textTemplate.setUid(uid);
            shareGoodsTextTemplateMapper.insertSelective(textTemplate);
        }
    }
    @Override
    public void saveTemplateJD(Long uid, String template) throws ShareGoodsTextTemplateException {
        verifyRightJD(template);
        ShareGoodsTextTemplate old = shareGoodsTextTemplateMapper.selectByUid(uid);
        if (old != null) {
            ShareGoodsTextTemplate update = new ShareGoodsTextTemplate();
            update.setId(old.getId());
            update.setShareJDTextTemplate(template);
            update.setUpdateTime(new Date());
            shareGoodsTextTemplateMapper.updateByPrimaryKeySelective(update);
        } else {
            ShareGoodsTextTemplate textTemplate = new ShareGoodsTextTemplate();
            textTemplate.setCreateTime(new Date());
            textTemplate.setShareJDTextTemplate(template);
            textTemplate.setUid(uid);
            shareGoodsTextTemplateMapper.insertSelective(textTemplate);
        }
    }
    @Override
    public void saveTemplatePDD(Long uid, String template) throws ShareGoodsTextTemplateException {
        verifyRightPDD(template);
        ShareGoodsTextTemplate old = shareGoodsTextTemplateMapper.selectByUid(uid);
        if (old != null) {
            ShareGoodsTextTemplate update = new ShareGoodsTextTemplate();
            update.setId(old.getId());
            update.setSharePDDTextTemplate(template);
            update.setUpdateTime(new Date());
            shareGoodsTextTemplateMapper.updateByPrimaryKeySelective(update);
        } else {
            ShareGoodsTextTemplate textTemplate = new ShareGoodsTextTemplate();
            textTemplate.setCreateTime(new Date());
            textTemplate.setSharePDDTextTemplate(template);
            textTemplate.setUid(uid);
            shareGoodsTextTemplateMapper.insertSelective(textTemplate);
        }
    }
    @Override
    public void verifyRightTB(String template) throws ShareGoodsTextTemplateException {
        String[] keys = new String[] { "{原价}", "{券后价}","{口令}" };
        int keysCount = 0;
        for (String key : keys)
            if (template != null && template.contains(key))
                keysCount++;
        if (keysCount == 0)
            throw new ShareGoodsTextTemplateException(1, "模板格式有误");
    }
    @Override
    public void verifyRightJD(String template) throws ShareGoodsTextTemplateException {
        String[] keys = new String[] { "{原价}", "{券后价}","{链接}" };
        int keysCount = 0;
        for (String key : keys)
            if (template != null && template.contains(key))
                keysCount++;
        if (keysCount == 0)
            throw new ShareGoodsTextTemplateException(1, "模板格式有误");
    }
    @Override
    public void verifyRightPDD(String template) throws ShareGoodsTextTemplateException {
        String[] keys = new String[] { "{原价}", "{券后价}","{链接}" };
        int keysCount = 0;
        for (String key : keys)
            if (template != null && template.contains(key))
                keysCount++;
        if (keysCount == 0)
            throw new ShareGoodsTextTemplateException(1, "模板格式有误");
    }
    @Override
    public String createContentTB(String template, TaoBaoGoodsBrief goods, String token, boolean coupon) {
        String commentText = template.replace("{原价}", goods.getZkPrice().toString());
        commentText = commentText.replace("{口令}", TaoBaoUtil.filterTaoToken(token));
        if (coupon) {
            commentText = commentText.replace("领券抢购", "抢购");
            commentText = commentText.replace("【券后价】{券后价}元", "");
        } else {
            commentText = commentText.replace("{券后价}",
                    TaoBaoUtil.getAfterUseCouplePrice(goods) + "");
        }
        return deleteBlankLine(commentText);
    }
    @Override
    public String createContentJD(String template, JDGoods goods, String jumpLink, boolean coupon) {
        String commentText = template.replace("{原价}", goods.getPrice().toString());
        commentText = commentText.replace("{链接}", jumpLink);
        if (coupon) {
            commentText = commentText.replace("领券抢购", "抢购");
            commentText = commentText.replace("【券后价】{券后价}元", "");
        } else {
            commentText = commentText.replace("{券后价}",
                    BigDecimalUtil.getWithNoZera(JDUtil.getQuanPrice(goods)).toString());
        }
        return deleteBlankLine(commentText);
    }
    @Override
    public String createContentPDD(String template, PDDGoodsDetail goods, String jumpLink, boolean coupon) {
        String commentText = template.replace("{原价}", MoneyBigDecimalUtil
                .div(new BigDecimal(goods.getMinGroupPrice()), new BigDecimal(100)).setScale(2).toString());
        commentText = commentText.replace("{链接}", jumpLink);
        if (coupon) {
            commentText = commentText.replace("领券抢购", "抢购");
            commentText = commentText.replace("【券后价】{券后价}元", "");
        } else {
            commentText = commentText.replace("{券后价}",
                    BigDecimalUtil.getWithNoZera(PinDuoDuoUtil.getQuanPrice(goods)).toString());
        }
        return deleteBlankLine(commentText);
    }
    @Override
    public void isCommonTemplateRight(String template) throws ShareGoodsTextTemplateException {
        String[] keys = new String[] { "{标题}", "{店铺类型}", "{商品原价}", "{月销量}", "{短链}", "{淘口令}" };
        int keysCount = 0;
@@ -298,6 +488,12 @@
            throw new ShareGoodsTextTemplateException(1, "模板格式有误");
    }
    private String deleteBlankLine(String st){
        return st.replace("\r\n\r\n", "\r\n").replace("\r\n\r\n", "\r\n").replace("\r\n\r\n", "\r\n");
    }
    @Override
    public String createContentByTemplate(String template, Long uid, TaoBaoGoodsBrief goods, String token,
            String shortLink, boolean hasCoupon, Long tljId) {
fanli/src/main/java/com/yeshi/fanli/service/inter/goods/ShareGoodsTextTemplateService.java
@@ -196,4 +196,30 @@
    public void saveCommonTemplateJD(Long uid, String template) throws ShareGoodsTextTemplateException;
    public void saveCommonTemplatePDD(Long uid, String template) throws ShareGoodsTextTemplateException;
    public void verifyRightTB(String template) throws ShareGoodsTextTemplateException;
    public void verifyRightJD(String template) throws ShareGoodsTextTemplateException;
    public void verifyRightPDD(String template) throws ShareGoodsTextTemplateException;
    public String createContentTB(String template, TaoBaoGoodsBrief goods, String token, boolean coupon);
    public String createContentJD(String template, JDGoods goods, String jumpLink, boolean coupon);
    public String createContentPDD(String template, PDDGoodsDetail goods, String jumpLink, boolean coupon);
    public String getTextTemplateByJD(Long uid);
    public String getTextTemplateByTB(Long uid);
    public String getTextTemplateByPDD(Long uid);
    public void saveTemplateTB(Long uid, String template) throws ShareGoodsTextTemplateException;
    public void saveTemplateJD(Long uid, String template) throws ShareGoodsTextTemplateException;
    public void saveTemplatePDD(Long uid, String template) throws ShareGoodsTextTemplateException;
}