|
|
@ -31,6 +31,7 @@ import com.alibaba.fastjson.JSONObject; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
import com.wh.mapper.restrictedcategory.RestrictedCategoryMapper; |
|
|
|
import com.wh.pojo.product.Product; |
|
|
|
import com.wh.pojo.restrictedcategory.*; |
|
|
|
import com.wh.service.restrictedbrand.RestrictedBrandService; |
|
|
|
import com.yxt.common.base.service.MybatisBaseService; |
|
|
@ -107,45 +108,74 @@ public class RestrictedCategoryService extends MybatisBaseService<RestrictedCate |
|
|
|
return pagging; |
|
|
|
} |
|
|
|
|
|
|
|
public List<RestrictedCategoryVo> categoryListByPsid(String psid) { |
|
|
|
List<RestrictedCategoryVo> pagging = baseMapper.categoryListByPsid(psid); |
|
|
|
return pagging; |
|
|
|
} |
|
|
|
|
|
|
|
public ResultBean saveOrUpdateDto(RestrictedCategoryDto dto) { |
|
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
|
String sid = dto.getSid(); |
|
|
|
String id = dto.getId(); |
|
|
|
String key = dto.getCategory_key(); |
|
|
|
if (StringUtils.isBlank(sid)) { |
|
|
|
RestrictedCategory restrictedCategory = baseMapper.selectByKey(key); |
|
|
|
//查询key是否重复
|
|
|
|
if (restrictedCategory != null) { |
|
|
|
return rb.setMsg("该类别编码已存在"); |
|
|
|
} |
|
|
|
RestrictedCategory restrictedCategory1 =new RestrictedCategory(); |
|
|
|
if(StringUtils.isNotBlank(dto.getPsid())){ |
|
|
|
if(dto.getPsid().equals("0")){ |
|
|
|
RestrictedCategory restrictedCategory1 = new RestrictedCategory(); |
|
|
|
if (StringUtils.isNotBlank(dto.getPsid())) { |
|
|
|
if (dto.getPsid().equals("0")) { |
|
|
|
dto.setGrade(String.valueOf(1)); |
|
|
|
}else { |
|
|
|
restrictedCategory1= baseMapper.selectOne(new QueryWrapper<RestrictedCategory>().eq("sid",dto.getPsid())); |
|
|
|
dto.setGrade(String.valueOf(Integer.valueOf(restrictedCategory1.getGrade())+1)); |
|
|
|
} else { |
|
|
|
restrictedCategory1 = baseMapper.selectOne(new QueryWrapper<RestrictedCategory>().eq("sid", dto.getPsid())); |
|
|
|
dto.setGrade(String.valueOf(Integer.valueOf(restrictedCategory1.getGrade()) + 1)); |
|
|
|
} |
|
|
|
} |
|
|
|
restrictedCategory = new RestrictedCategory(); |
|
|
|
RestrictedCategory restrictedCategory = new RestrictedCategory(); |
|
|
|
BeanUtil.copyProperties(dto, restrictedCategory, "sid"); |
|
|
|
String code = code(dto); |
|
|
|
restrictedCategory.setCategory_key(code); |
|
|
|
baseMapper.insert(restrictedCategory); |
|
|
|
} else { |
|
|
|
RestrictedCategory restrictedCategory = fetchByCode(sid); |
|
|
|
// if (restrictedCategory == null) {
|
|
|
|
// return rb.setMsg("该类别不存在");
|
|
|
|
// }
|
|
|
|
//查询该key是否存在
|
|
|
|
// RestrictedCategory restrictedCategorys = baseMapper.selectByKeyAndSid(key, sid);
|
|
|
|
// if (restrictedCategorys != null) {
|
|
|
|
// return rb.setMsg("该类别编码已存在");
|
|
|
|
// }
|
|
|
|
BeanUtil.copyProperties(dto, restrictedCategory, "sid"); |
|
|
|
baseMapper.update(restrictedCategory,new QueryWrapper<RestrictedCategory>().eq("sid",dto.getSid())); |
|
|
|
baseMapper.update(restrictedCategory, new QueryWrapper<RestrictedCategory>().eq("sid", dto.getSid())); |
|
|
|
} |
|
|
|
return rb.success(); |
|
|
|
} |
|
|
|
|
|
|
|
public String code(RestrictedCategoryDto dto) { |
|
|
|
String code = ""; |
|
|
|
String key = baseMapper.getCategoryByPsid(dto.getPsid()); |
|
|
|
RestrictedCategoryVo restrictedCategory1 = baseMapper.getCategoryBySid(dto.getPsid()); |
|
|
|
if (StringUtils.isBlank(key)) { |
|
|
|
|
|
|
|
key = restrictedCategory1.getCategoryKey(); |
|
|
|
} |
|
|
|
|
|
|
|
//上级品类
|
|
|
|
// RestrictedCategory restrictedCategory1= baseMapper.selectOne(new QueryWrapper<RestrictedCategory>().eq("sid",dto.getPsid()));
|
|
|
|
if (restrictedCategory1.getGrade().equals("0")) { |
|
|
|
//010000
|
|
|
|
if (String.valueOf(Integer.valueOf(key.substring(0, 2)) + 1).length() == 1) { |
|
|
|
code = "0" + String.valueOf(Integer.valueOf(key.substring(0, 2)) + 1) + "0000"; |
|
|
|
} else { |
|
|
|
code = String.valueOf(Integer.valueOf(key.substring(0, 2)) + 1) + "0000"; |
|
|
|
} |
|
|
|
} else if (restrictedCategory1.getGrade().equals("1")) { |
|
|
|
//010100
|
|
|
|
if (String.valueOf(Integer.valueOf(key.substring(2, 4)) + 1).length() == 1) { |
|
|
|
code = key.substring(0, 2) + "0" + String.valueOf(Integer.valueOf(key.substring(2, 4)) + 1) + "00"; |
|
|
|
} else { |
|
|
|
code = key.substring(0, 2) + String.valueOf(Integer.valueOf(key.substring(2, 4)) + 1) + "00"; |
|
|
|
} |
|
|
|
} else if (restrictedCategory1.getGrade().equals("2")) { |
|
|
|
//010101
|
|
|
|
// code=String.valueOf(Integer.valueOf(key.substring(4,6))+1);
|
|
|
|
if (String.valueOf(Integer.valueOf(key.substring(4, 6)) + 1).length() == 1) { |
|
|
|
code = key.substring(0, 4) + "0" + String.valueOf(Integer.valueOf(key.substring(4, 6)) + 1); |
|
|
|
} else { |
|
|
|
code = key.substring(0, 4) + String.valueOf(Integer.valueOf(key.substring(4, 6)) + 1); |
|
|
|
} |
|
|
|
} |
|
|
|
return code; |
|
|
|
} |
|
|
|
|
|
|
|
public RestrictedCategoryDetailsVo fetchDetailsVoBySid(String id) { |
|
|
|
RestrictedCategory entity = getRestById(id); |
|
|
|
RestrictedCategoryDetailsVo vo = new RestrictedCategoryDetailsVo(); |
|
|
@ -270,11 +300,11 @@ public class RestrictedCategoryService extends MybatisBaseService<RestrictedCate |
|
|
|
public void getChildList(List<RestrictedCategoryVo> list) { |
|
|
|
list.forEach(str -> { |
|
|
|
String sid = str.getSid(); |
|
|
|
String pName=str.getCategorys(); |
|
|
|
String pName = str.getCategorys(); |
|
|
|
List<RestrictedCategoryVo> listChildren = baseMapper.selectChildernList(sid); |
|
|
|
listChildren.forEach(i->{ |
|
|
|
listChildren.forEach(i -> { |
|
|
|
i.setPName(pName); |
|
|
|
if(i.getGrade().equals("3")){ |
|
|
|
if (i.getGrade().equals("3")) { |
|
|
|
i.setIsEnd("1"); |
|
|
|
} |
|
|
|
}); |
|
|
|