yujian
2019-07-23 5de85a1e6e1c6658e3c6379ef778b7aa009e2103
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/ShareControllerV2.java
@@ -560,32 +560,25 @@
      shareInfo.setPictUrl(jdGoods.getPicUrl());
      String shareText = "";
      String shopType = "京东价";
      boolean hasCoupon = false;
      // 分享模板
      JDCouponInfo couponInfo = jdGoods.getCouponInfo();
      if (couponInfo == null) {
         String text = shareGoodsTextTemplateService.getCommonTemplate(uid);
         if (StringUtil.isNullOrEmpty(text)) {
            text = configService.get("goods_share_text_nocoupon");
         }
         shareText = text.replace("{标题}", jdGoods.getSkuName()).replace("{商品原价}",
               MoneyBigDecimalUtil.getWithNoZera(jdGoods.getPrice()) + "");
      } else// 有券
      {
         String text = shareGoodsTextTemplateService.geteCouponTemplate(uid);
         if (StringUtil.isNullOrEmpty(text))
            text = configService.get("goods_share_text_coupon");
         shareText = text.replace("{标题}", jdGoods.getSkuName())
               .replace("{商品原价}", MoneyBigDecimalUtil.getWithNoZera(jdGoods.getPrice()) + "")
               .replace("{优惠券面额}", MoneyBigDecimalUtil.getWithNoZera(couponInfo.getDiscount()) + "")
               .replace("{优惠券价}", JDUtil.getQuanPrice(jdGoods) + "");
      ShareGoodsTextTemplate textTemplate = shareGoodsTextTemplateService.getShareGoodsTextTemplate(uid);
      if (couponInfo == null) { // 无券模板
         if (textTemplate != null)
            shareText = textTemplate.getShareJDTextTemplate();
         if (StringUtil.isNullOrEmpty(shareText))
            shareText = configService.get("goods_share_text_nocoupon_jd");
      } else { // 有券模板
         hasCoupon = true;
         if (textTemplate != null)
            shareText = textTemplate.getShareJDTextTemplateCoupon();
         if (StringUtil.isNullOrEmpty(shareText))
            shareText = configService.get("goods_share_text_coupon_jd");
      }
      shareText = shareText.replace("{店铺类型}", shopType)
            .replace("{月销量}", JDUtil.getSaleCount(jdGoods.getInOrderCount30Days())).replace("{领券短链}", shortLink)
            .replace("{淘口令}", null);
      shareText = shareGoodsTextTemplateService.createContentByTemplateJD(shareText, uid, jdGoods, shortLink, hasCoupon);
      shareInfo.setShareText(shareText);
      String descText = shareText.replace(jdGoods.getSkuName(), "").trim();
@@ -594,7 +587,6 @@
      }
      shareInfo.setDescText(descText);
      //
      String imgs = configService.get("goods_share_notify_imgs");
      JSONArray array = JSONArray.fromObject(imgs);
      int p = (int) (array.size() * Math.random());
@@ -678,33 +670,30 @@
      shareInfo.setRule(configService.get("share_rule_link_pdd"));
      shareInfo.setPictUrl(goods.getGoodsImageUrl());
      String shareText = "";
      String shopType = "拼多多价";
      // 无券
      String template = "";
      boolean hasCoupon = false;
      ShareGoodsTextTemplate textTemplate = shareGoodsTextTemplateService.getShareGoodsTextTemplate(uid);
      if (goods.getHasCoupon() == null || !goods.getHasCoupon()) {
         String text = shareGoodsTextTemplateService.getCommonTemplate(uid);
         if (StringUtil.isNullOrEmpty(text))
            text = configService.get("goods_share_text_nocoupon");
         shareText = text.replace("{标题}", goods.getGoodsName()).replace("{商品原价}",
               MoneyBigDecimalUtil.getWithNoZera(new BigDecimal(goods.getMinNormalPrice())) + "");
      } else// 有券
      {
         String text = shareGoodsTextTemplateService.geteCouponTemplate(uid);
         if (StringUtil.isNullOrEmpty(text))
            text = configService.get("goods_share_text_coupon");
         if (textTemplate != null)
            template = textTemplate.getSharePDDTextTemplate();
         shareText = text.replace("{标题}", goods.getGoodsName())
               .replace("{商品原价}",
                     MoneyBigDecimalUtil.getWithNoZera(new BigDecimal(goods.getMinNormalPrice())) + "")
               .replace("{优惠券面额}",
                     MoneyBigDecimalUtil.getWithNoZera(new BigDecimal(goods.getCouponDiscount())) + "")
               .replace("{优惠券价}", PinDuoDuoUtil.getQuanPrice(goods) + "");
         if (StringUtil.isNullOrEmpty(template))
            template = configService.get("goods_share_text_nocoupon_pdd");
      } else {
         hasCoupon = true;
         if (textTemplate != null)
            template = textTemplate.getSharePDDTextTemplateCoupon();
         if (StringUtil.isNullOrEmpty(template))
            template = configService.get("goods_share_text_coupon_pdd");
      }
      shareText = shareText.replace("{店铺类型}", shopType)
            .replace("{月销量}", goods.getSalesTip()).replace("{领券短链}", shortLink)
            .replace("{淘口令}", null);
      // 创建口令
      String token = PinDuoDuoApiUtil.createGenerate(goodsId);
      // 生成分享内容
      String shareText = shareGoodsTextTemplateService.createContentByTemplatePDD(template, uid, goods, shortLink,
                  hasCoupon, token);
      shareInfo.setShareText(shareText);
      String descText = shareText.replace(goods.getGoodsName(), "").trim();