admin
2019-06-05 07c13064382007999e87abe81efe76c98a47dce8
fanli/src/main/java/com/yeshi/fanli/service/impl/brand/BrandClassShopServiceImpl.java
@@ -17,8 +17,10 @@
import com.yeshi.fanli.entity.brand.BrandClass;
import com.yeshi.fanli.entity.brand.BrandClassShop;
import com.yeshi.fanli.entity.goods.CommonGoods;
import com.yeshi.fanli.entity.taobao.SearchFilter;
import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBriefExtra;
import com.yeshi.fanli.entity.taobao.TaoBaoSearchResult;
import com.yeshi.fanli.entity.taobao.TaoBaoShop;
import com.yeshi.fanli.exception.brand.BrandClassShopException;
import com.yeshi.fanli.service.inter.brand.BrandClassShopService;
@@ -31,6 +33,7 @@
import com.yeshi.fanli.util.Constant;
import com.yeshi.fanli.util.StringUtil;
import com.yeshi.fanli.util.taobao.TaoBaoUtil;
import com.yeshi.fanli.util.taobao.TaoKeApiUtil;
import com.yeshi.fanli.vo.brand.TaoBaoShopVO;
import net.sf.json.JSONObject;
@@ -59,13 +62,10 @@
   @Resource
   private TaoBaoGoodsBriefService taoBaoGoodsBriefService;
   
   @Override
   public List<BrandClassShop> getExistByShopIds(List<Long> list){
      return brandClassShopMapper.getExistByShopIds(list);
   }
   
   @Override
   @Transactional
@@ -124,10 +124,10 @@
      return shopIds;
   }
   
   @Override
   @Transactional
   public void changeShopInfo(MultipartFile file, Long id, Long cid, String shopName, Integer state, Integer top) throws BrandClassShopException{
   public void changeShopInfo(MultipartFile file, Long id, Long cid, String shopName, Integer state, Integer top)
         throws BrandClassShopException {
      
      if (id == null) {
         throw new BrandClassShopException(1, "数据为空:请选择店铺");
@@ -157,7 +157,6 @@
      updateshop.setBrandClass(new BrandClass(cid));
      brandClassShopMapper.updateByPrimaryKeySelective(updateshop);
   }
   @Override
   public List<BrandClassShop> listQuery(long start, int count, String key, Long cid, Integer state) {
@@ -191,12 +190,10 @@
      return listQuery;
   }
   @Override
   public long countQuery(String key, Long cid, Integer state) {
      return brandClassShopMapper.countQuery(key, cid, state);
   }
   @Override
   @Transactional
@@ -216,7 +213,6 @@
      }
      brandClassShopMapper.deleteBatchByClassId(list);
   }
   
   @Override
   public void updateOrder(Long id, Integer moveType) throws BrandClassShopException, Exception{
@@ -300,7 +296,8 @@
      data.put("listShop", JsonUtil.getApiCommonGson().toJson(listShop));
      
      long count = 0;
      List<TaoBaoShopVO> listInfo = taoBaoShopService.listBrandShopinfo((page-1)*Constant.PAGE_SIZE, Constant.PAGE_SIZE, cid);
      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) {
@@ -325,7 +322,6 @@
            taoBaoShopVO.setShopIcon(shopIconCustom);
         }
         
         List<TaoBaoGoodsBriefExtra> listGoods = new ArrayList<TaoBaoGoodsBriefExtra>();
         List<TaoBaoGoodsBrief> listGoodsBrief = taoBaoShopVO.getListGoodsBrief();
         for (TaoBaoGoodsBrief taoBaoGoodsBrief : listGoodsBrief) {
@@ -338,8 +334,6 @@
      
      return data;
   }
   
   @Override
   public void addClick(Long shopId) {
@@ -357,5 +351,34 @@
      }
   }
   
   @Override
   public void updateShopGoods() {
      // 查询店铺
      List<BrandClassShop> shopList = listQuery(0, 1000, "", null, BrandClassShop.STATE_VALID);
      if (shopList != null)
         for (BrandClassShop shop : shopList) {
            SearchFilter sf = new SearchFilter();
            sf.setKey(shop.getShop().getShopName().replace("官方旗舰店", "").replace("旗舰店", ""));
            sf.setPage(1);
            sf.setPageSize(100);
            TaoBaoSearchResult result = TaoKeApiUtil.searchWuLiao(sf);
            List<TaoBaoGoodsBrief> goodsList = new ArrayList<>();
            if (result != null && result.getTaoBaoGoodsBriefs() != null)
               for (TaoBaoGoodsBrief goods : result.getTaoBaoGoodsBriefs()) {
                  if (goods.getSellerId().longValue() == shop.getShop().getId()) {
                     if (taoBaoGoodsBriefService.queryByAuctionId(goods.getAuctionId()).size() == 0) {
                        goods.setCreatetime(new Date());
                        goods.setState(0);
                        goods.setUpdatetime(new Date());
                        goodsList.add(goods);
                     }
                  }
               }
            if (goodsList.size() > 0)
               taoBaoGoodsBriefService.insertBatch(goodsList);
         }
   }
   
}