mirror of
https://gitee.com/hhyykk/ipms-sjy.git
synced 2025-08-10 00:01:53 +08:00
合并分支修复差异
This commit is contained in:
@@ -15,7 +15,8 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* TODO LeeYan9: 类注释;
|
||||
* 商品 SKU API 实现类
|
||||
*
|
||||
* @author LeeYan9
|
||||
* @since 2022-09-06
|
||||
*/
|
||||
@@ -28,8 +29,8 @@ public class ProductSkuApiImpl implements ProductSkuApi {
|
||||
|
||||
@Override
|
||||
public ProductSkuRespDTO getSku(Long id) {
|
||||
// TODO TODO LeeYan9: 需要实现
|
||||
return null;
|
||||
ProductSkuDO sku = productSkuService.getSku(id);
|
||||
return ProductSkuConvert.INSTANCE.convert02(sku);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -1,8 +1,18 @@
|
||||
### 获得订单交易的分页 TODO
|
||||
### 获得订单交易的分页(默认)
|
||||
GET {{appApi}}/product/spu/page?pageNo=1&pageSize=10
|
||||
Authorization: Bearer {{appToken}}
|
||||
tenant-id: {{appTenentId}}
|
||||
|
||||
### 获得商品 SPU 明细
|
||||
GET {{appApi}}/product/spu/get-detail?id=4
|
||||
### 获得订单交易的分页(价格)
|
||||
GET {{appApi}}/product/spu/page?pageNo=1&pageSize=10&sortField=price&sortAsc=true
|
||||
Authorization: Bearer {{appToken}}
|
||||
tenant-id: {{appTenentId}}
|
||||
|
||||
### 获得订单交易的分页(销售)
|
||||
GET {{appApi}}/product/spu/page?pageNo=1&pageSize=10&sortField=salesCount&sortAsc=true
|
||||
Authorization: Bearer {{appToken}}
|
||||
tenant-id: {{appTenentId}}
|
||||
|
||||
### 获得商品 SPU 明细
|
||||
GET {{appApi}}/product/spu/get-detail?id=102
|
||||
tenant-id: {{appTenentId}}
|
||||
|
@@ -49,8 +49,8 @@ public class AppProductSpuController {
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得商品 SPU 分页")
|
||||
public CommonResult<PageResult<AppProductSpuPageItemRespVO>> getSpuPage(@Valid AppProductSpuPageReqVO pageVO) {
|
||||
PageResult<ProductSpuDO> pageResult = productSpuService.getSpuPage(pageVO, ProductSpuStatusEnum.ENABLE.getStatus());
|
||||
return success(ProductSpuConvert.INSTANCE.convertPage02(pageResult));
|
||||
PageResult<ProductSpuDO> pageResult = productSpuService.getSpuPage(pageVO);
|
||||
return success(ProductSpuConvert.INSTANCE.convertPageForGetSpuPage(pageResult));
|
||||
}
|
||||
|
||||
@GetMapping("/get-detail")
|
||||
@@ -73,7 +73,7 @@ public class AppProductSpuController {
|
||||
List<ProductPropertyValueDetailRespBO> propertyValues = productPropertyValueService
|
||||
.getPropertyValueDetailList(ProductSkuConvert.INSTANCE.convertPropertyValueIds(skus));
|
||||
// 拼接
|
||||
return success(ProductSpuConvert.INSTANCE.convert(spu, skus, propertyValues));
|
||||
return success(ProductSpuConvert.INSTANCE.convertForGetSpuDetail(spu, skus, propertyValues));
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -18,17 +18,17 @@ public class AppProductSpuDetailRespVO {
|
||||
@Schema(description = "商品名称", required = true, example = "芋道")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "促销语", example = "好吃!")
|
||||
private String sellPoint;
|
||||
|
||||
@Schema(description = "商品详情", required = true, example = "我是商品描述")
|
||||
private String description;
|
||||
|
||||
@Schema(description = "商品分类编号", required = true, example = "1")
|
||||
private Long categoryId;
|
||||
|
||||
@Schema(description = "商品图片的数组", required = true)
|
||||
private List<String> picUrls;
|
||||
@Schema(description = "商品封面图", required = true)
|
||||
private String picUrl;
|
||||
|
||||
@Schema(description = "商品轮播图", required = true)
|
||||
private List<String> sliderPicUrls;
|
||||
|
||||
@Schema(description = "商品视频", required = true)
|
||||
private String videoUrl;
|
||||
@@ -38,14 +38,14 @@ public class AppProductSpuDetailRespVO {
|
||||
@Schema(description = "规格类型", required = true, example = "true")
|
||||
private Boolean specType;
|
||||
|
||||
@Schema(description = "是否展示库存", required = true, example = "true")
|
||||
private Boolean showStock;
|
||||
@Schema(description = "商品价格,单位使用:分", required = true, example = "1024")
|
||||
private Integer price;
|
||||
|
||||
@Schema(description = " 最小价格,单位使用:分", required = true, example = "1024")
|
||||
private Integer minPrice;
|
||||
@Schema(description = "市场价,单位使用:分", required = true, example = "1024")
|
||||
private Integer marketPrice;
|
||||
|
||||
@Schema(description = "最大价格,单位使用:分", required = true, example = "1024")
|
||||
private Integer maxPrice;
|
||||
@Schema(description = "库存", required = true, example = "666")
|
||||
private Integer stock;
|
||||
|
||||
/**
|
||||
* SKU 数组
|
||||
@@ -72,7 +72,7 @@ public class AppProductSpuDetailRespVO {
|
||||
@Schema(description = "销售价格,单位:分", required = true, example = "1024")
|
||||
private Integer price;
|
||||
|
||||
@Schema(description = "市场价", example = "1024")
|
||||
@Schema(description = "市场价,单位使用:分", required = true, example = "1024")
|
||||
private Integer marketPrice;
|
||||
|
||||
@Schema(description = "图片地址", required = true, example = "https://www.iocoder.cn/xx.png")
|
||||
|
@@ -3,8 +3,6 @@ package cn.iocoder.yudao.module.product.controller.app.spu.vo;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.List;
|
||||
|
||||
@Schema(description = "用户 App - 商品 SPU 分页项 Response VO")
|
||||
@@ -15,25 +13,31 @@ public class AppProductSpuPageItemRespVO {
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "商品名称", required = true, example = "芋道")
|
||||
@NotEmpty(message = "商品名称不能为空")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "分类编号", required = true)
|
||||
@NotNull(message = "分类编号不能为空")
|
||||
private Long categoryId;
|
||||
|
||||
@Schema(description = "商品图片的数组", required = true)
|
||||
private List<String> picUrls;
|
||||
@Schema(description = "商品封面图", required = true)
|
||||
private String picUrl;
|
||||
|
||||
@Schema(description = " 最小价格,单位使用:分", required = true, example = "1024")
|
||||
private Integer minPrice;
|
||||
@Schema(description = "商品轮播图", required = true)
|
||||
private List<String> sliderPicUrls;
|
||||
|
||||
@Schema(description = "最大价格,单位使用:分", required = true, example = "1024")
|
||||
private Integer maxPrice;
|
||||
// ========== SKU 相关字段 =========
|
||||
|
||||
@Schema(description = "规格类型", required = true, example = "true")
|
||||
private Boolean specType;
|
||||
|
||||
@Schema(description = "商品价格,单位使用:分", required = true, example = "1024")
|
||||
private Integer price;
|
||||
|
||||
@Schema(description = "库存", required = true, example = "666")
|
||||
private Integer stock;
|
||||
|
||||
// ========== 统计相关字段 =========
|
||||
|
||||
@Schema(description = "商品销量", example = "1024")
|
||||
@Schema(description = "商品销量", required = true, example = "1024")
|
||||
private Integer salesCount;
|
||||
|
||||
}
|
||||
|
@@ -19,18 +19,23 @@ public class AppProductSpuPageReqVO extends PageParam {
|
||||
public static final String SORT_FIELD_PRICE = "price";
|
||||
public static final String SORT_FIELD_SALES_COUNT = "salesCount";
|
||||
|
||||
public static final String RECOMMEND_TYPE_HOT = "hot";
|
||||
|
||||
@Schema(description = "分类编号", example = "1")
|
||||
private Long categoryId;
|
||||
|
||||
@Schema(description = "关键字", example = "好看")
|
||||
private String keyword;
|
||||
|
||||
@Schema(description = "排序字段", example = "price") // 参见 AppSpuPageReqVO.SORT_FIELD_XXX 常量
|
||||
@Schema(description = "排序字段", example = "price") // 参见 AppProductSpuPageReqVO.SORT_FIELD_XXX 常量
|
||||
private String sortField;
|
||||
|
||||
@Schema(description = "排序方式", example = "true")
|
||||
private Boolean sortAsc;
|
||||
|
||||
@Schema(description = "推荐类型", example = "hot") // 参见 AppProductSpuPageReqVO.RECOMMEND_TYPE_XXX 常亮
|
||||
private String recommendType;
|
||||
|
||||
@AssertTrue(message = "排序字段不合法")
|
||||
@JsonIgnore
|
||||
public boolean isSortFieldValid() {
|
||||
|
@@ -34,7 +34,7 @@ public interface ProductSpuConvert {
|
||||
ProductSpuConvert INSTANCE = Mappers.getMapper(ProductSpuConvert.class);
|
||||
|
||||
ProductSpuDO convert(ProductSpuCreateReqVO bean);
|
||||
|
||||
// TODO 还是使用convert,重命名改动太多
|
||||
ProductSpuDO convert(ProductSpuUpdateReqVO bean);
|
||||
|
||||
List<ProductSpuDO> convertList(List<ProductSpuDO> list);
|
||||
@@ -47,36 +47,6 @@ public interface ProductSpuConvert {
|
||||
|
||||
List<ProductSpuSimpleRespVO> convertList02(List<ProductSpuDO> list);
|
||||
|
||||
default AppProductSpuDetailRespVO convert(ProductSpuDO spu, List<ProductSkuDO> skus,
|
||||
List<ProductPropertyValueDetailRespBO> propertyValues) {
|
||||
AppProductSpuDetailRespVO spuVO = convert02(spu)
|
||||
.setSalesCount(spu.getSalesCount() + defaultIfNull(spu.getVirtualSalesCount(), 0));
|
||||
spuVO.setSkus(convertList03(skus));
|
||||
// 处理商品属性
|
||||
Map<Long, ProductPropertyValueDetailRespBO> propertyValueMap = convertMap(propertyValues, ProductPropertyValueDetailRespBO::getValueId);
|
||||
for (int i = 0; i < skus.size(); i++) {
|
||||
List<ProductSkuDO.Property> properties = skus.get(i).getProperties();
|
||||
if (CollUtil.isEmpty(properties)) {
|
||||
continue;
|
||||
}
|
||||
AppProductSpuDetailRespVO.Sku sku = spuVO.getSkus().get(i);
|
||||
sku.setProperties(new ArrayList<>(properties.size()));
|
||||
// 遍历每个 properties,设置到 AppSpuDetailRespVO.Sku 中
|
||||
properties.forEach(property -> {
|
||||
ProductPropertyValueDetailRespBO propertyValue = propertyValueMap.get(property.getValueId());
|
||||
if (propertyValue == null) {
|
||||
return;
|
||||
}
|
||||
sku.getProperties().add(convert03(propertyValue));
|
||||
});
|
||||
}
|
||||
return spuVO;
|
||||
}
|
||||
AppProductSpuDetailRespVO convert02(ProductSpuDO spu);
|
||||
List<AppProductSpuDetailRespVO.Sku> convertList03(List<ProductSkuDO> skus);
|
||||
AppProductPropertyValueDetailRespVO convert03(ProductPropertyValueDetailRespBO propertyValue);
|
||||
|
||||
PageResult<AppProductSpuPageItemRespVO> convertPage02(PageResult<ProductSpuDO> page);
|
||||
|
||||
default ProductSpuDetailRespVO convert03(ProductSpuDO spu, List<ProductSkuDO> skus,
|
||||
List<ProductPropertyValueDetailRespBO> propertyValues) {
|
||||
@@ -106,4 +76,43 @@ public interface ProductSpuConvert {
|
||||
List<ProductSkuRespVO> convertList04(List<ProductSkuDO> skus);
|
||||
ProductPropertyValueDetailRespVO convert04(ProductPropertyValueDetailRespBO propertyValue);
|
||||
|
||||
// ========== 用户 App 相关 ==========
|
||||
|
||||
default PageResult<AppProductSpuPageItemRespVO> convertPageForGetSpuPage(PageResult<ProductSpuDO> page) {
|
||||
// 累加虚拟销量
|
||||
page.getList().forEach(spu -> spu.setSalesCount(spu.getSalesCount() + spu.getVirtualSalesCount()));
|
||||
// 然后进行转换
|
||||
return convertPageForGetSpuPage0(page);
|
||||
}
|
||||
PageResult<AppProductSpuPageItemRespVO> convertPageForGetSpuPage0(PageResult<ProductSpuDO> page);
|
||||
|
||||
default AppProductSpuDetailRespVO convertForGetSpuDetail(ProductSpuDO spu, List<ProductSkuDO> skus,
|
||||
List<ProductPropertyValueDetailRespBO> propertyValues) {
|
||||
AppProductSpuDetailRespVO spuVO = convertForGetSpuDetail(spu)
|
||||
.setSalesCount(spu.getSalesCount() + defaultIfNull(spu.getVirtualSalesCount(), 0));
|
||||
spuVO.setSkus(convertListForGetSpuDetail(skus));
|
||||
// 处理商品属性
|
||||
Map<Long, ProductPropertyValueDetailRespBO> propertyValueMap = convertMap(propertyValues, ProductPropertyValueDetailRespBO::getValueId);
|
||||
for (int i = 0; i < skus.size(); i++) {
|
||||
List<ProductSkuDO.Property> properties = skus.get(i).getProperties();
|
||||
if (CollUtil.isEmpty(properties)) {
|
||||
continue;
|
||||
}
|
||||
AppProductSpuDetailRespVO.Sku sku = spuVO.getSkus().get(i);
|
||||
sku.setProperties(new ArrayList<>(properties.size()));
|
||||
// 遍历每个 properties,设置到 AppSpuDetailRespVO.Sku 中
|
||||
properties.forEach(property -> {
|
||||
ProductPropertyValueDetailRespBO propertyValue = propertyValueMap.get(property.getValueId());
|
||||
if (propertyValue == null) {
|
||||
return;
|
||||
}
|
||||
sku.getProperties().add(convertForGetSpuDetail(propertyValue));
|
||||
});
|
||||
}
|
||||
return spuVO;
|
||||
}
|
||||
AppProductSpuDetailRespVO convertForGetSpuDetail(ProductSpuDO spu);
|
||||
List<AppProductSpuDetailRespVO.Sku> convertListForGetSpuDetail(List<ProductSkuDO> skus);
|
||||
AppProductPropertyValueDetailRespVO convertForGetSpuDetail(ProductPropertyValueDetailRespBO propertyValue);
|
||||
|
||||
}
|
||||
|
@@ -110,12 +110,29 @@ public class ProductSkuDO extends TenantBaseDO {
|
||||
* 关联 {@link ProductPropertyDO#getId()}
|
||||
*/
|
||||
private Long propertyId;
|
||||
///**
|
||||
// * 属性名字
|
||||
// *
|
||||
// * 冗余 {@link ProductPropertyDO#getName()}
|
||||
// *
|
||||
// * 注意:每次属性名字发生变化时,需要更新该冗余
|
||||
// */ TODO 与已有代码逻辑存在冲突
|
||||
//private String propertyName;
|
||||
|
||||
/**
|
||||
* 属性值编号
|
||||
*
|
||||
* 关联 {@link ProductPropertyValueDO#getId()}
|
||||
*/
|
||||
private Long valueId;
|
||||
///**
|
||||
// * 属性值名字
|
||||
// *
|
||||
// * 冗余 {@link ProductPropertyValueDO#getName()}
|
||||
// *
|
||||
// * 注意:每次属性值名字发生变化时,需要更新该冗余
|
||||
// */ TODO 与已有代码逻辑存在冲突
|
||||
//private String valueName;
|
||||
|
||||
}
|
||||
|
||||
@@ -140,9 +157,5 @@ public class ProductSkuDO extends TenantBaseDO {
|
||||
// TODO 芋艿:pinkStock from y
|
||||
// TODO 芋艿:seckillStock from y
|
||||
|
||||
// TODO 芋艿:quota from c
|
||||
// TODO 芋艿:quotaShow from c
|
||||
// TODO 芋艿:attrValue from c
|
||||
|
||||
}
|
||||
|
||||
|
@@ -68,6 +68,7 @@ public class ProductPropertyServiceImpl implements ProductPropertyService {
|
||||
// 更新
|
||||
ProductPropertyDO updateObj = ProductPropertyConvert.INSTANCE.convert(updateReqVO);
|
||||
productPropertyMapper.updateById(updateObj);
|
||||
// TODO 芋艿:更新时,需要看看 sku 表
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -68,6 +68,7 @@ public class ProductPropertyValueServiceImpl implements ProductPropertyValueServ
|
||||
// 更新
|
||||
ProductPropertyValueDO updateObj = ProductPropertyValueConvert.INSTANCE.convert(updateReqVO);
|
||||
productPropertyValueMapper.updateById(updateObj);
|
||||
// TODO 芋艿:更新时,需要看看 sku 表
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -169,7 +169,7 @@ public class ProductSkuServiceImpl implements ProductSkuService {
|
||||
// 拆分三个集合,新插入的、需要更新的、需要删除的
|
||||
List<ProductSkuDO> insertSkus = new ArrayList<>();
|
||||
List<ProductSkuDO> updateSkus = new ArrayList<>();
|
||||
List<ProductSkuDO> allUpdateSkus = ProductSkuConvert.INSTANCE.convertList06(skus, null);
|
||||
List<ProductSkuDO> allUpdateSkus = ProductSkuConvert.INSTANCE.convertList06(skus, spuId);
|
||||
allUpdateSkus.forEach(sku -> {
|
||||
String propertiesKey = ProductSkuConvert.INSTANCE.buildPropertyKey(sku);
|
||||
// 1、找得到的,进行更新
|
||||
|
@@ -54,12 +54,18 @@ public class ProductSkuServiceTest extends BaseDbUnitTest {
|
||||
// mock 数据
|
||||
ProductSkuDO sku01 = randomPojo(ProductSkuDO.class, o -> { // 测试更新
|
||||
o.setSpuId(1L);
|
||||
o.setProperties(singletonList(new ProductSkuDO.Property(10L, 20L)));
|
||||
//o.setProperties(singletonList(new ProductSkuDO.Property(
|
||||
// 10L, "颜色", 20L, "红色"))); TODO 新增字段已注释
|
||||
o.setProperties(singletonList(new ProductSkuDO.Property(
|
||||
10L, 20L)));
|
||||
});
|
||||
productSkuMapper.insert(sku01);
|
||||
ProductSkuDO sku02 = randomPojo(ProductSkuDO.class, o -> { // 测试删除
|
||||
o.setSpuId(1L);
|
||||
o.setProperties(singletonList(new ProductSkuDO.Property(10L, 30L)));
|
||||
//o.setProperties(singletonList(new ProductSkuDO.Property(
|
||||
// 10L, "颜色", 30L, "蓝色"))); TODO 新增字段已注释
|
||||
o.setProperties(singletonList(new ProductSkuDO.Property(
|
||||
10L, 30L)));
|
||||
});
|
||||
productSkuMapper.insert(sku02);
|
||||
// 准备参数
|
||||
|
Reference in New Issue
Block a user