admin
2020-07-03 651a15c78f668bef3859d9ed1bb7ad0b669d3600
fanli/src/main/java/com/yeshi/fanli/controller/client/v1/ShareController.java
@@ -10,6 +10,9 @@
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import com.yeshi.fanli.entity.SystemEnum;
import com.yeshi.fanli.exception.taobao.TaoBaoConvertLinkException;
import com.yeshi.fanli.service.manger.goods.TaoBaoLinkManager;
import org.springframework.core.task.TaskExecutor;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@@ -90,6 +93,9 @@
   @Resource
   private ShareGoodsService shareGoodsService;
   @Resource
   private TaoBaoLinkManager taoBaoLinkManager;
   @Resource
   private ConfigService configService;
@@ -193,15 +199,15 @@
      }
      if (source != null && "taolijin".equals(source)) {
         createTaoLijin(uid, auctionId, totalNum, relationId, request, out);
         createTaoLijin(uid, auctionId, totalNum, relationId,acceptData.getSystem(), request, out);
         return;
      }
      try {
         TaoBaoLink taoBaoLink = shareGoodsService.getTaoBaoLinkForShare(uid, auctionId, relationId);
         TaoBaoLink taoBaoLink = taoBaoLinkManager.getTaoBaoLinkForShare(uid, auctionId, relationId,null);
         JSONObject data = new JSONObject();
         String url = String.format("http://%s%s?uid=%s&id=%s&appType=flq", configService.getH5Host(),
         String url = String.format("http://%s%s?uid=%s&id=%s&appType=flq", configService.getH5Host(acceptData.getSystem()),
               Constant.systemCommonConfig.getShareGoodsPagePath(), AESUtil.encrypt(uid + "", Constant.UIDAESKEY),
               auctionId + "");
@@ -212,7 +218,7 @@
         data.put("clickUrl", url);
         data.put("token", TaoBaoUtil.filterTaoToken(taoBaoLink.getTaoToken()));
         data.put("rule", configService.get(ConfigKeyEnum.shareSingleGoodsRule.getKey()));
         data.put("rule", configService.getValue(ConfigKeyEnum.shareSingleGoodsRule.getKey(),acceptData.getSystem()));
         data.put("pictUrl", TbImgUtil.getTBSizeImg(taoBaoLink.getGoods().getPictUrl(), 500));
         String shareText = "";
@@ -223,14 +229,14 @@
         if (StringUtil.isNullOrEmpty(taoBaoLink.getGoods().getCouponInfo())) {
            String text = shareGoodsTextTemplateService.getCommonTemplate(uid);
            if (StringUtil.isNullOrEmpty(text))
               text = configService.get(ConfigKeyEnum.goodsShareTextNoCoupon.getKey());
               text = configService.getValue(ConfigKeyEnum.goodsShareTextNoCoupon.getKey(),acceptData.getSystem());
            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());
               text = configService.getValue(ConfigKeyEnum.goodsShareTextCoupon.getKey(),acceptData.getSystem());
            shareText = text.replace("{标题}", taoBaoLink.getGoods().getTitle())
                  .replace("{商品原价}", MoneyBigDecimalUtil.getWithNoZera(taoBaoLink.getGoods().getZkPrice()) + "")
@@ -248,12 +254,12 @@
            descText = descText.substring(0);
         data.put("descText", descText);
         //
         String imgs = configService.get(ConfigKeyEnum.goodsShareNotifyImgs.getKey());
         String imgs = configService.getValue(ConfigKeyEnum.goodsShareNotifyImgs.getKey(),acceptData.getSystem());
         JSONArray array = JSONArray.fromObject(imgs);
         int p = (int) (array.size() * Math.random());
         if (p < array.size())
            data.put("notifyPicture", array.optString(p));
         data.put("notifyDesc", configService.get(ConfigKeyEnum.goodsShareNotify.getKey()));
         data.put("notifyDesc", configService.getValue(ConfigKeyEnum.goodsShareNotify.getKey(),acceptData.getSystem()));
         // 添加分享记录
         BigDecimal rate = hongBaoManageService.getShareRate();
@@ -299,7 +305,7 @@
            }
         });
         return;
      } catch (ShareGoodsException e) {
      } catch (TaoBaoConvertLinkException e) {
         LogHelper.errorDetailInfo(e, "分享出错:uid:" + uid + "auctionId:" + auctionId, "");
         // 分享出错报警
         try {
@@ -307,7 +313,7 @@
         } catch (Exception e1) {
         }
         out.print(JsonUtil.loadFalseResult(e.getCode(), e.getMessage()));
         businessEmergent110Service.shareTaoBaoGoodsError(StringUtil.Md5(auctionId + ""));
         businessEmergent110Service.shareTaoBaoGoodsError(StringUtil.Md5(auctionId + ""),acceptData.getSystem());
      }
   }
@@ -321,10 +327,10 @@
    * @param request
    * @param out
    */
   public void createTaoLijin(Long uid, Long auctionId, int totalNum, String relationId, HttpServletRequest request,
         PrintWriter out) {
   public void createTaoLijin(Long uid, Long auctionId, int totalNum, String relationId, SystemEnum system, HttpServletRequest request,
                        PrintWriter out) {
      try {
         TaoBaoLink taoBaoLink = shareGoodsService.getTaoLiJinLinkForShare(uid, auctionId, relationId);
         TaoBaoLink taoBaoLink = taoBaoLinkManager.getTaoLiJinLinkForShare(uid, auctionId, relationId,null);
         TaoBaoGoodsBrief goods = taoBaoLink.getGoods();
@@ -354,7 +360,7 @@
            return;
         }
         String url = String.format("http://%s%s?uid=%s&id=%s&appType=flq&tid=%s", configService.getH5Host(),
         String url = String.format("http://%s%s?uid=%s&id=%s&appType=flq&tid=%s", configService.getH5Host(system),
               Constant.systemCommonConfig.getShareGoodsPagePath(), AESUtil.encrypt(uid + "", Constant.UIDAESKEY),
               auctionId + "", AESUtil.encrypt(tljId + "", Constant.UIDAESKEY));
         String shortLink = HttpUtil.getShortLink(url);
@@ -379,7 +385,7 @@
         data.put("token", TaoBaoUtil.filterTaoToken(taoBaoLink.getTaoToken()));
         data.put("rule",
               "http://apph5.yeshitv.com/apppage/all_help_content.html?id=148&from=singlemessage&isappinstalled=0");
               "http://apph5.banliapp.com/apppage/all_help_content.html?id=148&from=singlemessage&isappinstalled=0");
         data.put("pictUrl", TbImgUtil.getTBSizeImg(taoBaoLink.getGoods().getPictUrl(), 500));
         // 无券
@@ -390,7 +396,7 @@
         if (StringUtil.isNullOrEmpty(taoBaoLink.getGoods().getCouponInfo())) {
            String text = shareGoodsTextTemplateService.getCommonTemplate(uid);
            if (StringUtil.isNullOrEmpty(text))
               text = configService.get(ConfigKeyEnum.goodsShareTextNoCoupon.getKey());
               text = configService.getValue(ConfigKeyEnum.goodsShareTextNoCoupon.getKey(),system);
            shareText = text.replace("{标题}", taoBaoLink.getGoods().getTitle()).replace("{商品原价}",
                  MoneyBigDecimalUtil.getWithNoZera(taoBaoLink.getGoods().getZkPrice()) + "");
         } else// 有券
@@ -416,12 +422,12 @@
            descText = descText.substring(0);
         data.put("descText", descText);
         String imgs = configService.get(ConfigKeyEnum.goodsShareNotifyImgs.getKey());
         String imgs = configService.getValue(ConfigKeyEnum.goodsShareNotifyImgs.getKey(),system);
         JSONArray array = JSONArray.fromObject(imgs);
         int p = (int) (array.size() * Math.random());
         if (p < array.size())
            data.put("notifyPicture", array.optString(p));
         data.put("notifyDesc", configService.get(ConfigKeyEnum.goodsShareNotify.getKey()));
         data.put("notifyDesc", configService.getValue(ConfigKeyEnum.goodsShareNotify.getKey(),system));
         // 添加分享记录
         BigDecimal rate = hongBaoManageService.getShareRate();
@@ -467,7 +473,7 @@
            }
         });
         return;
      } catch (ShareGoodsException e) {
      } catch (TaoBaoConvertLinkException e) {
         LogHelper.errorDetailInfo(e, "分享出错:uid:" + uid + "auctionId:" + auctionId, "");
         // 分享出错报警
         try {
@@ -475,7 +481,7 @@
         } catch (Exception e1) {
         }
         out.print(JsonUtil.loadFalseResult(e.getCode(), e.getMessage()));
         businessEmergent110Service.shareTaoBaoGoodsError(StringUtil.Md5(auctionId + ""));
         businessEmergent110Service.shareTaoBaoGoodsError(StringUtil.Md5(auctionId + ""),system);
      }
   }
@@ -529,7 +535,7 @@
            }
         });
         Gson gson = gsonBuilder.create();
         data.put("count", count);
         data.put("result_list", gson.toJson(list));
         out.print(JsonUtil.loadTrueResult(data));
@@ -691,7 +697,7 @@
      }
      if (StringUtil.isNullOrEmpty(template))
         template = getShareTemplate(uid, hasCoupon, tljId);
         template = getShareTemplate(uid, hasCoupon, tljId,acceptData.getSystem());
      // 校验券模板是否正确
      if (hasCoupon) {
@@ -730,7 +736,7 @@
         }
         url = userTaoLiJinRecord.getSendUrl();
      } else {
         url = String.format("http://%s%s?uid=%s&id=%s&appType=flq", configService.getH5Host(),
         url = String.format("http://%s%s?uid=%s&id=%s&appType=flq", configService.getH5Host(acceptData.getSystem()),
               Constant.systemCommonConfig.getShareGoodsPagePath(), AESUtil.encrypt(uid + "", Constant.UIDAESKEY),
               goods.getAuctionId() + "");
      }
@@ -850,7 +856,7 @@
      out.print(JsonUtil.loadTrueResult(""));
   }
   private String getShareTemplate(Long uid, boolean hasCoupon, Long tljId) {
   private String getShareTemplate(Long uid, boolean hasCoupon, Long tljId,SystemEnum system) {
      if (hasCoupon) {
         if (tljId != null) {
            String template = shareGoodsTextTemplateService.getTaoLiJinTemplate(uid);
@@ -860,14 +866,14 @@
         } else {
            String template = shareGoodsTextTemplateService.geteCouponTemplate(uid);
            if (StringUtil.isNullOrEmpty(template))
               template = configService.get(ConfigKeyEnum.goodsShareTextCoupon.getKey());
               template = configService.getValue(ConfigKeyEnum.goodsShareTextCoupon.getKey(),system);
            return template;
         }
      } else {
         String template = shareGoodsTextTemplateService.getCommonTemplate(uid);
         if (StringUtil.isNullOrEmpty(template))
            template = configService.get(ConfigKeyEnum.goodsShareTextNoCoupon.getKey());
            template = configService.getValue(ConfigKeyEnum.goodsShareTextNoCoupon.getKey(),system);
         return template;
      }
   }
@@ -893,7 +899,7 @@
      }
      JSONObject data = new JSONObject();
      data.put("template", getShareTemplate(uid, hasCoupon, tljId));
      data.put("template", getShareTemplate(uid, hasCoupon, tljId,acceptData.getSystem()));
      out.print(JsonUtil.loadTrueResult(data));
   }
@@ -908,7 +914,7 @@
      if (tljId != null) {
         out.print(JsonUtil.loadTrueResult(configTaoLiJinService.getValueByKey("share_goods_rules", new Date())));
      } else {
         out.print(JsonUtil.loadTrueResult(configService.get(ConfigKeyEnum.shareGoodsTemplateRules.getKey())));
         out.print(JsonUtil.loadTrueResult(configService.getValue(ConfigKeyEnum.shareGoodsTemplateRules.getKey(),acceptData.getSystem())));
      }
   }
@@ -916,8 +922,8 @@
    * 查询顶部分类
    * 
    * @param acceptData
    * @param page
    * @param cid
    * @param id
    * @param uid
    * @param out
    */
   @RequestMapping(value = "shareDynamic", method = RequestMethod.POST)
@@ -1042,10 +1048,10 @@
            data.put("shareMoney", new BigDecimal(content.substring(index + 1, content.length())).toString());
            // 分享提醒
            data.put("notifyDesc", configService.get(ConfigKeyEnum.goodsShareNotify.getKey()));
            data.put("notifyDesc", configService.getValue(ConfigKeyEnum.goodsShareNotify.getKey(),acceptData.getSystem()));
            // 分享提示语
            String imgs = configService.get(ConfigKeyEnum.goodsShareNotifyImgs.getKey());
            String imgs = configService.getValue(ConfigKeyEnum.goodsShareNotifyImgs.getKey(),acceptData.getSystem());
            JSONArray array = JSONArray.fromObject(imgs);
            int p = (int) (array.size() * Math.random());
            if (p < array.size()) {
@@ -1058,7 +1064,7 @@
            // 帮助链接
            data.put("helpLink",
                  "http://apph5.yeshitv.com/apppage/all_help_content.html?id=148&from=singlemessage&isappinstalled=0");
                  "http://apph5.banliapp.com/apppage/all_help_content.html?id=148&from=singlemessage&isappinstalled=0");
            if (cid == 2) { // 2 推荐好货
               ShareGoodsRecordDTO shareRecord = userShareGoodsRecordService.addRecordDynamic(uid,
@@ -1073,7 +1079,7 @@
               Long auctionId = dynamicInfo.getImgs().get(0).getGoods().getAuctionId();
               // 商品分享链接
               String url = String.format("http://%s%s?uid=%s&id=%s&appType=flq", configService.getH5Host(),
               String url = String.format("http://%s%s?uid=%s&id=%s&appType=flq", configService.getH5Host(acceptData.getSystem()),
                     Constant.systemCommonConfig.getShareGoodsPagePath(),
                     AESUtil.encrypt(uid + "", Constant.UIDAESKEY), auctionId + "");
               String shortLink = HttpUtil.getShortLink(url);
@@ -1090,18 +1096,21 @@
                     && extraInfo.getRelationValid() == true) {
                  relationId = extraInfo.getRelationId();
               }
               TaoBaoLink taoBaoLink = shareGoodsService.getTaoBaoLinkForShare(uid, auctionId, relationId);
               TaoBaoLink taoBaoLink = taoBaoLinkManager.getTaoBaoLinkForShare(uid, auctionId, relationId,null);
               TaoBaoGoodsBrief goods = taoBaoLink.getGoods();
               if (!com.yeshi.fanli.util.VersionUtil.greaterThan_2_0_2(acceptData.getPlatform(),
                     acceptData.getVersion()))
                  data.put("clickUrl", ShareControllerV2.getERCodeContent(configService.get(ConfigKeyEnum.taobaoShareQrcodeText.getKey()), goods, taoBaoLink.getTaoToken()));
                  data.put("clickUrl",
                        ShareControllerV2.getERCodeContentNew(
                              configService.getValue(ConfigKeyEnum.taobaoShareQrcodeText.getKey(),acceptData.getSystem()), goods,
                              taoBaoLink.getTaoToken()));
               data.put("token", TaoBaoUtil.filterTaoToken(taoBaoLink.getTaoToken()));
               String inviteCode  = userInfoExtraService.getInviteCodeByUid(uid);
               String inviteCode = userInfoExtraService.getInviteCodeByUid(uid);
               // 测试
               List<String> commentTexts = new ArrayList<>();
               String commentTextStr = configService.get(ConfigKeyEnum.shareSingleGoodsCommentText.getKey());
               String commentTextStr = configService.getValue(ConfigKeyEnum.shareSingleGoodsCommentText.getKey(),acceptData.getSystem());
               if (!StringUtil.isNullOrEmpty(commentTextStr)) {
                  JSONArray arr = JSONArray.fromObject(commentTextStr);
                  for (int i = 0; i < arr.size(); i++) {
@@ -1119,7 +1128,10 @@
                  }
               }
               data.put("commentTexts", commentTexts);
               data.put("wxErCode", ShareControllerV2.getERCodeContent(configService.get(ConfigKeyEnum.taobaoShareQrcodeText.getKey()), goods, taoBaoLink.getTaoToken()));
               data.put("wxErCode",
                     ShareControllerV2.getERCodeContentNew(
                           configService.getValue(ConfigKeyEnum.taobaoShareQrcodeText.getKey(),acceptData.getSystem()), goods,
                           taoBaoLink.getTaoToken()));
            }
         } else if (cid == 4) { // 邀请分享
@@ -1191,12 +1203,9 @@
               String valueBr = valueN.replace("\n", "<br><br>");
               data.put("inviteRules", valueBr);
               // 邀请链接
               String shortLink = HttpUtil.getShortLink("http://" + Constant.wxGZConfig.getLoginHost() + "/"
                     + Constant.systemCommonConfig.getProjectName() + "/client/threeShareNew?uid=" + uid);
               data.put("inviteLink", shortLink);
               data.put("inviteLink", Constant.YINGYONGBAO_LINK);
               data.put("inviteCode", inviteCode);
               data.put("helpLink", configService.get(ConfigKeyEnum.inviteHelpLink.getKey()));
               data.put("helpLink", configService.getValue(ConfigKeyEnum.inviteHelpLink.getKey(),acceptData.getSystem()));
            }
         }
         out.print(JsonUtil.loadTrueResult(data));