yujian
2019-08-27 d8359ddb48dab5cc797a9d552e11fde571f4920c
fanli/src/main/java/com/yeshi/fanli/service/impl/goods/GoodsSubClassServiceImpl.java
@@ -18,7 +18,10 @@
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.GoodsSubClassLabel;
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;
@@ -37,6 +40,9 @@
   @Resource
   private TaoBaoClassService taoBaoClassService;
   @Resource
   private GoodsSubClassLabelService goodsSubClassLabelService;
   @Override
   public int deleteByPrimaryKey(Long id) {
@@ -67,7 +73,7 @@
   @Transactional
   public void deleteByRootId(Long id) throws Exception {
      List<GoodsSubClass> subClassList = goodsSubClassMapper.queryByRootId(id, null);
      List<GoodsSubClass> subClassList = goodsSubClassMapper.queryByRootId(id, null, null);
      if (subClassList != null && subClassList.size() > 0) {
         for (GoodsSubClass goodsSubClass : subClassList) {
            deleteSub(goodsSubClass.getId());
@@ -123,13 +129,16 @@
   }
   @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,
         Long labelId) throws GoodsSubClassException, Exception {
      String name = record.getName();
      if (name == null || name.trim().length() == 0) {
         throw new GoodsSubClassException(1, "分类名称不能为空");
      }
      if (StringUtil.isNullOrEmpty(record.getMonth()))
         record.setMonth(null);
      // 图片上传
      String picture = null;
@@ -189,6 +198,8 @@
         record.setIosClick(0L);
         record.setCreatetime(new Date());
         record.setUpdatetime(new Date());
         if (labelId != null)
            record.setClassLabel(new GoodsSubClassLabel(labelId));
         if (params == null || params.trim().length() == 0 || "null".equalsIgnoreCase(params)) {
            // 搜索条件:有券、在售价20-200、牛皮癣轻微
@@ -196,6 +207,13 @@
         }
         goodsSubClassMapper.insert(record);
         if (labelId != null) {
            GoodsSubClassLabelMap map = new GoodsSubClassLabelMap();
            map.setGoodsSubClass(record);
            map.setLabel(new GoodsSubClassLabel(labelId));
            goodsSubClassLabelService.addSubClassLabelMap(map);
         }
      } else {
         // 修改
@@ -231,6 +249,16 @@
         record.setAndroidClick(resultObj.getAndroidClick());
         record.setCreatetime(resultObj.getCreatetime());
         record.setUpdatetime(new Date());
         if (labelId != null) {
            GoodsSubClassLabelMap map = new GoodsSubClassLabelMap();
            map.setGoodsSubClass(record);
            map.setLabel(new GoodsSubClassLabel(labelId));
            try {
               goodsSubClassLabelService.addSubClassLabelMap(map);
            } catch (Exception e) {
            }
         }
         goodsSubClassMapper.updateByPrimaryKey(record);
      }
@@ -310,7 +338,7 @@
   @Override
   public List<GoodsSubClass> queryByRootId(Long rootId, Integer state) throws Exception {
      return goodsSubClassMapper.queryByRootId(rootId, state);
      return goodsSubClassMapper.queryByRootId(rootId, state, null);
   }
   @Override
@@ -329,14 +357,14 @@
   }
   @Override
   public List<GoodsSubClass> getGoodsSecondClass(Long rootId, Integer state) throws Exception {
      return goodsSubClassMapper.queryByRootId(rootId, state);
   public List<GoodsSubClass> getGoodsSecondClass(Long rootId, Integer state, Integer month) throws Exception {
      return goodsSubClassMapper.queryByRootId(rootId, state, month);
   }
   @Override
   @Cacheable(value = "classCache", key = "'getSubClassCache-'+#rootId +'-'+#state")
   public List<GoodsSubClass> getSubClassCache(Long rootId, Integer state) throws Exception {
      return getGoodsSecondClass(rootId, state);
   public List<GoodsSubClass> getSubClassCache(Long rootId, Integer state, Integer month) throws Exception {
      return getGoodsSecondClass(rootId, state, month);
   }
   @Override