mirror of
https://gitee.com/hhyykk/ipms-sjy.git
synced 2025-08-14 18:21:53 +08:00
promotion:完善限时折扣的添加逻辑
This commit is contained in:
@@ -130,11 +130,11 @@ public class CouponTemplateBaseVO {
|
||||
|| fixedEndTerm != null;
|
||||
}
|
||||
|
||||
@AssertTrue(message = "折扣百分比需要大于等于 1")
|
||||
@AssertTrue(message = "折扣百分比需要大于等于 1,小于等于 99")
|
||||
@JsonIgnore
|
||||
public boolean isDiscountPercentValid() {
|
||||
return ObjectUtil.notEqual(discountType, PromotionDiscountTypeEnum.PERCENT.getType())
|
||||
|| (discountPercent != null && discountPercent >= 1);
|
||||
|| (discountPercent != null && discountPercent >= 1 && discountPercent<= 99);
|
||||
}
|
||||
|
||||
@AssertTrue(message = "优惠金额不能为空")
|
||||
|
@@ -1,10 +1,15 @@
|
||||
package cn.iocoder.yudao.module.promotion.controller.admin.discount.vo;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.iocoder.yudao.framework.common.validation.InEnum;
|
||||
import cn.iocoder.yudao.module.promotion.enums.common.PromotionDiscountTypeEnum;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
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;
|
||||
@@ -47,10 +52,31 @@ public class DiscountActivityBaseVO {
|
||||
@NotNull(message = "商品 SKU 编号不能为空")
|
||||
private Long skuId;
|
||||
|
||||
@ApiModelProperty(value = "折扣价格,单位:分", required = true, example = "1000")
|
||||
@NotNull(message = "折扣价格不能为空")
|
||||
@Min(value = 1, message = "折扣价格必须大于 0")
|
||||
@ApiModelProperty(value = "优惠类型", required = true, example = "1", notes = "参见 PromotionDiscountTypeEnum 枚举")
|
||||
@NotNull(message = "优惠类型不能为空")
|
||||
@InEnum(PromotionDiscountTypeEnum.class)
|
||||
private Integer discountType;
|
||||
|
||||
@ApiModelProperty(value = "折扣百分比", example = "80", notes = "例如说,80% 为 80")
|
||||
private Integer discountPercent;
|
||||
|
||||
@ApiModelProperty(value = "优惠金额", example = "10", notes = "单位:分")
|
||||
@Min(value = 0, message = "优惠金额需要大于等于 0")
|
||||
private Integer discountPrice;
|
||||
|
||||
@AssertTrue(message = "折扣百分比需要大于等于 1,小于等于 99")
|
||||
@JsonIgnore
|
||||
public boolean isDiscountPercentValid() {
|
||||
return ObjectUtil.notEqual(discountType, PromotionDiscountTypeEnum.PERCENT.getType())
|
||||
|| (discountPercent != null && discountPercent >= 1 && discountPercent<= 99);
|
||||
}
|
||||
|
||||
@AssertTrue(message = "优惠金额不能为空")
|
||||
@JsonIgnore
|
||||
public boolean isDiscountPriceValid() {
|
||||
return ObjectUtil.notEqual(discountType, PromotionDiscountTypeEnum.PRICE.getType())
|
||||
|| discountPrice != null;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@@ -5,7 +5,8 @@ import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import java.util.List;
|
||||
|
||||
@ApiModel("管理后台 - 限时折扣活动创建 Request VO")
|
||||
@@ -17,7 +18,8 @@ public class DiscountActivityCreateReqVO extends DiscountActivityBaseVO {
|
||||
/**
|
||||
* 商品列表
|
||||
*/
|
||||
@NotNull(message = "商品列表不能为空")
|
||||
@NotEmpty(message = "商品列表不能为空")
|
||||
@Valid
|
||||
private List<Product> products;
|
||||
|
||||
}
|
||||
|
@@ -6,6 +6,8 @@ import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.List;
|
||||
|
||||
@@ -22,7 +24,8 @@ public class DiscountActivityUpdateReqVO extends DiscountActivityBaseVO {
|
||||
/**
|
||||
* 商品列表
|
||||
*/
|
||||
@NotNull(message = "商品列表不能为空")
|
||||
@NotEmpty(message = "商品列表不能为空")
|
||||
@Valid
|
||||
private List<DiscountActivityCreateReqVO.Product> products;
|
||||
|
||||
}
|
||||
|
@@ -1,6 +1,7 @@
|
||||
package cn.iocoder.yudao.module.promotion.dal.dataobject.discount;
|
||||
|
||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||
import cn.iocoder.yudao.module.promotion.enums.common.PromotionDiscountTypeEnum;
|
||||
import com.baomidou.mybatisplus.annotation.KeySequence;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
@@ -41,8 +42,23 @@ public class DiscountProductDO extends BaseDO {
|
||||
* 关联 ProductSkuDO 的 id 编号
|
||||
*/
|
||||
private Long skuId;
|
||||
|
||||
/**
|
||||
* 优惠价格,单位:分
|
||||
* 折扣类型
|
||||
*
|
||||
* 枚举 {@link PromotionDiscountTypeEnum}
|
||||
*/
|
||||
private Integer discountType;
|
||||
/**
|
||||
* 折扣百分比
|
||||
*
|
||||
* 例如,80% 为 80
|
||||
*/
|
||||
private Integer discountPercent;
|
||||
/**
|
||||
* 优惠金额,单位:分
|
||||
*
|
||||
* 当 {@link #discountType} 为 {@link PromotionDiscountTypeEnum#PRICE} 生效
|
||||
*/
|
||||
private Integer discountPrice;
|
||||
|
||||
|
Reference in New Issue
Block a user