mirror of
https://gitee.com/hhyykk/ipms-sjy.git
synced 2025-07-25 16:35:06 +08:00
Merge remote-tracking branch 'origin/feature/1.8.0-uniapp' into feature/1.8.0-uniapp
This commit is contained in:
@ -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;
|
||||
|
||||
}
|
@ -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;
|
||||
|
||||
}
|
@ -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;
|
||||
|
||||
}
|
@ -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;
|
||||
|
||||
}
|
@ -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;
|
||||
|
||||
}
|
@ -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;
|
||||
|
||||
}
|
@ -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;
|
||||
|
||||
}
|
@ -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, "优惠券模板不存在");
|
||||
|
@ -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<Long> create(@Valid @RequestBody CouponCreateReqVO createReqVO) {
|
||||
return success(Service.create(createReqVO));
|
||||
public CommonResult<Long> create(@RequestParam("couponTemplateId") Long couponTemplateId) {
|
||||
|
||||
return success(couponService.create(couponTemplateId));
|
||||
}
|
||||
|
||||
|
||||
@PutMapping("/update")
|
||||
@ApiOperation("更新优惠券")
|
||||
@PreAuthorize("@ss.hasPermission('coupon::update')")
|
||||
public CommonResult<Boolean> 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<Boolean> 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<CouponRespVO> 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<List<CouponRespVO>> getList(@RequestParam("ids") Collection<Long> ids) {
|
||||
List<CouponDO> list = Service.getList(ids);
|
||||
List<CouponDO> 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<PageResult<CouponRespVO>> getPage(@Valid CouponPageReqVO pageVO) {
|
||||
PageResult<CouponDO> pageResult = Service.getPage(pageVO);
|
||||
PageResult<CouponDO> 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<CouponDO> list = Service.getList(exportReqVO);
|
||||
// 导出 Excel
|
||||
List<CouponExcelVO> datas = CouponConvert.INSTANCE.convertList02(list);
|
||||
ExcelUtils.write(response, "优惠券.xls", "数据", CouponExcelVO.class, datas);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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<CouponTempleteRespVO> 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<List<CouponTempleteRespVO>> getList(@RequestParam("ids") Collection<Long> ids) {
|
||||
List<CouponTempleteDO> 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<CouponTempleteDO> list = Service.getList(exportReqVO);
|
||||
// 导出 Excel
|
||||
List<CouponTempleteExcelVO> datas = CouponTempleteConvert.INSTANCE.convertList02(list);
|
||||
ExcelUtils.write(response, "优惠券模板.xls", "数据", CouponTempleteExcelVO.class, datas);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -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;
|
||||
|
||||
|
||||
}
|
||||
|
@ -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) {
|
||||
// 校验存在
|
||||
|
@ -16,10 +16,10 @@ public interface CouponService {
|
||||
/**
|
||||
* 创建优惠券
|
||||
*
|
||||
* @param createReqVO 创建信息
|
||||
* @param templateId 优惠券模板id
|
||||
* @return 编号
|
||||
*/
|
||||
Long create(@Valid CouponCreateReqVO createReqVO);
|
||||
Long create(Long templateId);
|
||||
|
||||
/**
|
||||
* 更新优惠券
|
||||
|
@ -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) {
|
||||
// 校验存在
|
||||
|
Reference in New Issue
Block a user