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