huliguo
13 小时以前 968e374ed1c2ef0595b277fc44067fb61e063a41
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
package com.ruoyi.member.domain.dto;
 
import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.ruoyi.system.api.domain.dto.MgtBaseDto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.hibernate.validator.constraints.Range;
 
import javax.validation.constraints.AssertTrue;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
 
/**
 * @ClassName MgtCouponEditDto
 * @Description TODO
 * @Author jqs
 * @Date 2023/6/13 12:46
 * @Version 1.0
 */
@Data
public class MgtCouponEditDto extends MgtBaseDto {
 
    @ApiModelProperty(value = "优惠券id 新增不传")
    private String couponId;
 
    @ApiModelProperty(value="优惠券类型1.满减2.折扣3.代金4.商品")
    @NotNull(message = "优惠券类型不能为空")
    @Range(min = 1, max = 4 , message = "优惠券类型错误")
    private Integer couponType;
 
    @ApiModelProperty(value="优惠券名称")
    @NotNull(message = "优惠券名称不能为空")
    private String couponName;
 
    @ApiModelProperty(value = "发送类型1.手动领取2.指定发放3.抽奖领取")
    @NotNull(message = "发送类型不能为空")
    private Integer sendType;
 
    @ApiModelProperty(value = "发送对象2.全部用户3.会员用户4非会员用户5自定义")
    @NotNull(message = "发送对象不能为空")
    private Integer sendTarget;
 
    @ApiModelProperty(value="发送时间类型1立即2定时")
    private Integer sendTimeType;
 
    @ApiModelProperty(value="发送时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date sendTime;
 
    @ApiModelProperty(value = "使用范围1.全场2.指定商品")
    private Integer useScope;
 
    @ApiModelProperty(value = "有效期类型1.时间段2.领取之日起")
    @Range(min = 1, max = 2, message = "有效期类型只能是1或2")
    private Integer validTimeType;
 
    @ApiModelProperty(value = "有效开始时间")
    private Date validStartTime;
 
    @ApiModelProperty(value = "有效截止时间")
    private Date validEndTime;
 
    @ApiModelProperty(value = "有效期")
    private Integer validDay;
 
    @ApiModelProperty(value = "门槛金额")
    private BigDecimal moneyThreshold;
 
    @ApiModelProperty(value = "折扣金额")
    private BigDecimal discountMoney;
 
    @ApiModelProperty(value = "折扣百分比")
    private BigDecimal discountPercent;
 
    @ApiModelProperty(value = "选择商品id集合")
    private List<String> relGoodsIdList;
 
    @ApiModelProperty(value = "关联类型1.用户管理筛选2.活动管理筛选")
    private Integer relationType;
 
    @ApiModelProperty(value = "关联活动类型1秒杀活动")
    private Integer relationActivityType;
 
    @ApiModelProperty(value = "关联活动id")
    private String relationActivityId;
 
    @ApiModelProperty(value = "关联用户id集合")
    private List<Long> relUserIdList;
 
    @ApiModelProperty(value = "宣传海报")
    private String propagandaPoster;
 
    @ApiModelProperty(value = "发放限制数量")
    private Integer sendLimitNumber;
 
    @ApiModelProperty(value = "发放限制0否1是")
    private Integer sendLimitFlag;
 
    @ApiModelProperty(value = "领取限制数量 0为不限")
    private Integer limitNumber;
 
    @ApiModelProperty("分享文案")
    private String sharePassage;
 
    @ApiModelProperty("分享图片")
    private String sharePic;
    // 自定义校验逻辑
    @AssertTrue(message = "当有效期类型为时间段时,有效开始时间和有效截止时间不能为空")
    public boolean isValidTimeRange() {
        if (validTimeType == null) return true; // 由@NotNull校验
        if (validTimeType == 1) {
            return validStartTime != null && validEndTime != null;
        }
        return true;
    }
 
    @AssertTrue(message = "当有效期类型为领取之日起时,有效期不能为空且必须大于0")
    public boolean isValidDay() {
        if (validTimeType == null) return true;
        if (validTimeType == 2) {
            return validDay != null && validDay > 0;
        }
        return true;
    }
}