yujian
2020-05-09 7e7db2fa55a9a3af46d4fd8ede0dee147f101d64
fanli/src/main/java/com/yeshi/fanli/service/impl/taobao/TLJBuyGoodsServiceImpl.java
@@ -3,6 +3,7 @@
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
@@ -23,11 +24,11 @@
import com.yeshi.fanli.entity.taobao.dataoke.DaTaoKeDetailV2;
import com.yeshi.fanli.exception.taobao.TaoKeApiException;
import com.yeshi.fanli.exception.tlj.TaoLiJinCreateException;
import com.yeshi.fanli.log.LogHelper;
import com.yeshi.fanli.service.inter.goods.TaoBaoGoodsBriefService;
import com.yeshi.fanli.service.inter.taobao.TLJBuyGoodsService;
import com.yeshi.fanli.service.inter.taobao.TaoBaoGoodsUpdateService;
import com.yeshi.fanli.service.inter.taobao.TaoBaoUnionConfigService;
import com.yeshi.fanli.service.inter.taobao.dataoke.DaTaoKeGoodsDetailService;
import com.yeshi.fanli.service.inter.taobao.dataoke.DaTaoKeGoodsDetailV2Service;
import com.yeshi.fanli.util.StringUtil;
import com.yeshi.fanli.util.TaoBaoConstant;
@@ -47,9 +48,6 @@
   private TaoBaoGoodsBriefService taoBaoGoodsBriefService;
   @Resource
   private DaTaoKeGoodsDetailService daTaoKeGoodsDetailService;
   @Resource
   private EhCacheCacheManager ehCacheCacheManager;
   @Resource
@@ -67,6 +65,8 @@
         goods.setUpdateTime(new Date());
      if (taoKeAppInfo != null)
         goods.setAppKey(taoKeAppInfo.getAppKey());
      if (goods.getWeight() == null)
         goods.setWeight(1);
      tljBuyGoodsDao.save(goods);
   }
@@ -106,6 +106,14 @@
            goodsList.addAll(list);
      }
      Collections.shuffle(goodsList);
      Comparator<TLJBuyGoods> cm = new Comparator<TLJBuyGoods>() {
         @Override
         public int compare(TLJBuyGoods o1, TLJBuyGoods o2) {
            return o1.getWeight() != null && o2.getWeight() != null ? o2.getWeight() - o1.getWeight() : 0;
         }
      };
      Collections.sort(goodsList, cm);
      return goodsList;
   }
@@ -122,7 +130,7 @@
      // 过滤下线商品
      goodsList = taoBaoGoodsBriefService.filterOffLineGoods(goodsList);
      // 添加大淘客信息
      goodsList = daTaoKeGoodsDetailService.filterTaoBaoGoods(goodsList);
      goodsList = daTaoKeGoodsDetailV2Service.filterTaoBaoGoods(goodsList);
      Map<Long, TaoBaoGoodsBrief> goodsMap = new HashMap<>();
      if (goodsList != null)
         for (TaoBaoGoodsBrief g : goodsList)
@@ -175,6 +183,9 @@
               new Date(System.currentTimeMillis() + 1000 * 60 * 60 * 6), new Date(),
               new Date(System.currentTimeMillis() + 1000 * 60 * 60 * 6), app);
      } catch (TaoLiJinCreateException e1) {
         LogHelper.test("商品ID:"+auctionId);
         LogHelper.test("淘礼金验证出错:"+e1.getMsg());
         if (e1.getCode() == TaoLiJinCreateException.CODE_TLJ_FORBIDDEN) {
            // 该商品不支持创建淘礼金红包
            deleteByGoodsId(auctionId);
@@ -259,6 +270,9 @@
   @Override
   public void removeGoods(Long auctionId) {
      tljBuyGoodsDao.deleteByAuctionId(auctionId);
      // 清除列表缓存
      ehCacheCacheManager.getCache("commonContentCache")
            .evict("tljBuy-listByDay" + TimeUtil.getGernalTime(System.currentTimeMillis(), "yyyy-MM-dd"));
   }
}