yujian
2019-05-14 8cb7ec4a35a38ae91d0eed17cde711e81d2b2bbf
fanli/src/main/java/com/yeshi/fanli/service/impl/goods/GoodsSubClassServiceImpl.java
@@ -18,10 +18,13 @@
import com.yeshi.fanli.entity.accept.AcceptData;
import com.yeshi.fanli.entity.bus.clazz.GoodsClass;
import com.yeshi.fanli.entity.bus.clazz.GoodsSubClass;
import com.yeshi.fanli.entity.bus.clazz.GoodsSubClassLabelMap;
import com.yeshi.fanli.exception.GoodsSubClassException;
import com.yeshi.fanli.service.inter.clazz.GoodsSubClassLabelService;
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.Constant;
import com.yeshi.fanli.util.StringUtil;
@Service
@@ -36,6 +39,9 @@
   @Resource
   private TaoBaoClassService taoBaoClassService;
   @Resource
   private GoodsSubClassLabelService goodsSubClassLabelService;
   @Override
   public int deleteByPrimaryKey(Long id) {
@@ -122,8 +128,8 @@
   }
   @Override
   public void saveObject(MultipartFile file, MultipartFile file2, GoodsSubClass record, Integer type, Long pid)
         throws GoodsSubClassException, Exception {
   public void saveObject(MultipartFile file, MultipartFile file2, GoodsSubClass record, Integer type, Long pid,
         GoodsSubClassLabelMap labelMap) throws GoodsSubClassException, Exception {
      String name = record.getName();
      if (name == null || name.trim().length() == 0) {
@@ -195,6 +201,11 @@
         }
         goodsSubClassMapper.insert(record);
         if (labelMap != null) {
            labelMap.setCreateTime(new Date());
            labelMap.setGoodsSubClass(record);
            goodsSubClassLabelService.addSubClassLabelMap(labelMap);
         }
      } else {
         // 修改
@@ -205,7 +216,8 @@
         if (picture != null && picture.trim().length() > 0) {
            // 删除老图
            removePicture(resultObj.getPicture());
            if (!Constant.IS_TEST)
               removePicture(resultObj.getPicture());
            // 存储新图
            record.setPicture(picture);
         } else {
@@ -214,7 +226,8 @@
         if (pictureSecond != null && pictureSecond.trim().length() > 0) {
            // 删除老图
            removePicture(resultObj.getPictureSecond());
            if (!Constant.IS_TEST)
               removePicture(resultObj.getPictureSecond());
            // 存储新图
            record.setPictureSecond(pictureSecond);
         } else {
@@ -229,19 +242,26 @@
         record.setCreatetime(resultObj.getCreatetime());
         record.setUpdatetime(new Date());
         goodsSubClassMapper.updateByPrimaryKey(record);
         if (labelMap != null) {
            labelMap.setCreateTime(new Date());
            labelMap.setGoodsSubClass(record);
            goodsSubClassLabelService.addSubClassLabelMap(labelMap);
         }
      }
      // 保存淘宝商品分类id
      String taobaoCids = record.getTaobaoCids();
      List<Long> tbCidList = new ArrayList<>();
      if (!StringUtil.isNullOrEmpty(taobaoCids) && !"null".equalsIgnoreCase(taobaoCids)) {
         List<Long> tbCidList = new ArrayList<>();
         String[] sts = taobaoCids.split(",");
         for (String st : sts) {
            String cid = st.split("-")[st.split("-").length - 1];
            tbCidList.add(Long.parseLong(cid));
         }
         taoBaoClassService.saveSub(record.getId(), tbCidList);
      }
      taoBaoClassService.saveSub(record.getId(), tbCidList);
   }
   /**