| | |
| | | import com.yeshi.fanli.service.inter.taobao.TaoBaoUnionConfigService;
|
| | | import com.yeshi.fanli.service.inter.taobao.dataoke.DaTaoKeGoodsDetailV2Service;
|
| | | import com.yeshi.fanli.service.inter.user.UserInfoService;
|
| | | import com.yeshi.fanli.service.manger.goods.tb.TaoBaoTokenAuctionIdMapManager;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.Utils;
|
| | | import com.yeshi.fanli.util.taobao.TaoBaoUtil;
|
| | |
| | |
|
| | | @Resource
|
| | | private DaTaoKeGoodsDetailV2Service daTaoKeGoodsDetailV2Service;
|
| | |
|
| | | @Resource
|
| | | private TaoBaoTokenAuctionIdMapManager taoBaoTokenAuctionIdMapManager;
|
| | |
|
| | | /**
|
| | | * 获取商品信息
|
| | |
| | | List<String> tokenList = TaoBaoUtil.getTokenListFromText(text);
|
| | | if (tokenList != null && tokenList.size() > 0) {
|
| | | String token = tokenList.get(0);
|
| | | Long auctionId = null;
|
| | | try {
|
| | | auctionId = TaoKeApiUtil.tokenConvertAuctionId(token);
|
| | | } catch (TaoBaoTokenParseException e1) {
|
| | | e1.printStackTrace();
|
| | | }
|
| | | Long auctionId = taoBaoTokenAuctionIdMapManager.getAuctionIdByToken(token);
|
| | | if (auctionId != null) {
|
| | | TaoBaoGoodsBrief tb = null;
|
| | | try {
|
| | |
| | | import com.yeshi.fanli.exception.user.TokenRecordException;
|
| | | import com.yeshi.fanli.service.inter.user.TokenRecordService;
|
| | | import com.yeshi.fanli.service.manger.goods.jd.JDGoodsLinkParseManager;
|
| | | import com.yeshi.fanli.service.manger.goods.tb.TaoBaoTokenAuctionIdMapManager;
|
| | | import com.yeshi.fanli.util.DouYinUtil;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.TokenUtil;
|
| | |
| | |
|
| | | @Resource
|
| | | private TokenRecordService tokenRecordService;
|
| | |
|
| | | @Resource
|
| | | private TaoBaoTokenAuctionIdMapManager taoBaoTokenAuctionIdMapManager;
|
| | |
|
| | | /**
|
| | | * @Title: parseContentType @Description: 解析文本的类型 @param text @return Set
|
| | |
| | | }
|
| | |
|
| | | private CommonGoods parseTaoBaoToken(String token) throws TaoBaoTokenParseException {
|
| | |
|
| | | Long auctionId = TaoKeApiUtil.tokenConvertAuctionId(token);
|
| | | Long auctionId = taoBaoTokenAuctionIdMapManager.getAuctionIdByToken(token);
|
| | | if (auctionId != null) {//
|
| | | TaoBaoGoodsBrief goods = TaoBaoUtil.isAlimama(auctionId + "");
|
| | | if (goods == null) {
|
| | |
| | | import com.yeshi.fanli.entity.taobao.TaoKeAppInfo;
|
| | | import com.yeshi.fanli.service.inter.taobao.TaoBaoBuyRelationMapService;
|
| | | import com.yeshi.fanli.service.inter.user.tb.UserExtraTaoBaoInfoService;
|
| | | import com.yeshi.fanli.service.manger.goods.tb.TaoBaoTokenAuctionIdMapManager;
|
| | | import com.yeshi.fanli.util.RedisKeyEnum;
|
| | | import com.yeshi.fanli.util.RedisManager;
|
| | | import com.yeshi.fanli.util.TaoBaoConstant;
|
| | |
| | |
|
| | | @Resource
|
| | | private RedisManager redisManager;
|
| | |
|
| | | @Resource
|
| | | private TaoBaoTokenAuctionIdMapManager taoBaoTokenAuctionIdMapManager;
|
| | |
|
| | | /**
|
| | | *
|
| | |
| | | tokenSet.addAll(tokenList);
|
| | | Map<String, String> tokenMap = new HashMap<>();
|
| | | for (String token : tokenSet) {
|
| | | Long auctionId = TaoKeApiUtil.tokenConvertAuctionId(token);
|
| | | Long auctionId = taoBaoTokenAuctionIdMapManager.getAuctionIdByToken(token);
|
| | | if (auctionId == null)
|
| | | throw new Exception("从淘口令获取商品失败");
|
| | | TaoBaoGoodsBrief simpleGoods = TaoKeApiUtil.getSimpleGoodsInfo(auctionId);
|
New file |
| | |
| | | package com.yeshi.fanli.service.manger.goods.tb;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import org.springframework.stereotype.Component;
|
| | |
|
| | | import com.yeshi.fanli.exception.taobao.TaoBaoTokenParseException;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.cache.TaoBaoGoodsCacheUtil;
|
| | | import com.yeshi.fanli.util.taobao.TaoKeApiUtil;
|
| | |
|
| | | @Component
|
| | | public class TaoBaoTokenAuctionIdMapManager {
|
| | |
|
| | | @Resource
|
| | | private TaoBaoGoodsCacheUtil taoBaoGoodsCacheUtil;
|
| | |
|
| | | public Long getAuctionIdByToken(String token) {
|
| | | if (StringUtil.isNullOrEmpty(token))
|
| | | return null;
|
| | | Long auctionId = taoBaoGoodsCacheUtil.getGoodsIdByToken(token);
|
| | | if (auctionId != null)
|
| | | return auctionId;
|
| | | try {
|
| | | auctionId = TaoKeApiUtil.tokenConvertAuctionId(token);
|
| | | } catch (TaoBaoTokenParseException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | if (auctionId != null) {
|
| | | taoBaoGoodsCacheUtil.saveTokenGoodsIdMap(token, auctionId);
|
| | | }
|
| | | return auctionId;
|
| | | }
|
| | |
|
| | | }
|
| | |
| | | taobaoUpdate("tb-u-", "淘宝商品更新"),
|
| | | taobaoQueue("tb-u-q-", "淘宝商品队列"),
|
| | | taobaoCode("taobao-code-", "淘宝code"),
|
| | | taobaoTokenGoodsMap("tb-t-g_m-","淘宝口令对应商品的映射关系保存"),
|
| | | JDGoods("JD-goods-", "京东商品"),
|
| | | JDShortUrl("jd-link-to-goods-", "京东短链"),
|
| | | jingDongGoods("jingdong-goods-", "京东商品"),
|
| | |
| | | // TODO 凌晨删除缓存记录
|
| | | }
|
| | |
|
| | | /**
|
| | | * 保存口令对应的商品ID
|
| | | * |
| | | * @param token
|
| | | * @param auctionId
|
| | | */
|
| | | public void saveTokenGoodsIdMap(String token, Long auctionId) {
|
| | | String key = RedisKeyEnum.getRedisKey(RedisKeyEnum.taobaoTokenGoodsMap, StringUtil.Md5(token));
|
| | | redisManager.cacheCommonString(key, "1", 60 * 30);// 有效期30分钟
|
| | | }
|
| | |
|
| | | /**
|
| | | * 通过口令获取商品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);
|
| | | }
|
| | |
|
| | | }
|