商品规格修改
This commit is contained in:
parent
13961cc6fc
commit
9e13d1ff98
|
|
@ -436,6 +436,22 @@ public class TbProductServiceImpl implements TbProductService {
|
|||
TbProduct product = new TbProduct();
|
||||
//组装
|
||||
BeanUtils.copyProperties(resources, product);
|
||||
if(CollectionUtils.isEmpty(resources.getSkuList())){
|
||||
throw new BadRequestException("规格内容不可为空");
|
||||
} else if (!"sku".equals(product.getTypeEnum())) {
|
||||
product.setSelectSpec("[]");
|
||||
product.setSpecTableHeaders("[]");
|
||||
if (resources.getSkuList().size() > 1) {
|
||||
throw new BadRequestException("规格数据异常");
|
||||
}
|
||||
}
|
||||
if (!"group".equals(product.getTypeEnum())) {
|
||||
product.setIsCombo(0);
|
||||
product.setGroupSnap(null);
|
||||
if (resources.getNotices() != null && resources.getNotices().getId() != null) {
|
||||
noticeRepository.deleteById(resources.getNotices().getId());
|
||||
}
|
||||
}
|
||||
product.setIsDel(0);
|
||||
product.setIsDelete(0);
|
||||
product.setIsFreeFreight(1);
|
||||
|
|
@ -471,24 +487,7 @@ public class TbProductServiceImpl implements TbProductService {
|
|||
|
||||
//sku
|
||||
if (resources.getSkuList() != null) {
|
||||
// List<TbProductSku> skuList = new ArrayList<>();
|
||||
// for (TbProductSku sku : resources.getSkuList()) {
|
||||
// TbProductSku tbProductSku = tbProductSkuRepository.searchBarCode(sku.getBarCode());
|
||||
// if (tbProductSku != null) {
|
||||
// tbProductSkuRepository.updateByBarCode(sku.getBarCode(), sku.getCostPrice(), sku.getCoverImg(), sku.getFirstShared(), sku.getMemberPrice(),
|
||||
// sku.getOriginPrice(), sku.getSalePrice(), sku.getSpecSnap(), tbProductSku.getId());
|
||||
// } else {
|
||||
// if ("sku".equals(save.getTypeEnum())) {
|
||||
// tbProductSkuRepository.deleteByProductId(String.valueOf(save.getId()));
|
||||
// }
|
||||
// sku.setProductId(String.valueOf(save.getId()));
|
||||
// sku.setShopId(save.getShopId());
|
||||
// sku.setCreatedAt(Instant.now().toEpochMilli());
|
||||
// sku.setUpdatedAt(Instant.now().toEpochMilli());
|
||||
// skuList.add(sku);
|
||||
// }
|
||||
// }
|
||||
if ("sku".equals(save.getTypeEnum())) {
|
||||
// if ("sku".equals(save.getTypeEnum())) {
|
||||
List<Integer> collect = resources.getSkuList().stream().map(TbProductSku::getId).collect(Collectors.toList());
|
||||
List<TbProductSku> tbProductSkus = tbProductSkuRepository.searchSku(resources.getId().toString());
|
||||
for (TbProductSku productSkus : tbProductSkus) {
|
||||
|
|
@ -496,7 +495,7 @@ public class TbProductServiceImpl implements TbProductService {
|
|||
tbProductSkuRepository.deleteBySkuId(productSkus.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
// }
|
||||
tbProductSkuRepository.saveAll(resources.getSkuList());
|
||||
}
|
||||
//保存到sku_result
|
||||
|
|
|
|||
Loading…
Reference in New Issue