admin
2019-09-20 db88b87df461820152d68d3d55a28f30c2da83e6
fanli/src/main/java/com/yeshi/fanli/service/impl/taobao/TaoBaoShopServiceImpl.java
@@ -19,13 +19,15 @@
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.order.config.HongBaoManageService;
import com.yeshi.fanli.service.inter.taobao.TaoBaoShopService;
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 {
@@ -35,7 +37,7 @@
   @Resource
   private TaoBaoShopMapper taoBaoShopMapper;
   @Resource
   private HongBaoManageService hongBaoManageService;
@@ -81,7 +83,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;
@@ -113,6 +115,7 @@
      updateShop.setId(id);
      updateShop.setShopNameCustom(shopName);
      updateShop.setKey(key);
      taoBaoShopMapper.updateByPrimaryKeySelective(updateShop);
   }
@@ -153,12 +156,14 @@
      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) {
@@ -194,4 +199,50 @@
      }
      return list;
   }
   @Override
   @Cacheable(value = "brandCache", key = "'getShopByKeyV2-'+#key")
   public List<TaoBaoShopVO> getShopByKeyV2(String key) {
      List<TaoBaoShopVO> list = taoBaoShopMapper.getShopByKey(key);
      if (list == null || list.size() == 0) {
         return null;
      }
      BigDecimal fanLiRate = hongBaoManageService.getFanLiRate();
      BigDecimal shareRate = hongBaoManageService.getShareRate();
      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, null, fanLiRate, shareRate);
            listGoods.add(goodsDetailVO);
         }
         taoBaoShopVO.setListGoodsVO(listGoods);
      }
      return list;
   }
}