Commit 63cb9eb47ebfc21b100d93be6e0cfdd84daa5d0b
Merge branch 'feature/1.8.0-uniapp' of https://gitee.com/zhijiantianya/ruoyi-vue…
…-pro into feature/1.8.0-uniapp
Showing
67 changed files
with
1481 additions
and
2493 deletions
yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/string/StrUtils.java
| @@ -3,7 +3,10 @@ package cn.iocoder.yudao.framework.common.util.string; | @@ -3,7 +3,10 @@ package cn.iocoder.yudao.framework.common.util.string; | ||
| 3 | import cn.hutool.core.util.ArrayUtil; | 3 | import cn.hutool.core.util.ArrayUtil; |
| 4 | import cn.hutool.core.util.StrUtil; | 4 | import cn.hutool.core.util.StrUtil; |
| 5 | 5 | ||
| 6 | +import java.util.Arrays; | ||
| 6 | import java.util.Collection; | 7 | import java.util.Collection; |
| 8 | +import java.util.List; | ||
| 9 | +import java.util.stream.Collectors; | ||
| 7 | 10 | ||
| 8 | /** | 11 | /** |
| 9 | * 字符串工具类 | 12 | * 字符串工具类 |
| @@ -37,4 +40,9 @@ public class StrUtils { | @@ -37,4 +40,9 @@ public class StrUtils { | ||
| 37 | return false; | 40 | return false; |
| 38 | } | 41 | } |
| 39 | 42 | ||
| 43 | + public static List<Long> splitToLong(String value, CharSequence separator) { | ||
| 44 | + long[] longs = StrUtil.splitToLong(value, separator); | ||
| 45 | + return Arrays.stream(longs).boxed().collect(Collectors.toList()); | ||
| 46 | + } | ||
| 47 | + | ||
| 40 | } | 48 | } |
yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/mybatis/core/type/LongListTypeHandler.java
0 → 100644
| 1 | +package cn.iocoder.yudao.framework.mybatis.core.type; | ||
| 2 | + | ||
| 3 | +import cn.hutool.core.collection.CollUtil; | ||
| 4 | +import cn.iocoder.yudao.framework.common.util.string.StrUtils; | ||
| 5 | +import org.apache.ibatis.type.JdbcType; | ||
| 6 | +import org.apache.ibatis.type.MappedJdbcTypes; | ||
| 7 | +import org.apache.ibatis.type.MappedTypes; | ||
| 8 | +import org.apache.ibatis.type.TypeHandler; | ||
| 9 | + | ||
| 10 | +import java.sql.CallableStatement; | ||
| 11 | +import java.sql.PreparedStatement; | ||
| 12 | +import java.sql.ResultSet; | ||
| 13 | +import java.sql.SQLException; | ||
| 14 | +import java.util.List; | ||
| 15 | + | ||
| 16 | +/** | ||
| 17 | + * List<Long> 的类型转换器实现类,对应数据库的 varchar 类型 | ||
| 18 | + * | ||
| 19 | + * @author 芋道源码 | ||
| 20 | + */ | ||
| 21 | +@MappedJdbcTypes(JdbcType.VARCHAR) | ||
| 22 | +@MappedTypes(List.class) | ||
| 23 | +public class LongListTypeHandler implements TypeHandler<List<Long>> { | ||
| 24 | + | ||
| 25 | + private static final String COMMA = ","; | ||
| 26 | + | ||
| 27 | + @Override | ||
| 28 | + public void setParameter(PreparedStatement ps, int i, List<Long> strings, JdbcType jdbcType) throws SQLException { | ||
| 29 | + // 设置占位符 | ||
| 30 | + ps.setString(i, CollUtil.join(strings, COMMA)); | ||
| 31 | + } | ||
| 32 | + | ||
| 33 | + @Override | ||
| 34 | + public List<Long> getResult(ResultSet rs, String columnName) throws SQLException { | ||
| 35 | + String value = rs.getString(columnName); | ||
| 36 | + return getResult(value); | ||
| 37 | + } | ||
| 38 | + | ||
| 39 | + @Override | ||
| 40 | + public List<Long> getResult(ResultSet rs, int columnIndex) throws SQLException { | ||
| 41 | + String value = rs.getString(columnIndex); | ||
| 42 | + return getResult(value); | ||
| 43 | + } | ||
| 44 | + | ||
| 45 | + @Override | ||
| 46 | + public List<Long> getResult(CallableStatement cs, int columnIndex) throws SQLException { | ||
| 47 | + String value = cs.getString(columnIndex); | ||
| 48 | + return getResult(value); | ||
| 49 | + } | ||
| 50 | + | ||
| 51 | + private List<Long> getResult(String value) { | ||
| 52 | + if (value == null) { | ||
| 53 | + return null; | ||
| 54 | + } | ||
| 55 | + return StrUtils.splitToLong(value, COMMA); | ||
| 56 | + } | ||
| 57 | +} |
yudao-module-mall/yudao-module-coupon-api/pom.xml deleted
| 1 | -<?xml version="1.0" encoding="UTF-8"?> | ||
| 2 | -<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
| 3 | - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
| 4 | - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
| 5 | - <parent> | ||
| 6 | - <groupId>cn.iocoder.boot</groupId> | ||
| 7 | - <artifactId>yudao-module-mall</artifactId> | ||
| 8 | - <version>${revision}</version> | ||
| 9 | - </parent> | ||
| 10 | - | ||
| 11 | - <modelVersion>4.0.0</modelVersion> | ||
| 12 | - <artifactId>yudao-module-coupon-api</artifactId> | ||
| 13 | - <packaging>jar</packaging> | ||
| 14 | - | ||
| 15 | - | ||
| 16 | - <name>${project.artifactId}</name> | ||
| 17 | - <description> | ||
| 18 | - coupon 模块 API,暴露给其它模块调用 | ||
| 19 | - </description> | ||
| 20 | - | ||
| 21 | - <dependencies> | ||
| 22 | - <dependency> | ||
| 23 | - <groupId>cn.iocoder.boot</groupId> | ||
| 24 | - <artifactId>yudao-common</artifactId> | ||
| 25 | - </dependency> | ||
| 26 | - | ||
| 27 | - <!-- 参数校验 --> | ||
| 28 | - <dependency> | ||
| 29 | - <groupId>org.springframework.boot</groupId> | ||
| 30 | - <artifactId>spring-boot-starter-validation</artifactId> | ||
| 31 | - <optional>true</optional> | ||
| 32 | - </dependency> | ||
| 33 | - </dependencies> | ||
| 34 | - | ||
| 35 | -</project> | ||
| 36 | \ No newline at end of file | 0 | \ No newline at end of file |
yudao-module-mall/yudao-module-coupon-api/src/main/java/cn/iocoder/yudao/module/CouponTemplete/enums/CouponExpireTimeTypeEnum.java deleted
| 1 | -package cn.iocoder.yudao.module.CouponTemplete.enums; | ||
| 2 | - | ||
| 3 | - | ||
| 4 | -import lombok.Getter; | ||
| 5 | -import lombok.RequiredArgsConstructor; | ||
| 6 | - | ||
| 7 | - | ||
| 8 | -/** | ||
| 9 | - * 优惠券 - 是否开启过期提醒 | ||
| 10 | - * | ||
| 11 | - * @author Sin | ||
| 12 | - */ | ||
| 13 | -@RequiredArgsConstructor | ||
| 14 | -@Getter | ||
| 15 | -public enum CouponExpireTimeTypeEnum { | ||
| 16 | - | ||
| 17 | - OPEN(1,"不开启"), | ||
| 18 | - CLOSE(0,"开启"),; | ||
| 19 | - | ||
| 20 | - /** | ||
| 21 | - * 是否开启过期提醒 | ||
| 22 | - */ | ||
| 23 | - private final Integer type; | ||
| 24 | - /** | ||
| 25 | - * 是否开启过期提醒 | ||
| 26 | - */ | ||
| 27 | - private final String name; | ||
| 28 | - | ||
| 29 | -} |
yudao-module-mall/yudao-module-coupon-api/src/main/java/cn/iocoder/yudao/module/CouponTemplete/enums/CouponFetchTypeEnum.java deleted
| 1 | -package cn.iocoder.yudao.module.CouponTemplete.enums; | ||
| 2 | - | ||
| 3 | - | ||
| 4 | -import lombok.Getter; | ||
| 5 | -import lombok.RequiredArgsConstructor; | ||
| 6 | - | ||
| 7 | - | ||
| 8 | -/** | ||
| 9 | - * 优惠券 - 领取是否无限制 0 | ||
| 10 | - * | ||
| 11 | - * @author Sin | ||
| 12 | - */ | ||
| 13 | -@RequiredArgsConstructor | ||
| 14 | -@Getter | ||
| 15 | -public enum CouponFetchTypeEnum { | ||
| 16 | - | ||
| 17 | - LIMIT(1,"限制"), | ||
| 18 | - NOT_LIMIT(0,"不限制"),; | ||
| 19 | - | ||
| 20 | - /** | ||
| 21 | - * 是否开启过期提醒 | ||
| 22 | - */ | ||
| 23 | - private final Integer type; | ||
| 24 | - /** | ||
| 25 | - * 是否开启过期提醒 | ||
| 26 | - */ | ||
| 27 | - private final String name; | ||
| 28 | - | ||
| 29 | -} |
yudao-module-mall/yudao-module-coupon-api/src/main/java/cn/iocoder/yudao/module/CouponTemplete/enums/CouponForbidPreferenceEnum.java deleted
| 1 | -package cn.iocoder.yudao.module.CouponTemplete.enums; | ||
| 2 | - | ||
| 3 | - | ||
| 4 | -import lombok.Getter; | ||
| 5 | -import lombok.RequiredArgsConstructor; | ||
| 6 | - | ||
| 7 | - | ||
| 8 | -/** | ||
| 9 | - * 优惠券 - 优惠叠加类型 | ||
| 10 | - * | ||
| 11 | - * @author Sin | ||
| 12 | - */ | ||
| 13 | -@RequiredArgsConstructor | ||
| 14 | -@Getter | ||
| 15 | -public enum CouponForbidPreferenceEnum { | ||
| 16 | - | ||
| 17 | - UN_FORBID(0,"不限制"), | ||
| 18 | - FORBID(1,"优惠券仅原价购买商品时可用"); | ||
| 19 | - | ||
| 20 | - /** | ||
| 21 | - * 优惠券类型 | ||
| 22 | - */ | ||
| 23 | - private final Integer type; | ||
| 24 | - /** | ||
| 25 | - * 优惠券类型名 | ||
| 26 | - */ | ||
| 27 | - private final String name; | ||
| 28 | - | ||
| 29 | -} |
yudao-module-mall/yudao-module-coupon-api/src/main/java/cn/iocoder/yudao/module/CouponTemplete/enums/CouponGoodsTypeEnum.java deleted
| 1 | -package cn.iocoder.yudao.module.CouponTemplete.enums; | ||
| 2 | - | ||
| 3 | - | ||
| 4 | -import lombok.Getter; | ||
| 5 | -import lombok.RequiredArgsConstructor; | ||
| 6 | - | ||
| 7 | - | ||
| 8 | -/** | ||
| 9 | - * 优惠券 - 优惠券商品使用类型 | ||
| 10 | - * | ||
| 11 | - * @author Sin | ||
| 12 | - */ | ||
| 13 | -@RequiredArgsConstructor | ||
| 14 | -@Getter | ||
| 15 | -public enum CouponGoodsTypeEnum { | ||
| 16 | - | ||
| 17 | - ALL(1,"全部商品可用"), | ||
| 18 | - POINT_PRODUCT(2,"指定商品可用"), | ||
| 19 | - POINT_PRODUCT_NOT(3,"指定商品不可用"),; | ||
| 20 | - | ||
| 21 | - /** | ||
| 22 | - * 优惠券商品使用类型 | ||
| 23 | - */ | ||
| 24 | - private final Integer type; | ||
| 25 | - /** | ||
| 26 | - * 优惠券商品使用类型名 | ||
| 27 | - */ | ||
| 28 | - private final String name; | ||
| 29 | - | ||
| 30 | -} |
yudao-module-mall/yudao-module-coupon-api/src/main/java/cn/iocoder/yudao/module/CouponTemplete/enums/CouponStatusTypeEnum.java deleted
| 1 | -package cn.iocoder.yudao.module.CouponTemplete.enums; | ||
| 2 | - | ||
| 3 | - | ||
| 4 | -import lombok.Getter; | ||
| 5 | -import lombok.RequiredArgsConstructor; | ||
| 6 | - | ||
| 7 | - | ||
| 8 | -/** | ||
| 9 | - * 优惠券 - 优惠券状态类型 | ||
| 10 | - * | ||
| 11 | - * @author Sin | ||
| 12 | - */ | ||
| 13 | -@RequiredArgsConstructor | ||
| 14 | -@Getter | ||
| 15 | -public enum CouponStatusTypeEnum { | ||
| 16 | - | ||
| 17 | - PROCESSING(1,"进行中"), | ||
| 18 | - END(2,"已结束"), | ||
| 19 | - CLOSE(3,"已关闭"),; | ||
| 20 | - | ||
| 21 | - /** | ||
| 22 | - * 优惠券类型 | ||
| 23 | - */ | ||
| 24 | - private final Integer type; | ||
| 25 | - /** | ||
| 26 | - * 优惠券类型名 | ||
| 27 | - */ | ||
| 28 | - private final String name; | ||
| 29 | - | ||
| 30 | -} |
yudao-module-mall/yudao-module-coupon-api/src/main/java/cn/iocoder/yudao/module/CouponTemplete/enums/CouponTypeEnum.java deleted
| 1 | -package cn.iocoder.yudao.module.CouponTemplete.enums; | ||
| 2 | - | ||
| 3 | - | ||
| 4 | -import lombok.Getter; | ||
| 5 | -import lombok.RequiredArgsConstructor; | ||
| 6 | - | ||
| 7 | - | ||
| 8 | -/** | ||
| 9 | - * 优惠券 - 优惠券类型 | ||
| 10 | - * | ||
| 11 | - * @author Sin | ||
| 12 | - */ | ||
| 13 | -@RequiredArgsConstructor | ||
| 14 | -@Getter | ||
| 15 | -public enum CouponTypeEnum { | ||
| 16 | - | ||
| 17 | - REWARD(1,"满减"), | ||
| 18 | - DISCOUNT(2,"折扣"), | ||
| 19 | - RANDOW(3,"随机"),; | ||
| 20 | - | ||
| 21 | - /** | ||
| 22 | - * 优惠券类型 | ||
| 23 | - */ | ||
| 24 | - private final Integer type; | ||
| 25 | - /** | ||
| 26 | - * 优惠券类型名 | ||
| 27 | - */ | ||
| 28 | - private final String name; | ||
| 29 | - | ||
| 30 | -} |
yudao-module-mall/yudao-module-coupon-api/src/main/java/cn/iocoder/yudao/module/CouponTemplete/enums/CouponUseLimitEnum.java deleted
| 1 | -package cn.iocoder.yudao.module.CouponTemplete.enums; | ||
| 2 | - | ||
| 3 | - | ||
| 4 | -import lombok.Getter; | ||
| 5 | -import lombok.RequiredArgsConstructor; | ||
| 6 | - | ||
| 7 | - | ||
| 8 | -/** | ||
| 9 | - * 优惠券使用类型 - 优惠券使用类型类型 | ||
| 10 | - * | ||
| 11 | - * @author Sin | ||
| 12 | - */ | ||
| 13 | -@RequiredArgsConstructor | ||
| 14 | -@Getter | ||
| 15 | -public enum CouponUseLimitEnum { | ||
| 16 | - | ||
| 17 | - HAS_LIMIT(1,"无门槛"), | ||
| 18 | - NO_LIMIT(2,"有门槛"),; | ||
| 19 | - | ||
| 20 | - /** | ||
| 21 | - * 优惠券使用类型 | ||
| 22 | - */ | ||
| 23 | - private final Integer type; | ||
| 24 | - /** | ||
| 25 | - * 优惠券使用类型名 | ||
| 26 | - */ | ||
| 27 | - private final String name; | ||
| 28 | - | ||
| 29 | -} |
yudao-module-mall/yudao-module-coupon-api/src/main/java/cn/iocoder/yudao/module/CouponTemplete/enums/CouponValidityTypeEnum.java deleted
| 1 | -package cn.iocoder.yudao.module.CouponTemplete.enums; | ||
| 2 | - | ||
| 3 | -import lombok.Getter; | ||
| 4 | -import lombok.RequiredArgsConstructor; | ||
| 5 | - | ||
| 6 | -/** | ||
| 7 | - * 过期类型 - 状态 | ||
| 8 | - * | ||
| 9 | - * @author Sin | ||
| 10 | - */ | ||
| 11 | -@RequiredArgsConstructor | ||
| 12 | -@Getter | ||
| 13 | -public enum CouponValidityTypeEnum { | ||
| 14 | - | ||
| 15 | - TIME_RANGE_EXPIRTED(1,"时间范围过期"), | ||
| 16 | - EXPIRES_AFTER_FIXED_DATE(2,"领取之日固定日期后过期"), | ||
| 17 | - EXPIRES_DATE_NEXT_FIEXD_DATE(3,"领取次日固定日期后过期"),; | ||
| 18 | - | ||
| 19 | - | ||
| 20 | - /** | ||
| 21 | - * 状态值 | ||
| 22 | - */ | ||
| 23 | - private final Integer status; | ||
| 24 | - /** | ||
| 25 | - * 状态名 | ||
| 26 | - */ | ||
| 27 | - private final String name; | ||
| 28 | - | ||
| 29 | -} |
yudao-module-mall/yudao-module-coupon-api/src/main/java/cn/iocoder/yudao/module/CouponTemplete/enums/ErrorCodeConstants.java deleted
| 1 | -package cn.iocoder.yudao.module.CouponTemplete.enums; | ||
| 2 | - | ||
| 3 | -import cn.iocoder.yudao.framework.common.exception.ErrorCode; | ||
| 4 | - | ||
| 5 | -/** | ||
| 6 | - * coupon 优惠券错误码枚举类 | ||
| 7 | - * | ||
| 8 | - * coupon 优惠券系统,使用 1-010-000-000 段 | ||
| 9 | - */ | ||
| 10 | -public interface ErrorCodeConstants { | ||
| 11 | - // ========== COUPON分类相关 1010001000 ============ | ||
| 12 | - | ||
| 13 | - ErrorCode COUPON_TEMPLETE_NOT_EXISTS = new ErrorCode(1010001000, "优惠券模板不存在"); | ||
| 14 | - ErrorCode MONEY_NOT_NULL = new ErrorCode(1010001001, "当type为reward时需要添加发放面额不能为空"); | ||
| 15 | - ErrorCode DISCOUNT_NOT_NULL = new ErrorCode(1010001001, "当type为discount时需要添加折扣不能为空"); | ||
| 16 | - ErrorCode DISCOUNT_LIMIT_NOT_NULL = new ErrorCode(1010001001, "当type为discount时可选择性添加最多折扣金额不能为空"); | ||
| 17 | - ErrorCode MIN_MAX_NOT_NULL = new ErrorCode(1010001001, "当type为radom时需要添加最低金额"); | ||
| 18 | - ErrorCode START_END_TIME_NOT_NULL = new ErrorCode(1010001001, "使用开始日期,使用结束日期不能为空"); | ||
| 19 | - ErrorCode FIXED_TERM_NOT_NULL = new ErrorCode(1010001001, "领取之日起或者次日N天内有效不能为空"); | ||
| 20 | - | ||
| 21 | - | ||
| 22 | - // ========== COUPON分类相关 1010002000 ============ | ||
| 23 | - ErrorCode COUPON_NOT_EXISTS = new ErrorCode(1010001000, "优惠券模板不存在"); | ||
| 24 | - | ||
| 25 | - | ||
| 26 | -} | ||
| 27 | - |
yudao-module-mall/yudao-module-coupon-biz/pom.xml deleted
| 1 | -<?xml version="1.0" encoding="UTF-8"?> | ||
| 2 | -<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
| 3 | - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
| 4 | - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
| 5 | - <parent> | ||
| 6 | - <groupId>cn.iocoder.boot</groupId> | ||
| 7 | - <artifactId>yudao-module-mall</artifactId> | ||
| 8 | - <version>${revision}</version> | ||
| 9 | - </parent> | ||
| 10 | - <modelVersion>4.0.0</modelVersion> | ||
| 11 | - <packaging>jar</packaging> | ||
| 12 | - <artifactId>yudao-module-coupon-biz</artifactId> | ||
| 13 | - | ||
| 14 | - <name>${project.artifactId}</name> | ||
| 15 | - | ||
| 16 | - <description> | ||
| 17 | - coupon模块,主要负责优惠券的一些业务,含发布优惠券模板,分发优惠券等 | ||
| 18 | - </description> | ||
| 19 | - | ||
| 20 | - <dependencies> | ||
| 21 | - | ||
| 22 | - <dependency> | ||
| 23 | - <groupId>cn.iocoder.boot</groupId> | ||
| 24 | - <artifactId>yudao-module-coupon-api</artifactId> | ||
| 25 | - <version>${revision}</version> | ||
| 26 | - </dependency> | ||
| 27 | - | ||
| 28 | - <!-- 业务组件 --> | ||
| 29 | - <dependency> | ||
| 30 | - <groupId>cn.iocoder.boot</groupId> | ||
| 31 | - <artifactId>yudao-spring-boot-starter-biz-operatelog</artifactId> | ||
| 32 | - </dependency> | ||
| 33 | - | ||
| 34 | - <!-- Web 相关 --> | ||
| 35 | - <dependency> | ||
| 36 | - <groupId>cn.iocoder.boot</groupId> | ||
| 37 | - <artifactId>yudao-spring-boot-starter-web</artifactId> | ||
| 38 | - </dependency> | ||
| 39 | - <dependency> | ||
| 40 | - <groupId>cn.iocoder.boot</groupId> | ||
| 41 | - <artifactId>yudao-spring-boot-starter-security</artifactId> | ||
| 42 | - </dependency> | ||
| 43 | - | ||
| 44 | - <!-- DB 相关 --> | ||
| 45 | - <dependency> | ||
| 46 | - <groupId>cn.iocoder.boot</groupId> | ||
| 47 | - <artifactId>yudao-spring-boot-starter-mybatis</artifactId> | ||
| 48 | - </dependency> | ||
| 49 | - | ||
| 50 | - <!-- Test 测试相关 --> | ||
| 51 | - <dependency> | ||
| 52 | - <groupId>cn.iocoder.boot</groupId> | ||
| 53 | - <artifactId>yudao-spring-boot-starter-test</artifactId> | ||
| 54 | - </dependency> | ||
| 55 | - | ||
| 56 | - <!-- 工具类相关 --> | ||
| 57 | - <dependency> | ||
| 58 | - <groupId>cn.iocoder.boot</groupId> | ||
| 59 | - <artifactId>yudao-spring-boot-starter-excel</artifactId> | ||
| 60 | - </dependency> | ||
| 61 | - | ||
| 62 | - </dependencies> | ||
| 63 | - | ||
| 64 | -</project> |
yudao-module-mall/yudao-module-coupon-biz/src/main/java/cn/iocoder/yudao/module/coupon/controller/admin/coupon/CouponController.java deleted
| 1 | -package cn.iocoder.yudao.module.coupon.controller.admin.coupon; | ||
| 2 | - | ||
| 3 | -import org.springframework.web.bind.annotation.*; | ||
| 4 | -import javax.annotation.Resource; | ||
| 5 | -import org.springframework.validation.annotation.Validated; | ||
| 6 | -import org.springframework.security.access.prepost.PreAuthorize; | ||
| 7 | -import io.swagger.annotations.*; | ||
| 8 | - | ||
| 9 | -import javax.validation.*; | ||
| 10 | -import java.util.*; | ||
| 11 | - | ||
| 12 | -import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 13 | -import cn.iocoder.yudao.framework.common.pojo.CommonResult; | ||
| 14 | -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | ||
| 15 | - | ||
| 16 | - | ||
| 17 | -import cn.iocoder.yudao.module.coupon.controller.admin.coupon.vo.*; | ||
| 18 | -import cn.iocoder.yudao.module.coupon.dal.dataobject.coupon.CouponDO; | ||
| 19 | -import cn.iocoder.yudao.module.coupon.convert.coupon.CouponConvert; | ||
| 20 | -import cn.iocoder.yudao.module.coupon.service.coupon.CouponService; | ||
| 21 | - | ||
| 22 | -@Api(tags = "管理后台 - 优惠券") | ||
| 23 | -@RestController | ||
| 24 | -@RequestMapping("/coupon/item") | ||
| 25 | -@Validated | ||
| 26 | -public class CouponController { | ||
| 27 | - | ||
| 28 | - @Resource | ||
| 29 | - private CouponService couponService; | ||
| 30 | - | ||
| 31 | - | ||
| 32 | - //todo 用户优惠券 | ||
| 33 | - @PostMapping("/create") | ||
| 34 | - @ApiOperation("用户领取优惠券") | ||
| 35 | - @PreAuthorize("@ss.hasPermission('coupon::create')") | ||
| 36 | - public CommonResult<Long> create(@RequestParam("couponTemplateId") Long couponTemplateId) { | ||
| 37 | - | ||
| 38 | - return success(couponService.create(couponTemplateId)); | ||
| 39 | - } | ||
| 40 | - | ||
| 41 | - | ||
| 42 | - @PutMapping("/update") | ||
| 43 | - @ApiOperation("更新优惠券") | ||
| 44 | - @PreAuthorize("@ss.hasPermission('coupon::update')") | ||
| 45 | - public CommonResult<Boolean> update(@Valid @RequestBody CouponUpdateReqVO updateReqVO) { | ||
| 46 | - couponService.update(updateReqVO); | ||
| 47 | - return success(true); | ||
| 48 | - } | ||
| 49 | - | ||
| 50 | - @DeleteMapping("/delete") | ||
| 51 | - @ApiOperation("删除优惠券") | ||
| 52 | - @ApiImplicitParam(name = "id", value = "编号", required = true, dataTypeClass = Long.class) | ||
| 53 | - @PreAuthorize("@ss.hasPermission('coupon::delete')") | ||
| 54 | - public CommonResult<Boolean> delete(@RequestParam("id") Long id) { | ||
| 55 | - couponService.delete(id); | ||
| 56 | - return success(true); | ||
| 57 | - } | ||
| 58 | - | ||
| 59 | - @GetMapping("/get") | ||
| 60 | - @ApiOperation("获得优惠券") | ||
| 61 | - @ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class) | ||
| 62 | - @PreAuthorize("@ss.hasPermission('coupon::query')") | ||
| 63 | - public CommonResult<CouponRespVO> get(@RequestParam("id") Long id) { | ||
| 64 | - CouponDO couponDO = couponService.get(id); | ||
| 65 | - return success(CouponConvert.INSTANCE.convert(couponDO)); | ||
| 66 | - } | ||
| 67 | - | ||
| 68 | - | ||
| 69 | - | ||
| 70 | - @GetMapping("/list") | ||
| 71 | - @ApiOperation("获得优惠券列表") | ||
| 72 | - @ApiImplicitParam(name = "ids", value = "编号列表", required = true, example = "1024,2048", dataTypeClass = List.class) | ||
| 73 | - @PreAuthorize("@ss.hasPermission('coupon::query')") | ||
| 74 | - public CommonResult<List<CouponRespVO>> getList(@RequestParam("ids") Collection<Long> ids) { | ||
| 75 | - List<CouponDO> list = couponService.getList(ids); | ||
| 76 | - return success(CouponConvert.INSTANCE.convertList(list)); | ||
| 77 | - } | ||
| 78 | - | ||
| 79 | - @GetMapping("/page") | ||
| 80 | - @ApiOperation("获得优惠券分页") | ||
| 81 | - @PreAuthorize("@ss.hasPermission('coupon::query')") | ||
| 82 | - public CommonResult<PageResult<CouponRespVO>> getPage(@Valid CouponPageReqVO pageVO) { | ||
| 83 | - PageResult<CouponDO> pageResult = couponService.getPage(pageVO); | ||
| 84 | - return success(CouponConvert.INSTANCE.convertPage(pageResult)); | ||
| 85 | - } | ||
| 86 | - | ||
| 87 | - | ||
| 88 | -} |
yudao-module-mall/yudao-module-coupon-biz/src/main/java/cn/iocoder/yudao/module/coupon/controller/admin/coupon/vo/CouponBaseVO.java deleted
| 1 | -package cn.iocoder.yudao.module.coupon.controller.admin.coupon.vo; | ||
| 2 | - | ||
| 3 | -import lombok.*; | ||
| 4 | -import java.util.*; | ||
| 5 | -import java.math.BigDecimal; | ||
| 6 | -import io.swagger.annotations.*; | ||
| 7 | -import javax.validation.constraints.*; | ||
| 8 | -import org.springframework.format.annotation.DateTimeFormat; | ||
| 9 | - | ||
| 10 | -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; | ||
| 11 | - | ||
| 12 | -/** | ||
| 13 | -* 优惠券 Base VO,提供给添加、修改、详细的子 VO 使用 | ||
| 14 | -* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 | ||
| 15 | -*/ | ||
| 16 | -@Data | ||
| 17 | -public class CouponBaseVO { | ||
| 18 | - | ||
| 19 | - @ApiModelProperty(value = "优惠券类型 reward-满减 discount-折扣 random-随机", required = true) | ||
| 20 | - @NotNull(message = "优惠券类型 reward-满减 discount-折扣 random-随机不能为空") | ||
| 21 | - private String type; | ||
| 22 | - | ||
| 23 | - @ApiModelProperty(value = "优惠券名称", required = true) | ||
| 24 | - @NotNull(message = "优惠券名称不能为空") | ||
| 25 | - private String name; | ||
| 26 | - | ||
| 27 | - @ApiModelProperty(value = "优惠券类型id") | ||
| 28 | - private Long couponTypeId; | ||
| 29 | - | ||
| 30 | - @ApiModelProperty(value = "优惠券编码", required = true) | ||
| 31 | - @NotNull(message = "优惠券编码不能为空") | ||
| 32 | - private String couponCode; | ||
| 33 | - | ||
| 34 | - @ApiModelProperty(value = "领用人", required = true) | ||
| 35 | - @NotNull(message = "领用人不能为空") | ||
| 36 | - private Long memberId; | ||
| 37 | - | ||
| 38 | - @ApiModelProperty(value = "优惠券使用订单id", required = true) | ||
| 39 | - @NotNull(message = "优惠券使用订单id不能为空") | ||
| 40 | - private Long useOrderId; | ||
| 41 | - | ||
| 42 | - @ApiModelProperty(value = "适用商品类型1-全部商品可用;2-指定商品可用;3-指定商品不可用", required = true) | ||
| 43 | - @NotNull(message = "适用商品类型1-全部商品可用;2-指定商品可用;3-指定商品不可用不能为空") | ||
| 44 | - private Boolean goodsType; | ||
| 45 | - | ||
| 46 | - @ApiModelProperty(value = "适用商品id", required = true) | ||
| 47 | - @NotNull(message = "适用商品id不能为空") | ||
| 48 | - private String goodsIds; | ||
| 49 | - | ||
| 50 | - @ApiModelProperty(value = "最小金额", required = true) | ||
| 51 | - @NotNull(message = "最小金额不能为空") | ||
| 52 | - private BigDecimal atLeast; | ||
| 53 | - | ||
| 54 | - @ApiModelProperty(value = "面额", required = true) | ||
| 55 | - @NotNull(message = "面额不能为空") | ||
| 56 | - private BigDecimal money; | ||
| 57 | - | ||
| 58 | - @ApiModelProperty(value = "1 =< 折扣 <= 9.9 当type为discount时需要添加", required = true) | ||
| 59 | - @NotNull(message = "1 =< 折扣 <= 9.9 当type为discount时需要添加不能为空") | ||
| 60 | - private BigDecimal discount; | ||
| 61 | - | ||
| 62 | - @ApiModelProperty(value = "最多折扣金额 当type为discount时可选择性添加", required = true) | ||
| 63 | - @NotNull(message = "最多折扣金额 当type为discount时可选择性添加不能为空") | ||
| 64 | - private BigDecimal discountLimit; | ||
| 65 | - | ||
| 66 | - @ApiModelProperty(value = "优惠叠加 0-不限制 1- 优惠券仅原价购买商品时可用", required = true) | ||
| 67 | - @NotNull(message = "优惠叠加 0-不限制 1- 优惠券仅原价购买商品时可用不能为空") | ||
| 68 | - private Boolean whetherForbidPreference; | ||
| 69 | - | ||
| 70 | - @ApiModelProperty(value = "是否开启过期提醒0-不开启 1-开启", required = true) | ||
| 71 | - @NotNull(message = "是否开启过期提醒0-不开启 1-开启") | ||
| 72 | - private Boolean whetherExpireNotice; | ||
| 73 | - | ||
| 74 | - @ApiModelProperty(value = "过期前N天提醒", required = true) | ||
| 75 | - @NotNull(message = "过期前N天提醒不能为空") | ||
| 76 | - private Integer expireNoticeFixedTerm; | ||
| 77 | - | ||
| 78 | - @ApiModelProperty(value = "是否已提醒", required = true) | ||
| 79 | - @NotNull(message = "是否已提醒不能为空") | ||
| 80 | - private Boolean whetherNoticed; | ||
| 81 | - | ||
| 82 | - @ApiModelProperty(value = "优惠券状态 1已领用(未使用) 2已使用 3已过期", required = true) | ||
| 83 | - @NotNull(message = "优惠券状态 1已领用(未使用) 2已使用 3已过期不能为空") | ||
| 84 | - private Integer state; | ||
| 85 | - | ||
| 86 | - @ApiModelProperty(value = "获取方式1订单2.直接领取3.活动领取 4转赠 5分享获取", required = true) | ||
| 87 | - @NotNull(message = "获取方式1订单2.直接领取3.活动领取 4转赠 5分享获取不能为空") | ||
| 88 | - private Boolean getType; | ||
| 89 | - | ||
| 90 | - @ApiModelProperty(value = "领取时间", required = true) | ||
| 91 | - @NotNull(message = "领取时间不能为空") | ||
| 92 | - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | ||
| 93 | - private Date fetchTime; | ||
| 94 | - | ||
| 95 | - @ApiModelProperty(value = "使用时间", required = true) | ||
| 96 | - @NotNull(message = "使用时间不能为空") | ||
| 97 | - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | ||
| 98 | - private Date useTime; | ||
| 99 | - | ||
| 100 | - @ApiModelProperty(value = "可使用的开始时间", required = true) | ||
| 101 | - @NotNull(message = "可使用的开始时间不能为空") | ||
| 102 | - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | ||
| 103 | - private Date startTime; | ||
| 104 | - | ||
| 105 | - @ApiModelProperty(value = "有效期结束时间", required = true) | ||
| 106 | - @NotNull(message = "有效期结束时间不能为空") | ||
| 107 | - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | ||
| 108 | - private Date endTime; | ||
| 109 | - | ||
| 110 | -} |
yudao-module-mall/yudao-module-coupon-biz/src/main/java/cn/iocoder/yudao/module/coupon/controller/admin/coupon/vo/CouponCreateReqVO.java deleted
| 1 | -package cn.iocoder.yudao.module.coupon.controller.admin.coupon.vo; | ||
| 2 | - | ||
| 3 | -import lombok.*; | ||
| 4 | -import java.util.*; | ||
| 5 | -import io.swagger.annotations.*; | ||
| 6 | -import javax.validation.constraints.*; | ||
| 7 | - | ||
| 8 | -@ApiModel("管理后台 - 优惠券创建 Request VO") | ||
| 9 | -@Data | ||
| 10 | -@EqualsAndHashCode(callSuper = true) | ||
| 11 | -@ToString(callSuper = true) | ||
| 12 | -public class CouponCreateReqVO extends CouponBaseVO { | ||
| 13 | - | ||
| 14 | -} |
yudao-module-mall/yudao-module-coupon-biz/src/main/java/cn/iocoder/yudao/module/coupon/controller/admin/coupon/vo/CouponExcelVO.java deleted
| 1 | -package cn.iocoder.yudao.module.coupon.controller.admin.coupon.vo; | ||
| 2 | - | ||
| 3 | -import lombok.*; | ||
| 4 | -import java.util.*; | ||
| 5 | -import java.math.BigDecimal; | ||
| 6 | -import io.swagger.annotations.*; | ||
| 7 | - | ||
| 8 | -import com.alibaba.excel.annotation.ExcelProperty; | ||
| 9 | - | ||
| 10 | -/** | ||
| 11 | - * 优惠券 Excel VO | ||
| 12 | - * | ||
| 13 | - * @author wxr | ||
| 14 | - */ | ||
| 15 | -@Data | ||
| 16 | -public class CouponExcelVO { | ||
| 17 | - | ||
| 18 | - @ExcelProperty("用户ID") | ||
| 19 | - private Long id; | ||
| 20 | - | ||
| 21 | - @ExcelProperty("优惠券类型 reward-满减 discount-折扣 random-随机") | ||
| 22 | - private String type; | ||
| 23 | - | ||
| 24 | - @ExcelProperty("优惠券名称") | ||
| 25 | - private String name; | ||
| 26 | - | ||
| 27 | - @ExcelProperty("优惠券类型id") | ||
| 28 | - private Long couponTypeId; | ||
| 29 | - | ||
| 30 | - @ExcelProperty("优惠券编码") | ||
| 31 | - private String couponCode; | ||
| 32 | - | ||
| 33 | - @ExcelProperty("领用人") | ||
| 34 | - private Long memberId; | ||
| 35 | - | ||
| 36 | - @ExcelProperty("优惠券使用订单id") | ||
| 37 | - private Long useOrderId; | ||
| 38 | - | ||
| 39 | - @ExcelProperty("适用商品类型1-全部商品可用;2-指定商品可用;3-指定商品不可用") | ||
| 40 | - private Boolean goodsType; | ||
| 41 | - | ||
| 42 | - @ExcelProperty("适用商品id") | ||
| 43 | - private String goodsIds; | ||
| 44 | - | ||
| 45 | - @ExcelProperty("最小金额") | ||
| 46 | - private BigDecimal atLeast; | ||
| 47 | - | ||
| 48 | - @ExcelProperty("面额") | ||
| 49 | - private BigDecimal money; | ||
| 50 | - | ||
| 51 | - @ExcelProperty("1 =< 折扣 <= 9.9 当type为discount时需要添加") | ||
| 52 | - private BigDecimal discount; | ||
| 53 | - | ||
| 54 | - @ExcelProperty("最多折扣金额 当type为discount时可选择性添加") | ||
| 55 | - private BigDecimal discountLimit; | ||
| 56 | - | ||
| 57 | - @ExcelProperty("优惠叠加 0-不限制 1- 优惠券仅原价购买商品时可用") | ||
| 58 | - private Boolean whetherForbidPreference; | ||
| 59 | - | ||
| 60 | - @ExcelProperty("是否开启过期提醒0-不开启 1-开启") | ||
| 61 | - private Boolean whetherExpireNotice; | ||
| 62 | - | ||
| 63 | - @ExcelProperty("过期前N天提醒") | ||
| 64 | - private Integer expireNoticeFixedTerm; | ||
| 65 | - | ||
| 66 | - @ExcelProperty("是否已提醒") | ||
| 67 | - private Boolean whetherNoticed; | ||
| 68 | - | ||
| 69 | - @ExcelProperty("优惠券状态 1已领用(未使用) 2已使用 3已过期") | ||
| 70 | - private Integer state; | ||
| 71 | - | ||
| 72 | - @ExcelProperty("获取方式1订单2.直接领取3.活动领取 4转赠 5分享获取") | ||
| 73 | - private Boolean getType; | ||
| 74 | - | ||
| 75 | - @ExcelProperty("领取时间") | ||
| 76 | - private Date fetchTime; | ||
| 77 | - | ||
| 78 | - @ExcelProperty("使用时间") | ||
| 79 | - private Date useTime; | ||
| 80 | - | ||
| 81 | - @ExcelProperty("可使用的开始时间") | ||
| 82 | - private Date startTime; | ||
| 83 | - | ||
| 84 | - @ExcelProperty("有效期结束时间") | ||
| 85 | - private Date endTime; | ||
| 86 | - | ||
| 87 | - @ExcelProperty("创建时间") | ||
| 88 | - private Date createTime; | ||
| 89 | - | ||
| 90 | -} |
yudao-module-mall/yudao-module-coupon-biz/src/main/java/cn/iocoder/yudao/module/coupon/controller/admin/coupon/vo/CouponExportReqVO.java deleted
| 1 | -package cn.iocoder.yudao.module.coupon.controller.admin.coupon.vo; | ||
| 2 | - | ||
| 3 | -import lombok.*; | ||
| 4 | - | ||
| 5 | -import java.math.BigDecimal; | ||
| 6 | -import java.util.*; | ||
| 7 | -import io.swagger.annotations.*; | ||
| 8 | -import cn.iocoder.yudao.framework.common.pojo.PageParam; | ||
| 9 | -import org.springframework.format.annotation.DateTimeFormat; | ||
| 10 | - | ||
| 11 | -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; | ||
| 12 | - | ||
| 13 | -@ApiModel(value = "管理后台 - 优惠券 Excel 导出 Request VO", description = "参数和 CouponPageReqVO 是一致的") | ||
| 14 | -@Data | ||
| 15 | -public class CouponExportReqVO { | ||
| 16 | - | ||
| 17 | - @ApiModelProperty(value = "优惠券类型 reward-满减 discount-折扣 random-随机") | ||
| 18 | - private String type; | ||
| 19 | - | ||
| 20 | - @ApiModelProperty(value = "优惠券名称") | ||
| 21 | - private String name; | ||
| 22 | - | ||
| 23 | - @ApiModelProperty(value = "优惠券类型id") | ||
| 24 | - private Long couponTypeId; | ||
| 25 | - | ||
| 26 | - @ApiModelProperty(value = "优惠券编码") | ||
| 27 | - private String couponCode; | ||
| 28 | - | ||
| 29 | - @ApiModelProperty(value = "领用人") | ||
| 30 | - private Long memberId; | ||
| 31 | - | ||
| 32 | - @ApiModelProperty(value = "优惠券使用订单id") | ||
| 33 | - private Long useOrderId; | ||
| 34 | - | ||
| 35 | - @ApiModelProperty(value = "适用商品类型1-全部商品可用;2-指定商品可用;3-指定商品不可用") | ||
| 36 | - private Boolean goodsType; | ||
| 37 | - | ||
| 38 | - @ApiModelProperty(value = "适用商品id") | ||
| 39 | - private String goodsIds; | ||
| 40 | - | ||
| 41 | - @ApiModelProperty(value = "最小金额") | ||
| 42 | - private BigDecimal atLeast; | ||
| 43 | - | ||
| 44 | - @ApiModelProperty(value = "面额") | ||
| 45 | - private BigDecimal money; | ||
| 46 | - | ||
| 47 | - @ApiModelProperty(value = "1 =< 折扣 <= 9.9 当type为discount时需要添加") | ||
| 48 | - private BigDecimal discount; | ||
| 49 | - | ||
| 50 | - @ApiModelProperty(value = "最多折扣金额 当type为discount时可选择性添加") | ||
| 51 | - private BigDecimal discountLimit; | ||
| 52 | - | ||
| 53 | - @ApiModelProperty(value = "优惠叠加 0-不限制 1- 优惠券仅原价购买商品时可用") | ||
| 54 | - private Boolean whetherForbidPreference; | ||
| 55 | - | ||
| 56 | - @ApiModelProperty(value = "是否开启过期提醒0-不开启 1-开启") | ||
| 57 | - private Boolean whetherExpireNotice; | ||
| 58 | - | ||
| 59 | - @ApiModelProperty(value = "过期前N天提醒") | ||
| 60 | - private Integer expireNoticeFixedTerm; | ||
| 61 | - | ||
| 62 | - @ApiModelProperty(value = "是否已提醒") | ||
| 63 | - private Boolean whetherNoticed; | ||
| 64 | - | ||
| 65 | - @ApiModelProperty(value = "优惠券状态 1已领用(未使用) 2已使用 3已过期") | ||
| 66 | - private Integer state; | ||
| 67 | - | ||
| 68 | - @ApiModelProperty(value = "获取方式1订单2.直接领取3.活动领取 4转赠 5分享获取") | ||
| 69 | - private Boolean getType; | ||
| 70 | - | ||
| 71 | - @ApiModelProperty(value = "领取时间") | ||
| 72 | - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | ||
| 73 | - private Date[] fetchTime; | ||
| 74 | - | ||
| 75 | - @ApiModelProperty(value = "使用时间") | ||
| 76 | - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | ||
| 77 | - private Date[] useTime; | ||
| 78 | - | ||
| 79 | - @ApiModelProperty(value = "可使用的开始时间") | ||
| 80 | - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | ||
| 81 | - private Date[] startTime; | ||
| 82 | - | ||
| 83 | - @ApiModelProperty(value = "有效期结束时间") | ||
| 84 | - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | ||
| 85 | - private Date[] endTime; | ||
| 86 | - | ||
| 87 | - @ApiModelProperty(value = "创建时间") | ||
| 88 | - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | ||
| 89 | - private Date[] createTime; | ||
| 90 | - | ||
| 91 | -} |
yudao-module-mall/yudao-module-coupon-biz/src/main/java/cn/iocoder/yudao/module/coupon/controller/admin/coupon/vo/CouponPageReqVO.java deleted
| 1 | -package cn.iocoder.yudao.module.coupon.controller.admin.coupon.vo; | ||
| 2 | - | ||
| 3 | -import lombok.*; | ||
| 4 | - | ||
| 5 | -import java.math.BigDecimal; | ||
| 6 | -import java.util.*; | ||
| 7 | -import io.swagger.annotations.*; | ||
| 8 | -import cn.iocoder.yudao.framework.common.pojo.PageParam; | ||
| 9 | -import org.springframework.format.annotation.DateTimeFormat; | ||
| 10 | - | ||
| 11 | -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; | ||
| 12 | - | ||
| 13 | -@ApiModel("管理后台 - 优惠券分页 Request VO") | ||
| 14 | -@Data | ||
| 15 | -@EqualsAndHashCode(callSuper = true) | ||
| 16 | -@ToString(callSuper = true) | ||
| 17 | -public class CouponPageReqVO extends PageParam { | ||
| 18 | - | ||
| 19 | - @ApiModelProperty(value = "优惠券类型 reward-满减 discount-折扣 random-随机") | ||
| 20 | - private String type; | ||
| 21 | - | ||
| 22 | - @ApiModelProperty(value = "优惠券名称") | ||
| 23 | - private String name; | ||
| 24 | - | ||
| 25 | - @ApiModelProperty(value = "优惠券类型id") | ||
| 26 | - private Long couponTypeId; | ||
| 27 | - | ||
| 28 | - @ApiModelProperty(value = "优惠券编码") | ||
| 29 | - private String couponCode; | ||
| 30 | - | ||
| 31 | - @ApiModelProperty(value = "领用人") | ||
| 32 | - private Long memberId; | ||
| 33 | - | ||
| 34 | - @ApiModelProperty(value = "优惠券使用订单id") | ||
| 35 | - private Long useOrderId; | ||
| 36 | - | ||
| 37 | - @ApiModelProperty(value = "适用商品类型1-全部商品可用;2-指定商品可用;3-指定商品不可用") | ||
| 38 | - private Boolean goodsType; | ||
| 39 | - | ||
| 40 | - @ApiModelProperty(value = "适用商品id") | ||
| 41 | - private String goodsIds; | ||
| 42 | - | ||
| 43 | - @ApiModelProperty(value = "最小金额") | ||
| 44 | - private BigDecimal atLeast; | ||
| 45 | - | ||
| 46 | - @ApiModelProperty(value = "面额") | ||
| 47 | - private BigDecimal money; | ||
| 48 | - | ||
| 49 | - @ApiModelProperty(value = "1 =< 折扣 <= 9.9 当type为discount时需要添加") | ||
| 50 | - private BigDecimal discount; | ||
| 51 | - | ||
| 52 | - @ApiModelProperty(value = "最多折扣金额 当type为discount时可选择性添加") | ||
| 53 | - private BigDecimal discountLimit; | ||
| 54 | - | ||
| 55 | - @ApiModelProperty(value = "优惠叠加 0-不限制 1- 优惠券仅原价购买商品时可用") | ||
| 56 | - private Boolean whetherForbidPreference; | ||
| 57 | - | ||
| 58 | - @ApiModelProperty(value = "是否开启过期提醒0-不开启 1-开启") | ||
| 59 | - private Boolean whetherExpireNotice; | ||
| 60 | - | ||
| 61 | - @ApiModelProperty(value = "过期前N天提醒") | ||
| 62 | - private Integer expireNoticeFixedTerm; | ||
| 63 | - | ||
| 64 | - @ApiModelProperty(value = "是否已提醒") | ||
| 65 | - private Boolean whetherNoticed; | ||
| 66 | - | ||
| 67 | - @ApiModelProperty(value = "优惠券状态 1已领用(未使用) 2已使用 3已过期") | ||
| 68 | - private Integer state; | ||
| 69 | - | ||
| 70 | - @ApiModelProperty(value = "获取方式1订单2.直接领取3.活动领取 4转赠 5分享获取") | ||
| 71 | - private Boolean getType; | ||
| 72 | - | ||
| 73 | - @ApiModelProperty(value = "领取时间") | ||
| 74 | - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | ||
| 75 | - private Date[] fetchTime; | ||
| 76 | - | ||
| 77 | - @ApiModelProperty(value = "使用时间") | ||
| 78 | - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | ||
| 79 | - private Date[] useTime; | ||
| 80 | - | ||
| 81 | - @ApiModelProperty(value = "可使用的开始时间") | ||
| 82 | - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | ||
| 83 | - private Date[] startTime; | ||
| 84 | - | ||
| 85 | - @ApiModelProperty(value = "有效期结束时间") | ||
| 86 | - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | ||
| 87 | - private Date[] endTime; | ||
| 88 | - | ||
| 89 | - @ApiModelProperty(value = "创建时间") | ||
| 90 | - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | ||
| 91 | - private Date[] createTime; | ||
| 92 | - | ||
| 93 | -} |
yudao-module-mall/yudao-module-coupon-biz/src/main/java/cn/iocoder/yudao/module/coupon/controller/admin/coupon/vo/CouponRespVO.java deleted
| 1 | -package cn.iocoder.yudao.module.coupon.controller.admin.coupon.vo; | ||
| 2 | - | ||
| 3 | -import lombok.*; | ||
| 4 | -import java.util.*; | ||
| 5 | -import io.swagger.annotations.*; | ||
| 6 | - | ||
| 7 | -@ApiModel("管理后台 - 优惠券 Response VO") | ||
| 8 | -@Data | ||
| 9 | -@EqualsAndHashCode(callSuper = true) | ||
| 10 | -@ToString(callSuper = true) | ||
| 11 | -public class CouponRespVO extends CouponBaseVO { | ||
| 12 | - | ||
| 13 | - @ApiModelProperty(value = "用户ID", required = true) | ||
| 14 | - private Long id; | ||
| 15 | - | ||
| 16 | - @ApiModelProperty(value = "创建时间", required = true) | ||
| 17 | - private Date createTime; | ||
| 18 | - | ||
| 19 | -} |
yudao-module-mall/yudao-module-coupon-biz/src/main/java/cn/iocoder/yudao/module/coupon/controller/admin/coupon/vo/CouponUpdateReqVO.java deleted
| 1 | -package cn.iocoder.yudao.module.coupon.controller.admin.coupon.vo; | ||
| 2 | - | ||
| 3 | -import lombok.*; | ||
| 4 | -import java.util.*; | ||
| 5 | -import io.swagger.annotations.*; | ||
| 6 | -import javax.validation.constraints.*; | ||
| 7 | - | ||
| 8 | -@ApiModel("管理后台 - 优惠券更新 Request VO") | ||
| 9 | -@Data | ||
| 10 | -@EqualsAndHashCode(callSuper = true) | ||
| 11 | -@ToString(callSuper = true) | ||
| 12 | -public class CouponUpdateReqVO extends CouponBaseVO { | ||
| 13 | - | ||
| 14 | - @ApiModelProperty(value = "用户ID", required = true) | ||
| 15 | - @NotNull(message = "用户ID不能为空") | ||
| 16 | - private Long id; | ||
| 17 | - | ||
| 18 | -} |
yudao-module-mall/yudao-module-coupon-biz/src/main/java/cn/iocoder/yudao/module/coupon/controller/admin/templete/CouponTempleteController.java deleted
| 1 | -package cn.iocoder.yudao.module.coupon.controller.admin.templete; | ||
| 2 | - | ||
| 3 | -import cn.iocoder.yudao.module.coupon.controller.admin.templete.vo.*; | ||
| 4 | -import cn.iocoder.yudao.module.coupon.convert.CouponTemplete.CouponTempleteConvert; | ||
| 5 | -import cn.iocoder.yudao.module.coupon.dal.dataobject.CouponTemplete.CouponTempleteDO; | ||
| 6 | -import cn.iocoder.yudao.module.coupon.service.CouponTemplete.CouponTempleteService; | ||
| 7 | -import org.springframework.web.bind.annotation.*; | ||
| 8 | -import javax.annotation.Resource; | ||
| 9 | -import org.springframework.validation.annotation.Validated; | ||
| 10 | -import org.springframework.security.access.prepost.PreAuthorize; | ||
| 11 | -import io.swagger.annotations.*; | ||
| 12 | - | ||
| 13 | -import javax.validation.*; | ||
| 14 | -import java.util.*; | ||
| 15 | - | ||
| 16 | -import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 17 | -import cn.iocoder.yudao.framework.common.pojo.CommonResult; | ||
| 18 | -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | ||
| 19 | - | ||
| 20 | -@Api(tags = "管理后台 - 优惠券模板") | ||
| 21 | -@RestController | ||
| 22 | -@RequestMapping("/coupon/template") | ||
| 23 | -@Validated | ||
| 24 | -public class CouponTempleteController { | ||
| 25 | - | ||
| 26 | - @Resource | ||
| 27 | - private CouponTempleteService couponTempleteServiceService; | ||
| 28 | - | ||
| 29 | - @PostMapping("/create") | ||
| 30 | - @ApiOperation("创建优惠券模板") | ||
| 31 | - @PreAuthorize("@ss.hasPermission('CouponTemplete::create')") | ||
| 32 | - public CommonResult<Long> create(@Valid @RequestBody CouponTempleteCreateReqVO createReqVO) { | ||
| 33 | - return success(couponTempleteServiceService.create(createReqVO)); | ||
| 34 | - } | ||
| 35 | - | ||
| 36 | -// @PutMapping("/update") | ||
| 37 | -// @ApiOperation("更新优惠券模板") | ||
| 38 | -// @PreAuthorize("@ss.hasPermission('CouponTemplete::update')") | ||
| 39 | -// public CommonResult<Boolean> update(@Valid @RequestBody CouponTempleteUpdateReqVO updateReqVO) { | ||
| 40 | -// couponTempleteServiceService.update(updateReqVO); | ||
| 41 | -// return success(true); | ||
| 42 | -// } | ||
| 43 | -// | ||
| 44 | -// @DeleteMapping("/delete") | ||
| 45 | -// @ApiOperation("删除优惠券模板") | ||
| 46 | -// @ApiImplicitParam(name = "id", value = "编号", required = true, dataTypeClass = Long.class) | ||
| 47 | -// @PreAuthorize("@ss.hasPermission('CouponTemplete::delete')") | ||
| 48 | -// public CommonResult<Boolean> delete(@RequestParam("id") Long id) { | ||
| 49 | -// couponTempleteServiceService.delete(id); | ||
| 50 | -// return success(true); | ||
| 51 | -// } | ||
| 52 | -// | ||
| 53 | -// @GetMapping("/get") | ||
| 54 | -// @ApiOperation("获得优惠券模板") | ||
| 55 | -// @ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class) | ||
| 56 | -// @PreAuthorize("@ss.hasPermission('CouponTemplete::query')") | ||
| 57 | -// public CommonResult<CouponTempleteRespVO> get(@RequestParam("id") Long id) { | ||
| 58 | -// CouponTempleteDO couponTempleteDO = couponTempleteServiceService.get(id); | ||
| 59 | -// return success(CouponTempleteConvert.INSTANCE.convert(couponTempleteDO)); | ||
| 60 | -// } | ||
| 61 | -// | ||
| 62 | -// @GetMapping("/list") | ||
| 63 | -// @ApiOperation("获得优惠券模板列表") | ||
| 64 | -// @ApiImplicitParam(name = "ids", value = "编号列表", required = true, example = "1024,2048", dataTypeClass = List.class) | ||
| 65 | -// @PreAuthorize("@ss.hasPermission('CouponTemplete::query')") | ||
| 66 | -// public CommonResult<List<CouponTempleteRespVO>> getList(@RequestParam("ids") Collection<Long> ids) { | ||
| 67 | -// List<CouponTempleteDO> list = couponTempleteServiceService.getList(ids); | ||
| 68 | -// return success(CouponTempleteConvert.INSTANCE.convertList(list)); | ||
| 69 | -// } | ||
| 70 | -// | ||
| 71 | - @GetMapping("/page") | ||
| 72 | - @ApiOperation("获得优惠券模板分页") | ||
| 73 | - @PreAuthorize("@ss.hasPermission('CouponTemplete::query')") | ||
| 74 | - public CommonResult<PageResult<CouponTempleteRespVO>> getPage(@Valid CouponTempletePageReqVO pageVO) { | ||
| 75 | - PageResult<CouponTempleteDO> pageResult = couponTempleteServiceService.getPage(pageVO); | ||
| 76 | - return success(CouponTempleteConvert.INSTANCE.convertPage(pageResult)); | ||
| 77 | - } | ||
| 78 | - | ||
| 79 | - | ||
| 80 | - | ||
| 81 | -} |
yudao-module-mall/yudao-module-coupon-biz/src/main/java/cn/iocoder/yudao/module/coupon/controller/admin/templete/vo/CouponTempleteBaseVO.java deleted
| 1 | -package cn.iocoder.yudao.module.coupon.controller.admin.templete.vo; | ||
| 2 | - | ||
| 3 | -import lombok.*; | ||
| 4 | -import java.util.*; | ||
| 5 | -import java.math.BigDecimal; | ||
| 6 | -import io.swagger.annotations.*; | ||
| 7 | -import javax.validation.constraints.*; | ||
| 8 | -import org.springframework.format.annotation.DateTimeFormat; | ||
| 9 | - | ||
| 10 | -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; | ||
| 11 | - | ||
| 12 | -/** | ||
| 13 | -* 优惠券模板 Base VO,提供给添加、修改、详细的子 VO 使用 | ||
| 14 | -* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 | ||
| 15 | -*/ | ||
| 16 | -@Data | ||
| 17 | -public class CouponTempleteBaseVO { | ||
| 18 | - | ||
| 19 | - | ||
| 20 | - //基本信息 | ||
| 21 | - | ||
| 22 | - @ApiModelProperty(value = "优惠券名称", required = true) | ||
| 23 | - @NotNull(message = "优惠券名称不能为空") | ||
| 24 | - private String name; | ||
| 25 | - | ||
| 26 | - @ApiModelProperty(value = "名称备注") | ||
| 27 | - private String couponNameRemark; | ||
| 28 | - | ||
| 29 | - @ApiModelProperty(value = "优惠券图片") | ||
| 30 | - private String image; | ||
| 31 | - | ||
| 32 | - /* ============判断适用商品——开始============= */ | ||
| 33 | - | ||
| 34 | - | ||
| 35 | - @ApiModelProperty(value = "适用商品类型1-全部商品可用;2-指定商品可用;3-指定商品不可用", required = true) | ||
| 36 | - @NotNull(message = "适用商品类型1-全部商品可用;2-指定商品可用;3-指定商品不可用不能为空") | ||
| 37 | - private Integer goodsType; | ||
| 38 | - | ||
| 39 | - @ApiModelProperty(value = "适用商品id") | ||
| 40 | - private String productIds; | ||
| 41 | - | ||
| 42 | - @ApiModelProperty(value = "使用门槛0-无门槛 1-有门槛", required = true) | ||
| 43 | - @NotNull(message = "使用门槛0-无门槛 1-有门槛不能为空") | ||
| 44 | - private Boolean hasUseLimit; | ||
| 45 | - | ||
| 46 | - @ApiModelProperty(value = "满多少元使用 0代表无限制", required = true) | ||
| 47 | - @NotNull(message = "满多少元使用 0代表无限制不能为空") | ||
| 48 | - private BigDecimal atLeast; | ||
| 49 | - | ||
| 50 | - | ||
| 51 | - /* ============折扣类型——开始============= */ | ||
| 52 | - | ||
| 53 | - @ApiModelProperty(value = "优惠券类型 reward-满减 discount-折扣 random-随机", required = true) | ||
| 54 | - @NotNull(message = "优惠券类型 reward-满减 discount-折扣 random-随机不能为空") | ||
| 55 | - private String type; | ||
| 56 | - | ||
| 57 | - @ApiModelProperty(value = "发放面额 当type为reward时需要添加") | ||
| 58 | - @NotNull(message = "发放面额 当type为reward时需要添加不能为空") | ||
| 59 | - private BigDecimal money; | ||
| 60 | - | ||
| 61 | - @ApiModelProperty(value = "1 =< 折扣 <= 9.9 当type为discount时需要添加") | ||
| 62 | - @NotNull(message = "1 =< 折扣 <= 9.9 当type为discount时需要添加不能为空") | ||
| 63 | - private BigDecimal discount; | ||
| 64 | - | ||
| 65 | - @ApiModelProperty(value = "最多折扣金额 当type为discount时可选择性添加") | ||
| 66 | - @NotNull(message = "最多折扣金额 当type为discount时可选择性添加不能为空") | ||
| 67 | - private BigDecimal discountLimit; | ||
| 68 | - | ||
| 69 | - @ApiModelProperty(value = "最低金额 当type为radom时需要添加", required = true) | ||
| 70 | - @NotNull(message = "最低金额 当type为radom时需要添加不能为空") | ||
| 71 | - private BigDecimal minMoney; | ||
| 72 | - | ||
| 73 | - @ApiModelProperty(value = "最大金额 当type为radom时需要添加", required = true) | ||
| 74 | - @NotNull(message = "最大金额 当type为radom时需要添加不能为空") | ||
| 75 | - private BigDecimal maxMoney; | ||
| 76 | - | ||
| 77 | - /* ============折扣类型——结束============= */ | ||
| 78 | - | ||
| 79 | - | ||
| 80 | - /* ============过期类型——开始============= */ | ||
| 81 | - | ||
| 82 | - | ||
| 83 | - @ApiModelProperty(value = "过期类型1-时间范围过期 2-领取之日固定日期后过期 3-领取次日固定日期后过期", required = true) | ||
| 84 | - @NotNull(message = "过期类型1-时间范围过期 2-领取之日固定日期后过期 3-领取次日固定日期后过期 不能为空") | ||
| 85 | - private Integer validityType; | ||
| 86 | - | ||
| 87 | - @ApiModelProperty(value = "使用开始日期 过期类型1时必填") | ||
| 88 | - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | ||
| 89 | - private Date startUseTime; | ||
| 90 | - | ||
| 91 | - @ApiModelProperty(value = "使用结束日期 过期类型1时必填") | ||
| 92 | - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | ||
| 93 | - private Date endUseTime; | ||
| 94 | - | ||
| 95 | - @ApiModelProperty(value = "当validity_type为2或者3时需要添加 领取之日起或者次日N天内有效") | ||
| 96 | - @NotNull(message = "当validity_type为2或者3时需要添加 领取之日起或者次日N天内有效不能为空") | ||
| 97 | - private Integer fixedTerm; | ||
| 98 | - | ||
| 99 | - @ApiModelProperty(value = "有效日期结束时间") | ||
| 100 | - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | ||
| 101 | - private Date endTime; | ||
| 102 | - | ||
| 103 | - /* ============过期类型——结束============= */ | ||
| 104 | - | ||
| 105 | - | ||
| 106 | - @ApiModelProperty(value = "领取是否无限制0-否 1是", required = true) | ||
| 107 | - @NotNull(message = "是否无限制0-否 1是") | ||
| 108 | - private Boolean whetherLimitless; | ||
| 109 | - | ||
| 110 | - @ApiModelProperty(value = "每人最大领取个数", required = true) | ||
| 111 | - @NotNull(message = "每人最大领取个数不能为空") | ||
| 112 | - private Integer maxFetch; | ||
| 113 | - | ||
| 114 | - @ApiModelProperty(value = "是否开启过期提醒 0-不开启 1-开启", required = true) | ||
| 115 | - @NotNull(message = "是否开启过期提醒0-不开启 1-开启不能为空") | ||
| 116 | - private Boolean whetherExpireNotice; | ||
| 117 | - | ||
| 118 | - @ApiModelProperty(value = "过期前N天提醒", required = true) | ||
| 119 | - @NotNull(message = "过期前N天提醒不能为空") | ||
| 120 | - private Integer expireNoticeFixedTerm; | ||
| 121 | - | ||
| 122 | - @ApiModelProperty(value = "优惠叠加 0-不限制 1- 优惠券仅原价购买商品时可用", required = true) | ||
| 123 | - @NotNull(message = "优惠叠加 0-不限制 1- 优惠券仅原价购买商品时可用不能为空") | ||
| 124 | - private Boolean whetherForbidPreference; | ||
| 125 | - | ||
| 126 | - @ApiModelProperty(value = "是否显示", required = true) | ||
| 127 | - @NotNull(message = "是否显示不能为空") | ||
| 128 | - private Integer whetherShow; | ||
| 129 | - | ||
| 130 | - @ApiModelProperty(value = "是否禁止发放0-否 1-是", required = true) | ||
| 131 | - @NotNull(message = "是否禁止发放0-否 1-是不能为空") | ||
| 132 | - private Boolean whetherForbidden; | ||
| 133 | - | ||
| 134 | - /* ============汇总计算——开始============= */ | ||
| 135 | - | ||
| 136 | - | ||
| 137 | - | ||
| 138 | - @ApiModelProperty(value = "使用优惠券购买的商品数量", required = true) | ||
| 139 | - @NotNull(message = "使用优惠券购买的商品数量不能为空") | ||
| 140 | - private Integer orderGoodsNum; | ||
| 141 | - | ||
| 142 | - @ApiModelProperty(value = "订单的优惠总金额", required = true) | ||
| 143 | - @NotNull(message = "订单的优惠总金额不能为空") | ||
| 144 | - private BigDecimal discountOrderMoney; | ||
| 145 | - | ||
| 146 | - @ApiModelProperty(value = "用券总成交额", required = true) | ||
| 147 | - @NotNull(message = "用券总成交额不能为空") | ||
| 148 | - private BigDecimal orderMoney; | ||
| 149 | - | ||
| 150 | - @ApiModelProperty(value = "发放数量", required = true) | ||
| 151 | - @NotNull(message = "发放数量不能为空") | ||
| 152 | - private Integer count; | ||
| 153 | - | ||
| 154 | - @ApiModelProperty(value = "已领取数量", required = true) | ||
| 155 | - @NotNull(message = "已领取数量不能为空") | ||
| 156 | - private Integer leadCount; | ||
| 157 | - | ||
| 158 | - @ApiModelProperty(value = "已使用数量", required = true) | ||
| 159 | - @NotNull(message = "已使用数量不能为空") | ||
| 160 | - private Integer usedCount; | ||
| 161 | - | ||
| 162 | - | ||
| 163 | - /* ============汇总计算——结束============= */ | ||
| 164 | - | ||
| 165 | - | ||
| 166 | - @ApiModelProperty(value = "状态(1进行中2已结束3已关闭)", required = true) | ||
| 167 | - @NotNull(message = "状态(1进行中2已结束-1已关闭)不能为空") | ||
| 168 | - private Integer status; | ||
| 169 | - | ||
| 170 | - | ||
| 171 | - | ||
| 172 | -} |
yudao-module-mall/yudao-module-coupon-biz/src/main/java/cn/iocoder/yudao/module/coupon/controller/admin/templete/vo/CouponTempleteCreateReqVO.java deleted
| 1 | -package cn.iocoder.yudao.module.coupon.controller.admin.templete.vo; | ||
| 2 | - | ||
| 3 | -import lombok.*; | ||
| 4 | -import io.swagger.annotations.*; | ||
| 5 | - | ||
| 6 | -@ApiModel("管理后台 - 优惠券模板创建 Request VO") | ||
| 7 | -@Data | ||
| 8 | -@EqualsAndHashCode(callSuper = true) | ||
| 9 | -@ToString(callSuper = true) | ||
| 10 | -public class CouponTempleteCreateReqVO extends CouponTempleteBaseVO { | ||
| 11 | - | ||
| 12 | -} |
yudao-module-mall/yudao-module-coupon-biz/src/main/java/cn/iocoder/yudao/module/coupon/controller/admin/templete/vo/CouponTempleteExcelVO.java deleted
| 1 | -package cn.iocoder.yudao.module.coupon.controller.admin.templete.vo; | ||
| 2 | - | ||
| 3 | -import lombok.*; | ||
| 4 | -import java.util.*; | ||
| 5 | -import java.math.BigDecimal; | ||
| 6 | - | ||
| 7 | -import com.alibaba.excel.annotation.ExcelProperty; | ||
| 8 | - | ||
| 9 | -/** | ||
| 10 | - * 优惠券模板 Excel VO | ||
| 11 | - * | ||
| 12 | - * @author wxr | ||
| 13 | - */ | ||
| 14 | -@Data | ||
| 15 | -public class CouponTempleteExcelVO { | ||
| 16 | - | ||
| 17 | - @ExcelProperty("用户ID") | ||
| 18 | - private Long id; | ||
| 19 | - | ||
| 20 | - @ExcelProperty("优惠券类型 reward-满减 discount-折扣 random-随机") | ||
| 21 | - private String type; | ||
| 22 | - | ||
| 23 | - @ExcelProperty("优惠券名称") | ||
| 24 | - private String name; | ||
| 25 | - | ||
| 26 | - @ExcelProperty("名称备注") | ||
| 27 | - private String couponNameRemark; | ||
| 28 | - | ||
| 29 | - @ExcelProperty("优惠券图片") | ||
| 30 | - private String image; | ||
| 31 | - | ||
| 32 | - @ExcelProperty("发放数量") | ||
| 33 | - private Integer count; | ||
| 34 | - | ||
| 35 | - @ExcelProperty("已领取数量") | ||
| 36 | - private Integer leadCount; | ||
| 37 | - | ||
| 38 | - @ExcelProperty("已使用数量") | ||
| 39 | - private Integer usedCount; | ||
| 40 | - | ||
| 41 | - @ExcelProperty("适用商品类型1-全部商品可用;2-指定商品可用;3-指定商品不可用") | ||
| 42 | - private Integer goodsType; | ||
| 43 | - | ||
| 44 | - @ExcelProperty("适用商品id") | ||
| 45 | - private String productIds; | ||
| 46 | - | ||
| 47 | - @ExcelProperty("使用门槛0-无门槛 1-有门槛") | ||
| 48 | - private Boolean hasUseLimit; | ||
| 49 | - | ||
| 50 | - @ExcelProperty("满多少元使用 0代表无限制") | ||
| 51 | - private BigDecimal atLeast; | ||
| 52 | - | ||
| 53 | - @ExcelProperty("发放面额 当type为reward时需要添加") | ||
| 54 | - private BigDecimal money; | ||
| 55 | - | ||
| 56 | - @ExcelProperty("1 =< 折扣 <= 9.9 当type为discount时需要添加") | ||
| 57 | - private BigDecimal discount; | ||
| 58 | - | ||
| 59 | - @ExcelProperty("最多折扣金额 当type为discount时可选择性添加") | ||
| 60 | - private BigDecimal discountLimit; | ||
| 61 | - | ||
| 62 | - @ExcelProperty("最低金额 当type为radom时需要添加") | ||
| 63 | - private BigDecimal minMoney; | ||
| 64 | - | ||
| 65 | - @ExcelProperty("最大金额 当type为radom时需要添加") | ||
| 66 | - private BigDecimal maxMoney; | ||
| 67 | - | ||
| 68 | - @ExcelProperty("过期类型1-时间范围过期 2-领取之日固定日期后过期 3-领取次日固定日期后过期") | ||
| 69 | - private Integer validityType; | ||
| 70 | - | ||
| 71 | - @ExcelProperty("使用开始日期 过期类型1时必填") | ||
| 72 | - private Date startUseTime; | ||
| 73 | - | ||
| 74 | - @ExcelProperty("使用结束日期 过期类型1时必填") | ||
| 75 | - private Date endUseTime; | ||
| 76 | - | ||
| 77 | - @ExcelProperty("当validity_type为2或者3时需要添加 领取之日起或者次日N天内有效") | ||
| 78 | - private Integer fixedTerm; | ||
| 79 | - | ||
| 80 | - @ExcelProperty("是否无限制0-否 1是") | ||
| 81 | - private Boolean whetherLimitless; | ||
| 82 | - | ||
| 83 | - @ExcelProperty("每人最大领取个数") | ||
| 84 | - private Integer maxFetch; | ||
| 85 | - | ||
| 86 | - @ExcelProperty("是否开启过期提醒0-不开启 1-开启") | ||
| 87 | - private Boolean whetherExpireNotice; | ||
| 88 | - | ||
| 89 | - @ExcelProperty("过期前N天提醒") | ||
| 90 | - private Integer expireNoticeFixedTerm; | ||
| 91 | - | ||
| 92 | - @ExcelProperty("优惠叠加 0-不限制 1- 优惠券仅原价购买商品时可用") | ||
| 93 | - private Boolean whetherForbidPreference; | ||
| 94 | - | ||
| 95 | - @ExcelProperty("是否显示") | ||
| 96 | - private Integer whetherShow; | ||
| 97 | - | ||
| 98 | - @ExcelProperty("订单的优惠总金额") | ||
| 99 | - private BigDecimal discountOrderMoney; | ||
| 100 | - | ||
| 101 | - @ExcelProperty("用券总成交额") | ||
| 102 | - private BigDecimal orderMoney; | ||
| 103 | - | ||
| 104 | - @ExcelProperty("是否禁止发放0-否 1-是") | ||
| 105 | - private Boolean whetherForbidden; | ||
| 106 | - | ||
| 107 | - @ExcelProperty("使用优惠券购买的商品数量") | ||
| 108 | - private Integer orderGoodsNum; | ||
| 109 | - | ||
| 110 | - @ExcelProperty("状态(1进行中2已结束-1已关闭)") | ||
| 111 | - private Integer status; | ||
| 112 | - | ||
| 113 | - @ExcelProperty("有效日期结束时间") | ||
| 114 | - private Date endTime; | ||
| 115 | - | ||
| 116 | - @ExcelProperty("创建时间") | ||
| 117 | - private Date createTime; | ||
| 118 | - | ||
| 119 | -} |
yudao-module-mall/yudao-module-coupon-biz/src/main/java/cn/iocoder/yudao/module/coupon/controller/admin/templete/vo/CouponTempleteExportReqVO.java deleted
| 1 | -package cn.iocoder.yudao.module.coupon.controller.admin.templete.vo; | ||
| 2 | - | ||
| 3 | -import lombok.*; | ||
| 4 | - | ||
| 5 | -import java.math.BigDecimal; | ||
| 6 | -import java.util.*; | ||
| 7 | -import io.swagger.annotations.*; | ||
| 8 | -import org.springframework.format.annotation.DateTimeFormat; | ||
| 9 | - | ||
| 10 | -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; | ||
| 11 | - | ||
| 12 | -@ApiModel(value = "管理后台 - 优惠券模板 Excel 导出 Request VO", description = "参数和 CouponTempletePageReqVO 是一致的") | ||
| 13 | -@Data | ||
| 14 | -public class CouponTempleteExportReqVO { | ||
| 15 | - | ||
| 16 | - @ApiModelProperty(value = "优惠券类型 reward-满减 discount-折扣 random-随机") | ||
| 17 | - private String type; | ||
| 18 | - | ||
| 19 | - @ApiModelProperty(value = "优惠券名称") | ||
| 20 | - private String name; | ||
| 21 | - | ||
| 22 | - @ApiModelProperty(value = "名称备注") | ||
| 23 | - private String couponNameRemark; | ||
| 24 | - | ||
| 25 | - @ApiModelProperty(value = "优惠券图片") | ||
| 26 | - private String image; | ||
| 27 | - | ||
| 28 | - @ApiModelProperty(value = "发放数量") | ||
| 29 | - private Integer count; | ||
| 30 | - | ||
| 31 | - @ApiModelProperty(value = "已领取数量") | ||
| 32 | - private Integer leadCount; | ||
| 33 | - | ||
| 34 | - @ApiModelProperty(value = "已使用数量") | ||
| 35 | - private Integer usedCount; | ||
| 36 | - | ||
| 37 | - @ApiModelProperty(value = "适用商品类型1-全部商品可用;2-指定商品可用;3-指定商品不可用") | ||
| 38 | - private Boolean goodsType; | ||
| 39 | - | ||
| 40 | - @ApiModelProperty(value = "适用商品id") | ||
| 41 | - private String productIds; | ||
| 42 | - | ||
| 43 | - @ApiModelProperty(value = "使用门槛0-无门槛 1-有门槛") | ||
| 44 | - private Boolean hasUseLimit; | ||
| 45 | - | ||
| 46 | - @ApiModelProperty(value = "满多少元使用 0代表无限制") | ||
| 47 | - private BigDecimal atLeast; | ||
| 48 | - | ||
| 49 | - @ApiModelProperty(value = "发放面额 当type为reward时需要添加") | ||
| 50 | - private BigDecimal money; | ||
| 51 | - | ||
| 52 | - @ApiModelProperty(value = "1 =< 折扣 <= 9.9 当type为discount时需要添加") | ||
| 53 | - private BigDecimal discount; | ||
| 54 | - | ||
| 55 | - @ApiModelProperty(value = "最多折扣金额 当type为discount时可选择性添加") | ||
| 56 | - private BigDecimal discountLimit; | ||
| 57 | - | ||
| 58 | - @ApiModelProperty(value = "最低金额 当type为radom时需要添加") | ||
| 59 | - private BigDecimal minMoney; | ||
| 60 | - | ||
| 61 | - @ApiModelProperty(value = "最大金额 当type为radom时需要添加") | ||
| 62 | - private BigDecimal maxMoney; | ||
| 63 | - | ||
| 64 | - @ApiModelProperty(value = "过期类型1-时间范围过期 2-领取之日固定日期后过期 3-领取次日固定日期后过期") | ||
| 65 | - private Boolean validityType; | ||
| 66 | - | ||
| 67 | - @ApiModelProperty(value = "使用开始日期 过期类型1时必填") | ||
| 68 | - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | ||
| 69 | - private Date[] startUseTime; | ||
| 70 | - | ||
| 71 | - @ApiModelProperty(value = "使用结束日期 过期类型1时必填") | ||
| 72 | - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | ||
| 73 | - private Date[] endUseTime; | ||
| 74 | - | ||
| 75 | - @ApiModelProperty(value = "当validity_type为2或者3时需要添加 领取之日起或者次日N天内有效") | ||
| 76 | - private Integer fixedTerm; | ||
| 77 | - | ||
| 78 | - @ApiModelProperty(value = "是否无限制0-否 1是") | ||
| 79 | - private Boolean whetherLimitless; | ||
| 80 | - | ||
| 81 | - @ApiModelProperty(value = "每人最大领取个数") | ||
| 82 | - private Integer maxFetch; | ||
| 83 | - | ||
| 84 | - @ApiModelProperty(value = "是否开启过期提醒0-不开启 1-开启") | ||
| 85 | - private Boolean whetherExpireNotice; | ||
| 86 | - | ||
| 87 | - @ApiModelProperty(value = "过期前N天提醒") | ||
| 88 | - private Integer expireNoticeFixedTerm; | ||
| 89 | - | ||
| 90 | - @ApiModelProperty(value = "优惠叠加 0-不限制 1- 优惠券仅原价购买商品时可用") | ||
| 91 | - private Boolean whetherForbidPreference; | ||
| 92 | - | ||
| 93 | - @ApiModelProperty(value = "是否显示") | ||
| 94 | - private Integer whetherShow; | ||
| 95 | - | ||
| 96 | - @ApiModelProperty(value = "订单的优惠总金额") | ||
| 97 | - private BigDecimal discountOrderMoney; | ||
| 98 | - | ||
| 99 | - @ApiModelProperty(value = "用券总成交额") | ||
| 100 | - private BigDecimal orderMoney; | ||
| 101 | - | ||
| 102 | - @ApiModelProperty(value = "是否禁止发放0-否 1-是") | ||
| 103 | - private Boolean whetherForbidden; | ||
| 104 | - | ||
| 105 | - @ApiModelProperty(value = "使用优惠券购买的商品数量") | ||
| 106 | - private Integer orderGoodsNum; | ||
| 107 | - | ||
| 108 | - @ApiModelProperty(value = "状态(1进行中2已结束-1已关闭)") | ||
| 109 | - private Integer status; | ||
| 110 | - | ||
| 111 | - @ApiModelProperty(value = "有效日期结束时间") | ||
| 112 | - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | ||
| 113 | - private Date[] endTime; | ||
| 114 | - | ||
| 115 | - @ApiModelProperty(value = "创建时间") | ||
| 116 | - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | ||
| 117 | - private Date[] createTime; | ||
| 118 | - | ||
| 119 | -} |
yudao-module-mall/yudao-module-coupon-biz/src/main/java/cn/iocoder/yudao/module/coupon/controller/admin/templete/vo/CouponTempletePageReqVO.java deleted
| 1 | -package cn.iocoder.yudao.module.coupon.controller.admin.templete.vo; | ||
| 2 | - | ||
| 3 | -import lombok.*; | ||
| 4 | - | ||
| 5 | -import java.math.BigDecimal; | ||
| 6 | -import java.util.*; | ||
| 7 | -import io.swagger.annotations.*; | ||
| 8 | -import cn.iocoder.yudao.framework.common.pojo.PageParam; | ||
| 9 | -import org.springframework.format.annotation.DateTimeFormat; | ||
| 10 | - | ||
| 11 | -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; | ||
| 12 | - | ||
| 13 | -@ApiModel("管理后台 - 优惠券模板分页 Request VO") | ||
| 14 | -@Data | ||
| 15 | -@EqualsAndHashCode(callSuper = true) | ||
| 16 | -@ToString(callSuper = true) | ||
| 17 | -public class CouponTempletePageReqVO extends PageParam { | ||
| 18 | - | ||
| 19 | - @ApiModelProperty(value = "优惠券类型 reward-满减 discount-折扣 random-随机") | ||
| 20 | - private String type; | ||
| 21 | - | ||
| 22 | - @ApiModelProperty(value = "优惠券名称") | ||
| 23 | - private String name; | ||
| 24 | - | ||
| 25 | - @ApiModelProperty(value = "名称备注") | ||
| 26 | - private String couponNameRemark; | ||
| 27 | - | ||
| 28 | - @ApiModelProperty(value = "优惠券图片") | ||
| 29 | - private String image; | ||
| 30 | - | ||
| 31 | - @ApiModelProperty(value = "发放数量") | ||
| 32 | - private Integer count; | ||
| 33 | - | ||
| 34 | - @ApiModelProperty(value = "已领取数量") | ||
| 35 | - private Integer leadCount; | ||
| 36 | - | ||
| 37 | - @ApiModelProperty(value = "已使用数量") | ||
| 38 | - private Integer usedCount; | ||
| 39 | - | ||
| 40 | - @ApiModelProperty(value = "适用商品类型1-全部商品可用;2-指定商品可用;3-指定商品不可用") | ||
| 41 | - private Boolean goodsType; | ||
| 42 | - | ||
| 43 | - @ApiModelProperty(value = "适用商品id") | ||
| 44 | - private String productIds; | ||
| 45 | - | ||
| 46 | - @ApiModelProperty(value = "使用门槛0-无门槛 1-有门槛") | ||
| 47 | - private Boolean hasUseLimit; | ||
| 48 | - | ||
| 49 | - @ApiModelProperty(value = "满多少元使用 0代表无限制") | ||
| 50 | - private BigDecimal atLeast; | ||
| 51 | - | ||
| 52 | - @ApiModelProperty(value = "发放面额 当type为reward时需要添加") | ||
| 53 | - private BigDecimal money; | ||
| 54 | - | ||
| 55 | - @ApiModelProperty(value = "1 =< 折扣 <= 9.9 当type为discount时需要添加") | ||
| 56 | - private BigDecimal discount; | ||
| 57 | - | ||
| 58 | - @ApiModelProperty(value = "最多折扣金额 当type为discount时可选择性添加") | ||
| 59 | - private BigDecimal discountLimit; | ||
| 60 | - | ||
| 61 | - @ApiModelProperty(value = "最低金额 当type为radom时需要添加") | ||
| 62 | - private BigDecimal minMoney; | ||
| 63 | - | ||
| 64 | - @ApiModelProperty(value = "最大金额 当type为radom时需要添加") | ||
| 65 | - private BigDecimal maxMoney; | ||
| 66 | - | ||
| 67 | - @ApiModelProperty(value = "过期类型1-时间范围过期 2-领取之日固定日期后过期 3-领取次日固定日期后过期") | ||
| 68 | - private Boolean validityType; | ||
| 69 | - | ||
| 70 | - @ApiModelProperty(value = "使用开始日期 过期类型1时必填") | ||
| 71 | - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | ||
| 72 | - private Date[] startUseTime; | ||
| 73 | - | ||
| 74 | - @ApiModelProperty(value = "使用结束日期 过期类型1时必填") | ||
| 75 | - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | ||
| 76 | - private Date[] endUseTime; | ||
| 77 | - | ||
| 78 | - @ApiModelProperty(value = "当validity_type为2或者3时需要添加 领取之日起或者次日N天内有效") | ||
| 79 | - private Integer fixedTerm; | ||
| 80 | - | ||
| 81 | - @ApiModelProperty(value = "是否无限制0-否 1是") | ||
| 82 | - private Boolean whetherLimitless; | ||
| 83 | - | ||
| 84 | - @ApiModelProperty(value = "每人最大领取个数") | ||
| 85 | - private Integer maxFetch; | ||
| 86 | - | ||
| 87 | - @ApiModelProperty(value = "是否开启过期提醒0-不开启 1-开启") | ||
| 88 | - private Boolean whetherExpireNotice; | ||
| 89 | - | ||
| 90 | - @ApiModelProperty(value = "过期前N天提醒") | ||
| 91 | - private Integer expireNoticeFixedTerm; | ||
| 92 | - | ||
| 93 | - @ApiModelProperty(value = "优惠叠加 0-不限制 1- 优惠券仅原价购买商品时可用") | ||
| 94 | - private Boolean whetherForbidPreference; | ||
| 95 | - | ||
| 96 | - @ApiModelProperty(value = "是否显示") | ||
| 97 | - private Integer whetherShow; | ||
| 98 | - | ||
| 99 | - @ApiModelProperty(value = "订单的优惠总金额") | ||
| 100 | - private BigDecimal discountOrderMoney; | ||
| 101 | - | ||
| 102 | - @ApiModelProperty(value = "用券总成交额") | ||
| 103 | - private BigDecimal orderMoney; | ||
| 104 | - | ||
| 105 | - @ApiModelProperty(value = "是否禁止发放0-否 1-是") | ||
| 106 | - private Boolean whetherForbidden; | ||
| 107 | - | ||
| 108 | - @ApiModelProperty(value = "使用优惠券购买的商品数量") | ||
| 109 | - private Integer orderGoodsNum; | ||
| 110 | - | ||
| 111 | - @ApiModelProperty(value = "状态(1进行中2已结束-1已关闭)") | ||
| 112 | - private Integer status; | ||
| 113 | - | ||
| 114 | - @ApiModelProperty(value = "有效日期结束时间") | ||
| 115 | - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | ||
| 116 | - private Date[] endTime; | ||
| 117 | - | ||
| 118 | - @ApiModelProperty(value = "创建时间") | ||
| 119 | - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | ||
| 120 | - private Date[] createTime; | ||
| 121 | - | ||
| 122 | -} |
yudao-module-mall/yudao-module-coupon-biz/src/main/java/cn/iocoder/yudao/module/coupon/controller/admin/templete/vo/CouponTempleteRespVO.java deleted
| 1 | -package cn.iocoder.yudao.module.coupon.controller.admin.templete.vo; | ||
| 2 | - | ||
| 3 | -import lombok.*; | ||
| 4 | -import java.util.*; | ||
| 5 | -import io.swagger.annotations.*; | ||
| 6 | - | ||
| 7 | -@ApiModel("管理后台 - 优惠券模板 Response VO") | ||
| 8 | -@Data | ||
| 9 | -@EqualsAndHashCode(callSuper = true) | ||
| 10 | -@ToString(callSuper = true) | ||
| 11 | -public class CouponTempleteRespVO extends CouponTempleteBaseVO { | ||
| 12 | - | ||
| 13 | - @ApiModelProperty(value = "用户ID", required = true) | ||
| 14 | - private Long id; | ||
| 15 | - | ||
| 16 | - @ApiModelProperty(value = "创建时间", required = true) | ||
| 17 | - private Date createTime; | ||
| 18 | - | ||
| 19 | -} |
yudao-module-mall/yudao-module-coupon-biz/src/main/java/cn/iocoder/yudao/module/coupon/controller/admin/templete/vo/CouponTempleteUpdateReqVO.java deleted
| 1 | -package cn.iocoder.yudao.module.coupon.controller.admin.templete.vo; | ||
| 2 | - | ||
| 3 | -import lombok.*; | ||
| 4 | -import io.swagger.annotations.*; | ||
| 5 | -import javax.validation.constraints.*; | ||
| 6 | - | ||
| 7 | -@ApiModel("管理后台 - 优惠券模板更新 Request VO") | ||
| 8 | -@Data | ||
| 9 | -@EqualsAndHashCode(callSuper = true) | ||
| 10 | -@ToString(callSuper = true) | ||
| 11 | -public class CouponTempleteUpdateReqVO extends CouponTempleteBaseVO { | ||
| 12 | - | ||
| 13 | - @ApiModelProperty(value = "用户ID", required = true) | ||
| 14 | - @NotNull(message = "用户ID不能为空") | ||
| 15 | - private Long id; | ||
| 16 | - | ||
| 17 | -} |
yudao-module-mall/yudao-module-coupon-biz/src/main/java/cn/iocoder/yudao/module/coupon/convert/CouponTemplete/CouponTempleteConvert.java deleted
| 1 | -package cn.iocoder.yudao.module.coupon.convert.CouponTemplete; | ||
| 2 | - | ||
| 3 | -import java.util.*; | ||
| 4 | - | ||
| 5 | -import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 6 | - | ||
| 7 | -import cn.iocoder.yudao.module.coupon.controller.admin.templete.vo.CouponTempleteCreateReqVO; | ||
| 8 | -import cn.iocoder.yudao.module.coupon.controller.admin.templete.vo.CouponTempleteExcelVO; | ||
| 9 | -import cn.iocoder.yudao.module.coupon.controller.admin.templete.vo.CouponTempleteRespVO; | ||
| 10 | -import cn.iocoder.yudao.module.coupon.controller.admin.templete.vo.CouponTempleteUpdateReqVO; | ||
| 11 | -import cn.iocoder.yudao.module.coupon.dal.dataobject.CouponTemplete.CouponTempleteDO; | ||
| 12 | -import org.mapstruct.Mapper; | ||
| 13 | -import org.mapstruct.factory.Mappers; | ||
| 14 | - | ||
| 15 | - | ||
| 16 | -/** | ||
| 17 | - * 优惠券模板 Convert | ||
| 18 | - * | ||
| 19 | - * @author wxr | ||
| 20 | - */ | ||
| 21 | -@Mapper | ||
| 22 | -public interface CouponTempleteConvert { | ||
| 23 | - | ||
| 24 | - CouponTempleteConvert INSTANCE = Mappers.getMapper(CouponTempleteConvert.class); | ||
| 25 | - | ||
| 26 | - CouponTempleteDO convert(CouponTempleteCreateReqVO bean); | ||
| 27 | - | ||
| 28 | - CouponTempleteDO convert(CouponTempleteUpdateReqVO bean); | ||
| 29 | - | ||
| 30 | - CouponTempleteRespVO convert(CouponTempleteDO bean); | ||
| 31 | - | ||
| 32 | - List<CouponTempleteRespVO> convertList(List<CouponTempleteDO> list); | ||
| 33 | - | ||
| 34 | - PageResult<CouponTempleteRespVO> convertPage(PageResult<CouponTempleteDO> page); | ||
| 35 | - | ||
| 36 | - List<CouponTempleteExcelVO> convertList02(List<CouponTempleteDO> list); | ||
| 37 | - | ||
| 38 | -} |
yudao-module-mall/yudao-module-coupon-biz/src/main/java/cn/iocoder/yudao/module/coupon/convert/coupon/CouponConvert.java deleted
| 1 | -package cn.iocoder.yudao.module.coupon.convert.coupon; | ||
| 2 | - | ||
| 3 | -import java.util.*; | ||
| 4 | - | ||
| 5 | -import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 6 | - | ||
| 7 | -import org.mapstruct.Mapper; | ||
| 8 | -import org.mapstruct.factory.Mappers; | ||
| 9 | -import cn.iocoder.yudao.module.coupon.controller.admin.coupon.vo.*; | ||
| 10 | -import cn.iocoder.yudao.module.coupon.dal.dataobject.coupon.CouponDO; | ||
| 11 | - | ||
| 12 | -/** | ||
| 13 | - * 优惠券 Convert | ||
| 14 | - * | ||
| 15 | - * @author wxr | ||
| 16 | - */ | ||
| 17 | -@Mapper | ||
| 18 | -public interface CouponConvert { | ||
| 19 | - | ||
| 20 | - CouponConvert INSTANCE = Mappers.getMapper(CouponConvert.class); | ||
| 21 | - | ||
| 22 | - CouponDO convert(CouponCreateReqVO bean); | ||
| 23 | - | ||
| 24 | - CouponDO convert(CouponUpdateReqVO bean); | ||
| 25 | - | ||
| 26 | - CouponRespVO convert(CouponDO bean); | ||
| 27 | - | ||
| 28 | - List<CouponRespVO> convertList(List<CouponDO> list); | ||
| 29 | - | ||
| 30 | - PageResult<CouponRespVO> convertPage(PageResult<CouponDO> page); | ||
| 31 | - | ||
| 32 | - List<CouponExcelVO> convertList02(List<CouponDO> list); | ||
| 33 | - | ||
| 34 | -} |
yudao-module-mall/yudao-module-coupon-biz/src/main/java/cn/iocoder/yudao/module/coupon/dal/dataobject/CouponTemplete/CouponTempleteDO.java deleted
| 1 | -package cn.iocoder.yudao.module.coupon.dal.dataobject.CouponTemplete; | ||
| 2 | - | ||
| 3 | -import lombok.*; | ||
| 4 | -import java.util.*; | ||
| 5 | -import java.math.BigDecimal; | ||
| 6 | -import com.baomidou.mybatisplus.annotation.*; | ||
| 7 | -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; | ||
| 8 | - | ||
| 9 | -/** | ||
| 10 | - * 优惠券模板 DO | ||
| 11 | - * | ||
| 12 | - * @author wxr | ||
| 13 | - */ | ||
| 14 | -@TableName("coupon_templete") | ||
| 15 | -@KeySequence("coupon_templete_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 | ||
| 16 | -@Data | ||
| 17 | -@EqualsAndHashCode(callSuper = true) | ||
| 18 | -@ToString(callSuper = true) | ||
| 19 | -@Builder | ||
| 20 | -@NoArgsConstructor | ||
| 21 | -@AllArgsConstructor | ||
| 22 | -public class CouponTempleteDO extends BaseDO { | ||
| 23 | - | ||
| 24 | - /** | ||
| 25 | - * 用户ID | ||
| 26 | - */ | ||
| 27 | - @TableId | ||
| 28 | - private Long id; | ||
| 29 | - /** | ||
| 30 | - * 优惠券类型 reward-满减 discount-折扣 random-随机 | ||
| 31 | - */ | ||
| 32 | - private String type; | ||
| 33 | - /** | ||
| 34 | - * 优惠券名称 | ||
| 35 | - */ | ||
| 36 | - private String name; | ||
| 37 | - /** | ||
| 38 | - * 名称备注 | ||
| 39 | - */ | ||
| 40 | - private String couponNameRemark; | ||
| 41 | - /** | ||
| 42 | - * 优惠券图片 | ||
| 43 | - */ | ||
| 44 | - private String image; | ||
| 45 | - /** | ||
| 46 | - * 发放数量 | ||
| 47 | - */ | ||
| 48 | - private Integer count; | ||
| 49 | - /** | ||
| 50 | - * 已领取数量 | ||
| 51 | - */ | ||
| 52 | - private Integer leadCount; | ||
| 53 | - /** | ||
| 54 | - * 已使用数量 | ||
| 55 | - */ | ||
| 56 | - private Integer usedCount; | ||
| 57 | - /** | ||
| 58 | - * 适用商品类型1-全部商品可用;2-指定商品可用;3-指定商品不可用 | ||
| 59 | - */ | ||
| 60 | - private Integer goodsType; | ||
| 61 | - /** | ||
| 62 | - * 适用商品id | ||
| 63 | - */ | ||
| 64 | - private String productIds; | ||
| 65 | - /** | ||
| 66 | - * 使用门槛0-无门槛 1-有门槛 | ||
| 67 | - */ | ||
| 68 | - private Boolean hasUseLimit; | ||
| 69 | - /** | ||
| 70 | - * 满多少元使用 0代表无限制 | ||
| 71 | - */ | ||
| 72 | - private BigDecimal atLeast; | ||
| 73 | - /** | ||
| 74 | - * 发放面额 当type为reward时需要添加 | ||
| 75 | - */ | ||
| 76 | - private BigDecimal money; | ||
| 77 | - /** | ||
| 78 | - * 1 =< 折扣 <= 9.9 当type为discount时需要添加 | ||
| 79 | - */ | ||
| 80 | - private BigDecimal discount; | ||
| 81 | - /** | ||
| 82 | - * 最多折扣金额 当type为discount时可选择性添加 | ||
| 83 | - */ | ||
| 84 | - private BigDecimal discountLimit; | ||
| 85 | - /** | ||
| 86 | - * 最低金额 当type为radom时需要添加 | ||
| 87 | - */ | ||
| 88 | - private BigDecimal minMoney; | ||
| 89 | - /** | ||
| 90 | - * 最大金额 当type为radom时需要添加 | ||
| 91 | - */ | ||
| 92 | - private BigDecimal maxMoney; | ||
| 93 | - /** | ||
| 94 | - * 过期类型1-时间范围过期 2-领取之日固定日期后过期 3-领取次日固定日期后过期 | ||
| 95 | - */ | ||
| 96 | - private Integer validityType; | ||
| 97 | - /** | ||
| 98 | - * 使用开始日期 过期类型1时必填 | ||
| 99 | - */ | ||
| 100 | - private Date startUseTime; | ||
| 101 | - /** | ||
| 102 | - * 使用结束日期 过期类型1时必填 | ||
| 103 | - */ | ||
| 104 | - private Date endUseTime; | ||
| 105 | - /** | ||
| 106 | - * 当validity_type为2或者3时需要添加 领取之日起或者次日N天内有效 | ||
| 107 | - */ | ||
| 108 | - private Integer fixedTerm; | ||
| 109 | - /** | ||
| 110 | - * 是否无限制0-否 1是 | ||
| 111 | - */ | ||
| 112 | - private Boolean whetherLimitless; | ||
| 113 | - /** | ||
| 114 | - * 每人最大领取个数 | ||
| 115 | - */ | ||
| 116 | - private Integer maxFetch; | ||
| 117 | - /** | ||
| 118 | - * 是否开启过期提醒0-不开启 1-开启 | ||
| 119 | - */ | ||
| 120 | - private Boolean whetherExpireNotice; | ||
| 121 | - /** | ||
| 122 | - * 过期前N天提醒 | ||
| 123 | - */ | ||
| 124 | - private Integer expireNoticeFixedTerm; | ||
| 125 | - /** | ||
| 126 | - * 优惠叠加 0-不限制 1- 优惠券仅原价购买商品时可用 | ||
| 127 | - */ | ||
| 128 | - private Boolean whetherForbidPreference; | ||
| 129 | - /** | ||
| 130 | - * 是否显示 | ||
| 131 | - */ | ||
| 132 | - private Integer whetherShow; | ||
| 133 | - /** | ||
| 134 | - * 订单的优惠总金额 | ||
| 135 | - */ | ||
| 136 | - private BigDecimal discountOrderMoney; | ||
| 137 | - /** | ||
| 138 | - * 用券总成交额 | ||
| 139 | - */ | ||
| 140 | - private BigDecimal orderMoney; | ||
| 141 | - /** | ||
| 142 | - * 是否禁止发放0-否 1-是 | ||
| 143 | - */ | ||
| 144 | - private Boolean whetherForbidden; | ||
| 145 | - /** | ||
| 146 | - * 使用优惠券购买的商品数量 | ||
| 147 | - */ | ||
| 148 | - private Integer orderGoodsNum; | ||
| 149 | - /** | ||
| 150 | - * 状态(1进行中2已结束-1已关闭) | ||
| 151 | - */ | ||
| 152 | - private Integer status; | ||
| 153 | - /** | ||
| 154 | - * 有效日期结束时间 | ||
| 155 | - */ | ||
| 156 | - private Date endTime; | ||
| 157 | - | ||
| 158 | -} |
yudao-module-mall/yudao-module-coupon-biz/src/main/java/cn/iocoder/yudao/module/coupon/dal/dataobject/coupon/CouponDO.java deleted
| 1 | -package cn.iocoder.yudao.module.coupon.dal.dataobject.coupon; | ||
| 2 | - | ||
| 3 | -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; | ||
| 4 | -import lombok.*; | ||
| 5 | -import java.util.*; | ||
| 6 | -import java.math.BigDecimal; | ||
| 7 | -import com.baomidou.mybatisplus.annotation.*; | ||
| 8 | - | ||
| 9 | -/** | ||
| 10 | - * 优惠券 DO | ||
| 11 | - * | ||
| 12 | - * @author wxr | ||
| 13 | - */ | ||
| 14 | -@TableName("coupon") | ||
| 15 | -@KeySequence("coupon_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 | ||
| 16 | -@Data | ||
| 17 | -@EqualsAndHashCode(callSuper = true) | ||
| 18 | -@ToString(callSuper = true) | ||
| 19 | -@Builder | ||
| 20 | -@NoArgsConstructor | ||
| 21 | -@AllArgsConstructor | ||
| 22 | -public class CouponDO extends BaseDO { | ||
| 23 | - | ||
| 24 | - /** | ||
| 25 | - * 用户ID | ||
| 26 | - */ | ||
| 27 | - @TableId | ||
| 28 | - private Long id; | ||
| 29 | - /** | ||
| 30 | - * 优惠券类型 reward-满减 discount-折扣 random-随机 | ||
| 31 | - */ | ||
| 32 | - private String type; | ||
| 33 | - /** | ||
| 34 | - * 优惠券名称 | ||
| 35 | - */ | ||
| 36 | - private String name; | ||
| 37 | - /** | ||
| 38 | - * 优惠券类型id | ||
| 39 | - */ | ||
| 40 | - private Long couponTypeId; | ||
| 41 | - /** | ||
| 42 | - * 优惠券编码 | ||
| 43 | - */ | ||
| 44 | - private String couponCode; | ||
| 45 | - /** | ||
| 46 | - * 领用人 | ||
| 47 | - */ | ||
| 48 | - private Long memberId; | ||
| 49 | - /** | ||
| 50 | - * 优惠券使用订单id | ||
| 51 | - */ | ||
| 52 | - private Long useOrderId; | ||
| 53 | - /** | ||
| 54 | - * 适用商品类型1-全部商品可用;2-指定商品可用;3-指定商品不可用 | ||
| 55 | - */ | ||
| 56 | - private Boolean goodsType; | ||
| 57 | - /** | ||
| 58 | - * 适用商品id | ||
| 59 | - */ | ||
| 60 | - private String goodsIds; | ||
| 61 | - /** | ||
| 62 | - * 最小金额 | ||
| 63 | - */ | ||
| 64 | - private BigDecimal atLeast; | ||
| 65 | - /** | ||
| 66 | - * 面额 | ||
| 67 | - */ | ||
| 68 | - private BigDecimal money; | ||
| 69 | - /** | ||
| 70 | - * 1 =< 折扣 <= 9.9 当type为discount时需要添加 | ||
| 71 | - */ | ||
| 72 | - private BigDecimal discount; | ||
| 73 | - /** | ||
| 74 | - * 最多折扣金额 当type为discount时可选择性添加 | ||
| 75 | - */ | ||
| 76 | - private BigDecimal discountLimit; | ||
| 77 | - /** | ||
| 78 | - * 优惠叠加 0-不限制 1- 优惠券仅原价购买商品时可用 | ||
| 79 | - */ | ||
| 80 | - private Boolean whetherForbidPreference; | ||
| 81 | - /** | ||
| 82 | - * 是否开启过期提醒0-不开启 1-开启 | ||
| 83 | - */ | ||
| 84 | - private Boolean whetherExpireNotice; | ||
| 85 | - /** | ||
| 86 | - * 过期前N天提醒 | ||
| 87 | - */ | ||
| 88 | - private Integer expireNoticeFixedTerm; | ||
| 89 | - /** | ||
| 90 | - * 是否已提醒 | ||
| 91 | - */ | ||
| 92 | - private Boolean whetherNoticed; | ||
| 93 | - /** | ||
| 94 | - * 优惠券状态 1已领用(未使用) 2已使用 3已过期 | ||
| 95 | - */ | ||
| 96 | - private Integer state; | ||
| 97 | - /** | ||
| 98 | - * 获取方式1订单2.直接领取3.活动领取 4转赠 5分享获取 | ||
| 99 | - */ | ||
| 100 | - private Boolean getType; | ||
| 101 | - /** | ||
| 102 | - * 领取时间 | ||
| 103 | - */ | ||
| 104 | - private Date fetchTime; | ||
| 105 | - /** | ||
| 106 | - * 使用时间 | ||
| 107 | - */ | ||
| 108 | - private Date useTime; | ||
| 109 | - /** | ||
| 110 | - * 可使用的开始时间 | ||
| 111 | - */ | ||
| 112 | - private Date startTime; | ||
| 113 | - /** | ||
| 114 | - * 有效期结束时间 | ||
| 115 | - */ | ||
| 116 | - private Date endTime; | ||
| 117 | - | ||
| 118 | -} |
yudao-module-mall/yudao-module-coupon-biz/src/main/java/cn/iocoder/yudao/module/coupon/dal/mysql/CouponTemplete/CouponTempleteMapper.java deleted
| 1 | -package cn.iocoder.yudao.module.coupon.dal.mysql.CouponTemplete; | ||
| 2 | - | ||
| 3 | -import java.util.*; | ||
| 4 | - | ||
| 5 | -import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 6 | -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; | ||
| 7 | -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; | ||
| 8 | -import cn.iocoder.yudao.module.coupon.controller.admin.templete.vo.CouponTempleteExportReqVO; | ||
| 9 | -import cn.iocoder.yudao.module.coupon.controller.admin.templete.vo.CouponTempletePageReqVO; | ||
| 10 | -import cn.iocoder.yudao.module.coupon.dal.dataobject.CouponTemplete.CouponTempleteDO; | ||
| 11 | -import org.apache.ibatis.annotations.Mapper; | ||
| 12 | - | ||
| 13 | - | ||
| 14 | -/** | ||
| 15 | - * 优惠券模板 Mapper | ||
| 16 | - * | ||
| 17 | - * @author wxr | ||
| 18 | - */ | ||
| 19 | -@Mapper | ||
| 20 | -public interface CouponTempleteMapper extends BaseMapperX<CouponTempleteDO> { | ||
| 21 | - | ||
| 22 | - default PageResult<CouponTempleteDO> selectPage(CouponTempletePageReqVO reqVO) { | ||
| 23 | - return selectPage(reqVO, new LambdaQueryWrapperX<CouponTempleteDO>() | ||
| 24 | - .eqIfPresent(CouponTempleteDO::getType, reqVO.getType()) | ||
| 25 | - .likeIfPresent(CouponTempleteDO::getName, reqVO.getName()) | ||
| 26 | - .eqIfPresent(CouponTempleteDO::getCouponNameRemark, reqVO.getCouponNameRemark()) | ||
| 27 | - .eqIfPresent(CouponTempleteDO::getImage, reqVO.getImage()) | ||
| 28 | - .eqIfPresent(CouponTempleteDO::getCount, reqVO.getCount()) | ||
| 29 | - .eqIfPresent(CouponTempleteDO::getLeadCount, reqVO.getLeadCount()) | ||
| 30 | - .eqIfPresent(CouponTempleteDO::getUsedCount, reqVO.getUsedCount()) | ||
| 31 | - .eqIfPresent(CouponTempleteDO::getGoodsType, reqVO.getGoodsType()) | ||
| 32 | - .eqIfPresent(CouponTempleteDO::getProductIds, reqVO.getProductIds()) | ||
| 33 | - .eqIfPresent(CouponTempleteDO::getHasUseLimit, reqVO.getHasUseLimit()) | ||
| 34 | - .eqIfPresent(CouponTempleteDO::getAtLeast, reqVO.getAtLeast()) | ||
| 35 | - .eqIfPresent(CouponTempleteDO::getMoney, reqVO.getMoney()) | ||
| 36 | - .eqIfPresent(CouponTempleteDO::getDiscount, reqVO.getDiscount()) | ||
| 37 | - .eqIfPresent(CouponTempleteDO::getDiscountLimit, reqVO.getDiscountLimit()) | ||
| 38 | - .eqIfPresent(CouponTempleteDO::getMinMoney, reqVO.getMinMoney()) | ||
| 39 | - .eqIfPresent(CouponTempleteDO::getMaxMoney, reqVO.getMaxMoney()) | ||
| 40 | - .eqIfPresent(CouponTempleteDO::getValidityType, reqVO.getValidityType()) | ||
| 41 | - .betweenIfPresent(CouponTempleteDO::getStartUseTime, reqVO.getStartUseTime()) | ||
| 42 | - .betweenIfPresent(CouponTempleteDO::getEndUseTime, reqVO.getEndUseTime()) | ||
| 43 | - .eqIfPresent(CouponTempleteDO::getFixedTerm, reqVO.getFixedTerm()) | ||
| 44 | - .eqIfPresent(CouponTempleteDO::getWhetherLimitless, reqVO.getWhetherLimitless()) | ||
| 45 | - .eqIfPresent(CouponTempleteDO::getMaxFetch, reqVO.getMaxFetch()) | ||
| 46 | - .eqIfPresent(CouponTempleteDO::getWhetherExpireNotice, reqVO.getWhetherExpireNotice()) | ||
| 47 | - .eqIfPresent(CouponTempleteDO::getExpireNoticeFixedTerm, reqVO.getExpireNoticeFixedTerm()) | ||
| 48 | - .eqIfPresent(CouponTempleteDO::getWhetherForbidPreference, reqVO.getWhetherForbidPreference()) | ||
| 49 | - .eqIfPresent(CouponTempleteDO::getWhetherShow, reqVO.getWhetherShow()) | ||
| 50 | - .eqIfPresent(CouponTempleteDO::getDiscountOrderMoney, reqVO.getDiscountOrderMoney()) | ||
| 51 | - .eqIfPresent(CouponTempleteDO::getOrderMoney, reqVO.getOrderMoney()) | ||
| 52 | - .eqIfPresent(CouponTempleteDO::getWhetherForbidden, reqVO.getWhetherForbidden()) | ||
| 53 | - .eqIfPresent(CouponTempleteDO::getOrderGoodsNum, reqVO.getOrderGoodsNum()) | ||
| 54 | - .eqIfPresent(CouponTempleteDO::getStatus, reqVO.getStatus()) | ||
| 55 | - .betweenIfPresent(CouponTempleteDO::getEndTime, reqVO.getEndTime()) | ||
| 56 | - .betweenIfPresent(CouponTempleteDO::getCreateTime, reqVO.getCreateTime()) | ||
| 57 | - .orderByDesc(CouponTempleteDO::getId)); | ||
| 58 | - } | ||
| 59 | - | ||
| 60 | - default List<CouponTempleteDO> selectList(CouponTempleteExportReqVO reqVO) { | ||
| 61 | - return selectList(new LambdaQueryWrapperX<CouponTempleteDO>() | ||
| 62 | - .eqIfPresent(CouponTempleteDO::getType, reqVO.getType()) | ||
| 63 | - .likeIfPresent(CouponTempleteDO::getName, reqVO.getName()) | ||
| 64 | - .eqIfPresent(CouponTempleteDO::getCouponNameRemark, reqVO.getCouponNameRemark()) | ||
| 65 | - .eqIfPresent(CouponTempleteDO::getImage, reqVO.getImage()) | ||
| 66 | - .eqIfPresent(CouponTempleteDO::getCount, reqVO.getCount()) | ||
| 67 | - .eqIfPresent(CouponTempleteDO::getLeadCount, reqVO.getLeadCount()) | ||
| 68 | - .eqIfPresent(CouponTempleteDO::getUsedCount, reqVO.getUsedCount()) | ||
| 69 | - .eqIfPresent(CouponTempleteDO::getGoodsType, reqVO.getGoodsType()) | ||
| 70 | - .eqIfPresent(CouponTempleteDO::getProductIds, reqVO.getProductIds()) | ||
| 71 | - .eqIfPresent(CouponTempleteDO::getHasUseLimit, reqVO.getHasUseLimit()) | ||
| 72 | - .eqIfPresent(CouponTempleteDO::getAtLeast, reqVO.getAtLeast()) | ||
| 73 | - .eqIfPresent(CouponTempleteDO::getMoney, reqVO.getMoney()) | ||
| 74 | - .eqIfPresent(CouponTempleteDO::getDiscount, reqVO.getDiscount()) | ||
| 75 | - .eqIfPresent(CouponTempleteDO::getDiscountLimit, reqVO.getDiscountLimit()) | ||
| 76 | - .eqIfPresent(CouponTempleteDO::getMinMoney, reqVO.getMinMoney()) | ||
| 77 | - .eqIfPresent(CouponTempleteDO::getMaxMoney, reqVO.getMaxMoney()) | ||
| 78 | - .eqIfPresent(CouponTempleteDO::getValidityType, reqVO.getValidityType()) | ||
| 79 | - .betweenIfPresent(CouponTempleteDO::getStartUseTime, reqVO.getStartUseTime()) | ||
| 80 | - .betweenIfPresent(CouponTempleteDO::getEndUseTime, reqVO.getEndUseTime()) | ||
| 81 | - .eqIfPresent(CouponTempleteDO::getFixedTerm, reqVO.getFixedTerm()) | ||
| 82 | - .eqIfPresent(CouponTempleteDO::getWhetherLimitless, reqVO.getWhetherLimitless()) | ||
| 83 | - .eqIfPresent(CouponTempleteDO::getMaxFetch, reqVO.getMaxFetch()) | ||
| 84 | - .eqIfPresent(CouponTempleteDO::getWhetherExpireNotice, reqVO.getWhetherExpireNotice()) | ||
| 85 | - .eqIfPresent(CouponTempleteDO::getExpireNoticeFixedTerm, reqVO.getExpireNoticeFixedTerm()) | ||
| 86 | - .eqIfPresent(CouponTempleteDO::getWhetherForbidPreference, reqVO.getWhetherForbidPreference()) | ||
| 87 | - .eqIfPresent(CouponTempleteDO::getWhetherShow, reqVO.getWhetherShow()) | ||
| 88 | - .eqIfPresent(CouponTempleteDO::getDiscountOrderMoney, reqVO.getDiscountOrderMoney()) | ||
| 89 | - .eqIfPresent(CouponTempleteDO::getOrderMoney, reqVO.getOrderMoney()) | ||
| 90 | - .eqIfPresent(CouponTempleteDO::getWhetherForbidden, reqVO.getWhetherForbidden()) | ||
| 91 | - .eqIfPresent(CouponTempleteDO::getOrderGoodsNum, reqVO.getOrderGoodsNum()) | ||
| 92 | - .eqIfPresent(CouponTempleteDO::getStatus, reqVO.getStatus()) | ||
| 93 | - .betweenIfPresent(CouponTempleteDO::getEndTime, reqVO.getEndTime()) | ||
| 94 | - .betweenIfPresent(CouponTempleteDO::getCreateTime, reqVO.getCreateTime()) | ||
| 95 | - .orderByDesc(CouponTempleteDO::getId)); | ||
| 96 | - } | ||
| 97 | - | ||
| 98 | -} |
yudao-module-mall/yudao-module-coupon-biz/src/main/java/cn/iocoder/yudao/module/coupon/dal/mysql/coupon/CouponMapper.java deleted
| 1 | -package cn.iocoder.yudao.module.coupon.dal.mysql.coupon; | ||
| 2 | - | ||
| 3 | -import java.util.*; | ||
| 4 | - | ||
| 5 | -import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 6 | -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; | ||
| 7 | -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; | ||
| 8 | -import cn.iocoder.yudao.module.coupon.dal.dataobject.coupon.CouponDO; | ||
| 9 | -import org.apache.ibatis.annotations.Mapper; | ||
| 10 | -import cn.iocoder.yudao.module.coupon.controller.admin.coupon.vo.*; | ||
| 11 | - | ||
| 12 | -/** | ||
| 13 | - * 优惠券 Mapper | ||
| 14 | - * | ||
| 15 | - * @author wxr | ||
| 16 | - */ | ||
| 17 | -@Mapper | ||
| 18 | -public interface CouponMapper extends BaseMapperX<CouponDO> { | ||
| 19 | - | ||
| 20 | - default PageResult<CouponDO> selectPage(CouponPageReqVO reqVO) { | ||
| 21 | - return selectPage(reqVO, new LambdaQueryWrapperX<CouponDO>() | ||
| 22 | - .eqIfPresent(CouponDO::getType, reqVO.getType()) | ||
| 23 | - .likeIfPresent(CouponDO::getName, reqVO.getName()) | ||
| 24 | - .eqIfPresent(CouponDO::getCouponTypeId, reqVO.getCouponTypeId()) | ||
| 25 | - .eqIfPresent(CouponDO::getCouponCode, reqVO.getCouponCode()) | ||
| 26 | - .eqIfPresent(CouponDO::getMemberId, reqVO.getMemberId()) | ||
| 27 | - .eqIfPresent(CouponDO::getUseOrderId, reqVO.getUseOrderId()) | ||
| 28 | - .eqIfPresent(CouponDO::getGoodsType, reqVO.getGoodsType()) | ||
| 29 | - .eqIfPresent(CouponDO::getGoodsIds, reqVO.getGoodsIds()) | ||
| 30 | - .eqIfPresent(CouponDO::getAtLeast, reqVO.getAtLeast()) | ||
| 31 | - .eqIfPresent(CouponDO::getMoney, reqVO.getMoney()) | ||
| 32 | - .eqIfPresent(CouponDO::getDiscount, reqVO.getDiscount()) | ||
| 33 | - .eqIfPresent(CouponDO::getDiscountLimit, reqVO.getDiscountLimit()) | ||
| 34 | - .eqIfPresent(CouponDO::getWhetherForbidPreference, reqVO.getWhetherForbidPreference()) | ||
| 35 | - .eqIfPresent(CouponDO::getWhetherExpireNotice, reqVO.getWhetherExpireNotice()) | ||
| 36 | - .eqIfPresent(CouponDO::getExpireNoticeFixedTerm, reqVO.getExpireNoticeFixedTerm()) | ||
| 37 | - .eqIfPresent(CouponDO::getWhetherNoticed, reqVO.getWhetherNoticed()) | ||
| 38 | - .eqIfPresent(CouponDO::getState, reqVO.getState()) | ||
| 39 | - .eqIfPresent(CouponDO::getGetType, reqVO.getGetType()) | ||
| 40 | - .betweenIfPresent(CouponDO::getFetchTime, reqVO.getFetchTime()) | ||
| 41 | - .betweenIfPresent(CouponDO::getUseTime, reqVO.getUseTime()) | ||
| 42 | - .betweenIfPresent(CouponDO::getStartTime, reqVO.getStartTime()) | ||
| 43 | - .betweenIfPresent(CouponDO::getEndTime, reqVO.getEndTime()) | ||
| 44 | - .betweenIfPresent(CouponDO::getCreateTime, reqVO.getCreateTime()) | ||
| 45 | - .orderByDesc(CouponDO::getId)); | ||
| 46 | - } | ||
| 47 | - | ||
| 48 | - default List<CouponDO> selectList(CouponExportReqVO reqVO) { | ||
| 49 | - return selectList(new LambdaQueryWrapperX<CouponDO>() | ||
| 50 | - .eqIfPresent(CouponDO::getType, reqVO.getType()) | ||
| 51 | - .likeIfPresent(CouponDO::getName, reqVO.getName()) | ||
| 52 | - .eqIfPresent(CouponDO::getCouponTypeId, reqVO.getCouponTypeId()) | ||
| 53 | - .eqIfPresent(CouponDO::getCouponCode, reqVO.getCouponCode()) | ||
| 54 | - .eqIfPresent(CouponDO::getMemberId, reqVO.getMemberId()) | ||
| 55 | - .eqIfPresent(CouponDO::getUseOrderId, reqVO.getUseOrderId()) | ||
| 56 | - .eqIfPresent(CouponDO::getGoodsType, reqVO.getGoodsType()) | ||
| 57 | - .eqIfPresent(CouponDO::getGoodsIds, reqVO.getGoodsIds()) | ||
| 58 | - .eqIfPresent(CouponDO::getAtLeast, reqVO.getAtLeast()) | ||
| 59 | - .eqIfPresent(CouponDO::getMoney, reqVO.getMoney()) | ||
| 60 | - .eqIfPresent(CouponDO::getDiscount, reqVO.getDiscount()) | ||
| 61 | - .eqIfPresent(CouponDO::getDiscountLimit, reqVO.getDiscountLimit()) | ||
| 62 | - .eqIfPresent(CouponDO::getWhetherForbidPreference, reqVO.getWhetherForbidPreference()) | ||
| 63 | - .eqIfPresent(CouponDO::getWhetherExpireNotice, reqVO.getWhetherExpireNotice()) | ||
| 64 | - .eqIfPresent(CouponDO::getExpireNoticeFixedTerm, reqVO.getExpireNoticeFixedTerm()) | ||
| 65 | - .eqIfPresent(CouponDO::getWhetherNoticed, reqVO.getWhetherNoticed()) | ||
| 66 | - .eqIfPresent(CouponDO::getState, reqVO.getState()) | ||
| 67 | - .eqIfPresent(CouponDO::getGetType, reqVO.getGetType()) | ||
| 68 | - .betweenIfPresent(CouponDO::getFetchTime, reqVO.getFetchTime()) | ||
| 69 | - .betweenIfPresent(CouponDO::getUseTime, reqVO.getUseTime()) | ||
| 70 | - .betweenIfPresent(CouponDO::getStartTime, reqVO.getStartTime()) | ||
| 71 | - .betweenIfPresent(CouponDO::getEndTime, reqVO.getEndTime()) | ||
| 72 | - .betweenIfPresent(CouponDO::getCreateTime, reqVO.getCreateTime()) | ||
| 73 | - .orderByDesc(CouponDO::getId)); | ||
| 74 | - } | ||
| 75 | - | ||
| 76 | -} |
yudao-module-mall/yudao-module-coupon-biz/src/main/java/cn/iocoder/yudao/module/coupon/package-info.java deleted
yudao-module-mall/yudao-module-coupon-biz/src/main/java/cn/iocoder/yudao/module/coupon/service/CouponTemplete/CouponTempleteService.java deleted
| 1 | -package cn.iocoder.yudao.module.coupon.service.CouponTemplete; | ||
| 2 | - | ||
| 3 | -import java.util.*; | ||
| 4 | -import javax.validation.*; | ||
| 5 | -import cn.iocoder.yudao.module.coupon.controller.admin.templete.vo.*; | ||
| 6 | -import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 7 | -import cn.iocoder.yudao.module.coupon.dal.dataobject.CouponTemplete.CouponTempleteDO; | ||
| 8 | - | ||
| 9 | -/** | ||
| 10 | - * 优惠券模板 Service 接口 | ||
| 11 | - * | ||
| 12 | - * @author wxr | ||
| 13 | - */ | ||
| 14 | -public interface CouponTempleteService { | ||
| 15 | - | ||
| 16 | - /** | ||
| 17 | - * 创建优惠券模板 | ||
| 18 | - * | ||
| 19 | - * @param createReqVO 创建信息 | ||
| 20 | - * @return 编号 | ||
| 21 | - */ | ||
| 22 | - Long create(@Valid CouponTempleteCreateReqVO createReqVO); | ||
| 23 | - | ||
| 24 | - /** | ||
| 25 | - * 更新优惠券模板 | ||
| 26 | - * | ||
| 27 | - * @param updateReqVO 更新信息 | ||
| 28 | - */ | ||
| 29 | - void update(@Valid CouponTempleteUpdateReqVO updateReqVO); | ||
| 30 | - | ||
| 31 | - /** | ||
| 32 | - * 删除优惠券模板 | ||
| 33 | - * | ||
| 34 | - * @param id 编号 | ||
| 35 | - */ | ||
| 36 | - void delete(Long id); | ||
| 37 | - | ||
| 38 | - /** | ||
| 39 | - * 获得优惠券模板 | ||
| 40 | - * | ||
| 41 | - * @param id 编号 | ||
| 42 | - * @return 优惠券模板 | ||
| 43 | - */ | ||
| 44 | - CouponTempleteDO get(Long id); | ||
| 45 | - | ||
| 46 | - /** | ||
| 47 | - * 获得优惠券模板列表 | ||
| 48 | - * | ||
| 49 | - * @param ids 编号 | ||
| 50 | - * @return 优惠券模板列表 | ||
| 51 | - */ | ||
| 52 | - List<CouponTempleteDO> getList(Collection<Long> ids); | ||
| 53 | - | ||
| 54 | - /** | ||
| 55 | - * 获得优惠券模板分页 | ||
| 56 | - * | ||
| 57 | - * @param pageReqVO 分页查询 | ||
| 58 | - * @return 优惠券模板分页 | ||
| 59 | - */ | ||
| 60 | - PageResult<CouponTempleteDO> getPage(CouponTempletePageReqVO pageReqVO); | ||
| 61 | - | ||
| 62 | - /** | ||
| 63 | - * 获得优惠券模板列表, 用于 Excel 导出 | ||
| 64 | - * | ||
| 65 | - * @param exportReqVO 查询条件 | ||
| 66 | - * @return 优惠券模板列表 | ||
| 67 | - */ | ||
| 68 | - List<CouponTempleteDO> getList(CouponTempleteExportReqVO exportReqVO); | ||
| 69 | - | ||
| 70 | -} |
yudao-module-mall/yudao-module-coupon-biz/src/main/java/cn/iocoder/yudao/module/coupon/service/CouponTemplete/CouponTempleteServiceImpl.java deleted
| 1 | -package cn.iocoder.yudao.module.coupon.service.CouponTemplete; | ||
| 2 | - | ||
| 3 | -import cn.iocoder.yudao.module.CouponTemplete.enums.CouponTypeEnum; | ||
| 4 | -import cn.iocoder.yudao.module.CouponTemplete.enums.CouponValidityTypeEnum; | ||
| 5 | -import cn.iocoder.yudao.module.coupon.controller.admin.templete.vo.CouponTempleteCreateReqVO; | ||
| 6 | -import cn.iocoder.yudao.module.coupon.controller.admin.templete.vo.CouponTempleteExportReqVO; | ||
| 7 | -import cn.iocoder.yudao.module.coupon.controller.admin.templete.vo.CouponTempletePageReqVO; | ||
| 8 | -import cn.iocoder.yudao.module.coupon.controller.admin.templete.vo.CouponTempleteUpdateReqVO; | ||
| 9 | -import cn.iocoder.yudao.module.coupon.convert.CouponTemplete.CouponTempleteConvert; | ||
| 10 | -import cn.iocoder.yudao.module.coupon.dal.dataobject.CouponTemplete.CouponTempleteDO; | ||
| 11 | -import cn.iocoder.yudao.module.coupon.dal.mysql.CouponTemplete.CouponTempleteMapper; | ||
| 12 | -import org.springframework.stereotype.Service; | ||
| 13 | -import javax.annotation.Resource; | ||
| 14 | -import org.springframework.validation.annotation.Validated; | ||
| 15 | - | ||
| 16 | -import java.util.*; | ||
| 17 | -import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 18 | - | ||
| 19 | - | ||
| 20 | - | ||
| 21 | -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | ||
| 22 | -import static cn.iocoder.yudao.module.CouponTemplete.enums.ErrorCodeConstants.*; | ||
| 23 | - | ||
| 24 | -/** | ||
| 25 | - * 优惠券模板 Service 实现类 | ||
| 26 | - * | ||
| 27 | - * @author wxr | ||
| 28 | - */ | ||
| 29 | -@Service | ||
| 30 | -@Validated | ||
| 31 | -public class CouponTempleteServiceImpl implements CouponTempleteService { | ||
| 32 | - | ||
| 33 | - @Resource | ||
| 34 | - private CouponTempleteMapper couponTempleteMapper; | ||
| 35 | - | ||
| 36 | - @Override | ||
| 37 | - public Long create(CouponTempleteCreateReqVO createReqVO) { | ||
| 38 | - // 插入 | ||
| 39 | - CouponTempleteDO couponTempleteDO = CouponTempleteConvert.INSTANCE.convert(createReqVO); | ||
| 40 | - /* 验证类型、判断必填*/ | ||
| 41 | - checkCouponType(createReqVO); | ||
| 42 | - | ||
| 43 | - /*验证过期类型、判断必填*/ | ||
| 44 | - checkValidityType(createReqVO); | ||
| 45 | - | ||
| 46 | - | ||
| 47 | - | ||
| 48 | - couponTempleteMapper.insert(couponTempleteDO); | ||
| 49 | - // 返回 | ||
| 50 | - return couponTempleteDO.getId(); | ||
| 51 | - } | ||
| 52 | - | ||
| 53 | - /*确认优惠券类型*/ | ||
| 54 | - private void checkValidityType(CouponTempleteCreateReqVO createReqVO) { | ||
| 55 | - Integer validtyType = createReqVO.getValidityType(); | ||
| 56 | - | ||
| 57 | - if(CouponValidityTypeEnum.TIME_RANGE_EXPIRTED.getStatus().equals(validtyType)){ | ||
| 58 | - if(createReqVO.getStartUseTime() == null||createReqVO.getEndUseTime() == null){ | ||
| 59 | - throw exception(START_END_TIME_NOT_NULL); | ||
| 60 | - } | ||
| 61 | - }else{ | ||
| 62 | - if(createReqVO.getFixedTerm() == null){ | ||
| 63 | - throw exception(FIXED_TERM_NOT_NULL); | ||
| 64 | - } | ||
| 65 | - } | ||
| 66 | - } | ||
| 67 | - | ||
| 68 | - private void checkCouponType(CouponTempleteCreateReqVO createReqVO) { | ||
| 69 | - | ||
| 70 | - String couponType = createReqVO.getType(); | ||
| 71 | - //当type=reward时候,需要添加 | ||
| 72 | - if(couponType.equals(CouponTypeEnum.REWARD.getName())){ | ||
| 73 | - if(createReqVO.getMoney()==null){ | ||
| 74 | - throw exception(MONEY_NOT_NULL); | ||
| 75 | - } | ||
| 76 | - }else if(couponType.equals(CouponTypeEnum.DISCOUNT.getName())){ | ||
| 77 | - if(createReqVO.getDiscount()==null){ | ||
| 78 | - throw exception(DISCOUNT_NOT_NULL); | ||
| 79 | - } | ||
| 80 | - if(createReqVO.getDiscountLimit()==null){ | ||
| 81 | - throw exception(DISCOUNT_LIMIT_NOT_NULL); | ||
| 82 | - } | ||
| 83 | - }else if (couponType.equals(CouponTypeEnum.RANDOW.getName())){ | ||
| 84 | - //当type为radom时需要添加不能为空 | ||
| 85 | - if(createReqVO.getMinMoney()==null||createReqVO.getMaxMoney()==null){ | ||
| 86 | - throw exception(MIN_MAX_NOT_NULL); | ||
| 87 | - } | ||
| 88 | - } | ||
| 89 | - } | ||
| 90 | - | ||
| 91 | - @Override | ||
| 92 | - public void update(CouponTempleteUpdateReqVO updateReqVO) { | ||
| 93 | - // 校验存在 | ||
| 94 | - this.validateExists(updateReqVO.getId()); | ||
| 95 | - // 更新 | ||
| 96 | - CouponTempleteDO updateObj = CouponTempleteConvert.INSTANCE.convert(updateReqVO); | ||
| 97 | - couponTempleteMapper.updateById(updateObj); | ||
| 98 | - } | ||
| 99 | - | ||
| 100 | - @Override | ||
| 101 | - public void delete(Long id) { | ||
| 102 | - // 校验存在 | ||
| 103 | - this.validateExists(id); | ||
| 104 | - // 删除 | ||
| 105 | - couponTempleteMapper.deleteById(id); | ||
| 106 | - } | ||
| 107 | - | ||
| 108 | - private void validateExists(Long id) { | ||
| 109 | - if (couponTempleteMapper.selectById(id) == null) { | ||
| 110 | - throw exception(COUPON_TEMPLETE_NOT_EXISTS); | ||
| 111 | - } | ||
| 112 | - } | ||
| 113 | - | ||
| 114 | - @Override | ||
| 115 | - public CouponTempleteDO get(Long id) { | ||
| 116 | - return couponTempleteMapper.selectById(id); | ||
| 117 | - } | ||
| 118 | - | ||
| 119 | - @Override | ||
| 120 | - public List<CouponTempleteDO> getList(Collection<Long> ids) { | ||
| 121 | - return couponTempleteMapper.selectBatchIds(ids); | ||
| 122 | - } | ||
| 123 | - | ||
| 124 | - @Override | ||
| 125 | - public PageResult<CouponTempleteDO> getPage(CouponTempletePageReqVO pageReqVO) { | ||
| 126 | - return couponTempleteMapper.selectPage(pageReqVO); | ||
| 127 | - } | ||
| 128 | - | ||
| 129 | - @Override | ||
| 130 | - public List<CouponTempleteDO> getList(CouponTempleteExportReqVO exportReqVO) { | ||
| 131 | - return couponTempleteMapper.selectList(exportReqVO); | ||
| 132 | - } | ||
| 133 | - | ||
| 134 | -} |
yudao-module-mall/yudao-module-coupon-biz/src/main/java/cn/iocoder/yudao/module/coupon/service/coupon/CouponService.java deleted
| 1 | -package cn.iocoder.yudao.module.coupon.service.coupon; | ||
| 2 | - | ||
| 3 | -import java.util.*; | ||
| 4 | -import javax.validation.*; | ||
| 5 | -import cn.iocoder.yudao.module.coupon.controller.admin.coupon.vo.*; | ||
| 6 | -import cn.iocoder.yudao.module.coupon.dal.dataobject.coupon.CouponDO; | ||
| 7 | -import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 8 | - | ||
| 9 | -/** | ||
| 10 | - * 优惠券 Service 接口 | ||
| 11 | - * | ||
| 12 | - * @author wxr | ||
| 13 | - */ | ||
| 14 | -public interface CouponService { | ||
| 15 | - | ||
| 16 | - /** | ||
| 17 | - * 创建优惠券 | ||
| 18 | - * | ||
| 19 | - * @param templateId 优惠券模板id | ||
| 20 | - * @return 编号 | ||
| 21 | - */ | ||
| 22 | - Long create(Long templateId); | ||
| 23 | - | ||
| 24 | - /** | ||
| 25 | - * 更新优惠券 | ||
| 26 | - * | ||
| 27 | - * @param updateReqVO 更新信息 | ||
| 28 | - */ | ||
| 29 | - void update(@Valid CouponUpdateReqVO updateReqVO); | ||
| 30 | - | ||
| 31 | - /** | ||
| 32 | - * 删除优惠券 | ||
| 33 | - * | ||
| 34 | - * @param id 编号 | ||
| 35 | - */ | ||
| 36 | - void delete(Long id); | ||
| 37 | - | ||
| 38 | - /** | ||
| 39 | - * 获得优惠券 | ||
| 40 | - * | ||
| 41 | - * @param id 编号 | ||
| 42 | - * @return 优惠券 | ||
| 43 | - */ | ||
| 44 | - CouponDO get(Long id); | ||
| 45 | - | ||
| 46 | - /** | ||
| 47 | - * 获得优惠券列表 | ||
| 48 | - * | ||
| 49 | - * @param ids 编号 | ||
| 50 | - * @return 优惠券列表 | ||
| 51 | - */ | ||
| 52 | - List<CouponDO> getList(Collection<Long> ids); | ||
| 53 | - | ||
| 54 | - /** | ||
| 55 | - * 获得优惠券分页 | ||
| 56 | - * | ||
| 57 | - * @param pageReqVO 分页查询 | ||
| 58 | - * @return 优惠券分页 | ||
| 59 | - */ | ||
| 60 | - PageResult<CouponDO> getPage(CouponPageReqVO pageReqVO); | ||
| 61 | - | ||
| 62 | - /** | ||
| 63 | - * 获得优惠券列表, 用于 Excel 导出 | ||
| 64 | - * | ||
| 65 | - * @param exportReqVO 查询条件 | ||
| 66 | - * @return 优惠券列表 | ||
| 67 | - */ | ||
| 68 | - List<CouponDO> getList(CouponExportReqVO exportReqVO); | ||
| 69 | - | ||
| 70 | -} |
yudao-module-mall/yudao-module-coupon-biz/src/main/java/cn/iocoder/yudao/module/coupon/service/coupon/CouponServiceImpl.java deleted
| 1 | -package cn.iocoder.yudao.module.coupon.service.coupon; | ||
| 2 | - | ||
| 3 | -import cn.hutool.core.bean.BeanUtil; | ||
| 4 | -import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils; | ||
| 5 | -import cn.iocoder.yudao.module.coupon.dal.dataobject.CouponTemplete.CouponTempleteDO; | ||
| 6 | -import cn.iocoder.yudao.module.coupon.dal.mysql.CouponTemplete.CouponTempleteMapper; | ||
| 7 | -import org.springframework.stereotype.Service; | ||
| 8 | -import javax.annotation.Resource; | ||
| 9 | -import org.springframework.validation.annotation.Validated; | ||
| 10 | - | ||
| 11 | -import java.util.*; | ||
| 12 | -import cn.iocoder.yudao.module.coupon.controller.admin.coupon.vo.*; | ||
| 13 | -import cn.iocoder.yudao.module.coupon.dal.dataobject.coupon.CouponDO; | ||
| 14 | -import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 15 | - | ||
| 16 | -import cn.iocoder.yudao.module.coupon.convert.coupon.CouponConvert; | ||
| 17 | -import cn.iocoder.yudao.module.coupon.dal.mysql.coupon.CouponMapper; | ||
| 18 | - | ||
| 19 | -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | ||
| 20 | -import static cn.iocoder.yudao.module.CouponTemplete.enums.ErrorCodeConstants.COUPON_NOT_EXISTS; | ||
| 21 | - | ||
| 22 | -/** | ||
| 23 | - * 优惠券 Service 实现类 | ||
| 24 | - * | ||
| 25 | - * @author wxr | ||
| 26 | - */ | ||
| 27 | -@Service | ||
| 28 | -@Validated | ||
| 29 | -public class CouponServiceImpl implements CouponService { | ||
| 30 | - | ||
| 31 | - @Resource | ||
| 32 | - private CouponMapper couponMapper; | ||
| 33 | - | ||
| 34 | - @Resource | ||
| 35 | - private CouponTempleteMapper couponTempleteMapper; | ||
| 36 | - | ||
| 37 | - public Long create(CouponCreateReqVO createReqVO) { | ||
| 38 | - // 插入 | ||
| 39 | - CouponDO couponDO = CouponConvert.INSTANCE.convert(createReqVO); | ||
| 40 | - couponMapper.insert(couponDO); | ||
| 41 | - // 返回 | ||
| 42 | - return couponDO.getId(); | ||
| 43 | - } | ||
| 44 | - | ||
| 45 | - | ||
| 46 | - /** | ||
| 47 | - *todo 获取用户id收获优惠券 | ||
| 48 | - *@author:wxr | ||
| 49 | - *@date:2022-08-13 3:11 | ||
| 50 | - *@Description | ||
| 51 | - */ | ||
| 52 | - @Override | ||
| 53 | - public Long create(Long templateId) { | ||
| 54 | - Long userid = SecurityFrameworkUtils.getLoginUserId(); | ||
| 55 | - CouponDO couponDO = CouponDO.builder().memberId(userid).build(); | ||
| 56 | - CouponTempleteDO couponTempleteDO = couponTempleteMapper.selectById(templateId); | ||
| 57 | - //todo 缺少判空 | ||
| 58 | - BeanUtil.copyProperties(couponTempleteDO,couponTempleteDO); | ||
| 59 | - couponMapper.insert(couponDO); | ||
| 60 | - return couponDO.getId(); | ||
| 61 | - } | ||
| 62 | - | ||
| 63 | - @Override | ||
| 64 | - public void update(CouponUpdateReqVO updateReqVO) { | ||
| 65 | - // 校验存在 | ||
| 66 | - this.validateExists(updateReqVO.getId()); | ||
| 67 | - // 更新 | ||
| 68 | - CouponDO updateObj = CouponConvert.INSTANCE.convert(updateReqVO); | ||
| 69 | - couponMapper.updateById(updateObj); | ||
| 70 | - } | ||
| 71 | - | ||
| 72 | - @Override | ||
| 73 | - public void delete(Long id) { | ||
| 74 | - // 校验存在 | ||
| 75 | - this.validateExists(id); | ||
| 76 | - // 删除 | ||
| 77 | - couponMapper.deleteById(id); | ||
| 78 | - } | ||
| 79 | - | ||
| 80 | - private void validateExists(Long id) { | ||
| 81 | - if (couponMapper.selectById(id) == null) { | ||
| 82 | - throw exception(COUPON_NOT_EXISTS); | ||
| 83 | - } | ||
| 84 | - } | ||
| 85 | - | ||
| 86 | - @Override | ||
| 87 | - public CouponDO get(Long id) { | ||
| 88 | - return couponMapper.selectById(id); | ||
| 89 | - } | ||
| 90 | - | ||
| 91 | - @Override | ||
| 92 | - public List<CouponDO> getList(Collection<Long> ids) { | ||
| 93 | - return couponMapper.selectBatchIds(ids); | ||
| 94 | - } | ||
| 95 | - | ||
| 96 | - @Override | ||
| 97 | - public PageResult<CouponDO> getPage(CouponPageReqVO pageReqVO) { | ||
| 98 | - return couponMapper.selectPage(pageReqVO); | ||
| 99 | - } | ||
| 100 | - | ||
| 101 | - @Override | ||
| 102 | - public List<CouponDO> getList(CouponExportReqVO exportReqVO) { | ||
| 103 | - return couponMapper.selectList(exportReqVO); | ||
| 104 | - } | ||
| 105 | - | ||
| 106 | -} |
yudao-module-mall/yudao-module-coupon-biz/src/main/resources/mapper/CouponTemplete/CouponTempleteMapper.xml deleted
| 1 | -<?xml version="1.0" encoding="UTF-8"?> | ||
| 2 | -<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | ||
| 3 | -<mapper namespace="cn.iocoder.yudao.module.coupon.dal.mysql.CouponTemplete.CouponTempleteMapper"> | ||
| 4 | - | ||
| 5 | - <!-- | ||
| 6 | - 一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。 | ||
| 7 | - 无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。 | ||
| 8 | - 代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。 | ||
| 9 | - 文档可见:https://www.iocoder.cn/MyBatis/x-plugins/ | ||
| 10 | - --> | ||
| 11 | - | ||
| 12 | -</mapper> |
yudao-module-mall/yudao-module-coupon-biz/src/main/resources/mapper/coupon/CouponMapper.xml deleted
| 1 | -<?xml version="1.0" encoding="UTF-8"?> | ||
| 2 | -<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | ||
| 3 | -<mapper namespace="cn.iocoder.yudao.module.coupon.dal.mysql.coupon.CouponMapper"> | ||
| 4 | - | ||
| 5 | - <!-- | ||
| 6 | - 一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。 | ||
| 7 | - 无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。 | ||
| 8 | - 代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。 | ||
| 9 | - 文档可见:https://www.iocoder.cn/MyBatis/x-plugins/ | ||
| 10 | - --> | ||
| 11 | - | ||
| 12 | -</mapper> |
yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/ErrorCodeConstants.java
| @@ -19,4 +19,8 @@ public interface ErrorCodeConstants { | @@ -19,4 +19,8 @@ public interface ErrorCodeConstants { | ||
| 19 | ErrorCode COUPON_NO_MATCH_SPU = new ErrorCode(1003003000, "优惠劵没有可使用的商品!"); | 19 | ErrorCode COUPON_NO_MATCH_SPU = new ErrorCode(1003003000, "优惠劵没有可使用的商品!"); |
| 20 | ErrorCode COUPON_NO_MATCH_MIN_PRICE = new ErrorCode(1003003000, "不满足优惠劵使用的最低金额"); | 20 | ErrorCode COUPON_NO_MATCH_MIN_PRICE = new ErrorCode(1003003000, "不满足优惠劵使用的最低金额"); |
| 21 | 21 | ||
| 22 | + // ========== 优惠劵模板 1003004000 ========== | ||
| 23 | + ErrorCode COUPON_TEMPLATE_NOT_EXISTS = new ErrorCode(1003004000, "优惠劵模板不存在"); | ||
| 24 | + ErrorCode COUPON_TEMPLATE_TOTAL_COUNT_TOO_SMALL = new ErrorCode(1003004001, "发放数量不能小于已领取数量({})"); | ||
| 25 | + | ||
| 22 | } | 26 | } |
yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/common/PromotionDiscountTypeEnum.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.promotion.enums.common; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.common.core.IntArrayValuable; | ||
| 4 | +import lombok.AllArgsConstructor; | ||
| 5 | +import lombok.Getter; | ||
| 6 | + | ||
| 7 | +import java.util.Arrays; | ||
| 8 | + | ||
| 9 | +/** | ||
| 10 | + * 优惠类型枚举 | ||
| 11 | + * | ||
| 12 | + * @author 芋道源码 | ||
| 13 | + */ | ||
| 14 | +@Getter | ||
| 15 | +@AllArgsConstructor | ||
| 16 | +public enum PromotionDiscountTypeEnum implements IntArrayValuable { | ||
| 17 | + | ||
| 18 | + PRICE(1, "满减"), // 具体金额 | ||
| 19 | + PERCENT(2, "折扣"), // 百分比 | ||
| 20 | + ; | ||
| 21 | + | ||
| 22 | + public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(PromotionDiscountTypeEnum::getType).toArray(); | ||
| 23 | + | ||
| 24 | + /** | ||
| 25 | + * 优惠类型 | ||
| 26 | + */ | ||
| 27 | + private final Integer type; | ||
| 28 | + /** | ||
| 29 | + * 名字 | ||
| 30 | + */ | ||
| 31 | + private final String name; | ||
| 32 | + | ||
| 33 | + @Override | ||
| 34 | + public int[] array() { | ||
| 35 | + return ARRAYS; | ||
| 36 | + } | ||
| 37 | + | ||
| 38 | +} |
yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/coupon/CouponTakeTypeEnum.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.promotion.enums.coupon; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.common.core.IntArrayValuable; | ||
| 4 | + | ||
| 5 | +import java.util.Arrays; | ||
| 6 | + | ||
| 7 | +/** | ||
| 8 | + * 优惠劵领取方式 | ||
| 9 | + * | ||
| 10 | + * @author 芋道源码 | ||
| 11 | + */ | ||
| 12 | +public enum CouponTakeTypeEnum implements IntArrayValuable { | ||
| 13 | + | ||
| 14 | + BY_USER(1, "直接领取"), // 用户可在首页、每日领劵直接领取 | ||
| 15 | + BY_ADMIN(2, "指定发放"), // 后台指定会员赠送优惠劵 | ||
| 16 | + ; | ||
| 17 | + | ||
| 18 | + public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(CouponTakeTypeEnum::getValue).toArray(); | ||
| 19 | + | ||
| 20 | + /** | ||
| 21 | + * 值 | ||
| 22 | + */ | ||
| 23 | + private final Integer value; | ||
| 24 | + /** | ||
| 25 | + * 名字 | ||
| 26 | + */ | ||
| 27 | + private final String name; | ||
| 28 | + | ||
| 29 | + CouponTakeTypeEnum(Integer value, String name) { | ||
| 30 | + this.value = value; | ||
| 31 | + this.name = name; | ||
| 32 | + } | ||
| 33 | + | ||
| 34 | + public Integer getValue() { | ||
| 35 | + return value; | ||
| 36 | + } | ||
| 37 | + | ||
| 38 | + public String getName() { | ||
| 39 | + return name; | ||
| 40 | + } | ||
| 41 | + | ||
| 42 | + @Override | ||
| 43 | + public int[] array() { | ||
| 44 | + return ARRAYS; | ||
| 45 | + } | ||
| 46 | +} |
yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/coupon/CouponTemplateValidityTypeEnum.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.promotion.enums.coupon; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.common.core.IntArrayValuable; | ||
| 4 | +import lombok.AllArgsConstructor; | ||
| 5 | +import lombok.Getter; | ||
| 6 | + | ||
| 7 | +import java.util.Arrays; | ||
| 8 | + | ||
| 9 | +/** | ||
| 10 | + * 优惠劵模板的有限期类型的枚举 | ||
| 11 | + * | ||
| 12 | + * @author 芋道源码 | ||
| 13 | + */ | ||
| 14 | +@AllArgsConstructor | ||
| 15 | +@Getter | ||
| 16 | +public enum CouponTemplateValidityTypeEnum implements IntArrayValuable { | ||
| 17 | + | ||
| 18 | + DATE(1, "固定日期"), | ||
| 19 | + TERM(2, "领取之后"), | ||
| 20 | + ; | ||
| 21 | + | ||
| 22 | + public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(CouponTemplateValidityTypeEnum::getType).toArray(); | ||
| 23 | + | ||
| 24 | + /** | ||
| 25 | + * 值 | ||
| 26 | + */ | ||
| 27 | + private final Integer type; | ||
| 28 | + /** | ||
| 29 | + * 名字 | ||
| 30 | + */ | ||
| 31 | + private final String name; | ||
| 32 | + | ||
| 33 | + @Override | ||
| 34 | + public int[] array() { | ||
| 35 | + return ARRAYS; | ||
| 36 | + } | ||
| 37 | + | ||
| 38 | +} |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/CouponTemplateController.java
0 → 100755
| 1 | +package cn.iocoder.yudao.module.promotion.controller.admin.coupon; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.common.pojo.CommonResult; | ||
| 4 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 5 | +import cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.CouponTemplateCreateReqVO; | ||
| 6 | +import cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.CouponTemplatePageReqVO; | ||
| 7 | +import cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.CouponTemplateRespVO; | ||
| 8 | +import cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.CouponTemplateUpdateReqVO; | ||
| 9 | +import cn.iocoder.yudao.module.promotion.convert.coupon.CouponTemplateConvert; | ||
| 10 | +import cn.iocoder.yudao.module.promotion.dal.dataobject.coupon.CouponTemplateDO; | ||
| 11 | +import cn.iocoder.yudao.module.promotion.service.coupon.CouponTemplateService; | ||
| 12 | +import io.swagger.annotations.Api; | ||
| 13 | +import io.swagger.annotations.ApiImplicitParam; | ||
| 14 | +import io.swagger.annotations.ApiOperation; | ||
| 15 | +import org.springframework.security.access.prepost.PreAuthorize; | ||
| 16 | +import org.springframework.validation.annotation.Validated; | ||
| 17 | +import org.springframework.web.bind.annotation.*; | ||
| 18 | + | ||
| 19 | +import javax.annotation.Resource; | ||
| 20 | +import javax.validation.Valid; | ||
| 21 | + | ||
| 22 | +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | ||
| 23 | + | ||
| 24 | +@Api(tags = "管理后台 - 优惠劵模板") | ||
| 25 | +@RestController | ||
| 26 | +@RequestMapping("/promotion/coupon-template") | ||
| 27 | +@Validated | ||
| 28 | +public class CouponTemplateController { | ||
| 29 | + | ||
| 30 | + @Resource | ||
| 31 | + private CouponTemplateService couponTemplateService; | ||
| 32 | + | ||
| 33 | + @PostMapping("/create") | ||
| 34 | + @ApiOperation("创建优惠劵模板") | ||
| 35 | + @PreAuthorize("@ss.hasPermission('promotion:coupon-template:create')") | ||
| 36 | + public CommonResult<Long> createCouponTemplate(@Valid @RequestBody CouponTemplateCreateReqVO createReqVO) { | ||
| 37 | + return success(couponTemplateService.createCouponTemplate(createReqVO)); | ||
| 38 | + } | ||
| 39 | + | ||
| 40 | + @PutMapping("/update") | ||
| 41 | + @ApiOperation("更新优惠劵模板") | ||
| 42 | + @PreAuthorize("@ss.hasPermission('promotion:coupon-template:update')") | ||
| 43 | + public CommonResult<Boolean> updateCouponTemplate(@Valid @RequestBody CouponTemplateUpdateReqVO updateReqVO) { | ||
| 44 | + couponTemplateService.updateCouponTemplate(updateReqVO); | ||
| 45 | + return success(true); | ||
| 46 | + } | ||
| 47 | + | ||
| 48 | + @DeleteMapping("/delete") | ||
| 49 | + @ApiOperation("删除优惠劵模板") | ||
| 50 | + @ApiImplicitParam(name = "id", value = "编号", required = true, dataTypeClass = Long.class) | ||
| 51 | + @PreAuthorize("@ss.hasPermission('promotion:coupon-template:delete')") | ||
| 52 | + public CommonResult<Boolean> deleteCouponTemplate(@RequestParam("id") Long id) { | ||
| 53 | + couponTemplateService.deleteCouponTemplate(id); | ||
| 54 | + return success(true); | ||
| 55 | + } | ||
| 56 | + | ||
| 57 | + @GetMapping("/get") | ||
| 58 | + @ApiOperation("获得优惠劵模板") | ||
| 59 | + @ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class) | ||
| 60 | + @PreAuthorize("@ss.hasPermission('promotion:coupon-template:query')") | ||
| 61 | + public CommonResult<CouponTemplateRespVO> getCouponTemplate(@RequestParam("id") Long id) { | ||
| 62 | + CouponTemplateDO couponTemplate = couponTemplateService.getCouponTemplate(id); | ||
| 63 | + return success(CouponTemplateConvert.INSTANCE.convert(couponTemplate)); | ||
| 64 | + } | ||
| 65 | + | ||
| 66 | + @GetMapping("/page") | ||
| 67 | + @ApiOperation("获得优惠劵模板分页") | ||
| 68 | + @PreAuthorize("@ss.hasPermission('promotion:coupon-template:query')") | ||
| 69 | + public CommonResult<PageResult<CouponTemplateRespVO>> getCouponTemplatePage(@Valid CouponTemplatePageReqVO pageVO) { | ||
| 70 | + PageResult<CouponTemplateDO> pageResult = couponTemplateService.getCouponTemplatePage(pageVO); | ||
| 71 | + return success(CouponTemplateConvert.INSTANCE.convertPage(pageResult)); | ||
| 72 | + } | ||
| 73 | + | ||
| 74 | +} |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/CouponTemplateBaseVO.java
0 → 100755
| 1 | +package cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo; | ||
| 2 | + | ||
| 3 | +import cn.hutool.core.collection.CollUtil; | ||
| 4 | +import cn.hutool.core.util.ObjectUtil; | ||
| 5 | +import cn.iocoder.yudao.framework.common.validation.InEnum; | ||
| 6 | +import cn.iocoder.yudao.module.promotion.enums.common.PromotionDiscountTypeEnum; | ||
| 7 | +import cn.iocoder.yudao.module.promotion.enums.common.PromotionProductScopeEnum; | ||
| 8 | +import cn.iocoder.yudao.module.promotion.enums.coupon.CouponTemplateValidityTypeEnum; | ||
| 9 | +import com.fasterxml.jackson.annotation.JsonIgnore; | ||
| 10 | +import io.swagger.annotations.ApiModelProperty; | ||
| 11 | +import lombok.Data; | ||
| 12 | +import org.springframework.format.annotation.DateTimeFormat; | ||
| 13 | + | ||
| 14 | +import javax.validation.constraints.AssertTrue; | ||
| 15 | +import javax.validation.constraints.Min; | ||
| 16 | +import javax.validation.constraints.NotNull; | ||
| 17 | +import java.util.Date; | ||
| 18 | +import java.util.List; | ||
| 19 | +import java.util.Objects; | ||
| 20 | + | ||
| 21 | +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; | ||
| 22 | + | ||
| 23 | +/** | ||
| 24 | +* 优惠劵模板 Base VO,提供给添加、修改、详细的子 VO 使用 | ||
| 25 | +* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 | ||
| 26 | +*/ | ||
| 27 | +@Data | ||
| 28 | +public class CouponTemplateBaseVO { | ||
| 29 | + | ||
| 30 | + @ApiModelProperty(value = "优惠劵名", required = true, example = "春节送送送") | ||
| 31 | + @NotNull(message = "优惠劵名不能为空") | ||
| 32 | + private String name; | ||
| 33 | + | ||
| 34 | + @ApiModelProperty(value = "发行总量", required = true, example = "1024", notes = "-1 - 则表示不限制发放数量") | ||
| 35 | + @NotNull(message = "发行总量不能为空") | ||
| 36 | + private Integer totalCount; | ||
| 37 | + | ||
| 38 | + @ApiModelProperty(value = "每人限领个数", required = true, example = "66", notes = "-1 - 则表示不限制") | ||
| 39 | + @NotNull(message = "每人限领个数不能为空") | ||
| 40 | + private Integer takeLimitCount; | ||
| 41 | + | ||
| 42 | + @ApiModelProperty(value = "领取方式", required = true, example = "1", notes = "参见 CouponTakeTypeEnum 枚举类") | ||
| 43 | + @NotNull(message = "领取方式不能为空") | ||
| 44 | + private Integer takeType; | ||
| 45 | + | ||
| 46 | + @ApiModelProperty(value = "是否设置满多少金额可用", required = true, example = "100", notes = "单位:分;0 - 不限制") | ||
| 47 | + @NotNull(message = "是否设置满多少金额可用不能为空") | ||
| 48 | + private Integer usePrice; | ||
| 49 | + | ||
| 50 | + @ApiModelProperty(value = "商品范围", required = true, example = "1", notes = "参见 PromotionProductScopeEnum 枚举类") | ||
| 51 | + @NotNull(message = "商品范围不能为空") | ||
| 52 | + @InEnum(PromotionProductScopeEnum.class) | ||
| 53 | + private Integer productScope; | ||
| 54 | + | ||
| 55 | + @ApiModelProperty(value = "商品 SPU 编号的数组", example = "1,3") | ||
| 56 | + private List<Long> productSpuIds; | ||
| 57 | + | ||
| 58 | + @ApiModelProperty(value = "生效日期类型", required = true, example = "1") | ||
| 59 | + @NotNull(message = "生效日期类型不能为空") | ||
| 60 | + @InEnum(CouponTemplateValidityTypeEnum.class) | ||
| 61 | + private Integer validityType; | ||
| 62 | + | ||
| 63 | + @ApiModelProperty(value = "固定日期 - 生效开始时间") | ||
| 64 | + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | ||
| 65 | + private Date validStartTime; | ||
| 66 | + | ||
| 67 | + @ApiModelProperty(value = "固定日期 - 生效结束时间") | ||
| 68 | + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | ||
| 69 | + private Date validEndTime; | ||
| 70 | + | ||
| 71 | + @ApiModelProperty(value = "领取日期 - 开始天数") | ||
| 72 | + @Min(value = 0L, message = "开始天数必须大于 0") | ||
| 73 | + private Integer fixedStartTerm; | ||
| 74 | + | ||
| 75 | + @ApiModelProperty(value = "领取日期 - 结束天数") | ||
| 76 | + @Min(value = 1L, message = "开始天数必须大于 1") | ||
| 77 | + private Integer fixedEndTerm; | ||
| 78 | + | ||
| 79 | + @ApiModelProperty(value = "优惠类型", required = true, example = "1", notes = "参见 PromotionDiscountTypeEnum 枚举") | ||
| 80 | + @NotNull(message = "优惠类型不能为空") | ||
| 81 | + @InEnum(PromotionDiscountTypeEnum.class) | ||
| 82 | + private Integer discountType; | ||
| 83 | + | ||
| 84 | + @ApiModelProperty(value = "折扣百分比", example = "80", notes = "例如说,80% 为 80") | ||
| 85 | + @Min(value = 1) | ||
| 86 | + private Integer discountPercent; | ||
| 87 | + | ||
| 88 | + @ApiModelProperty(value = "优惠金额", example = "10", notes = "单位:分") | ||
| 89 | + @Min(value = 1) | ||
| 90 | + private Integer discountPrice; | ||
| 91 | + | ||
| 92 | + @ApiModelProperty(value = "折扣上限", example = "100", notes = "单位:分,仅在 discountType 为 PERCENT 使用") | ||
| 93 | + private Integer discountPriceLimit; | ||
| 94 | + | ||
| 95 | + @AssertTrue(message = "商品 SPU 编号的数组不能为空") | ||
| 96 | + @JsonIgnore | ||
| 97 | + public boolean isProductSpuIdsValid() { | ||
| 98 | + return Objects.equals(productScope, PromotionProductScopeEnum.ALL.getScope()) // 全部范围时,可以为空 | ||
| 99 | + || CollUtil.isNotEmpty(productSpuIds); | ||
| 100 | + } | ||
| 101 | + | ||
| 102 | + @AssertTrue(message = "生效开始时间不能为空") | ||
| 103 | + @JsonIgnore | ||
| 104 | + public boolean isValidStartTimeValid() { | ||
| 105 | + return ObjectUtil.notEqual(validityType, CouponTemplateValidityTypeEnum.DATE.getType()) | ||
| 106 | + || validStartTime != null; | ||
| 107 | + } | ||
| 108 | + | ||
| 109 | + @AssertTrue(message = "生效结束时间不能为空") | ||
| 110 | + @JsonIgnore | ||
| 111 | + public boolean isValidEndTimeValid() { | ||
| 112 | + return ObjectUtil.notEqual(validityType, CouponTemplateValidityTypeEnum.DATE.getType()) | ||
| 113 | + || validEndTime != null; | ||
| 114 | + } | ||
| 115 | + | ||
| 116 | + @AssertTrue(message = "开始天数不能为空") | ||
| 117 | + @JsonIgnore | ||
| 118 | + public boolean isFixedStartTermValid() { | ||
| 119 | + return ObjectUtil.notEqual(validityType, CouponTemplateValidityTypeEnum.TERM.getType()) | ||
| 120 | + || fixedStartTerm != null; | ||
| 121 | + } | ||
| 122 | + | ||
| 123 | + @AssertTrue(message = "结束天数不能为空") | ||
| 124 | + @JsonIgnore | ||
| 125 | + public boolean isFixedEndTermValid() { | ||
| 126 | + return ObjectUtil.notEqual(validityType, CouponTemplateValidityTypeEnum.TERM.getType()) | ||
| 127 | + || fixedEndTerm != null; | ||
| 128 | + } | ||
| 129 | + | ||
| 130 | + @AssertTrue(message = "折扣百分比不能为空") | ||
| 131 | + @JsonIgnore | ||
| 132 | + public boolean isDiscountPercentValid() { | ||
| 133 | + return ObjectUtil.notEqual(discountType, PromotionDiscountTypeEnum.PERCENT.getType()) | ||
| 134 | + || discountPercent != null; | ||
| 135 | + } | ||
| 136 | + | ||
| 137 | + @AssertTrue(message = "优惠金额不能为空") | ||
| 138 | + @JsonIgnore | ||
| 139 | + public boolean isDiscountPriceValid() { | ||
| 140 | + return ObjectUtil.notEqual(discountType, PromotionDiscountTypeEnum.PRICE.getType()) | ||
| 141 | + || discountPrice != null; | ||
| 142 | + } | ||
| 143 | + | ||
| 144 | + @AssertTrue(message = "折扣上限不能为空") | ||
| 145 | + @JsonIgnore | ||
| 146 | + public boolean isDiscountPriceLimit() { | ||
| 147 | + return ObjectUtil.notEqual(discountType, PromotionDiscountTypeEnum.PERCENT.getType()) | ||
| 148 | + || discountPriceLimit != null; | ||
| 149 | + } | ||
| 150 | + | ||
| 151 | +} |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/CouponTemplateCreateReqVO.java
0 → 100755
| 1 | +package cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo; | ||
| 2 | + | ||
| 3 | +import io.swagger.annotations.ApiModel; | ||
| 4 | +import lombok.Data; | ||
| 5 | +import lombok.EqualsAndHashCode; | ||
| 6 | +import lombok.ToString; | ||
| 7 | + | ||
| 8 | +@ApiModel("管理后台 - 优惠劵模板创建 Request VO") | ||
| 9 | +@Data | ||
| 10 | +@EqualsAndHashCode(callSuper = true) | ||
| 11 | +@ToString(callSuper = true) | ||
| 12 | +public class CouponTemplateCreateReqVO extends CouponTemplateBaseVO { | ||
| 13 | + | ||
| 14 | +} |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/CouponTemplatePageReqVO.java
0 → 100755
| 1 | +package cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageParam; | ||
| 4 | +import cn.iocoder.yudao.framework.common.validation.InEnum; | ||
| 5 | +import cn.iocoder.yudao.module.promotion.enums.common.PromotionDiscountTypeEnum; | ||
| 6 | +import io.swagger.annotations.ApiModel; | ||
| 7 | +import io.swagger.annotations.ApiModelProperty; | ||
| 8 | +import lombok.Data; | ||
| 9 | +import lombok.EqualsAndHashCode; | ||
| 10 | +import lombok.ToString; | ||
| 11 | +import org.springframework.format.annotation.DateTimeFormat; | ||
| 12 | + | ||
| 13 | +import javax.validation.constraints.NotNull; | ||
| 14 | +import java.util.Date; | ||
| 15 | + | ||
| 16 | +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; | ||
| 17 | + | ||
| 18 | +@ApiModel("管理后台 - 优惠劵模板分页 Request VO") | ||
| 19 | +@Data | ||
| 20 | +@EqualsAndHashCode(callSuper = true) | ||
| 21 | +@ToString(callSuper = true) | ||
| 22 | +public class CouponTemplatePageReqVO extends PageParam { | ||
| 23 | + | ||
| 24 | + @ApiModelProperty(value = "优惠劵名", example = "你好") | ||
| 25 | + private String name; | ||
| 26 | + | ||
| 27 | + @ApiModelProperty(value = "状态", example = "1", notes = "参见 CommonStatusEnum 枚举类") | ||
| 28 | + private Integer status; | ||
| 29 | + | ||
| 30 | + @ApiModelProperty(value = "优惠类型", example = "1", notes = "参见 PromotionDiscountTypeEnum 枚举") | ||
| 31 | + private Integer discountType; | ||
| 32 | + | ||
| 33 | + @ApiModelProperty(value = "创建时间") | ||
| 34 | + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | ||
| 35 | + private Date[] createTime; | ||
| 36 | + | ||
| 37 | +} |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/CouponTemplateRespVO.java
0 → 100755
| 1 | +package cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; | ||
| 4 | +import cn.iocoder.yudao.framework.common.validation.InEnum; | ||
| 5 | +import io.swagger.annotations.ApiModel; | ||
| 6 | +import io.swagger.annotations.ApiModelProperty; | ||
| 7 | +import lombok.Data; | ||
| 8 | +import lombok.EqualsAndHashCode; | ||
| 9 | +import lombok.ToString; | ||
| 10 | + | ||
| 11 | +import java.util.Date; | ||
| 12 | + | ||
| 13 | +@ApiModel("管理后台 - 优惠劵模板 Response VO") | ||
| 14 | +@Data | ||
| 15 | +@EqualsAndHashCode(callSuper = true) | ||
| 16 | +@ToString(callSuper = true) | ||
| 17 | +public class CouponTemplateRespVO extends CouponTemplateBaseVO { | ||
| 18 | + | ||
| 19 | + @ApiModelProperty(value = "模板编号", required = true, example = "1024") | ||
| 20 | + private Long id; | ||
| 21 | + | ||
| 22 | + @ApiModelProperty(value = "状态", required = true, example = "1") | ||
| 23 | + @InEnum(CommonStatusEnum.class) | ||
| 24 | + private Integer status; | ||
| 25 | + | ||
| 26 | + @ApiModelProperty(value = "领取优惠券的数量", required = true, example = "1024") | ||
| 27 | + private Integer takeCount; | ||
| 28 | + | ||
| 29 | + @ApiModelProperty(value = "使用优惠券的次数", required = true, example = "2048") | ||
| 30 | + private Integer useCount; | ||
| 31 | + | ||
| 32 | + @ApiModelProperty(value = "创建时间", required = true) | ||
| 33 | + private Date createTime; | ||
| 34 | + | ||
| 35 | +} |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/CouponTemplateUpdateReqVO.java
0 → 100755
| 1 | +package cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo; | ||
| 2 | + | ||
| 3 | +import io.swagger.annotations.ApiModel; | ||
| 4 | +import io.swagger.annotations.ApiModelProperty; | ||
| 5 | +import lombok.Data; | ||
| 6 | +import lombok.EqualsAndHashCode; | ||
| 7 | +import lombok.ToString; | ||
| 8 | + | ||
| 9 | +import javax.validation.constraints.NotNull; | ||
| 10 | + | ||
| 11 | +@ApiModel("管理后台 - 优惠劵模板更新 Request VO") | ||
| 12 | +@Data | ||
| 13 | +@EqualsAndHashCode(callSuper = true) | ||
| 14 | +@ToString(callSuper = true) | ||
| 15 | +public class CouponTemplateUpdateReqVO extends CouponTemplateBaseVO { | ||
| 16 | + | ||
| 17 | + @ApiModelProperty(value = "模板编号", required = true, example = "1024") | ||
| 18 | + @NotNull(message = "模板编号不能为空") | ||
| 19 | + private Long id; | ||
| 20 | + | ||
| 21 | +} |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/coupon/CouponTemplateConvert.java
0 → 100755
| 1 | +package cn.iocoder.yudao.module.promotion.convert.coupon; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 4 | +import cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.CouponTemplateCreateReqVO; | ||
| 5 | +import cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.CouponTemplateRespVO; | ||
| 6 | +import cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.CouponTemplateUpdateReqVO; | ||
| 7 | +import cn.iocoder.yudao.module.promotion.dal.dataobject.coupon.CouponTemplateDO; | ||
| 8 | +import org.mapstruct.Mapper; | ||
| 9 | +import org.mapstruct.factory.Mappers; | ||
| 10 | + | ||
| 11 | +/** | ||
| 12 | + * 优惠劵模板 Convert | ||
| 13 | + * | ||
| 14 | + * @author 芋道源码 | ||
| 15 | + */ | ||
| 16 | +@Mapper | ||
| 17 | +public interface CouponTemplateConvert { | ||
| 18 | + | ||
| 19 | + CouponTemplateConvert INSTANCE = Mappers.getMapper(CouponTemplateConvert.class); | ||
| 20 | + | ||
| 21 | + CouponTemplateDO convert(CouponTemplateCreateReqVO bean); | ||
| 22 | + | ||
| 23 | + CouponTemplateDO convert(CouponTemplateUpdateReqVO bean); | ||
| 24 | + | ||
| 25 | + CouponTemplateRespVO convert(CouponTemplateDO bean); | ||
| 26 | + | ||
| 27 | + PageResult<CouponTemplateRespVO> convertPage(PageResult<CouponTemplateDO> page); | ||
| 28 | + | ||
| 29 | +} |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/coupon/CouponDO.java
| @@ -2,24 +2,23 @@ package cn.iocoder.yudao.module.promotion.dal.dataobject.coupon; | @@ -2,24 +2,23 @@ package cn.iocoder.yudao.module.promotion.dal.dataobject.coupon; | ||
| 2 | 2 | ||
| 3 | import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; | 3 | import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; |
| 4 | import cn.iocoder.yudao.module.promotion.enums.common.PromotionProductScopeEnum; | 4 | import cn.iocoder.yudao.module.promotion.enums.common.PromotionProductScopeEnum; |
| 5 | +import com.baomidou.mybatisplus.annotation.KeySequence; | ||
| 5 | import com.baomidou.mybatisplus.annotation.TableField; | 6 | import com.baomidou.mybatisplus.annotation.TableField; |
| 6 | import com.baomidou.mybatisplus.annotation.TableName; | 7 | import com.baomidou.mybatisplus.annotation.TableName; |
| 7 | import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler; | 8 | import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler; |
| 8 | import lombok.Data; | 9 | import lombok.Data; |
| 9 | import lombok.EqualsAndHashCode; | 10 | import lombok.EqualsAndHashCode; |
| 10 | -import lombok.experimental.Accessors; | ||
| 11 | 11 | ||
| 12 | import java.util.Date; | 12 | import java.util.Date; |
| 13 | import java.util.List; | 13 | import java.util.List; |
| 14 | 14 | ||
| 15 | -// TODO 芋艿:待完善该实体 | ||
| 16 | /** | 15 | /** |
| 17 | * 优惠劵 DO | 16 | * 优惠劵 DO |
| 18 | */ | 17 | */ |
| 19 | -@TableName("coupon") | 18 | +@TableName(value = "promotion_coupon", autoResultMap = true) |
| 19 | +@KeySequence("promotion_coupo_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 | ||
| 20 | @Data | 20 | @Data |
| 21 | @EqualsAndHashCode(callSuper = true) | 21 | @EqualsAndHashCode(callSuper = true) |
| 22 | -@Accessors(chain = true) | ||
| 23 | public class CouponDO extends BaseDO { | 22 | public class CouponDO extends BaseDO { |
| 24 | 23 | ||
| 25 | // ========== 基本信息 BEGIN ========== | 24 | // ========== 基本信息 BEGIN ========== |
| @@ -28,7 +27,9 @@ public class CouponDO extends BaseDO { | @@ -28,7 +27,9 @@ public class CouponDO extends BaseDO { | ||
| 28 | */ | 27 | */ |
| 29 | private Long id; | 28 | private Long id; |
| 30 | /** | 29 | /** |
| 31 | - * 优惠劵(码)分组编号,{@link CouponTemplateDO} 的 id | 30 | + * 优惠劵模板编号 |
| 31 | + * | ||
| 32 | + * 关联 {@link CouponTemplateDO#getId()} | ||
| 32 | */ | 33 | */ |
| 33 | private Integer templateId; | 34 | private Integer templateId; |
| 34 | /** | 35 | /** |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/coupon/CouponTemplateDO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.promotion.dal.dataobject.coupon; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; | ||
| 4 | +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; | ||
| 5 | +import cn.iocoder.yudao.framework.mybatis.core.type.LongListTypeHandler; | ||
| 6 | +import cn.iocoder.yudao.module.promotion.enums.common.PromotionDiscountTypeEnum; | ||
| 7 | +import cn.iocoder.yudao.module.promotion.enums.common.PromotionProductScopeEnum; | ||
| 8 | +import cn.iocoder.yudao.module.promotion.enums.coupon.CouponTakeTypeEnum; | ||
| 9 | +import cn.iocoder.yudao.module.promotion.enums.coupon.CouponTemplateValidityTypeEnum; | ||
| 10 | +import com.baomidou.mybatisplus.annotation.KeySequence; | ||
| 11 | +import com.baomidou.mybatisplus.annotation.TableField; | ||
| 12 | +import com.baomidou.mybatisplus.annotation.TableId; | ||
| 13 | +import com.baomidou.mybatisplus.annotation.TableName; | ||
| 14 | +import lombok.Data; | ||
| 15 | +import lombok.EqualsAndHashCode; | ||
| 16 | + | ||
| 17 | +import java.util.Date; | ||
| 18 | +import java.util.List; | ||
| 19 | + | ||
| 20 | +/** | ||
| 21 | + * 优惠劵模板 DO | ||
| 22 | + * | ||
| 23 | + * 当用户领取时,会生成 {@link CouponDO} 优惠劵 | ||
| 24 | + */ | ||
| 25 | +@TableName(value = "promotion_coupon_template", autoResultMap = true) | ||
| 26 | +@KeySequence("promotion_coupon_template_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 | ||
| 27 | +@Data | ||
| 28 | +@EqualsAndHashCode(callSuper = true) | ||
| 29 | +public class CouponTemplateDO extends BaseDO { | ||
| 30 | + | ||
| 31 | + // ========== 基本信息 BEGIN ========== | ||
| 32 | + /** | ||
| 33 | + * 模板编号,自增唯一 | ||
| 34 | + */ | ||
| 35 | + @TableId | ||
| 36 | + private Long id; | ||
| 37 | + /** | ||
| 38 | + * 优惠劵名 | ||
| 39 | + */ | ||
| 40 | + private String name; | ||
| 41 | + /** | ||
| 42 | + * 状态 | ||
| 43 | + * | ||
| 44 | + * 枚举 {@link CommonStatusEnum} | ||
| 45 | + */ | ||
| 46 | + private Integer status; | ||
| 47 | + | ||
| 48 | + // ========== 基本信息 END ========== | ||
| 49 | + | ||
| 50 | + // ========== 领取规则 BEGIN ========== | ||
| 51 | + /** | ||
| 52 | + * 发放数量 | ||
| 53 | + * | ||
| 54 | + * -1 - 则表示不限制发放数量 | ||
| 55 | + */ | ||
| 56 | + private Integer totalCount; | ||
| 57 | + /** | ||
| 58 | + * 每人限领个数 | ||
| 59 | + * | ||
| 60 | + * -1 - 则表示不限制 | ||
| 61 | + */ | ||
| 62 | + private Integer takeLimitCount; | ||
| 63 | + /** | ||
| 64 | + * 领取方式 | ||
| 65 | + * | ||
| 66 | + * 枚举 {@link CouponTakeTypeEnum} | ||
| 67 | + */ | ||
| 68 | + private Integer takeType; | ||
| 69 | + // ========== 领取规则 END ========== | ||
| 70 | + | ||
| 71 | + // ========== 使用规则 BEGIN ========== | ||
| 72 | + /** | ||
| 73 | + * 是否设置满多少金额可用,单位:分 | ||
| 74 | + * | ||
| 75 | + * 0 - 不限制 | ||
| 76 | + * 大于 0 - 多少金额可用 | ||
| 77 | + */ | ||
| 78 | + private Integer usePrice; | ||
| 79 | + /** | ||
| 80 | + * 商品范围 | ||
| 81 | + * | ||
| 82 | + * 枚举 {@link PromotionProductScopeEnum} | ||
| 83 | + */ | ||
| 84 | + private Integer productScope; | ||
| 85 | + /** | ||
| 86 | + * 商品 SPU 编号的数组 | ||
| 87 | + */ | ||
| 88 | + @TableField(typeHandler = LongListTypeHandler.class) | ||
| 89 | + private List<Long> productSpuIds; | ||
| 90 | + /** | ||
| 91 | + * 生效日期类型 | ||
| 92 | + * | ||
| 93 | + * 枚举 {@link CouponTemplateValidityTypeEnum} | ||
| 94 | + */ | ||
| 95 | + private Integer validityType; | ||
| 96 | + /** | ||
| 97 | + * 固定日期 - 生效开始时间 | ||
| 98 | + * | ||
| 99 | + * 当 {@link #validityType} 为 {@link CouponTemplateValidityTypeEnum#DATE} | ||
| 100 | + */ | ||
| 101 | + private Date validStartTime; | ||
| 102 | + /** | ||
| 103 | + * 固定日期 - 生效结束时间 | ||
| 104 | + * | ||
| 105 | + * 当 {@link #validityType} 为 {@link CouponTemplateValidityTypeEnum#DATE} | ||
| 106 | + */ | ||
| 107 | + private Date validEndTime; | ||
| 108 | + /** | ||
| 109 | + * 领取日期 - 开始天数 | ||
| 110 | + * | ||
| 111 | + * 当 {@link #validityType} 为 {@link CouponTemplateValidityTypeEnum#TERM} | ||
| 112 | + */ | ||
| 113 | + private Integer fixedStartTerm; | ||
| 114 | + /** | ||
| 115 | + * 领取日期 - 结束天数 | ||
| 116 | + * | ||
| 117 | + * 当 {@link #validityType} 为 {@link CouponTemplateValidityTypeEnum#TERM} | ||
| 118 | + */ | ||
| 119 | + private Integer fixedEndTerm; | ||
| 120 | + // ========== 使用规则 END ========== | ||
| 121 | + | ||
| 122 | + // ========== 使用效果 BEGIN ========== | ||
| 123 | + /** | ||
| 124 | + * 折扣类型 | ||
| 125 | + * | ||
| 126 | + * 枚举 {@link PromotionDiscountTypeEnum} | ||
| 127 | + */ | ||
| 128 | + private Integer discountType; | ||
| 129 | + /** | ||
| 130 | + * 折扣百分比 | ||
| 131 | + * | ||
| 132 | + * 例如,80% 为 80 | ||
| 133 | + */ | ||
| 134 | + private Integer discountPercent; | ||
| 135 | + /** | ||
| 136 | + * 优惠金额,单位:分 | ||
| 137 | + * | ||
| 138 | + * 当 {@link #discountType} 为 {@link PromotionDiscountTypeEnum#PRICE} 生效 | ||
| 139 | + */ | ||
| 140 | + private Integer discountPrice; | ||
| 141 | + /** | ||
| 142 | + * 折扣上限,仅在 {@link #discountType} 等于 {@link PromotionDiscountTypeEnum#PERCENT} 时生效 | ||
| 143 | + * | ||
| 144 | + * 例如,折扣上限为 20 元,当使用 8 折优惠券,订单金额为 1000 元时,最高只可折扣 20 元,而非 80 元。 | ||
| 145 | + */ | ||
| 146 | + private Integer discountLimitPrice; | ||
| 147 | + // ========== 使用效果 END ========== | ||
| 148 | + | ||
| 149 | + // ========== 统计信息 BEGIN ========== | ||
| 150 | + /** | ||
| 151 | + * 领取优惠券的数量 | ||
| 152 | + */ | ||
| 153 | + private Integer takeCount; | ||
| 154 | + /** | ||
| 155 | + * 使用优惠券的次数 | ||
| 156 | + */ | ||
| 157 | + private Integer useCount; | ||
| 158 | + // ========== 统计信息 END ========== | ||
| 159 | + | ||
| 160 | +} |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/reward/RewardActivityDO.java
| @@ -69,7 +69,7 @@ public class RewardActivityDO extends BaseDO { | @@ -69,7 +69,7 @@ public class RewardActivityDO extends BaseDO { | ||
| 69 | * 商品 SPU 编号的数组 | 69 | * 商品 SPU 编号的数组 |
| 70 | */ | 70 | */ |
| 71 | @TableField(typeHandler = JacksonTypeHandler.class) | 71 | @TableField(typeHandler = JacksonTypeHandler.class) |
| 72 | - private List<Long> spuIds; | 72 | + private List<Long> productSpuIds; |
| 73 | /** | 73 | /** |
| 74 | * 优惠规则的数组 | 74 | * 优惠规则的数组 |
| 75 | */ | 75 | */ |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/coupon/CouponTemplateMapper.java
0 → 100755
| 1 | +package cn.iocoder.yudao.module.promotion.dal.mysql.coupon; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 4 | +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; | ||
| 5 | +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; | ||
| 6 | +import cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.CouponTemplatePageReqVO; | ||
| 7 | +import cn.iocoder.yudao.module.promotion.dal.dataobject.coupon.CouponTemplateDO; | ||
| 8 | +import org.apache.ibatis.annotations.Mapper; | ||
| 9 | + | ||
| 10 | +/** | ||
| 11 | + * 优惠劵模板 Mapper | ||
| 12 | + * | ||
| 13 | + * @author 芋道源码 | ||
| 14 | + */ | ||
| 15 | +@Mapper | ||
| 16 | +public interface CouponTemplateMapper extends BaseMapperX<CouponTemplateDO> { | ||
| 17 | + | ||
| 18 | + default PageResult<CouponTemplateDO> selectPage(CouponTemplatePageReqVO reqVO) { | ||
| 19 | + return selectPage(reqVO, new LambdaQueryWrapperX<CouponTemplateDO>() | ||
| 20 | + .likeIfPresent(CouponTemplateDO::getName, reqVO.getName()) | ||
| 21 | + .eqIfPresent(CouponTemplateDO::getStatus, reqVO.getStatus()) | ||
| 22 | + .eqIfPresent(CouponTemplateDO::getDiscountType, reqVO.getDiscountType()) | ||
| 23 | + .betweenIfPresent(CouponTemplateDO::getCreateTime, reqVO.getCreateTime()) | ||
| 24 | + .orderByDesc(CouponTemplateDO::getId)); | ||
| 25 | + } | ||
| 26 | + | ||
| 27 | +} |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/coupon/CouponTemplateService.java
0 → 100755
| 1 | +package cn.iocoder.yudao.module.promotion.service.coupon; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 4 | +import cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.CouponTemplateCreateReqVO; | ||
| 5 | +import cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.CouponTemplatePageReqVO; | ||
| 6 | +import cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.CouponTemplateUpdateReqVO; | ||
| 7 | +import cn.iocoder.yudao.module.promotion.dal.dataobject.coupon.CouponTemplateDO; | ||
| 8 | + | ||
| 9 | +import javax.validation.Valid; | ||
| 10 | + | ||
| 11 | +/** | ||
| 12 | + * 优惠劵模板 Service 接口 | ||
| 13 | + * | ||
| 14 | + * @author 芋道源码 | ||
| 15 | + */ | ||
| 16 | +public interface CouponTemplateService { | ||
| 17 | + | ||
| 18 | + /** | ||
| 19 | + * 创建优惠劵模板 | ||
| 20 | + * | ||
| 21 | + * @param createReqVO 创建信息 | ||
| 22 | + * @return 编号 | ||
| 23 | + */ | ||
| 24 | + Long createCouponTemplate(@Valid CouponTemplateCreateReqVO createReqVO); | ||
| 25 | + | ||
| 26 | + /** | ||
| 27 | + * 更新优惠劵模板 | ||
| 28 | + * | ||
| 29 | + * @param updateReqVO 更新信息 | ||
| 30 | + */ | ||
| 31 | + void updateCouponTemplate(@Valid CouponTemplateUpdateReqVO updateReqVO); | ||
| 32 | + | ||
| 33 | + /** | ||
| 34 | + * 删除优惠劵模板 | ||
| 35 | + * | ||
| 36 | + * @param id 编号 | ||
| 37 | + */ | ||
| 38 | + void deleteCouponTemplate(Long id); | ||
| 39 | + | ||
| 40 | + /** | ||
| 41 | + * 获得优惠劵模板 | ||
| 42 | + * | ||
| 43 | + * @param id 编号 | ||
| 44 | + * @return 优惠劵模板 | ||
| 45 | + */ | ||
| 46 | + CouponTemplateDO getCouponTemplate(Long id); | ||
| 47 | + | ||
| 48 | + /** | ||
| 49 | + * 获得优惠劵模板分页 | ||
| 50 | + * | ||
| 51 | + * @param pageReqVO 分页查询 | ||
| 52 | + * @return 优惠劵模板分页 | ||
| 53 | + */ | ||
| 54 | + PageResult<CouponTemplateDO> getCouponTemplatePage(CouponTemplatePageReqVO pageReqVO); | ||
| 55 | + | ||
| 56 | +} |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/coupon/CouponTemplateServiceImpl.java
0 → 100755
| 1 | +package cn.iocoder.yudao.module.promotion.service.coupon; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 4 | +import cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.CouponTemplateCreateReqVO; | ||
| 5 | +import cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.CouponTemplatePageReqVO; | ||
| 6 | +import cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.CouponTemplateUpdateReqVO; | ||
| 7 | +import cn.iocoder.yudao.module.promotion.convert.coupon.CouponTemplateConvert; | ||
| 8 | +import cn.iocoder.yudao.module.promotion.dal.dataobject.coupon.CouponTemplateDO; | ||
| 9 | +import cn.iocoder.yudao.module.promotion.dal.mysql.coupon.CouponTemplateMapper; | ||
| 10 | +import org.springframework.stereotype.Service; | ||
| 11 | +import org.springframework.validation.annotation.Validated; | ||
| 12 | + | ||
| 13 | +import javax.annotation.Resource; | ||
| 14 | + | ||
| 15 | +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | ||
| 16 | +import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.*; | ||
| 17 | + | ||
| 18 | +/** | ||
| 19 | + * 优惠劵模板 Service 实现类 | ||
| 20 | + * | ||
| 21 | + * @author 芋道源码 | ||
| 22 | + */ | ||
| 23 | +@Service | ||
| 24 | +@Validated | ||
| 25 | +public class CouponTemplateServiceImpl implements CouponTemplateService { | ||
| 26 | + | ||
| 27 | + @Resource | ||
| 28 | + private CouponTemplateMapper couponTemplateMapper; | ||
| 29 | + | ||
| 30 | + @Override | ||
| 31 | + public Long createCouponTemplate(CouponTemplateCreateReqVO createReqVO) { | ||
| 32 | + // 插入 | ||
| 33 | + CouponTemplateDO couponTemplate = CouponTemplateConvert.INSTANCE.convert(createReqVO); | ||
| 34 | + couponTemplateMapper.insert(couponTemplate); | ||
| 35 | + // 返回 | ||
| 36 | + return couponTemplate.getId(); | ||
| 37 | + } | ||
| 38 | + | ||
| 39 | + @Override | ||
| 40 | + public void updateCouponTemplate(CouponTemplateUpdateReqVO updateReqVO) { | ||
| 41 | + // 校验存在 | ||
| 42 | + CouponTemplateDO couponTemplate = validateCouponTemplateExists(updateReqVO.getId()); | ||
| 43 | + // 校验发放数量不能过小 | ||
| 44 | + if (updateReqVO.getTotalCount() < couponTemplate.getTakeCount()) { | ||
| 45 | + throw exception(COUPON_TEMPLATE_TOTAL_COUNT_TOO_SMALL, couponTemplate.getTakeCount()); | ||
| 46 | + } | ||
| 47 | + | ||
| 48 | + // 更新 | ||
| 49 | + CouponTemplateDO updateObj = CouponTemplateConvert.INSTANCE.convert(updateReqVO); | ||
| 50 | + couponTemplateMapper.updateById(updateObj); | ||
| 51 | + } | ||
| 52 | + | ||
| 53 | + @Override | ||
| 54 | + public void deleteCouponTemplate(Long id) { | ||
| 55 | + // 校验存在 | ||
| 56 | + validateCouponTemplateExists(id); | ||
| 57 | + // 删除 | ||
| 58 | + couponTemplateMapper.deleteById(id); | ||
| 59 | + } | ||
| 60 | + | ||
| 61 | + private CouponTemplateDO validateCouponTemplateExists(Long id) { | ||
| 62 | + CouponTemplateDO couponTemplate = couponTemplateMapper.selectById(id); | ||
| 63 | + if (couponTemplate == null) { | ||
| 64 | + throw exception(COUPON_TEMPLATE_NOT_EXISTS); | ||
| 65 | + } | ||
| 66 | + return couponTemplate; | ||
| 67 | + } | ||
| 68 | + | ||
| 69 | + @Override | ||
| 70 | + public CouponTemplateDO getCouponTemplate(Long id) { | ||
| 71 | + return couponTemplateMapper.selectById(id); | ||
| 72 | + } | ||
| 73 | + | ||
| 74 | + @Override | ||
| 75 | + public PageResult<CouponTemplateDO> getCouponTemplatePage(CouponTemplatePageReqVO pageReqVO) { | ||
| 76 | + return couponTemplateMapper.selectPage(pageReqVO); | ||
| 77 | + } | ||
| 78 | + | ||
| 79 | +} |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/price/PriceServiceImpl.java
| @@ -114,24 +114,24 @@ public class PriceServiceImpl implements PriceService { | @@ -114,24 +114,24 @@ public class PriceServiceImpl implements PriceService { | ||
| 114 | */ | 114 | */ |
| 115 | private void calculatePriceForSkuLevel(Long userId, PriceCalculateRespDTO priceCalculate) { | 115 | private void calculatePriceForSkuLevel(Long userId, PriceCalculateRespDTO priceCalculate) { |
| 116 | // 获取 SKU 级别的所有优惠信息 | 116 | // 获取 SKU 级别的所有优惠信息 |
| 117 | - Supplier<Double> memberDiscountSupplier = getMemberDiscountSupplier(userId); | 117 | + Supplier<Double> memberDiscountPercentSupplier = getMemberDiscountPercentSupplier(userId); |
| 118 | Map<Long, DiscountProductDO> discountProducts = discountService.getMatchDiscountProducts( | 118 | Map<Long, DiscountProductDO> discountProducts = discountService.getMatchDiscountProducts( |
| 119 | convertSet(priceCalculate.getOrder().getItems(), PriceCalculateRespDTO.OrderItem::getSkuId)); | 119 | convertSet(priceCalculate.getOrder().getItems(), PriceCalculateRespDTO.OrderItem::getSkuId)); |
| 120 | 120 | ||
| 121 | // 处理每个 SKU 的优惠 | 121 | // 处理每个 SKU 的优惠 |
| 122 | priceCalculate.getOrder().getItems().forEach(orderItem -> { | 122 | priceCalculate.getOrder().getItems().forEach(orderItem -> { |
| 123 | // 获取该 SKU 的优惠信息 | 123 | // 获取该 SKU 的优惠信息 |
| 124 | - Double memberDiscount = memberDiscountSupplier.get(); | 124 | + Double memberDiscountPercent = memberDiscountPercentSupplier.get(); |
| 125 | DiscountProductDO discountProduct = discountProducts.get(orderItem.getSkuId()); | 125 | DiscountProductDO discountProduct = discountProducts.get(orderItem.getSkuId()); |
| 126 | if (discountProduct != null // 假设优惠价格更贵,则认为没优惠 | 126 | if (discountProduct != null // 假设优惠价格更贵,则认为没优惠 |
| 127 | && discountProduct.getPromotionPrice() >= orderItem.getOriginalUnitPrice()) { | 127 | && discountProduct.getPromotionPrice() >= orderItem.getOriginalUnitPrice()) { |
| 128 | discountProduct = null; | 128 | discountProduct = null; |
| 129 | } | 129 | } |
| 130 | - if (memberDiscount == null && discountProduct == null) { | 130 | + if (memberDiscountPercent == null && discountProduct == null) { |
| 131 | return; | 131 | return; |
| 132 | } | 132 | } |
| 133 | // 计算价格,判断选择哪个折扣 | 133 | // 计算价格,判断选择哪个折扣 |
| 134 | - Integer memberPrice = memberDiscount != null ? (int) (orderItem.getPayPrice() * memberDiscount / 100) : null; | 134 | + Integer memberPrice = memberDiscountPercent != null ? (int) (orderItem.getPayPrice() * memberDiscountPercent / 100) : null; |
| 135 | Integer promotionPrice = discountProduct != null ? discountProduct.getPromotionPrice() * orderItem.getCount() : null; | 135 | Integer promotionPrice = discountProduct != null ? discountProduct.getPromotionPrice() * orderItem.getCount() : null; |
| 136 | if (memberPrice == null) { | 136 | if (memberPrice == null) { |
| 137 | calculatePriceByDiscountActivity(priceCalculate, orderItem, discountProduct, promotionPrice); | 137 | calculatePriceByDiscountActivity(priceCalculate, orderItem, discountProduct, promotionPrice); |
| @@ -166,7 +166,7 @@ public class PriceServiceImpl implements PriceService { | @@ -166,7 +166,7 @@ public class PriceServiceImpl implements PriceService { | ||
| 166 | } | 166 | } |
| 167 | 167 | ||
| 168 | // TODO 芋艿:提前实现 | 168 | // TODO 芋艿:提前实现 |
| 169 | - private Supplier<Double> getMemberDiscountSupplier(Long userId) { | 169 | + private Supplier<Double> getMemberDiscountPercentSupplier(Long userId) { |
| 170 | return Suppliers.memoize(() -> { | 170 | return Suppliers.memoize(() -> { |
| 171 | if (userId == 1) { | 171 | if (userId == 1) { |
| 172 | return 90d; | 172 | return 90d; |
yudao-module-mall/yudao-module-promotion-biz/src/test/java/cn/iocoder/yudao/module/promotion/service/coupon/CouponTemplateServiceImplTest.java
0 → 100755
| 1 | +package cn.iocoder.yudao.module.promotion.service.coupon; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 4 | +import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; | ||
| 5 | +import cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.CouponTemplateCreateReqVO; | ||
| 6 | +import cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.CouponTemplatePageReqVO; | ||
| 7 | +import cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.CouponTemplateUpdateReqVO; | ||
| 8 | +import cn.iocoder.yudao.module.promotion.dal.dataobject.coupon.CouponTemplateDO; | ||
| 9 | +import cn.iocoder.yudao.module.promotion.dal.mysql.coupon.CouponTemplateMapper; | ||
| 10 | +import org.junit.jupiter.api.Disabled; | ||
| 11 | +import org.junit.jupiter.api.Test; | ||
| 12 | +import org.springframework.context.annotation.Import; | ||
| 13 | + | ||
| 14 | +import javax.annotation.Resource; | ||
| 15 | +import java.util.Date; | ||
| 16 | + | ||
| 17 | +import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; | ||
| 18 | +import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; | ||
| 19 | +import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; | ||
| 20 | +import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomLongId; | ||
| 21 | +import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; | ||
| 22 | +import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.COUPON_TEMPLATE_NOT_EXISTS; | ||
| 23 | +import static org.junit.jupiter.api.Assertions.*; | ||
| 24 | + | ||
| 25 | +/** | ||
| 26 | +* {@link CouponTemplateServiceImpl} 的单元测试类 | ||
| 27 | +* | ||
| 28 | +* @author 芋道源码 | ||
| 29 | +*/ | ||
| 30 | +@Import(CouponTemplateServiceImpl.class) | ||
| 31 | +public class CouponTemplateServiceImplTest extends BaseDbUnitTest { | ||
| 32 | + | ||
| 33 | + @Resource | ||
| 34 | + private CouponTemplateServiceImpl couponTemplateService; | ||
| 35 | + | ||
| 36 | + @Resource | ||
| 37 | + private CouponTemplateMapper couponTemplateMapper; | ||
| 38 | + | ||
| 39 | + @Test | ||
| 40 | + public void testCreateCouponTemplate_success() { | ||
| 41 | + // 准备参数 | ||
| 42 | + CouponTemplateCreateReqVO reqVO = randomPojo(CouponTemplateCreateReqVO.class); | ||
| 43 | + | ||
| 44 | + // 调用 | ||
| 45 | + Long couponTemplateId = couponTemplateService.createCouponTemplate(reqVO); | ||
| 46 | + // 断言 | ||
| 47 | + assertNotNull(couponTemplateId); | ||
| 48 | + // 校验记录的属性是否正确 | ||
| 49 | + CouponTemplateDO couponTemplate = couponTemplateMapper.selectById(couponTemplateId); | ||
| 50 | + assertPojoEquals(reqVO, couponTemplate); | ||
| 51 | + } | ||
| 52 | + | ||
| 53 | + @Test | ||
| 54 | + public void testUpdateCouponTemplate_success() { | ||
| 55 | + // mock 数据 | ||
| 56 | + CouponTemplateDO dbCouponTemplate = randomPojo(CouponTemplateDO.class); | ||
| 57 | + couponTemplateMapper.insert(dbCouponTemplate);// @Sql: 先插入出一条存在的数据 | ||
| 58 | + // 准备参数 | ||
| 59 | + CouponTemplateUpdateReqVO reqVO = randomPojo(CouponTemplateUpdateReqVO.class, o -> { | ||
| 60 | + o.setId(dbCouponTemplate.getId()); // 设置更新的 ID | ||
| 61 | + }); | ||
| 62 | + | ||
| 63 | + // 调用 | ||
| 64 | + couponTemplateService.updateCouponTemplate(reqVO); | ||
| 65 | + // 校验是否更新正确 | ||
| 66 | + CouponTemplateDO couponTemplate = couponTemplateMapper.selectById(reqVO.getId()); // 获取最新的 | ||
| 67 | + assertPojoEquals(reqVO, couponTemplate); | ||
| 68 | + } | ||
| 69 | + | ||
| 70 | + @Test | ||
| 71 | + public void testUpdateCouponTemplate_notExists() { | ||
| 72 | + // 准备参数 | ||
| 73 | + CouponTemplateUpdateReqVO reqVO = randomPojo(CouponTemplateUpdateReqVO.class); | ||
| 74 | + | ||
| 75 | + // 调用, 并断言异常 | ||
| 76 | + assertServiceException(() -> couponTemplateService.updateCouponTemplate(reqVO), COUPON_TEMPLATE_NOT_EXISTS); | ||
| 77 | + } | ||
| 78 | + | ||
| 79 | + @Test | ||
| 80 | + public void testDeleteCouponTemplate_success() { | ||
| 81 | + // mock 数据 | ||
| 82 | + CouponTemplateDO dbCouponTemplate = randomPojo(CouponTemplateDO.class); | ||
| 83 | + couponTemplateMapper.insert(dbCouponTemplate);// @Sql: 先插入出一条存在的数据 | ||
| 84 | + // 准备参数 | ||
| 85 | + Long id = dbCouponTemplate.getId(); | ||
| 86 | + | ||
| 87 | + // 调用 | ||
| 88 | + couponTemplateService.deleteCouponTemplate(id); | ||
| 89 | + // 校验数据不存在了 | ||
| 90 | + assertNull(couponTemplateMapper.selectById(id)); | ||
| 91 | + } | ||
| 92 | + | ||
| 93 | + @Test | ||
| 94 | + public void testDeleteCouponTemplate_notExists() { | ||
| 95 | + // 准备参数 | ||
| 96 | + Long id = randomLongId(); | ||
| 97 | + | ||
| 98 | + // 调用, 并断言异常 | ||
| 99 | + assertServiceException(() -> couponTemplateService.deleteCouponTemplate(id), COUPON_TEMPLATE_NOT_EXISTS); | ||
| 100 | + } | ||
| 101 | + | ||
| 102 | + @Test | ||
| 103 | + @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 | ||
| 104 | + public void testGetCouponTemplatePage() { | ||
| 105 | + // mock 数据 | ||
| 106 | + CouponTemplateDO dbCouponTemplate = randomPojo(CouponTemplateDO.class, o -> { // 等会查询到 | ||
| 107 | + o.setName(null); | ||
| 108 | + o.setStatus(null); | ||
| 109 | + o.setDiscountType(null); | ||
| 110 | + o.setCreateTime(null); | ||
| 111 | + }); | ||
| 112 | + couponTemplateMapper.insert(dbCouponTemplate); | ||
| 113 | + // 测试 name 不匹配 | ||
| 114 | + couponTemplateMapper.insert(cloneIgnoreId(dbCouponTemplate, o -> o.setName(null))); | ||
| 115 | + // 测试 status 不匹配 | ||
| 116 | + couponTemplateMapper.insert(cloneIgnoreId(dbCouponTemplate, o -> o.setStatus(null))); | ||
| 117 | + // 测试 type 不匹配 | ||
| 118 | + couponTemplateMapper.insert(cloneIgnoreId(dbCouponTemplate, o -> o.setDiscountType(null))); | ||
| 119 | + // 测试 createTime 不匹配 | ||
| 120 | + couponTemplateMapper.insert(cloneIgnoreId(dbCouponTemplate, o -> o.setCreateTime(null))); | ||
| 121 | + // 准备参数 | ||
| 122 | + CouponTemplatePageReqVO reqVO = new CouponTemplatePageReqVO(); | ||
| 123 | + reqVO.setName(null); | ||
| 124 | + reqVO.setStatus(null); | ||
| 125 | + reqVO.setDiscountType(null); | ||
| 126 | + reqVO.setCreateTime((new Date[]{})); | ||
| 127 | + | ||
| 128 | + // 调用 | ||
| 129 | + PageResult<CouponTemplateDO> pageResult = couponTemplateService.getCouponTemplatePage(reqVO); | ||
| 130 | + // 断言 | ||
| 131 | + assertEquals(1, pageResult.getTotal()); | ||
| 132 | + assertEquals(1, pageResult.getList().size()); | ||
| 133 | + assertPojoEquals(dbCouponTemplate, pageResult.getList().get(0)); | ||
| 134 | + } | ||
| 135 | + | ||
| 136 | +} |
yudao-module-mall/yudao-module-promotion-biz/src/test/java/cn/iocoder/yudao/module/promotion/service/price/PriceServiceTest.java
| @@ -198,10 +198,10 @@ public class PriceServiceTest extends BaseMockitoUnitTest { | @@ -198,10 +198,10 @@ public class PriceServiceTest extends BaseMockitoUnitTest { | ||
| 198 | when(productSkuApi.getSkuList(eq(asSet(10L, 20L, 30L)))).thenReturn(asList(productSku01, productSku02, productSku03)); | 198 | when(productSkuApi.getSkuList(eq(asSet(10L, 20L, 30L)))).thenReturn(asList(productSku01, productSku02, productSku03)); |
| 199 | // mock 方法(限时折扣 DiscountActivity 信息) | 199 | // mock 方法(限时折扣 DiscountActivity 信息) |
| 200 | RewardActivityDO rewardActivity01 = randomPojo(RewardActivityDO.class, o -> o.setId(1000L).setName("活动 1000 号") | 200 | RewardActivityDO rewardActivity01 = randomPojo(RewardActivityDO.class, o -> o.setId(1000L).setName("活动 1000 号") |
| 201 | - .setSpuIds(asList(10L, 20L)).setConditionType(PromotionConditionTypeEnum.PRICE.getType()) | 201 | + .setProductSpuIds(asList(10L, 20L)).setConditionType(PromotionConditionTypeEnum.PRICE.getType()) |
| 202 | .setRules(singletonList(new RewardActivityDO.Rule().setLimit(200).setDiscountPrice(70)))); | 202 | .setRules(singletonList(new RewardActivityDO.Rule().setLimit(200).setDiscountPrice(70)))); |
| 203 | RewardActivityDO rewardActivity02 = randomPojo(RewardActivityDO.class, o -> o.setId(2000L).setName("活动 2000 号") | 203 | RewardActivityDO rewardActivity02 = randomPojo(RewardActivityDO.class, o -> o.setId(2000L).setName("活动 2000 号") |
| 204 | - .setSpuIds(singletonList(30L)).setConditionType(PromotionConditionTypeEnum.COUNT.getType()) | 204 | + .setProductSpuIds(singletonList(30L)).setConditionType(PromotionConditionTypeEnum.COUNT.getType()) |
| 205 | .setRules(asList(new RewardActivityDO.Rule().setLimit(1).setDiscountPrice(10), | 205 | .setRules(asList(new RewardActivityDO.Rule().setLimit(1).setDiscountPrice(10), |
| 206 | new RewardActivityDO.Rule().setLimit(2).setDiscountPrice(60), // 最大可满足,因为是 4 个 | 206 | new RewardActivityDO.Rule().setLimit(2).setDiscountPrice(60), // 最大可满足,因为是 4 个 |
| 207 | new RewardActivityDO.Rule().setLimit(10).setDiscountPrice(100)))); | 207 | new RewardActivityDO.Rule().setLimit(10).setDiscountPrice(100)))); |
| @@ -301,7 +301,7 @@ public class PriceServiceTest extends BaseMockitoUnitTest { | @@ -301,7 +301,7 @@ public class PriceServiceTest extends BaseMockitoUnitTest { | ||
| 301 | when(productSkuApi.getSkuList(eq(asSet(10L, 20L)))).thenReturn(asList(productSku01, productSku02)); | 301 | when(productSkuApi.getSkuList(eq(asSet(10L, 20L)))).thenReturn(asList(productSku01, productSku02)); |
| 302 | // mock 方法(限时折扣 DiscountActivity 信息) | 302 | // mock 方法(限时折扣 DiscountActivity 信息) |
| 303 | RewardActivityDO rewardActivity01 = randomPojo(RewardActivityDO.class, o -> o.setId(1000L).setName("活动 1000 号") | 303 | RewardActivityDO rewardActivity01 = randomPojo(RewardActivityDO.class, o -> o.setId(1000L).setName("活动 1000 号") |
| 304 | - .setSpuIds(asList(10L, 20L)).setConditionType(PromotionConditionTypeEnum.PRICE.getType()) | 304 | + .setProductSpuIds(asList(10L, 20L)).setConditionType(PromotionConditionTypeEnum.PRICE.getType()) |
| 305 | .setRules(singletonList(new RewardActivityDO.Rule().setLimit(351).setDiscountPrice(70)))); | 305 | .setRules(singletonList(new RewardActivityDO.Rule().setLimit(351).setDiscountPrice(70)))); |
| 306 | Map<RewardActivityDO, Set<Long>> matchRewardActivities = new LinkedHashMap<>(); | 306 | Map<RewardActivityDO, Set<Long>> matchRewardActivities = new LinkedHashMap<>(); |
| 307 | matchRewardActivities.put(rewardActivity01, asSet(1L, 2L)); | 307 | matchRewardActivities.put(rewardActivity01, asSet(1L, 2L)); |
yudao-ui-admin/src/api/promotion/couponTemplate.js
0 → 100755
| 1 | +import request from '@/utils/request' | ||
| 2 | + | ||
| 3 | +// 创建优惠劵模板 | ||
| 4 | +export function createCouponTemplate(data) { | ||
| 5 | + return request({ | ||
| 6 | + url: '/promotion/coupon-template/create', | ||
| 7 | + method: 'post', | ||
| 8 | + data: data | ||
| 9 | + }) | ||
| 10 | +} | ||
| 11 | + | ||
| 12 | +// 更新优惠劵模板 | ||
| 13 | +export function updateCouponTemplate(data) { | ||
| 14 | + return request({ | ||
| 15 | + url: '/promotion/coupon-template/update', | ||
| 16 | + method: 'put', | ||
| 17 | + data: data | ||
| 18 | + }) | ||
| 19 | +} | ||
| 20 | + | ||
| 21 | +// 删除优惠劵模板 | ||
| 22 | +export function deleteCouponTemplate(id) { | ||
| 23 | + return request({ | ||
| 24 | + url: '/promotion/coupon-template/delete?id=' + id, | ||
| 25 | + method: 'delete' | ||
| 26 | + }) | ||
| 27 | +} | ||
| 28 | + | ||
| 29 | +// 获得优惠劵模板 | ||
| 30 | +export function getCouponTemplate(id) { | ||
| 31 | + return request({ | ||
| 32 | + url: '/promotion/coupon-template/get?id=' + id, | ||
| 33 | + method: 'get' | ||
| 34 | + }) | ||
| 35 | +} | ||
| 36 | + | ||
| 37 | +// 获得优惠劵模板分页 | ||
| 38 | +export function getCouponTemplatePage(query) { | ||
| 39 | + return request({ | ||
| 40 | + url: '/promotion/coupon-template/page', | ||
| 41 | + method: 'get', | ||
| 42 | + params: query | ||
| 43 | + }) | ||
| 44 | +} | ||
| 45 | + | ||
| 46 | +// 导出优惠劵模板 Excel | ||
| 47 | +export function exportCouponTemplateExcel(query) { | ||
| 48 | + return request({ | ||
| 49 | + url: '/promotion/coupon-template/export-excel', | ||
| 50 | + method: 'get', | ||
| 51 | + params: query, | ||
| 52 | + responseType: 'blob' | ||
| 53 | + }) | ||
| 54 | +} |
yudao-ui-admin/src/utils/constants.js
| @@ -236,3 +236,45 @@ export const ProductSpuStatusEnum = { | @@ -236,3 +236,45 @@ export const ProductSpuStatusEnum = { | ||
| 236 | name: '上架' | 236 | name: '上架' |
| 237 | }, | 237 | }, |
| 238 | } | 238 | } |
| 239 | + | ||
| 240 | +/** | ||
| 241 | + * 优惠类型枚举 | ||
| 242 | + */ | ||
| 243 | +export const PromotionDiscountTypeEnum = { | ||
| 244 | + PRICE: { | ||
| 245 | + type: 1, | ||
| 246 | + name: '满减' | ||
| 247 | + }, | ||
| 248 | + PERCENT: { | ||
| 249 | + type: 2, | ||
| 250 | + name: '折扣' | ||
| 251 | + } | ||
| 252 | +} | ||
| 253 | + | ||
| 254 | +/** | ||
| 255 | + * 优惠劵模板的有限期类型的枚举 | ||
| 256 | + */ | ||
| 257 | +export const CouponTemplateValidityTypeEnum = { | ||
| 258 | + DATE: { | ||
| 259 | + type: 1, | ||
| 260 | + name: '固定日期可用' | ||
| 261 | + }, | ||
| 262 | + TERM: { | ||
| 263 | + type: 2, | ||
| 264 | + name: '领取之后可用' | ||
| 265 | + } | ||
| 266 | +} | ||
| 267 | + | ||
| 268 | +/** | ||
| 269 | + * 营销的商品范围枚举 | ||
| 270 | + */ | ||
| 271 | +export const PromotionProductScopeEnum = { | ||
| 272 | + ALL: { | ||
| 273 | + scope: 1, | ||
| 274 | + name: '全部商品参与' | ||
| 275 | + }, | ||
| 276 | + SPU: { | ||
| 277 | + scope: 2, | ||
| 278 | + name: '指定商品参与' | ||
| 279 | + } | ||
| 280 | +} |
yudao-ui-admin/src/utils/dict.js
| @@ -59,6 +59,11 @@ export const DICT_TYPE = { | @@ -59,6 +59,11 @@ export const DICT_TYPE = { | ||
| 59 | 59 | ||
| 60 | // ========== MALL - PRODUCT 模块 ========== | 60 | // ========== MALL - PRODUCT 模块 ========== |
| 61 | PRODUCT_SPU_STATUS: 'product_spu_status', // 商品 SPU 状态 | 61 | PRODUCT_SPU_STATUS: 'product_spu_status', // 商品 SPU 状态 |
| 62 | + | ||
| 63 | + // ========== MALL - PROMOTION 模块 ========== | ||
| 64 | + PROMOTION_DISCOUNT_TYPE: 'promotion_discount_type', // 优惠类型 | ||
| 65 | + PROMOTION_PRODUCT_SCOPE: 'promotion_product_scope', // 营销的商品范围 | ||
| 66 | + COUPON_TEMPLATE_VALIDITY_TYPE: 'coupon_template_validity_type', // 优惠劵模板的有限期类型 | ||
| 62 | } | 67 | } |
| 63 | 68 | ||
| 64 | /** | 69 | /** |
yudao-ui-admin/src/views/mall/product/brand/index.vue
| 1 | <template> | 1 | <template> |
| 2 | <div class="app-container"> | 2 | <div class="app-container"> |
| 3 | 3 | ||
| 4 | - <!-- 搜索工作栏 --> | ||
| 5 | - <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px"> | 4 | +« <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px"> |
| 6 | <el-form-item label="品牌名称" prop="name"> | 5 | <el-form-item label="品牌名称" prop="name"> |
| 7 | <el-input v-model="queryParams.name" placeholder="请输入品牌名称" clearable @keyup.enter.native="handleQuery"/> | 6 | <el-input v-model="queryParams.name" placeholder="请输入品牌名称" clearable @keyup.enter.native="handleQuery"/> |
| 8 | </el-form-item> | 7 | </el-form-item> |
yudao-ui-admin/src/views/promotion/couponTemplate/index.vue
0 → 100755
| 1 | +<template> | ||
| 2 | + <div class="app-container"> | ||
| 3 | + | ||
| 4 | + <!-- 搜索工作栏 --> | ||
| 5 | + <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="82px"> | ||
| 6 | + <el-form-item label="优惠券名称" prop="name"> | ||
| 7 | + <el-input v-model="queryParams.name" placeholder="请输入优惠劵名" clearable @keyup.enter.native="handleQuery"/> | ||
| 8 | + </el-form-item> | ||
| 9 | + <el-form-item label="优惠券类型" prop="discountType"> | ||
| 10 | + <el-select v-model="queryParams.discountType" placeholder="请选择优惠券类型" clearable size="small"> | ||
| 11 | + <el-option v-for="dict in this.getDictDatas(DICT_TYPE.PROMOTION_DISCOUNT_TYPE)" | ||
| 12 | + :key="dict.value" :label="dict.label" :value="dict.value"/> | ||
| 13 | + </el-select> | ||
| 14 | + </el-form-item> | ||
| 15 | + <el-form-item label="优惠券状态" prop="status"> | ||
| 16 | + <el-select v-model="queryParams.status" placeholder="请选择优惠券状态" clearable size="small"> | ||
| 17 | + <el-option v-for="dict in this.getDictDatas(DICT_TYPE.COMMON_STATUS)" | ||
| 18 | + :key="dict.value" :label="dict.label" :value="dict.value"/> | ||
| 19 | + </el-select> | ||
| 20 | + </el-form-item> | ||
| 21 | + <el-form-item label="创建时间" prop="createTime"> | ||
| 22 | + <el-date-picker v-model="queryParams.createTime" style="width: 240px" value-format="yyyy-MM-dd HH:mm:ss" type="daterange" | ||
| 23 | + range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期" :default-time="['00:00:00', '23:59:59']" /> | ||
| 24 | + </el-form-item> | ||
| 25 | + <el-form-item> | ||
| 26 | + <el-button type="primary" icon="el-icon-search" @click="handleQuery">搜索</el-button> | ||
| 27 | + <el-button icon="el-icon-refresh" @click="resetQuery">重置</el-button> | ||
| 28 | + </el-form-item> | ||
| 29 | + </el-form> | ||
| 30 | + | ||
| 31 | + <!-- 操作工具栏 --> | ||
| 32 | + <el-row :gutter="10" class="mb8"> | ||
| 33 | + <el-col :span="1.5"> | ||
| 34 | + <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd" | ||
| 35 | + v-hasPermi="['promotion:coupon-template:create']">新增</el-button> | ||
| 36 | + </el-col> | ||
| 37 | + <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar> | ||
| 38 | + </el-row> | ||
| 39 | + | ||
| 40 | + <!-- 列表 --> | ||
| 41 | + <el-table v-loading="loading" :data="list"> | ||
| 42 | + <el-table-column label="优惠券名称" align="center" prop="name" /> | ||
| 43 | + <el-table-column label="优惠券类型" align="center" prop="discountType"> | ||
| 44 | + <template slot-scope="scope"> | ||
| 45 | + <dict-tag :type="DICT_TYPE.PROMOTION_DISCOUNT_TYPE" :value="scope.row.discountType" /> | ||
| 46 | + </template> | ||
| 47 | + </el-table-column> | ||
| 48 | + <el-table-column label="优惠金额 / 折扣" align="center" prop="discount" :formatter="discountFormat" /> | ||
| 49 | + <el-table-column label="发放数量" align="center" prop="totalCount" /> | ||
| 50 | + <el-table-column label="剩余数量" align="center" prop="totalCount" :formatter="row => (row.totalCount - row.takeCount)" /> | ||
| 51 | + <el-table-column label="领取上限" align="center" prop="takeLimitCount" :formatter="takeLimitCountFormat" /> | ||
| 52 | + <el-table-column label="有效期限" align="center" prop="validityType" width="180" :formatter="validityTypeFormat" /> | ||
| 53 | + <el-table-column label="状态" align="center" prop="status"> | ||
| 54 | + <template slot-scope="scope"> | ||
| 55 | + <dict-tag :type="DICT_TYPE.COMMON_STATUS" :value="scope.row.status" /> | ||
| 56 | + </template> | ||
| 57 | + </el-table-column> | ||
| 58 | + <el-table-column label="创建时间" align="center" prop="createTime" width="180"> | ||
| 59 | + <template slot-scope="scope"> | ||
| 60 | + <span>{{ parseTime(scope.row.createTime) }}</span> | ||
| 61 | + </template> | ||
| 62 | + </el-table-column> | ||
| 63 | + <el-table-column label="操作" align="center" class-name="small-padding fixed-width"> | ||
| 64 | + <template slot-scope="scope"> | ||
| 65 | + <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)" | ||
| 66 | + v-hasPermi="['promotion:coupon-template:update']">修改</el-button> | ||
| 67 | + <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)" | ||
| 68 | + v-hasPermi="['promotion:coupon-template:delete']">删除</el-button> | ||
| 69 | + </template> | ||
| 70 | + </el-table-column> | ||
| 71 | + </el-table> | ||
| 72 | + <!-- 分页组件 --> | ||
| 73 | + <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize" | ||
| 74 | + @pagination="getList"/> | ||
| 75 | + | ||
| 76 | + <!-- 对话框(添加 / 修改) --> | ||
| 77 | + <el-dialog :title="title" :visible.sync="open" width="600px" v-dialogDrag append-to-body> | ||
| 78 | + <el-form ref="form" :model="form" :rules="rules" label-width="140px"> | ||
| 79 | + <el-form-item label="优惠券名称" prop="name"> | ||
| 80 | + <el-input v-model="form.name" placeholder="请输入优惠券名称" /> | ||
| 81 | + </el-form-item> | ||
| 82 | + <el-form-item label="优惠券类型" prop="discountType"> | ||
| 83 | + <el-radio-group v-model="form.discountType"> | ||
| 84 | + <el-radio v-for="dict in this.getDictDatas(DICT_TYPE.PROMOTION_DISCOUNT_TYPE)" | ||
| 85 | + :key="dict.value" :label="parseInt(dict.value)">{{dict.label}}</el-radio> | ||
| 86 | + </el-radio-group> | ||
| 87 | + </el-form-item> | ||
| 88 | + <el-form-item v-if="form.discountType === PromotionDiscountTypeEnum.PRICE.type" label="优惠券面额" prop="discountPrice"> | ||
| 89 | + <el-input-number v-model="form.discountPrice" placeholder="请输入优惠金额,单位:元" | ||
| 90 | + style="width: 400px" :precision="2" :min="0" /> 元 | ||
| 91 | + </el-form-item> | ||
| 92 | + <el-form-item v-if="form.discountType === PromotionDiscountTypeEnum.PERCENT.type" label="优惠券折扣" prop="discountPercent"> | ||
| 93 | + <el-input-number v-model="form.discountPercent" placeholder="优惠券折扣不能小于 1 折,且不可大于 9.9 折" | ||
| 94 | + style="width: 400px" :precision="1" :min="1" :max="9.9" /> 折 | ||
| 95 | + </el-form-item> | ||
| 96 | + <el-form-item v-if="form.discountType === PromotionDiscountTypeEnum.PERCENT.type" label="最多优惠" prop="discountLimitPrice"> | ||
| 97 | + <el-input-number v-model="form.discountLimitPrice" placeholder="请输入最多优惠" | ||
| 98 | + style="width: 400px" :precision="2" :min="0" /> 元 | ||
| 99 | + </el-form-item> | ||
| 100 | + <el-form-item label="满多少元可以使用" prop="usePrice"> | ||
| 101 | + <el-input-number v-model="form.usePrice" placeholder="无门槛请设为 0" | ||
| 102 | + style="width: 400px" :precision="2" :min="0" /> 元 | ||
| 103 | + </el-form-item> | ||
| 104 | + <el-form-item label="领取方式" prop="takeType"> | ||
| 105 | + <el-radio-group v-model="form.takeType"> | ||
| 106 | + <el-radio :key="1" :label="1">直接领取</el-radio> | ||
| 107 | + <el-radio :key="2" :label="2">指定发放</el-radio> | ||
| 108 | + </el-radio-group> | ||
| 109 | + </el-form-item> | ||
| 110 | + <el-form-item v-if="form.takeType === 1" label="发放数量" prop="totalCount"> | ||
| 111 | + <el-input-number v-model="form.usePrice" placeholder="发放数量,没有之后不能领取或发放,-1 为不限制" | ||
| 112 | + style="width: 400px" :precision="0" :min="-1" /> 张 | ||
| 113 | + </el-form-item> | ||
| 114 | + <el-form-item v-if="form.takeType === 1" label="每人限领个数" prop="takeLimitCount"> | ||
| 115 | + <el-input-number v-model="form.takeLimitCount" placeholder="设置为 -1 时,可无限领取" | ||
| 116 | + style="width: 400px" :precision="0" :min="-1" /> 张 | ||
| 117 | + </el-form-item> | ||
| 118 | + <el-form-item label="有效期类型" prop="validityType"> | ||
| 119 | + <el-radio-group v-model="form.validityType"> | ||
| 120 | + <el-radio v-for="dict in this.getDictDatas(DICT_TYPE.COUPON_TEMPLATE_VALIDITY_TYPE)" | ||
| 121 | + :key="dict.value" :label="parseInt(dict.value)">{{dict.label}}</el-radio> | ||
| 122 | + </el-radio-group> | ||
| 123 | + </el-form-item> | ||
| 124 | + <el-form-item v-if="form.validityType === CouponTemplateValidityTypeEnum.DATE.type" label="固定日期" prop="validTimes"> | ||
| 125 | + <el-date-picker v-model="queryParams.validTimes" style="width: 240px" value-format="yyyy-MM-dd HH:mm:ss" type="daterange" | ||
| 126 | + range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期" :default-time="['00:00:00', '23:59:59']" /> | ||
| 127 | + </el-form-item> | ||
| 128 | + <el-form-item v-if="form.validityType === CouponTemplateValidityTypeEnum.TERM.type" label="领取日期" prop="fixedStartTerm"> | ||
| 129 | + 第 <el-input-number v-model="form.fixedStartTerm" placeholder="0 为今天生效" | ||
| 130 | + style="width: 165px" :precision="0" :min="0"/> 至 | ||
| 131 | + <el-input-number v-model="form.fixedEndTerm" placeholder="请输入结束天数" | ||
| 132 | + style="width: 165px" :precision="0" :min="0"/> 天有效 | ||
| 133 | + </el-form-item> | ||
| 134 | + <el-form-item label="活动商品" prop="productScope"> | ||
| 135 | + <el-radio-group v-model="form.productScope"> | ||
| 136 | + <el-radio v-for="dict in this.getDictDatas(DICT_TYPE.PROMOTION_PRODUCT_SCOPE)" | ||
| 137 | + :key="dict.value" :label="parseInt(dict.value)">{{dict.label}}</el-radio> | ||
| 138 | + </el-radio-group> | ||
| 139 | + </el-form-item> | ||
| 140 | + <el-form-item v-if="form.productScope === PromotionProductScopeEnum.SPU.scope" prop="productSpuIds"> | ||
| 141 | + <el-input v-model="form.productSpuIds" placeholder="请输入商品 SPU 编号的数组" /> | ||
| 142 | + </el-form-item> | ||
| 143 | + </el-form> | ||
| 144 | + <div slot="footer" class="dialog-footer"> | ||
| 145 | + <el-button type="primary" @click="submitForm">确 定</el-button> | ||
| 146 | + <el-button @click="cancel">取 消</el-button> | ||
| 147 | + </div> | ||
| 148 | + </el-dialog> | ||
| 149 | + </div> | ||
| 150 | +</template> | ||
| 151 | + | ||
| 152 | +<script> | ||
| 153 | +import { createCouponTemplate, updateCouponTemplate, deleteCouponTemplate, getCouponTemplate, getCouponTemplatePage } from "@/api/promotion/couponTemplate"; | ||
| 154 | +import { CommonStatusEnum, CouponTemplateValidityTypeEnum, PromotionDiscountTypeEnum, PromotionProductScopeEnum} from "@/utils/constants"; | ||
| 155 | + | ||
| 156 | +export default { | ||
| 157 | + name: "CouponTemplate", | ||
| 158 | + components: { | ||
| 159 | + }, | ||
| 160 | + data() { | ||
| 161 | + return { | ||
| 162 | + // 遮罩层 | ||
| 163 | + loading: true, | ||
| 164 | + // 导出遮罩层 | ||
| 165 | + exportLoading: false, | ||
| 166 | + // 显示搜索条件 | ||
| 167 | + showSearch: true, | ||
| 168 | + // 总条数 | ||
| 169 | + total: 0, | ||
| 170 | + // 优惠劵列表 | ||
| 171 | + list: [], | ||
| 172 | + // 弹出层标题 | ||
| 173 | + title: "", | ||
| 174 | + // 是否显示弹出层 | ||
| 175 | + open: false, | ||
| 176 | + // 查询参数 | ||
| 177 | + queryParams: { | ||
| 178 | + pageNo: 1, | ||
| 179 | + pageSize: 10, | ||
| 180 | + name: null, | ||
| 181 | + status: null, | ||
| 182 | + type: null, | ||
| 183 | + createTime: [], | ||
| 184 | + }, | ||
| 185 | + // 表单参数 | ||
| 186 | + form: {}, | ||
| 187 | + // 表单校验 | ||
| 188 | + rules: { | ||
| 189 | + name: [{ required: true, message: "优惠券名称不能为空", trigger: "blur" }], | ||
| 190 | + discountType: [{ required: true, message: "优惠券类型不能为空", trigger: "change" }], | ||
| 191 | + discountPrice: [{ required: true, message: "优惠券面额不能为空", trigger: "blur" }], | ||
| 192 | + discountPercent: [{ required: true, message: "优惠券折扣不能为空", trigger: "blur" }], | ||
| 193 | + discountLimitPrice: [{ required: true, message: "最多优惠不能为空", trigger: "blur" }], | ||
| 194 | + usePrice: [{ required: true, message: "满多少元可以使用不能为空", trigger: "blur" }], | ||
| 195 | + takeType: [{ required: true, message: "领取方式不能为空", trigger: "change" }], | ||
| 196 | + totalCount: [{ required: true, message: "发放数量不能为空", trigger: "blur" }], | ||
| 197 | + takeLimitCount: [{ required: true, message: "每人限领个数不能为空", trigger: "blur" }], | ||
| 198 | + validityType: [{ required: true, message: "有效期类型不能为空", trigger: "change" }], | ||
| 199 | + validTimes: [{ required: true, message: "固定日期不能为空", trigger: "change" }], | ||
| 200 | + fixedStartTerm: [{ required: true, message: "开始领取天数不能为空", trigger: "blur" }], | ||
| 201 | + fixedEndTerm: [{ required: true, message: "开始领取天数不能为空", trigger: "blur" }], | ||
| 202 | + productScope: [{ required: true, message: "商品范围不能为空", trigger: "blur" }], | ||
| 203 | + productSpuIds: [{ required: true, message: "商品范围不能为空", trigger: "blur" }], | ||
| 204 | + }, | ||
| 205 | + // 如下的变量,主要为了 v-if 判断可以使用到 | ||
| 206 | + PromotionProductScopeEnum: PromotionProductScopeEnum, | ||
| 207 | + CouponTemplateValidityTypeEnum: CouponTemplateValidityTypeEnum, | ||
| 208 | + PromotionDiscountTypeEnum: PromotionDiscountTypeEnum, | ||
| 209 | + }; | ||
| 210 | + }, | ||
| 211 | + created() { | ||
| 212 | + this.getList(); | ||
| 213 | + }, | ||
| 214 | + methods: { | ||
| 215 | + /** 查询列表 */ | ||
| 216 | + getList() { | ||
| 217 | + this.loading = true; | ||
| 218 | + // 执行查询 | ||
| 219 | + getCouponTemplatePage(this.queryParams).then(response => { | ||
| 220 | + this.list = response.data.list; | ||
| 221 | + this.total = response.data.total; | ||
| 222 | + this.loading = false; | ||
| 223 | + }); | ||
| 224 | + }, | ||
| 225 | + /** 取消按钮 */ | ||
| 226 | + cancel() { | ||
| 227 | + this.open = false; | ||
| 228 | + this.reset(); | ||
| 229 | + }, | ||
| 230 | + /** 表单重置 */ | ||
| 231 | + reset() { | ||
| 232 | + this.form = { | ||
| 233 | + id: undefined, | ||
| 234 | + name: undefined, | ||
| 235 | + discountType: PromotionDiscountTypeEnum.PRICE.type, | ||
| 236 | + discountPrice: 0, | ||
| 237 | + discountPercent: undefined, | ||
| 238 | + discountLimitPrice: undefined, | ||
| 239 | + usePrice: undefined, | ||
| 240 | + takeType: 1, | ||
| 241 | + totalCount: undefined, | ||
| 242 | + takeLimitCount: undefined, | ||
| 243 | + validityType: CouponTemplateValidityTypeEnum.DATE.type, | ||
| 244 | + validTimes: [], | ||
| 245 | + validStartTime: undefined, | ||
| 246 | + validEndTime: undefined, | ||
| 247 | + fixedStartTerm: undefined, | ||
| 248 | + fixedEndTerm: undefined, | ||
| 249 | + productScope: PromotionProductScopeEnum.ALL.scope, | ||
| 250 | + productSpuIds: [], | ||
| 251 | + }; | ||
| 252 | + this.resetForm("form"); | ||
| 253 | + }, | ||
| 254 | + /** 搜索按钮操作 */ | ||
| 255 | + handleQuery() { | ||
| 256 | + this.queryParams.pageNo = 1; | ||
| 257 | + this.getList(); | ||
| 258 | + }, | ||
| 259 | + /** 重置按钮操作 */ | ||
| 260 | + resetQuery() { | ||
| 261 | + this.resetForm("queryForm"); | ||
| 262 | + this.handleQuery(); | ||
| 263 | + }, | ||
| 264 | + /** 新增按钮操作 */ | ||
| 265 | + handleAdd() { | ||
| 266 | + this.reset(); | ||
| 267 | + this.open = true; | ||
| 268 | + this.title = "添加优惠劵"; | ||
| 269 | + }, | ||
| 270 | + /** 修改按钮操作 */ | ||
| 271 | + handleUpdate(row) { | ||
| 272 | + this.reset(); | ||
| 273 | + const id = row.id; | ||
| 274 | + getCouponTemplate(id).then(response => { | ||
| 275 | + this.form = { | ||
| 276 | + ...response.data, | ||
| 277 | + discountPrice: response.data.discountPrice ? response.data.discountPrice / 100.0 : undefined, | ||
| 278 | + discountPercent: response.data.discountPercent ? response.data.discountPercent / 10.0 : undefined, | ||
| 279 | + usePrice: response.data.usePrice ? response.data.usePrice / 100.0 : undefined, | ||
| 280 | + } | ||
| 281 | + this.open = true; | ||
| 282 | + this.title = "修改优惠劵"; | ||
| 283 | + }); | ||
| 284 | + }, | ||
| 285 | + /** 提交按钮 */ | ||
| 286 | + submitForm() { | ||
| 287 | + this.$refs["form"].validate(valid => { | ||
| 288 | + if (!valid) { | ||
| 289 | + return; | ||
| 290 | + } | ||
| 291 | + // 金额相关字段的缩放 | ||
| 292 | + let data = { | ||
| 293 | + ...this.form, | ||
| 294 | + discountPrice: this.form.discountPrice ? this.form.discountPrice * 100 : undefined, | ||
| 295 | + discountPercent: this.form.discountPercent ? this.form.discountPercent * 10 : undefined, | ||
| 296 | + usePrice: this.form.usePrice ? this.form.usePrice * 100 : undefined, | ||
| 297 | + } | ||
| 298 | + // 修改的提交 | ||
| 299 | + if (this.form.id != null) { | ||
| 300 | + updateCouponTemplate(data).then(response => { | ||
| 301 | + this.$modal.msgSuccess("修改成功"); | ||
| 302 | + this.open = false; | ||
| 303 | + this.getList(); | ||
| 304 | + }); | ||
| 305 | + return; | ||
| 306 | + } | ||
| 307 | + // 添加的提交 | ||
| 308 | + createCouponTemplate(data).then(response => { | ||
| 309 | + this.$modal.msgSuccess("新增成功"); | ||
| 310 | + this.open = false; | ||
| 311 | + this.getList(); | ||
| 312 | + }); | ||
| 313 | + }); | ||
| 314 | + }, | ||
| 315 | + /** 删除按钮操作 */ | ||
| 316 | + handleDelete(row) { | ||
| 317 | + const id = row.id; | ||
| 318 | + this.$modal.confirm('是否确认删除优惠劵编号为"' + id + '"的数据项?').then(function() { | ||
| 319 | + return deleteCouponTemplate(id); | ||
| 320 | + }).then(() => { | ||
| 321 | + this.getList(); | ||
| 322 | + this.$modal.msgSuccess("删除成功"); | ||
| 323 | + }).catch(() => {}); | ||
| 324 | + }, | ||
| 325 | + // 格式化【优惠金额/折扣】 | ||
| 326 | + discountFormat(row, column) { | ||
| 327 | + if (row.discountType === PromotionDiscountTypeEnum.PRICE.type) { | ||
| 328 | + return `¥${(row.discountPrice / 100.0).toFixed(2)}`; | ||
| 329 | + } | ||
| 330 | + if (row.discountType === PromotionDiscountTypeEnum.PERCENT.type) { | ||
| 331 | + return `¥${(row.discountPrice / 100.0).toFixed(2)}`; | ||
| 332 | + } | ||
| 333 | + return '未知【' + row.discountType + '】'; | ||
| 334 | + }, | ||
| 335 | + // 格式化【领取上限】 | ||
| 336 | + takeLimitCountFormat(row, column) { | ||
| 337 | + if (row.takeLimitCount === -1) { | ||
| 338 | + return '无领取限制'; | ||
| 339 | + } | ||
| 340 | + return `${row.takeLimitCount} 张/人` | ||
| 341 | + }, | ||
| 342 | + // 格式化【有效期限】 | ||
| 343 | + validityTypeFormat(row, column) { | ||
| 344 | + if (row.validityType === CouponTemplateValidityTypeEnum.DATE.type) { | ||
| 345 | + return `${parseTime(row.validStartTime)} 至 ${parseTime(row.validEndTime)}` | ||
| 346 | + } | ||
| 347 | + if (row.validityType === CouponTemplateValidityTypeEnum.TERM.type) { | ||
| 348 | + return `领取后第 ${row.fixedStartTerm} - ${row.fixedEndTerm} 天内可用` | ||
| 349 | + } | ||
| 350 | + return '未知【' + row.validityType + '】'; | ||
| 351 | + } | ||
| 352 | + } | ||
| 353 | +}; | ||
| 354 | +</script> |