admin
2020-07-07 c9cbad5f5d18c6b2ac5a063e41007933d7028329
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/DynamicControllerV2.java
@@ -16,6 +16,10 @@
import javax.annotation.Resource;
import com.yeshi.fanli.entity.SystemEnum;
import com.yeshi.fanli.exception.taobao.TaoBaoConvertLinkException;
import com.yeshi.fanli.service.manger.goods.TaoBaoLinkManager;
import com.yeshi.fanli.util.*;
import org.apache.commons.beanutils.PropertyUtils;
import org.springframework.core.task.TaskExecutor;
import org.springframework.stereotype.Controller;
@@ -71,15 +75,9 @@
import com.yeshi.fanli.service.inter.user.QrCodeService;
import com.yeshi.fanli.service.inter.user.UserInfoExtraService;
import com.yeshi.fanli.service.inter.user.UserInfoService;
import com.yeshi.fanli.service.inter.user.cloud.UserCloudService;
import com.yeshi.fanli.service.inter.user.tb.UserExtraTaoBaoInfoService;
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.ImageUtil;
import com.yeshi.fanli.util.MoneyBigDecimalUtil;
import com.yeshi.fanli.util.StringUtil;
import com.yeshi.fanli.util.TimeUtil;
import com.yeshi.fanli.util.VersionUtil;
import com.yeshi.fanli.util.cache.JDGoodsCacheUtil;
import com.yeshi.fanli.util.jd.JDApiUtil;
import com.yeshi.fanli.util.jd.JDUtil;
@@ -107,10 +105,7 @@
public class DynamicControllerV2 {
   @Resource
   private HongBaoManageService hongBaoManageService;
   @Resource
   private TaoBaoGoodsBriefService taoBaoGoodsBriefService;
   private TaoBaoLinkManager taoBaoLinkManager;
   @Resource
   private JumpDetailV2Service jumpDetailV2Service;
@@ -158,6 +153,9 @@
   @Resource
   private CommonShareInfoService commonShareInfoService;
   @Resource
   private UserCloudService userCloudService;
   @Resource(name = "taskExecutor")
   private TaskExecutor executor;
@@ -224,7 +222,6 @@
    * 查询顶部分类
    * 
    * @param acceptData
    * @param page
    * @param cid
    * @param out
    */
@@ -381,7 +378,7 @@
      }
      List<SpecialVO> list = specialService.listByPlaceKeyHasLabel((page - 1) * Constant.PAGE_SIZE,
            Constant.PAGE_SIZE, listKey, platformCode, Integer.parseInt(acceptData.getVersion()));
            Constant.PAGE_SIZE, listKey, platformCode, Integer.parseInt(acceptData.getVersion()),acceptData.getSystem());
      long time = System.currentTimeMillis();
@@ -415,7 +412,7 @@
      }
      long count = specialService.countByPlaceKeyList(listKey, platformCode,
            Integer.parseInt(acceptData.getVersion()));
            Integer.parseInt(acceptData.getVersion()),acceptData.getSystem());
      GsonBuilder gsonBuilder = new GsonBuilder().excludeFieldsWithoutExposeAnnotation();
      Gson gson = gsonBuilder.create();
@@ -540,13 +537,13 @@
      JSONObject data = new JSONObject();
      if (page == 1 && !search) {
         List<BannerVO> banners = swiperPictureService.getByBannerCardAndVersion("article_banners",
               acceptData.getPlatform(), Integer.parseInt(acceptData.getVersion()));
               acceptData.getPlatform(), Integer.parseInt(acceptData.getVersion()),acceptData.getSystem());
         if (banners == null)
            banners = new ArrayList<>();
         data.put("banners", gson.toJson(banners));
         List<SpecialVO> listSpecial = specialService.listByVersion(0, Integer.MAX_VALUE, "article_specials",
               acceptData.getPlatform(), Integer.parseInt(acceptData.getVersion()));
               acceptData.getPlatform(), Integer.parseInt(acceptData.getVersion()),acceptData.getSystem());
         if (listSpecial == null)
            listSpecial = new ArrayList<>();
@@ -569,8 +566,7 @@
    * 文章搜索
    * 
    * @param acceptData
    * @param page
    * @param key
    * @param id
    * @param out
    */
   @RequestMapping(value = "readArticle", method = RequestMethod.POST)
@@ -600,14 +596,12 @@
    * 文章搜索
    * 
    * @param acceptData
    * @param page
    * @param key
    * @param out
    */
   @RequestMapping(value = "getArticleHot", method = RequestMethod.POST)
   public void getArticleHot(AcceptData acceptData, PrintWriter out) {
      JSONObject data = new JSONObject();
      data.put("words", configService.get(ConfigKeyEnum.articleHotWords.getKey()));
      data.put("words", configService.getValue(ConfigKeyEnum.articleHotWords.getKey(), SystemInfoUtil.getSystem(acceptData)));
      out.print(JsonUtil.loadTrueResult(data));
   }
@@ -621,7 +615,7 @@
    * @param out
    */
   @RequestMapping(value = "getDynamicList", method = RequestMethod.POST)
   public void getDynamicListNew(AcceptData acceptData, Integer page, Long cid, String subId, PrintWriter out) {
   public void getDynamicListNew(AcceptData acceptData, Integer page, Long cid, String subId, Long uid, PrintWriter out) {
      try {
         int type = 1;
         if (cid == TYPE_FAQUAN) {
@@ -632,17 +626,22 @@
         List<GoodsEvaluate> listNew = new ArrayList<GoodsEvaluate>();
         List<GoodsEvaluate> list = goodsEvaluateService.queryMaterialsCache((page - 1) * Constant.PAGE_SIZE,
               Constant.PAGE_SIZE, type);
               Constant.PAGE_SIZE, type,acceptData.getSystem());
         if (!VersionUtil.greaterThan_2_1_1(acceptData.getPlatform(), acceptData.getVersion())) {
            listNew.addAll(list);
         } else if (list.size() > 0) { // 活动图片不允许跳转
            for (GoodsEvaluate goodsEvaluate : list) {
               if (goodsEvaluate.getType() != EvaluateEnum.activity) {
                  listNew.add(goodsEvaluate);
                  continue;
            // 云发单是否开启
            boolean cloudOpen = configService.isRobotCloudOpen(ConfigKeyEnum.robotCloudOpenCircle.getKey(),acceptData.getPlatform(), acceptData.getVersion(),SystemInfoUtil.getSystem(acceptData));
            if (!cloudOpen && uid != null) {
               List<String> testUsers = configService.getTestUsers(SystemInfoUtil.getSystem(acceptData));
               if (testUsers != null && testUsers.contains(uid+"")) {
                  cloudOpen = true;
               }
            }
            for (GoodsEvaluate goodsEvaluate : list) {
               GoodsEvaluate evaluateNew = new GoodsEvaluate();
               try {
                  PropertyUtils.copyProperties(evaluateNew, goodsEvaluate);
@@ -650,6 +649,19 @@
                  e.printStackTrace();
                  continue;
               }
               EvaluateEnum evaluateEnum = evaluateNew.getType();
               // 单品 活动可以一键云发单
               if (evaluateEnum == EvaluateEnum.activity || evaluateEnum == EvaluateEnum.single) {
                  evaluateNew.setCloud(cloudOpen);
               }
               if (evaluateEnum != EvaluateEnum.activity) {
                  listNew.add(evaluateNew);
                  continue;
               }
               // 跳转过渡页
               // String jumpLink =
               // configService.get(ConfigKeyEnum.activityDetailLink.getKey())
@@ -763,7 +775,7 @@
            }
         });
         Gson gson = gsonBuilder.create();
         long count = goodsEvaluateService.countValidMaterials(type);
         long count = goodsEvaluateService.countValidMaterials(type,acceptData.getSystem());
         JSONArray jsonArray = new JSONArray();
@@ -813,8 +825,8 @@
    * @param out
    */
   @RequestMapping(value = "evaluateShare", method = RequestMethod.POST)
   public void evaluateShare(AcceptData acceptData, Long uid, String id, Integer type, Long goodsId, Integer goodsType,
         PrintWriter out) {
   public void evaluateShare(AcceptData acceptData, Long uid, String id, Integer type, String goodsId,
         Integer goodsType, PrintWriter out) {
      try {
         if (uid == null) {
            out.print(JsonUtil.loadFalseResult("用户未登录"));
@@ -826,7 +838,7 @@
            return;
         }
         if (type == 1 && (goodsId == null || goodsType == null)) {
         if (type == 1 && (StringUtil.isNullOrEmpty(goodsId) || goodsType == null)) {
            out.print(JsonUtil.loadFalseResult("商品参数不能为空"));
            return;
         }
@@ -898,7 +910,7 @@
                     continue;
                  }
                  String jumpLink = getJumpLink(goodsVO, user, relationId, inviteCode, imgInfo.getUrl());
                  String jumpLink = getJumpLink(goodsVO, user, relationId, inviteCode, imgInfo.getUrl(),SystemInfoUtil.getSystem(acceptData));
                  if (!StringUtil.isNullOrEmpty(jumpLink)) {
                     list.add(jumpLink);
                  }
@@ -908,10 +920,10 @@
               if (type == 1) {
                  for (ImgInfo imgInfo : imgs) {
                     if (imgInfo.getGoodsVO() != null)
                        if (imgInfo.getGoodsVO().getGoodsId().longValue() == goodsId.longValue()
                        if (imgInfo.getGoodsVO().getGoodsId().equalsIgnoreCase(goodsId)
                              && imgInfo.getGoodsVO().getGoodsType() == goodsType.intValue()) {
                           String jumpLink = getJumpLink(imgInfo.getGoodsVO(), user, relationId, inviteCode,
                                 imgInfo.getUrl());
                                 imgInfo.getUrl(),SystemInfoUtil.getSystem(acceptData));
                           if (!StringUtil.isNullOrEmpty(jumpLink)) {
                              list.add(jumpLink);
                           }
@@ -922,7 +934,7 @@
                  for (ImgInfo imgInfo : imgs) {
                     if (imgInfo.getGoodsVO() != null) {
                        String jumpLink = getJumpLink(imgInfo.getGoodsVO(), user, relationId, inviteCode,
                              imgInfo.getUrl());
                              imgInfo.getUrl(),SystemInfoUtil.getSystem(acceptData));
                        if (!StringUtil.isNullOrEmpty(jumpLink)) {
                           list.add(jumpLink);
                        }
@@ -980,20 +992,21 @@
   }
   private String getJumpLink(GoodsDetailVO goodsVO, UserInfo user, String relationId, String inviteCode,
         String mainPic) {
                               String mainPic, SystemEnum system) {
      String jumpLink = null;
      if (goodsVO.getGoodsType() == Constant.SOURCE_TYPE_TAOBAO) {
         TaoBaoLink taoBaoLink = null;
         try {
            taoBaoLink = shareGoodsService.getTaoBaoLinkForShare(user.getId(), goodsVO.getGoodsId(), relationId);
         } catch (ShareGoodsException e) {
            taoBaoLink = taoBaoLinkManager.getTaoBaoLinkForShare(user.getId(), Long.parseLong(goodsVO.getGoodsId()),
                  relationId,null);
         } catch (TaoBaoConvertLinkException e) {
            e.printStackTrace();
         }
         jumpLink = ShareControllerV2.getERCodeContentNew(
               configService.get(ConfigKeyEnum.taobaoShareQrcodeText.getKey()), taoBaoLink.getGoods(),
               configService.getValue(ConfigKeyEnum.taobaoShareQrcodeText.getKey(),system), taoBaoLink.getGoods(),
               TaoBaoUtil.filterTaoToken(taoBaoLink.getTaoToken()));
      } else if (goodsVO.getGoodsType() == Constant.SOURCE_TYPE_JD) {
         JDGoods jdGoods = jdGoodsCacheUtil.getGoodsInfo(goodsVO.getGoodsId());
         JDGoods jdGoods = jdGoodsCacheUtil.getGoodsInfo(Long.parseLong(goodsVO.getGoodsId()));
         if (jdGoods == null) {
            return null;
         }
@@ -1007,8 +1020,8 @@
         jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, couponUrl, JDApiUtil.POSITION_SHARE + "",
               user.getId() + "");
      } else if (goodsVO.getGoodsType() == Constant.SOURCE_TYPE_PDD) {
         jumpLink = PinDuoDuoApiUtil.getPromotionUrl(goodsVO.getGoodsId(), PinDuoDuoApiUtil.PID_SHARE + "",
               user.getId() + "");
         jumpLink = PinDuoDuoApiUtil.getPromotionUrl(Long.parseLong(goodsVO.getGoodsId()),
               PinDuoDuoApiUtil.PID_SHARE + "", user.getId() + "");
      }
      FileUploadResult uploadResult = qrCodeService.drawDynamicGoodsPoster(jumpLink, user.getPortrait(), inviteCode,
@@ -1102,7 +1115,7 @@
         } else {
            newText = newText.replace("[券后价]", MoneyBigDecimalUtil.getWithNoZera(goods.getCouponPrice()) + "");
         }
         newText.replace("\r\n\r\n", "\r\n").replace("\r\n\r\n", "\r\n").replace("\r\n\r\n", "\r\n");
         newText = newText.replace("\r\n\r\n", "\r\n").replace("\r\n\r\n", "\r\n").replace("\r\n\r\n", "\r\n");
      }
      JSONObject data = new JSONObject();
@@ -1251,7 +1264,9 @@
            if (!StringUtil.isNullOrEmpty(special.getPicture())) {
               imgs.add(special.getPicture());
            }
            title=special.getName();
            title = special.getName();
            desc = special.getRemark();
            startTime = special.getStartTime();
            endTime = special.getEndTime();
@@ -1266,8 +1281,9 @@
            if (!StringUtil.isNullOrEmpty(swiper.getSrc())) {
               imgs.add(swiper.getSrc());
            }
            title=swiper.getTitle();
            desc = swiper.getRemark();
            title = swiper.getTitle();
            desc = swiper.getDesc();
            startTime = swiper.getStartTime();
            endTime = swiper.getEndTime();
         }
@@ -1377,9 +1393,8 @@
    * 活动分享绘图
    * @Title: createActivityShareImg
    * @Description: 
    * @param title
    * @param desc
    * @param imgUrl
    * @param type
    * @param id
    * @param erCodeContent
    * @return 
    * String 返回类型
@@ -1494,7 +1509,7 @@
            if (tokenList != null && tokenList.size() > 0) {
               // 构造分享链接
               erCodeContent = ShareControllerV2.getTaoBaoActiivtyERCodeContentNew(
                     configService.get(ConfigKeyEnum.taobaoShareQrcodeText.getKey()), tokenList.get(0));
                     configService.getValue(ConfigKeyEnum.taobaoShareQrcodeText.getKey(),SystemInfoUtil.getSystem(acceptData)), tokenList.get(0));
            } else {
               // 获取链接
               List<String> urlList = JDUtil.getJDShortLinksFromText(newText);
@@ -1608,4 +1623,5 @@
         }
      });
   }
}