admin
2019-07-30 573c491b4a1ba60e12a5678a01c1546c0077c1ee
fanli/src/main/java/com/yeshi/fanli/service/impl/taobao/TaoBaoShopServiceImpl.java
@@ -1,20 +1,25 @@
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 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.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.hongbao.HongBaoManageService;
import com.yeshi.fanli.service.inter.taobao.TaoBaoShopService;
import com.yeshi.fanli.util.StringUtil;
import com.yeshi.fanli.util.db.MongoDBManager;
@@ -30,6 +35,9 @@
   @Resource
   private TaoBaoShopMapper taoBaoShopMapper;
   @Resource
   private HongBaoManageService hongBaoManageService;
   @Override
   public TaoBaoShopInfo getTaoBaoShopInfo(TaoBaoGoodsBrief goodsInfo) {
@@ -73,7 +81,7 @@
   }
   @Override
   public void changeInfo(MultipartFile file, Long id, String shopName) {
   public void changeInfo(MultipartFile file, Long id, String shopName, String key) {
      TaoBaoShop taoBaoShop = taoBaoShopMapper.selectByPrimaryKey(id);
      if (taoBaoShop == null) {
         return;
@@ -105,6 +113,7 @@
      updateShop.setId(id);
      updateShop.setShopNameCustom(shopName);
      updateShop.setKey(key);
      taoBaoShopMapper.updateByPrimaryKeySelective(updateShop);
   }
@@ -145,9 +154,47 @@
      if (shop != null)
         return shop;
      shop = TaoBaoUtil.getTaoBaoShopDetailByAuctionId(auctionId);
      if (shop != null)
         taoBaoShopMapper.insert(shop);
      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) {
      List<TaoBaoShopVO> list = taoBaoShopMapper.getShopByKey(key);
      if (list == null || list.size() == 0) {
         return null;
      }
      BigDecimal proportion = hongBaoManageService.getFanLiRate();
      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;
   }
}