yujian
2020-01-18 f4a0f2acc63d7785eab108419a4e16f5f688cb95
fanli/src/main/java/com/yeshi/fanli/service/impl/brand/BrandClassShopGoodsServiceImpl.java
@@ -8,6 +8,7 @@
import com.yeshi.fanli.entity.brand.BrandClassShop;
import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
import com.yeshi.fanli.log.LogHelper;
import com.yeshi.fanli.service.inter.brand.BrandClassShopGoodsService;
import com.yeshi.fanli.service.inter.brand.BrandClassShopService;
import com.yeshi.fanli.service.inter.goods.TaoBaoGoodsBriefService;
@@ -38,19 +39,24 @@
   @Override
   public void startUpdateGoods() {
      long count = brandClassShopService.countQuery(null, null, BrandClassShop.STATE_VALID);
      int page = (int) (count % 100 == 0 ? count / 100 : count / 100 + 1);
      int goodsCount = 0;
      try {
         long count = brandClassShopService.countQuery(null, null, BrandClassShop.STATE_VALID);
         int page = (int) (count % 100 == 0 ? count / 100 : count / 100 + 1);
      for (int i = 0; i < page; i++) {
         List<BrandClassShop> shopList = brandClassShopService.listQuery(i * 100, 100, null, null,
               BrandClassShop.STATE_VALID);
         // 每个品牌最多更新100个商品
         if (shopList != null)
            for (BrandClassShop shop : shopList) {
               Long sellerId = shop.getShop().getId();
               List<TaoBaoGoodsBrief> goodsList = listBrandShopGoods(sellerId, 1, 100);
               taoBaoGoodsUpdateService.addUpdateQueueAsync(goodsList);
            }
         for (int i = 0; i < page; i++) {
            List<BrandClassShop> shopList = brandClassShopService.listQuery(i * 100, 100, null, null,
                  BrandClassShop.STATE_VALID);
            // 每个品牌最多更新100个商品
            if (shopList != null)
               for (BrandClassShop shop : shopList) {
                  Long sellerId = shop.getShop().getId();
                  List<TaoBaoGoodsBrief> goodsList = listBrandShopGoods(sellerId, 1, 100);
                  taoBaoGoodsUpdateService.addUpdateQueueAsync(goodsList);
               }
         }
      } finally {
         LogHelper.test("品牌商品更新数量:" + goodsCount);
      }
   }