yujian
2019-11-25 aa552facf6d833acab0d3e3e29bda2a0fb826ffe
fanli/src/main/java/com/yeshi/fanli/service/impl/brand/BrandInfoServiceImpl.java
@@ -21,6 +21,7 @@
import com.yeshi.fanli.dto.pdd.PDDGoodsDetail;
import com.yeshi.fanli.entity.brand.BrandGoodsCahe;
import com.yeshi.fanli.entity.brand.BrandInfo;
import com.yeshi.fanli.entity.brand.BrandShopCahe;
import com.yeshi.fanli.entity.jd.JDGoods;
import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
import com.yeshi.fanli.entity.taobao.TaoBaoShop;
@@ -80,6 +81,10 @@
      if (StringUtil.isNullOrEmpty(name))
         throw new BrandInfoException(1, "名称不能为空");
      String shopKey = record.getShopKey();
      if (StringUtil.isNullOrEmpty(shopKey))
         record.setShopKey(name);
      String searchKey = record.getSearchKey();
      if (StringUtil.isNullOrEmpty(searchKey))
         record.setSearchKey(name);
@@ -110,16 +115,19 @@
         if (picture != null && picture.trim().length() > 0) {
            // 删除老图
            if (picture != null && picture.trim().length() > 0 && !Constant.IS_TEST) {
               COSManager.getInstance().deleteFile(picture);
            if (resultObj.getIcon() != null && resultObj.getIcon().trim().length() > 0 && !Constant.IS_TEST) {
               COSManager.getInstance().deleteFile(resultObj.getIcon());
            };
            // 存储新图
            record.setIcon(picture);
         } else {
            record.setIcon(resultObj.getIcon());
         }
         record.setGoodsTotal(resultObj.getGoodsTotal());
         if (state == 0){
            record.setGoodsTotal(0);
         } else {
            record.setGoodsTotal(resultObj.getGoodsTotal());
         }
         record.setCreateTime(resultObj.getCreateTime());
         record.setUpdateTime(new Date());
         brandInfoMapper.updateByPrimaryKey(record);
@@ -142,6 +150,13 @@
            public void run() {
               int goodsTotal = brandGoodsCaheService.addBrandGoods(record);
               record.setGoodsTotal(goodsTotal);
               List<BrandShopCahe> listshop = brandShopCaheService.getByBrandId(record.getId());
               if (listshop == null) {
                  record.setShopTotal(0);
               } else {
                  record.setShopTotal(listshop.size());
               }
               brandInfoMapper.updateByPrimaryKeySelective(record);
            }
         });
@@ -260,8 +275,8 @@
      if (count == 0)
         return;
      for (int page = 1; page < (count / 100) + 1; page++) {
         updateTotalGoods((page - 1) * 100, 100);
      for (int page = 0; page < (count / 100) + 1; page++) {
         updateTotalGoods(page * 100, 100);
      }
   }
@@ -281,6 +296,13 @@
         BrandInfo updateInfo = new BrandInfo();
         updateInfo.setId(brandInfo.getId());
         updateInfo.setGoodsTotal((int)goodsTotal);
         List<BrandShopCahe> listshop = brandShopCaheService.getByBrandId(brandInfo.getId());
         if (listshop == null) {
            updateInfo.setShopTotal(0);
         } else {
            updateInfo.setShopTotal(listshop.size());
         }
         brandInfoMapper.updateByPrimaryKeySelective(updateInfo);
      }
   }
@@ -303,6 +325,13 @@
         brandInfo.setGoodsTotal(goodsTotal);
         brandInfo.setUpdateTime(new Date());
         List<BrandShopCahe> listshop = brandShopCaheService.getByBrandId(brandInfo.getId());
         if (listshop == null) {
            brandInfo.setShopTotal(0);
         } else {
            brandInfo.setShopTotal(listshop.size());
         }
         brandInfoMapper.updateByPrimaryKeySelective(brandInfo);
      }
   }
@@ -325,7 +354,7 @@
      return brandInfoMapper.listValidByCidToApp(cid);
   }
   @Cacheable(value = "brandCache", key = "'listValidToApp-'+#start+'-'+#start +'-'+#cid")
   @Cacheable(value = "brandCache", key = "'listValidToApp-'+#start+'-'+#cid")
   @Override
   public List<BrandInfoVO> listValidToApp(long start, int count, Long cid) {
      List<BrandInfoVO> list = brandInfoMapper.listBrandInfoVO(start, count, cid);