|
|
@@ -243,65 +243,86 @@ public class ProductAttachServiceImpl implements ProductAttachService {
|
|
|
|
|
|
@Override
|
|
|
public ResultMap auditSuccess(ProductAttachSubmit submit) {
|
|
|
- if (submit.getId() == null) {
|
|
|
- return new ResultMap(CodeType.NOT_EXiST, "此申请不存在,请重新确认申请信息");
|
|
|
- }
|
|
|
+ ResultMap map = validateSubmit(submit);
|
|
|
|
|
|
- ProductAttachSubmit exsitedSubmit = productAttachSubmitDao.findOne(submit.getId());
|
|
|
- if (exsitedSubmit == null) {
|
|
|
- return new ResultMap(CodeType.NOT_EXiST, "此申请不存在,请重新确认申请信息");
|
|
|
+ if (CodeType.OK.code() != map.getCode()) {
|
|
|
+ return map;
|
|
|
} else {
|
|
|
- exsitedSubmit.setBrandId(submit.getBrandId());
|
|
|
- exsitedSubmit.setKindId(submit.getKindId());
|
|
|
- exsitedSubmit.setSpec(submit.getSpec());
|
|
|
- if (StringUtils.isEmpty(exsitedSubmit.getUploadAttach())) {
|
|
|
- return new ResultMap(CodeType.NO_INFO, "此申请规格书为空,请重新确认申请信息");
|
|
|
- }
|
|
|
- if (exsitedSubmit.getBrandId() == null || exsitedSubmit.getKindId() == null) {
|
|
|
- return new ResultMap(CodeType.NO_INFO, "商城类目、品牌不完善,请重新确认申请信息");
|
|
|
- }
|
|
|
- BrandInfo brandInfo = brandInfoDao.findOne(exsitedSubmit.getBrandId());
|
|
|
- if (brandInfo == null) {
|
|
|
- return new ResultMap(CodeType.PARAMETER_ERROR, "商城品牌不存在,请重新填写商城品牌");
|
|
|
- }
|
|
|
- KindInfo kindInfo = kindInfoDao.findOne(exsitedSubmit.getKindId());
|
|
|
- if (kindInfo == null) {
|
|
|
- return new ResultMap(CodeType.PARAMETER_ERROR, "商城物料名称(类目)不存在,请重新填写商城物料名称(类目)");
|
|
|
- }
|
|
|
+ ProductAttachSubmit exsitedSubmit = (ProductAttachSubmit) map.getData();
|
|
|
|
|
|
// 标准型号
|
|
|
- if (StringUtils.isEmpty(exsitedSubmit.getUuid())) {
|
|
|
+ if (!StringUtils.isEmpty(exsitedSubmit.getUuid())) {
|
|
|
Component component = componentDao.findByUuid(exsitedSubmit.getUuid());
|
|
|
// 实际为非标物料
|
|
|
if (component == null) {
|
|
|
return new ResultMap(CodeType.ERROR_STATE, "该物料匹配的标准器件不存在,请重新确认该物料信息");
|
|
|
- // 标准物料无规格书,更新规格书
|
|
|
+ // 标准物料无规格书,更新规格书
|
|
|
} else if (component.getAttach() == null){
|
|
|
component = addComponent(exsitedSubmit, component.getId());
|
|
|
+ // TODO updateProduct
|
|
|
return ResultMap.success(auditSubmit(exsitedSubmit));
|
|
|
- // 标准物料有规格书,返回两规格书
|
|
|
+ // 标准物料有规格书,返回两规格书
|
|
|
} else {
|
|
|
return ResultMap.success(componentAttachNotNull(exsitedSubmit, component.getAttach()));
|
|
|
}
|
|
|
- // 非标型号
|
|
|
+ // 非标型号
|
|
|
} else {
|
|
|
- List<Component> components = componentDao.findByBrandidAndCode(submit.getBrandId(), submit.getCode());
|
|
|
+ List<Component> components = componentDao.findByBrandidAndCode(exsitedSubmit.getBrandId(), exsitedSubmit.getCode());
|
|
|
if (!CollectionUtils.isEmpty(components)) {
|
|
|
Component component = components.get(0);
|
|
|
+ // 保存uuid
|
|
|
+ exsitedSubmit.setUuid(component.getUuid());
|
|
|
+ productAttachSubmitDao.save(exsitedSubmit);
|
|
|
+
|
|
|
if (component.getAttach() != null) {
|
|
|
return ResultMap.success(componentAttachNotNull(exsitedSubmit, component.getAttach()));
|
|
|
} else {
|
|
|
component = addComponent(exsitedSubmit, component.getId());
|
|
|
+ // TODO updateProduct
|
|
|
return ResultMap.success(auditSubmit(exsitedSubmit));
|
|
|
}
|
|
|
} else {
|
|
|
Component component = addComponent(exsitedSubmit, null);
|
|
|
+ // 保存uuid
|
|
|
+ exsitedSubmit.setUuid(component.getUuid());
|
|
|
+ productAttachSubmitDao.save(exsitedSubmit);
|
|
|
+ // TODO updateProduct
|
|
|
return ResultMap.success(auditSubmit(exsitedSubmit));
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private ResultMap validateSubmit(ProductAttachSubmit submit) {
|
|
|
+ if (submit.getId() == null) {
|
|
|
+ return new ResultMap(CodeType.NOT_EXiST, "此申请不存在,请重新确认申请信息");
|
|
|
+ }
|
|
|
+
|
|
|
+ ProductAttachSubmit exsitedSubmit = productAttachSubmitDao.findOne(submit.getId());
|
|
|
+ if (exsitedSubmit == null) {
|
|
|
+ return new ResultMap(CodeType.NOT_EXiST, "此申请不存在,请重新确认申请信息");
|
|
|
+ } else {
|
|
|
+ exsitedSubmit.setBrandId(submit.getBrandId());
|
|
|
+ exsitedSubmit.setKindId(submit.getKindId());
|
|
|
+ exsitedSubmit.setSpec(submit.getSpec());
|
|
|
+ if (StringUtils.isEmpty(exsitedSubmit.getUploadAttach())) {
|
|
|
+ return new ResultMap(CodeType.NO_INFO, "此申请规格书为空,请重新确认申请信息");
|
|
|
+ }
|
|
|
+ if (exsitedSubmit.getBrandId() == null || exsitedSubmit.getKindId() == null) {
|
|
|
+ return new ResultMap(CodeType.NO_INFO, "商城类目、品牌不完善,请重新确认申请信息");
|
|
|
+ }
|
|
|
+ BrandInfo brandInfo = brandInfoDao.findOne(exsitedSubmit.getBrandId());
|
|
|
+ if (brandInfo == null) {
|
|
|
+ return new ResultMap(CodeType.PARAMETER_ERROR, "商城品牌不存在,请重新填写商城品牌");
|
|
|
+ }
|
|
|
+ KindInfo kindInfo = kindInfoDao.findOne(exsitedSubmit.getKindId());
|
|
|
+ if (kindInfo == null) {
|
|
|
+ return new ResultMap(CodeType.PARAMETER_ERROR, "商城物料名称(类目)不存在,请重新填写商城物料名称(类目)");
|
|
|
+ }
|
|
|
+ return ResultMap.success(exsitedSubmit);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 完善审核信息
|
|
|
* @param submit
|
|
|
@@ -357,8 +378,25 @@ public class ProductAttachServiceImpl implements ProductAttachService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public ResultMap chooseAttach(String attach, ProductAttachSubmit productAttachSubmit) {
|
|
|
- return null;
|
|
|
+ public ResultMap chooseAttach(String attach, ProductAttachSubmit submit) {
|
|
|
+ ResultMap map = validateSubmit(submit);
|
|
|
+ if (CodeType.OK.code() != map.getCode()) {
|
|
|
+ return map;
|
|
|
+ } else {
|
|
|
+ ProductAttachSubmit exsitedSubmit = (ProductAttachSubmit) map.getData();
|
|
|
+ if (!StringUtils.isEmpty(attach)) {
|
|
|
+ Component component = componentDao.findByUuid(exsitedSubmit.getUuid());
|
|
|
+ if (component != null) {
|
|
|
+ component = addComponent(exsitedSubmit, component.getId());
|
|
|
+ // TODO updateProduct
|
|
|
+ return ResultMap.success(auditSubmit(exsitedSubmit));
|
|
|
+ } else {
|
|
|
+ return new ResultMap(CodeType.ERROR_STATE, "该物料匹配的标准器件不存在,请重新确认该物料信息");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ return new ResultMap(CodeType.PARAMETER_ERROR, "请选择一份规格书");
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
private Component addComponent(ProductAttachSubmit submit, Long componentId) {
|