yujian
2019-11-15 dbc8f0b2058d809e6dad0ada92d391109cbb4f57
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/ShareControllerV2.java
@@ -21,6 +21,7 @@
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.yeshi.fanli.dto.ConfigParamsDTO;
import com.yeshi.fanli.dto.jd.JDCouponInfo;
import com.yeshi.fanli.dto.pdd.PDDGoodsDetail;
import com.yeshi.fanli.dto.share.ShareGoodsRecordDTO;
@@ -31,6 +32,7 @@
import com.yeshi.fanli.entity.bus.tlj.UserTaoLiJinRecord;
import com.yeshi.fanli.entity.bus.user.UserExtraTaoBaoInfo;
import com.yeshi.fanli.entity.bus.user.UserInfo;
import com.yeshi.fanli.entity.bus.user.UserInfoExtra;
import com.yeshi.fanli.entity.goods.CommonGoods;
import com.yeshi.fanli.entity.goods.ShareGoodsTextTemplate;
import com.yeshi.fanli.entity.jd.JDGoods;
@@ -66,6 +68,7 @@
import com.yeshi.fanli.util.RedisManager;
import com.yeshi.fanli.util.StringUtil;
import com.yeshi.fanli.util.TaoBaoConstant;
import com.yeshi.fanli.util.VersionUtil;
import com.yeshi.fanli.util.cache.JDGoodsCacheUtil;
import com.yeshi.fanli.util.cache.PinDuoDuoCacheUtil;
import com.yeshi.fanli.util.cache.TaoBaoGoodsCacheUtil;
@@ -208,6 +211,21 @@
      }
   }
   public static String getERCodeContent(TaoBaoGoodsBrief goods, String token) {
      String content = String.format("【%s】%s元", goods.getUserType() == 1 ? "T猫价" : "T宝价",
            MoneyBigDecimalUtil.getWithNoZera(goods.getZkPrice()) + "");
      content += "\n\r";
      if (!StringUtil.isNullOrEmpty(goods.getCouponInfo())) {
         content += String.format("【券后价】%s元", TaoBaoUtil.getAfterUseCouplePrice(goods) + "");
         content += "\n\r";
      }
      content += "------------";
      content += "\n\r";
      content += "復制这条" + token + ",進入Tao宝即可购买";
      return content;
   }
   /**
    * 创建淘宝分享信息
    * 
@@ -221,8 +239,12 @@
    */
   public void createTaoBaoShare(AcceptData acceptData, Long uid, Long goodsId, Integer totalNum, String source,
         HttpServletRequest request, PrintWriter out) {
      UserExtraTaoBaoInfo extraInfo = userExtraTaoBaoInfoService.getByUid(uid);
      UserInfoExtra userExtraInfo = userInfoExtraService.getUserInfoExtra(uid);
      String inviteCode=null;
      if(userExtraInfo!=null)
         inviteCode=userExtraInfo.getInviteCode();
      String relationId = null;
      if (extraInfo != null && extraInfo.getRelationId() != null && extraInfo.getRelationValid() != null
            && extraInfo.getRelationValid() == true)
@@ -241,6 +263,12 @@
      try {
         ShareInfoVO shareInfo = new ShareInfoVO();
         // 测试
         TaoBaoLink taoBaoLink = shareGoodsService.getTaoBaoLinkForShare(uid, goodsId, relationId);
@@ -257,6 +285,27 @@
         shareInfo.setToken(TaoBaoUtil.filterTaoToken(taoBaoLink.getTaoToken()));
         shareInfo.setRule(configService.get("share_single_goods_rule"));
         shareInfo.setPictUrl(TbImgUtil.getTBSizeImg(taoBaoLink.getGoods().getPictUrl(), 500));
         String  commentTextStr=    configService.get("share_single_goods_comment_text");
         List<String> commentTexts = new ArrayList<>();
         if(!StringUtil.isNullOrEmpty(commentTextStr))
         {
            JSONArray array=   JSONArray.fromObject(commentTextStr);
            for(int i=0;i<array.size();i++)
            {
               if(StringUtil.isNullOrEmpty(inviteCode))
               {
                  if(array.optString(i).contains("[邀请码]"))
                  {
                     continue;
                  }
               }
               commentTexts.add(array.optString(i).replace("[下载链接]", Constant.YINGYONGBAO_LINK).replace("[邀请码]", inviteCode).replace("[淘口令]", shareInfo.getToken()));
            }
         }
         shareInfo.setCommentTexts(commentTexts);
         String shareText = "";
         // 无券
@@ -293,6 +342,12 @@
            descText = descText.substring(0);
         }
         shareInfo.setDescText(descText);
         // 测试
         // 2.0.2之前
         if (!VersionUtil.greaterThan_2_0_2(acceptData.getPlatform(), acceptData.getVersion()))
            shareInfo.setClickUrl(getERCodeContent(taoBaoLink.getGoods(), shareInfo.getToken()));
         shareInfo.setWxErCode(getERCodeContent(taoBaoLink.getGoods(), shareInfo.getToken()));
         // 提示图文内容
         String imgs = configService.get("goods_share_notify_imgs");
@@ -551,7 +606,7 @@
   public void createJDShare(AcceptData acceptData, Long uid, Long goodsId, String source, PrintWriter out) {
      JDGoods jdGoods = jdGoodsCacheUtil.getGoodsInfo(goodsId);
      if (jdGoods == null) {
         out.print(JsonUtil.loadFalseResult(1, "该商品淘已下架"));
         out.print(JsonUtil.loadFalseResult(1, "该商品已下架"));
         return;
      }
@@ -571,8 +626,10 @@
      ShareInfoVO shareInfo = new ShareInfoVO();
      shareInfo.setClickUrl(jumpLink);
      shareInfo.setWxErCode(jumpLink);
      shareInfo.setRule(configService.get("share_rule_link_jd"));
      shareInfo.setPictUrl(jdGoods.getPicUrl());
      shareInfo.setCommentTexts(new ArrayList<>());
      String shareText = "";
      boolean hasCoupon = false;
@@ -681,6 +738,8 @@
      ShareInfoVO shareInfo = new ShareInfoVO();
      shareInfo.setClickUrl(jumpLink);
      shareInfo.setWxErCode(jumpLink);
      shareInfo.setCommentTexts(new ArrayList<>());
      shareInfo.setRule(configService.get("share_rule_link_pdd"));
      shareInfo.setPictUrl(goods.getGoodsImageUrl());
@@ -1331,6 +1390,8 @@
      BigDecimal fanLiRate = hongBaoManageService.getFanLiRate();
      BigDecimal shareRate = hongBaoManageService.getShareRate();
      ConfigParamsDTO paramsDTO = new ConfigParamsDTO(fanLiRate, shareRate, Constant.MAX_REWARD_RATE);
      Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
            .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
@@ -1369,7 +1430,7 @@
         dataObject.put("totalOrder", goodsGroup.getTotalOrder());
         dataObject.put("totalMoney", "¥" + goodsGroup.getTotalMoney());
         GoodsDetailVO detailVO = GoodsDetailVOFactory.convertCommonGoods(commonGoods, null, fanLiRate, shareRate);
         GoodsDetailVO detailVO = GoodsDetailVOFactory.convertCommonGoods(commonGoods, paramsDTO);
         detailVO.setId(commonGoods.getId());
         dataObject.put("goods", gson.toJson(detailVO));
         array.add(dataObject);