记得上下班打卡 | git大法好,push需谨慎

Commit 8ffa0dac authored by 张国柄's avatar 张国柄

~API:商品管理:+商品名称重复校验;

parent 7ab7d5ca
...@@ -102,7 +102,7 @@ public class GoblinStoreMgtCategoryController { ...@@ -102,7 +102,7 @@ public class GoblinStoreMgtCategoryController {
} else {// 存在则判断,是否为已存在的父级分类 } else {// 存在则判断,是否为已存在的父级分类
if (storeGoodsCategoryVosCache.stream().anyMatch(r -> r.getName().equals(catename))) { if (storeGoodsCategoryVosCache.stream().anyMatch(r -> r.getName().equals(catename))) {
log.warn("店铺商品分类管理:添加:分类名称重复[UID={},storeId={},catefid={},catesid={},catename={}]", currentUid, storeId, catefid, catesid, catename); log.warn("店铺商品分类管理:添加:分类名称重复[UID={},storeId={},catefid={},catesid={},catename={}]", currentUid, storeId, catefid, catesid, catename);
return ResponseDto.failure(ErrorMapping.get("149007")); return ResponseDto.failure(ErrorMapping.get("149008"));
} }
Map<String, GoblinStoreGoodsCategoryVo> existFilterMap = storeGoodsCategoryVosCache.stream().filter(r -> catePidList.contains(r.getCateId())) Map<String, GoblinStoreGoodsCategoryVo> existFilterMap = storeGoodsCategoryVosCache.stream().filter(r -> catePidList.contains(r.getCateId()))
......
...@@ -17,6 +17,7 @@ import com.liquidnet.service.goblin.dto.manage.GoblinStoreMgtGoodsFilterParam; ...@@ -17,6 +17,7 @@ import com.liquidnet.service.goblin.dto.manage.GoblinStoreMgtGoodsFilterParam;
import com.liquidnet.service.goblin.dto.manage.vo.GoblinStoreMgtGoodsInfoVo; import com.liquidnet.service.goblin.dto.manage.vo.GoblinStoreMgtGoodsInfoVo;
import com.liquidnet.service.goblin.dto.manage.vo.GoblinStoreMgtGoodsListVo; import com.liquidnet.service.goblin.dto.manage.vo.GoblinStoreMgtGoodsListVo;
import com.liquidnet.service.goblin.dto.vo.*; import com.liquidnet.service.goblin.dto.vo.*;
import com.liquidnet.service.goblin.service.manage.IGoblinStoreMgtExtraService;
import com.liquidnet.service.goblin.service.manage.IGoblinstoreMgtGoodsService; import com.liquidnet.service.goblin.service.manage.IGoblinstoreMgtGoodsService;
import com.liquidnet.service.goblin.util.GoblinMongoUtils; import com.liquidnet.service.goblin.util.GoblinMongoUtils;
import com.liquidnet.service.goblin.util.GoblinRedisUtils; import com.liquidnet.service.goblin.util.GoblinRedisUtils;
...@@ -50,6 +51,8 @@ public class GoblinStoreMgtGoodsController { ...@@ -50,6 +51,8 @@ public class GoblinStoreMgtGoodsController {
@Autowired @Autowired
IGoblinstoreMgtGoodsService goblinstoreMgtGoodsService; IGoblinstoreMgtGoodsService goblinstoreMgtGoodsService;
@Autowired @Autowired
IGoblinStoreMgtExtraService goblinStoreMgtExtraService;
@Autowired
GoblinRedisUtils goblinRedisUtils; GoblinRedisUtils goblinRedisUtils;
@Autowired @Autowired
GoblinMongoUtils goblinMongoUtils; GoblinMongoUtils goblinMongoUtils;
...@@ -125,7 +128,8 @@ public class GoblinStoreMgtGoodsController { ...@@ -125,7 +128,8 @@ public class GoblinStoreMgtGoodsController {
@PutMapping("add") @PutMapping("add")
public ResponseDto<Object> add(@Valid @RequestBody GoblinStoreMgtGoodsAddParam storeMgtGoodsAddParam) { public ResponseDto<Object> add(@Valid @RequestBody GoblinStoreMgtGoodsAddParam storeMgtGoodsAddParam) {
String currentUid = CurrentUtil.getCurrentUid(); String currentUid = CurrentUtil.getCurrentUid();
if (!goblinRedisUtils.hasStoreId(currentUid, storeMgtGoodsAddParam.getStoreId())) { String storeId = storeMgtGoodsAddParam.getStoreId();
if (!goblinRedisUtils.hasStoreId(currentUid, storeId)) {
return ResponseDto.failure(ErrorMapping.get("149002")); return ResponseDto.failure(ErrorMapping.get("149002"));
} }
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
...@@ -137,6 +141,22 @@ public class GoblinStoreMgtGoodsController { ...@@ -137,6 +141,22 @@ public class GoblinStoreMgtGoodsController {
if (CollectionUtils.isEmpty(storeMgtGoodsAddParam.getImageList())) { if (CollectionUtils.isEmpty(storeMgtGoodsAddParam.getImageList())) {
return ResponseDto.failure(ErrorCode.HTTP_PARAM_ERROR.getCode(), "商品图片不能为空"); return ResponseDto.failure(ErrorCode.HTTP_PARAM_ERROR.getCode(), "商品图片不能为空");
} }
String cateSid = storeMgtGoodsAddParam.getCateSid(), cateTid = storeMgtGoodsAddParam.getCateTid();
List<GoblinSelfGoodsCategoryVo> selfGoodsCategoryVos = goblinStoreMgtExtraService.listCategoryVo();
if (selfGoodsCategoryVos.stream().noneMatch(r -> r.getCateId().equals(storeMgtGoodsAddParam.getCateFid()) && r.getGrade().equals("1"))) {
return ResponseDto.failure(ErrorCode.HTTP_PARAM_ERROR.getCode(), "商品分类1无效");
}
if (StringUtils.isNotBlank(cateSid) && selfGoodsCategoryVos.stream().noneMatch(r -> r.getCateId().equals(cateSid) && r.getGrade().equals("2"))) {
return ResponseDto.failure(ErrorCode.HTTP_PARAM_ERROR.getCode(), "商品分类2无效");
}
if (StringUtils.isNotBlank(cateTid) && selfGoodsCategoryVos.stream().noneMatch(r -> r.getCateId().equals(cateTid) && r.getGrade().equals("3"))) {
return ResponseDto.failure(ErrorCode.HTTP_PARAM_ERROR.getCode(), "商品分类3无效");
}
GoblinGoodsInfoVo mgtGoodsInfoVo = goblinMongoUtils.getMgtGoodsInfoVo(storeId, storeMgtGoodsAddParam.getName());
if (null != mgtGoodsInfoVo) {
return ResponseDto.failure(ErrorMapping.get("149007"));
}
LocalDateTime now = LocalDateTime.now(); LocalDateTime now = LocalDateTime.now();
GoblinGoodsInfoVo goodsInfoVo = storeMgtGoodsAddParam.initGoodsInfoVo(); GoblinGoodsInfoVo goodsInfoVo = storeMgtGoodsAddParam.initGoodsInfoVo();
goodsInfoVo.setCreatedBy(currentUid); goodsInfoVo.setCreatedBy(currentUid);
...@@ -202,7 +222,8 @@ public class GoblinStoreMgtGoodsController { ...@@ -202,7 +222,8 @@ public class GoblinStoreMgtGoodsController {
@PostMapping("edit_spu") @PostMapping("edit_spu")
public ResponseDto<Object> editSpu(@Valid @RequestBody GoblinStoreMgtGoodsAddParam storeMgtGoodsAddParam) { public ResponseDto<Object> editSpu(@Valid @RequestBody GoblinStoreMgtGoodsAddParam storeMgtGoodsAddParam) {
String currentUid = CurrentUtil.getCurrentUid(); String currentUid = CurrentUtil.getCurrentUid();
if (!goblinRedisUtils.hasStoreId(currentUid, storeMgtGoodsAddParam.getStoreId())) { String storeId = storeMgtGoodsAddParam.getStoreId();
if (!goblinRedisUtils.hasStoreId(currentUid, storeId)) {
return ResponseDto.failure(ErrorMapping.get("149002")); return ResponseDto.failure(ErrorMapping.get("149002"));
} }
if (StringUtils.isBlank(storeMgtGoodsAddParam.getSpuId()) || null == goblinRedisUtils.getMgtGoodsInfoVo(storeMgtGoodsAddParam.getSpuId())) { if (StringUtils.isBlank(storeMgtGoodsAddParam.getSpuId()) || null == goblinRedisUtils.getMgtGoodsInfoVo(storeMgtGoodsAddParam.getSpuId())) {
...@@ -211,7 +232,21 @@ public class GoblinStoreMgtGoodsController { ...@@ -211,7 +232,21 @@ public class GoblinStoreMgtGoodsController {
if (CollectionUtils.isEmpty(storeMgtGoodsAddParam.getImageList())) { if (CollectionUtils.isEmpty(storeMgtGoodsAddParam.getImageList())) {
return ResponseDto.failure(ErrorCode.HTTP_PARAM_ERROR.getCode(), "商品图片不能为空"); return ResponseDto.failure(ErrorCode.HTTP_PARAM_ERROR.getCode(), "商品图片不能为空");
} }
// TODO: 2022/1/20 zhanggb==valid category String cateSid = storeMgtGoodsAddParam.getCateSid(), cateTid = storeMgtGoodsAddParam.getCateTid();
List<GoblinSelfGoodsCategoryVo> selfGoodsCategoryVos = goblinStoreMgtExtraService.listCategoryVo();
if (selfGoodsCategoryVos.stream().noneMatch(r -> r.getCateId().equals(storeMgtGoodsAddParam.getCateFid()) && r.getGrade().equals("1"))) {
return ResponseDto.failure(ErrorCode.HTTP_PARAM_ERROR.getCode(), "商品分类1无效");
}
if (StringUtils.isNotBlank(cateSid) && selfGoodsCategoryVos.stream().noneMatch(r -> r.getCateId().equals(cateSid) && r.getGrade().equals("2"))) {
return ResponseDto.failure(ErrorCode.HTTP_PARAM_ERROR.getCode(), "商品分类2无效");
}
if (StringUtils.isNotBlank(cateTid) && selfGoodsCategoryVos.stream().noneMatch(r -> r.getCateId().equals(cateTid) && r.getGrade().equals("3"))) {
return ResponseDto.failure(ErrorCode.HTTP_PARAM_ERROR.getCode(), "商品分类3无效");
}
GoblinGoodsInfoVo mgtGoodsInfoVo = goblinMongoUtils.getMgtGoodsInfoVo(storeId, storeMgtGoodsAddParam.getName());
if (null != mgtGoodsInfoVo && !mgtGoodsInfoVo.getSpuId().equals(storeMgtGoodsAddParam.getSpuId())) {
return ResponseDto.failure(ErrorMapping.get("149007"));
}
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.debug("商品管理:商品编辑:SPU编辑:[GoblinStoreMgtGoodsAddParam={}]", JsonUtils.toJson(storeMgtGoodsAddParam)); log.debug("商品管理:商品编辑:SPU编辑:[GoblinStoreMgtGoodsAddParam={}]", JsonUtils.toJson(storeMgtGoodsAddParam));
} }
......
...@@ -13,7 +13,7 @@ import org.springframework.util.CollectionUtils; ...@@ -13,7 +13,7 @@ import org.springframework.util.CollectionUtils;
import java.util.List; import java.util.List;
@Service @Service
public class GoblinStoreMgtExtraImpl implements IGoblinStoreMgtExtraService { public class GoblinStoreMgtExtraServiceImpl implements IGoblinStoreMgtExtraService {
@Autowired @Autowired
private GoblinRedisUtils goblinRedisUtils; private GoblinRedisUtils goblinRedisUtils;
@Autowired @Autowired
......
...@@ -12,10 +12,8 @@ import com.liquidnet.service.goblin.dto.manage.GoblinStoreMgtGoodsFilterParam; ...@@ -12,10 +12,8 @@ import com.liquidnet.service.goblin.dto.manage.GoblinStoreMgtGoodsFilterParam;
import com.liquidnet.service.goblin.dto.manage.vo.GoblinMgtCategorySpecVo; import com.liquidnet.service.goblin.dto.manage.vo.GoblinMgtCategorySpecVo;
import com.liquidnet.service.goblin.dto.manage.vo.GoblinStoreMgtGoodsInfoVo; import com.liquidnet.service.goblin.dto.manage.vo.GoblinStoreMgtGoodsInfoVo;
import com.liquidnet.service.goblin.dto.manage.vo.GoblinStoreMgtGoodsListVo; import com.liquidnet.service.goblin.dto.manage.vo.GoblinStoreMgtGoodsListVo;
import com.liquidnet.service.goblin.dto.vo.GoblinGoodsInfoVo; import com.liquidnet.service.goblin.dto.vo.*;
import com.liquidnet.service.goblin.dto.vo.GoblinGoodsSkuInfoVo; import com.liquidnet.service.goblin.service.manage.IGoblinStoreMgtExtraService;
import com.liquidnet.service.goblin.dto.vo.GoblinGoodsSpecValueVo;
import com.liquidnet.service.goblin.dto.vo.GoblinGoodsSpecVo;
import com.liquidnet.service.goblin.service.manage.IGoblinstoreMgtGoodsService; import com.liquidnet.service.goblin.service.manage.IGoblinstoreMgtGoodsService;
import com.liquidnet.service.goblin.util.GoblinMongoUtils; import com.liquidnet.service.goblin.util.GoblinMongoUtils;
import com.liquidnet.service.goblin.util.GoblinRedisUtils; import com.liquidnet.service.goblin.util.GoblinRedisUtils;
...@@ -39,10 +37,37 @@ public class GoblinStoreMgtGoodsServiceImpl implements IGoblinstoreMgtGoodsServi ...@@ -39,10 +37,37 @@ public class GoblinStoreMgtGoodsServiceImpl implements IGoblinstoreMgtGoodsServi
GoblinRedisUtils goblinRedisUtils; GoblinRedisUtils goblinRedisUtils;
@Autowired @Autowired
GoblinMongoUtils goblinMongoUtils; GoblinMongoUtils goblinMongoUtils;
@Autowired
IGoblinStoreMgtExtraService goblinStoreMgtExtraService;
@Override @Override
public PagedResult<GoblinStoreMgtGoodsListVo> goodsList(GoblinStoreMgtGoodsFilterParam filterParam) { public PagedResult<GoblinStoreMgtGoodsListVo> goodsList(GoblinStoreMgtGoodsFilterParam filterParam) {
return goblinMongoUtils.getMgtGoodsInfoVos(filterParam); PagedResult<GoblinStoreMgtGoodsListVo> goodsListVoPagedResult = goblinMongoUtils.getMgtGoodsInfoVos(filterParam);
if (goodsListVoPagedResult.getTotal() > 0) {
List<GoblinSelfGoodsCategoryVo> selfGoodsCategoryVos = goblinStoreMgtExtraService.listCategoryVo();
List<GoblinStoreMgtGoodsListVo> list = goodsListVoPagedResult.getList();
list.forEach(r -> {
String cateFid = r.getCateFid(), cateSid = r.getCateSid(), cateTid = r.getCateTid();
List<GoblinSelfGoodsCategoryVo> categoryVoList = selfGoodsCategoryVos.stream()
.filter(cr -> Arrays.asList(cateFid, cateSid, cateTid).contains(cr.getCateId())).collect(Collectors.toList());
categoryVoList.forEach(cr -> {
if (cr.getCateId().equals(cateFid)) {
r.setCateFid(cr.getName());
}
if (cr.getCateId().equals(cateSid)) {
r.setCateFid(cr.getName());
}
if (cr.getCateId().equals(cateSid)) {
r.setCateFid(cr.getName());
}
});
});
goodsListVoPagedResult.setList(list);
}
return goodsListVoPagedResult;
} }
@Override @Override
......
...@@ -398,6 +398,12 @@ public class GoblinMongoUtils { ...@@ -398,6 +398,12 @@ public class GoblinMongoUtils {
GoblinGoodsInfoVo.class, GoblinGoodsInfoVo.class.getSimpleName()); GoblinGoodsInfoVo.class, GoblinGoodsInfoVo.class.getSimpleName());
} }
// SPU信息
public GoblinGoodsInfoVo getMgtGoodsInfoVo(String storeId, String name) {
return mongoTemplate.findOne(Query.query(Criteria.where("name").is(name).and("delFlg").is("0")),
GoblinGoodsInfoVo.class, GoblinGoodsInfoVo.class.getSimpleName());
}
// SPU信息 // SPU信息
public boolean updateGoodsInfoVo(GoblinGoodsInfoVo vo) { public boolean updateGoodsInfoVo(GoblinGoodsInfoVo vo) {
return mongoTemplate.getCollection(GoblinGoodsInfoVo.class.getSimpleName()).updateOne( return mongoTemplate.getCollection(GoblinGoodsInfoVo.class.getSimpleName()).updateOne(
......
...@@ -21,8 +21,8 @@ ...@@ -21,8 +21,8 @@
149004= 149004=
149005= 149005=
149006=添加商品失败,规格信息无效 149006=添加商品失败,规格信息无效
149007=商品分类名称重复,请核实 149007=添加商品失败,商品名称重复
149008= 149008=商品分类名称重复,请核实
149009= 149009=
149010=商品不存在,请核实 149010=商品不存在,请核实
149011=SKU不存在,请核实 149011=SKU不存在,请核实
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment