|
@@ -13,7 +13,6 @@ import cn.newfeifan.mall.module.product.dal.dataobject.category.ProductCategoryD
|
|
|
import cn.newfeifan.mall.module.product.dal.dataobject.spu.ProductSpuDO;
|
|
|
import cn.newfeifan.mall.module.product.dal.mysql.spu.ProductSpuMapper;
|
|
|
import cn.newfeifan.mall.module.product.enums.spu.ProductSpuStatusEnum;
|
|
|
-import cn.newfeifan.mall.module.product.service.brand.ProductBrandService;
|
|
|
import cn.newfeifan.mall.module.product.service.category.ProductCategoryService;
|
|
|
import cn.newfeifan.mall.module.product.service.favorite.ProductFavoriteService;
|
|
|
import cn.newfeifan.mall.module.product.service.sku.ProductSkuService;
|
|
@@ -49,8 +48,6 @@ public class ProductSpuServiceImpl implements ProductSpuService {
|
|
|
@Lazy // 循环依赖,避免报错
|
|
|
private ProductSkuService productSkuService;
|
|
|
@Resource
|
|
|
- private ProductBrandService brandService;
|
|
|
- @Resource
|
|
|
private ProductCategoryService categoryService;
|
|
|
|
|
|
@Resource
|
|
@@ -61,7 +58,7 @@ public class ProductSpuServiceImpl implements ProductSpuService {
|
|
|
public Long createSpu(ProductSpuSaveReqVO createReqVO) {
|
|
|
// 校验分类、品牌
|
|
|
validateCategory(createReqVO.getCategoryId());
|
|
|
- brandService.validateProductBrand(createReqVO.getBrandId());
|
|
|
+// brandService.validateProductBrand(createReqVO.getBrandId());
|
|
|
|
|
|
// 根据商户ID查询对应的店铺ID
|
|
|
// todo 后续如果存在多店铺的情况下
|
|
@@ -92,7 +89,7 @@ public class ProductSpuServiceImpl implements ProductSpuService {
|
|
|
validateSpuExists(updateReqVO.getId());
|
|
|
// 校验分类、品牌
|
|
|
validateCategory(updateReqVO.getCategoryId());
|
|
|
- brandService.validateProductBrand(updateReqVO.getBrandId());
|
|
|
+// brandService.validateProductBrand(updateReqVO.getBrandId());
|
|
|
// 校验SKU
|
|
|
List<ProductSkuSaveReqVO> skuSaveReqList = updateReqVO.getSkus();
|
|
|
productSkuService.validateSkuList(skuSaveReqList, updateReqVO.getSpecType());
|
|
@@ -113,12 +110,19 @@ public class ProductSpuServiceImpl implements ProductSpuService {
|
|
|
* @param skus 商品 SKU 数组
|
|
|
*/
|
|
|
private void initSpuFromSkus(ProductSpuDO spu, List<ProductSkuSaveReqVO> skus) {
|
|
|
- // sku 单价最低的商品的价格
|
|
|
- spu.setPrice(getMinValue(skus, ProductSkuSaveReqVO::getPrice));
|
|
|
- // sku 单价最低的商品的市场价格
|
|
|
- spu.setMarketPrice(getMinValue(skus, ProductSkuSaveReqVO::getMarketPrice));
|
|
|
- // sku 单价最低的商品的成本价格
|
|
|
- spu.setCostPrice(getMinValue(skus, ProductSkuSaveReqVO::getCostPrice));
|
|
|
+ //是否是高精度商品
|
|
|
+ if(!spu.getHighPrecision()){
|
|
|
+ // sku 单价最低的商品的价格
|
|
|
+ spu.setPrice(getMinValue(skus, ProductSkuSaveReqVO::getPrice));
|
|
|
+ // sku 单价最低的商品的市场价格
|
|
|
+ spu.setMarketPrice(getMinValue(skus, ProductSkuSaveReqVO::getMarketPrice));
|
|
|
+ // sku 单价最低的商品的成本价格
|
|
|
+ spu.setCostPrice(getMinValue(skus, ProductSkuSaveReqVO::getCostPrice));
|
|
|
+ }else{
|
|
|
+ // sku 单价最低的商品的价格
|
|
|
+ spu.setHighPrecisionPrice(getMinValue(skus, ProductSkuSaveReqVO::getHighPrecisionPrice));
|
|
|
+ }
|
|
|
+
|
|
|
// skus 库存总数
|
|
|
spu.setStock(getSumValue(skus, ProductSkuSaveReqVO::getStock, Integer::sum));
|
|
|
// 若是 spu 已有状态则不处理
|