yujian
2019-04-29 9a24f2802a3d6fe3e82c05e52f2880d65ad04dcf
fanli/src/main/java/com/yeshi/fanli/service/impl/goods/GoodsClassServiceImpl.java
@@ -9,10 +9,10 @@
import java.util.UUID;
import javax.annotation.Resource;
import javax.transaction.Transactional;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
import org.yeshi.utils.tencentcloud.COSManager;
@@ -21,9 +21,11 @@
import com.yeshi.fanli.dao.mybatis.GoodsClassMapper;
import com.yeshi.fanli.entity.bus.clazz.GoodsClass;
import com.yeshi.fanli.entity.bus.clazz.GoodsSubClass;
import com.yeshi.fanli.entity.bus.clazz.TaoBaoClass;
import com.yeshi.fanli.exception.GoodsClassException;
import com.yeshi.fanli.service.inter.goods.GoodsClassService;
import com.yeshi.fanli.service.inter.goods.GoodsSubClassService;
import com.yeshi.fanli.service.inter.goods.TaoBaoClassService;
import com.yeshi.fanli.service.inter.lable.LabelClassService;
import com.yeshi.fanli.util.StringUtil;
@@ -39,6 +41,9 @@
   @Resource
   private LabelClassService labelClassService;
   
   @Resource
   private TaoBaoClassService taoBaoClassService;
   public GoodsClass getGoodsClass(long id) {
      return goodsClassMapper.selectByPrimaryKey(id);
@@ -112,6 +117,23 @@
         // 标签
         int countlabel = labelClassService.getCountQueryByClassId(gclass.getId());
         gclass.setCountlabel(countlabel);
         List<TaoBaoClass> listTB = taoBaoClassService.listBySystemCid(0, Integer.MAX_VALUE, gclass.getId());
         if (listTB == null || listTB.size() == 0) {
            gclass.setTaobaoCids("");
         } else {
            String taobaoCids = "";
            for (TaoBaoClass taoBaoClass: listTB) {
               taobaoCids = taobaoCids + taoBaoClass.getCategoryName() + "-" + taoBaoClass.getCategoryId() + ",";
            }
            if (!StringUtil.isNullOrEmpty(taobaoCids)){
               taobaoCids = taobaoCids.substring(0, taobaoCids.length()-1);
            }
            gclass.setTaobaoCids(taobaoCids);
         }
      }
      return list;
   }
@@ -122,6 +144,7 @@
   
   @Override
   @Transactional
   public void saveObject(MultipartFile file, GoodsClass record) throws GoodsClassException, Exception{
      
      String name = record.getName();
@@ -141,6 +164,7 @@
      } else if (!StringUtil.isJson(params)) {
         throw new GoodsClassException(1, "筛选条件非JSON格式");
      }
      
      
      Long id = record.getId();
@@ -189,6 +213,12 @@
         record.setCreatetime(resultObj.getCreatetime());
         goodsClassMapper.updateByPrimaryKey(record);
      }
      // 保存淘宝商品分类id
      String taobaoCids = record.getTaobaoCids();
      if (!StringUtil.isNullOrEmpty(taobaoCids) && !"null".equalsIgnoreCase(taobaoCids)) {
         taoBaoClassService.save(record.getId(), taobaoCids);
      }
   }