✨ MALL:调整商品 SPU 字段,简化部分接口
This commit is contained in:
parent
722b33513c
commit
fe5c5e4223
|
@ -7,7 +7,6 @@ package cn.iocoder.yudao.module.product.enums;
|
||||||
*/
|
*/
|
||||||
public interface DictTypeConstants {
|
public interface DictTypeConstants {
|
||||||
|
|
||||||
String PRODUCT_UNIT = "product_unit"; // 商品单位
|
|
||||||
String PRODUCT_SPU_STATUS = "product_spu_status"; // 商品 SPU 状态
|
String PRODUCT_SPU_STATUS = "product_spu_status"; // 商品 SPU 状态
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,28 +1,22 @@
|
||||||
package cn.iocoder.yudao.module.product.controller.admin.property;
|
package cn.iocoder.yudao.module.product.controller.admin.property;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
|
||||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
import cn.iocoder.yudao.module.product.controller.admin.property.vo.property.*;
|
import cn.iocoder.yudao.module.product.controller.admin.property.vo.property.*;
|
||||||
import cn.iocoder.yudao.module.product.convert.property.ProductPropertyConvert;
|
import cn.iocoder.yudao.module.product.convert.property.ProductPropertyConvert;
|
||||||
import cn.iocoder.yudao.module.product.dal.dataobject.property.ProductPropertyDO;
|
|
||||||
import cn.iocoder.yudao.module.product.dal.dataobject.property.ProductPropertyValueDO;
|
|
||||||
import cn.iocoder.yudao.module.product.service.property.ProductPropertyService;
|
import cn.iocoder.yudao.module.product.service.property.ProductPropertyService;
|
||||||
import cn.iocoder.yudao.module.product.service.property.ProductPropertyValueService;
|
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import io.swagger.v3.oas.annotations.Parameter;
|
import io.swagger.v3.oas.annotations.Parameter;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import jakarta.annotation.Resource;
|
||||||
|
import jakarta.validation.Valid;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import jakarta.annotation.Resource;
|
|
||||||
import jakarta.validation.Valid;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
|
|
||||||
|
|
||||||
@Tag(name = "管理后台 - 商品属性项")
|
@Tag(name = "管理后台 - 商品属性项")
|
||||||
@RestController
|
@RestController
|
||||||
|
@ -32,8 +26,6 @@ public class ProductPropertyController {
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private ProductPropertyService productPropertyService;
|
private ProductPropertyService productPropertyService;
|
||||||
@Resource
|
|
||||||
private ProductPropertyValueService productPropertyValueService;
|
|
||||||
|
|
||||||
@PostMapping("/create")
|
@PostMapping("/create")
|
||||||
@Operation(summary = "创建属性项")
|
@Operation(summary = "创建属性项")
|
||||||
|
@ -81,20 +73,4 @@ public class ProductPropertyController {
|
||||||
return success(ProductPropertyConvert.INSTANCE.convertPage(productPropertyService.getPropertyPage(pageVO)));
|
return success(ProductPropertyConvert.INSTANCE.convertPage(productPropertyService.getPropertyPage(pageVO)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/get-value-list")
|
|
||||||
@Operation(summary = "获得属性项列表")
|
|
||||||
@PreAuthorize("@ss.hasPermission('product:property:query')")
|
|
||||||
public CommonResult<List<ProductPropertyAndValueRespVO>> getPropertyAndValueList(
|
|
||||||
@Valid @RequestBody ProductPropertyListReqVO listReqVO) {
|
|
||||||
// 查询属性项
|
|
||||||
List<ProductPropertyDO> keys = productPropertyService.getPropertyList(listReqVO);
|
|
||||||
if (CollUtil.isEmpty(keys)) {
|
|
||||||
return success(Collections.emptyList());
|
|
||||||
}
|
|
||||||
// 查询属性值
|
|
||||||
List<ProductPropertyValueDO> values = productPropertyValueService.getPropertyValueListByPropertyId(
|
|
||||||
convertSet(keys, ProductPropertyDO::getId));
|
|
||||||
return success(ProductPropertyConvert.INSTANCE.convertList(keys, values));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,35 +0,0 @@
|
||||||
package cn.iocoder.yudao.module.product.controller.admin.property.vo.property;
|
|
||||||
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Schema(description = "管理后台 - 商品属性项 + 属性值 Response VO")
|
|
||||||
@Data
|
|
||||||
public class ProductPropertyAndValueRespVO {
|
|
||||||
|
|
||||||
@Schema(description = "属性项的编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
|
||||||
private Long id;
|
|
||||||
|
|
||||||
@Schema(description = "属性项的名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "颜色")
|
|
||||||
private String name;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 属性值的集合
|
|
||||||
*/
|
|
||||||
private List<Value> values;
|
|
||||||
|
|
||||||
@Schema(description = "管理后台 - 属性值的简单 Response VO")
|
|
||||||
@Data
|
|
||||||
public static class Value {
|
|
||||||
|
|
||||||
@Schema(description = "属性值的编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2048")
|
|
||||||
private Long id;
|
|
||||||
|
|
||||||
@Schema(description = "属性值的名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "红色")
|
|
||||||
private String name;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -47,13 +47,6 @@ public class ProductSpuBaseVO {
|
||||||
@Schema(description = "商品轮播图", requiredMode = Schema.RequiredMode.REQUIRED, example = "[https://www.iocoder.cn/xx.png, https://www.iocoder.cn/xxx.png]")
|
@Schema(description = "商品轮播图", requiredMode = Schema.RequiredMode.REQUIRED, example = "[https://www.iocoder.cn/xx.png, https://www.iocoder.cn/xxx.png]")
|
||||||
private List<String> sliderPicUrls;
|
private List<String> sliderPicUrls;
|
||||||
|
|
||||||
@Schema(description = "商品视频", example = "https://www.iocoder.cn/xx.mp4")
|
|
||||||
private String videoUrl;
|
|
||||||
|
|
||||||
@Schema(description = "单位", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
|
||||||
@NotNull(message = "商品单位不能为空")
|
|
||||||
private Integer unit;
|
|
||||||
|
|
||||||
@Schema(description = "排序字段", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
@Schema(description = "排序字段", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||||
@NotNull(message = "商品排序字段不能为空")
|
@NotNull(message = "商品排序字段不能为空")
|
||||||
private Integer sort;
|
private Integer sort;
|
||||||
|
@ -66,32 +59,16 @@ public class ProductSpuBaseVO {
|
||||||
|
|
||||||
// ========== 物流相关字段 =========
|
// ========== 物流相关字段 =========
|
||||||
|
|
||||||
|
@Schema(description = "配送方式数组", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||||
|
@NotEmpty(message = "配送方式不能为空")
|
||||||
|
private List<Integer> deliveryTypes;
|
||||||
|
|
||||||
@Schema(description = "物流配置模板编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "111")
|
@Schema(description = "物流配置模板编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "111")
|
||||||
@NotNull(message = "物流配置模板编号不能为空")
|
@NotNull(message = "物流配置模板编号不能为空")
|
||||||
private Long deliveryTemplateId;
|
private Long deliveryTemplateId;
|
||||||
|
|
||||||
// ========== 营销相关字段 =========
|
// ========== 营销相关字段 =========
|
||||||
|
|
||||||
@Schema(description = "是否热卖推荐", requiredMode = Schema.RequiredMode.REQUIRED, example = "true")
|
|
||||||
@NotNull(message = "商品推荐不能为空")
|
|
||||||
private Boolean recommendHot;
|
|
||||||
|
|
||||||
@Schema(description = "是否优惠推荐", requiredMode = Schema.RequiredMode.REQUIRED, example = "true")
|
|
||||||
@NotNull(message = "商品推荐不能为空")
|
|
||||||
private Boolean recommendBenefit;
|
|
||||||
|
|
||||||
@Schema(description = "是否精品推荐", requiredMode = Schema.RequiredMode.REQUIRED, example = "true")
|
|
||||||
@NotNull(message = "商品推荐不能为空")
|
|
||||||
private Boolean recommendBest;
|
|
||||||
|
|
||||||
@Schema(description = "是否新品推荐", requiredMode = Schema.RequiredMode.REQUIRED, example = "true")
|
|
||||||
@NotNull(message = "商品推荐不能为空")
|
|
||||||
private Boolean recommendNew;
|
|
||||||
|
|
||||||
@Schema(description = "是否优品推荐", requiredMode = Schema.RequiredMode.REQUIRED, example = "true")
|
|
||||||
@NotNull(message = "商品推荐不能为空")
|
|
||||||
private Boolean recommendGood;
|
|
||||||
|
|
||||||
@Schema(description = "赠送积分", requiredMode = Schema.RequiredMode.REQUIRED, example = "111")
|
@Schema(description = "赠送积分", requiredMode = Schema.RequiredMode.REQUIRED, example = "111")
|
||||||
@NotNull(message = "商品赠送积分不能为空")
|
@NotNull(message = "商品赠送积分不能为空")
|
||||||
private Integer giveIntegral;
|
private Integer giveIntegral;
|
||||||
|
@ -100,9 +77,6 @@ public class ProductSpuBaseVO {
|
||||||
@NotNull(message = "商品分销类型不能为空")
|
@NotNull(message = "商品分销类型不能为空")
|
||||||
private Boolean subCommissionType;
|
private Boolean subCommissionType;
|
||||||
|
|
||||||
@Schema(description = "活动展示顺序", example = "[1, 3, 2, 4, 5]")
|
|
||||||
private List<Integer> activityOrders;
|
|
||||||
|
|
||||||
// ========== 统计相关字段 =========
|
// ========== 统计相关字段 =========
|
||||||
|
|
||||||
@Schema(description = "虚拟销量", example = "66")
|
@Schema(description = "虚拟销量", example = "66")
|
||||||
|
|
|
@ -44,13 +44,6 @@ public class ProductSpuExcelVO {
|
||||||
@ExcelProperty("商品封面图")
|
@ExcelProperty("商品封面图")
|
||||||
private String picUrl;
|
private String picUrl;
|
||||||
|
|
||||||
@ExcelProperty("商品视频")
|
|
||||||
private String videoUrl;
|
|
||||||
|
|
||||||
@ExcelProperty(value = "商品单位", converter = DictConvert.class)
|
|
||||||
@DictFormat(DictTypeConstants.PRODUCT_UNIT)
|
|
||||||
private Integer unit;
|
|
||||||
|
|
||||||
@ExcelProperty("排序字段")
|
@ExcelProperty("排序字段")
|
||||||
private Integer sort;
|
private Integer sort;
|
||||||
|
|
||||||
|
@ -76,21 +69,6 @@ public class ProductSpuExcelVO {
|
||||||
@ExcelProperty("物流配置模板编号")
|
@ExcelProperty("物流配置模板编号")
|
||||||
private Long deliveryTemplateId;
|
private Long deliveryTemplateId;
|
||||||
|
|
||||||
@ExcelProperty("是否热卖推荐")
|
|
||||||
private Boolean recommendHot;
|
|
||||||
|
|
||||||
@ExcelProperty("是否优惠推荐")
|
|
||||||
private Boolean recommendBenefit;
|
|
||||||
|
|
||||||
@ExcelProperty("是否精品推荐")
|
|
||||||
private Boolean recommendBest;
|
|
||||||
|
|
||||||
@ExcelProperty("是否新品推荐")
|
|
||||||
private Boolean recommendNew;
|
|
||||||
|
|
||||||
@ExcelProperty("是否优品推荐")
|
|
||||||
private Boolean recommendGood;
|
|
||||||
|
|
||||||
@ExcelProperty("赠送积分")
|
@ExcelProperty("赠送积分")
|
||||||
private Integer giveIntegral;
|
private Integer giveIntegral;
|
||||||
|
|
||||||
|
|
|
@ -33,17 +33,8 @@ public class AppProductSpuDetailRespVO {
|
||||||
@Schema(description = "商品轮播图", requiredMode = Schema.RequiredMode.REQUIRED)
|
@Schema(description = "商品轮播图", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
private List<String> sliderPicUrls;
|
private List<String> sliderPicUrls;
|
||||||
|
|
||||||
@Schema(description = "商品视频", requiredMode = Schema.RequiredMode.REQUIRED)
|
|
||||||
private String videoUrl;
|
|
||||||
|
|
||||||
@Schema(description = "单位名", requiredMode = Schema.RequiredMode.REQUIRED, example = "个")
|
|
||||||
private String unitName;
|
|
||||||
|
|
||||||
// ========== 营销相关字段 =========
|
// ========== 营销相关字段 =========
|
||||||
|
|
||||||
@Schema(description = "活动排序数组", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
|
||||||
private List<Integer> activityOrders;
|
|
||||||
|
|
||||||
// ========== SKU 相关字段 =========
|
// ========== SKU 相关字段 =========
|
||||||
|
|
||||||
@Schema(description = "规格类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "true")
|
@Schema(description = "规格类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "true")
|
||||||
|
|
|
@ -27,9 +27,6 @@ public class AppProductSpuPageRespVO {
|
||||||
@Schema(description = "商品轮播图", requiredMode = Schema.RequiredMode.REQUIRED)
|
@Schema(description = "商品轮播图", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
private List<String> sliderPicUrls;
|
private List<String> sliderPicUrls;
|
||||||
|
|
||||||
@Schema(description = "单位名", requiredMode = Schema.RequiredMode.REQUIRED, example = "个")
|
|
||||||
private String unitName;
|
|
||||||
|
|
||||||
// ========== SKU 相关字段 =========
|
// ========== SKU 相关字段 =========
|
||||||
|
|
||||||
@Schema(description = "规格类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "true")
|
@Schema(description = "规格类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "true")
|
||||||
|
@ -43,15 +40,12 @@ public class AppProductSpuPageRespVO {
|
||||||
|
|
||||||
@Schema(description = "VIP 价格,单位使用:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "968") // 通过会员等级,计算出折扣后价格
|
@Schema(description = "VIP 价格,单位使用:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "968") // 通过会员等级,计算出折扣后价格
|
||||||
private Integer vipPrice;
|
private Integer vipPrice;
|
||||||
|
|
||||||
@Schema(description = "库存", requiredMode = Schema.RequiredMode.REQUIRED, example = "666")
|
@Schema(description = "库存", requiredMode = Schema.RequiredMode.REQUIRED, example = "666")
|
||||||
private Integer stock;
|
private Integer stock;
|
||||||
|
|
||||||
// ========== 营销相关字段 =========
|
// ========== 营销相关字段 =========
|
||||||
|
|
||||||
@Schema(description = "活动排序数组", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
|
||||||
private List<Integer> activityOrders;
|
|
||||||
|
|
||||||
// ========== 统计相关字段 =========
|
// ========== 统计相关字段 =========
|
||||||
|
|
||||||
@Schema(description = "商品销量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
@Schema(description = "商品销量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||||
|
|
|
@ -1,22 +1,14 @@
|
||||||
package cn.iocoder.yudao.module.product.convert.property;
|
package cn.iocoder.yudao.module.product.convert.property;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
|
||||||
import cn.iocoder.yudao.module.product.controller.admin.property.vo.property.ProductPropertyAndValueRespVO;
|
|
||||||
import cn.iocoder.yudao.module.product.controller.admin.property.vo.property.ProductPropertyCreateReqVO;
|
import cn.iocoder.yudao.module.product.controller.admin.property.vo.property.ProductPropertyCreateReqVO;
|
||||||
import cn.iocoder.yudao.module.product.controller.admin.property.vo.property.ProductPropertyRespVO;
|
import cn.iocoder.yudao.module.product.controller.admin.property.vo.property.ProductPropertyRespVO;
|
||||||
import cn.iocoder.yudao.module.product.controller.admin.property.vo.property.ProductPropertyUpdateReqVO;
|
import cn.iocoder.yudao.module.product.controller.admin.property.vo.property.ProductPropertyUpdateReqVO;
|
||||||
import cn.iocoder.yudao.module.product.dal.dataobject.property.ProductPropertyDO;
|
import cn.iocoder.yudao.module.product.dal.dataobject.property.ProductPropertyDO;
|
||||||
import cn.iocoder.yudao.module.product.dal.dataobject.property.ProductPropertyValueDO;
|
|
||||||
import org.mapstruct.Mapper;
|
import org.mapstruct.Mapper;
|
||||||
import org.mapstruct.factory.Mappers;
|
import org.mapstruct.factory.Mappers;
|
||||||
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 属性项 Convert
|
* 属性项 Convert
|
||||||
|
@ -38,20 +30,4 @@ public interface ProductPropertyConvert {
|
||||||
|
|
||||||
PageResult<ProductPropertyRespVO> convertPage(PageResult<ProductPropertyDO> page);
|
PageResult<ProductPropertyRespVO> convertPage(PageResult<ProductPropertyDO> page);
|
||||||
|
|
||||||
default List<ProductPropertyAndValueRespVO> convertList(List<ProductPropertyDO> keys, List<ProductPropertyValueDO> values) {
|
|
||||||
Map<Long, List<ProductPropertyValueDO>> valueMap = CollectionUtils.convertMultiMap(values, ProductPropertyValueDO::getPropertyId);
|
|
||||||
return CollectionUtils.convertList(keys, key -> {
|
|
||||||
ProductPropertyAndValueRespVO respVO = convert02(key);
|
|
||||||
// 如果属性值为空value不为null,返回空列表
|
|
||||||
if (CollUtil.isEmpty(values)) {
|
|
||||||
respVO.setValues(Collections.emptyList());
|
|
||||||
}else {
|
|
||||||
respVO.setValues(convertList02(valueMap.get(key.getId())));
|
|
||||||
}
|
|
||||||
return respVO;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
ProductPropertyAndValueRespVO convert02(ProductPropertyDO bean);
|
|
||||||
List<ProductPropertyAndValueRespVO.Value> convertList02(List<ProductPropertyValueDO> list);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,6 @@ package cn.iocoder.yudao.module.product.convert.spu;
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
||||||
import cn.iocoder.yudao.framework.dict.core.util.DictFrameworkUtils;
|
|
||||||
import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO;
|
import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO;
|
||||||
import cn.iocoder.yudao.module.product.controller.admin.spu.vo.*;
|
import cn.iocoder.yudao.module.product.controller.admin.spu.vo.*;
|
||||||
import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppProductSpuDetailRespVO;
|
import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppProductSpuDetailRespVO;
|
||||||
|
@ -11,7 +10,6 @@ import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppProductSpuPageRe
|
||||||
import cn.iocoder.yudao.module.product.convert.sku.ProductSkuConvert;
|
import cn.iocoder.yudao.module.product.convert.sku.ProductSkuConvert;
|
||||||
import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO;
|
import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO;
|
||||||
import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO;
|
import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO;
|
||||||
import cn.iocoder.yudao.module.product.enums.DictTypeConstants;
|
|
||||||
import org.mapstruct.Mapper;
|
import org.mapstruct.Mapper;
|
||||||
import org.mapstruct.Mapping;
|
import org.mapstruct.Mapping;
|
||||||
import org.mapstruct.Named;
|
import org.mapstruct.Named;
|
||||||
|
@ -74,13 +72,7 @@ public interface ProductSpuConvert {
|
||||||
// 处理虚拟销量
|
// 处理虚拟销量
|
||||||
list.forEach(spu -> spu.setSalesCount(spu.getSalesCount() + spu.getVirtualSalesCount()));
|
list.forEach(spu -> spu.setSalesCount(spu.getSalesCount() + spu.getVirtualSalesCount()));
|
||||||
// 处理 VO 字段
|
// 处理 VO 字段
|
||||||
List<AppProductSpuPageRespVO> voList = convertListForGetSpuList0(list);
|
return convertListForGetSpuList0(list);
|
||||||
for (int i = 0; i < list.size(); i++) {
|
|
||||||
ProductSpuDO spu = list.get(i);
|
|
||||||
AppProductSpuPageRespVO spuVO = voList.get(i);
|
|
||||||
spuVO.setUnitName(DictFrameworkUtils.getDictDataLabel(DictTypeConstants.PRODUCT_UNIT, spu.getUnit()));
|
|
||||||
}
|
|
||||||
return voList;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Named("convertListForGetSpuList0")
|
@Named("convertListForGetSpuList0")
|
||||||
|
@ -89,8 +81,7 @@ public interface ProductSpuConvert {
|
||||||
default AppProductSpuDetailRespVO convertForGetSpuDetail(ProductSpuDO spu, List<ProductSkuDO> skus) {
|
default AppProductSpuDetailRespVO convertForGetSpuDetail(ProductSpuDO spu, List<ProductSkuDO> skus) {
|
||||||
// 处理 SPU
|
// 处理 SPU
|
||||||
AppProductSpuDetailRespVO spuVO = convertForGetSpuDetail(spu)
|
AppProductSpuDetailRespVO spuVO = convertForGetSpuDetail(spu)
|
||||||
.setSalesCount(spu.getSalesCount() + defaultIfNull(spu.getVirtualSalesCount(), 0))
|
.setSalesCount(spu.getSalesCount() + defaultIfNull(spu.getVirtualSalesCount(), 0));
|
||||||
.setUnitName(DictFrameworkUtils.getDictDataLabel(DictTypeConstants.PRODUCT_UNIT, spu.getUnit()));
|
|
||||||
// 处理 SKU
|
// 处理 SKU
|
||||||
spuVO.setSkus(convertListForGetSpuDetail(skus));
|
spuVO.setSkus(convertListForGetSpuDetail(skus));
|
||||||
return spuVO;
|
return spuVO;
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package cn.iocoder.yudao.module.product.dal.dataobject.spu;
|
package cn.iocoder.yudao.module.product.dal.dataobject.spu;
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||||
|
import cn.iocoder.yudao.framework.mybatis.core.type.IntegerListTypeHandler;
|
||||||
import cn.iocoder.yudao.module.product.dal.dataobject.brand.ProductBrandDO;
|
import cn.iocoder.yudao.module.product.dal.dataobject.brand.ProductBrandDO;
|
||||||
import cn.iocoder.yudao.module.product.dal.dataobject.category.ProductCategoryDO;
|
import cn.iocoder.yudao.module.product.dal.dataobject.category.ProductCategoryDO;
|
||||||
import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO;
|
import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO;
|
||||||
|
@ -80,17 +81,7 @@ public class ProductSpuDO extends BaseDO {
|
||||||
*/
|
*/
|
||||||
@TableField(typeHandler = JacksonTypeHandler.class)
|
@TableField(typeHandler = JacksonTypeHandler.class)
|
||||||
private List<String> sliderPicUrls;
|
private List<String> sliderPicUrls;
|
||||||
/**
|
|
||||||
* 商品视频
|
|
||||||
*/
|
|
||||||
private String videoUrl;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 单位
|
|
||||||
*
|
|
||||||
* 对应 product_unit 数据字典
|
|
||||||
*/
|
|
||||||
private Integer unit;
|
|
||||||
/**
|
/**
|
||||||
* 排序字段
|
* 排序字段
|
||||||
*/
|
*/
|
||||||
|
@ -138,6 +129,13 @@ public class ProductSpuDO extends BaseDO {
|
||||||
|
|
||||||
// ========== 物流相关字段 =========
|
// ========== 物流相关字段 =========
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 配送方式数组
|
||||||
|
*
|
||||||
|
* 对应 DeliveryTypeEnum 枚举
|
||||||
|
*/
|
||||||
|
@TableField(typeHandler = IntegerListTypeHandler.class)
|
||||||
|
private List<Integer> deliveryTypes;
|
||||||
/**
|
/**
|
||||||
* 物流配置模板编号
|
* 物流配置模板编号
|
||||||
*
|
*
|
||||||
|
@ -146,26 +144,6 @@ public class ProductSpuDO extends BaseDO {
|
||||||
private Long deliveryTemplateId;
|
private Long deliveryTemplateId;
|
||||||
|
|
||||||
// ========== 营销相关字段 =========
|
// ========== 营销相关字段 =========
|
||||||
/**
|
|
||||||
* 是否热卖推荐
|
|
||||||
*/
|
|
||||||
private Boolean recommendHot;
|
|
||||||
/**
|
|
||||||
* 是否优惠推荐
|
|
||||||
*/
|
|
||||||
private Boolean recommendBenefit;
|
|
||||||
/**
|
|
||||||
* 是否精品推荐
|
|
||||||
*/
|
|
||||||
private Boolean recommendBest;
|
|
||||||
/**
|
|
||||||
* 是否新品推荐
|
|
||||||
*/
|
|
||||||
private Boolean recommendNew;
|
|
||||||
/**
|
|
||||||
* 是否优品推荐
|
|
||||||
*/
|
|
||||||
private Boolean recommendGood;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 赠送积分
|
* 赠送积分
|
||||||
|
@ -188,14 +166,6 @@ public class ProductSpuDO extends BaseDO {
|
||||||
*/
|
*/
|
||||||
private Boolean subCommissionType;
|
private Boolean subCommissionType;
|
||||||
|
|
||||||
/**
|
|
||||||
* 活动展示顺序
|
|
||||||
*
|
|
||||||
* 对应 PromotionTypeEnum 枚举
|
|
||||||
*/
|
|
||||||
@TableField(typeHandler = JacksonTypeHandler.class)
|
|
||||||
private List<Integer> activityOrders; // TODO @芋艿: 活动顺序字段长度需要增加
|
|
||||||
|
|
||||||
// ========== 统计相关字段 =========
|
// ========== 统计相关字段 =========
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -64,18 +64,6 @@ public interface ProductSpuMapper extends BaseMapperX<ProductSpuDO> {
|
||||||
.inIfPresent(ProductSpuDO::getCategoryId, categoryIds);
|
.inIfPresent(ProductSpuDO::getCategoryId, categoryIds);
|
||||||
// 上架状态 且有库存
|
// 上架状态 且有库存
|
||||||
query.eq(ProductSpuDO::getStatus, ProductSpuStatusEnum.ENABLE.getStatus());
|
query.eq(ProductSpuDO::getStatus, ProductSpuStatusEnum.ENABLE.getStatus());
|
||||||
// 推荐类型的过滤条件
|
|
||||||
if (ObjUtil.equal(pageReqVO.getRecommendType(), AppProductSpuPageReqVO.RECOMMEND_TYPE_HOT)) {
|
|
||||||
query.eq(ProductSpuDO::getRecommendHot, true);
|
|
||||||
} else if (ObjUtil.equal(pageReqVO.getRecommendType(), AppProductSpuPageReqVO.RECOMMEND_TYPE_BENEFIT)) {
|
|
||||||
query.eq(ProductSpuDO::getRecommendBenefit, true);
|
|
||||||
} else if (ObjUtil.equal(pageReqVO.getRecommendType(), AppProductSpuPageReqVO.RECOMMEND_TYPE_BEST)) {
|
|
||||||
query.eq(ProductSpuDO::getRecommendBest, true);
|
|
||||||
} else if (ObjUtil.equal(pageReqVO.getRecommendType(), AppProductSpuPageReqVO.RECOMMEND_TYPE_NEW)) {
|
|
||||||
query.eq(ProductSpuDO::getRecommendNew, true);
|
|
||||||
} else if (ObjUtil.equal(pageReqVO.getRecommendType(), AppProductSpuPageReqVO.RECOMMEND_TYPE_GOOD)) {
|
|
||||||
query.eq(ProductSpuDO::getRecommendGood, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 排序逻辑
|
// 排序逻辑
|
||||||
if (Objects.equals(pageReqVO.getSortField(), AppProductSpuPageReqVO.SORT_FIELD_SALES_COUNT)) {
|
if (Objects.equals(pageReqVO.getSortField(), AppProductSpuPageReqVO.SORT_FIELD_SALES_COUNT)) {
|
||||||
|
|
|
@ -152,8 +152,8 @@ public class ProductCategoryServiceImplTest extends BaseDbUnitTest {
|
||||||
reqVO.setParentId(PARENT_ID_NULL);
|
reqVO.setParentId(PARENT_ID_NULL);
|
||||||
|
|
||||||
// 调用
|
// 调用
|
||||||
List<ProductCategoryDO> list = productCategoryService.getEnableCategoryList(reqVO);
|
List<ProductCategoryDO> list = productCategoryService.getCategoryList(reqVO);
|
||||||
List<ProductCategoryDO> all = productCategoryService.getEnableCategoryList(new ProductCategoryListReqVO());
|
List<ProductCategoryDO> all = productCategoryService.getCategoryList(new ProductCategoryListReqVO());
|
||||||
// 断言
|
// 断言
|
||||||
assertEquals(1, list.size());
|
assertEquals(1, list.size());
|
||||||
assertEquals(4, all.size());
|
assertEquals(4, all.size());
|
||||||
|
|
|
@ -103,11 +103,9 @@ public class ProductSpuServiceImplTest extends BaseDbUnitTest {
|
||||||
ProductSpuCreateReqVO createReqVO = randomPojo(ProductSpuCreateReqVO.class,o->{
|
ProductSpuCreateReqVO createReqVO = randomPojo(ProductSpuCreateReqVO.class,o->{
|
||||||
o.setCategoryId(generateId());
|
o.setCategoryId(generateId());
|
||||||
o.setBrandId(generateId());
|
o.setBrandId(generateId());
|
||||||
o.setUnit(RandomUtil.randomInt(1,20)); // 限制商品单位范围
|
|
||||||
o.setSort(RandomUtil.randomInt(1,100)); // 限制排序范围
|
o.setSort(RandomUtil.randomInt(1,100)); // 限制排序范围
|
||||||
o.setGiveIntegral(generaInt()); // 限制范围为正整数
|
o.setGiveIntegral(generaInt()); // 限制范围为正整数
|
||||||
o.setVirtualSalesCount(generaInt()); // 限制范围为正整数
|
o.setVirtualSalesCount(generaInt()); // 限制范围为正整数
|
||||||
o.setActivityOrders(newArrayList(1,3,2,4,5)); // 活动排序
|
|
||||||
o.setSkus(newArrayList(skuCreateOrUpdateReqVO,skuCreateOrUpdateReqVO,skuCreateOrUpdateReqVO));
|
o.setSkus(newArrayList(skuCreateOrUpdateReqVO,skuCreateOrUpdateReqVO,skuCreateOrUpdateReqVO));
|
||||||
});
|
});
|
||||||
when(categoryService.getCategoryLevel(eq(createReqVO.getCategoryId()))).thenReturn(2);
|
when(categoryService.getCategoryLevel(eq(createReqVO.getCategoryId()))).thenReturn(2);
|
||||||
|
@ -123,11 +121,9 @@ public class ProductSpuServiceImplTest extends BaseDbUnitTest {
|
||||||
o.setCategoryId(generateId());
|
o.setCategoryId(generateId());
|
||||||
o.setBrandId(generateId());
|
o.setBrandId(generateId());
|
||||||
o.setDeliveryTemplateId(generateId());
|
o.setDeliveryTemplateId(generateId());
|
||||||
o.setUnit(RandomUtil.randomInt(1,20)); // 限制商品单位范围
|
|
||||||
o.setSort(RandomUtil.randomInt(1,100)); // 限制排序范围
|
o.setSort(RandomUtil.randomInt(1,100)); // 限制排序范围
|
||||||
o.setGiveIntegral(generaInt()); // 限制范围为正整数
|
o.setGiveIntegral(generaInt()); // 限制范围为正整数
|
||||||
o.setVirtualSalesCount(generaInt()); // 限制范围为正整数
|
o.setVirtualSalesCount(generaInt()); // 限制范围为正整数
|
||||||
o.setActivityOrders(newArrayList(1,3,2,4,5)); // 活动排序
|
|
||||||
o.setPrice(generaInt()); // 限制范围为正整数
|
o.setPrice(generaInt()); // 限制范围为正整数
|
||||||
o.setMarketPrice(generaInt()); // 限制范围为正整数
|
o.setMarketPrice(generaInt()); // 限制范围为正整数
|
||||||
o.setCostPrice(generaInt()); // 限制范围为正整数
|
o.setCostPrice(generaInt()); // 限制范围为正整数
|
||||||
|
@ -156,11 +152,9 @@ public class ProductSpuServiceImplTest extends BaseDbUnitTest {
|
||||||
o.setId(createReqVO.getId()); // 设置更新的 ID
|
o.setId(createReqVO.getId()); // 设置更新的 ID
|
||||||
o.setCategoryId(generateId());
|
o.setCategoryId(generateId());
|
||||||
o.setBrandId(generateId());
|
o.setBrandId(generateId());
|
||||||
o.setUnit(RandomUtil.randomInt(1,20)); // 限制商品单位范围
|
|
||||||
o.setSort(RandomUtil.randomInt(1,100)); // 限制排序范围
|
o.setSort(RandomUtil.randomInt(1,100)); // 限制排序范围
|
||||||
o.setGiveIntegral(generaInt()); // 限制范围为正整数
|
o.setGiveIntegral(generaInt()); // 限制范围为正整数
|
||||||
o.setVirtualSalesCount(generaInt()); // 限制范围为正整数
|
o.setVirtualSalesCount(generaInt()); // 限制范围为正整数
|
||||||
o.setActivityOrders(newArrayList(1,3,2,4,5)); // 活动排序
|
|
||||||
o.setGiveIntegral(generaInt()); // 限制范围为正整数
|
o.setGiveIntegral(generaInt()); // 限制范围为正整数
|
||||||
o.setSalesCount(generaInt()); // 限制范围为正整数
|
o.setSalesCount(generaInt()); // 限制范围为正整数
|
||||||
o.setBrowseCount(generaInt()); // 限制范围为正整数
|
o.setBrowseCount(generaInt()); // 限制范围为正整数
|
||||||
|
@ -189,11 +183,9 @@ public class ProductSpuServiceImplTest extends BaseDbUnitTest {
|
||||||
o.setCategoryId(generateId());
|
o.setCategoryId(generateId());
|
||||||
o.setBrandId(generateId());
|
o.setBrandId(generateId());
|
||||||
o.setDeliveryTemplateId(generateId());
|
o.setDeliveryTemplateId(generateId());
|
||||||
o.setUnit(RandomUtil.randomInt(1,20)); // 限制商品单位范围
|
|
||||||
o.setSort(RandomUtil.randomInt(1,100)); // 限制排序范围
|
o.setSort(RandomUtil.randomInt(1,100)); // 限制排序范围
|
||||||
o.setGiveIntegral(generaInt()); // 限制范围为正整数
|
o.setGiveIntegral(generaInt()); // 限制范围为正整数
|
||||||
o.setVirtualSalesCount(generaInt()); // 限制范围为正整数
|
o.setVirtualSalesCount(generaInt()); // 限制范围为正整数
|
||||||
o.setActivityOrders(newArrayList(1,3,2,4,5)); // 活动排序
|
|
||||||
o.setPrice(generaInt()); // 限制范围为正整数
|
o.setPrice(generaInt()); // 限制范围为正整数
|
||||||
o.setMarketPrice(generaInt()); // 限制范围为正整数
|
o.setMarketPrice(generaInt()); // 限制范围为正整数
|
||||||
o.setCostPrice(generaInt()); // 限制范围为正整数
|
o.setCostPrice(generaInt()); // 限制范围为正整数
|
||||||
|
@ -218,11 +210,9 @@ public class ProductSpuServiceImplTest extends BaseDbUnitTest {
|
||||||
o.setCategoryId(generateId());
|
o.setCategoryId(generateId());
|
||||||
o.setBrandId(generateId());
|
o.setBrandId(generateId());
|
||||||
o.setDeliveryTemplateId(generateId());
|
o.setDeliveryTemplateId(generateId());
|
||||||
o.setUnit(RandomUtil.randomInt(1,20)); // 限制商品单位范围
|
|
||||||
o.setSort(RandomUtil.randomInt(1,100)); // 限制排序范围
|
o.setSort(RandomUtil.randomInt(1,100)); // 限制排序范围
|
||||||
o.setGiveIntegral(generaInt()); // 限制范围为正整数
|
o.setGiveIntegral(generaInt()); // 限制范围为正整数
|
||||||
o.setVirtualSalesCount(generaInt()); // 限制范围为正整数
|
o.setVirtualSalesCount(generaInt()); // 限制范围为正整数
|
||||||
o.setActivityOrders(newArrayList(1,3,2,4,5)); // 活动排序
|
|
||||||
o.setPrice(generaInt()); // 限制范围为正整数
|
o.setPrice(generaInt()); // 限制范围为正整数
|
||||||
o.setMarketPrice(generaInt()); // 限制范围为正整数
|
o.setMarketPrice(generaInt()); // 限制范围为正整数
|
||||||
o.setCostPrice(generaInt()); // 限制范围为正整数
|
o.setCostPrice(generaInt()); // 限制范围为正整数
|
||||||
|
@ -244,11 +234,9 @@ public class ProductSpuServiceImplTest extends BaseDbUnitTest {
|
||||||
o.setCategoryId(generateId());
|
o.setCategoryId(generateId());
|
||||||
o.setBrandId(generateId());
|
o.setBrandId(generateId());
|
||||||
o.setDeliveryTemplateId(generateId());
|
o.setDeliveryTemplateId(generateId());
|
||||||
o.setUnit(RandomUtil.randomInt(1,20)); // 限制商品单位范围
|
|
||||||
o.setSort(RandomUtil.randomInt(1,100)); // 限制排序范围
|
o.setSort(RandomUtil.randomInt(1,100)); // 限制排序范围
|
||||||
o.setGiveIntegral(generaInt()); // 限制范围为正整数
|
o.setGiveIntegral(generaInt()); // 限制范围为正整数
|
||||||
o.setVirtualSalesCount(generaInt()); // 限制范围为正整数
|
o.setVirtualSalesCount(generaInt()); // 限制范围为正整数
|
||||||
o.setActivityOrders(newArrayList(1,3,2,4,5)); // 活动排序
|
|
||||||
o.setPrice(generaInt()); // 限制范围为正整数
|
o.setPrice(generaInt()); // 限制范围为正整数
|
||||||
o.setMarketPrice(generaInt()); // 限制范围为正整数
|
o.setMarketPrice(generaInt()); // 限制范围为正整数
|
||||||
o.setCostPrice(generaInt()); // 限制范围为正整数
|
o.setCostPrice(generaInt()); // 限制范围为正整数
|
||||||
|
@ -260,11 +248,9 @@ public class ProductSpuServiceImplTest extends BaseDbUnitTest {
|
||||||
o.setCategoryId(generateId());
|
o.setCategoryId(generateId());
|
||||||
o.setBrandId(generateId());
|
o.setBrandId(generateId());
|
||||||
o.setDeliveryTemplateId(generateId());
|
o.setDeliveryTemplateId(generateId());
|
||||||
o.setUnit(RandomUtil.randomInt(1,20)); // 限制商品单位范围
|
|
||||||
o.setSort(RandomUtil.randomInt(1,100)); // 限制排序范围
|
o.setSort(RandomUtil.randomInt(1,100)); // 限制排序范围
|
||||||
o.setGiveIntegral(generaInt()); // 限制范围为正整数
|
o.setGiveIntegral(generaInt()); // 限制范围为正整数
|
||||||
o.setVirtualSalesCount(generaInt()); // 限制范围为正整数
|
o.setVirtualSalesCount(generaInt()); // 限制范围为正整数
|
||||||
o.setActivityOrders(newArrayList(1,3,2,4,5)); // 活动排序
|
|
||||||
o.setPrice(generaInt()); // 限制范围为正整数
|
o.setPrice(generaInt()); // 限制范围为正整数
|
||||||
o.setMarketPrice(generaInt()); // 限制范围为正整数
|
o.setMarketPrice(generaInt()); // 限制范围为正整数
|
||||||
o.setCostPrice(generaInt()); // 限制范围为正整数
|
o.setCostPrice(generaInt()); // 限制范围为正整数
|
||||||
|
@ -287,11 +273,9 @@ public class ProductSpuServiceImplTest extends BaseDbUnitTest {
|
||||||
o.setCategoryId(generateId());
|
o.setCategoryId(generateId());
|
||||||
o.setBrandId(generateId());
|
o.setBrandId(generateId());
|
||||||
o.setDeliveryTemplateId(generateId());
|
o.setDeliveryTemplateId(generateId());
|
||||||
o.setUnit(RandomUtil.randomInt(1,20)); // 限制商品单位范围
|
|
||||||
o.setSort(RandomUtil.randomInt(1,100)); // 限制排序范围
|
o.setSort(RandomUtil.randomInt(1,100)); // 限制排序范围
|
||||||
o.setGiveIntegral(generaInt()); // 限制范围为正整数
|
o.setGiveIntegral(generaInt()); // 限制范围为正整数
|
||||||
o.setVirtualSalesCount(generaInt()); // 限制范围为正整数
|
o.setVirtualSalesCount(generaInt()); // 限制范围为正整数
|
||||||
o.setActivityOrders(newArrayList(1,3,2,4,5)); // 活动排序
|
|
||||||
o.setPrice(generaInt()); // 限制范围为正整数
|
o.setPrice(generaInt()); // 限制范围为正整数
|
||||||
o.setMarketPrice(generaInt()); // 限制范围为正整数
|
o.setMarketPrice(generaInt()); // 限制范围为正整数
|
||||||
o.setCostPrice(generaInt()); // 限制范围为正整数
|
o.setCostPrice(generaInt()); // 限制范围为正整数
|
||||||
|
@ -303,11 +287,9 @@ public class ProductSpuServiceImplTest extends BaseDbUnitTest {
|
||||||
o.setCategoryId(generateId());
|
o.setCategoryId(generateId());
|
||||||
o.setBrandId(generateId());
|
o.setBrandId(generateId());
|
||||||
o.setDeliveryTemplateId(generateId());
|
o.setDeliveryTemplateId(generateId());
|
||||||
o.setUnit(RandomUtil.randomInt(1,20)); // 限制商品单位范围
|
|
||||||
o.setSort(RandomUtil.randomInt(1,100)); // 限制排序范围
|
o.setSort(RandomUtil.randomInt(1,100)); // 限制排序范围
|
||||||
o.setGiveIntegral(generaInt()); // 限制范围为正整数
|
o.setGiveIntegral(generaInt()); // 限制范围为正整数
|
||||||
o.setVirtualSalesCount(generaInt()); // 限制范围为正整数
|
o.setVirtualSalesCount(generaInt()); // 限制范围为正整数
|
||||||
o.setActivityOrders(newArrayList(1,3,2,4,5)); // 活动排序
|
|
||||||
o.setPrice(generaInt()); // 限制范围为正整数
|
o.setPrice(generaInt()); // 限制范围为正整数
|
||||||
o.setMarketPrice(generaInt()); // 限制范围为正整数
|
o.setMarketPrice(generaInt()); // 限制范围为正整数
|
||||||
o.setCostPrice(generaInt()); // 限制范围为正整数
|
o.setCostPrice(generaInt()); // 限制范围为正整数
|
||||||
|
@ -335,11 +317,9 @@ public class ProductSpuServiceImplTest extends BaseDbUnitTest {
|
||||||
o.setCategoryId(generateId());
|
o.setCategoryId(generateId());
|
||||||
o.setBrandId(generateId());
|
o.setBrandId(generateId());
|
||||||
o.setDeliveryTemplateId(generateId());
|
o.setDeliveryTemplateId(generateId());
|
||||||
o.setUnit(RandomUtil.randomInt(1,20)); // 限制商品单位范围
|
|
||||||
o.setSort(RandomUtil.randomInt(1,100)); // 限制排序范围
|
o.setSort(RandomUtil.randomInt(1,100)); // 限制排序范围
|
||||||
o.setGiveIntegral(generaInt()); // 限制范围为正整数
|
o.setGiveIntegral(generaInt()); // 限制范围为正整数
|
||||||
o.setVirtualSalesCount(generaInt()); // 限制范围为正整数
|
o.setVirtualSalesCount(generaInt()); // 限制范围为正整数
|
||||||
o.setActivityOrders(newArrayList(1,3,2,4,5)); // 活动排序
|
|
||||||
o.setPrice(generaInt()); // 限制范围为正整数
|
o.setPrice(generaInt()); // 限制范围为正整数
|
||||||
o.setMarketPrice(generaInt()); // 限制范围为正整数
|
o.setMarketPrice(generaInt()); // 限制范围为正整数
|
||||||
o.setCostPrice(generaInt()); // 限制范围为正整数
|
o.setCostPrice(generaInt()); // 限制范围为正整数
|
||||||
|
@ -351,11 +331,9 @@ public class ProductSpuServiceImplTest extends BaseDbUnitTest {
|
||||||
o.setCategoryId(generateId());
|
o.setCategoryId(generateId());
|
||||||
o.setBrandId(generateId());
|
o.setBrandId(generateId());
|
||||||
o.setDeliveryTemplateId(generateId());
|
o.setDeliveryTemplateId(generateId());
|
||||||
o.setUnit(RandomUtil.randomInt(1,20)); // 限制商品单位范围
|
|
||||||
o.setSort(RandomUtil.randomInt(1,100)); // 限制排序范围
|
o.setSort(RandomUtil.randomInt(1,100)); // 限制排序范围
|
||||||
o.setGiveIntegral(generaInt()); // 限制范围为正整数
|
o.setGiveIntegral(generaInt()); // 限制范围为正整数
|
||||||
o.setVirtualSalesCount(generaInt()); // 限制范围为正整数
|
o.setVirtualSalesCount(generaInt()); // 限制范围为正整数
|
||||||
o.setActivityOrders(newArrayList(1,3,2,4,5)); // 活动排序
|
|
||||||
o.setPrice(generaInt()); // 限制范围为正整数
|
o.setPrice(generaInt()); // 限制范围为正整数
|
||||||
o.setMarketPrice(generaInt()); // 限制范围为正整数
|
o.setMarketPrice(generaInt()); // 限制范围为正整数
|
||||||
o.setCostPrice(generaInt()); // 限制范围为正整数
|
o.setCostPrice(generaInt()); // 限制范围为正整数
|
||||||
|
@ -379,11 +357,9 @@ public class ProductSpuServiceImplTest extends BaseDbUnitTest {
|
||||||
o.setCategoryId(generateId());
|
o.setCategoryId(generateId());
|
||||||
o.setBrandId(generateId());
|
o.setBrandId(generateId());
|
||||||
o.setDeliveryTemplateId(generateId());
|
o.setDeliveryTemplateId(generateId());
|
||||||
o.setUnit(RandomUtil.randomInt(1,20)); // 限制商品单位范围
|
|
||||||
o.setSort(RandomUtil.randomInt(1,100)); // 限制排序范围
|
o.setSort(RandomUtil.randomInt(1,100)); // 限制排序范围
|
||||||
o.setGiveIntegral(generaInt()); // 限制范围为正整数
|
o.setGiveIntegral(generaInt()); // 限制范围为正整数
|
||||||
o.setVirtualSalesCount(generaInt()); // 限制范围为正整数
|
o.setVirtualSalesCount(generaInt()); // 限制范围为正整数
|
||||||
o.setActivityOrders(newArrayList(1,3,2,4,5)); // 活动排序
|
|
||||||
o.setPrice(generaInt()); // 限制范围为正整数
|
o.setPrice(generaInt()); // 限制范围为正整数
|
||||||
o.setMarketPrice(generaInt()); // 限制范围为正整数
|
o.setMarketPrice(generaInt()); // 限制范围为正整数
|
||||||
o.setCostPrice(generaInt()); // 限制范围为正整数
|
o.setCostPrice(generaInt()); // 限制范围为正整数
|
||||||
|
@ -462,11 +438,9 @@ public class ProductSpuServiceImplTest extends BaseDbUnitTest {
|
||||||
o.setCategoryId(generateId());
|
o.setCategoryId(generateId());
|
||||||
o.setBrandId(generateId());
|
o.setBrandId(generateId());
|
||||||
o.setDeliveryTemplateId(generateId());
|
o.setDeliveryTemplateId(generateId());
|
||||||
o.setUnit(RandomUtil.randomInt(1,20)); // 限制商品单位范围
|
|
||||||
o.setSort(RandomUtil.randomInt(1,100)); // 限制排序范围
|
o.setSort(RandomUtil.randomInt(1,100)); // 限制排序范围
|
||||||
o.setGiveIntegral(generaInt()); // 限制范围为正整数
|
o.setGiveIntegral(generaInt()); // 限制范围为正整数
|
||||||
o.setVirtualSalesCount(generaInt()); // 限制范围为正整数
|
o.setVirtualSalesCount(generaInt()); // 限制范围为正整数
|
||||||
o.setActivityOrders(newArrayList(1,3,2,4,5)); // 活动排序
|
|
||||||
o.setPrice(generaInt()); // 限制范围为正整数
|
o.setPrice(generaInt()); // 限制范围为正整数
|
||||||
o.setMarketPrice(generaInt()); // 限制范围为正整数
|
o.setMarketPrice(generaInt()); // 限制范围为正整数
|
||||||
o.setCostPrice(generaInt()); // 限制范围为正整数
|
o.setCostPrice(generaInt()); // 限制范围为正整数
|
||||||
|
@ -480,11 +454,9 @@ public class ProductSpuServiceImplTest extends BaseDbUnitTest {
|
||||||
o.setCategoryId(generateId());
|
o.setCategoryId(generateId());
|
||||||
o.setBrandId(generateId());
|
o.setBrandId(generateId());
|
||||||
o.setDeliveryTemplateId(generateId());
|
o.setDeliveryTemplateId(generateId());
|
||||||
o.setUnit(RandomUtil.randomInt(1,20)); // 限制商品单位范围
|
|
||||||
o.setSort(RandomUtil.randomInt(1,100)); // 限制排序范围
|
o.setSort(RandomUtil.randomInt(1,100)); // 限制排序范围
|
||||||
o.setGiveIntegral(generaInt()); // 限制范围为正整数
|
o.setGiveIntegral(generaInt()); // 限制范围为正整数
|
||||||
o.setVirtualSalesCount(generaInt()); // 限制范围为正整数
|
o.setVirtualSalesCount(generaInt()); // 限制范围为正整数
|
||||||
o.setActivityOrders(newArrayList(1,3,2,4,5)); // 活动排序
|
|
||||||
o.setPrice(generaInt()); // 限制范围为正整数
|
o.setPrice(generaInt()); // 限制范围为正整数
|
||||||
o.setMarketPrice(generaInt()); // 限制范围为正整数
|
o.setMarketPrice(generaInt()); // 限制范围为正整数
|
||||||
o.setCostPrice(generaInt()); // 限制范围为正整数
|
o.setCostPrice(generaInt()); // 限制范围为正整数
|
||||||
|
|
|
@ -42,9 +42,6 @@ public class AppBargainActivityDetailRespVO {
|
||||||
@Schema(description = "商品市场价,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "50") // 从 SPU 的 marketPrice 读取
|
@Schema(description = "商品市场价,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "50") // 从 SPU 的 marketPrice 读取
|
||||||
private Integer marketPrice;
|
private Integer marketPrice;
|
||||||
|
|
||||||
@Schema(description = "商品单位", requiredMode = Schema.RequiredMode.REQUIRED, example = "个") // 从 SPU 的 unit 读取,然后转换
|
|
||||||
private String unitName;
|
|
||||||
|
|
||||||
@Schema(description = "砍价起始价格,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "200")
|
@Schema(description = "砍价起始价格,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "200")
|
||||||
private Integer bargainFirstPrice;
|
private Integer bargainFirstPrice;
|
||||||
|
|
||||||
|
|
|
@ -19,8 +19,7 @@ public class AppSeckillActivityRespVO {
|
||||||
@Schema(description = "商品图片", requiredMode = Schema.RequiredMode.REQUIRED, // 从 SPU 的 picUrl 读取
|
@Schema(description = "商品图片", requiredMode = Schema.RequiredMode.REQUIRED, // 从 SPU 的 picUrl 读取
|
||||||
example = "https://www.iocoder.cn/xx.png")
|
example = "https://www.iocoder.cn/xx.png")
|
||||||
private String picUrl;
|
private String picUrl;
|
||||||
@Schema(description = "单位名", requiredMode = Schema.RequiredMode.REQUIRED, example = "个")
|
|
||||||
private String unitName;
|
|
||||||
@Schema(description = "商品市场价,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, // 从 SPU 的 marketPrice 读取
|
@Schema(description = "商品市场价,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, // 从 SPU 的 marketPrice 读取
|
||||||
example = "50")
|
example = "50")
|
||||||
private Integer marketPrice;
|
private Integer marketPrice;
|
||||||
|
|
|
@ -2,9 +2,7 @@ package cn.iocoder.yudao.module.promotion.convert.bargain;
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
||||||
import cn.iocoder.yudao.framework.dict.core.util.DictFrameworkUtils;
|
|
||||||
import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO;
|
import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO;
|
||||||
import cn.iocoder.yudao.module.product.enums.DictTypeConstants;
|
|
||||||
import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.activity.BargainActivityBaseVO;
|
import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.activity.BargainActivityBaseVO;
|
||||||
import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.activity.BargainActivityPageItemRespVO;
|
import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.activity.BargainActivityPageItemRespVO;
|
||||||
import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.activity.BargainActivityRespVO;
|
import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.activity.BargainActivityRespVO;
|
||||||
|
@ -64,8 +62,7 @@ public interface BargainActivityConvert {
|
||||||
default AppBargainActivityDetailRespVO convert(BargainActivityDO bean, Integer successUserCount, ProductSpuRespDTO spu) {
|
default AppBargainActivityDetailRespVO convert(BargainActivityDO bean, Integer successUserCount, ProductSpuRespDTO spu) {
|
||||||
AppBargainActivityDetailRespVO detail = convert1(bean).setSuccessUserCount(successUserCount);
|
AppBargainActivityDetailRespVO detail = convert1(bean).setSuccessUserCount(successUserCount);
|
||||||
if (spu != null) {
|
if (spu != null) {
|
||||||
detail.setPicUrl(spu.getPicUrl()).setMarketPrice(spu.getMarketPrice())
|
detail.setPicUrl(spu.getPicUrl()).setMarketPrice(spu.getMarketPrice());
|
||||||
.setUnitName(DictFrameworkUtils.getDictDataLabel(DictTypeConstants.PRODUCT_UNIT, spu.getUnit()));
|
|
||||||
}
|
}
|
||||||
return detail;
|
return detail;
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,9 +3,7 @@ package cn.iocoder.yudao.module.promotion.convert.seckill.seckillactivity;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
||||||
import cn.iocoder.yudao.framework.common.util.collection.MapUtils;
|
import cn.iocoder.yudao.framework.common.util.collection.MapUtils;
|
||||||
import cn.iocoder.yudao.framework.dict.core.util.DictFrameworkUtils;
|
|
||||||
import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO;
|
import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO;
|
||||||
import cn.iocoder.yudao.module.product.enums.DictTypeConstants;
|
|
||||||
import cn.iocoder.yudao.module.promotion.api.seckill.dto.SeckillValidateJoinRespDTO;
|
import cn.iocoder.yudao.module.promotion.api.seckill.dto.SeckillValidateJoinRespDTO;
|
||||||
import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity.SeckillActivityCreateReqVO;
|
import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity.SeckillActivityCreateReqVO;
|
||||||
import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity.SeckillActivityDetailRespVO;
|
import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity.SeckillActivityDetailRespVO;
|
||||||
|
@ -104,8 +102,7 @@ public interface SeckillActivityConvert {
|
||||||
item.setSeckillPrice(getMinValue(productMap.get(item.getId()), SeckillProductDO::getSeckillPrice));
|
item.setSeckillPrice(getMinValue(productMap.get(item.getId()), SeckillProductDO::getSeckillPrice));
|
||||||
// spu 信息
|
// spu 信息
|
||||||
findAndThen(spuMap, item.getSpuId(), spu ->
|
findAndThen(spuMap, item.getSpuId(), spu ->
|
||||||
item.setPicUrl(spu.getPicUrl()).setMarketPrice(spu.getMarketPrice())
|
item.setPicUrl(spu.getPicUrl()).setMarketPrice(spu.getMarketPrice()));
|
||||||
.setUnitName(DictFrameworkUtils.getDictDataLabel(DictTypeConstants.PRODUCT_UNIT, spu.getUnit())));
|
|
||||||
return item;
|
return item;
|
||||||
}));
|
}));
|
||||||
return respVO;
|
return respVO;
|
||||||
|
@ -121,8 +118,7 @@ public interface SeckillActivityConvert {
|
||||||
// product 信息
|
// product 信息
|
||||||
item.setSeckillPrice(getMinValue(productMap.get(item.getId()), SeckillProductDO::getSeckillPrice));
|
item.setSeckillPrice(getMinValue(productMap.get(item.getId()), SeckillProductDO::getSeckillPrice));
|
||||||
// spu 信息
|
// spu 信息
|
||||||
findAndThen(spuMap, item.getSpuId(), spu -> item.setPicUrl(spu.getPicUrl()).setMarketPrice(spu.getMarketPrice())
|
findAndThen(spuMap, item.getSpuId(), spu -> item.setPicUrl(spu.getPicUrl()).setMarketPrice(spu.getMarketPrice()));
|
||||||
.setUnitName(DictFrameworkUtils.getDictDataLabel(DictTypeConstants.PRODUCT_UNIT, spu.getUnit())));
|
|
||||||
return item;
|
return item;
|
||||||
});
|
});
|
||||||
result.setList(list);
|
result.setList(list);
|
||||||
|
|
Loading…
Reference in New Issue