admin
2019-08-05 34e65d72e73acab040b68d01ef6b4764b4408624
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/ShareControllerV2.java
@@ -533,36 +533,34 @@
    * @param out
    */
   public void createJDShare(AcceptData acceptData, Long uid, Long goodsId, String source, PrintWriter out) {
      JDGoods jdGoods = JDApiUtil.queryGoodsDetail(goodsId);
      if (jdGoods == null) {
         jdGoods = JDApiUtil.getGoodsDetail(goodsId);
      }
      JDGoods jdGoods = jdGoodsCacheUtil.getGoodsInfo(goodsId);
      if (jdGoods == null) {
         out.print(JsonUtil.loadFalseResult(1, "该商品淘已下架"));
         return;
      }
      ShareInfoVO shareInfo = new ShareInfoVO();
      String url = String.format("http://%s%s?uid=%s&id=%s", configService.getH5Host(),
            Constant.systemCommonConfig.getShareGoodsPagePathJD(), AESUtil.encrypt(uid + "", Constant.UIDAESKEY),
            goodsId + "");
//      String url = String.format("http://%s%s?uid=%s&id=%s", configService.getH5Host(),
//            Constant.systemCommonConfig.getShareGoodsPagePathJD(), AESUtil.encrypt(uid + "", Constant.UIDAESKEY),
//            goodsId + "");
      // 券短连接
      String shortLink = HttpUtil.getShortLink(url);
      if (!StringUtil.isNullOrEmpty(shortLink)) {
         url = shortLink;
      String couponUrl = null;
      JDCouponInfo couponInfo = jdGoods.getCouponInfo();
      if (couponInfo != null) {
         couponUrl = couponInfo.getLink();
      }
      String materialId = "https://item.jd.com/" + goodsId + ".html";
      String jumpLink = JDApiUtil.convertShortLink(materialId, couponUrl, JDApiUtil.POSITION_SHARE + "", uid+ "");
      shareInfo.setClickUrl(url);
      ShareInfoVO shareInfo = new ShareInfoVO();
      shareInfo.setClickUrl(jumpLink);
      shareInfo.setRule(configService.get("share_rule_link_jd"));
      shareInfo.setPictUrl(jdGoods.getPicUrl());
      String shareText = "";
      boolean hasCoupon = false;
      // 分享模板
      JDCouponInfo couponInfo = jdGoods.getCouponInfo();
      ShareGoodsTextTemplate textTemplate = shareGoodsTextTemplateService.getShareGoodsTextTemplate(uid);
      if (couponInfo == null) { // 无券模板
         if (textTemplate != null) 
@@ -578,7 +576,7 @@
         if (StringUtil.isNullOrEmpty(shareText))
            shareText = configService.get("goods_share_text_coupon_jd");
      }
      shareText = shareGoodsTextTemplateService.createContentByTemplateJD(shareText, uid, jdGoods, shortLink, hasCoupon);
      shareText = shareGoodsTextTemplateService.createContentByTemplateJD(shareText, uid, jdGoods, jumpLink, hasCoupon);
      shareInfo.setShareText(shareText);
      String descText = shareText.replace(jdGoods.getSkuName(), "").trim();
@@ -649,24 +647,20 @@
    * @param out
    */
   public void createPDDShare(AcceptData acceptData, Long uid, Long goodsId, String source, PrintWriter out) {
      PDDGoodsDetail goods = PinDuoDuoApiUtil.getGoodsDetail(goodsId);
      PDDGoodsDetail goods = pinDuoDuoCacheUtil.getGoodsInfo(goodsId);
      if (goods == null) {
         out.print(JsonUtil.loadFalseResult(1, "该商品已下架"));
         return;
      }
//      String url = String.format("http://%s%s?uid=%s&id=%s", configService.getH5Host(),
//            Constant.systemCommonConfig.getShareGoodsPagePathPDD(), AESUtil.encrypt(uid + "", Constant.UIDAESKEY),
//            goodsId + "");
      String jumpLink = PinDuoDuoApiUtil.getPromotionUrl(goodsId, PinDuoDuoApiUtil.PID_SHARE + "", uid + "");
      ShareInfoVO shareInfo = new ShareInfoVO();
      String url = String.format("http://%s%s?uid=%s&id=%s", configService.getH5Host(),
            Constant.systemCommonConfig.getShareGoodsPagePathPDD(), AESUtil.encrypt(uid + "", Constant.UIDAESKEY),
            goodsId + "");
      String shortLink = HttpUtil.getShortLink(url);
      if (!StringUtil.isNullOrEmpty(shortLink)) {
         url = shortLink;
      }
      shareInfo.setClickUrl(url);
      shareInfo.setClickUrl(jumpLink);
      shareInfo.setRule(configService.get("share_rule_link_pdd"));
      shareInfo.setPictUrl(goods.getGoodsImageUrl());
@@ -692,7 +686,7 @@
      String token = PinDuoDuoApiUtil.createGenerate(goodsId);
            
      // 生成分享内容
      String shareText = shareGoodsTextTemplateService.createContentByTemplatePDD(template, uid, goods, shortLink,
      String shareText = shareGoodsTextTemplateService.createContentByTemplatePDD(template, uid, goods, jumpLink,
                  hasCoupon, token);
      shareInfo.setShareText(shareText);
@@ -718,7 +712,7 @@
      try {
         ShareGoodsRecordDTO shareRecord = userShareGoodsRecordService.addRecordGoodsDetail(uid, goodsId,
               Constant.SOURCE_TYPE_JD);
               Constant.SOURCE_TYPE_PDD);
         shareInfo.setShareId(shareRecord.getRedisKey());
      } catch (Exception e) {
         try {
@@ -738,7 +732,7 @@
            history.setUser(new UserInfo(uid));
            history.setHongbao(shareMoney);
            history.setCreateTime(new Date());
            history.setGoodsType(Constant.SOURCE_TYPE_JD);
            history.setGoodsType(Constant.SOURCE_TYPE_PDD);
            history.setTkCode(null);
            history.setLink(null);
            history.setQuanLink(null);
@@ -792,12 +786,12 @@
         return;
      }
      if (goodsType == Constant.SOURCE_TYPE_TAOBAO) {
      if (goodsType == Constant.SOURCE_TYPE_JD) {
         createJDViewText(goodsType, uid, template, goodsId, hasCoupon, out);
         return;
      }
      if (goodsType == Constant.SOURCE_TYPE_TAOBAO) {
      if (goodsType == Constant.SOURCE_TYPE_PDD) {
         createPDDViewText(goodsType, uid, template, goodsId, hasCoupon, out);
         return;
      }
@@ -946,10 +940,13 @@
         }
      }
      String url = String.format("http://%s%s?uid=%s&id=%s&appType=flq", configService.getH5Host(),
            Constant.systemCommonConfig.getShareGoodsPagePath(), AESUtil.encrypt(uid + "", Constant.UIDAESKEY),
            goodsId + "");
      String shortLink = HttpUtil.getShortLink(url);
      String couponUrl = null;
      JDCouponInfo couponInfo = goods.getCouponInfo();
      if (couponInfo != null) {
         couponUrl = couponInfo.getLink();
      }
      String materialId = "https://item.jd.com/" + goodsId + ".html";
      String shortLink = JDApiUtil.convertShortLink(materialId, couponUrl, JDApiUtil.POSITION_SHARE + "", uid+ "");
      String content = shareGoodsTextTemplateService.createContentByTemplateJD(template, uid, goods, shortLink,
            hasCoupon);
@@ -959,7 +956,7 @@
   }
   /**
    * 创建京东分享模板
    * 创建拼多多分享模板
    * 
    * @param uid
    * @param template
@@ -1001,11 +998,13 @@
         }
      }
      // 创建h5连接
      String url = String.format("http://%s%s?uid=%s&id=%s&appType=flq", configService.getH5Host(),
            Constant.systemCommonConfig.getShareGoodsPagePath(), AESUtil.encrypt(uid + "", Constant.UIDAESKEY),
            goodsId + "");
      String shortLink = HttpUtil.getShortLink(url);
//      // 创建h5连接
//      String url = String.format("http://%s%s?uid=%s&id=%s&appType=flq", configService.getH5Host(),
//            Constant.systemCommonConfig.getShareGoodsPagePath(), AESUtil.encrypt(uid + "", Constant.UIDAESKEY),
//            goodsId + "");
//      String shortLink = HttpUtil.getShortLink(url);
      String shortLink = PinDuoDuoApiUtil.getPromotionUrl(goodsId, PinDuoDuoApiUtil.PID_SHARE + "", uid + "");
      // 创建口令
      String token = PinDuoDuoApiUtil.createGenerate(goodsId);