后端 + 前端:优惠劵模板添加(未完成)
This commit is contained in:
@@ -0,0 +1,85 @@
|
||||
package cn.iocoder.mall.promotion.application.controller.admins;
|
||||
|
||||
import cn.iocoder.common.framework.vo.CommonResult;
|
||||
import cn.iocoder.mall.promotion.api.CouponService;
|
||||
import cn.iocoder.mall.promotion.api.bo.CouponTemplateBO;
|
||||
import cn.iocoder.mall.promotion.api.dto.CouponCardTemplateAddDTO;
|
||||
import cn.iocoder.mall.promotion.application.convert.CouponTemplateConvert;
|
||||
import cn.iocoder.mall.promotion.application.vo.admins.AdminsCouponTemplateVO;
|
||||
import com.alibaba.dubbo.config.annotation.Reference;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
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 java.util.Date;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("admins/product_recommend")
|
||||
@Api("优惠劵(码)模块")
|
||||
public class AdminsCouponTemplateController {
|
||||
|
||||
@Reference(validation = "true")
|
||||
private CouponService couponService;
|
||||
|
||||
// ========== 优惠劵(码)模板 ==========
|
||||
|
||||
@PostMapping("/template/add_card")
|
||||
@ApiOperation(value = "创建优惠劵模板")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "title", value = "标题", required = true, example = "优惠劵牛逼"),
|
||||
@ApiImplicitParam(name = "description", value = "使用说明", example = "我只是描述"),
|
||||
@ApiImplicitParam(name = "quota", value = "每人限领个数", example = "null - 则表示不限制"),
|
||||
@ApiImplicitParam(name = "stock", value = "剩余可用库存", example = "null - 则表示无限库存"),
|
||||
@ApiImplicitParam(name = "priceAvailable", value = "是否设置满多少金额可用,单位:分", example = "0-不限制;大于0-多少金额可用"),
|
||||
@ApiImplicitParam(name = "rangeType", value = "可用范围的类型", required = true, example = "参见 CouponTemplateRangeTypeEnum 枚举"),
|
||||
@ApiImplicitParam(name = "rangeValues", value = "指定商品 / 分类列表,使用逗号分隔商品编号"),
|
||||
@ApiImplicitParam(name = "dateType", value = "生效日期类型", example = "参见 CouponTemplateDateTypeEnum 枚举"),
|
||||
@ApiImplicitParam(name = "validStartTime", value = "固定日期-生效开始时间", example = "当 dateType 为固定日期时,非空"),
|
||||
@ApiImplicitParam(name = "validEndTime", value = "固定日期-生效结束时间", example = "当 dateType 为固定日期时,非空"),
|
||||
@ApiImplicitParam(name = "fixedBeginTerm", value = "领取日期-开始天数", example = "当 dateType 为领取日期时,非空"),
|
||||
@ApiImplicitParam(name = "fixedEndTerm", value = "领取日期-结束天数", example = "当 dateType 为领取日期时,非空"),
|
||||
@ApiImplicitParam(name = "preferentialType", value = "优惠类型", example = "参见 CouponTemplatePreferentialTypeEnum 枚举"),
|
||||
@ApiImplicitParam(name = "priceOff", value = "优惠金额,单位:分", example = "当 preferentialType 为现金券时,非空"),
|
||||
@ApiImplicitParam(name = "percentOff", value = "折扣百分比", example = "当 preferentialType 为折扣卷时,非空"),
|
||||
@ApiImplicitParam(name = "discountPriceLimit", value = "折扣上限", example = "当 preferentialType 为折扣卷时,非空"),
|
||||
})
|
||||
public CommonResult<AdminsCouponTemplateVO> add(@RequestParam(value = "title") String title,
|
||||
@RequestParam(value = "description", required = false) String description,
|
||||
@RequestParam(value = "quota", required = false) Integer quota,
|
||||
@RequestParam(value = "stock", required = false) Integer stock,
|
||||
@RequestParam(value = "priceAvailable") Integer priceAvailable,
|
||||
@RequestParam(value = "rangeType") Integer rangeType,
|
||||
@RequestParam(value = "rangeType", required = false) String rangeValues,
|
||||
@RequestParam(value = "dateType") Integer dateType,
|
||||
@RequestParam(value = "validStartTime", required = false) Date validStartTime,
|
||||
@RequestParam(value = "validEndTime", required = false) Date validEndTime,
|
||||
@RequestParam(value = "fixedBeginTerm", required = false) Integer fixedBeginTerm,
|
||||
@RequestParam(value = "fixedEndTerm", required = false) Integer fixedEndTerm,
|
||||
@RequestParam(value = "preferentialType") Integer preferentialType,
|
||||
@RequestParam(value = "priceOff", required = false) Integer priceOff,
|
||||
@RequestParam(value = "percentOff", required = false) Integer percentOff,
|
||||
@RequestParam(value = "discountPriceLimit", required = false) Integer discountPriceLimit) {
|
||||
// 创建 CouponCardTemplateAddDTO 对象
|
||||
CouponCardTemplateAddDTO couponCardTemplateAddDTO = new CouponCardTemplateAddDTO()
|
||||
.setTitle(title).setDescription(description)
|
||||
.setQuota(quota).setStock(stock)
|
||||
.setPriceAvailable(priceAvailable).setRangeType(rangeType).setRangeValues(rangeValues)
|
||||
.setDateType(dateType).setValidStartTime(validStartTime).setValidEndTime(validEndTime)
|
||||
.setFixedBeginTerm(fixedBeginTerm).setFixedEndTerm(fixedEndTerm)
|
||||
.setPreferentialType(preferentialType).setPriceOff(priceOff).setPercentOff(percentOff).setDiscountPriceLimit(discountPriceLimit);
|
||||
// 提交请求
|
||||
CommonResult<CouponTemplateBO> result = couponService.addCouponCardTemplate(couponCardTemplateAddDTO);
|
||||
// 返回结果
|
||||
return CouponTemplateConvert.INSTANCE.convert2(result);
|
||||
}
|
||||
|
||||
// ========== 优惠劵 ==========
|
||||
|
||||
// ========== 优惠码 ==========
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package cn.iocoder.mall.promotion.application.convert;
|
||||
|
||||
import cn.iocoder.common.framework.vo.CommonResult;
|
||||
import cn.iocoder.mall.promotion.api.bo.CouponTemplateBO;
|
||||
import cn.iocoder.mall.promotion.application.vo.admins.AdminsCouponTemplateVO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mappings;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
@Mapper
|
||||
public interface CouponTemplateConvert {
|
||||
|
||||
CouponTemplateConvert INSTANCE = Mappers.getMapper(CouponTemplateConvert.class);
|
||||
|
||||
@Mappings({})
|
||||
AdminsCouponTemplateVO convert(CouponTemplateBO bannerBO);
|
||||
|
||||
@Mappings({})
|
||||
CommonResult<AdminsCouponTemplateVO> convert2(CommonResult<CouponTemplateBO> result);
|
||||
|
||||
// @Mappings({})
|
||||
// CommonResult<AdminsCouponTemplatePageVO> convert(CommonResult<CouponTemplatePageBO> result);
|
||||
//
|
||||
// @Mappings({})
|
||||
// List<UsersCouponTemplateVO> convertList(List<CouponTemplateBO> banners);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,273 @@
|
||||
package cn.iocoder.mall.promotion.application.vo.admins;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@ApiModel("CouponTemplate VO")
|
||||
public class AdminsCouponTemplateVO {
|
||||
|
||||
// ========== 基本信息 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 = "参见 CouponTemplateTypeEnum 枚举")
|
||||
private Integer type;
|
||||
/**
|
||||
* 码类型
|
||||
*
|
||||
* 1-一卡一码(UNIQUE)
|
||||
* 2-通用码(GENERAL)
|
||||
*
|
||||
* 【优惠码独有】 @see CouponCodeDO
|
||||
*/
|
||||
// TODO
|
||||
private Integer codeType;
|
||||
@ApiModelProperty(value = "优惠码状态", required = true, example = "参见 CouponTemplateStatusEnum 枚举")
|
||||
private Integer status;
|
||||
@ApiModelProperty(value = "每人限领个数", example = "null - 则表示不限制")
|
||||
private Integer quota;
|
||||
@ApiModelProperty(value = "发放总量")
|
||||
private Integer total;
|
||||
// ========== 领取规则 END ==========
|
||||
|
||||
// ========== 使用规则 BEGIN ==========
|
||||
@ApiModelProperty(value = "是否设置满多少金额可用,单位:分", required = true, example = "0-不限制;大于0-多少金额可用")
|
||||
private Integer priceAvailable;
|
||||
@ApiModelProperty(value = "可用范围的类型", required = true, example = "参见 CouponTemplateRangeTypeEnum 枚举")
|
||||
private Integer rangeType;
|
||||
@ApiModelProperty(value = "指定商品 / 分类列表,使用逗号分隔商品编号", example = "参见 CouponTemplateRangeTypeEnum 枚举")
|
||||
private String rangeValues;
|
||||
@ApiModelProperty(value = "生效日期类型", example = "参见 CouponTemplateDateTypeEnum 枚举")
|
||||
private Integer dateType;
|
||||
@ApiModelProperty(value = "固定日期-生效开始时间")
|
||||
private Date validStartTime;
|
||||
@ApiModelProperty(value = "固定日期-生效结束时间")
|
||||
private Date validEndTime;
|
||||
@ApiModelProperty(value = "领取日期-开始天数", example = "例如,0-当天;1-次天")
|
||||
private Integer fixedBeginTerm;
|
||||
@ApiModelProperty(value = "领取日期-结束天数")
|
||||
private Integer fixedEndTerm;
|
||||
// ========== 使用规则 END ==========
|
||||
|
||||
// ========== 使用效果 BEGIN ==========
|
||||
@ApiModelProperty(value = "优惠类型", example = "参见 CouponTemplatePreferentialTypeEnum 枚举")
|
||||
private Integer preferentialType;
|
||||
@ApiModelProperty(value = "折扣百分比")
|
||||
private Integer percentOff;
|
||||
@ApiModelProperty(value = "优惠金额,单位:分")
|
||||
private Integer priceOff;
|
||||
@ApiModelProperty(value = "折扣上限")
|
||||
private Integer discountPriceLimit;
|
||||
// ========== 使用效果 END ==========
|
||||
|
||||
// ========== 统计信息 BEGIN ==========
|
||||
@ApiModelProperty(value = "折扣上限", required = true)
|
||||
private Integer statFetchNum;
|
||||
// ========== 统计信息 END ==========
|
||||
|
||||
@ApiModelProperty(value = "折扣上限", required = true)
|
||||
private Date createTime;
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public AdminsCouponTemplateVO setId(Integer id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public AdminsCouponTemplateVO setTitle(String title) {
|
||||
this.title = title;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public AdminsCouponTemplateVO setDescription(String description) {
|
||||
this.description = description;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Integer getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public AdminsCouponTemplateVO setType(Integer type) {
|
||||
this.type = type;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Integer getCodeType() {
|
||||
return codeType;
|
||||
}
|
||||
|
||||
public AdminsCouponTemplateVO setCodeType(Integer codeType) {
|
||||
this.codeType = codeType;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Integer getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public AdminsCouponTemplateVO setStatus(Integer status) {
|
||||
this.status = status;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Integer getQuota() {
|
||||
return quota;
|
||||
}
|
||||
|
||||
public AdminsCouponTemplateVO setQuota(Integer quota) {
|
||||
this.quota = quota;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Integer getStock() {
|
||||
return stock;
|
||||
}
|
||||
|
||||
public AdminsCouponTemplateVO setStock(Integer stock) {
|
||||
this.stock = stock;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Integer getPriceAvailable() {
|
||||
return priceAvailable;
|
||||
}
|
||||
|
||||
public AdminsCouponTemplateVO setPriceAvailable(Integer priceAvailable) {
|
||||
this.priceAvailable = priceAvailable;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Integer getRangeType() {
|
||||
return rangeType;
|
||||
}
|
||||
|
||||
public AdminsCouponTemplateVO setRangeType(Integer rangeType) {
|
||||
this.rangeType = rangeType;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getRangeValues() {
|
||||
return rangeValues;
|
||||
}
|
||||
|
||||
public AdminsCouponTemplateVO setRangeValues(String rangeValues) {
|
||||
this.rangeValues = rangeValues;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Integer getDateType() {
|
||||
return dateType;
|
||||
}
|
||||
|
||||
public AdminsCouponTemplateVO setDateType(Integer dateType) {
|
||||
this.dateType = dateType;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Date getValidStartTime() {
|
||||
return validStartTime;
|
||||
}
|
||||
|
||||
public AdminsCouponTemplateVO setValidStartTime(Date validStartTime) {
|
||||
this.validStartTime = validStartTime;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Date getValidEndTime() {
|
||||
return validEndTime;
|
||||
}
|
||||
|
||||
public AdminsCouponTemplateVO setValidEndTime(Date validEndTime) {
|
||||
this.validEndTime = validEndTime;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Integer getFixedBeginTerm() {
|
||||
return fixedBeginTerm;
|
||||
}
|
||||
|
||||
public AdminsCouponTemplateVO setFixedBeginTerm(Integer fixedBeginTerm) {
|
||||
this.fixedBeginTerm = fixedBeginTerm;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Integer getFixedEndTerm() {
|
||||
return fixedEndTerm;
|
||||
}
|
||||
|
||||
public AdminsCouponTemplateVO setFixedEndTerm(Integer fixedEndTerm) {
|
||||
this.fixedEndTerm = fixedEndTerm;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Integer getPreferentialType() {
|
||||
return preferentialType;
|
||||
}
|
||||
|
||||
public AdminsCouponTemplateVO setPreferentialType(Integer preferentialType) {
|
||||
this.preferentialType = preferentialType;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Integer getPercentOff() {
|
||||
return percentOff;
|
||||
}
|
||||
|
||||
public AdminsCouponTemplateVO setPercentOff(Integer percentOff) {
|
||||
this.percentOff = percentOff;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Integer getPriceOff() {
|
||||
return priceOff;
|
||||
}
|
||||
|
||||
public AdminsCouponTemplateVO setPriceOff(Integer priceOff) {
|
||||
this.priceOff = priceOff;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Integer getDiscountPriceLimit() {
|
||||
return discountPriceLimit;
|
||||
}
|
||||
|
||||
public AdminsCouponTemplateVO setDiscountPriceLimit(Integer discountPriceLimit) {
|
||||
this.discountPriceLimit = discountPriceLimit;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Integer getStatFetchNum() {
|
||||
return statFetchNum;
|
||||
}
|
||||
|
||||
public AdminsCouponTemplateVO setStatFetchNum(Integer statFetchNum) {
|
||||
this.statFetchNum = statFetchNum;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Date getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
||||
public AdminsCouponTemplateVO setCreateTime(Date createTime) {
|
||||
this.createTime = createTime;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user