Merge branch 'ww' into test

This commit is contained in:
2024-09-27 14:31:45 +08:00
2 changed files with 20 additions and 4 deletions

View File

@@ -69,7 +69,7 @@ public class TbProskuConController {
throw new Exception(be.getMessage()); throw new Exception(be.getMessage());
}catch (Exception e){ }catch (Exception e){
e.printStackTrace(); e.printStackTrace();
throw new Exception("参数错误"); throw new Exception(e.getMessage());
} }
} }

View File

@@ -196,15 +196,31 @@ public class TbProskuConServiceImpl implements TbProskuConService {
if (ObjectUtil.isNull(tbConsInfo) || ObjectUtil.isNull(tbConsInfo.getId())) { if (ObjectUtil.isNull(tbConsInfo) || ObjectUtil.isNull(tbConsInfo.getId())) {
throw new BadRequestException("对应的耗材信息不存在"); throw new BadRequestException("对应的耗材信息不存在");
} }
TbProductSku sku = null;
if (resource.getProductSkuId() != 0) { if (resource.getProductSkuId() != 0) {
TbProductSku sku = tbProductSkuRepository.findById(resource.getProductSkuId()).orElseGet(TbProductSku::new); sku = tbProductSkuRepository.findById(resource.getProductSkuId()).orElseGet(TbProductSku::new);
if (ObjectUtil.isNull(sku) || ObjectUtil.isNull(sku.getId())) { if (ObjectUtil.isNull(sku) || ObjectUtil.isNull(sku.getId())) {
throw new BadRequestException("规格信息不存在"); throw new BadRequestException("规格信息不存在");
} }
} }
TbProskuCon tbConsInfo1 = new TbProskuCon(); TbProskuCon tbConsInfo1 = new TbProskuCon();
BeanUtil.copyProperties(resource,tbConsInfo1, CopyOptions.create().setIgnoreNullValue(true)); if (resource.getId() == null) {
newCons.add(tbConsInfo1); int count = tbProskuConRepository.countByConInfoIdAndProductSkuIdAndShopId(resource.getConInfoId(), resource.getProductSkuId(), resource.getShopId(), resource.getProductId());
if (count <= 0) {
BeanUtil.copyProperties(resource, tbConsInfo1, CopyOptions.create().setIgnoreNullValue(true));
newCons.add(tbConsInfo1);
} else {
StringBuilder strResult = new StringBuilder(product.getName());
if (sku != null) {
strResult.append(" 规格" + sku.getSpecSnap());
}
strResult.append("与耗材 " + tbConsInfo.getConName() + " 的对应关系已存在");
throw new BadRequestException(product.getName().concat("对应的").concat(Objects.nonNull(sku.getSpecSnap())?sku.getSpecSnap():"").concat("规格已存在"));
}
}else {
BeanUtil.copyProperties(resource,tbConsInfo1, CopyOptions.create().setIgnoreNullValue(true));
newCons.add(tbConsInfo1);
}
} }
if (!CollectionUtils.isEmpty(newCons)) { if (!CollectionUtils.isEmpty(newCons)) {
tbProskuConRepository.saveAll(newCons); tbProskuConRepository.saveAll(newCons);