From 65460a2dc7c69d8c0e031ec4c89e25d47e5173f2 Mon Sep 17 00:00:00 2001 From: yujian <yujian@123.com> Date: 星期二, 10 九月 2019 16:54:11 +0800 Subject: [PATCH] Merge branch 'div' of ssh://193.112.35.168:29418/fanli-server into div --- fanli/src/main/java/com/yeshi/fanli/service/impl/taobao/TLJBuyGoodsServiceImpl.java | 20 ++++++++++++++++++++ 1 files changed, 20 insertions(+), 0 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/taobao/TLJBuyGoodsServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/taobao/TLJBuyGoodsServiceImpl.java index c8e8305..6ba6bee 100644 --- a/fanli/src/main/java/com/yeshi/fanli/service/impl/taobao/TLJBuyGoodsServiceImpl.java +++ b/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; } @@ -256,4 +268,12 @@ return tljBuyGoodsDao.selectByAuctionIdAndDay(auctionId, day); } + @Override + public void removeGoods(Long auctionId) { + tljBuyGoodsDao.deleteByAuctionId(auctionId); + // 娓呴櫎鍒楄〃缂撳瓨 + ehCacheCacheManager.getCache("commonContentCache") + .evict("tljBuy-listByDay" + TimeUtil.getGernalTime(System.currentTimeMillis(), "yyyy-MM-dd")); + } + } \ No newline at end of file -- Gitblit v1.8.0