From 51a4ff5d777028d52a19c314a99f796334cb7b51 Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期六, 23 十一月 2019 18:30:01 +0800
Subject: [PATCH] 配置文件修改

---
 fanli/src/main/java/com/yeshi/fanli/service/impl/taobao/TLJBuyGoodsServiceImpl.java |   32 +++++++++++++++++++++++++++++---
 1 files changed, 29 insertions(+), 3 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 6a9dd20..d2be2a5 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;
@@ -22,6 +24,8 @@
 import com.yeshi.fanli.entity.taobao.TaoKeAppInfo;
 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;
@@ -66,6 +70,8 @@
 			goods.setUpdateTime(new Date());
 		if (taoKeAppInfo != null)
 			goods.setAppKey(taoKeAppInfo.getAppKey());
+		if (goods.getWeight() == null)
+			goods.setWeight(1);
 		tljBuyGoodsDao.save(goods);
 	}
 
@@ -105,6 +111,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;
 	}
 
@@ -173,14 +187,18 @@
 			taoLiJinDTO = TaoKeApiUtil.createTaoLiJin(auctionId, "娣樼ぜ閲戦獙璇�", new BigDecimal("1.00"), 1, new Date(),
 					new Date(System.currentTimeMillis() + 1000 * 60 * 60 * 6), new Date(),
 					new Date(System.currentTimeMillis() + 1000 * 60 * 60 * 6), app);
-		} catch (TaoKeApiException e) {
-			if (e.getCode() == TaoKeApiException.CODE_TLJ_FORBIDDEN) {
+		} catch (TaoLiJinCreateException e1) {
+			LogHelper.test("鍟嗗搧ID:"+auctionId);
+			LogHelper.test("娣樼ぜ閲戦獙璇佸嚭閿�:"+e1.getMsg());
+			
+			if (e1.getCode() == TaoLiJinCreateException.CODE_TLJ_FORBIDDEN) {
 				// 璇ュ晢鍝佷笉鏀寔鍒涘缓娣樼ぜ閲戠孩鍖�
 				deleteByGoodsId(auctionId);
 				return false;
-			} else if (e.getCode() == TaoKeApiException.CODE_TLJ_NO_MONEY) {
+			} else if (e1.getCode() == TaoLiJinCreateException.CODE_TLJ_NO_MONEY) {
 				// 瀹樻柟鐜╂硶閽卞寘浣欓涓嶈冻 TODO
 			}
+		} catch (TaoKeApiException e) {
 		}
 		return true;
 	}
@@ -254,4 +272,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