优惠劵模板相关逻辑的迁移
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
package cn.iocoder.mall.managementweb.controller.promotion.coupon;
|
||||
|
||||
import cn.iocoder.common.framework.vo.CommonResult;
|
||||
import cn.iocoder.mall.managementweb.controller.promotion.coupon.vo.template.CouponTemplateCardCreateReqVO;
|
||||
import cn.iocoder.mall.managementweb.controller.promotion.coupon.vo.template.CouponTemplateCardUpdateReqVO;
|
||||
import cn.iocoder.mall.managementweb.manager.promotion.coupon.CouponTemplateManager;
|
||||
import cn.iocoder.security.annotations.RequiresPermissions;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.validation.Valid;
|
||||
|
||||
import static cn.iocoder.common.framework.vo.CommonResult.success;
|
||||
|
||||
/**
|
||||
* 优惠劵模板 Controller
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/promotion/coupon-template")
|
||||
@Api(tags = "优惠劵(码)模板 API")
|
||||
@Validated
|
||||
public class CouponTemplateController {
|
||||
|
||||
@Autowired
|
||||
private CouponTemplateManager couponTemplateManager;
|
||||
|
||||
@PostMapping("/create-card")
|
||||
@ApiOperation("创建优惠劵模板")
|
||||
@RequiresPermissions("promotion:coupon-template:create-card")
|
||||
public CommonResult<Integer> createCouponTemplateCard(@Valid CouponTemplateCardCreateReqVO createVO) {
|
||||
return success(couponTemplateManager.createCouponTemplateCard(createVO));
|
||||
}
|
||||
|
||||
@PostMapping("/update-card")
|
||||
@ApiOperation("更新优惠劵模板")
|
||||
@RequiresPermissions("promotion:coupon-template:update-card")
|
||||
public CommonResult<Boolean> updateCouponTemplateCard(@Valid CouponTemplateCardUpdateReqVO updateVO) {
|
||||
couponTemplateManager.updateCouponTemplateCard(updateVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@PostMapping("/update-status")
|
||||
@ApiOperation("更新优惠劵(码)模板")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "id", value = "优惠劵(码)模板编号", required = true, example = "1"),
|
||||
@ApiImplicitParam(name = "status", value = "状态。1 - 开启;2 - 禁用", required = true, example = "1"),
|
||||
})
|
||||
@RequiresPermissions("promotion:coupon-template:update-status")
|
||||
public CommonResult<Boolean> updateCouponTemplateStatus(@RequestParam("id") Integer id,
|
||||
@RequestParam("status") Integer status) {
|
||||
couponTemplateManager.updateCouponTemplateStatus(id, status);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
package cn.iocoder.mall.managementweb.controller.promotion.coupon.vo.template;
|
||||
|
||||
import cn.iocoder.common.framework.validator.InEnum;
|
||||
import cn.iocoder.mall.promotion.api.enums.PreferentialTypeEnum;
|
||||
import cn.iocoder.mall.promotion.api.enums.RangeTypeEnum;
|
||||
import cn.iocoder.mall.promotion.api.enums.coupon.template.CouponTemplateDateTypeEnum;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
|
||||
import javax.validation.constraints.Max;
|
||||
import javax.validation.constraints.Min;
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.Date;
|
||||
|
||||
@ApiModel("优惠劵模板创建 Request VO")
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class CouponTemplateCardCreateReqVO {
|
||||
|
||||
// ========== 基本信息 BEGIN ==========
|
||||
@ApiModelProperty(value = "标题", required = true, example = "优惠劵牛逼")
|
||||
@NotEmpty(message = "标题不能为空")
|
||||
@Length(min = 2, max = 16, message = "标题长度为 {min}-{max} 位")
|
||||
private String title;
|
||||
@ApiModelProperty(value = "使用说明", required = true, example = "我只是描述")
|
||||
@Length(max = 255, message = "使用说明最大长度为 {max} 位")
|
||||
private String description;
|
||||
@ApiModelProperty(value = "每人限领个数", example = "1", notes = "null - 则表示不限制")
|
||||
@Min(value = 1, message = "每人限领个数最小为 {value}")
|
||||
private Integer quota;
|
||||
@ApiModelProperty(value = "发放总量", example = "100")
|
||||
@Min(value = 1, message = "每人限领个数最小为 {value}")
|
||||
private Integer total;
|
||||
// ========== 领取规则 END ==========
|
||||
|
||||
// ========== 使用规则 BEGIN ==========
|
||||
@ApiModelProperty(value = "是否设置满多少金额可用,单位:分", required = true, example = "0", notes = "0-不限制;大于0-多少金额可用")
|
||||
@Min(value = 0L, message = "使用金额门槛最低为 {value}")
|
||||
private Integer priceAvailable;
|
||||
@ApiModelProperty(value = "可用范围的类型", required = true, example = "10", notes = "参见 RangeTypeEnum 枚举")
|
||||
@NotNull(message = "可用范围的类型不能为空")
|
||||
@InEnum(value = RangeTypeEnum.class, message = "可用范围的类型必须在 {value}")
|
||||
private Integer rangeType;
|
||||
@ApiModelProperty(value = "指定商品 / 分类列表,使用逗号分隔商品编号", example = "1,3,5")
|
||||
private String rangeValues;
|
||||
@ApiModelProperty(value = "生效日期类型", example = "1", notes = "参见 CouponTemplateDateTypeEnum 枚举")
|
||||
@NotNull(message = "生效日期类型不能为空")
|
||||
@InEnum(value = CouponTemplateDateTypeEnum.class, message = "生效日期类型必须在 {value}")
|
||||
private Integer dateType;
|
||||
@ApiModelProperty(value = "固定日期-生效开始时间", notes = "当 dateType 为固定日期时,非空")
|
||||
private Date validStartTime;
|
||||
@ApiModelProperty(value = "固定日期-生效结束时间", notes = "当 dateType 为固定日期时,非空")
|
||||
private Date validEndTime;
|
||||
@ApiModelProperty(value = "领取日期-开始天数", example = "0", notes = "例如,0-当天;1-次天")
|
||||
@Min(value = 0L, message = "领取日期开始时间最小为 {value}")
|
||||
private Integer fixedStartTerm;
|
||||
@ApiModelProperty(value = "领取日期-结束天数", example = "1", notes = "当 dateType 为领取日期时,非空")
|
||||
@Min(value = 1L, message = "领取日期结束时间最小为 {value}")
|
||||
private Integer fixedEndTerm;
|
||||
|
||||
// ========== 使用效果 BEGIN ==========
|
||||
@ApiModelProperty(value = "优惠类型", required = true, example = "1", notes = "参见 PreferentialTypeEnum 枚举")
|
||||
@NotNull(message = "优惠类型不能为空")
|
||||
@InEnum(value = PreferentialTypeEnum.class, message = "优惠类型必须在 {value}")
|
||||
private Integer preferentialType;
|
||||
@ApiModelProperty(value = "折扣百分比", example = "80", notes = "当 preferentialType 为现金券时,非空")
|
||||
@Max(value = 100, message = "折扣比最大值为 {value}")
|
||||
private Integer percentOff;
|
||||
@ApiModelProperty(value = "优惠金额,单位:分", example = "100", notes = "当 preferentialType 为折扣卷时,非空")
|
||||
@Min(value = 1, message = "优惠金额最小值为 {value}")
|
||||
private Integer priceOff;
|
||||
@ApiModelProperty(value = "折扣上限", example = "100", notes = "当 preferentialType 为折扣卷时,非空")
|
||||
@Min(value = 1, message = "折扣上限最小值为 {value}")
|
||||
private Integer discountPriceLimit;
|
||||
// ========== 使用效果 END ==========
|
||||
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package cn.iocoder.mall.managementweb.controller.promotion.coupon.vo.template;
|
||||
|
||||
import cn.iocoder.common.framework.validator.InEnum;
|
||||
import cn.iocoder.mall.promotion.api.enums.RangeTypeEnum;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
|
||||
import javax.validation.constraints.Min;
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
@ApiModel("优惠劵模板更新 Request VO")
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class CouponTemplateCardUpdateReqVO {
|
||||
|
||||
// ========== 基本信息 BEGIN ==========
|
||||
@ApiModelProperty(value = "模板编号,自增唯一", required = true, example = "1")
|
||||
@NotNull(message = "编号不能为空")
|
||||
private Integer id;
|
||||
@ApiModelProperty(value = "标题", required = true, example = "优惠劵牛逼")
|
||||
@NotEmpty(message = "标题不能为空")
|
||||
@Length(min = 2, max = 16, message = "标题长度为 {min}-{max} 位")
|
||||
private String title;
|
||||
@ApiModelProperty(value = "使用说明", required = true, example = "我只是描述")
|
||||
@Length(max = 255, message = "使用说明最大长度为 {max} 位")
|
||||
private String description;
|
||||
@ApiModelProperty(value = "每人限领个数", example = "1", notes = "null - 则表示不限制")
|
||||
@Min(value = 1, message = "每人限领个数最小为 {value}")
|
||||
private Integer quota;
|
||||
@ApiModelProperty(value = "发放总量", example = "100")
|
||||
@Min(value = 1, message = "每人限领个数最小为 {value}")
|
||||
private Integer total;
|
||||
// ========== 领取规则 END ==========
|
||||
|
||||
// ========== 使用规则 BEGIN ==========
|
||||
@NotNull(message = "可用范围的类型不能为空")
|
||||
@InEnum(value = RangeTypeEnum.class, message = "可用范围的类型必须在 {value}")
|
||||
private Integer rangeType;
|
||||
@ApiModelProperty(value = "指定商品 / 分类列表,使用逗号分隔商品编号", example = "1,3,5")
|
||||
private String rangeValues;
|
||||
// ========== 使用规则 END ==========
|
||||
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
package cn.iocoder.mall.managementweb.controller.promotion.coupon.vo.template;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@ApiModel("优惠劵(码)模板 VO")
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class CouponTemplateRespVO {
|
||||
|
||||
// ========== 基本信息 BEGIN ==========
|
||||
@ApiModelProperty(value = "模板编号,自增唯一", required = true, example = "1")
|
||||
private Integer id;
|
||||
@ApiModelProperty(value = "标题", required = true, example = "优惠劵牛逼")
|
||||
private String title;
|
||||
@ApiModelProperty(value = "使用说明", required = true, example = "我只是描述")
|
||||
private String description;
|
||||
@ApiModelProperty(value = "优惠劵类型", required = true, example = "1", notes = "参见 CouponTemplateTypeEnum 枚举")
|
||||
private Integer type;
|
||||
/**
|
||||
* 码类型
|
||||
*
|
||||
* 1-一卡一码(UNIQUE)
|
||||
* 2-通用码(GENERAL)
|
||||
*
|
||||
* 【优惠码独有】 @see CouponCodeDO
|
||||
*/
|
||||
private Integer codeType;
|
||||
@ApiModelProperty(value = "优惠码状态", required = true, example = "1", notes = "参见 CouponTemplateStatusEnum 枚举")
|
||||
private Integer status;
|
||||
@ApiModelProperty(value = "每人限领个数", example = "1", notes = "null - 则表示不限制")
|
||||
private Integer quota;
|
||||
@ApiModelProperty(value = "发放总量", example = "100")
|
||||
private Integer total;
|
||||
// ========== 领取规则 END ==========
|
||||
|
||||
// ========== 使用规则 BEGIN ==========
|
||||
@ApiModelProperty(value = "是否设置满多少金额可用,单位:分", required = true, example = "0", notes = "0-不限制;大于0-多少金额可用")
|
||||
private Integer priceAvailable;
|
||||
@ApiModelProperty(value = "可用范围的类型", required = true, example = "10", notes = "参见 RangeTypeEnum 枚举")
|
||||
private Integer rangeType;
|
||||
@ApiModelProperty(value = "指定商品 / 分类列表,使用逗号分隔商品编号", example = "1,3,5")
|
||||
private String rangeValues;
|
||||
@ApiModelProperty(value = "生效日期类型", example = "1", notes = "参见 CouponTemplateDateTypeEnum 枚举")
|
||||
private Integer dateType;
|
||||
@ApiModelProperty(value = "固定日期-生效开始时间", notes = "当 dateType 为固定日期时,非空")
|
||||
private Date validStartTime;
|
||||
@ApiModelProperty(value = "固定日期-生效结束时间", notes = "当 dateType 为固定日期时,非空")
|
||||
private Date validEndTime;
|
||||
@ApiModelProperty(value = "领取日期-开始天数", example = "0", notes = "例如,0-当天;1-次天")
|
||||
private Integer fixedStartTerm;
|
||||
@ApiModelProperty(value = "领取日期-结束天数", example = "1", notes = "当 dateType 为领取日期时,非空")
|
||||
private Integer fixedEndTerm;
|
||||
// ========== 使用规则 END ==========
|
||||
|
||||
// ========== 使用效果 BEGIN ==========
|
||||
@ApiModelProperty(value = "优惠类型", required = true, example = "1", notes = "参见 PreferentialTypeEnum 枚举")
|
||||
private Integer preferentialType;
|
||||
@ApiModelProperty(value = "折扣百分比", example = "80", notes = "当 preferentialType 为现金券时,非空")
|
||||
private Integer percentOff;
|
||||
@ApiModelProperty(value = "优惠金额,单位:分", example = "100", notes = "当 preferentialType 为折扣卷时,非空")
|
||||
private Integer priceOff;
|
||||
@ApiModelProperty(value = "折扣上限", example = "100", notes = "当 preferentialType 为折扣卷时,非空")
|
||||
private Integer discountPriceLimit;
|
||||
// ========== 使用效果 END ==========
|
||||
|
||||
// ========== 统计信息 BEGIN ==========
|
||||
@ApiModelProperty(value = "领取优惠券的次数", required = true)
|
||||
private Integer statFetchNum;
|
||||
// ========== 统计信息 END ==========
|
||||
|
||||
@ApiModelProperty(value = "创建时间", required = true)
|
||||
private Date createTime;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package cn.iocoder.mall.managementweb.convert.promotion.coupon;
|
||||
|
||||
import cn.iocoder.mall.managementweb.controller.promotion.coupon.vo.template.CouponTemplateCardUpdateReqVO;
|
||||
import cn.iocoder.mall.promotion.api.rpc.coupon.dto.template.CouponCardTemplateUpdateReqDTO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
@Mapper
|
||||
public interface CouponTemplateConvert {
|
||||
|
||||
CouponTemplateConvert INSTANCE = Mappers.getMapper(CouponTemplateConvert.class);
|
||||
|
||||
CouponCardTemplateUpdateReqDTO convert(CouponTemplateCardUpdateReqVO bean);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package cn.iocoder.mall.managementweb.manager.promotion.coupon;
|
||||
|
||||
import cn.iocoder.common.framework.vo.CommonResult;
|
||||
import cn.iocoder.mall.managementweb.controller.promotion.coupon.vo.template.CouponTemplateCardCreateReqVO;
|
||||
import cn.iocoder.mall.managementweb.controller.promotion.coupon.vo.template.CouponTemplateCardUpdateReqVO;
|
||||
import cn.iocoder.mall.managementweb.convert.promotion.coupon.CouponTemplateConvert;
|
||||
import cn.iocoder.mall.promotion.api.rpc.coupon.CouponTemplateRpc;
|
||||
import cn.iocoder.mall.promotion.api.rpc.coupon.dto.template.CouponCardTemplateUpdateStatusReqDTO;
|
||||
import org.apache.dubbo.config.annotation.DubboReference;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
@Service
|
||||
@Validated
|
||||
public class CouponTemplateManager {
|
||||
|
||||
@DubboReference(version = "${dubbo.consumer.CouponTemplateRpc.version}")
|
||||
private CouponTemplateRpc couponTemplateRpc;
|
||||
|
||||
public Integer createCouponTemplateCard(CouponTemplateCardCreateReqVO createVO) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void updateCouponTemplateCard(CouponTemplateCardUpdateReqVO updateVO) {
|
||||
CommonResult<Boolean> updateCouponCardTemplateResult = couponTemplateRpc.updateCouponCardTemplate(
|
||||
CouponTemplateConvert.INSTANCE.convert(updateVO));
|
||||
updateCouponCardTemplateResult.checkError();
|
||||
}
|
||||
|
||||
public void updateCouponTemplateStatus(Integer id, Integer status) {
|
||||
CommonResult<Boolean> updateCouponTemplateStatusResult = couponTemplateRpc.updateCouponTemplateStatus(
|
||||
new CouponCardTemplateUpdateStatusReqDTO().setId(id).setStatus(status));
|
||||
updateCouponTemplateStatusResult.checkError();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -6,7 +6,7 @@ import cn.iocoder.mall.managementweb.controller.systemlog.dto.SystemAccessLogPag
|
||||
import cn.iocoder.mall.managementweb.controller.systemlog.vo.SystemAccessLogVO;
|
||||
import cn.iocoder.mall.managementweb.convert.systemlog.SystemAccessLogConvert;
|
||||
import cn.iocoder.mall.systemservice.rpc.systemlog.SystemAccessLogRpc;
|
||||
import org.apache.dubbo.config.annotation.Reference;
|
||||
import org.apache.dubbo.config.annotation.DubboReference;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
@@ -15,7 +15,7 @@ import org.springframework.stereotype.Service;
|
||||
@Service
|
||||
public class SystemAccessLogManager {
|
||||
|
||||
@Reference(version = "${dubbo.consumer.SystemAccessLogRpc.version}")
|
||||
@DubboReference(version = "${dubbo.consumer.SystemAccessLogRpc.version}")
|
||||
private SystemAccessLogRpc systemAccessLogRpc;
|
||||
|
||||
/**
|
||||
|
||||
@@ -57,6 +57,8 @@ dubbo:
|
||||
version: 1.0.0
|
||||
ProductAttrRpc:
|
||||
version: 1.0.0
|
||||
CouponTemplateRpc:
|
||||
version: 1.0.0
|
||||
|
||||
# Swagger 配置项
|
||||
swagger:
|
||||
|
||||
Reference in New Issue
Block a user