yujian
2019-09-10 65460a2dc7c69d8c0e031ec4c89e25d47e5173f2
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;
@@ -10,6 +11,7 @@
import javax.annotation.Resource;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.cache.ehcache.EhCacheCacheManager;
import org.springframework.stereotype.Service;
@@ -67,6 +69,8 @@
         goods.setUpdateTime(new Date());
      if (taoKeAppInfo != null)
         goods.setAppKey(taoKeAppInfo.getAppKey());
      if (goods.getWeight() == null)
         goods.setWeight(1);
      tljBuyGoodsDao.save(goods);
   }
@@ -106,6 +110,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;
   }
@@ -259,6 +271,9 @@
   @Override
   public void removeGoods(Long auctionId) {
      tljBuyGoodsDao.deleteByAuctionId(auctionId);
      // 清除列表缓存
      ehCacheCacheManager.getCache("commonContentCache")
            .evict("tljBuy-listByDay" + TimeUtil.getGernalTime(System.currentTimeMillis(), "yyyy-MM-dd"));
   }
}