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/service/impl/taobao/TaoBaoShopServiceImpl.java | 510 ++++++++++++++++++++++++++++---------------------------- 1 files changed, 255 insertions(+), 255 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/taobao/TaoBaoShopServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/taobao/TaoBaoShopServiceImpl.java index 63d6c80..68b98bd 100644 --- a/fanli/src/main/java/com/yeshi/fanli/service/impl/taobao/TaoBaoShopServiceImpl.java +++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/taobao/TaoBaoShopServiceImpl.java @@ -1,255 +1,255 @@ -package com.yeshi.fanli.service.impl.taobao; - -import java.io.InputStream; -import java.math.BigDecimal; -import java.util.ArrayList; -import java.util.List; -import java.util.UUID; - -import javax.annotation.Resource; - -import com.yeshi.fanli.entity.SystemEnum; -import org.springframework.cache.annotation.Cacheable; -import org.springframework.stereotype.Service; -import org.springframework.web.multipart.MultipartFile; -import org.yeshi.utils.tencentcloud.COSManager; - -import com.yeshi.fanli.dao.mybatis.taobao.TaoBaoShopMapper; -import com.yeshi.fanli.dto.ConfigParamsDTO; -import com.yeshi.fanli.entity.bus.user.vip.UserLevelEnum; -import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief; -import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBriefExtra; -import com.yeshi.fanli.entity.taobao.TaoBaoShop; -import com.yeshi.fanli.entity.taobao.TaoBaoShopInfo; -import com.yeshi.fanli.log.LogHelper; -import com.yeshi.fanli.service.inter.order.OrderHongBaoMoneyComputeService; -import com.yeshi.fanli.service.inter.order.config.HongBaoManageService; -import com.yeshi.fanli.service.inter.taobao.TaoBaoShopService; -import com.yeshi.fanli.util.FilePathEnum; -import com.yeshi.fanli.util.StringUtil; -import com.yeshi.fanli.util.db.MongoDBManager; -import com.yeshi.fanli.util.factory.goods.GoodsDetailVOFactory; -import com.yeshi.fanli.util.taobao.TaoBaoShopUtil; -import com.yeshi.fanli.util.taobao.TaoBaoUtil; -import com.yeshi.fanli.vo.brand.TaoBaoShopVO; -import com.yeshi.fanli.vo.goods.GoodsDetailVO; - -@Service -public class TaoBaoShopServiceImpl implements TaoBaoShopService { - - @Resource - private MongoDBManager mongoDBManager; - - @Resource - private TaoBaoShopMapper taoBaoShopMapper; - - @Resource - private HongBaoManageService hongBaoManageService; - - @Resource - private OrderHongBaoMoneyComputeService orderHongBaoMoneyComputeService; - - @Override - public TaoBaoShopInfo getTaoBaoShopInfo(TaoBaoGoodsBrief goodsInfo) { - if (goodsInfo == null) - return null; - long startTime = System.currentTimeMillis(); - TaoBaoShopInfo shopInfo = null; - try { - shopInfo = mongoDBManager.getTBShopInfo(goodsInfo.getSellerId()); - } catch (Exception e) { - LogHelper.error(e); - } - - if (shopInfo == null) { - shopInfo = TaoBaoShopUtil.getTaoBaoShopInfo(goodsInfo.getShopTitle(), goodsInfo.getSellerId(), - goodsInfo.getAuctionId()); - if (shopInfo != null) - try { - mongoDBManager.saveTBShopInfo(shopInfo); - } catch (Exception e) { - } - } - - LogHelper.test("鑾峰彇搴楅摵淇℃伅鑰楁椂:" + (System.currentTimeMillis() - startTime)); - return shopInfo; - } - - @Override - public TaoBaoShop selectByPrimaryKey(Long id) { - return taoBaoShopMapper.selectByPrimaryKey(id); - } - - @Override - public int insertSelective(TaoBaoShop record) { - return taoBaoShopMapper.insertSelective(record); - } - - @Override - public int updateByPrimaryKeySelective(TaoBaoShop record) { - return taoBaoShopMapper.updateByPrimaryKeySelective(record); - } - - @Override - public void changeInfo(MultipartFile file, Long id, String shopName, String key) { - TaoBaoShop taoBaoShop = taoBaoShopMapper.selectByPrimaryKey(id); - if (taoBaoShop == null) { - return; - } - - String fileLink = null; - if (file != null) { - try { - fileLink = uploadPicture(file); - } catch (Exception e) { - e.printStackTrace(); - } - } - - TaoBaoShop updateShop = new TaoBaoShop(); - if (!StringUtil.isNullOrEmpty(fileLink)) { - updateShop.setShopIconCustom(fileLink); - - // 鍒犻櫎鍥剧墖 - String shopIconCustom = taoBaoShop.getShopIconCustom(); - if (!StringUtil.isNullOrEmpty(shopIconCustom)) { - COSManager.getInstance().deleteFile(shopIconCustom); - } - } - - if (StringUtil.isNullOrEmpty(shopName) || "null".equalsIgnoreCase(shopName)) { - shopName = null; - } - - updateShop.setId(id); - updateShop.setShopNameCustom(shopName); - updateShop.setKey(key); - taoBaoShopMapper.updateByPrimaryKeySelective(updateShop); - } - - /** - * 涓婁紶鍥剧墖 - * - * @param file - * @return - * @throws Exception - */ - public String uploadPicture(MultipartFile file) throws Exception { - // 鏂囦欢瑙f瀽 - InputStream inputStream = file.getInputStream(); - String contentType = file.getContentType(); - String type = contentType.substring(contentType.indexOf("/") + 1); - - // 鏂囦欢璺緞 - String filePath = FilePathEnum.taoBaoShop.getPath() + UUID.randomUUID().toString().replace("-", "") + "." + type; - // 鎵ц涓婁紶 - String fileLink = COSManager.getInstance().uploadFile(inputStream, filePath).getUrl(); - - return fileLink; - } - - @Override - public List<TaoBaoShopVO> listBrandShopinfo(long start, int count, Long cid) { - return taoBaoShopMapper.listBrandShopinfo(start, count, cid); - } - - @Override - public long countBrandShopinfo(Long cid) { - return taoBaoShopMapper.countBrandShopinfo(cid); - } - - @Override - public TaoBaoShop getTaoBaoShop(Long auctionId, Long sellerId) { - TaoBaoShop shop = taoBaoShopMapper.selectByPrimaryKey(sellerId); - if (shop != null) - return shop; - shop = TaoBaoUtil.getTaoBaoShopDetailByAuctionId(auctionId); - try { - if (shop != null) - taoBaoShopMapper.insert(shop); - } catch (Exception e) { - } - return shop; - } - - @Override - @Cacheable(value = "brandCache", key = "'getShopByKey-'+#key") - public List<TaoBaoShopVO> getShopByKey(String key, SystemEnum system) { - List<TaoBaoShopVO> list = taoBaoShopMapper.getShopByKey(key); - if (list == null || list.size() == 0) { - return null; - } - - BigDecimal proportion = hongBaoManageService.getFanLiRate(UserLevelEnum.daRen,system); - for (TaoBaoShopVO taoBaoShopVO : list) { - - String shopLink = taoBaoShopVO.getShopLink(); - if (StringUtil.isNullOrEmpty(shopLink)) { - taoBaoShopVO.setShopLink(TaoBaoUtil.getShopLink(taoBaoShopVO.getId())); - } - - String shopNameCustom = taoBaoShopVO.getShopNameCustom(); - if (!StringUtil.isNullOrEmpty(shopNameCustom)) { - taoBaoShopVO.setShopName(shopNameCustom); - } - - String shopIconCustom = taoBaoShopVO.getShopIconCustom(); - if (!StringUtil.isNullOrEmpty(shopIconCustom)) { - taoBaoShopVO.setShopIcon(shopIconCustom); - } - - List<TaoBaoGoodsBriefExtra> listGoods = new ArrayList<TaoBaoGoodsBriefExtra>(); - List<TaoBaoGoodsBrief> listGoodsBrief = taoBaoShopVO.getListGoodsBrief(); - for (TaoBaoGoodsBrief taoBaoGoodsBrief : listGoodsBrief) { - listGoods.add(TaoBaoUtil.getTaoBaoGoodsBriefExtra(taoBaoGoodsBrief, proportion.toString(), null)); - } - taoBaoShopVO.setListGoods(listGoods); - } - return list; - } - - @Override - @Cacheable(value = "brandCache", key = "'getShopByKeyV2-'+#key+'-'+#platform+'-'+#version+'-'+#system") - public List<TaoBaoShopVO> getShopByKeyV2(String key, String platform, String version,SystemEnum system) { - List<TaoBaoShopVO> list = taoBaoShopMapper.getShopByKey(key); - if (list == null || list.size() == 0) { - return null; - } - - ConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate(platform, version,UserLevelEnum.daRen,system); - - for (TaoBaoShopVO taoBaoShopVO : list) { - - Integer userType = taoBaoShopVO.getUserType(); - if (userType == null || userType == 0) { - taoBaoShopVO.setUserType(10); - } else { - taoBaoShopVO.setUserType(11); - } - - String shopLink = taoBaoShopVO.getShopLink(); - if (StringUtil.isNullOrEmpty(shopLink)) { - taoBaoShopVO.setShopLink(TaoBaoUtil.getShopLink(taoBaoShopVO.getId())); - } - - String shopNameCustom = taoBaoShopVO.getShopNameCustom(); - if (!StringUtil.isNullOrEmpty(shopNameCustom)) { - taoBaoShopVO.setShopName(shopNameCustom); - } - - String shopIconCustom = taoBaoShopVO.getShopIconCustom(); - if (!StringUtil.isNullOrEmpty(shopIconCustom)) { - taoBaoShopVO.setShopIcon(shopIconCustom); - } - - List<GoodsDetailVO> listGoods = new ArrayList<GoodsDetailVO>(); - List<TaoBaoGoodsBrief> listGoodsBrief = taoBaoShopVO.getListGoodsBrief(); - for (TaoBaoGoodsBrief taoBaoGoodsBrief : listGoodsBrief) { - GoodsDetailVO goodsDetailVO = GoodsDetailVOFactory.convertTaoBao(taoBaoGoodsBrief, paramsDTO); - listGoods.add(goodsDetailVO); - } - taoBaoShopVO.setListGoodsVO(listGoods); - } - return list; - } -} +package com.yeshi.fanli.service.impl.taobao; + +import java.io.InputStream; +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; + +import javax.annotation.Resource; + +import com.yeshi.fanli.entity.SystemEnum; +import org.springframework.cache.annotation.Cacheable; +import org.springframework.stereotype.Service; +import org.springframework.web.multipart.MultipartFile; +import org.yeshi.utils.tencentcloud.COSManager; + +import com.yeshi.fanli.dao.mybatis.taobao.TaoBaoShopMapper; +import com.yeshi.fanli.dto.GoodsMoneyConfigParamsDTO; +import com.yeshi.fanli.entity.bus.user.vip.UserLevelEnum; +import com.yeshi.goods.facade.entity.taobao.TaoBaoGoodsBrief; +import com.yeshi.goods.facade.entity.taobao.TaoBaoGoodsBriefExtra; +import com.yeshi.common.entity.taobao.TaoBaoShop; +import com.yeshi.common.entity.taobao.TaoBaoShopInfo; +import com.yeshi.fanli.log.LogHelper; +import com.yeshi.fanli.service.inter.order.OrderHongBaoMoneyComputeService; +import com.yeshi.fanli.service.inter.order.config.HongBaoManageService; +import com.yeshi.fanli.service.inter.taobao.TaoBaoShopService; +import com.yeshi.fanli.util.FilePathEnum; +import com.yeshi.fanli.util.StringUtil; +import com.yeshi.fanli.util.db.MongoDBManager; +import com.yeshi.fanli.util.factory.goods.GoodsDetailVOFactory; +import com.yeshi.fanli.util.taobao.TaoBaoShopUtil; +import com.yeshi.fanli.util.taobao.TaoBaoUtil; +import com.yeshi.fanli.vo.brand.TaoBaoShopVO; +import com.yeshi.fanli.vo.goods.GoodsDetailVO; + +@Service +public class TaoBaoShopServiceImpl implements TaoBaoShopService { + + @Resource + private MongoDBManager mongoDBManager; + + @Resource + private TaoBaoShopMapper taoBaoShopMapper; + + @Resource + private HongBaoManageService hongBaoManageService; + + @Resource + private OrderHongBaoMoneyComputeService orderHongBaoMoneyComputeService; + + @Override + public TaoBaoShopInfo getTaoBaoShopInfo(TaoBaoGoodsBrief goodsInfo) { + if (goodsInfo == null) + return null; + long startTime = System.currentTimeMillis(); + TaoBaoShopInfo shopInfo = null; + try { + shopInfo = mongoDBManager.getTBShopInfo(goodsInfo.getSellerId()); + } catch (Exception e) { + LogHelper.error(e); + } + + if (shopInfo == null) { + shopInfo = TaoBaoShopUtil.getTaoBaoShopInfo(goodsInfo.getShopTitle(), goodsInfo.getSellerId(), + goodsInfo.getAuctionId()); + if (shopInfo != null) + try { + mongoDBManager.saveTBShopInfo(shopInfo); + } catch (Exception e) { + } + } + + LogHelper.test("鑾峰彇搴楅摵淇℃伅鑰楁椂:" + (System.currentTimeMillis() - startTime)); + return shopInfo; + } + + @Override + public TaoBaoShop selectByPrimaryKey(Long id) { + return taoBaoShopMapper.selectByPrimaryKey(id); + } + + @Override + public int insertSelective(TaoBaoShop record) { + return taoBaoShopMapper.insertSelective(record); + } + + @Override + public int updateByPrimaryKeySelective(TaoBaoShop record) { + return taoBaoShopMapper.updateByPrimaryKeySelective(record); + } + + @Override + public void changeInfo(MultipartFile file, Long id, String shopName, String key) { + TaoBaoShop taoBaoShop = taoBaoShopMapper.selectByPrimaryKey(id); + if (taoBaoShop == null) { + return; + } + + String fileLink = null; + if (file != null) { + try { + fileLink = uploadPicture(file); + } catch (Exception e) { + e.printStackTrace(); + } + } + + TaoBaoShop updateShop = new TaoBaoShop(); + if (!StringUtil.isNullOrEmpty(fileLink)) { + updateShop.setShopIconCustom(fileLink); + + // 鍒犻櫎鍥剧墖 + String shopIconCustom = taoBaoShop.getShopIconCustom(); + if (!StringUtil.isNullOrEmpty(shopIconCustom)) { + COSManager.getInstance().deleteFile(shopIconCustom); + } + } + + if (StringUtil.isNullOrEmpty(shopName) || "null".equalsIgnoreCase(shopName)) { + shopName = null; + } + + updateShop.setId(id); + updateShop.setShopNameCustom(shopName); + updateShop.setKey(key); + taoBaoShopMapper.updateByPrimaryKeySelective(updateShop); + } + + /** + * 涓婁紶鍥剧墖 + * + * @param file + * @return + * @throws Exception + */ + public String uploadPicture(MultipartFile file) throws Exception { + // 鏂囦欢瑙f瀽 + InputStream inputStream = file.getInputStream(); + String contentType = file.getContentType(); + String type = contentType.substring(contentType.indexOf("/") + 1); + + // 鏂囦欢璺緞 + String filePath = FilePathEnum.taoBaoShop.getPath() + UUID.randomUUID().toString().replace("-", "") + "." + type; + // 鎵ц涓婁紶 + String fileLink = COSManager.getInstance().uploadFile(inputStream, filePath).getUrl(); + + return fileLink; + } + + @Override + public List<TaoBaoShopVO> listBrandShopinfo(long start, int count, Long cid) { + return taoBaoShopMapper.listBrandShopinfo(start, count, cid); + } + + @Override + public long countBrandShopinfo(Long cid) { + return taoBaoShopMapper.countBrandShopinfo(cid); + } + + @Override + public TaoBaoShop getTaoBaoShop(String auctionId, Long sellerId) { + TaoBaoShop shop = taoBaoShopMapper.selectByPrimaryKey(sellerId); + if (shop != null) + return shop; + shop = TaoBaoUtil.getTaoBaoShopDetailByAuctionId(auctionId); + try { + if (shop != null) + taoBaoShopMapper.insert(shop); + } catch (Exception e) { + } + return shop; + } + + @Override + @Cacheable(value = "brandCache", key = "'getShopByKey-'+#key") + public List<TaoBaoShopVO> getShopByKey(String key, SystemEnum system) { + List<TaoBaoShopVO> list = taoBaoShopMapper.getShopByKey(key); + if (list == null || list.size() == 0) { + return null; + } + + BigDecimal proportion = hongBaoManageService.getFanLiRate(UserLevelEnum.daRen,system); + for (TaoBaoShopVO taoBaoShopVO : list) { + + String shopLink = taoBaoShopVO.getShopLink(); + if (StringUtil.isNullOrEmpty(shopLink)) { + taoBaoShopVO.setShopLink(TaoBaoUtil.getShopLink(taoBaoShopVO.getId())); + } + + String shopNameCustom = taoBaoShopVO.getShopNameCustom(); + if (!StringUtil.isNullOrEmpty(shopNameCustom)) { + taoBaoShopVO.setShopName(shopNameCustom); + } + + String shopIconCustom = taoBaoShopVO.getShopIconCustom(); + if (!StringUtil.isNullOrEmpty(shopIconCustom)) { + taoBaoShopVO.setShopIcon(shopIconCustom); + } + + List<TaoBaoGoodsBriefExtra> listGoods = new ArrayList<TaoBaoGoodsBriefExtra>(); + List<TaoBaoGoodsBrief> listGoodsBrief = taoBaoShopVO.getListGoodsBrief(); + for (TaoBaoGoodsBrief taoBaoGoodsBrief : listGoodsBrief) { + listGoods.add(TaoBaoUtil.getTaoBaoGoodsBriefExtra(taoBaoGoodsBrief, proportion.toString(), null)); + } + taoBaoShopVO.setListGoods(listGoods); + } + return list; + } + + @Override + @Cacheable(value = "brandCache", key = "'getShopByKeyV2-'+#key+'-'+#platform+'-'+#version+'-'+#system") + public List<TaoBaoShopVO> getShopByKeyV2(String key, String platform, String version,SystemEnum system) { + List<TaoBaoShopVO> list = taoBaoShopMapper.getShopByKey(key); + if (list == null || list.size() == 0) { + return null; + } + + GoodsMoneyConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate(platform, version,UserLevelEnum.daRen,system); + + for (TaoBaoShopVO taoBaoShopVO : list) { + + Integer userType = taoBaoShopVO.getUserType(); + if (userType == null || userType == 0) { + taoBaoShopVO.setUserType(10); + } else { + taoBaoShopVO.setUserType(11); + } + + String shopLink = taoBaoShopVO.getShopLink(); + if (StringUtil.isNullOrEmpty(shopLink)) { + taoBaoShopVO.setShopLink(TaoBaoUtil.getShopLink(taoBaoShopVO.getId())); + } + + String shopNameCustom = taoBaoShopVO.getShopNameCustom(); + if (!StringUtil.isNullOrEmpty(shopNameCustom)) { + taoBaoShopVO.setShopName(shopNameCustom); + } + + String shopIconCustom = taoBaoShopVO.getShopIconCustom(); + if (!StringUtil.isNullOrEmpty(shopIconCustom)) { + taoBaoShopVO.setShopIcon(shopIconCustom); + } + + List<GoodsDetailVO> listGoods = new ArrayList<GoodsDetailVO>(); + List<TaoBaoGoodsBrief> listGoodsBrief = taoBaoShopVO.getListGoodsBrief(); + for (TaoBaoGoodsBrief taoBaoGoodsBrief : listGoodsBrief) { + GoodsDetailVO goodsDetailVO = GoodsDetailVOFactory.convertTaoBao(taoBaoGoodsBrief, paramsDTO); + listGoods.add(goodsDetailVO); + } + taoBaoShopVO.setListGoodsVO(listGoods); + } + return list; + } +} -- Gitblit v1.8.0