admin
2020-06-16 5f13dcc8eaac7cd26c0ec41bd1b3efbb70a08180
fanli/src/main/java/com/yeshi/fanli/service/impl/dynamic/GoodsEvaluateServiceImpl.java
@@ -33,6 +33,7 @@
import com.yeshi.fanli.dto.pdd.PDDGoodsDetail;
import com.yeshi.fanli.dto.suning.SuningGoodsInfo;
import com.yeshi.fanli.dto.vip.goods.VIPGoodsInfo;
import com.yeshi.fanli.entity.bus.activity.ActivityRuleUser;
import com.yeshi.fanli.entity.bus.activity.ActivityUser;
import com.yeshi.fanli.entity.bus.clazz.GoodsClass;
import com.yeshi.fanli.entity.dynamic.CommentInfo;
@@ -66,7 +67,6 @@
import com.yeshi.fanli.util.MoneyBigDecimalUtil;
import com.yeshi.fanli.util.RedisManager;
import com.yeshi.fanli.util.StringUtil;
import com.yeshi.fanli.util.TimeUtil;
import com.yeshi.fanli.util.cache.JDGoodsCacheUtil;
import com.yeshi.fanli.util.cache.PinDuoDuoCacheUtil;
import com.yeshi.fanli.util.factory.goods.GoodsDetailVOFactory;
@@ -1419,7 +1419,19 @@
   public GoodsEvaluate getById(String id) {
      return goodsEvaluateDao.getById(id);
   }
   @Override
   public List<GoodsEvaluate> listByStartTime(Date date) {
      return goodsEvaluateDao.listByStartTime(date);
   }
   @Override
   public List<GoodsEvaluate> queryValidSortASC(int start, int count, EvaluateEnum tyepEnum, boolean sortDesc) {
      return goodsEvaluateDao.queryValidSortASC(start, count, tyepEnum, sortDesc);
   }
   @Override
   public void saveComment(String pid, CommentInfo commentInfo) throws GoodsEvaluateException {
      GoodsEvaluate goodsEvaluate = goodsEvaluateDao.getById(pid);
@@ -1921,9 +1933,11 @@
         throw new GoodsEvaluateException(1, "相关参数不能为空");
      }
      List<GoodsEvaluate> evaluateList = goodsEvaluateDao.queryExist(Constant.SOURCE_TYPE_TAOBAO, Long.parseLong(goodsId));
      Date limitDate = DateUtil.reduceDay(new Date(), 7);
      List<GoodsEvaluate> evaluateList = goodsEvaluateDao.queryExistLimitTime(Constant.SOURCE_TYPE_TAOBAO, goodsId, limitDate);
      if (evaluateList != null && evaluateList.size() > 0)
         return;
         throw new GoodsEvaluateException(1, "该商品已存在");
      TaoBaoGoodsBrief goodsBrief = null;
      try {
@@ -1943,9 +1957,6 @@
      // 白底图
      List<String> imgs = new ArrayList<>();
      if (!StringUtil.isNullOrEmpty(goodsBrief.getPictUrlWhite())) {
         imgs.add(goodsBrief.getPictUrlWhite());
      }
      imgs.addAll(goodsBrief.getImgList());
      // 商品VO
@@ -1955,7 +1966,10 @@
      // 商品图片信息
      int i = 0;
      if (imgList == null || imgList.size() == 0)
      if (imgList == null)
         imgList = new ArrayList<ImgInfo>();
      if (imgList.size() == 0)
         for (String img : imgs) {
            ImgInfo imgInfo = new ImgInfo();
            imgInfo.setH(1);
@@ -2072,15 +2086,24 @@
      }
      for (int i = 0; i < list.size(); i++) {
         boolean cerateGoods = cerateGoods(list.get(i));
         boolean cerateGoods = addByDaTaoKeGoods(list.get(i));
         if (cerateGoods) {
            break;
         }
      }
   }
   private boolean cerateGoods(DaTaoKeDetailV2 daTaoKe) {
   @Override
   public boolean addByDaTaoKeGoods(DaTaoKeDetailV2 daTaoKe) {
      try {
         Date limitDate = DateUtil.reduceDay(new Date(), 7);
         List<GoodsEvaluate> evaluateList = goodsEvaluateDao.queryExistLimitTime(Constant.SOURCE_TYPE_TAOBAO,
               daTaoKe.getGoodsId()+"", limitDate);
         if (evaluateList != null && evaluateList.size() > 0)
            return false;
         TaoBaoGoodsBrief goodsBrief = redisManager.getTaoBaoGoodsBrief(daTaoKe.getGoodsId());
         if (goodsBrief == null) {
            return false;
@@ -2094,8 +2117,15 @@
         ConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate("android", "55");
         paramsDTO.setBaseFanliRate(hongBaoManageService.getBaseFanliRate());
         GoodsDetailVO goodsVO = GoodsDetailVOFactory.convertTaoBao(goodsBrief, paramsDTO);
         // 发布用户
         ActivityUser user = activityUserService.getRandomByDaTaoKeCid(daTaoKe.getCid());
         ActivityUser user = null;
         if(daTaoKe.getCid() != null) {
            user = activityUserService.getRandomByDaTaoKeCid(daTaoKe.getCid());
         } else {
            List<ActivityRuleUser> ruleList = activityUserService.listByRuleCode(ActivityRuleUser.RULE_HAOHUO, 1, 20);
            user = ruleList.get((int) (ruleList.size() * Math.random())).getActivityUser();
         }
         String desc = daTaoKe.getDesc().replace(",", ",");
         String[] split = desc.split(",");
@@ -2137,7 +2167,6 @@
         goodsEvaluate.setState(1);
         goodsEvaluate.setDynamicType(1);
         goodsEvaluate.setType(EvaluateEnum.single);
         goodsEvaluate.setShareNum((int) (Math.random() * 5000) + 1000);
         goodsEvaluate.setShareNumReal(0);
         goodsEvaluate.setWeight(0.0);
@@ -2150,9 +2179,6 @@
         List<String> goodsimgs = goodsBrief.getImgList();
         List<String> imgs = new ArrayList<>();
         if (!StringUtil.isNullOrEmpty(goodsBrief.getPictUrlWhite())) {
            imgs.add(goodsBrief.getPictUrlWhite());
         }
         imgs.addAll(goodsimgs);
         int i = 0;
@@ -2311,7 +2337,7 @@
            return;
         }
         List<GoodsEvaluate> queryExist = goodsEvaluateDao.queryExist(Constant.SOURCE_TYPE_TAOBAO,
               goods.getAuctionId());
               goods.getAuctionId()+"");
         if (queryExist == null || queryExist.size() == 0) {
            return;
         }
@@ -2331,7 +2357,7 @@
      if (jdGoods == null) {
         return;
      }
      List<GoodsEvaluate> queryExist = goodsEvaluateDao.queryExist(Constant.SOURCE_TYPE_JD, jdGoods.getSkuId());
      List<GoodsEvaluate> queryExist = goodsEvaluateDao.queryExist(Constant.SOURCE_TYPE_JD, jdGoods.getSkuId()+"");
      if (queryExist == null || queryExist.size() == 0) {
         return;
      }
@@ -2348,7 +2374,7 @@
      if (pddGoods == null) {
         return;
      }
      List<GoodsEvaluate> queryExist = goodsEvaluateDao.queryExist(Constant.SOURCE_TYPE_PDD, pddGoods.getGoodsId());
      List<GoodsEvaluate> queryExist = goodsEvaluateDao.queryExist(Constant.SOURCE_TYPE_PDD, pddGoods.getGoodsId()+"");
      if (queryExist == null || queryExist.size() == 0) {
         return;
      }
@@ -2365,7 +2391,7 @@
         return;
      }
      List<GoodsEvaluate> queryExist = goodsEvaluateDao.queryExist(Constant.SOURCE_TYPE_VIP,
            Long.parseLong(goods.getGoodsId()));
            goods.getGoodsId());
      if (queryExist == null || queryExist.size() == 0) {
         return;
      }
@@ -2382,7 +2408,7 @@
         return;
      }
      List<GoodsEvaluate> queryExist = goodsEvaluateDao.queryExist(Constant.SOURCE_TYPE_SUNING,
            Long.parseLong(goods.getCommodityInfo().getCommodityCode()));
            goods.getCommodityInfo().getCommodityCode());
      if (queryExist == null || queryExist.size() == 0) {
         return;
      }
@@ -2442,7 +2468,7 @@
         if (goodsId == null) {
            return;
         }
         List<GoodsEvaluate> list = goodsEvaluateDao.queryExist(Constant.SOURCE_TYPE_TAOBAO,Long.parseLong(goodsId));
         List<GoodsEvaluate> list = goodsEvaluateDao.queryExist(Constant.SOURCE_TYPE_TAOBAO,goodsId);
         if (list == null || list.size() == 0) {
            return;
         }
@@ -2536,4 +2562,14 @@
      }
   }
   @Override
   public GoodsEvaluate queryExistSingle(String goodsId, int goodsType) {
      List<GoodsEvaluate> list = goodsEvaluateDao.queryExistSingle(goodsType, goodsId);
      if (list != null && list.size() > 0)
         return list.get(0);
      return null;
   }
}