From 30d8e227e8d823b6c38c3b9c90ac2df03b63befe Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期二, 25 二月 2025 16:41:22 +0800
Subject: [PATCH] 淘宝转链接口更新

---
 fanli/src/main/java/com/yeshi/fanli/util/cache/TaoBaoGoodsCacheUtil.java |  365 ++++++++++++++++++++++++++++-----------------------
 1 files changed, 199 insertions(+), 166 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/util/cache/TaoBaoGoodsCacheUtil.java b/fanli/src/main/java/com/yeshi/fanli/util/cache/TaoBaoGoodsCacheUtil.java
index 9e8d91a..89fbd96 100644
--- a/fanli/src/main/java/com/yeshi/fanli/util/cache/TaoBaoGoodsCacheUtil.java
+++ b/fanli/src/main/java/com/yeshi/fanli/util/cache/TaoBaoGoodsCacheUtil.java
@@ -1,166 +1,199 @@
-package com.yeshi.fanli.util.cache;
-
-import java.util.Calendar;
-
-import javax.annotation.Resource;
-
-import org.springframework.stereotype.Component;
-
-import com.google.gson.Gson;
-import com.yeshi.goods.facade.entity.taobao.TaoBaoGoodsBrief;
-import com.yeshi.fanli.util.RedisKeyEnum;
-import com.yeshi.fanli.util.RedisManager;
-import com.yeshi.fanli.util.StringUtil;
-import org.yeshi.utils.TimeUtil;
-
-@Component
-public class TaoBaoGoodsCacheUtil {
-	@Resource
-	private RedisManager redisManager;
-
-	/**
-	 * 淇濆瓨甯歌鐨勬窐瀹濆晢鍝佽鎯咃紙鎼滅储锛岃鎯咃級
-	 * 
-	 * @param goods
-	 */
-	public void saveCommonTaoBaoGoodsInfo(TaoBaoGoodsBrief goods) {
-		if (goods == null || goods.getAuctionId() == null)
-			return;
-		String key = RedisKeyEnum.getRedisKey(RedisKeyEnum.taobaoGoodsCommon, goods.getAuctionId() + "");
-		// 淇濆瓨20鍒嗛挓
-		redisManager.cacheCommonString(key, new Gson().toJson(goods), 60 * 20);
-	}
-
-	/**
-	 * 鑾峰彇缂撳瓨
-	 * 
-	 * @param auctionId
-	 * @return
-	 */
-	public TaoBaoGoodsBrief getCommonTaoBaoGoodsInfo(long auctionId) {
-		String key = RedisKeyEnum.getRedisKey(RedisKeyEnum.taobaoGoodsCommon, auctionId + "");
-		String value = redisManager.getCommonString(key);
-		if (!StringUtil.isNullOrEmpty(value)) {
-			return new Gson().fromJson(value, TaoBaoGoodsBrief.class);
-		} else
-			return null;
-	}
-
-	/**
-	 * 鏄惁鍙互娣诲姞鍒版洿鏂伴槦鍒椾腑
-	 * 
-	 * @param auctionId
-	 * @return
-	 */
-	public boolean canAddToUpdateQueue(Long auctionId) {
-		String key = RedisKeyEnum.getRedisKey(RedisKeyEnum.taobaoQueue, auctionId + "");
-		String value = redisManager.getCommonString(key);
-		if (StringUtil.isNullOrEmpty(value))
-			return true;
-		else
-			return false;
-	}
-
-	/**
-	 * 澧炲姞娣诲姞鍒伴槦鍒椾腑鐨勮褰�
-	 * 
-	 * @param auctionId
-	 */
-	public void addAddToQueueHistory(Long auctionId) {
-		String key = RedisKeyEnum.getRedisKey(RedisKeyEnum.taobaoQueue, auctionId + "");
-		redisManager.cacheCommonString(key, "1", 60 * 60 * 2);// 鏈夋晥鏈�2涓皬鏃�
-	}
-
-	/**
-	 * 鏌ヨ鍟嗗搧鏄惁闇�瑕佹洿鏂�
-	 * 
-	 * @param actionId
-	 * @return
-	 */
-	public boolean needUpdate(Long actionId) {
-		String key = RedisKeyEnum.getRedisKey(RedisKeyEnum.taobaoUpdate, actionId + "");
-		String value = redisManager.getCommonString(key);
-		if (StringUtil.isNullOrEmpty(value))
-			return true;
-		else
-			return false;
-	}
-
-	/**
-	 * 娣诲姞鏇存柊璁板綍鏁版嵁
-	 * 
-	 * @param actionId
-	 * @return
-	 */
-	public void addUpdateHistory(Long actionId) {
-		String key = RedisKeyEnum.getRedisKey(RedisKeyEnum.taobaoUpdate, actionId + "");
-		redisManager.cacheCommonString(key, "1", 60 * 60 * 1);// 鏈夋晥鏈�1涓皬鏃�
-	}
-
-	/**
-	 * 鍒犻櫎鏇存柊璁板綍
-	 */
-	public void removeUpdateHistory() {
-		// TODO 鍑屾櫒鍒犻櫎缂撳瓨璁板綍
-	}
-
-	/**
-	 * 淇濆瓨鍙d护瀵瑰簲鐨勫晢鍝両D
-	 * 
-	 * @param token
-	 * @param auctionId
-	 */
-	public void saveTokenGoodsIdMap(String token, Long auctionId) {
-		String key = RedisKeyEnum.getRedisKey(RedisKeyEnum.taobaoTokenGoodsMap, StringUtil.Md5(token));
-		redisManager.cacheCommonString(key, auctionId + "", 60 * 30);// 鏈夋晥鏈�30鍒嗛挓
-	}
-
-	/**
-	 * 閫氳繃鍙d护鑾峰彇鍟嗗搧ID
-	 * 
-	 * @param token
-	 * @return
-	 */
-	public Long getGoodsIdByToken(String token) {
-		String key = RedisKeyEnum.getRedisKey(RedisKeyEnum.taobaoTokenGoodsMap, StringUtil.Md5(token));
-		String goodsId = redisManager.getCommonString(key);
-		if (StringUtil.isNullOrEmpty(goodsId))
-			return null;
-		return Long.parseLong(goodsId);
-	}
-
-	/**
-	 * 缂撳瓨杞摼缁撴灉
-	 * @Title: cacheBaseConvertLink
-	 * @Description: 
-	 * @param auctionId
-	 * @param pid
-	 * @param link 
-	 * void 杩斿洖绫诲瀷
-	 * @throws
-	 */
-	public void cacheBaseConvertLink(Long auctionId, String pid, String link) {
-		String key = RedisKeyEnum.getRedisKey(RedisKeyEnum.taobaoBaseLink, StringUtil.Md5(auctionId + "#" + pid));
-		//
-		Calendar calendar = Calendar.getInstance();
-		long now = calendar.getTimeInMillis();
-		calendar.add(Calendar.HOUR, 1);
-
-		Long time = TimeUtil.convertToTimeTemp(TimeUtil.getGernalTime(calendar.getTimeInMillis(), "yyyy-MM-dd HH"),
-				"yyyy-MM-dd HH");
-
-		int second = (int) ((time - now) / 1000);
-		if (second <= 0)
-			second = 1;
-
-		redisManager.cacheCommonString(key, link, second);// 鏈夋晥鏈�30鍒嗛挓
-	}
-
-	public String getBaseConvertLink(Long auctionId, String pid) {
-		String key = RedisKeyEnum.getRedisKey(RedisKeyEnum.taobaoBaseLink, StringUtil.Md5(auctionId + "#" + pid));
-		String url = redisManager.getCommonString(key);
-
-		return StringUtil.isNullOrEmpty(url) ? null : url;
-	}
-
-}
+package com.yeshi.fanli.util.cache;
+
+import java.util.Calendar;
+
+import javax.annotation.Resource;
+
+import com.yeshi.fanli.entity.taobao.SearchFilter;
+import com.yeshi.fanli.entity.taobao.TaoBaoSearchResult;
+import org.springframework.stereotype.Component;
+
+import com.google.gson.Gson;
+import com.yeshi.goods.facade.entity.taobao.TaoBaoGoodsBrief;
+import com.yeshi.fanli.util.RedisKeyEnum;
+import com.yeshi.fanli.util.RedisManager;
+import com.yeshi.fanli.util.StringUtil;
+import org.yeshi.utils.TimeUtil;
+
+@Component
+public class TaoBaoGoodsCacheUtil {
+    @Resource
+    private RedisManager redisManager;
+
+    /**
+     * 淇濆瓨甯歌鐨勬窐瀹濆晢鍝佽鎯咃紙鎼滅储锛岃鎯咃級
+     *
+     * @param goods
+     */
+    public void saveCommonTaoBaoGoodsInfo(TaoBaoGoodsBrief goods) {
+        if (goods == null || goods.getAuctionId() == null)
+            return;
+        String key = RedisKeyEnum.getRedisKey(RedisKeyEnum.taobaoGoodsCommon, goods.getAuctionId() + "");
+        // 淇濆瓨20鍒嗛挓
+        redisManager.cacheCommonString(key, new Gson().toJson(goods), 60 * 20);
+    }
+
+    /**
+     * 鑾峰彇缂撳瓨
+     *
+     * @param auctionId
+     * @return
+     */
+    public TaoBaoGoodsBrief getCommonTaoBaoGoodsInfo(String auctionId) {
+        String key = RedisKeyEnum.getRedisKey(RedisKeyEnum.taobaoGoodsCommon, auctionId + "");
+        String value = redisManager.getCommonString(key);
+        if (!StringUtil.isNullOrEmpty(value)) {
+            return new Gson().fromJson(value, TaoBaoGoodsBrief.class);
+        } else
+            return null;
+    }
+
+    /**
+     * 鏄惁鍙互娣诲姞鍒版洿鏂伴槦鍒椾腑
+     *
+     * @param auctionId
+     * @return
+     */
+    public boolean canAddToUpdateQueue(String auctionId) {
+        String key = RedisKeyEnum.getRedisKey(RedisKeyEnum.taobaoQueue, auctionId + "");
+        String value = redisManager.getCommonString(key);
+        if (StringUtil.isNullOrEmpty(value))
+            return true;
+        else
+            return false;
+    }
+
+    /**
+     * 澧炲姞娣诲姞鍒伴槦鍒椾腑鐨勮褰�
+     *
+     * @param auctionId
+     */
+    public void addAddToQueueHistory(String auctionId) {
+        String key = RedisKeyEnum.getRedisKey(RedisKeyEnum.taobaoQueue, auctionId + "");
+        redisManager.cacheCommonString(key, "1", 60 * 60 * 2);// 鏈夋晥鏈�2涓皬鏃�
+    }
+
+    /**
+     * 鏌ヨ鍟嗗搧鏄惁闇�瑕佹洿鏂�
+     *
+     * @param actionId
+     * @return
+     */
+    public boolean needUpdate(String actionId) {
+        String key = RedisKeyEnum.getRedisKey(RedisKeyEnum.taobaoUpdate, actionId + "");
+        String value = redisManager.getCommonString(key);
+        if (StringUtil.isNullOrEmpty(value))
+            return true;
+        else
+            return false;
+    }
+
+    /**
+     * 娣诲姞鏇存柊璁板綍鏁版嵁
+     *
+     * @param actionId
+     * @return
+     */
+    public void addUpdateHistory(String actionId) {
+        String key = RedisKeyEnum.getRedisKey(RedisKeyEnum.taobaoUpdate, actionId + "");
+        redisManager.cacheCommonString(key, "1", 60 * 60 * 1);// 鏈夋晥鏈�1涓皬鏃�
+    }
+
+    /**
+     * 鍒犻櫎鏇存柊璁板綍
+     */
+    public void removeUpdateHistory() {
+        // TODO 鍑屾櫒鍒犻櫎缂撳瓨璁板綍
+    }
+
+    /**
+     * 淇濆瓨鍙d护瀵瑰簲鐨勫晢鍝両D
+     *
+     * @param token
+     * @param auctionId
+     */
+    public void saveTokenGoodsIdMap(String token, String auctionId) {
+        String key = RedisKeyEnum.getRedisKey(RedisKeyEnum.taobaoTokenGoodsMap, StringUtil.Md5(token));
+        redisManager.cacheCommonString(key, auctionId + "", 60 * 30);// 鏈夋晥鏈�30鍒嗛挓
+    }
+
+    /**
+     * 閫氳繃鍙d护鑾峰彇鍟嗗搧ID
+     *
+     * @param token
+     * @return
+     */
+    public String getGoodsIdByToken(String token) {
+        String key = RedisKeyEnum.getRedisKey(RedisKeyEnum.taobaoTokenGoodsMap, StringUtil.Md5(token));
+        String goodsId = redisManager.getCommonString(key);
+        if (StringUtil.isNullOrEmpty(goodsId))
+            return null;
+        return goodsId;
+    }
+
+    /**
+     * 缂撳瓨杞摼缁撴灉
+     *
+     * @param auctionId
+     * @param pid
+     * @param link      void 杩斿洖绫诲瀷
+     * @throws
+     * @Title: cacheBaseConvertLink
+     * @Description:
+     */
+    public void cacheBaseConvertLink(String auctionId, String pid, String link) {
+        String key = RedisKeyEnum.getRedisKey(RedisKeyEnum.taobaoBaseLink, StringUtil.Md5(auctionId + "#" + pid));
+        //
+        Calendar calendar = Calendar.getInstance();
+        long now = calendar.getTimeInMillis();
+        calendar.add(Calendar.HOUR, 1);
+
+        Long time = TimeUtil.convertToTimeTemp(TimeUtil.getGernalTime(calendar.getTimeInMillis(), "yyyy-MM-dd HH"),
+                "yyyy-MM-dd HH");
+
+        int second = (int) ((time - now) / 1000);
+        if (second <= 0)
+            second = 1;
+
+        redisManager.cacheCommonString(key, link, second);// 鏈夋晥鏈�30鍒嗛挓
+    }
+
+    public String getBaseConvertLink(String auctionId, String pid) {
+        String key = RedisKeyEnum.getRedisKey(RedisKeyEnum.taobaoBaseLink, StringUtil.Md5(auctionId + "#" + pid));
+        String url = redisManager.getCommonString(key);
+
+        return StringUtil.isNullOrEmpty(url) ? null : url;
+    }
+
+
+    /**
+     * 淇濆瓨鎼滅储鎺ュ彛
+     *
+     * @param sf
+     * @param result
+     */
+    public void saveSearchResult(SearchFilter sf, TaoBaoSearchResult result) {
+        if (result == null||result.getTaoBaoGoodsBriefs()==null)
+            return;
+        String key = RedisKeyEnum.taobaoSearchResult.getKey() + StringUtil.Md5(new Gson().toJson(sf));
+        //缂撳瓨20鍒嗛挓
+        redisManager.cacheCommonString(key, new Gson().toJson(result), 60 * 20);
+    }
+
+    /**
+     * 鑾峰彇鎼滅储缁撴灉
+     *
+     * @param sf
+     * @return
+     */
+    public TaoBaoSearchResult getSearchResult(SearchFilter sf) {
+        String key = RedisKeyEnum.taobaoSearchResult.getKey() + StringUtil.Md5(new Gson().toJson(sf));
+        String result = redisManager.getCommonString(key);
+
+        if (StringUtil.isNullOrEmpty(result))
+            return null;
+        else
+            return new Gson().fromJson(result, TaoBaoSearchResult.class);
+    }
+
+}

--
Gitblit v1.8.0