后端 + 前端:优惠劵模板添加
This commit is contained in:
@@ -82,11 +82,9 @@ public class CouponTemplateDO extends BaseDO {
|
||||
*/
|
||||
private Integer quota;
|
||||
/**
|
||||
* 剩余可用库存
|
||||
*
|
||||
* null - 则表示无限库存
|
||||
* 发行总量
|
||||
*/
|
||||
private Integer stock;
|
||||
private Integer total;
|
||||
// ========== 领取规则 END ==========
|
||||
|
||||
// ========== 使用规则 BEGIN ==========
|
||||
@@ -274,12 +272,12 @@ public class CouponTemplateDO extends BaseDO {
|
||||
return this;
|
||||
}
|
||||
|
||||
public Integer getStock() {
|
||||
return stock;
|
||||
public Integer getTotal() {
|
||||
return total;
|
||||
}
|
||||
|
||||
public CouponTemplateDO setStock(Integer stock) {
|
||||
this.stock = stock;
|
||||
public CouponTemplateDO setTotal(Integer total) {
|
||||
this.total = total;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@@ -49,8 +49,8 @@ public class CouponServiceImpl implements CouponService {
|
||||
// 校验优惠类型
|
||||
CommonResult<Boolean> checkCouponTemplateDateTypeResult = this.checkCouponTemplatePreferentialType(
|
||||
couponCardTemplateAddDTO.getPreferentialType(), couponCardTemplateAddDTO.getPercentOff(),
|
||||
couponCardTemplateAddDTO.getPriceOff());
|
||||
if (checkCouponCodeTemplateDateTypeResult.isError()) {
|
||||
couponCardTemplateAddDTO.getPriceOff(), couponCardTemplateAddDTO.getPriceAvailable());
|
||||
if (checkCouponTemplateDateTypeResult.isError()) {
|
||||
return CommonResult.error(checkCouponTemplateDateTypeResult);
|
||||
}
|
||||
// 保存优惠劵模板到数据库
|
||||
@@ -58,6 +58,7 @@ public class CouponServiceImpl implements CouponService {
|
||||
.setType(CouponTemplateTypeEnum.CARD.getValue())
|
||||
.setStatus(CouponTemplateStatusEnum.ENABLE.getValue())
|
||||
.setStatFetchNum(0);
|
||||
template.setCreateTime(new Date());
|
||||
couponTemplateMapper.insert(template);
|
||||
// 返回成功
|
||||
return CommonResult.success(CouponTemplateConvert.INSTANCE.convert(template));
|
||||
@@ -106,6 +107,9 @@ public class CouponServiceImpl implements CouponService {
|
||||
if (validEndTime == null) {
|
||||
return CommonResult.error(SysErrorCodeEnum.VALIDATION_REQUEST_PARAM_ERROR.getCode(), "生效结束时间不能为空");
|
||||
}
|
||||
if (validStartTime.after(validEndTime)) {
|
||||
return CommonResult.error(SysErrorCodeEnum.VALIDATION_REQUEST_PARAM_ERROR.getCode(), "生效开始时间不能大于生效结束时间");
|
||||
}
|
||||
} else if (CouponTemplateDateTypeEnum.FIXED_TERM.getValue().equals(dateType)) { // 领取日期
|
||||
if (fixedBeginTerm == null) {
|
||||
return CommonResult.error(SysErrorCodeEnum.VALIDATION_REQUEST_PARAM_ERROR.getCode(), "领取日期开始时间不能为空");
|
||||
@@ -119,11 +123,15 @@ public class CouponServiceImpl implements CouponService {
|
||||
return CommonResult.success(true);
|
||||
}
|
||||
|
||||
private CommonResult<Boolean> checkCouponTemplatePreferentialType(Integer preferentialType, Integer percentOff, Integer priceOff) {
|
||||
private CommonResult<Boolean> checkCouponTemplatePreferentialType(Integer preferentialType, Integer percentOff,
|
||||
Integer priceOff, Integer priceAvailable) {
|
||||
if (CouponTemplatePreferentialTypeEnum.PRICE.getValue().equals(preferentialType)) {
|
||||
if (priceOff == null) {
|
||||
return CommonResult.error(SysErrorCodeEnum.VALIDATION_REQUEST_PARAM_ERROR.getCode(), "优惠金额不能为空");
|
||||
}
|
||||
if (priceOff >= priceAvailable) {
|
||||
return CommonResult.error(SysErrorCodeEnum.VALIDATION_REQUEST_PARAM_ERROR.getCode(), "优惠金额不能d大于等于使用金额门槛");
|
||||
}
|
||||
} else if (CouponTemplatePreferentialTypeEnum.DISCOUNT.getValue().equals(preferentialType)) {
|
||||
if (percentOff == null) {
|
||||
return CommonResult.error(SysErrorCodeEnum.VALIDATION_REQUEST_PARAM_ERROR.getCode(), "折扣百分比不能为空");
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
<sql id="FIELDS">
|
||||
id, title, description, type, code_type,
|
||||
status, quota, stock, price_available, range_type,
|
||||
status, quota, total, price_available, range_type,
|
||||
range_values, date_type, valid_start_time, valid_end_time, fixed_term,
|
||||
preferential_type, percent_off, price_off, discount_price_limit, stat_fetch_num,
|
||||
create_time
|
||||
@@ -100,8 +100,8 @@
|
||||
<if test="quota != null">
|
||||
quota = #{quota},
|
||||
</if>
|
||||
<if test="stock != null">
|
||||
stock = #{stock},
|
||||
<if test="total != null">
|
||||
total = #{total},
|
||||
</if>
|
||||
<if test="priceAvailable != null">
|
||||
price_available = #{priceAvailable},
|
||||
|
||||
Reference in New Issue
Block a user