记得上下班打卡 | git大法好,push需谨慎

Commit a654ca39 authored by 张国柄's avatar 张国柄

后台发放券校验调整;

parent eb8a40f0
...@@ -61,7 +61,7 @@ create table candy_coupon ...@@ -61,7 +61,7 @@ create table candy_coupon
notice varchar(200) comment '注意/须知', notice varchar(200) comment '注意/须知',
exclusive smallint comment '专享标识[0-常规|1-会员礼包]', exclusive smallint comment '专享标识[0-常规|1-会员礼包]',
busi_type smallint comment '业务类别[0-全场|1-演出|2-商品|3-优先购]', busi_type smallint comment '业务类别[0-全场|1-演出|2-商品|3-优先购]',
cou_type smallint comment '券类型[1-代金券|2-满减券|3-兑换券|4-折扣券]', cou_type smallint comment '券类型[1-代金券|2-满减券|3-兑换券|4-折扣券|101-优先券]',
bind_type smallint comment '领取方式[0-用户输入兑换|1-发放至用户]', bind_type smallint comment '领取方式[0-用户输入兑换|1-发放至用户]',
discount decimal(8, 2) comment '折扣[8折即0.8]', discount decimal(8, 2) comment '折扣[8折即0.8]',
......
...@@ -17,7 +17,7 @@ public class AdamMemberRightsCouponVo implements java.io.Serializable, Cloneable ...@@ -17,7 +17,7 @@ public class AdamMemberRightsCouponVo implements java.io.Serializable, Cloneable
private String couponId; private String couponId;
@ApiModelProperty(position = 3, value = "券类别[0-全场|1-演出|2-商品|3-优先购]") @ApiModelProperty(position = 3, value = "券类别[0-全场|1-演出|2-商品|3-优先购]")
private Integer busiType; private Integer busiType;
@ApiModelProperty(position = 4, value = "券类型[1-代金券|2-满减券|3-兑换券|4-折扣券]") @ApiModelProperty(position = 4, value = "券类型[1-代金券|2-满减券|3-兑换券|4-折扣券|101-优先券]")
private Integer couType; private Integer couType;
@ApiModelProperty(position = 5, value = "券标题") @ApiModelProperty(position = 5, value = "券标题")
private String title; private String title;
......
...@@ -38,7 +38,7 @@ public class CandyMemberCouponBuildParam { ...@@ -38,7 +38,7 @@ public class CandyMemberCouponBuildParam {
private Integer busiType; private Integer busiType;
@NotNull(message = "券类型不能为空") @NotNull(message = "券类型不能为空")
@Pattern(regexp = "\\b(1|2)\\b", message = "券类型无效") @Pattern(regexp = "\\b(1|2)\\b", message = "券类型无效")
// @ApiModelProperty(required = true, value = "券类型[1-代金券|2-满减券|3-兑换券|4-折扣券]", allowableValues = "1,2,3,4") // @ApiModelProperty(required = true, value = "券类型[1-代金券|2-满减券|3-兑换券|4-折扣券|101-优先券]", allowableValues = "1,2,3,4")
@ApiModelProperty(required = true, value = "券类型[1-代金券|2-满减券]", allowableValues = "1,2") @ApiModelProperty(required = true, value = "券类型[1-代金券|2-满减券]", allowableValues = "1,2")
private Integer couType; private Integer couType;
// @NotNull(message = "券领取方式不能为空") // @NotNull(message = "券领取方式不能为空")
......
...@@ -27,7 +27,7 @@ public class CandyMgtCouponBuildParam { ...@@ -27,7 +27,7 @@ public class CandyMgtCouponBuildParam {
@ApiModelProperty(required = true, value = "业务类别[0-全场|1-演出|2-商品|3-优先购]", allowableValues = "0,1,2,3,4") @ApiModelProperty(required = true, value = "业务类别[0-全场|1-演出|2-商品|3-优先购]", allowableValues = "0,1,2,3,4")
private Integer busiType; private Integer busiType;
@NotNull(message = "券类型不能为空") @NotNull(message = "券类型不能为空")
@ApiModelProperty(required = true, value = "券类型[1-代金券|2-满减券|3-兑换券|4-折扣券]", allowableValues = "1,2,3,4") @ApiModelProperty(required = true, value = "券类型[1-代金券|2-满减券|3-兑换券|4-折扣券|101-优先券]", allowableValues = "1,2,3,4")
private Integer couType; private Integer couType;
@NotNull(message = "券领取方式不能为空") @NotNull(message = "券领取方式不能为空")
@ApiModelProperty(required = true, value = "领取方式[0-用户输入兑换|1-发放至用户]", allowableValues = "0,1") @ApiModelProperty(required = true, value = "领取方式[0-用户输入兑换|1-发放至用户]", allowableValues = "0,1")
...@@ -41,11 +41,15 @@ public class CandyMgtCouponBuildParam { ...@@ -41,11 +41,15 @@ public class CandyMgtCouponBuildParam {
@ApiModelProperty(required = false, value = "满减~减", example = "0.01") @ApiModelProperty(required = false, value = "满减~减", example = "0.01")
private BigDecimal valMinus; private BigDecimal valMinus;
@ApiModelProperty(required = false, value = "叠加限制[0-限制|1-叠加]", allowableValues = "0,1") @ApiModelProperty(required = false, value = "叠加限制[0-限制|1-叠加]", allowableValues = "0,1")
@Min(value = 0, message = "叠加限制配置无效")
@Max(value = 1, message = "叠加限制配置无效")
private Integer overlay; private Integer overlay;
//private Integer overlayLevel; //private Integer overlayLevel;
@NotNull(message = "券有效期不能为空") @NotNull(message = "券有效期不能为空")
@Min(value = 1, message = "有效期不能小于1")
@ApiModelProperty(required = true, value = "有效期(单位天)", example = "30") @ApiModelProperty(required = true, value = "有效期(单位天)", example = "30")
private Integer validity; private Integer validity;
@Min(value = 1, message = "兑换有效期不能小于1")
@ApiModelProperty(required = false, value = "兑换有效期(单位天)", example = "30") @ApiModelProperty(required = false, value = "兑换有效期(单位天)", example = "30")
private Integer redeemValidity; private Integer redeemValidity;
//private LocalDateTime redeemStart; //private LocalDateTime redeemStart;
...@@ -73,7 +77,6 @@ public class CandyMgtCouponBuildParam { ...@@ -73,7 +77,6 @@ public class CandyMgtCouponBuildParam {
private Integer eventType; private Integer eventType;
@ApiModelProperty(required = false, value = "`发放类型`为2-手机号时发放手机号以,分隔", example = "18510957291,17701223310") @ApiModelProperty(required = false, value = "`发放类型`为2-手机号时发放手机号以,分隔", example = "18510957291,17701223310")
private String eventLimit; private String eventLimit;
@NotNull(message = "券发放时间不能为空")
@Pattern(regexp = LnsRegex.Valid.DATETIME_FULL, message = "发放时间格式有误") @Pattern(regexp = LnsRegex.Valid.DATETIME_FULL, message = "发放时间格式有误")
@ApiModelProperty(required = true, value = "发放时间[yyyy-MM-dd HH:mm:ss](立即-当前时间|预约-点选时间)", example = "2021-08-26 00:00:00") @ApiModelProperty(required = true, value = "发放时间[yyyy-MM-dd HH:mm:ss](立即-当前时间|预约-点选时间)", example = "2021-08-26 00:00:00")
private String eventAt; private String eventAt;
......
...@@ -73,49 +73,83 @@ public class CandyMgtCouponAdminController extends BaseController { ...@@ -73,49 +73,83 @@ public class CandyMgtCouponAdminController extends BaseController {
@PostMapping("add") @PostMapping("add")
@ResponseBody @ResponseBody
public AjaxResult addSave(@RequestBody @Validated CandyMgtCouponBuildParam buildParam) { public AjaxResult addSave(@RequestBody @Validated CandyMgtCouponBuildParam buildParam) {
BigDecimal discount = null, valFace = null, valOver = null, valMinus = null; LocalDateTime nowTime = LocalDateTime.now(), redeemStart = null, redeemStop = null, effectAt, expireAt;
Integer couType = buildParam.getCouType(),
validity = buildParam.getValidity(), String eventAtStr = buildParam.getEventAt();
redeemValidity = buildParam.getRedeemValidity(); LocalDateTime eventAt = StringUtils.isEmpty(eventAtStr.trim()) ? nowTime
LocalDateTime nowTime = LocalDateTime.now(), : LocalDateTime.parse(eventAtStr, DateTimeFormatter.ofPattern(DateUtils.YYYY_MM_DD_HH_MM_SS));
redeemStart = null, redeemStop = null, effectAt, expireAt,
eventAt = LocalDateTime.parse(buildParam.getEventAt(), DateTimeFormatter.ofPattern(DateUtils.YYYY_MM_DD_HH_MM_SS)); switch (buildParam.getCouType()) {// TODO: 2021/8/20 校验
switch (couType) {// TODO: 2021/8/20 校验
case 1:// 代金券 case 1:// 代金券
valFace = buildParam.getValFace(); BigDecimal valFace = buildParam.getValFace();
if (null == valFace || valFace.compareTo(BigDecimal.ZERO) <= 0) {
return AjaxResult.warn("代金券金额无效");
}
buildParam.setDiscount(null);
buildParam.setValOver(null);
buildParam.setValMinus(null);
buildParam.setOverlay(0);
break; break;
case 2:// 满减券 case 2:// 满减券
valOver = buildParam.getValOver(); BigDecimal valOver = buildParam.getValOver();
valMinus = buildParam.getValMinus(); BigDecimal valMinus = buildParam.getValMinus();
if (null == valOver || valOver.compareTo(BigDecimal.ZERO) <= 0
|| null == valMinus || valMinus.compareTo(BigDecimal.ZERO) <= 0) {
return AjaxResult.warn("满减金额无效");
}
buildParam.setDiscount(null);
buildParam.setValFace(valMinus);
buildParam.setOverlay(0);
break; break;
case 3:// 兑换券 case 3:// 兑换券
redeemStart = eventAt.with(LocalTime.MIN); buildParam.setBindType(0);
redeemStop = eventAt.plusDays(redeemValidity).withHour(23).withMinute(59).withSecond(59); buildParam.setDiscount(null);
buildParam.setValFace(null);
buildParam.setValOver(null);
buildParam.setValMinus(null);
buildParam.setOverlay(0);
break; break;
case 4:// 折扣券 case 4:// 折扣券
discount = buildParam.getDiscount(); BigDecimal discount = buildParam.getDiscount();
if (null == discount || discount.compareTo(BigDecimal.ZERO) <= 0) {
return AjaxResult.warn("折扣配置无效");
}
break;
case 101:
buildParam.setDiscount(null);
buildParam.setValFace(null);
buildParam.setValOver(null);
buildParam.setValMinus(null);
if (null == buildParam.getOverlay()) {
return AjaxResult.warn("叠加限制配置无效");
}
break; break;
default: default:
logger.warn("Invalid operation[buildParam.couType={}]", couType); logger.warn("Invalid operation[buildParam.couType={}]", buildParam.getCouType());
return this.error(AjaxResult.Type.WARN, "券类型无效"); return this.error(AjaxResult.Type.WARN, "券类型无效");
} }
effectAt = eventAt.with(LocalTime.MIN); Integer validity = buildParam.getValidity();
expireAt = eventAt.plusDays(validity).withHour(23).withMinute(59).withSecond(59); Integer redeemValidity = buildParam.getRedeemValidity();
if (0 == buildParam.getBindType()) {
StringBuilder eventLimit = new StringBuilder(); buildParam.setEventType(null);
String operator = ShiroUtils.getLoginName(); buildParam.setEventLimit(null);
if (null == redeemValidity) {
return AjaxResult.warn("兑换有效期无效");
}
redeemStart = eventAt.with(LocalTime.MIN);
redeemStop = eventAt.plusDays(redeemValidity).withHour(23).withMinute(59).withSecond(59);
} else {
if (buildParam.getEventType() == 2) {// 指定用户手机号 if (buildParam.getEventType() == 2) {// 指定用户手机号
String eventLimitStr = buildParam.getEventLimit().trim(); if (StringUtils.isEmpty(buildParam.getEventLimit().trim())) {
// TODO: 2021/8/20 正则校验手机号字符串
if (StringUtils.isEmpty(eventLimitStr)) {
return this.error(AjaxResult.Type.WARN, "请指定手机号"); return this.error(AjaxResult.Type.WARN, "请指定手机号");
} }
Set<String> eventLimitSet = Stream.of(eventLimitStr.split(",")).collect(Collectors.toSet());
for (String l : eventLimitSet) {
eventLimit.append(l).append(",");
} }
} }
effectAt = eventAt.with(LocalTime.MIN);
expireAt = eventAt.plusDays(validity).withHour(23).withMinute(59).withSecond(59);
String operator = ShiroUtils.getLoginName();
CandyCoupon initCoupon = new CandyCoupon(); CandyCoupon initCoupon = new CandyCoupon();
initCoupon.setCouponId(IDGenerator.nextMilliId()); initCoupon.setCouponId(IDGenerator.nextMilliId());
...@@ -125,12 +159,12 @@ public class CandyMgtCouponAdminController extends BaseController { ...@@ -125,12 +159,12 @@ public class CandyMgtCouponAdminController extends BaseController {
initCoupon.setNotice(buildParam.getNotice()); initCoupon.setNotice(buildParam.getNotice());
initCoupon.setExclusive(0); initCoupon.setExclusive(0);
initCoupon.setBusiType(buildParam.getBusiType()); initCoupon.setBusiType(buildParam.getBusiType());
initCoupon.setCouType(couType); initCoupon.setCouType(buildParam.getCouType());
initCoupon.setBindType(buildParam.getBindType()); initCoupon.setBindType(buildParam.getBindType());
initCoupon.setDiscount(discount); initCoupon.setDiscount(buildParam.getDiscount());
initCoupon.setValFace(valFace); initCoupon.setValFace(buildParam.getValFace());
initCoupon.setValOver(valOver); initCoupon.setValOver(buildParam.getValOver());
initCoupon.setValMinus(valMinus); initCoupon.setValMinus(buildParam.getValMinus());
initCoupon.setOverlay(buildParam.getOverlay()); initCoupon.setOverlay(buildParam.getOverlay());
initCoupon.setValidity(validity); initCoupon.setValidity(validity);
initCoupon.setRedeemValidity(redeemValidity); initCoupon.setRedeemValidity(redeemValidity);
...@@ -163,7 +197,7 @@ public class CandyMgtCouponAdminController extends BaseController { ...@@ -163,7 +197,7 @@ public class CandyMgtCouponAdminController extends BaseController {
initMgtCoupon.setState(0); initMgtCoupon.setState(0);
initMgtCoupon.setEventAmt(buildParam.getEventAmt()); initMgtCoupon.setEventAmt(buildParam.getEventAmt());
initMgtCoupon.setEventType(buildParam.getEventType()); initMgtCoupon.setEventType(buildParam.getEventType());
initMgtCoupon.setEventLimit(eventLimit.toString()); initMgtCoupon.setEventLimit(buildParam.getEventLimit());
initMgtCoupon.setEventAt(eventAt); initMgtCoupon.setEventAt(eventAt);
initMgtCoupon.setOperator(operator); initMgtCoupon.setOperator(operator);
initMgtCoupon.setCreatedAt(nowTime); initMgtCoupon.setCreatedAt(nowTime);
......
...@@ -5,7 +5,7 @@ import lombok.Data; ...@@ -5,7 +5,7 @@ import lombok.Data;
@Data @Data
public class CandyMgtCouponListParam { public class CandyMgtCouponListParam {
/** /**
* 券类型[1-代金券|2-满减券|3-兑换券|4-折扣券] * 券类型[1-代金券|2-满减券|3-兑换券|4-折扣券|101-优先券]
*/ */
private Integer couType; private Integer couType;
/** /**
......
...@@ -60,7 +60,7 @@ public class CandyCoupon implements Serializable { ...@@ -60,7 +60,7 @@ public class CandyCoupon implements Serializable {
private Integer busiType; private Integer busiType;
/** /**
* 券类型[1-代金券|2-满减券|3-兑换券|4-折扣券] * 券类型[1-代金券|2-满减券|3-兑换券|4-折扣券|101-优先券]
*/ */
private Integer couType; private Integer couType;
......
...@@ -38,7 +38,7 @@ create table candy_coupon ...@@ -38,7 +38,7 @@ create table candy_coupon
notice varchar(200) comment '注意/须知', notice varchar(200) comment '注意/须知',
exclusive smallint comment '专享标识[0-常规|1-会员礼包]', exclusive smallint comment '专享标识[0-常规|1-会员礼包]',
busi_type smallint comment '业务类别[0-全场|1-演出|2-商品|3-优先购]', busi_type smallint comment '业务类别[0-全场|1-演出|2-商品|3-优先购]',
cou_type smallint comment '券类型[1-代金券|2-满减券|3-兑换券|4-折扣券]', cou_type smallint comment '券类型[1-代金券|2-满减券|3-兑换券|4-折扣券|101-优先券]',
bind_type smallint comment '领取方式[0-用户输入兑换|1-发放至用户]', bind_type smallint comment '领取方式[0-用户输入兑换|1-发放至用户]',
discount decimal(8, 2) comment '折扣[8折即0.8]', discount decimal(8, 2) comment '折扣[8折即0.8]',
......
...@@ -260,7 +260,7 @@ public class CandyCouponServiceImpl implements ICandyCouponService { ...@@ -260,7 +260,7 @@ public class CandyCouponServiceImpl implements ICandyCouponService {
dto.setCouType(dto.getCouType()); dto.setCouType(dto.getCouType());
} }
vo.setCouType(dto.getCouType()); vo.setCouType(dto.getCouType());
switch (dto.getCouType()) {//券类型[1-代金券|2-满减券|3-兑换券|4-折扣券] switch (dto.getCouType()) {//券类型[1-代金券|2-满减券|3-兑换券|4-折扣券|101-优先券]
case 1: case 1:
vo.setValue(dto.getValFace()); vo.setValue(dto.getValFace());
break; break;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment