|
@@ -1,17 +1,26 @@
|
|
|
package com.yonge.cooleshow.admin.io.request.coupon;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
+import com.yonge.cooleshow.biz.dal.enums.ClientEnum;
|
|
|
+import com.yonge.cooleshow.biz.dal.enums.coupon.CouponCategoryEnum;
|
|
|
+import com.yonge.cooleshow.biz.dal.enums.coupon.CouponTypeEnum;
|
|
|
+import com.yonge.cooleshow.common.enums.EStatus;
|
|
|
+import com.yonge.toolset.base.exception.BizException;
|
|
|
import com.yonge.toolset.base.page.QueryInfo;
|
|
|
import io.swagger.annotations.ApiModel;
|
|
|
import io.swagger.annotations.ApiModelProperty;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
+import lombok.Builder;
|
|
|
import lombok.Data;
|
|
|
import lombok.NoArgsConstructor;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.joda.time.DateTime;
|
|
|
|
|
|
import java.io.Serializable;
|
|
|
import java.math.BigDecimal;
|
|
|
-import java.time.LocalDateTime;
|
|
|
import java.util.Date;
|
|
|
+import java.util.Objects;
|
|
|
+import java.util.Optional;
|
|
|
|
|
|
/**
|
|
|
* 优惠券信息
|
|
@@ -30,12 +39,15 @@ public class CouponInfoVO {
|
|
|
|
|
|
@ApiModelProperty("优惠券名称")
|
|
|
private String name;
|
|
|
+
|
|
|
@ApiModelProperty("客户类型")
|
|
|
- private String clientType;
|
|
|
+ private ClientEnum clientType;
|
|
|
+
|
|
|
@ApiModelProperty("优惠券类型")
|
|
|
- private String couponType;
|
|
|
+ private CouponTypeEnum couponType;
|
|
|
+
|
|
|
@ApiModelProperty("可用品类")
|
|
|
- private String category;
|
|
|
+ private CouponCategoryEnum category;
|
|
|
|
|
|
public String jsonString() {
|
|
|
return JSON.toJSONString(this);
|
|
@@ -78,6 +90,12 @@ public class CouponInfoVO {
|
|
|
@ApiModelProperty("状态")
|
|
|
private Integer status;
|
|
|
|
|
|
+ @ApiModelProperty("发放领取数")
|
|
|
+ private Integer issueNum;
|
|
|
+
|
|
|
+ @ApiModelProperty("关联奖品数")
|
|
|
+ private Integer rewardNum;
|
|
|
+
|
|
|
@ApiModelProperty("最后更新人")
|
|
|
private String updatedUser;
|
|
|
|
|
@@ -85,7 +103,7 @@ public class CouponInfoVO {
|
|
|
private Long updateTime;
|
|
|
|
|
|
@ApiModelProperty("创建时间")
|
|
|
- private LocalDateTime createdTime;
|
|
|
+ private Date createdTime;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -102,17 +120,14 @@ public class CouponInfoVO {
|
|
|
@ApiModelProperty("优惠券名称")
|
|
|
private String name;
|
|
|
|
|
|
- @ApiModelProperty("优惠券编号")
|
|
|
- private String serialNum;
|
|
|
-
|
|
|
@ApiModelProperty("描述")
|
|
|
private String describe;
|
|
|
|
|
|
@ApiModelProperty("客户端类型: TEACHER(老师端), STUDENT(学生端)")
|
|
|
- private String clientType;
|
|
|
+ private ClientEnum clientType;
|
|
|
|
|
|
@ApiModelProperty("可用品类: UNIVERSAL(全场通用) VIP(小酷Ai) PIANO(云酷琴房) MALL(商场购物券) MUSIC(单曲点播券) SPARRING(陪练课购买券) LIVE(直播课购买券) VIDEO(视频课购买券) ")
|
|
|
- private String category;
|
|
|
+ private CouponCategoryEnum category;
|
|
|
|
|
|
@ApiModelProperty("使用门槛")
|
|
|
private BigDecimal useLimit;
|
|
@@ -121,7 +136,7 @@ public class CouponInfoVO {
|
|
|
private BigDecimal discountPrice;
|
|
|
|
|
|
@ApiModelProperty("优惠券类型")
|
|
|
- private String couponType;
|
|
|
+ private CouponTypeEnum couponType;
|
|
|
|
|
|
@ApiModelProperty("有效天数")
|
|
|
private Integer validDay;
|
|
@@ -153,8 +168,8 @@ public class CouponInfoVO {
|
|
|
@ApiModelProperty("创建时间")
|
|
|
private Date createdTime;
|
|
|
|
|
|
- public String jsonString() {
|
|
|
- return JSON.toJSONString(this);
|
|
|
+ public static CouponQueryInfo from(String recv) {
|
|
|
+ return JSON.parseObject(recv, CouponQueryInfo.class);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -162,6 +177,7 @@ public class CouponInfoVO {
|
|
|
* 新增或更新优惠券信息
|
|
|
*/
|
|
|
@Data
|
|
|
+ @Builder
|
|
|
@NoArgsConstructor
|
|
|
@AllArgsConstructor
|
|
|
public static class CouponInfo implements Serializable {
|
|
@@ -172,17 +188,14 @@ public class CouponInfoVO {
|
|
|
@ApiModelProperty("优惠券名称")
|
|
|
private String name;
|
|
|
|
|
|
- @ApiModelProperty("优惠券编号")
|
|
|
- private String serialNum;
|
|
|
-
|
|
|
@ApiModelProperty("描述")
|
|
|
private String describe;
|
|
|
|
|
|
@ApiModelProperty("客户端类型: TEACHER(老师端), STUDENT(学生端)")
|
|
|
- private String clientType;
|
|
|
+ private ClientEnum clientType;
|
|
|
|
|
|
@ApiModelProperty("可用品类: UNIVERSAL(全场通用) VIP(小酷Ai) PIANO(云酷琴房) MALL(商场购物券) MUSIC(单曲点播券) SPARRING(陪练课购买券) LIVE(直播课购买券) VIDEO(视频课购买券) ")
|
|
|
- private String category;
|
|
|
+ private CouponCategoryEnum category;
|
|
|
|
|
|
@ApiModelProperty("使用门槛")
|
|
|
private BigDecimal useLimit;
|
|
@@ -191,7 +204,7 @@ public class CouponInfoVO {
|
|
|
private BigDecimal discountPrice;
|
|
|
|
|
|
@ApiModelProperty("优惠券类型: FULL_DISCOUNT(满减券) VOUCHER(代金券) ")
|
|
|
- private String couponType;
|
|
|
+ private CouponTypeEnum couponType;
|
|
|
|
|
|
@ApiModelProperty("有效天数")
|
|
|
private Integer validDay;
|
|
@@ -211,20 +224,140 @@ public class CouponInfoVO {
|
|
|
@ApiModelProperty("启禁状态")
|
|
|
private Integer status;
|
|
|
|
|
|
- @ApiModelProperty("更新用户")
|
|
|
+ @ApiModelProperty(value = "更新用户", hidden = true)
|
|
|
private Long updatedBy;
|
|
|
|
|
|
- @ApiModelProperty("更新时间")
|
|
|
+ @ApiModelProperty(value = "更新时间", hidden = true)
|
|
|
private Long updateTime;
|
|
|
|
|
|
- @ApiModelProperty("创建用户")
|
|
|
+ @ApiModelProperty(value = "创建用户", hidden = true)
|
|
|
private Long createdBy;
|
|
|
|
|
|
- @ApiModelProperty("创建时间")
|
|
|
- private Date createdTime;
|
|
|
-
|
|
|
public String jsonString() {
|
|
|
return JSON.toJSONString(this);
|
|
|
}
|
|
|
+
|
|
|
+ public boolean invalidRequestParam(Long userId) {
|
|
|
+
|
|
|
+ if (Objects.isNull(getId())) {
|
|
|
+
|
|
|
+ // 新增参数
|
|
|
+ if (StringUtils.isEmpty(getName())) {
|
|
|
+ throw new BizException("优惠券名称不能为空");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (Objects.isNull(getClientType())) {
|
|
|
+ throw new BizException("客户端不能为空");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (Objects.isNull(getCategory())) {
|
|
|
+ throw new BizException("可用品类不能为空");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (Objects.isNull(getCouponType())) {
|
|
|
+ throw new BizException("优惠券类型不能为空");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (CouponTypeEnum.FULL_DISCOUNT == getCouponType()
|
|
|
+ && Optional.ofNullable(getUseLimit()).map(BigDecimal::intValue).orElse(0) <= 0) {
|
|
|
+ throw new BizException("满减金额未设置");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (Optional.ofNullable(getValidDay()).orElse(0) <= 0
|
|
|
+ || (Optional.ofNullable(getStartTime()).orElse(0L) == 0
|
|
|
+ || Optional.ofNullable(getEndTime()).orElse(0L) == 0)) {
|
|
|
+ throw new BizException("优惠券时间有效期不合法");
|
|
|
+ }
|
|
|
+
|
|
|
+ this.createdBy(userId).initSaveParam();
|
|
|
+ } else {
|
|
|
+
|
|
|
+ // 更新参数
|
|
|
+ this.updatedBy(userId).setUpdateTime(DateTime.now().getMillis());
|
|
|
+ }
|
|
|
+
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ public CouponInfo initSaveParam() {
|
|
|
+
|
|
|
+ return this.describe("")
|
|
|
+ .useLimit(BigDecimal.ZERO)
|
|
|
+ .discountPrice(BigDecimal.ZERO)
|
|
|
+ .validDay(0)
|
|
|
+ .startTime(0L)
|
|
|
+ .endTime(0L)
|
|
|
+ .inventory(0)
|
|
|
+ .quantityLimit(0)
|
|
|
+ .status(EStatus.DISABLE.getValue());
|
|
|
+ }
|
|
|
+
|
|
|
+ public CouponInfo describe(String describe) {
|
|
|
+ if (StringUtils.isEmpty(this.describe)) {
|
|
|
+ this.describe = describe;
|
|
|
+ }
|
|
|
+ return this;
|
|
|
+ }
|
|
|
+
|
|
|
+ public CouponInfo useLimit(BigDecimal useLimit) {
|
|
|
+ if (Objects.isNull(this.useLimit)) {
|
|
|
+ this.useLimit = useLimit;
|
|
|
+ }
|
|
|
+ return this;
|
|
|
+ }
|
|
|
+
|
|
|
+ public CouponInfo discountPrice(BigDecimal discountPrice) {
|
|
|
+ if (Objects.isNull(this.discountPrice)) {
|
|
|
+ this.discountPrice = discountPrice;
|
|
|
+ }
|
|
|
+ return this;
|
|
|
+ }
|
|
|
+
|
|
|
+ public CouponInfo validDay(Integer validDay) {
|
|
|
+ if (Objects.isNull(this.validDay)) {
|
|
|
+ this.validDay = validDay;
|
|
|
+ }
|
|
|
+ return this;
|
|
|
+ }
|
|
|
+
|
|
|
+ public CouponInfo startTime(Long startTime) {
|
|
|
+ if (Objects.isNull(this.startTime)) {
|
|
|
+ this.startTime = startTime;
|
|
|
+ }
|
|
|
+ return this;
|
|
|
+ }
|
|
|
+
|
|
|
+ public CouponInfo endTime(Long endTime) {
|
|
|
+ if (Objects.isNull(this.endTime)) {
|
|
|
+ this.endTime = endTime;
|
|
|
+ }
|
|
|
+ return this;
|
|
|
+ }
|
|
|
+
|
|
|
+ public CouponInfo inventory(Integer inventory) {
|
|
|
+ this.inventory = inventory;
|
|
|
+ return this;
|
|
|
+ }
|
|
|
+
|
|
|
+ public CouponInfo quantityLimit(Integer quantityLimit) {
|
|
|
+ this.quantityLimit = quantityLimit;
|
|
|
+ return this;
|
|
|
+ }
|
|
|
+
|
|
|
+ public CouponInfo status(Integer status) {
|
|
|
+ this.status = status;
|
|
|
+ return this;
|
|
|
+ }
|
|
|
+
|
|
|
+ public CouponInfo createdBy(Long createdBy) {
|
|
|
+ this.createdBy = createdBy;
|
|
|
+ return this;
|
|
|
+ }
|
|
|
+
|
|
|
+ public CouponInfo updatedBy(Long updatedBy) {
|
|
|
+ this.updatedBy = updatedBy;
|
|
|
+ return this;
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
}
|