|
|
@@ -121,10 +121,13 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
|
|
|
}
|
|
|
// 设置付款方式
|
|
|
product.setPaymentType(paymentType);
|
|
|
+ // 设置积分价格
|
|
|
+ product.setPricePoint(skuList.get(0).getPricePoint());
|
|
|
+ // 设置现金价格
|
|
|
+ product.setPriceMoney(skuList.get(0).getPriceMoney());
|
|
|
product.setStatus(0); // 默认下架
|
|
|
product.setSales(0); // 初始销量为0
|
|
|
product.setDeleted(0); // 未删除
|
|
|
-
|
|
|
// 计算总库存
|
|
|
if (!CollectionUtils.isEmpty(dto.getSkuList())) {
|
|
|
int totalStock = dto.getSkuList().stream().mapToInt(ProductSkuDTO::getStock).sum();
|
|
|
@@ -162,7 +165,6 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
|
|
|
if (CollectionUtils.isEmpty(dto.getSpecList())) {
|
|
|
throw new RuntimeException("商品规格不能为空");
|
|
|
}
|
|
|
-
|
|
|
// 4. 校验SKU列表是否为空
|
|
|
if (CollectionUtils.isEmpty(dto.getSkuList())) {
|
|
|
throw new RuntimeException("商品SKU不能为空");
|
|
|
@@ -199,18 +201,23 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
|
|
|
productSpecMapper.delete(new LambdaQueryWrapper<ProductSpec>().eq(ProductSpec::getProductId, productId));
|
|
|
//删除商品规格值
|
|
|
productSpecValueMapper.delete(new LambdaQueryWrapper<ProductSpecValue>().eq(ProductSpecValue::getProductId, productId));
|
|
|
+ //根据商品ID查询商品编号
|
|
|
+ Product product = this.getById(productId);
|
|
|
+
|
|
|
//添加商品规格
|
|
|
for (ProductSpecDTO spec : specList) {
|
|
|
ProductSpec productSpec = new ProductSpec();
|
|
|
productSpec.setProductId(productId);
|
|
|
productSpec.setSpecName(spec.getSpecName());
|
|
|
productSpec.setSort(spec.getSort());
|
|
|
+ productSpec.setProductNo(product.getProductNo());
|
|
|
productSpecMapper.insert(productSpec);
|
|
|
//添加商品规格值
|
|
|
for (ProductSpecValueDTO value : spec.getSpecValues()) {
|
|
|
ProductSpecValue productSpecValue = new ProductSpecValue();
|
|
|
productSpecValue.setSpecId(productSpec.getId());
|
|
|
productSpecValue.setProductId(productId);
|
|
|
+ productSpecValue.setProductNo(product.getProductNo());
|
|
|
productSpecValue.setSpecValue(value.getSpecValue());
|
|
|
productSpecValue.setSort(value.getSort());
|
|
|
productSpecValueMapper.insert(productSpecValue);
|