yujian
2019-07-19 8222e8b237c5dfb0affcdc03335bfadc06403bf8
fanli/src/main/java/com/yeshi/fanli/service/impl/brand/BrandClassShopServiceImpl.java
@@ -32,9 +32,11 @@
import com.yeshi.fanli.service.inter.taobao.TaoBaoShopService;
import com.yeshi.fanli.util.Constant;
import com.yeshi.fanli.util.StringUtil;
import com.yeshi.fanli.util.factory.goods.GoodsDetailVOFactory;
import com.yeshi.fanli.util.taobao.TaoBaoUtil;
import com.yeshi.fanli.util.taobao.TaoKeApiUtil;
import com.yeshi.fanli.vo.brand.TaoBaoShopVO;
import com.yeshi.fanli.vo.goods.GoodsDetailVO;
import net.sf.json.JSONObject;
@@ -54,7 +56,7 @@
   private TaoBaoShopHistoryService taoBaoShopHistoryService;
   @Resource
   private HongBaoManageService manageService;
   private HongBaoManageService hongBaoManageService;
   @Resource
   private QualityGoodsService qualityGoodsService;
@@ -82,7 +84,7 @@
      BrandClass brandClass = new BrandClass(cid);
      for (Long shopId : list) {
         List<CommonGoods> listGoods = commonGoodsService.listBySellerId(shopId);
         List<CommonGoods> listGoods = commonGoodsService.listBySellerId(shopId, Constant.SOURCE_TYPE_TAOBAO);
         TaoBaoShop taoBaoShop = null;
         for (CommonGoods commonGoods : listGoods) {
@@ -168,7 +170,7 @@
      for (BrandClassShop brandClassShop : listQuery) {
         TaoBaoShop shop = brandClassShop.getShop();
         if (shop != null) {
            long couponNum = commonGoodsService.countBySellerIdAndHasCoupon(shop.getId());
            long couponNum = commonGoodsService.countBySellerIdAndHasCoupon(shop.getId(), Constant.SOURCE_TYPE_TAOBAO);
            brandClassShop.setCouponNum(couponNum);
            String shopLink = shop.getShopLink();
@@ -304,7 +306,7 @@
         count = taoBaoShopService.countBrandShopinfo(cid);
      }
      BigDecimal proportion = manageService.getFanLiRate();
      BigDecimal proportion = hongBaoManageService.getFanLiRate();
      for (TaoBaoShopVO taoBaoShopVO : listInfo) {
         String shopLink = taoBaoShopVO.getShopLink();
@@ -335,6 +337,113 @@
      return data;
   }
   @Override
   @Cacheable(value = "brandCache", key = "'listEffectiveCacheV2-'+#page+'-'+#cid")
   public JSONObject listEffectiveCacheV2(int page, Long cid) {
      long countShop = 0;
      if (cid != null && cid <= 0) {
         cid = null;
      }
      List<TaoBaoShop> listShop = new ArrayList<TaoBaoShop>();
      // 第一页 查询全部分类下店铺
      if (page == 1 && cid != null) {
         List<BrandClassShop> list = brandClassShopMapper.listEffective(cid);
         if (list == null) {
            list = new ArrayList<BrandClassShop>();
         } else if (list.size() > 0) {
            countShop = brandClassShopMapper.countEffective(cid);
         }
         for (BrandClassShop brandClassShop : list) {
            TaoBaoShop shop = brandClassShop.getShop();
            if (shop != null) {
               Integer userType = shop.getUserType();
               if (userType == null || userType == 0) {
                  shop.setUserType(10);
               } else {
                  shop.setUserType(11);
               }
               String shopLink = shop.getShopLink();
               if (StringUtil.isNullOrEmpty(shopLink)) {
                  shop.setShopLink(TaoBaoUtil.getShopLink(shop.getId()));
               }
               String shopNameCustom = shop.getShopNameCustom();
               if (!StringUtil.isNullOrEmpty(shopNameCustom)) {
                  shop.setShopName(shopNameCustom);
               }
               String shopIconCustom = shop.getShopIconCustom();
               if (!StringUtil.isNullOrEmpty(shopIconCustom)) {
                  shop.setShopIcon(shopIconCustom);
               }
               listShop.add(shop);
            }
         }
      }
      JSONObject data = new JSONObject();
      data.put("countShop", countShop);
      data.put("listShop", JsonUtil.getApiCommonGson().toJson(listShop));
      long count = 0;
      List<TaoBaoShopVO> listInfo = taoBaoShopService.listBrandShopinfo((page - 1) * Constant.PAGE_SIZE,
            Constant.PAGE_SIZE, cid);
      if (listInfo == null) {
         listInfo = new ArrayList<TaoBaoShopVO>();
      } else if (listInfo.size() > 0) {
         count = taoBaoShopService.countBrandShopinfo(cid);
      }
      BigDecimal fanLiRate = hongBaoManageService.getFanLiRate();
      BigDecimal shareRate = hongBaoManageService.getShareRate();
      for (TaoBaoShopVO taoBaoShopVO : listInfo) {
         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);
      }
      data.put("count", count);
      data.put("list", JsonUtil.getApiCommonGson().toJson(listInfo));
      return data;
   }
   @Override
   public void addClick(Long shopId) {
      BrandClassShop brandClassShop = brandClassShopMapper.getByShopId(shopId);