diff --git a/yudao-module-mall/pom.xml b/yudao-module-mall/pom.xml deleted file mode 100644 index 37484f00c..000000000 --- a/yudao-module-mall/pom.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - - yudao - cn.iocoder.boot - ${revision} - - 4.0.0 - - yudao-module-mall - pom - - ${project.artifactId} - - - 商城大模块,由 product 商品、promotion 营销、trade 交易等组成 - - - yudao-module-promotion-api - yudao-module-promotion-biz - yudao-module-product-api - yudao-module-product-biz - yudao-module-trade-api - yudao-module-trade-biz - - - diff --git a/yudao-module-mall/yudao-module-product-api/pom.xml b/yudao-module-mall/yudao-module-product-api/pom.xml deleted file mode 100644 index 123e7c334..000000000 --- a/yudao-module-mall/yudao-module-product-api/pom.xml +++ /dev/null @@ -1,34 +0,0 @@ - - - 4.0.0 - - cn.iocoder.boot - yudao-module-mall - ${revision} - - - yudao-module-product-api - jar - - ${project.artifactId} - - product 模块 API,暴露给其它模块调用 - - - - - cn.iocoder.boot - yudao-common - - - - - org.springframework.boot - spring-boot-starter-validation - true - - - - diff --git a/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/package-info.java b/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/package-info.java deleted file mode 100644 index b19092853..000000000 --- a/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 占位 - */ -package cn.iocoder.yudao.module.product.api; \ No newline at end of file diff --git a/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/property/ProductPropertyValueApi.java b/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/property/ProductPropertyValueApi.java deleted file mode 100644 index 83269f91d..000000000 --- a/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/property/ProductPropertyValueApi.java +++ /dev/null @@ -1,23 +0,0 @@ -package cn.iocoder.yudao.module.product.api.property; - -import cn.iocoder.yudao.module.product.api.property.dto.ProductPropertyValueDetailRespDTO; - -import java.util.Collection; -import java.util.List; - -/** - * 商品属性值 API 接口 - * - * @author 芋道源码 - */ -public interface ProductPropertyValueApi { - - /** - * 根据编号数组,获得属性值列表 - * - * @param ids 编号数组 - * @return 属性值明细列表 - */ - List getPropertyValueDetailList(Collection ids); - -} diff --git a/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/property/dto/ProductPropertyValueDetailRespDTO.java b/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/property/dto/ProductPropertyValueDetailRespDTO.java deleted file mode 100644 index 2a1ab71a9..000000000 --- a/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/property/dto/ProductPropertyValueDetailRespDTO.java +++ /dev/null @@ -1,33 +0,0 @@ -package cn.iocoder.yudao.module.product.api.property.dto; - -import lombok.Data; - -/** - * 商品属性项的明细 Response DTO - * - * @author 芋道源码 - */ -@Data -public class ProductPropertyValueDetailRespDTO { - - /** - * 属性的编号 - */ - private Long propertyId; - - /** - * 属性的名称 - */ - private String propertyName; - - /** - * 属性值的编号 - */ - private Long valueId; - - /** - * 属性值的名称 - */ - private String valueName; - -} diff --git a/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/sku/ProductSkuApi.java b/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/sku/ProductSkuApi.java deleted file mode 100644 index d5d93dc37..000000000 --- a/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/sku/ProductSkuApi.java +++ /dev/null @@ -1,40 +0,0 @@ -package cn.iocoder.yudao.module.product.api.sku; - -import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuUpdateStockReqDTO; -import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuRespDTO; - -import java.util.Collection; -import java.util.List; - -/** - * 商品 SKU API 接口 - * - * @author LeeYan9 - * @since 2022-08-26 - */ -public interface ProductSkuApi { - - /** - * 查询 SKU 信息 - * - * @param id SKU 编号 - * @return SKU 信息 - */ - ProductSkuRespDTO getSku(Long id); - - /** - * 批量查询 SKU 数组 - * - * @param ids SKU 编号列表 - * @return SKU 数组 - */ - List getSkuList(Collection ids); - - /** - * 更新 SKU 库存 - * - * @param updateStockReqDTO 更新请求 - */ - void updateSkuStock(ProductSkuUpdateStockReqDTO updateStockReqDTO); - -} diff --git a/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/sku/dto/ProductSkuRespDTO.java b/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/sku/dto/ProductSkuRespDTO.java deleted file mode 100644 index aaaf767f2..000000000 --- a/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/sku/dto/ProductSkuRespDTO.java +++ /dev/null @@ -1,95 +0,0 @@ -package cn.iocoder.yudao.module.product.api.sku.dto; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import lombok.Data; - -import java.util.List; - -/** - * 商品 SKU 信息 Response DTO - * - * @author LeeYan9 - * @since 2022-08-26 - */ -@Data -public class ProductSkuRespDTO { - - /** - * 商品 SKU 编号,自增 - */ - private Long id; - /** - * SPU 编号 - */ - private Long spuId; - /** - * SPU 名字 - */ - private String spuName; - - /** - * 属性数组,JSON 格式 - */ - private List properties; - /** - * 销售价格,单位:分 - */ - private Integer price; - /** - * 市场价,单位:分 - */ - private Integer marketPrice; - /** - * 成本价,单位:分 - */ - private Integer costPrice; - /** - * SKU 的条形码 - */ - private String barCode; - /** - * 图片地址 - */ - private String picUrl; - /** - * SKU 状态 - *

- * 枚举 {@link CommonStatusEnum} - */ - private Integer status; - /** - * 库存 - */ - private Integer stock; - /** - * 预警预存 - */ - private Integer warnStock; - /** - * 商品重量,单位:kg 千克 - */ - private Double weight; - /** - * 商品体积,单位:m^3 平米 - */ - private Double volume; - - /** - * 商品属性 - */ - @Data - public static class Property { - - /** - * 属性编号 - */ - private Long propertyId; - /** - * 属性值编号 - */ - private Long valueId; - - } - - -} diff --git a/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/sku/dto/ProductSkuUpdateStockReqDTO.java b/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/sku/dto/ProductSkuUpdateStockReqDTO.java deleted file mode 100644 index 345c17cbd..000000000 --- a/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/sku/dto/ProductSkuUpdateStockReqDTO.java +++ /dev/null @@ -1,47 +0,0 @@ -package cn.iocoder.yudao.module.product.api.sku.dto; - -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - -import javax.validation.constraints.NotNull; -import java.util.List; - -/** - * 商品 SKU 更新库存 Request DTO - * - * @author LeeYan9 - * @since 2022-08-26 - */ -@Data -@NoArgsConstructor -@AllArgsConstructor -public class ProductSkuUpdateStockReqDTO { - - /** - * 商品 SKU - */ - @NotNull(message = "商品 SKU 不能为空") - private List items; - - @Data - public static class Item { - - /** - * 商品 SKU 编号 - */ - @NotNull(message = "商品 SKU 编号不能为空") - private Long id; - - /** - * 库存变化数量 - * - * 正数:增加库存 - * 负数:扣减库存 - */ - @NotNull(message = "库存变化数量不能为空") - private Integer incrCount; - - } - -} diff --git a/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/spu/ProductSpuApi.java b/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/spu/ProductSpuApi.java deleted file mode 100644 index 8ba0fba7d..000000000 --- a/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/spu/ProductSpuApi.java +++ /dev/null @@ -1,24 +0,0 @@ -package cn.iocoder.yudao.module.product.api.spu; - -import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO; - -import java.util.Collection; -import java.util.List; - -/** - * 商品 SPU API 接口 - * - * @author LeeYan9 - * @since 2022-08-26 - */ -public interface ProductSpuApi { - - /** - * 批量查询 SPU 数组 - * - * @param ids SPU 编号列表 - * @return SPU 数组 - */ - List getSpuList(Collection ids); - -} diff --git a/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/spu/dto/ProductSpuRespDTO.java b/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/spu/dto/ProductSpuRespDTO.java deleted file mode 100644 index 45d42f41b..000000000 --- a/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/spu/dto/ProductSpuRespDTO.java +++ /dev/null @@ -1,127 +0,0 @@ -package cn.iocoder.yudao.module.product.api.spu.dto; - -import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuRespDTO; -import cn.iocoder.yudao.module.product.enums.spu.ProductSpuSpecTypeEnum; -import cn.iocoder.yudao.module.product.enums.spu.ProductSpuStatusEnum; -import lombok.Data; - -import java.util.List; - -// TODO @LeeYan9: ProductSpuRespDTO -/** - * 商品 SPU 信息 Response DTO - * - * @author LeeYan9 - * @since 2022-08-26 - */ -@Data -public class ProductSpuRespDTO { - - /** - * 商品 SPU 编号,自增 - */ - private Long id; - - // ========== 基本信息 ========= - - /** - * 商品名称 - */ - private String name; - /** - * 商品编码 - */ - private String code; - /** - * 促销语 - */ - private String sellPoint; - /** - * 商品详情 - */ - private String description; - /** - * 商品分类编号 - */ - private Long categoryId; - /** - * 商品品牌编号 - */ - private Long brandId; - /** - * 商品图片的数组 - *

- * 1. 第一张图片将作为商品主图,支持同时上传多张图; - * 2. 建议使用尺寸 800x800 像素以上、大小不超过 1M 的正方形图片; - * 3. 至少 1 张,最多上传 10 张 - */ - private List picUrls; - /** - * 商品视频 - */ - private String videoUrl; - - /** - * 排序字段 - */ - private Integer sort; - /** - * 商品状态 - *

- * 枚举 {@link ProductSpuStatusEnum} - */ - private Integer status; - - // ========== SKU 相关字段 ========= - - /** - * 规格类型 - *

- * 枚举 {@link ProductSpuSpecTypeEnum} - */ - private Integer specType; - /** - * 最小价格,单位使用:分 - *

- * 基于其对应的 {@link ProductSkuRespDTO#getPrice()} 最小值 - */ - private Integer minPrice; - /** - * 最大价格,单位使用:分 - *

- * 基于其对应的 {@link ProductSkuRespDTO#getPrice()} 最大值 - */ - private Integer maxPrice; - /** - * 市场价,单位使用:分 - *

- * 基于其对应的 {@link ProductSkuRespDTO#getMarketPrice()} 最大值 - */ - private Integer marketPrice; - /** - * 总库存 - *

- * 基于其对应的 {@link ProductSkuRespDTO#getStock()} 求和 - */ - private Integer totalStock; - /** - * 是否展示库存 - */ - private Boolean showStock; - - // ========== 统计相关字段 ========= - - /** - * 商品销量 - */ - private Integer salesCount; - /** - * 虚拟销量 - */ - private Integer virtualSalesCount; - /** - * 商品点击量 - */ - private Integer clickCount; - -} diff --git a/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/enums/ErrorCodeConstants.java b/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/enums/ErrorCodeConstants.java deleted file mode 100644 index 4adad0afc..000000000 --- a/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/enums/ErrorCodeConstants.java +++ /dev/null @@ -1,45 +0,0 @@ -package cn.iocoder.yudao.module.product.enums; - -import cn.iocoder.yudao.framework.common.exception.ErrorCode; - -/** - * Product 错误码枚举类 - * - * product 系统,使用 1-008-000-000 段 - */ -public interface ErrorCodeConstants { - - // ========== 商品分类相关 1008001000 ============ - ErrorCode CATEGORY_NOT_EXISTS = new ErrorCode(1008001000, "商品分类不存在"); - ErrorCode CATEGORY_PARENT_NOT_EXISTS = new ErrorCode(1008001001, "父分类不存在"); - ErrorCode CATEGORY_PARENT_NOT_FIRST_LEVEL = new ErrorCode(1008001002, "父分类不能是二级分类"); - ErrorCode CATEGORY_EXISTS_CHILDREN = new ErrorCode(1008001003, "存在子分类,无法删除"); - ErrorCode CATEGORY_DISABLED = new ErrorCode(1008001004, "商品分类({})已禁用,无法使用"); - - // ========== 商品品牌相关编号 1008002000 ========== - ErrorCode BRAND_NOT_EXISTS = new ErrorCode(1008002000, "品牌不存在"); - ErrorCode BRAND_DISABLED = new ErrorCode(1008002001, "品牌不存在"); - ErrorCode BRAND_NAME_EXISTS = new ErrorCode(1008002002, "品牌名称已存在"); - - // ========== 商品属性项 1008003000 ========== - ErrorCode PROPERTY_NOT_EXISTS = new ErrorCode(1008003000, "属性项不存在"); - ErrorCode PROPERTY_EXISTS = new ErrorCode(1008003001, "属性项的名称已存在"); - ErrorCode PROPERTY_DELETE_FAIL_VALUE_EXISTS = new ErrorCode(1008003002, "属性项下存在属性值,无法删除"); - - // ========== 商品属性值 1008004000 ========== - ErrorCode PROPERTY_VALUE_NOT_EXISTS = new ErrorCode(1008004000, "属性值不存在"); - ErrorCode PROPERTY_VALUE_EXISTS = new ErrorCode(1008004001, "属性值的名称已存在"); - - // ========== 商品 SPU 1008005000 ========== - ErrorCode SPU_NOT_EXISTS = new ErrorCode(1008005000, "商品 SPU 不存在"); - ErrorCode SPU_SAVE_FAIL_CATEGORY_LEVEL_ERROR = new ErrorCode(1008005001, "商品分类不正确,原因:必须使用第三级的商品分类下"); - ErrorCode SPU_NOT_ENABLE = new ErrorCode(1008005002, "商品 SPU 不处于上架状态"); - - // ========== 商品 SKU 1008006000 ========== - ErrorCode SKU_NOT_EXISTS = new ErrorCode(1008006000, "商品 SKU 不存在"); - ErrorCode SKU_PROPERTIES_DUPLICATED = new ErrorCode(1008006001, "商品 SKU 的属性组合存在重复"); - ErrorCode SPU_ATTR_NUMBERS_MUST_BE_EQUALS = new ErrorCode(1008006002, "一个 SPU 下的每个 SKU,其属性项必须一致"); - ErrorCode SPU_SKU_NOT_DUPLICATE = new ErrorCode(1008006003, "一个 SPU 下的每个 SKU,必须不重复"); - ErrorCode SKU_STOCK_NOT_ENOUGH = new ErrorCode(1008006004, "商品 SKU 库存不足"); - -} diff --git a/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/enums/comment/ProductCommentAuditStatusEnum.java b/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/enums/comment/ProductCommentAuditStatusEnum.java deleted file mode 100644 index 276839daf..000000000 --- a/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/enums/comment/ProductCommentAuditStatusEnum.java +++ /dev/null @@ -1,38 +0,0 @@ -package cn.iocoder.yudao.module.product.enums.comment; - -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Arrays; - -/** - * 商品评论的审批状态枚举 - * - * @author 芋道源码 - */ -@Getter -@AllArgsConstructor -public enum ProductCommentAuditStatusEnum implements IntArrayValuable { - - NONE(1, "待审核"), - APPROVE(2, "审批通过"), - REJECT(2, "审批不通过"),; - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(ProductCommentAuditStatusEnum::getStatus).toArray(); - - /** - * 审批状态 - */ - private final Integer status; - /** - * 状态名 - */ - private final String name; - - @Override - public int[] array() { - return ARRAYS; - } - -} diff --git a/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/enums/delivery/DeliveryTypeEnum.java b/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/enums/delivery/DeliveryTypeEnum.java deleted file mode 100644 index da322ff24..000000000 --- a/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/enums/delivery/DeliveryTypeEnum.java +++ /dev/null @@ -1,38 +0,0 @@ -package cn.iocoder.yudao.module.product.enums.delivery; - -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Arrays; - -/** - * 配送方式枚举 - * - * @author 芋道源码 - */ -@Getter -@AllArgsConstructor -public enum DeliveryTypeEnum implements IntArrayValuable { - - // TODO 芋艿:英文单词,需要再想下; - EXPRESS(1, "快递发货"), - USER(2, "用户自提"),; - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(DeliveryTypeEnum::getMode).toArray(); - - /** - * 配送方式 - */ - private final Integer mode; - /** - * 状态名 - */ - private final String name; - - @Override - public int[] array() { - return ARRAYS; - } - -} diff --git a/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/enums/group/ProductGroupStyleEnum.java b/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/enums/group/ProductGroupStyleEnum.java deleted file mode 100644 index c5e55e8e4..000000000 --- a/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/enums/group/ProductGroupStyleEnum.java +++ /dev/null @@ -1,38 +0,0 @@ -package cn.iocoder.yudao.module.product.enums.group; - -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Arrays; - -/** - * 商品分组的样式枚举 - * - * @author 芋道源码 - */ -@Getter -@AllArgsConstructor -public enum ProductGroupStyleEnum implements IntArrayValuable { - - ONE(1, "每列一个"), - TWO(2, "每列两个"), - THREE(2, "每列三个"),; - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(ProductGroupStyleEnum::getStyle).toArray(); - - /** - * 列表样式 - */ - private final Integer style; - /** - * 状态名 - */ - private final String name; - - @Override - public int[] array() { - return ARRAYS; - } - -} diff --git a/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/enums/spu/ProductSpuSpecTypeEnum.java b/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/enums/spu/ProductSpuSpecTypeEnum.java deleted file mode 100644 index fbc227b53..000000000 --- a/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/enums/spu/ProductSpuSpecTypeEnum.java +++ /dev/null @@ -1,37 +0,0 @@ -package cn.iocoder.yudao.module.product.enums.spu; - -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Arrays; - -/** - * 商品 SPU 规格类型 - * - * @author 芋道源码 - */ -@Getter -@AllArgsConstructor -public enum ProductSpuSpecTypeEnum implements IntArrayValuable { - - RECYCLE(1, "统一规格"), - DISABLE(2, "多规格"); - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(ProductSpuSpecTypeEnum::getType).toArray(); - - /** - * 规格类型 - */ - private final Integer type; - /** - * 规格名称 - */ - private final String name; - - @Override - public int[] array() { - return ARRAYS; - } - -} diff --git a/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/enums/spu/ProductSpuStatusEnum.java b/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/enums/spu/ProductSpuStatusEnum.java deleted file mode 100644 index 2223cf23d..000000000 --- a/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/enums/spu/ProductSpuStatusEnum.java +++ /dev/null @@ -1,48 +0,0 @@ -package cn.iocoder.yudao.module.product.enums.spu; - -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Arrays; - -/** - * 商品 SPU 状态 - * - * @author 芋道源码 - */ -@Getter -@AllArgsConstructor -public enum ProductSpuStatusEnum implements IntArrayValuable { - - RECYCLE(-1, "回收站"), - DISABLE(0, "下架"), - ENABLE(1, "上架"),; - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(ProductSpuStatusEnum::getStatus).toArray(); - - /** - * 状态 - */ - private final Integer status; - /** - * 状态名 - */ - private final String name; - - @Override - public int[] array() { - return ARRAYS; - } - - /** - * 判断是否处于【上架】状态 - * - * @param status 状态 - * @return 是否处于【上架】状态 - */ - public static boolean isEnable(Integer status) { - return ENABLE.getStatus().equals(status); - } - -} diff --git a/yudao-module-mall/yudao-module-product-biz/pom.xml b/yudao-module-mall/yudao-module-product-biz/pom.xml deleted file mode 100644 index e89ed105e..000000000 --- a/yudao-module-mall/yudao-module-product-biz/pom.xml +++ /dev/null @@ -1,62 +0,0 @@ - - - - cn.iocoder.boot - yudao-module-mall - ${revision} - - 4.0.0 - yudao-module-product-biz - jar - - ${project.artifactId} - - product 模块,主要实现商品相关功能 - 例如:品牌、商品分类、spu、sku等功能。 - - - - - cn.iocoder.boot - yudao-module-product-api - ${revision} - - - - - cn.iocoder.boot - yudao-spring-boot-starter-biz-operatelog - - - - - cn.iocoder.boot - yudao-spring-boot-starter-web - - - cn.iocoder.boot - yudao-spring-boot-starter-security - - - - - cn.iocoder.boot - yudao-spring-boot-starter-mybatis - - - - - cn.iocoder.boot - yudao-spring-boot-starter-test - - - - - cn.iocoder.boot - yudao-spring-boot-starter-excel - - - - diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/api/package-info.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/api/package-info.java deleted file mode 100644 index 162453c3c..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/api/package-info.java +++ /dev/null @@ -1 +0,0 @@ -package cn.iocoder.yudao.module.product.api; diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/api/property/ProductPropertyValueApiImpl.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/api/property/ProductPropertyValueApiImpl.java deleted file mode 100644 index 9aab9e560..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/api/property/ProductPropertyValueApiImpl.java +++ /dev/null @@ -1,31 +0,0 @@ -package cn.iocoder.yudao.module.product.api.property; - -import cn.iocoder.yudao.module.product.api.property.dto.ProductPropertyValueDetailRespDTO; -import cn.iocoder.yudao.module.product.convert.propertyvalue.ProductPropertyValueConvert; -import cn.iocoder.yudao.module.product.service.property.ProductPropertyValueService; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.util.Collection; -import java.util.List; - -/** - * 商品属性值 API 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class ProductPropertyValueApiImpl implements ProductPropertyValueApi { - - @Resource - private ProductPropertyValueService productPropertyValueService; - - @Override - public List getPropertyValueDetailList(Collection ids) { - return ProductPropertyValueConvert.INSTANCE.convertList02( - productPropertyValueService.getPropertyValueDetailList(ids)); - } - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/api/sku/ProductSkuApiImpl.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/api/sku/ProductSkuApiImpl.java deleted file mode 100644 index 89913c70e..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/api/sku/ProductSkuApiImpl.java +++ /dev/null @@ -1,49 +0,0 @@ -package cn.iocoder.yudao.module.product.api.sku; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuRespDTO; -import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuUpdateStockReqDTO; -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.service.sku.ProductSkuService; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.util.Collection; -import java.util.Collections; -import java.util.List; - -/** - * TODO LeeYan9: 类注释; - * @author LeeYan9 - * @since 2022-09-06 - */ -@Service -@Validated -public class ProductSkuApiImpl implements ProductSkuApi { - - @Resource - private ProductSkuService productSkuService; - - @Override - public ProductSkuRespDTO getSku(Long id) { - // TODO TODO LeeYan9: 需要实现 - return null; - } - - @Override - public List getSkuList(Collection ids) { - if (CollUtil.isEmpty(ids)) { - return Collections.emptyList(); - } - List skus = productSkuService.getSkuList(ids); - return ProductSkuConvert.INSTANCE.convertList04(skus); - } - - @Override - public void updateSkuStock(ProductSkuUpdateStockReqDTO updateStockReqDTO) { - productSkuService.updateSkuStock(updateStockReqDTO); - } - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/api/spu/ProductSpuApiImpl.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/api/spu/ProductSpuApiImpl.java deleted file mode 100644 index 4d880e662..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/api/spu/ProductSpuApiImpl.java +++ /dev/null @@ -1,38 +0,0 @@ -package cn.iocoder.yudao.module.product.api.spu; - -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO; -import cn.iocoder.yudao.module.product.convert.spu.ProductSpuConvert; -import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO; -import cn.iocoder.yudao.module.product.dal.mysql.spu.ProductSpuMapper; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.util.Collection; -import java.util.Collections; -import java.util.List; - -/** - * TODO LeeYan9: 类注释; - * - * @author LeeYan9 - * @since 2022-09-06 - */ -@Service -@Validated -public class ProductSpuApiImpl implements ProductSpuApi { - - @Resource - private ProductSpuMapper productSpuMapper; - - @Override - public List getSpuList(Collection spuIds) { - // TODO TODO LeeYan9: AllEmpty? - if (CollectionUtils.isAnyEmpty(spuIds)) { - return Collections.emptyList(); - } - List productSpuDOList = productSpuMapper.selectBatchIds(spuIds); - return ProductSpuConvert.INSTANCE.convertList2(productSpuDOList); - } -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/brand/ProductBrandController.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/brand/ProductBrandController.java deleted file mode 100644 index 8427449f7..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/brand/ProductBrandController.java +++ /dev/null @@ -1,82 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.brand; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.product.controller.admin.brand.vo.*; -import cn.iocoder.yudao.module.product.convert.brand.ProductBrandConvert; -import cn.iocoder.yudao.module.product.dal.dataobject.brand.ProductBrandDO; -import cn.iocoder.yudao.module.product.service.brand.ProductBrandService; -import io.swagger.v3.oas.annotations.tags.Tag; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.Operation; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.validation.Valid; -import java.util.Comparator; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "管理后台 - 商品品牌") -@RestController -@RequestMapping("/product/brand") -@Validated -public class ProductBrandController { - - @Resource - private ProductBrandService brandService; - - @PostMapping("/create") - @Operation(summary = "创建品牌") - @PreAuthorize("@ss.hasPermission('product:brand:create')") - public CommonResult createBrand(@Valid @RequestBody ProductBrandCreateReqVO createReqVO) { - return success(brandService.createBrand(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新品牌") - @PreAuthorize("@ss.hasPermission('product:brand:update')") - public CommonResult updateBrand(@Valid @RequestBody ProductBrandUpdateReqVO updateReqVO) { - brandService.updateBrand(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除品牌") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('product:brand:delete')") - public CommonResult deleteBrand(@RequestParam("id") Long id) { - brandService.deleteBrand(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得品牌") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('product:brand:query')") - public CommonResult getBrand(@RequestParam("id") Long id) { - ProductBrandDO brand = brandService.getBrand(id); - return success(ProductBrandConvert.INSTANCE.convert(brand)); - } - - @GetMapping("/page") - @Operation(summary = "获得品牌分页") - @PreAuthorize("@ss.hasPermission('product:brand:query')") - public CommonResult> getBrandPage(@Valid ProductBrandPageReqVO pageVO) { - PageResult pageResult = brandService.getBrandPage(pageVO); - return success(ProductBrandConvert.INSTANCE.convertPage(pageResult)); - } - - @GetMapping("/list") - @Operation(summary = "获得品牌列表") - @PreAuthorize("@ss.hasPermission('product:brand:query')") - public CommonResult> getBrandList(@Valid ProductBrandListReqVO listVO) { - List list = brandService.getBrandList(listVO); - list.sort(Comparator.comparing(ProductBrandDO::getSort)); - return success(ProductBrandConvert.INSTANCE.convertList(list)); - } - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/brand/vo/ProductBrandBaseVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/brand/vo/ProductBrandBaseVO.java deleted file mode 100644 index 033199d9f..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/brand/vo/ProductBrandBaseVO.java +++ /dev/null @@ -1,33 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.brand.vo; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotNull; - -/** -* 商品品牌 Base VO,提供给添加、修改、详细的子 VO 使用 -* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 -*/ -@Data -public class ProductBrandBaseVO { - - @Schema(description = "品牌名称", required = true, example = "芋道") - @NotNull(message = "品牌名称不能为空") - private String name; - - @Schema(description = "品牌图片", required = true) - @NotNull(message = "品牌图片不能为空") - private String picUrl; - - @Schema(description = "品牌排序", required = true, example = "1") - @NotNull(message = "品牌排序不能为空") - private Integer sort; - - @Schema(description = "品牌描述", example = "描述") - private String description; - - @Schema(description = "状态", required = true, example = "0") - @NotNull(message = "状态不能为空") - private Integer status; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/brand/vo/ProductBrandCreateReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/brand/vo/ProductBrandCreateReqVO.java deleted file mode 100644 index 2ab9c354a..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/brand/vo/ProductBrandCreateReqVO.java +++ /dev/null @@ -1,11 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.brand.vo; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; - -@Schema(description = "管理后台 - 商品品牌创建 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class ProductBrandCreateReqVO extends ProductBrandBaseVO { - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/brand/vo/ProductBrandListReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/brand/vo/ProductBrandListReqVO.java deleted file mode 100644 index 63305810c..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/brand/vo/ProductBrandListReqVO.java +++ /dev/null @@ -1,13 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.brand.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "管理后台 - 商品品牌分页 Request VO") -@Data -public class ProductBrandListReqVO { - - @Schema(description = "品牌名称", example = "芋道") - private String name; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/brand/vo/ProductBrandPageReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/brand/vo/ProductBrandPageReqVO.java deleted file mode 100644 index e90744a10..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/brand/vo/ProductBrandPageReqVO.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.brand.vo; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 商品品牌分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class ProductBrandPageReqVO extends PageParam { - - @Schema(description = "品牌名称", example = "芋道") - private String name; - - @Schema(description = "状态-参考 CommonStatusEnum 枚举", example = "0") - private Integer status; - - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - @Schema(description = "创建时间") - private LocalDateTime[] createTime; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/brand/vo/ProductBrandRespVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/brand/vo/ProductBrandRespVO.java deleted file mode 100644 index b68fbc5be..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/brand/vo/ProductBrandRespVO.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.brand.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 品牌 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class ProductBrandRespVO extends ProductBrandBaseVO { - - @Schema(description = "品牌编号", required = true, example = "1") - private Long id; - - @Schema(description = "创建时间", required = true) - private LocalDateTime createTime; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/brand/vo/ProductBrandUpdateReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/brand/vo/ProductBrandUpdateReqVO.java deleted file mode 100644 index 15648164f..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/brand/vo/ProductBrandUpdateReqVO.java +++ /dev/null @@ -1,16 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.brand.vo; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; -import javax.validation.constraints.*; - -@Schema(description = "管理后台 - 商品品牌更新 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class ProductBrandUpdateReqVO extends ProductBrandBaseVO { - - @Schema(description = "品牌编号", required = true, example = "1") - @NotNull(message = "品牌编号不能为空") - private Long id; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/category/ProductCategoryController.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/category/ProductCategoryController.java deleted file mode 100644 index c51498d3b..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/category/ProductCategoryController.java +++ /dev/null @@ -1,76 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.category; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.product.controller.admin.category.vo.ProductCategoryRespVO; -import cn.iocoder.yudao.module.product.controller.admin.category.vo.ProductCategoryListReqVO; -import cn.iocoder.yudao.module.product.controller.admin.category.vo.ProductCategoryCreateReqVO; -import cn.iocoder.yudao.module.product.controller.admin.category.vo.ProductCategoryUpdateReqVO; -import cn.iocoder.yudao.module.product.convert.category.ProductCategoryConvert; -import cn.iocoder.yudao.module.product.dal.dataobject.category.ProductCategoryDO; -import cn.iocoder.yudao.module.product.service.category.ProductCategoryService; -import io.swagger.v3.oas.annotations.tags.Tag; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.Operation; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.validation.Valid; -import java.util.Comparator; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "管理后台 - 商品分类") -@RestController -@RequestMapping("/product/category") -@Validated -public class ProductCategoryController { - - @Resource - private ProductCategoryService categoryService; - - @PostMapping("/create") - @Operation(summary = "创建商品分类") - @PreAuthorize("@ss.hasPermission('product:category:create')") - public CommonResult createCategory(@Valid @RequestBody ProductCategoryCreateReqVO createReqVO) { - return success(categoryService.createCategory(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新商品分类") - @PreAuthorize("@ss.hasPermission('product:category:update')") - public CommonResult updateCategory(@Valid @RequestBody ProductCategoryUpdateReqVO updateReqVO) { - categoryService.updateCategory(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除商品分类") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('product:category:delete')") - public CommonResult deleteCategory(@RequestParam("id") Long id) { - categoryService.deleteCategory(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得商品分类") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('product:category:query')") - public CommonResult getCategory(@RequestParam("id") Long id) { - ProductCategoryDO category = categoryService.getCategory(id); - return success(ProductCategoryConvert.INSTANCE.convert(category)); - } - - @GetMapping("/list") - @Operation(summary = "获得商品分类列表") - @PreAuthorize("@ss.hasPermission('product:category:query')") - public CommonResult> getCategoryList(@Valid ProductCategoryListReqVO treeListReqVO) { - List list = categoryService.getEnableCategoryList(treeListReqVO); - list.sort(Comparator.comparing(ProductCategoryDO::getSort)); - return success(ProductCategoryConvert.INSTANCE.convertList(list)); - } - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/category/vo/ProductCategoryBaseVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/category/vo/ProductCategoryBaseVO.java deleted file mode 100644 index c2276e9ac..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/category/vo/ProductCategoryBaseVO.java +++ /dev/null @@ -1,37 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.category.vo; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.NotNull; - -/** -* 商品分类 Base VO,提供给添加、修改、详细的子 VO 使用 -* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 -*/ -@Data -public class ProductCategoryBaseVO { - - @Schema(description = "父分类编号", required = true, example = "1") - @NotNull(message = "父分类编号不能为空") - private Long parentId; - - @Schema(description = "分类名称", required = true, example = "办公文具") - @NotBlank(message = "分类名称不能为空") - private String name; - - @Schema(description = "分类图片", required = true) - @NotBlank(message = "分类图片不能为空") - private String picUrl; - - @Schema(description = "分类排序", required = true, example = "1") - private Integer sort; - - @Schema(description = "分类描述", required = true, example = "描述") - private String description; - - @Schema(description = "开启状态", required = true, example = "0") - @NotNull(message = "开启状态不能为空") - private Integer status; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/category/vo/ProductCategoryCreateReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/category/vo/ProductCategoryCreateReqVO.java deleted file mode 100644 index 577b9e774..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/category/vo/ProductCategoryCreateReqVO.java +++ /dev/null @@ -1,11 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.category.vo; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; - -@Schema(description = "管理后台 - 商品分类创建 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class ProductCategoryCreateReqVO extends ProductCategoryBaseVO { - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/category/vo/ProductCategoryListReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/category/vo/ProductCategoryListReqVO.java deleted file mode 100644 index 9c9439d3e..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/category/vo/ProductCategoryListReqVO.java +++ /dev/null @@ -1,13 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.category.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "管理后台 - 商品分类列表查询 Request VO") -@Data -public class ProductCategoryListReqVO { - - @Schema(description = "分类名称", example = "办公文具") - private String name; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/category/vo/ProductCategoryRespVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/category/vo/ProductCategoryRespVO.java deleted file mode 100644 index 4e2b64188..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/category/vo/ProductCategoryRespVO.java +++ /dev/null @@ -1,19 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.category.vo; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 商品分类 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class ProductCategoryRespVO extends ProductCategoryBaseVO { - - @Schema(description = "分类编号", required = true, example = "2") - private Long id; - - @Schema(description = "创建时间", required = true) - private LocalDateTime createTime; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/category/vo/ProductCategoryUpdateReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/category/vo/ProductCategoryUpdateReqVO.java deleted file mode 100644 index 01deb165c..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/category/vo/ProductCategoryUpdateReqVO.java +++ /dev/null @@ -1,16 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.category.vo; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; -import javax.validation.constraints.*; - -@Schema(description = "管理后台 - 商品分类更新 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class ProductCategoryUpdateReqVO extends ProductCategoryBaseVO { - - @Schema(description = "分类编号", required = true, example = "2") - @NotNull(message = "分类编号不能为空") - private Long id; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/ProductPropertyController.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/ProductPropertyController.java deleted file mode 100644 index 8f5120723..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/ProductPropertyController.java +++ /dev/null @@ -1,99 +0,0 @@ -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.PageResult; -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.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.ProductPropertyValueService; -import io.swagger.v3.oas.annotations.tags.Tag; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.Operation; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.validation.Valid; -import java.util.Collections; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; - -@Tag(name = "管理后台 - 商品属性项") -@RestController -@RequestMapping("/product/property") -@Validated -public class ProductPropertyController { - - @Resource - private ProductPropertyService productPropertyService; - @Resource - private ProductPropertyValueService productPropertyValueService; - - @PostMapping("/create") - @Operation(summary = "创建属性项") - @PreAuthorize("@ss.hasPermission('product:property:create')") - public CommonResult createProperty(@Valid @RequestBody ProductPropertyCreateReqVO createReqVO) { - return success(productPropertyService.createProperty(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新属性项") - @PreAuthorize("@ss.hasPermission('product:property:update')") - public CommonResult updateProperty(@Valid @RequestBody ProductPropertyUpdateReqVO updateReqVO) { - productPropertyService.updateProperty(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除属性项") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('product:property:delete')") - public CommonResult deleteProperty(@RequestParam("id") Long id) { - productPropertyService.deleteProperty(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得属性项") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('product:property:query')") - public CommonResult getProperty(@RequestParam("id") Long id) { - return success(ProductPropertyConvert.INSTANCE.convert(productPropertyService.getProperty(id))); - } - - @GetMapping("/list") - @Operation(summary = "获得属性项列表") - @PreAuthorize("@ss.hasPermission('product:property:query')") - public CommonResult> getPropertyList(@Valid ProductPropertyListReqVO listReqVO) { - return success(ProductPropertyConvert.INSTANCE.convertList(productPropertyService.getPropertyList(listReqVO))); - } - - @GetMapping("/page") - @Operation(summary = "获得属性项分页") - @PreAuthorize("@ss.hasPermission('product:property:query')") - public CommonResult> getPropertyPage(@Valid ProductPropertyPageReqVO pageVO) { - return success(ProductPropertyConvert.INSTANCE.convertPage(productPropertyService.getPropertyPage(pageVO))); - } - - @GetMapping("/get-value-list") - @Operation(summary = "获得属性项列表") - @PreAuthorize("@ss.hasPermission('product:property:query')") - public CommonResult> getPropertyAndValueList(@Valid ProductPropertyListReqVO listReqVO) { - // 查询属性项 - List keys = productPropertyService.getPropertyList(listReqVO); - if (CollUtil.isEmpty(keys)) { - return success(Collections.emptyList()); - } - // 查询属性值 - List values = productPropertyValueService.getPropertyValueListByPropertyId( - convertSet(keys, ProductPropertyDO::getId)); - return success(ProductPropertyConvert.INSTANCE.convertList(keys, values)); - } - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/ProductPropertyValueController.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/ProductPropertyValueController.java deleted file mode 100644 index 5c377220a..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/ProductPropertyValueController.java +++ /dev/null @@ -1,70 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.property; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValueCreateReqVO; -import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValuePageReqVO; -import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValueRespVO; -import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValueUpdateReqVO; -import cn.iocoder.yudao.module.product.convert.propertyvalue.ProductPropertyValueConvert; -import cn.iocoder.yudao.module.product.service.property.ProductPropertyValueService; -import io.swagger.v3.oas.annotations.tags.Tag; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.Operation; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.validation.Valid; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "管理后台 - 商品属性值") -@RestController -@RequestMapping("/product/property/value") -@Validated -public class ProductPropertyValueController { - - @Resource - private ProductPropertyValueService productPropertyValueService; - - @PostMapping("/create") - @Operation(summary = "创建属性值") - @PreAuthorize("@ss.hasPermission('product:property:create')") - public CommonResult createProperty(@Valid @RequestBody ProductPropertyValueCreateReqVO createReqVO) { - return success(productPropertyValueService.createPropertyValue(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新属性值") - @PreAuthorize("@ss.hasPermission('product:property:update')") - public CommonResult updateProperty(@Valid @RequestBody ProductPropertyValueUpdateReqVO updateReqVO) { - productPropertyValueService.updatePropertyValue(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除属性值") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('product:property:delete')") - public CommonResult deleteProperty(@RequestParam("id") Long id) { - productPropertyValueService.deletePropertyValue(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得属性值") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('product:property:query')") - public CommonResult getProperty(@RequestParam("id") Long id) { - return success(ProductPropertyValueConvert.INSTANCE.convert(productPropertyValueService.getPropertyValue(id))); - } - - @GetMapping("/page") - @Operation(summary = "获得属性值分页") - @PreAuthorize("@ss.hasPermission('product:property:query')") - public CommonResult> getPropertyValuePage(@Valid ProductPropertyValuePageReqVO pageVO) { - return success(ProductPropertyValueConvert.INSTANCE.convertPage(productPropertyValueService.getPropertyValuePage(pageVO))); - } -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/ProductPropertyViewRespVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/ProductPropertyViewRespVO.java deleted file mode 100644 index e69de29bb..000000000 diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/property/ProductPropertyAndValueRespVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/property/ProductPropertyAndValueRespVO.java deleted file mode 100644 index ec569d1f3..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/property/ProductPropertyAndValueRespVO.java +++ /dev/null @@ -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 { - - @ApiModelProperty(value = "属性项的编号", required = true, example = "1024") - private Long id; - - @ApiModelProperty(value = "属性项的名称", required = true, example = "颜色") - private String name; - - /** - * 属性值的集合 - */ - private List values; - - @ApiModel("管理后台 - 属性值的简单 Response VO") - @Data - public static class Value { - - @Schema(description = "属性值的编号", required = true, example = "2048") - private Long id; - - @Schema(description = "属性值的名称", required = true, example = "红色") - private String name; - - } - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/property/ProductPropertyBaseVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/property/ProductPropertyBaseVO.java deleted file mode 100644 index 1f05af4b2..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/property/ProductPropertyBaseVO.java +++ /dev/null @@ -1,22 +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 javax.validation.constraints.NotBlank; - -/** - * 商品属性项 Base VO,提供给添加、修改、详细的子 VO 使用 - * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 - */ -@Data -public class ProductPropertyBaseVO { - - @Schema(description = "名称", required = true, example = "颜色") - @NotBlank(message = "名称不能为空") - private String name; - - @Schema(description = "备注", example = "颜色") - private String remark; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/property/ProductPropertyCreateReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/property/ProductPropertyCreateReqVO.java deleted file mode 100644 index b854dd73c..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/property/ProductPropertyCreateReqVO.java +++ /dev/null @@ -1,15 +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 lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "管理后台 - 属性项创建 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class ProductPropertyCreateReqVO extends ProductPropertyBaseVO { - - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/property/ProductPropertyListReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/property/ProductPropertyListReqVO.java deleted file mode 100644 index 242caff84..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/property/ProductPropertyListReqVO.java +++ /dev/null @@ -1,15 +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 lombok.ToString; - -@Schema(description = "管理后台 - 属性项 List Request VO") -@Data -@ToString(callSuper = true) -public class ProductPropertyListReqVO { - - @Schema(description = "名称", example = "颜色") - private String name; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/property/ProductPropertyPageReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/property/ProductPropertyPageReqVO.java deleted file mode 100644 index a725e2076..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/property/ProductPropertyPageReqVO.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.property.vo.property; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 属性项 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class ProductPropertyPageReqVO extends PageParam { - - @Schema(description = "名称", example = "颜色") - private String name; - - @Schema(description = "状态-参见 CommonStatusEnum 枚举", required = true, example = "1") - private Integer status; - - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - @Schema(description = "创建时间") - private LocalDateTime[] createTime; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/property/ProductPropertyRespVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/property/ProductPropertyRespVO.java deleted file mode 100644 index b33e615fc..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/property/ProductPropertyRespVO.java +++ /dev/null @@ -1,22 +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 lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 属性项 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class ProductPropertyRespVO extends ProductPropertyBaseVO { - - @Schema(description = "编号", required = true, example = "1024") - private Long id; - - @Schema(description = "创建时间", required = true) - private LocalDateTime createTime; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/property/ProductPropertyUpdateReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/property/ProductPropertyUpdateReqVO.java deleted file mode 100644 index 33ba8f2c1..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/property/ProductPropertyUpdateReqVO.java +++ /dev/null @@ -1,20 +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 lombok.EqualsAndHashCode; -import lombok.ToString; - -import javax.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 属性项更新 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class ProductPropertyUpdateReqVO extends ProductPropertyBaseVO { - - @Schema(description = "主键", required = true, example = "1") - @NotNull(message = "主键不能为空") - private Long id; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/value/ProductPropertyValueBaseVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/value/ProductPropertyValueBaseVO.java deleted file mode 100644 index da3bf5068..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/value/ProductPropertyValueBaseVO.java +++ /dev/null @@ -1,27 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.property.vo.value; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; - -/** -* 属性值 Base VO,提供给添加、修改、详细的子 VO 使用 -* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 -*/ -@Data -public class ProductPropertyValueBaseVO { - - @Schema(description = "属性项的编号", required = true, example = "1024") - @NotNull(message = "属性项的编号不能为空") - private Long propertyId; - - @Schema(description = "名称", required = true, example = "红色") - @NotEmpty(message = "名称名字不能为空") - private String name; - - @Schema(description = "备注", example = "颜色") - private String remark; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/value/ProductPropertyValueCreateReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/value/ProductPropertyValueCreateReqVO.java deleted file mode 100644 index a643927ae..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/value/ProductPropertyValueCreateReqVO.java +++ /dev/null @@ -1,12 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.property.vo.value; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; - -@Schema(description = "管理后台 - 商品属性值创建 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class ProductPropertyValueCreateReqVO extends ProductPropertyValueBaseVO { - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/value/ProductPropertyValueDetailRespVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/value/ProductPropertyValueDetailRespVO.java deleted file mode 100644 index 55bae16df..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/value/ProductPropertyValueDetailRespVO.java +++ /dev/null @@ -1,23 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.property.vo.value; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; - -@ApiModel("管理后台 - 商品属性值的明细 Response VO") -@Data -public class ProductPropertyValueDetailRespVO { - - @ApiModelProperty(value = "属性的编号", required = true, example = "1") - private Long propertyId; - - @ApiModelProperty(value = "属性的名称", required = true, example = "颜色") - private String propertyName; - - @ApiModelProperty(value = "属性值的编号", required = true, example = "1024") - private Long valueId; - - @ApiModelProperty(value = "属性值的名称", required = true, example = "红色") - private String valueName; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/value/ProductPropertyValuePageReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/value/ProductPropertyValuePageReqVO.java deleted file mode 100644 index e484324f0..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/value/ProductPropertyValuePageReqVO.java +++ /dev/null @@ -1,24 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.property.vo.value; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "管理后台 - 商品属性值分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class ProductPropertyValuePageReqVO extends PageParam { - - @Schema(description = "属性项的编号", example = "1024") - private String propertyId; - - @Schema(description = "名称", example = "红色") - private String name; - - @Schema(description = "状态 - 参见 CommonStatusEnum 枚举", required = true, example = "1") - private Integer status; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/value/ProductPropertyValueRespVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/value/ProductPropertyValueRespVO.java deleted file mode 100644 index dac075b86..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/value/ProductPropertyValueRespVO.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.property.vo.value; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 商品属性值 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class ProductPropertyValueRespVO extends ProductPropertyValueBaseVO { - - @Schema(description = "编号", required = true, example = "10") - private Long id; - - @Schema(description = "创建时间") - private LocalDateTime createTime; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/value/ProductPropertyValueUpdateReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/value/ProductPropertyValueUpdateReqVO.java deleted file mode 100644 index e23b8927c..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/value/ProductPropertyValueUpdateReqVO.java +++ /dev/null @@ -1,17 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.property.vo.value; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; -import javax.validation.constraints.*; - -@Schema(description = "管理后台 - 商品属性值更新 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class ProductPropertyValueUpdateReqVO extends ProductPropertyValueBaseVO { - - @Schema(description = "主键", required = true, example = "1024") - @NotNull(message = "主键不能为空") - private Long id; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/ProductSkuController.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/ProductSkuController.java deleted file mode 100755 index 6c8601782..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/ProductSkuController.java +++ /dev/null @@ -1,57 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.sku; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.util.collection.MapUtils; -import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuOptionRespVO; -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.spu.ProductSpuDO; -import cn.iocoder.yudao.module.product.service.sku.ProductSkuService; -import cn.iocoder.yudao.module.product.service.spu.ProductSpuService; -import io.swagger.v3.oas.annotations.tags.Tag; -import io.swagger.v3.oas.annotations.Operation; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; -import java.util.Collections; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; - -@Tag(name = "管理后台 - 商品 sku") -@RestController -@RequestMapping("/product/sku") -@Validated -public class ProductSkuController { - - @Resource - private ProductSkuService productSkuService; - @Resource - private ProductSpuService productSpuService; - - @GetMapping("/get-option-list") - @Operation(summary = "获得商品 SKU 选项的列表") -// @PreAuthorize("@ss.hasPermission('product:sku:query')") - public CommonResult> getSkuOptionList() { - // 获得 SKU 列表 - List skus = productSkuService.getSkuList(); - if (CollUtil.isEmpty(skus)) { - return success(Collections.emptyList()); - } - - // 获得对应的 SPU 映射 - Map spuMap = productSpuService.getSpuMap(convertSet(skus, ProductSkuDO::getSpuId)); - // 转换为返回结果 - List skuVOs = ProductSkuConvert.INSTANCE.convertList05(skus); - skuVOs.forEach(sku -> MapUtils.findAndThen(spuMap, sku.getSpuId(), - spu -> sku.setSpuId(spu.getId()).setSpuName(spu.getName()))); - return success(skuVOs); - } - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/vo/ProductSkuBaseVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/vo/ProductSkuBaseVO.java deleted file mode 100755 index 7c1117d57..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/vo/ProductSkuBaseVO.java +++ /dev/null @@ -1,75 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.sku.vo; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; - -/** -* 商品 SKU Base VO,提供给添加、修改、详细的子 VO 使用 -* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 -*/ -@Data -public class ProductSkuBaseVO { - - @Schema(description = "商品 SKU 名字", required = true, example = "芋道") - @NotEmpty(message = "商品 SKU 名字不能为空") - private String name; - - @Schema(description = "销售价格,单位:分", required = true, example = "1024", notes = "单位:分") - @NotNull(message = "销售价格,单位:分不能为空") - private Integer price; - - @Schema(description = "市场价", example = "1024", notes = "单位:分") - private Integer marketPrice; - - @Schema(description = "成本价", example = "1024", notes = "单位:分") - private Integer costPrice; - - @Schema(description = "条形码", example = "haha") - private String barCode; - - @Schema(description = "图片地址", required = true, example = "https://www.iocoder.cn/xx.png") - @NotNull(message = "图片地址不能为空") - private String picUrl; - - @Schema(description = "SKU 状态", required = true, example = "1", notes = "参见 CommonStatusEnum 枚举") - @NotNull(message = "SKU 状态不能为空") - @InEnum(CommonStatusEnum.class) - private Integer status; - - @Schema(description = "库存", required = true, example = "1") - @NotNull(message = "库存不能为空") - private Integer stock; - - @Schema(description = "预警预存", example = "1") - private Integer warnStock; - - @Schema(description = "商品重量 - 单位:kg 千克", example = "1") - private Double weight; - - @Schema(description = "商品体积 - 单位:m^3 平米", example = "1024") - private Double volume; - - @ApiModel("商品属性") - @Data - @AllArgsConstructor - @NoArgsConstructor - public static class Property { - - @Schema(description = "属性编号", required = true, example = "1") - @NotNull(message = "属性编号不能为空") - private Long propertyId; - - @Schema(description = "属性值编号", required = true, example = "1024") - @NotNull(message = "属性值编号不能为空") - private Long valueId; - - } - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/vo/ProductSkuCreateOrUpdateReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/vo/ProductSkuCreateOrUpdateReqVO.java deleted file mode 100755 index 496475f99..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/vo/ProductSkuCreateOrUpdateReqVO.java +++ /dev/null @@ -1,21 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.sku.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.util.List; - -@Schema(description = "管理后台 - 商品 SKU 创建/更新 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class ProductSkuCreateOrUpdateReqVO extends ProductSkuBaseVO { - - /** - * 属性数组 - */ - private List properties; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/vo/ProductSkuOptionRespVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/vo/ProductSkuOptionRespVO.java deleted file mode 100644 index 1522ca59e..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/vo/ProductSkuOptionRespVO.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.sku.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "管理后台 - 商品 SKU 选项 Response VO,用于前端 SELECT 选项") -@Data -public class ProductSkuOptionRespVO { - - @Schema(description = "主键", required = true, example = "1024") - private Long id; - - @Schema(description = "商品 SKU 名字", example = "红色") - private String name; - - @Schema(description = "销售价格,单位:分", required = true, example = "100") - private String price; - - @Schema(description = "库存", required = true, example = "100") - private Integer stock; - - // ========== 商品 SPU 信息 ========== - - @Schema(description = "商品 SPU 编号", required = true, example = "1") - private Long spuId; - - @Schema(description = "商品 SPU 名字", required = true, example = "iPhone 11") - private String spuName; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/vo/ProductSkuRespVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/vo/ProductSkuRespVO.java deleted file mode 100755 index 95e394ada..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/vo/ProductSkuRespVO.java +++ /dev/null @@ -1,28 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.sku.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.time.LocalDateTime; -import java.util.List; - -@Schema(description = "管理后台 - 商品 SKU Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class ProductSkuRespVO extends ProductSkuBaseVO { - - @Schema(description = "主键", required = true, example = "1024") - private Long id; - - @Schema(description = "创建时间") - private LocalDateTime createTime; - - /** - * 属性数组 - */ - private List properties; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/ProductSpuController.http b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/ProductSpuController.http deleted file mode 100644 index 4ab7b4f71..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/ProductSpuController.http +++ /dev/null @@ -1,4 +0,0 @@ -### 获得商品 SPU 明细 -GET {{baseUrl}}/product/spu/get-detail?id=4 -Authorization: Bearer {{token}} -tenant-id: {{adminTenentId}} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/ProductSpuController.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/ProductSpuController.java deleted file mode 100755 index 10da8104f..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/ProductSpuController.java +++ /dev/null @@ -1,101 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.spu; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.product.controller.admin.spu.vo.*; -import cn.iocoder.yudao.module.product.convert.sku.ProductSkuConvert; -import cn.iocoder.yudao.module.product.convert.spu.ProductSpuConvert; -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.service.property.ProductPropertyValueService; -import cn.iocoder.yudao.module.product.service.property.bo.ProductPropertyValueDetailRespBO; -import cn.iocoder.yudao.module.product.service.sku.ProductSkuService; -import cn.iocoder.yudao.module.product.service.spu.ProductSpuService; -import io.swagger.v3.oas.annotations.tags.Tag; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.Operation; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.validation.Valid; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.SPU_NOT_EXISTS; - -@Tag(name = "管理后台 - 商品 SPU") -@RestController -@RequestMapping("/product/spu") -@Validated -public class ProductSpuController { - - @Resource - private ProductSpuService productSpuService; - @Resource - private ProductSkuService productSkuService; - @Resource - private ProductPropertyValueService productPropertyValueService; - - @PostMapping("/create") - @Operation(summary = "创建商品 SPU") - @PreAuthorize("@ss.hasPermission('product:spu:create')") - public CommonResult createProductSpu(@Valid @RequestBody ProductSpuCreateReqVO createReqVO) { - return success(productSpuService.createSpu(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新商品 SPU") - @PreAuthorize("@ss.hasPermission('product:spu:update')") - public CommonResult updateSpu(@Valid @RequestBody ProductSpuUpdateReqVO updateReqVO) { - productSpuService.updateSpu(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除商品 SPU") - @ApiImplicitParam(name = "id", value = "编号", required = true, dataTypeClass = Long.class) - @PreAuthorize("@ss.hasPermission('product:spu:delete')") - public CommonResult deleteSpu(@RequestParam("id") Long id) { - productSpuService.deleteSpu(id); - return success(true); - } - - @GetMapping("/get-detail") - @Operation(summary = "获得商品 SPU 明细") - @Parameter(name = "id", value = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('product:spu:query')") - public CommonResult getSpuDetail(@RequestParam("id") Long id) { - // 获得商品 SPU - ProductSpuDO spu = productSpuService.getSpu(id); - if (spu == null) { - throw exception(SPU_NOT_EXISTS); - } - - // 查询商品 SKU - List skus = productSkuService.getSkuListBySpuIdAndStatus(spu.getId(), null); - // 查询商品属性 - List propertyValues = productPropertyValueService - .getPropertyValueDetailList(ProductSkuConvert.INSTANCE.convertPropertyValueIds(skus)); - // 拼接 - return success(ProductSpuConvert.INSTANCE.convert03(spu, skus, propertyValues)); - } - - @GetMapping("/get-simple-list") - @Operation(summary = "获得商品 SPU 精简列表") - @PreAuthorize("@ss.hasPermission('product:spu:query')") - public CommonResult> getSpuSimpleList() { - List list = productSpuService.getSpuList(); - return success(ProductSpuConvert.INSTANCE.convertList02(list)); - } - - @GetMapping("/page") - @Operation(summary = "获得商品 SPU 分页") - @PreAuthorize("@ss.hasPermission('product:spu:query')") - public CommonResult> getSpuPage(@Valid ProductSpuPageReqVO pageVO) { - return success(ProductSpuConvert.INSTANCE.convertPage(productSpuService.getSpuPage(pageVO))); - } - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuBaseVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuBaseVO.java deleted file mode 100755 index 22d1d3025..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuBaseVO.java +++ /dev/null @@ -1,76 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.spu.vo; - -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.module.product.enums.spu.ProductSpuSpecTypeEnum; -import cn.iocoder.yudao.module.product.enums.spu.ProductSpuStatusEnum; -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; - -/** - * 商品 SPU Base VO,提供给添加、修改、详细的子 VO 使用 - * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 - */ -@Data -public class ProductSpuBaseVO { - - @Schema(description = = "商品名称", required = true, example = "芋道") - @NotEmpty(message = "商品名称不能为空") - private String name; - - @Schema(description = = "商品编码", example = "yudaoyuanma") - private String code; - - @Schema(description = = "促销语", example = "好吃!") - private String sellPoint; - - @Schema(description = = "商品详情", required = true, example = "我是商品描述") - @NotNull(message = "商品详情不能为空") - private String description; - - @Schema(description = = "商品分类编号", required = true, example = "1") - @NotNull(message = "商品分类编号不能为空") - private Long categoryId; - - @Schema(description = = "商品品牌编号", example = "1") - private Long brandId; - - @Schema(description = = "商品图片的数组", required = true) - @NotNull(message = "商品图片的数组不能为空") - private List picUrls; - - @Schema(description = = "商品视频", required = true) - private String videoUrl; - - @Schema(description = = "排序字段", required = true, example = "1") - private Integer sort; - - @Schema(description = = "商品状态 参见 ProductSpuStatusEnum 枚举类", required = true, example = "1") - @NotNull(message = "商品状态不能为空") - @InEnum(ProductSpuStatusEnum.class) - private Integer status; - - // ========== SKU 相关字段 ========= - - @Schema(description = = "规格类型 参见 ProductSpuSpecTypeEnum 枚举类", required = true, example = "1") - @NotNull(message = "规格类型不能为空") - @InEnum(ProductSpuSpecTypeEnum.class) - private Integer specType; - - @Schema(description = = "是否展示库存", required = true, example = "true") - @NotNull(message = "是否展示库存不能为空") - private Boolean showStock; - - @Schema(description = = "市场价", example = "1024") - private Integer marketPrice; - - // ========== 统计相关字段 ========= - - @Schema(description = = "虚拟销量", required = true, example = "1024") - @NotNull(message = "虚拟销量不能为空") - private Integer virtualSalesCount; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuCreateReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuCreateReqVO.java deleted file mode 100755 index c75ed4d2e..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuCreateReqVO.java +++ /dev/null @@ -1,24 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.spu.vo; - -import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuCreateOrUpdateReqVO; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import javax.validation.Valid; -import java.util.List; - -@Schema(description = "管理后台 - 商品 SPU 创建 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class ProductSpuCreateReqVO extends ProductSpuBaseVO { - - /** - * SKU 数组 - */ - @Valid - private List skus; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuDetailRespVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuDetailRespVO.java deleted file mode 100644 index a8cf9f5b9..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuDetailRespVO.java +++ /dev/null @@ -1,38 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.spu.vo; - -import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValueDetailRespVO; -import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuBaseVO; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.util.List; - -@Schema(description = "管理后台 - 商品 SPU 详细 Response VO 包括关联的 SKU 等信息") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class ProductSpuDetailRespVO extends ProductSpuRespVO { - - // ========== SKU 相关字段 ========= - - /** - * SKU 数组 - */ - private List skus; - - @Schema(description = "管理后台 - 商品 SKU 详细 Response VO") - @Data - @EqualsAndHashCode(callSuper = true) - @ToString(callSuper = true) - public static class Sku extends ProductSkuBaseVO { - - /** - * 属性数组 - */ - private List properties; - - } - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuPageReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuPageReqVO.java deleted file mode 100755 index d4714328f..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuPageReqVO.java +++ /dev/null @@ -1,45 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.spu.vo; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "管理后台 - 商品 SPU 分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class ProductSpuPageReqVO extends PageParam { - - @Schema(description = "商品名称", example = "yutou") - private String name; - - @Schema(description = "商品编码", example = "yudaoyuanma") - private String code; - - @Schema(description = "分类编号", example = "1") - private Long categoryId; - - @Schema(description = "商品品牌编号", example = "1") - private Long brandId; - - @Schema(description = "上下架状态 参见 ProductSpuStatusEnum 枚举值", example = "1") - private Integer status; - - @Schema(description = "销量最小值", example = "1") - private Integer salesCountMin; - - @Schema(description = "销量最大值", example = "1024") - private Integer salesCountMax; - - @Schema(description = "市场价最小值", example = "1") - private Integer marketPriceMin; - - @Schema(description = "市场价最大值", example = "1024") - private Integer marketPriceMax; - - @Schema(description = "是否库存告警", example = "true") - private Boolean alarmStock; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuRespVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuRespVO.java deleted file mode 100755 index 49303a7a3..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuRespVO.java +++ /dev/null @@ -1,40 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.spu.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 商品 SPU Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class ProductSpuRespVO extends ProductSpuBaseVO { - - @Schema(description = "主键", required = true, example = "1") - private Long id; - - @Schema(description = "创建时间") - private LocalDateTime createTime; - - // ========== SKU 相关字段 ========= - - @ApiModelProperty(value = "库存", required = true, example = "true") - private Integer totalStock; - - @ApiModelProperty(value = " 最小价格,单位使用:分", required = true, example = "1024") - private Integer minPrice; - - @ApiModelProperty(value = "最大价格,单位使用:分", required = true, example = "1024") - private Integer maxPrice; - - @ApiModelProperty(value = "商品销量", example = "1024") - private Integer salesCount; - - // ========== 统计相关字段 ========= - - @ApiModelProperty(value = "点击量", example = "1024") - private Integer clickCount; -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuSimpleRespVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuSimpleRespVO.java deleted file mode 100755 index 9cc7bf169..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuSimpleRespVO.java +++ /dev/null @@ -1,26 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.spu.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "管理后台 - 商品 SPU 精简 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class ProductSpuSimpleRespVO extends ProductSpuBaseVO { - - @Schema(description = "主键", required = true, example = "1") - private Long id; - - @Schema(description = "商品名称", required = true, example = "芋道") - private String name; - - @Schema(description = " 最小价格,单位使用:分", required = true, example = "1024") - private Integer minPrice; - - @Schema(description = "最大价格,单位使用:分", required = true, example = "1024") - private Integer maxPrice; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuUpdateReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuUpdateReqVO.java deleted file mode 100755 index 6ea84fb9e..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuUpdateReqVO.java +++ /dev/null @@ -1,29 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.spu.vo; - -import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuCreateOrUpdateReqVO; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import javax.validation.Valid; -import javax.validation.constraints.NotNull; -import java.util.List; - -@Schema(description = "管理后台 - 商品 SPU 更新 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class ProductSpuUpdateReqVO extends ProductSpuBaseVO { - - @Schema(description = "商品编号", required = true, example = "1") - @NotNull(message = "商品编号不能为空") - private Long id; - - /** - * SKU 数组 - */ - @Valid - private List skus; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/category/AppCategoryController.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/category/AppCategoryController.java deleted file mode 100644 index 79f066de4..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/category/AppCategoryController.java +++ /dev/null @@ -1,38 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.app.category; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.product.controller.app.category.vo.AppCategoryRespVO; -import cn.iocoder.yudao.module.product.convert.category.ProductCategoryConvert; -import cn.iocoder.yudao.module.product.dal.dataobject.category.ProductCategoryDO; -import cn.iocoder.yudao.module.product.service.category.ProductCategoryService; -import io.swagger.v3.oas.annotations.tags.Tag; -import io.swagger.v3.oas.annotations.Operation; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; -import java.util.Comparator; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "用户 APP - 商品分类") -@RestController -@RequestMapping("/product/category") -@Validated -public class AppCategoryController { - - @Resource - private ProductCategoryService categoryService; - - @GetMapping("/list") - @Operation(summary = "获得商品分类列表") - public CommonResult> getProductCategoryList() { - List list = categoryService.getEnableCategoryList(); - list.sort(Comparator.comparing(ProductCategoryDO::getSort)); - return success(ProductCategoryConvert.INSTANCE.convertList03(list)); - } - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/category/vo/AppCategoryRespVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/category/vo/AppCategoryRespVO.java deleted file mode 100644 index 1dca05a3a..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/category/vo/AppCategoryRespVO.java +++ /dev/null @@ -1,28 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.app.category.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.NotNull; - -@Data -@Schema(description = "用户 APP - 商品分类 Response VO") -public class AppCategoryRespVO { - - @Schema(description = "分类编号", required = true, example = "2") - private Long id; - - @Schema(description = "父分类编号", required = true, example = "1") - @NotNull(message = "父分类编号不能为空") - private Long parentId; - - @Schema(description = "分类名称", required = true, example = "办公文具") - @NotBlank(message = "分类名称不能为空") - private String name; - - @Schema(description = "分类图片", required = true) - @NotBlank(message = "分类图片不能为空") - private String picUrl; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/property/package-info.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/property/package-info.java deleted file mode 100644 index 379e85180..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/property/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 占位符,无时间作用,避免 package 缩进 - */ -package cn.iocoder.yudao.module.product.controller.app.property; diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/property/vo/property/package-info.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/property/vo/property/package-info.java deleted file mode 100644 index 6538bea3c..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/property/vo/property/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 占位符,无时间作用,避免 package 缩进 - */ -package cn.iocoder.yudao.module.product.controller.app.property.vo.property; diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/property/vo/value/AppProductPropertyValueDetailRespVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/property/vo/value/AppProductPropertyValueDetailRespVO.java deleted file mode 100644 index 516dd077f..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/property/vo/value/AppProductPropertyValueDetailRespVO.java +++ /dev/null @@ -1,23 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.app.property.vo.value; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; - -@ApiModel("用户 App - 商品属性值的明细 Response VO") -@Data -public class AppProductPropertyValueDetailRespVO { - - @ApiModelProperty(value = "属性的编号", required = true, example = "1") - private Long propertyId; - - @ApiModelProperty(value = "属性的名称", required = true, example = "颜色") - private String propertyName; - - @ApiModelProperty(value = "属性值的编号", required = true, example = "1024") - private Long valueId; - - @ApiModelProperty(value = "属性值的名称", required = true, example = "红色") - private String valueName; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/AppProductSpuController.http b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/AppProductSpuController.http deleted file mode 100644 index 04df7bfec..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/AppProductSpuController.http +++ /dev/null @@ -1,8 +0,0 @@ -### 获得订单交易的分页 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 -tenant-id: {{appTenentId}} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/AppProductSpuController.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/AppProductSpuController.java deleted file mode 100644 index b2f8b495d..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/AppProductSpuController.java +++ /dev/null @@ -1,78 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.app.spu; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppProductSpuPageReqVO; -import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppProductSpuDetailRespVO; -import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppProductSpuPageItemRespVO; -import cn.iocoder.yudao.module.product.convert.sku.ProductSkuConvert; -import cn.iocoder.yudao.module.product.convert.spu.ProductSpuConvert; -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.enums.spu.ProductSpuStatusEnum; -import cn.iocoder.yudao.module.product.service.property.ProductPropertyValueService; -import cn.iocoder.yudao.module.product.service.property.bo.ProductPropertyValueDetailRespBO; -import cn.iocoder.yudao.module.product.service.sku.ProductSkuService; -import cn.iocoder.yudao.module.product.service.spu.ProductSpuService; -import io.swagger.v3.oas.annotations.tags.Tag; -import io.swagger.v3.oas.annotations.Operation; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; -import javax.validation.Valid; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.SPU_NOT_ENABLE; -import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.SPU_NOT_EXISTS; - -@Tag(name = "用户 APP - 商品spu") -@RestController -@RequestMapping("/product/spu") -@Validated -public class AppProductSpuController { - - @Resource - private ProductSpuService productSpuService; - @Resource - private ProductSkuService productSkuService; - @Resource - private ProductPropertyValueService productPropertyValueService; - - @GetMapping("/page") - @Operation(summary = "获得商品 SPU 分页") - public CommonResult> getSpuPage(@Valid AppProductSpuPageReqVO pageVO) { - PageResult pageResult = productSpuService.getSpuPage(pageVO, ProductSpuStatusEnum.ENABLE.getStatus()); - return success(ProductSpuConvert.INSTANCE.convertPage02(pageResult)); - } - - @GetMapping("/get-detail") - @Operation(summary = "获得商品 SPU 明细") - @ApiImplicitParam(name = "id", value = "编号", required = true, dataTypeClass = Long.class) - public CommonResult getSpuDetail(@RequestParam("id") Long id) { - // 获得商品 SPU - ProductSpuDO spu = productSpuService.getSpu(id); - if (spu == null) { - throw exception(SPU_NOT_EXISTS); - } - if (!ProductSpuStatusEnum.isEnable(spu.getStatus())) { - throw exception(SPU_NOT_ENABLE); - } - - // 查询商品 SKU - List skus = productSkuService.getSkuListBySpuIdAndStatus(spu.getId(), - CommonStatusEnum.ENABLE.getStatus()); - // 查询商品属性 - List propertyValues = productPropertyValueService - .getPropertyValueDetailList(ProductSkuConvert.INSTANCE.convertPropertyValueIds(skus)); - // 拼接 - return success(ProductSpuConvert.INSTANCE.convert(spu, skus, propertyValues)); - } - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/vo/AppProductSpuDetailRespVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/vo/AppProductSpuDetailRespVO.java deleted file mode 100644 index 699ca1caa..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/vo/AppProductSpuDetailRespVO.java +++ /dev/null @@ -1,92 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.app.spu.vo; - -import cn.iocoder.yudao.module.product.controller.app.property.vo.value.AppProductPropertyValueDetailRespVO; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; - -import java.util.List; - -@ApiModel("用户 App - 商品 SPU 明细 Response VO") -@Data -public class AppProductSpuDetailRespVO { - - @ApiModelProperty(value = "商品 SPU 编号", required = true, example = "1") - private Long id; - - // ========== 基本信息 ========= - - @ApiModelProperty(value = "商品名称", required = true, example = "芋道") - private String name; - - @ApiModelProperty(value = "促销语", example = "好吃!") - private String sellPoint; - - @ApiModelProperty(value = "商品详情", required = true, example = "我是商品描述") - private String description; - - @ApiModelProperty(value = "商品分类编号", required = true, example = "1") - private Long categoryId; - - @ApiModelProperty(value = "商品图片的数组", required = true) - private List picUrls; - - @ApiModelProperty(value = "商品视频", required = true) - private String videoUrl; - - // ========== SKU 相关字段 ========= - - @ApiModelProperty(value = "规格类型", required = true, example = "1", notes = "参见 ProductSpuSpecTypeEnum 枚举类") - private Integer specType; - - @ApiModelProperty(value = "是否展示库存", required = true, example = "true") - private Boolean showStock; - - @ApiModelProperty(value = " 最小价格,单位使用:分", required = true, example = "1024") - private Integer minPrice; - - @ApiModelProperty(value = "最大价格,单位使用:分", required = true, example = "1024") - private Integer maxPrice; - - /** - * SKU 数组 - */ - private List skus; - - // ========== 统计相关字段 ========= - - @ApiModelProperty(value = "商品销量", required = true, example = "1024") - private Integer salesCount; - - @ApiModel("用户 App - 商品 SPU 明细的 SKU 信息") - @Data - public static class Sku { - - @ApiModelProperty(value = "商品 SKU 编号", example = "1") - private Long id; - - /** - * 商品属性数组 - */ - private List properties; - - @ApiModelProperty(value = "销售价格,单位:分", required = true, example = "1024", notes = "单位:分") - private Integer price; - - @ApiModelProperty(value = "市场价", example = "1024", notes = "单位:分") - private Integer marketPrice; - - @ApiModelProperty(value = "图片地址", required = true, example = "https://www.iocoder.cn/xx.png") - private String picUrl; - - @ApiModelProperty(value = "库存", required = true, example = "1") - private Integer stock; - - @ApiModelProperty(value = "商品重量", example = "1", notes = "单位:kg 千克") - private Double weight; - - @ApiModelProperty(value = "商品体积", example = "1024", notes = "单位:m^3 平米") - private Double volume; - } - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/vo/AppProductSpuPageItemRespVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/vo/AppProductSpuPageItemRespVO.java deleted file mode 100644 index 60fc9235e..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/vo/AppProductSpuPageItemRespVO.java +++ /dev/null @@ -1,40 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.app.spu.vo; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; - -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; -import java.util.List; - -@ApiModel("用户 App - 商品 SPU 分页项 Response VO") -@Data -public class AppProductSpuPageItemRespVO { - - @ApiModelProperty(value = "商品 SPU 编号", required = true, example = "1") - private Long id; - - @ApiModelProperty(value = "商品名称", required = true, example = "芋道") - @NotEmpty(message = "商品名称不能为空") - private String name; - - @ApiModelProperty(value = "分类编号", required = true) - @NotNull(message = "分类编号不能为空") - private Long categoryId; - - @ApiModelProperty(value = "商品图片的数组", required = true) - private List picUrls; - - @ApiModelProperty(value = " 最小价格,单位使用:分", required = true, example = "1024") - private Integer minPrice; - - @ApiModelProperty(value = "最大价格,单位使用:分", required = true, example = "1024") - private Integer maxPrice; - - // ========== 统计相关字段 ========= - - @ApiModelProperty(value = "商品销量", example = "1024") - private Integer salesCount; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/vo/AppProductSpuPageReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/vo/AppProductSpuPageReqVO.java deleted file mode 100644 index f19a7c21a..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/vo/AppProductSpuPageReqVO.java +++ /dev/null @@ -1,44 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.app.spu.vo; - -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import com.fasterxml.jackson.annotation.JsonIgnore; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import javax.validation.constraints.AssertTrue; - -@ApiModel("用户 App - 商品 SPU 分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class AppProductSpuPageReqVO extends PageParam { - - public static final String SORT_FIELD_PRICE = "price"; - public static final String SORT_FIELD_SALES_COUNT = "salesCount"; - - @ApiModelProperty(value = "分类编号", example = "1") - private Long categoryId; - - @ApiModelProperty(value = "关键字", example = "好看") - private String keyword; - - @ApiModelProperty(value = "排序字段", example = "price", notes = "参见 AppSpuPageReqVO.SORT_FIELD_XXX 常量") - private String sortField; - - @ApiModelProperty(value = "排序方式", example = "true", notes = "true - 升序;false - 降序") - private Boolean sortAsc; - - @AssertTrue(message = "排序字段不合法") - @JsonIgnore - public boolean isSortFieldValid() { - if (StrUtil.isEmpty(sortField)) { - return true; - } - return StrUtil.equalsAny(sortField, SORT_FIELD_PRICE, SORT_FIELD_SALES_COUNT); - } - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/vo/AppSpuPageReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/vo/AppSpuPageReqVO.java deleted file mode 100644 index e69de29bb..000000000 diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/vo/AppSpuPageRespVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/vo/AppSpuPageRespVO.java deleted file mode 100644 index e69de29bb..000000000 diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/vo/AppSpuRespVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/vo/AppSpuRespVO.java deleted file mode 100644 index e69de29bb..000000000 diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/brand/ProductBrandConvert.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/brand/ProductBrandConvert.java deleted file mode 100644 index a318e9128..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/brand/ProductBrandConvert.java +++ /dev/null @@ -1,33 +0,0 @@ -package cn.iocoder.yudao.module.product.convert.brand; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.product.controller.admin.brand.vo.ProductBrandCreateReqVO; -import cn.iocoder.yudao.module.product.controller.admin.brand.vo.ProductBrandRespVO; -import cn.iocoder.yudao.module.product.controller.admin.brand.vo.ProductBrandUpdateReqVO; -import cn.iocoder.yudao.module.product.dal.dataobject.brand.ProductBrandDO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -import java.util.List; - -/** - * 品牌 Convert - * - * @author 芋道源码 - */ -@Mapper -public interface ProductBrandConvert { - - ProductBrandConvert INSTANCE = Mappers.getMapper(ProductBrandConvert.class); - - ProductBrandDO convert(ProductBrandCreateReqVO bean); - - ProductBrandDO convert(ProductBrandUpdateReqVO bean); - - ProductBrandRespVO convert(ProductBrandDO bean); - - List convertList(List list); - - PageResult convertPage(PageResult page); - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/category/ProductCategoryConvert.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/category/ProductCategoryConvert.java deleted file mode 100644 index ae01ca9d5..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/category/ProductCategoryConvert.java +++ /dev/null @@ -1,32 +0,0 @@ -package cn.iocoder.yudao.module.product.convert.category; - -import cn.iocoder.yudao.module.product.controller.admin.category.vo.ProductCategoryCreateReqVO; -import cn.iocoder.yudao.module.product.controller.admin.category.vo.ProductCategoryRespVO; -import cn.iocoder.yudao.module.product.controller.admin.category.vo.ProductCategoryUpdateReqVO; -import cn.iocoder.yudao.module.product.controller.app.category.vo.AppCategoryRespVO; -import cn.iocoder.yudao.module.product.dal.dataobject.category.ProductCategoryDO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -import java.util.List; - -/** - * 商品分类 Convert - * - * @author 芋道源码 - */ -@Mapper -public interface ProductCategoryConvert { - - ProductCategoryConvert INSTANCE = Mappers.getMapper(ProductCategoryConvert.class); - - ProductCategoryDO convert(ProductCategoryCreateReqVO bean); - - ProductCategoryDO convert(ProductCategoryUpdateReqVO bean); - - ProductCategoryRespVO convert(ProductCategoryDO bean); - - List convertList(List list); - - List convertList03(List list); -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/property/ProductPropertyConvert.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/property/ProductPropertyConvert.java deleted file mode 100644 index 211bcc293..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/property/ProductPropertyConvert.java +++ /dev/null @@ -1,48 +0,0 @@ -package cn.iocoder.yudao.module.product.convert.property; - -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.ProductPropertyRespVO; -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.ProductPropertyValueDO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -import java.util.List; -import java.util.Map; - -/** - * 属性项 Convert - * - * @author 芋道源码 - */ -@Mapper -public interface ProductPropertyConvert { - - ProductPropertyConvert INSTANCE = Mappers.getMapper(ProductPropertyConvert.class); - - ProductPropertyDO convert(ProductPropertyCreateReqVO bean); - - ProductPropertyDO convert(ProductPropertyUpdateReqVO bean); - - ProductPropertyRespVO convert(ProductPropertyDO bean); - - List convertList(List list); - - PageResult convertPage(PageResult page); - - default List convertList(List keys, List values) { - Map> valueMap = CollectionUtils.convertMultiMap(values, ProductPropertyValueDO::getPropertyId); - return CollectionUtils.convertList(keys, key -> { - ProductPropertyAndValueRespVO respVO = convert02(key); - respVO.setValues(convertList02(valueMap.get(key.getId()))); - return respVO; - }); - } - ProductPropertyAndValueRespVO convert02(ProductPropertyDO bean); - List convertList02(List list); - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/propertyvalue/ProductPropertyValueConvert.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/propertyvalue/ProductPropertyValueConvert.java deleted file mode 100644 index d6167c174..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/propertyvalue/ProductPropertyValueConvert.java +++ /dev/null @@ -1,55 +0,0 @@ -package cn.iocoder.yudao.module.product.convert.propertyvalue; - -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.MapUtils; -import cn.iocoder.yudao.module.product.api.property.dto.ProductPropertyValueDetailRespDTO; -import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValueCreateReqVO; -import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValueRespVO; -import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValueUpdateReqVO; -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.bo.ProductPropertyValueDetailRespBO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; - -/** - * 属性值 Convert - * - * @author 芋道源码 - */ -@Mapper -public interface ProductPropertyValueConvert { - - ProductPropertyValueConvert INSTANCE = Mappers.getMapper(ProductPropertyValueConvert.class); - - ProductPropertyValueDO convert(ProductPropertyValueCreateReqVO bean); - - ProductPropertyValueDO convert(ProductPropertyValueUpdateReqVO bean); - - ProductPropertyValueRespVO convert(ProductPropertyValueDO bean); - - List convertList(List list); - - PageResult convertPage(PageResult page); - - default List convertList(List values, List keys) { - Map keyMap = convertMap(keys, ProductPropertyDO::getId); - return CollectionUtils.convertList(values, value -> { - ProductPropertyValueDetailRespBO valueDetail = new ProductPropertyValueDetailRespBO() - .setValueId(value.getId()).setValueName(value.getName()); - // 设置属性项 - MapUtils.findAndThen(keyMap, value.getPropertyId(), - key -> valueDetail.setPropertyId(key.getId()).setPropertyName(key.getName())); - return valueDetail; - }); - } - - List convertList02(List list); - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/sku/ProductSkuConvert.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/sku/ProductSkuConvert.java deleted file mode 100755 index f397dfc48..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/sku/ProductSkuConvert.java +++ /dev/null @@ -1,93 +0,0 @@ -package cn.iocoder.yudao.module.product.convert.sku; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuRespDTO; -import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuUpdateStockReqDTO; -import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuCreateOrUpdateReqVO; -import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuOptionRespVO; -import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuRespVO; -import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSpuDetailRespVO; -import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -import java.util.*; -import java.util.stream.Collectors; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; - -/** - * 商品 SKU Convert - * - * @author 芋道源码 - */ -@Mapper -public interface ProductSkuConvert { - - ProductSkuConvert INSTANCE = Mappers.getMapper(ProductSkuConvert.class); - - ProductSkuDO convert(ProductSkuCreateOrUpdateReqVO bean); - - ProductSkuRespVO convert(ProductSkuDO bean); - - List convertList(List list); - - List convertList06(List list); - - default List convertList06(List list, Long spuId, String spuName) { - List result = convertList06(list); - result.forEach(item -> item.setSpuId(spuId).setSpuName(spuName)); - return result; - } - - ProductSkuRespDTO convert02(ProductSkuDO bean); - - List convertList03(List list); - - List convertList04(List list); - - List convertList05(List skus); - - /** - * 获得 SPU 的库存变化 Map - * - * @param items SKU 库存变化 - * @param skus SKU 列表 - * @return SPU 的库存变化 Map - */ - default Map convertSpuStockMap(List items, - List skus) { - Map skuIdAndSpuIdMap = convertMap(skus, ProductSkuDO::getId, ProductSkuDO::getSpuId); // SKU 与 SKU 编号的 Map 关系 - Map spuIdAndStockMap = new HashMap<>(); // SPU 的库存变化 Map 关系 - items.forEach(item -> { - Long spuId = skuIdAndSpuIdMap.get(item.getId()); - if (spuId == null) { - return; - } - Integer stock = spuIdAndStockMap.getOrDefault(spuId, 0) + item.getIncrCount(); - spuIdAndStockMap.put(spuId, stock); - }); - return spuIdAndStockMap; - } - - default Collection convertPropertyValueIds(List list) { - if (CollUtil.isEmpty(list)) { - return new HashSet<>(); - } - return list.stream().filter(item -> item.getProperties() != null) - .flatMap(p -> p.getProperties().stream()) // 遍历多个 Property 属性 - .map(ProductSkuDO.Property::getValueId) // 将每个 Property 转换成对应的 propertyId,最后形成集合 - .collect(Collectors.toSet()); - } - - default String buildPropertyKey(ProductSkuDO bean) { - if (CollUtil.isEmpty(bean.getProperties())) { - return StrUtil.EMPTY; - } - List properties = new ArrayList<>(bean.getProperties()); - properties.sort(Comparator.comparing(ProductSkuDO.Property::getValueId)); - return properties.stream().map(m -> String.valueOf(m.getValueId())).collect(Collectors.joining()); - } - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/spu/ProductSpuConvert.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/spu/ProductSpuConvert.java deleted file mode 100755 index fcf6d6436..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/spu/ProductSpuConvert.java +++ /dev/null @@ -1,108 +0,0 @@ -package cn.iocoder.yudao.module.product.convert.spu; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO; -import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValueDetailRespVO; -import cn.iocoder.yudao.module.product.controller.admin.spu.vo.*; -import cn.iocoder.yudao.module.product.controller.app.property.vo.value.AppProductPropertyValueDetailRespVO; -import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppProductSpuDetailRespVO; -import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppProductSpuPageReqVO; -import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppProductSpuPageItemRespVO; -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.service.property.bo.ProductPropertyValueDetailRespBO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import static cn.hutool.core.util.ObjectUtil.defaultIfNull; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; - -/** - * 商品 SPU Convert - * - * @author 芋道源码 - */ -@Mapper -public interface ProductSpuConvert { - - ProductSpuConvert INSTANCE = Mappers.getMapper(ProductSpuConvert.class); - - ProductSpuDO convert(ProductSpuCreateReqVO bean); - - ProductSpuDO convert(ProductSpuUpdateReqVO bean); - - List convertList(List list); - - PageResult convertPage(PageResult page); - - ProductSpuPageReqVO convert(AppProductSpuPageReqVO bean); - - List convertList2(List list); - - List convertList02(List list); - - default AppProductSpuDetailRespVO convert(ProductSpuDO spu, List skus, - List propertyValues) { - AppProductSpuDetailRespVO spuVO = convert02(spu) - .setSalesCount(spu.getSalesCount() + defaultIfNull(spu.getVirtualSalesCount(), 0)); - spuVO.setSkus(convertList03(skus)); - // 处理商品属性 - Map propertyValueMap = convertMap(propertyValues, ProductPropertyValueDetailRespBO::getValueId); - for (int i = 0; i < skus.size(); i++) { - List 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 convertList03(List skus); - AppProductPropertyValueDetailRespVO convert03(ProductPropertyValueDetailRespBO propertyValue); - - PageResult convertPage02(PageResult page); - - default ProductSpuDetailRespVO convert03(ProductSpuDO spu, List skus, - List propertyValues) { - ProductSpuDetailRespVO spuVO = convert03(spu); - spuVO.setSkus(convertList04(skus)); - // 处理商品属性 - Map propertyValueMap = convertMap(propertyValues, ProductPropertyValueDetailRespBO::getValueId); - for (int i = 0; i < skus.size(); i++) { - List properties = skus.get(i).getProperties(); - if (CollUtil.isEmpty(properties)) { - continue; - } - ProductSpuDetailRespVO.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(convert04(propertyValue)); - }); - } - return spuVO; - } - ProductSpuDetailRespVO convert03(ProductSpuDO spu); - List convertList04(List skus); - ProductPropertyValueDetailRespVO convert04(ProductPropertyValueDetailRespBO propertyValue); - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/brand/ProductBrandDO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/brand/ProductBrandDO.java deleted file mode 100644 index 9775f36a5..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/brand/ProductBrandDO.java +++ /dev/null @@ -1,53 +0,0 @@ -package cn.iocoder.yudao.module.product.dal.dataobject.brand; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -/** - * 商品品牌 DO - * - * @author 芋道源码 - */ -@TableName("product_brand") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class ProductBrandDO extends BaseDO { - - /** - * 品牌编号 - */ - @TableId - private Long id; - /** - * 品牌名称 - */ - private String name; - /** - * 品牌图片 - */ - private String picUrl; - /** - * 品牌排序 - */ - private Integer sort; - /** - * 品牌描述 - */ - private String description; - /** - * 状态 - * - * 枚举 {@link CommonStatusEnum} - */ - private Integer status; - - // TODO 芋艿:firstLetter 首字母 - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/category/ProductCategoryDO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/category/ProductCategoryDO.java deleted file mode 100644 index 93ec925a9..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/category/ProductCategoryDO.java +++ /dev/null @@ -1,67 +0,0 @@ -package cn.iocoder.yudao.module.product.dal.dataobject.category; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -/** - * 商品分类 DO - * - * 商品分类一共两类: - * 1)一级分类:{@link #parentId} 等于 0 - * 2)二级 + 三级分类:{@link #parentId} 不等于 0 - * - * @author 芋道源码 - */ -@TableName("product_category") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class ProductCategoryDO extends BaseDO { - - /** - * 父分类编号 - 根分类 - */ - public static final Long PARENT_ID_NULL = 0L; - - /** - * 分类编号 - */ - @TableId - private Long id; - /** - * 父分类编号 - */ - private Long parentId; - /** - * 分类名称 - */ - private String name; - /** - * 分类图片 - * - * 一级分类:推荐 200 x 100 分辨率 - * 二级 + 三级分类:推荐 100 x 100 分辨率 - */ - private String picUrl; - /** - * 分类排序 - */ - private Integer sort; - /** - * 分类描述 - */ - private String description; - /** - * 开启状态 - * - * 枚举 {@link CommonStatusEnum} - */ - private Integer status; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/comment/ProductCommentDO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/comment/ProductCommentDO.java deleted file mode 100644 index c14808f22..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/comment/ProductCommentDO.java +++ /dev/null @@ -1,129 +0,0 @@ -package cn.iocoder.yudao.module.product.dal.dataobject.comment; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO; -import cn.iocoder.yudao.module.product.enums.comment.ProductCommentAuditStatusEnum; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler; -import lombok.*; - -import java.time.LocalDateTime; -import java.util.List; - -/** - * 商品评论 DO - * - * @author 芋道源码 - */ -@TableName("product_comment") -@KeySequence("product_comment_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class ProductCommentDO extends BaseDO { - - /** - * 评论编号,主键自增 - */ - @TableId - private Long id; - /** - * 商品 SPU 编号 - * - * 关联 {@link ProductSpuDO#getId()} - */ - private Long spuId; - /** - * 交易订单编号 - * - * 关联 TradeOrderDO 的 id 编号 - */ - private Long orderId; - /** - * 交易订单项编号 - * - * 关联 TradeOrderItemDO 的 id 编号 - */ - private Long orderItemId; - /** - * 审核状态 - * - * 枚举 {@link ProductCommentAuditStatusEnum} - */ - private Integer auditStatus; - - /** - * 用户编号 - * - * 关联 MemberUserDO 的 id 编号 - */ - private Long userId; - /** - * 用户 IP - */ - private String userIp; - /** - * 是否匿名 - */ - private Boolean anonymous; - /** - * 评论内容 - */ - private String content; - /** - * 评论图片地址数组 - */ - @TableField(typeHandler = JacksonTypeHandler.class) - private List picUrls; - /** - * 描述相符星级 - * - * 1-5 星 - */ - private Integer descriptionScore; - /** - * 商品评论星级 - * - * 1-5 星 - */ - private Integer productScore; - /** - * 服务评论星级 - * - * 1-5 星 - */ - private Integer serviceScore; - /** - * 物流评论星级 - * - * 1-5 星 - */ - private Integer expressComment; - - /** - * 商家是否回复 - */ - private Boolean replied; - /** - * 商家回复内容 - */ - private String replyContent; - /** - * 商家回复时间 - */ - private LocalDateTime replyTime; - - /** - * 有用的计数 - * - * 其他用户看到评论时,可点击「有用」按钮 - */ - private Integer usefulCount; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/delivery/DeliveryTemplateDO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/delivery/DeliveryTemplateDO.java deleted file mode 100644 index 70445dc01..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/delivery/DeliveryTemplateDO.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.product.dal.dataobject.delivery; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -/** - * 配送模板 SPU DO - * - * @author 芋道源码 - */ -@TableName("delivery_template") -@KeySequence("delivery_template_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class DeliveryTemplateDO extends BaseDO { - - /** - * 编号,自增 - */ - @TableId - private Long id; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/favorite/ProductFavoriteDO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/favorite/ProductFavoriteDO.java deleted file mode 100644 index 54d4b31ac..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/favorite/ProductFavoriteDO.java +++ /dev/null @@ -1,45 +0,0 @@ -package cn.iocoder.yudao.module.product.dal.dataobject.favorite; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -/** - * 商品收藏 DO - * - * @author 芋道源码 - */ -@TableName("product_favorite") -@KeySequence("product_favorite_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class ProductFavoriteDO extends BaseDO { - - /** - * 编号,主键自增 - */ - @TableId - private Long id; - /** - * 用户编号 - * - * 关联 MemberUserDO 的 id 编号 - */ - private Long userId; - /** - * 商品 SPU 编号 - * - * 关联 {@link ProductSpuDO#getId()} - */ - private Long spuId; - - // TODO 芋艿:type 1 收藏;2 点赞 - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/group/ProductGroupBindDO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/group/ProductGroupBindDO.java deleted file mode 100644 index 2e3b63e59..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/group/ProductGroupBindDO.java +++ /dev/null @@ -1,43 +0,0 @@ -package cn.iocoder.yudao.module.product.dal.dataobject.group; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -/** - * 商品分组的绑定 DO - * - * @author 芋道源码 - */ -@TableName("product_group_bind") -@KeySequence("product_group_bind_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class ProductGroupBindDO extends BaseDO { - - /** - * 编号,自增 - */ - @TableId - private Long id; - /** - * 商品分组编号 - * - * 关联 {@link ProductGroupDO#getId()} - */ - private Long groupId; - /** - * 商品 SPU 编号 - * - * 关联 {@link ProductSpuDO#getId()} - */ - private Long spuId; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/group/ProductGroupDO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/group/ProductGroupDO.java deleted file mode 100644 index 605e8c38a..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/group/ProductGroupDO.java +++ /dev/null @@ -1,63 +0,0 @@ -package cn.iocoder.yudao.module.product.dal.dataobject.group; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.product.enums.group.ProductGroupStyleEnum; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -/** - * 商品分组 DO - * - * @author 芋道源码 - */ -@TableName("product_group") -@KeySequence("product_group_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class ProductGroupDO extends BaseDO { - - /** - * 商品分组编号,自增 - */ - @TableId - private Long id; - /** - * 分组名称 - */ - private String name; - /** - * 状态 - * - * 枚举 {@link CommonStatusEnum} - */ - private Integer status; - /** - * 商品数量 - */ - private Integer count; - /** - * 排序 - */ - private Integer sort; - /** - * 风格,用于 APP 首页展示商品的样式 - * - * 枚举 {@link ProductGroupStyleEnum} - */ - private Integer style; - /** - * 是否默认 - * - * true - 系统默认,不允许删除 - * false - 自定义,允许删除 - */ - private Boolean defaulted; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/property/ProductPropertyDO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/property/ProductPropertyDO.java deleted file mode 100644 index 2976674c1..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/property/ProductPropertyDO.java +++ /dev/null @@ -1,38 +0,0 @@ -package cn.iocoder.yudao.module.product.dal.dataobject.property; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -/** - * 商品属性项 DO - * - * @author 芋道源码 - */ -@TableName("product_property") -@KeySequence("product_property_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class ProductPropertyDO extends BaseDO { - - /** - * 主键 - */ - @TableId - private Long id; - /** - * 名称 - */ - private String name; - /** - * 备注 - */ - private String remark; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/property/ProductPropertyValueDO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/property/ProductPropertyValueDO.java deleted file mode 100644 index d73fe06b2..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/property/ProductPropertyValueDO.java +++ /dev/null @@ -1,46 +0,0 @@ -package cn.iocoder.yudao.module.product.dal.dataobject.property; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - - -/** - * 商品属性值 DO - * - * @author 芋道源码 - */ -@TableName("product_property_value") -@KeySequence("product_property_value_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class ProductPropertyValueDO extends BaseDO { - - /** - * 主键 - */ - @TableId - private Long id; - /** - * 属性项的编号 - * - * 关联 {@link ProductPropertyDO#getId()} - */ - private Long propertyId; - /** - * 名称 - */ - private String name; - /** - * 备注 - * - */ - private String remark; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/search/ProductHotSearchDO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/search/ProductHotSearchDO.java deleted file mode 100644 index 3d5cf9101..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/search/ProductHotSearchDO.java +++ /dev/null @@ -1,38 +0,0 @@ -package cn.iocoder.yudao.module.product.dal.dataobject.search; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -/** - * 商品热搜关键字 DO - * - * @author 芋道源码 - */ -@TableName("product_hot_search") -@KeySequence("product_hot_search_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class ProductHotSearchDO extends BaseDO { - - /** - * 编号,主键自增 - */ - @TableId - private Long id; - /** - * 关键字 - */ - private String name; - /** - * 内容 - */ - private String content; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/shop/ShopDO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/shop/ShopDO.java deleted file mode 100644 index 1c702da91..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/shop/ShopDO.java +++ /dev/null @@ -1,26 +0,0 @@ -package cn.iocoder.yudao.module.product.dal.dataobject.shop; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -// TODO 芋艿:待设计 -/** - * 店铺 DO - * - * @author 芋道源码 - */ -@TableName("shop") -@KeySequence("shop_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class ShopDO extends BaseDO { - - private Long id; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/sku/ProductSkuDO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/sku/ProductSkuDO.java deleted file mode 100755 index 3836f20e5..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/sku/ProductSkuDO.java +++ /dev/null @@ -1,137 +0,0 @@ -package cn.iocoder.yudao.module.product.dal.dataobject.sku; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.util.json.JsonUtils; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -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.dal.dataobject.spu.ProductSpuDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import com.baomidou.mybatisplus.extension.handlers.AbstractJsonTypeHandler; -import lombok.*; - -import java.util.List; - -/** - * 商品 SKU DO - * - * @author 芋道源码 - */ -@TableName(value = "product_sku",autoResultMap = true) -@KeySequence("product_sku_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class ProductSkuDO extends BaseDO { - - /** - * 商品 SKU 编号,自增 - */ - @TableId - private Long id; - /** - * SPU 编号 - *

- * 关联 {@link ProductSpuDO#getId()} - */ - private Long spuId; - /** - * SPU 名字 - * - * 冗余 {@link ProductSkuDO#getSpuName()} - */ - private String spuName; - /** - * 属性数组,JSON 格式 - */ - @TableField(typeHandler = PropertyTypeHandler.class) - private List properties; - /** - * 销售价格,单位:分 - */ - private Integer price; - /** - * 市场价,单位:分 - */ - private Integer marketPrice; - /** - * 成本价,单位:分 - */ - private Integer costPrice; - /** - * SKU 的条形码 - */ - private String barCode; - /** - * 图片地址 - */ - private String picUrl; - /** - * SKU 状态 - *

- * 枚举 {@link CommonStatusEnum} - */ - private Integer status; - /** - * 库存 - */ - private Integer stock; - /** - * 预警预存 - */ - private Integer warnStock; - /** - * 商品重量,单位:kg 千克 - */ - private Double weight; - /** - * 商品体积,单位:m^3 平米 - */ - private Double volume; - - /** - * 商品属性 - */ - @Data - @NoArgsConstructor - @AllArgsConstructor - public static class Property { - - /** - * 属性编号 - *

- * 关联 {@link ProductPropertyDO#getId()} - */ - private Long propertyId; - /** - * 属性值编号 - *

- * 关联 {@link ProductPropertyValueDO#getId()} - */ - private Long valueId; - - } - - // TODO @芋艿:可以找一些新的思路 - public static class PropertyTypeHandler extends AbstractJsonTypeHandler { - - @Override - protected Object parse(String json) { - return JsonUtils.parseArray(json, Property.class); - } - - @Override - protected String toJson(Object obj) { - return JsonUtils.toJsonString(obj); - } - - } - -} - diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/spu/ProductSpuDO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/spu/ProductSpuDO.java deleted file mode 100755 index 93c47d4af..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/spu/ProductSpuDO.java +++ /dev/null @@ -1,212 +0,0 @@ -package cn.iocoder.yudao.module.product.dal.dataobject.spu; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -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.sku.ProductSkuDO; -import cn.iocoder.yudao.module.product.enums.spu.ProductSpuSpecTypeEnum; -import cn.iocoder.yudao.module.product.enums.spu.ProductSpuStatusEnum; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler; -import lombok.*; - -import java.util.List; - -/** - * 商品 SPU DO - * - * @author 芋道源码 - */ -@TableName(value = "product_spu", autoResultMap = true) -@KeySequence("product_spu_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class ProductSpuDO extends BaseDO { - - /** - * 商品 SPU 编号,自增 - */ - @TableId - private Long id; - - // ========== 基本信息 ========= - - /** - * 商品名称 - */ - private String name; - /** - * 商品编码 - */ - private String code; - /** - * 促销语 - */ - private String sellPoint; - /** - * 商品详情 - */ - private String description; - /** - * 商品分类编号 - * - * 关联 {@link ProductCategoryDO#getId()} - */ - private Long categoryId; - /** - * 商品品牌编号 - * - * 关联 {@link ProductBrandDO#getId()} - */ - private Long brandId; - /** - * 商品图片的数组 - * - * 1. 第一张图片将作为商品主图,支持同时上传多张图; - * 2. 建议使用尺寸 800x800 像素以上、大小不超过 1M 的正方形图片; - * 3. 至少 1 张,最多上传 10 张 - */ - @TableField(typeHandler = JacksonTypeHandler.class) - private List picUrls; - /** - * 商品视频 - */ - private String videoUrl; - - /** - * 排序字段 - */ - private Integer sort; - /** - * 商品状态 - * - * 枚举 {@link ProductSpuStatusEnum} - */ - private Integer status; - - // ========== SKU 相关字段 ========= - - /** - * 规格类型 - * - * 枚举 {@link ProductSpuSpecTypeEnum} - */ - private Integer specType; - /** - * 最小价格,单位使用:分 - * - * 基于其对应的 {@link ProductSkuDO#getPrice()} 最小值 - */ - private Integer minPrice; - /** - * 最大价格,单位使用:分 - * - * 基于其对应的 {@link ProductSkuDO#getPrice()} 最大值 - */ - private Integer maxPrice; - /** - * 市场价,单位使用:分 - * - * 基于其对应的 {@link ProductSkuDO#getMarketPrice()} 最大值 - */ - private Integer marketPrice; - /** - * 总库存 - * - * 基于其对应的 {@link ProductSkuDO#getStock()} 求和 - */ - private Integer totalStock; - /** - * 是否展示库存 - */ - private Boolean showStock; - - // ========== 统计相关字段 ========= - - /** - * 商品销量 - */ - private Integer salesCount; - /** - * 虚拟销量 - */ - private Integer virtualSalesCount; - /** - * 商品点击量 - */ - private Integer clickCount; - - // ========== 物流相关字段 ========= - - // TODO 芋艿:稍后完善物流的字段 -// /** -// * 配送方式 -// * -// * 枚举 {@link DeliveryModeEnum} -// */ -// private Integer deliveryMode; -// /** -// * 配置模板编号 -// * -// * 关联 {@link DeliveryTemplateDO#getId()} -// */ -// private Long deliveryTemplateId; - - // TODO ========== 待定字段:yv ========= - // TODO vip_price 会员价格 - // TODO postage 邮费 - // TODO is_postage 是否包邮 - // TODO unit_name 单位 - // TODO is_new 商户是否代理 - // TODO give_integral 获得积分 - // TODO is_integral 是开启积分兑换 - // TODO integral 所需积分 - // TODO is_seckill 秒杀状态 - // TODO is_bargain 砍价状态 - // TODO code_path 产品二维码地址 - // TODO is_sub 是否分佣 - - // TODO ↓↓ 芋艿 ↓↓ 看起来走分组更合适? - // TODO is_hot 是否热卖 - // TODO is_benefit 是否优惠 - // TODO is_best 是否精品 - // TODO is_new 是否新品 - // TODO is_good 是否优品推荐 - - // TODO ========== 待定字段:cf ========= - // TODO source_link 淘宝京东1688类型 - // TODO activity 活动显示排序 0=默认 1=秒 2=砍价 3=拼团 - - // TODO ========== 待定字段:lf ========= - - // TODO free_shipping_type:运费类型:1-包邮;2-统一运费;3-运费模板 - // TODO free_shipping:统一运费金额 - // TODO free_shipping_template_id:运费模板 - // TODO is_commission:分销佣金:1-开启;0-不开启;first_ratio second_ratio three_ratio - // TODO is_share_bouns:区域股东分红:1-开启;0-不开启;region_ratio;shareholder_ratio - - // TODO is_new:新品推荐:1-是;0-否 - // TODO is_best:好物优选:1-是;0-否 - // TODO is_like:猜你喜欢:1-是;0-否 - - // TODO is_team:是否开启拼团[0=否, 1=是] - // TODO is_integral:积分抵扣:1-开启;0-不开启 - // TODO is_member:会员价:1-开启;0-不开启 - // TODO give_integral_type:赠送积分类型:0-不赠送;1-赠送固定积分;2-按比例赠送积分 - // TODO give_integral:赠送积分; - - // TODO poster:商品自定义海报 - - // TODO ========== 待定字段:laoji ========= - // TODO productType 1 - 普通商品 2 - 预售商品;可能和 type 合并不错 - // TODO productUnit 商品单位 - // TODO extJson 扩展信息;例如说,预售商品的信息 - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/brand/ProductBrandMapper.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/brand/ProductBrandMapper.java deleted file mode 100644 index a62df7dc8..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/brand/ProductBrandMapper.java +++ /dev/null @@ -1,34 +0,0 @@ -package cn.iocoder.yudao.module.product.dal.mysql.brand; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.product.controller.admin.brand.vo.ProductBrandListReqVO; -import cn.iocoder.yudao.module.product.controller.admin.brand.vo.ProductBrandPageReqVO; -import cn.iocoder.yudao.module.product.dal.dataobject.brand.ProductBrandDO; -import org.apache.ibatis.annotations.Mapper; - -import java.util.List; - -@Mapper -public interface ProductBrandMapper extends BaseMapperX { - - default PageResult selectPage(ProductBrandPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .likeIfPresent(ProductBrandDO::getName, reqVO.getName()) - .eqIfPresent(ProductBrandDO::getStatus, reqVO.getStatus()) - .betweenIfPresent(ProductBrandDO::getCreateTime, reqVO.getCreateTime()) - .orderByDesc(ProductBrandDO::getId)); - } - - - default List selectList(ProductBrandListReqVO reqVO) { - return selectList(new LambdaQueryWrapperX() - .likeIfPresent(ProductBrandDO::getName, reqVO.getName())); - } - - default ProductBrandDO selectByName(String name) { - return selectOne(ProductBrandDO::getName, name); - } - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/category/ProductCategoryMapper.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/category/ProductCategoryMapper.java deleted file mode 100644 index 8130d5a46..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/category/ProductCategoryMapper.java +++ /dev/null @@ -1,33 +0,0 @@ -package cn.iocoder.yudao.module.product.dal.mysql.category; - -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.product.controller.admin.category.vo.ProductCategoryListReqVO; -import cn.iocoder.yudao.module.product.dal.dataobject.category.ProductCategoryDO; -import org.apache.ibatis.annotations.Mapper; - -import java.util.List; - -/** - * 商品分类 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface ProductCategoryMapper extends BaseMapperX { - - default List selectList(ProductCategoryListReqVO listReqVO) { - return selectList(new LambdaQueryWrapperX() - .likeIfPresent(ProductCategoryDO::getName, listReqVO.getName()) - .orderByDesc(ProductCategoryDO::getId)); - } - - default Long selectCountByParentId(Long parentId) { - return selectCount(ProductCategoryDO::getParentId, parentId); - } - - default List selectListByStatus(Integer status) { - return selectList(ProductCategoryDO::getStatus, status); - } - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/property/ProductPropertyMapper.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/property/ProductPropertyMapper.java deleted file mode 100644 index 26f8d5239..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/property/ProductPropertyMapper.java +++ /dev/null @@ -1,32 +0,0 @@ -package cn.iocoder.yudao.module.product.dal.mysql.property; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.product.controller.admin.property.vo.property.ProductPropertyListReqVO; -import cn.iocoder.yudao.module.product.controller.admin.property.vo.property.ProductPropertyPageReqVO; -import cn.iocoder.yudao.module.product.dal.dataobject.property.ProductPropertyDO; -import org.apache.ibatis.annotations.Mapper; - -import java.util.List; - -@Mapper -public interface ProductPropertyMapper extends BaseMapperX { - - default PageResult selectPage(ProductPropertyPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .likeIfPresent(ProductPropertyDO::getName, reqVO.getName()) - .betweenIfPresent(ProductPropertyDO::getCreateTime, reqVO.getCreateTime()) - .orderByDesc(ProductPropertyDO::getId)); - } - - default ProductPropertyDO selectByName(String name) { - return selectOne(ProductPropertyDO::getName, name); - } - - default List selectList(ProductPropertyListReqVO listReqVO) { - return selectList(new LambdaQueryWrapperX() - .eqIfPresent(ProductPropertyDO::getName, listReqVO.getName())); - } - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/property/ProductPropertyValueMapper.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/property/ProductPropertyValueMapper.java deleted file mode 100644 index 402df51e7..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/property/ProductPropertyValueMapper.java +++ /dev/null @@ -1,43 +0,0 @@ -package cn.iocoder.yudao.module.product.dal.mysql.property; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValuePageReqVO; -import cn.iocoder.yudao.module.product.dal.dataobject.property.ProductPropertyValueDO; -import org.apache.ibatis.annotations.Mapper; - -import java.util.Collection; -import java.util.List; - -@Mapper -public interface ProductPropertyValueMapper extends BaseMapperX { - - default List selectListByPropertyId(Collection propertyIds) { - return selectList(new LambdaQueryWrapperX() - .inIfPresent(ProductPropertyValueDO::getPropertyId, propertyIds)); - } - - default ProductPropertyValueDO selectByName(Long propertyId, String name) { - return selectOne(new LambdaQueryWrapperX() - .eq(ProductPropertyValueDO::getPropertyId, propertyId) - .eq(ProductPropertyValueDO::getName, name)); - } - - default void deleteByPropertyId(Long propertyId) { - delete(new LambdaQueryWrapperX() - .eq(ProductPropertyValueDO::getPropertyId, propertyId)); - } - - default PageResult selectPage(ProductPropertyValuePageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .eqIfPresent(ProductPropertyValueDO::getPropertyId, reqVO.getPropertyId()) - .likeIfPresent(ProductPropertyValueDO::getName, reqVO.getName()) - .orderByDesc(ProductPropertyValueDO::getId)); - } - - default Integer selectCountByPropertyId(Long propertyId) { - return selectCount(ProductPropertyValueDO::getPropertyId, propertyId).intValue(); - } - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/sku/ProductSkuMapper.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/sku/ProductSkuMapper.java deleted file mode 100755 index 56bc54499..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/sku/ProductSkuMapper.java +++ /dev/null @@ -1,75 +0,0 @@ -package cn.iocoder.yudao.module.product.dal.mysql.sku; - -import cn.hutool.core.lang.Assert; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; -import org.apache.ibatis.annotations.Mapper; - -import java.util.Collection; -import java.util.List; - -/** - * 商品 SKU Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface ProductSkuMapper extends BaseMapperX { - - default List selectListBySpuId(Long spuId) { - return selectList(ProductSkuDO::getSpuId, spuId); - } - - default List selectListBySpuIdAndStatus(Long spuId, - Integer status) { - return selectList(new LambdaQueryWrapperX() - .eq(ProductSkuDO::getSpuId, spuId) - .eqIfPresent(ProductSkuDO::getStatus, status)); - } - - default List selectListBySpuId(Collection spuIds) { - return selectList(ProductSkuDO::getSpuId, spuIds); - } - - default void deleteBySpuId(Long spuId) { - delete(new LambdaQueryWrapperX().eq(ProductSkuDO::getSpuId, spuId)); - } - - /** - * 更新 SKU 库存(增加) - * - * @param id 编号 - * @param incrCount 增加库存(正数) - */ - default void updateStockIncr(Long id, Integer incrCount) { - Assert.isTrue(incrCount > 0); - LambdaUpdateWrapper lambdaUpdateWrapper = new LambdaUpdateWrapper() - .setSql(" stock = stock + " + incrCount) - .eq(ProductSkuDO::getId, id); - update(null, lambdaUpdateWrapper); - } - - /** - * 更新 SKU 库存(减少) - * - * @param id 编号 - * @param incrCount 减少库存(负数) - * @return 更新条数 - */ - default int updateStockDecr(Long id, Integer incrCount) { - Assert.isTrue(incrCount < 0); - LambdaUpdateWrapper updateWrapper = new LambdaUpdateWrapper() - .setSql(" stock = stock + " + incrCount) // 负数,所以使用 + 号 - .eq(ProductSkuDO::getId, id) - .ge(ProductSkuDO::getStock, -incrCount); // cas 逻辑 - return update(null, updateWrapper); - } - - default List selectListByAlarmStock(){ - return selectList(new QueryWrapper().apply("stock <= warn_stock")); - } - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/spu/ProductSpuMapper.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/spu/ProductSpuMapper.java deleted file mode 100755 index 57a3125d8..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/spu/ProductSpuMapper.java +++ /dev/null @@ -1,75 +0,0 @@ -package cn.iocoder.yudao.module.product.dal.mysql.spu; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSpuPageReqVO; -import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppProductSpuPageReqVO; -import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO; -import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; -import org.apache.ibatis.annotations.Mapper; - -import java.util.Objects; -import java.util.Set; - -/** - * 商品spu Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface ProductSpuMapper extends BaseMapperX { - - default PageResult selectPage(ProductSpuPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .likeIfPresent(ProductSpuDO::getName, reqVO.getName()) - .eqIfPresent(ProductSpuDO::getCategoryId, reqVO.getCategoryId()) - .eqIfPresent(ProductSpuDO::getStatus, reqVO.getStatus()) - .leIfPresent(ProductSpuDO::getSalesCount, reqVO.getSalesCountMax()) - .geIfPresent(ProductSpuDO::getSalesCount, reqVO.getSalesCountMin()) - .leIfPresent(ProductSpuDO::getMarketPrice, reqVO.getMarketPriceMax()) - .geIfPresent(ProductSpuDO::getMarketPrice, reqVO.getMarketPriceMin()) - .orderByDesc(ProductSpuDO::getSort)); - } - - default PageResult selectPage(ProductSpuPageReqVO reqVO, Set alarmStockSpuIds) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .likeIfPresent(ProductSpuDO::getName, reqVO.getName()) - .eqIfPresent(ProductSpuDO::getCategoryId, reqVO.getCategoryId()) - .eqIfPresent(ProductSpuDO::getStatus, reqVO.getStatus()) - .leIfPresent(ProductSpuDO::getSalesCount, reqVO.getSalesCountMax()) - .geIfPresent(ProductSpuDO::getSalesCount, reqVO.getSalesCountMin()) - .leIfPresent(ProductSpuDO::getMarketPrice, reqVO.getMarketPriceMax()) - .geIfPresent(ProductSpuDO::getMarketPrice, reqVO.getMarketPriceMin()) - .inIfPresent(ProductSpuDO::getId, alarmStockSpuIds) // 库存告警 - .eqIfPresent(ProductSpuDO::getStatus, reqVO.getStatus()) - .orderByDesc(ProductSpuDO::getSort)); - } - - default PageResult selectPage(AppProductSpuPageReqVO pageReqVO, Integer status) { - LambdaQueryWrapperX query = new LambdaQueryWrapperX() - .eqIfPresent(ProductSpuDO::getCategoryId, pageReqVO.getCategoryId()) - .eqIfPresent(ProductSpuDO::getStatus, status); - // 排序逻辑 - if (Objects.equals(pageReqVO.getSortField(), AppProductSpuPageReqVO.SORT_FIELD_PRICE)) { - query.orderBy(true, pageReqVO.getSortAsc(), ProductSpuDO::getMaxPrice); - } else if (Objects.equals(pageReqVO.getSortField(), AppProductSpuPageReqVO.SORT_FIELD_SALES_COUNT)) { - query.orderBy(true, pageReqVO.getSortAsc(), ProductSpuDO::getSalesCount); - } - return selectPage(pageReqVO, query); - } - - /** - * 更新商品 SPU 库存 - * - * @param id 商品 SPU 编号 - * @param incrCount 增加的库存数量 - */ - default void updateStock(Long id, Integer incrCount) { - LambdaUpdateWrapper updateWrapper = new LambdaUpdateWrapper() - .setSql(" total_stock = total_stock +" + incrCount) // 负数,所以使用 + 号 - .eq(ProductSpuDO::getId, id); - update(null, updateWrapper); - } - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/package-info.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/package-info.java deleted file mode 100644 index 01967857e..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/package-info.java +++ /dev/null @@ -1,8 +0,0 @@ -/** - * trade 模块,主要实现交易相关功能 - * 例如:订单、退款、购物车等功能。 - * - * 1. Controller URL:以 /product/ 开头,避免和其它 Module 冲突 - * 2. DataObject 表名:以 product_ 开头,方便在数据库中区分 - */ -package cn.iocoder.yudao.module.product; diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/brand/ProductBrandService.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/brand/ProductBrandService.java deleted file mode 100644 index a90ec8a87..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/brand/ProductBrandService.java +++ /dev/null @@ -1,79 +0,0 @@ -package cn.iocoder.yudao.module.product.service.brand; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.product.controller.admin.brand.vo.*; -import cn.iocoder.yudao.module.product.dal.dataobject.brand.ProductBrandDO; - -import javax.validation.Valid; -import java.util.Collection; -import java.util.List; - -/** - * 商品品牌 Service 接口 - * - * @author 芋道源码 - */ -public interface ProductBrandService { - - /** - * 创建品牌 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createBrand(@Valid ProductBrandCreateReqVO createReqVO); - - /** - * 更新品牌 - * - * @param updateReqVO 更新信息 - */ - void updateBrand(@Valid ProductBrandUpdateReqVO updateReqVO); - - /** - * 删除品牌 - * - * @param id 编号 - */ - void deleteBrand(Long id); - - /** - * 获得品牌 - * - * @param id 编号 - * @return 品牌 - */ - ProductBrandDO getBrand(Long id); - - /** - * 获得品牌列表 - * - * @param ids 编号 - * @return 品牌列表 - */ - List getBrandList(Collection ids); - - /** - * 获得品牌列表 - * - * @param listReqVO 请求参数 - * @return 品牌列表 - */ - List getBrandList(ProductBrandListReqVO listReqVO); - - /** - * 验证选择的商品分类是否合法 - * - * @param id 分类编号 - */ - void validateProductBrand(Long id); - - /** - * 获得品牌分页 - * - * @param pageReqVO 分页查询 - * @return 品牌分页 - */ - PageResult getBrandPage(ProductBrandPageReqVO pageReqVO); - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/brand/ProductBrandServiceImpl.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/brand/ProductBrandServiceImpl.java deleted file mode 100644 index c7a3e5198..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/brand/ProductBrandServiceImpl.java +++ /dev/null @@ -1,117 +0,0 @@ -package cn.iocoder.yudao.module.product.service.brand; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.product.controller.admin.brand.vo.ProductBrandCreateReqVO; -import cn.iocoder.yudao.module.product.controller.admin.brand.vo.ProductBrandListReqVO; -import cn.iocoder.yudao.module.product.controller.admin.brand.vo.ProductBrandPageReqVO; -import cn.iocoder.yudao.module.product.controller.admin.brand.vo.ProductBrandUpdateReqVO; -import cn.iocoder.yudao.module.product.convert.brand.ProductBrandConvert; -import cn.iocoder.yudao.module.product.dal.dataobject.brand.ProductBrandDO; -import cn.iocoder.yudao.module.product.dal.mysql.brand.ProductBrandMapper; -import com.google.common.annotations.VisibleForTesting; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.util.Collection; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.*; - -/** - * 品牌 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class ProductBrandServiceImpl implements ProductBrandService { - - @Resource - private ProductBrandMapper brandMapper; - - @Override - public Long createBrand(ProductBrandCreateReqVO createReqVO) { - // 校验 - validateBrandNameUnique(null, createReqVO.getName()); - - // 插入 - ProductBrandDO brand = ProductBrandConvert.INSTANCE.convert(createReqVO); - brandMapper.insert(brand); - // 返回 - return brand.getId(); - } - - @Override - public void updateBrand(ProductBrandUpdateReqVO updateReqVO) { - // 校验存在 - validateBrandExists(updateReqVO.getId()); - validateBrandNameUnique(updateReqVO.getId(), updateReqVO.getName()); - // 更新 - ProductBrandDO updateObj = ProductBrandConvert.INSTANCE.convert(updateReqVO); - brandMapper.updateById(updateObj); - } - - @Override - public void deleteBrand(Long id) { - // 校验存在 - validateBrandExists(id); - // 删除 - brandMapper.deleteById(id); - } - - private void validateBrandExists(Long id) { - if (brandMapper.selectById(id) == null) { - throw exception(BRAND_NOT_EXISTS); - } - } - - @VisibleForTesting - public void validateBrandNameUnique(Long id, String name) { - ProductBrandDO brand = brandMapper.selectByName(name); - if (brand == null) { - return; - } - // 如果 id 为空,说明不用比较是否为相同 id 的字典类型 - if (id == null) { - throw exception(BRAND_NAME_EXISTS); - } - if (!brand.getId().equals(id)) { - throw exception(BRAND_NAME_EXISTS); - } - } - - @Override - public ProductBrandDO getBrand(Long id) { - return brandMapper.selectById(id); - } - - @Override - public List getBrandList(Collection ids) { - return brandMapper.selectBatchIds(ids); - } - - @Override - public List getBrandList(ProductBrandListReqVO listReqVO) { - return brandMapper.selectList(listReqVO); - } - - @Override - public void validateProductBrand(Long id) { - ProductBrandDO brand = brandMapper.selectById(id); - if (brand == null) { - throw exception(BRAND_NOT_EXISTS); - } - if (brand.getStatus().equals(CommonStatusEnum.DISABLE.getStatus())) { - throw exception(BRAND_DISABLED); - } - } - - @Override - public PageResult getBrandPage(ProductBrandPageReqVO pageReqVO) { - return brandMapper.selectPage(pageReqVO); - } - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/category/ProductCategoryService.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/category/ProductCategoryService.java deleted file mode 100644 index 32a4c030d..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/category/ProductCategoryService.java +++ /dev/null @@ -1,78 +0,0 @@ -package cn.iocoder.yudao.module.product.service.category; - -import cn.iocoder.yudao.module.product.controller.admin.category.vo.ProductCategoryCreateReqVO; -import cn.iocoder.yudao.module.product.controller.admin.category.vo.ProductCategoryListReqVO; -import cn.iocoder.yudao.module.product.controller.admin.category.vo.ProductCategoryUpdateReqVO; -import cn.iocoder.yudao.module.product.dal.dataobject.category.ProductCategoryDO; - -import javax.validation.Valid; -import java.util.List; - -/** - * 商品分类 Service 接口 - * - * @author 芋道源码 - */ -public interface ProductCategoryService { - - /** - * 创建商品分类 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createCategory(@Valid ProductCategoryCreateReqVO createReqVO); - - /** - * 更新商品分类 - * - * @param updateReqVO 更新信息 - */ - void updateCategory(@Valid ProductCategoryUpdateReqVO updateReqVO); - - /** - * 删除商品分类 - * - * @param id 编号 - */ - void deleteCategory(Long id); - - /** - * 获得商品分类 - * - * @param id 编号 - * @return 商品分类 - */ - ProductCategoryDO getCategory(Long id); - - /** - * 校验商品分类 - * - * @param id 分类编号 - */ - void validateCategory(Long id); - - /** - * 获得商品分类的层级 - * - * @param id 编号 - * @return 商品分类的层级 - */ - Integer getCategoryLevel(Long id); - - /** - * 获得商品分类列表 - * - * @param listReqVO 查询条件 - * @return 商品分类列表 - */ - List getEnableCategoryList(ProductCategoryListReqVO listReqVO); - - /** - * 获得开启状态的商品分类列表 - * - * @return 商品分类列表 - */ - List getEnableCategoryList(); - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/category/ProductCategoryServiceImpl.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/category/ProductCategoryServiceImpl.java deleted file mode 100644 index f0d10b8b8..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/category/ProductCategoryServiceImpl.java +++ /dev/null @@ -1,138 +0,0 @@ -package cn.iocoder.yudao.module.product.service.category; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.module.product.controller.admin.category.vo.ProductCategoryCreateReqVO; -import cn.iocoder.yudao.module.product.controller.admin.category.vo.ProductCategoryListReqVO; -import cn.iocoder.yudao.module.product.controller.admin.category.vo.ProductCategoryUpdateReqVO; -import cn.iocoder.yudao.module.product.convert.category.ProductCategoryConvert; -import cn.iocoder.yudao.module.product.dal.dataobject.category.ProductCategoryDO; -import cn.iocoder.yudao.module.product.dal.mysql.category.ProductCategoryMapper; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.util.List; -import java.util.Objects; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.*; - -/** - * 商品分类 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class ProductCategoryServiceImpl implements ProductCategoryService { - - @Resource - private ProductCategoryMapper productCategoryMapper; - - @Override - public Long createCategory(ProductCategoryCreateReqVO createReqVO) { - // 校验父分类存在 - validateParentProductCategory(createReqVO.getParentId()); - - // 插入 - ProductCategoryDO category = ProductCategoryConvert.INSTANCE.convert(createReqVO); - productCategoryMapper.insert(category); - // 返回 - return category.getId(); - } - - @Override - public void updateCategory(ProductCategoryUpdateReqVO updateReqVO) { - // 校验分类是否存在 - validateProductCategoryExists(updateReqVO.getId()); - // 校验父分类存在 - validateParentProductCategory(updateReqVO.getParentId()); - - // 更新 - ProductCategoryDO updateObj = ProductCategoryConvert.INSTANCE.convert(updateReqVO); - productCategoryMapper.updateById(updateObj); - } - - @Override - public void deleteCategory(Long id) { - // 校验分类是否存在 - validateProductCategoryExists(id); - // 校验是否还有子分类 - if (productCategoryMapper.selectCountByParentId(id) > 0) { - throw exception(CATEGORY_EXISTS_CHILDREN); - } - // TODO 芋艿 补充只有不存在商品才可以删除 - // 删除 - productCategoryMapper.deleteById(id); - } - - private void validateParentProductCategory(Long id) { - // 如果是根分类,无需验证 - if (Objects.equals(id, ProductCategoryDO.PARENT_ID_NULL)) { - return; - } - // 父分类不存在 - ProductCategoryDO category = productCategoryMapper.selectById(id); - if (category == null) { - throw exception(CATEGORY_PARENT_NOT_EXISTS); - } - // 父分类不能是二级分类 - if (Objects.equals(id, ProductCategoryDO.PARENT_ID_NULL)) { - throw exception(CATEGORY_PARENT_NOT_FIRST_LEVEL); - } - } - - private void validateProductCategoryExists(Long id) { - ProductCategoryDO category = productCategoryMapper.selectById(id); - if (category == null) { - throw exception(CATEGORY_NOT_EXISTS); - } - } - - @Override - public ProductCategoryDO getCategory(Long id) { - return productCategoryMapper.selectById(id); - } - - @Override - public void validateCategory(Long id) { - ProductCategoryDO category = productCategoryMapper.selectById(id); - if (category == null) { - throw exception(CATEGORY_NOT_EXISTS); - } - if (Objects.equals(category.getStatus(), CommonStatusEnum.ENABLE.getStatus())) { - throw exception(CATEGORY_DISABLED, category.getName()); - } - } - - @Override - public Integer getCategoryLevel(Long id) { - if (Objects.equals(id, ProductCategoryDO.PARENT_ID_NULL)) { - return 0; - } - int level = 1; - for (int i = 0; i < 100; i++) { - ProductCategoryDO category = productCategoryMapper.selectById(id); - // 如果没有父节点,break 结束 - if (category == null - || Objects.equals(category.getParentId(), ProductCategoryDO.PARENT_ID_NULL)) { - break; - } - // 继续递归父节点 - level++; - id = category.getParentId(); - } - return level; - } - - @Override - public List getEnableCategoryList(ProductCategoryListReqVO listReqVO) { - return productCategoryMapper.selectList(listReqVO); - } - - @Override - public List getEnableCategoryList() { - return productCategoryMapper.selectListByStatus(CommonStatusEnum.ENABLE.getStatus()); - } - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/property/ProductPropertyService.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/property/ProductPropertyService.java deleted file mode 100644 index 564bc82a9..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/property/ProductPropertyService.java +++ /dev/null @@ -1,72 +0,0 @@ -package cn.iocoder.yudao.module.product.service.property; - -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.dal.dataobject.property.ProductPropertyDO; - -import javax.validation.Valid; -import java.util.Collection; -import java.util.List; - -/** - * 商品属性项 Service 接口 - * - * @author 芋道源码 - */ -public interface ProductPropertyService { - - /** - * 创建属性项 - * 注意,如果已经存在该属性项,直接返回它的编号即可 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createProperty(@Valid ProductPropertyCreateReqVO createReqVO); - - /** - * 更新属性项 - * - * @param updateReqVO 更新信息 - */ - void updateProperty(@Valid ProductPropertyUpdateReqVO updateReqVO); - - /** - * 删除属性项 - * - * @param id 编号 - */ - void deleteProperty(Long id); - - /** - * 获得属性项列表 - * @param listReqVO 集合查询 - * @return 属性项集合 - */ - List getPropertyList(ProductPropertyListReqVO listReqVO); - - /** - * 获取属性名称分页 - * - * @param pageReqVO 分页条件 - * @return 属性项分页 - */ - PageResult getPropertyPage(ProductPropertyPageReqVO pageReqVO); - - /** - * 获得指定编号的属性项 - * - * @param id 编号 - * @return 属性项 - */ - ProductPropertyDO getProperty(Long id); - - /** - * 根据属性项的编号的集合,获得对应的属性项数组 - * - * @param ids 属性项的编号的集合 - * @return 属性项数组 - */ - List getPropertyList(Collection ids); - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/property/ProductPropertyServiceImpl.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/property/ProductPropertyServiceImpl.java deleted file mode 100644 index 328c343d6..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/property/ProductPropertyServiceImpl.java +++ /dev/null @@ -1,113 +0,0 @@ -package cn.iocoder.yudao.module.product.service.property; - -import cn.hutool.core.util.ObjUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.product.controller.admin.property.vo.property.ProductPropertyCreateReqVO; -import cn.iocoder.yudao.module.product.controller.admin.property.vo.property.ProductPropertyListReqVO; -import cn.iocoder.yudao.module.product.controller.admin.property.vo.property.ProductPropertyPageReqVO; -import cn.iocoder.yudao.module.product.controller.admin.property.vo.property.ProductPropertyUpdateReqVO; -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.mysql.property.ProductPropertyMapper; -import org.springframework.context.annotation.Lazy; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.util.Collection; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.*; - -/** - * 商品属性项 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class ProductPropertyServiceImpl implements ProductPropertyService { - - @Resource - private ProductPropertyMapper productPropertyMapper; - - @Resource - @Lazy // 延迟加载,解决循环依赖问题 - private ProductPropertyValueService productPropertyValueService; - - @Override - @Transactional(rollbackFor = Exception.class) - public Long createProperty(ProductPropertyCreateReqVO createReqVO) { - // 如果已经添加过该属性项,直接返回 - ProductPropertyDO dbProperty = productPropertyMapper.selectByName(createReqVO.getName()); - if (dbProperty != null) { - return dbProperty.getId(); - } - - // 插入 - ProductPropertyDO property = ProductPropertyConvert.INSTANCE.convert(createReqVO); - productPropertyMapper.insert(property); - // 返回 - return property.getId(); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void updateProperty(ProductPropertyUpdateReqVO updateReqVO) { - validatePropertyExists(updateReqVO.getId()); - // 校验名字重复 - ProductPropertyDO productPropertyDO = productPropertyMapper.selectByName(updateReqVO.getName()); - if (productPropertyDO != null && - ObjUtil.notEqual(productPropertyDO.getId(), updateReqVO.getId())) { - throw exception(PROPERTY_EXISTS); - } - - // 更新 - ProductPropertyDO updateObj = ProductPropertyConvert.INSTANCE.convert(updateReqVO); - productPropertyMapper.updateById(updateObj); - } - - @Override - public void deleteProperty(Long id) { - // 校验存在 - validatePropertyExists(id); - // 校验其下是否有规格值 - if (productPropertyValueService.getPropertyValueCountByPropertyId(id) > 0) { - throw exception(PROPERTY_DELETE_FAIL_VALUE_EXISTS); - } - - // 删除 - productPropertyMapper.deleteById(id); - // 同步删除属性值 - productPropertyValueService.deletePropertyValueByPropertyId(id); - } - - private void validatePropertyExists(Long id) { - if (productPropertyMapper.selectById(id) == null) { - throw exception(PROPERTY_NOT_EXISTS); - } - } - - @Override - public List getPropertyList(ProductPropertyListReqVO listReqVO) { - return productPropertyMapper.selectList(listReqVO); - } - - @Override - public PageResult getPropertyPage(ProductPropertyPageReqVO pageReqVO) { - return productPropertyMapper.selectPage(pageReqVO); - } - - @Override - public ProductPropertyDO getProperty(Long id) { - return productPropertyMapper.selectById(id); - } - - @Override - public List getPropertyList(Collection ids) { - return productPropertyMapper.selectBatchIds(ids); - } - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/property/ProductPropertyValueService.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/property/ProductPropertyValueService.java deleted file mode 100644 index 553e2578d..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/property/ProductPropertyValueService.java +++ /dev/null @@ -1,90 +0,0 @@ -package cn.iocoder.yudao.module.product.service.property; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValueCreateReqVO; -import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValuePageReqVO; -import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValueUpdateReqVO; -import cn.iocoder.yudao.module.product.dal.dataobject.property.ProductPropertyValueDO; -import cn.iocoder.yudao.module.product.service.property.bo.ProductPropertyValueDetailRespBO; - -import java.util.Collection; -import java.util.List; - -/** - * 商品属性值 Service 接口 - * - * @author LuoWenFeng - */ -public interface ProductPropertyValueService { - - /** - * 创建属性值 - * 注意,如果已经存在该属性值,直接返回它的编号即可 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createPropertyValue(ProductPropertyValueCreateReqVO createReqVO); - - /** - * 更新属性值 - * - * @param updateReqVO 更新信息 - */ - void updatePropertyValue(ProductPropertyValueUpdateReqVO updateReqVO); - - /** - * 删除属性值 - * - * @param id 编号 - */ - void deletePropertyValue(Long id); - - /** - * 获得属性值 - * - * @param id 编号 - * @return 属性值 - */ - ProductPropertyValueDO getPropertyValue(Long id); - - /** - * 根据属性项编号数组,获得属性值列表 - * - * @param propertyIds 属性项目编号数组 - * @return 属性值列表 - */ - List getPropertyValueListByPropertyId(Collection propertyIds); - - /** - * 根据编号数组,获得属性值列表 - * - * @param ids 编号数组 - * @return 属性值明细列表 - */ - List getPropertyValueDetailList(Collection ids); - - /** - * 根据属性项编号,活的属性值数量 - * - * @param propertyId 属性项编号数 - * @return 属性值数量 - */ - Integer getPropertyValueCountByPropertyId(Long propertyId); - - /** - * 获取属性值的分页 - * - * @param pageReqVO 查询条件 - * @return 属性值的分页 - */ - PageResult getPropertyValuePage(ProductPropertyValuePageReqVO pageReqVO); - - /** - * 删除指定属性项编号下的属性值们 - * - * @param propertyId 属性项的编号 - */ - void deletePropertyValueByPropertyId(Long propertyId); - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/property/ProductPropertyValueServiceImpl.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/property/ProductPropertyValueServiceImpl.java deleted file mode 100644 index e5bc6874b..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/property/ProductPropertyValueServiceImpl.java +++ /dev/null @@ -1,127 +0,0 @@ -package cn.iocoder.yudao.module.product.service.property; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValueCreateReqVO; -import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValuePageReqVO; -import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValueUpdateReqVO; -import cn.iocoder.yudao.module.product.convert.propertyvalue.ProductPropertyValueConvert; -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.dal.mysql.property.ProductPropertyValueMapper; -import cn.iocoder.yudao.module.product.service.property.bo.ProductPropertyValueDetailRespBO; -import org.springframework.context.annotation.Lazy; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.util.Collection; -import java.util.Collections; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; -import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.PROPERTY_VALUE_EXISTS; -import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.PROPERTY_VALUE_NOT_EXISTS; - -/** - * 商品属性值 Service 实现类 - * - * @author LuoWenFeng - */ -@Service -@Validated -public class ProductPropertyValueServiceImpl implements ProductPropertyValueService { - - @Resource - private ProductPropertyValueMapper productPropertyValueMapper; - - @Resource - @Lazy // 延迟加载,避免循环依赖 - private ProductPropertyService productPropertyService; - - @Override - public Long createPropertyValue(ProductPropertyValueCreateReqVO createReqVO) { - // 如果已经添加过该属性值,直接返回 - ProductPropertyValueDO dbValue = productPropertyValueMapper.selectByName( - createReqVO.getPropertyId(), createReqVO.getName()); - if (dbValue != null) { - return dbValue.getId(); - } - - // 新增 - ProductPropertyValueDO value = ProductPropertyValueConvert.INSTANCE.convert(createReqVO); - productPropertyValueMapper.insert(value); - return value.getId(); - } - - @Override - public void updatePropertyValue(ProductPropertyValueUpdateReqVO updateReqVO) { - validatePropertyValueExists(updateReqVO.getId()); - // 校验名字唯一 - ProductPropertyValueDO productPropertyValueDO = productPropertyValueMapper.selectByName - (updateReqVO.getPropertyId(), updateReqVO.getName()); - if (productPropertyValueDO != null && !productPropertyValueDO.getId().equals(updateReqVO.getId())) { - throw exception(PROPERTY_VALUE_EXISTS); - } - - // 更新 - ProductPropertyValueDO updateObj = ProductPropertyValueConvert.INSTANCE.convert(updateReqVO); - productPropertyValueMapper.updateById(updateObj); - } - - @Override - public void deletePropertyValue(Long id) { - validatePropertyValueExists(id); - productPropertyValueMapper.deleteById(id); - } - - private void validatePropertyValueExists(Long id) { - if (productPropertyValueMapper.selectById(id) == null) { - throw exception(PROPERTY_VALUE_NOT_EXISTS); - } - } - - @Override - public ProductPropertyValueDO getPropertyValue(Long id) { - return productPropertyValueMapper.selectById(id); - } - - @Override - public List getPropertyValueListByPropertyId(Collection propertyIds) { - return productPropertyValueMapper.selectListByPropertyId(propertyIds); - } - - @Override - public List getPropertyValueDetailList(Collection ids) { - // 获得属性值列表 - if (CollUtil.isEmpty(ids)) { - return Collections.emptyList(); - } - List values = productPropertyValueMapper.selectBatchIds(ids); - if (CollUtil.isEmpty(values)) { - return Collections.emptyList(); - } - // 获得属性项列表 - List keys = productPropertyService.getPropertyList( - convertSet(values, ProductPropertyValueDO::getPropertyId)); - // 组装明细 - return ProductPropertyValueConvert.INSTANCE.convertList(values, keys); - } - - @Override - public Integer getPropertyValueCountByPropertyId(Long propertyId) { - return productPropertyValueMapper.selectCountByPropertyId(propertyId); - } - - @Override - public PageResult getPropertyValuePage(ProductPropertyValuePageReqVO pageReqVO) { - return productPropertyValueMapper.selectPage(pageReqVO); - } - - @Override - public void deletePropertyValueByPropertyId(Long propertyId) { - productPropertyValueMapper.deleteByPropertyId(propertyId); - } - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/property/bo/ProductPropertyValueDetailRespBO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/property/bo/ProductPropertyValueDetailRespBO.java deleted file mode 100644 index 6776731f9..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/property/bo/ProductPropertyValueDetailRespBO.java +++ /dev/null @@ -1,33 +0,0 @@ -package cn.iocoder.yudao.module.product.service.property.bo; - -import lombok.Data; - -/** - * 商品属性项的明细 Response BO - * - * @author 芋道源码 - */ -@Data -public class ProductPropertyValueDetailRespBO { - - /** - * 属性的编号 - */ - private Long propertyId; - - /** - * 属性的名称 - */ - private String propertyName; - - /** - * 属性值的编号 - */ - private Long valueId; - - /** - * 属性值的名称 - */ - private String valueName; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/sku/ProductSkuService.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/sku/ProductSkuService.java deleted file mode 100755 index 621e12d9f..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/sku/ProductSkuService.java +++ /dev/null @@ -1,122 +0,0 @@ -package cn.iocoder.yudao.module.product.service.sku; - -import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuUpdateStockReqDTO; -import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuCreateOrUpdateReqVO; -import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO; -import org.springframework.lang.Nullable; - -import java.util.Collection; -import java.util.List; - -/** - * 商品 SKU Service 接口 - * - * @author 芋道源码 - */ -public interface ProductSkuService { - - /** - * 删除商品 SKU - * - * @param id 编号 - */ - void deleteSku(Long id); - - /** - * 获得商品 SKU 信息 - * - * @param id 编号 - * @return 商品 SKU 信息 - */ - ProductSkuDO getSku(Long id); - - /** - * 获得商品 SKU 列表 - * - * @return 商品sku列表 - */ - List getSkuList(); - - /** - * 获得商品 SKU 列表 - * - * @param ids 编号 - * @return 商品sku列表 - */ - List getSkuList(Collection ids); - - /** - * 对 sku 的组合的属性等进行合法性校验 - * - * @param list sku组合的集合 - */ - void validateSkuList(List list, Integer specType); - - /** - * 批量创建 SKU - * - * @param spuId 商品 SPU 编号 - * @param spuName 商品 SPU 名称 - * @param list SKU 对象集合 - */ - void createSkuList(Long spuId, String spuName, List list); - - /** - * 根据 SPU 编号,批量更新它的 SKU 信息 - * - * @param spuId SPU 编码 - * @param spuName 商品 SPU 名称 - * @param skus SKU 的集合 - */ - void updateSkuList(Long spuId, String spuName, List skus); - - /** - * 更新 SKU 库存(增量) - * - * 如果更新的库存不足,会抛出异常 - * - * @param updateStockReqDTO 更行请求 - */ - void updateSkuStock(ProductSkuUpdateStockReqDTO updateStockReqDTO); - - /** - * 获得商品 SKU 集合 - * - * @param spuId spu 编号 - * @return 商品sku 集合 - */ - List getSkuListBySpuId(Long spuId); - - /** - * 基于 SPU 编号和状态,获得商品 SKU 集合 - * - * @param spuId SPU 编号 - * @param status 状态 - * @return 商品 SKU 集合 - */ - List getSkuListBySpuIdAndStatus(Long spuId, - @Nullable Integer status); - - /** - * 获得 spu 对应的 SKU 集合 - * - * @param spuIds spu 编码集合 - * @return 商品 sku 集合 - */ - List getSkuListBySpuId(List spuIds); - - /** - * 通过 spuId 删除 sku 信息 - * - * @param spuId spu 编码 - */ - void deleteSkuBySpuId(Long spuId); - - /** - * 获得库存预警的 SKU 数组 - * - * @return SKU 数组 - */ - List getSkuListByAlarmStock(); - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/sku/ProductSkuServiceImpl.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/sku/ProductSkuServiceImpl.java deleted file mode 100755 index 1ab2523cc..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/sku/ProductSkuServiceImpl.java +++ /dev/null @@ -1,214 +0,0 @@ -package cn.iocoder.yudao.module.product.service.sku; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.util.ObjectUtil; -import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuUpdateStockReqDTO; -import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuBaseVO; -import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuCreateOrUpdateReqVO; -import cn.iocoder.yudao.module.product.convert.sku.ProductSkuConvert; -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.dal.dataobject.sku.ProductSkuDO; -import cn.iocoder.yudao.module.product.dal.mysql.sku.ProductSkuMapper; -import cn.iocoder.yudao.module.product.enums.ErrorCodeConstants; -import cn.iocoder.yudao.module.product.enums.spu.ProductSpuSpecTypeEnum; -import cn.iocoder.yudao.module.product.service.property.ProductPropertyService; -import cn.iocoder.yudao.module.product.service.property.ProductPropertyValueService; -import cn.iocoder.yudao.module.product.service.spu.ProductSpuService; -import org.springframework.context.annotation.Lazy; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.util.*; -import java.util.stream.Collectors; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; -import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.*; - -/** - * 商品 SKU Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class ProductSkuServiceImpl implements ProductSkuService { - - @Resource - private ProductSkuMapper productSkuMapper; - - @Resource - @Lazy // 循环依赖,避免报错 - private ProductSpuService productSpuService; - @Resource - private ProductPropertyService productPropertyService; - @Resource - private ProductPropertyValueService productPropertyValueService; - - @Override - public void deleteSku(Long id) { - // 校验存在 - validateSkuExists(id); - // 删除 - productSkuMapper.deleteById(id); - } - - private void validateSkuExists(Long id) { - if (productSkuMapper.selectById(id) == null) { - throw exception(SKU_NOT_EXISTS); - } - } - - @Override - public ProductSkuDO getSku(Long id) { - return productSkuMapper.selectById(id); - } - - @Override - public List getSkuList() { - return productSkuMapper.selectList(); - } - - @Override - public List getSkuList(Collection ids) { - return productSkuMapper.selectBatchIds(ids); - } - - @Override - public void validateSkuList(List skus, Integer specType) { - // 非多规格,不需要校验 - if (ObjectUtil.notEqual(specType, ProductSpuSpecTypeEnum.DISABLE.getType())) { - return; - } - - // 1、校验属性项存在 - Set propertyIds = skus.stream().filter(p -> p.getProperties() != null) - .flatMap(p -> p.getProperties().stream()) // 遍历多个 Property 属性 - .map(ProductSkuBaseVO.Property::getPropertyId) // 将每个 Property 转换成对应的 propertyId,最后形成集合 - .collect(Collectors.toSet()); - List propertyList = productPropertyService.getPropertyList(propertyIds); - if (propertyList.size() != propertyIds.size()) { - throw exception(PROPERTY_NOT_EXISTS); - } - - // 2. 校验,一个 SKU 下,没有重复的属性。校验方式是,遍历每个 SKU ,看看是否有重复的属性 propertyId - Map propertyValueMap = convertMap(productPropertyValueService.getPropertyValueListByPropertyId(propertyIds), ProductPropertyValueDO::getId); - skus.forEach(sku -> { - Set skuPropertyIds = convertSet(sku.getProperties(), propertyItem -> propertyValueMap.get(propertyItem.getValueId()).getPropertyId()); - if (skuPropertyIds.size() != sku.getProperties().size()) { - throw exception(SKU_PROPERTIES_DUPLICATED); - } - }); - - // 3. 再校验,每个 Sku 的属性值的数量,是一致的。 - int attrValueIdsSize = skus.get(0).getProperties().size(); - for (int i = 1; i < skus.size(); i++) { - if (attrValueIdsSize != skus.get(i).getProperties().size()) { - throw exception(ErrorCodeConstants.SPU_ATTR_NUMBERS_MUST_BE_EQUALS); - } - } - - // 4. 最后校验,每个 Sku 之间不是重复的 - Set> skuAttrValues = new HashSet<>(); // 每个元素,都是一个 Sku 的 attrValueId 集合。这样,通过最外层的 Set ,判断是否有重复的. - for (ProductSkuCreateOrUpdateReqVO sku : skus) { - if (!skuAttrValues.add(convertSet(sku.getProperties(), ProductSkuBaseVO.Property::getValueId))) { // 添加失败,说明重复 - throw exception(ErrorCodeConstants.SPU_SKU_NOT_DUPLICATE); - } - } - } - - @Override - public void createSkuList(Long spuId, String spuName, List skuCreateReqList) { - productSkuMapper.insertBatch(ProductSkuConvert.INSTANCE.convertList06(skuCreateReqList, spuId, spuName)); - } - - @Override - public List getSkuListBySpuId(Long spuId) { - return productSkuMapper.selectListBySpuId(spuId); - } - - @Override - public List getSkuListBySpuIdAndStatus(Long spuId, Integer status) { - return productSkuMapper.selectListBySpuIdAndStatus(spuId, status); - } - - @Override - public List getSkuListBySpuId(List spuIds) { - return productSkuMapper.selectListBySpuId(spuIds); - } - - @Override - public void deleteSkuBySpuId(Long spuId) { - productSkuMapper.deleteBySpuId(spuId); - } - - @Override - public List getSkuListByAlarmStock() { - return productSkuMapper.selectListByAlarmStock(); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void updateSkuList(Long spuId, String spuName, List skus) { - // 构建属性与 SKU 的映射关系; - Map existsSkuMap = convertMap(productSkuMapper.selectListBySpuId(spuId), - ProductSkuConvert.INSTANCE::buildPropertyKey, ProductSkuDO::getId); - - // 拆分三个集合,新插入的、需要更新的、需要删除的 - List insertSkus = new ArrayList<>(); - List updateSkus = new ArrayList<>(); - List allUpdateSkus = ProductSkuConvert.INSTANCE.convertList06(skus, null, spuName); - allUpdateSkus.forEach(sku -> { - String propertiesKey = ProductSkuConvert.INSTANCE.buildPropertyKey(sku); - // 1、找得到的,进行更新 - Long existsSkuId = existsSkuMap.remove(propertiesKey); - if (existsSkuId != null) { - sku.setId(existsSkuId); - updateSkus.add(sku); - return; - } - // 2、找不到,进行插入 - sku.setSpuId(spuId); - insertSkus.add(sku); - }); - - // 执行最终的批量操作 - if (CollUtil.isNotEmpty(insertSkus)) { - productSkuMapper.insertBatch(insertSkus); - } - if (CollUtil.isNotEmpty(updateSkus)) { - updateSkus.forEach(sku -> productSkuMapper.updateById(sku)); - } - if (CollUtil.isNotEmpty(existsSkuMap)) { - productSkuMapper.deleteBatchIds(existsSkuMap.values()); - } - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void updateSkuStock(ProductSkuUpdateStockReqDTO updateStockReqDTO) { - // 更新 SKU 库存 - updateStockReqDTO.getItems().forEach(item -> { - if (item.getIncrCount() > 0) { - productSkuMapper.updateStockIncr(item.getId(), item.getIncrCount()); - } else if (item.getIncrCount() < 0) { - int updateStockIncr = productSkuMapper.updateStockDecr(item.getId(), item.getIncrCount()); - if (updateStockIncr == 0) { - throw exception(SKU_STOCK_NOT_ENOUGH); - } - } - }); - - // 更新 SPU 库存 - List skus = productSkuMapper.selectBatchIds( - convertSet(updateStockReqDTO.getItems(), ProductSkuUpdateStockReqDTO.Item::getId)); - Map spuStockIncrCounts = ProductSkuConvert.INSTANCE.convertSpuStockMap( - updateStockReqDTO.getItems(), skus); - productSpuService.updateSpuStock(spuStockIncrCounts); - } - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/spu/ProductSpuService.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/spu/ProductSpuService.java deleted file mode 100755 index 0ae7359eb..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/spu/ProductSpuService.java +++ /dev/null @@ -1,101 +0,0 @@ -package cn.iocoder.yudao.module.product.service.spu; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.product.controller.admin.spu.vo.*; -import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppProductSpuPageReqVO; -import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO; - -import javax.validation.Valid; -import java.util.Collection; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; - -/** - * 商品 SPU Service 接口 - * - * @author 芋道源码 - */ -public interface ProductSpuService { - - /** - * 创建商品 SPU - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createSpu(@Valid ProductSpuCreateReqVO createReqVO); - - /** - * 更新商品 SPU - * - * @param updateReqVO 更新信息 - */ - void updateSpu(@Valid ProductSpuUpdateReqVO updateReqVO); - - /** - * 删除商品 SPU - * - * @param id 编号 - */ - void deleteSpu(Long id); - - /** - * 获得商品 SPU - * - * @param id 编号 - * @return 商品 SPU - */ - ProductSpuDO getSpu(Long id); - - /** - * 获得商品 SPU 列表 - * - * @param ids 编号数组 - * @return 商品 SPU 列表 - */ - List getSpuList(Collection ids); - - /** - * 获得商品 SPU 映射 - * - * @param ids 编号数组 - * @return 商品 SPU 映射 - */ - default Map getSpuMap(Collection ids) { - return convertMap(getSpuList(ids), ProductSpuDO::getId); - } - - /** - * 获得所有商品 SPU 列表 - * - * @return 商品 SPU 列表 - */ - List getSpuList(); - - /** - * 获得商品 SPU 分页 - * - * @param pageReqVO 分页查询 - * @return 商品spu分页 - */ - PageResult getSpuPage(ProductSpuPageReqVO pageReqVO); - - /** - * 获得商品 SPU 分页 - * - * @param pageReqVO 分页查询 - * @param status 状态 - * @return 商品 SPU 分页 - */ - PageResult getSpuPage(AppProductSpuPageReqVO pageReqVO, Integer status); - - /** - * 更新商品 SPU 库存(增量) - * - * @param stockIncrCounts SPU 编号与库存变化(增量)的映射 - */ - void updateSpuStock(Map stockIncrCounts); - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/spu/ProductSpuServiceImpl.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/spu/ProductSpuServiceImpl.java deleted file mode 100755 index 0dd9cdf55..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/spu/ProductSpuServiceImpl.java +++ /dev/null @@ -1,180 +0,0 @@ -package cn.iocoder.yudao.module.product.service.spu; - -import cn.hutool.core.collection.CollUtil; -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.sku.vo.ProductSkuCreateOrUpdateReqVO; -import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSpuCreateReqVO; -import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSpuPageReqVO; -import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSpuUpdateReqVO; -import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppProductSpuPageReqVO; -import cn.iocoder.yudao.module.product.convert.spu.ProductSpuConvert; -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.mysql.spu.ProductSpuMapper; -import cn.iocoder.yudao.module.product.service.brand.ProductBrandService; -import cn.iocoder.yudao.module.product.service.category.ProductCategoryService; -import cn.iocoder.yudao.module.product.service.sku.ProductSkuService; -import org.springframework.context.annotation.Lazy; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.util.Collection; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*; -import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.SPU_NOT_EXISTS; -import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.SPU_SAVE_FAIL_CATEGORY_LEVEL_ERROR; - -/** - * 商品 SPU Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class ProductSpuServiceImpl implements ProductSpuService { - - @Resource - private ProductSpuMapper productSpuMapper; - - @Resource - @Lazy // 循环依赖,避免报错 - private ProductSkuService productSkuService; - @Resource - private ProductBrandService brandService; - @Resource - private ProductCategoryService categoryService; - - @Override - @Transactional(rollbackFor = Exception.class) - public Long createSpu(ProductSpuCreateReqVO createReqVO) { - // 校验分类 - validateCategory(createReqVO.getCategoryId()); - // 校验品牌 - brandService.validateProductBrand(createReqVO.getBrandId()); - // 校验SKU - List skuSaveReqList = createReqVO.getSkus(); - productSkuService.validateSkuList(skuSaveReqList, createReqVO.getSpecType()); - - // 插入 SPU - ProductSpuDO spu = ProductSpuConvert.INSTANCE.convert(createReqVO); - initSpuFromSkus(spu, skuSaveReqList); - productSpuMapper.insert(spu); - // 插入 SKU - productSkuService.createSkuList(spu.getId(), spu.getName(), skuSaveReqList); - // 返回 - return spu.getId(); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void updateSpu(ProductSpuUpdateReqVO updateReqVO) { - // 校验 SPU 是否存在 - validateSpuExists(updateReqVO.getId()); - // 校验分类 - validateCategory(updateReqVO.getCategoryId()); - // 校验品牌 - brandService.validateProductBrand(updateReqVO.getBrandId()); - // 校验SKU - List skuSaveReqList = updateReqVO.getSkus(); - productSkuService.validateSkuList(skuSaveReqList, updateReqVO.getSpecType()); - - // 更新 SPU - ProductSpuDO updateObj = ProductSpuConvert.INSTANCE.convert(updateReqVO); - initSpuFromSkus(updateObj, skuSaveReqList); - productSpuMapper.updateById(updateObj); - // 批量更新 SKU - productSkuService.updateSkuList(updateObj.getId(), updateObj.getName(), updateReqVO.getSkus()); - } - - /** - * 基于 SKU 的信息,初始化 SPU 的信息 - * 主要是计数相关的字段,例如说市场价、最大最小价、库存等等 - * - * @param spu 商品 SPU - * @param skus 商品 SKU 数组 - */ - private void initSpuFromSkus(ProductSpuDO spu, List skus) { - spu.setMarketPrice(getMaxValue(skus, ProductSkuCreateOrUpdateReqVO::getMarketPrice)); - spu.setMaxPrice(getMaxValue(skus, ProductSkuCreateOrUpdateReqVO::getPrice)); - spu.setMinPrice(getMinValue(skus, ProductSkuCreateOrUpdateReqVO::getPrice)); - spu.setTotalStock(getSumValue(skus, ProductSkuCreateOrUpdateReqVO::getStock, Integer::sum)); - } - - /** - * 校验商品分类是否合法 - * - * @param id 商品分类编号 - */ - private void validateCategory(Long id) { - categoryService.validateCategory(id); - // 校验层级 - if (categoryService.getCategoryLevel(id) != 3) { - throw exception(SPU_SAVE_FAIL_CATEGORY_LEVEL_ERROR); - } - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void deleteSpu(Long id) { - // 校验存在 - validateSpuExists(id); - // 删除 SPU - productSpuMapper.deleteById(id); - // 删除关联的 SKU - productSkuService.deleteSkuBySpuId(id); - } - - private void validateSpuExists(Long id) { - if (productSpuMapper.selectById(id) == null) { - throw exception(SPU_NOT_EXISTS); - } - } - - @Override - public ProductSpuDO getSpu(Long id) { - return productSpuMapper.selectById(id); - } - - @Override - public List getSpuList(Collection ids) { - return productSpuMapper.selectBatchIds(ids); - } - - @Override - public List getSpuList() { - return productSpuMapper.selectList(); - } - - @Override - public PageResult getSpuPage(ProductSpuPageReqVO pageReqVO) { - // 库存告警的 SPU 编号的集合 - Set alarmStockSpuIds = null; - if (Boolean.TRUE.equals(pageReqVO.getAlarmStock())) { - alarmStockSpuIds = CollectionUtils.convertSet(productSkuService.getSkuListByAlarmStock(), ProductSkuDO::getSpuId); - if (CollUtil.isEmpty(alarmStockSpuIds)) { - return PageResult.empty(); - } - } - // 分页查询 - return productSpuMapper.selectPage(pageReqVO, alarmStockSpuIds); - } - - @Override - public PageResult getSpuPage(AppProductSpuPageReqVO pageReqVO, Integer status) { - return productSpuMapper.selectPage(pageReqVO, status); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void updateSpuStock(Map stockIncrCounts) { - stockIncrCounts.forEach((id, incCount) -> productSpuMapper.updateStock(id, incCount)); - } - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/test/java/cn/iocoder/yudao/module/product/service/brand/ProductBrandServiceImplTest.java b/yudao-module-mall/yudao-module-product-biz/src/test/java/cn/iocoder/yudao/module/product/service/brand/ProductBrandServiceImplTest.java deleted file mode 100644 index 1b5c68ba4..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/test/java/cn/iocoder/yudao/module/product/service/brand/ProductBrandServiceImplTest.java +++ /dev/null @@ -1,133 +0,0 @@ -package cn.iocoder.yudao.module.product.service.brand; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.module.product.controller.admin.brand.vo.ProductBrandCreateReqVO; -import cn.iocoder.yudao.module.product.controller.admin.brand.vo.ProductBrandPageReqVO; -import cn.iocoder.yudao.module.product.controller.admin.brand.vo.ProductBrandUpdateReqVO; -import cn.iocoder.yudao.module.product.dal.dataobject.brand.ProductBrandDO; -import cn.iocoder.yudao.module.product.dal.mysql.brand.ProductBrandMapper; -import org.junit.jupiter.api.Test; -import org.springframework.context.annotation.Import; - -import javax.annotation.Resource; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildTime; -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomLongId; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; -import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.BRAND_NOT_EXISTS; -import static org.junit.jupiter.api.Assertions.*; - -/** -* {@link ProductBrandServiceImpl} 的单元测试类 -* -* @author 芋道源码 -*/ -@Import(ProductBrandServiceImpl.class) -public class ProductBrandServiceImplTest extends BaseDbUnitTest { - - @Resource - private ProductBrandServiceImpl brandService; - - @Resource - private ProductBrandMapper brandMapper; - - @Test - public void testCreateBrand_success() { - // 准备参数 - ProductBrandCreateReqVO reqVO = randomPojo(ProductBrandCreateReqVO.class); - - // 调用 - Long brandId = brandService.createBrand(reqVO); - // 断言 - assertNotNull(brandId); - // 校验记录的属性是否正确 - ProductBrandDO brand = brandMapper.selectById(brandId); - assertPojoEquals(reqVO, brand); - } - - @Test - public void testUpdateBrand_success() { - // mock 数据 - ProductBrandDO dbBrand = randomPojo(ProductBrandDO.class); - brandMapper.insert(dbBrand);// @Sql: 先插入出一条存在的数据 - // 准备参数 - ProductBrandUpdateReqVO reqVO = randomPojo(ProductBrandUpdateReqVO.class, o -> { - o.setId(dbBrand.getId()); // 设置更新的 ID - }); - - // 调用 - brandService.updateBrand(reqVO); - // 校验是否更新正确 - ProductBrandDO brand = brandMapper.selectById(reqVO.getId()); // 获取最新的 - assertPojoEquals(reqVO, brand); - } - - @Test - public void testUpdateBrand_notExists() { - // 准备参数 - ProductBrandUpdateReqVO reqVO = randomPojo(ProductBrandUpdateReqVO.class); - - // 调用, 并断言异常 - assertServiceException(() -> brandService.updateBrand(reqVO), BRAND_NOT_EXISTS); - } - - @Test - public void testDeleteBrand_success() { - // mock 数据 - ProductBrandDO dbBrand = randomPojo(ProductBrandDO.class); - brandMapper.insert(dbBrand);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbBrand.getId(); - - // 调用 - brandService.deleteBrand(id); - // 校验数据不存在了 - assertNull(brandMapper.selectById(id)); - } - - @Test - public void testDeleteBrand_notExists() { - // 准备参数 - Long id = randomLongId(); - - // 调用, 并断言异常 - assertServiceException(() -> brandService.deleteBrand(id), BRAND_NOT_EXISTS); - } - - @Test - public void testGetBrandPage() { - // mock 数据 - ProductBrandDO dbBrand = randomPojo(ProductBrandDO.class, o -> { // 等会查询到 - o.setName("芋道源码"); - o.setStatus(CommonStatusEnum.ENABLE.getStatus()); - o.setCreateTime(buildTime(2022, 2, 1)); - }); - brandMapper.insert(dbBrand); - // 测试 name 不匹配 - brandMapper.insert(cloneIgnoreId(dbBrand, o -> o.setName("源码"))); - // 测试 status 不匹配 - brandMapper.insert(cloneIgnoreId(dbBrand, o -> o.setStatus(CommonStatusEnum.DISABLE.getStatus()))); - // 测试 createTime 不匹配 - brandMapper.insert(cloneIgnoreId(dbBrand, o -> o.setCreateTime(buildTime(2022, 3, 1)))); - // 准备参数 - ProductBrandPageReqVO reqVO = new ProductBrandPageReqVO(); - reqVO.setName("芋道"); - reqVO.setStatus(CommonStatusEnum.ENABLE.getStatus()); - reqVO.setCreateTime((new LocalDateTime[]{buildTime(2022, 1, 1), buildTime(2022, 2, 25)})); - - // 调用 - PageResult pageResult = brandService.getBrandPage(reqVO); - // 断言 - assertEquals(1, pageResult.getTotal()); - assertEquals(1, pageResult.getList().size()); - assertPojoEquals(dbBrand, pageResult.getList().get(0)); - } - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/test/java/cn/iocoder/yudao/module/product/service/category/ProductCategoryServiceImplTest.java b/yudao-module-mall/yudao-module-product-biz/src/test/java/cn/iocoder/yudao/module/product/service/category/ProductCategoryServiceImplTest.java deleted file mode 100644 index a2963d498..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/test/java/cn/iocoder/yudao/module/product/service/category/ProductCategoryServiceImplTest.java +++ /dev/null @@ -1,145 +0,0 @@ -package cn.iocoder.yudao.module.product.service.category; - -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.module.product.controller.admin.category.vo.ProductCategoryCreateReqVO; -import cn.iocoder.yudao.module.product.controller.admin.category.vo.ProductCategoryListReqVO; -import cn.iocoder.yudao.module.product.controller.admin.category.vo.ProductCategoryUpdateReqVO; -import cn.iocoder.yudao.module.product.dal.dataobject.category.ProductCategoryDO; -import cn.iocoder.yudao.module.product.dal.mysql.category.ProductCategoryMapper; -import org.junit.jupiter.api.Test; -import org.springframework.context.annotation.Import; - -import javax.annotation.Resource; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomLongId; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; -import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.CATEGORY_NOT_EXISTS; -import static org.junit.jupiter.api.Assertions.*; - -/** - * {@link ProductCategoryServiceImpl} 的单元测试类 - * - * @author 芋道源码 - */ -@Import(ProductCategoryServiceImpl.class) -public class ProductCategoryServiceImplTest extends BaseDbUnitTest { - - @Resource - private ProductCategoryServiceImpl productCategoryService; - - @Resource - private ProductCategoryMapper productCategoryMapper; - - @Test - public void testCreateCategory_success() { - // 准备参数 - ProductCategoryCreateReqVO reqVO = randomPojo(ProductCategoryCreateReqVO.class); - // mock 父类 - ProductCategoryDO parentProductCategory = randomPojo(ProductCategoryDO.class, o -> o.setId(reqVO.getParentId())); - productCategoryMapper.insert(parentProductCategory); - - // 调用 - Long categoryId = productCategoryService.createCategory(reqVO); - // 断言 - assertNotNull(categoryId); - // 校验记录的属性是否正确 - ProductCategoryDO category = productCategoryMapper.selectById(categoryId); - assertPojoEquals(reqVO, category); - } - - @Test - public void testUpdateCategory_success() { - // mock 数据 - ProductCategoryDO dbCategory = randomPojo(ProductCategoryDO.class); - productCategoryMapper.insert(dbCategory);// @Sql: 先插入出一条存在的数据 - // 准备参数 - ProductCategoryUpdateReqVO reqVO = randomPojo(ProductCategoryUpdateReqVO.class, o -> { - o.setId(dbCategory.getId()); // 设置更新的 ID - }); - // mock 父类 - ProductCategoryDO parentProductCategory = randomPojo(ProductCategoryDO.class, o -> o.setId(reqVO.getParentId())); - productCategoryMapper.insert(parentProductCategory); - - // 调用 - productCategoryService.updateCategory(reqVO); - // 校验是否更新正确 - ProductCategoryDO category = productCategoryMapper.selectById(reqVO.getId()); // 获取最新的 - assertPojoEquals(reqVO, category); - } - - @Test - public void testUpdateCategory_notExists() { - // 准备参数 - ProductCategoryUpdateReqVO reqVO = randomPojo(ProductCategoryUpdateReqVO.class); - - // 调用, 并断言异常 - assertServiceException(() -> productCategoryService.updateCategory(reqVO), CATEGORY_NOT_EXISTS); - } - - @Test - public void testDeleteCategory_success() { - // mock 数据 - ProductCategoryDO dbCategory = randomPojo(ProductCategoryDO.class); - productCategoryMapper.insert(dbCategory);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbCategory.getId(); - - // 调用 - productCategoryService.deleteCategory(id); - // 校验数据不存在了 - assertNull(productCategoryMapper.selectById(id)); - } - - @Test - public void testDeleteCategory_notExists() { - // 准备参数 - Long id = randomLongId(); - - // 调用, 并断言异常 - assertServiceException(() -> productCategoryService.deleteCategory(id), CATEGORY_NOT_EXISTS); - } - - @Test - public void testGetCategoryLevel() { - // mock 数据 - ProductCategoryDO category1 = randomPojo(ProductCategoryDO.class, - o -> o.setParentId(ProductCategoryDO.PARENT_ID_NULL)); - productCategoryMapper.insert(category1); - ProductCategoryDO category2 = randomPojo(ProductCategoryDO.class, - o -> o.setParentId(category1.getId())); - productCategoryMapper.insert(category2); - ProductCategoryDO category3 = randomPojo(ProductCategoryDO.class, - o -> o.setParentId(category2.getId())); - productCategoryMapper.insert(category3); - - // 调用,并断言 - assertEquals(productCategoryService.getCategoryLevel(category1.getId()), 1); - assertEquals(productCategoryService.getCategoryLevel(category2.getId()), 2); - assertEquals(productCategoryService.getCategoryLevel(category3.getId()), 3); - } - - @Test - public void testGetCategoryList() { - // mock 数据 - ProductCategoryDO dbCategory = randomPojo(ProductCategoryDO.class, o -> { // 等会查询到 - o.setName("奥特曼"); - }); - productCategoryMapper.insert(dbCategory); - // 测试 name 不匹配 - productCategoryMapper.insert(cloneIgnoreId(dbCategory, o -> o.setName("奥特块"))); - // 准备参数 - ProductCategoryListReqVO reqVO = new ProductCategoryListReqVO(); - reqVO.setName("特曼"); - - // 调用 - List list = productCategoryService.getEnableCategoryList(reqVO); - // 断言 - assertEquals(1, list.size()); - assertPojoEquals(dbCategory, list.get(0)); - } - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/test/java/cn/iocoder/yudao/module/product/service/sku/ProductSkuServiceTest.java b/yudao-module-mall/yudao-module-product-biz/src/test/java/cn/iocoder/yudao/module/product/service/sku/ProductSkuServiceTest.java deleted file mode 100644 index ec088cfdd..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/test/java/cn/iocoder/yudao/module/product/service/sku/ProductSkuServiceTest.java +++ /dev/null @@ -1,171 +0,0 @@ -package cn.iocoder.yudao.module.product.service.sku; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.framework.test.core.util.AssertUtils; -import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuUpdateStockReqDTO; -import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuCreateOrUpdateReqVO; -import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO; -import cn.iocoder.yudao.module.product.dal.mysql.sku.ProductSkuMapper; -import cn.iocoder.yudao.module.product.service.property.ProductPropertyService; -import cn.iocoder.yudao.module.product.service.property.ProductPropertyValueService; -import cn.iocoder.yudao.module.product.service.spu.ProductSpuService; -import org.junit.jupiter.api.Test; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.context.annotation.Import; - -import javax.annotation.Resource; -import java.util.Arrays; -import java.util.List; - -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; -import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.SKU_NOT_EXISTS; -import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.SKU_STOCK_NOT_ENOUGH; -import static java.util.Collections.singletonList; -import static org.junit.jupiter.api.Assertions.*; -import static org.mockito.ArgumentMatchers.argThat; -import static org.mockito.Mockito.verify; - -/** - * {@link ProductSkuServiceImpl} 的单元测试 - * - * @author 芋道源码 - */ -@Import(ProductSkuServiceImpl.class) -public class ProductSkuServiceTest extends BaseDbUnitTest { - - @Resource - private ProductSkuService productSkuService; - - @Resource - private ProductSkuMapper productSkuMapper; - - @MockBean - private ProductSpuService productSpuService; - @MockBean - private ProductPropertyService productPropertyService; - @MockBean - private ProductPropertyValueService productPropertyValueService; - - @Test - public void testUpdateSkuList() { - // mock 数据 - ProductSkuDO sku01 = randomPojo(ProductSkuDO.class, o -> { // 测试更新 - o.setSpuId(1L); - 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))); - }); - productSkuMapper.insert(sku02); - // 准备参数 - Long spuId = 1L; - String spuName = "测试商品"; - List skus = Arrays.asList( - randomPojo(ProductSkuCreateOrUpdateReqVO.class, o -> { // 测试更新 - o.setProperties(singletonList(new ProductSkuCreateOrUpdateReqVO.Property(10L, 20L))); - o.setStatus(CommonStatusEnum.ENABLE.getStatus()); - }), - randomPojo(ProductSkuCreateOrUpdateReqVO.class, o -> { // 测试新增 - o.setProperties(singletonList(new ProductSkuCreateOrUpdateReqVO.Property(10L, 40L))); - o.setStatus(CommonStatusEnum.ENABLE.getStatus()); - }) - ); - - // 调用 - productSkuService.updateSkuList(spuId, spuName, skus); - // 断言 - List dbSkus = productSkuMapper.selectListBySpuId(spuId); - assertEquals(dbSkus.size(), 2); - // 断言更新的 - assertEquals(dbSkus.get(0).getId(), sku01.getId()); - assertPojoEquals(dbSkus.get(0), skus.get(0), "properties"); - assertEquals(skus.get(0).getProperties().size(), 1); - assertPojoEquals(dbSkus.get(0).getProperties().get(0), skus.get(0).getProperties().get(0)); - // 断言新增的 - assertNotEquals(dbSkus.get(1).getId(), sku02.getId()); - assertPojoEquals(dbSkus.get(1), skus.get(1), "properties"); - assertEquals(skus.get(1).getProperties().size(), 1); - assertPojoEquals(dbSkus.get(1).getProperties().get(0), skus.get(1).getProperties().get(0)); - } - - @Test - public void testUpdateSkuStock_incrSuccess() { - // 准备参数 - ProductSkuUpdateStockReqDTO updateStockReqDTO = new ProductSkuUpdateStockReqDTO() - .setItems(singletonList(new ProductSkuUpdateStockReqDTO.Item().setId(1L).setIncrCount(10))); - // mock 数据 - productSkuMapper.insert(randomPojo(ProductSkuDO.class, o -> o.setId(1L).setSpuId(10L).setStock(20))); - - // 调用 - productSkuService.updateSkuStock(updateStockReqDTO); - // 断言 - ProductSkuDO sku = productSkuMapper.selectById(1L); - assertEquals(sku.getStock(), 30); - verify(productSpuService).updateSpuStock(argThat(spuStockIncrCounts -> { - assertEquals(spuStockIncrCounts.size(), 1); - assertEquals(spuStockIncrCounts.get(10L), 10); - return true; - })); - } - - @Test - public void testUpdateSkuStock_decrSuccess() { - // 准备参数 - ProductSkuUpdateStockReqDTO updateStockReqDTO = new ProductSkuUpdateStockReqDTO() - .setItems(singletonList(new ProductSkuUpdateStockReqDTO.Item().setId(1L).setIncrCount(-10))); - // mock 数据 - productSkuMapper.insert(randomPojo(ProductSkuDO.class, o -> o.setId(1L).setSpuId(10L).setStock(20))); - - // 调用 - productSkuService.updateSkuStock(updateStockReqDTO); - // 断言 - ProductSkuDO sku = productSkuMapper.selectById(1L); - assertEquals(sku.getStock(), 10); - verify(productSpuService).updateSpuStock(argThat(spuStockIncrCounts -> { - assertEquals(spuStockIncrCounts.size(), 1); - assertEquals(spuStockIncrCounts.get(10L), -10); - return true; - })); - } - - @Test - public void testUpdateSkuStock_decrFail() { - // 准备参数 - ProductSkuUpdateStockReqDTO updateStockReqDTO = new ProductSkuUpdateStockReqDTO() - .setItems(singletonList(new ProductSkuUpdateStockReqDTO.Item().setId(1L).setIncrCount(-30))); - // mock 数据 - productSkuMapper.insert(randomPojo(ProductSkuDO.class, o -> o.setId(1L).setSpuId(10L).setStock(20))); - - // 调用并断言 - AssertUtils.assertServiceException(() -> productSkuService.updateSkuStock(updateStockReqDTO), - SKU_STOCK_NOT_ENOUGH); - } - - @Test - public void testDeleteSku_success() { - // mock 数据 - ProductSkuDO dbSku = randomPojo(ProductSkuDO.class); - productSkuMapper.insert(dbSku);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbSku.getId(); - - // 调用 - productSkuService.deleteSku(id); - // 校验数据不存在了 - assertNull(productSkuMapper.selectById(id)); - } - - @Test - public void testDeleteSku_notExists() { - // 准备参数 - Long id = 1L; - - // 调用, 并断言异常 - assertServiceException(() -> productSkuService.deleteSku(id), SKU_NOT_EXISTS); - } -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/test/java/cn/iocoder/yudao/module/product/service/spu/ProductSpuServiceImplTest.java b/yudao-module-mall/yudao-module-product-biz/src/test/java/cn/iocoder/yudao/module/product/service/spu/ProductSpuServiceImplTest.java deleted file mode 100755 index 1e029570c..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/test/java/cn/iocoder/yudao/module/product/service/spu/ProductSpuServiceImplTest.java +++ /dev/null @@ -1,359 +0,0 @@ -package cn.iocoder.yudao.module.product.service.spu; - -import cn.hutool.core.date.DateUtil; -import cn.hutool.core.map.MapUtil; -import cn.hutool.core.util.RandomUtil; -import cn.iocoder.yudao.framework.common.exception.ServiceException; -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.SetUtils; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuCreateOrUpdateReqVO; -import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSpuCreateReqVO; -import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSpuPageReqVO; -import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSpuRespVO; -import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSpuUpdateReqVO; -import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppProductSpuPageReqVO; -import cn.iocoder.yudao.module.product.convert.spu.ProductSpuConvert; -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.mysql.spu.ProductSpuMapper; -import cn.iocoder.yudao.module.product.enums.spu.ProductSpuSpecTypeEnum; -import cn.iocoder.yudao.module.product.enums.spu.ProductSpuStatusEnum; -import cn.iocoder.yudao.module.product.service.brand.ProductBrandServiceImpl; -import cn.iocoder.yudao.module.product.service.category.ProductCategoryServiceImpl; -import cn.iocoder.yudao.module.product.service.property.ProductPropertyService; -import cn.iocoder.yudao.module.product.service.property.ProductPropertyValueService; -import cn.iocoder.yudao.module.product.service.sku.ProductSkuServiceImpl; -import com.google.common.collect.Lists; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; -import org.mockito.Mockito; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.context.annotation.Import; - -import javax.annotation.Resource; -import java.util.*; -import java.util.stream.Collectors; -import java.util.stream.Stream; - -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; -import static org.junit.jupiter.api.Assertions.assertEquals; - -// TODO @芋艿:review 下单元测试 - -/** - * {@link ProductSpuServiceImpl} 的单元测试类 - * - * @author 芋道源码 - */ -@Import(ProductSpuServiceImpl.class) -@Disabled // TODO 芋艿:临时去掉 -public class ProductSpuServiceImplTest extends BaseDbUnitTest { - - @Resource - private ProductSpuServiceImpl productSpuService; - - @Resource - private ProductSpuMapper productSpuMapper; - - @MockBean - private ProductSkuServiceImpl productSkuService; - @MockBean - private ProductCategoryServiceImpl categoryService; - @MockBean - private ProductBrandServiceImpl brandService; - @MockBean - private ProductPropertyService productPropertyService; - @MockBean - private ProductPropertyValueService productPropertyValueService; - - public String generateNo() { - return DateUtil.format(new Date(), "yyyyMMddHHmmss") + RandomUtil.randomInt(100000, 999999); - } - - public Long generateId() { - return RandomUtil.randomLong(100000, 999999); - } - - @Test - public void testCreateSpu_success() { - // 准备参数 - ProductSpuCreateReqVO createReqVO = randomPojo(ProductSpuCreateReqVO.class, o -> { - o.setSpecType(ProductSpuSpecTypeEnum.DISABLE.getType()); - o.setStatus(ProductSpuStatusEnum.ENABLE.getStatus()); - }); - - // 校验SKU - List skuCreateReqList = createReqVO.getSkus(); - - Long spu = productSpuService.createSpu(createReqVO); - ProductSpuDO productSpuDO = productSpuMapper.selectById(spu); - - createReqVO.setMarketPrice(CollectionUtils.getMaxValue(skuCreateReqList, ProductSkuCreateOrUpdateReqVO::getMarketPrice)); -// createReqVO.setMaxPrice(CollectionUtils.getMaxValue(skuCreateReqList, ProductSkuCreateOrUpdateReqVO::getPrice)); -// createReqVO.setMinPrice(CollectionUtils.getMinValue(skuCreateReqList, ProductSkuCreateOrUpdateReqVO::getPrice)); -// createReqVO.setTotalStock(CollectionUtils.getSumValue(skuCreateReqList, ProductSkuCreateOrUpdateReqVO::getStock, Integer::sum)); - - assertPojoEquals(createReqVO, productSpuDO); - - } - - @Test - public void testUpdateSpu_success() { - // 准备参数 - ProductSpuDO createReqVO = randomPojo(ProductSpuDO.class); - productSpuMapper.insert(createReqVO); - // 准备参数 - ProductSpuUpdateReqVO reqVO = randomPojo(ProductSpuUpdateReqVO.class, o -> { - o.setId(createReqVO.getId()); // 设置更新的 ID - o.setSpecType(ProductSpuSpecTypeEnum.DISABLE.getType()); - o.setStatus(ProductSpuStatusEnum.DISABLE.getStatus()); - }); - // 调用 - productSpuService.updateSpu(reqVO); - - List skuCreateReqList = reqVO.getSkus(); - reqVO.setMarketPrice(CollectionUtils.getMaxValue(skuCreateReqList, ProductSkuCreateOrUpdateReqVO::getMarketPrice)); -// reqVO.setMaxPrice(CollectionUtils.getMaxValue(skuCreateReqList, ProductSkuCreateOrUpdateReqVO::getPrice)); -// reqVO.setMinPrice(CollectionUtils.getMinValue(skuCreateReqList, ProductSkuCreateOrUpdateReqVO::getPrice)); -// reqVO.setTotalStock(CollectionUtils.getSumValue(skuCreateReqList, ProductSkuCreateOrUpdateReqVO::getStock, Integer::sum)); - - // 校验是否更新正确 - ProductSpuDO spu = productSpuMapper.selectById(reqVO.getId()); // 获取最新的 - assertPojoEquals(reqVO, spu); - } - - @Test - public void testValidateSpuExists_exception() { - ProductSpuUpdateReqVO reqVO = randomPojo(ProductSpuUpdateReqVO.class, o -> { - o.setSpecType(ProductSpuSpecTypeEnum.DISABLE.getType()); - o.setStatus(ProductSpuStatusEnum.DISABLE.getStatus()); - }); - // 调用 - Assertions.assertThrows(ServiceException.class, () -> productSpuService.updateSpu(reqVO)); - } - - @Test - void deleteSpu() { - // 准备参数 - ProductSpuDO createReqVO = randomPojo(ProductSpuDO.class); - productSpuMapper.insert(createReqVO); - - // 调用 - productSpuService.deleteSpu(createReqVO.getId()); - - Assertions.assertNull(productSpuMapper.selectById(createReqVO.getId())); - } - - @Test - void getSpu() { - // 准备参数 - ProductSpuDO createReqVO = randomPojo(ProductSpuDO.class); - productSpuMapper.insert(createReqVO); - - ProductSpuDO spu = productSpuService.getSpu(createReqVO.getId()); - assertPojoEquals(createReqVO, spu); - } - - @Test - void getSpuList() { - // 准备参数 - ArrayList createReqVO = Lists.newArrayList(randomPojo(ProductSpuDO.class), randomPojo(ProductSpuDO.class)); - productSpuMapper.insertBatch(createReqVO); - - // 调用 - List spuList = productSpuService.getSpuList(createReqVO.stream().map(ProductSpuDO::getId).collect(Collectors.toList())); - Assertions.assertIterableEquals(createReqVO, spuList); - } - - @Test - void getSpuPage_alarmStock_empty() { - // 调用 - ProductSpuPageReqVO productSpuPageReqVO = new ProductSpuPageReqVO(); - productSpuPageReqVO.setAlarmStock(true); - - PageResult spuPage = productSpuService.getSpuPage(productSpuPageReqVO); - - PageResult result = PageResult.empty(); - Assertions.assertIterableEquals(result.getList(), spuPage.getList()); - assertEquals(spuPage.getTotal(), result.getTotal()); - } - - @Test - void getSpuPage_alarmStock() { - // mock 数据 - Long brandId = generateId(); - Long categoryId = generateId(); - String code = generateNo(); - - // 准备参数 - ProductSpuDO createReqVO = randomPojo(ProductSpuDO.class, o->{ - o.setStatus(ProductSpuStatusEnum.ENABLE.getStatus()); - o.setTotalStock(500); - o.setMinPrice(1); - o.setMaxPrice(50); - o.setMarketPrice(25); - o.setSpecType(ProductSpuSpecTypeEnum.RECYCLE.getType()); - o.setBrandId(brandId); - o.setCategoryId(categoryId); - o.setClickCount(100); - o.setCode(code); - o.setDescription("测试商品"); - o.setPicUrls(new ArrayList<>()); - o.setName("测试"); - o.setSalesCount(100); - o.setSellPoint("超级加倍"); - o.setShowStock(true); - o.setVideoUrl(""); - }); - productSpuMapper.insert(createReqVO); - - Set alarmStockSpuIds = SetUtils.asSet(createReqVO.getId()); - - List productSpuDOS = Arrays.asList(randomPojo(ProductSkuDO.class, o -> { - o.setSpuId(createReqVO.getId()); - }), randomPojo(ProductSkuDO.class, o -> { - o.setSpuId(createReqVO.getId()); - })); - - Mockito.when(productSkuService.getSkuListByAlarmStock()).thenReturn(productSpuDOS); - - // 调用 - ProductSpuPageReqVO productSpuPageReqVO = new ProductSpuPageReqVO(); - productSpuPageReqVO.setAlarmStock(true); - PageResult spuPage = productSpuService.getSpuPage(productSpuPageReqVO); - - PageResult result = ProductSpuConvert.INSTANCE.convertPage(productSpuMapper.selectPage(productSpuPageReqVO, alarmStockSpuIds)); - Assertions.assertIterableEquals(result.getList(), spuPage.getList()); - assertEquals(spuPage.getTotal(), result.getTotal()); - } - - @Test - void getSpuPage() { - // mock 数据 - Long brandId = generateId(); - Long categoryId = generateId(); - - // 准备参数 - ProductSpuDO createReqVO = randomPojo(ProductSpuDO.class, o->{ - o.setStatus(ProductSpuStatusEnum.ENABLE.getStatus()); - o.setTotalStock(1); - o.setMinPrice(1); - o.setMaxPrice(1); - o.setMarketPrice(1); - o.setSpecType(ProductSpuSpecTypeEnum.RECYCLE.getType()); - o.setBrandId(brandId); - o.setCategoryId(categoryId); - o.setClickCount(1); - o.setCode(generateNo()); - o.setDescription("测试商品"); - o.setPicUrls(new ArrayList<>()); - o.setName("测试"); - o.setSalesCount(1); - o.setSellPoint("卖点"); - o.setShowStock(true); - }); - - // 准备参数 - productSpuMapper.insert(createReqVO); - // 测试 status 不匹配 - productSpuMapper.insert(cloneIgnoreId(createReqVO, o -> o.setStatus(ProductSpuStatusEnum.DISABLE.getStatus()))); - productSpuMapper.insert(cloneIgnoreId(createReqVO, o -> o.setStatus(ProductSpuStatusEnum.RECYCLE.getStatus()))); - // 测试 SpecType 不匹配 - productSpuMapper.insert(cloneIgnoreId(createReqVO, o -> o.setSpecType(ProductSpuSpecTypeEnum.DISABLE.getType()))); - // 测试 BrandId 不匹配 - productSpuMapper.insert(cloneIgnoreId(createReqVO, o -> o.setBrandId(generateId()))); - // 测试 CategoryId 不匹配 - productSpuMapper.insert(cloneIgnoreId(createReqVO, o -> o.setCategoryId(generateId()))); - - // 调用 - ProductSpuPageReqVO productSpuPageReqVO = new ProductSpuPageReqVO(); - productSpuPageReqVO.setAlarmStock(false); - productSpuPageReqVO.setBrandId(brandId); - productSpuPageReqVO.setStatus(ProductSpuStatusEnum.ENABLE.getStatus()); - productSpuPageReqVO.setCategoryId(categoryId); - - PageResult spuPage = productSpuService.getSpuPage(productSpuPageReqVO); - - PageResult result = ProductSpuConvert.INSTANCE.convertPage(productSpuMapper.selectPage(productSpuPageReqVO, (Set) null)); - assertEquals(result, spuPage); - } - - @Test - void testGetSpuPage() { -// 准备参数 - ProductSpuDO createReqVO = randomPojo(ProductSpuDO.class, o -> { - o.setCategoryId(2L); - }); - productSpuMapper.insert(createReqVO); - - // 调用 - AppProductSpuPageReqVO appSpuPageReqVO = new AppProductSpuPageReqVO(); - appSpuPageReqVO.setCategoryId(2L); - -// PageResult spuPage = productSpuService.getSpuPage(appSpuPageReqVO); -// -// PageResult result = productSpuMapper.selectPage( -// ProductSpuConvert.INSTANCE.convert(appSpuPageReqVO)); -// -// List collect = result.getList() -// .stream() -// .map(ProductSpuConvert.INSTANCE::convertAppResp) -// .collect(Collectors.toList()); -// -// Assertions.assertIterableEquals(collect, spuPage.getList()); -// assertEquals(spuPage.getTotal(), result.getTotal()); - } - - - /** - * 生成笛卡尔积 - * - * @param data 数据 - * @return 笛卡尔积 - */ - public static List> cartesianProduct(List> data) { - List> res = null; // 结果集(当前为第N个List,则该处存放的就为前N-1个List的笛卡尔积集合) - for (List list : data) { // 遍历数据 - List> temp = new ArrayList<>(); // 临时结果集,存放本次循环后生成的笛卡尔积集合 - if (res == null) { // 结果集为null表示第一次循环既list为第一个List - for (T t : list) { // 便利第一个List - // 利用stream生成List,第一个List的笛卡尔积集合约等于自己本身(需要创建一个List并把对象添加到当中),存放到临时结果集 - temp.add(Stream.of(t).collect(Collectors.toList())); - } - res = temp; // 将临时结果集赋值给结果集 - continue; // 跳过本次循环 - } - // 不为第一个List,计算前面的集合(笛卡尔积)和当前List的笛卡尔积集合 - for (T t : list) { // 便利 - for (List rl : res) { // 便利前面的笛卡尔积集合 - // 利用stream生成List - temp.add(Stream.concat(rl.stream(), Stream.of(t)).collect(Collectors.toList())); - } - } - res = temp; // 将临时结果集赋值给结果集 - } - // 返回结果 - return res; - } - - @Test - public void testUpdateSpuStock() { - // 准备参数 - Map stockIncrCounts = MapUtil.builder(1L, 10).put(2L, -20).build(); - // mock 方法(数据) - productSpuMapper.insert(randomPojo(ProductSpuDO.class, o -> o.setId(1L).setTotalStock(20))); - productSpuMapper.insert(randomPojo(ProductSpuDO.class, o -> o.setId(2L).setTotalStock(30))); - - // 调用 - productSpuService.updateSpuStock(stockIncrCounts); - // 断言 - assertEquals(productSpuService.getSpu(1L).getTotalStock(), 30); - assertEquals(productSpuService.getSpu(2L).getTotalStock(), 10); - } - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/test/resources/application-unit-test.yaml b/yudao-module-mall/yudao-module-product-biz/src/test/resources/application-unit-test.yaml deleted file mode 100644 index 31e5ae5c9..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/test/resources/application-unit-test.yaml +++ /dev/null @@ -1,50 +0,0 @@ -spring: - main: - lazy-initialization: true # 开启懒加载,加快速度 - banner-mode: off # 单元测试,禁用 Banner - ---- #################### 数据库相关配置 #################### - -spring: - # 数据源配置项 - datasource: - name: ruoyi-vue-pro - url: jdbc:h2:mem:testdb;MODE=MYSQL;DATABASE_TO_UPPER=false;NON_KEYWORDS=value; # MODE 使用 MySQL 模式;DATABASE_TO_UPPER 配置表和字段使用小写 - driver-class-name: org.h2.Driver - username: sa - password: - druid: - async-init: true # 单元测试,异步初始化 Druid 连接池,提升启动速度 - initial-size: 1 # 单元测试,配置为 1,提升启动速度 - sql: - init: - schema-locations: classpath:/sql/create_tables.sql - - # Redis 配置。Redisson 默认的配置足够使用,一般不需要进行调优 - redis: - host: 127.0.0.1 # 地址 - port: 16379 # 端口(单元测试,使用 16379 端口) - database: 0 # 数据库索引 - -mybatis-plus: - lazy-initialization: true # 单元测试,设置 MyBatis Mapper 延迟加载,加速每个单元测试 - type-aliases-package: ${yudao.info.base-package}.module.*.dal.dataobject - ---- #################### 定时任务相关配置 #################### - ---- #################### 配置中心相关配置 #################### - ---- #################### 服务保障相关配置 #################### - -# Lock4j 配置项(单元测试,禁用 Lock4j) - -# Resilience4j 配置项 - ---- #################### 监控相关配置 #################### - ---- #################### 芋道相关配置 #################### - -# 芋道配置项,设置当前项目所有自定义的配置 -yudao: - info: - base-package: cn.iocoder.yudao diff --git a/yudao-module-mall/yudao-module-product-biz/src/test/resources/logback.xml b/yudao-module-mall/yudao-module-product-biz/src/test/resources/logback.xml deleted file mode 100644 index daf756bff..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/test/resources/logback.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/yudao-module-mall/yudao-module-product-biz/src/test/resources/sql/clean.sql b/yudao-module-mall/yudao-module-product-biz/src/test/resources/sql/clean.sql deleted file mode 100644 index aad191337..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/test/resources/sql/clean.sql +++ /dev/null @@ -1,3 +0,0 @@ -DELETE FROM "product_sku"; - -DELETE FROM "product_spu"; \ No newline at end of file diff --git a/yudao-module-mall/yudao-module-product-biz/src/test/resources/sql/create_tables.sql b/yudao-module-mall/yudao-module-product-biz/src/test/resources/sql/create_tables.sql deleted file mode 100644 index 9d26cc733..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/test/resources/sql/create_tables.sql +++ /dev/null @@ -1,69 +0,0 @@ -CREATE TABLE IF NOT EXISTS `product_sku` ( - `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键', - `spu_id` bigint NOT NULL COMMENT 'spu编号', - `spu_name` varchar DEFAULT NULL COMMENT '商品 SPU 名字', - `properties` varchar DEFAULT NULL COMMENT '规格值数组-json格式, [{propertId: , valueId: }, {propertId: , valueId: }]', - `price` int NOT NULL DEFAULT '-1' COMMENT '销售价格,单位:分', - `market_price` int DEFAULT NULL COMMENT '市场价', - `cost_price` int NOT NULL DEFAULT '-1' COMMENT '成本价,单位: 分', - `pic_url` varchar NOT NULL COMMENT '图片地址', - `stock` int DEFAULT NULL COMMENT '库存', - `warn_stock` int DEFAULT NULL COMMENT '预警库存', - `volume` double DEFAULT NULL COMMENT '商品体积', - `weight` double DEFAULT NULL COMMENT '商品重量', - `bar_code` varchar DEFAULT NULL COMMENT '条形码', - `status` tinyint DEFAULT NULL COMMENT '状态: 0-正常 1-禁用', - `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', - `update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', - `creator` varchar DEFAULT NULL COMMENT '创建人', - `updater` varchar DEFAULT NULL COMMENT '更新人', - `deleted` bit(1) NOT NULL DEFAULT 0 COMMENT '是否删除', - PRIMARY KEY (`id`) -) COMMENT '商品sku'; - - -CREATE TABLE IF NOT EXISTS `product_spu` ( - `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键', - `tenant_id` bigint NOT NULL DEFAULT '0' COMMENT '租户编号', - `brand_id` bigint DEFAULT NULL COMMENT '商品品牌编号', - `category_id` bigint NOT NULL COMMENT '分类id', - `spec_type` int NOT NULL COMMENT '规格类型:0 单规格 1 多规格', - `code` varchar(128) DEFAULT NULL COMMENT '商品编码', - `name` varchar(128) NOT NULL COMMENT '商品名称', - `sell_point` varchar(128) DEFAULT NULL COMMENT '卖点', - `description` text COMMENT '描述', - `pic_urls` varchar(1024) DEFAULT '' COMMENT '商品轮播图地址数组,以逗号分隔最多上传15张', - `video_url` varchar(128) DEFAULT NULL COMMENT '商品视频', - `market_price` int DEFAULT NULL COMMENT '市场价,单位使用:分', - `min_price` int DEFAULT NULL COMMENT '最小价格,单位使用:分', - `max_price` int DEFAULT NULL COMMENT '最大价格,单位使用:分', - `total_stock` int NOT NULL DEFAULT '0' COMMENT '总库存', - `show_stock` int DEFAULT '0' COMMENT '是否展示库存', - `sales_count` int DEFAULT '0' COMMENT '商品销量', - `virtual_sales_count` int DEFAULT '0' COMMENT '虚拟销量', - `click_count` int DEFAULT '0' COMMENT '商品点击量', - `status` bit(1) DEFAULT NULL COMMENT '上下架状态: 0 上架(开启) 1 下架(禁用)-1 回收', - `sort` int NOT NULL DEFAULT '0' COMMENT '排序字段', - `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', - `update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', - `creator` varchar DEFAULT NULL COMMENT '创建人', - `updater` varchar DEFAULT NULL COMMENT '更新人', - `deleted` bit(1) NOT NULL DEFAULT 0 COMMENT '是否删除', -PRIMARY KEY (`id`) -) COMMENT '商品spu'; - -CREATE TABLE IF NOT EXISTS `product_category` ( - `id` bigint NOT NULL AUTO_INCREMENT COMMENT '分类编号', - `parent_id` bigint DEFAULT NULL COMMENT '父分类编号', - `name` varchar(128) NOT NULL COMMENT '分类名称', - `description` varchar(128) NOT NULL COMMENT '分类描述', - `pic_url` varchar DEFAULT NULL COMMENT '分类图片', - `sort` int NOT NULL DEFAULT '0' COMMENT '排序字段', - `status` bit(1) DEFAULT NULL COMMENT '状态', - `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', - `update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', - `creator` varchar DEFAULT NULL COMMENT '创建人', - `updater` varchar DEFAULT NULL COMMENT '更新人', - `deleted` bit(1) NOT NULL DEFAULT 0 COMMENT '是否删除', - PRIMARY KEY (`id`) -) COMMENT '商品分类'; diff --git a/yudao-module-mall/yudao-module-promotion-api/pom.xml b/yudao-module-mall/yudao-module-promotion-api/pom.xml deleted file mode 100644 index 510b17bee..000000000 --- a/yudao-module-mall/yudao-module-promotion-api/pom.xml +++ /dev/null @@ -1,33 +0,0 @@ - - - - cn.iocoder.boot - yudao-module-mall - ${revision} - - 4.0.0 - yudao-module-promotion-api - jar - - ${project.artifactId} - - market 模块 API,暴露给其它模块调用 - - - - - cn.iocoder.boot - yudao-common - - - - - org.springframework.boot - spring-boot-starter-validation - true - - - - diff --git a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/coupon/CouponApi.java b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/coupon/CouponApi.java deleted file mode 100644 index f99ff815f..000000000 --- a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/coupon/CouponApi.java +++ /dev/null @@ -1,21 +0,0 @@ -package cn.iocoder.yudao.module.promotion.api.coupon; - -import cn.iocoder.yudao.module.promotion.api.coupon.dto.CouponUseReqDTO; - -import javax.validation.Valid; - -/** - * 优惠劵 API 接口 - * - * @author 芋道源码 - */ -public interface CouponApi { - - /** - * 使用优惠劵 - * - * @param useReqDTO 使用请求 - */ - void useCoupon(@Valid CouponUseReqDTO useReqDTO); - -} diff --git a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/coupon/dto/CouponUseReqDTO.java b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/coupon/dto/CouponUseReqDTO.java deleted file mode 100644 index 9323ab553..000000000 --- a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/coupon/dto/CouponUseReqDTO.java +++ /dev/null @@ -1,33 +0,0 @@ -package cn.iocoder.yudao.module.promotion.api.coupon.dto; - -import lombok.Data; - -import javax.validation.constraints.NotNull; - -/** - * 优惠劵使用 Request DTO - * - * @author 芋道源码 - */ -@Data -public class CouponUseReqDTO { - - /** - * 优惠劵编号 - */ - @NotNull(message = "优惠劵编号不能为空") - private Long id; - - /** - * 用户编号 - */ - @NotNull(message = "用户编号不能为空") - private Long userId; - - /** - * 订单编号 - */ - @NotNull(message = "订单编号不能为空") - private Long orderId; - -} diff --git a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/package-info.java b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/package-info.java deleted file mode 100644 index 08e1020a6..000000000 --- a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 占位 - */ -package cn.iocoder.yudao.module.promotion.api; diff --git a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/price/PriceApi.java b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/price/PriceApi.java deleted file mode 100644 index b36c938bc..000000000 --- a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/price/PriceApi.java +++ /dev/null @@ -1,21 +0,0 @@ -package cn.iocoder.yudao.module.promotion.api.price; - -import cn.iocoder.yudao.module.promotion.api.price.dto.PriceCalculateReqDTO; -import cn.iocoder.yudao.module.promotion.api.price.dto.PriceCalculateRespDTO; - -/** - * 价格 API 接口 - * - * @author 芋道源码 - */ -public interface PriceApi { - - /** - * 计算商品的价格 - * - * @param calculateReqDTO 价格请求 - * @return 价格相应 - */ - PriceCalculateRespDTO calculatePrice(PriceCalculateReqDTO calculateReqDTO); - -} diff --git a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/price/dto/CouponMeetRespDTO.java b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/price/dto/CouponMeetRespDTO.java deleted file mode 100644 index 310959e2c..000000000 --- a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/price/dto/CouponMeetRespDTO.java +++ /dev/null @@ -1,35 +0,0 @@ -package cn.iocoder.yudao.module.promotion.api.price.dto; - -import lombok.Data; - -/** - * 优惠劵的匹配信息 Response DTO - * - * why 放在 price 包下?主要获取的时候,需要涉及到较多的价格计算逻辑,放在 price 可以更好的复用逻辑 - * - * @author 芋道源码 - */ -@Data -public class CouponMeetRespDTO { - - /** - * 优惠劵编号 - */ - private Long id; - - // ========== 非优惠劵的基本信息字段 ========== - /** - * 是否匹配 - */ - private Boolean meet; - /** - * 不匹配的提示,即 {@link #meet} = true 才有值 - * - * 例如说: - * 1. 所结算商品没有符合条件的商品 - * 2. 差 XXX 元可用优惠劵 - * 3. 优惠劵未到使用时间 - */ - private String meetTip; - -} diff --git a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/price/dto/PriceCalculateReqDTO.java b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/price/dto/PriceCalculateReqDTO.java deleted file mode 100644 index 01f0ac220..000000000 --- a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/price/dto/PriceCalculateReqDTO.java +++ /dev/null @@ -1,56 +0,0 @@ -package cn.iocoder.yudao.module.promotion.api.price.dto; - -import lombok.Data; - -import javax.validation.constraints.Min; -import javax.validation.constraints.NotNull; -import java.util.List; - -/** - * 价格计算 Request DTO - * - * @author 芋道源码 - */ -@Data -public class PriceCalculateReqDTO { - - /** - * 用户编号 - * - * 对应 MemberUserDO 的 id 编号 - */ - private Long userId; - - /** - * 优惠劵编号 - */ - private Long couponId; - - /** - * 商品 SKU 数组 - */ - @NotNull(message = "商品数组不能为空") - private List items; - - /** - * 商品 SKU - */ - @Data - public static class Item { - - /** - * SKU 编号 - */ - @NotNull(message = "商品 SKU 编号不能为空") - private Long skuId; - - /** - * SKU 数量 - */ - @NotNull(message = "商品 SKU 数量不能为空") - @Min(value = 0L, message = "商品 SKU 数量必须大于等于 0") // 可传递 0 数量,用于购物车未选中的情况 - private Integer count; - - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/price/dto/PriceCalculateRespDTO.java b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/price/dto/PriceCalculateRespDTO.java deleted file mode 100644 index cda6d99d6..000000000 --- a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/price/dto/PriceCalculateRespDTO.java +++ /dev/null @@ -1,257 +0,0 @@ -package cn.iocoder.yudao.module.promotion.api.price.dto; - -import cn.iocoder.yudao.module.promotion.enums.common.PromotionLevelEnum; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionTypeEnum; -import lombok.Data; - -import java.util.List; - -/** - * 价格计算 Response DTO - * - * 整体设计,参考 taobao 的技术文档: - * 1. 订单管理 - * 2. 常用订单金额说明 - * - * 举个例子:订单图 - * 输入: - * 1. 订单实付: trade.payment = 198.00;订单邮费:5 元; - * 2. 商品级优惠 圣诞价: 省 29.00 元 和 圣诞价:省 150.00 元; 订单级优惠,圣诞 2:省 5.00 元; - * 分摊: - * 1. 商品 1:原价 108 元,优惠 29 元,子订单实付 79 元,分摊主订单优惠 1.99 元; - * 2. 商品 2:原价 269 元,优惠 150 元,子订单实付 119 元,分摊主订单优惠 3.01 元; - * - * @author 芋道源码 - */ -@Data -public class PriceCalculateRespDTO { - - /** - * 订单 - */ - private Order order; - - /** - * 营销活动数组 - * - * 只对应 {@link Order#items} 商品匹配的活动 - */ - private List promotions; - - /** - * 订单 - */ - @Data - public static class Order { - - /** - * 商品原价(总),单位:分 - * - * 基于 {@link OrderItem#getOriginalPrice()} 求和 - * - * 对应 taobao 的 trade.total_fee 字段 - */ - private Integer originalPrice; - /** - * 订单原价(总),单位:分 - * - * 基于 {@link OrderItem#getPayPrice()} 求和 - * 和 {@link #originalPrice} 的差异:去除商品级优惠 - */ - private Integer orderPrice; - /** - * 订单优惠(总),单位:分 - * - * 订单级优惠:对主订单的优惠,常见如:订单满 200 元减 10 元;订单满 80 包邮。 - * - * 对应 taobao 的 order.discount_fee 字段 - */ - private Integer discountPrice; - /** - * 优惠劵减免金额(总),单位:分 - * - * 对应 taobao 的 trade.coupon_fee 字段 - */ - private Integer couponPrice; - /** - * 积分减免金额(总),单位:分 - * - * 对应 taobao 的 trade.point_fee 字段 - */ - private Integer pointPrice; - /** - * 运费金额,单位:分 - */ - private Integer deliveryPrice; - /** - * 最终购买金额(总),单位:分 - * - * = {@link OrderItem#getPayPrice()} 求和 - * - {@link #couponPrice} - * - {@link #pointPrice} - * + {@link #deliveryPrice} - * - {@link #discountPrice} - */ - private Integer payPrice; - /** - * 商品 SKU 数组 - */ - private List items; - - // ========== 营销基本信息 ========== - /** - * 优惠劵编号 - */ - private Long couponId; - - } - - /** - * 订单商品 SKU - */ - @Data - public static class OrderItem { - - /** - * SPU 编号 - */ - private Long spuId; - /** - * SKU 编号 - */ - private Long skuId; - /** - * 购买数量 - */ - private Integer count; - - /** - * 商品原价(总),单位:分 - * - * = {@link #originalUnitPrice} * {@link #getCount()} - */ - private Integer originalPrice; - /** - * 商品原价(单),单位:分 - * - * 对应 ProductSkuDO 的 price 字段 - * 对应 taobao 的 order.price 字段 - */ - private Integer originalUnitPrice; - /** - * 商品优惠(总),单位:分 - * - * 商品级优惠:对单个商品的,常见如:商品原价的 8 折;商品原价的减 50 元 - * - * 对应 taobao 的 order.discount_fee 字段 - */ - private Integer discountPrice; - /** - * 子订单实付金额,不算主订单分摊金额,单位:分 - * - * = {@link #originalPrice} - * - {@link #discountPrice} - * - * 对应 taobao 的 order.payment 字段 - */ - private Integer payPrice; - - /** - * 子订单分摊金额(总),单位:分 - * 需要分摊 {@link Order#discountPrice}、{@link Order#couponPrice}、{@link Order#pointPrice} - * - * 对应 taobao 的 order.part_mjz_discount 字段 - * 淘宝说明:子订单分摊优惠基础逻辑:一般正常优惠券和满减优惠按照子订单的金额进行分摊,特殊情况如果优惠券是指定商品使用的,只会分摊到对应商品子订单上不分摊。 - */ - private Integer orderPartPrice; - /** - * 分摊后子订单实付金额(总),单位:分 - * - * = {@link #payPrice} - * - {@link #orderPartPrice} - * - * 对应 taobao 的 divide_order_fee 字段 - */ - private Integer orderDividePrice; - - } - - /** - * 营销明细 - */ - @Data - public static class Promotion { - - /** - * 营销编号 - * - * 例如说:营销活动的编号、优惠劵的编号 - */ - private Long id; - /** - * 营销名字 - */ - private String name; - /** - * 营销类型 - * - * 枚举 {@link PromotionTypeEnum} - */ - private Integer type; - /** - * 营销级别 - * - * 枚举 {@link PromotionLevelEnum} - */ - private Integer level; - /** - * 计算时的原价(总),单位:分 - */ - private Integer originalPrice; - /** - * 计算时的优惠(总),单位:分 - */ - private Integer discountPrice; - /** - * 匹配的商品 SKU 数组 - */ - private List items; - - // ========== 匹配情况 ========== - - /** - * 是否满足优惠条件 - */ - private Boolean meet; - /** - * 满足条件的提示 - * - * 如果 {@link #meet} = true 满足,则提示“圣诞价:省 150.00 元” - * 如果 {@link #meet} = false 不满足,则提示“购满 85 元,可减 40 元” - */ - private String meetTip; - - } - - /** - * 营销匹配的商品 SKU - */ - @Data - public static class PromotionItem { - - /** - * 商品 SKU 编号 - */ - private Long skuId; - /** - * 计算时的原价(总),单位:分 - */ - private Integer originalPrice; - /** - * 计算时的优惠(总),单位:分 - */ - private Integer discountPrice; - - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/ErrorCodeConstants.java b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/ErrorCodeConstants.java deleted file mode 100644 index 47ce28b4b..000000000 --- a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/ErrorCodeConstants.java +++ /dev/null @@ -1,60 +0,0 @@ -package cn.iocoder.yudao.module.promotion.enums; - -import cn.iocoder.yudao.framework.common.exception.ErrorCode; - -/** - * promotion 错误码枚举类 - * - * market 系统,使用 1-003-000-000 段 - */ -public interface ErrorCodeConstants { - - // ========== 促销活动相关 1003001000 ============ - ErrorCode DISCOUNT_ACTIVITY_NOT_EXISTS = new ErrorCode(1003001000, "限时折扣活动不存在"); - ErrorCode DISCOUNT_ACTIVITY_SPU_CONFLICTS = new ErrorCode(1003006001, "存在商品参加了其它限时折扣活动"); - ErrorCode DISCOUNT_ACTIVITY_UPDATE_FAIL_STATUS_CLOSED = new ErrorCode(1003006002, "限时折扣活动已关闭,不能修改"); - ErrorCode DISCOUNT_ACTIVITY_DELETE_FAIL_STATUS_NOT_CLOSED = new ErrorCode(1003006003, "限时折扣活动未关闭,不能删除"); - ErrorCode DISCOUNT_ACTIVITY_CLOSE_FAIL_STATUS_CLOSED = new ErrorCode(1003006004, "限时折扣活动已关闭,不能重复关闭"); - ErrorCode DISCOUNT_ACTIVITY_CLOSE_FAIL_STATUS_END = new ErrorCode(1003006004, "限时折扣活动已结束,不能关闭"); - - // ========== Banner 相关 1003002000 ============ - ErrorCode BANNER_NOT_EXISTS = new ErrorCode(1003002000, "Banner 不存在"); - - // ========== Coupon 相关 1003003000 ============ - ErrorCode COUPON_NO_MATCH_SPU = new ErrorCode(1003003000, "优惠劵没有可使用的商品!"); - ErrorCode COUPON_NO_MATCH_MIN_PRICE = new ErrorCode(1003003000, "所结算的商品中未满足使用的金额"); - - // ========== 优惠劵模板 1003004000 ========== - ErrorCode COUPON_TEMPLATE_NOT_EXISTS = new ErrorCode(1003004000, "优惠劵模板不存在"); - ErrorCode COUPON_TEMPLATE_TOTAL_COUNT_TOO_SMALL = new ErrorCode(1003004001, "发放数量不能小于已领取数量({})"); - - // ========== 优惠劵模板 1003005000 ========== - ErrorCode COUPON_NOT_EXISTS = new ErrorCode(1003005000, "优惠券不存在"); - ErrorCode COUPON_DELETE_FAIL_USED = new ErrorCode(1003005001, "回收优惠劵失败,优惠劵已被使用"); - ErrorCode COUPON_STATUS_NOT_UNUSED = new ErrorCode(1006003003, "优惠劵不处于待使用状态"); - ErrorCode COUPON_VALID_TIME_NOT_NOW = new ErrorCode(1006003004, "优惠券不在使用时间范围内"); - - // ========== 满减送活动 1003006000 ========== - ErrorCode REWARD_ACTIVITY_NOT_EXISTS = new ErrorCode(1003006000, "满减送活动不存在"); - ErrorCode REWARD_ACTIVITY_SPU_CONFLICTS = new ErrorCode(1003006001, "存在商品参加了其它满减送活动"); - ErrorCode REWARD_ACTIVITY_UPDATE_FAIL_STATUS_CLOSED = new ErrorCode(1003006002, "满减送活动已关闭,不能修改"); - ErrorCode REWARD_ACTIVITY_DELETE_FAIL_STATUS_NOT_CLOSED = new ErrorCode(1003006003, "满减送活动未关闭,不能删除"); - ErrorCode REWARD_ACTIVITY_CLOSE_FAIL_STATUS_CLOSED = new ErrorCode(1003006004, "满减送活动已关闭,不能重复关闭"); - ErrorCode REWARD_ACTIVITY_CLOSE_FAIL_STATUS_END = new ErrorCode(1003006004, "满减送活动已结束,不能关闭"); - - // ========== Price 相关 1003007000 ============ - ErrorCode PRICE_CALCULATE_PAY_PRICE_ILLEGAL = new ErrorCode(1003007000, "支付价格计算异常,原因:价格小于等于 0"); - - // ========== 秒杀活动 1003008000 ========== - ErrorCode SECKILL_ACTIVITY_NOT_EXISTS = new ErrorCode(1003008000, "秒杀活动不存在"); - ErrorCode SECKILL_ACTIVITY_SPU_CONFLICTS = new ErrorCode(1003008002, "存在商品参加了其它秒杀活动"); - ErrorCode SECKILL_ACTIVITY_UPDATE_FAIL_STATUS_CLOSED = new ErrorCode(1003008003, "秒杀活动已关闭,不能修改"); - ErrorCode SECKILL_ACTIVITY_DELETE_FAIL_STATUS_NOT_CLOSED_OR_END = new ErrorCode(1003008004, "秒杀活动未关闭或未结束,不能删除"); - ErrorCode SECKILL_ACTIVITY_CLOSE_FAIL_STATUS_CLOSED = new ErrorCode(1003008005, "秒杀活动已关闭,不能重复关闭"); - ErrorCode SECKILL_ACTIVITY_CLOSE_FAIL_STATUS_END = new ErrorCode(1003008006, "秒杀活动已结束,不能关闭"); - - // ========== 秒杀时段 1003009000 ========== - ErrorCode SECKILL_TIME_NOT_EXISTS = new ErrorCode(1003009000, "秒杀时段不存在"); - ErrorCode SECKILL_TIME_CONFLICTS = new ErrorCode(1003009001, "秒杀时段冲突"); - -} diff --git a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/common/PromotionActivityStatusEnum.java b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/common/PromotionActivityStatusEnum.java deleted file mode 100644 index db79f871b..000000000 --- a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/common/PromotionActivityStatusEnum.java +++ /dev/null @@ -1,39 +0,0 @@ -package cn.iocoder.yudao.module.promotion.enums.common; - -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Arrays; - -/** - * 促销活动的状态枚举 - * - * @author 芋道源码 - */ -@AllArgsConstructor -@Getter -public enum PromotionActivityStatusEnum implements IntArrayValuable { - - WAIT(10, "未开始"), - RUN(20, "进行中"), - END(30, "已结束"), - CLOSE(40, "已关闭"); - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(PromotionActivityStatusEnum::getStatus).toArray(); - - /** - * 状态值 - */ - private final Integer status; - /** - * 状态名 - */ - private final String name; - - @Override - public int[] array() { - return ARRAYS; - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/common/PromotionConditionTypeEnum.java b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/common/PromotionConditionTypeEnum.java deleted file mode 100644 index 05e62e399..000000000 --- a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/common/PromotionConditionTypeEnum.java +++ /dev/null @@ -1,37 +0,0 @@ -package cn.iocoder.yudao.module.promotion.enums.common; - -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Arrays; - -/** - * 营销的条件类型枚举 - * - * @author 芋道源码 - */ -@AllArgsConstructor -@Getter -public enum PromotionConditionTypeEnum implements IntArrayValuable { - - PRICE(10, "满 N 元"), - COUNT(20, "满 N 件"); - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(PromotionConditionTypeEnum::getType).toArray(); - - /** - * 类型值 - */ - private final Integer type; - /** - * 类型名 - */ - private final String name; - - @Override - public int[] array() { - return ARRAYS; - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/common/PromotionDiscountTypeEnum.java b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/common/PromotionDiscountTypeEnum.java deleted file mode 100644 index 7da6b4b08..000000000 --- a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/common/PromotionDiscountTypeEnum.java +++ /dev/null @@ -1,38 +0,0 @@ -package cn.iocoder.yudao.module.promotion.enums.common; - -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Arrays; - -/** - * 优惠类型枚举 - * - * @author 芋道源码 - */ -@Getter -@AllArgsConstructor -public enum PromotionDiscountTypeEnum implements IntArrayValuable { - - PRICE(1, "满减"), // 具体金额 - PERCENT(2, "折扣"), // 百分比 - ; - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(PromotionDiscountTypeEnum::getType).toArray(); - - /** - * 优惠类型 - */ - private final Integer type; - /** - * 名字 - */ - private final String name; - - @Override - public int[] array() { - return ARRAYS; - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/common/PromotionLevelEnum.java b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/common/PromotionLevelEnum.java deleted file mode 100644 index ed0564a70..000000000 --- a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/common/PromotionLevelEnum.java +++ /dev/null @@ -1,40 +0,0 @@ -package cn.iocoder.yudao.module.promotion.enums.common; - -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Arrays; - -/** - * 营销的级别枚举 - * - * 参考有赞:营销级别 - * - * @author 芋道源码 - */ -@Getter -@AllArgsConstructor -public enum PromotionLevelEnum implements IntArrayValuable { - - ORDER(1, "订单级"), // 多个商品,进行组合后优惠。例如说:满减送、打包一口价、第二件半价 - SKU(2, "商品级"), // 单个商品,直接优惠。例如说:限时折扣、会员折扣 - COUPON(3, "优惠劵"), // 多个商品,进行组合后优惠。例如说:优惠劵 - ; - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(PromotionLevelEnum::getLevel).toArray(); - - /** - * 级别值 - */ - private final Integer level; - /** - * 类型名 - */ - private final String name; - - @Override - public int[] array() { - return ARRAYS; - } -} diff --git a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/common/PromotionProductScopeEnum.java b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/common/PromotionProductScopeEnum.java deleted file mode 100644 index 0a7a4994d..000000000 --- a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/common/PromotionProductScopeEnum.java +++ /dev/null @@ -1,38 +0,0 @@ -package cn.iocoder.yudao.module.promotion.enums.common; - -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Arrays; - -/** - * 营销的商品范围枚举 - * - * @author 芋道源码 - */ -@Getter -@AllArgsConstructor -public enum PromotionProductScopeEnum implements IntArrayValuable { - - ALL(1, "全部商品参与"), - SPU(2, "指定商品参与"), - ; - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(PromotionProductScopeEnum::getScope).toArray(); - - /** - * 范围值 - */ - private final Integer scope; - /** - * 范围名 - */ - private final String name; - - @Override - public int[] array() { - return ARRAYS; - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/common/PromotionTypeEnum.java b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/common/PromotionTypeEnum.java deleted file mode 100644 index eea48f7dc..000000000 --- a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/common/PromotionTypeEnum.java +++ /dev/null @@ -1,40 +0,0 @@ -package cn.iocoder.yudao.module.promotion.enums.common; - -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Arrays; - -/** - * 营销类型枚举 - * - * @author 芋道源码 - */ -@Getter -@AllArgsConstructor -public enum PromotionTypeEnum implements IntArrayValuable { - - DISCOUNT_ACTIVITY(1, "限时折扣"), - REWARD_ACTIVITY(2, "满减送"), - - MEMBER(3, "会员折扣"), - COUPON(4, "优惠劵") - ; - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(PromotionTypeEnum::getType).toArray(); - - /** - * 类型值 - */ - private final Integer type; - /** - * 类型名 - */ - private final String name; - - @Override - public int[] array() { - return ARRAYS; - } -} diff --git a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/coupon/CouponStatusEnum.java b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/coupon/CouponStatusEnum.java deleted file mode 100644 index 320345d85..000000000 --- a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/coupon/CouponStatusEnum.java +++ /dev/null @@ -1,39 +0,0 @@ -package cn.iocoder.yudao.module.promotion.enums.coupon; - -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Arrays; - -/** - * 优惠劵状态枚举 - * - * @author 芋道源码 - */ -@AllArgsConstructor -@Getter -public enum CouponStatusEnum implements IntArrayValuable { - - UNUSED(1, "未使用"), - USED(2, "已使用"), - EXPIRE(3, "已过期"), - ; - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(CouponStatusEnum::getStatus).toArray(); - - /** - * 值 - */ - private final Integer status; - /** - * 名字 - */ - private final String name; - - @Override - public int[] array() { - return ARRAYS; - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/coupon/CouponTakeTypeEnum.java b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/coupon/CouponTakeTypeEnum.java deleted file mode 100644 index ce7974142..000000000 --- a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/coupon/CouponTakeTypeEnum.java +++ /dev/null @@ -1,37 +0,0 @@ -package cn.iocoder.yudao.module.promotion.enums.coupon; - -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Arrays; - -/** - * 优惠劵领取方式 - * - * @author 芋道源码 - */ -@AllArgsConstructor -@Getter -public enum CouponTakeTypeEnum implements IntArrayValuable { - - BY_USER(1, "直接领取"), // 用户可在首页、每日领劵直接领取 - BY_ADMIN(2, "指定发放"), // 后台指定会员赠送优惠劵 - ; - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(CouponTakeTypeEnum::getValue).toArray(); - - /** - * 值 - */ - private final Integer value; - /** - * 名字 - */ - private final String name; - - @Override - public int[] array() { - return ARRAYS; - } -} diff --git a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/coupon/CouponTemplateValidityTypeEnum.java b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/coupon/CouponTemplateValidityTypeEnum.java deleted file mode 100644 index 391515de3..000000000 --- a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/coupon/CouponTemplateValidityTypeEnum.java +++ /dev/null @@ -1,38 +0,0 @@ -package cn.iocoder.yudao.module.promotion.enums.coupon; - -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Arrays; - -/** - * 优惠劵模板的有限期类型的枚举 - * - * @author 芋道源码 - */ -@AllArgsConstructor -@Getter -public enum CouponTemplateValidityTypeEnum implements IntArrayValuable { - - DATE(1, "固定日期"), - TERM(2, "领取之后"), - ; - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(CouponTemplateValidityTypeEnum::getType).toArray(); - - /** - * 值 - */ - private final Integer type; - /** - * 名字 - */ - private final String name; - - @Override - public int[] array() { - return ARRAYS; - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/pom.xml b/yudao-module-mall/yudao-module-promotion-biz/pom.xml deleted file mode 100644 index 266cb1511..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/pom.xml +++ /dev/null @@ -1,77 +0,0 @@ - - - - cn.iocoder.boot - yudao-module-mall - ${revision} - - 4.0.0 - jar - yudao-module-promotion-biz - - ${project.artifactId} - - - market模块,主要实现营销相关功能 - 例如:营销活动、banner广告、优惠券、优惠码等功能。 - - - - - cn.iocoder.boot - yudao-module-promotion-api - ${revision} - - - cn.iocoder.boot - yudao-module-product-api - ${revision} - - - cn.iocoder.boot - yudao-module-member-api - ${revision} - - - - - cn.iocoder.boot - yudao-spring-boot-starter-biz-operatelog - - - cn.iocoder.boot - yudao-spring-boot-starter-biz-weixin - - - - - cn.iocoder.boot - yudao-spring-boot-starter-web - - - cn.iocoder.boot - yudao-spring-boot-starter-security - - - - - cn.iocoder.boot - yudao-spring-boot-starter-mybatis - - - - - cn.iocoder.boot - yudao-spring-boot-starter-test - - - - - cn.iocoder.boot - yudao-spring-boot-starter-excel - - - - diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/api/coupon/CouponApiImpl.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/api/coupon/CouponApiImpl.java deleted file mode 100644 index 349eba1ff..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/api/coupon/CouponApiImpl.java +++ /dev/null @@ -1,27 +0,0 @@ -package cn.iocoder.yudao.module.promotion.api.coupon; - - -import cn.iocoder.yudao.module.promotion.api.coupon.dto.CouponUseReqDTO; -import cn.iocoder.yudao.module.promotion.service.coupon.CouponService; -import org.springframework.stereotype.Service; - -import javax.annotation.Resource; - -/** - * 优惠劵 API 实现类 - * - * @author 芋道源码 - */ -@Service -public class CouponApiImpl implements CouponApi { - - @Resource - private CouponService couponService; - - @Override - public void useCoupon(CouponUseReqDTO useReqDTO) { - couponService.useCoupon(useReqDTO.getId(), useReqDTO.getUserId(), - useReqDTO.getOrderId()); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/api/discount/package-info.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/api/discount/package-info.java deleted file mode 100644 index 4e3ce77a8..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/api/discount/package-info.java +++ /dev/null @@ -1 +0,0 @@ -package cn.iocoder.yudao.module.promotion.api.discount; diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/api/price/PriceApiImpl.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/api/price/PriceApiImpl.java deleted file mode 100644 index 3c415f1c4..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/api/price/PriceApiImpl.java +++ /dev/null @@ -1,26 +0,0 @@ -package cn.iocoder.yudao.module.promotion.api.price; - -import cn.iocoder.yudao.module.promotion.api.price.dto.PriceCalculateReqDTO; -import cn.iocoder.yudao.module.promotion.api.price.dto.PriceCalculateRespDTO; -import cn.iocoder.yudao.module.promotion.service.price.PriceService; -import org.springframework.stereotype.Service; - -import javax.annotation.Resource; - -/** - * 价格 API 实现类 - * - * @author 芋道源码 - */ -@Service -public class PriceApiImpl implements PriceApi { - - @Resource - private PriceService priceService; - - @Override - public PriceCalculateRespDTO calculatePrice(PriceCalculateReqDTO calculateReqDTO) { - return priceService.calculatePrice(calculateReqDTO); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/banner/BannerController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/banner/BannerController.java deleted file mode 100644 index f052a3349..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/banner/BannerController.java +++ /dev/null @@ -1,71 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.banner; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.controller.admin.banner.vo.*; -import cn.iocoder.yudao.module.promotion.convert.banner.BannerConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.banner.BannerDO; -import cn.iocoder.yudao.module.promotion.service.banner.BannerService; -import io.swagger.v3.oas.annotations.tags.Tag; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.Operation; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.validation.Valid; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "管理后台 - Banner 管理") -@RestController -@RequestMapping("/market/banner") -@Validated -public class BannerController { - - @Resource - private BannerService bannerService; - - @PostMapping("/create") - @Operation(summary = "创建 Banner") - @PreAuthorize("@ss.hasPermission('market:banner:create')") - public CommonResult createBanner(@Valid @RequestBody BannerCreateReqVO createReqVO) { - return success(bannerService.createBanner(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新 Banner") - @PreAuthorize("@ss.hasPermission('market:banner:update')") - public CommonResult updateBanner(@Valid @RequestBody BannerUpdateReqVO updateReqVO) { - bannerService.updateBanner(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除 Banner") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('market:banner:delete')") - public CommonResult deleteBanner(@RequestParam("id") Long id) { - bannerService.deleteBanner(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得 Banner") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('market:banner:query')") - public CommonResult getBanner(@RequestParam("id") Long id) { - BannerDO banner = bannerService.getBanner(id); - return success(BannerConvert.INSTANCE.convert(banner)); - } - - @GetMapping("/page") - @Operation(summary = "获得 Banner 分页") - @PreAuthorize("@ss.hasPermission('market:banner:query')") - public CommonResult> getBannerPage(@Valid BannerPageReqVO pageVO) { - PageResult pageResult = bannerService.getBannerPage(pageVO); - return success(BannerConvert.INSTANCE.convertPage(pageResult)); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/banner/vo/BannerBaseVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/banner/vo/BannerBaseVO.java deleted file mode 100644 index 6c72155f4..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/banner/vo/BannerBaseVO.java +++ /dev/null @@ -1,42 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.banner.vo; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotNull; - -/** - * Banner Base VO,提供给添加、修改、详细的子 VO 使用 - * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 - * @author xia - */ -@Data -public class BannerBaseVO { - - @Schema(description = "标题", required = true) - @NotNull(message = "标题不能为空") - private String title; - - @Schema(description = "跳转链接", required = true) - @NotNull(message = "跳转链接不能为空") - private String url; - - @Schema(description = "图片地址", required = true) - @NotNull(message = "图片地址不能为空") - private String picUrl; - - @Schema(description = "排序", required = true) - @NotNull(message = "排序不能为空") - private Integer sort; - - @Schema(description = "状态", required = true) - @NotNull(message = "状态不能为空") - @InEnum(CommonStatusEnum.class) - private Integer status; - - @Schema(description = "备注") - private String memo; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/banner/vo/BannerCreateReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/banner/vo/BannerCreateReqVO.java deleted file mode 100644 index eefdd175a..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/banner/vo/BannerCreateReqVO.java +++ /dev/null @@ -1,18 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.banner.vo; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -/** - * @author xia - */ -@Schema(description = "管理后台 - Banner 创建 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class BannerCreateReqVO extends BannerBaseVO { - - - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/banner/vo/BannerPageReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/banner/vo/BannerPageReqVO.java deleted file mode 100644 index b97008ccd..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/banner/vo/BannerPageReqVO.java +++ /dev/null @@ -1,37 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.banner.vo; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -/** - * @author xia - */ -@Schema(description = "管理后台 - Banner 分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class BannerPageReqVO extends PageParam { - - @Schema(description = "标题") - private String title; - - - @Schema(description = "状态") - @InEnum(CommonStatusEnum.class) - private Integer status; - - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - @Schema(description = "创建时间") - private LocalDateTime[] createTime; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/banner/vo/BannerRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/banner/vo/BannerRespVO.java deleted file mode 100644 index fb0010669..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/banner/vo/BannerRespVO.java +++ /dev/null @@ -1,25 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.banner.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.ToString; - -import javax.validation.constraints.NotNull; -import java.time.LocalDateTime; - -/** - * @author xia - */ -@Schema(description = "管理后台 - Banner Response VO") -@Data -@ToString(callSuper = true) -public class BannerRespVO extends BannerBaseVO { - - @Schema(description = "banner编号", required = true) - @NotNull(message = "banner编号不能为空") - private Long id; - - @Schema(description = "创建时间", required = true) - private LocalDateTime createTime; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/banner/vo/BannerUpdateReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/banner/vo/BannerUpdateReqVO.java deleted file mode 100644 index 033b6054d..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/banner/vo/BannerUpdateReqVO.java +++ /dev/null @@ -1,23 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.banner.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import javax.validation.constraints.NotNull; - -/** - * @author xia - */ -@Schema(description = "管理后台 - Banner更新 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class BannerUpdateReqVO extends BannerBaseVO { - - @Schema(description = "banner 编号", required = true) - @NotNull(message = "banner 编号不能为空") - private Long id; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/CouponController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/CouponController.java deleted file mode 100755 index b6b87b567..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/CouponController.java +++ /dev/null @@ -1,75 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.coupon; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.MapUtils; -import cn.iocoder.yudao.module.member.api.user.MemberUserApi; -import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; -import cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.coupon.CouponPageItemRespVO; -import cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.coupon.CouponPageReqVO; -import cn.iocoder.yudao.module.promotion.convert.coupon.CouponConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.coupon.CouponDO; -import cn.iocoder.yudao.module.promotion.service.coupon.CouponService; -import io.swagger.v3.oas.annotations.tags.Tag; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.Operation; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.validation.Valid; -import java.util.Map; -import java.util.Set; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; - -@Tag(name = "管理后台 - 优惠劵") -@RestController -@RequestMapping("/promotion/coupon") -@Validated -public class CouponController { - - @Resource - private CouponService couponService; - @Resource - private MemberUserApi memberUserApi; - -// @GetMapping("/get") -// @Operation(summary = "获得优惠劵") -// @Parameter(name = "id", description = "编号", required = true, example = "1024") -// @PreAuthorize("@ss.hasPermission('promotion:coupon:query')") -// public CommonResult getCoupon(@RequestParam("id") Long id) { -// CouponDO coupon = couponService.getCoupon(id); -// return success(CouponConvert.INSTANCE.convert(coupon)); -// } - - @DeleteMapping("/delete") - @Operation(summary = "回收优惠劵") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('promotion:coupon:delete')") - public CommonResult deleteCoupon(@RequestParam("id") Long id) { - couponService.deleteCoupon(id); - return success(true); - } - - @GetMapping("/page") - @Operation(summary = "获得优惠劵分页") - @PreAuthorize("@ss.hasPermission('promotion:coupon:query')") - public CommonResult> getCouponPage(@Valid CouponPageReqVO pageVO) { - PageResult pageResult = couponService.getCouponPage(pageVO); - PageResult pageResulVO = CouponConvert.INSTANCE.convertPage(pageResult); - if (CollUtil.isEmpty(pageResulVO.getList())) { - return success(pageResulVO); - } - // 读取用户信息,进行拼接 - Set userIds = convertSet(pageResult.getList(), CouponDO::getUserId); - Map userMap = memberUserApi.getUserMap(userIds); - pageResulVO.getList().forEach(itemRespVO -> MapUtils.findAndThen(userMap, itemRespVO.getUserId(), - userRespDTO -> itemRespVO.setNickname(userRespDTO.getNickname()))); - return success(pageResulVO); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/CouponTemplateController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/CouponTemplateController.java deleted file mode 100755 index df5b16986..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/CouponTemplateController.java +++ /dev/null @@ -1,79 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.coupon; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.template.*; -import cn.iocoder.yudao.module.promotion.convert.coupon.CouponTemplateConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.coupon.CouponTemplateDO; -import cn.iocoder.yudao.module.promotion.service.coupon.CouponTemplateService; -import io.swagger.v3.oas.annotations.tags.Tag; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.Operation; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.validation.Valid; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "管理后台 - 优惠劵模板") -@RestController -@RequestMapping("/promotion/coupon-template") -@Validated -public class CouponTemplateController { - - @Resource - private CouponTemplateService couponTemplateService; - - @PostMapping("/create") - @Operation(summary = "创建优惠劵模板") - @PreAuthorize("@ss.hasPermission('promotion:coupon-template:create')") - public CommonResult createCouponTemplate(@Valid @RequestBody CouponTemplateCreateReqVO createReqVO) { - return success(couponTemplateService.createCouponTemplate(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新优惠劵模板") - @PreAuthorize("@ss.hasPermission('promotion:coupon-template:update')") - public CommonResult updateCouponTemplate(@Valid @RequestBody CouponTemplateUpdateReqVO updateReqVO) { - couponTemplateService.updateCouponTemplate(updateReqVO); - return success(true); - } - - @PutMapping("/update-status") - @Operation(summary = "更新优惠劵模板状态") - @PreAuthorize("@ss.hasPermission('promotion:coupon-template:update')") - public CommonResult updateCouponTemplateStatus(@Valid @RequestBody CouponTemplateUpdateStatusReqVO reqVO) { - couponTemplateService.updateCouponTemplateStatus(reqVO.getId(), reqVO.getStatus()); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除优惠劵模板") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('promotion:coupon-template:delete')") - public CommonResult deleteCouponTemplate(@RequestParam("id") Long id) { - couponTemplateService.deleteCouponTemplate(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得优惠劵模板") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('promotion:coupon-template:query')") - public CommonResult getCouponTemplate(@RequestParam("id") Long id) { - CouponTemplateDO couponTemplate = couponTemplateService.getCouponTemplate(id); - return success(CouponTemplateConvert.INSTANCE.convert(couponTemplate)); - } - - @GetMapping("/page") - @Operation(summary = "获得优惠劵模板分页") - @PreAuthorize("@ss.hasPermission('promotion:coupon-template:query')") - public CommonResult> getCouponTemplatePage(@Valid CouponTemplatePageReqVO pageVO) { - PageResult pageResult = couponTemplateService.getCouponTemplatePage(pageVO); - return success(CouponTemplateConvert.INSTANCE.convertPage(pageResult)); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/coupon/CouponBaseVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/coupon/CouponBaseVO.java deleted file mode 100755 index 43611a903..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/coupon/CouponBaseVO.java +++ /dev/null @@ -1,103 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.coupon; - -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionDiscountTypeEnum; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionProductScopeEnum; -import com.fasterxml.jackson.annotation.JsonFormat; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import org.springframework.format.annotation.DateTimeFormat; - -import javax.validation.constraints.Min; -import javax.validation.constraints.NotNull; -import java.time.LocalDateTime; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.TIME_ZONE_DEFAULT; - -/** -* 优惠劵 Base VO,提供给添加、修改、详细的子 VO 使用 -* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 -*/ -@Data -public class CouponBaseVO { - - // ========== 基本信息 BEGIN ========== - @Schema(description = "优惠劵模板编号", required = true, example = "1024") - @NotNull(message = "优惠劵模板编号不能为空") - private Integer templateId; - - @Schema(description = "优惠劵名", required = true, example = "春节送送送") - @NotNull(message = "优惠劵名不能为空") - private String name; - - @Schema(description = "优惠码状态,参见 CouponStatusEnum 枚举", required = true, example = "1") - private Integer status; - - // ========== 基本信息 END ========== - - // ========== 领取情况 BEGIN ========== - @Schema(description = "用户编号", required = true, example = "1") - @NotNull(message = "用户编号不能为空") - private Long userId; - - @Schema(description = "领取方式,参见 CouponTakeTypeEnum 枚举类", required = true, example = "1") - @NotNull(message = "领取方式不能为空") - private Integer takeType; - // ========== 领取情况 END ========== - - // ========== 使用规则 BEGIN ========== - @Schema(description = "是否设置满多少金额可用,单位:分;0 - 不限制", required = true, example = "100") - @NotNull(message = "是否设置满多少金额可用不能为空") - private Integer usePrice; - - @Schema(description = "固定日期 - 生效开始时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - @JsonFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND, timezone = TIME_ZONE_DEFAULT) - private LocalDateTime validStartTime; - - @Schema(description = "固定日期 - 生效结束时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - @JsonFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND, timezone = TIME_ZONE_DEFAULT) - private LocalDateTime validEndTime; - - @Schema(description = "商品范围,参见 PromotionProductScopeEnum 枚举类", required = true, example = "1") - @NotNull(message = "商品范围不能为空") - @InEnum(PromotionProductScopeEnum.class) - private Integer productScope; - - @Schema(description = "商品 SPU 编号的数组", example = "1,3") - private List productSpuIds; - // ========== 使用规则 END ========== - - // ========== 使用效果 BEGIN ========== - @Schema(description = "优惠类型,参见 PromotionDiscountTypeEnum 枚举", required = true, example = "1") - @NotNull(message = "优惠类型不能为空") - @InEnum(PromotionDiscountTypeEnum.class) - private Integer discountType; - - @Schema(description = "折扣百分比,例如说,80% 为 80", example = "80") - private Integer discountPercent; - - @Schema(description = "优惠金额,单位:分", example = "10") - @Min(value = 0, message = "优惠金额需要大于等于 0") - private Integer discountPrice; - - @Schema(description = "折扣上限,单位:分,仅在 discountType 为 PERCENT 使用", example = "100") - private Integer discountLimitPrice; - // ========== 使用效果 END ========== - - // ========== 使用情况 BEGIN ========== - - @Schema(description = "使用订单号", example = "4096") - private Long useOrderId; - - @Schema(description = "使用时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - @JsonFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND, timezone = TIME_ZONE_DEFAULT) - private LocalDateTime useTime; - - // ========== 使用情况 END ========== - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/coupon/CouponPageItemRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/coupon/CouponPageItemRespVO.java deleted file mode 100755 index 118736ef6..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/coupon/CouponPageItemRespVO.java +++ /dev/null @@ -1,17 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.coupon; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "管理后台 - 优惠劵分页的每一项 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class CouponPageItemRespVO extends CouponRespVO { - - @Schema(description = "用户昵称", example = "老芋艿") - private String nickname; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/coupon/CouponPageReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/coupon/CouponPageReqVO.java deleted file mode 100755 index e74f6327d..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/coupon/CouponPageReqVO.java +++ /dev/null @@ -1,33 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.coupon; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 优惠劵分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class CouponPageReqVO extends PageParam { - - @Schema(description = "优惠劵模板编号", example = "2048") - private Long templateId; - - @Schema(description = "优惠码状态,参见 CouponStatusEnum 枚举", example = "1") - private Integer status; - - @Schema(description = "创建时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] createTime; - - @Schema(description = "用户昵称,模糊匹配", example = "芋艿") - private String nickname; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/coupon/CouponRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/coupon/CouponRespVO.java deleted file mode 100755 index 68f0bc44e..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/coupon/CouponRespVO.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.coupon; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 优惠劵 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class CouponRespVO extends CouponBaseVO { - - @Schema(description = "优惠劵编号", required = true, example = "1024") - private Long id; - - @Schema(description = "创建时间", required = true) - private LocalDateTime createTime; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/template/CouponTemplateBaseVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/template/CouponTemplateBaseVO.java deleted file mode 100755 index 0100c91c6..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/template/CouponTemplateBaseVO.java +++ /dev/null @@ -1,154 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.template; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.util.ObjectUtil; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionDiscountTypeEnum; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionProductScopeEnum; -import cn.iocoder.yudao.module.promotion.enums.coupon.CouponTemplateValidityTypeEnum; -import com.fasterxml.jackson.annotation.JsonFormat; -import com.fasterxml.jackson.annotation.JsonIgnore; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import org.springframework.format.annotation.DateTimeFormat; - -import javax.validation.constraints.AssertTrue; -import javax.validation.constraints.Min; -import javax.validation.constraints.NotNull; -import java.time.LocalDateTime; -import java.util.List; -import java.util.Objects; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.TIME_ZONE_DEFAULT; - -/** -* 优惠劵模板 Base VO,提供给添加、修改、详细的子 VO 使用 -* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 -*/ -@Data -public class CouponTemplateBaseVO { - - @Schema(description = "优惠劵名", required = true, example = "春节送送送") - @NotNull(message = "优惠劵名不能为空") - private String name; - - @Schema(description = "发行总量,-1 - 则表示不限制发放数量", required = true, example = "1024") - @NotNull(message = "发行总量不能为空") - private Integer totalCount; - - @Schema(description = "每人限领个数,-1 - 则表示不限制", required = true, example = "66") - @NotNull(message = "每人限领个数不能为空") - private Integer takeLimitCount; - - @Schema(description = "领取方式,参见 CouponTakeTypeEnum 枚举类", required = true, example = "1") - @NotNull(message = "领取方式不能为空") - private Integer takeType; - - @Schema(description = "是否设置满多少金额可用,单位:分;0 - 不限制", required = true, example = "100") - @NotNull(message = "是否设置满多少金额可用不能为空") - private Integer usePrice; - - @Schema(description = "商品范围,参见 PromotionProductScopeEnum 枚举类", required = true, example = "1") - @NotNull(message = "商品范围不能为空") - @InEnum(PromotionProductScopeEnum.class) - private Integer productScope; - - @Schema(description = "商品 SPU 编号的数组", example = "1,3") - private List productSpuIds; - - @Schema(description = "生效日期类型", required = true, example = "1") - @NotNull(message = "生效日期类型不能为空") - @InEnum(CouponTemplateValidityTypeEnum.class) - private Integer validityType; - - @Schema(description = "固定日期 - 生效开始时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - @JsonFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND, timezone = TIME_ZONE_DEFAULT) - private LocalDateTime validStartTime; - - @Schema(description = "固定日期 - 生效结束时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - @JsonFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND, timezone = TIME_ZONE_DEFAULT) - private LocalDateTime validEndTime; - - @Schema(description = "领取日期 - 开始天数") - @Min(value = 0L, message = "开始天数必须大于 0") - private Integer fixedStartTerm; - - @Schema(description = "领取日期 - 结束天数") - @Min(value = 1L, message = "开始天数必须大于 1") - private Integer fixedEndTerm; - - @Schema(description = "优惠类型,参见 PromotionDiscountTypeEnum 枚举", required = true, example = "1") - @NotNull(message = "优惠类型不能为空") - @InEnum(PromotionDiscountTypeEnum.class) - private Integer discountType; - - @Schema(description = "折扣百分比,例如说,80% 为 80", example = "80") - private Integer discountPercent; - - @Schema(description = "优惠金额,单位:分", example = "10") - @Min(value = 0, message = "优惠金额需要大于等于 0") - private Integer discountPrice; - - @Schema(description = "折扣上限,单位:分,仅在 discountType 为 PERCENT 使用", example = "100") - private Integer discountLimitPrice; - - @AssertTrue(message = "商品 SPU 编号的数组不能为空") - @JsonIgnore - public boolean isProductSpuIdsValid() { - return Objects.equals(productScope, PromotionProductScopeEnum.ALL.getScope()) // 全部范围时,可以为空 - || CollUtil.isNotEmpty(productSpuIds); - } - - @AssertTrue(message = "生效开始时间不能为空") - @JsonIgnore - public boolean isValidStartTimeValid() { - return ObjectUtil.notEqual(validityType, CouponTemplateValidityTypeEnum.DATE.getType()) - || validStartTime != null; - } - - @AssertTrue(message = "生效结束时间不能为空") - @JsonIgnore - public boolean isValidEndTimeValid() { - return ObjectUtil.notEqual(validityType, CouponTemplateValidityTypeEnum.DATE.getType()) - || validEndTime != null; - } - - @AssertTrue(message = "开始天数不能为空") - @JsonIgnore - public boolean isFixedStartTermValid() { - return ObjectUtil.notEqual(validityType, CouponTemplateValidityTypeEnum.TERM.getType()) - || fixedStartTerm != null; - } - - @AssertTrue(message = "结束天数不能为空") - @JsonIgnore - public boolean isFixedEndTermValid() { - return ObjectUtil.notEqual(validityType, CouponTemplateValidityTypeEnum.TERM.getType()) - || fixedEndTerm != null; - } - - @AssertTrue(message = "折扣百分比需要大于等于 1,小于等于 99") - @JsonIgnore - public boolean isDiscountPercentValid() { - return ObjectUtil.notEqual(discountType, PromotionDiscountTypeEnum.PERCENT.getType()) - || (discountPercent != null && discountPercent >= 1 && discountPercent<= 99); - } - - @AssertTrue(message = "优惠金额不能为空") - @JsonIgnore - public boolean isDiscountPriceValid() { - return ObjectUtil.notEqual(discountType, PromotionDiscountTypeEnum.PRICE.getType()) - || discountPrice != null; - } - - @AssertTrue(message = "折扣上限不能为空") - @JsonIgnore - public boolean isDiscountLimitPriceValid() { - return ObjectUtil.notEqual(discountType, PromotionDiscountTypeEnum.PERCENT.getType()) - || discountLimitPrice != null; - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/template/CouponTemplateCreateReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/template/CouponTemplateCreateReqVO.java deleted file mode 100755 index 7b24dbbdb..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/template/CouponTemplateCreateReqVO.java +++ /dev/null @@ -1,13 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.template; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "管理后台 - 优惠劵模板创建 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class CouponTemplateCreateReqVO extends CouponTemplateBaseVO { - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/template/CouponTemplatePageReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/template/CouponTemplatePageReqVO.java deleted file mode 100755 index bcbafcd06..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/template/CouponTemplatePageReqVO.java +++ /dev/null @@ -1,33 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.template; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 优惠劵模板分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class CouponTemplatePageReqVO extends PageParam { - - @Schema(description = "优惠劵名", example = "你好") - private String name; - - @Schema(description = "状态,参见 CommonStatusEnum 枚举类", example = "1") - private Integer status; - - @Schema(description = "优惠类型,参见 PromotionDiscountTypeEnum 枚举", example = "1") - private Integer discountType; - - @Schema(description = "创建时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] createTime; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/template/CouponTemplateRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/template/CouponTemplateRespVO.java deleted file mode 100755 index b90407b43..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/template/CouponTemplateRespVO.java +++ /dev/null @@ -1,34 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.template; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 优惠劵模板 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class CouponTemplateRespVO extends CouponTemplateBaseVO { - - @Schema(description = "模板编号", required = true, example = "1024") - private Long id; - - @Schema(description = "状态", required = true, example = "1") - @InEnum(CommonStatusEnum.class) - private Integer status; - - @Schema(description = "领取优惠券的数量", required = true, example = "1024") - private Integer takeCount; - - @Schema(description = "使用优惠券的次数", required = true, example = "2048") - private Integer useCount; - - @Schema(description = "创建时间", required = true) - private LocalDateTime createTime; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/template/CouponTemplateUpdateReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/template/CouponTemplateUpdateReqVO.java deleted file mode 100755 index 922e4f057..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/template/CouponTemplateUpdateReqVO.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.template; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import javax.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 优惠劵模板更新 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class CouponTemplateUpdateReqVO extends CouponTemplateBaseVO { - - @Schema(description = "模板编号", required = true, example = "1024") - @NotNull(message = "模板编号不能为空") - private Long id; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/template/CouponTemplateUpdateStatusReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/template/CouponTemplateUpdateStatusReqVO.java deleted file mode 100644 index f12f6b756..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/template/CouponTemplateUpdateStatusReqVO.java +++ /dev/null @@ -1,23 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.template; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 优惠劵模板更新状态 Request VO") -@Data -public class CouponTemplateUpdateStatusReqVO { - - @Schema(description = "优惠劵模板编号", required = true, example = "1024") - @NotNull(message = "优惠劵模板编号不能为空") - private Long id; - - @Schema(description = "状态,见 CommonStatusEnum 枚举", required = true, example = "1") - @NotNull(message = "状态不能为空") - @InEnum(value = CommonStatusEnum.class, message = "修改状态必须是 {value}") - private Integer status; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/discount/DiscountActivityController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/discount/DiscountActivityController.java deleted file mode 100755 index 08d4dc10e..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/discount/DiscountActivityController.java +++ /dev/null @@ -1,87 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.discount; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.controller.admin.discount.vo.*; -import cn.iocoder.yudao.module.promotion.convert.discount.DiscountActivityConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.discount.DiscountActivityDO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.discount.DiscountProductDO; -import cn.iocoder.yudao.module.promotion.service.discount.DiscountActivityService; -import io.swagger.v3.oas.annotations.tags.Tag; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.Operation; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.validation.Valid; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "管理后台 - 限时折扣活动") -@RestController -@RequestMapping("/promotion/discount-activity") -@Validated -public class DiscountActivityController { - - @Resource - private DiscountActivityService discountActivityService; - - @PostMapping("/create") - @Operation(summary = "创建限时折扣活动") - @PreAuthorize("@ss.hasPermission('promotion:discount-activity:create')") - public CommonResult createDiscountActivity(@Valid @RequestBody DiscountActivityCreateReqVO createReqVO) { - return success(discountActivityService.createDiscountActivity(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新限时折扣活动") - @PreAuthorize("@ss.hasPermission('promotion:discount-activity:update')") - public CommonResult updateDiscountActivity(@Valid @RequestBody DiscountActivityUpdateReqVO updateReqVO) { - discountActivityService.updateDiscountActivity(updateReqVO); - return success(true); - } - - @PutMapping("/close") - @Operation(summary = "关闭限时折扣活动") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('promotion:discount-activity:close')") - public CommonResult closeRewardActivity(@RequestParam("id") Long id) { - discountActivityService.closeRewardActivity(id); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除限时折扣活动") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('promotion:discount-activity:delete')") - public CommonResult deleteDiscountActivity(@RequestParam("id") Long id) { - discountActivityService.deleteDiscountActivity(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得限时折扣活动") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('promotion:discount-activity:query')") - public CommonResult getDiscountActivity(@RequestParam("id") Long id) { - DiscountActivityDO discountActivity = discountActivityService.getDiscountActivity(id); - if (discountActivity == null) { - return success(null); - } - // 拼接结果 - List discountProducts = discountActivityService.getDiscountProductsByActivityId(id); - return success(DiscountActivityConvert.INSTANCE.convert(discountActivity, discountProducts)); - } - - @GetMapping("/page") - @Operation(summary = "获得限时折扣活动分页") - @PreAuthorize("@ss.hasPermission('promotion:discount-activity:query')") - public CommonResult> getDiscountActivityPage(@Valid DiscountActivityPageReqVO pageVO) { - PageResult pageResult = discountActivityService.getDiscountActivityPage(pageVO); - return success(DiscountActivityConvert.INSTANCE.convertPage(pageResult)); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/discount/vo/DiscountActivityBaseVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/discount/vo/DiscountActivityBaseVO.java deleted file mode 100755 index d30df6c1c..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/discount/vo/DiscountActivityBaseVO.java +++ /dev/null @@ -1,81 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.discount.vo; - -import cn.hutool.core.util.ObjectUtil; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionDiscountTypeEnum; -import com.fasterxml.jackson.annotation.JsonIgnore; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import org.springframework.format.annotation.DateTimeFormat; - -import javax.validation.constraints.AssertTrue; -import javax.validation.constraints.Min; -import javax.validation.constraints.NotNull; -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -/** -* 限时折扣活动 Base VO,提供给添加、修改、详细的子 VO 使用 -* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 -*/ -@Data -public class DiscountActivityBaseVO { - - @Schema(description = "活动标题", required = true, example = "一个标题") - @NotNull(message = "活动标题不能为空") - private String name; - - @Schema(description = "开始时间", required = true) - @NotNull(message = "开始时间不能为空") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime startTime; - - @Schema(description = "结束时间", required = true) - @NotNull(message = "结束时间不能为空") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime endTime; - - @Schema(description = "备注", example = "我是备注") - private String remark; - - @Schema(description = "商品") - @Data - public static class Product { - - @Schema(description = "商品 SPU 编号", required = true, example = "1") - @NotNull(message = "商品 SPU 编号不能为空") - private Long spuId; - - @Schema(description = "商品 SKU 编号", required = true, example = "1") - @NotNull(message = "商品 SKU 编号不能为空") - private Long skuId; - - @Schema(description = "优惠类型,参见 PromotionDiscountTypeEnum 枚举", required = true, example = "1") - @NotNull(message = "优惠类型不能为空") - @InEnum(PromotionDiscountTypeEnum.class) - private Integer discountType; - - @Schema(description = "折扣百分比,例如说,80% 为 80", example = "80") - private Integer discountPercent; - - @Schema(description = "优惠金额,单位:分", example = "10") - @Min(value = 0, message = "优惠金额需要大于等于 0") - private Integer discountPrice; - - @AssertTrue(message = "折扣百分比需要大于等于 1,小于等于 99") - @JsonIgnore - public boolean isDiscountPercentValid() { - return ObjectUtil.notEqual(discountType, PromotionDiscountTypeEnum.PERCENT.getType()) - || (discountPercent != null && discountPercent >= 1 && discountPercent<= 99); - } - - @AssertTrue(message = "优惠金额不能为空") - @JsonIgnore - public boolean isDiscountPriceValid() { - return ObjectUtil.notEqual(discountType, PromotionDiscountTypeEnum.PRICE.getType()) - || discountPrice != null; - } - - } -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/discount/vo/DiscountActivityCreateReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/discount/vo/DiscountActivityCreateReqVO.java deleted file mode 100755 index 5b22cbd35..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/discount/vo/DiscountActivityCreateReqVO.java +++ /dev/null @@ -1,24 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.discount.vo; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import javax.validation.Valid; -import javax.validation.constraints.NotEmpty; -import java.util.List; - -@Schema(description = "管理后台 - 限时折扣活动创建 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class DiscountActivityCreateReqVO extends DiscountActivityBaseVO { - - /** - * 商品列表 - */ - @NotEmpty(message = "商品列表不能为空") - @Valid - private List products; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/discount/vo/DiscountActivityDetailRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/discount/vo/DiscountActivityDetailRespVO.java deleted file mode 100755 index caa0a648c..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/discount/vo/DiscountActivityDetailRespVO.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.discount.vo; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.util.List; - -@Schema(description = "管理后台 - 限时折扣活动的详细 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class DiscountActivityDetailRespVO extends DiscountActivityRespVO { - - /** - * 商品列表 - */ - private List products; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/discount/vo/DiscountActivityPageReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/discount/vo/DiscountActivityPageReqVO.java deleted file mode 100755 index 4463555ea..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/discount/vo/DiscountActivityPageReqVO.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.discount.vo; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 限时折扣活动分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class DiscountActivityPageReqVO extends PageParam { - - @Schema(description = "活动标题", example = "一个标题") - private String name; - - @Schema(description = "活动状态", example = "1") - private Integer status; - - @Schema(description = "创建时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] createTime; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/discount/vo/DiscountActivityRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/discount/vo/DiscountActivityRespVO.java deleted file mode 100755 index b552c56ed..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/discount/vo/DiscountActivityRespVO.java +++ /dev/null @@ -1,27 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.discount.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import javax.validation.constraints.NotNull; -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 限时折扣活动 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class DiscountActivityRespVO extends DiscountActivityBaseVO { - - @Schema(description = "活动编号", required = true, example = "1024") - private Long id; - - @Schema(description = "活动状态", required = true, example = "1") - @NotNull(message = "活动状态不能为空") - private Integer status; - - @Schema(description = "创建时间", required = true) - private LocalDateTime createTime; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/discount/vo/DiscountActivityUpdateReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/discount/vo/DiscountActivityUpdateReqVO.java deleted file mode 100755 index f9bf48c06..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/discount/vo/DiscountActivityUpdateReqVO.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.discount.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import javax.validation.Valid; -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; -import java.util.List; - -@Schema(description = "管理后台 - 限时折扣活动更新 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class DiscountActivityUpdateReqVO extends DiscountActivityBaseVO { - - @Schema(description = "活动编号", required = true, example = "1024") - @NotNull(message = "活动编号不能为空") - private Long id; - - /** - * 商品列表 - */ - @NotEmpty(message = "商品列表不能为空") - @Valid - private List products; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/reward/RewardActivityController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/reward/RewardActivityController.java deleted file mode 100755 index c8c13ccf0..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/reward/RewardActivityController.java +++ /dev/null @@ -1,83 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.reward; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.controller.admin.reward.vo.RewardActivityCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.reward.vo.RewardActivityPageReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.reward.vo.RewardActivityRespVO; -import cn.iocoder.yudao.module.promotion.controller.admin.reward.vo.RewardActivityUpdateReqVO; -import cn.iocoder.yudao.module.promotion.convert.reward.RewardActivityConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.reward.RewardActivityDO; -import cn.iocoder.yudao.module.promotion.service.reward.RewardActivityService; -import io.swagger.v3.oas.annotations.tags.Tag; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.Operation; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.validation.Valid; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "管理后台 - 满减送活动") -@RestController -@RequestMapping("/promotion/reward-activity") -@Validated -public class RewardActivityController { - - @Resource - private RewardActivityService rewardActivityService; - - @PostMapping("/create") - @Operation(summary = "创建满减送活动") - @PreAuthorize("@ss.hasPermission('promotion:reward-activity:create')") - public CommonResult createRewardActivity(@Valid @RequestBody RewardActivityCreateReqVO createReqVO) { - return success(rewardActivityService.createRewardActivity(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新满减送活动") - @PreAuthorize("@ss.hasPermission('promotion:reward-activity:update')") - public CommonResult updateRewardActivity(@Valid @RequestBody RewardActivityUpdateReqVO updateReqVO) { - rewardActivityService.updateRewardActivity(updateReqVO); - return success(true); - } - - @PutMapping("/close") - @Operation(summary = "关闭满减送活动") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('promotion:reward-activity:close')") - public CommonResult closeRewardActivity(@RequestParam("id") Long id) { - rewardActivityService.closeRewardActivity(id); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除满减送活动") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('promotion:reward-activity:delete')") - public CommonResult deleteRewardActivity(@RequestParam("id") Long id) { - rewardActivityService.deleteRewardActivity(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得满减送活动") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('promotion:reward-activity:query')") - public CommonResult getRewardActivity(@RequestParam("id") Long id) { - RewardActivityDO rewardActivity = rewardActivityService.getRewardActivity(id); - return success(RewardActivityConvert.INSTANCE.convert(rewardActivity)); - } - - @GetMapping("/page") - @Operation(summary = "获得满减送活动分页") - @PreAuthorize("@ss.hasPermission('promotion:reward-activity:query')") - public CommonResult> getRewardActivityPage(@Valid RewardActivityPageReqVO pageVO) { - PageResult pageResult = rewardActivityService.getRewardActivityPage(pageVO); - return success(RewardActivityConvert.INSTANCE.convertPage(pageResult)); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/reward/vo/RewardActivityBaseVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/reward/vo/RewardActivityBaseVO.java deleted file mode 100755 index 6896e93c9..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/reward/vo/RewardActivityBaseVO.java +++ /dev/null @@ -1,98 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.reward.vo; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionConditionTypeEnum; -import com.fasterxml.jackson.annotation.JsonIgnore; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import org.springframework.format.annotation.DateTimeFormat; - -import javax.validation.Valid; -import javax.validation.constraints.AssertTrue; -import javax.validation.constraints.Future; -import javax.validation.constraints.Min; -import javax.validation.constraints.NotNull; -import java.time.LocalDateTime; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -/** -* 满减送活动 Base VO,提供给添加、修改、详细的子 VO 使用 -* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 -*/ -@Data -public class RewardActivityBaseVO { - - @Schema(description = "活动标题", required = true, example = "满啦满啦") - @NotNull(message = "活动标题不能为空") - private String name; - - @Schema(description = "开始时间", required = true) - @NotNull(message = "开始时间不能为空") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime startTime; - - @Schema(description = "结束时间", required = true) - @NotNull(message = "结束时间不能为空") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - @Future(message = "结束时间必须大于当前时间") - private LocalDateTime endTime; - - @Schema(description = "备注", example = "biubiubiu") - private String remark; - - @Schema(description = "条件类型", required = true, example = "1") - @NotNull(message = "条件类型不能为空") - @InEnum(value = PromotionConditionTypeEnum.class, message = "条件类型必须是 {value}") - private Integer conditionType; - - @Schema(description = "商品范围", required = true, example = "1") - @NotNull(message = "商品范围不能为空") - @InEnum(value = PromotionConditionTypeEnum.class, message = "商品范围必须是 {value}") - private Integer productScope; - - @Schema(description = "商品 SPU 编号的数组", example = "1,2,3") - private List productSpuIds; - - /** - * 优惠规则的数组 - */ - @Valid // 校验下子对象 - private List rules; - - @Schema(description = "优惠规则") - @Data - public static class Rule { - - @Schema(description = "优惠门槛,1. 满 N 元,单位:分; 2. 满 N 件", required = true, example = "100") - @Min(value = 1L, message = "优惠门槛必须大于等于 1") - private Integer limit; - - @Schema(description = "优惠价格,单位:分", required = true, example = "100") - @Min(value = 1L, message = "优惠价格必须大于等于 1") - private Integer discountPrice; - - @Schema(description = "是否包邮", required = true, example = "true") - private Boolean freeDelivery; - - @Schema(description = "赠送的积分", required = true, example = "100") - @Min(value = 1L, message = "赠送的积分必须大于等于 1") - private Integer point; - - @Schema(description = "赠送的优惠劵编号的数组", example = "1,2,3") - private List couponIds; - - @Schema(description = "赠送的优惠卷数量的数组", example = "1,2,3") - private List couponCounts; - - @AssertTrue(message = "优惠劵和数量必须一一对应") - @JsonIgnore - public boolean isCouponCountsValid() { - return CollUtil.size(couponCounts) == CollUtil.size(couponCounts); - } - - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/reward/vo/RewardActivityCreateReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/reward/vo/RewardActivityCreateReqVO.java deleted file mode 100755 index a5f35e030..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/reward/vo/RewardActivityCreateReqVO.java +++ /dev/null @@ -1,11 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.reward.vo; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; - -@Schema(description = "管理后台 - 满减送活动创建 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class RewardActivityCreateReqVO extends RewardActivityBaseVO { - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/reward/vo/RewardActivityPageReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/reward/vo/RewardActivityPageReqVO.java deleted file mode 100755 index dc99e79fa..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/reward/vo/RewardActivityPageReqVO.java +++ /dev/null @@ -1,18 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.reward.vo; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; -import cn.iocoder.yudao.framework.common.pojo.PageParam; - -@Schema(description = "管理后台 - 满减送活动分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class RewardActivityPageReqVO extends PageParam { - - @Schema(description = "活动标题", example = "满啦满啦") - private String name; - - @Schema(description = "活动状态", example = "1") - private Integer status; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/reward/vo/RewardActivityRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/reward/vo/RewardActivityRespVO.java deleted file mode 100755 index 8ad93cb59..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/reward/vo/RewardActivityRespVO.java +++ /dev/null @@ -1,25 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.reward.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 满减送活动 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class RewardActivityRespVO extends RewardActivityBaseVO { - - @Schema(description = "活动编号", required = true, example = "1024") - private Integer id; - - @Schema(description = "活动状态", required = true, example = "1") - private Integer status; - - @Schema(description = "创建时间", required = true) - private LocalDateTime createTime; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/reward/vo/RewardActivityUpdateReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/reward/vo/RewardActivityUpdateReqVO.java deleted file mode 100755 index 5c1106d1e..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/reward/vo/RewardActivityUpdateReqVO.java +++ /dev/null @@ -1,16 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.reward.vo; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; -import javax.validation.constraints.*; - -@Schema(description = "管理后台 - 满减送活动更新 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class RewardActivityUpdateReqVO extends RewardActivityBaseVO { - - @Schema(description = "活动编号", required = true, example = "1024") - @NotNull(message = "活动编号不能为空") - private Long id; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/SeckillActivityController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/SeckillActivityController.java deleted file mode 100644 index 5acaf7cf0..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/SeckillActivityController.java +++ /dev/null @@ -1,96 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.seckill; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity.*; -import cn.iocoder.yudao.module.promotion.convert.seckill.seckillactivity.SeckillActivityConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.seckillactivity.SeckillActivityDO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.seckillactivity.SeckillProductDO; -import cn.iocoder.yudao.module.promotion.service.seckill.seckillactivity.SeckillActivityService; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiImplicitParam; -import io.swagger.annotations.ApiOperation; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.validation.Valid; -import java.util.Collection; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Api(tags = "管理后台 - 秒杀活动") -@RestController -@RequestMapping("/promotion/seckill-activity") -@Validated -public class SeckillActivityController { - - @Resource - private SeckillActivityService seckillActivityService; - - @PostMapping("/create") - @ApiOperation("创建秒杀活动") - @PreAuthorize("@ss.hasPermission('promotion:seckill-activity:create')") - public CommonResult createSeckillActivity(@Valid @RequestBody SeckillActivityCreateReqVO createReqVO) { - return success(seckillActivityService.createSeckillActivity(createReqVO)); - } - - @PutMapping("/update") - @ApiOperation("更新秒杀活动") - @PreAuthorize("@ss.hasPermission('promotion:seckill-activity:update')") - public CommonResult updateSeckillActivity(@Valid @RequestBody SeckillActivityUpdateReqVO updateReqVO) { - seckillActivityService.updateSeckillActivity(updateReqVO); - return success(true); - } - - @PutMapping("/close") - @ApiOperation("关闭秒杀活动") - @ApiImplicitParam(name = "id", value = "编号", required = true, dataTypeClass = Long.class) - @PreAuthorize("@ss.hasPermission('promotion:seckill-activity:close')") - public CommonResult closeSeckillActivity(@RequestParam("id") Long id) { - seckillActivityService.closeSeckillActivity(id); - return success(true); - } - - @DeleteMapping("/delete") - @ApiOperation("删除秒杀活动") - @ApiImplicitParam(name = "id", value = "编号", required = true, dataTypeClass = Long.class) - @PreAuthorize("@ss.hasPermission('promotion:seckill-activity:delete')") - public CommonResult deleteSeckillActivity(@RequestParam("id") Long id) { - seckillActivityService.deleteSeckillActivity(id); - return success(true); - } - - @GetMapping("/get") - @ApiOperation("获得秒杀活动") - @ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class) - @PreAuthorize("@ss.hasPermission('promotion:seckill-activity:query')") - public CommonResult getSeckillActivity(@RequestParam("id") Long id) { - SeckillActivityDO seckillActivity = seckillActivityService.getSeckillActivity(id); - if (seckillActivity == null) { - return success(null); - } - List seckillProducts = seckillActivityService.getSeckillProductListByActivityId(id); - return success(SeckillActivityConvert.INSTANCE.convert(seckillActivity,seckillProducts)); - } - - @GetMapping("/list") - @ApiOperation("获得秒杀活动列表") - @ApiImplicitParam(name = "ids", value = "编号列表", required = true, example = "1024,2048", dataTypeClass = List.class) - @PreAuthorize("@ss.hasPermission('promotion:seckill-activity:query')") - public CommonResult> getSeckillActivityList(@RequestParam("ids") Collection ids) { - List list = seckillActivityService.getSeckillActivityList(ids); - return success(SeckillActivityConvert.INSTANCE.convertList(list)); - } - - @GetMapping("/page") - @ApiOperation("获得秒杀活动分页") - @PreAuthorize("@ss.hasPermission('promotion:seckill-activity:query')") - public CommonResult> getSeckillActivityPage(@Valid SeckillActivityPageReqVO pageVO) { - PageResult pageResult = seckillActivityService.getSeckillActivityPage(pageVO); - return success(SeckillActivityConvert.INSTANCE.convertPage(pageResult)); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/SeckillTimeController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/SeckillTimeController.java deleted file mode 100644 index 3cb6d4ca6..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/SeckillTimeController.java +++ /dev/null @@ -1,72 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.seckill; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.time.SeckillTimeCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.time.SeckillTimeRespVO; -import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.time.SeckillTimeUpdateReqVO; -import cn.iocoder.yudao.module.promotion.convert.seckill.seckilltime.SeckillTimeConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.seckilltime.SeckillTimeDO; -import cn.iocoder.yudao.module.promotion.service.seckill.seckilltime.SeckillTimeService; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiImplicitParam; -import io.swagger.annotations.ApiOperation; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.validation.Valid; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Api(tags = "管理后台 - 秒杀时段") -@RestController -@RequestMapping("/promotion/seckill-time") -@Validated -public class SeckillTimeController { - - @Resource - private SeckillTimeService seckillTimeService; - - @PostMapping("/create") - @ApiOperation("创建秒杀时段") - @PreAuthorize("@ss.hasPermission('promotion:seckill-time:create')") - public CommonResult createSeckillTime(@Valid @RequestBody SeckillTimeCreateReqVO createReqVO) { - return success(seckillTimeService.createSeckillTime(createReqVO)); - } - - @PutMapping("/update") - @ApiOperation("更新秒杀时段") - @PreAuthorize("@ss.hasPermission('promotion:seckill-time:update')") - public CommonResult updateSeckillTime(@Valid @RequestBody SeckillTimeUpdateReqVO updateReqVO) { - seckillTimeService.updateSeckillTime(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @ApiOperation("删除秒杀时段") - @ApiImplicitParam(name = "id", value = "编号", required = true, dataTypeClass = Long.class) - @PreAuthorize("@ss.hasPermission('promotion:seckill-time:delete')") - public CommonResult deleteSeckillTime(@RequestParam("id") Long id) { - seckillTimeService.deleteSeckillTime(id); - return success(true); - } - - @GetMapping("/get") - @ApiOperation("获得秒杀时段") - @ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class) - @PreAuthorize("@ss.hasPermission('promotion:seckill-time:query')") - public CommonResult getSeckillTime(@RequestParam("id") Long id) { - SeckillTimeDO seckillTime = seckillTimeService.getSeckillTime(id); - return success(SeckillTimeConvert.INSTANCE.convert(seckillTime)); - } - - @GetMapping("/list") - @ApiOperation("获得所有秒杀时段列表") - @PreAuthorize("@ss.hasPermission('promotion:seckill-time:query')") - public CommonResult> getSeckillTimeList() { - List list = seckillTimeService.getSeckillTimeList(); - return success(SeckillTimeConvert.INSTANCE.convertList(list)); - } -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/activity/SeckillActivityBaseVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/activity/SeckillActivityBaseVO.java deleted file mode 100644 index 877e7553a..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/activity/SeckillActivityBaseVO.java +++ /dev/null @@ -1,66 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity; - -import com.fasterxml.jackson.annotation.JsonFormat; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; -import org.springframework.format.annotation.DateTimeFormat; - -import javax.validation.constraints.Min; -import javax.validation.constraints.NotNull; -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.TIME_ZONE_DEFAULT; - -/** - * 秒杀活动 Base VO,提供给添加、修改、详细的子 VO 使用 - * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 - */ -@Data -public class SeckillActivityBaseVO { - - @ApiModelProperty(value = "秒杀活动名称", required = true, example = "晚九点限时秒杀") - @NotNull(message = "秒杀活动名称不能为空") - private String name; - - @ApiModelProperty(value = "活动开始时间", required = true) - @NotNull(message = "活动开始时间不能为空") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - @JsonFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND, timezone = TIME_ZONE_DEFAULT) - private LocalDateTime startTime; - - @ApiModelProperty(value = "活动结束时间", required = true) - @NotNull(message = "活动结束时间不能为空") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - @JsonFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND, timezone = TIME_ZONE_DEFAULT) - private LocalDateTime endTime; - - - @ApiModel("商品") - @Data - public static class Product { - - @ApiModelProperty(value = "商品 SPU 编号", required = true, example = "1") - @NotNull(message = "商品 SPU 编号不能为空") - private Long spuId; - - @ApiModelProperty(value = "商品 SKU 编号", required = true, example = "1") - @NotNull(message = "商品 SKU 编号不能为空") - private Long skuId; - - @ApiModelProperty(value = "秒杀金额", required = true, example = "12.00") - @NotNull(message = "秒杀金额不能为空") - private Integer seckillPrice; - - @ApiModelProperty(value = "秒杀库存", example = "80") - @Min(value = 0, message = "秒杀库存需要大于等于 0") - private Integer stock; - - @ApiModelProperty(value = "每人限购", example = "10", notes = "如果为0则不限购") - @Min(value = 0, message = "每人限购需要大于等于 0") - private Integer limitBuyCount; - - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/activity/SeckillActivityCreateReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/activity/SeckillActivityCreateReqVO.java deleted file mode 100644 index 58dbd0dd9..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/activity/SeckillActivityCreateReqVO.java +++ /dev/null @@ -1,38 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import javax.validation.Valid; -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; -import java.util.List; - -@ApiModel("管理后台 - 秒杀活动创建 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class SeckillActivityCreateReqVO extends SeckillActivityBaseVO { - - @ApiModelProperty(value = "备注", example = "限时秒杀活动") - private String remark; - - @ApiModelProperty(value = "排序", required = true, example = "1") - @NotNull(message = "排序不能为空") - private Integer sort; - - @ApiModelProperty(value = "秒杀时段id", required = true, example = "1,3") - @NotEmpty(message = "参与场次不能为空") - private List timeIds; - - /** - * 商品列表 - */ - @NotEmpty(message = "商品列表不能为空") - @Valid - private List products; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/activity/SeckillActivityDetailRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/activity/SeckillActivityDetailRespVO.java deleted file mode 100644 index a8a079abf..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/activity/SeckillActivityDetailRespVO.java +++ /dev/null @@ -1,21 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity; - -import io.swagger.annotations.ApiModel; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.util.List; - -@ApiModel("管理后台 - 秒杀活动的详细 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class SeckillActivityDetailRespVO extends SeckillActivityRespVO { - - /** - * 商品列表 - */ - private List products; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/activity/SeckillActivityPageReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/activity/SeckillActivityPageReqVO.java deleted file mode 100644 index 34808d523..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/activity/SeckillActivityPageReqVO.java +++ /dev/null @@ -1,37 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import com.fasterxml.jackson.annotation.JsonFormat; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.TIME_ZONE_DEFAULT; - -@ApiModel("管理后台 - 秒杀活动分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class SeckillActivityPageReqVO extends PageParam { - - @ApiModelProperty(value = "秒杀活动名称", example = "晚九点限时秒杀") - private String name; - - @ApiModelProperty(value = "活动状态", example = "进行中") - private Integer status; - - @ApiModelProperty(value = "秒杀时段id", example = "1") - private Long timeId; - - @ApiModelProperty(value = "创建时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - @JsonFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND, timezone = TIME_ZONE_DEFAULT) - private LocalDateTime[] createTime; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/activity/SeckillActivityRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/activity/SeckillActivityRespVO.java deleted file mode 100644 index 50055f8b0..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/activity/SeckillActivityRespVO.java +++ /dev/null @@ -1,42 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.time.LocalDateTime; -import java.util.List; - -@ApiModel("管理后台 - 秒杀活动 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class SeckillActivityRespVO extends SeckillActivityBaseVO { - - @ApiModelProperty(value = "秒杀活动id", required = true, example = "1") - private Long id; - - @ApiModelProperty(value = "付款订单数", required = true, example = "1") - private Integer orderCount; - - @ApiModelProperty(value = "付款人数", required = true, example = "1") - private Integer userCount; - - @ApiModelProperty(value = "创建时间", required = true) - private LocalDateTime createTime; - - @ApiModelProperty(value = "秒杀时段id", required = true, example = "1,3") - private List timeIds; - - @ApiModelProperty(value = "排序", required = true, example = "1") - private Integer sort; - - @ApiModelProperty(value = "备注", example = "限时秒杀活动") - private String remark; - - @ApiModelProperty(value = "活动状态", example = "进行中") - private Integer status; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/activity/SeckillActivityUpdateReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/activity/SeckillActivityUpdateReqVO.java deleted file mode 100644 index e55739a4b..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/activity/SeckillActivityUpdateReqVO.java +++ /dev/null @@ -1,42 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import javax.validation.Valid; -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; -import java.util.List; - -@ApiModel("管理后台 - 秒杀活动更新 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class SeckillActivityUpdateReqVO extends SeckillActivityBaseVO { - - @ApiModelProperty(value = "秒杀活动编号", required = true, example = "224") - @NotNull(message = "秒杀活动编号不能为空") - private Long id; - - @ApiModelProperty(value = "备注", example = "限时秒杀活动") - private String remark; - - @ApiModelProperty(value = "排序", required = true, example = "1") - @NotNull(message = "排序不能为空") - private Integer sort; - - @ApiModelProperty(value = "秒杀时段id", required = true, example = "1,3") - @NotEmpty(message = "秒杀时段id不能为空") - private List timeIds; - - /** - * 商品列表 - */ - @NotEmpty(message = "商品列表不能为空") - @Valid - private List products; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/time/SeckillTimeBaseVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/time/SeckillTimeBaseVO.java deleted file mode 100644 index 4fc8c8f3c..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/time/SeckillTimeBaseVO.java +++ /dev/null @@ -1,28 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.time; - -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; - -import javax.validation.constraints.NotNull; -import java.time.LocalTime; - -/** - * 秒杀时段 Base VO,提供给添加、修改、详细的子 VO 使用 - * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 - */ -@Data -public class SeckillTimeBaseVO { - - @ApiModelProperty(value = "秒杀时段名称", required = true, example = "上午场") - @NotNull(message = "秒杀时段名称不能为空") - private String name; - - @ApiModelProperty(value = "开始时间点", required = true, example = "16:30:40") - @NotNull(message = "开始时间点不能为空") - private LocalTime startTime; - - @ApiModelProperty(value = "结束时间点", required = true, example = "16:30:40") - @NotNull(message = "结束时间点不能为空") - private LocalTime endTime; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/time/SeckillTimeCreateReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/time/SeckillTimeCreateReqVO.java deleted file mode 100644 index 197fb8a68..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/time/SeckillTimeCreateReqVO.java +++ /dev/null @@ -1,12 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.time; - -import lombok.*; -import io.swagger.annotations.*; - -@ApiModel("管理后台 - 秒杀时段创建 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class SeckillTimeCreateReqVO extends SeckillTimeBaseVO { - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/time/SeckillTimePageReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/time/SeckillTimePageReqVO.java deleted file mode 100644 index b482ca34e..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/time/SeckillTimePageReqVO.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.time; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalTime; - -@ApiModel("管理后台 - 秒杀时段分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class SeckillTimePageReqVO extends PageParam { - - @ApiModelProperty(value = "秒杀时段名称", example = "上午场") - private String name; - - @ApiModelProperty(value = "开始时间点", example = "16:30:40") - @DateTimeFormat(pattern = "HH:mm:ss") - private LocalTime startTime; - - @ApiModelProperty(value = "结束时间点", example = "16:30:40") - @DateTimeFormat(pattern = "HH:mm:ss") - private LocalTime endTime; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/time/SeckillTimeRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/time/SeckillTimeRespVO.java deleted file mode 100644 index 632020191..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/time/SeckillTimeRespVO.java +++ /dev/null @@ -1,26 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.time; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.time.LocalDateTime; - -@ApiModel("管理后台 - 秒杀时段 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class SeckillTimeRespVO extends SeckillTimeBaseVO { - - @ApiModelProperty(value = "编号", required = true, example = "1") - private Long id; - - @ApiModelProperty(value = "秒杀活动数量", required = true, example = "1") - private Integer seckillActivityCount; - - @ApiModelProperty(value = "创建时间", required = true) - private LocalDateTime createTime; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/time/SeckillTimeUpdateReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/time/SeckillTimeUpdateReqVO.java deleted file mode 100644 index 72931938d..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/time/SeckillTimeUpdateReqVO.java +++ /dev/null @@ -1,21 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.time; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import javax.validation.constraints.NotNull; - -@ApiModel("管理后台 - 秒杀时段更新 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class SeckillTimeUpdateReqVO extends SeckillTimeBaseVO { - - @ApiModelProperty(value = "编号", required = true, example = "1") - @NotNull(message = "编号不能为空") - private Long id; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/AppMarketTestController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/AppMarketTestController.java deleted file mode 100644 index 510889f9c..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/AppMarketTestController.java +++ /dev/null @@ -1,24 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.app; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import io.swagger.v3.oas.annotations.tags.Tag; -import io.swagger.v3.oas.annotations.Operation; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "用户 App - 营销") -@RestController -@RequestMapping("/market/test") -@Validated -public class AppMarketTestController { - - @GetMapping("/get") - @Operation(summary = "获取 market 信息") - public CommonResult get() { - return success("true"); - } -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/banner/AppBannerController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/banner/AppBannerController.java deleted file mode 100644 index 1a7f148ff..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/banner/AppBannerController.java +++ /dev/null @@ -1,42 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.app.banner; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.promotion.controller.admin.banner.vo.BannerRespVO; -import cn.iocoder.yudao.module.promotion.convert.banner.BannerConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.banner.BannerDO; -import cn.iocoder.yudao.module.promotion.service.banner.BannerService; -import io.swagger.v3.oas.annotations.tags.Tag; -import io.swagger.v3.oas.annotations.Operation; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -/** - * @author: XIA - */ -@RestController -@RequestMapping("/market/banner") -@Tag(name = "用户APP- 首页Banner") -@Validated -public class AppBannerController { - - @Resource - private BannerService bannerService; - - // TODO @xia:新建一个 AppBannerRespVO,只返回必要的字段。status 要过滤下。然后 sort 下结果 - @GetMapping("/list") - @Operation(summary = "获得banner列表") - @PreAuthorize("@ss.hasPermission('market:banner:query')") - public CommonResult> getBannerList() { - List list = bannerService.getBannerList(); - return success(BannerConvert.INSTANCE.convertList(list)); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/banner/BannerConvert.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/banner/BannerConvert.java deleted file mode 100644 index 87d2da187..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/banner/BannerConvert.java +++ /dev/null @@ -1,34 +0,0 @@ -package cn.iocoder.yudao.module.promotion.convert.banner; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.controller.admin.banner.vo.BannerCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.banner.vo.BannerRespVO; -import cn.iocoder.yudao.module.promotion.controller.admin.banner.vo.BannerUpdateReqVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.banner.BannerDO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -import java.util.List; - -/** - * Banner Convert - * - * @author xia - */ -@Mapper -public interface BannerConvert { - - BannerConvert INSTANCE = Mappers.getMapper(BannerConvert.class); - - - List convertList(List list); - - PageResult convertPage(PageResult pageResult); - - BannerRespVO convert(BannerDO banner); - - BannerDO convert(BannerCreateReqVO createReqVO); - - BannerDO convert(BannerUpdateReqVO updateReqVO); - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/coupon/CouponConvert.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/coupon/CouponConvert.java deleted file mode 100755 index 281318f7d..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/coupon/CouponConvert.java +++ /dev/null @@ -1,21 +0,0 @@ -package cn.iocoder.yudao.module.promotion.convert.coupon; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.coupon.CouponPageItemRespVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.coupon.CouponDO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -/** - * 优惠劵 Convert - * - * @author 芋道源码 - */ -@Mapper -public interface CouponConvert { - - CouponConvert INSTANCE = Mappers.getMapper(CouponConvert.class); - - PageResult convertPage(PageResult page); - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/coupon/CouponTemplateConvert.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/coupon/CouponTemplateConvert.java deleted file mode 100755 index 22d78f46f..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/coupon/CouponTemplateConvert.java +++ /dev/null @@ -1,29 +0,0 @@ -package cn.iocoder.yudao.module.promotion.convert.coupon; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.template.CouponTemplateCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.template.CouponTemplateRespVO; -import cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.template.CouponTemplateUpdateReqVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.coupon.CouponTemplateDO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -/** - * 优惠劵模板 Convert - * - * @author 芋道源码 - */ -@Mapper -public interface CouponTemplateConvert { - - CouponTemplateConvert INSTANCE = Mappers.getMapper(CouponTemplateConvert.class); - - CouponTemplateDO convert(CouponTemplateCreateReqVO bean); - - CouponTemplateDO convert(CouponTemplateUpdateReqVO bean); - - CouponTemplateRespVO convert(CouponTemplateDO bean); - - PageResult convertPage(PageResult page); - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/discount/DiscountActivityConvert.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/discount/DiscountActivityConvert.java deleted file mode 100755 index 07d2e03ab..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/discount/DiscountActivityConvert.java +++ /dev/null @@ -1,102 +0,0 @@ -package cn.iocoder.yudao.module.promotion.convert.discount; - -import cn.hutool.core.util.ObjectUtil; -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.MapUtils; -import cn.iocoder.yudao.module.promotion.controller.admin.discount.vo.*; -import cn.iocoder.yudao.module.promotion.dal.dataobject.discount.DiscountActivityDO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.discount.DiscountProductDO; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionDiscountTypeEnum; -import cn.iocoder.yudao.module.promotion.service.discount.bo.DiscountProductDetailBO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -import java.util.List; -import java.util.Map; - -/** - * 限时折扣活动 Convert - * - * @author 芋道源码 - */ -@Mapper -public interface DiscountActivityConvert { - - DiscountActivityConvert INSTANCE = Mappers.getMapper(DiscountActivityConvert.class); - - DiscountActivityDO convert(DiscountActivityCreateReqVO bean); - - DiscountActivityDO convert(DiscountActivityUpdateReqVO bean); - - DiscountActivityRespVO convert(DiscountActivityDO bean); - - List convertList(List list); - - PageResult convertPage(PageResult page); - - DiscountProductDetailBO convert(DiscountProductDO product); - - default List convertList(List products, Map activityMap) { - return CollectionUtils.convertList(products, product -> { - DiscountProductDetailBO detail = convert(product); - MapUtils.findAndThen(activityMap, product.getActivityId(), activity -> { - detail.setActivityName(activity.getName()); - }); - return detail; - }); - } - - DiscountProductDO convert(DiscountActivityBaseVO.Product bean); - - DiscountActivityDetailRespVO convert(DiscountActivityDO activity, List products); - - // =========== 比较是否相等 ========== - /** - * 比较两个限时折扣商品是否相等 - * - * @param productDO 数据库中的商品 - * @param productVO 前端传入的商品 - * @return 是否匹配 - */ - @SuppressWarnings("DuplicatedCode") - default boolean isEquals(DiscountProductDO productDO, DiscountActivityBaseVO.Product productVO) { - if (ObjectUtil.notEqual(productDO.getSpuId(), productVO.getSpuId()) - || ObjectUtil.notEqual(productDO.getSkuId(), productVO.getSkuId()) - || ObjectUtil.notEqual(productDO.getDiscountType(), productVO.getDiscountType())) { - return false; - } - if (productDO.getDiscountType().equals(PromotionDiscountTypeEnum.PRICE.getType())) { - return ObjectUtil.equal(productDO.getDiscountPrice(), productVO.getDiscountPrice()); - } - if (productDO.getDiscountType().equals(PromotionDiscountTypeEnum.PERCENT.getType())) { - return ObjectUtil.equal(productDO.getDiscountPercent(), productVO.getDiscountPercent()); - } - return true; - } - - /** - * 比较两个限时折扣商品是否相等 - * 注意,比较时忽略 id 编号 - * - * @param productDO 商品 1 - * @param productVO 商品 2 - * @return 是否匹配 - */ - @SuppressWarnings("DuplicatedCode") - default boolean isEquals(DiscountProductDO productDO, DiscountProductDO productVO) { - if (ObjectUtil.notEqual(productDO.getSpuId(), productVO.getSpuId()) - || ObjectUtil.notEqual(productDO.getSkuId(), productVO.getSkuId()) - || ObjectUtil.notEqual(productDO.getDiscountType(), productVO.getDiscountType())) { - return false; - } - if (productDO.getDiscountType().equals(PromotionDiscountTypeEnum.PRICE.getType())) { - return ObjectUtil.equal(productDO.getDiscountPrice(), productVO.getDiscountPrice()); - } - if (productDO.getDiscountType().equals(PromotionDiscountTypeEnum.PERCENT.getType())) { - return ObjectUtil.equal(productDO.getDiscountPercent(), productVO.getDiscountPercent()); - } - return true; - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/price/PriceConvert.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/price/PriceConvert.java deleted file mode 100644 index 8e4b24666..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/price/PriceConvert.java +++ /dev/null @@ -1,49 +0,0 @@ -package cn.iocoder.yudao.module.promotion.convert.price; - -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.module.promotion.api.price.dto.CouponMeetRespDTO; -import cn.iocoder.yudao.module.promotion.api.price.dto.PriceCalculateReqDTO; -import cn.iocoder.yudao.module.promotion.api.price.dto.PriceCalculateRespDTO; -import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuRespDTO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.coupon.CouponDO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -@Mapper -public interface PriceConvert { - - PriceConvert INSTANCE = Mappers.getMapper(PriceConvert.class); - - default PriceCalculateRespDTO convert(PriceCalculateReqDTO calculateReqDTO, List skuList) { - // 创建 PriceCalculateRespDTO 对象 - PriceCalculateRespDTO priceCalculate = new PriceCalculateRespDTO(); - // 创建它的 Order 属性 - PriceCalculateRespDTO.Order order = new PriceCalculateRespDTO.Order().setOriginalPrice(0).setDiscountPrice(0) - .setCouponPrice(0).setPointPrice(0).setDeliveryPrice(0).setPayPrice(0) - .setItems(new ArrayList<>()).setCouponId(calculateReqDTO.getCouponId()); - priceCalculate.setOrder(order).setPromotions(new ArrayList<>()); - // 创建它的 OrderItem 属性 - Map skuIdCountMap = CollectionUtils.convertMap(calculateReqDTO.getItems(), - PriceCalculateReqDTO.Item::getSkuId, PriceCalculateReqDTO.Item::getCount); - skuList.forEach(sku -> { - Integer count = skuIdCountMap.get(sku.getId()); - PriceCalculateRespDTO.OrderItem orderItem = new PriceCalculateRespDTO.OrderItem() - .setSpuId(sku.getSpuId()).setSkuId(sku.getId()).setCount(count) - .setOriginalUnitPrice(sku.getPrice()).setOriginalPrice(sku.getPrice() * count) - .setDiscountPrice(0).setOrderPartPrice(0); - orderItem.setPayPrice(orderItem.getOriginalPrice()).setOrderDividePrice(orderItem.getOriginalPrice()); - priceCalculate.getOrder().getItems().add(orderItem); - // 补充价格信息到 Order 中 - order.setOriginalPrice(order.getOriginalPrice() + orderItem.getOriginalPrice()) - .setOrderPrice(order.getOriginalPrice()).setPayPrice(order.getOriginalPrice()); - }); - return priceCalculate; - } - - CouponMeetRespDTO convert(CouponDO coupon); - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/reward/RewardActivityConvert.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/reward/RewardActivityConvert.java deleted file mode 100755 index 5343656ed..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/reward/RewardActivityConvert.java +++ /dev/null @@ -1,29 +0,0 @@ -package cn.iocoder.yudao.module.promotion.convert.reward; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.controller.admin.reward.vo.RewardActivityCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.reward.vo.RewardActivityRespVO; -import cn.iocoder.yudao.module.promotion.controller.admin.reward.vo.RewardActivityUpdateReqVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.reward.RewardActivityDO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -/** - * 满减送活动 Convert - * - * @author 芋道源码 - */ -@Mapper -public interface RewardActivityConvert { - - RewardActivityConvert INSTANCE = Mappers.getMapper(RewardActivityConvert.class); - - RewardActivityDO convert(RewardActivityCreateReqVO bean); - - RewardActivityDO convert(RewardActivityUpdateReqVO bean); - - RewardActivityRespVO convert(RewardActivityDO bean); - - PageResult convertPage(PageResult page); - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/seckill/seckillactivity/SeckillActivityConvert.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/seckill/seckillactivity/SeckillActivityConvert.java deleted file mode 100644 index 1a00fdeb6..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/seckill/seckillactivity/SeckillActivityConvert.java +++ /dev/null @@ -1,83 +0,0 @@ -package cn.iocoder.yudao.module.promotion.convert.seckill.seckillactivity; - -import cn.hutool.core.util.ObjectUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity.*; -import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.seckillactivity.SeckillActivityDO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.seckillactivity.SeckillProductDO; -import org.mapstruct.Mapper; -import org.mapstruct.Mapping; -import org.mapstruct.Mappings; -import org.mapstruct.factory.Mappers; - -import java.util.List; - -/** - * 秒杀活动 Convert - * - * @author 芋道源码 - */ -@Mapper -public interface SeckillActivityConvert { - - SeckillActivityConvert INSTANCE = Mappers.getMapper(SeckillActivityConvert.class); - - SeckillProductDO convert(SeckillActivityBaseVO.Product product); - - - SeckillActivityDO convert(SeckillActivityCreateReqVO bean); - - default String map(Long[] value) { - return value.toString(); - } - - SeckillActivityDO convert(SeckillActivityUpdateReqVO bean); - - SeckillActivityRespVO convert(SeckillActivityDO bean); - - List convertList(List list); - - PageResult convertPage(PageResult page); - - @Mappings({@Mapping(target = "products", source = "seckillProducts")}) - SeckillActivityDetailRespVO convert(SeckillActivityDO seckillActivity, List seckillProducts); - - - /** - * 比较两个秒杀商品对象是否相等 - * - * @param productDO 数据库中的商品 - * @param productVO 前端传入的商品 - * @return 是否匹配 - */ - default boolean isEquals(SeckillProductDO productDO, SeckillActivityBaseVO.Product productVO) { - return ObjectUtil.equals(productDO.getSpuId(), productVO.getSpuId()) - && ObjectUtil.equals(productDO.getSkuId(), productVO.getSkuId()) - && ObjectUtil.equals(productDO.getSeckillPrice(), productVO.getSeckillPrice()) - && ObjectUtil.equals(productDO.getStock(), productVO.getStock()) - && ObjectUtil.equals(productDO.getLimitBuyCount(), productVO.getLimitBuyCount()); - } - - /** - * 比较两个秒杀商品对象是否相等 - * - * @param productDO 商品1 - * @param productVO 商品2 - * @return 是否匹配 - */ - default boolean isEquals(SeckillProductDO productDO, SeckillProductDO productVO) { - return ObjectUtil.equals(productDO.getSpuId(), productVO.getSpuId()) - && ObjectUtil.equals(productDO.getSkuId(), productVO.getSkuId()) - && ObjectUtil.equals(productDO.getSeckillPrice(), productVO.getSeckillPrice()) - && ObjectUtil.equals(productDO.getStock(), productVO.getStock()) - && ObjectUtil.equals(productDO.getLimitBuyCount(), productVO.getLimitBuyCount()); - - } - - default List convertList(List products, SeckillActivityDO seckillActivity) { - return CollectionUtils.convertList(products, product -> convert(product) - .setActivityId(seckillActivity.getId()).setTimeIds(seckillActivity.getTimeIds())); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/seckill/seckilltime/SeckillTimeConvert.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/seckill/seckilltime/SeckillTimeConvert.java deleted file mode 100644 index 4cea7a91c..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/seckill/seckilltime/SeckillTimeConvert.java +++ /dev/null @@ -1,34 +0,0 @@ -package cn.iocoder.yudao.module.promotion.convert.seckill.seckilltime; - -import java.util.*; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; - -import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.time.SeckillTimeCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.time.SeckillTimeRespVO; -import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.time.SeckillTimeUpdateReqVO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; -import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.seckilltime.SeckillTimeDO; - -/** - * 秒杀时段 Convert - * - * @author 芋道源码 - */ -@Mapper -public interface SeckillTimeConvert { - - SeckillTimeConvert INSTANCE = Mappers.getMapper(SeckillTimeConvert.class); - - SeckillTimeDO convert(SeckillTimeCreateReqVO bean); - - SeckillTimeDO convert(SeckillTimeUpdateReqVO bean); - - SeckillTimeRespVO convert(SeckillTimeDO bean); - - List convertList(List list); - - PageResult convertPage(PageResult page); - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/banner/BannerDO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/banner/BannerDO.java deleted file mode 100644 index 585462b95..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/banner/BannerDO.java +++ /dev/null @@ -1,53 +0,0 @@ -package cn.iocoder.yudao.module.promotion.dal.dataobject.banner; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -/** - * banner DO - * - * @author xia - */ -@TableName("market_banner") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class BannerDO extends BaseDO { - - /** - * 编号 - */ - private Long id; - /** - * 标题 - */ - private String title; - /** - * 跳转链接 - */ - private String url; - /** - * 图片链接 - */ - private String picUrl; - /** - * 排序 - */ - private Integer sort; - - /** - * 状态 {@link cn.iocoder.yudao.framework.common.enums.CommonStatusEnum} - */ - private Integer status; - /** - * 备注 - */ - private String memo; - - // TODO 芋艿 点击次数。&& 其他数据相关 - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/coupon/CouponDO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/coupon/CouponDO.java deleted file mode 100644 index 7971392d4..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/coupon/CouponDO.java +++ /dev/null @@ -1,139 +0,0 @@ -package cn.iocoder.yudao.module.promotion.dal.dataobject.coupon; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.framework.mybatis.core.type.LongListTypeHandler; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionDiscountTypeEnum; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionProductScopeEnum; -import cn.iocoder.yudao.module.promotion.enums.coupon.CouponStatusEnum; -import cn.iocoder.yudao.module.promotion.enums.coupon.CouponTakeTypeEnum; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.Data; -import lombok.EqualsAndHashCode; - -import java.time.LocalDateTime; -import java.util.List; - -/** - * 优惠劵 DO - * - * @author 芋道源码 - */ -@TableName(value = "promotion_coupon", autoResultMap = true) -@KeySequence("promotion_coupon_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -public class CouponDO extends BaseDO { - - // ========== 基本信息 BEGIN ========== - /** - * 优惠劵编号 - */ - private Long id; - /** - * 优惠劵模板编号 - * - * 关联 {@link CouponTemplateDO#getId()} - */ - private Integer templateId; - /** - * 优惠劵名 - * - * 冗余 {@link CouponTemplateDO#getName()} - */ - private String name; - /** - * 优惠码状态 - * - * 枚举 {@link CouponStatusEnum} - */ - private Integer status; - - // ========== 基本信息 END ========== - - // ========== 领取情况 BEGIN ========== - /** - * 用户编号 - * - * 关联 MemberUserDO 的 id 字段 - */ - private Long userId; - /** - * 领取类型 - * - * 枚举 {@link CouponTakeTypeEnum} - */ - private Integer takeType; - // ========== 领取情况 END ========== - - // ========== 使用规则 BEGIN ========== - /** - * 是否设置满多少金额可用,单位:分 - * - * 冗余 {@link CouponTemplateDO#getUsePrice()} - */ - private Integer usePrice; - /** - * 生效开始时间 - */ - private LocalDateTime validStartTime; - /** - * 生效结束时间 - */ - private LocalDateTime validEndTime; - /** - * 商品范围 - * - * 枚举 {@link PromotionProductScopeEnum} - */ - private Integer productScope; - /** - * 商品 SPU 编号的数组 - * - * 冗余 {@link CouponTemplateDO#getProductSpuIds()} - */ - @TableField(typeHandler = LongListTypeHandler.class) - private List productSpuIds; - // ========== 使用规则 END ========== - - // ========== 使用效果 BEGIN ========== - /** - * 折扣类型 - * - * 冗余 {@link CouponTemplateDO#getDiscountType()} - */ - private Integer discountType; - /** - * 折扣百分比 - * - * 冗余 {@link CouponTemplateDO#getDiscountPercent()} - */ - private Integer discountPercent; - /** - * 优惠金额,单位:分 - * - * 冗余 {@link CouponTemplateDO#getDiscountPrice()} - */ - private Integer discountPrice; - /** - * 折扣上限,仅在 {@link #discountType} 等于 {@link PromotionDiscountTypeEnum#PERCENT} 时生效 - * - * 冗余 {@link CouponTemplateDO#getDiscountLimitPrice()} - */ - private Integer discountLimitPrice; - // ========== 使用效果 END ========== - - // ========== 使用情况 BEGIN ========== - /** - * 使用订单号 - */ - private Long useOrderId; - /** - * 使用时间 - */ - private LocalDateTime useTime; - - // ========== 使用情况 END ========== - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/coupon/CouponTemplateDO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/coupon/CouponTemplateDO.java deleted file mode 100644 index 93f9ace35..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/coupon/CouponTemplateDO.java +++ /dev/null @@ -1,162 +0,0 @@ -package cn.iocoder.yudao.module.promotion.dal.dataobject.coupon; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.framework.mybatis.core.type.LongListTypeHandler; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionDiscountTypeEnum; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionProductScopeEnum; -import cn.iocoder.yudao.module.promotion.enums.coupon.CouponTakeTypeEnum; -import cn.iocoder.yudao.module.promotion.enums.coupon.CouponTemplateValidityTypeEnum; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.Data; -import lombok.EqualsAndHashCode; - -import java.time.LocalDateTime; -import java.util.List; - -/** - * 优惠劵模板 DO - * - * 当用户领取时,会生成 {@link CouponDO} 优惠劵 - * - * @author 芋道源码 - */ -@TableName(value = "promotion_coupon_template", autoResultMap = true) -@KeySequence("promotion_coupon_template_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -public class CouponTemplateDO extends BaseDO { - - // ========== 基本信息 BEGIN ========== - /** - * 模板编号,自增唯一 - */ - @TableId - private Long id; - /** - * 优惠劵名 - */ - private String name; - /** - * 状态 - * - * 枚举 {@link CommonStatusEnum} - */ - private Integer status; - - // ========== 基本信息 END ========== - - // ========== 领取规则 BEGIN ========== - /** - * 发放数量 - * - * -1 - 则表示不限制发放数量 - */ - private Integer totalCount; - /** - * 每人限领个数 - * - * -1 - 则表示不限制 - */ - private Integer takeLimitCount; - /** - * 领取方式 - * - * 枚举 {@link CouponTakeTypeEnum} - */ - private Integer takeType; - // ========== 领取规则 END ========== - - // ========== 使用规则 BEGIN ========== - /** - * 是否设置满多少金额可用,单位:分 - * - * 0 - 不限制 - * 大于 0 - 多少金额可用 - */ - private Integer usePrice; - /** - * 商品范围 - * - * 枚举 {@link PromotionProductScopeEnum} - */ - private Integer productScope; - /** - * 商品 SPU 编号的数组 - */ - @TableField(typeHandler = LongListTypeHandler.class) - private List productSpuIds; - /** - * 生效日期类型 - * - * 枚举 {@link CouponTemplateValidityTypeEnum} - */ - private Integer validityType; - /** - * 固定日期 - 生效开始时间 - * - * 当 {@link #validityType} 为 {@link CouponTemplateValidityTypeEnum#DATE} - */ - private LocalDateTime validStartTime; - /** - * 固定日期 - 生效结束时间 - * - * 当 {@link #validityType} 为 {@link CouponTemplateValidityTypeEnum#DATE} - */ - private LocalDateTime validEndTime; - /** - * 领取日期 - 开始天数 - * - * 当 {@link #validityType} 为 {@link CouponTemplateValidityTypeEnum#TERM} - */ - private Integer fixedStartTerm; - /** - * 领取日期 - 结束天数 - * - * 当 {@link #validityType} 为 {@link CouponTemplateValidityTypeEnum#TERM} - */ - private Integer fixedEndTerm; - // ========== 使用规则 END ========== - - // ========== 使用效果 BEGIN ========== - /** - * 折扣类型 - * - * 枚举 {@link PromotionDiscountTypeEnum} - */ - private Integer discountType; - /** - * 折扣百分比 - * - * 例如,80% 为 80 - */ - private Integer discountPercent; - /** - * 优惠金额,单位:分 - * - * 当 {@link #discountType} 为 {@link PromotionDiscountTypeEnum#PRICE} 生效 - */ - private Integer discountPrice; - /** - * 折扣上限,仅在 {@link #discountType} 等于 {@link PromotionDiscountTypeEnum#PERCENT} 时生效 - * - * 例如,折扣上限为 20 元,当使用 8 折优惠券,订单金额为 1000 元时,最高只可折扣 20 元,而非 80 元。 - */ - private Integer discountLimitPrice; - // ========== 使用效果 END ========== - - // ========== 统计信息 BEGIN ========== - /** - * 领取优惠券的数量 - */ - private Integer takeCount; - /** - * 使用优惠券的次数 - */ - private Integer useCount; - // ========== 统计信息 END ========== - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/discount/DiscountActivityDO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/discount/DiscountActivityDO.java deleted file mode 100644 index 91071f309..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/discount/DiscountActivityDO.java +++ /dev/null @@ -1,55 +0,0 @@ -package cn.iocoder.yudao.module.promotion.dal.dataobject.discount; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionActivityStatusEnum; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.Data; -import lombok.EqualsAndHashCode; - -import java.time.LocalDateTime; - -/** - * 限时折扣活动 DO - * - * 一个活动下,可以有 {@link DiscountProductDO} 商品; - * 一个商品,在指定时间段内,只能属于一个活动; - * - * @author 芋道源码 - */ -@TableName(value = "promotion_discount_activity", autoResultMap = true) -@KeySequence("promotion_discount_activity_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -public class DiscountActivityDO extends BaseDO { - - /** - * 活动编号,主键自增 - */ - @TableId - private Long id; - /** - * 活动标题 - */ - private String name; - /** - * 状态 - * - * 枚举 {@link PromotionActivityStatusEnum} - */ - private Integer status; - /** - * 开始时间 - */ - private LocalDateTime startTime; - /** - * 结束时间 - */ - private LocalDateTime endTime; - /** - * 备注 - */ - private String remark; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/discount/DiscountProductDO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/discount/DiscountProductDO.java deleted file mode 100644 index 55c924e4f..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/discount/DiscountProductDO.java +++ /dev/null @@ -1,65 +0,0 @@ -package cn.iocoder.yudao.module.promotion.dal.dataobject.discount; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionDiscountTypeEnum; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.Data; -import lombok.EqualsAndHashCode; - -/** - * 限时折扣商品 DO - * - * @author 芋道源码 - */ -@TableName(value = "promotion_discount_product", autoResultMap = true) -@KeySequence("promotion_discount_product_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -public class DiscountProductDO extends BaseDO { - - /** - * 编号,主键自增 - */ - @TableId - private Long id; - /** - * 限时折扣活动的编号 - * - * 关联 {@link DiscountActivityDO#getId()} - */ - private Long activityId; - /** - * 商品 SPU 编号 - * - * 关联 ProductSpuDO 的 id 编号 - */ - private Long spuId; - /** - * 商品 SKU 编号 - * - * 关联 ProductSkuDO 的 id 编号 - */ - private Long skuId; - - /** - * 折扣类型 - * - * 枚举 {@link PromotionDiscountTypeEnum} - */ - private Integer discountType; - /** - * 折扣百分比 - * - * 例如,80% 为 80 - */ - private Integer discountPercent; - /** - * 优惠金额,单位:分 - * - * 当 {@link #discountType} 为 {@link PromotionDiscountTypeEnum#PRICE} 生效 - */ - private Integer discountPrice; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/reward/RewardActivityDO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/reward/RewardActivityDO.java deleted file mode 100644 index e825881d1..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/reward/RewardActivityDO.java +++ /dev/null @@ -1,133 +0,0 @@ -package cn.iocoder.yudao.module.promotion.dal.dataobject.reward; - -import cn.iocoder.yudao.framework.common.util.json.JsonUtils; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.framework.mybatis.core.type.LongListTypeHandler; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionActivityStatusEnum; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionConditionTypeEnum; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionProductScopeEnum; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import com.baomidou.mybatisplus.extension.handlers.AbstractJsonTypeHandler; -import lombok.Data; -import lombok.EqualsAndHashCode; - -import java.io.Serializable; -import java.time.LocalDateTime; -import java.util.List; - -/** - * 满减送活动 DO - * - * @author 芋道源码 - */ -@TableName(value = "promotion_reward_activity", autoResultMap = true) -@KeySequence("promotion_reward_activity_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -public class RewardActivityDO extends BaseDO { - - /** - * 活动编号,主键自增 - */ - @TableId - private Long id; - /** - * 活动标题 - */ - private String name; - /** - * 状态 - * - * 枚举 {@link PromotionActivityStatusEnum} - */ - private Integer status; - /** - * 开始时间 - */ - private LocalDateTime startTime; - /** - * 结束时间 - */ - private LocalDateTime endTime; - /** - * 备注 - */ - private String remark; - /** - * 条件类型 - * - * 枚举 {@link PromotionConditionTypeEnum} - */ - private Integer conditionType; - /** - * 商品范围 - * - * 枚举 {@link PromotionProductScopeEnum} - */ - private Integer productScope; - /** - * 商品 SPU 编号的数组 - */ - @TableField(typeHandler = LongListTypeHandler.class) - private List productSpuIds; - /** - * 优惠规则的数组 - */ - @TableField(typeHandler = RuleTypeHandler.class) - private List rules; - - /** - * 优惠规则 - */ - @Data - public static class Rule implements Serializable { - - /** - * 优惠门槛 - * - * 1. 满 N 元,单位:分 - * 2. 满 N 件 - */ - private Integer limit; - /** - * 优惠价格,单位:分 - */ - private Integer discountPrice; - /** - * 是否包邮 - */ - private Boolean freeDelivery; - /** - * 赠送的积分 - */ - private Integer point; - /** - * 赠送的优惠劵编号的数组 - */ - private List couponIds; - /** - * 赠送的优惠卷数量的数组 - */ - private List couponCounts; - - } - - // TODO @芋艿:可以找一些新的思路 - public static class RuleTypeHandler extends AbstractJsonTypeHandler> { - - @Override - protected List parse(String json) { - return JsonUtils.parseArray(json, Rule.class); - } - - @Override - protected String toJson(List obj) { - return JsonUtils.toJsonString(obj); - } - - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/seckill/seckillactivity/SeckillActivityDO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/seckill/seckillactivity/SeckillActivityDO.java deleted file mode 100644 index 1d3b6da27..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/seckill/seckillactivity/SeckillActivityDO.java +++ /dev/null @@ -1,78 +0,0 @@ -package cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.seckillactivity; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.framework.mybatis.core.type.LongListTypeHandler; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionActivityStatusEnum; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.time.LocalDateTime; -import java.util.List; - -/** - * 秒杀活动 DO - * - * @author halfninety - */ -@TableName(value = "promotion_seckill_activity", autoResultMap = true) -@KeySequence("promotion_seckill_activity_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class SeckillActivityDO extends BaseDO { - - /** - * 秒杀活动编号 - */ - @TableId - private Long id; - /** - * 秒杀活动名称 - */ - private String name; - /** - * 活动状态 - *

- * 枚举 {@link PromotionActivityStatusEnum 对应的类} - */ - private Integer status; - /** - * 备注 - */ - private String remark; - /** - * 活动开始时间 - */ - private LocalDateTime startTime; - /** - * 活动结束时间 - */ - private LocalDateTime endTime; - /** - * 排序 - */ - private Integer sort; - /** - * 秒杀时段 id - */ - @TableField(typeHandler = LongListTypeHandler.class) - private List timeIds; - /** - * 付款订单数 - */ - private Integer orderCount; - /** - * 付款人数 - */ - private Integer userCount; - /** - * 订单实付金额,单位:分 - */ - private Long totalPrice; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/seckill/seckillactivity/SeckillProductDO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/seckill/seckillactivity/SeckillProductDO.java deleted file mode 100644 index 3783d6dda..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/seckill/seckillactivity/SeckillProductDO.java +++ /dev/null @@ -1,65 +0,0 @@ -package cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.seckillactivity; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.framework.mybatis.core.type.LongListTypeHandler; -import com.baomidou.mybatisplus.annotation.*; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.util.List; - -/** - * 秒杀参与商品 - * - * @author halfninety - * @TableName promotion_seckill_product - */ -@TableName(value = "promotion_seckill_product", autoResultMap = true) -@KeySequence("promotion_seckill_product_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class SeckillProductDO extends BaseDO { - /** - * 秒杀参与商品编号 - */ - @TableId(type = IdType.AUTO) - private Long id; - - /** - * 秒杀活动id - */ - private Long activityId; - - /** - * 秒杀时段id - */ - @TableField(typeHandler = LongListTypeHandler.class) - private List timeIds; - - /** - * 商品id - */ - private Long spuId; - - /** - * 商品sku_id - */ - private Long skuId; - - /** - * 秒杀金额 - */ - private Integer seckillPrice; - - /** - * 秒杀库存 - */ - private Integer stock; - - /** - * 每人限购 - */ - private Integer limitBuyCount; -} \ No newline at end of file diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/seckill/seckilltime/SeckillTimeDO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/seckill/seckilltime/SeckillTimeDO.java deleted file mode 100644 index df338c0e6..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/seckill/seckilltime/SeckillTimeDO.java +++ /dev/null @@ -1,47 +0,0 @@ -package cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.seckilltime; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.time.LocalTime; - -/** - * 秒杀时段 DO - * - * @author 芋道源码 - */ -@TableName("promotion_seckill_time") -@KeySequence("promotion_seckill_time_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class SeckillTimeDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - /** - * 秒杀时段名称 - */ - private String name; - /** - * 开始时间点 - */ - private LocalTime startTime; - /** - * 结束时间点 - */ - private LocalTime endTime; - /** - * 秒杀活动数量 - */ - private Integer seckillActivityCount; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/banner/BannerMapper.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/banner/BannerMapper.java deleted file mode 100644 index d98375365..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/banner/BannerMapper.java +++ /dev/null @@ -1,26 +0,0 @@ -package cn.iocoder.yudao.module.promotion.dal.mysql.banner; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.promotion.controller.admin.banner.vo.BannerPageReqVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.banner.BannerDO; -import org.apache.ibatis.annotations.Mapper; - -/** - * Banner Mapper - * - * @author xia - */ -@Mapper -public interface BannerMapper extends BaseMapperX { - - default PageResult selectPage(BannerPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .likeIfPresent(BannerDO::getTitle, reqVO.getTitle()) - .eqIfPresent(BannerDO::getStatus, reqVO.getStatus()) - .betweenIfPresent(BannerDO::getCreateTime, reqVO.getCreateTime()) - .orderByDesc(BannerDO::getSort)); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/coupon/CouponMapper.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/coupon/CouponMapper.java deleted file mode 100755 index e5ae5f79d..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/coupon/CouponMapper.java +++ /dev/null @@ -1,52 +0,0 @@ -package cn.iocoder.yudao.module.promotion.dal.mysql.coupon; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.coupon.CouponPageReqVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.coupon.CouponDO; -import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; -import org.apache.ibatis.annotations.Mapper; - -import java.util.Collection; -import java.util.List; - -/** - * 优惠劵 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface CouponMapper extends BaseMapperX { - - default PageResult selectPage(CouponPageReqVO reqVO, Collection userIds) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .eqIfPresent(CouponDO::getTemplateId, reqVO.getTemplateId()) - .eqIfPresent(CouponDO::getStatus, reqVO.getStatus()) - .inIfPresent(CouponDO::getUserId, userIds) - .betweenIfPresent(CouponDO::getCreateTime, reqVO.getCreateTime()) - .orderByDesc(CouponDO::getId)); - } - - default List selectListByUserIdAndStatus(Long userId, Integer status) { - return selectList(new LambdaQueryWrapperX() - .eq(CouponDO::getUserId, userId).eq(CouponDO::getStatus, status)); - } - - default CouponDO selectByIdAndUserId(Long id, Long userId) { - return selectOne(new LambdaQueryWrapperX() - .eq(CouponDO::getId, id).eq(CouponDO::getUserId, userId)); - } - - default int delete(Long id, Collection whereStatuses) { - return update(null, new LambdaUpdateWrapper() - .eq(CouponDO::getId, id).in(CouponDO::getStatus, whereStatuses) - .set(CouponDO::getDeleted, 1)); - } - - default int updateByIdAndStatus(Long id, Integer status, CouponDO updateObj) { - return update(updateObj, new LambdaUpdateWrapper() - .eq(CouponDO::getId, id).eq(CouponDO::getStatus, status)); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/coupon/CouponTemplateMapper.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/coupon/CouponTemplateMapper.java deleted file mode 100755 index 7cea814af..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/coupon/CouponTemplateMapper.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.promotion.dal.mysql.coupon; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.template.CouponTemplatePageReqVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.coupon.CouponTemplateDO; -import org.apache.ibatis.annotations.Mapper; -import org.apache.ibatis.annotations.Param; - -/** - * 优惠劵模板 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface CouponTemplateMapper extends BaseMapperX { - - default PageResult selectPage(CouponTemplatePageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .likeIfPresent(CouponTemplateDO::getName, reqVO.getName()) - .eqIfPresent(CouponTemplateDO::getStatus, reqVO.getStatus()) - .eqIfPresent(CouponTemplateDO::getDiscountType, reqVO.getDiscountType()) - .betweenIfPresent(CouponTemplateDO::getCreateTime, reqVO.getCreateTime()) - .orderByDesc(CouponTemplateDO::getId)); - } - - void updateTakeCount(@Param("id") Long id, @Param("incrCount") Integer incrCount); - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/discount/DiscountActivityMapper.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/discount/DiscountActivityMapper.java deleted file mode 100755 index 534ce627a..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/discount/DiscountActivityMapper.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.promotion.dal.mysql.discount; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.promotion.controller.admin.discount.vo.DiscountActivityPageReqVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.discount.DiscountActivityDO; -import org.apache.ibatis.annotations.Mapper; - -import java.util.Collection; -import java.util.List; -import java.util.Set; - -/** - * 限时折扣活动 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface DiscountActivityMapper extends BaseMapperX { - - default PageResult selectPage(DiscountActivityPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .likeIfPresent(DiscountActivityDO::getName, reqVO.getName()) - .eqIfPresent(DiscountActivityDO::getStatus, reqVO.getStatus()) - .betweenIfPresent(DiscountActivityDO::getCreateTime, reqVO.getCreateTime()) - .orderByDesc(DiscountActivityDO::getId)); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/discount/DiscountProductMapper.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/discount/DiscountProductMapper.java deleted file mode 100755 index 646b60707..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/discount/DiscountProductMapper.java +++ /dev/null @@ -1,26 +0,0 @@ -package cn.iocoder.yudao.module.promotion.dal.mysql.discount; - -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.module.promotion.dal.dataobject.discount.DiscountProductDO; -import org.apache.ibatis.annotations.Mapper; - -import java.util.Collection; -import java.util.List; - -/** - * 限时折扣商城 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface DiscountProductMapper extends BaseMapperX { - - default List selectListBySkuId(Collection skuIds) { - return selectList(DiscountProductDO::getSkuId, skuIds); - } - - default List selectListByActivityId(Long activityId) { - return selectList(DiscountProductDO::getActivityId, activityId); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/reward/RewardActivityMapper.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/reward/RewardActivityMapper.java deleted file mode 100755 index 2ee879823..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/reward/RewardActivityMapper.java +++ /dev/null @@ -1,38 +0,0 @@ -package cn.iocoder.yudao.module.promotion.dal.mysql.reward; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.promotion.controller.admin.reward.vo.RewardActivityPageReqVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.reward.RewardActivityDO; -import org.apache.ibatis.annotations.Mapper; - -import java.util.Collection; -import java.util.List; - -/** - * 满减送活动 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface RewardActivityMapper extends BaseMapperX { - - default PageResult selectPage(RewardActivityPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .likeIfPresent(RewardActivityDO::getName, reqVO.getName()) - .eqIfPresent(RewardActivityDO::getStatus, reqVO.getStatus()) - .orderByDesc(RewardActivityDO::getId)); - } - - default List selectListByStatus(Collection statuses) { - return selectList(RewardActivityDO::getStatus, statuses); - } - - default List selectListByProductScopeAndStatus(Integer productScope, Integer status) { - return selectList(new LambdaQueryWrapperX() - .eq(RewardActivityDO::getProductScope, productScope) - .eq(RewardActivityDO::getStatus, status)); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/seckill/seckillactivity/SeckillActivityMapper.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/seckill/seckillactivity/SeckillActivityMapper.java deleted file mode 100644 index c01676c2a..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/seckill/seckillactivity/SeckillActivityMapper.java +++ /dev/null @@ -1,26 +0,0 @@ -package cn.iocoder.yudao.module.promotion.dal.mysql.seckill.seckillactivity; - -import cn.hutool.core.util.ObjectUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity.SeckillActivityPageReqVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.seckillactivity.SeckillActivityDO; -import org.apache.ibatis.annotations.Mapper; - -/** - * 秒杀活动 Mapper - * - * @author halfninety - */ -@Mapper -public interface SeckillActivityMapper extends BaseMapperX { - default PageResult selectPage(SeckillActivityPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .likeIfPresent(SeckillActivityDO::getName, reqVO.getName()) - .eqIfPresent(SeckillActivityDO::getStatus, reqVO.getStatus()) - .betweenIfPresent(SeckillActivityDO::getCreateTime, reqVO.getCreateTime()) - .apply(ObjectUtil.isNotNull(reqVO.getTimeId()),"FIND_IN_SET(" + reqVO.getTimeId() + ",time_ids) > 0") - .orderByDesc(SeckillActivityDO::getId)); - } -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/seckill/seckillactivity/SeckillProductMapper.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/seckill/seckillactivity/SeckillProductMapper.java deleted file mode 100644 index a590de1a5..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/seckill/seckillactivity/SeckillProductMapper.java +++ /dev/null @@ -1,35 +0,0 @@ -package cn.iocoder.yudao.module.promotion.dal.mysql.seckill.seckillactivity; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.seckillactivity.SeckillProductDO; -import com.baomidou.mybatisplus.extension.conditions.update.LambdaUpdateChainWrapper; -import org.apache.ibatis.annotations.Mapper; - -import java.util.Collection; -import java.util.List; - -/** - * 秒杀活动商品 Mapper - * - * @author halfninety - */ -@Mapper -public interface SeckillProductMapper extends BaseMapperX { - - default List selectListByActivityId(Long id) { - return selectList(SeckillProductDO::getActivityId, id); - } - - default List selectListBySkuIds(Collection skuIds) { - return selectList(SeckillProductDO::getSkuId, skuIds); - } - - default void updateTimeIdsByActivityId(Long id, List timeIds) { - new LambdaUpdateChainWrapper<>(this) - .set(SeckillProductDO::getTimeIds, CollUtil.join(timeIds, ",")) - .eq(SeckillProductDO::getActivityId, id) - .update(); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/seckill/seckilltime/SeckillTimeMapper.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/seckill/seckilltime/SeckillTimeMapper.java deleted file mode 100644 index c34484e8c..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/seckill/seckilltime/SeckillTimeMapper.java +++ /dev/null @@ -1,37 +0,0 @@ -package cn.iocoder.yudao.module.promotion.dal.mysql.seckill.seckilltime; - -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.seckilltime.SeckillTimeDO; -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.baomidou.mybatisplus.extension.conditions.update.LambdaUpdateChainWrapper; -import org.apache.ibatis.annotations.Mapper; - -import java.time.LocalTime; -import java.util.Collection; -import java.util.List; - -/** - * 秒杀时段 Mapper - * - * @author halfninety - */ -@Mapper -public interface SeckillTimeMapper extends BaseMapperX { - - default List selectListByTime(LocalTime time) { - return selectList(SeckillTimeDO::getStartTime, SeckillTimeDO::getEndTime, time); - } - - default List selectListByTime(LocalTime startTime, LocalTime endTime) { - return selectList(new LambdaQueryWrapper() - .ge(SeckillTimeDO::getStartTime, startTime) - .le(SeckillTimeDO::getEndTime, endTime)); - } - - default void updateActivityCount(Collection ids, String type, Integer count) { - new LambdaUpdateChainWrapper<>(this) - .in(SeckillTimeDO::getId, ids) - .setSql("`seckill_activity_count` = `seckill_activity_count` " + type + count) - .update(); - } -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/package-info.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/package-info.java deleted file mode 100644 index c022c6276..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/package-info.java +++ /dev/null @@ -1,8 +0,0 @@ -/** - * promotion 模块,我们放营销业务。 - * 例如说:营销活动、banner、优惠券等等 - * - * 1. Controller URL:以 /promotion/ 开头,避免和其它 Module 冲突 - * 2. DataObject 表名:以 promotion_ 开头,方便在数据库中区分 - */ -package cn.iocoder.yudao.module.promotion; diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/banner/BannerService.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/banner/BannerService.java deleted file mode 100644 index d541211be..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/banner/BannerService.java +++ /dev/null @@ -1,63 +0,0 @@ -package cn.iocoder.yudao.module.promotion.service.banner; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.controller.admin.banner.vo.BannerCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.banner.vo.BannerPageReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.banner.vo.BannerUpdateReqVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.banner.BannerDO; - -import javax.validation.Valid; -import java.util.List; - -/** - * 首页 Banner Service 接口 - * - * @author xia - */ -public interface BannerService { - - /** - * 创建 Banner - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createBanner(@Valid BannerCreateReqVO createReqVO); - - /** - * 更新 Banner - * - * @param updateReqVO 更新信息 - */ - void updateBanner(@Valid BannerUpdateReqVO updateReqVO); - - /** - * 删除 Banner - * - * @param id 编号 - */ - void deleteBanner(Long id); - - /** - * 获得 Banner - * - * @param id 编号 - * @return Banner - */ - BannerDO getBanner(Long id); - - /** - * 获得所有 Banner列表 - * @return Banner列表 - */ - List getBannerList(); - - /** - * 获得 Banner 分页 - * - * @param pageReqVO 分页查询 - * @return Banner分页 - */ - PageResult getBannerPage(BannerPageReqVO pageReqVO); - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/banner/BannerServiceImpl.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/banner/BannerServiceImpl.java deleted file mode 100644 index 013ae8992..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/banner/BannerServiceImpl.java +++ /dev/null @@ -1,78 +0,0 @@ -package cn.iocoder.yudao.module.promotion.service.banner; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.controller.admin.banner.vo.BannerCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.banner.vo.BannerPageReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.banner.vo.BannerUpdateReqVO; -import cn.iocoder.yudao.module.promotion.convert.banner.BannerConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.banner.BannerDO; -import cn.iocoder.yudao.module.promotion.dal.mysql.banner.BannerMapper; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.BANNER_NOT_EXISTS; - -/** - * 首页 banner 实现类 - * - * @author xia - */ -@Service -@Validated -public class BannerServiceImpl implements BannerService { - - @Resource - private BannerMapper bannerMapper; - - @Override - public Long createBanner(BannerCreateReqVO createReqVO) { - // 插入 - BannerDO banner = BannerConvert.INSTANCE.convert(createReqVO); - bannerMapper.insert(banner); - // 返回 - return banner.getId(); - } - - @Override - public void updateBanner(BannerUpdateReqVO updateReqVO) { - // 校验存在 - this.validateBannerExists(updateReqVO.getId()); - // 更新 - BannerDO updateObj = BannerConvert.INSTANCE.convert(updateReqVO); - bannerMapper.updateById(updateObj); - } - - @Override - public void deleteBanner(Long id) { - // 校验存在 - this.validateBannerExists(id); - // 删除 - bannerMapper.deleteById(id); - } - - private void validateBannerExists(Long id) { - if (bannerMapper.selectById(id) == null) { - throw exception(BANNER_NOT_EXISTS); - } - } - - @Override - public BannerDO getBanner(Long id) { - return bannerMapper.selectById(id); - } - - @Override - public List getBannerList() { - return bannerMapper.selectList(); - } - - @Override - public PageResult getBannerPage(BannerPageReqVO pageReqVO) { - return bannerMapper.selectPage(pageReqVO); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/coupon/CouponService.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/coupon/CouponService.java deleted file mode 100644 index 96b5b5d63..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/coupon/CouponService.java +++ /dev/null @@ -1,70 +0,0 @@ -package cn.iocoder.yudao.module.promotion.service.coupon; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.coupon.CouponPageReqVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.coupon.CouponDO; - -import java.util.List; - -/** - * 优惠劵 Service 接口 - * - * @author 芋道源码 - */ -public interface CouponService { - - /** - * 校验优惠劵,包括状态、有限期 - * - * 1. 如果校验通过,则返回优惠劵信息 - * 2. 如果校验不通过,则直接抛出业务异常 - * - * @param id 优惠劵编号 - * @param userId 用户编号 - * @return 优惠劵信息 - */ - CouponDO validCoupon(Long id, Long userId); - - /** - * 校验优惠劵,包括状态、有限期 - * - * @see #validCoupon(Long, Long) 逻辑相同,只是入参不同 - * - * @param coupon 优惠劵 - */ - void validCoupon(CouponDO coupon); - - /** - * 获得优惠劵分页 - * - * @param pageReqVO 分页查询 - * @return 优惠劵分页 - */ - PageResult getCouponPage(CouponPageReqVO pageReqVO); - - /** - * 使用优惠劵 - * - * @param id 优惠劵编号 - * @param userId 用户编号 - * @param orderId 订单编号 - */ - void useCoupon(Long id, Long userId, Long orderId); - - /** - * 回收优惠劵 - * - * @param id 优惠劵编号 - */ - void deleteCoupon(Long id); - - /** - * 获得用户的优惠劵列表 - * - * @param userId 用户编号 - * @param status 优惠劵状态 - * @return 优惠劵列表 - */ - List getCouponList(Long userId, Integer status); - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/coupon/CouponServiceImpl.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/coupon/CouponServiceImpl.java deleted file mode 100644 index a573e0d9c..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/coupon/CouponServiceImpl.java +++ /dev/null @@ -1,123 +0,0 @@ -package cn.iocoder.yudao.module.promotion.service.coupon; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.util.ObjectUtil; -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils; -import cn.iocoder.yudao.module.member.api.user.MemberUserApi; -import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; -import cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.coupon.CouponPageReqVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.coupon.CouponDO; -import cn.iocoder.yudao.module.promotion.dal.mysql.coupon.CouponMapper; -import cn.iocoder.yudao.module.promotion.enums.coupon.CouponStatusEnum; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.time.LocalDateTime; -import java.util.List; -import java.util.Set; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.*; -import static java.util.Arrays.asList; - -/** - * 优惠劵 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class CouponServiceImpl implements CouponService { - - @Resource - private CouponTemplateService couponTemplateService; - - @Resource - private CouponMapper couponMapper; - - @Resource - private MemberUserApi memberUserApi; - - @Override - public CouponDO validCoupon(Long id, Long userId) { - CouponDO coupon = couponMapper.selectByIdAndUserId(id, userId); - if (coupon == null) { - throw exception(COUPON_NOT_EXISTS); - } - validCoupon(coupon); - return coupon; - } - - @Override - public void validCoupon(CouponDO coupon) { - // 校验状态 - if (ObjectUtil.notEqual(coupon.getStatus(), CouponStatusEnum.UNUSED.getStatus())) { - throw exception(COUPON_STATUS_NOT_UNUSED); - } - // 校验有效期;为避免定时器没跑,实际优惠劵已经过期 - if (LocalDateTimeUtils.isBetween(coupon.getValidStartTime(), coupon.getValidEndTime())) { - throw exception(COUPON_VALID_TIME_NOT_NOW); - } - } - - @Override - public PageResult getCouponPage(CouponPageReqVO pageReqVO) { - // 获得用户编号 - Set userIds = null; - if (StrUtil.isNotEmpty(pageReqVO.getNickname())) { - userIds = CollectionUtils.convertSet(memberUserApi.getUserListByNickname(pageReqVO.getNickname()), - MemberUserRespDTO::getId); - if (CollUtil.isEmpty(userIds)) { - return PageResult.empty(); - } - } - // 分页查询 - return couponMapper.selectPage(pageReqVO, userIds); - } - - @Override - public void useCoupon(Long id, Long userId, Long orderId) { - // 校验优惠劵 - validCoupon(id, userId); - // 更新状态 - int updateCount = couponMapper.updateByIdAndStatus(id, CouponStatusEnum.UNUSED.getStatus(), - new CouponDO().setStatus(CouponStatusEnum.USED.getStatus()) - .setUseOrderId(orderId).setUseTime(LocalDateTime.now())); - if (updateCount == 0) { - throw exception(COUPON_STATUS_NOT_UNUSED); - } - } - - @Override - @Transactional - public void deleteCoupon(Long id) { - // 校验存在 - validateCouponExists(id); - - // 更新优惠劵 - int deleteCount = couponMapper.delete(id, - asList(CouponStatusEnum.UNUSED.getStatus(), CouponStatusEnum.EXPIRE.getStatus())); - if (deleteCount == 0) { - throw exception(COUPON_DELETE_FAIL_USED); - } - // 减少优惠劵模板的领取数量 -1 - couponTemplateService.updateCouponTemplateTakeCount(id, -1); - } - - @Override - public List getCouponList(Long userId, Integer status) { - return couponMapper.selectListByUserIdAndStatus(userId, status); - } - - private void validateCouponExists(Long id) { - if (couponMapper.selectById(id) == null) { - throw exception(COUPON_NOT_EXISTS); - } - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/coupon/CouponTemplateService.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/coupon/CouponTemplateService.java deleted file mode 100755 index fdf018974..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/coupon/CouponTemplateService.java +++ /dev/null @@ -1,72 +0,0 @@ -package cn.iocoder.yudao.module.promotion.service.coupon; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.template.CouponTemplateCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.template.CouponTemplatePageReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.template.CouponTemplateUpdateReqVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.coupon.CouponTemplateDO; - -import javax.validation.Valid; - -/** - * 优惠劵模板 Service 接口 - * - * @author 芋道源码 - */ -public interface CouponTemplateService { - - /** - * 创建优惠劵模板 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createCouponTemplate(@Valid CouponTemplateCreateReqVO createReqVO); - - /** - * 更新优惠劵模板 - * - * @param updateReqVO 更新信息 - */ - void updateCouponTemplate(@Valid CouponTemplateUpdateReqVO updateReqVO); - - /** - * 更新优惠劵模板的状态 - * - * @param id 编号 - * @param status 状态 - */ - void updateCouponTemplateStatus(Long id, Integer status); - - /** - * 删除优惠劵模板 - * - * @param id 编号 - */ - void deleteCouponTemplate(Long id); - - /** - * 获得优惠劵模板 - * - * @param id 编号 - * @return 优惠劵模板 - */ - CouponTemplateDO getCouponTemplate(Long id); - - /** - * 获得优惠劵模板分页 - * - * @param pageReqVO 分页查询 - * @return 优惠劵模板分页 - */ - PageResult getCouponTemplatePage(CouponTemplatePageReqVO pageReqVO); - - /** - * 更新优惠劵模板的领取数量 - * - * @param id 优惠劵模板编号 - * @param incrCount 增加数量 - */ - void updateCouponTemplateTakeCount(Long id, int incrCount); - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/coupon/CouponTemplateServiceImpl.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/coupon/CouponTemplateServiceImpl.java deleted file mode 100755 index 1a9cc8bfb..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/coupon/CouponTemplateServiceImpl.java +++ /dev/null @@ -1,94 +0,0 @@ -package cn.iocoder.yudao.module.promotion.service.coupon; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.template.CouponTemplateCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.template.CouponTemplatePageReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.template.CouponTemplateUpdateReqVO; -import cn.iocoder.yudao.module.promotion.convert.coupon.CouponTemplateConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.coupon.CouponTemplateDO; -import cn.iocoder.yudao.module.promotion.dal.mysql.coupon.CouponTemplateMapper; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.*; - -/** - * 优惠劵模板 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class CouponTemplateServiceImpl implements CouponTemplateService { - - @Resource - private CouponTemplateMapper couponTemplateMapper; - - @Override - public Long createCouponTemplate(CouponTemplateCreateReqVO createReqVO) { - // 插入 - CouponTemplateDO couponTemplate = CouponTemplateConvert.INSTANCE.convert(createReqVO) - .setStatus(CommonStatusEnum.ENABLE.getStatus()); - couponTemplateMapper.insert(couponTemplate); - // 返回 - return couponTemplate.getId(); - } - - @Override - public void updateCouponTemplate(CouponTemplateUpdateReqVO updateReqVO) { - // 校验存在 - CouponTemplateDO couponTemplate = validateCouponTemplateExists(updateReqVO.getId()); - // 校验发放数量不能过小 - if (updateReqVO.getTotalCount() < couponTemplate.getTakeCount()) { - throw exception(COUPON_TEMPLATE_TOTAL_COUNT_TOO_SMALL, couponTemplate.getTakeCount()); - } - - // 更新 - CouponTemplateDO updateObj = CouponTemplateConvert.INSTANCE.convert(updateReqVO); - couponTemplateMapper.updateById(updateObj); - } - - @Override - public void updateCouponTemplateStatus(Long id, Integer status) { - // 校验存在 - validateCouponTemplateExists(id); - // 更新 - couponTemplateMapper.updateById(new CouponTemplateDO().setId(id).setStatus(status)); - } - - @Override - public void deleteCouponTemplate(Long id) { - // 校验存在 - validateCouponTemplateExists(id); - // 删除 - couponTemplateMapper.deleteById(id); - } - - private CouponTemplateDO validateCouponTemplateExists(Long id) { - CouponTemplateDO couponTemplate = couponTemplateMapper.selectById(id); - if (couponTemplate == null) { - throw exception(COUPON_TEMPLATE_NOT_EXISTS); - } - return couponTemplate; - } - - @Override - public CouponTemplateDO getCouponTemplate(Long id) { - return couponTemplateMapper.selectById(id); - } - - @Override - public PageResult getCouponTemplatePage(CouponTemplatePageReqVO pageReqVO) { - return couponTemplateMapper.selectPage(pageReqVO); - } - - @Override - public void updateCouponTemplateTakeCount(Long id, int incrCount) { - couponTemplateMapper.updateTakeCount(id, incrCount); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/discount/DiscountActivityService.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/discount/DiscountActivityService.java deleted file mode 100644 index 8b6e5895b..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/discount/DiscountActivityService.java +++ /dev/null @@ -1,86 +0,0 @@ -package cn.iocoder.yudao.module.promotion.service.discount; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.controller.admin.discount.vo.DiscountActivityCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.discount.vo.DiscountActivityPageReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.discount.vo.DiscountActivityUpdateReqVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.discount.DiscountActivityDO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.discount.DiscountProductDO; -import cn.iocoder.yudao.module.promotion.service.discount.bo.DiscountProductDetailBO; - -import javax.validation.Valid; -import java.util.Collection; -import java.util.List; -import java.util.Map; - -/** - * 限时折扣 Service 接口 - * - * @author 芋道源码 - */ -public interface DiscountActivityService { - - /** - * 基于指定 SKU 编号数组,获得匹配的限时折扣商品 - * - * 注意,匹配的条件,仅仅是日期符合,并且处于开启状态 - * - * @param skuIds SKU 编号数组 - * @return 匹配的限时折扣商品 - */ - Map getMatchDiscountProducts(Collection skuIds); - - /** - * 创建限时折扣活动 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createDiscountActivity(@Valid DiscountActivityCreateReqVO createReqVO); - - /** - * 更新限时折扣活动 - * - * @param updateReqVO 更新信息 - */ - void updateDiscountActivity(@Valid DiscountActivityUpdateReqVO updateReqVO); - - /** - * 关闭限时折扣活动 - * - * @param id 编号 - */ - void closeRewardActivity(Long id); - - /** - * 删除限时折扣活动 - * - * @param id 编号 - */ - void deleteDiscountActivity(Long id); - - /** - * 获得限时折扣活动 - * - * @param id 编号 - * @return 限时折扣活动 - */ - DiscountActivityDO getDiscountActivity(Long id); - - /** - * 获得限时折扣活动分页 - * - * @param pageReqVO 分页查询 - * @return 限时折扣活动分页 - */ - PageResult getDiscountActivityPage(DiscountActivityPageReqVO pageReqVO); - - /** - * 获得活动编号,对应对应的商品列表 - * - * @param activityId 活动编号 - * @return 活动的商品列表 - */ - List getDiscountProductsByActivityId(Long activityId); - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/discount/DiscountActivityServiceImpl.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/discount/DiscountActivityServiceImpl.java deleted file mode 100644 index df54d44f2..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/discount/DiscountActivityServiceImpl.java +++ /dev/null @@ -1,196 +0,0 @@ -package cn.iocoder.yudao.module.promotion.service.discount; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.collection.CollectionUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.module.promotion.controller.admin.discount.vo.DiscountActivityBaseVO; -import cn.iocoder.yudao.module.promotion.controller.admin.discount.vo.DiscountActivityCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.discount.vo.DiscountActivityPageReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.discount.vo.DiscountActivityUpdateReqVO; -import cn.iocoder.yudao.module.promotion.convert.discount.DiscountActivityConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.discount.DiscountActivityDO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.discount.DiscountProductDO; -import cn.iocoder.yudao.module.promotion.dal.mysql.discount.DiscountActivityMapper; -import cn.iocoder.yudao.module.promotion.dal.mysql.discount.DiscountProductMapper; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionActivityStatusEnum; -import cn.iocoder.yudao.module.promotion.service.discount.bo.DiscountProductDetailBO; -import cn.iocoder.yudao.module.promotion.util.PromotionUtils; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.util.*; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*; -import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.*; -import static java.util.Arrays.asList; - -/** - * 限时折扣 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class DiscountActivityServiceImpl implements DiscountActivityService { - - @Resource - private DiscountActivityMapper discountActivityMapper; - @Resource - private DiscountProductMapper discountProductMapper; - - @Override - public Map getMatchDiscountProducts(Collection skuIds) { - List discountProducts = getRewardProductListBySkuIds(skuIds, singleton(PromotionActivityStatusEnum.RUN.getStatus())); - return convertMap(discountProducts, DiscountProductDetailBO::getSkuId); - } - - @Override - public Long createDiscountActivity(DiscountActivityCreateReqVO createReqVO) { - // 校验商品是否冲突 - validateDiscountActivityProductConflicts(null, createReqVO.getProducts()); - - // 插入活动 - DiscountActivityDO discountActivity = DiscountActivityConvert.INSTANCE.convert(createReqVO) - .setStatus(PromotionUtils.calculateActivityStatus(createReqVO.getStartTime(), createReqVO.getEndTime())); - discountActivityMapper.insert(discountActivity); - // 插入商品 - List discountProducts = convertList(createReqVO.getProducts(), - product -> DiscountActivityConvert.INSTANCE.convert(product).setActivityId(discountActivity.getId())); - discountProductMapper.insertBatch(discountProducts); - // 返回 - return discountActivity.getId(); - } - - @Override - public void updateDiscountActivity(DiscountActivityUpdateReqVO updateReqVO) { - // 校验存在 - DiscountActivityDO discountActivity = validateDiscountActivityExists(updateReqVO.getId()); - if (discountActivity.getStatus().equals(PromotionActivityStatusEnum.CLOSE.getStatus())) { // 已关闭的活动,不能修改噢 - throw exception(DISCOUNT_ACTIVITY_UPDATE_FAIL_STATUS_CLOSED); - } - // 校验商品是否冲突 - validateDiscountActivityProductConflicts(updateReqVO.getId(), updateReqVO.getProducts()); - - // 更新活动 - DiscountActivityDO updateObj = DiscountActivityConvert.INSTANCE.convert(updateReqVO) - .setStatus(PromotionUtils.calculateActivityStatus(updateReqVO.getStartTime(), updateReqVO.getEndTime())); - discountActivityMapper.updateById(updateObj); - // 更新商品 - updateDiscountProduct(updateReqVO); - } - - private void updateDiscountProduct(DiscountActivityUpdateReqVO updateReqVO) { - List dbDiscountProducts = discountProductMapper.selectListByActivityId(updateReqVO.getId()); - // 计算要删除的记录 - List deleteIds = convertList(dbDiscountProducts, DiscountProductDO::getId, - discountProductDO -> updateReqVO.getProducts().stream() - .noneMatch(product -> DiscountActivityConvert.INSTANCE.isEquals(discountProductDO, product))); - if (CollUtil.isNotEmpty(deleteIds)) { - discountProductMapper.deleteBatchIds(deleteIds); - } - // 计算新增的记录 - List newDiscountProducts = convertList(updateReqVO.getProducts(), - product -> DiscountActivityConvert.INSTANCE.convert(product).setActivityId(updateReqVO.getId())); - newDiscountProducts.removeIf(product -> dbDiscountProducts.stream().anyMatch( - dbProduct -> DiscountActivityConvert.INSTANCE.isEquals(dbProduct, product))); // 如果匹配到,说明是更新的 - if (CollectionUtil.isNotEmpty(newDiscountProducts)) { - discountProductMapper.insertBatch(newDiscountProducts); - } - } - - /** - * 校验商品是否冲突 - * - * @param id 编号 - * @param products 商品列表 - */ - private void validateDiscountActivityProductConflicts(Long id, List products) { - if (CollUtil.isEmpty(products)) { - return; - } - // 查询商品参加的活动 - List discountActivityProductList = getRewardProductListBySkuIds( - convertSet(products, DiscountActivityBaseVO.Product::getSkuId), - asList(PromotionActivityStatusEnum.WAIT.getStatus(), PromotionActivityStatusEnum.RUN.getStatus())); - if (id != null) { // 排除自己这个活动 - discountActivityProductList.removeIf(product -> id.equals(product.getActivityId())); - } - // 如果非空,则说明冲突 - if (CollUtil.isNotEmpty(discountActivityProductList)) { - throw exception(DISCOUNT_ACTIVITY_SPU_CONFLICTS); - } - } - - private List getRewardProductListBySkuIds(Collection skuIds, - Collection statuses) { - // 查询商品 - List products = discountProductMapper.selectListBySkuId(skuIds); - if (CollUtil.isEmpty(products)) { - return new ArrayList<>(0); - } - - // 查询活动 - List activities = discountActivityMapper.selectBatchIds(skuIds); - activities.removeIf(activity -> !statuses.contains(activity.getStatus())); // 移除不满足 statuses 状态的 - Map activityMap = CollectionUtils.convertMap(activities, DiscountActivityDO::getId); - - // 移除不满足活动的商品 - products.removeIf(product -> !activityMap.containsKey(product.getActivityId())); - return DiscountActivityConvert.INSTANCE.convertList(products, activityMap); - } - - @Override - public void closeRewardActivity(Long id) { - // 校验存在 - DiscountActivityDO dbDiscountActivity = validateDiscountActivityExists(id); - if (dbDiscountActivity.getStatus().equals(PromotionActivityStatusEnum.CLOSE.getStatus())) { // 已关闭的活动,不能关闭噢 - throw exception(DISCOUNT_ACTIVITY_CLOSE_FAIL_STATUS_CLOSED); - } - if (dbDiscountActivity.getStatus().equals(PromotionActivityStatusEnum.END.getStatus())) { // 已关闭的活动,不能关闭噢 - throw exception(DISCOUNT_ACTIVITY_CLOSE_FAIL_STATUS_END); - } - - // 更新 - DiscountActivityDO updateObj = new DiscountActivityDO().setId(id).setStatus(PromotionActivityStatusEnum.CLOSE.getStatus()); - discountActivityMapper.updateById(updateObj); - } - - @Override - public void deleteDiscountActivity(Long id) { - // 校验存在 - DiscountActivityDO discountActivity = validateDiscountActivityExists(id); - if (!discountActivity.getStatus().equals(PromotionActivityStatusEnum.CLOSE.getStatus())) { // 未关闭的活动,不能删除噢 - throw exception(DISCOUNT_ACTIVITY_DELETE_FAIL_STATUS_NOT_CLOSED); - } - - // 删除 - discountActivityMapper.deleteById(id); - } - - private DiscountActivityDO validateDiscountActivityExists(Long id) { - DiscountActivityDO discountActivity = discountActivityMapper.selectById(id); - if (discountActivity == null) { - throw exception(DISCOUNT_ACTIVITY_NOT_EXISTS); - } - return discountActivity; - } - - @Override - public DiscountActivityDO getDiscountActivity(Long id) { - return discountActivityMapper.selectById(id); - } - - @Override - public PageResult getDiscountActivityPage(DiscountActivityPageReqVO pageReqVO) { - return discountActivityMapper.selectPage(pageReqVO); - } - - @Override - public List getDiscountProductsByActivityId(Long activityId) { - return discountProductMapper.selectListByActivityId(activityId); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/discount/bo/DiscountProductDetailBO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/discount/bo/DiscountProductDetailBO.java deleted file mode 100644 index 7b8f4a20f..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/discount/bo/DiscountProductDetailBO.java +++ /dev/null @@ -1,50 +0,0 @@ -package cn.iocoder.yudao.module.promotion.service.discount.bo; - -import lombok.Data; - -/** - * 限时折扣活动商品 BO - * - * @author 芋道源码 - */ -@Data -public class DiscountProductDetailBO { - - // ========== DiscountProductDO 字段 ========== - - /** - * 编号,主键自增 - */ - private Long id; - /** - * 限时折扣活动的编号 - */ - private Long activityId; - /** - * 商品 SPU 编号 - */ - private Long spuId; - /** - * 商品 SKU 编号 - */ - private Long skuId; - /** - * 折扣类型 - */ - private Integer discountType; - /** - * 折扣百分比 - */ - private Integer discountPercent; - /** - * 优惠金额,单位:分 - */ - private Integer discountPrice; - - // ========== DiscountActivityDO 字段 ========== - /** - * 活动标题 - */ - private String activityName; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/price/PriceService.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/price/PriceService.java deleted file mode 100644 index a7420e119..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/price/PriceService.java +++ /dev/null @@ -1,32 +0,0 @@ -package cn.iocoder.yudao.module.promotion.service.price; - -import cn.iocoder.yudao.module.promotion.api.price.dto.CouponMeetRespDTO; -import cn.iocoder.yudao.module.promotion.api.price.dto.PriceCalculateReqDTO; -import cn.iocoder.yudao.module.promotion.api.price.dto.PriceCalculateRespDTO; - -import java.util.List; - -/** - * 价格计算 Service 接口 - * - * @author 芋道源码 - */ -public interface PriceService { - - /** - * 计算商品的价格 - * - * @param calculateReqDTO 价格请求 - * @return 价格响应 - */ - PriceCalculateRespDTO calculatePrice(PriceCalculateReqDTO calculateReqDTO); - - /** - * 获得优惠劵的匹配信息列表 - * - * @param calculateReqDTO 价格请求 - * @return 价格响应 - */ - List getMeetCouponList(PriceCalculateReqDTO calculateReqDTO); - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/price/PriceServiceImpl.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/price/PriceServiceImpl.java deleted file mode 100644 index 03abb061f..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/price/PriceServiceImpl.java +++ /dev/null @@ -1,547 +0,0 @@ -package cn.iocoder.yudao.module.promotion.service.price; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.lang.Assert; -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.common.exception.ServiceException; -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.module.product.api.sku.ProductSkuApi; -import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuRespDTO; -import cn.iocoder.yudao.module.promotion.api.price.dto.CouponMeetRespDTO; -import cn.iocoder.yudao.module.promotion.api.price.dto.PriceCalculateReqDTO; -import cn.iocoder.yudao.module.promotion.api.price.dto.PriceCalculateRespDTO; -import cn.iocoder.yudao.module.promotion.convert.price.PriceConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.coupon.CouponDO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.reward.RewardActivityDO; -import cn.iocoder.yudao.module.promotion.enums.common.*; -import cn.iocoder.yudao.module.promotion.enums.coupon.CouponStatusEnum; -import cn.iocoder.yudao.module.promotion.service.coupon.CouponService; -import cn.iocoder.yudao.module.promotion.service.discount.DiscountActivityService; -import cn.iocoder.yudao.module.promotion.service.discount.bo.DiscountProductDetailBO; -import cn.iocoder.yudao.module.promotion.service.reward.RewardActivityService; -import com.google.common.base.Suppliers; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.util.*; -import java.util.function.Supplier; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.getSumValue; -import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.SKU_NOT_EXISTS; -import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.*; -import static java.util.Collections.singletonList; - -/** - * 价格计算 Service 实现类 - * - * 优惠计算顺序:min(限时折扣, 会员折扣) > 满减送 > 优惠券。 - * 参考文档: - * 1. 有赞文档:限时折扣、满减送、优惠券哪个优先计算? - * - * TODO 芋艿:进一步完善 - * 1. 限时折扣:指定金额、减免金额、折扣 - * 2. 满减送:循环、折扣 - * 3. 优惠劵:待定 - * - * @author 芋道源码 - */ -@Service -@Validated -@Slf4j -public class PriceServiceImpl implements PriceService { - - @Resource - private DiscountActivityService discountService; - @Resource - private RewardActivityService rewardActivityService; - @Resource - private CouponService couponService; - - @Resource - private ProductSkuApi productSkuApi; - - @Override - public PriceCalculateRespDTO calculatePrice(PriceCalculateReqDTO calculateReqDTO) { - // 获得商品 SKU 数组 - List skuList = checkSkus(calculateReqDTO); - // 初始化 PriceCalculateRespDTO 对象 - PriceCalculateRespDTO priceCalculate = PriceConvert.INSTANCE.convert(calculateReqDTO, skuList); - - // 计算商品级别的价格 - calculatePriceForSkuLevel(calculateReqDTO.getUserId(), priceCalculate); - // 计算订单级别的价格 - calculatePriceForOrderLevel(calculateReqDTO.getUserId(), priceCalculate); - // 计算优惠劵级别的价格 - calculatePriceForCouponLevel(calculateReqDTO.getUserId(), calculateReqDTO.getCouponId(), priceCalculate); - - // 如果最终支付金额小于等于 0,则抛出业务异常 - if (priceCalculate.getOrder().getPayPrice() <= 0) { - log.error("[calculatePrice][价格计算不正确,请求 calculateReqDTO({}),结果 priceCalculate({})]", - calculateReqDTO, priceCalculate); - throw exception(PRICE_CALCULATE_PAY_PRICE_ILLEGAL); - } - return priceCalculate; - } - - @Override - public List getMeetCouponList(PriceCalculateReqDTO calculateReqDTO) { - // 先计算一轮价格 - PriceCalculateRespDTO priceCalculate = calculatePrice(calculateReqDTO); - - // 获得用户的待使用优惠劵 - List couponList = couponService.getCouponList(calculateReqDTO.getUserId(), CouponStatusEnum.UNUSED.getStatus()); - if (CollUtil.isEmpty(couponList)) { - return Collections.emptyList(); - } - - // 获得优惠劵的匹配信息 - return CollectionUtils.convertList(couponList, coupon -> { - CouponMeetRespDTO couponMeetRespDTO = PriceConvert.INSTANCE.convert(coupon); - try { - // 校验优惠劵 - couponService.validCoupon(coupon); - - // 获得匹配的商品 SKU 数组 - List orderItems = getMatchCouponOrderItems(priceCalculate, coupon); - if (CollUtil.isEmpty(orderItems)) { - return couponMeetRespDTO.setMeet(false).setMeetTip("所结算商品没有符合条件的商品"); - } - - // 计算是否满足优惠劵的使用金额 - Integer originPrice = getSumValue(orderItems, PriceCalculateRespDTO.OrderItem::getOrderDividePrice, Integer::sum); - assert originPrice != null; - if (originPrice < coupon.getUsePrice()) { - return couponMeetRespDTO.setMeet(false) -// .setMeetTip(String.format("差 %s 元可用优惠劵", formatPrice(coupon.getUsePrice() - originPrice))); - .setMeetTip("所结算的商品中未满足使用的金额"); - } - } catch (ServiceException serviceException) { - couponMeetRespDTO.setMeet(false); - if (serviceException.getCode().equals(COUPON_VALID_TIME_NOT_NOW.getCode())) { - couponMeetRespDTO.setMeetTip("优惠劵未到使用时间"); - } else { - log.error("[getMeetCouponList][calculateReqDTO({}) 获得优惠劵匹配信息异常]", calculateReqDTO, serviceException); - couponMeetRespDTO.setMeetTip("优惠劵不满足使用条件"); - } - return couponMeetRespDTO; - } - // 满足 - return couponMeetRespDTO.setMeet(true); - }); - } - - private List checkSkus(PriceCalculateReqDTO calculateReqDTO) { - // 获得商品 SKU 数组 - Map skuIdCountMap = CollectionUtils.convertMap(calculateReqDTO.getItems(), - PriceCalculateReqDTO.Item::getSkuId, PriceCalculateReqDTO.Item::getCount); - List skus = productSkuApi.getSkuList(skuIdCountMap.keySet()); - - // 校验商品 SKU - skus.forEach(sku -> { - Integer count = skuIdCountMap.get(sku.getId()); - if (count == null) { - throw exception(SKU_NOT_EXISTS); - } - // 不校验库存不足,避免购物车场景,商品无货的情况 - }); - return skus; - } - - // ========== 计算商品级别的价格 ========== - - /** - * 计算商品级别的价格,例如说: - * 1. 会员折扣 - * 2. 限时折扣 {@link cn.iocoder.yudao.module.promotion.dal.dataobject.discount.DiscountActivityDO} - * - * 其中,会员折扣、限时折扣取最低价 - * - * @param userId 用户编号 - * @param priceCalculate 价格计算的结果 - */ - private void calculatePriceForSkuLevel(Long userId, PriceCalculateRespDTO priceCalculate) { - // 获取 SKU 级别的所有优惠信息 - Supplier memberDiscountPercentSupplier = getMemberDiscountPercentSupplier(userId); - Map discountProducts = discountService.getMatchDiscountProducts( - convertSet(priceCalculate.getOrder().getItems(), PriceCalculateRespDTO.OrderItem::getSkuId)); - - // 处理每个 SKU 的优惠 - priceCalculate.getOrder().getItems().forEach(orderItem -> { - // 获取该 SKU 的优惠信息 - Double memberDiscountPercent = memberDiscountPercentSupplier.get(); - DiscountProductDetailBO discountProduct = discountProducts.get(orderItem.getSkuId()); - if (memberDiscountPercent == null && discountProduct == null) { - return; - } - // 计算价格,判断选择哪个折扣 - Integer memberPrice = memberDiscountPercent != null ? (int) (orderItem.getPayPrice() * memberDiscountPercent / 100) : null; - Integer promotionPrice = discountProduct != null ? getDiscountProductPrice(discountProduct, orderItem) : null; - if (memberPrice == null) { - calculatePriceByDiscountActivity(priceCalculate, orderItem, discountProduct, promotionPrice); - } else if (promotionPrice == null) { - calculatePriceByMemberDiscount(priceCalculate, orderItem, memberPrice); - } else if (memberPrice < promotionPrice) { - calculatePriceByDiscountActivity(priceCalculate, orderItem, discountProduct, promotionPrice); - } else { - calculatePriceByMemberDiscount(priceCalculate, orderItem, memberPrice); - } - }); - } - - private Integer getDiscountProductPrice(DiscountProductDetailBO discountProduct, - PriceCalculateRespDTO.OrderItem orderItem) { - Integer price = orderItem.getPayPrice(); - if (PromotionDiscountTypeEnum.PRICE.getType().equals(discountProduct.getDiscountType())) { // 减价 - price -= discountProduct.getDiscountPrice() * orderItem.getCount(); - } else if (PromotionDiscountTypeEnum.PERCENT.getType().equals(discountProduct.getDiscountType())) { // 打折 - price = price * discountProduct.getDiscountPercent() / 100; - } else { - throw new IllegalArgumentException(String.format("优惠活动的商品(%s) 的优惠类型不正确", discountProduct)); - } - return price; - } - - private void calculatePriceByMemberDiscount(PriceCalculateRespDTO priceCalculate, PriceCalculateRespDTO.OrderItem orderItem, - Integer memberPrice) { - // 记录优惠明细 - addPromotion(priceCalculate, orderItem, null, PromotionTypeEnum.MEMBER.getName(), - PromotionTypeEnum.MEMBER.getType(), PromotionLevelEnum.SKU.getLevel(), memberPrice, - true, StrUtil.format("会员折扣:省 {} 元", formatPrice(orderItem.getPayPrice() - memberPrice))); - // 修改 SKU 的优惠 - modifyOrderItemPayPrice(orderItem, memberPrice, priceCalculate); - } - - private void calculatePriceByDiscountActivity(PriceCalculateRespDTO priceCalculate, PriceCalculateRespDTO.OrderItem orderItem, - DiscountProductDetailBO discountProduct, Integer promotionPrice) { - // 记录优惠明细 - addPromotion(priceCalculate, orderItem, discountProduct.getActivityId(), discountProduct.getActivityName(), - PromotionTypeEnum.DISCOUNT_ACTIVITY.getType(), PromotionLevelEnum.SKU.getLevel(), promotionPrice, - true, StrUtil.format("限时折扣:省 {} 元", formatPrice(orderItem.getPayPrice() - promotionPrice))); - // 修改 SKU 的优惠 - modifyOrderItemPayPrice(orderItem, promotionPrice, priceCalculate); - } - - // TODO 芋艿:提前实现 - private Supplier getMemberDiscountPercentSupplier(Long userId) { - return Suppliers.memoize(() -> { - if (userId == 1) { - return 90d; - } - if (userId == 2) { - return 80d; - } - return null; // 无优惠 - }); - } - - // ========== 计算商品级别的价格 ========== - - /** - * 计算订单级别的价格,例如说: - * 1. 满减送 {@link cn.iocoder.yudao.module.promotion.dal.dataobject.reward.RewardActivityDO} - * - * @param userId 用户编号 - * @param priceCalculate 价格计算的结果 - */ - @SuppressWarnings("unused") - private void calculatePriceForOrderLevel(Long userId, PriceCalculateRespDTO priceCalculate) { - // 获取 SKU 级别的所有优惠信息 - Set spuIds = convertSet(priceCalculate.getOrder().getItems(), PriceCalculateRespDTO.OrderItem::getSpuId); - Map> rewardActivities = rewardActivityService.getMatchRewardActivities(spuIds); - - // 处理满减送活动 - if (CollUtil.isNotEmpty(rewardActivities)) { - rewardActivities.forEach((rewardActivity, activitySpuIds) -> { - List orderItems = CollectionUtils.filterList(priceCalculate.getOrder().getItems(), - orderItem -> CollUtil.contains(activitySpuIds, orderItem.getSpuId())); - calculatePriceByRewardActivity(priceCalculate, orderItems, rewardActivity); - }); - } - } - - private void calculatePriceByRewardActivity(PriceCalculateRespDTO priceCalculate, List orderItems, - RewardActivityDO rewardActivity) { - // 获得最大匹配的满减送活动的规则 - RewardActivityDO.Rule rule = getLastMatchRewardActivityRule(rewardActivity, orderItems); - if (rule == null) { - // 获取不到的情况下,记录不满足的优惠明细 - addNotMeetPromotion(priceCalculate, orderItems, rewardActivity.getId(), rewardActivity.getName(), - PromotionTypeEnum.REWARD_ACTIVITY.getType(), PromotionLevelEnum.ORDER.getLevel(), - getRewardActivityNotMeetTip(rewardActivity)); - return; - } - - // 分摊金额 - List discountPartPrices = dividePrice(orderItems, rule.getDiscountPrice()); - // 记录优惠明细 - addPromotion(priceCalculate, orderItems, rewardActivity.getId(), rewardActivity.getName(), - PromotionTypeEnum.REWARD_ACTIVITY.getType(), PromotionLevelEnum.ORDER.getLevel(), discountPartPrices, - true, StrUtil.format("满减送:省 {} 元", formatPrice(rule.getDiscountPrice()))); - // 修改 SKU 的分摊 - for (int i = 0; i < orderItems.size(); i++) { - modifyOrderItemOrderPartPriceFromDiscountPrice(orderItems.get(i), discountPartPrices.get(i), priceCalculate); - } - } - - /** - * 获得最大匹配的满减送活动的规则 - * - * @param rewardActivity 满减送活动 - * @param orderItems 商品项 - * @return 匹配的活动规则 - */ - private RewardActivityDO.Rule getLastMatchRewardActivityRule(RewardActivityDO rewardActivity, - List orderItems) { - Integer count = getSumValue(orderItems, PriceCalculateRespDTO.OrderItem::getCount, Integer::sum); - // price 的计算逻辑,使用 orderDividePrice 的原因,主要考虑分摊后,这个才是该 SKU 当前真实的支付总价 - Integer price = getSumValue(orderItems, PriceCalculateRespDTO.OrderItem::getOrderDividePrice, Integer::sum); - assert count != null && price != null; - for (int i = rewardActivity.getRules().size() - 1; i >= 0; i--) { - RewardActivityDO.Rule rule = rewardActivity.getRules().get(i); - if (PromotionConditionTypeEnum.PRICE.getType().equals(rewardActivity.getConditionType()) - && price >= rule.getLimit()) { - return rule; - } - if (PromotionConditionTypeEnum.COUNT.getType().equals(rewardActivity.getConditionType()) - && count >= rule.getLimit()) { - return rule; - } - } - return null; - } - - /** - * 获得满减送活动部匹配时的提示 - * - * @param rewardActivity 满减送活动 - * @return 提示 - */ - private String getRewardActivityNotMeetTip(RewardActivityDO rewardActivity) { - return "TODO"; // TODO 芋艿:后面再想想 - } - - // ========== 计算优惠劵级别的价格 ========== - - private void calculatePriceForCouponLevel(Long userId, Long couponId, PriceCalculateRespDTO priceCalculate) { - // 校验优惠劵 - if (couponId == null) { - return; - } - CouponDO coupon = couponService.validCoupon(couponId, userId); - - // 获得匹配的商品 SKU 数组 - List orderItems = getMatchCouponOrderItems(priceCalculate, coupon); - if (CollUtil.isEmpty(orderItems)) { - throw exception(COUPON_NO_MATCH_SPU); - } - - // 计算是否满足优惠劵的使用金额 - Integer originPrice = getSumValue(orderItems, PriceCalculateRespDTO.OrderItem::getOrderDividePrice, Integer::sum); - assert originPrice != null; - if (originPrice < coupon.getUsePrice()) { - throw exception(COUPON_NO_MATCH_MIN_PRICE); - } - - // 计算可以优惠的金额 - priceCalculate.getOrder().setCouponId(couponId); - Integer couponPrice = getCouponPrice(coupon, originPrice); - // 分摊金额 - List couponPartPrices = dividePrice(orderItems, couponPrice); - // 记录优惠明细 - addPromotion(priceCalculate, orderItems, coupon.getId(), coupon.getName(), - PromotionTypeEnum.COUPON.getType(), PromotionLevelEnum.COUPON.getLevel(), couponPartPrices, - true, StrUtil.format("优惠劵:省 {} 元", formatPrice(couponPrice))); - // 修改 SKU 的分摊 - for (int i = 0; i < orderItems.size(); i++) { - modifyOrderItemOrderPartPriceFromCouponPrice(orderItems.get(i), couponPartPrices.get(i), priceCalculate); - } - } - - private List getMatchCouponOrderItems(PriceCalculateRespDTO priceCalculate, - CouponDO coupon) { - if (PromotionProductScopeEnum.ALL.getScope().equals(coupon.getProductScope())) { - return priceCalculate.getOrder().getItems(); - } - return CollectionUtils.filterList(priceCalculate.getOrder().getItems(), - orderItem -> coupon.getProductSpuIds().contains(orderItem.getSpuId())); - } - - private Integer getCouponPrice(CouponDO coupon, Integer originPrice) { - if (PromotionDiscountTypeEnum.PRICE.getType().equals(coupon.getDiscountType())) { // 减价 - return coupon.getDiscountPrice(); - } else if (PromotionDiscountTypeEnum.PERCENT.getType().equals(coupon.getDiscountType())) { // 打折 - int couponPrice = originPrice * coupon.getDiscountPercent() / 100; - return coupon.getDiscountLimitPrice() == null ? couponPrice - : Math.min(couponPrice, coupon.getDiscountLimitPrice()); // 优惠上限 - } - throw new IllegalArgumentException(String.format("优惠劵(%s) 的优惠类型不正确", coupon)); - } - - // ========== 其它相对通用的方法 ========== - - /** - * 添加单个 OrderItem 的营销明细 - * - * @param priceCalculate 价格计算结果 - * @param orderItem 单个订单商品 SKU - * @param id 营销编号 - * @param name 营销名字 - * @param type 营销类型 - * @param level 营销级别 - * @param newPayPrice 新的单实付金额(总) - * @param meet 是否满足优惠条件 - * @param meetTip 满足条件的提示 - */ - private void addPromotion(PriceCalculateRespDTO priceCalculate, PriceCalculateRespDTO.OrderItem orderItem, - Long id, String name, Integer type, Integer level, - Integer newPayPrice, Boolean meet, String meetTip) { - // 创建营销明细 Item - // TODO 芋艿:orderItem.getPayPrice() 要不要改成 orderDividePrice;同时,newPayPrice 要不要改成直接传递 discountPrice - PriceCalculateRespDTO.PromotionItem promotionItem = new PriceCalculateRespDTO.PromotionItem().setSkuId(orderItem.getSkuId()) - .setOriginalPrice(orderItem.getPayPrice()).setDiscountPrice(orderItem.getPayPrice() - newPayPrice); - // 创建营销明细 - PriceCalculateRespDTO.Promotion promotion = new PriceCalculateRespDTO.Promotion() - .setId(id).setName(name).setType(type).setLevel(level) - .setOriginalPrice(promotionItem.getOriginalPrice()).setDiscountPrice(promotionItem.getDiscountPrice()) - .setItems(singletonList(promotionItem)).setMeet(meet).setMeetTip(meetTip); - priceCalculate.getPromotions().add(promotion); - } - - /** - * 添加多个 OrderItem 的营销明细 - * - * @param priceCalculate 价格计算结果 - * @param orderItems 多个订单商品 SKU - * @param id 营销编号 - * @param name 营销名字 - * @param type 营销类型 - * @param level 营销级别 - * @param discountPrices 多个订单商品 SKU 的优惠价格(总),和 orderItems 一一对应 - * @param meet 是否满足优惠条件 - * @param meetTip 满足条件的提示 - */ - private void addPromotion(PriceCalculateRespDTO priceCalculate, List orderItems, - Long id, String name, Integer type, Integer level, - List discountPrices, Boolean meet, String meetTip) { - // 创建营销明细 Item - List promotionItems = new ArrayList<>(discountPrices.size()); - for (int i = 0; i < orderItems.size(); i++) { - PriceCalculateRespDTO.OrderItem orderItem = orderItems.get(i); - promotionItems.add(new PriceCalculateRespDTO.PromotionItem().setSkuId(orderItem.getSkuId()) - .setOriginalPrice(orderItem.getPayPrice()).setDiscountPrice(discountPrices.get(i))); - } - // 创建营销明细 - PriceCalculateRespDTO.Promotion promotion = new PriceCalculateRespDTO.Promotion() - .setId(id).setName(name).setType(type).setLevel(level) - .setOriginalPrice(getSumValue(orderItems, PriceCalculateRespDTO.OrderItem::getOrderDividePrice, Integer::sum)) - .setDiscountPrice(getSumValue(discountPrices, value -> value, Integer::sum)) - .setItems(promotionItems).setMeet(meet).setMeetTip(meetTip); - priceCalculate.getPromotions().add(promotion); - } - - private void addNotMeetPromotion(PriceCalculateRespDTO priceCalculate, List orderItems, - Long id, String name, Integer type, Integer level, String meetTip) { - // 创建营销明细 Item - List promotionItems = CollectionUtils.convertList(orderItems, - orderItem -> new PriceCalculateRespDTO.PromotionItem().setSkuId(orderItem.getSkuId()) - .setOriginalPrice(orderItem.getOrderDividePrice()).setDiscountPrice(0)); - // 创建营销明细 - Integer originalPrice = getSumValue(orderItems, PriceCalculateRespDTO.OrderItem::getOrderDividePrice, Integer::sum); - PriceCalculateRespDTO.Promotion promotion = new PriceCalculateRespDTO.Promotion() - .setId(id).setName(name).setType(type).setLevel(level) - .setOriginalPrice(originalPrice).setDiscountPrice(0) - .setItems(promotionItems).setMeet(false).setMeetTip(meetTip); - priceCalculate.getPromotions().add(promotion); - } - - /** - * 修改 OrderItem 的 payPrice 价格,同时会修改 Order 的 payPrice 价格 - * - * @param orderItem 订单商品 SKU - * @param newPayPrice 新的 payPrice 价格 - * @param priceCalculate 价格计算结果 - */ - private void modifyOrderItemPayPrice(PriceCalculateRespDTO.OrderItem orderItem, Integer newPayPrice, - PriceCalculateRespDTO priceCalculate) { - // diffPayPrice 等于额外增加的商品级的优惠 - int diffPayPrice = orderItem.getPayPrice() - newPayPrice; - // 设置 OrderItem 价格相关字段 - orderItem.setDiscountPrice(orderItem.getDiscountPrice() + diffPayPrice); - orderItem.setPayPrice(newPayPrice); - orderItem.setOrderDividePrice(orderItem.getPayPrice() - orderItem.getOrderPartPrice()); - // 设置 Order 相关相关字段 - PriceCalculateRespDTO.Order order = priceCalculate.getOrder(); - order.setPayPrice(order.getPayPrice() - diffPayPrice); - order.setOrderPrice(order.getOrderPrice() - diffPayPrice); - } - - /** - * 修改 OrderItem 的 orderPartPrice 价格,同时会修改 Order 的 discountPrice 价格 - * - * 本质:分摊 Order 的 discountPrice 价格,到对应的 OrderItem 的 orderPartPrice 价格中 - * - * @param orderItem 订单商品 SKU - * @param addOrderPartPrice 新增的 discountPrice 价格 - * @param priceCalculate 价格计算结果 - */ - private void modifyOrderItemOrderPartPriceFromDiscountPrice(PriceCalculateRespDTO.OrderItem orderItem, Integer addOrderPartPrice, - PriceCalculateRespDTO priceCalculate) { - // 设置 OrderItem 价格相关字段 - orderItem.setOrderPartPrice(orderItem.getOrderPartPrice() + addOrderPartPrice); - orderItem.setOrderDividePrice(orderItem.getPayPrice() - orderItem.getOrderPartPrice()); - // 设置 Order 相关相关字段 - PriceCalculateRespDTO.Order order = priceCalculate.getOrder(); - order.setDiscountPrice(order.getDiscountPrice() + addOrderPartPrice); - order.setPayPrice(order.getPayPrice() - addOrderPartPrice); - } - - /** - * 修改 OrderItem 的 orderPartPrice 价格,同时会修改 Order 的 couponPrice 价格 - * - * 本质:分摊 Order 的 couponPrice 价格,到对应的 OrderItem 的 orderPartPrice 价格中 - * - * @param orderItem 订单商品 SKU - * @param addOrderPartPrice 新增的 couponPrice 价格 - * @param priceCalculate 价格计算结果 - */ - private void modifyOrderItemOrderPartPriceFromCouponPrice(PriceCalculateRespDTO.OrderItem orderItem, Integer addOrderPartPrice, - PriceCalculateRespDTO priceCalculate) { - // 设置 OrderItem 价格相关字段 - orderItem.setOrderPartPrice(orderItem.getOrderPartPrice() + addOrderPartPrice); - orderItem.setOrderDividePrice(orderItem.getPayPrice() - orderItem.getOrderPartPrice()); - // 设置 Order 相关相关字段 - PriceCalculateRespDTO.Order order = priceCalculate.getOrder(); - order.setCouponPrice(order.getCouponPrice() + addOrderPartPrice); - order.setPayPrice(order.getPayPrice() - addOrderPartPrice); - } - - private List dividePrice(List orderItems, Integer price) { - List prices = new ArrayList<>(orderItems.size()); - Integer total = getSumValue(orderItems, PriceCalculateRespDTO.OrderItem::getOrderDividePrice, Integer::sum); - assert total != null; - int remainPrice = price; - // 遍历每一个,进行分摊 - for (int i = 0; i < orderItems.size(); i++) { - PriceCalculateRespDTO.OrderItem orderItem = orderItems.get(i); - int partPrice; - if (i < orderItems.size() - 1) { // 减一的原因,是因为拆分时,如果按照比例,可能会出现.所以最后一个,使用反减 - partPrice = (int) (price * (1.0D * orderItem.getOrderDividePrice() / total)); - remainPrice -= partPrice; - } else { - partPrice = remainPrice; - } - Assert.isTrue(partPrice > 0, "分摊金额必须大于 0"); - prices.add(partPrice); - } - return prices; - } - - private String formatPrice(Integer price) { - return String.format("%.2f", price / 100d); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/reward/RewardActivityService.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/reward/RewardActivityService.java deleted file mode 100755 index 40bcc2836..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/reward/RewardActivityService.java +++ /dev/null @@ -1,73 +0,0 @@ -package cn.iocoder.yudao.module.promotion.service.reward; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.controller.admin.reward.vo.RewardActivityCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.reward.vo.RewardActivityPageReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.reward.vo.RewardActivityUpdateReqVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.reward.RewardActivityDO; - -import javax.validation.Valid; -import java.util.Map; -import java.util.Set; - -/** - * 满减送活动 Service 接口 - * - * @author 芋道源码 - */ -public interface RewardActivityService { - - /** - * 创建满减送活动 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createRewardActivity(@Valid RewardActivityCreateReqVO createReqVO); - - /** - * 更新满减送活动 - * - * @param updateReqVO 更新信息 - */ - void updateRewardActivity(@Valid RewardActivityUpdateReqVO updateReqVO); - - /** - * 关闭满减送活动 - * - * @param id 活动编号 - */ - void closeRewardActivity(Long id); - - /** - * 删除满减送活动 - * - * @param id 编号 - */ - void deleteRewardActivity(Long id); - - /** - * 获得满减送活动 - * - * @param id 编号 - * @return 满减送活动 - */ - RewardActivityDO getRewardActivity(Long id); - - /** - * 获得满减送活动分页 - * - * @param pageReqVO 分页查询 - * @return 满减送活动分页 - */ - PageResult getRewardActivityPage(RewardActivityPageReqVO pageReqVO); - - /** - * 基于指定的 SPU 编号数组,获得它们匹配的满减送活动 - * - * @param spuIds SPU 编号数组 - * @return 满减送活动,与对应的 SPU 编号的映射。即,value 就是 SPU 编号的集合 - */ - Map> getMatchRewardActivities(Set spuIds); - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/reward/RewardActivityServiceImpl.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/reward/RewardActivityServiceImpl.java deleted file mode 100755 index 51d0ce626..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/reward/RewardActivityServiceImpl.java +++ /dev/null @@ -1,169 +0,0 @@ -package cn.iocoder.yudao.module.promotion.service.reward; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.map.MapUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.controller.admin.reward.vo.RewardActivityCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.reward.vo.RewardActivityPageReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.reward.vo.RewardActivityUpdateReqVO; -import cn.iocoder.yudao.module.promotion.convert.reward.RewardActivityConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.reward.RewardActivityDO; -import cn.iocoder.yudao.module.promotion.dal.mysql.reward.RewardActivityMapper; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionActivityStatusEnum; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionProductScopeEnum; -import cn.iocoder.yudao.module.promotion.util.PromotionUtils; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.util.Collection; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import static cn.hutool.core.collection.CollUtil.intersectionDistinct; -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; -import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.*; -import static java.util.Arrays.asList; -import static java.util.Collections.singleton; - -/** - * 满减送活动 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class RewardActivityServiceImpl implements RewardActivityService { - - @Resource - private RewardActivityMapper rewardActivityMapper; - - @Override - public Long createRewardActivity(RewardActivityCreateReqVO createReqVO) { - // 校验商品是否冲突 - validateRewardActivitySpuConflicts(null, createReqVO.getProductSpuIds()); - - // 插入 - RewardActivityDO rewardActivity = RewardActivityConvert.INSTANCE.convert(createReqVO) - .setStatus(PromotionUtils.calculateActivityStatus(createReqVO.getStartTime(), createReqVO.getEndTime())); - rewardActivityMapper.insert(rewardActivity); - // 返回 - return rewardActivity.getId(); - } - - @Override - public void updateRewardActivity(RewardActivityUpdateReqVO updateReqVO) { - // 校验存在 - RewardActivityDO dbRewardActivity = validateRewardActivityExists(updateReqVO.getId()); - if (dbRewardActivity.getStatus().equals(PromotionActivityStatusEnum.CLOSE.getStatus())) { // 已关闭的活动,不能修改噢 - throw exception(REWARD_ACTIVITY_UPDATE_FAIL_STATUS_CLOSED); - } - // 校验商品是否冲突 - validateRewardActivitySpuConflicts(updateReqVO.getId(), updateReqVO.getProductSpuIds()); - - // 更新 - RewardActivityDO updateObj = RewardActivityConvert.INSTANCE.convert(updateReqVO) - .setStatus(PromotionUtils.calculateActivityStatus(updateReqVO.getStartTime(), updateReqVO.getEndTime())); - rewardActivityMapper.updateById(updateObj); - } - - @Override - public void closeRewardActivity(Long id) { - // 校验存在 - RewardActivityDO dbRewardActivity = validateRewardActivityExists(id); - if (dbRewardActivity.getStatus().equals(PromotionActivityStatusEnum.CLOSE.getStatus())) { // 已关闭的活动,不能关闭噢 - throw exception(REWARD_ACTIVITY_CLOSE_FAIL_STATUS_CLOSED); - } - if (dbRewardActivity.getStatus().equals(PromotionActivityStatusEnum.END.getStatus())) { // 已关闭的活动,不能关闭噢 - throw exception(REWARD_ACTIVITY_CLOSE_FAIL_STATUS_END); - } - - // 更新 - RewardActivityDO updateObj = new RewardActivityDO().setId(id).setStatus(PromotionActivityStatusEnum.CLOSE.getStatus()); - rewardActivityMapper.updateById(updateObj); - } - - @Override - public void deleteRewardActivity(Long id) { - // 校验存在 - RewardActivityDO dbRewardActivity = validateRewardActivityExists(id); - if (!dbRewardActivity.getStatus().equals(PromotionActivityStatusEnum.CLOSE.getStatus())) { // 未关闭的活动,不能删除噢 - throw exception(REWARD_ACTIVITY_DELETE_FAIL_STATUS_NOT_CLOSED); - } - - // 删除 - rewardActivityMapper.deleteById(id); - } - - private RewardActivityDO validateRewardActivityExists(Long id) { - RewardActivityDO activity = rewardActivityMapper.selectById(id); - if (activity == null) { - throw exception(REWARD_ACTIVITY_NOT_EXISTS); - } - return activity; - } - - /** - * 校验商品参加的活动是否冲突 - * - * @param id 活动编号 - * @param spuIds 商品 SPU 编号数组 - */ - private void validateRewardActivitySpuConflicts(Long id, Collection spuIds) { - if (CollUtil.isEmpty(spuIds)) { - return; - } - // 查询商品参加的活动 - List rewardActivityList = getRewardActivityListBySpuIds(spuIds, - asList(PromotionActivityStatusEnum.WAIT.getStatus(), PromotionActivityStatusEnum.RUN.getStatus())); - if (id != null) { // 排除自己这个活动 - rewardActivityList.removeIf(activity -> id.equals(activity.getId())); - } - // 如果非空,则说明冲突 - if (CollUtil.isNotEmpty(rewardActivityList)) { - throw exception(REWARD_ACTIVITY_SPU_CONFLICTS); - } - } - - /** - * 获得商品参加的满减送活动的数组 - * - * @param spuIds 商品 SPU 编号数组 - * @param statuses 活动状态数组 - * @return 商品参加的满减送活动的数组 - */ - private List getRewardActivityListBySpuIds(Collection spuIds, - Collection statuses) { - List list = rewardActivityMapper.selectListByStatus(statuses); - return CollUtil.filter(list, activity -> CollUtil.containsAny(activity.getProductSpuIds(), spuIds)); - } - - @Override - public RewardActivityDO getRewardActivity(Long id) { - return rewardActivityMapper.selectById(id); - } - - @Override - public PageResult getRewardActivityPage(RewardActivityPageReqVO pageReqVO) { - return rewardActivityMapper.selectPage(pageReqVO); - } - - @Override - public Map> getMatchRewardActivities(Set spuIds) { - // 如果有全局活动,则直接选择它 - List allActivities = rewardActivityMapper.selectListByProductScopeAndStatus( - PromotionProductScopeEnum.ALL.getScope(), PromotionActivityStatusEnum.RUN.getStatus()); - if (CollUtil.isNotEmpty(allActivities)) { - return MapUtil.builder(allActivities.get(0), spuIds).build(); - } - - // 查询某个活动参加的活动 - List productActivityList = getRewardActivityListBySpuIds(spuIds, - singleton(PromotionActivityStatusEnum.RUN.getStatus())); - return convertMap(productActivityList, activity -> activity, - rewardActivityDO -> intersectionDistinct(rewardActivityDO.getProductSpuIds(), spuIds)); // 求交集返回 - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/seckill/seckillactivity/SeckillActivityService.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/seckill/seckillactivity/SeckillActivityService.java deleted file mode 100644 index a0ff74dc8..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/seckill/seckillactivity/SeckillActivityService.java +++ /dev/null @@ -1,80 +0,0 @@ -package cn.iocoder.yudao.module.promotion.service.seckill.seckillactivity; - -import java.util.*; -import javax.validation.*; - -import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity.SeckillActivityCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity.SeckillActivityPageReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity.SeckillActivityUpdateReqVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.seckillactivity.SeckillActivityDO; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.seckillactivity.SeckillProductDO; - -/** - * 秒杀活动 Service 接口 - * - * @author halfninety - */ -public interface SeckillActivityService { - - /** - * 创建秒杀活动 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createSeckillActivity(@Valid SeckillActivityCreateReqVO createReqVO); - - /** - * 更新秒杀活动 - * - * @param updateReqVO 更新信息 - */ - void updateSeckillActivity(@Valid SeckillActivityUpdateReqVO updateReqVO); - - /** - * 关闭秒杀活动 - * - * @param id 编号 - */ - void closeSeckillActivity(Long id); - - /** - * 删除秒杀活动 - * - * @param id 编号 - */ - void deleteSeckillActivity(Long id); - - /** - * 获得秒杀活动 - * - * @param id 编号 - * @return 秒杀活动 - */ - SeckillActivityDO getSeckillActivity(Long id); - - /** - * 获得秒杀活动列表 - * - * @param ids 编号 - * @return 秒杀活动列表 - */ - List getSeckillActivityList(Collection ids); - - /** - * 获得秒杀活动分页 - * - * @param pageReqVO 分页查询 - * @return 秒杀活动分页 - */ - PageResult getSeckillActivityPage(SeckillActivityPageReqVO pageReqVO); - - /** - * 通过活动编号获取活动商品 - * - * @param id 活动编号 - * @return 活动商品列表 - */ - List getSeckillProductListByActivityId(Long id); -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/seckill/seckillactivity/SeckillActivityServiceImpl.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/seckill/seckillactivity/SeckillActivityServiceImpl.java deleted file mode 100644 index 45581d825..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/seckill/seckillactivity/SeckillActivityServiceImpl.java +++ /dev/null @@ -1,226 +0,0 @@ -package cn.iocoder.yudao.module.promotion.service.seckill.seckillactivity; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity.SeckillActivityBaseVO; -import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity.SeckillActivityCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity.SeckillActivityPageReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity.SeckillActivityUpdateReqVO; -import cn.iocoder.yudao.module.promotion.convert.seckill.seckillactivity.SeckillActivityConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.seckillactivity.SeckillActivityDO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.seckillactivity.SeckillProductDO; -import cn.iocoder.yudao.module.promotion.dal.mysql.seckill.seckillactivity.SeckillActivityMapper; -import cn.iocoder.yudao.module.promotion.dal.mysql.seckill.seckillactivity.SeckillProductMapper; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionActivityStatusEnum; -import cn.iocoder.yudao.module.promotion.service.seckill.seckilltime.SeckillTimeService; -import cn.iocoder.yudao.module.promotion.util.PromotionUtils; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.util.Collection; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.*; -import static java.util.Arrays.asList; - -/** - * 秒杀活动 Service 实现类 - * - * @author halfninety - */ -@Service -@Validated -public class SeckillActivityServiceImpl implements SeckillActivityService { - @Resource - private SeckillActivityMapper seckillActivityMapper; - @Resource - private SeckillProductMapper seckillProductMapper; - @Resource - private SeckillTimeService seckillTimeService; - - @Override - public Long createSeckillActivity(SeckillActivityCreateReqVO createReqVO) { - // 校验商品是否冲突 - validateSeckillActivityProductConflicts(null, createReqVO.getProducts()); - // 校验秒杀时段是否存在 - seckillTimeService.validateSeckillTimeExists(createReqVO.getTimeIds()); - - // 插入秒杀活动 - SeckillActivityDO seckillActivity = SeckillActivityConvert.INSTANCE.convert(createReqVO) - .setStatus(PromotionUtils.calculateActivityStatus(createReqVO.getStartTime(), createReqVO.getEndTime())); - seckillActivityMapper.insert(seckillActivity); - // 插入商品 - List productDOS = SeckillActivityConvert.INSTANCE.convertList(createReqVO.getProducts(), seckillActivity); - seckillProductMapper.insertBatch(productDOS); - // 更新秒杀时段的秒杀活动数量 - seckillTimeService.sekillActivityCountIncr(createReqVO.getTimeIds()); - return seckillActivity.getId(); - } - - @Override - public void updateSeckillActivity(SeckillActivityUpdateReqVO updateReqVO) { - // 校验存在 - SeckillActivityDO seckillActivity = validateSeckillActivityExists(updateReqVO.getId()); - if (PromotionActivityStatusEnum.CLOSE.getStatus().equals(seckillActivity.getStatus())) { - throw exception(SECKILL_ACTIVITY_UPDATE_FAIL_STATUS_CLOSED); - } - // 校验商品是否冲突 - validateSeckillActivityProductConflicts(updateReqVO.getId(), updateReqVO.getProducts()); - - // 更新活动 - SeckillActivityDO updateObj = SeckillActivityConvert.INSTANCE.convert(updateReqVO) - .setStatus(PromotionUtils.calculateActivityStatus(updateReqVO.getStartTime(), updateReqVO.getEndTime())); - seckillActivityMapper.updateById(updateObj); - // 更新商品 - updateSeckillProduct(updateReqVO); - // 更新秒杀时段的秒杀活动数量 - updateSeckillTimeActivityCount(seckillActivity, updateReqVO.getTimeIds()); - } - - - /** - * 更新秒杀时段的秒杀活动数量 - * - * @param seckillActivity 查询出的秒杀活动 - * @param updateTimeIds 更新后的秒杀时段id列表 - */ - private void updateSeckillTimeActivityCount(SeckillActivityDO seckillActivity, List updateTimeIds) { - // 查询出 timeIds - List existsTimeIds = seckillActivity.getTimeIds(); - // 需要减少的时间段 - Collection reduceIds = CollUtil.filterNew(existsTimeIds, existsTimeId -> !updateTimeIds.contains(existsTimeId)); - // 需要添加的时间段 - updateTimeIds.removeIf(existsTimeIds::contains); - // 更新减少时间段和增加时间段 - if (CollUtil.isNotEmpty(updateTimeIds)) { - seckillTimeService.sekillActivityCountIncr(updateTimeIds); - } - if (CollUtil.isNotEmpty(reduceIds)) { - seckillTimeService.sekillActivityCountDecr(reduceIds); - } - } - - /** - * 更新秒杀商品 - * 后台查出的数据和前台查出的数据进行遍历, - * 1. 对前台数据进行遍历:如果不存在于后台的 sku 中需要新增 - * 2. 对后台数据进行遍历:如果不存在于前台的 sku 中需要删除 - * 3. 最后对当前活动商品全部更新,更新秒杀时段id列表 - * - * @param updateReqVO 更新的请求VO - */ - private void updateSeckillProduct(SeckillActivityUpdateReqVO updateReqVO) { - List seckillProductDOS = seckillProductMapper.selectListByActivityId(updateReqVO.getId()); - List products = updateReqVO.getProducts(); - - // 计算需要删除的数据 - List deleteIds = CollectionUtils.convertList(seckillProductDOS, SeckillProductDO::getId, - seckillProductDO -> products.stream() - .noneMatch(product -> SeckillActivityConvert.INSTANCE.isEquals(seckillProductDO, product))); - if (CollUtil.isNotEmpty(deleteIds)) { - seckillProductMapper.deleteBatchIds(deleteIds); - } - - // 计算需要新增的数据 - List newSeckillProductDOs = CollectionUtils.convertList(products, - product -> SeckillActivityConvert.INSTANCE.convert(product).setActivityId(updateReqVO.getId())); - newSeckillProductDOs.removeIf(product -> seckillProductDOS.stream() - .anyMatch(seckillProduct -> SeckillActivityConvert.INSTANCE.isEquals(seckillProduct, product))); - if (CollUtil.isNotEmpty(newSeckillProductDOs)) { - seckillProductMapper.insertBatch(newSeckillProductDOs); - } - - //全量更新当前活动商品的秒杀时段id列表(timeIds) - seckillProductMapper.updateTimeIdsByActivityId(updateReqVO.getId(), updateReqVO.getTimeIds()); - } - - /** - * 校验商品是否冲突 - * - * @param id 秒杀活动编号 - * @param products 商品列表 - */ - private void validateSeckillActivityProductConflicts(Long id, List products) { - if (CollUtil.isEmpty(products)) { - return; - } - List seckillProductDOS = seckillProductMapper - .selectListBySkuIds(CollectionUtils.convertSet(products, SeckillActivityBaseVO.Product::getSkuId)); - if (CollUtil.isEmpty(seckillProductDOS)) { - return; - } - List seckillActivityDOS = seckillActivityMapper - .selectBatchIds(CollectionUtils.convertSet(seckillProductDOS, SeckillProductDO::getActivityId)); - if (id != null) { // 排除自己这个活动 - seckillActivityDOS.removeIf(item -> id.equals(item.getId())); - } - // 排除不满足 status 的活动 - List statuses = asList(PromotionActivityStatusEnum.WAIT.getStatus(), PromotionActivityStatusEnum.RUN.getStatus()); - seckillActivityDOS.removeIf(item -> !statuses.contains(item.getStatus())); - // 如果非空,则说明冲突 - if (CollUtil.isNotEmpty(seckillActivityDOS)) { - throw exception(SECKILL_ACTIVITY_SPU_CONFLICTS); - } - } - - @Override - public void closeSeckillActivity(Long id) { - // 校验存在 - SeckillActivityDO seckillActivity = this.validateSeckillActivityExists(id); - if (PromotionActivityStatusEnum.CLOSE.getStatus().equals(seckillActivity.getStatus())) { - throw exception(SECKILL_ACTIVITY_CLOSE_FAIL_STATUS_CLOSED); - } - if (PromotionActivityStatusEnum.END.getStatus().equals(seckillActivity.getStatus())) { - throw exception(SECKILL_ACTIVITY_CLOSE_FAIL_STATUS_END); - } - // 更新 - SeckillActivityDO updateObj = new SeckillActivityDO().setId(id).setStatus(PromotionActivityStatusEnum.CLOSE.getStatus()); - seckillActivityMapper.updateById(updateObj); - } - - @Override - public void deleteSeckillActivity(Long id) { - // 校验存在 - SeckillActivityDO seckillActivity = this.validateSeckillActivityExists(id); - List statuses = asList(PromotionActivityStatusEnum.CLOSE.getStatus(), PromotionActivityStatusEnum.END.getStatus()); - if (!statuses.contains(seckillActivity.getStatus())) { - throw exception(SECKILL_ACTIVITY_DELETE_FAIL_STATUS_NOT_CLOSED_OR_END); - } - // 更新秒杀时段的秒杀活动数量 - seckillTimeService.sekillActivityCountDecr(seckillActivity.getTimeIds()); - // 删除 - seckillActivityMapper.deleteById(id); - } - - private SeckillActivityDO validateSeckillActivityExists(Long id) { - SeckillActivityDO seckillActivity = seckillActivityMapper.selectById(id); - if (seckillActivity == null) { - throw exception(SECKILL_ACTIVITY_NOT_EXISTS); - } - return seckillActivity; - } - - @Override - public SeckillActivityDO getSeckillActivity(Long id) { - return seckillActivityMapper.selectById(id); - } - - @Override - public List getSeckillActivityList(Collection ids) { - return seckillActivityMapper.selectBatchIds(ids); - } - - @Override - public PageResult getSeckillActivityPage(SeckillActivityPageReqVO pageReqVO) { - return seckillActivityMapper.selectPage(pageReqVO); - } - - @Override - public List getSeckillProductListByActivityId(Long id) { - return seckillProductMapper.selectListByActivityId(id); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/seckill/seckilltime/SeckillTimeService.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/seckill/seckilltime/SeckillTimeService.java deleted file mode 100644 index 2e9c21249..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/seckill/seckilltime/SeckillTimeService.java +++ /dev/null @@ -1,76 +0,0 @@ -package cn.iocoder.yudao.module.promotion.service.seckill.seckilltime; - -import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.time.SeckillTimeCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.time.SeckillTimeUpdateReqVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.seckilltime.SeckillTimeDO; - -import javax.validation.Valid; -import java.util.Collection; -import java.util.List; - -/** - * 秒杀时段 Service 接口 - * - * @author halfninety - */ -public interface SeckillTimeService { - - /** - * 创建秒杀时段 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createSeckillTime(@Valid SeckillTimeCreateReqVO createReqVO); - - /** - * 更新秒杀时段 - * - * @param updateReqVO 更新信息 - */ - void updateSeckillTime(@Valid SeckillTimeUpdateReqVO updateReqVO); - - /** - * 删除秒杀时段 - * - * @param id 编号 - */ - void deleteSeckillTime(Long id); - - /** - * 获得秒杀时段 - * - * @param id 编号 - * @return 秒杀时段 - */ - SeckillTimeDO getSeckillTime(Long id); - - /** - * 获得所有秒杀时段列表 - * - * @return 所有秒杀时段列表 - */ - List getSeckillTimeList(); - - /** - * 校验秒杀时段是否存在 - * - * @param timeIds 秒杀时段id集合 - */ - void validateSeckillTimeExists(Collection timeIds); - - /** - * 秒杀时段列表的秒杀活动数量加 1 - * - * @param ids 秒杀时段id列表 - */ - void sekillActivityCountIncr(Collection ids); - - - /** - * 秒杀时段列表的秒杀活动数量减 1 - * - * @param ids 秒杀时段id列表 - */ - void sekillActivityCountDecr(Collection ids); -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/seckill/seckilltime/SeckillTimeServiceImpl.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/seckill/seckilltime/SeckillTimeServiceImpl.java deleted file mode 100644 index d38183860..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/seckill/seckilltime/SeckillTimeServiceImpl.java +++ /dev/null @@ -1,124 +0,0 @@ -package cn.iocoder.yudao.module.promotion.service.seckill.seckilltime; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.time.SeckillTimeCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.time.SeckillTimeUpdateReqVO; -import cn.iocoder.yudao.module.promotion.convert.seckill.seckilltime.SeckillTimeConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.seckilltime.SeckillTimeDO; -import cn.iocoder.yudao.module.promotion.dal.mysql.seckill.seckilltime.SeckillTimeMapper; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.time.LocalTime; -import java.util.Collection; -import java.util.List; -import java.util.Objects; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.SECKILL_TIME_CONFLICTS; -import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.SECKILL_TIME_NOT_EXISTS; - -/** - * 秒杀时段 Service 实现类 - * - * @author halfninety - */ -@Service -@Validated -public class SeckillTimeServiceImpl implements SeckillTimeService { - - @Resource - private SeckillTimeMapper seckillTimeMapper; - - @Override - public Long createSeckillTime(SeckillTimeCreateReqVO createReqVO) { - // 校验时间段是否冲突 - validateSeckillTimeConflict(null, createReqVO.getStartTime(), createReqVO.getEndTime()); - // 插入 - SeckillTimeDO seckillTime = SeckillTimeConvert.INSTANCE.convert(createReqVO); - seckillTimeMapper.insert(seckillTime); - // 返回 - return seckillTime.getId(); - } - - @Override - public void updateSeckillTime(SeckillTimeUpdateReqVO updateReqVO) { - // 校验存在 - this.validateSeckillTimeExists(updateReqVO.getId()); - // 校验时间段是否冲突 - validateSeckillTimeConflict(updateReqVO.getId(), updateReqVO.getStartTime(), updateReqVO.getEndTime()); - // 更新 - SeckillTimeDO updateObj = SeckillTimeConvert.INSTANCE.convert(updateReqVO); - seckillTimeMapper.updateById(updateObj); - } - - @Override - public void deleteSeckillTime(Long id) { - // 校验存在 - this.validateSeckillTimeExists(id); - // 删除 - seckillTimeMapper.deleteById(id); - } - - private void validateSeckillTimeExists(Long id) { - if (seckillTimeMapper.selectById(id) == null) { - throw exception(SECKILL_TIME_NOT_EXISTS); - } - } - - /** - * 校验时间是否存在冲突 - * - * @param startTime 开始时间 - * @param endTime 结束时间 - */ - private void validateSeckillTimeConflict(Long id, LocalTime startTime, LocalTime endTime) { - //查询开始时间,结束时间,是否在别人的时间段内 - List startTimeList = seckillTimeMapper.selectListByTime(startTime); - List endTimeList = seckillTimeMapper.selectListByTime(endTime); - //查询自己时间段内是否有时间段 - List startEndTimeList = seckillTimeMapper.selectListByTime(startTime, endTime); - if (id != null) { - //移除自己 - startTimeList.removeIf(seckillTime -> Objects.equals(seckillTime.getId(), id)); - endTimeList.removeIf(seckillTime -> Objects.equals(seckillTime.getId(), id)); - startEndTimeList.removeIf(seckillTime -> Objects.equals(seckillTime.getId(), id)); - } - if (CollUtil.isNotEmpty(startTimeList) || CollUtil.isNotEmpty(endTimeList) - || CollUtil.isNotEmpty(startEndTimeList)) { - throw exception(SECKILL_TIME_CONFLICTS); - } - } - - @Override - public SeckillTimeDO getSeckillTime(Long id) { - return seckillTimeMapper.selectById(id); - } - - @Override - public List getSeckillTimeList() { - return seckillTimeMapper.selectList(); - } - - @Override - public void validateSeckillTimeExists(Collection timeIds) { - if (CollUtil.isEmpty(timeIds)) { - throw exception(SECKILL_TIME_NOT_EXISTS); - } - if (seckillTimeMapper.selectBatchIds(timeIds).size() != timeIds.size()) { - throw exception(SECKILL_TIME_NOT_EXISTS); - } - } - - @Override - public void sekillActivityCountIncr(Collection ids) { - seckillTimeMapper.updateActivityCount(ids, "+", 1); - } - - @Override - public void sekillActivityCountDecr(Collection ids) { - seckillTimeMapper.updateActivityCount(ids, "-", 1); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/util/PromotionUtils.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/util/PromotionUtils.java deleted file mode 100644 index fc8ca16cf..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/util/PromotionUtils.java +++ /dev/null @@ -1,32 +0,0 @@ -package cn.iocoder.yudao.module.promotion.util; - -import cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionActivityStatusEnum; - -import java.time.LocalDateTime; - -/** - * 活动工具类 - * - * @author 芋道源码 - */ -public class PromotionUtils { - - /** - * 根据时间,计算活动状态 - * - * @param startTime 开始时间 - * @param endTime 结束时间 - * @return 活动状态 - */ - public static Integer calculateActivityStatus(LocalDateTime startTime, LocalDateTime endTime) { - if (LocalDateTimeUtils.beforeNow(endTime)) { - return PromotionActivityStatusEnum.END.getStatus(); - } - if (LocalDateTimeUtils.afterNow(startTime)) { - return PromotionActivityStatusEnum.WAIT.getStatus(); - } - return PromotionActivityStatusEnum.RUN.getStatus(); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/resources/mapper/coupon/CouponTemplateMapper.xml b/yudao-module-mall/yudao-module-promotion-biz/src/main/resources/mapper/coupon/CouponTemplateMapper.xml deleted file mode 100644 index 987143534..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/resources/mapper/coupon/CouponTemplateMapper.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - UPDATE promotion_coupon_template - SET take_count = take_count + #{incrCount} - WHERE id = #{id} - - - diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/test/java/cn/iocoder/yudao/module/promotion/service/coupon/CouponTemplateServiceImplTest.java b/yudao-module-mall/yudao-module-promotion-biz/src/test/java/cn/iocoder/yudao/module/promotion/service/coupon/CouponTemplateServiceImplTest.java deleted file mode 100755 index 5a41563e7..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/test/java/cn/iocoder/yudao/module/promotion/service/coupon/CouponTemplateServiceImplTest.java +++ /dev/null @@ -1,147 +0,0 @@ -package cn.iocoder.yudao.module.promotion.service.coupon; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.template.CouponTemplateCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.template.CouponTemplatePageReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.template.CouponTemplateUpdateReqVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.coupon.CouponTemplateDO; -import cn.iocoder.yudao.module.promotion.dal.mysql.coupon.CouponTemplateMapper; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionDiscountTypeEnum; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionProductScopeEnum; -import cn.iocoder.yudao.module.promotion.enums.coupon.CouponTemplateValidityTypeEnum; -import org.junit.jupiter.api.Test; -import org.springframework.context.annotation.Import; - -import javax.annotation.Resource; -import java.time.LocalDateTime; - -import static cn.hutool.core.util.RandomUtil.randomEle; -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildTime; -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomLongId; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; -import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.COUPON_TEMPLATE_NOT_EXISTS; -import static org.junit.jupiter.api.Assertions.*; - -/** -* {@link CouponTemplateServiceImpl} 的单元测试类 -* -* @author 芋道源码 -*/ -@Import(CouponTemplateServiceImpl.class) -public class CouponTemplateServiceImplTest extends BaseDbUnitTest { - - @Resource - private CouponTemplateServiceImpl couponTemplateService; - - @Resource - private CouponTemplateMapper couponTemplateMapper; - - @Test - public void testCreateCouponTemplate_success() { - // 准备参数 - CouponTemplateCreateReqVO reqVO = randomPojo(CouponTemplateCreateReqVO.class, - o -> o.setProductScope(randomEle(PromotionProductScopeEnum.values()).getScope()) - .setValidityType(randomEle(CouponTemplateValidityTypeEnum.values()).getType()) - .setDiscountType(randomEle(PromotionDiscountTypeEnum.values()).getType())); - - // 调用 - Long couponTemplateId = couponTemplateService.createCouponTemplate(reqVO); - // 断言 - assertNotNull(couponTemplateId); - // 校验记录的属性是否正确 - CouponTemplateDO couponTemplate = couponTemplateMapper.selectById(couponTemplateId); - assertPojoEquals(reqVO, couponTemplate); - } - - @Test - public void testUpdateCouponTemplate_success() { - // mock 数据 - CouponTemplateDO dbCouponTemplate = randomPojo(CouponTemplateDO.class); - couponTemplateMapper.insert(dbCouponTemplate);// @Sql: 先插入出一条存在的数据 - // 准备参数 - CouponTemplateUpdateReqVO reqVO = randomPojo(CouponTemplateUpdateReqVO.class, o -> { - o.setId(dbCouponTemplate.getId()); // 设置更新的 ID - // 其它通用字段 - o.setProductScope(randomEle(PromotionProductScopeEnum.values()).getScope()) - .setValidityType(randomEle(CouponTemplateValidityTypeEnum.values()).getType()) - .setDiscountType(randomEle(PromotionDiscountTypeEnum.values()).getType()); - }); - - // 调用 - couponTemplateService.updateCouponTemplate(reqVO); - // 校验是否更新正确 - CouponTemplateDO couponTemplate = couponTemplateMapper.selectById(reqVO.getId()); // 获取最新的 - assertPojoEquals(reqVO, couponTemplate); - } - - @Test - public void testUpdateCouponTemplate_notExists() { - // 准备参数 - CouponTemplateUpdateReqVO reqVO = randomPojo(CouponTemplateUpdateReqVO.class); - - // 调用, 并断言异常 - assertServiceException(() -> couponTemplateService.updateCouponTemplate(reqVO), COUPON_TEMPLATE_NOT_EXISTS); - } - - @Test - public void testDeleteCouponTemplate_success() { - // mock 数据 - CouponTemplateDO dbCouponTemplate = randomPojo(CouponTemplateDO.class); - couponTemplateMapper.insert(dbCouponTemplate);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbCouponTemplate.getId(); - - // 调用 - couponTemplateService.deleteCouponTemplate(id); - // 校验数据不存在了 - assertNull(couponTemplateMapper.selectById(id)); - } - - @Test - public void testDeleteCouponTemplate_notExists() { - // 准备参数 - Long id = randomLongId(); - - // 调用, 并断言异常 - assertServiceException(() -> couponTemplateService.deleteCouponTemplate(id), COUPON_TEMPLATE_NOT_EXISTS); - } - - @Test - public void testGetCouponTemplatePage() { - // mock 数据 - CouponTemplateDO dbCouponTemplate = randomPojo(CouponTemplateDO.class, o -> { // 等会查询到 - o.setName("芋艿"); - o.setStatus(CommonStatusEnum.ENABLE.getStatus()); - o.setDiscountType(PromotionDiscountTypeEnum.PERCENT.getType()); - o.setCreateTime(buildTime(2022, 2, 2)); - }); - couponTemplateMapper.insert(dbCouponTemplate); - // 测试 name 不匹配 - couponTemplateMapper.insert(cloneIgnoreId(dbCouponTemplate, o -> o.setName("土豆"))); - // 测试 status 不匹配 - couponTemplateMapper.insert(cloneIgnoreId(dbCouponTemplate, o -> o.setStatus(CommonStatusEnum.DISABLE.getStatus()))); - // 测试 type 不匹配 - couponTemplateMapper.insert(cloneIgnoreId(dbCouponTemplate, o -> o.setDiscountType(PromotionDiscountTypeEnum.PRICE.getType()))); - // 测试 createTime 不匹配 - couponTemplateMapper.insert(cloneIgnoreId(dbCouponTemplate, o -> o.setCreateTime(buildTime(2022, 1, 1)))); - // 准备参数 - CouponTemplatePageReqVO reqVO = new CouponTemplatePageReqVO(); - reqVO.setName("芋艿"); - reqVO.setStatus(CommonStatusEnum.ENABLE.getStatus()); - reqVO.setDiscountType(PromotionDiscountTypeEnum.PERCENT.getType()); - reqVO.setCreateTime((new LocalDateTime[]{buildTime(2022, 2, 1), buildTime(2022, 2, 3)})); - - // 调用 - PageResult pageResult = couponTemplateService.getCouponTemplatePage(reqVO); - // 断言 - assertEquals(1, pageResult.getTotal()); - assertEquals(1, pageResult.getList().size()); - assertPojoEquals(dbCouponTemplate, pageResult.getList().get(0)); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/test/java/cn/iocoder/yudao/module/promotion/service/discount/DiscountActivityServiceImplTest.java b/yudao-module-mall/yudao-module-promotion-biz/src/test/java/cn/iocoder/yudao/module/promotion/service/discount/DiscountActivityServiceImplTest.java deleted file mode 100755 index 5ad517463..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/test/java/cn/iocoder/yudao/module/promotion/service/discount/DiscountActivityServiceImplTest.java +++ /dev/null @@ -1,210 +0,0 @@ -package cn.iocoder.yudao.module.promotion.service.discount; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.module.promotion.controller.admin.discount.vo.DiscountActivityBaseVO; -import cn.iocoder.yudao.module.promotion.controller.admin.discount.vo.DiscountActivityCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.discount.vo.DiscountActivityPageReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.discount.vo.DiscountActivityUpdateReqVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.discount.DiscountActivityDO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.discount.DiscountProductDO; -import cn.iocoder.yudao.module.promotion.dal.mysql.discount.DiscountActivityMapper; -import cn.iocoder.yudao.module.promotion.dal.mysql.discount.DiscountProductMapper; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionActivityStatusEnum; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionDiscountTypeEnum; -import org.junit.jupiter.api.Test; -import org.springframework.context.annotation.Import; - -import javax.annotation.Resource; -import java.time.Duration; -import java.time.LocalDateTime; -import java.util.Date; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.addTime; -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildTime; -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomLongId; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; -import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.DISCOUNT_ACTIVITY_NOT_EXISTS; -import static java.util.Arrays.asList; -import static org.junit.jupiter.api.Assertions.*; - -/** -* {@link DiscountActivityServiceImpl} 的单元测试类 -* -* @author 芋道源码 -*/ -@Import(DiscountActivityServiceImpl.class) -public class DiscountActivityServiceImplTest extends BaseDbUnitTest { - - @Resource - private DiscountActivityServiceImpl discountActivityService; - - @Resource - private DiscountActivityMapper discountActivityMapper; - @Resource - private DiscountProductMapper discountProductMapper; - - @Test - public void testCreateDiscountActivity_success() { - // 准备参数 - DiscountActivityCreateReqVO reqVO = randomPojo(DiscountActivityCreateReqVO.class, o -> { - // 用于触发进行中的状态 - o.setStartTime(addTime(Duration.ofDays(1))).setEndTime(addTime(Duration.ofDays(2))); - // 设置商品 - o.setProducts(asList(new DiscountActivityBaseVO.Product().setSpuId(1L).setSkuId(2L) - .setDiscountType(PromotionDiscountTypeEnum.PRICE.getType()).setDiscountPrice(3), - new DiscountActivityBaseVO.Product().setSpuId(10L).setSkuId(20L) - .setDiscountType(PromotionDiscountTypeEnum.PERCENT.getType()).setDiscountPercent(30))); - }); - - // 调用 - Long discountActivityId = discountActivityService.createDiscountActivity(reqVO); - // 断言 - assertNotNull(discountActivityId); - // 校验活动 - DiscountActivityDO discountActivity = discountActivityMapper.selectById(discountActivityId); - assertPojoEquals(reqVO, discountActivity); - assertEquals(discountActivity.getStatus(), PromotionActivityStatusEnum.WAIT.getStatus()); - // 校验商品 - List discountProducts = discountProductMapper.selectList(DiscountProductDO::getActivityId, discountActivity.getId()); - assertEquals(discountProducts.size(), reqVO.getProducts().size()); - for (int i = 0; i < reqVO.getProducts().size(); i++) { - DiscountActivityBaseVO.Product product = reqVO.getProducts().get(i); - DiscountProductDO discountProduct = discountProducts.get(i); - assertEquals(discountProduct.getActivityId(), discountActivity.getId()); - assertEquals(discountProduct.getSpuId(), product.getSpuId()); - assertEquals(discountProduct.getSkuId(), product.getSkuId()); - assertEquals(discountProduct.getDiscountType(), product.getDiscountType()); - assertEquals(discountProduct.getDiscountPrice(), product.getDiscountPrice()); - assertEquals(discountProduct.getDiscountPercent(), product.getDiscountPercent()); - } - } - - @Test - public void testUpdateDiscountActivity_success() { - // mock 数据(商品) - DiscountActivityDO dbDiscountActivity = randomPojo(DiscountActivityDO.class); - discountActivityMapper.insert(dbDiscountActivity);// @Sql: 先插入出一条存在的数据 - // mock 数据(活动) - DiscountProductDO dbDiscountProduct01 = randomPojo(DiscountProductDO.class, o -> o.setActivityId(dbDiscountActivity.getId()) - .setSpuId(1L).setSkuId(2L).setDiscountType(PromotionDiscountTypeEnum.PRICE.getType()).setDiscountPrice(3).setDiscountPercent(null)); - DiscountProductDO dbDiscountProduct02 = randomPojo(DiscountProductDO.class, o -> o.setActivityId(dbDiscountActivity.getId()) - .setSpuId(10L).setSkuId(20L).setDiscountType(PromotionDiscountTypeEnum.PERCENT.getType()).setDiscountPercent(30).setDiscountPrice(null)); - discountProductMapper.insert(dbDiscountProduct01); - discountProductMapper.insert(dbDiscountProduct02); - // 准备参数 - DiscountActivityUpdateReqVO reqVO = randomPojo(DiscountActivityUpdateReqVO.class, o -> { - o.setId(dbDiscountActivity.getId()); // 设置更新的 ID - // 用于触发进行中的状态 - o.setStartTime(addTime(Duration.ofDays(1))).setEndTime(addTime(Duration.ofDays(2))); - // 设置商品 - o.setProducts(asList(new DiscountActivityBaseVO.Product().setSpuId(1L).setSkuId(2L) - .setDiscountType(PromotionDiscountTypeEnum.PRICE.getType()).setDiscountPrice(3).setDiscountPercent(null), - new DiscountActivityBaseVO.Product().setSpuId(100L).setSkuId(200L) - .setDiscountType(PromotionDiscountTypeEnum.PERCENT.getType()).setDiscountPercent(30).setDiscountPrice(null))); - }); - - // 调用 - discountActivityService.updateDiscountActivity(reqVO); - // 校验活动 - DiscountActivityDO discountActivity = discountActivityMapper.selectById(reqVO.getId()); // 获取最新的 - assertPojoEquals(reqVO, discountActivity); - assertEquals(discountActivity.getStatus(), PromotionActivityStatusEnum.WAIT.getStatus()); - // 校验商品 - List discountProducts = discountProductMapper.selectList(DiscountProductDO::getActivityId, discountActivity.getId()); - assertEquals(discountProducts.size(), reqVO.getProducts().size()); - for (int i = 0; i < reqVO.getProducts().size(); i++) { - DiscountActivityBaseVO.Product product = reqVO.getProducts().get(i); - DiscountProductDO discountProduct = discountProducts.get(i); - assertEquals(discountProduct.getActivityId(), discountActivity.getId()); - assertEquals(discountProduct.getSpuId(), product.getSpuId()); - assertEquals(discountProduct.getSkuId(), product.getSkuId()); - assertEquals(discountProduct.getDiscountType(), product.getDiscountType()); - assertEquals(discountProduct.getDiscountPrice(), product.getDiscountPrice()); - assertEquals(discountProduct.getDiscountPercent(), product.getDiscountPercent()); - } - } - - @Test - public void testCloseDiscountActivity() { - // mock 数据 - DiscountActivityDO dbDiscountActivity = randomPojo(DiscountActivityDO.class, - o -> o.setStatus(PromotionActivityStatusEnum.WAIT.getStatus())); - discountActivityMapper.insert(dbDiscountActivity);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbDiscountActivity.getId(); - - // 调用 - discountActivityService.closeRewardActivity(id); - // 校验状态 - DiscountActivityDO discountActivity = discountActivityMapper.selectById(id); - assertEquals(discountActivity.getStatus(), PromotionActivityStatusEnum.CLOSE.getStatus()); - } - - @Test - public void testUpdateDiscountActivity_notExists() { - // 准备参数 - DiscountActivityUpdateReqVO reqVO = randomPojo(DiscountActivityUpdateReqVO.class); - - // 调用, 并断言异常 - assertServiceException(() -> discountActivityService.updateDiscountActivity(reqVO), DISCOUNT_ACTIVITY_NOT_EXISTS); - } - - @Test - public void testDeleteDiscountActivity_success() { - // mock 数据 - DiscountActivityDO dbDiscountActivity = randomPojo(DiscountActivityDO.class, - o -> o.setStatus(PromotionActivityStatusEnum.CLOSE.getStatus())); - discountActivityMapper.insert(dbDiscountActivity);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbDiscountActivity.getId(); - - // 调用 - discountActivityService.deleteDiscountActivity(id); - // 校验数据不存在了 - assertNull(discountActivityMapper.selectById(id)); - } - - @Test - public void testDeleteDiscountActivity_notExists() { - // 准备参数 - Long id = randomLongId(); - - // 调用, 并断言异常 - assertServiceException(() -> discountActivityService.deleteDiscountActivity(id), DISCOUNT_ACTIVITY_NOT_EXISTS); - } - - @Test - public void testGetDiscountActivityPage() { - // mock 数据 - DiscountActivityDO dbDiscountActivity = randomPojo(DiscountActivityDO.class, o -> { // 等会查询到 - o.setName("芋艿"); - o.setStatus(PromotionActivityStatusEnum.WAIT.getStatus()); - o.setCreateTime(buildTime(2021, 1, 15)); - }); - discountActivityMapper.insert(dbDiscountActivity); - // 测试 name 不匹配 - discountActivityMapper.insert(cloneIgnoreId(dbDiscountActivity, o -> o.setName("土豆"))); - // 测试 status 不匹配 - discountActivityMapper.insert(cloneIgnoreId(dbDiscountActivity, o -> o.setStatus(PromotionActivityStatusEnum.END.getStatus()))); - // 测试 createTime 不匹配 - discountActivityMapper.insert(cloneIgnoreId(dbDiscountActivity, o -> o.setCreateTime(buildTime(2021, 2, 10)))); - // 准备参数 - DiscountActivityPageReqVO reqVO = new DiscountActivityPageReqVO(); - reqVO.setName("芋艿"); - reqVO.setStatus(PromotionActivityStatusEnum.WAIT.getStatus()); - reqVO.setCreateTime((new LocalDateTime[]{buildTime(2021, 1, 1), buildTime(2021, 1, 31)})); - - // 调用 - PageResult pageResult = discountActivityService.getDiscountActivityPage(reqVO); - // 断言 - assertEquals(1, pageResult.getTotal()); - assertEquals(1, pageResult.getList().size()); - assertPojoEquals(dbDiscountActivity, pageResult.getList().get(0)); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/test/java/cn/iocoder/yudao/module/promotion/service/price/PriceServiceTest.java b/yudao-module-mall/yudao-module-promotion-biz/src/test/java/cn/iocoder/yudao/module/promotion/service/price/PriceServiceTest.java deleted file mode 100644 index 0c7b2d6ec..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/test/java/cn/iocoder/yudao/module/promotion/service/price/PriceServiceTest.java +++ /dev/null @@ -1,506 +0,0 @@ -package cn.iocoder.yudao.module.promotion.service.price; - -import cn.hutool.core.map.MapUtil; -import cn.iocoder.yudao.framework.common.exception.ServiceException; -import cn.iocoder.yudao.framework.test.core.ut.BaseMockitoUnitTest; -import cn.iocoder.yudao.module.product.api.sku.ProductSkuApi; -import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuRespDTO; -import cn.iocoder.yudao.module.promotion.api.price.dto.CouponMeetRespDTO; -import cn.iocoder.yudao.module.promotion.api.price.dto.PriceCalculateReqDTO; -import cn.iocoder.yudao.module.promotion.api.price.dto.PriceCalculateRespDTO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.coupon.CouponDO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.reward.RewardActivityDO; -import cn.iocoder.yudao.module.promotion.enums.common.*; -import cn.iocoder.yudao.module.promotion.enums.coupon.CouponStatusEnum; -import cn.iocoder.yudao.module.promotion.service.coupon.CouponService; -import cn.iocoder.yudao.module.promotion.service.discount.DiscountActivityService; -import cn.iocoder.yudao.module.promotion.service.discount.bo.DiscountProductDetailBO; -import cn.iocoder.yudao.module.promotion.service.reward.RewardActivityService; -import org.junit.jupiter.api.Test; -import org.mockito.InjectMocks; -import org.mockito.Mock; - -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import static cn.iocoder.yudao.framework.common.util.collection.SetUtils.asSet; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomLongId; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; -import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.COUPON_VALID_TIME_NOT_NOW; -import static java.util.Arrays.asList; -import static java.util.Collections.singletonList; -import static org.junit.jupiter.api.Assertions.*; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.doThrow; -import static org.mockito.Mockito.when; - -/** - * {@link PriceServiceImpl} 的单元测试 - * - * @author 芋道源码 - */ -public class PriceServiceTest extends BaseMockitoUnitTest { - - @InjectMocks - private PriceServiceImpl priceService; - - @Mock - private DiscountActivityService discountService; - @Mock - private RewardActivityService rewardActivityService; - @Mock - private CouponService couponService; - @Mock - private ProductSkuApi productSkuApi; - - @Test - public void testCalculatePrice_memberDiscount() { - // 准备参数 - // TODO 芋艿:userId = 1,实现 9 折;后续改成 mock - PriceCalculateReqDTO calculateReqDTO = new PriceCalculateReqDTO().setUserId(1L) - .setItems(singletonList(new PriceCalculateReqDTO.Item().setSkuId(10L).setCount(2))); - // mock 方法(商品 SKU 信息) - ProductSkuRespDTO productSku = randomPojo(ProductSkuRespDTO.class, o -> o.setId(10L).setPrice(100)); - when(productSkuApi.getSkuList(eq(asSet(10L)))).thenReturn(singletonList(productSku)); - - // 调用 - PriceCalculateRespDTO priceCalculate = priceService.calculatePrice(calculateReqDTO); - // 断言 Order 部分 - PriceCalculateRespDTO.Order order = priceCalculate.getOrder(); - assertEquals(order.getOriginalPrice(), 200); - assertEquals(order.getOrderPrice(), 180); - assertEquals(order.getDiscountPrice(), 0); - assertEquals(order.getPointPrice(), 0); - assertEquals(order.getDeliveryPrice(), 0); - assertEquals(order.getPayPrice(), 180); - assertNull(order.getCouponId()); - // 断言 OrderItem 部分 - assertEquals(order.getItems().size(), 1); - PriceCalculateRespDTO.OrderItem orderItem = order.getItems().get(0); - assertEquals(orderItem.getSkuId(), 10L); - assertEquals(orderItem.getCount(), 2); - assertEquals(orderItem.getOriginalPrice(), 200); - assertEquals(orderItem.getOriginalUnitPrice(), 100); - assertEquals(orderItem.getDiscountPrice(), 20); - assertEquals(orderItem.getPayPrice(), 180); - assertEquals(orderItem.getOrderPartPrice(), 0); - assertEquals(orderItem.getOrderDividePrice(), 180); - // 断言 Promotion 部分 - assertEquals(priceCalculate.getPromotions().size(), 1); - PriceCalculateRespDTO.Promotion promotion = priceCalculate.getPromotions().get(0); - assertNull(promotion.getId()); - assertEquals(promotion.getName(), "会员折扣"); - assertEquals(promotion.getType(), PromotionTypeEnum.MEMBER.getType()); - assertEquals(promotion.getLevel(), PromotionLevelEnum.SKU.getLevel()); - assertEquals(promotion.getOriginalPrice(), 200); - assertEquals(promotion.getDiscountPrice(), 20); - assertTrue(promotion.getMeet()); - assertEquals(promotion.getMeetTip(), "会员折扣:省 0.20 元"); - PriceCalculateRespDTO.PromotionItem promotionItem = promotion.getItems().get(0); - assertEquals(promotion.getItems().size(), 1); - assertEquals(promotionItem.getSkuId(), 10L); - assertEquals(promotionItem.getOriginalPrice(), 200); - assertEquals(promotionItem.getDiscountPrice(), 20); - } - - @Test - public void testCalculatePrice_discountActivity() { - // 准备参数 - PriceCalculateReqDTO calculateReqDTO = new PriceCalculateReqDTO().setUserId(randomLongId()) - .setItems(asList(new PriceCalculateReqDTO.Item().setSkuId(10L).setCount(2), - new PriceCalculateReqDTO.Item().setSkuId(20L).setCount(3))); - // mock 方法(商品 SKU 信息) - ProductSkuRespDTO productSku01 = randomPojo(ProductSkuRespDTO.class, o -> o.setId(10L).setPrice(100)); - ProductSkuRespDTO productSku02 = randomPojo(ProductSkuRespDTO.class, o -> o.setId(20L).setPrice(50)); - when(productSkuApi.getSkuList(eq(asSet(10L, 20L)))).thenReturn(asList(productSku01, productSku02)); - // mock 方法(限时折扣 DiscountActivity 信息) - DiscountProductDetailBO discountProduct01 = randomPojo(DiscountProductDetailBO.class, o -> o.setActivityId(1000L) - .setActivityName("活动 1000 号").setSkuId(10L) - .setDiscountType(PromotionDiscountTypeEnum.PRICE.getType()).setDiscountPrice(40)); - DiscountProductDetailBO discountProduct02 = randomPojo(DiscountProductDetailBO.class, o -> o.setActivityId(2000L) - .setActivityName("活动 2000 号").setSkuId(20L) - .setDiscountType(PromotionDiscountTypeEnum.PERCENT.getType()).setDiscountPercent(60)); - when(discountService.getMatchDiscountProducts(eq(asSet(10L, 20L)))).thenReturn( - MapUtil.builder(10L, discountProduct01).put(20L, discountProduct02).map()); - - // 10L: 100 * 2 - 40 * 2 = 120 - // 20L:50 * 3 - 50 * 3 * 0.4 = 90 - - // 调用 - PriceCalculateRespDTO priceCalculate = priceService.calculatePrice(calculateReqDTO); - // 断言 Order 部分 - PriceCalculateRespDTO.Order order = priceCalculate.getOrder(); - assertEquals(order.getOriginalPrice(), 350); - assertEquals(order.getOrderPrice(), 210); - assertEquals(order.getDiscountPrice(), 0); - assertEquals(order.getPointPrice(), 0); - assertEquals(order.getDeliveryPrice(), 0); - assertEquals(order.getPayPrice(), 210); - assertNull(order.getCouponId()); - // 断言 OrderItem 部分 - assertEquals(order.getItems().size(), 2); - PriceCalculateRespDTO.OrderItem orderItem01 = order.getItems().get(0); - assertEquals(orderItem01.getSkuId(), 10L); - assertEquals(orderItem01.getCount(), 2); - assertEquals(orderItem01.getOriginalPrice(), 200); - assertEquals(orderItem01.getOriginalUnitPrice(), 100); - assertEquals(orderItem01.getDiscountPrice(), 80); - assertEquals(orderItem01.getPayPrice(), 120); - assertEquals(orderItem01.getOrderPartPrice(), 0); - assertEquals(orderItem01.getOrderDividePrice(), 120); - PriceCalculateRespDTO.OrderItem orderItem02 = order.getItems().get(1); - assertEquals(orderItem02.getSkuId(), 20L); - assertEquals(orderItem02.getCount(), 3); - assertEquals(orderItem02.getOriginalPrice(), 150); - assertEquals(orderItem02.getOriginalUnitPrice(), 50); - assertEquals(orderItem02.getDiscountPrice(), 60); - assertEquals(orderItem02.getPayPrice(), 90); - assertEquals(orderItem02.getOrderPartPrice(), 0); - assertEquals(orderItem02.getOrderDividePrice(), 90); - // 断言 Promotion 部分 - assertEquals(priceCalculate.getPromotions().size(), 2); - PriceCalculateRespDTO.Promotion promotion01 = priceCalculate.getPromotions().get(0); - assertEquals(promotion01.getId(), 1000L); - assertEquals(promotion01.getName(), "活动 1000 号"); - assertEquals(promotion01.getType(), PromotionTypeEnum.DISCOUNT_ACTIVITY.getType()); - assertEquals(promotion01.getLevel(), PromotionLevelEnum.SKU.getLevel()); - assertEquals(promotion01.getOriginalPrice(), 200); - assertEquals(promotion01.getDiscountPrice(), 80); - assertTrue(promotion01.getMeet()); - assertEquals(promotion01.getMeetTip(), "限时折扣:省 0.80 元"); - PriceCalculateRespDTO.PromotionItem promotionItem01 = promotion01.getItems().get(0); - assertEquals(promotion01.getItems().size(), 1); - assertEquals(promotionItem01.getSkuId(), 10L); - assertEquals(promotionItem01.getOriginalPrice(), 200); - assertEquals(promotionItem01.getDiscountPrice(), 80); - PriceCalculateRespDTO.Promotion promotion02 = priceCalculate.getPromotions().get(1); - assertEquals(promotion02.getId(), 2000L); - assertEquals(promotion02.getName(), "活动 2000 号"); - assertEquals(promotion02.getType(), PromotionTypeEnum.DISCOUNT_ACTIVITY.getType()); - assertEquals(promotion02.getLevel(), PromotionLevelEnum.SKU.getLevel()); - assertEquals(promotion02.getOriginalPrice(), 150); - assertEquals(promotion02.getDiscountPrice(), 60); - assertTrue(promotion02.getMeet()); - assertEquals(promotion02.getMeetTip(), "限时折扣:省 0.60 元"); - PriceCalculateRespDTO.PromotionItem promotionItem02 = promotion02.getItems().get(0); - assertEquals(promotion02.getItems().size(), 1); - assertEquals(promotionItem02.getSkuId(), 20L); - assertEquals(promotionItem02.getOriginalPrice(), 150); - assertEquals(promotionItem02.getDiscountPrice(), 60); - } - - /** - * 测试满减送活动,匹配的情况 - */ - @Test - public void testCalculatePrice_rewardActivity() { - // 准备参数 - PriceCalculateReqDTO calculateReqDTO = new PriceCalculateReqDTO().setUserId(randomLongId()) - .setItems(asList(new PriceCalculateReqDTO.Item().setSkuId(10L).setCount(2), - new PriceCalculateReqDTO.Item().setSkuId(20L).setCount(3), - new PriceCalculateReqDTO.Item().setSkuId(30L).setCount(4))); - // mock 方法(商品 SKU 信息) - ProductSkuRespDTO productSku01 = randomPojo(ProductSkuRespDTO.class, o -> o.setId(10L).setPrice(100).setSpuId(1L)); - ProductSkuRespDTO productSku02 = randomPojo(ProductSkuRespDTO.class, o -> o.setId(20L).setPrice(50).setSpuId(2L)); - ProductSkuRespDTO productSku03 = randomPojo(ProductSkuRespDTO.class, o -> o.setId(30L).setPrice(30).setSpuId(3L)); - when(productSkuApi.getSkuList(eq(asSet(10L, 20L, 30L)))).thenReturn(asList(productSku01, productSku02, productSku03)); - // mock 方法(限时折扣 DiscountActivity 信息) - RewardActivityDO rewardActivity01 = randomPojo(RewardActivityDO.class, o -> o.setId(1000L).setName("活动 1000 号") - .setProductSpuIds(asList(10L, 20L)).setConditionType(PromotionConditionTypeEnum.PRICE.getType()) - .setRules(singletonList(new RewardActivityDO.Rule().setLimit(200).setDiscountPrice(70)))); - RewardActivityDO rewardActivity02 = randomPojo(RewardActivityDO.class, o -> o.setId(2000L).setName("活动 2000 号") - .setProductSpuIds(singletonList(30L)).setConditionType(PromotionConditionTypeEnum.COUNT.getType()) - .setRules(asList(new RewardActivityDO.Rule().setLimit(1).setDiscountPrice(10), - new RewardActivityDO.Rule().setLimit(2).setDiscountPrice(60), // 最大可满足,因为是 4 个 - new RewardActivityDO.Rule().setLimit(10).setDiscountPrice(100)))); - Map> matchRewardActivities = new LinkedHashMap<>(); - matchRewardActivities.put(rewardActivity01, asSet(1L, 2L)); - matchRewardActivities.put(rewardActivity02, asSet(3L)); - when(rewardActivityService.getMatchRewardActivities(eq(asSet(1L, 2L, 3L)))).thenReturn(matchRewardActivities); - - // 调用 - PriceCalculateRespDTO priceCalculate = priceService.calculatePrice(calculateReqDTO); - // 断言 Order 部分 - PriceCalculateRespDTO.Order order = priceCalculate.getOrder(); - assertEquals(order.getOriginalPrice(), 470); - assertEquals(order.getOrderPrice(), 470); - assertEquals(order.getDiscountPrice(), 130); - assertEquals(order.getPointPrice(), 0); - assertEquals(order.getDeliveryPrice(), 0); - assertEquals(order.getPayPrice(), 340); - assertNull(order.getCouponId()); - // 断言 OrderItem 部分 - assertEquals(order.getItems().size(), 3); - PriceCalculateRespDTO.OrderItem orderItem01 = order.getItems().get(0); - assertEquals(orderItem01.getSkuId(), 10L); - assertEquals(orderItem01.getCount(), 2); - assertEquals(orderItem01.getOriginalPrice(), 200); - assertEquals(orderItem01.getOriginalUnitPrice(), 100); - assertEquals(orderItem01.getDiscountPrice(), 0); - assertEquals(orderItem01.getPayPrice(), 200); - assertEquals(orderItem01.getOrderPartPrice(), 40); - assertEquals(orderItem01.getOrderDividePrice(), 160); - PriceCalculateRespDTO.OrderItem orderItem02 = order.getItems().get(1); - assertEquals(orderItem02.getSkuId(), 20L); - assertEquals(orderItem02.getCount(), 3); - assertEquals(orderItem02.getOriginalPrice(), 150); - assertEquals(orderItem02.getOriginalUnitPrice(), 50); - assertEquals(orderItem02.getDiscountPrice(), 0); - assertEquals(orderItem02.getPayPrice(), 150); - assertEquals(orderItem02.getOrderPartPrice(), 30); - assertEquals(orderItem02.getOrderDividePrice(), 120); - PriceCalculateRespDTO.OrderItem orderItem03 = order.getItems().get(2); - assertEquals(orderItem03.getSkuId(), 30L); - assertEquals(orderItem03.getCount(), 4); - assertEquals(orderItem03.getOriginalPrice(), 120); - assertEquals(orderItem03.getOriginalUnitPrice(), 30); - assertEquals(orderItem03.getDiscountPrice(), 0); - assertEquals(orderItem03.getPayPrice(), 120); - assertEquals(orderItem03.getOrderPartPrice(), 60); - assertEquals(orderItem03.getOrderDividePrice(), 60); - // 断言 Promotion 部分(第一个) - assertEquals(priceCalculate.getPromotions().size(), 2); - PriceCalculateRespDTO.Promotion promotion01 = priceCalculate.getPromotions().get(0); - assertEquals(promotion01.getId(), 1000L); - assertEquals(promotion01.getName(), "活动 1000 号"); - assertEquals(promotion01.getType(), PromotionTypeEnum.REWARD_ACTIVITY.getType()); - assertEquals(promotion01.getLevel(), PromotionLevelEnum.ORDER.getLevel()); - assertEquals(promotion01.getOriginalPrice(), 350); - assertEquals(promotion01.getDiscountPrice(), 70); - assertTrue(promotion01.getMeet()); - assertEquals(promotion01.getMeetTip(), "满减送:省 0.70 元"); - assertEquals(promotion01.getItems().size(), 2); - PriceCalculateRespDTO.PromotionItem promotionItem011 = promotion01.getItems().get(0); - assertEquals(promotionItem011.getSkuId(), 10L); - assertEquals(promotionItem011.getOriginalPrice(), 200); - assertEquals(promotionItem011.getDiscountPrice(), 40); - PriceCalculateRespDTO.PromotionItem promotionItem012 = promotion01.getItems().get(1); - assertEquals(promotionItem012.getSkuId(), 20L); - assertEquals(promotionItem012.getOriginalPrice(), 150); - assertEquals(promotionItem012.getDiscountPrice(), 30); - // 断言 Promotion 部分(第二个) - PriceCalculateRespDTO.Promotion promotion02 = priceCalculate.getPromotions().get(1); - assertEquals(promotion02.getId(), 2000L); - assertEquals(promotion02.getName(), "活动 2000 号"); - assertEquals(promotion02.getType(), PromotionTypeEnum.REWARD_ACTIVITY.getType()); - assertEquals(promotion02.getLevel(), PromotionLevelEnum.ORDER.getLevel()); - assertEquals(promotion02.getOriginalPrice(), 120); - assertEquals(promotion02.getDiscountPrice(), 60); - assertTrue(promotion02.getMeet()); - assertEquals(promotion02.getMeetTip(), "满减送:省 0.60 元"); - PriceCalculateRespDTO.PromotionItem promotionItem02 = promotion02.getItems().get(0); - assertEquals(promotion02.getItems().size(), 1); - assertEquals(promotionItem02.getSkuId(), 30L); - assertEquals(promotionItem02.getOriginalPrice(), 120); - assertEquals(promotionItem02.getDiscountPrice(), 60); - } - - /** - * 测试满减送活动,不匹配的情况 - */ - @Test - public void testCalculatePrice_rewardActivityNotMeet() { - // 准备参数 - PriceCalculateReqDTO calculateReqDTO = new PriceCalculateReqDTO().setUserId(randomLongId()) - .setItems(asList(new PriceCalculateReqDTO.Item().setSkuId(10L).setCount(2), - new PriceCalculateReqDTO.Item().setSkuId(20L).setCount(3))); - // mock 方法(商品 SKU 信息) - ProductSkuRespDTO productSku01 = randomPojo(ProductSkuRespDTO.class, o -> o.setId(10L).setPrice(100).setSpuId(1L)); - ProductSkuRespDTO productSku02 = randomPojo(ProductSkuRespDTO.class, o -> o.setId(20L).setPrice(50).setSpuId(2L)); - when(productSkuApi.getSkuList(eq(asSet(10L, 20L)))).thenReturn(asList(productSku01, productSku02)); - // mock 方法(限时折扣 DiscountActivity 信息) - RewardActivityDO rewardActivity01 = randomPojo(RewardActivityDO.class, o -> o.setId(1000L).setName("活动 1000 号") - .setProductSpuIds(asList(10L, 20L)).setConditionType(PromotionConditionTypeEnum.PRICE.getType()) - .setRules(singletonList(new RewardActivityDO.Rule().setLimit(351).setDiscountPrice(70)))); - Map> matchRewardActivities = new LinkedHashMap<>(); - matchRewardActivities.put(rewardActivity01, asSet(1L, 2L)); - when(rewardActivityService.getMatchRewardActivities(eq(asSet(1L, 2L)))).thenReturn(matchRewardActivities); - - // 调用 - PriceCalculateRespDTO priceCalculate = priceService.calculatePrice(calculateReqDTO); - // 断言 Order 部分 - PriceCalculateRespDTO.Order order = priceCalculate.getOrder(); - assertEquals(order.getOriginalPrice(), 350); - assertEquals(order.getOrderPrice(), 350); - assertEquals(order.getDiscountPrice(), 0); - assertEquals(order.getPointPrice(), 0); - assertEquals(order.getDeliveryPrice(), 0); - assertEquals(order.getPayPrice(), 350); - assertNull(order.getCouponId()); - // 断言 OrderItem 部分 - assertEquals(order.getItems().size(), 2); - PriceCalculateRespDTO.OrderItem orderItem01 = order.getItems().get(0); - assertEquals(orderItem01.getSkuId(), 10L); - assertEquals(orderItem01.getCount(), 2); - assertEquals(orderItem01.getOriginalPrice(), 200); - assertEquals(orderItem01.getOriginalUnitPrice(), 100); - assertEquals(orderItem01.getDiscountPrice(), 0); - assertEquals(orderItem01.getPayPrice(), 200); - assertEquals(orderItem01.getOrderPartPrice(), 0); - assertEquals(orderItem01.getOrderDividePrice(), 200); - PriceCalculateRespDTO.OrderItem orderItem02 = order.getItems().get(1); - assertEquals(orderItem02.getSkuId(), 20L); - assertEquals(orderItem02.getCount(), 3); - assertEquals(orderItem02.getOriginalPrice(), 150); - assertEquals(orderItem02.getOriginalUnitPrice(), 50); - assertEquals(orderItem02.getDiscountPrice(), 0); - assertEquals(orderItem02.getPayPrice(), 150); - assertEquals(orderItem02.getOrderPartPrice(), 0); - assertEquals(orderItem02.getOrderDividePrice(), 150); - // 断言 Promotion 部分 - assertEquals(priceCalculate.getPromotions().size(), 1); - PriceCalculateRespDTO.Promotion promotion01 = priceCalculate.getPromotions().get(0); - assertEquals(promotion01.getId(), 1000L); - assertEquals(promotion01.getName(), "活动 1000 号"); - assertEquals(promotion01.getType(), PromotionTypeEnum.REWARD_ACTIVITY.getType()); - assertEquals(promotion01.getLevel(), PromotionLevelEnum.ORDER.getLevel()); - assertEquals(promotion01.getOriginalPrice(), 350); - assertEquals(promotion01.getDiscountPrice(), 0); - assertFalse(promotion01.getMeet()); - assertEquals(promotion01.getMeetTip(), "TODO"); // TODO 芋艿:后面再想想 - assertEquals(promotion01.getItems().size(), 2); - PriceCalculateRespDTO.PromotionItem promotionItem011 = promotion01.getItems().get(0); - assertEquals(promotionItem011.getSkuId(), 10L); - assertEquals(promotionItem011.getOriginalPrice(), 200); - assertEquals(promotionItem011.getDiscountPrice(), 0); - PriceCalculateRespDTO.PromotionItem promotionItem012 = promotion01.getItems().get(1); - assertEquals(promotionItem012.getSkuId(), 20L); - assertEquals(promotionItem012.getOriginalPrice(), 150); - assertEquals(promotionItem012.getDiscountPrice(), 0); - } - - @Test - public void testCalculatePrice_coupon() { - // 准备参数 - PriceCalculateReqDTO calculateReqDTO = new PriceCalculateReqDTO().setUserId(randomLongId()) - .setItems(asList(new PriceCalculateReqDTO.Item().setSkuId(10L).setCount(2), - new PriceCalculateReqDTO.Item().setSkuId(20L).setCount(3), - new PriceCalculateReqDTO.Item().setSkuId(30L).setCount(4))) - .setCouponId(1024L); - // mock 方法(商品 SKU 信息) - ProductSkuRespDTO productSku01 = randomPojo(ProductSkuRespDTO.class, o -> o.setId(10L).setPrice(100).setSpuId(1L)); - ProductSkuRespDTO productSku02 = randomPojo(ProductSkuRespDTO.class, o -> o.setId(20L).setPrice(50).setSpuId(2L)); - ProductSkuRespDTO productSku03 = randomPojo(ProductSkuRespDTO.class, o -> o.setId(30L).setPrice(30).setSpuId(3L)); - when(productSkuApi.getSkuList(eq(asSet(10L, 20L, 30L)))).thenReturn(asList(productSku01, productSku02, productSku03)); - // mock 方法(优惠劵 Coupon 信息) - CouponDO coupon = randomPojo(CouponDO.class, o -> o.setId(1024L).setName("程序员节") - .setProductScope(PromotionProductScopeEnum.SPU.getScope()).setProductSpuIds(asList(1L, 2L)) - .setUsePrice(350).setDiscountType(PromotionDiscountTypeEnum.PERCENT.getType()) - .setDiscountPercent(50).setDiscountLimitPrice(70)); - when(couponService.validCoupon(eq(1024L), eq(calculateReqDTO.getUserId()))).thenReturn(coupon); - - // 调用 - PriceCalculateRespDTO priceCalculate = priceService.calculatePrice(calculateReqDTO); - // 断言 Order 部分 - PriceCalculateRespDTO.Order order = priceCalculate.getOrder(); - assertEquals(order.getOriginalPrice(), 470); - assertEquals(order.getOrderPrice(), 470); - assertEquals(order.getDiscountPrice(), 0); - assertEquals(order.getPointPrice(), 0); - assertEquals(order.getDeliveryPrice(), 0); - assertEquals(order.getPayPrice(), 400); - assertEquals(order.getCouponId(), 1024L); - assertEquals(order.getCouponPrice(), 70); - // 断言 OrderItem 部分 - assertEquals(order.getItems().size(), 3); - PriceCalculateRespDTO.OrderItem orderItem01 = order.getItems().get(0); - assertEquals(orderItem01.getSkuId(), 10L); - assertEquals(orderItem01.getCount(), 2); - assertEquals(orderItem01.getOriginalPrice(), 200); - assertEquals(orderItem01.getOriginalUnitPrice(), 100); - assertEquals(orderItem01.getDiscountPrice(), 0); - assertEquals(orderItem01.getPayPrice(), 200); - assertEquals(orderItem01.getOrderPartPrice(), 40); - assertEquals(orderItem01.getOrderDividePrice(), 160); - PriceCalculateRespDTO.OrderItem orderItem02 = order.getItems().get(1); - assertEquals(orderItem02.getSkuId(), 20L); - assertEquals(orderItem02.getCount(), 3); - assertEquals(orderItem02.getOriginalPrice(), 150); - assertEquals(orderItem02.getOriginalUnitPrice(), 50); - assertEquals(orderItem02.getDiscountPrice(), 0); - assertEquals(orderItem02.getPayPrice(), 150); - assertEquals(orderItem02.getOrderPartPrice(), 30); - assertEquals(orderItem02.getOrderDividePrice(), 120); - PriceCalculateRespDTO.OrderItem orderItem03 = order.getItems().get(2); - assertEquals(orderItem03.getSkuId(), 30L); - assertEquals(orderItem03.getCount(), 4); - assertEquals(orderItem03.getOriginalPrice(), 120); - assertEquals(orderItem03.getOriginalUnitPrice(), 30); - assertEquals(orderItem03.getDiscountPrice(), 0); - assertEquals(orderItem03.getPayPrice(), 120); - assertEquals(orderItem03.getOrderPartPrice(), 0); - assertEquals(orderItem03.getOrderDividePrice(), 120); - // 断言 Promotion 部分 - assertEquals(priceCalculate.getPromotions().size(), 1); - PriceCalculateRespDTO.Promotion promotion01 = priceCalculate.getPromotions().get(0); - assertEquals(promotion01.getId(), 1024L); - assertEquals(promotion01.getName(), "程序员节"); - assertEquals(promotion01.getType(), PromotionTypeEnum.COUPON.getType()); - assertEquals(promotion01.getLevel(), PromotionLevelEnum.COUPON.getLevel()); - assertEquals(promotion01.getOriginalPrice(), 350); - assertEquals(promotion01.getDiscountPrice(), 70); - assertTrue(promotion01.getMeet()); - assertEquals(promotion01.getMeetTip(), "优惠劵:省 0.70 元"); - assertEquals(promotion01.getItems().size(), 2); - PriceCalculateRespDTO.PromotionItem promotionItem011 = promotion01.getItems().get(0); - assertEquals(promotionItem011.getSkuId(), 10L); - assertEquals(promotionItem011.getOriginalPrice(), 200); - assertEquals(promotionItem011.getDiscountPrice(), 40); - PriceCalculateRespDTO.PromotionItem promotionItem012 = promotion01.getItems().get(1); - assertEquals(promotionItem012.getSkuId(), 20L); - assertEquals(promotionItem012.getOriginalPrice(), 150); - assertEquals(promotionItem012.getDiscountPrice(), 30); - } - - @Test - public void testGetMeetCouponList() { - // 准备参数 - PriceCalculateReqDTO calculateReqDTO = new PriceCalculateReqDTO().setUserId(1024L) - .setItems(singletonList(new PriceCalculateReqDTO.Item().setSkuId(10L).setCount(2))); - // mock 方法(商品 SKU 信息) - ProductSkuRespDTO productSku = randomPojo(ProductSkuRespDTO.class, o -> o.setId(10L).setPrice(100)); - when(productSkuApi.getSkuList(eq(asSet(10L)))).thenReturn(singletonList(productSku)); - // mock 方法(情况一:优惠劵未到使用时间) - CouponDO coupon01 = randomPojo(CouponDO.class); - doThrow(new ServiceException(COUPON_VALID_TIME_NOT_NOW)).when(couponService).validCoupon(coupon01); - // mock 方法(情况二:所结算商品没有符合条件的商品) - CouponDO coupon02 = randomPojo(CouponDO.class); - // mock 方法(情况三:使用金额不足) - CouponDO coupon03 = randomPojo(CouponDO.class, o -> o.setProductScope(PromotionProductScopeEnum.ALL.getScope()) - .setUsePrice(300)); - // mock 方法(情况五:满足条件) - CouponDO coupon04 = randomPojo(CouponDO.class, o -> o.setProductScope(PromotionProductScopeEnum.ALL.getScope()) - .setUsePrice(190)); - // mock 方法(获得用户的待使用优惠劵) - when(couponService.getCouponList(eq(1024L), eq(CouponStatusEnum.UNUSED.getStatus()))) - .thenReturn(asList(coupon01, coupon02, coupon03, coupon04)); - // 调用 - List list = priceService.getMeetCouponList(calculateReqDTO); - // 断言 - assertEquals(list.size(), 4); - // 断言情况一:优惠劵未到使用时间 - CouponMeetRespDTO couponMeetRespDTO01 = list.get(0); - assertPojoEquals(couponMeetRespDTO01, coupon01); - assertFalse(couponMeetRespDTO01.getMeet()); - assertEquals(couponMeetRespDTO01.getMeetTip(), "优惠劵未到使用时间"); - // 断言情况二:所结算商品没有符合条件的商品 - CouponMeetRespDTO couponMeetRespDTO02 = list.get(1); - assertPojoEquals(couponMeetRespDTO02, coupon02); - assertFalse(couponMeetRespDTO02.getMeet()); - assertEquals(couponMeetRespDTO02.getMeetTip(), "所结算商品没有符合条件的商品"); - // 断言情况三:差 %s 元可用优惠劵 - CouponMeetRespDTO couponMeetRespDTO03 = list.get(2); - assertPojoEquals(couponMeetRespDTO03, coupon03); - assertFalse(couponMeetRespDTO03.getMeet()); - assertEquals(couponMeetRespDTO03.getMeetTip(), "所结算的商品中未满足使用的金额"); - // 断言情况四:满足条件 - CouponMeetRespDTO couponMeetRespDTO04 = list.get(3); - assertPojoEquals(couponMeetRespDTO04, coupon04); - assertTrue(couponMeetRespDTO04.getMeet()); - assertNull(couponMeetRespDTO04.getMeetTip()); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/test/java/cn/iocoder/yudao/module/promotion/service/reward/RewardActivityServiceImplTest.java b/yudao-module-mall/yudao-module-promotion-biz/src/test/java/cn/iocoder/yudao/module/promotion/service/reward/RewardActivityServiceImplTest.java deleted file mode 100755 index 9f9e28c07..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/test/java/cn/iocoder/yudao/module/promotion/service/reward/RewardActivityServiceImplTest.java +++ /dev/null @@ -1,218 +0,0 @@ -package cn.iocoder.yudao.module.promotion.service.reward; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.module.promotion.controller.admin.reward.vo.RewardActivityCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.reward.vo.RewardActivityPageReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.reward.vo.RewardActivityUpdateReqVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.reward.RewardActivityDO; -import cn.iocoder.yudao.module.promotion.dal.mysql.reward.RewardActivityMapper; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionActivityStatusEnum; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionConditionTypeEnum; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionProductScopeEnum; -import org.junit.jupiter.api.Test; -import org.springframework.context.annotation.Import; - -import javax.annotation.Resource; -import java.time.Duration; -import java.util.Map; -import java.util.Set; - -import static cn.hutool.core.util.RandomUtil.randomEle; -import static cn.iocoder.yudao.framework.common.util.collection.SetUtils.asSet; -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.addTime; -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomLongId; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; -import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.REWARD_ACTIVITY_NOT_EXISTS; -import static java.util.Arrays.asList; -import static java.util.Collections.singletonList; -import static org.junit.jupiter.api.Assertions.*; - -/** -* {@link RewardActivityServiceImpl} 的单元测试类 -* -* @author 芋道源码 -*/ -@Import(RewardActivityServiceImpl.class) -public class RewardActivityServiceImplTest extends BaseDbUnitTest { - - @Resource - private RewardActivityServiceImpl rewardActivityService; - - @Resource - private RewardActivityMapper rewardActivityMapper; - - @Test - public void testCreateRewardActivity_success() { - // 准备参数 - RewardActivityCreateReqVO reqVO = randomPojo(RewardActivityCreateReqVO.class, o -> { - o.setConditionType(randomEle(PromotionConditionTypeEnum.values()).getType()); - o.setProductScope(randomEle(PromotionProductScopeEnum.values()).getScope()); - // 用于触发进行中的状态 - o.setStartTime(addTime(Duration.ofDays(1))).setEndTime(addTime(Duration.ofDays(2))); - }); - - // 调用 - Long rewardActivityId = rewardActivityService.createRewardActivity(reqVO); - // 断言 - assertNotNull(rewardActivityId); - // 校验记录的属性是否正确 - RewardActivityDO rewardActivity = rewardActivityMapper.selectById(rewardActivityId); - assertPojoEquals(reqVO, rewardActivity, "rules"); - assertEquals(rewardActivity.getStatus(), PromotionActivityStatusEnum.WAIT.getStatus()); - for (int i = 0; i < reqVO.getRules().size(); i++) { - assertPojoEquals(reqVO.getRules().get(i), rewardActivity.getRules().get(i)); - } - } - - @Test - public void testUpdateRewardActivity_success() { - // mock 数据 - RewardActivityDO dbRewardActivity = randomPojo(RewardActivityDO.class, o -> o.setStatus(PromotionActivityStatusEnum.WAIT.getStatus())); - rewardActivityMapper.insert(dbRewardActivity);// @Sql: 先插入出一条存在的数据 - // 准备参数 - RewardActivityUpdateReqVO reqVO = randomPojo(RewardActivityUpdateReqVO.class, o -> { - o.setId(dbRewardActivity.getId()); // 设置更新的 ID - o.setConditionType(randomEle(PromotionConditionTypeEnum.values()).getType()); - o.setProductScope(randomEle(PromotionProductScopeEnum.values()).getScope()); - // 用于触发进行中的状态 - o.setStartTime(addTime(Duration.ofDays(1))).setEndTime(addTime(Duration.ofDays(2))); - }); - - // 调用 - rewardActivityService.updateRewardActivity(reqVO); - // 校验是否更新正确 - RewardActivityDO rewardActivity = rewardActivityMapper.selectById(reqVO.getId()); // 获取最新的 - assertPojoEquals(reqVO, rewardActivity, "rules"); - assertEquals(rewardActivity.getStatus(), PromotionActivityStatusEnum.WAIT.getStatus()); - for (int i = 0; i < reqVO.getRules().size(); i++) { - assertPojoEquals(reqVO.getRules().get(i), rewardActivity.getRules().get(i)); - } - } - - @Test - public void testCloseRewardActivity() { - // mock 数据 - RewardActivityDO dbRewardActivity = randomPojo(RewardActivityDO.class, o -> o.setStatus(PromotionActivityStatusEnum.WAIT.getStatus())); - rewardActivityMapper.insert(dbRewardActivity);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbRewardActivity.getId(); - - // 调用 - rewardActivityService.closeRewardActivity(id); - // 校验状态 - RewardActivityDO rewardActivity = rewardActivityMapper.selectById(id); - assertEquals(rewardActivity.getStatus(), PromotionActivityStatusEnum.CLOSE.getStatus()); - } - - @Test - public void testUpdateRewardActivity_notExists() { - // 准备参数 - RewardActivityUpdateReqVO reqVO = randomPojo(RewardActivityUpdateReqVO.class); - - // 调用, 并断言异常 - assertServiceException(() -> rewardActivityService.updateRewardActivity(reqVO), REWARD_ACTIVITY_NOT_EXISTS); - } - - @Test - public void testDeleteRewardActivity_success() { - // mock 数据 - RewardActivityDO dbRewardActivity = randomPojo(RewardActivityDO.class, o -> o.setStatus(PromotionActivityStatusEnum.CLOSE.getStatus())); - rewardActivityMapper.insert(dbRewardActivity);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbRewardActivity.getId(); - - // 调用 - rewardActivityService.deleteRewardActivity(id); - // 校验数据不存在了 - assertNull(rewardActivityMapper.selectById(id)); - } - - @Test - public void testDeleteRewardActivity_notExists() { - // 准备参数 - Long id = randomLongId(); - - // 调用, 并断言异常 - assertServiceException(() -> rewardActivityService.deleteRewardActivity(id), REWARD_ACTIVITY_NOT_EXISTS); - } - - @Test - public void testGetRewardActivityPage() { - // mock 数据 - RewardActivityDO dbRewardActivity = randomPojo(RewardActivityDO.class, o -> { // 等会查询到 - o.setName("芋艿"); - o.setStatus(PromotionActivityStatusEnum.CLOSE.getStatus()); - }); - rewardActivityMapper.insert(dbRewardActivity); - // 测试 name 不匹配 - rewardActivityMapper.insert(cloneIgnoreId(dbRewardActivity, o -> o.setName("土豆"))); - // 测试 status 不匹配 - rewardActivityMapper.insert(cloneIgnoreId(dbRewardActivity, o -> o.setStatus(PromotionActivityStatusEnum.RUN.getStatus()))); - // 准备参数 - RewardActivityPageReqVO reqVO = new RewardActivityPageReqVO(); - reqVO.setName("芋艿"); - reqVO.setStatus(PromotionActivityStatusEnum.CLOSE.getStatus()); - - // 调用 - PageResult pageResult = rewardActivityService.getRewardActivityPage(reqVO); - // 断言 - assertEquals(1, pageResult.getTotal()); - assertEquals(1, pageResult.getList().size()); - assertPojoEquals(dbRewardActivity, pageResult.getList().get(0), "rules"); - } - - @Test - public void testGetRewardActivities_all() { - // mock 数据 - RewardActivityDO allActivity = randomPojo(RewardActivityDO.class, o -> o.setStatus(PromotionActivityStatusEnum.RUN.getStatus()) - .setProductScope(PromotionProductScopeEnum.ALL.getScope())); - rewardActivityMapper.insert(allActivity); - RewardActivityDO productActivity = randomPojo(RewardActivityDO.class, o -> o.setStatus(PromotionActivityStatusEnum.RUN.getStatus()) - .setProductScope(PromotionProductScopeEnum.SPU.getScope()).setProductSpuIds(asList(1L, 2L))); - rewardActivityMapper.insert(productActivity); - // 准备参数 - Set spuIds = asSet(1L, 2L); - - // 调用 - Map> matchRewardActivities = rewardActivityService.getMatchRewardActivities(spuIds); - // 断言 - assertEquals(matchRewardActivities.size(), 1); - Map.Entry> next = matchRewardActivities.entrySet().iterator().next(); - assertPojoEquals(next.getKey(), allActivity); - assertEquals(next.getValue(), spuIds); - } - - @Test - public void testGetRewardActivities_product() { - // mock 数据 - RewardActivityDO productActivity01 = randomPojo(RewardActivityDO.class, o -> o.setStatus(PromotionActivityStatusEnum.RUN.getStatus()) - .setProductScope(PromotionProductScopeEnum.SPU.getScope()).setProductSpuIds(asList(1L, 2L))); - rewardActivityMapper.insert(productActivity01); - RewardActivityDO productActivity02 = randomPojo(RewardActivityDO.class, o -> o.setStatus(PromotionActivityStatusEnum.RUN.getStatus()) - .setProductScope(PromotionProductScopeEnum.SPU.getScope()).setProductSpuIds(singletonList(3L))); - rewardActivityMapper.insert(productActivity02); - // 准备参数 - Set spuIds = asSet(1L, 2L, 3L); - - // 调用 - Map> matchRewardActivities = rewardActivityService.getMatchRewardActivities(spuIds); - // 断言 - assertEquals(matchRewardActivities.size(), 2); - matchRewardActivities.forEach((activity, activitySpuIds) -> { - if (activity.getId().equals(productActivity01.getId())) { - assertPojoEquals(activity, productActivity01); - assertEquals(activitySpuIds, asSet(1L, 2L)); - } else if (activity.getId().equals(productActivity02.getId())) { - assertPojoEquals(activity, productActivity02); - assertEquals(activitySpuIds, asSet(3L)); - } else { - fail(); - } - }); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/test/java/cn/iocoder/yudao/module/promotion/service/seckillactivity/SeckillActivityServiceImplTest.java b/yudao-module-mall/yudao-module-promotion-biz/src/test/java/cn/iocoder/yudao/module/promotion/service/seckillactivity/SeckillActivityServiceImplTest.java deleted file mode 100644 index 853568077..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/test/java/cn/iocoder/yudao/module/promotion/service/seckillactivity/SeckillActivityServiceImplTest.java +++ /dev/null @@ -1,170 +0,0 @@ -package cn.iocoder.yudao.module.promotion.service.seckillactivity; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity.SeckillActivityCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity.SeckillActivityPageReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity.SeckillActivityUpdateReqVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.seckillactivity.SeckillActivityDO; -import cn.iocoder.yudao.module.promotion.dal.mysql.seckill.seckillactivity.SeckillActivityMapper; -import cn.iocoder.yudao.module.promotion.service.seckill.seckillactivity.SeckillActivityServiceImpl; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; -import org.springframework.context.annotation.Import; - -import javax.annotation.Resource; -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomLongId; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; -import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.SECKILL_ACTIVITY_NOT_EXISTS; -import static org.junit.jupiter.api.Assertions.*; - -/** -* {@link SeckillActivityServiceImpl} 的单元测试类 -* -* @author 芋道源码 -*/ -@Import(SeckillActivityServiceImpl.class) -public class SeckillActivityServiceImplTest extends BaseDbUnitTest { - - @Resource - private SeckillActivityServiceImpl seckillActivityService; - - @Resource - private SeckillActivityMapper seckillActivityMapper; - - @Test - public void testCreateSeckillActivity_success() { - // 准备参数 - SeckillActivityCreateReqVO reqVO = randomPojo(SeckillActivityCreateReqVO.class); - - // 调用 - Long seckillActivityId = seckillActivityService.createSeckillActivity(reqVO); - // 断言 - assertNotNull(seckillActivityId); - // 校验记录的属性是否正确 - SeckillActivityDO seckillActivity = seckillActivityMapper.selectById(seckillActivityId); - assertPojoEquals(reqVO, seckillActivity); - } - - @Test - public void testUpdateSeckillActivity_success() { - // mock 数据 - SeckillActivityDO dbSeckillActivity = randomPojo(SeckillActivityDO.class); - seckillActivityMapper.insert(dbSeckillActivity);// @Sql: 先插入出一条存在的数据 - // 准备参数 - SeckillActivityUpdateReqVO reqVO = randomPojo(SeckillActivityUpdateReqVO.class, o -> { - o.setId(dbSeckillActivity.getId()); // 设置更新的 ID - }); - - // 调用 - seckillActivityService.updateSeckillActivity(reqVO); - // 校验是否更新正确 - SeckillActivityDO seckillActivity = seckillActivityMapper.selectById(reqVO.getId()); // 获取最新的 - assertPojoEquals(reqVO, seckillActivity); - } - - @Test - public void testUpdateSeckillActivity_notExists() { - // 准备参数 - SeckillActivityUpdateReqVO reqVO = randomPojo(SeckillActivityUpdateReqVO.class); - - // 调用, 并断言异常 - assertServiceException(() -> seckillActivityService.updateSeckillActivity(reqVO), SECKILL_ACTIVITY_NOT_EXISTS); - } - - @Test - public void testDeleteSeckillActivity_success() { - // mock 数据 - SeckillActivityDO dbSeckillActivity = randomPojo(SeckillActivityDO.class); - seckillActivityMapper.insert(dbSeckillActivity);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbSeckillActivity.getId(); - - // 调用 - seckillActivityService.deleteSeckillActivity(id); - // 校验数据不存在了 - assertNull(seckillActivityMapper.selectById(id)); - } - - @Test - public void testDeleteSeckillActivity_notExists() { - // 准备参数 - Long id = randomLongId(); - - // 调用, 并断言异常 - assertServiceException(() -> seckillActivityService.deleteSeckillActivity(id), SECKILL_ACTIVITY_NOT_EXISTS); - } - - @Test - @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 - public void testGetSeckillActivityPage() { - // mock 数据 - SeckillActivityDO dbSeckillActivity = randomPojo(SeckillActivityDO.class, o -> { // 等会查询到 - o.setName(null); - o.setStatus(null); - o.setTimeIds(null); - o.setCreateTime(null); - }); - seckillActivityMapper.insert(dbSeckillActivity); - // 测试 name 不匹配 - seckillActivityMapper.insert(cloneIgnoreId(dbSeckillActivity, o -> o.setName(null))); - // 测试 status 不匹配 - seckillActivityMapper.insert(cloneIgnoreId(dbSeckillActivity, o -> o.setStatus(null))); - // 测试 timeId 不匹配 - seckillActivityMapper.insert(cloneIgnoreId(dbSeckillActivity, o -> o.setTimeIds(null))); - // 测试 createTime 不匹配 - seckillActivityMapper.insert(cloneIgnoreId(dbSeckillActivity, o -> o.setCreateTime(null))); - // 准备参数 - SeckillActivityPageReqVO reqVO = new SeckillActivityPageReqVO(); - reqVO.setName(null); - reqVO.setStatus(null); - reqVO.setTimeId(null); - reqVO.setCreateTime((new LocalDateTime[]{})); - - // 调用 - PageResult pageResult = seckillActivityService.getSeckillActivityPage(reqVO); - // 断言 - assertEquals(1, pageResult.getTotal()); - assertEquals(1, pageResult.getList().size()); - assertPojoEquals(dbSeckillActivity, pageResult.getList().get(0)); - } - - @Test - @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 - public void testGetSeckillActivityList() { - // mock 数据 - SeckillActivityDO dbSeckillActivity = randomPojo(SeckillActivityDO.class, o -> { // 等会查询到 - o.setName(null); - o.setStatus(null); - o.setTimeIds(null); - o.setCreateTime(null); - }); - seckillActivityMapper.insert(dbSeckillActivity); - // 测试 name 不匹配 - seckillActivityMapper.insert(cloneIgnoreId(dbSeckillActivity, o -> o.setName(null))); - // 测试 status 不匹配 - seckillActivityMapper.insert(cloneIgnoreId(dbSeckillActivity, o -> o.setStatus(null))); - // 测试 timeId 不匹配 - seckillActivityMapper.insert(cloneIgnoreId(dbSeckillActivity, o -> o.setTimeIds(null))); - // 测试 createTime 不匹配 - seckillActivityMapper.insert(cloneIgnoreId(dbSeckillActivity, o -> o.setCreateTime(null))); - // 准备参数 -// SeckillActivityExportReqVO reqVO = new SeckillActivityExportReqVO(); -// reqVO.setName(null); -// reqVO.setStatus(null); -// reqVO.setTimeId(null); -// reqVO.setCreateTime((new Date[]{})); -// -// // 调用 -// List list = seckillActivityService.getSeckillActivityList(reqVO); -// // 断言 -// assertEquals(1, list.size()); -// assertPojoEquals(dbSeckillActivity, list.get(0)); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/test/java/cn/iocoder/yudao/module/promotion/service/seckilltime/SeckillTimeServiceImplTest.java b/yudao-module-mall/yudao-module-promotion-biz/src/test/java/cn/iocoder/yudao/module/promotion/service/seckilltime/SeckillTimeServiceImplTest.java deleted file mode 100644 index e61023c66..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/test/java/cn/iocoder/yudao/module/promotion/service/seckilltime/SeckillTimeServiceImplTest.java +++ /dev/null @@ -1,189 +0,0 @@ -package cn.iocoder.yudao.module.promotion.service.seckilltime; - -import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.time.SeckillTimeCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.time.SeckillTimeUpdateReqVO; -import cn.iocoder.yudao.module.promotion.service.seckill.seckilltime.SeckillTimeServiceImpl; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; - -import javax.annotation.Resource; - -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; - -import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.seckilltime.SeckillTimeDO; -import cn.iocoder.yudao.module.promotion.dal.mysql.seckill.seckilltime.SeckillTimeMapper; - -import org.springframework.context.annotation.Import; - -import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.*; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.*; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.*; -import static org.junit.jupiter.api.Assertions.*; - -/** -* {@link SeckillTimeServiceImpl} 的单元测试类 -* -* @author 芋道源码 -*/ -@Import(SeckillTimeServiceImpl.class) -public class SeckillTimeServiceImplTest extends BaseDbUnitTest { - - @Resource - private SeckillTimeServiceImpl seckillTimeService; - - @Resource - private SeckillTimeMapper seckillTimeMapper; - - @Resource - private ObjectMapper objectMapper; - - @Test - public void testJacksonSerializ(){ - - // 准备参数 - SeckillTimeCreateReqVO reqVO = randomPojo(SeckillTimeCreateReqVO.class); -// ObjectMapper objectMapper = new ObjectMapper(); - try { - String string = objectMapper.writeValueAsString(reqVO); - System.out.println(string); - } catch (JsonProcessingException e) { - e.printStackTrace(); - } - - - } - - @Test - public void testCreateSeckillTime_success() { - // 准备参数 - SeckillTimeCreateReqVO reqVO = randomPojo(SeckillTimeCreateReqVO.class); - - // 调用 - Long seckillTimeId = seckillTimeService.createSeckillTime(reqVO); - // 断言 - assertNotNull(seckillTimeId); - // 校验记录的属性是否正确 - SeckillTimeDO seckillTime = seckillTimeMapper.selectById(seckillTimeId); - assertPojoEquals(reqVO, seckillTime); - } - - @Test - public void testUpdateSeckillTime_success() { - // mock 数据 - SeckillTimeDO dbSeckillTime = randomPojo(SeckillTimeDO.class); - seckillTimeMapper.insert(dbSeckillTime);// @Sql: 先插入出一条存在的数据 - // 准备参数 - SeckillTimeUpdateReqVO reqVO = randomPojo(SeckillTimeUpdateReqVO.class, o -> { - o.setId(dbSeckillTime.getId()); // 设置更新的 ID - }); - - // 调用 - seckillTimeService.updateSeckillTime(reqVO); - // 校验是否更新正确 - SeckillTimeDO seckillTime = seckillTimeMapper.selectById(reqVO.getId()); // 获取最新的 - assertPojoEquals(reqVO, seckillTime); - } - - @Test - public void testUpdateSeckillTime_notExists() { - // 准备参数 - SeckillTimeUpdateReqVO reqVO = randomPojo(SeckillTimeUpdateReqVO.class); - - // 调用, 并断言异常 - assertServiceException(() -> seckillTimeService.updateSeckillTime(reqVO), SECKILL_TIME_NOT_EXISTS); - } - - @Test - public void testDeleteSeckillTime_success() { - // mock 数据 - SeckillTimeDO dbSeckillTime = randomPojo(SeckillTimeDO.class); - seckillTimeMapper.insert(dbSeckillTime);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbSeckillTime.getId(); - - // 调用 - seckillTimeService.deleteSeckillTime(id); - // 校验数据不存在了 - assertNull(seckillTimeMapper.selectById(id)); - } - - @Test - public void testDeleteSeckillTime_notExists() { - // 准备参数 - Long id = randomLongId(); - - // 调用, 并断言异常 - assertServiceException(() -> seckillTimeService.deleteSeckillTime(id), SECKILL_TIME_NOT_EXISTS); - } - - @Test - @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 - public void testGetSeckillTimePage() { - // mock 数据 -// SeckillTimeDO dbSeckillTime = randomPojo(SeckillTimeDO.class, o -> { // 等会查询到 -// o.setName(null); -// o.setStartTime(null); -// o.setEndTime(null); -// o.setCreateTime(null); -// }); -// seckillTimeMapper.insert(dbSeckillTime); -// // 测试 name 不匹配 -// seckillTimeMapper.insert(cloneIgnoreId(dbSeckillTime, o -> o.setName(null))); -// // 测试 startTime 不匹配 -// seckillTimeMapper.insert(cloneIgnoreId(dbSeckillTime, o -> o.setStartTime(null))); -// // 测试 endTime 不匹配 -// seckillTimeMapper.insert(cloneIgnoreId(dbSeckillTime, o -> o.setEndTime(null))); -// // 测试 createTime 不匹配 -// seckillTimeMapper.insert(cloneIgnoreId(dbSeckillTime, o -> o.setCreateTime(null))); -// // 准备参数 -// SeckillTimePageReqVO reqVO = new SeckillTimePageReqVO(); -// reqVO.setName(null); -//// reqVO.setStartTime((new LocalTime())); -//// reqVO.setEndTime((new LocalTime[]{})); -//// reqVO.setCreateTime((new Date[]{})); -// -// // 调用 -// PageResult pageResult = seckillTimeService.getSeckillTimePage(reqVO); -// // 断言 -// assertEquals(1, pageResult.getTotal()); -// assertEquals(1, pageResult.getList().size()); -// assertPojoEquals(dbSeckillTime, pageResult.getList().get(0)); - } - - @Test - @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 - public void testGetSeckillTimeList() { - // mock 数据 - SeckillTimeDO dbSeckillTime = randomPojo(SeckillTimeDO.class, o -> { // 等会查询到 - o.setName(null); - o.setStartTime(null); - o.setEndTime(null); - o.setCreateTime(null); - }); - seckillTimeMapper.insert(dbSeckillTime); - // 测试 name 不匹配 - seckillTimeMapper.insert(cloneIgnoreId(dbSeckillTime, o -> o.setName(null))); - // 测试 startTime 不匹配 - seckillTimeMapper.insert(cloneIgnoreId(dbSeckillTime, o -> o.setStartTime(null))); - // 测试 endTime 不匹配 - seckillTimeMapper.insert(cloneIgnoreId(dbSeckillTime, o -> o.setEndTime(null))); - // 测试 createTime 不匹配 - seckillTimeMapper.insert(cloneIgnoreId(dbSeckillTime, o -> o.setCreateTime(null))); - // 准备参数 -// SeckillTimeExportReqVO reqVO = new SeckillTimeExportReqVO(); -// reqVO.setName(null); -// reqVO.setStartTime((new LocalTime[]{})); -// reqVO.setEndTime((new LocalTime[]{})); -// reqVO.setCreateTime((new Date[]{})); -// -// // 调用 -// List list = seckillTimeService.getSeckillTimeList(reqVO); -// // 断言 -// assertEquals(1, list.size()); -// assertPojoEquals(dbSeckillTime, list.get(0)); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/test/resources/application-unit-test.yaml b/yudao-module-mall/yudao-module-promotion-biz/src/test/resources/application-unit-test.yaml deleted file mode 100644 index a384353aa..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/test/resources/application-unit-test.yaml +++ /dev/null @@ -1,49 +0,0 @@ -spring: - main: - lazy-initialization: true # 开启懒加载,加快速度 - banner-mode: off # 单元测试,禁用 Banner - ---- #################### 数据库相关配置 #################### - -spring: - # 数据源配置项 - datasource: - name: ruoyi-vue-pro - url: jdbc:h2:mem:testdb;MODE=MYSQL;DATABASE_TO_UPPER=false;NON_KEYWORDS=value; # MODE 使用 MySQL 模式;DATABASE_TO_UPPER 配置表和字段使用小写 - driver-class-name: org.h2.Driver - username: sa - password: - druid: - async-init: true # 单元测试,异步初始化 Druid 连接池,提升启动速度 - initial-size: 1 # 单元测试,配置为 1,提升启动速度 - sql: - init: - schema-locations: classpath:/sql/create_tables.sql - - # Redis 配置。Redisson 默认的配置足够使用,一般不需要进行调优 - redis: - host: 127.0.0.1 # 地址 - port: 16379 # 端口(单元测试,使用 16379 端口) - database: 0 # 数据库索引 - -mybatis: - lazy-initialization: true # 单元测试,设置 MyBatis Mapper 延迟加载,加速每个单元测试 - ---- #################### 定时任务相关配置 #################### - ---- #################### 配置中心相关配置 #################### - ---- #################### 服务保障相关配置 #################### - -# Lock4j 配置项(单元测试,禁用 Lock4j) - -# Resilience4j 配置项 - ---- #################### 监控相关配置 #################### - ---- #################### 芋道相关配置 #################### - -# 芋道配置项,设置当前项目所有自定义的配置 -yudao: - info: - base-package: cn.iocoder.yudao.module diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/test/resources/logback.xml b/yudao-module-mall/yudao-module-promotion-biz/src/test/resources/logback.xml deleted file mode 100644 index daf756bff..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/test/resources/logback.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/test/resources/sql/clean.sql b/yudao-module-mall/yudao-module-promotion-biz/src/test/resources/sql/clean.sql deleted file mode 100644 index d3f8e3718..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/test/resources/sql/clean.sql +++ /dev/null @@ -1,6 +0,0 @@ -DELETE FROM "market_activity"; -DELETE FROM "promotion_coupon_template"; -DELETE FROM "promotion_coupon"; -DELETE FROM "promotion_reward_activity"; -DELETE FROM "promotion_discount_activity"; -DELETE FROM "promotion_discount_product"; diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/test/resources/sql/create_tables.sql b/yudao-module-mall/yudao-module-promotion-biz/src/test/resources/sql/create_tables.sql deleted file mode 100644 index 7ff1a7239..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/test/resources/sql/create_tables.sql +++ /dev/null @@ -1,124 +0,0 @@ -CREATE TABLE IF NOT EXISTS "market_activity" ( - "id" bigint(20) NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "title" varchar(50) NOT NULL, - "activity_type" tinyint(4) NOT NULL, - "status" tinyint(4) NOT NULL, - "start_time" datetime NOT NULL, - "end_time" datetime NOT NULL, - "invalid_time" datetime, - "delete_time" datetime, - "time_limited_discount" varchar(2000), - "full_privilege" varchar(2000), - "creator" varchar(64) DEFAULT '', - "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar(64) DEFAULT '', - "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - "tenant_id" bigint(20) NOT NULL, - PRIMARY KEY ("id") - ) COMMENT '促销活动'; - -CREATE TABLE IF NOT EXISTS "promotion_coupon_template" ( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "name" varchar NOT NULL, - "status" int NOT NULL, - "total_count" int NOT NULL, - "take_limit_count" int NOT NULL, - "take_type" int NOT NULL, - "use_price" int NOT NULL, - "product_scope" int NOT NULL, - "product_spu_ids" varchar, - "validity_type" int NOT NULL, - "valid_start_time" datetime, - "valid_end_time" datetime, - "fixed_start_term" int, - "fixed_end_term" int, - "discount_type" int NOT NULL, - "discount_percent" int, - "discount_price" int, - "discount_limit_price" int, - "take_count" int NOT NULL DEFAULT 0, - "use_count" int NOT NULL DEFAULT 0, - "creator" varchar DEFAULT '', - "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar DEFAULT '', - "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - PRIMARY KEY ("id") -) COMMENT '优惠劵模板'; - -CREATE TABLE IF NOT EXISTS "promotion_coupon" ( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "template_id" bigint NOT NULL, - "name" varchar NOT NULL, - "status" int NOT NULL, - "user_id" bigint NOT NULL, - "take_type" int NOT NULL, - "useprice" int NOT NULL, - "valid_start_time" datetime NOT NULL, - "valid_end_time" datetime NOT NULL, - "product_scope" int NOT NULL, - "product_spu_ids" varchar, - "discount_type" int NOT NULL, - "discount_percent" int, - "discount_price" int, - "discount_limit_price" int, - "use_order_id" bigint, - "use_time" datetime, - "creator" varchar DEFAULT '', - "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar DEFAULT '', - "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - PRIMARY KEY ("id") -) COMMENT '优惠劵'; - -CREATE TABLE IF NOT EXISTS "promotion_reward_activity" ( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "name" varchar NOT NULL, - "status" int NOT NULL, - "start_time" datetime NOT NULL, - "end_time" datetime NOT NULL, - "remark" varchar, - "condition_type" int NOT NULL, - "product_scope" int NOT NULL, - "product_spu_ids" varchar, - "rules" varchar, - "creator" varchar DEFAULT '', - "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar DEFAULT '', - "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - PRIMARY KEY ("id") -) COMMENT '满减送活动'; - -CREATE TABLE IF NOT EXISTS "promotion_discount_activity" ( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "name" varchar NOT NULL, - "status" int NOT NULL, - "start_time" datetime NOT NULL, - "end_time" datetime NOT NULL, - "remark" varchar, - "creator" varchar DEFAULT '', - "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar DEFAULT '', - "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - PRIMARY KEY ("id") -) COMMENT '限时折扣活动'; - -CREATE TABLE IF NOT EXISTS "promotion_discount_product" ( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "activity_id" bigint NOT NULL, - "spu_id" bigint NOT NULL, - "sku_id" bigint NOT NULL, - "discount_type" int NOT NULL, - "discount_percent" int, - "discount_price" int, - "creator" varchar DEFAULT '', - "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar DEFAULT '', - "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - PRIMARY KEY ("id") -) COMMENT '限时折扣活动'; diff --git a/yudao-module-mall/yudao-module-trade-api/pom.xml b/yudao-module-mall/yudao-module-trade-api/pom.xml deleted file mode 100644 index 1299ad11d..000000000 --- a/yudao-module-mall/yudao-module-trade-api/pom.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - cn.iocoder.boot - yudao-module-mall - ${revision} - - 4.0.0 - yudao-module-trade-api - jar - - ${project.artifactId} - - trade 模块 API,暴露给其它模块调用 - - - - - cn.iocoder.boot - yudao-common - - - - diff --git a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/ErrorCodeConstants.java b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/ErrorCodeConstants.java deleted file mode 100644 index af387ab85..000000000 --- a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/ErrorCodeConstants.java +++ /dev/null @@ -1,49 +0,0 @@ -package cn.iocoder.yudao.module.trade.enums; - -import cn.iocoder.yudao.framework.common.exception.ErrorCode; - -/** - * 交易 错误码枚举类 - * 交易系统,使用 1-011-000-000 段 - * - * @author LeeYan9 - * @since 2022-08-26 - */ -public interface ErrorCodeConstants { - - // ========== Order 模块 1-011-000-000 ========== - ErrorCode ORDER_CREATE_SKU_NOT_FOUND = new ErrorCode(1011000001, "商品 SKU 不存在"); - ErrorCode ORDER_CREATE_SPU_NOT_SALE = new ErrorCode(1011000002, "商品 SPU 不可售卖"); - ErrorCode ORDER_CREATE_SKU_NOT_SALE = new ErrorCode(1011000003, "商品 SKU 不可售卖"); - ErrorCode ORDER_CREATE_SKU_STOCK_NOT_ENOUGH = new ErrorCode(1011000004, "商品 SKU 库存不足"); - ErrorCode ORDER_CREATE_SPU_NOT_FOUND = new ErrorCode(1011000005, "商品 SPU 不可售卖"); - ErrorCode ORDER_CREATE_ADDRESS_NOT_FOUND = new ErrorCode(1011000006, "收货地址不存在"); - - ErrorCode ORDER_ITEM_NOT_FOUND = new ErrorCode(1011000010, "交易订单项不存在"); - ErrorCode ORDER_NOT_FOUND = new ErrorCode(1011000011, "交易订单不存在"); - ErrorCode ORDER_ITEM_UPDATE_AFTER_SALE_STATUS_FAIL = new ErrorCode(1011000012, "交易订单项更新售后状态失败,请重试"); - ErrorCode ORDER_UPDATE_PAID_STATUS_NOT_UNPAID = new ErrorCode(1011000013, "交易订单更新支付状态失败,订单不是【未支付】状态"); - ErrorCode ORDER_UPDATE_PAID_FAIL_PAY_ORDER_ID_ERROR = new ErrorCode(1011000014, "交易订单更新支付状态失败,支付单编号不匹配"); - ErrorCode ORDER_UPDATE_PAID_FAIL_PAY_ORDER_STATUS_NOT_SUCCESS = new ErrorCode(1011000015, "交易订单更新支付状态失败,支付单状态不是【支付成功】状态"); - ErrorCode ORDER_UPDATE_PAID_FAIL_PAY_PRICE_NOT_MATCH = new ErrorCode(1011000016, "交易订单更新支付状态失败,支付单金额不匹配"); - ErrorCode ORDER_DELIVERY_FAIL_STATUS_NOT_UNDELIVERED = new ErrorCode(1011000017, "交易订单发货失败,订单不是【待发货】状态"); - ErrorCode ORDER_RECEIVE_FAIL_STATUS_NOT_DELIVERED = new ErrorCode(1011000018, "交易订单收货失败,订单不是【待收货】状态"); - - // ========== After Sale 模块 1-011-000-000 ========== - ErrorCode AFTER_SALE_NOT_FOUND = new ErrorCode(1011000100, "售后单不存在"); - ErrorCode AFTER_SALE_CREATE_FAIL_REFUND_PRICE_ERROR = new ErrorCode(1011000101, "申请退款金额错误"); - ErrorCode AFTER_SALE_CREATE_FAIL_ORDER_STATUS_CANCELED = new ErrorCode(1011000102, "订单已关闭,无法申请售后"); - ErrorCode AFTER_SALE_CREATE_FAIL_ORDER_STATUS_NO_PAID = new ErrorCode(1011000103, "订单未支付,无法申请售后"); - ErrorCode AFTER_SALE_CREATE_FAIL_ORDER_STATUS_NO_DELIVERED = new ErrorCode(1011000104, "订单未发货,无法申请【退货退款】售后"); - ErrorCode AFTER_SALE_CREATE_FAIL_ORDER_ITEM_APPLIED = new ErrorCode(1011000105, "订单项已申请售后,无法重复申请"); - ErrorCode AFTER_SALE_AUDIT_FAIL_STATUS_NOT_APPLY = new ErrorCode(1011000106, "审批失败,售后状态不处于审批中"); - ErrorCode AFTER_SALE_UPDATE_STATUS_FAIL = new ErrorCode(1011000107, "操作售后单失败,请刷新后重试"); - ErrorCode AFTER_SALE_DELIVERY_FAIL_STATUS_NOT_SELLER_AGREE = new ErrorCode(1011000108, "退货失败,售后单状态不处于【待买家退货】"); - ErrorCode AFTER_SALE_CONFIRM_FAIL_STATUS_NOT_BUYER_DELIVERY = new ErrorCode(1011000109, "确认收货失败,售后单状态不处于【待确认收货】"); - ErrorCode AFTER_SALE_REFUND_FAIL_STATUS_NOT_WAIT_REFUND = new ErrorCode(1011000110, "退款失败,售后单状态不是【待退款】"); - ErrorCode AFTER_SALE_CANCEL_FAIL_STATUS_NOT_APPLY_OR_AGREE = new ErrorCode(1011000111, "取消售后单失败,售后单状态不是【待审核】或【卖家同意】"); - - // ========== Cart 模块 1-011-001-000 ========== - ErrorCode CARD_ITEM_NOT_FOUND = new ErrorCode(1011002000, "购物车项不存在"); - -} diff --git a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/aftersale/TradeAfterSaleStatusEnum.java b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/aftersale/TradeAfterSaleStatusEnum.java deleted file mode 100644 index 88ea5230c..000000000 --- a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/aftersale/TradeAfterSaleStatusEnum.java +++ /dev/null @@ -1,67 +0,0 @@ -package cn.iocoder.yudao.module.trade.enums.aftersale; - -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Arrays; - -import static cn.hutool.core.util.ArrayUtil.firstMatch; - -/** - * 售后状态的枚举 - * - * 状态流转 - * - * @author 芋道源码 - */ -@AllArgsConstructor -@Getter -public enum TradeAfterSaleStatusEnum implements IntArrayValuable { - - APPLY(10,"申请中", // 【申请售后】 - "会员申请退款"), - SELLER_AGREE(20, "卖家通过", // 卖家通过售后;【商品待退货】 - "商家同意退款"), - BUYER_DELIVERY(30,"待卖家收货", // 买家已退货,等待卖家收货;【商家待收货】 - "会员填写退货物流信息"), - WAIT_REFUND(40, "等待平台退款", // 卖家已收货,等待平台退款;等待退款【等待退款】 - "商家收货"), - COMPLETE(50, "完成", // 完成退款【退款成功】 - "商家确认退款"), - - BUYER_CANCEL(61, "买家取消售后", // 【买家取消】 - "会员取消退款"), - SELLER_DISAGREE(62,"卖家拒绝", // 卖家拒绝售后;商家拒绝【商家拒绝】 - "商家拒绝退款"), - SELLER_REFUSE(63,"卖家拒绝收货", // 卖家拒绝收货,终止售后;【商家拒收货】 - "商家拒绝收货"), - ; - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(TradeAfterSaleStatusEnum::getStatus).toArray(); - - /** - * 状态 - */ - private final Integer status; - /** - * 状态名 - */ - private final String name; - /** - * 操作内容 - * - * 目的:记录售后日志的内容 - */ - private final String content; - - @Override - public int[] array() { - return ARRAYS; - } - - public static TradeAfterSaleStatusEnum valueOf(Integer status) { - return firstMatch(value -> value.getStatus().equals(status), values()); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/aftersale/TradeAfterSaleTypeEnum.java b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/aftersale/TradeAfterSaleTypeEnum.java deleted file mode 100644 index d5323aac8..000000000 --- a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/aftersale/TradeAfterSaleTypeEnum.java +++ /dev/null @@ -1,37 +0,0 @@ -package cn.iocoder.yudao.module.trade.enums.aftersale; - -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.Getter; -import lombok.RequiredArgsConstructor; - -import java.util.Arrays; - -/** - * 交易售后 - 类型 - * - * @author 芋道源码 - */ -@RequiredArgsConstructor -@Getter -public enum TradeAfterSaleTypeEnum implements IntArrayValuable { - - IN_SALE(10, "售中退款"), // 交易完成前买家申请退款 - AFTER_SALE(20, "售后退款"); // 交易完成后买家申请退款 - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(TradeAfterSaleTypeEnum::getType).toArray(); - - /** - * 类型 - */ - private final Integer type; - /** - * 类型名 - */ - private final String name; - - @Override - public int[] array() { - return ARRAYS; - } - -} diff --git a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/aftersale/TradeAfterSaleWayEnum.java b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/aftersale/TradeAfterSaleWayEnum.java deleted file mode 100644 index 1bbb35327..000000000 --- a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/aftersale/TradeAfterSaleWayEnum.java +++ /dev/null @@ -1,37 +0,0 @@ -package cn.iocoder.yudao.module.trade.enums.aftersale; - -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.Getter; -import lombok.RequiredArgsConstructor; - -import java.util.Arrays; - -/** - * 交易售后 - 方式 - * - * @author Sin - */ -@RequiredArgsConstructor -@Getter -public enum TradeAfterSaleWayEnum implements IntArrayValuable { - - REFUND(10, "仅退款"), - RETURN_AND_REFUND(20, "退货退款"); - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(TradeAfterSaleWayEnum::getWay).toArray(); - - /** - * 方式 - */ - private final Integer way; - /** - * 方式名 - */ - private final String name; - - @Override - public int[] array() { - return ARRAYS; - } - -} diff --git a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/order/TradeOrderAfterSaleStatusEnum.java b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/order/TradeOrderAfterSaleStatusEnum.java deleted file mode 100644 index 40402b6f8..000000000 --- a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/order/TradeOrderAfterSaleStatusEnum.java +++ /dev/null @@ -1,38 +0,0 @@ -package cn.iocoder.yudao.module.trade.enums.order; - -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.Getter; -import lombok.RequiredArgsConstructor; - -import java.util.Arrays; - -/** - * 交易订单 - 售后状态 - * - * @author Sin - */ -@RequiredArgsConstructor -@Getter -public enum TradeOrderAfterSaleStatusEnum implements IntArrayValuable { - - NONE(0, "未退款"), - PART(1, "部分退款"), - ALL(2, "全部退款"); - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(TradeOrderAfterSaleStatusEnum::getStatus).toArray(); - - /** - * 状态值 - */ - private final Integer status; - /** - * 状态名 - */ - private final String name; - - @Override - public int[] array() { - return ARRAYS; - } - -} diff --git a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/order/TradeOrderCancelTypeEnum.java b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/order/TradeOrderCancelTypeEnum.java deleted file mode 100644 index 1dabec194..000000000 --- a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/order/TradeOrderCancelTypeEnum.java +++ /dev/null @@ -1,39 +0,0 @@ -package cn.iocoder.yudao.module.trade.enums.order; - -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.Getter; -import lombok.RequiredArgsConstructor; - -import java.util.Arrays; - -/** - * 交易订单 - 关闭类型 - * - * @author Sin - */ -@RequiredArgsConstructor -@Getter -public enum TradeOrderCancelTypeEnum implements IntArrayValuable { - - PAY_TIMEOUT(10, "超时未支付"), - AFTER_SALE_CLOSE(20, "退款关闭"), - MEMBER_CANCEL(30, "买家取消"), - PAY_ON_DELIVERY(40, "已通过货到付款交易"),; // TODO 芋艿:这个类型,是不是可以去掉 - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(TradeOrderCancelTypeEnum::getType).toArray(); - - /** - * 关闭类型 - */ - private final Integer type; - /** - * 关闭类型名 - */ - private final String name; - - @Override - public int[] array() { - return ARRAYS; - } - -} diff --git a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/order/TradeOrderDeliveryStatusEnum.java b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/order/TradeOrderDeliveryStatusEnum.java deleted file mode 100644 index 27b061e37..000000000 --- a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/order/TradeOrderDeliveryStatusEnum.java +++ /dev/null @@ -1,28 +0,0 @@ -package cn.iocoder.yudao.module.trade.enums.order; - -import lombok.Getter; -import lombok.RequiredArgsConstructor; - -/** - * 交易订单 - 发货状态 - * - * @author 芋道源码 - */ -@RequiredArgsConstructor -@Getter -public enum TradeOrderDeliveryStatusEnum { - - UNDELIVERED(0, "未发货"), - DELIVERED(1, "已发货"), - RECEIVED(2, "已收货"); - - /** - * 状态值 - */ - private final Integer status; - /** - * 状态名 - */ - private final String name; - -} diff --git a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/order/TradeOrderItemAfterSaleStatusEnum.java b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/order/TradeOrderItemAfterSaleStatusEnum.java deleted file mode 100644 index c4fc8a373..000000000 --- a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/order/TradeOrderItemAfterSaleStatusEnum.java +++ /dev/null @@ -1,52 +0,0 @@ -package cn.iocoder.yudao.module.trade.enums.order; - -import cn.hutool.core.util.ObjectUtil; -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.Getter; -import lombok.RequiredArgsConstructor; - -import java.util.Arrays; - -/** - * 交易订单项 - 售后状态 - * - * @author 芋道源码 - */ -@RequiredArgsConstructor -@Getter -public enum TradeOrderItemAfterSaleStatusEnum implements IntArrayValuable { - - NONE(0, "未售后"), - APPLY(1, "售后中"), - SUCCESS(2, "已退款"); - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(TradeOrderItemAfterSaleStatusEnum::getStatus).toArray(); - - /** - * 状态值 - */ - private final Integer status; - /** - * 状态名 - */ - private final String name; - - // TODO 芋艿:EXPIRED 已失效不允许申请售后 - // TODO 芋艿:PART_AFTER_SALE 部分售后 - - @Override - public int[] array() { - return ARRAYS; - } - - /** - * 判断指定状态,是否正处于【未申请】状态 - * - * @param status 指定状态 - * @return 是否 - */ - public static boolean isNone(Integer status) { - return ObjectUtil.equals(status, NONE.getStatus()); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/order/TradeOrderStatusEnum.java b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/order/TradeOrderStatusEnum.java deleted file mode 100644 index 06fc3821e..000000000 --- a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/order/TradeOrderStatusEnum.java +++ /dev/null @@ -1,118 +0,0 @@ -package cn.iocoder.yudao.module.trade.enums.order; - -import cn.hutool.core.util.ObjectUtil; -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import cn.iocoder.yudao.framework.common.util.object.ObjectUtils; -import lombok.Getter; -import lombok.RequiredArgsConstructor; - -import java.util.Arrays; - -/** - * 交易订单 - 状态 - * - * @author Sin - */ -@RequiredArgsConstructor -@Getter -public enum TradeOrderStatusEnum implements IntArrayValuable { - - UNPAID(0, "待支付"), - UNDELIVERED(10, "待发货"), - DELIVERED(20, "已发货"), - COMPLETED(30, "已完成"), - CANCELED(40, "已取消"); - - // TODO 芋艿: TAKE("待核验"):虚拟订单需要核验商品 - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(TradeOrderStatusEnum::getStatus).toArray(); - - /** - * 状态值 - */ - private final Integer status; - /** - * 状态名 - */ - private final String name; - - @Override - public int[] array() { - return ARRAYS; - } - - // ========== 问:为什么写了很多 isXXX 和 haveXXX 的判断逻辑呢? ========== - // ========== 答:方便找到某一类判断,哪些业务正在使用 ========== - - /** - * 判断指定状态,是否正处于【未付款】状态 - * - * @param status 指定状态 - * @return 是否 - */ - public static boolean isUnpaid(Integer status) { - return ObjectUtil.equal(UNPAID.getStatus(), status); - } - - /** - * 判断指定状态,是否正处于【待发货】状态 - * - * @param status 指定状态 - * @return 是否 - */ - public static boolean isUndelivered(Integer status) { - return ObjectUtil.equal(UNDELIVERED.getStatus(), status); - } - - /** - * 判断指定状态,是否正处于【已发货】状态 - * - * @param status 指定状态 - * @return 是否 - */ - public static boolean isDelivered(Integer status) { - return ObjectUtil.equals(status, DELIVERED.getStatus()); - } - - /** - * 判断指定状态,是否正处于【已取消】状态 - * - * @param status 指定状态 - * @return 是否 - */ - public static boolean isCanceled(Integer status) { - return ObjectUtil.equals(status, CANCELED.getStatus()); - } - - /** - * 判断指定状态,是否正处于【已完成】状态 - * - * @param status 指定状态 - * @return 是否 - */ - public static boolean isCompleted(Integer status) { - return ObjectUtil.equals(status, COMPLETED.getStatus()); - } - - /** - * 判断指定状态,是否有过【已付款】状态 - * - * @param status 指定状态 - * @return 是否 - */ - public static boolean havePaid(Integer status) { - return ObjectUtils.equalsAny(status, UNDELIVERED.getStatus(), - DELIVERED.getStatus(), COMPLETED.getStatus()); - } - - /** - * 判断指定状态,是否有过【已发货】状态 - * - * @param status 指定状态 - * @return 是否 - */ - public static boolean haveDelivered(Integer status) { - return ObjectUtils.equalsAny(status, DELIVERED.getStatus(), COMPLETED.getStatus()); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/order/TradeOrderTypeEnum.java b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/order/TradeOrderTypeEnum.java deleted file mode 100644 index c8001b490..000000000 --- a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/order/TradeOrderTypeEnum.java +++ /dev/null @@ -1,39 +0,0 @@ -package cn.iocoder.yudao.module.trade.enums.order; - -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.Getter; -import lombok.RequiredArgsConstructor; - -import java.util.Arrays; - -/** - * 交易订单 - 类型 - * - * @author Sin - */ -@RequiredArgsConstructor -@Getter -public enum TradeOrderTypeEnum implements IntArrayValuable { - - NORMAL(0, "普通订单"), - SECKILL(1, "秒杀订单"), - TEAM(2, "拼团订单"), - BARGAIN(3, "砍价订单"); - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(TradeOrderTypeEnum::getType).toArray(); - - /** - * 类型 - */ - private final Integer type; - /** - * 类型名 - */ - private final String name; - - @Override - public int[] array() { - return ARRAYS; - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/pom.xml b/yudao-module-mall/yudao-module-trade-biz/pom.xml deleted file mode 100644 index 4eb0164d4..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/pom.xml +++ /dev/null @@ -1,94 +0,0 @@ - - - - cn.iocoder.boot - yudao-module-mall - ${revision} - - 4.0.0 - yudao-module-trade-biz - jar - - ${project.artifactId} - - trade 模块,主要实现交易相关功能 - 例如:订单、退款、购物车等功能。 - - - - - cn.iocoder.boot - yudao-module-trade-api - ${revision} - - - - cn.iocoder.boot - yudao-module-product-api - ${revision} - - - cn.iocoder.boot - yudao-module-pay-api - ${revision} - - - cn.iocoder.boot - yudao-module-promotion-api - ${revision} - - - cn.iocoder.boot - yudao-module-member-api - ${revision} - - - - - cn.iocoder.boot - yudao-spring-boot-starter-biz-operatelog - - - cn.iocoder.boot - yudao-spring-boot-starter-biz-ip - - - - - cn.iocoder.boot - yudao-spring-boot-starter-web - - - - cn.iocoder.boot - yudao-spring-boot-starter-security - - - - - cn.iocoder.boot - yudao-spring-boot-starter-biz-pay - - - - - cn.iocoder.boot - yudao-spring-boot-starter-mybatis - - - - - cn.iocoder.boot - yudao-spring-boot-starter-test - - - - - cn.iocoder.boot - yudao-spring-boot-starter-excel - - - - diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/aftersale/TradeAfterSaleController.http b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/aftersale/TradeAfterSaleController.http deleted file mode 100644 index d1a2acaf7..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/aftersale/TradeAfterSaleController.http +++ /dev/null @@ -1,4 +0,0 @@ -### 获得交易售后分页 => 成功 -GET {{baseUrl}}/trade/after-sale/page?pageNo=1&pageSize=10 -Authorization: Bearer {{token}} -tenant-id: {{adminTenentId}} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/aftersale/TradeAfterSaleController.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/aftersale/TradeAfterSaleController.java deleted file mode 100644 index f2c7b1cc1..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/aftersale/TradeAfterSaleController.java +++ /dev/null @@ -1,113 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.aftersale; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.member.api.user.MemberUserApi; -import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; -import cn.iocoder.yudao.module.product.api.property.ProductPropertyValueApi; -import cn.iocoder.yudao.module.product.api.property.dto.ProductPropertyValueDetailRespDTO; -import cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo.TradeAfterSaleDisagreeReqVO; -import cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo.TradeAfterSalePageReqVO; -import cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo.TradeAfterSaleRefuseReqVO; -import cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo.TradeAfterSaleRespPageItemVO; -import cn.iocoder.yudao.module.trade.convert.aftersale.TradeAfterSaleConvert; -import cn.iocoder.yudao.module.trade.dal.dataobject.aftersale.TradeAfterSaleDO; -import cn.iocoder.yudao.module.trade.service.aftersale.TradeAfterSaleService; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiImplicitParam; -import io.swagger.annotations.ApiOperation; -import lombok.extern.slf4j.Slf4j; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.validation.Valid; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; -import static cn.iocoder.yudao.framework.common.util.servlet.ServletUtils.getClientIP; -import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; - -@Api(tags = "管理后台 - 交易售后") -@RestController -@RequestMapping("/trade/after-sale") -@Validated -@Slf4j -public class TradeAfterSaleController { - - @Resource - private TradeAfterSaleService afterSaleService; - - @Resource - private MemberUserApi memberUserApi; - @Resource - private ProductPropertyValueApi productPropertyValueApi; - - @GetMapping("/page") - @ApiOperation("获得交易售后分页") - @PreAuthorize("@ss.hasPermission('trade:after-sale:query')") - public CommonResult> getAfterSalePage(@Valid TradeAfterSalePageReqVO pageVO) { - // 查询售后 - PageResult pageResult = afterSaleService.getAfterSalePage(pageVO); - if (CollUtil.isEmpty(pageResult.getList())) { - return success(PageResult.empty()); - } - - // 查询商品属性 - List propertyValueDetails = productPropertyValueApi - .getPropertyValueDetailList(TradeAfterSaleConvert.INSTANCE.convertPropertyValueIds(pageResult.getList())); - // 查询会员 - Map memberUsers = memberUserApi.getUserMap( - convertSet(pageResult.getList(), TradeAfterSaleDO::getUserId)); - return success(TradeAfterSaleConvert.INSTANCE.convertPage(pageResult, memberUsers, propertyValueDetails)); - } - - @PutMapping("/agree") - @ApiOperation("同意售后") - @ApiImplicitParam(name = "id", value = "售后编号", required = true, example = "1") - @PreAuthorize("@ss.hasPermission('trade:after-sale:agree')") - public CommonResult agreeAfterSale(@RequestParam("id") Long id) { - afterSaleService.agreeAfterSale(getLoginUserId(), id); - return success(true); - } - - @PutMapping("/disagree") - @ApiOperation("拒绝售后") - @PreAuthorize("@ss.hasPermission('trade:after-sale:disagree')") - public CommonResult disagreeAfterSale(@RequestBody TradeAfterSaleDisagreeReqVO confirmReqVO) { - afterSaleService.disagreeAfterSale(getLoginUserId(), confirmReqVO); - return success(true); - } - - @PutMapping("/receive") - @ApiOperation("确认收货") - @ApiImplicitParam(name = "id", value = "售后编号", required = true, example = "1") - @PreAuthorize("@ss.hasPermission('trade:after-sale:receive')") - public CommonResult receiveAfterSale(@RequestParam("id") Long id) { - afterSaleService.receiveAfterSale(getLoginUserId(), id); - return success(true); - } - - @PutMapping("/refuse") - @ApiOperation("确认收货") - @ApiImplicitParam(name = "id", value = "售后编号", required = true, example = "1") - @PreAuthorize("@ss.hasPermission('trade:after-sale:receive')") - public CommonResult refuseAfterSale(TradeAfterSaleRefuseReqVO refuseReqVO) { - afterSaleService.refuseAfterSale(getLoginUserId(), refuseReqVO); - return success(true); - } - - @PostMapping("/refund") - @ApiOperation(value = "确认退款") - @ApiImplicitParam(name = "id", value = "售后编号", required = true, example = "1") - @PreAuthorize("@ss.hasPermission('trade:after-sale:refund')") - public CommonResult refundAfterSale(@RequestParam("id") Long id) { - afterSaleService.refundAfterSale(getLoginUserId(), getClientIP(), id); - return success(true); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/aftersale/vo/TradeAfterSaleBaseVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/aftersale/vo/TradeAfterSaleBaseVO.java deleted file mode 100644 index 4277fadd3..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/aftersale/vo/TradeAfterSaleBaseVO.java +++ /dev/null @@ -1,119 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo; - -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; -import org.springframework.format.annotation.DateTimeFormat; - -import javax.validation.constraints.NotNull; -import java.time.LocalDateTime; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -/** -* 交易售后 Base VO,提供给添加、修改、详细的子 VO 使用 -* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 -*/ -@Data -public class TradeAfterSaleBaseVO { - - @ApiModelProperty(value = "售后流水号", required = true, example = "202211190847450020500077") - @NotNull(message = "售后流水号不能为空") - private String no; - - @ApiModelProperty(value = "售后状态", required = true, example = "10", notes = "参见 TradeAfterSaleStatusEnum 枚举") - @NotNull(message = "售后状态不能为空") - private Integer status; - - @ApiModelProperty(value = "售后类型", required = true, example = "20", notes = "参见 TradeAfterSaleTypeEnum 枚举") - @NotNull(message = "售后类型不能为空") - private Integer type; - - @ApiModelProperty(value = "售后方式", required = true, example = "10", notes = "参见 TradeAfterSaleWayEnum 枚举") - @NotNull(message = "售后方式不能为空") - private Integer way; - - @ApiModelProperty(value = "用户编号", required = true, example = "30337") - @NotNull(message = "用户编号不能为空") - private Long userId; - - @ApiModelProperty(value = "申请原因", required = true, example = "不喜欢") - @NotNull(message = "申请原因不能为空") - private String applyReason; - - @ApiModelProperty(value = "补充描述", example = "你说的对") - private String applyDescription; - - @ApiModelProperty(value = "补充凭证图片", example = "https://www.iocoder.cn/1.png") - private List applyPicUrls; - - @ApiModelProperty(value = "订单编号", required = true, example = "18078") - @NotNull(message = "订单编号不能为空") - private Long orderId; - - @ApiModelProperty(value = "订单流水号", required = true, example = "2022111917190001") - @NotNull(message = "订单流水号不能为空") - private Long orderNo; - - @ApiModelProperty(value = "订单项编号", required = true, example = "572") - @NotNull(message = "订单项编号不能为空") - private Long orderItemId; - - @ApiModelProperty(value = "商品 SPU 编号", required = true, example = "2888") - @NotNull(message = "商品 SPU 编号不能为空") - private Long spuId; - - @ApiModelProperty(value = "商品 SPU 名称", required = true, example = "李四") - @NotNull(message = "商品 SPU 名称不能为空") - private String spuName; - - @ApiModelProperty(value = "商品 SKU 编号", required = true, example = "15657") - @NotNull(message = "商品 SKU 编号不能为空") - private Long skuId; - - @ApiModelProperty(value = "商品图片", example = "https://www.iocoder.cn/2.png") - private String picUrl; - - @ApiModelProperty(value = "购买数量", required = true, example = "20012") - @NotNull(message = "购买数量不能为空") - private Integer count; - - @ApiModelProperty(value = "审批时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime auditTime; - - @ApiModelProperty(value = "审批人", example = "30835") - private Long auditUserId; - - @ApiModelProperty(value = "审批备注", example = "不香") - private String auditReason; - - @ApiModelProperty(value = "退款金额,单位:分", required = true, example = "18077") - @NotNull(message = "退款金额,单位:分不能为空") - private Integer refundPrice; - - @ApiModelProperty(value = "支付退款编号", example = "10271") - private Long payRefundId; - - @ApiModelProperty(value = "退款时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime refundTime; - - @ApiModelProperty(value = "退货物流公司编号", example = "10") - private Long logisticsId; - - @ApiModelProperty(value = "退货物流单号", example = "610003952009") - private String logisticsNo; - - @ApiModelProperty(value = "退货时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime deliveryTime; - - @ApiModelProperty(value = "收货时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime receiveTime; - - @ApiModelProperty(value = "收货备注", example = "不喜欢") - private String receiveReason; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/aftersale/vo/TradeAfterSaleDisagreeReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/aftersale/vo/TradeAfterSaleDisagreeReqVO.java deleted file mode 100644 index 67baca3b7..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/aftersale/vo/TradeAfterSaleDisagreeReqVO.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; - -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; - -@ApiModel("管理后台 - 交易售后拒绝 Request VO") -@Data -public class TradeAfterSaleDisagreeReqVO { - - @ApiModelProperty(value = "售后编号", required = true, example = "1024") - @NotNull(message = "售后编号不能为空") - private Long id; - - @ApiModelProperty(value = "审批备注", required = true, example = "你猜") - @NotEmpty(message = "审批备注不能为空") - private String auditReason; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/aftersale/vo/TradeAfterSalePageReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/aftersale/vo/TradeAfterSalePageReqVO.java deleted file mode 100644 index 628b8bc56..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/aftersale/vo/TradeAfterSalePageReqVO.java +++ /dev/null @@ -1,50 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.module.trade.enums.aftersale.TradeAfterSaleStatusEnum; -import cn.iocoder.yudao.module.trade.enums.aftersale.TradeAfterSaleTypeEnum; -import cn.iocoder.yudao.module.trade.enums.aftersale.TradeAfterSaleWayEnum; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@ApiModel("管理后台 - 交易售后分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class TradeAfterSalePageReqVO extends PageParam { - - @ApiModelProperty(value = "售后流水号", example = "202211190847450020500077", notes = "模糊匹配") - private String no; - - @ApiModelProperty(value = "售后状态", example = "10", notes = "参见 TradeAfterSaleStatusEnum 枚举") - @InEnum(value = TradeAfterSaleStatusEnum.class, message = "售后状态必须是 {value}") - private Integer status; - - @ApiModelProperty(value = "售后类型", example = "20", notes = "参见 TradeAfterSaleTypeEnum 枚举") - @InEnum(value = TradeAfterSaleTypeEnum.class, message = "售后类型必须是 {value}") - private Integer type; - - @ApiModelProperty(value = "售后方式", example = "10", notes = "参见 TradeAfterSaleWayEnum 枚举") - @InEnum(value = TradeAfterSaleWayEnum.class, message = "售后方式必须是 {value}") - private Integer way; - - @ApiModelProperty(value = "订单编号", example = "18078", notes = "模糊匹配") - private String orderNo; - - @ApiModelProperty(value = "商品 SPU 名称", example = "李四", notes = "模糊匹配") - private String spuName; - - @ApiModelProperty(value = "创建时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] createTime; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/aftersale/vo/TradeAfterSaleRefuseReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/aftersale/vo/TradeAfterSaleRefuseReqVO.java deleted file mode 100644 index b74d73c7c..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/aftersale/vo/TradeAfterSaleRefuseReqVO.java +++ /dev/null @@ -1,21 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; - -import javax.validation.constraints.NotNull; - -@ApiModel("管理后台 - 交易售后拒绝收货 Request VO") -@Data -public class TradeAfterSaleRefuseReqVO { - - @ApiModelProperty(value = "售后编号", required = true, example = "1024") - @NotNull(message = "售后编号不能为空") - private Long id; - - @ApiModelProperty(value = "收货备注", required = true, example = "你猜") - @NotNull(message = "收货备注不能为空") - private String refuseMemo; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/aftersale/vo/TradeAfterSaleRespPageItemVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/aftersale/vo/TradeAfterSaleRespPageItemVO.java deleted file mode 100644 index f57676bdc..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/aftersale/vo/TradeAfterSaleRespPageItemVO.java +++ /dev/null @@ -1,36 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo; - -import cn.iocoder.yudao.module.trade.controller.admin.base.member.user.MemberUserRespVO; -import cn.iocoder.yudao.module.trade.controller.admin.base.product.property.ProductPropertyValueDetailRespVO; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.time.LocalDateTime; -import java.util.List; - -@ApiModel("管理后台 - 交易售后分页的每一条记录 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class TradeAfterSaleRespPageItemVO extends TradeAfterSaleBaseVO { - - @ApiModelProperty(value = "售后编号", required = true, example = "27630") - private Long id; - - @ApiModelProperty(value = "创建时间", required = true) - private LocalDateTime createTime; - - /** - * 商品属性数组 - */ - private List properties; - - /** - * 用户信息 - */ - private MemberUserRespVO user; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/aftersale/vo/log/TradeAfterSaleLogRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/aftersale/vo/log/TradeAfterSaleLogRespVO.java deleted file mode 100644 index 990182499..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/aftersale/vo/log/TradeAfterSaleLogRespVO.java +++ /dev/null @@ -1,51 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo.log; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; - -import javax.validation.constraints.NotNull; -import java.time.LocalDateTime; - -@ApiModel("管理后台 - 交易售后日志 Response VO") -@Data -public class TradeAfterSaleLogRespVO { - - @ApiModelProperty(value = "编号", required = true, example = "20669") - private Long id; - - @ApiModelProperty(value = "用户编号", required = true, example = "22634") - @NotNull(message = "用户编号不能为空") - private Long userId; - - @ApiModelProperty(value = "用户类型", required = true, example = "2") - @NotNull(message = "用户类型不能为空") - private Integer userType; - - @ApiModelProperty(value = "售后编号", required = true, example = "3023") - @NotNull(message = "售后编号不能为空") - private Long afterSaleId; - - @ApiModelProperty(value = "订单编号", required = true, example = "25870") - @NotNull(message = "订单编号不能为空") - private Long orderId; - - @ApiModelProperty(value = "订单项编号", required = true, example = "23154") - @NotNull(message = "订单项编号不能为空") - private Long orderItemId; - - @ApiModelProperty(value = "售后状态(之前)", example = "2", notes = "参见 TradeAfterSaleStatusEnum 枚举") - private Integer beforeStatus; - - @ApiModelProperty(value = "售后状态(之后)", required = true, example = "1", notes = "参见 TradeAfterSaleStatusEnum 枚举") - @NotNull(message = "售后状态(之后)不能为空") - private Integer afterStatus; - - @ApiModelProperty(value = "操作明细", required = true, example = "维权完成,退款金额:¥37776.00") - @NotNull(message = "操作明细不能为空") - private String content; - - @ApiModelProperty(value = "创建时间", required = true) - private LocalDateTime createTime; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/base/member/package-info.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/base/member/package-info.java deleted file mode 100644 index f874e482d..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/base/member/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 占位符,可忽略 - */ -package cn.iocoder.yudao.module.trade.controller.admin.base.member; diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/base/member/user/MemberUserRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/base/member/user/MemberUserRespVO.java deleted file mode 100644 index 4f3545a91..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/base/member/user/MemberUserRespVO.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.base.member.user; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; - -@ApiModel("管理后台 - 会员用户 Response VO") -@Data -public class MemberUserRespVO { - - @ApiModelProperty(value = "用户 ID", required = true, example = "1") - private Long id; - - @ApiModelProperty(value = "用户昵称", required = true, example = "芋道源码") - private String nickname; - - @ApiModelProperty(value = "用户头像", example = "https://www.iocoder.cn/xxx.png") - private String avatar; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/base/package-info.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/base/package-info.java deleted file mode 100644 index 0baa83e49..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/base/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 放置该模块通用的 VO 类 - */ -package cn.iocoder.yudao.module.trade.controller.admin.base; diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/base/product/property/ProductPropertyValueDetailRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/base/product/property/ProductPropertyValueDetailRespVO.java deleted file mode 100644 index b9978770c..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/base/product/property/ProductPropertyValueDetailRespVO.java +++ /dev/null @@ -1,23 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.base.product.property; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; - -@ApiModel("管理后台 - 商品属性值的明细 Response VO") -@Data -public class ProductPropertyValueDetailRespVO { - - @ApiModelProperty(value = "属性的编号", required = true, example = "1") - private Long propertyId; - - @ApiModelProperty(value = "属性的名称", required = true, example = "颜色") - private String propertyName; - - @ApiModelProperty(value = "属性值的编号", required = true, example = "1024") - private Long valueId; - - @ApiModelProperty(value = "属性值的名称", required = true, example = "红色") - private String valueName; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/TradeOrderController.http b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/TradeOrderController.http deleted file mode 100644 index 0bf8812b2..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/TradeOrderController.http +++ /dev/null @@ -1,9 +0,0 @@ -### 获得交易订单分页 => 成功 -GET {{baseUrl}}/trade/order/page?pageNo=1&pageSize=10 -Authorization: Bearer {{token}} -tenant-id: {{adminTenentId}} - -### 获得交易订单分页 => 成功 -GET {{baseUrl}}/trade/order/get-detail?id=21 -Authorization: Bearer {{token}} -tenant-id: {{adminTenentId}} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/TradeOrderController.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/TradeOrderController.java deleted file mode 100644 index 58f3bf318..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/TradeOrderController.java +++ /dev/null @@ -1,93 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.order; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.member.api.user.MemberUserApi; -import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; -import cn.iocoder.yudao.module.product.api.property.ProductPropertyValueApi; -import cn.iocoder.yudao.module.product.api.property.dto.ProductPropertyValueDetailRespDTO; -import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderDeliveryReqVO; -import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderDetailRespVO; -import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderPageItemRespVO; -import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderPageReqVO; -import cn.iocoder.yudao.module.trade.convert.order.TradeOrderConvert; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderItemDO; -import cn.iocoder.yudao.module.trade.service.order.TradeOrderService; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiImplicitParam; -import io.swagger.annotations.ApiOperation; -import lombok.extern.slf4j.Slf4j; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; -import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; - -@Api(tags = "管理后台 - 交易订单") -@RestController -@RequestMapping("/trade/order") -@Validated -@Slf4j -public class TradeOrderController { - - @Resource - private TradeOrderService tradeOrderService; - - @Resource - private ProductPropertyValueApi productPropertyValueApi; - @Resource - private MemberUserApi memberUserApi; - - @GetMapping("/page") - @ApiOperation("获得交易订单分页") - @PreAuthorize("@ss.hasPermission('trade:order:query')") - public CommonResult> getOrderPage(TradeOrderPageReqVO reqVO) { - // 查询订单 - PageResult pageResult = tradeOrderService.getOrderPage(reqVO); - if (CollUtil.isEmpty(pageResult.getList())) { - return success(PageResult.empty()); - } - // 查询订单项 - List orderItems = tradeOrderService.getOrderItemListByOrderId( - convertSet(pageResult.getList(), TradeOrderDO::getId)); - // 查询商品属性 - List propertyValueDetails = productPropertyValueApi - .getPropertyValueDetailList(TradeOrderConvert.INSTANCE.convertPropertyValueIds(orderItems)); - // 最终组合 - return success(TradeOrderConvert.INSTANCE.convertPage(pageResult, orderItems, propertyValueDetails)); - } - - @GetMapping("/get-detail") - @ApiOperation("获得交易订单详情") - @ApiImplicitParam(name = "id", value = "订单编号", required = true, example = "1") - @PreAuthorize("@ss.hasPermission('trade:order:query')") - public CommonResult getOrderDetail(@RequestParam("id") Long id) { - // 查询订单 - TradeOrderDO order = tradeOrderService.getOrder(id); - // 查询订单项 - List orderItems = tradeOrderService.getOrderItemListByOrderId(id); - // 查询商品属性 - List propertyValueDetails = productPropertyValueApi - .getPropertyValueDetailList(TradeOrderConvert.INSTANCE.convertPropertyValueIds(orderItems)); - // 查询会员 - MemberUserRespDTO user = memberUserApi.getUser(order.getUserId()); - // 最终组合 - return success(TradeOrderConvert.INSTANCE.convert(order, orderItems, propertyValueDetails, user)); - } - - @PostMapping("/delivery") - @ApiOperation("发货订单") - @PreAuthorize("@ss.hasPermission('trade:order:delivery')") - public CommonResult deliveryOrder(@RequestBody TradeOrderDeliveryReqVO deliveryReqVO) { - tradeOrderService.deliveryOrder(getLoginUserId(), deliveryReqVO); - return success(true); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderBaseVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderBaseVO.java deleted file mode 100755 index 1669bc1ff..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderBaseVO.java +++ /dev/null @@ -1,145 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.order.vo; - -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; - -import java.time.LocalDateTime; -import java.util.Date; - -/** -* 交易订单 Base VO,提供给添加、修改、详细的子 VO 使用 -* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 -*/ -@Data -public class TradeOrderBaseVO { - - // ========== 订单基本信息 ========== - - @ApiModelProperty(value = "订单编号", required = true, example = "1024") - private Long id; - - @ApiModelProperty(value = "订单流水号", required = true, example = "1146347329394184195") - private String no; - - @ApiModelProperty(value = "创建时间", required = true, notes = "下单时间") - private Date createTime; - - @ApiModelProperty(value = "订单类型", required = true, example = "1", notes = "参见 TradeOrderTypeEnum 枚举") - private Integer type; - - @ApiModelProperty(value = "订单来源", required = true, example = "1", notes = "参见 TerminalEnum 枚举") - private Integer terminal; - - @ApiModelProperty(value = "用户编号", required = true, example = "2048") - private Long userId; - - @ApiModelProperty(value = "用户 IP", required = true, example = "127.0.0.1") - private String userIp; - - @ApiModelProperty(value = "用户备注", required = true, example = "你猜") - private String userRemark; - - @ApiModelProperty(value = "订单状态", required = true, example = "1", notes = "参见 TradeOrderStatusEnum 枚举") - private Integer status; - - @ApiModelProperty(value = "购买的商品数量", required = true, example = "10") - private Integer productCount; - - @ApiModelProperty(value = "订单完成时间") - private LocalDateTime finishTime; - - @ApiModelProperty(value = "订单取消时间") - private LocalDateTime cancelTime; - - @ApiModelProperty(value = "取消类型", example = "10", notes = "参见 TradeOrderCancelTypeEnum 枚举") - private Integer cancelType; - - @ApiModelProperty(value = "商家备注", example = "你猜一下") - private String remark; - - // ========== 价格 + 支付基本信息 ========== - - @ApiModelProperty(value = "支付订单编号", required = true, example = "1024") - private Long payOrderId; - - @ApiModelProperty(value = "是否已支付", required = true, example = "true") - private Boolean payed; - - @ApiModelProperty(value = "付款时间") - private LocalDateTime payTime; - - @ApiModelProperty(value = "支付渠道", required = true, example = "wx_lite", notes = "参见 PayChannelEnum 枚举") - private String payChannelCode; - - @ApiModelProperty(value = "商品原价(总)", required = true, example = "1000", notes = "单位:分") - private Integer originalPrice; - - @ApiModelProperty(value = "订单原价(总)", required = true, example = "1000", notes = "单位:分") - private Integer orderPrice; - - @ApiModelProperty(value = "订单优惠(总)", required = true, example = "100", notes = "单位:分") - private Integer discountPrice; - - @ApiModelProperty(value = "运费金额", required = true, example = "100", notes = "单位:分") - private Integer deliveryPrice; - - @ApiModelProperty(value = "订单调价(总)", required = true, example = "100", notes = "单位:分") - private Integer adjustPrice; - - @ApiModelProperty(value = "应付金额(总)", required = true, example = "1000", notes = "单位:分") - private Integer payPrice; - - // ========== 收件 + 物流基本信息 ========== - - @ApiModelProperty(value = "配送模板编号", example = "1024") - private Long deliveryTemplateId; - - @ApiModelProperty(value = "发货物流公司编号", example = "1024") - private Long logisticsId; - - @ApiModelProperty(value = "发货物流单号", example = "1024") - private String logisticsNo; - - @ApiModelProperty(value = "发货状态", required = true, example = "1", notes = "参见 TradeOrderDeliveryStatusEnum 枚举") - private Integer deliveryStatus; - - @ApiModelProperty(value = "发货时间") - private LocalDateTime deliveryTime; - - @ApiModelProperty(value = "收货时间") - private LocalDateTime receiveTime; - - @ApiModelProperty(value = "收件人名称", required = true, example = "张三") - private String receiverName; - - @ApiModelProperty(value = "收件人手机", required = true, example = "13800138000") - private String receiverMobile; - - @ApiModelProperty(value = "收件人地区编号", required = true, example = "110000") - private Integer receiverAreaId; - - @ApiModelProperty(value = "收件人邮编", required = true, example = "100000") - private Integer receiverPostCode; - - @ApiModelProperty(value = "收件人详细地址", required = true, example = "中关村大街 1 号") - private String receiverDetailAddress; - - // ========== 售后基本信息 ========== - - @ApiModelProperty(value = "售后状态", example = "1", notes = "参见 TradeOrderAfterSaleStatusEnum 枚举") - private Integer afterSaleStatus; - - @ApiModelProperty(value = "退款金额", required = true, example = "100", notes = "单位:分") - private Integer refundPrice; - - // ========== 营销基本信息 ========== - - @ApiModelProperty(value = "优惠劵编号", example = "1024") - private Long couponId; - - @ApiModelProperty(value = "优惠劵减免金额", required = true, example = "100", notes = "单位:分") - private Integer couponPrice; - - @ApiModelProperty(value = "积分抵扣的金额", required = true, example = "100", notes = "单位:分") - private Integer pointPrice; -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderDeliveryReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderDeliveryReqVO.java deleted file mode 100644 index e75fcacf2..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderDeliveryReqVO.java +++ /dev/null @@ -1,26 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.order.vo; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; - -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; - -@ApiModel("管理后台 - 订单发货 Request VO") -@Data -public class TradeOrderDeliveryReqVO { - - @ApiModelProperty(name = "订单编号", required = true, example = "1024") - @NotNull(message = "订单编号不能为空") - private Long id; - - @ApiModelProperty(name = "发货物流公司编号", required = true, example = "1") - @NotNull(message = "发货物流公司编号不能为空") - private Long logisticsId; - - @ApiModelProperty(name = "发货物流单号", required = true, example = "SF123456789") - @NotEmpty(message = "发货物流单号不能为空") - private String logisticsNo; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderDetailRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderDetailRespVO.java deleted file mode 100644 index a5fe26fda..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderDetailRespVO.java +++ /dev/null @@ -1,39 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.order.vo; - -import cn.iocoder.yudao.module.trade.controller.admin.base.member.user.MemberUserRespVO; -import cn.iocoder.yudao.module.trade.controller.admin.base.product.property.ProductPropertyValueDetailRespVO; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; - -import java.util.List; - -@ApiModel("管理后台 - 交易订单的详情 Response VO") -@Data -public class TradeOrderDetailRespVO extends TradeOrderBaseVO { - - @ApiModelProperty(value = "收件人地区名字", required = true, example = "上海 上海市 普陀区") - private String receiverAreaName; - - /** - * 订单项列表 - */ - private List items; - - /** - * 用户信息 - */ - private MemberUserRespVO user; - - @ApiModel("管理后台 - 交易订单的详情的订单项目") - @Data - public static class Item extends TradeOrderItemBaseVO { - - /** - * 属性数组 - */ - private List properties; - - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderItemBaseVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderItemBaseVO.java deleted file mode 100644 index 8e55b8ea7..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderItemBaseVO.java +++ /dev/null @@ -1,70 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.order.vo; - -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; - -/** - * 交易订单项 Base VO,提供给添加、修改、详细的子 VO 使用 - * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 - */ -@Data -public class TradeOrderItemBaseVO { - - // ========== 订单项基本信息 ========== - - @ApiModelProperty(value = "编号", required = true, example = "1") - private Long id; - - @ApiModelProperty(value = "用户编号", required = true, example = "1") - private Long userId; - - @ApiModelProperty(value = "订单编号", required = true, example = "1") - private Long orderId; - - // ========== 商品基本信息 ========== - - @ApiModelProperty(value = "商品 SPU 编号", required = true, example = "1") - private Long spuId; - - @ApiModelProperty(value = "商品 SPU 名称", required = true, example = "芋道源码") - private String spuName; - - @ApiModelProperty(value = "商品 SKU 编号", required = true, example = "1") - private Long skuId; - - @ApiModelProperty(value = "商品图片", required = true, example = "https://www.iocoder.cn/1.png") - private String picUrl; - - @ApiModelProperty(value = "购买数量", required = true, example = "1") - private Integer count; - - // ========== 价格 + 支付基本信息 ========== - - @ApiModelProperty(value = "商品原价(总)", required = true, example = "100", notes = "单位:分") - private Integer originalPrice; - - @ApiModelProperty(value = "商品原价(单)", required = true, example = "100", notes = "单位:分") - private Integer originalUnitPrice; - - @ApiModelProperty(value = "商品优惠(总)", required = true, example = "100", notes = "单位:分") - private Integer discountPrice; - - @ApiModelProperty(value = "商品实付金额(总)", required = true, example = "100", notes = "单位:分") - private Integer payPrice; - - @ApiModelProperty(value = "子订单分摊金额(总)", required = true, example = "100", notes = "单位:分") - private Integer orderPartPrice; - - @ApiModelProperty(value = "分摊后子订单实付金额(总)", required = true, example = "100", notes = "单位:分") - private Integer orderDividePrice; - - // ========== 营销基本信息 ========== - - // TODO 芋艿:在捉摸一下 - - // ========== 售后基本信息 ========== - - @ApiModelProperty(value = "售后状态", required = true, example = "1", notes = "参见 TradeOrderItemAfterSaleStatusEnum 枚举类") - private Integer afterSaleStatus; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderPageItemRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderPageItemRespVO.java deleted file mode 100644 index deb71d819..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderPageItemRespVO.java +++ /dev/null @@ -1,33 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.order.vo; - -import cn.iocoder.yudao.module.trade.controller.admin.base.product.property.ProductPropertyValueDetailRespVO; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; - -import java.util.List; - -@ApiModel("管理后台 - 交易订单的分页项 Response VO") -@Data -public class TradeOrderPageItemRespVO extends TradeOrderBaseVO { - - @ApiModelProperty(value = "收件人地区名字", required = true, example = "上海 上海市 普陀区") - private String receiverAreaName; - - /** - * 订单项列表 - */ - private List items; - - @ApiModel("管理后台 - 交易订单的分页项的订单项目") - @Data - public static class Item extends TradeOrderItemBaseVO { - - /** - * 属性数组 - */ - private List properties; - - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderPageReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderPageReqVO.java deleted file mode 100644 index 4295d8c3d..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderPageReqVO.java +++ /dev/null @@ -1,54 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.order.vo; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.framework.common.validation.Mobile; -import cn.iocoder.yudao.module.trade.enums.order.TradeOrderStatusEnum; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@ApiModel("管理后台 - 交易订单的分页 Request VO") -@Data -public class TradeOrderPageReqVO extends PageParam { - - @ApiModelProperty(value = "订单号", example = "88888888", notes = "模糊匹配") - private String no; - - @ApiModelProperty(value = "用户编号", example = "1024") - private Long userId; - - @ApiModelProperty(value = "用户昵称", example = "小王", notes = "模糊匹配") - private String userNickname; - - @ApiModelProperty(value = "用户手机号", example = "小王", notes = "精准匹配") - @Mobile - private String userMobile; - - @ApiModelProperty(value = "收件人名称", example = "小红", notes = "模糊匹配") - private String receiverName; - - @ApiModelProperty(value = "收件人手机", example = "1560", notes = "模糊匹配") - @Mobile - private String receiverMobile; - - @ApiModelProperty(value = "订单类型", example = "1", notes = "参见 TradeOrderTypeEnum 枚举") - private Integer type; - - @ApiModelProperty(value = "订单状态", example = "1", notes = "参见 TradeOrderStatusEnum 枚举") - @InEnum(value = TradeOrderStatusEnum.class, message = "订单状态必须是 {value}") - private Integer status; - - @ApiModelProperty(value = "支付渠道", example = "wx_lite") - private String payChannelCode; - - @ApiModelProperty(value = "创建时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] createTime; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/aftersale/AppTradeAfterSaleController.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/aftersale/AppTradeAfterSaleController.java deleted file mode 100644 index 5c1758f3b..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/aftersale/AppTradeAfterSaleController.java +++ /dev/null @@ -1,50 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.aftersale; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.trade.controller.app.aftersale.vo.AppTradeAfterSaleCreateReqVO; -import cn.iocoder.yudao.module.trade.controller.app.aftersale.vo.AppTradeAfterSaleDeliveryReqVO; -import cn.iocoder.yudao.module.trade.service.aftersale.TradeAfterSaleService; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiImplicitParam; -import io.swagger.annotations.ApiOperation; -import lombok.extern.slf4j.Slf4j; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; - -@Api(tags = "用户 App - 交易售后") -@RestController -@RequestMapping("/trade/after-sale") -@Validated -@Slf4j -public class AppTradeAfterSaleController { - - @Resource - private TradeAfterSaleService afterSaleService; - - @PostMapping(value = "/create") - @ApiOperation(value = "申请售后") - public CommonResult createAfterSale(@RequestBody AppTradeAfterSaleCreateReqVO createReqVO) { - return success(afterSaleService.createAfterSale(getLoginUserId(), createReqVO)); - } - - @PostMapping(value = "/delivery") - @ApiOperation(value = "退回货物") - public CommonResult deliveryAfterSale(@RequestBody AppTradeAfterSaleDeliveryReqVO deliveryReqVO) { - afterSaleService.deliveryAfterSale(getLoginUserId(), deliveryReqVO); - return success(true); - } - - @DeleteMapping(value = "/cancel") - @ApiOperation(value = "取消售后") - @ApiImplicitParam(name = "id", value = "售后编号", required = true, example = "1") - public CommonResult cancelAfterSale(@RequestParam("id") Long id) { - afterSaleService.cancelAfterSale(getLoginUserId(), id); - return success(true); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/aftersale/vo/AppTradeAfterSaleCreateReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/aftersale/vo/AppTradeAfterSaleCreateReqVO.java deleted file mode 100644 index b5ea83904..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/aftersale/vo/AppTradeAfterSaleCreateReqVO.java +++ /dev/null @@ -1,41 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.aftersale.vo; - -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.module.trade.enums.aftersale.TradeAfterSaleWayEnum; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; - -import javax.validation.constraints.Min; -import javax.validation.constraints.NotNull; -import java.util.List; - -@ApiModel("用户 App - 交易售后创建 Request VO") -@Data -public class AppTradeAfterSaleCreateReqVO { - - @ApiModelProperty(name = "订单项编号", required = true, example = "1024") - @NotNull(message = "订单项编号不能为空") - private Long orderItemId; - - @ApiModelProperty(name = "售后方式", required = true, example = "1", notes = "对应 TradeAfterSaleWayEnum 枚举") - @NotNull(message = "售后方式不能为空") - @InEnum(value = TradeAfterSaleWayEnum.class, message = "售后方式必须是 {value}") - private Integer way; - - @ApiModelProperty(name = "退款金额", required = true, example = "100", notes = "单位:分") - @NotNull(message = "退款金额不能为空") - @Min(value = 1, message = "退款金额必须大于 0") - private Integer refundPrice; - - @ApiModelProperty(name = "申请原因", required = true, example = "1", notes = "使用数据字典枚举,对应 trade_refund_apply_reason 类型") - @NotNull(message = "申请原因不能为空") - private String applyReason; - - @ApiModelProperty(name = "补充描述", example = "商品质量不好") - private String applyDescription; - - @ApiModelProperty(name = "补充凭证图片", example = "https://www.iocoder.cn/1.png, https://www.iocoder.cn/2.png") - private List applyPicUrls; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/aftersale/vo/AppTradeAfterSaleDeliveryReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/aftersale/vo/AppTradeAfterSaleDeliveryReqVO.java deleted file mode 100644 index c59d00034..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/aftersale/vo/AppTradeAfterSaleDeliveryReqVO.java +++ /dev/null @@ -1,31 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.aftersale.vo; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; - -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; -import java.time.LocalDateTime; - -@ApiModel("用户 App - 交易售后退回货物 Request VO") -@Data -public class AppTradeAfterSaleDeliveryReqVO { - - @ApiModelProperty(name = "售后编号", required = true, example = "1024") - @NotNull(message = "售后编号不能为空") - private Long id; - - @ApiModelProperty(name = "退货物流公司编号", required = true, example = "1") - @NotNull(message = "退货物流公司编号不能为空") - private Long logisticsId; - - @ApiModelProperty(name = "退货物流单号", required = true, example = "SF123456789") - @NotNull(message = "退货物流单号不能为空") - private String logisticsNo; - - @ApiModelProperty(name = "退货时间", required = true) - @NotEmpty(message = "退货时间不能为空") - private LocalDateTime deliveryTime; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/base/package-info.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/base/package-info.java deleted file mode 100644 index 08acfdbca..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/base/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 基础包,放一些通用的 VO 类 - */ -package cn.iocoder.yudao.module.trade.controller.app.base; diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/base/property/AppProductPropertyValueDetailRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/base/property/AppProductPropertyValueDetailRespVO.java deleted file mode 100644 index adcb978ec..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/base/property/AppProductPropertyValueDetailRespVO.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.base.property; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description ="用户 App - 商品属性值的明细 Response VO") -@Data -public class AppProductPropertyValueDetailRespVO { - - @Schema(description = "属性的编号", required = true, example = "1") - private Long propertyId; - - @Schema(description = "属性的名称", required = true, example = "颜色") - private String propertyName; - - @Schema(description = "属性值的编号", required = true, example = "1024") - private Long valueId; - - @Schema(description = "属性值的名称", required = true, example = "红色") - private String valueName; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/base/sku/AppProductSkuBaseRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/base/sku/AppProductSkuBaseRespVO.java deleted file mode 100644 index 053e329b4..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/base/sku/AppProductSkuBaseRespVO.java +++ /dev/null @@ -1,34 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.base.sku; - -import cn.iocoder.yudao.module.trade.controller.app.base.property.AppProductPropertyValueDetailRespVO; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.util.List; - -/** - * 商品 SKU 基础 Response VO - * - * @author 芋道源码 - */ -@Data -public class AppProductSkuBaseRespVO { - - @Schema(description = "主键", required = true, example = "1024") - private Long id; - - @Schema(description = "商品 SKU 名字", required = true, example = "芋道") - private String name; - - @Schema(description = "图片地址", example = "https://www.iocoder.cn/xx.png") - private String picUrl; - - @Schema(description = "库存", required = true, example = "1") - private Integer stock; - - /** - * 属性数组 - */ - private List properties; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/base/spu/AppProductSpuBaseRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/base/spu/AppProductSpuBaseRespVO.java deleted file mode 100644 index 61ecf59d2..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/base/spu/AppProductSpuBaseRespVO.java +++ /dev/null @@ -1,24 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.base.spu; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.util.List; - -/** - * 商品 SPU 基础 Response VO - * - * @author 芋道源码 - */ -@Data -public class AppProductSpuBaseRespVO { - - @Schema(description = "主键", required = true, example = "1024") - private Long id; - - @Schema(description = "商品 SPU 名字", required = true, example = "芋道") - private String name; - - @Schema(description = "商品主图地址", example = "https://www.iocoder.cn/xx.png") - private List picUrls; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/cart/TradeCartController.http b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/cart/TradeCartController.http deleted file mode 100644 index 3ce8797fc..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/cart/TradeCartController.http +++ /dev/null @@ -1,47 +0,0 @@ -### 请求 /trade/cart/add-count 接口 => 成功 -POST {{appApi}}/trade/cart/add-count -tenant-id: {{appTenentId}} -Authorization: Bearer {{appToken}} -Content-Type: application/json - -{ - "skuId": 1, - "count": 1 -} - -### 请求 /trade/cart/update-count 接口 => 成功 -PUT {{appApi}}/trade/cart/update-count -tenant-id: {{appTenentId}} -Authorization: Bearer {{appToken}} -Content-Type: application/json - -{ - "skuId": 1, - "count": 5 -} - -### 请求 /trade/cart/update-selected 接口 => 成功 -PUT {{appApi}}/trade/cart/update-selected -tenant-id: {{appTenentId}} -Authorization: Bearer {{appToken}} -Content-Type: application/json - -{ - "skuIds": [1], - "selected": false -} - -### 请求 /trade/cart/delete 接口 => 成功 -DELETE {{appApi}}/trade/cart/delete?skuIds=1 -tenant-id: {{appTenentId}} -Authorization: Bearer {{appToken}} - -### 请求 /trade/cart/get-count 接口 => 成功 -GET {{appApi}}/trade/cart/get-count -tenant-id: {{appTenentId}} -Authorization: Bearer {{appToken}} - -### 请求 /trade/cart/get-detail 接口 => 成功 -GET {{appApi}}/trade/cart/get-detail -tenant-id: {{appTenentId}} -Authorization: Bearer {{appToken}} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/cart/TradeCartController.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/cart/TradeCartController.java deleted file mode 100644 index 96f55d9a3..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/cart/TradeCartController.java +++ /dev/null @@ -1,84 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.cart; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.security.core.annotations.PreAuthenticated; -import cn.iocoder.yudao.module.trade.controller.app.cart.vo.AppTradeCartDetailRespVO; -import cn.iocoder.yudao.module.trade.controller.app.cart.vo.AppTradeCartItemAddCountReqVO; -import cn.iocoder.yudao.module.trade.controller.app.cart.vo.AppTradeCartItemUpdateCountReqVO; -import cn.iocoder.yudao.module.trade.controller.app.cart.vo.AppTradeCartItemUpdateSelectedReqVO; -import cn.iocoder.yudao.module.trade.service.cart.TradeCartService; -import io.swagger.v3.oas.annotations.tags.Tag; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.Operation; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.validation.Valid; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; - -@Tag(name = "用户 App - 购物车") -@RestController -@RequestMapping("/trade/cart") -@RequiredArgsConstructor -@Validated -@Slf4j -public class TradeCartController { - - @Resource - private TradeCartService cartService; - - @PostMapping("/add-count") - @Operation(summary = "添加商品到购物车") - @PreAuthenticated - public CommonResult addCartItemCount(@Valid @RequestBody AppTradeCartItemAddCountReqVO addCountReqVO) { - cartService.addCartItemCount(getLoginUserId(), addCountReqVO); - return success(true); - } - - @PutMapping("update-count") - @Operation(summary = "更新购物车商品数量") - @PreAuthenticated - public CommonResult updateCartItemQuantity(@Valid @RequestBody AppTradeCartItemUpdateCountReqVO updateCountReqVO) { - cartService.updateCartItemCount(getLoginUserId(), updateCountReqVO); - return success(true); - } - - @PutMapping("update-selected") - @Operation(summary = "更新购物车商品是否选中") - @PreAuthenticated - public CommonResult updateCartItemSelected(@Valid @RequestBody AppTradeCartItemUpdateSelectedReqVO updateSelectedReqVO) { - cartService.updateCartItemSelected(getLoginUserId(), updateSelectedReqVO); - // 获得目前购物车明细 - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除购物车商品") - @Parameter(name = "skuIds", description = "商品 SKU 编号的数组", required = true, example = "1024,2048") - @PreAuthenticated - public CommonResult deleteCartItem(@RequestParam("skuIds") List skuIds) { - cartService.deleteCartItems(getLoginUserId(), skuIds); - return success(true); - } - - @GetMapping("get-count") - @Operation(summary = "查询用户在购物车中的商品数量") - @PreAuthenticated - public CommonResult getCartCount() { - return success(cartService.getCartCount(getLoginUserId())); - } - - @GetMapping("/get-detail") - @Operation(summary = "查询用户的购物车的详情") - @PreAuthenticated - public CommonResult getCartDetail() { - return success(cartService.getCartDetail(getLoginUserId())); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/cart/vo/AppTradeCartDetailRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/cart/vo/AppTradeCartDetailRespVO.java deleted file mode 100644 index f58421b68..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/cart/vo/AppTradeCartDetailRespVO.java +++ /dev/null @@ -1,117 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.cart.vo; - -import cn.iocoder.yudao.module.trade.controller.app.base.sku.AppProductSkuBaseRespVO; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.util.List; - -@Schema(description = "用户 App - 用户的购物车明细 Response VO") -@Data -public class AppTradeCartDetailRespVO { - - /** - * 商品分组数组 - */ - private List itemGroups; - - /** - * 费用 - */ - private Order order; - - @Schema(description = "商品分组,多个商品,参加同一个活动,从而形成分组") - @Data - public static class ItemGroup { - - /** - * 商品数组 - */ - private List items; - /** - * 营销活动,订单级别 - */ - private Promotion promotion; - - } - - @Schema(description = "商品 SKU") - @Data - public static class Sku extends AppProductSkuBaseRespVO { - - /** - * SPU 信息 - */ - private AppProductSkuBaseRespVO spu; - - // ========== 购物车相关的字段 ========== - - @Schema(description = "商品数量", required = true, example = "1") - private Integer count; - @Schema(description = "是否选中", required = true, example = "true") - private Boolean selected; - - // ========== 价格相关的字段,对应 PriceCalculateRespDTO.OrderItem 的属性 ========== - - // TODO 芋艿:后续可以去除一些无用的字段 - - @Schema(description = "商品原价(单)", required = true, example = "100") - private Integer originalPrice; - @Schema(description = "商品原价(总)", required = true, example = "200") - private Integer totalOriginalPrice; - @Schema(description = "商品级优惠(总)", required = true, example = "300") - private Integer totalPromotionPrice; - @Schema(description = "最终购买金额(总)", required = true, example = "400") - private Integer totalPresentPrice; - @Schema(description = "最终购买金额(单)", required = true, example = "500") - private Integer presentPrice; - @Schema(description = "应付金额(总)", required = true, example = "600") - private Integer totalPayPrice; - - // ========== 营销相关的字段 ========== - /** - * 营销活动,商品级别 - */ - private Promotion promotion; - - } - - @Schema(description = "订单,对应 PriceCalculateRespDTO.Order 类,用于费用(合计)") - @Data - public static class Order { - - // TODO 芋艿:后续可以去除一些无用的字段 - - @Schema(description = "商品原价(总)", required = true, example = "100") - private Integer skuOriginalPrice; - @Schema(description = "商品优惠(总)", required = true, example = "200") - private Integer skuPromotionPrice; - @Schema(description = "订单优惠(总)", required = true, example = "300") - private Integer orderPromotionPrice; - @Schema(description = "运费金额", required = true, example = "400") - private Integer deliveryPrice; - @Schema(description = "应付金额(总)", required = true, example = "500") - private Integer payPrice; - - } - - @Schema(description = "营销活动,对应 PriceCalculateRespDTO.Promotion 类的属性") - @Data - public static class Promotion { - - @Schema(description = "营销编号,营销活动的编号、优惠劵的编号", required = true, example = "1024") - private Long id; - @Schema(description = "营销名字", required = true, example = "xx 活动") - private String name; - @Schema(description = "营销类型,参见 PromotionTypeEnum 枚举类", required = true, example = "1") - private Integer type; - - // ========== 匹配情况 ========== - @Schema(description = "是否满足优惠条件", required = true, example = "true") - private Boolean meet; - @Schema(description = "满足条件的提示", required = true, example = "圣诞价:省 150.00 元") - private String meetTip; - - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/cart/vo/AppTradeCartItemAddCountReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/cart/vo/AppTradeCartItemAddCountReqVO.java deleted file mode 100644 index 280150537..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/cart/vo/AppTradeCartItemAddCountReqVO.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.cart.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.Min; -import javax.validation.constraints.NotNull; - -@Schema(description = "用户 App - 购物车添加购物项 Request VO") -@Data -public class AppTradeCartItemAddCountReqVO { - - @Schema(description = "商品 SKU 编号", required = true,example = "1024") - @NotNull(message = "商品 SKU 编号不能为空") - private Long skuId; - - @Schema(description = "商品数量,注意,这是新增数量", required = true, example = "1") - @NotNull(message = "数量不能为空") - @Min(message = "数量必须大于 0", value = 1L) - private Integer count; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/cart/vo/AppTradeCartItemUpdateCountReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/cart/vo/AppTradeCartItemUpdateCountReqVO.java deleted file mode 100644 index d3d12487e..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/cart/vo/AppTradeCartItemUpdateCountReqVO.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.cart.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.Min; -import javax.validation.constraints.NotNull; - -@Schema(description = "用户 App - 购物车更新数量 Request VO") -@Data -public class AppTradeCartItemUpdateCountReqVO { - - @Schema(description = "商品 SKU 编号", required = true, example = "1024") - @NotNull(message = "商品 SKU 编号不能为空") - private Long skuId; - - @Schema(description = "商品数量", required = true, example = "1") - @NotNull(message = "数量不能为空") - @Min(message = "数量必须大于 0", value = 1L) - private Integer count; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/cart/vo/AppTradeCartItemUpdateSelectedReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/cart/vo/AppTradeCartItemUpdateSelectedReqVO.java deleted file mode 100644 index 62327f320..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/cart/vo/AppTradeCartItemUpdateSelectedReqVO.java +++ /dev/null @@ -1,21 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.cart.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotNull; -import java.util.Collection; - -@Schema(description = "用户 App - 购物车更新是否选中 Request VO") -@Data -public class AppTradeCartItemUpdateSelectedReqVO { - - @Schema(description = "商品 SKU 编号列表", required = true, example = "1024,2048") - @NotNull(message = "商品 SKU 编号列表不能为空") - private Collection skuIds; - - @Schema(description = "是否选中", required = true, example = "true") - @NotNull(message = "是否选中不能为空") - private Boolean selected; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/AppTradeOrderController.http b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/AppTradeOrderController.http deleted file mode 100644 index 8e7746359..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/AppTradeOrderController.http +++ /dev/null @@ -1,37 +0,0 @@ -### /trade-order/confirm-create-order-info 基于商品,确认创建订单 -GET {{appApi}}/trade/order/get-create-info?items[0].skuId=1&items[0].count=1 -Authorization: Bearer {{user-access-token}} -tenant-id: {{appTenentId}} - -### /trade-order/confirm-create-order-info-from-cart 基于购物车,确认创建订单 -GET {{shop-api-base-url}}/trade-order/confirm-create-order-info-from-cart -Content-Type: application/x-www-form-urlencoded -Authorization: Bearer {{user-access-token}} - -### /trade-order/create 基于商品,创建订单 -POST {{appApi}}/trade/order/create -Content-Type: application/json -Authorization: Bearer {{appToken}} -tenant-id: {{appTenentId}} - -{ - "addressId": 21, - "remark": "我是备注", - "fromCart": false, - "items": [ - { - "skuId": 29, - "count": 1 - } - ] -} - -### 获得订单交易的分页 -GET {{appApi}}/trade/order/page?pageNo=1&pageSize=10 -Authorization: Bearer {{appToken}} -tenant-id: {{appTenentId}} - -### 获得订单交易的详细 -GET {{appApi}}/trade/order/get-detail?id=21 -Authorization: Bearer {{appToken}} -tenant-id: {{appTenentId}} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/AppTradeOrderController.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/AppTradeOrderController.java deleted file mode 100644 index 876da3621..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/AppTradeOrderController.java +++ /dev/null @@ -1,102 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.order; - -import cn.hutool.extra.servlet.ServletUtil; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.security.core.annotations.PreAuthenticated; -import cn.iocoder.yudao.module.pay.api.notify.dto.PayOrderNotifyReqDTO; -import cn.iocoder.yudao.module.product.api.property.ProductPropertyValueApi; -import cn.iocoder.yudao.module.product.api.property.dto.ProductPropertyValueDetailRespDTO; -import cn.iocoder.yudao.module.trade.controller.app.order.vo.*; -import cn.iocoder.yudao.module.trade.convert.order.TradeOrderConvert; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderItemDO; -import cn.iocoder.yudao.module.trade.service.order.TradeOrderService; -import io.swagger.v3.oas.annotations.tags.Tag; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.Operation; -import lombok.extern.slf4j.Slf4j; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.servlet.http.HttpServletRequest; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; -import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; - -@Tag(name = "用户 App - 交易订单") -@RestController -@RequestMapping("/trade/order") -@Validated -@Slf4j -public class AppTradeOrderController { - - @Resource - private TradeOrderService tradeOrderService; - - @Resource - private ProductPropertyValueApi productPropertyValueApi; - - @GetMapping("/get-create-info") - @Operation(summary = "基于商品,确认创建订单") - @PreAuthenticated - public CommonResult getOrderCreateInfo(AppTradeOrderCreateReqVO createReqVO) { -// return success(tradeOrderService.getOrderConfirmCreateInfo(UserSecurityContextHolder.getUserId(), skuId, quantity, couponCardId)); - return null; - } - - @PostMapping("/create") - @Operation(summary = "创建订单") - @PreAuthenticated - public CommonResult createOrder(@RequestBody AppTradeOrderCreateReqVO createReqVO, - HttpServletRequest servletRequest) { - // 获取登录用户、用户 IP 地址 - Long loginUserId = getLoginUserId(); - String clientIp = ServletUtil.getClientIP(servletRequest); - // 创建交易订单,预支付记录 - Long orderId = tradeOrderService.createOrder(loginUserId, clientIp, createReqVO); - return success(orderId); - } - - @PostMapping("/update-paid") - @Operation(summary = "更新订单为已支付", notes = "由 pay-module 支付服务,进行回调,可见 PayNotifyJob") - public CommonResult updateOrderPaid(@RequestBody PayOrderNotifyReqDTO notifyReqDTO) { - tradeOrderService.updateOrderPaid(Long.valueOf(notifyReqDTO.getMerchantOrderId()), - notifyReqDTO.getPayOrderId()); - return success(true); - } - - @GetMapping("/get-detail") - @Operation(summary = "获得交易订单") - @Parameter(name = "id", description = "交易订单编号", required = true) - public CommonResult getOrder(@RequestParam("id") Long id) { - // 查询订单 - TradeOrderDO order = tradeOrderService.getOrder(getLoginUserId(), id); - // 查询订单项 - List orderItems = tradeOrderService.getOrderItemListByOrderId(order.getId()); - // 查询商品属性 - List propertyValueDetails = productPropertyValueApi - .getPropertyValueDetailList(TradeOrderConvert.INSTANCE.convertPropertyValueIds(orderItems)); - // 最终组合 - return success(TradeOrderConvert.INSTANCE.convert02(order, orderItems, propertyValueDetails)); - } - - @GetMapping("/page") - @Operation(summary = "获得订单交易分页") - public CommonResult> getOrderPage(AppTradeOrderPageReqVO reqVO) { - // 查询订单 - PageResult pageResult = tradeOrderService.getOrderPage(getLoginUserId(), reqVO); - // 查询订单项 - List orderItems = tradeOrderService.getOrderItemListByOrderId( - convertSet(pageResult.getList(), TradeOrderDO::getId)); - // 查询商品属性 - List propertyValueDetails = productPropertyValueApi - .getPropertyValueDetailList(TradeOrderConvert.INSTANCE.convertPropertyValueIds(orderItems)); - // 最终组合 - return success(TradeOrderConvert.INSTANCE.convertPage02(pageResult, orderItems, propertyValueDetails)); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/vo/AppTradeOrderCreateReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/vo/AppTradeOrderCreateReqVO.java deleted file mode 100644 index 4d6c19c34..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/vo/AppTradeOrderCreateReqVO.java +++ /dev/null @@ -1,52 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.order.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.Valid; -import javax.validation.constraints.Min; -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; -import java.util.List; - -@Schema(description = "用户 App - 交易订单创建 Request VO") -@Data -public class AppTradeOrderCreateReqVO { - - @Schema(description = "收件地址编号", required = true, example = "1") - @NotNull(message = "收件地址不能为空") - private Long addressId; - - @Schema(description = "优惠劵编号", example = "1024") - private Long couponId; - - @Schema(description = "备注", example = "这个是我的订单哟") - private String remark; - - @Schema(description = "是否来自购物车,true - 来自购物车;false - 立即购买", required = true, example = "true") - @NotNull(message = "是否来自购物车不能为空") - private Boolean fromCart; - - /** - * 订单商品项列表 - */ - @NotEmpty(message = "必须选择购买的商品") - @Valid - private List items; - - @Schema(description = "订单商品项") - @Data - public static class Item { - - @Schema(description = "商品 SKU 编号", required = true, example = "111") - @NotNull(message = "商品 SKU 编号不能为空") - private Long skuId; - - @Schema(description = "商品 SKU 购买数量", required = true, example = "1024") - @NotNull(message = "商品 SKU 购买数量不能为空") - @Min(value = 1, message = "商品 SKU 购买数量必须大于 0") - private Integer count; - - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/vo/AppTradeOrderDetailRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/vo/AppTradeOrderDetailRespVO.java deleted file mode 100644 index 14614a57e..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/vo/AppTradeOrderDetailRespVO.java +++ /dev/null @@ -1,150 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.order.vo; - -import cn.iocoder.yudao.module.trade.controller.app.base.property.AppProductPropertyValueDetailRespVO; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; - -import java.time.LocalDateTime; -import java.util.Date; -import java.util.List; - -@ApiModel("用户 App - 订单交易的明细 Response VO") -@Data -public class AppTradeOrderDetailRespVO { - - // ========== 订单基本信息 ========== - - @ApiModelProperty(value = "订单编号", required = true, example = "1024") - private Long id; - - @ApiModelProperty(value = "订单流水号", required = true, example = "1146347329394184195") - private String no; - - @ApiModelProperty(value = "创建时间", required = true, notes = "下单时间") - private Date createTime; - - @ApiModelProperty(value = "用户备注", required = true, example = "你猜") - private String userRemark; - - @ApiModelProperty(value = "订单状态", required = true, example = "1", notes = "参见 TradeOrderStatusEnum 枚举") - private Integer status; - - @ApiModelProperty(value = "购买的商品数量", required = true, example = "10") - private Integer productCount; - - @ApiModelProperty(value = "订单完成时间") - private LocalDateTime finishTime; - - @ApiModelProperty(value = "订单取消时间") - private LocalDateTime cancelTime; - - // ========== 价格 + 支付基本信息 ========== - - @ApiModelProperty(value = "支付订单编号", required = true, example = "1024") - private Long payOrderId; - - @ApiModelProperty(value = "付款时间") - private LocalDateTime payTime; - - @ApiModelProperty(value = "商品原价(总)", required = true, example = "1000", notes = "单位:分") - private Integer originalPrice; - - @ApiModelProperty(value = "订单原价(总)", required = true, example = "1000", notes = "单位:分") - private Integer orderPrice; - - @ApiModelProperty(value = "订单优惠(总)", required = true, example = "100", notes = "单位:分") - private Integer discountPrice; - - @ApiModelProperty(value = "运费金额", required = true, example = "100", notes = "单位:分") - private Integer deliveryPrice; - - @ApiModelProperty(value = "订单调价(总)", required = true, example = "100", notes = "单位:分") - private Integer adjustPrice; - - @ApiModelProperty(value = "应付金额(总)", required = true, example = "1000", notes = "单位:分") - private Integer payPrice; - - // ========== 收件 + 物流基本信息 ========== - - @ApiModelProperty(value = "发货物流单号", example = "1024") - private String logisticsNo; - - @ApiModelProperty(value = "发货时间") - private LocalDateTime deliveryTime; - - @ApiModelProperty(value = "收货时间") - private LocalDateTime receiveTime; - - @ApiModelProperty(value = "收件人名称", required = true, example = "张三") - private String receiverName; - - @ApiModelProperty(value = "收件人手机", required = true, example = "13800138000") - private String receiverMobile; - - @ApiModelProperty(value = "收件人地区编号", required = true, example = "110000") - private Integer receiverAreaId; - - @ApiModelProperty(value = "收件人地区名字", required = true, example = "上海 上海市 普陀区") - private String receiverAreaName; - - @ApiModelProperty(value = "收件人邮编", required = true, example = "100000") - private Integer receiverPostCode; - - @ApiModelProperty(value = "收件人详细地址", required = true, example = "中关村大街 1 号") - private String receiverDetailAddress; - - // ========== 售后基本信息 ========== - - // ========== 营销基本信息 ========== - - @ApiModelProperty(value = "优惠劵编号", example = "1024") - private Long couponId; - - @ApiModelProperty(value = "优惠劵减免金额", required = true, example = "100", notes = "单位:分") - private Integer couponPrice; - - @ApiModelProperty(value = "积分抵扣的金额", required = true, example = "100", notes = "单位:分") - private Integer pointPrice; - - /** - * 订单项数组 - */ - private List items; - - @ApiModel("用户 App - 交易订单的分页项的订单项目") - @Data - public static class Item { - - @ApiModelProperty(value = "编号", required = true, example = "1") - private Long id; - - @ApiModelProperty(value = "商品 SPU 编号", required = true, example = "1") - private Long spuId; - - @ApiModelProperty(value = "商品 SPU 名称", required = true, example = "芋道源码") - private String spuName; - - @ApiModelProperty(value = "商品 SKU 编号", required = true, example = "1") - private Long skuId; - - @ApiModelProperty(value = "商品图片", required = true, example = "https://www.iocoder.cn/1.png") - private String picUrl; - - @ApiModelProperty(value = "购买数量", required = true, example = "1") - private Integer count; - - @ApiModelProperty(value = "商品原价(总)", required = true, example = "100", notes = "单位:分") - private Integer originalPrice; - - @ApiModelProperty(value = "商品原价(单)", required = true, example = "100", notes = "单位:分") - private Integer originalUnitPrice; - - /** - * 属性数组 - */ - private List properties; - - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/vo/AppTradeOrderGetCreateInfoRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/vo/AppTradeOrderGetCreateInfoRespVO.java deleted file mode 100644 index 2f73a5c8e..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/vo/AppTradeOrderGetCreateInfoRespVO.java +++ /dev/null @@ -1,168 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.order.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.AllArgsConstructor; -import lombok.Data; - -import java.util.List; - -@Schema(description = "用户 App - 订单获得创建信息 Response VO") -@Data -public class AppTradeOrderGetCreateInfoRespVO { - - /** - * 商品分组数组 - */ - private List itemGroups; - /** - * 费用 - */ - private Fee fee; - -// /** -// * 优惠劵列表 TODO 芋艿,后续改改 -// */ -// private List coupons; - - @Schema(description = "商品分组,多个商品,参加同一个活动,从而形成分组") - @Data - public static class ItemGroup { - -// /** -// * 优惠活动 -// */ -// private PromotionActivityRespDTO activity; // TODO 芋艿,偷懒 - /** - * 商品 SKU 数组 - */ - private List items; - - } - - @Schema(description = "商品 SKU") - @Data - public static class Sku { - - // SKU 自带信息 - @Schema(description = "SKU 编号", required = true, example = "1024") - private Integer id; - /** - * SPU 信息 - */ - private Spu spu; - /** - * 图片地址 - */ - private String picURL; -// /** -// * 属性数组 -// */ -// private List attrs; // TODO 后面改下 - /** - * 价格,单位:分 - */ - private Integer price; - /** - * 库存数量 - */ - private Integer stock; - - // 非 SKU 自带信息 - - /** - * 购买数量 - */ - private Integer buyQuantity; -// /** -// * 优惠活动 -// */ -// private PromotionActivityRespDTO activity; // TODO 芋艿,偷懒 - /** - * 原始单价,单位:分。 - */ - private Integer originPrice; - /** - * 购买单价,单位:分 - */ - private Integer buyPrice; - /** - * 最终价格,单位:分。 - */ - private Integer presentPrice; - /** - * 购买总金额,单位:分 - * - * 用途类似 {@link #presentTotal} - */ - private Integer buyTotal; - /** - * 优惠总金额,单位:分。 - */ - private Integer discountTotal; - /** - * 最终总金额,单位:分。 - * - * 注意,presentPrice * quantity 不一定等于 presentTotal 。 - * 因为,存在无法整除的情况。 - * 举个例子,presentPrice = 8.33 ,quantity = 3 的情况,presentTotal 有可能是 24.99 ,也可能是 25 。 - * 所以,需要存储一个该字段。 - */ - private Integer presentTotal; - - } - - @Data - public static class Spu { - - /** - * SPU 编号 - */ - private Integer id; - - // ========== 基本信息 ========= - /** - * SPU 名字 - */ - private String name; - /** - * 分类编号 - */ - private Integer cid; - /** - * 商品主图地址 - * - * 数组,以逗号分隔 - * - * 建议尺寸:800*800像素,你可以拖拽图片调整顺序,最多上传15张 - */ - private List picUrls; - - } - - @Schema(description = "费用(合计)") - @Data - @AllArgsConstructor - public static class Fee { - - @Schema(description = "购买总价", required = true, example = "1024") - private Integer buyPrice; - /** - * 优惠总价 - * - * 注意,满多少元包邮,不算在优惠中。 - */ - private Integer discountTotal; - /** - * 邮费 - */ - private Integer postageTotal; - /** - * 最终价格 - * - * 计算公式 = 总价 - 优惠总价 + 邮费 - */ - private Integer presentTotal; - - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/vo/AppTradeOrderPageItemRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/vo/AppTradeOrderPageItemRespVO.java deleted file mode 100644 index 8815c0c39..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/vo/AppTradeOrderPageItemRespVO.java +++ /dev/null @@ -1,66 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.order.vo; - -import cn.iocoder.yudao.module.trade.controller.app.base.property.AppProductPropertyValueDetailRespVO; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; - -import java.util.List; - -@ApiModel("用户 App - 订单交易的分页项 Response VO") -@Data -public class AppTradeOrderPageItemRespVO { - - @ApiModelProperty(value = "订单编号", required = true, example = "1024") - private Long id; - - @ApiModelProperty(value = "订单流水号", required = true, example = "1146347329394184195") - private String no; - - @ApiModelProperty(value = "订单状态", required = true, example = "1", notes = "参见 TradeOrderStatusEnum 枚举") - private Integer status; - - @ApiModelProperty(value = "购买的商品数量", required = true, example = "10") - private Integer productCount; - - /** - * 订单项数组 - */ - private List items; - - @ApiModel("用户 App - 交易订单的明细的订单项目") - @Data - public static class Item { - - @ApiModelProperty(value = "编号", required = true, example = "1") - private Long id; - - @ApiModelProperty(value = "商品 SPU 编号", required = true, example = "1") - private Long spuId; - - @ApiModelProperty(value = "商品 SPU 名称", required = true, example = "芋道源码") - private String spuName; - - @ApiModelProperty(value = "商品 SKU 编号", required = true, example = "1") - private Long skuId; - - @ApiModelProperty(value = "商品图片", required = true, example = "https://www.iocoder.cn/1.png") - private String picUrl; - - @ApiModelProperty(value = "购买数量", required = true, example = "1") - private Integer count; - - @ApiModelProperty(value = "商品原价(总)", required = true, example = "100", notes = "单位:分") - private Integer originalPrice; - - @ApiModelProperty(value = "商品原价(单)", required = true, example = "100", notes = "单位:分") - private Integer originalUnitPrice; - - /** - * 属性数组 - */ - private List properties; - - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/vo/AppTradeOrderPageReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/vo/AppTradeOrderPageReqVO.java deleted file mode 100644 index 00bd2a571..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/vo/AppTradeOrderPageReqVO.java +++ /dev/null @@ -1,18 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.order.vo; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.module.trade.enums.order.TradeOrderStatusEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -// TODO 芋艿:字段优化 -@Schema(description = "交易订单分页 Request VO") -@Data -public class AppTradeOrderPageReqVO extends PageParam { - - @Schema(description = "订单状态-参见 TradeOrderStatusEnum 枚举", example = "1") - @InEnum(value = TradeOrderStatusEnum.class, message = "订单状态必须是 {value}") - private Integer status; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/vo/TradeOrderItemRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/vo/TradeOrderItemRespVO.java deleted file mode 100644 index e69de29bb..000000000 diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/vo/TradeOrderRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/vo/TradeOrderRespVO.java deleted file mode 100644 index e69de29bb..000000000 diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/package-info.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/package-info.java deleted file mode 100644 index aa2f99f35..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/package-info.java +++ /dev/null @@ -1,6 +0,0 @@ -/** - * 提供 RESTful API 给前端: - * 1. admin 包:提供给管理后台 yudao-ui-admin 前端项目 - * 2. app 包:提供给用户 APP yudao-ui-app 前端项目,它的 Controller 和 VO 都要添加 App 前缀,用于和管理后台进行区分 - */ -package cn.iocoder.yudao.module.trade.controller; diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/aftersale/TradeAfterSaleConvert.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/aftersale/TradeAfterSaleConvert.java deleted file mode 100644 index fe1e3bd01..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/aftersale/TradeAfterSaleConvert.java +++ /dev/null @@ -1,89 +0,0 @@ -package cn.iocoder.yudao.module.trade.convert.aftersale; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; -import cn.iocoder.yudao.module.pay.api.refund.dto.PayRefundCreateReqDTO; -import cn.iocoder.yudao.module.product.api.property.dto.ProductPropertyValueDetailRespDTO; -import cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo.TradeAfterSaleRespPageItemVO; -import cn.iocoder.yudao.module.trade.controller.admin.base.member.user.MemberUserRespVO; -import cn.iocoder.yudao.module.trade.controller.admin.base.product.property.ProductPropertyValueDetailRespVO; -import cn.iocoder.yudao.module.trade.controller.app.aftersale.vo.AppTradeAfterSaleCreateReqVO; -import cn.iocoder.yudao.module.trade.dal.dataobject.aftersale.TradeAfterSaleDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderItemDO; -import cn.iocoder.yudao.module.trade.framework.order.config.TradeOrderProperties; -import org.mapstruct.Mapper; -import org.mapstruct.Mapping; -import org.mapstruct.Mappings; -import org.mapstruct.factory.Mappers; - -import java.util.*; -import java.util.stream.Collectors; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; - -@Mapper -public interface TradeAfterSaleConvert { - - TradeAfterSaleConvert INSTANCE = Mappers.getMapper(TradeAfterSaleConvert.class); - - @Mappings({ - @Mapping(target = "id", ignore = true), - @Mapping(target = "createTime", ignore = true), - @Mapping(target = "updateTime", ignore = true), - @Mapping(target = "creator", ignore = true), - @Mapping(target = "updater", ignore = true), - }) - TradeAfterSaleDO convert(AppTradeAfterSaleCreateReqVO createReqVO, TradeOrderItemDO tradeOrderItem); - - @Mappings({ - @Mapping(source = "afterSale.orderId", target = "merchantOrderId"), - @Mapping(source = "afterSale.applyReason", target = "reason"), - @Mapping(source = "afterSale.refundPrice", target = "amount") - }) - PayRefundCreateReqDTO convert(String userIp, TradeAfterSaleDO afterSale, - TradeOrderProperties orderProperties); - - MemberUserRespVO convert(MemberUserRespDTO bean); - - PageResult convertPage(PageResult page); - - default PageResult convertPage(PageResult pageResult, - Map memberUsers, List propertyValueDetails) { - PageResult pageVOResult = convertPage(pageResult); - // 处理会员 + 商品属性等关联信息 - Map propertyValueDetailMap = convertMap(propertyValueDetails, ProductPropertyValueDetailRespDTO::getValueId); - for (int i = 0; i < pageResult.getList().size(); i++) { - TradeAfterSaleRespPageItemVO afterSaleVO = pageVOResult.getList().get(i); - TradeAfterSaleDO afterSaleDO = pageResult.getList().get(i); - // 会员 - afterSaleVO.setUser(convert(memberUsers.get(afterSaleDO.getUserId()))); - // 商品属性 - if (CollUtil.isNotEmpty(afterSaleDO.getProperties())) { - afterSaleVO.setProperties(new ArrayList<>(afterSaleDO.getProperties().size())); - // 遍历每个 properties,设置到 TradeOrderPageItemRespVO.Item 中 - afterSaleDO.getProperties().forEach(property -> { - ProductPropertyValueDetailRespDTO propertyValueDetail = propertyValueDetailMap.get(property.getValueId()); - if (propertyValueDetail == null) { - return; - } - afterSaleVO.getProperties().add(convert(propertyValueDetail)); - }); - } - } - return pageVOResult; - } - - ProductPropertyValueDetailRespVO convert(ProductPropertyValueDetailRespDTO bean); - - default Set convertPropertyValueIds(List list) { - if (CollUtil.isEmpty(list)) { - return new HashSet<>(); - } - return list.stream().filter(item -> item.getProperties() != null) - .flatMap(p -> p.getProperties().stream()) // 遍历多个 Property 属性 - .map(TradeOrderItemDO.Property::getValueId) // 将每个 Property 转换成对应的 propertyId,最后形成集合 - .collect(Collectors.toSet()); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/cart/TradeCartConvert.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/cart/TradeCartConvert.java deleted file mode 100644 index eb696ae30..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/cart/TradeCartConvert.java +++ /dev/null @@ -1,45 +0,0 @@ -package cn.iocoder.yudao.module.trade.convert.cart; - -import cn.iocoder.yudao.module.promotion.api.price.dto.PriceCalculateReqDTO; -import cn.iocoder.yudao.module.promotion.api.price.dto.PriceCalculateRespDTO; -import cn.iocoder.yudao.module.trade.controller.app.cart.vo.AppTradeCartDetailRespVO; -import cn.iocoder.yudao.module.trade.dal.dataobject.cart.TradeCartItemDO; -import org.mapstruct.Mapper; -import org.mapstruct.Mapping; -import org.mapstruct.Mappings; -import org.mapstruct.factory.Mappers; - -import java.util.Collections; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; - -@Mapper -public interface TradeCartConvert { - - TradeCartConvert INSTANCE = Mappers.getMapper(TradeCartConvert.class); - - default AppTradeCartDetailRespVO buildEmptyAppTradeCartDetailRespVO() { - return new AppTradeCartDetailRespVO().setItemGroups(Collections.emptyList()) - .setOrder(new AppTradeCartDetailRespVO.Order().setSkuOriginalPrice(0).setSkuPromotionPrice(0) - .setOrderPromotionPrice(0).setDeliveryPrice(0).setPayPrice(0)); - } - - default PriceCalculateReqDTO convert(Long userId, List cartItems) { - return new PriceCalculateReqDTO().setUserId(userId) - .setItems(convertList(cartItems, cartItem -> new PriceCalculateReqDTO.Item().setSkuId(cartItem.getSkuId()) - .setCount(cartItem.getSelected() ? cartItem.getCount() : 0))); - } - - // ========== AppTradeCartDetailRespVO 相关 ========== - - AppTradeCartDetailRespVO.Promotion convert(PriceCalculateRespDTO.Promotion bean); - - @Mappings({ - @Mapping(source = "cartItem.count", target = "count") - }) - AppTradeCartDetailRespVO.Sku convert(PriceCalculateRespDTO.OrderItem orderItem, TradeCartItemDO cartItem); - - AppTradeCartDetailRespVO.Order convert(PriceCalculateRespDTO.Order bean); - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/order/TradeOrderConvert.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/order/TradeOrderConvert.java deleted file mode 100644 index b1f0b4b2a..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/order/TradeOrderConvert.java +++ /dev/null @@ -1,241 +0,0 @@ -package cn.iocoder.yudao.module.trade.convert.order; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.framework.ip.core.utils.AreaUtils; -import cn.iocoder.yudao.module.member.api.address.dto.AddressRespDTO; -import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; -import cn.iocoder.yudao.module.pay.api.order.dto.PayOrderCreateReqDTO; -import cn.iocoder.yudao.module.product.api.property.dto.ProductPropertyValueDetailRespDTO; -import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuRespDTO; -import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuUpdateStockReqDTO; -import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO; -import cn.iocoder.yudao.module.promotion.api.price.dto.PriceCalculateReqDTO; -import cn.iocoder.yudao.module.promotion.api.price.dto.PriceCalculateRespDTO; -import cn.iocoder.yudao.module.trade.controller.admin.base.member.user.MemberUserRespVO; -import cn.iocoder.yudao.module.trade.controller.admin.base.product.property.ProductPropertyValueDetailRespVO; -import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderDetailRespVO; -import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderPageItemRespVO; -import cn.iocoder.yudao.module.trade.controller.app.base.property.AppProductPropertyValueDetailRespVO; -import cn.iocoder.yudao.module.trade.controller.app.order.vo.AppTradeOrderCreateReqVO; -import cn.iocoder.yudao.module.trade.controller.app.order.vo.AppTradeOrderDetailRespVO; -import cn.iocoder.yudao.module.trade.controller.app.order.vo.AppTradeOrderPageItemRespVO; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderItemDO; -import cn.iocoder.yudao.module.trade.enums.order.TradeOrderItemAfterSaleStatusEnum; -import cn.iocoder.yudao.module.trade.framework.order.config.TradeOrderProperties; -import org.mapstruct.Mapper; -import org.mapstruct.Mapping; -import org.mapstruct.Mappings; -import org.mapstruct.factory.Mappers; - -import java.util.*; -import java.util.stream.Collectors; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMultiMap; -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.addTime; - -@Mapper -public interface TradeOrderConvert { - - TradeOrderConvert INSTANCE = Mappers.getMapper(TradeOrderConvert.class); - - @Mappings({ - @Mapping(target = "id", ignore = true), - @Mapping(source = "createReqVO.couponId", target = "couponId"), - @Mapping(target = "remark", ignore = true), - @Mapping(source = "createReqVO.remark", target = "userRemark"), - @Mapping(source = "address.name", target = "receiverName"), - @Mapping(source = "address.mobile", target = "receiverMobile"), - @Mapping(source = "address.areaId", target = "receiverAreaId"), - @Mapping(source = "address.postCode", target = "receiverPostCode"), - @Mapping(source = "address.detailAddress", target = "receiverDetailAddress"), - }) - TradeOrderDO convert(Long userId, String userIp, AppTradeOrderCreateReqVO createReqVO, - PriceCalculateRespDTO.Order order, AddressRespDTO address); - - @Mappings({ - @Mapping(target = "id", ignore = true), - @Mapping(source = "sku.spuId", target = "spuId"), - }) - TradeOrderItemDO convert(PriceCalculateRespDTO.OrderItem orderItem, ProductSkuRespDTO sku); - - default List convertList(TradeOrderDO tradeOrderDO, - List orderItems, List skus) { - Map skuMap = convertMap(skus, ProductSkuRespDTO::getId); - return CollectionUtils.convertList(orderItems, orderItem -> { - TradeOrderItemDO tradeOrderItemDO = convert(orderItem, skuMap.get(orderItem.getSkuId())); - tradeOrderItemDO.setOrderId(tradeOrderDO.getId()); - tradeOrderItemDO.setUserId(tradeOrderDO.getUserId()); - tradeOrderItemDO.setAfterSaleStatus(TradeOrderItemAfterSaleStatusEnum.NONE.getStatus()); // 退款信息 -// tradeOrderItemDO.setCommented(false); - return tradeOrderItemDO; - }); - } - - @Mapping(source = "userId" , target = "userId") - PriceCalculateReqDTO convert(AppTradeOrderCreateReqVO createReqVO, Long userId); - - @Mappings({ - @Mapping(source = "skuId", target = "id"), - @Mapping(source = "count", target = "incrCount"), - }) - ProductSkuUpdateStockReqDTO.Item convert(TradeOrderItemDO bean); - List convertList(List list); - - default PayOrderCreateReqDTO convert(TradeOrderDO tradeOrderDO, List tradeOrderItemDOs, - List spus, TradeOrderProperties tradeOrderProperties) { - PayOrderCreateReqDTO createReqDTO = new PayOrderCreateReqDTO() - .setAppId(tradeOrderProperties.getAppId()).setUserIp(tradeOrderDO.getUserIp()); - // 商户相关字段 - createReqDTO.setMerchantOrderId(String.valueOf(tradeOrderDO.getId())); - String subject = spus.get(0).getName(); - if (spus.size() > 1) { - subject += " 等多件"; - } - createReqDTO.setSubject(subject); - // 订单相关字段 - createReqDTO.setAmount(tradeOrderDO.getPayPrice()).setExpireTime(addTime(tradeOrderProperties.getExpireTime())); - return createReqDTO; - } - - default Set convertPropertyValueIds(List list) { - if (CollUtil.isEmpty(list)) { - return new HashSet<>(); - } - return list.stream().filter(item -> item.getProperties() != null) - .flatMap(p -> p.getProperties().stream()) // 遍历多个 Property 属性 - .map(TradeOrderItemDO.Property::getValueId) // 将每个 Property 转换成对应的 propertyId,最后形成集合 - .collect(Collectors.toSet()); - } - - default PageResult convertPage(PageResult pageResult, List orderItems, - List propertyValueDetails) { - Map> orderItemMap = convertMultiMap(orderItems, TradeOrderItemDO::getOrderId); - Map propertyValueDetailMap = convertMap(propertyValueDetails, ProductPropertyValueDetailRespDTO::getValueId); - // 转化 List - List orderVOs = CollectionUtils.convertList(pageResult.getList(), order -> { - List xOrderItems = orderItemMap.get(order.getId()); - TradeOrderPageItemRespVO orderVO = convert(order, xOrderItems); - if (CollUtil.isNotEmpty(xOrderItems)) { - // 处理商品属性 - for (int i = 0; i < xOrderItems.size(); i++) { - List properties = xOrderItems.get(i).getProperties(); - if (CollUtil.isEmpty(properties)) { - continue; - } - TradeOrderPageItemRespVO.Item item = orderVO.getItems().get(i); - item.setProperties(new ArrayList<>(properties.size())); - // 遍历每个 properties,设置到 TradeOrderPageItemRespVO.Item 中 - properties.forEach(property -> { - ProductPropertyValueDetailRespDTO propertyValueDetail = propertyValueDetailMap.get(property.getValueId()); - if (propertyValueDetail == null) { - return; - } - item.getProperties().add(convert(propertyValueDetail)); - }); - } - } - // 处理收货地址 - orderVO.setReceiverAreaName(AreaUtils.format(order.getReceiverAreaId())); - return orderVO; - }); - return new PageResult<>(orderVOs, pageResult.getTotal()); - } - TradeOrderPageItemRespVO convert(TradeOrderDO order, List items); - ProductPropertyValueDetailRespVO convert(ProductPropertyValueDetailRespDTO bean); - - default TradeOrderDetailRespVO convert(TradeOrderDO order, List orderItems, - List propertyValueDetails, MemberUserRespDTO user) { - TradeOrderDetailRespVO orderVO = convert2(order, orderItems); - // 处理商品属性 - Map propertyValueDetailMap = convertMap(propertyValueDetails, ProductPropertyValueDetailRespDTO::getValueId); - for (int i = 0; i < orderItems.size(); i++) { - List properties = orderItems.get(i).getProperties(); - if (CollUtil.isEmpty(properties)) { - continue; - } - TradeOrderDetailRespVO.Item item = orderVO.getItems().get(i); - item.setProperties(new ArrayList<>(properties.size())); - // 遍历每个 properties,设置到 TradeOrderPageItemRespVO.Item 中 - properties.forEach(property -> { - ProductPropertyValueDetailRespDTO propertyValueDetail = propertyValueDetailMap.get(property.getValueId()); - if (propertyValueDetail == null) { - return; - } - item.getProperties().add(convert(propertyValueDetail)); - }); - } - // 处理收货地址 - orderVO.setReceiverAreaName(AreaUtils.format(order.getReceiverAreaId())); - // 处理用户信息 - orderVO.setUser(convert(user)); - return orderVO; - } - TradeOrderDetailRespVO convert2(TradeOrderDO order, List items); - MemberUserRespVO convert(MemberUserRespDTO bean); - - default PageResult convertPage02(PageResult pageResult, List orderItems, - List propertyValueDetails) { - Map> orderItemMap = convertMultiMap(orderItems, TradeOrderItemDO::getOrderId); - Map propertyValueDetailMap = convertMap(propertyValueDetails, ProductPropertyValueDetailRespDTO::getValueId); - // 转化 List - List orderVOs = CollectionUtils.convertList(pageResult.getList(), order -> { - List xOrderItems = orderItemMap.get(order.getId()); - AppTradeOrderPageItemRespVO orderVO = convert02(order, xOrderItems); - if (CollUtil.isNotEmpty(xOrderItems)) { - // 处理商品属性 - for (int i = 0; i < xOrderItems.size(); i++) { - List properties = xOrderItems.get(i).getProperties(); - if (CollUtil.isEmpty(properties)) { - continue; - } - AppTradeOrderPageItemRespVO.Item item = orderVO.getItems().get(i); - item.setProperties(new ArrayList<>(properties.size())); - // 遍历每个 properties,设置到 TradeOrderPageItemRespVO.Item 中 - properties.forEach(property -> { - ProductPropertyValueDetailRespDTO propertyValueDetail = propertyValueDetailMap.get(property.getValueId()); - if (propertyValueDetail == null) { - return; - } - item.getProperties().add(convert02(propertyValueDetail)); - }); - } - } - return orderVO; - }); - return new PageResult<>(orderVOs, pageResult.getTotal()); - } - AppTradeOrderPageItemRespVO convert02(TradeOrderDO order, List items); - AppProductPropertyValueDetailRespVO convert02(ProductPropertyValueDetailRespDTO bean); - - default AppTradeOrderDetailRespVO convert02(TradeOrderDO order, List orderItems, - List propertyValueDetails) { - AppTradeOrderDetailRespVO orderVO = convert3(order, orderItems); - // 处理商品属性 - Map propertyValueDetailMap = convertMap(propertyValueDetails, ProductPropertyValueDetailRespDTO::getValueId); - for (int i = 0; i < orderItems.size(); i++) { - List properties = orderItems.get(i).getProperties(); - if (CollUtil.isEmpty(properties)) { - continue; - } - AppTradeOrderDetailRespVO.Item item = orderVO.getItems().get(i); - item.setProperties(new ArrayList<>(properties.size())); - // 遍历每个 properties,设置到 TradeOrderPageItemRespVO.Item 中 - properties.forEach(property -> { - ProductPropertyValueDetailRespDTO propertyValueDetail = propertyValueDetailMap.get(property.getValueId()); - if (propertyValueDetail == null) { - return; - } - item.getProperties().add(convert02(propertyValueDetail)); - }); - } - // 处理收货地址 - orderVO.setReceiverAreaName(AreaUtils.format(order.getReceiverAreaId())); - return orderVO; - } - AppTradeOrderDetailRespVO convert3(TradeOrderDO order, List items); - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/aftersale/TradeAfterSaleDO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/aftersale/TradeAfterSaleDO.java deleted file mode 100644 index 1b703d9e7..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/aftersale/TradeAfterSaleDO.java +++ /dev/null @@ -1,201 +0,0 @@ -package cn.iocoder.yudao.module.trade.dal.dataobject.aftersale; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderItemDO; -import cn.iocoder.yudao.module.trade.enums.aftersale.TradeAfterSaleStatusEnum; -import cn.iocoder.yudao.module.trade.enums.aftersale.TradeAfterSaleTypeEnum; -import cn.iocoder.yudao.module.trade.enums.aftersale.TradeAfterSaleWayEnum; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableName; -import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.experimental.Accessors; - -import java.time.LocalDateTime; -import java.util.List; - -/** - * 交易售后,用于处理 {@link TradeOrderDO} 交易订单的退款退货流程 - * - * @author 芋道源码 - */ -@TableName(value = "trade_after_sale", autoResultMap = true) -@Data -@EqualsAndHashCode(callSuper = true) -@Accessors(chain = true) -public class TradeAfterSaleDO extends BaseDO { - - /** - * 售后编号,主键自增 - */ - private Long id; - /** - * 售后流水号 - * - * 例如说,1146347329394184195 - */ - private String no; - /** - * 退款状态 - * - * 枚举 {@link TradeAfterSaleStatusEnum} - */ - private Integer status; - /** - * 售后方式 - * - * 枚举 {@link TradeAfterSaleWayEnum} - */ - private Integer way; - /** - * 售后类型 - * - * 枚举 {@link TradeAfterSaleTypeEnum} - */ - private Integer type; - /** - * 用户编号 - * - * 关联 MemberUserDO 的 id 编号 - */ - private Long userId; - /** - * 申请原因 - * - * type = 退款,对应 trade_after_sale_refund_reason 类型 - * type = 退货退款,对应 trade_after_sale_refund_and_return_reason 类型 - */ - private String applyReason; - /** - * 补充描述 - */ - private String applyDescription; - /** - * 补充凭证图片 - * - * 数组,以逗号分隔 - */ - @TableField(typeHandler = JacksonTypeHandler.class) - private List applyPicUrls; - - // ========== 交易订单相关 ========== - /** - * 交易订单编号 - * - * 关联 {@link TradeOrderDO#getId()} - */ - private Long orderId; - /** - * 订单流水号 - * - * 冗余 {@link TradeOrderDO#getNo()} - */ - private String orderNo; - /** - * 交易订单项编号 - * - * 关联 {@link TradeOrderItemDO#getId()} - */ - private Long orderItemId; - /** - * 商品 SPU 编号 - * - * 关联 ProductSpuDO 的 id 字段 - * 冗余 {@link TradeOrderItemDO#getSpuId()} - */ - private Long spuId; - /** - * 商品 SPU 名称 - * - * 关联 ProductSkuDO 的 name 字段 - * 冗余 {@link TradeOrderItemDO#getSpuName()} - */ - private String spuName; - /** - * 商品 SKU 编号 - * - * 关联 ProductSkuDO 的编号 - */ - private Long skuId; - /** - * 属性数组,JSON 格式 - * - * 冗余 {@link TradeOrderItemDO#getProperties()} - */ - @TableField(typeHandler = TradeOrderItemDO.PropertyTypeHandler.class) - private List properties; - /** - * 商品图片 - * - * 冗余 {@link TradeOrderItemDO#getPicUrl()} - */ - private String picUrl; - /** - * 退货商品数量 - */ - private Integer count; - - // ========== 审批相关 ========== - - /** - * 审批时间 - */ - private LocalDateTime auditTime; - /** - * 审批人 - * - * 关联 AdminUserDO 的 id 编号 - */ - private Long auditUserId; - /** - * 审批备注 - * - * 注意,只有审批不通过才会填写 - */ - private String auditReason; - - // ========== 退款相关 ========== - /** - * 退款金额,单位:分。 - */ - private Integer refundPrice; - /** - * 支付退款编号 - * - * 对接 pay-module-biz 支付服务的退款订单编号,即 PayRefundDO 的 id 编号 - */ - private Long payRefundId; - /** - * 退款时间 - */ - private LocalDateTime refundTime; - - // ========== 退货相关 ========== - /** - * 退货物流公司编号 - * - * 关联 LogisticsDO 的 id 编号 - */ - private Long logisticsId; - /** - * 退货物流单号 - */ - private String logisticsNo; - /** - * 退货时间 - */ - private LocalDateTime deliveryTime; - /** - * 收货时间 - */ - private LocalDateTime receiveTime; - /** - * 收货备注 - * - * 注意,只有拒绝收货才会填写 - */ - private String receiveReason; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/aftersale/TradeAfterSaleLogDO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/aftersale/TradeAfterSaleLogDO.java deleted file mode 100644 index 5aa627403..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/aftersale/TradeAfterSaleLogDO.java +++ /dev/null @@ -1,83 +0,0 @@ -package cn.iocoder.yudao.module.trade.dal.dataobject.aftersale; - -import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderItemDO; -import cn.iocoder.yudao.module.trade.enums.aftersale.TradeAfterSaleStatusEnum; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -/** - * 交易售后日志 DO - * - * // TODO 可优化:参考淘宝或者有赞:1)增加 action 表示什么操作;2)content 记录每个操作的明细 - * - * @author 芋道源码 - */ -@TableName("trade_after_sale_log") -@KeySequence("trade_after_sale_log_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class TradeAfterSaleLogDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - /** - * 用户编号 - * - * 关联 1:AdminUserDO 的 id 字段 - * 关联 2:MemberUserDO 的 id 字段 - */ - private Long userId; - /** - * 用户类型 - * - * 枚举 {@link UserTypeEnum} - */ - private Integer userType; - /** - * 售后编号 - * - * 关联 {@link TradeAfterSaleDO#getId()} - */ - private Long afterSaleId; - /** - * 订单编号 - * - * 关联 {@link TradeOrderDO#getId()} - */ - private Long orderId; - /** - * 订单项编号 - * - * 关联 {@link TradeOrderItemDO#getId()} - */ - private Long orderItemId; - /** - * 售后状态(之前) - * - * 枚举 {@link TradeAfterSaleStatusEnum} - */ - private Integer beforeStatus; - /** - * 售后状态(之后) - * - * 枚举 {@link TradeAfterSaleStatusEnum} - */ - private Integer afterStatus; - /** - * 操作明细 - */ - private String content; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/cart/TradeCartItemDO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/cart/TradeCartItemDO.java deleted file mode 100644 index 05fbb801d..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/cart/TradeCartItemDO.java +++ /dev/null @@ -1,90 +0,0 @@ -package cn.iocoder.yudao.module.trade.dal.dataobject.cart; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.experimental.Accessors; - -/** - * 购物车的商品信息 DO - * - * @author 芋道源码 - */ -@TableName("trade_cart_item") -@Data -@EqualsAndHashCode(callSuper = true) -@Accessors(chain = true) -public class TradeCartItemDO extends BaseDO { - - // ========= 基础字段 BEGIN ========= - - /** - * 编号,唯一自增 - */ - private Long id; - /** - * 是否选中 - */ - private Boolean selected; - - // ========= 基础字段 END ========= - - // ========= 买家信息 BEGIN ========= - - /** - * 用户编号 - * - * 关联 MemberUserDO 的 id 编号 - */ - private Long userId; - - // ========= 买家信息 END ========= - - // ========= 商品信息 BEGIN ========= - - /** - * 商品 SPU 编号 - * - * 关联 ProductSpuDO 的 id 编号 - */ - private Long spuId; - /** - * 商品 SKU 编号 - * - * 关联 ProductSkuDO 的 id 编号 - */ - private Long skuId; - /** - * 商品购买数量 - */ - private Integer count; - - // ========= 商品信息 END ========= - - // ========= 优惠信息 BEGIN ========= - -// /** -// * 商品营销活动编号 -// */ -// private Long activityId; // discount_id -// /** -// * 商品营销活动类型 -// */ -// private Integer activityType; - // TODO 芋艿:combination_id 拼团 ID - // TODO 芋艿:seckill_id 秒杀产品 ID - // TODO 芋艿:bargain_id 砍价 ID - - // ========= 优惠信息 END ========= - - // TODO 待确定字段:mf - // TODO 芋艿:distribution_card_no 推广员 - // TODO 芋艿:is_pay 未购买、已购买 - // TODO 芋艿:is_new 是否立即购买 - - // TODO 待确定字段: yv - // TODO isPay: 是否购买 - // TODO isNew:是否立即购买 - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/order/TradeOrderDO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/order/TradeOrderDO.java deleted file mode 100644 index 49d60ee37..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/order/TradeOrderDO.java +++ /dev/null @@ -1,257 +0,0 @@ -package cn.iocoder.yudao.module.trade.dal.dataobject.order; - -import cn.iocoder.yudao.framework.common.enums.TerminalEnum; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.promotion.api.price.dto.PriceCalculateRespDTO.OrderItem; -import cn.iocoder.yudao.module.trade.enums.order.TradeOrderCancelTypeEnum; -import cn.iocoder.yudao.module.trade.enums.order.TradeOrderAfterSaleStatusEnum; -import cn.iocoder.yudao.module.trade.enums.order.TradeOrderDeliveryStatusEnum; -import cn.iocoder.yudao.module.trade.enums.order.TradeOrderStatusEnum; -import cn.iocoder.yudao.module.trade.enums.order.TradeOrderTypeEnum; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.time.LocalDateTime; - -/** - * 交易订单 DO - * - * @author 芋道源码 - */ -@TableName("trade_order") -@KeySequence("trade_order_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class TradeOrderDO extends BaseDO { - - // ========== 订单基本信息 ========== - /** - * 订单编号,主键自增 - */ - private Long id; - /** - * 订单流水号 - * - * 例如说,1146347329394184195 - */ - private String no; - /** - * 订单类型 - * - * 枚举 {@link TradeOrderTypeEnum} - */ - private Integer type; - /** - * 订单来源 - * - * 枚举 {@link TerminalEnum} - */ - private Integer terminal; - /** - * 用户编号 - * - * 关联 MemberUserDO 的 id 编号 - */ - private Long userId; - /** - * 用户 IP - */ - private String userIp; - /** - * 用户备注 - */ - private String userRemark; - /** - * 订单状态 - * - * 枚举 {@link TradeOrderStatusEnum} - */ - private Integer status; - /** - * 购买的商品数量 - */ - private Integer productCount; - /** - * 订单完成时间 - */ - private LocalDateTime finishTime; - /** - * 订单取消时间 - */ - private LocalDateTime cancelTime; - /** - * 取消类型 - * - * 枚举 {@link TradeOrderCancelTypeEnum} - */ - private Integer cancelType; - /** - * 商家备注 - */ - private String remark; - - // ========== 价格 + 支付基本信息 ========== - - // 价格文档 - 淘宝:https://open.taobao.com/docV3.htm?docId=108471&docType=1 - // 价格文档 - 京东到家:https://openo2o.jddj.com/api/getApiDetail/182/4d1494c5e7ac4679bfdaaed950c5bc7f.htm - // 价格文档 - 有赞:https://doc.youzanyun.com/detail/API/0/906 - - /** - * 支付订单编号 - * - * 对接 pay-module-biz 支付服务的支付订单编号,即 PayOrderDO 的 id 编号 - */ - private Long payOrderId; - /** - * 是否已支付 - * - * true - 已经支付过 - * false - 没有支付过 - */ - private Boolean payed; - /** - * 付款时间 - */ - private LocalDateTime payTime; - /** - * 支付渠道 - * - * 对应 PayChannelEnum 枚举 - */ - private String payChannelCode; - - /** - * 商品原价(总),单位:分 - * - * 基于 {@link TradeOrderItemDO#getOriginalPrice()} 求和 - * - * 对应 taobao 的 trade.total_fee 字段 - */ - private Integer originalPrice; - /** - * 订单原价(总),单位:分 - * - * 基于 {@link OrderItem#getPayPrice()} 求和 - * 和 {@link #originalPrice} 的差异:去除商品级优惠 - */ - private Integer orderPrice; - /** - * 订单优惠(总),单位:分 - * - * 订单级优惠:对主订单的优惠,常见如:订单满 200 元减 10 元;订单满 80 包邮。 - * - * 对应 taobao 的 order.discount_fee 字段 - */ - private Integer discountPrice; - /** - * 运费金额,单位:分 - */ - private Integer deliveryPrice; - /** - * 订单调价(总),单位:分 - * - * 正数,加价;负数,减价 - */ - private Integer adjustPrice; - /** - * 应付金额(总),单位:分 - * - * = {@link OrderItem#getPayPrice()} 求和 - * - {@link #couponPrice} - * - {@link #pointPrice} - * + {@link #deliveryPrice} - * - {@link #discountPrice} - * + {@link #adjustPrice} - */ - private Integer payPrice; - - // ========== 收件 + 物流基本信息 ========== - /** - * 配置模板的编号 - * - * 关联 DeliveryTemplateDO 的 id 编号 - */ - private Long deliveryTemplateId; - /** - * 发货物流公司编号 - */ - private Long logisticsId; - /** - * 发货物流单号 - */ - private String logisticsNo; - /** - * 发货状态 - * - * 枚举 {@link TradeOrderDeliveryStatusEnum} - */ - private Integer deliveryStatus; - /** - * 发货时间 - */ - private LocalDateTime deliveryTime; - - /** - * 收货时间 - */ - private LocalDateTime receiveTime; - /** - * 收件人名称 - */ - private String receiverName; - /** - * 收件人手机 - */ - private String receiverMobile; - /** - * 收件人地区编号 - */ - private Integer receiverAreaId; - /** - * 收件人邮编 - */ - private Integer receiverPostCode; - /** - * 收件人详细地址 - */ - private String receiverDetailAddress; - - // ========== 售后基本信息 ========== - /** - * 收货状态 - * - * 枚举 {@link TradeOrderAfterSaleStatusEnum} - */ - private Integer afterSaleStatus; - /** - * 退款金额,单位:分 - * - * 注意,退款并不会影响 {@link #payPrice} 实际支付金额 - * 也就说,一个订单最终产生多少金额的收入 = payPrice - refundPrice - */ - private Integer refundPrice; - - // ========== 营销基本信息 ========== - /** - * 优惠劵编号 - */ - private Long couponId; - /** - * 优惠劵减免金额,单位:分 - * - * 对应 taobao 的 trade.coupon_fee 字段 - */ - private Integer couponPrice; - /** - * 积分抵扣的金额,单位:分 - * - * 对应 taobao 的 trade.point_fee 字段 - */ - private Integer pointPrice; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/order/TradeOrderItemDO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/order/TradeOrderItemDO.java deleted file mode 100644 index f8438030b..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/order/TradeOrderItemDO.java +++ /dev/null @@ -1,190 +0,0 @@ -package cn.iocoder.yudao.module.trade.dal.dataobject.order; - -import cn.iocoder.yudao.framework.common.util.json.JsonUtils; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.aftersale.TradeAfterSaleDO; -import cn.iocoder.yudao.module.trade.enums.order.TradeOrderItemAfterSaleStatusEnum; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableName; -import com.baomidou.mybatisplus.extension.handlers.AbstractJsonTypeHandler; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.experimental.Accessors; - -import java.io.Serializable; -import java.util.List; - -/** - * 交易订单项 DO - * - * @author 芋道源码 - */ -@TableName(value = "trade_order_item", autoResultMap = true) -@Data -@Accessors(chain = true) -@EqualsAndHashCode(callSuper = true) -public class TradeOrderItemDO extends BaseDO { - - // ========== 订单项基本信息 ========== - /** - * 编号 - */ - private Long id; - /** - * 用户编号 - * - * 关联 MemberUserDO 的 id 编号 - */ - private Long userId; - /** - * 订单编号 - * - * 关联 {@link TradeOrderDO#getId()} - */ - private Long orderId; - - // ========== 商品基本信息; 冗余较多字段,减少关联查询 ========== - /** - * 商品 SPU 编号 - * - * 关联 ProductSkuDO 的 spuId 编号 - */ - private Long spuId; - /** - * 商品 SPU 名称 - * - * 冗余 ProductSkuDO 的 spuName 编号 - */ - private String spuName; - /** - * 商品 SKU 编号 - * - * 关联 ProductSkuDO 的 id 编号 - */ - private Long skuId; - /** - * 属性数组,JSON 格式 - * - * 冗余 ProductSkuDO 的 properties 字段 - */ - @TableField(typeHandler = PropertyTypeHandler.class) - private List properties; - /** - * 商品图片 - */ - private String picUrl; - /** - * 购买数量 - */ - private Integer count; -// /** -// * 是否评论 TODO -// * -// * false - 未评论 -// * true - 已评论 -// */ -// private Boolean commented; - - // ========== 价格 + 支付基本信息 ========== - - /** - * 商品原价(总),单位:分 - * - * = {@link #originalUnitPrice} * {@link #getCount()} - */ - private Integer originalPrice; - /** - * 商品原价(单),单位:分 - * - * 对应 ProductSkuDO 的 price 字段 - * 对应 taobao 的 order.price 字段 - */ - private Integer originalUnitPrice; - /** - * 商品优惠(总),单位:分 - * - * 商品级优惠:对单个商品的,常见如:商品原价的 8 折;商品原价的减 50 元 - * - * 对应 taobao 的 order.discount_fee 字段 - */ - private Integer discountPrice; - /** - * 子订单实付金额,不算主订单分摊金额,单位:分 - * - * = {@link #originalPrice} - * - {@link #discountPrice} - * - * 对应 taobao 的 order.payment 字段 - */ - private Integer payPrice; - - /** - * 子订单分摊金额(总),单位:分 - * 需要分摊 {@link TradeOrderDO#getDiscountPrice()}、{@link TradeOrderDO#getCouponPrice()}、{@link TradeOrderDO#getPointPrice()} - * - * 对应 taobao 的 order.part_mjz_discount 字段 - * 淘宝说明:子订单分摊优惠基础逻辑:一般正常优惠券和满减优惠按照子订单的金额进行分摊,特殊情况如果优惠券是指定商品使用的,只会分摊到对应商品子订单上不分摊。 - */ - private Integer orderPartPrice; - /** - * 分摊后子订单实付金额(总),单位:分 - * - * = {@link #payPrice} - * - {@link #orderPartPrice} - * - * 对应 taobao 的 divide_order_fee 字段 - */ - private Integer orderDividePrice; - - // ========== 营销基本信息 ========== - - // TODO 芋艿:在捉摸一下 - - // ========== 售后基本信息 ========== - /** - * 售后状态 - * - * 枚举 {@link TradeOrderItemAfterSaleStatusEnum} - * - * @see TradeAfterSaleDO - */ - private Integer afterSaleStatus; - - /** - * 商品属性 - */ - @Data - public static class Property implements Serializable { - - /** - * 属性编号 - * - * 关联 ProductPropertyDO 的 id 编号 - */ - private Long propertyId; - /** - * 属性值编号 - * - * 关联 ProductPropertyValueDO 的 id 编号 - */ - private Long valueId; - - } - - // TODO @芋艿:可以找一些新的思路 - public static class PropertyTypeHandler extends AbstractJsonTypeHandler> { - - @Override - protected List parse(String json) { - return JsonUtils.parseArray(json, Property.class); - } - - @Override - protected String toJson(List obj) { - return JsonUtils.toJsonString(obj); - } - - } - -} - diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/aftersale/TradeAfterSaleLogMapper.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/aftersale/TradeAfterSaleLogMapper.java deleted file mode 100644 index b92ce075f..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/aftersale/TradeAfterSaleLogMapper.java +++ /dev/null @@ -1,9 +0,0 @@ -package cn.iocoder.yudao.module.trade.dal.mysql.aftersale; - -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.module.trade.dal.dataobject.aftersale.TradeAfterSaleLogDO; -import org.apache.ibatis.annotations.Mapper; - -@Mapper -public interface TradeAfterSaleLogMapper extends BaseMapperX { -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/aftersale/TradeAfterSaleMapper.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/aftersale/TradeAfterSaleMapper.java deleted file mode 100644 index 175d7d2b0..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/aftersale/TradeAfterSaleMapper.java +++ /dev/null @@ -1,35 +0,0 @@ -package cn.iocoder.yudao.module.trade.dal.mysql.aftersale; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo.TradeAfterSalePageReqVO; -import cn.iocoder.yudao.module.trade.dal.dataobject.aftersale.TradeAfterSaleDO; -import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; -import org.apache.ibatis.annotations.Mapper; - -@Mapper -public interface TradeAfterSaleMapper extends BaseMapperX { - - default PageResult selectPage(TradeAfterSalePageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .likeIfPresent(TradeAfterSaleDO::getNo, reqVO.getNo()) - .eqIfPresent(TradeAfterSaleDO::getStatus, reqVO.getStatus()) - .eqIfPresent(TradeAfterSaleDO::getType, reqVO.getType()) - .eqIfPresent(TradeAfterSaleDO::getWay, reqVO.getWay()) - .likeIfPresent(TradeAfterSaleDO::getOrderNo, reqVO.getOrderNo()) - .likeIfPresent(TradeAfterSaleDO::getSpuName, reqVO.getSpuName()) - .betweenIfPresent(TradeAfterSaleDO::getCreateTime, reqVO.getCreateTime()) - .orderByDesc(TradeAfterSaleDO::getId)); - } - - default int updateByIdAndStatus(Long id, Integer status, TradeAfterSaleDO update) { - return update(update, new LambdaUpdateWrapper() - .eq(TradeAfterSaleDO::getId, id).eq(TradeAfterSaleDO::getStatus, status)); - } - - default TradeAfterSaleDO selectByPayRefundId(Long payRefundId) { - return selectOne(TradeAfterSaleDO::getPayRefundId, payRefundId); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/cart/TradeCartItemMapper.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/cart/TradeCartItemMapper.java deleted file mode 100644 index fa6adbf41..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/cart/TradeCartItemMapper.java +++ /dev/null @@ -1,47 +0,0 @@ -package cn.iocoder.yudao.module.trade.dal.mysql.cart; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.map.MapUtil; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.trade.dal.dataobject.cart.TradeCartItemDO; -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import org.apache.ibatis.annotations.Mapper; - -import java.util.Collection; -import java.util.List; -import java.util.Map; - -@Mapper -public interface TradeCartItemMapper extends BaseMapperX { - - default TradeCartItemDO selectByUserIdAndSkuId(Long userId, Long skuId) { - return selectOne(TradeCartItemDO::getUserId, userId, - TradeCartItemDO::getSkuId, skuId); - } - - default List selectListByUserIdAndSkuIds(Long userId, Collection skuIds) { - return selectList(new LambdaQueryWrapper().eq(TradeCartItemDO::getUserId, userId) - .in(TradeCartItemDO::getSkuId, skuIds)); - } - - default void updateByIds(Collection ids, TradeCartItemDO updateObject) { - update(updateObject, new LambdaQueryWrapper().in(TradeCartItemDO::getId, ids)); - } - - default Integer selectSumByUserId(Long userId) { - // SQL sum 查询 - List> result = selectMaps(new QueryWrapper() - .select("SUM(count) AS sumCount") - .eq("user_id", userId)); - // 获得数量 - return CollUtil.isNotEmpty(result) ? MapUtil.getInt(result.get(0), "sumCount") : 0; - } - - default List selectListByUserId(Long userId, Boolean selected) { - return selectList(new LambdaQueryWrapperX().eq(TradeCartItemDO::getUserId, userId) - .eqIfPresent(TradeCartItemDO::getSelected, selected)); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/order/TradeOrderItemMapper.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/order/TradeOrderItemMapper.java deleted file mode 100644 index edb45fb62..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/order/TradeOrderItemMapper.java +++ /dev/null @@ -1,27 +0,0 @@ -package cn.iocoder.yudao.module.trade.dal.mysql.order; - -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderItemDO; -import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; -import org.apache.ibatis.annotations.Mapper; - -import java.util.Collection; -import java.util.List; - -@Mapper -public interface TradeOrderItemMapper extends BaseMapperX { - - default int updateAfterSaleStatus(Long id, Integer oldAfterSaleStatus, Integer newAfterSaleStatus) { - return update(new TradeOrderItemDO().setAfterSaleStatus(newAfterSaleStatus), - new LambdaUpdateWrapper<>(new TradeOrderItemDO().setId(id).setAfterSaleStatus(oldAfterSaleStatus))); - } - - default List selectListByOrderId(Long orderId) { - return selectList(TradeOrderItemDO::getOrderId, orderId); - } - - default List selectListByOrderId(Collection orderIds) { - return selectList(TradeOrderItemDO::getOrderId, orderIds); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/order/TradeOrderMapper.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/order/TradeOrderMapper.java deleted file mode 100644 index 7be224744..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/order/TradeOrderMapper.java +++ /dev/null @@ -1,46 +0,0 @@ -package cn.iocoder.yudao.module.trade.dal.mysql.order; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderPageReqVO; -import cn.iocoder.yudao.module.trade.controller.app.order.vo.AppTradeOrderPageReqVO; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderDO; -import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; -import org.apache.ibatis.annotations.Mapper; - -import java.util.Set; - -@Mapper -public interface TradeOrderMapper extends BaseMapperX { - - default int updateByIdAndStatus(Long id, Integer status, TradeOrderDO update) { - return update(update, new LambdaUpdateWrapper() - .eq(TradeOrderDO::getId, id).eq(TradeOrderDO::getStatus, status)); - } - - default TradeOrderDO selectByIdAndUserId(Long id, Long userId) { - return selectOne(TradeOrderDO::getId, id, TradeOrderDO::getUserId, userId); - } - - default PageResult selectPage(TradeOrderPageReqVO reqVO, Set userIds) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .likeIfPresent(TradeOrderDO::getNo, reqVO.getNo()) - .eqIfPresent(TradeOrderDO::getUserId, reqVO.getUserId()) - .inIfPresent(TradeOrderDO::getUserId, userIds) - .likeIfPresent(TradeOrderDO::getReceiverName, reqVO.getReceiverName()) - .likeIfPresent(TradeOrderDO::getReceiverMobile, reqVO.getReceiverMobile()) - .eqIfPresent(TradeOrderDO::getType, reqVO.getType()) - .eqIfPresent(TradeOrderDO::getStatus, reqVO.getStatus()) - .eqIfPresent(TradeOrderDO::getPayChannelCode, reqVO.getPayChannelCode()) - .betweenIfPresent(TradeOrderDO::getCreateTime, reqVO.getCreateTime())); - } - - default PageResult selectPage(AppTradeOrderPageReqVO reqVO, Long userId) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .eq(TradeOrderDO::getUserId, userId) - .eqIfPresent(TradeOrderDO::getStatus, reqVO.getStatus()) - .orderByDesc(TradeOrderDO::getId)); // TODO 芋艿:未来不同的 status,不同的排序 - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/package-info.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/package-info.java deleted file mode 100644 index 37e0ba7d6..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * TODO 占位 - */ -package cn.iocoder.yudao.module.trade.dal.mysql; diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/order/config/TradeOrderConfig.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/order/config/TradeOrderConfig.java deleted file mode 100644 index 715169275..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/order/config/TradeOrderConfig.java +++ /dev/null @@ -1,14 +0,0 @@ -package cn.iocoder.yudao.module.trade.framework.order.config; - -import org.springframework.boot.context.properties.EnableConfigurationProperties; -import org.springframework.context.annotation.Configuration; - -// TODO @LeeYan9: 可以直接给 TradeOrderProperties 一个 @Component生效哈 -/** - * @author LeeYan9 - * @since 2022-09-15 - */ -@Configuration -@EnableConfigurationProperties(TradeOrderProperties.class) -public class TradeOrderConfig { -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/order/config/TradeOrderProperties.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/order/config/TradeOrderProperties.java deleted file mode 100644 index 4d584f4c9..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/order/config/TradeOrderProperties.java +++ /dev/null @@ -1,33 +0,0 @@ -package cn.iocoder.yudao.module.trade.framework.order.config; - -import lombok.Data; -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.validation.annotation.Validated; - -import javax.validation.constraints.NotNull; -import java.time.Duration; - -/** - * 交易订单的配置项 - * - * @author LeeYan9 - * @since 2022-09-15 - */ -@ConfigurationProperties(prefix = "yudao.trade.order") -@Data -@Validated -public class TradeOrderProperties { - - /** - * 应用编号 - */ - @NotNull(message = "应用编号不能为空") - private Long appId; - - /** - * 支付超时时间 - */ - @NotNull(message = "支付超时时间不能为空") - private Duration expireTime; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/package-info.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/package-info.java deleted file mode 100644 index 393abea6a..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/package-info.java +++ /dev/null @@ -1,8 +0,0 @@ -/** - * product 模块,product 模块,主要实现商品相关功能 - * 例如:品牌、商品分类、spu、sku等功能。 - * - * 1. Controller URL:以 /product/ 开头,避免和其它 Module 冲突 - * 2. DataObject 表名:以 product_ 开头,方便在数据库中区分 - */ -package cn.iocoder.yudao.module.trade; diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/aftersale/TradeAfterSaleService.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/aftersale/TradeAfterSaleService.java deleted file mode 100644 index d0d86c033..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/aftersale/TradeAfterSaleService.java +++ /dev/null @@ -1,94 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.aftersale; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo.TradeAfterSaleDisagreeReqVO; -import cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo.TradeAfterSalePageReqVO; -import cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo.TradeAfterSaleRefuseReqVO; -import cn.iocoder.yudao.module.trade.controller.app.aftersale.vo.AppTradeAfterSaleCreateReqVO; -import cn.iocoder.yudao.module.trade.controller.app.aftersale.vo.AppTradeAfterSaleDeliveryReqVO; -import cn.iocoder.yudao.module.trade.dal.dataobject.aftersale.TradeAfterSaleDO; - -/** - * 交易售后 Service 接口 - * - * @author 芋道源码 - */ -public interface TradeAfterSaleService { - - /** - * 获得交易售后分页 - * - * @param pageReqVO 分页查询 - * @return 交易售后分页 - */ - PageResult getAfterSalePage(TradeAfterSalePageReqVO pageReqVO); - - /** - * 【会员】创建交易售后 - *

- * 一般是用户发起售后请求 - * - * @param userId 会员用户编号 - * @param createReqVO 创建 Request 信息 - * @return 交易售后编号 - */ - Long createAfterSale(Long userId, AppTradeAfterSaleCreateReqVO createReqVO); - - /** - * 【管理员】同意交易售后 - * - * @param userId 管理员用户编号 - * @param id 交易售后编号 - */ - void agreeAfterSale(Long userId, Long id); - - /** - * 【管理员】拒绝交易售后 - * - * @param userId 管理员用户编号 - * @param auditReqVO 审批 Request 信息 - */ - void disagreeAfterSale(Long userId, TradeAfterSaleDisagreeReqVO auditReqVO); - - /** - * 【会员】退回货物 - * - * @param userId 会员用户编号 - * @param deliveryReqVO 退货 Request 信息 - */ - void deliveryAfterSale(Long userId, AppTradeAfterSaleDeliveryReqVO deliveryReqVO); - - /** - * 【管理员】确认收货 - * - * @param userId 管理员编号 - * @param id 交易售后编号 - */ - void receiveAfterSale(Long userId, Long id); - - /** - * 【管理员】拒绝收货 - * - * @param userId 管理员用户编号 - * @param refuseReqVO 拒绝收货 Request 信息 - */ - void refuseAfterSale(Long userId, TradeAfterSaleRefuseReqVO refuseReqVO); - - /** - * 【管理员】确认退款 - * - * @param userId 管理员用户编号 - * @param userIp 管理员用户 IP - * @param id 售后编号 - */ - void refundAfterSale(Long userId, String userIp, Long id); - - /** - * 【会员】取消售后 - * - * @param userId 会员用户编号 - * @param id 交易售后编号 - */ - void cancelAfterSale(Long userId, Long id); - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/aftersale/TradeAfterSaleServiceImpl.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/aftersale/TradeAfterSaleServiceImpl.java deleted file mode 100644 index 2da892d61..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/aftersale/TradeAfterSaleServiceImpl.java +++ /dev/null @@ -1,392 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.aftersale; - -import cn.hutool.core.util.ObjectUtil; -import cn.hutool.core.util.RandomUtil; -import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.object.ObjectUtils; -import cn.iocoder.yudao.module.pay.api.refund.PayRefundApi; -import cn.iocoder.yudao.module.pay.api.refund.dto.PayRefundCreateReqDTO; -import cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo.TradeAfterSaleDisagreeReqVO; -import cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo.TradeAfterSalePageReqVO; -import cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo.TradeAfterSaleRefuseReqVO; -import cn.iocoder.yudao.module.trade.controller.app.aftersale.vo.AppTradeAfterSaleCreateReqVO; -import cn.iocoder.yudao.module.trade.controller.app.aftersale.vo.AppTradeAfterSaleDeliveryReqVO; -import cn.iocoder.yudao.module.trade.convert.aftersale.TradeAfterSaleConvert; -import cn.iocoder.yudao.module.trade.dal.dataobject.aftersale.TradeAfterSaleDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.aftersale.TradeAfterSaleLogDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderItemDO; -import cn.iocoder.yudao.module.trade.dal.mysql.aftersale.TradeAfterSaleLogMapper; -import cn.iocoder.yudao.module.trade.dal.mysql.aftersale.TradeAfterSaleMapper; -import cn.iocoder.yudao.module.trade.enums.aftersale.TradeAfterSaleStatusEnum; -import cn.iocoder.yudao.module.trade.enums.aftersale.TradeAfterSaleTypeEnum; -import cn.iocoder.yudao.module.trade.enums.aftersale.TradeAfterSaleWayEnum; -import cn.iocoder.yudao.module.trade.enums.order.TradeOrderItemAfterSaleStatusEnum; -import cn.iocoder.yudao.module.trade.enums.order.TradeOrderStatusEnum; -import cn.iocoder.yudao.module.trade.framework.order.config.TradeOrderProperties; -import cn.iocoder.yudao.module.trade.service.order.TradeOrderService; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.transaction.support.TransactionSynchronization; -import org.springframework.transaction.support.TransactionSynchronizationManager; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.*; - -/** - * 交易售后 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class TradeAfterSaleServiceImpl implements TradeAfterSaleService { - - @Resource - private TradeOrderService tradeOrderService; - - @Resource - private TradeAfterSaleMapper tradeAfterSaleMapper; - @Resource - private TradeAfterSaleLogMapper tradeAfterSaleLogMapper; - - @Resource - private PayRefundApi payRefundApi; - - @Resource - private TradeOrderProperties tradeOrderProperties; - - @Override - public PageResult getAfterSalePage(TradeAfterSalePageReqVO pageReqVO) { - return tradeAfterSaleMapper.selectPage(pageReqVO); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public Long createAfterSale(Long userId, AppTradeAfterSaleCreateReqVO createReqVO) { - // 第一步,前置校验 - TradeOrderItemDO tradeOrderItem = validateOrderItemApplicable(userId, createReqVO); - - // 第二步,存储交易售后 - TradeAfterSaleDO afterSale = createAfterSale(createReqVO, tradeOrderItem); - return afterSale.getId(); - } - - /** - * 校验交易订单项是否可以申请售后 - * - * @param userId 用户编号 - * @param createReqVO 售后创建信息 - * @return 交易订单项 - */ - private TradeOrderItemDO validateOrderItemApplicable(Long userId, AppTradeAfterSaleCreateReqVO createReqVO) { - // 校验订单项存在 - TradeOrderItemDO orderItem = tradeOrderService.getOrderItem(userId, createReqVO.getOrderItemId()); - if (orderItem == null) { - throw exception(ORDER_ITEM_NOT_FOUND); - } - - // 已申请售后,不允许再发起售后申请 - if (!TradeOrderItemAfterSaleStatusEnum.isNone(orderItem.getAfterSaleStatus())) { - throw exception(AFTER_SALE_CREATE_FAIL_ORDER_ITEM_APPLIED); - } - - // 申请的退款金额,不能超过商品的价格 - if (createReqVO.getRefundPrice() > orderItem.getOrderDividePrice()) { - throw exception(AFTER_SALE_CREATE_FAIL_REFUND_PRICE_ERROR); - } - - // 校验订单存在 - TradeOrderDO order = tradeOrderService.getOrder(userId, orderItem.getOrderId()); - if (order == null) { - throw exception(ORDER_NOT_FOUND); - } - // TODO 芋艿:超过一定时间,不允许售后 - // 已取消,无法发起售后 - if (TradeOrderStatusEnum.isCanceled(order.getStatus())) { - throw exception(AFTER_SALE_CREATE_FAIL_ORDER_STATUS_CANCELED); - } - // 未支付,无法发起售后 - if (!TradeOrderStatusEnum.havePaid(order.getStatus())) { - throw exception(AFTER_SALE_CREATE_FAIL_ORDER_STATUS_NO_PAID); - } - // 如果是【退货退款】的情况,需要额外校验是否发货 - if (createReqVO.getWay().equals(TradeAfterSaleWayEnum.RETURN_AND_REFUND.getWay()) - && !TradeOrderStatusEnum.haveDelivered(order.getStatus())) { - throw exception(AFTER_SALE_CREATE_FAIL_ORDER_STATUS_NO_DELIVERED); - } - return orderItem; - } - - private TradeAfterSaleDO createAfterSale(AppTradeAfterSaleCreateReqVO createReqVO, - TradeOrderItemDO orderItem) { - // 创建售后单 - TradeAfterSaleDO afterSale = TradeAfterSaleConvert.INSTANCE.convert(createReqVO, orderItem); - afterSale.setNo(RandomUtil.randomString(10)); // TODO 芋艿:优化 no 生成逻辑 - afterSale.setStatus(TradeAfterSaleStatusEnum.APPLY.getStatus()); - // 标记是售中还是售后 - TradeOrderDO order = tradeOrderService.getOrder(orderItem.getUserId(), orderItem.getOrderId()); - afterSale.setOrderNo(order.getNo()); // 记录 orderNo 订单流水,方便后续检索 - afterSale.setType(TradeOrderStatusEnum.isCompleted(order.getStatus()) - ? TradeAfterSaleTypeEnum.AFTER_SALE.getType() : TradeAfterSaleTypeEnum.IN_SALE.getType()); - // TODO 退还积分 - tradeAfterSaleMapper.insert(afterSale); - - // 更新交易订单项的售后状态 - tradeOrderService.updateOrderItemAfterSaleStatus(orderItem.getId(), - TradeOrderItemAfterSaleStatusEnum.NONE.getStatus(), - TradeOrderItemAfterSaleStatusEnum.APPLY.getStatus(), null); - - // 记录售后日志 - createAfterSaleLog(orderItem.getUserId(), UserTypeEnum.MEMBER.getValue(), - afterSale, null, afterSale.getStatus()); - - // TODO 发送售后消息 - return afterSale; - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void agreeAfterSale(Long userId, Long id) { - // 校验售后单存在,并状态未审批 - TradeAfterSaleDO afterSale = validateAfterSaleAuditable(id); - - // 更新售后单的状态 - // 情况一:退款:标记为 WAIT_REFUND 状态。后续等退款发起成功后,在标记为 COMPLETE 状态 - // 情况二:退货退款:需要等用户退货后,才能发起退款 - Integer newStatus = afterSale.getType().equals(TradeAfterSaleWayEnum.REFUND.getWay()) ? - TradeAfterSaleStatusEnum.WAIT_REFUND.getStatus() : TradeAfterSaleStatusEnum.SELLER_AGREE.getStatus(); - updateAfterSaleStatus(afterSale.getId(), TradeAfterSaleStatusEnum.APPLY.getStatus(), new TradeAfterSaleDO() - .setStatus(newStatus).setAuditUserId(userId).setAuditTime(LocalDateTime.now())); - - // 记录售后日志 - createAfterSaleLog(userId, UserTypeEnum.ADMIN.getValue(), - afterSale, afterSale.getStatus(), newStatus); - - // TODO 发送售后消息 - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void disagreeAfterSale(Long userId, TradeAfterSaleDisagreeReqVO auditReqVO) { - // 校验售后单存在,并状态未审批 - TradeAfterSaleDO afterSale = validateAfterSaleAuditable(auditReqVO.getId()); - - // 更新售后单的状态 - Integer newStatus = TradeAfterSaleStatusEnum.SELLER_DISAGREE.getStatus(); - updateAfterSaleStatus(afterSale.getId(), TradeAfterSaleStatusEnum.APPLY.getStatus(), new TradeAfterSaleDO() - .setStatus(newStatus).setAuditUserId(userId).setAuditTime(LocalDateTime.now()) - .setAuditReason(auditReqVO.getAuditReason())); - - // 记录售后日志 - createAfterSaleLog(userId, UserTypeEnum.ADMIN.getValue(), - afterSale, afterSale.getStatus(), newStatus); - - // TODO 发送售后消息 - - // 更新交易订单项的售后状态为【未申请】 - tradeOrderService.updateOrderItemAfterSaleStatus(afterSale.getOrderItemId(), - TradeOrderItemAfterSaleStatusEnum.APPLY.getStatus(), - TradeOrderItemAfterSaleStatusEnum.NONE.getStatus(), null); - } - - /** - * 校验售后单是否可审批(同意售后、拒绝售后) - * - * @param id 售后编号 - * @return 售后单 - */ - private TradeAfterSaleDO validateAfterSaleAuditable(Long id) { - TradeAfterSaleDO afterSale = tradeAfterSaleMapper.selectById(id); - if (afterSale == null) { - throw exception(AFTER_SALE_NOT_FOUND); - } - if (ObjectUtil.notEqual(afterSale.getStatus(), TradeAfterSaleStatusEnum.APPLY.getStatus())) { - throw exception(AFTER_SALE_AUDIT_FAIL_STATUS_NOT_APPLY); - } - return afterSale; - } - - private void updateAfterSaleStatus(Long id, Integer status, TradeAfterSaleDO updateObj) { - int updateCount = tradeAfterSaleMapper.updateByIdAndStatus(id, status, updateObj); - if (updateCount == 0) { - throw exception(AFTER_SALE_UPDATE_STATUS_FAIL); - } - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void deliveryAfterSale(Long userId, AppTradeAfterSaleDeliveryReqVO deliveryReqVO) { - // 校验售后单存在,并状态未退货 - TradeAfterSaleDO afterSale = tradeAfterSaleMapper.selectById(deliveryReqVO.getId()); - if (afterSale == null) { - throw exception(AFTER_SALE_NOT_FOUND); - } - if (ObjectUtil.notEqual(afterSale.getStatus(), TradeAfterSaleStatusEnum.SELLER_AGREE.getStatus())) { - throw exception(AFTER_SALE_DELIVERY_FAIL_STATUS_NOT_SELLER_AGREE); - } - - // 更新售后单的物流信息 - updateAfterSaleStatus(afterSale.getId(), TradeAfterSaleStatusEnum.SELLER_AGREE.getStatus(), new TradeAfterSaleDO() - .setStatus(TradeAfterSaleStatusEnum.BUYER_DELIVERY.getStatus()) - .setLogisticsId(deliveryReqVO.getLogisticsId()).setLogisticsNo(deliveryReqVO.getLogisticsNo()) - .setDeliveryTime(deliveryReqVO.getDeliveryTime())); - - // 记录售后日志 - createAfterSaleLog(userId, UserTypeEnum.MEMBER.getValue(), - afterSale, afterSale.getStatus(), TradeAfterSaleStatusEnum.BUYER_DELIVERY.getStatus()); - - // TODO 发送售后消息 - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void receiveAfterSale(Long userId, Long id) { - // 校验售后单存在,并状态为已退货 - TradeAfterSaleDO afterSale = validateAfterSaleReceivable(id); - - // 更新售后单的状态 - updateAfterSaleStatus(afterSale.getId(), TradeAfterSaleStatusEnum.BUYER_DELIVERY.getStatus(), new TradeAfterSaleDO() - .setStatus(TradeAfterSaleStatusEnum.WAIT_REFUND.getStatus()).setReceiveTime(LocalDateTime.now())); - - // 记录售后日志 - createAfterSaleLog(userId, UserTypeEnum.ADMIN.getValue(), - afterSale, afterSale.getStatus(), TradeAfterSaleStatusEnum.WAIT_REFUND.getStatus()); - - // TODO 发送售后消息 - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void refuseAfterSale(Long userId, TradeAfterSaleRefuseReqVO refuseReqVO) { - // 校验售后单存在,并状态为已退货 - TradeAfterSaleDO afterSale = tradeAfterSaleMapper.selectById(refuseReqVO.getId()); - if (afterSale == null) { - throw exception(AFTER_SALE_NOT_FOUND); - } - if (ObjectUtil.notEqual(afterSale.getStatus(), TradeAfterSaleStatusEnum.BUYER_DELIVERY.getStatus())) { - throw exception(AFTER_SALE_CONFIRM_FAIL_STATUS_NOT_BUYER_DELIVERY); - } - - // 更新售后单的状态 - updateAfterSaleStatus(afterSale.getId(), TradeAfterSaleStatusEnum.BUYER_DELIVERY.getStatus(), new TradeAfterSaleDO() - .setStatus(TradeAfterSaleStatusEnum.SELLER_REFUSE.getStatus()).setReceiveTime(LocalDateTime.now()) - .setReceiveReason(refuseReqVO.getRefuseMemo())); - - // 记录售后日志 - createAfterSaleLog(userId, UserTypeEnum.ADMIN.getValue(), - afterSale, afterSale.getStatus(), TradeAfterSaleStatusEnum.SELLER_REFUSE.getStatus()); - - // TODO 发送售后消息 - - // 更新交易订单项的售后状态为【未申请】 - tradeOrderService.updateOrderItemAfterSaleStatus(afterSale.getOrderItemId(), - TradeOrderItemAfterSaleStatusEnum.APPLY.getStatus(), - TradeOrderItemAfterSaleStatusEnum.NONE.getStatus(), null); - } - - /** - * 校验售后单是否可收货,即处于买家已发货 - * - * @param id 售后编号 - * @return 售后单 - */ - private TradeAfterSaleDO validateAfterSaleReceivable(Long id) { - TradeAfterSaleDO afterSale = tradeAfterSaleMapper.selectById(id); - if (afterSale == null) { - throw exception(AFTER_SALE_NOT_FOUND); - } - if (ObjectUtil.notEqual(afterSale.getStatus(), TradeAfterSaleStatusEnum.BUYER_DELIVERY.getStatus())) { - throw exception(AFTER_SALE_CONFIRM_FAIL_STATUS_NOT_BUYER_DELIVERY); - } - return afterSale; - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void refundAfterSale(Long userId, String userIp, Long id) { - // 校验售后单的状态,并状态待退款 - TradeAfterSaleDO afterSale = tradeAfterSaleMapper.selectByPayRefundId(id); - if (afterSale == null) { - throw exception(AFTER_SALE_NOT_FOUND); - } - if (ObjectUtil.notEqual(afterSale.getStatus(), TradeAfterSaleStatusEnum.WAIT_REFUND.getStatus())) { - throw exception(AFTER_SALE_REFUND_FAIL_STATUS_NOT_WAIT_REFUND); - } - - // 发起退款单。注意,需要在事务提交后,再进行发起,避免重复发起 - createPayRefund(userIp, afterSale); - - // 更新售后单的状态为【已完成】 - updateAfterSaleStatus(afterSale.getId(), TradeAfterSaleStatusEnum.WAIT_REFUND.getStatus(), new TradeAfterSaleDO() - .setStatus(TradeAfterSaleStatusEnum.COMPLETE.getStatus()).setRefundTime(LocalDateTime.now())); - - // 记录售后日志 - createAfterSaleLog(userId, UserTypeEnum.ADMIN.getValue(), - afterSale, afterSale.getStatus(), TradeAfterSaleStatusEnum.COMPLETE.getStatus()); - - // TODO 发送售后消息 - - // 更新交易订单项的售后状态为【已完成】 - tradeOrderService.updateOrderItemAfterSaleStatus(afterSale.getOrderItemId(), - TradeOrderItemAfterSaleStatusEnum.APPLY.getStatus(), - TradeOrderItemAfterSaleStatusEnum.SUCCESS.getStatus(), afterSale.getRefundPrice()); - } - - private void createPayRefund(String userIp, TradeAfterSaleDO afterSale) { - TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronization() { - - @Override - public void afterCommit() { - // 创建退款单 - PayRefundCreateReqDTO createReqDTO = TradeAfterSaleConvert.INSTANCE.convert(userIp, afterSale, tradeOrderProperties); - Long payRefundId = payRefundApi.createPayRefund(createReqDTO); - // 更新售后单的退款单号 - tradeAfterSaleMapper.updateById(new TradeAfterSaleDO().setId(afterSale.getId()).setPayRefundId(payRefundId)); - } - }); - } - - @Override - public void cancelAfterSale(Long userId, Long id) { - // 校验售后单的状态,并状态待退款 - TradeAfterSaleDO afterSale = tradeAfterSaleMapper.selectByPayRefundId(id); - if (afterSale == null) { - throw exception(AFTER_SALE_NOT_FOUND); - } - if (ObjectUtils.equalsAny(afterSale.getStatus(), TradeAfterSaleStatusEnum.APPLY.getStatus(), - TradeAfterSaleStatusEnum.SELLER_AGREE.getStatus())) { - throw exception(AFTER_SALE_CANCEL_FAIL_STATUS_NOT_APPLY_OR_AGREE); - } - - // 更新售后单的状态为【已取消】 - updateAfterSaleStatus(afterSale.getId(), afterSale.getStatus(), new TradeAfterSaleDO() - .setStatus(TradeAfterSaleStatusEnum.BUYER_CANCEL.getStatus())); - - // 记录售后日志 - createAfterSaleLog(userId, UserTypeEnum.MEMBER.getValue(), - afterSale, afterSale.getStatus(), TradeAfterSaleStatusEnum.BUYER_CANCEL.getStatus()); - - // TODO 发送售后消息 - - // 更新交易订单项的售后状态为【未申请】 - tradeOrderService.updateOrderItemAfterSaleStatus(afterSale.getOrderItemId(), - TradeOrderItemAfterSaleStatusEnum.APPLY.getStatus(), - TradeOrderItemAfterSaleStatusEnum.NONE.getStatus(), null); - } - - private void createAfterSaleLog(Long userId, Integer userType, TradeAfterSaleDO afterSale, - Integer beforeStatus, Integer afterStatus) { - TradeAfterSaleLogDO afterSaleLog = new TradeAfterSaleLogDO().setUserId(userId).setUserType(userType) - .setAfterSaleId(afterSale.getId()).setOrderId(afterSale.getOrderId()) - .setOrderItemId(afterSale.getOrderItemId()).setBeforeStatus(beforeStatus).setAfterStatus(afterStatus) - .setContent(TradeAfterSaleStatusEnum.valueOf(afterStatus).getContent()); - tradeAfterSaleLogMapper.insert(afterSaleLog); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/cart/TradeCartService.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/cart/TradeCartService.java deleted file mode 100644 index 3f46f5102..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/cart/TradeCartService.java +++ /dev/null @@ -1,66 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.cart; - -import cn.iocoder.yudao.module.trade.controller.app.cart.vo.AppTradeCartDetailRespVO; -import cn.iocoder.yudao.module.trade.controller.app.cart.vo.AppTradeCartItemAddCountReqVO; -import cn.iocoder.yudao.module.trade.controller.app.cart.vo.AppTradeCartItemUpdateCountReqVO; -import cn.iocoder.yudao.module.trade.controller.app.cart.vo.AppTradeCartItemUpdateSelectedReqVO; - -import javax.validation.Valid; -import java.util.Collection; - -/** - * 购物车 Service 接口 - * - * @author 芋道源码 - */ -public interface TradeCartService { - - /** - * 添加商品到购物车 - * - * @param userId 用户编号 - * @param addCountReqVO 添加信息 - */ - void addCartItemCount(Long userId, @Valid AppTradeCartItemAddCountReqVO addCountReqVO); - - /** - * 更新购物车商品数量 - * - * @param userId 用户编号 - * @param updateCountReqVO 更新信息 - */ - void updateCartItemCount(Long userId, AppTradeCartItemUpdateCountReqVO updateCountReqVO); - - /** - * 更新购物车商品是否选中 - * - * @param userId 用户编号 - * @param updateSelectedReqVO 更新信息 - */ - void updateCartItemSelected(Long userId, AppTradeCartItemUpdateSelectedReqVO updateSelectedReqVO); - - /** - * 删除购物车商品 - * - * @param userId 用户编号 - * @param skuIds SKU 编号的数组 - */ - void deleteCartItems(Long userId, Collection skuIds); - - /** - * 查询用户在购物车中的商品数量 - * - * @param userId 用户编号 - * @return 商品数量 - */ - Integer getCartCount(Long userId); - - /** - * 查询用户的购物车详情 - * - * @param userId 用户编号 - * @return 购物车详情 - */ - AppTradeCartDetailRespVO getCartDetail(Long userId); - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/cart/TradeCartServiceImpl.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/cart/TradeCartServiceImpl.java deleted file mode 100644 index ae0301e83..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/cart/TradeCartServiceImpl.java +++ /dev/null @@ -1,184 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.cart; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.lang.Assert; -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.module.promotion.api.price.PriceApi; -import cn.iocoder.yudao.module.promotion.api.price.dto.PriceCalculateRespDTO; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionLevelEnum; -import cn.iocoder.yudao.module.product.api.sku.ProductSkuApi; -import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuRespDTO; -import cn.iocoder.yudao.module.trade.controller.app.cart.vo.AppTradeCartDetailRespVO; -import cn.iocoder.yudao.module.trade.controller.app.cart.vo.AppTradeCartItemAddCountReqVO; -import cn.iocoder.yudao.module.trade.controller.app.cart.vo.AppTradeCartItemUpdateCountReqVO; -import cn.iocoder.yudao.module.trade.controller.app.cart.vo.AppTradeCartItemUpdateSelectedReqVO; -import cn.iocoder.yudao.module.trade.convert.cart.TradeCartConvert; -import cn.iocoder.yudao.module.trade.dal.dataobject.cart.TradeCartItemDO; -import cn.iocoder.yudao.module.trade.dal.mysql.cart.TradeCartItemMapper; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; -import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.SKU_NOT_EXISTS; -import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.SKU_STOCK_NOT_ENOUGH; -import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.CARD_ITEM_NOT_FOUND; - -/** - * 购物车 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class TradeCartServiceImpl implements TradeCartService { - - @Resource - private TradeCartItemMapper cartItemMapper; - - @Resource - private ProductSkuApi productSkuApi; - @Resource - private PriceApi priceApi; - - @Override - public void addCartItemCount(Long userId, AppTradeCartItemAddCountReqVO addCountReqVO) { - Long skuId = addCountReqVO.getSkuId(); - Integer count = addCountReqVO.getCount(); - // 查询 CartItemDO - TradeCartItemDO tradeItem = cartItemMapper.selectByUserIdAndSkuId(userId, addCountReqVO.getSkuId()); - - // 存在,则进行数量更新 - if (tradeItem != null) { - checkProductSku(skuId, tradeItem.getCount() + count); - cartItemMapper.updateById(new TradeCartItemDO().setId(tradeItem.getId()) - .setSelected(true).setCount(tradeItem.getCount() + count)); - return; - } - - // 不存在,则进行插入 - ProductSkuRespDTO sku = checkProductSku(skuId, count); - cartItemMapper.insert(new TradeCartItemDO().setUserId(userId).setSpuId(sku.getSpuId()).setSkuId(sku.getId()) - .setSelected(true).setCount(count)); - } - - @Override - public void updateCartItemCount(Long userId, AppTradeCartItemUpdateCountReqVO updateCountReqVO) { - // 校验 TradeCartItemDO 存在 - TradeCartItemDO tradeItem = cartItemMapper.selectByUserIdAndSkuId(userId, updateCountReqVO.getSkuId()); - if (tradeItem == null) { - throw exception(CARD_ITEM_NOT_FOUND); - } - // 校验商品 SKU - checkProductSku(updateCountReqVO.getSkuId(), updateCountReqVO.getCount()); - - // 更新数量 - cartItemMapper.updateById(new TradeCartItemDO().setId(tradeItem.getId()).setCount(updateCountReqVO.getCount())); - } - - @Override - public void updateCartItemSelected(Long userId, AppTradeCartItemUpdateSelectedReqVO updateSelectedReqVO) { - // 查询 CartItemDO 列表 - List cartItems = cartItemMapper.selectListByUserIdAndSkuIds(userId, updateSelectedReqVO.getSkuIds()); - if (CollUtil.isEmpty(cartItems)) { - return; - } - - // 更新选中 - cartItemMapper.updateByIds(CollectionUtils.convertList(cartItems, TradeCartItemDO::getId), - new TradeCartItemDO().setSelected(updateSelectedReqVO.getSelected())); - } - - /** - * 购物车删除商品 - * - * @param userId 用户编号 - * @param skuIds 商品 SKU 编号的数组 - */ - @Override - public void deleteCartItems(Long userId, Collection skuIds) { - // 查询 CartItemDO 列表 - List cartItems = cartItemMapper.selectListByUserIdAndSkuIds(userId, skuIds); - if (CollUtil.isEmpty(cartItems)) { - return; - } - - // 批量标记删除 - cartItemMapper.deleteBatchIds(CollectionUtils.convertSet(cartItems, TradeCartItemDO::getId)); - } - - @Override - public Integer getCartCount(Long userId) { - return cartItemMapper.selectSumByUserId(userId); - } - - @Override - public AppTradeCartDetailRespVO getCartDetail(Long userId) { - // 获得购物车的商品 - List cartItems = cartItemMapper.selectListByUserId(userId, null); - // 如果未空,则返回空结果 - if (CollUtil.isEmpty(cartItems)) { - return TradeCartConvert.INSTANCE.buildEmptyAppTradeCartDetailRespVO(); - } - - // 调用价格服务,计算价格 - PriceCalculateRespDTO priceCalculate = priceApi.calculatePrice(TradeCartConvert.INSTANCE.convert(userId, cartItems)); - - // 转换返回 - Map cartItemMap = convertMap(cartItems, TradeCartItemDO::getSkuId); - Map orderItemMap = convertMap(priceCalculate.getOrder().getItems(), - PriceCalculateRespDTO.OrderItem::getSkuId); - List itemGroups = new ArrayList<>(cartItems.size()); - // ① 场景一,营销活动,订单级别 TODO 芋艿:待测试 - priceCalculate.getPromotions().stream().filter(promotion -> PromotionLevelEnum.ORDER.getLevel().equals(promotion.getLevel())) - .forEach(promotion -> { - AppTradeCartDetailRespVO.ItemGroup itemGroup = new AppTradeCartDetailRespVO.ItemGroup().setItems(new ArrayList<>()) - .setPromotion(TradeCartConvert.INSTANCE.convert(promotion)); - itemGroups.add(itemGroup); - promotion.getItems().forEach(promotionItem -> { - PriceCalculateRespDTO.OrderItem orderItem = orderItemMap.remove(promotionItem.getSkuId()); - Assert.notNull(orderItem, "商品 SKU({}) 对应的订单项不能为空", promotionItem.getSkuId()); - TradeCartItemDO cartItem = cartItemMap.get(orderItem.getSkuId()); - itemGroup.getItems().add(TradeCartConvert.INSTANCE.convert(orderItem, cartItem)); // TODO spu - }); - }); - // ② 场景二,营销活动,商品级别 - orderItemMap.values().forEach(orderItem -> { - AppTradeCartDetailRespVO.ItemGroup itemGroup = new AppTradeCartDetailRespVO.ItemGroup().setItems(new ArrayList<>(1)).setPromotion(null); - itemGroups.add(itemGroup); - TradeCartItemDO cartItem = cartItemMap.get(orderItem.getSkuId()); - itemGroup.getItems().add(TradeCartConvert.INSTANCE.convert(orderItem, cartItem)); // TODO spu - }); - return new AppTradeCartDetailRespVO().setItemGroups(itemGroups) - .setOrder(TradeCartConvert.INSTANCE.convert(priceCalculate.getOrder())); - } - - /** - * 校验商品 SKU 是否合法 - * 1. 是否存在 - * 2. 是否下架 - * 3. 库存不足 - * - * @param skuId 商品 SKU 编号 - * @param count 商品数量 - * @return 商品 SKU - */ - private ProductSkuRespDTO checkProductSku(Long skuId, Integer count) { - ProductSkuRespDTO sku = productSkuApi.getSku(skuId); - if (sku == null || CommonStatusEnum.DISABLE.getStatus().equals(sku.getStatus())) { - throw exception(SKU_NOT_EXISTS); - } - if (count > sku.getStock()) { - throw exception(SKU_STOCK_NOT_ENOUGH); - } - return sku; - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderService.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderService.java deleted file mode 100644 index 086f65edd..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderService.java +++ /dev/null @@ -1,142 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.order; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderDeliveryReqVO; -import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderPageReqVO; -import cn.iocoder.yudao.module.trade.controller.app.order.vo.AppTradeOrderCreateReqVO; -import cn.iocoder.yudao.module.trade.controller.app.order.vo.AppTradeOrderPageReqVO; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderItemDO; - -import java.util.Collection; -import java.util.List; - -import static java.util.Collections.singleton; - -/** - * 交易订单 Service 接口 - * - * @author LeeYan9 - * @since 2022-08-26 - */ -public interface TradeOrderService { - - // =================== Order =================== - - /** - * 【会员】创建交易订单 - * - * @param userId 登录用户 - * @param userIp 用户 IP 地址 - * @param createReqVO 创建交易订单请求模型 - * @return 交易订单的编号 - */ - Long createOrder(Long userId, String userIp, AppTradeOrderCreateReqVO createReqVO); - - /** - * 更新交易订单已支付 - * - * @param id 交易订单编号 - * @param payOrderId 支付订单编号 - */ - void updateOrderPaid(Long id, Long payOrderId); - - /** - * 【管理员】发货交易订单 - * - * @param userId 管理员编号 - * @param deliveryReqVO 发货请求 - */ - void deliveryOrder(Long userId, TradeOrderDeliveryReqVO deliveryReqVO); - - /** - * 【会员】收货交易订单 - * - * @param userId 用户编号 - * @param id 订单编号 - */ - void receiveOrder(Long userId, Long id); - - /** - * 获得指定编号的交易订单 - * - * @param id 交易订单编号 - * @return 交易订单 - */ - TradeOrderDO getOrder(Long id); - - /** - * 获得指定用户,指定的交易订单 - * - * @param userId 用户编号 - * @param id 交易订单编号 - * @return 交易订单 - */ - TradeOrderDO getOrder(Long userId, Long id); - - /** - * 【管理员】获得交易订单分页 - * - * @param reqVO 分页请求 - * @return 交易订单 - */ - PageResult getOrderPage(TradeOrderPageReqVO reqVO); - - /** - * 【会员】获得交易订单分页 - * - * @param userId 用户编号 - * @param reqVO 分页请求 - * @return 交易订单 - */ - PageResult getOrderPage(Long userId, AppTradeOrderPageReqVO reqVO); - - // =================== Order Item =================== - - /** - * 获得指定用户,指定的交易订单项 - * - * @param userId 用户编号 - * @param itemId 交易订单项编号 - * @return 交易订单项 - */ - TradeOrderItemDO getOrderItem(Long userId, Long itemId); - - /** - * 更新交易订单项的售后状态 - * - * @param id 交易订单项编号 - * @param oldAfterSaleStatus 当前售后状态;如果不符,更新后会抛出异常 - * @param newAfterSaleStatus 目标售后状态 - * @param refundPrice 退款金额;当订单项退款成功时,必须传递该值 - */ - void updateOrderItemAfterSaleStatus(Long id, Integer oldAfterSaleStatus, - Integer newAfterSaleStatus, Integer refundPrice); - - /** - * 根据交易订单项编号数组,查询交易订单项 - * - * @param ids 交易订单项编号数组 - * @return 交易订单项数组 - */ - List getOrderItemList(Collection ids); - - /** - * 根据交易订单编号,查询交易订单项 - * - * @param orderId 交易订单编号 - * @return 交易订单项数组 - */ - default List getOrderItemListByOrderId(Long orderId) { - return getOrderItemListByOrderId(singleton(orderId)); - } - - /** - * 根据交易订单编号数组,查询交易订单项 - * - * @param orderIds 交易订单编号数组 - * @return 交易订单项数组 - */ - List getOrderItemListByOrderId(Collection orderIds); - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderServiceImpl.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderServiceImpl.java deleted file mode 100644 index 86d84c415..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderServiceImpl.java +++ /dev/null @@ -1,530 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.order; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.util.IdUtil; -import cn.hutool.core.util.ObjectUtil; -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.common.core.KeyValue; -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.enums.TerminalEnum; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.framework.common.util.json.JsonUtils; -import cn.iocoder.yudao.module.member.api.address.AddressApi; -import cn.iocoder.yudao.module.member.api.address.dto.AddressRespDTO; -import cn.iocoder.yudao.module.member.api.user.MemberUserApi; -import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; -import cn.iocoder.yudao.module.pay.api.order.PayOrderApi; -import cn.iocoder.yudao.module.pay.api.order.dto.PayOrderCreateReqDTO; -import cn.iocoder.yudao.module.pay.api.order.dto.PayOrderRespDTO; -import cn.iocoder.yudao.module.pay.enums.order.PayOrderStatusEnum; -import cn.iocoder.yudao.module.product.api.sku.ProductSkuApi; -import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuRespDTO; -import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuUpdateStockReqDTO; -import cn.iocoder.yudao.module.product.api.spu.ProductSpuApi; -import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO; -import cn.iocoder.yudao.module.product.enums.spu.ProductSpuStatusEnum; -import cn.iocoder.yudao.module.promotion.api.coupon.CouponApi; -import cn.iocoder.yudao.module.promotion.api.coupon.dto.CouponUseReqDTO; -import cn.iocoder.yudao.module.promotion.api.price.PriceApi; -import cn.iocoder.yudao.module.promotion.api.price.dto.PriceCalculateRespDTO; -import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderDeliveryReqVO; -import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderPageReqVO; -import cn.iocoder.yudao.module.trade.controller.app.order.vo.AppTradeOrderCreateReqVO; -import cn.iocoder.yudao.module.trade.controller.app.order.vo.AppTradeOrderCreateReqVO.Item; -import cn.iocoder.yudao.module.trade.controller.app.order.vo.AppTradeOrderPageReqVO; -import cn.iocoder.yudao.module.trade.convert.order.TradeOrderConvert; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderItemDO; -import cn.iocoder.yudao.module.trade.dal.mysql.order.TradeOrderItemMapper; -import cn.iocoder.yudao.module.trade.dal.mysql.order.TradeOrderMapper; -import cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants; -import cn.iocoder.yudao.module.trade.enums.order.*; -import cn.iocoder.yudao.module.trade.framework.order.config.TradeOrderProperties; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -import javax.annotation.Resource; -import java.time.LocalDateTime; -import java.util.*; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*; -import static cn.iocoder.yudao.module.pay.enums.ErrorCodeConstants.PAY_ORDER_NOT_FOUND; -import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.*; - -/** - * 交易订单 Service 实现类 - * - * @author LeeYan9 - * @since 2022-08-26 - */ -@Service -@Slf4j -public class TradeOrderServiceImpl implements TradeOrderService { - - @Resource - private TradeOrderMapper tradeOrderMapper; - @Resource - private TradeOrderItemMapper tradeOrderItemMapper; - - @Resource - private PriceApi priceApi; - @Resource - private ProductSkuApi productSkuApi; - @Resource - private ProductSpuApi productSpuApi; - @Resource - private PayOrderApi payOrderApi; - @Resource - private AddressApi addressApi; - @Resource - private CouponApi couponApi; - @Resource - private MemberUserApi memberUserApi; - - @Resource - private TradeOrderProperties tradeOrderProperties; - - // =================== Order =================== - - @Override - @Transactional(rollbackFor = Exception.class) - public Long createOrder(Long userId, String userIp, AppTradeOrderCreateReqVO createReqVO) { - // 商品 SKU 检查:可售状态、库存 - List skus = validateSkuSaleable(createReqVO.getItems()); - // 商品 SPU 检查:可售状态 - List spus = validateSpuSaleable(convertSet(skus, ProductSkuRespDTO::getSpuId)); - // 用户收件地址的校验 - AddressRespDTO address = validateAddress(userId, createReqVO.getAddressId()); - - // 价格计算 - PriceCalculateRespDTO priceResp = priceApi.calculatePrice(TradeOrderConvert.INSTANCE.convert(createReqVO, userId)); - - // 插入 TradeOrderDO 订单 - TradeOrderDO tradeOrderDO = createTradeOrder(userId, userIp, createReqVO, priceResp.getOrder(), address); - // 插入 TradeOrderItemDO 订单项 - List tradeOrderItems = createTradeOrderItems(tradeOrderDO, priceResp.getOrder().getItems(), skus); - - // 订单创建完后的逻辑 - afterCreateTradeOrder(userId, createReqVO, tradeOrderDO, tradeOrderItems, spus); - // TODO @LeeYan9: 是可以思考下, 订单的营销优惠记录, 应该记录在哪里, 微信讨论起来! - return tradeOrderDO.getId(); - } - - /** - * 校验商品 SKU 是否可出售 - * - * @param items 商品 SKU - * @return 商品 SKU 数组 - */ - private List validateSkuSaleable(List items) { - List skus = productSkuApi.getSkuList(convertSet(items, Item::getSkuId)); - // SKU 不存在 - if (items.size() != skus.size()) { - throw exception(ORDER_CREATE_SKU_NOT_FOUND); - } - // 校验是否禁用 or 库存不足 - Map skuMap = convertMap(skus, ProductSkuRespDTO::getId); - items.forEach(item -> { - ProductSkuRespDTO sku = skuMap.get(item.getSkuId()); - // SKU 禁用 - if (ObjectUtil.notEqual(CommonStatusEnum.ENABLE.getStatus(), sku.getStatus())) { - throw exception(ORDER_CREATE_SKU_NOT_SALE); - } - // SKU 库存不足 - if (item.getCount() > sku.getStock()) { - throw exception(ErrorCodeConstants.ORDER_CREATE_SKU_STOCK_NOT_ENOUGH); - } - }); - return skus; - } - - /** - * 校验商品 SPU 是否可出售 - * - * @param spuIds 商品 SPU 编号数组 - * @return 商品 SPU 数组 - */ - private List validateSpuSaleable(Set spuIds) { - List spus = productSpuApi.getSpuList(spuIds); - // SPU 不存在 - if (spus.size() != spuIds.size()) { - throw exception(ORDER_CREATE_SPU_NOT_FOUND); - } - // 校验是否存在禁用的 SPU - ProductSpuRespDTO spu = CollectionUtils.findFirst(spus, - spuDTO -> ObjectUtil.notEqual(ProductSpuStatusEnum.ENABLE.getStatus(), spuDTO.getStatus())); - if (spu != null) { - throw exception(ErrorCodeConstants.ORDER_CREATE_SPU_NOT_SALE); - } - return spus; - } - - /** - * 校验收件地址是否存在 - * - * @param userId 用户编号 - * @param addressId 收件地址编号 - * @return 收件地址 - */ - private AddressRespDTO validateAddress(Long userId, Long addressId) { - AddressRespDTO address = addressApi.getAddress(addressId, userId); - if (Objects.isNull(address)) { - throw exception(ErrorCodeConstants.ORDER_CREATE_ADDRESS_NOT_FOUND); - } - return address; - } - - private TradeOrderDO createTradeOrder(Long userId, String clientIp, AppTradeOrderCreateReqVO createReqVO, - PriceCalculateRespDTO.Order order, AddressRespDTO address) { - TradeOrderDO tradeOrderDO = TradeOrderConvert.INSTANCE.convert(userId, clientIp, createReqVO, order, address); - tradeOrderDO.setNo(IdUtil.getSnowflakeNextId() + ""); // TODO @LeeYan9: 思考下, 怎么生成好点哈; 这个是会展示给用户的; - tradeOrderDO.setStatus(TradeOrderStatusEnum.UNPAID.getStatus()); - tradeOrderDO.setType(TradeOrderTypeEnum.NORMAL.getType()); - tradeOrderDO.setAfterSaleStatus(TradeOrderAfterSaleStatusEnum.NONE.getStatus()); - tradeOrderDO.setProductCount(getSumValue(order.getItems(), PriceCalculateRespDTO.OrderItem::getCount, Integer::sum)); - tradeOrderDO.setTerminal(TerminalEnum.H5.getTerminal()); // todo 数据来源? - tradeOrderDO.setAdjustPrice(0).setPayed(false); // 支付信息 - tradeOrderDO.setDeliveryStatus(TradeOrderDeliveryStatusEnum.UNDELIVERED.getStatus()); // 物流信息 - tradeOrderDO.setAfterSaleStatus(TradeOrderAfterSaleStatusEnum.NONE.getStatus()).setRefundPrice(0); // 退款信息 - tradeOrderMapper.insert(tradeOrderDO); - return tradeOrderDO; - } - - private List createTradeOrderItems(TradeOrderDO tradeOrderDO, - List orderItems, List skus) { - List tradeOrderItemDOs = TradeOrderConvert.INSTANCE.convertList(tradeOrderDO, orderItems, skus); - tradeOrderItemMapper.insertBatch(tradeOrderItemDOs); - return tradeOrderItemDOs; - } - - /** - * 执行创建完创建完订单后的逻辑 - * - * 例如说:优惠劵的扣减、积分的扣减、支付单的创建等等 - * - * @param userId 用户编号 - * @param createReqVO 创建订单请求 - * @param tradeOrderDO 交易订单 - */ - private void afterCreateTradeOrder(Long userId, AppTradeOrderCreateReqVO createReqVO, - TradeOrderDO tradeOrderDO, List tradeOrderItemDOs, - List spus) { - // 下单时扣减商品库存 - productSkuApi.updateSkuStock(new ProductSkuUpdateStockReqDTO(TradeOrderConvert.INSTANCE.convertList(tradeOrderItemDOs))); - - // 删除购物车商品 TODO 芋艿:待实现 - - // 扣减积分,抵扣金额 TODO 芋艿:待实现 - - // 有使用优惠券时更新 - if (createReqVO.getCouponId() != null) { - couponApi.useCoupon(new CouponUseReqDTO().setId(createReqVO.getCouponId()).setUserId(userId) - .setOrderId(tradeOrderDO.getId())); - } - - // 生成预支付 - createPayOrder(tradeOrderDO, tradeOrderItemDOs, spus); - - // 增加订单日志 TODO 芋艿:待实现 - } - - private void createPayOrder(TradeOrderDO tradeOrderDO, List tradeOrderItemDOs, - List spus) { - // 创建支付单,用于后续的支付 - PayOrderCreateReqDTO payOrderCreateReqDTO = TradeOrderConvert.INSTANCE.convert( - tradeOrderDO, tradeOrderItemDOs, spus, tradeOrderProperties); - Long payOrderId = payOrderApi.createOrder(payOrderCreateReqDTO); - - // 更新到交易单上 - tradeOrderMapper.updateById(new TradeOrderDO().setId(tradeOrderDO.getId()).setPayOrderId(payOrderId)); - } - - @Override - public void updateOrderPaid(Long id, Long payOrderId) { - // 校验并获得交易订单(可支付) - KeyValue orderResult = validateOrderPayable(id, payOrderId); - TradeOrderDO order = orderResult.getKey(); - PayOrderRespDTO payOrder = orderResult.getValue(); - - // 更新 TradeOrderDO 状态为已支付,等待发货 - int updateCount = tradeOrderMapper.updateByIdAndStatus(id, order.getStatus(), - new TradeOrderDO().setStatus(TradeOrderStatusEnum.UNDELIVERED.getStatus()).setPayed(true) - .setPayTime(LocalDateTime.now()).setPayChannelCode(payOrder.getChannelCode())); - if (updateCount == 0) { - throw exception(ORDER_UPDATE_PAID_STATUS_NOT_UNPAID); - } - - // TODO 芋艿:发送订单变化的消息 - - // TODO 芋艿:发送站内信 - - // TODO 芋艿:OrderLog - } - - /** - * 校验交易订单满足被支付的条件 - * - * 1. 交易订单未支付 - * 2. 支付单已支付 - * - * @param id 交易订单编号 - * @param payOrderId 支付订单编号 - * @return 交易订单 - */ - private KeyValue validateOrderPayable(Long id, Long payOrderId) { - // 校验订单是否存在 - TradeOrderDO order = tradeOrderMapper.selectById(id); - if (order == null) { - throw exception(ORDER_NOT_FOUND); - } - // 校验订单未支付 - if (!TradeOrderStatusEnum.isUnpaid(order.getStatus()) || order.getPayed()) { - log.error("[validateOrderPaid][order({}) 不处于待支付状态,请进行处理!order 数据是:{}]", - id, JsonUtils.toJsonString(order)); - throw exception(ORDER_UPDATE_PAID_STATUS_NOT_UNPAID); - } - // 校验支付订单匹配 - if (ObjectUtil.notEqual(order.getPayOrderId(), payOrderId)) { // 支付单号 - log.error("[validateOrderPaid][order({}) 支付单不匹配({}),请进行处理!order 数据是:{}]", - id, payOrderId, JsonUtils.toJsonString(order)); - throw exception(ORDER_UPDATE_PAID_FAIL_PAY_ORDER_ID_ERROR); - } - - // 校验支付单是否存在 - PayOrderRespDTO payOrder = payOrderApi.getOrder(payOrderId); - if (payOrder == null) { - log.error("[validateOrderPaid][order({}) payOrder({}) 不存在,请进行处理!]", id, payOrderId); - throw exception(PAY_ORDER_NOT_FOUND); - } - // 校验支付单已支付 - if (!PayOrderStatusEnum.isSuccess(payOrder.getStatus())) { - log.error("[validateOrderPaid][order({}) payOrder({}) 未支付,请进行处理!payOrder 数据是:{}]", - id, payOrderId, JsonUtils.toJsonString(payOrder)); - throw exception(ORDER_UPDATE_PAID_FAIL_PAY_ORDER_STATUS_NOT_SUCCESS); - } - // 校验支付金额一致 - if (ObjectUtil.notEqual(payOrder.getAmount(), order.getPayPrice())) { - log.error("[validateOrderPaid][order({}) payOrder({}) 支付金额不匹配,请进行处理!order 数据是:{},payOrder 数据是:{}]", - id, payOrderId, JsonUtils.toJsonString(order), JsonUtils.toJsonString(payOrder)); - throw exception(ORDER_UPDATE_PAID_FAIL_PAY_PRICE_NOT_MATCH); - } - // 校验支付订单匹配(二次) - if (ObjectUtil.notEqual(payOrder.getMerchantOrderId(), id.toString())) { - log.error("[validateOrderPaid][order({}) 支付单不匹配({}),请进行处理!payOrder 数据是:{}]", - id, payOrderId, JsonUtils.toJsonString(payOrder)); - throw exception(ORDER_UPDATE_PAID_FAIL_PAY_ORDER_ID_ERROR); - } - return new KeyValue<>(order, payOrder); - } - - // TODO 芋艿:如果无需发货,需要怎么存储? - @Override - public void deliveryOrder(Long userId, TradeOrderDeliveryReqVO deliveryReqVO) { - // 校验并获得交易订单(可发货) - TradeOrderDO order = validateOrderDeliverable(deliveryReqVO.getId()); - - // TODO 芋艿:logisticsId 校验存在 - - // 更新 TradeOrderDO 状态为已发货,等待收货 - int updateCount = tradeOrderMapper.updateByIdAndStatus(order.getId(), order.getStatus(), - new TradeOrderDO().setStatus(TradeOrderStatusEnum.DELIVERED.getStatus()) - .setLogisticsId(deliveryReqVO.getLogisticsId()).setLogisticsNo(deliveryReqVO.getLogisticsNo()) - .setDeliveryStatus(TradeOrderDeliveryStatusEnum.DELIVERED.getStatus()).setDeliveryTime(LocalDateTime.now())); - if (updateCount == 0) { - throw exception(ORDER_DELIVERY_FAIL_STATUS_NOT_UNDELIVERED); - } - - // TODO 芋艿:发送订单变化的消息 - - // TODO 芋艿:发送站内信 - - // TODO 芋艿:OrderLog - - // TODO 设计:like:是否要单独一个 delivery 发货单表??? - // TODO 设计:niu:要不要支持一个订单下,多个 order item 单独发货,类似有赞 - // TODO 设计:lili:是不是发货后,才支持售后? - } - - /** - * 校验交易订单满足被发货的条件 - * - * 1. 交易订单未发货 - * - * @param id 交易订单编号 - * @return 交易订单 - */ - private TradeOrderDO validateOrderDeliverable(Long id) { - // 校验订单是否存在 - TradeOrderDO order = tradeOrderMapper.selectById(id); - if (order == null) { - throw exception(ORDER_NOT_FOUND); - } - // 校验订单是否是待发货状态 - if (!TradeOrderStatusEnum.isUndelivered(order.getStatus()) - || ObjectUtil.notEqual(order.getDeliveryStatus(), TradeOrderDeliveryStatusEnum.UNDELIVERED.getStatus())) { - throw exception(ORDER_DELIVERY_FAIL_STATUS_NOT_UNDELIVERED); - } - return order; - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void receiveOrder(Long userId, Long id) { - // 校验并获得交易订单(可收货) - TradeOrderDO order = validateOrderReceivable(userId, id); - - // 更新 TradeOrderDO 状态为已完成 - int updateCount = tradeOrderMapper.updateByIdAndStatus(order.getId(), order.getStatus(), - new TradeOrderDO().setStatus(TradeOrderStatusEnum.COMPLETED.getStatus()) - .setDeliveryStatus(TradeOrderDeliveryStatusEnum.RECEIVED.getStatus()).setReceiveTime(LocalDateTime.now())); - if (updateCount == 0) { - throw exception(ORDER_RECEIVE_FAIL_STATUS_NOT_DELIVERED); - } - - // TODO 芋艿:OrderLog - - // TODO 芋艿:lili 发送订单变化的消息 - - // TODO 芋艿:lili 发送商品被购买完成的数据 - } - - @Override - public TradeOrderDO getOrder(Long id) { - return tradeOrderMapper.selectById(id); - } - - /** - * 校验交易订单满足可售货的条件 - * - * 1. 交易订单待收货 - * - * @param userId 用户编号 - * @param id 交易订单编号 - * @return 交易订单 - */ - private TradeOrderDO validateOrderReceivable(Long userId, Long id) { - // 校验订单是否存在 - TradeOrderDO order = tradeOrderMapper.selectByIdAndUserId(id, userId); - if (order == null) { - throw exception(ORDER_NOT_FOUND); - } - // 校验订单是否是待收货状态 - if (!TradeOrderStatusEnum.isDelivered(order.getStatus()) - || ObjectUtil.notEqual(order.getDeliveryStatus(), TradeOrderDeliveryStatusEnum.DELIVERED.getStatus())) { - throw exception(ORDER_RECEIVE_FAIL_STATUS_NOT_DELIVERED); - } - return order; - } - - @Override - public TradeOrderDO getOrder(Long userId, Long id) { - TradeOrderDO order = tradeOrderMapper.selectById(id); - if (order != null - && ObjectUtil.notEqual(order.getUserId(), userId)) { - return null; - } - return order; - } - - @Override - public PageResult getOrderPage(TradeOrderPageReqVO reqVO) { - // 获得 userId 相关的查询 - Set userIds = new HashSet<>(); - if (StrUtil.isNotEmpty(reqVO.getUserMobile())) { - MemberUserRespDTO user = memberUserApi.getUserByMobile(reqVO.getUserMobile()); - if (user == null) { // 没查询到用户,说明肯定也没他的订单 - return new PageResult<>(); - } - userIds.add(user.getId()); - } - if (StrUtil.isNotEmpty(reqVO.getUserNickname())) { - List users = memberUserApi.getUserListByNickname(reqVO.getUserNickname()); - if (CollUtil.isEmpty(users)) { // 没查询到用户,说明肯定也没他的订单 - return new PageResult<>(); - } - userIds.addAll(convertSet(users, MemberUserRespDTO::getId)); - } - // 分页查询 - return tradeOrderMapper.selectPage(reqVO, userIds); - } - - @Override - public PageResult getOrderPage(Long userId, AppTradeOrderPageReqVO reqVO) { - return tradeOrderMapper.selectPage(reqVO, userId); - } - - // =================== Order Item =================== - - @Override - public TradeOrderItemDO getOrderItem(Long userId, Long itemId) { - TradeOrderItemDO orderItem = tradeOrderItemMapper.selectById(itemId); - if (orderItem != null - && ObjectUtil.notEqual(orderItem.getUserId(), userId)) { - return null; - } - return orderItem; - } - - @Override - public void updateOrderItemAfterSaleStatus(Long id, Integer oldAfterSaleStatus, Integer newAfterSaleStatus, Integer refundPrice) { - // 如果退款成功,则 refundPrice 非空 - if (Objects.equals(newAfterSaleStatus, TradeOrderItemAfterSaleStatusEnum.SUCCESS.getStatus()) - && refundPrice == null) { - throw new IllegalArgumentException(StrUtil.format("id({}) 退款成功,退款金额不能为空", id)); - } - - // 更新订单项 - int updateCount = tradeOrderItemMapper.updateAfterSaleStatus(id, oldAfterSaleStatus, newAfterSaleStatus); - if (updateCount <= 0) { - throw exception(ORDER_ITEM_UPDATE_AFTER_SALE_STATUS_FAIL); - } - - // 如果有退款金额,则需要更新订单 - if (refundPrice == null) { - return; - } - // 计算总的退款金额 - TradeOrderDO order = tradeOrderMapper.selectById(tradeOrderItemMapper.selectById(id).getOrderId()); - Integer orderRefundPrice = order.getRefundPrice() + refundPrice; - if (isAllOrderItemAfterSaleSuccess(order.getId())) { // 如果都售后成功,则需要取消订单 - tradeOrderMapper.updateById(new TradeOrderDO().setId(order.getId()) - .setAfterSaleStatus(TradeOrderAfterSaleStatusEnum.ALL.getStatus()).setRefundPrice(orderRefundPrice) - .setCancelType(TradeOrderCancelTypeEnum.AFTER_SALE_CLOSE.getType()).setCancelTime(LocalDateTime.now())); - - // TODO 芋艿:记录订单日志 - - // TODO 芋艿:站内信? - } else { // 如果部分售后,则更新退款金额 - tradeOrderMapper.updateById(new TradeOrderDO().setId(order.getId()) - .setAfterSaleStatus(TradeOrderAfterSaleStatusEnum.PART.getStatus()).setRefundPrice(orderRefundPrice)); - } - - // TODO 芋艿:未来如果有分佣,需要更新相关分佣订单为已失效 - } - - @Override - public List getOrderItemList(Collection ids) { - return tradeOrderItemMapper.selectBatchIds(ids); - } - - @Override - public List getOrderItemListByOrderId(Collection orderIds) { - return tradeOrderItemMapper.selectListByOrderId(orderIds); - } - - /** - * 判断指定订单的所有订单项,是不是都售后成功 - * - * @param id 订单编号 - * @return 是否都售后成功 - */ - private boolean isAllOrderItemAfterSaleSuccess(Long id) { - List orderItems = tradeOrderItemMapper.selectListByOrderId(id); - return orderItems.stream().allMatch(orderItem -> Objects.equals(orderItem.getAfterSaleStatus(), - TradeOrderItemAfterSaleStatusEnum.SUCCESS.getStatus())); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/test/java/cn/iocoder/yudao/module/trade/service/aftersale/TradeAfterSaleServiceTest.java b/yudao-module-mall/yudao-module-trade-biz/src/test/java/cn/iocoder/yudao/module/trade/service/aftersale/TradeAfterSaleServiceTest.java deleted file mode 100644 index f628cef4a..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/test/java/cn/iocoder/yudao/module/trade/service/aftersale/TradeAfterSaleServiceTest.java +++ /dev/null @@ -1,154 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.aftersale; - -import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.module.pay.api.refund.PayRefundApi; -import cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo.TradeAfterSalePageReqVO; -import cn.iocoder.yudao.module.trade.controller.app.aftersale.vo.AppTradeAfterSaleCreateReqVO; -import cn.iocoder.yudao.module.trade.dal.dataobject.aftersale.TradeAfterSaleDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.aftersale.TradeAfterSaleLogDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderItemDO; -import cn.iocoder.yudao.module.trade.dal.mysql.aftersale.TradeAfterSaleLogMapper; -import cn.iocoder.yudao.module.trade.dal.mysql.aftersale.TradeAfterSaleMapper; -import cn.iocoder.yudao.module.trade.enums.aftersale.TradeAfterSaleStatusEnum; -import cn.iocoder.yudao.module.trade.enums.aftersale.TradeAfterSaleTypeEnum; -import cn.iocoder.yudao.module.trade.enums.aftersale.TradeAfterSaleWayEnum; -import cn.iocoder.yudao.module.trade.enums.order.TradeOrderItemAfterSaleStatusEnum; -import cn.iocoder.yudao.module.trade.enums.order.TradeOrderStatusEnum; -import cn.iocoder.yudao.module.trade.framework.order.config.TradeOrderProperties; -import cn.iocoder.yudao.module.trade.service.order.TradeOrderService; -import org.junit.jupiter.api.Test; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.context.annotation.Import; - -import javax.annotation.Resource; -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildTime; -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; -import static java.util.Arrays.asList; -import static org.junit.jupiter.api.Assertions.*; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.when; - -/** - * {@link TradeAfterSaleService} 的单元测试 - * - * @author 芋道源码 - */ -@Import(TradeAfterSaleServiceImpl.class) -public class TradeAfterSaleServiceTest extends BaseDbUnitTest { - - @Resource - private TradeAfterSaleServiceImpl tradeAfterSaleService; - - @Resource - private TradeAfterSaleMapper tradeAfterSaleMapper; - @Resource - private TradeAfterSaleLogMapper tradeAfterSaleLogMapper; - - @MockBean - private TradeOrderService tradeOrderService; - @MockBean - private PayRefundApi payRefundApi; - - @MockBean - private TradeOrderProperties tradeOrderProperties; - - @Test - public void testCreateAfterSale() { - // 准备参数 - Long userId = 1024L; - AppTradeAfterSaleCreateReqVO createReqVO = new AppTradeAfterSaleCreateReqVO() - .setOrderItemId(1L).setRefundPrice(100).setWay(TradeAfterSaleWayEnum.RETURN_AND_REFUND.getWay()) - .setApplyReason("退钱").setApplyDescription("快退") - .setApplyPicUrls(asList("https://www.baidu.com/1.png", "https://www.baidu.com/2.png")); - // mock 方法(交易订单项) - TradeOrderItemDO orderItem = randomPojo(TradeOrderItemDO.class, o -> { - o.setOrderId(111L).setUserId(userId).setOrderDividePrice(200); - o.setAfterSaleStatus(TradeOrderItemAfterSaleStatusEnum.NONE.getStatus()); - }); - when(tradeOrderService.getOrderItem(eq(1024L), eq(1L))) - .thenReturn(orderItem); - // mock 方法(交易订单) - TradeOrderDO order = randomPojo(TradeOrderDO.class, o -> o.setStatus(TradeOrderStatusEnum.DELIVERED.getStatus()) - .setNo("202211301234")); - when(tradeOrderService.getOrder(eq(1024L), eq(111L))).thenReturn(order); - - // 调用 - Long afterSaleId = tradeAfterSaleService.createAfterSale(userId, createReqVO); - // 断言(TradeAfterSaleDO) - TradeAfterSaleDO afterSale = tradeAfterSaleMapper.selectById(afterSaleId); - assertNotNull(afterSale.getNo()); - assertEquals(afterSale.getStatus(), TradeAfterSaleStatusEnum.APPLY.getStatus()); - assertEquals(afterSale.getType(), TradeAfterSaleTypeEnum.IN_SALE.getType()); - assertPojoEquals(afterSale, createReqVO); - assertEquals(afterSale.getUserId(), 1024L); - assertPojoEquals(afterSale, orderItem, "id", "creator", "createTime", "updater", "updateTime"); - assertEquals(afterSale.getOrderNo(), "202211301234"); - assertNull(afterSale.getPayRefundId()); - assertNull(afterSale.getRefundTime()); - assertNull(afterSale.getLogisticsId()); - assertNull(afterSale.getLogisticsNo()); - assertNull(afterSale.getDeliveryTime()); - assertNull(afterSale.getReceiveReason()); - // 断言(TradeAfterSaleLogDO) - TradeAfterSaleLogDO afterSaleLog = tradeAfterSaleLogMapper.selectList().get(0); - assertEquals(afterSaleLog.getUserId(), userId); - assertEquals(afterSaleLog.getUserType(), UserTypeEnum.MEMBER.getValue()); - assertEquals(afterSaleLog.getAfterSaleId(), afterSaleId); - assertPojoEquals(afterSale, orderItem, "id", "creator", "createTime", "updater", "updateTime"); - assertNull(afterSaleLog.getBeforeStatus()); - assertEquals(afterSaleLog.getAfterStatus(), TradeAfterSaleStatusEnum.APPLY.getStatus()); - assertEquals(afterSaleLog.getContent(), TradeAfterSaleStatusEnum.APPLY.getContent()); - } - - @Test - public void testGetAfterSalePage() { - // mock 数据 - TradeAfterSaleDO dbAfterSale = randomPojo(TradeAfterSaleDO.class, o -> { // 等会查询到 - o.setNo("202211190847450020500077"); - o.setStatus(TradeAfterSaleStatusEnum.APPLY.getStatus()); - o.setWay(TradeAfterSaleWayEnum.RETURN_AND_REFUND.getWay()); - o.setType(TradeAfterSaleTypeEnum.IN_SALE.getType()); - o.setOrderNo("202211190847450020500011"); - o.setSpuName("芋艿"); - o.setCreateTime(buildTime(2022, 1, 15)); - }); - tradeAfterSaleMapper.insert(dbAfterSale); - // 测试 no 不匹配 - tradeAfterSaleMapper.insert(cloneIgnoreId(dbAfterSale, o -> o.setNo("202211190847450020500066"))); - // 测试 status 不匹配 - tradeAfterSaleMapper.insert(cloneIgnoreId(dbAfterSale, o -> o.setStatus(TradeAfterSaleStatusEnum.SELLER_REFUSE.getStatus()))); - // 测试 way 不匹配 - tradeAfterSaleMapper.insert(cloneIgnoreId(dbAfterSale, o -> o.setWay(TradeAfterSaleWayEnum.REFUND.getWay()))); - // 测试 type 不匹配 - tradeAfterSaleMapper.insert(cloneIgnoreId(dbAfterSale, o -> o.setType(TradeAfterSaleTypeEnum.AFTER_SALE.getType()))); - // 测试 orderNo 不匹配 - tradeAfterSaleMapper.insert(cloneIgnoreId(dbAfterSale, o -> o.setOrderNo("202211190847450020500022"))); - // 测试 spuName 不匹配 - tradeAfterSaleMapper.insert(cloneIgnoreId(dbAfterSale, o -> o.setSpuName("土豆"))); - // 测试 createTime 不匹配 - tradeAfterSaleMapper.insert(cloneIgnoreId(dbAfterSale, o -> o.setCreateTime(buildTime(2022, 1, 20)))); - // 准备参数 - TradeAfterSalePageReqVO reqVO = new TradeAfterSalePageReqVO(); - reqVO.setNo("20221119084745002050007"); - reqVO.setStatus(TradeAfterSaleStatusEnum.APPLY.getStatus()); - reqVO.setWay(TradeAfterSaleWayEnum.RETURN_AND_REFUND.getWay()); - reqVO.setType(TradeAfterSaleTypeEnum.IN_SALE.getType()); - reqVO.setOrderNo("20221119084745002050001"); - reqVO.setSpuName("芋"); - reqVO.setCreateTime(new LocalDateTime[]{buildTime(2022, 1, 1), buildTime(2022, 1, 16)}); - - // 调用 - PageResult pageResult = tradeAfterSaleService.getAfterSalePage(reqVO); - // 断言 - assertEquals(1, pageResult.getTotal()); - assertEquals(1, pageResult.getList().size()); - assertPojoEquals(dbAfterSale, pageResult.getList().get(0)); - } -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/test/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderServiceTest.java b/yudao-module-mall/yudao-module-trade-biz/src/test/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderServiceTest.java deleted file mode 100644 index 55bff8de6..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/test/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderServiceTest.java +++ /dev/null @@ -1,320 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.order; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.enums.TerminalEnum; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.module.member.api.address.AddressApi; -import cn.iocoder.yudao.module.member.api.address.dto.AddressRespDTO; -import cn.iocoder.yudao.module.pay.api.order.PayOrderApi; -import cn.iocoder.yudao.module.pay.api.order.dto.PayOrderRespDTO; -import cn.iocoder.yudao.module.pay.enums.order.PayOrderStatusEnum; -import cn.iocoder.yudao.module.product.api.sku.ProductSkuApi; -import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuRespDTO; -import cn.iocoder.yudao.module.product.api.spu.ProductSpuApi; -import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO; -import cn.iocoder.yudao.module.product.enums.spu.ProductSpuStatusEnum; -import cn.iocoder.yudao.module.promotion.api.coupon.CouponApi; -import cn.iocoder.yudao.module.promotion.api.price.PriceApi; -import cn.iocoder.yudao.module.promotion.api.price.dto.PriceCalculateRespDTO; -import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderDeliveryReqVO; -import cn.iocoder.yudao.module.trade.controller.app.order.vo.AppTradeOrderCreateReqVO; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderItemDO; -import cn.iocoder.yudao.module.trade.dal.mysql.order.TradeOrderItemMapper; -import cn.iocoder.yudao.module.trade.dal.mysql.order.TradeOrderMapper; -import cn.iocoder.yudao.module.trade.enums.order.*; -import cn.iocoder.yudao.module.trade.framework.order.config.TradeOrderConfig; -import cn.iocoder.yudao.module.trade.framework.order.config.TradeOrderProperties; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.context.annotation.Import; - -import javax.annotation.Resource; -import java.time.Duration; -import java.util.Arrays; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.util.collection.SetUtils.asSet; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomLongId; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; -import static java.util.Collections.singletonList; -import static org.junit.jupiter.api.Assertions.*; -import static org.mockito.ArgumentMatchers.argThat; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -/** - * {@link TradeOrderServiceImpl} 的单元测试类 - * - * @author LeeYan9 - * @since 2022-09-07 - */ -@Import({TradeOrderServiceImpl.class, TradeOrderConfig.class}) -public class TradeOrderServiceTest extends BaseDbUnitTest { - - @Resource - private TradeOrderServiceImpl tradeOrderService; - - @Resource - private TradeOrderMapper tradeOrderMapper; - @Resource - private TradeOrderItemMapper tradeOrderItemMapper; - - @MockBean - private ProductSpuApi productSpuApi; - @MockBean - private ProductSkuApi productSkuApi; - @MockBean - private PriceApi priceApi; - @MockBean - private PayOrderApi payOrderApi; - @MockBean - private AddressApi addressApi; - @MockBean - private CouponApi couponApi; - - @MockBean - private TradeOrderProperties tradeOrderProperties; - - @BeforeEach - public void setUp() { - when(tradeOrderProperties.getAppId()).thenReturn(888L); - when(tradeOrderProperties.getExpireTime()).thenReturn(Duration.ofDays(1)); - } - - @Test - public void testCreateTradeOrder_success() { - // 准备参数 - Long userId = 100L; - String userIp = "127.0.0.1"; - AppTradeOrderCreateReqVO reqVO = new AppTradeOrderCreateReqVO() - .setAddressId(10L).setCouponId(101L).setRemark("我是备注").setFromCart(true) - .setItems(Arrays.asList(new AppTradeOrderCreateReqVO.Item().setSkuId(1L).setCount(3), - new AppTradeOrderCreateReqVO.Item().setSkuId(2L).setCount(4))); - // mock 方法(商品 SKU 检查) - ProductSkuRespDTO sku01 = randomPojo(ProductSkuRespDTO.class, o -> o.setId(1L).setSpuId(11L) - .setPrice(50).setStock(100).setStatus(CommonStatusEnum.ENABLE.getStatus()) - .setProperties(singletonList(new ProductSkuRespDTO.Property().setPropertyId(111L).setValueId(222L)))); - ProductSkuRespDTO sku02 = randomPojo(ProductSkuRespDTO.class, o -> o.setId(2L).setSpuId(21L) - .setPrice(20).setStock(50).setStatus(CommonStatusEnum.ENABLE.getStatus())) - .setProperties(singletonList(new ProductSkuRespDTO.Property().setPropertyId(333L).setValueId(444L))); - when(productSkuApi.getSkuList(eq(asSet(1L, 2L)))).thenReturn(Arrays.asList(sku01, sku02)); - // mock 方法(商品 SPU 检查) - ProductSpuRespDTO spu01 = randomPojo(ProductSpuRespDTO.class, o -> o.setId(11L) - .setStatus(ProductSpuStatusEnum.ENABLE.getStatus()).setName("商品 1")); - ProductSpuRespDTO spu02 = randomPojo(ProductSpuRespDTO.class, o -> o.setId(21L) - .setStatus(ProductSpuStatusEnum.ENABLE.getStatus())); - when(productSpuApi.getSpuList(eq(asSet(11L, 21L)))).thenReturn(Arrays.asList(spu01, spu02)); - // mock 方法(用户收件地址的校验) - AddressRespDTO addressRespDTO = new AddressRespDTO().setId(10L).setUserId(userId).setName("芋艿") - .setMobile("15601691300").setAreaId(3306L).setPostCode("85757").setDetailAddress("土豆村"); - when(addressApi.getAddress(eq(10L), eq(userId))).thenReturn(addressRespDTO); - // mock 方法(价格计算) - PriceCalculateRespDTO.OrderItem priceOrderItem01 = new PriceCalculateRespDTO.OrderItem() - .setSpuId(11L).setSkuId(1L).setCount(3).setOriginalPrice(150).setOriginalUnitPrice(50) - .setDiscountPrice(20).setPayPrice(130).setOrderPartPrice(7).setOrderDividePrice(35); - PriceCalculateRespDTO.OrderItem priceOrderItem02 = new PriceCalculateRespDTO.OrderItem() - .setSpuId(21L).setSkuId(2L).setCount(4).setOriginalPrice(80).setOriginalUnitPrice(20) - .setDiscountPrice(40).setPayPrice(40).setOrderPartPrice(15).setOrderDividePrice(25); - PriceCalculateRespDTO.Order priceOrder = new PriceCalculateRespDTO.Order() - .setOriginalPrice(230).setOrderPrice(100).setDiscountPrice(0).setCouponPrice(30) - .setPointPrice(10).setDeliveryPrice(20).setPayPrice(80).setCouponId(101L).setCouponPrice(30) - .setItems(Arrays.asList(priceOrderItem01, priceOrderItem02)); - when(priceApi.calculatePrice(argThat(priceCalculateReqDTO -> { - assertEquals(priceCalculateReqDTO.getUserId(), 100L); - assertEquals(priceCalculateReqDTO.getCouponId(), 101L); - assertEquals(priceCalculateReqDTO.getItems().get(0).getSkuId(), 1L); - assertEquals(priceCalculateReqDTO.getItems().get(0).getCount(), 3); - assertEquals(priceCalculateReqDTO.getItems().get(1).getSkuId(), 2L); - assertEquals(priceCalculateReqDTO.getItems().get(1).getCount(), 4); - return true; - }))).thenReturn(new PriceCalculateRespDTO().setOrder(priceOrder)); - // mock 方法(创建支付单) - when(payOrderApi.createOrder(argThat(createReqDTO -> { - assertEquals(createReqDTO.getAppId(), 888L); - assertEquals(createReqDTO.getUserIp(), userIp); - assertNotNull(createReqDTO.getMerchantOrderId()); // 由于 tradeOrderId 后生成,只能校验非空 - assertEquals(createReqDTO.getSubject(), "商品 1 等多件"); - assertNull(createReqDTO.getBody()); - assertEquals(createReqDTO.getAmount(), 80); - assertNotNull(createReqDTO.getExpireTime()); - return true; - }))).thenReturn(1000L); - - // 调用方法 - Long tradeOrderId = tradeOrderService.createOrder(userId, userIp, reqVO); - // 断言 TradeOrderDO 订单 - List tradeOrderDOs = tradeOrderMapper.selectList(); - assertEquals(tradeOrderDOs.size(), 1); - TradeOrderDO tradeOrderDO = tradeOrderDOs.get(0); - assertEquals(tradeOrderDO.getId(), tradeOrderId); - assertNotNull(tradeOrderDO.getNo()); - assertEquals(tradeOrderDO.getType(), TradeOrderTypeEnum.NORMAL.getType()); - assertEquals(tradeOrderDO.getTerminal(), TerminalEnum.H5.getTerminal()); - assertEquals(tradeOrderDO.getUserId(), userId); - assertEquals(tradeOrderDO.getUserIp(), userIp); - assertEquals(tradeOrderDO.getStatus(), TradeOrderStatusEnum.UNPAID.getStatus()); - assertEquals(tradeOrderDO.getProductCount(), 7); - assertNull(tradeOrderDO.getFinishTime()); - assertNull(tradeOrderDO.getCancelTime()); - assertNull(tradeOrderDO.getCancelType()); - assertEquals(tradeOrderDO.getUserRemark(), "我是备注"); - assertNull(tradeOrderDO.getRemark()); - assertFalse(tradeOrderDO.getPayed()); - assertNull(tradeOrderDO.getPayTime()); - assertEquals(tradeOrderDO.getOriginalPrice(), 230); - assertEquals(tradeOrderDO.getOrderPrice(), 100); - assertEquals(tradeOrderDO.getDiscountPrice(), 0); - assertEquals(tradeOrderDO.getAdjustPrice(), 0); - assertEquals(tradeOrderDO.getPayPrice(), 80); - assertEquals(tradeOrderDO.getPayOrderId(), 1000L); - assertNull(tradeOrderDO.getPayChannelCode()); - assertNull(tradeOrderDO.getDeliveryTemplateId()); - assertNull(tradeOrderDO.getLogisticsId()); - assertEquals(tradeOrderDO.getDeliveryStatus(), TradeOrderDeliveryStatusEnum.UNDELIVERED.getStatus()); - assertNull(tradeOrderDO.getDeliveryTime()); - assertNull(tradeOrderDO.getReceiveTime()); - assertEquals(tradeOrderDO.getReceiverName(), "芋艿"); - assertEquals(tradeOrderDO.getReceiverMobile(), "15601691300"); - assertEquals(tradeOrderDO.getReceiverAreaId(), 3306); - assertEquals(tradeOrderDO.getReceiverPostCode(), 85757); - assertEquals(tradeOrderDO.getReceiverDetailAddress(), "土豆村"); - assertEquals(tradeOrderDO.getAfterSaleStatus(), TradeOrderAfterSaleStatusEnum.NONE.getStatus()); - assertEquals(tradeOrderDO.getRefundPrice(), 0); - assertEquals(tradeOrderDO.getCouponPrice(), 30); - assertEquals(tradeOrderDO.getPointPrice(), 10); - // 断言 TradeOrderItemDO 订单(第 1 个) - List tradeOrderItemDOs = tradeOrderItemMapper.selectList(); - assertEquals(tradeOrderItemDOs.size(), 2); - TradeOrderItemDO tradeOrderItemDO01 = tradeOrderItemDOs.get(0); - assertNotNull(tradeOrderItemDO01.getId()); - assertEquals(tradeOrderItemDO01.getUserId(), userId); - assertEquals(tradeOrderItemDO01.getOrderId(), tradeOrderId); - assertEquals(tradeOrderItemDO01.getSpuId(), 11L); - assertEquals(tradeOrderItemDO01.getSkuId(), 1L); - assertEquals(tradeOrderItemDO01.getProperties().size(), 1); - assertEquals(tradeOrderItemDO01.getProperties().get(0).getPropertyId(), 111L); - assertEquals(tradeOrderItemDO01.getProperties().get(0).getValueId(), 222L); - assertEquals(tradeOrderItemDO01.getSpuName(), sku01.getSpuName()); - assertEquals(tradeOrderItemDO01.getPicUrl(), sku01.getPicUrl()); - assertEquals(tradeOrderItemDO01.getCount(), 3); - assertEquals(tradeOrderItemDO01.getOriginalPrice(), 150); - assertEquals(tradeOrderItemDO01.getOriginalUnitPrice(), 50); - assertEquals(tradeOrderItemDO01.getDiscountPrice(), 20); - assertEquals(tradeOrderItemDO01.getPayPrice(), 130); - assertEquals(tradeOrderItemDO01.getOrderPartPrice(), 7); - assertEquals(tradeOrderItemDO01.getOrderDividePrice(), 35); - assertEquals(tradeOrderItemDO01.getAfterSaleStatus(), TradeOrderItemAfterSaleStatusEnum.NONE.getStatus()); - // 断言 TradeOrderItemDO 订单(第 2 个) - TradeOrderItemDO tradeOrderItemDO02 = tradeOrderItemDOs.get(1); - assertNotNull(tradeOrderItemDO02.getId()); - assertEquals(tradeOrderItemDO02.getUserId(), userId); - assertEquals(tradeOrderItemDO02.getOrderId(), tradeOrderId); - assertEquals(tradeOrderItemDO02.getSpuId(), 21L); - assertEquals(tradeOrderItemDO02.getSkuId(), 2L); - assertEquals(tradeOrderItemDO02.getProperties().size(), 1); - assertEquals(tradeOrderItemDO02.getProperties().get(0).getPropertyId(), 333L); - assertEquals(tradeOrderItemDO02.getProperties().get(0).getValueId(), 444L); - assertEquals(tradeOrderItemDO02.getSpuName(), sku02.getSpuName()); - assertEquals(tradeOrderItemDO02.getPicUrl(), sku02.getPicUrl()); - assertEquals(tradeOrderItemDO02.getCount(), 4); - assertEquals(tradeOrderItemDO02.getOriginalPrice(), 80); - assertEquals(tradeOrderItemDO02.getOriginalUnitPrice(), 20); - assertEquals(tradeOrderItemDO02.getDiscountPrice(), 40); - assertEquals(tradeOrderItemDO02.getPayPrice(), 40); - assertEquals(tradeOrderItemDO02.getOrderPartPrice(), 15); - assertEquals(tradeOrderItemDO02.getOrderDividePrice(), 25); - assertEquals(tradeOrderItemDO02.getAfterSaleStatus(), TradeOrderItemAfterSaleStatusEnum.NONE.getStatus()); - // 校验调用 - verify(productSkuApi).updateSkuStock(argThat(updateStockReqDTO -> { - assertEquals(updateStockReqDTO.getItems().size(), 2); - assertEquals(updateStockReqDTO.getItems().get(0).getId(), 1L); - assertEquals(updateStockReqDTO.getItems().get(0).getIncrCount(), 3); - assertEquals(updateStockReqDTO.getItems().get(1).getId(), 2L); - assertEquals(updateStockReqDTO.getItems().get(1).getIncrCount(), 4); - return true; - })); - verify(couponApi).useCoupon(argThat(reqDTO -> { - assertEquals(reqDTO.getId(), reqVO.getCouponId()); - assertEquals(reqDTO.getUserId(), userId); - assertEquals(reqDTO.getOrderId(), tradeOrderId); - return true; - })); - } - - @Test - public void testUpdateOrderPaid() { - // mock 数据(TradeOrder) - TradeOrderDO order = randomPojo(TradeOrderDO.class, o -> { - o.setId(1L).setStatus(TradeOrderStatusEnum.UNPAID.getStatus()); - o.setPayOrderId(10L).setPayed(false).setPayPrice(100).setPayTime(null); - }); - tradeOrderMapper.insert(order); - // 准备参数 - Long id = 1L; - Long payOrderId = 10L; - // mock 方法(支付单) - when(payOrderApi.getOrder(eq(10L))).thenReturn(randomPojo(PayOrderRespDTO.class, - o -> o.setStatus(PayOrderStatusEnum.SUCCESS.getStatus()).setChannelCode("wx_pub") - .setMerchantOrderId("1")).setAmount(100)); - - // 调用 - tradeOrderService.updateOrderPaid(id, payOrderId); - // 断言 - TradeOrderDO dbOrder = tradeOrderMapper.selectById(id); - assertEquals(dbOrder.getStatus(), TradeOrderStatusEnum.UNDELIVERED.getStatus()); - assertTrue(dbOrder.getPayed()); - assertNotNull(dbOrder.getPayTime()); - assertEquals(dbOrder.getPayChannelCode(), "wx_pub"); - } - - @Test - public void testDeliveryOrder() { - // mock 数据(TradeOrder) - TradeOrderDO order = randomPojo(TradeOrderDO.class, o -> { - o.setId(1L).setStatus(TradeOrderStatusEnum.UNDELIVERED.getStatus()); - o.setLogisticsId(null).setLogisticsNo(null).setDeliveryTime(null) - .setDeliveryStatus(TradeOrderDeliveryStatusEnum.UNDELIVERED.getStatus()); - }); - tradeOrderMapper.insert(order); - // 准备参数 - TradeOrderDeliveryReqVO deliveryReqVO = new TradeOrderDeliveryReqVO().setId(1L) - .setLogisticsId(10L).setLogisticsNo("100"); - // mock 方法(支付单) - - // 调用 - tradeOrderService.deliveryOrder(randomLongId(), deliveryReqVO); - // 断言 - TradeOrderDO dbOrder = tradeOrderMapper.selectById(1L); - assertEquals(dbOrder.getStatus(), TradeOrderStatusEnum.DELIVERED.getStatus()); - assertEquals(dbOrder.getDeliveryStatus(), TradeOrderDeliveryStatusEnum.DELIVERED.getStatus()); - assertPojoEquals(dbOrder, deliveryReqVO); - assertNotNull(dbOrder.getDeliveryTime()); - } - - @Test - public void testReceiveOrder() { - // mock 数据(TradeOrder) - TradeOrderDO order = randomPojo(TradeOrderDO.class, o -> { - o.setId(1L).setUserId(10L).setStatus(TradeOrderStatusEnum.DELIVERED.getStatus()); - o.setDeliveryStatus(TradeOrderDeliveryStatusEnum.DELIVERED.getStatus()).setReceiveTime(null); - }); - tradeOrderMapper.insert(order); - // 准备参数 - Long id = 1L; - Long userId = 10L; - // mock 方法(支付单) - - // 调用 - tradeOrderService.receiveOrder(userId, id); - // 断言 - TradeOrderDO dbOrder = tradeOrderMapper.selectById(1L); - assertEquals(dbOrder.getStatus(), TradeOrderStatusEnum.COMPLETED.getStatus()); - assertEquals(dbOrder.getDeliveryStatus(), TradeOrderDeliveryStatusEnum.RECEIVED.getStatus()); - assertNotNull(dbOrder.getReceiveTime()); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/test/resources/application-unit-test.yaml b/yudao-module-mall/yudao-module-trade-biz/src/test/resources/application-unit-test.yaml deleted file mode 100644 index 19dd0e97b..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/test/resources/application-unit-test.yaml +++ /dev/null @@ -1,53 +0,0 @@ -spring: - main: - lazy-initialization: true # 开启懒加载,加快速度 - banner-mode: off # 单元测试,禁用 Banner - ---- #################### 数据库相关配置 #################### - -spring: - # 数据源配置项 - datasource: - name: ruoyi-vue-pro - url: jdbc:h2:mem:testdb;MODE=MYSQL;DATABASE_TO_UPPER=false;NON_KEYWORDS=value; # MODE 使用 MySQL 模式;DATABASE_TO_UPPER 配置表和字段使用小写 - driver-class-name: org.h2.Driver - username: sa - password: - druid: - async-init: true # 单元测试,异步初始化 Druid 连接池,提升启动速度 - initial-size: 1 # 单元测试,配置为 1,提升启动速度 - sql: - init: - schema-locations: classpath:/sql/create_tables.sql - - # Redis 配置。Redisson 默认的配置足够使用,一般不需要进行调优 - redis: - host: 127.0.0.1 # 地址 - port: 16379 # 端口(单元测试,使用 16379 端口) - database: 0 # 数据库索引 - -mybatis: - lazy-initialization: true # 单元测试,设置 MyBatis Mapper 延迟加载,加速每个单元测试 - ---- #################### 定时任务相关配置 #################### - ---- #################### 配置中心相关配置 #################### - ---- #################### 服务保障相关配置 #################### - -# Lock4j 配置项(单元测试,禁用 Lock4j) - -# Resilience4j 配置项 - ---- #################### 监控相关配置 #################### - ---- #################### 芋道相关配置 #################### - -# 芋道配置项,设置当前项目所有自定义的配置 -yudao: - info: - base-package: cn.iocoder.yudao.module - trade: - order: - app-id: 1 - merchant-order-id: 1 diff --git a/yudao-module-mall/yudao-module-trade-biz/src/test/resources/logback.xml b/yudao-module-mall/yudao-module-trade-biz/src/test/resources/logback.xml deleted file mode 100644 index daf756bff..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/test/resources/logback.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/yudao-module-mall/yudao-module-trade-biz/src/test/resources/sql/clean.sql b/yudao-module-mall/yudao-module-trade-biz/src/test/resources/sql/clean.sql deleted file mode 100644 index dfa4a5b42..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/test/resources/sql/clean.sql +++ /dev/null @@ -1,4 +0,0 @@ -DELETE FROM trade_order; -DELETE FROM trade_order_item; -DELETE FROM trade_after_sale; -DELETE FROM trade_after_sale_log; diff --git a/yudao-module-mall/yudao-module-trade-biz/src/test/resources/sql/create_tables.sql b/yudao-module-mall/yudao-module-trade-biz/src/test/resources/sql/create_tables.sql deleted file mode 100644 index 452362eb5..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/test/resources/sql/create_tables.sql +++ /dev/null @@ -1,128 +0,0 @@ -CREATE TABLE IF NOT EXISTS "trade_order" ( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "no" varchar NOT NULL, - "type" int NOT NULL, - "terminal" int NOT NULL, - "user_id" bigint NOT NULL, - "user_ip" varchar NOT NULL, - "user_remark" varchar, - "status" int NOT NULL, - "product_count" int NOT NULL, - "cancel_type" int, - "remark" varchar, - "payed" bit NOT NULL, - "pay_time" datetime, - "finish_time" datetime, - "cancel_time" datetime, - "original_price" int NOT NULL, - "order_price" int NOT NULL, - "discount_price" int NOT NULL, - "delivery_price" int NOT NULL, - "adjust_price" int NOT NULL, - "pay_price" int NOT NULL, - "pay_order_id" bigint, - "pay_channel_code" varchar, - "delivery_template_id" bigint, - "logistics_id" bigint, - "logistics_no" varchar, - "delivery_status" smallint NOT NULL, - "delivery_time" datetime, - "receive_time" datetime, - "receiver_name" varchar NOT NULL, - "receiver_mobile" varchar NOT NULL, - "receiver_area_id" int NOT NULL, - "receiver_post_code" int, - "receiver_detail_address" varchar NOT NULL, - "after_sale_status" int NOT NULL, - "refund_price" int NOT NULL, - "coupon_id" bigint NOT NULL, - "coupon_price" int NOT NULL, - "point_price" int NOT NULL, - "creator" varchar DEFAULT '', - "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar DEFAULT '', - "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - PRIMARY KEY ("id") -) COMMENT '交易订单表'; - -CREATE TABLE IF NOT EXISTS "trade_order_item" ( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "user_id" bigint NOT NULL, - "order_id" bigint NOT NULL, - "spu_id" bigint NOT NULL, - "spu_name" varchar NOT NULL, - "sku_id" bigint NOT NULL, - "properties" varchar, - "pic_url" varchar, - "count" int NOT NULL, - "original_price" int NOT NULL, - "original_unit_price" int NOT NULL, - "discount_price" int NOT NULL, - "pay_price" int NOT NULL, - "order_part_price" int NOT NULL, - "order_divide_price" int NOT NULL, - "after_sale_status" int NOT NULL, - "creator" varchar DEFAULT '', - "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar DEFAULT '', - "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - PRIMARY KEY ("id") -) COMMENT '交易订单明细表'; - -CREATE TABLE IF NOT EXISTS "trade_after_sale" ( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "no" varchar NOT NULL, - "status" int NOT NULL, - "type" int NOT NULL, - "way" int NOT NULL, - "user_id" bigint NOT NULL, - "apply_reason" varchar NOT NULL, - "apply_description" varchar, - "apply_pic_urls" varchar, - "order_id" bigint NOT NULL, - "order_no" varchar NOT NULL, - "order_item_id" bigint NOT NULL, - "spu_id" bigint NOT NULL, - "spu_name" varchar NOT NULL, - "sku_id" bigint NOT NULL, - "properties" varchar, - "pic_url" varchar, - "count" int NOT NULL, - "audit_time" varchar, - "audit_user_id" bigint, - "audit_reason" varchar, - "refund_price" int NOT NULL, - "pay_refund_id" bigint, - "refund_time" varchar, - "logistics_id" bigint, - "logistics_no" varchar, - "delivery_time" varchar, - "receive_time" varchar, - "receive_reason" varchar, - "creator" varchar DEFAULT '', - "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar DEFAULT '', - "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - PRIMARY KEY ("id") -) COMMENT '交易售后表'; - -CREATE TABLE IF NOT EXISTS "trade_after_sale_log" ( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "user_id" bigint NOT NULL, - "user_type" int NOT NULL, - "after_sale_id" bigint NOT NULL, - "order_id" bigint NOT NULL, - "order_item_id" bigint NOT NULL, - "before_status" int, - "after_status" int NOT NULL, - "content" varchar NOT NULL, - "creator" varchar DEFAULT '', - "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar DEFAULT '', - "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - PRIMARY KEY ("id") -) COMMENT '交易售后日志'; diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/notify/PayNotifyController.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/notify/PayNotifyController.java index fa9177538..62b753730 100644 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/notify/PayNotifyController.java +++ b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/notify/PayNotifyController.java @@ -6,8 +6,8 @@ import cn.iocoder.yudao.framework.pay.core.client.PayClientFactory; import cn.iocoder.yudao.framework.pay.core.client.dto.PayNotifyDataDTO; import cn.iocoder.yudao.module.pay.service.order.PayOrderService; import cn.iocoder.yudao.module.pay.service.refund.PayRefundService; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; import lombok.extern.slf4j.Slf4j; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; @@ -19,7 +19,7 @@ import java.util.Map; import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; import static cn.iocoder.yudao.module.pay.enums.ErrorCodeConstants.PAY_CHANNEL_CLIENT_NOT_FOUND; -@Api(tags = "管理后台 - 支付通知") +@Tag(name = "管理后台 - 支付通知") @RestController @RequestMapping("/pay/notify") @Validated @@ -43,7 +43,7 @@ public class PayNotifyController { * @return 返回跳转页面 */ @GetMapping(value = "/return/{channelId}") - @ApiOperation("渠道统一的支付成功返回地址") + @Operation(summary = "渠道统一的支付成功返回地址") @Deprecated // TODO yunai:如果是 way 的情况,应该是跳转回前端地址 public String returnCallback(@PathVariable("channelId") Long channelId, @RequestParam Map params) { @@ -60,7 +60,7 @@ public class PayNotifyController { * @return 成功返回 "success" */ @PostMapping(value = "/callback/{channelId}") - @ApiOperation(value = "支付渠道的统一回调接口", notes = "包括支付回调,退款回调") + @Operation(summary = "支付渠道的统一回调接口 - 包括支付回调,退款回调") @PermitAll @OperateLog(enable = false) // 回调地址,无需记录操作日志 public String notifyCallback(@PathVariable("channelId") Long channelId, diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/ip/AreaController.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/ip/AreaController.java index a7e4d3e03..2d5c766fd 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/ip/AreaController.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/ip/AreaController.java @@ -7,9 +7,9 @@ import cn.iocoder.yudao.framework.ip.core.utils.AreaUtils; import cn.iocoder.yudao.framework.ip.core.utils.IPUtils; import cn.iocoder.yudao.module.system.controller.admin.ip.vo.AreaNodeRespVO; import cn.iocoder.yudao.module.system.convert.ip.AreaConvert; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiImplicitParam; -import io.swagger.annotations.ApiOperation; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.tags.Tag; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; @@ -20,14 +20,14 @@ import java.util.List; import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -@Api(tags = "管理后台 - 地区") +@Tag(name = "管理后台 - 地区") @RestController @RequestMapping("/system/area") @Validated public class AreaController { @GetMapping("/tree") - @ApiOperation("获得地区树") + @Operation(summary = "获得地区树") public CommonResult> getAreaTree() { Area area = AreaUtils.getArea(Area.ID_CHINA); Assert.notNull(area, "获取不到中国"); @@ -35,8 +35,8 @@ public class AreaController { } @GetMapping("/get-by-ip") - @ApiOperation("获得 IP 对应的地区名") - @ApiImplicitParam(name = "ip", value = "IP", required = true, dataTypeClass = String.class) + @Operation(summary = "获得 IP 对应的地区名") + @Parameter(name = "ip", description = "IP", required = true) public CommonResult getAreaByIp(@RequestParam("ip") String ip) { // 获得城市 Area area = IPUtils.getArea(ip); diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/ip/vo/AreaNodeRespVO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/ip/vo/AreaNodeRespVO.java index a2416832d..614b84fe0 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/ip/vo/AreaNodeRespVO.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/ip/vo/AreaNodeRespVO.java @@ -1,19 +1,18 @@ package cn.iocoder.yudao.module.system.controller.admin.ip.vo; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; +import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; import java.util.List; -@ApiModel("管理后台 - 地区节点 Response VO") +@Schema(description = "管理后台 - 地区节点 Response VO") @Data public class AreaNodeRespVO { - @ApiModelProperty(value = "编号", required = true, example = "110000") + @Schema(description = "编号", required = true, example = "110000") private Integer id; - @ApiModelProperty(value = "名字", required = true, example = "北京") + @Schema(description = "名字", required = true, example = "北京") private String name; /**