diff --git a/yudao-module-mall/yudao-module-coupon-api/src/main/java/cn/iocoder/yudao/module/CouponTemplete/enums/CouponExpireTimeTypeEnum.java b/yudao-module-mall/yudao-module-coupon-api/src/main/java/cn/iocoder/yudao/module/CouponTemplete/enums/CouponExpireTimeTypeEnum.java new file mode 100644 index 000000000..be6d2a90e --- /dev/null +++ b/yudao-module-mall/yudao-module-coupon-api/src/main/java/cn/iocoder/yudao/module/CouponTemplete/enums/CouponExpireTimeTypeEnum.java @@ -0,0 +1,28 @@ +package cn.iocoder.yudao.module.CouponTemplete.enums; + + +import lombok.Getter; +import lombok.RequiredArgsConstructor; + + +/** + * 优惠券 - 是否开启过期提醒 + * + * @author Sin + */ +@RequiredArgsConstructor +@Getter +public enum CouponExpireTimeTypeEnum { + + OPEN(1,"不开启"),CLOSE(0,"开启"),; + + /** + * 是否开启过期提醒 + */ + private final Integer type; + /** + * 是否开启过期提醒 + */ + private final String name; + +} diff --git a/yudao-module-mall/yudao-module-coupon-api/src/main/java/cn/iocoder/yudao/module/CouponTemplete/enums/CouponFetchTypeEnum.java b/yudao-module-mall/yudao-module-coupon-api/src/main/java/cn/iocoder/yudao/module/CouponTemplete/enums/CouponFetchTypeEnum.java new file mode 100644 index 000000000..ffdd99c28 --- /dev/null +++ b/yudao-module-mall/yudao-module-coupon-api/src/main/java/cn/iocoder/yudao/module/CouponTemplete/enums/CouponFetchTypeEnum.java @@ -0,0 +1,28 @@ +package cn.iocoder.yudao.module.CouponTemplete.enums; + + +import lombok.Getter; +import lombok.RequiredArgsConstructor; + + +/** + * 优惠券 - 领取是否无限制 0 + * + * @author Sin + */ +@RequiredArgsConstructor +@Getter +public enum CouponFetchTypeEnum { + + LIMIT(0,"否"),NOT_LIMIT(0,"开启"),; + + /** + * 是否开启过期提醒 + */ + private final Integer type; + /** + * 是否开启过期提醒 + */ + private final String name; + +} diff --git a/yudao-module-mall/yudao-module-coupon-api/src/main/java/cn/iocoder/yudao/module/CouponTemplete/enums/CouponProductTypeEnum.java b/yudao-module-mall/yudao-module-coupon-api/src/main/java/cn/iocoder/yudao/module/CouponTemplete/enums/CouponProductTypeEnum.java new file mode 100644 index 000000000..f5e6cf995 --- /dev/null +++ b/yudao-module-mall/yudao-module-coupon-api/src/main/java/cn/iocoder/yudao/module/CouponTemplete/enums/CouponProductTypeEnum.java @@ -0,0 +1,30 @@ +package cn.iocoder.yudao.module.CouponTemplete.enums; + + +import lombok.Getter; +import lombok.RequiredArgsConstructor; + + +/** + * 优惠券 - 优惠券类型 + * + * @author Sin + */ +@RequiredArgsConstructor +@Getter +public enum CouponProductTypeEnum { + + PROCESSING(1,"进行中"), + END(2,"已结束"), + CLOSE(3,"已关闭"),; + + /** + * 优惠券类型 + */ + private final Integer type; + /** + * 优惠券类型名 + */ + private final String name; + +} diff --git a/yudao-module-mall/yudao-module-coupon-api/src/main/java/cn/iocoder/yudao/module/CouponTemplete/enums/CouponStatusTypeEnum.java b/yudao-module-mall/yudao-module-coupon-api/src/main/java/cn/iocoder/yudao/module/CouponTemplete/enums/CouponStatusTypeEnum.java new file mode 100644 index 000000000..c58ce36b4 --- /dev/null +++ b/yudao-module-mall/yudao-module-coupon-api/src/main/java/cn/iocoder/yudao/module/CouponTemplete/enums/CouponStatusTypeEnum.java @@ -0,0 +1,30 @@ +package cn.iocoder.yudao.module.CouponTemplete.enums; + + +import lombok.Getter; +import lombok.RequiredArgsConstructor; + + +/** + * 优惠券 - 优惠券类型 + * + * @author Sin + */ +@RequiredArgsConstructor +@Getter +public enum CouponStatusTypeEnum { + + ALL(1,"全部商品可用"), + POINT_PRODUCT(2,"指定商品可用"), + POINT_PRODUCT_NOT(3,"指定商品不可用不能为空"),; + + /** + * 优惠券类型 + */ + private final Integer type; + /** + * 优惠券类型名 + */ + private final String name; + +} diff --git a/yudao-module-mall/yudao-module-coupon-api/src/main/java/cn/iocoder/yudao/module/CouponTemplete/enums/CouponTypeEnum.java b/yudao-module-mall/yudao-module-coupon-api/src/main/java/cn/iocoder/yudao/module/CouponTemplete/enums/CouponTypeEnum.java new file mode 100644 index 000000000..639d5080d --- /dev/null +++ b/yudao-module-mall/yudao-module-coupon-api/src/main/java/cn/iocoder/yudao/module/CouponTemplete/enums/CouponTypeEnum.java @@ -0,0 +1,30 @@ +package cn.iocoder.yudao.module.CouponTemplete.enums; + + +import lombok.Getter; +import lombok.RequiredArgsConstructor; + + +/** + * 优惠券 - 优惠券类型 + * + * @author Sin + */ +@RequiredArgsConstructor +@Getter +public enum CouponTypeEnum { + + REWARD(1,"满减"), + DISCOUNT(2,"折扣"), + RANDOW(3,"随机"),; + + /** + * 优惠券类型 + */ + private final Integer type; + /** + * 优惠券类型名 + */ + private final String name; + +} diff --git a/yudao-module-mall/yudao-module-coupon-api/src/main/java/cn/iocoder/yudao/module/CouponTemplete/enums/CouponUseLimitEnum.java b/yudao-module-mall/yudao-module-coupon-api/src/main/java/cn/iocoder/yudao/module/CouponTemplete/enums/CouponUseLimitEnum.java new file mode 100644 index 000000000..61d2f429b --- /dev/null +++ b/yudao-module-mall/yudao-module-coupon-api/src/main/java/cn/iocoder/yudao/module/CouponTemplete/enums/CouponUseLimitEnum.java @@ -0,0 +1,29 @@ +package cn.iocoder.yudao.module.CouponTemplete.enums; + + +import lombok.Getter; +import lombok.RequiredArgsConstructor; + + +/** + * 优惠券 - 优惠券类型 + * + * @author Sin + */ +@RequiredArgsConstructor +@Getter +public enum CouponUseLimitEnum { + + HAS_LIMIT(1,"无门槛"), + NO_LIMIT(2,"有门槛"),; + + /** + * 优惠券类型 + */ + private final Integer type; + /** + * 优惠券类型名 + */ + private final String name; + +} diff --git a/yudao-module-mall/yudao-module-coupon-api/src/main/java/cn/iocoder/yudao/module/CouponTemplete/enums/CouponValidityTypeEnum.java b/yudao-module-mall/yudao-module-coupon-api/src/main/java/cn/iocoder/yudao/module/CouponTemplete/enums/CouponValidityTypeEnum.java new file mode 100644 index 000000000..6411ecbf9 --- /dev/null +++ b/yudao-module-mall/yudao-module-coupon-api/src/main/java/cn/iocoder/yudao/module/CouponTemplete/enums/CouponValidityTypeEnum.java @@ -0,0 +1,29 @@ +package cn.iocoder.yudao.module.CouponTemplete.enums; + +import lombok.Getter; +import lombok.RequiredArgsConstructor; + +/** + * 过期类型 - 状态 + * + * @author Sin + */ +@RequiredArgsConstructor +@Getter +public enum CouponValidityTypeEnum { + + TIME_RANGE_EXPIRTED(1,"时间范围过期"), + EXPIRES_AFTER_FIXED_DATE(2,"领取之日固定日期后过期"), + EXPIRES_DATE_NEXT_FIEXD_DATE(3,"领取次日固定日期后过期不能为空"),; + + + /** + * 状态值 + */ + private final Integer status; + /** + * 状态名 + */ + private final String name; + +} diff --git a/yudao-module-mall/yudao-module-coupon-api/src/main/java/cn/iocoder/yudao/module/CouponTemplete/enums/ErrorCodeConstants.java b/yudao-module-mall/yudao-module-coupon-api/src/main/java/cn/iocoder/yudao/module/CouponTemplete/enums/ErrorCodeConstants.java index 331824466..fced9d140 100644 --- a/yudao-module-mall/yudao-module-coupon-api/src/main/java/cn/iocoder/yudao/module/CouponTemplete/enums/ErrorCodeConstants.java +++ b/yudao-module-mall/yudao-module-coupon-api/src/main/java/cn/iocoder/yudao/module/CouponTemplete/enums/ErrorCodeConstants.java @@ -11,6 +11,13 @@ public interface ErrorCodeConstants { // ========== COUPON分类相关 1010001000 ============ ErrorCode COUPON_TEMPLETE_NOT_EXISTS = new ErrorCode(1010001000, "优惠券模板不存在"); + ErrorCode MONEY_NOT_NULL = new ErrorCode(1010001001, "当type为reward时需要添加发放面额不能为空"); + ErrorCode DISCOUNT_NOT_NULL = new ErrorCode(1010001001, "当type为discount时需要添加折扣不能为空"); + ErrorCode DISCOUNT_LIMIT_NOT_NULL = new ErrorCode(1010001001, "当type为discount时可选择性添加最多折扣金额不能为空"); + ErrorCode MIN_MAX_NOT_NULL = new ErrorCode(1010001001, "当type为radom时需要添加最低金额"); + ErrorCode START_END_TIME_NOT_NULL = new ErrorCode(1010001001, "使用开始日期,使用结束日期不能为空"); + ErrorCode FIXED_TERM_NOT_NULL = new ErrorCode(1010001001, "领取之日起或者次日N天内有效不能为空"); + // ========== COUPON分类相关 1010002000 ============ ErrorCode COUPON_NOT_EXISTS = new ErrorCode(1010001000, "优惠券模板不存在"); diff --git a/yudao-module-mall/yudao-module-coupon-biz/src/main/java/cn/iocoder/yudao/module/coupon/controller/admin/coupon/CouponController.java b/yudao-module-mall/yudao-module-coupon-biz/src/main/java/cn/iocoder/yudao/module/coupon/controller/admin/coupon/CouponController.java index 21a91e4b5..6e099269a 100644 --- a/yudao-module-mall/yudao-module-coupon-biz/src/main/java/cn/iocoder/yudao/module/coupon/controller/admin/coupon/CouponController.java +++ b/yudao-module-mall/yudao-module-coupon-biz/src/main/java/cn/iocoder/yudao/module/coupon/controller/admin/coupon/CouponController.java @@ -6,20 +6,13 @@ import org.springframework.validation.annotation.Validated; import org.springframework.security.access.prepost.PreAuthorize; import io.swagger.annotations.*; -import javax.validation.constraints.*; import javax.validation.*; -import javax.servlet.http.*; import java.util.*; -import java.io.IOException; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.pojo.CommonResult; import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; - -import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; -import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.*; import cn.iocoder.yudao.module.coupon.controller.admin.coupon.vo.*; import cn.iocoder.yudao.module.coupon.dal.dataobject.coupon.CouponDO; @@ -28,25 +21,29 @@ import cn.iocoder.yudao.module.coupon.service.coupon.CouponService; @Api(tags = "管理后台 - 优惠券") @RestController -@RequestMapping("/coupon/") +@RequestMapping("/coupon/coupon/") @Validated public class CouponController { @Resource - private CouponService Service; + private CouponService couponService; + + //todo 用户优惠券 @PostMapping("/create") - @ApiOperation("创建优惠券") + @ApiOperation("用户领取优惠券") @PreAuthorize("@ss.hasPermission('coupon::create')") - public CommonResult create(@Valid @RequestBody CouponCreateReqVO createReqVO) { - return success(Service.create(createReqVO)); + public CommonResult create(@RequestParam("couponTemplateId") Long couponTemplateId) { + + return success(couponService.create(couponTemplateId)); } + @PutMapping("/update") @ApiOperation("更新优惠券") @PreAuthorize("@ss.hasPermission('coupon::update')") public CommonResult update(@Valid @RequestBody CouponUpdateReqVO updateReqVO) { - Service.update(updateReqVO); + couponService.update(updateReqVO); return success(true); } @@ -55,7 +52,7 @@ public class CouponController { @ApiImplicitParam(name = "id", value = "编号", required = true, dataTypeClass = Long.class) @PreAuthorize("@ss.hasPermission('coupon::delete')") public CommonResult delete(@RequestParam("id") Long id) { - Service.delete(id); + couponService.delete(id); return success(true); } @@ -64,16 +61,18 @@ public class CouponController { @ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class) @PreAuthorize("@ss.hasPermission('coupon::query')") public CommonResult get(@RequestParam("id") Long id) { - CouponDO couponDO = Service.get(id); + CouponDO couponDO = couponService.get(id); return success(CouponConvert.INSTANCE.convert(couponDO)); } + + @GetMapping("/list") @ApiOperation("获得优惠券列表") - @ApiImplicitParam(name = "ids", value = "编号列表", required = true, example = "1024,2048", dataTypeClass = List.class) +// @ApiImplicitParam(name = "ids", value = "编号列表", required = true, example = "1024,2048", dataTypeClass = List.class) @PreAuthorize("@ss.hasPermission('coupon::query')") public CommonResult> getList(@RequestParam("ids") Collection ids) { - List list = Service.getList(ids); + List list = couponService.getList(ids); return success(CouponConvert.INSTANCE.convertList(list)); } @@ -81,20 +80,9 @@ public class CouponController { @ApiOperation("获得优惠券分页") @PreAuthorize("@ss.hasPermission('coupon::query')") public CommonResult> getPage(@Valid CouponPageReqVO pageVO) { - PageResult pageResult = Service.getPage(pageVO); + PageResult pageResult = couponService.getPage(pageVO); return success(CouponConvert.INSTANCE.convertPage(pageResult)); } - @GetMapping("/export-excel") - @ApiOperation("导出优惠券 Excel") - @PreAuthorize("@ss.hasPermission('coupon::export')") - @OperateLog(type = EXPORT) - public void exportExcel(@Valid CouponExportReqVO exportReqVO, - HttpServletResponse response) throws IOException { - List list = Service.getList(exportReqVO); - // 导出 Excel - List datas = CouponConvert.INSTANCE.convertList02(list); - ExcelUtils.write(response, "优惠券.xls", "数据", CouponExcelVO.class, datas); - } } diff --git a/yudao-module-mall/yudao-module-coupon-biz/src/main/java/cn/iocoder/yudao/module/coupon/controller/admin/coupontemplete/CouponTempleteController.java b/yudao-module-mall/yudao-module-coupon-biz/src/main/java/cn/iocoder/yudao/module/coupon/controller/admin/coupontemplete/CouponTempleteController.java index d60ed45aa..40d9ac429 100644 --- a/yudao-module-mall/yudao-module-coupon-biz/src/main/java/cn/iocoder/yudao/module/coupon/controller/admin/coupontemplete/CouponTempleteController.java +++ b/yudao-module-mall/yudao-module-coupon-biz/src/main/java/cn/iocoder/yudao/module/coupon/controller/admin/coupontemplete/CouponTempleteController.java @@ -11,24 +11,15 @@ import org.springframework.security.access.prepost.PreAuthorize; import io.swagger.annotations.*; import javax.validation.*; -import javax.servlet.http.*; import java.util.*; -import java.io.IOException; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.pojo.CommonResult; import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; - -import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; -import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.*; - - - @Api(tags = "管理后台 - 优惠券模板") @RestController -@RequestMapping("/CouponTemplete/") +@RequestMapping("/coupon/CouponTemplete/") @Validated public class CouponTempleteController { @@ -61,7 +52,7 @@ public class CouponTempleteController { @GetMapping("/get") @ApiOperation("获得优惠券模板") - @ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class) +// @ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class) @PreAuthorize("@ss.hasPermission('CouponTemplete::query')") public CommonResult get(@RequestParam("id") Long id) { CouponTempleteDO couponTempleteDO = Service.get(id); @@ -70,7 +61,7 @@ public class CouponTempleteController { @GetMapping("/list") @ApiOperation("获得优惠券模板列表") - @ApiImplicitParam(name = "ids", value = "编号列表", required = true, example = "1024,2048", dataTypeClass = List.class) +// @ApiImplicitParam(name = "ids", value = "编号列表", required = true, example = "1024,2048", dataTypeClass = List.class) @PreAuthorize("@ss.hasPermission('CouponTemplete::query')") public CommonResult> getList(@RequestParam("ids") Collection ids) { List list = Service.getList(ids); @@ -85,16 +76,6 @@ public class CouponTempleteController { return success(CouponTempleteConvert.INSTANCE.convertPage(pageResult)); } - @GetMapping("/export-excel") - @ApiOperation("导出优惠券模板 Excel") - @PreAuthorize("@ss.hasPermission('CouponTemplete::export')") - @OperateLog(type = EXPORT) - public void exportExcel(@Valid CouponTempleteExportReqVO exportReqVO, - HttpServletResponse response) throws IOException { - List list = Service.getList(exportReqVO); - // 导出 Excel - List datas = CouponTempleteConvert.INSTANCE.convertList02(list); - ExcelUtils.write(response, "优惠券模板.xls", "数据", CouponTempleteExcelVO.class, datas); - } + } diff --git a/yudao-module-mall/yudao-module-coupon-biz/src/main/java/cn/iocoder/yudao/module/coupon/controller/admin/coupontemplete/vo/CouponTempleteBaseVO.java b/yudao-module-mall/yudao-module-coupon-biz/src/main/java/cn/iocoder/yudao/module/coupon/controller/admin/coupontemplete/vo/CouponTempleteBaseVO.java index f43339f0f..d9818344f 100644 --- a/yudao-module-mall/yudao-module-coupon-biz/src/main/java/cn/iocoder/yudao/module/coupon/controller/admin/coupontemplete/vo/CouponTempleteBaseVO.java +++ b/yudao-module-mall/yudao-module-coupon-biz/src/main/java/cn/iocoder/yudao/module/coupon/controller/admin/coupontemplete/vo/CouponTempleteBaseVO.java @@ -16,9 +16,8 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_ @Data public class CouponTempleteBaseVO { - @ApiModelProperty(value = "优惠券类型 reward-满减 discount-折扣 random-随机", required = true) - @NotNull(message = "优惠券类型 reward-满减 discount-折扣 random-随机不能为空") - private String type; + + //基本信息 @ApiModelProperty(value = "优惠券名称", required = true) @NotNull(message = "优惠券名称不能为空") @@ -30,17 +29,8 @@ public class CouponTempleteBaseVO { @ApiModelProperty(value = "优惠券图片") private String image; - @ApiModelProperty(value = "发放数量", required = true) - @NotNull(message = "发放数量不能为空") - private Integer count; + /* ============判断适用商品——开始============= */ - @ApiModelProperty(value = "已领取数量", required = true) - @NotNull(message = "已领取数量不能为空") - private Integer leadCount; - - @ApiModelProperty(value = "已使用数量", required = true) - @NotNull(message = "已使用数量不能为空") - private Integer usedCount; @ApiModelProperty(value = "适用商品类型1-全部商品可用;2-指定商品可用;3-指定商品不可用", required = true) @NotNull(message = "适用商品类型1-全部商品可用;2-指定商品可用;3-指定商品不可用不能为空") @@ -57,15 +47,22 @@ public class CouponTempleteBaseVO { @NotNull(message = "满多少元使用 0代表无限制不能为空") private BigDecimal atLeast; - @ApiModelProperty(value = "发放面额 当type为reward时需要添加", required = true) + + /* ============折扣类型——开始============= */ + + @ApiModelProperty(value = "优惠券类型 reward-满减 discount-折扣 random-随机", required = true) + @NotNull(message = "优惠券类型 reward-满减 discount-折扣 random-随机不能为空") + private String type; + + @ApiModelProperty(value = "发放面额 当type为reward时需要添加") @NotNull(message = "发放面额 当type为reward时需要添加不能为空") private BigDecimal money; - @ApiModelProperty(value = "1 =< 折扣 <= 9.9 当type为discount时需要添加", required = true) + @ApiModelProperty(value = "1 =< 折扣 <= 9.9 当type为discount时需要添加") @NotNull(message = "1 =< 折扣 <= 9.9 当type为discount时需要添加不能为空") private BigDecimal discount; - @ApiModelProperty(value = "最多折扣金额 当type为discount时可选择性添加", required = true) + @ApiModelProperty(value = "最多折扣金额 当type为discount时可选择性添加") @NotNull(message = "最多折扣金额 当type为discount时可选择性添加不能为空") private BigDecimal discountLimit; @@ -77,9 +74,15 @@ public class CouponTempleteBaseVO { @NotNull(message = "最大金额 当type为radom时需要添加不能为空") private BigDecimal maxMoney; + /* ============折扣类型——结束============= */ + + + /* ============过期类型——开始============= */ + + @ApiModelProperty(value = "过期类型1-时间范围过期 2-领取之日固定日期后过期 3-领取次日固定日期后过期", required = true) - @NotNull(message = "过期类型1-时间范围过期 2-领取之日固定日期后过期 3-领取次日固定日期后过期不能为空") - private Boolean validityType; + @NotNull(message = "过期类型1-时间范围过期 2-领取之日固定日期后过期 3-领取次日固定日期后过期 不能为空") + private Integer validityType; @ApiModelProperty(value = "使用开始日期 过期类型1时必填") @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) @@ -89,19 +92,26 @@ public class CouponTempleteBaseVO { @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) private Date endUseTime; - @ApiModelProperty(value = "当validity_type为2或者3时需要添加 领取之日起或者次日N天内有效", required = true) + @ApiModelProperty(value = "当validity_type为2或者3时需要添加 领取之日起或者次日N天内有效") @NotNull(message = "当validity_type为2或者3时需要添加 领取之日起或者次日N天内有效不能为空") private Integer fixedTerm; - @ApiModelProperty(value = "是否无限制0-否 1是", required = true) - @NotNull(message = "是否无限制0-否 1是不能为空") + @ApiModelProperty(value = "有效日期结束时间") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private Date endTime; + + /* ============过期类型——结束============= */ + + + @ApiModelProperty(value = "领取是否无限制0-否 1是", required = true) + @NotNull(message = "是否无限制0-否 1是 不能为空") private Boolean whetherLimitless; @ApiModelProperty(value = "每人最大领取个数", required = true) @NotNull(message = "每人最大领取个数不能为空") private Integer maxFetch; - @ApiModelProperty(value = "是否开启过期提醒0-不开启 1-开启", required = true) + @ApiModelProperty(value = "是否开启过期提醒 0-不开启 1-开启", required = true) @NotNull(message = "是否开启过期提醒0-不开启 1-开启不能为空") private Boolean whetherExpireNotice; @@ -117,6 +127,18 @@ public class CouponTempleteBaseVO { @NotNull(message = "是否显示不能为空") private Integer whetherShow; + @ApiModelProperty(value = "是否禁止发放0-否 1-是", required = true) + @NotNull(message = "是否禁止发放0-否 1-是不能为空") + private Boolean whetherForbidden; + + /* ============汇总计算——开始============= */ + + + + @ApiModelProperty(value = "使用优惠券购买的商品数量", required = true) + @NotNull(message = "使用优惠券购买的商品数量不能为空") + private Integer orderGoodsNum; + @ApiModelProperty(value = "订单的优惠总金额", required = true) @NotNull(message = "订单的优惠总金额不能为空") private BigDecimal discountOrderMoney; @@ -125,20 +147,26 @@ public class CouponTempleteBaseVO { @NotNull(message = "用券总成交额不能为空") private BigDecimal orderMoney; - @ApiModelProperty(value = "是否禁止发放0-否 1-是", required = true) - @NotNull(message = "是否禁止发放0-否 1-是不能为空") - private Boolean whetherForbidden; + @ApiModelProperty(value = "发放数量", required = true) + @NotNull(message = "发放数量不能为空") + private Integer count; - @ApiModelProperty(value = "使用优惠券购买的商品数量", required = true) - @NotNull(message = "使用优惠券购买的商品数量不能为空") - private Integer orderGoodsNum; + @ApiModelProperty(value = "已领取数量", required = true) + @NotNull(message = "已领取数量不能为空") + private Integer leadCount; - @ApiModelProperty(value = "状态(1进行中2已结束-1已关闭)", required = true) + @ApiModelProperty(value = "已使用数量", required = true) + @NotNull(message = "已使用数量不能为空") + private Integer usedCount; + + + /* ============汇总计算——结束============= */ + + + @ApiModelProperty(value = "状态(1进行中2已结束3已关闭)", required = true) @NotNull(message = "状态(1进行中2已结束-1已关闭)不能为空") private Integer status; - @ApiModelProperty(value = "有效日期结束时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private Date endTime; + } diff --git a/yudao-module-mall/yudao-module-coupon-biz/src/main/java/cn/iocoder/yudao/module/coupon/service/CouponTemplete/CouponTempleteServiceImpl.java b/yudao-module-mall/yudao-module-coupon-biz/src/main/java/cn/iocoder/yudao/module/coupon/service/CouponTemplete/CouponTempleteServiceImpl.java index 982b2f1b2..f3f826b81 100644 --- a/yudao-module-mall/yudao-module-coupon-biz/src/main/java/cn/iocoder/yudao/module/coupon/service/CouponTemplete/CouponTempleteServiceImpl.java +++ b/yudao-module-mall/yudao-module-coupon-biz/src/main/java/cn/iocoder/yudao/module/coupon/service/CouponTemplete/CouponTempleteServiceImpl.java @@ -1,5 +1,7 @@ package cn.iocoder.yudao.module.coupon.service.CouponTemplete; +import cn.iocoder.yudao.module.CouponTemplete.enums.CouponTypeEnum; +import cn.iocoder.yudao.module.CouponTemplete.enums.CouponValidityTypeEnum; import cn.iocoder.yudao.module.coupon.controller.admin.coupontemplete.vo.CouponTempleteCreateReqVO; import cn.iocoder.yudao.module.coupon.controller.admin.coupontemplete.vo.CouponTempleteExportReqVO; import cn.iocoder.yudao.module.coupon.controller.admin.coupontemplete.vo.CouponTempletePageReqVO; @@ -18,7 +20,7 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult; import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.CouponTemplete.enums.ErrorCodeConstants.COUPON_TEMPLETE_NOT_EXISTS; +import static cn.iocoder.yudao.module.CouponTemplete.enums.ErrorCodeConstants.*; /** * 优惠券模板 Service 实现类 @@ -36,11 +38,57 @@ public class CouponTempleteServiceImpl implements CouponTempleteService { public Long create(CouponTempleteCreateReqVO createReqVO) { // 插入 CouponTempleteDO couponTempleteDO = CouponTempleteConvert.INSTANCE.convert(createReqVO); + /* 验证类型、判断必填*/ + checkCouponType(createReqVO); + + /*todo 验证过期类型、判断必填*/ + checkValidityType(createReqVO); + + + couponTempleteMapper.insert(couponTempleteDO); // 返回 return couponTempleteDO.getId(); } + /*确认优惠券类型*/ + private void checkValidityType(CouponTempleteCreateReqVO createReqVO) { + Integer validtyType = createReqVO.getValidityType(); + + if(CouponValidityTypeEnum.TIME_RANGE_EXPIRTED.getStatus().equals(validtyType)){ + if(createReqVO.getStartUseTime() == null||createReqVO.getEndUseTime() == null){ + throw exception(START_END_TIME_NOT_NULL); + } + }else{ + if(createReqVO.getFixedTerm() == null){ + throw exception(FIXED_TERM_NOT_NULL); + } + } + } + + private void checkCouponType(CouponTempleteCreateReqVO createReqVO) { + + String couponType = createReqVO.getType(); + //当type=reward时候,需要添加 + if(couponType.equals(CouponTypeEnum.REWARD.getName())){ + if(createReqVO.getMoney()==null){ + throw exception(MONEY_NOT_NULL); + } + }else if(couponType.equals(CouponTypeEnum.DISCOUNT.getName())){ + if(createReqVO.getDiscount()==null){ + throw exception(DISCOUNT_NOT_NULL); + } + if(createReqVO.getDiscountLimit()==null){ + throw exception(DISCOUNT_LIMIT_NOT_NULL); + } + }else if (couponType.equals(CouponTypeEnum.RANDOW.getName())){ + //当type为radom时需要添加不能为空 + if(createReqVO.getMinMoney()==null||createReqVO.getMaxMoney()==null){ + throw exception(MIN_MAX_NOT_NULL); + } + } + } + @Override public void update(CouponTempleteUpdateReqVO updateReqVO) { // 校验存在 diff --git a/yudao-module-mall/yudao-module-coupon-biz/src/main/java/cn/iocoder/yudao/module/coupon/service/coupon/CouponService.java b/yudao-module-mall/yudao-module-coupon-biz/src/main/java/cn/iocoder/yudao/module/coupon/service/coupon/CouponService.java index a3ca66611..6a9d31520 100644 --- a/yudao-module-mall/yudao-module-coupon-biz/src/main/java/cn/iocoder/yudao/module/coupon/service/coupon/CouponService.java +++ b/yudao-module-mall/yudao-module-coupon-biz/src/main/java/cn/iocoder/yudao/module/coupon/service/coupon/CouponService.java @@ -16,10 +16,10 @@ public interface CouponService { /** * 创建优惠券 * - * @param createReqVO 创建信息 + * @param templateId 优惠券模板id * @return 编号 */ - Long create(@Valid CouponCreateReqVO createReqVO); + Long create(Long templateId); /** * 更新优惠券 diff --git a/yudao-module-mall/yudao-module-coupon-biz/src/main/java/cn/iocoder/yudao/module/coupon/service/coupon/CouponServiceImpl.java b/yudao-module-mall/yudao-module-coupon-biz/src/main/java/cn/iocoder/yudao/module/coupon/service/coupon/CouponServiceImpl.java index 99f87ecfc..0a1737a31 100644 --- a/yudao-module-mall/yudao-module-coupon-biz/src/main/java/cn/iocoder/yudao/module/coupon/service/coupon/CouponServiceImpl.java +++ b/yudao-module-mall/yudao-module-coupon-biz/src/main/java/cn/iocoder/yudao/module/coupon/service/coupon/CouponServiceImpl.java @@ -1,5 +1,10 @@ package cn.iocoder.yudao.module.coupon.service.coupon; +import cn.hutool.core.bean.BeanUtil; +import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils; +import cn.iocoder.yudao.module.coupon.dal.dataobject.CouponTemplete.CouponTempleteDO; +import cn.iocoder.yudao.module.coupon.dal.mysql.CouponTemplete.CouponTempleteMapper; +import io.micrometer.core.instrument.Counter; import org.springframework.stereotype.Service; import javax.annotation.Resource; import org.springframework.validation.annotation.Validated; @@ -27,7 +32,9 @@ public class CouponServiceImpl implements CouponService { @Resource private CouponMapper couponMapper; - @Override + @Resource + private CouponTempleteMapper couponTempleteMapper; + public Long create(CouponCreateReqVO createReqVO) { // 插入 CouponDO couponDO = CouponConvert.INSTANCE.convert(createReqVO); @@ -36,6 +43,24 @@ public class CouponServiceImpl implements CouponService { return couponDO.getId(); } + + /** + *todo 获取用户id收获优惠券 + *@author:wxr + *@date:2022-08-13 3:11 + *@Description + */ + @Override + public Long create(Long templateId) { + Long userid = SecurityFrameworkUtils.getLoginUserId(); + CouponDO couponDO = CouponDO.builder().memberId(userid).build(); + CouponTempleteDO couponTempleteDO = couponTempleteMapper.selectById(templateId); + //todo 缺少判空 + BeanUtil.copyProperties(couponTempleteDO,couponTempleteDO); + couponMapper.insert(couponDO); + return couponDO.getId(); + } + @Override public void update(CouponUpdateReqVO updateReqVO) { // 校验存在 diff --git a/yudao-ui-admin/.env.dev b/yudao-ui-admin/.env.dev index db9e33854..bb68d6fe2 100644 --- a/yudao-ui-admin/.env.dev +++ b/yudao-ui-admin/.env.dev @@ -5,7 +5,7 @@ ENV = 'development' VUE_APP_TITLE = 芋道管理系统 # 芋道管理系统/开发环境 -VUE_APP_BASE_API = 'http://localhost:48080' +VUE_APP_BASE_API = 'http://localhost:48081' # 路由懒加载 VUE_CLI_BABEL_TRANSPILE_MODULES = true diff --git a/yudao-ui-admin/.env.local b/yudao-ui-admin/.env.local index 58029b662..af9741467 100644 --- a/yudao-ui-admin/.env.local +++ b/yudao-ui-admin/.env.local @@ -6,7 +6,7 @@ VUE_APP_TITLE = 芋道管理系统 # 芋道管理系统/本地环境 # VUE_APP_BASE_API = '/proxy-api' -VUE_APP_BASE_API = 'http://127.0.0.1:48080' +VUE_APP_BASE_API = 'http://127.0.0.1:48081' # 路由懒加载 VUE_CLI_BABEL_TRANSPILE_MODULES = true diff --git a/yudao-ui-admin/.eslintignore b/yudao-ui-admin/.eslintignore index 89be6f659..21cfec76a 100644 --- a/yudao-ui-admin/.eslintignore +++ b/yudao-ui-admin/.eslintignore @@ -7,4 +7,4 @@ public # 忽略当前目录下为js的文件的语法检查 *.js # 忽略当前目录下为vue的文件的语法检查 -*.vue \ No newline at end of file +*.vue diff --git a/yudao-ui-admin/src/api/mall/CouponTemplete/CouponTemplete.js b/yudao-ui-admin/src/api/mall/CouponTemplete/CouponTemplete.js new file mode 100644 index 000000000..429dfb8dc --- /dev/null +++ b/yudao-ui-admin/src/api/mall/CouponTemplete/CouponTemplete.js @@ -0,0 +1,54 @@ +import request from '@/utils/request' + +// 创建优惠券模板 +export function create(data) { + return request({ + url: '/coupon/CouponTemplete/create', + method: 'post', + data: data + }) +} + +// 更新优惠券模板 +export function update(data) { + return request({ + url: '/coupon/CouponTemplete/update', + method: 'put', + data: data + }) +} + +// 删除优惠券模板 +export function deleteCouponTemplete (id) { + return request({ + url: '/coupon/CouponTemplete/delete?id=' + id, + method: 'delete' + }) +} + +// 获得优惠券模板 +export function get(id) { + return request({ + url: '/coupon/CouponTemplete/get?id=' + id, + method: 'get' + }) +} + +// 获得优惠券模板分页 +export function getPage(query) { + return request({ + url: '/coupon/CouponTemplete/page', + method: 'get', + params: query + }) +} + +// 导出优惠券模板 Excel +export function exportExcel(query) { + return request({ + url: '/coupon/CouponTemplete/export-excel', + method: 'get', + params: query, + responseType: 'blob' + }) +} diff --git a/yudao-ui-admin/src/views/mall/CouponTemplete/index.vue b/yudao-ui-admin/src/views/mall/CouponTemplete/index.vue new file mode 100644 index 000000000..47be4afd3 --- /dev/null +++ b/yudao-ui-admin/src/views/mall/CouponTemplete/index.vue @@ -0,0 +1,457 @@ + + +