mall:上传enum类,做后端模板添加判定、前端页面添加

pull/2/head
wuxiran 2022-08-16 00:26:44 +08:00
parent 515c0de78d
commit c8ec5c8952
19 changed files with 883 additions and 91 deletions

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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, "优惠券模板不存在");

View File

@ -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);
}
}

View File

@ -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);
}
}

View File

@ -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;
}

View File

@ -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) {
// 校验存在

View File

@ -16,10 +16,10 @@ public interface CouponService {
/**
*
*
* @param createReqVO
* @param templateId id
* @return
*/
Long create(@Valid CouponCreateReqVO createReqVO);
Long create(Long templateId);
/**
*

View File

@ -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) {
// 校验存在

View File

@ -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

View File

@ -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

View File

@ -7,4 +7,4 @@ public
# 忽略当前目录下为js的文件的语法检查
*.js
# 忽略当前目录下为vue的文件的语法检查
*.vue
*.vue

View File

@ -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'
})
}

View File

@ -0,0 +1,457 @@
<template>
<div class="app-container">
<!-- 搜索工作栏 -->
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="优惠券类" prop="type">
<el-select v-model="queryParams.type" placeholder="请选择优惠券类型 reward-满减 discount-折扣 random-随机" clearable size="small">
<el-option label="请选择字典生成" value="" />
</el-select>
</el-form-item>
<el-form-item label="优惠券名称" prop="name">
<el-input v-model="queryParams.name" placeholder="请输入优惠券名称" clearable @keyup.enter.native="handleQuery"/>
</el-form-item>
<el-form-item label="状态" prop="status">
<el-select v-model="queryParams.status" placeholder="请选择状态1进行中2已结束-1已关闭" clearable size="small">
<el-option label="请选择字典生成" value="" />
</el-select>
</el-form-item>
<el-form-item label="有效日期结束时间" prop="endTime">
<el-date-picker v-model="queryParams.endTime" style="width: 240px" value-format="yyyy-MM-dd HH:mm:ss" type="daterange"
range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期" :default-time="['00:00:00', '23:59:59']" />
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" @click="handleQuery"></el-button>
<el-button icon="el-icon-refresh" @click="resetQuery"></el-button>
</el-form-item>
</el-form>
<!-- 操作工具栏 -->
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd"
v-hasPermi="['CouponTemplete::create']">新增</el-button>
</el-col>
<el-col :span="1.5">
<el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport" :loading="exportLoading"
v-hasPermi="['CouponTemplete::export']">导出</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<!-- 列表 -->
<el-table v-loading="loading" :data="list">
<el-table-column label="用户ID" align="center" prop="id" />
<!-- todo 优惠券类型-->
<el-table-column label="优惠券类型" align="center" prop="type" />
<el-table-column label="优惠券名称" align="center" prop="name" />
<el-table-column label="优惠券图片" align="center" prop="image" />
<el-table-column label="发放数量" align="center" prop="count" />
<el-table-column label="已领取数量" align="center" prop="leadCount" />
<el-table-column label="已使用数量" align="center" prop="usedCount" />
<!-- todo 适用商品类型-->
<!-- <el-table-column label="适用商品类型" align="center" prop="goodsType" />-->
<!-- todo 使用门槛0-无门槛 1-有门槛-->
<el-table-column label="使用门槛" align="center" prop="hasUseLimit" />
<!-- <el-table-column label="满多少元使用 0代表无限制" align="center" prop="atLeast" />-->
<!-- todo 发放面额 折扣-->
<el-table-column label="优惠金额/折扣" align="center" prop="money" />
<!-- <el-table-column label="1 =< 折扣 <= 9.9 当type为discount时需要添加" align="center" prop="discount" />-->
<!-- <el-table-column label="最多折扣金额 当type为discount时可选择性添加" align="center" prop="discountLimit" />-->
<!-- <el-table-column label="最低金额 当type为radom时需要添加" align="center" prop="minMoney" />-->
<!-- <el-table-column label="最大金额 当type为radom时需要添加" align="center" prop="maxMoney" />-->
<!-- todo 1-时间范围过期 2-领取之日固定日期后过期 3-领取次日固定日期后过期 -->
<el-table-column label="有效期限" align="center" prop="validityType" />
<!-- <el-table-column label="使用开始日期 过期类型1时必填" align="center" prop="startUseTime" width="180">-->
<!-- <template slot-scope="scope">-->
<!-- <span>{{ parseTime(scope.row.startUseTime) }}</span>-->
<!-- </template>-->
<!-- </el-table-column>-->
<!-- <el-table-column label="使用结束日期 过期类型1时必填" align="center" prop="endUseTime" width="180">-->
<!-- <template slot-scope="scope">-->
<!-- <span>{{ parseTime(scope.row.endUseTime) }}</span>-->
<!-- </template>-->
<!-- </el-table-column>-->
<!-- <el-table-column label="有效日期结束时间" align="center" prop="endTime" width="180">-->
<!-- <template slot-scope="scope">-->
<!-- <span>{{ parseTime(scope.row.endTime) }}</span>-->
<!-- </template>-->
<!-- </el-table-column>-->
<!-- <el-table-column label="当validity_type为2或者3时需要添加 领取之日起或者次日N天内有效" align="center" prop="fixedTerm" />-->
<!-- <el-table-column label="是否无限制0-否 1是" align="center" prop="whetherLimitless" />-->
<el-table-column label="领取上限" align="center" prop="maxFetch" />
<!-- todo 0-不限制 1- 优惠券仅原价购买商品时可用-->
<el-table-column label="优惠叠加" align="center" prop="whetherForbidPreference" />
<el-table-column label="是否显示" align="center" prop="whetherShow" />
<el-table-column label="订单的优惠总金额" align="center" prop="discountOrderMoney" />
<el-table-column label="用券总成交额" align="center" prop="orderMoney" />
<el-table-column label="是否禁止发放" align="center" prop="whetherForbidden" />
<el-table-column label="使用优惠券购买的商品数量" align="center" prop="orderGoodsNum" />
<el-table-column label="状态" align="center" prop="status" />
<el-table-column label="备注" align="center" prop="couponNameRemark" />
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template #scope>
<el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)"
v-hasPermi="['CouponTemplete::update']">修改</el-button>
<el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)"
v-hasPermi="['CouponTemplete::delete']">删除</el-button>
</template>
</el-table-column>
</el-table>
<!-- 分页组件 -->
<pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize"
@pagination="getList"/>
<!-- 对话框(添加 / 修改) -->
<el-dialog :title="title" :visible.sync="open" width="800px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="150px">
<el-form-item label="优惠券类型" prop="type">
<el-select v-model="form.type" placeholder="请选择优惠券类型 reward-满减 discount-折扣 random-随机">
<el-option label="请选择字典生成" value="" />
</el-select>
</el-form-item>
<el-form-item label="优惠券名称" prop="name">
<el-input v-model="form.name" placeholder="请输入优惠券名称" />
</el-form-item>
<el-form-item label="名称备注" prop="couponNameRemark">
<el-input v-model="form.couponNameRemark" placeholder="请输入名称备注" />
</el-form-item>
<el-form-item label="发放数量" prop="count">
<el-input v-model="form.count" placeholder="请输入发放数量" />
</el-form-item>
<el-form-item label="适用商品类型" prop="goodsType">
<el-radio-group v-model="form.goodsType">
<el-radio label="1">请选择字典生成</el-radio>
</el-radio-group>
</el-form-item>
<!-- todo 请输入适用商品id-->
<el-form-item label="适用商品id" prop="productIds">
<el-input v-model="form.productIds" placeholder="请输入适用商品id" />
</el-form-item>
<el-form-item label="使用门槛" prop="hasUseLimit">
<el-radio-group v-model="form.hasUseLimit">
<el-radio label="1">请选择字典生成</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="满多少元使用" prop="atLeast">
<el-input v-model="form.atLeast" placeholder="请输入满多少元使用 0代表无限制" />
</el-form-item>
<el-form-item label="发放面额" prop="money">
<el-input v-model="form.money" placeholder="请输入发放面额 当type为reward时需要添加" />
</el-form-item>
<el-form-item label="1 =< 折扣 <= 9.9" prop="discount">
<el-input v-model="form.discount" placeholder="请输入1 =< 折扣 <= 9.9 当type为discount时需要添加" />
</el-form-item>
<el-form-item label="最多折扣金额" prop="discountLimit">
<el-input v-model="form.discountLimit" placeholder="请输入最多折扣金额 当type为discount时可选择性添加" />
</el-form-item>
<el-form-item label="最低金额" prop="minMoney">
<el-input v-model="form.minMoney" placeholder="请输入最低金额 当type为radom时需要添加" />
</el-form-item>
<el-form-item label="最大金额" prop="maxMoney">
<el-input v-model="form.maxMoney" placeholder="请输入最大金额 当type为radom时需要添加" />
</el-form-item>
<el-form-item label="过期类型" prop="validityType">
<el-radio-group v-model="form.validityType">
<el-radio label="1">请选择字典生成</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="使用开始日期 过期类型1时必填" prop="startUseTime">
<el-date-picker clearable v-model="form.startUseTime" type="date" value-format="timestamp" placeholder="选择使用开始日期 过期类型1时必填" />
</el-form-item>
<el-form-item label="使用结束日期 过期类型1时必填" prop="endUseTime">
<el-date-picker clearable v-model="form.endUseTime" type="date" value-format="timestamp" placeholder="选择使用结束日期 过期类型1时必填" />
</el-form-item>
<el-form-item label="当validity_type为2或者3时需要添加 领取之日起或者次日N天内有效" prop="fixedTerm">
<el-input v-model="form.fixedTerm" placeholder="请输入当validity_type为2或者3时需要添加 领取之日起或者次日N天内有效" />
</el-form-item>
<el-form-item label="是否无限制0-否 1是" prop="whetherLimitless">
<el-radio-group v-model="form.whetherLimitless">
<el-radio label="1">请选择字典生成</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="每人最大领取个数" prop="maxFetch">
<el-input v-model="form.maxFetch" placeholder="请输入每人最大领取个数" />
</el-form-item>
<el-form-item label="是否开启过期提醒0-不开启 1-开启" prop="whetherExpireNotice">
<el-radio-group v-model="form.whetherExpireNotice">
<el-radio label="1">请选择字典生成</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="过期前N天提醒" prop="expireNoticeFixedTerm">
<el-input v-model="form.expireNoticeFixedTerm" placeholder="请输入过期前N天提醒" />
</el-form-item>
<el-form-item label="优惠叠加 0-不限制 1- 优惠券仅原价购买商品时可用" prop="whetherForbidPreference">
<el-radio-group v-model="form.whetherForbidPreference">
<el-radio label="1">请选择字典生成</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="是否显示" prop="whetherShow">
<el-input v-model="form.whetherShow" placeholder="请输入是否显示" />
</el-form-item>
<el-form-item label="订单的优惠总金额" prop="discountOrderMoney">
<el-input v-model="form.discountOrderMoney" placeholder="请输入订单的优惠总金额" />
</el-form-item>
<el-form-item label="用券总成交额" prop="orderMoney">
<el-input v-model="form.orderMoney" placeholder="请输入用券总成交额" />
</el-form-item>
<el-form-item label="是否禁止发放0-否 1-是" prop="whetherForbidden">
<el-radio-group v-model="form.whetherForbidden">
<el-radio label="1">请选择字典生成</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="使用优惠券购买的商品数量" prop="orderGoodsNum">
<el-input v-model="form.orderGoodsNum" placeholder="请输入使用优惠券购买的商品数量" />
</el-form-item>
<el-form-item label="状态" prop="status">
<el-radio-group v-model="form.status">
<el-radio label="1">请选择字典生成</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="有效日期结束时间" prop="endTime">
<el-date-picker clearable v-model="form.endTime" type="date" value-format="timestamp" placeholder="选择有效日期结束时间" />
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm"> </el-button>
<el-button @click="cancel"> </el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import { create, update, deleteCouponTemplete, get, getPage, exportExcel } from "@/api/mall/CouponTemplete/CouponTemplete.js";
export default {
name: "",
components: {
},
data() {
return {
//
loading: true,
//
exportLoading: false,
//
showSearch: true,
//
total: 0,
//
list: [],
//
title: "",
//
open: false,
//
queryParams: {
pageNo: 1,
pageSize: 10,
type: null,
name: null,
couponNameRemark: null,
image: null,
count: null,
leadCount: null,
usedCount: null,
goodsType: null,
productIds: null,
hasUseLimit: null,
atLeast: null,
money: null,
discount: null,
discountLimit: null,
minMoney: null,
maxMoney: null,
validityType: null,
startUseTime: [],
endUseTime: [],
fixedTerm: null,
whetherLimitless: null,
maxFetch: null,
whetherExpireNotice: null,
expireNoticeFixedTerm: null,
whetherForbidPreference: null,
whetherShow: null,
discountOrderMoney: null,
orderMoney: null,
whetherForbidden: null,
orderGoodsNum: null,
status: null,
endTime: [],
createTime: [],
},
//
form: {},
//
rules: {
type: [{ required: true, message: "优惠券类型 reward-满减 discount-折扣 random-随机不能为空", trigger: "change" }],
name: [{ required: true, message: "优惠券名称不能为空", trigger: "blur" }],
count: [{ required: true, message: "发放数量不能为空", trigger: "blur" }],
leadCount: [{ required: true, message: "已领取数量不能为空", trigger: "blur" }],
usedCount: [{ required: true, message: "已使用数量不能为空", trigger: "blur" }],
goodsType: [{ required: true, message: "适用商品类型1-全部商品可用2-指定商品可用3-指定商品不可用不能为空", trigger: "blur" }],
hasUseLimit: [{ required: true, message: "使用门槛0-无门槛 1-有门槛不能为空", trigger: "blur" }],
atLeast: [{ required: true, message: "满多少元使用 0代表无限制不能为空", trigger: "blur" }],
money: [{ required: true, message: "发放面额 当type为reward时需要添加不能为空", trigger: "blur" }],
discount: [{ required: true, message: "1 =< 折扣 <= 9.9 当type为discount时需要添加不能为空", trigger: "blur" }],
discountLimit: [{ required: true, message: "最多折扣金额 当type为discount时可选择性添加不能为空", trigger: "blur" }],
minMoney: [{ required: true, message: "最低金额 当type为radom时需要添加不能为空", trigger: "blur" }],
maxMoney: [{ required: true, message: "最大金额 当type为radom时需要添加不能为空", trigger: "blur" }],
validityType: [{ required: true, message: "过期类型1-时间范围过期 2-领取之日固定日期后过期 3-领取次日固定日期后过期不能为空", trigger: "blur" }],
fixedTerm: [{ required: true, message: "当validity_type为2或者3时需要添加 领取之日起或者次日N天内有效不能为空", trigger: "blur" }],
whetherLimitless: [{ required: true, message: "是否无限制0-否 1是不能为空", trigger: "blur" }],
maxFetch: [{ required: true, message: "每人最大领取个数不能为空", trigger: "blur" }],
whetherExpireNotice: [{ required: true, message: "是否开启过期提醒0-不开启 1-开启不能为空", trigger: "blur" }],
expireNoticeFixedTerm: [{ required: true, message: "过期前N天提醒不能为空", trigger: "blur" }],
whetherForbidPreference: [{ required: true, message: "优惠叠加 0-不限制 1- 优惠券仅原价购买商品时可用不能为空", trigger: "blur" }],
whetherShow: [{ required: true, message: "是否显示不能为空", trigger: "blur" }],
discountOrderMoney: [{ required: true, message: "订单的优惠总金额不能为空", trigger: "blur" }],
orderMoney: [{ required: true, message: "用券总成交额不能为空", trigger: "blur" }],
whetherForbidden: [{ required: true, message: "是否禁止发放0-否 1-是不能为空", trigger: "blur" }],
orderGoodsNum: [{ required: true, message: "使用优惠券购买的商品数量不能为空", trigger: "blur" }],
status: [{ required: true, message: "状态1进行中2已结束-1已关闭不能为空", trigger: "blur" }],
}
};
},
created() {
this.getList();
},
methods: {
/** 查询列表 */
getList() {
this.loading = true;
//
getPage(this.queryParams).then(response => {
this.list = response.data.list;
this.total = response.data.total;
this.loading = false;
});
},
/** 取消按钮 */
cancel() {
this.open = false;
this.reset();
},
/** 表单重置 */
reset() {
this.form = {
id: undefined,
type: undefined,
name: undefined,
couponNameRemark: undefined,
image: undefined,
count: undefined,
leadCount: undefined,
usedCount: undefined,
goodsType: undefined,
productIds: undefined,
hasUseLimit: undefined,
atLeast: undefined,
money: undefined,
discount: undefined,
discountLimit: undefined,
minMoney: undefined,
maxMoney: undefined,
validityType: undefined,
startUseTime: undefined,
endUseTime: undefined,
fixedTerm: undefined,
whetherLimitless: undefined,
maxFetch: undefined,
whetherExpireNotice: undefined,
expireNoticeFixedTerm: undefined,
whetherForbidPreference: undefined,
whetherShow: undefined,
discountOrderMoney: undefined,
orderMoney: undefined,
whetherForbidden: undefined,
orderGoodsNum: undefined,
status: undefined,
endTime: undefined,
};
this.resetForm("form");
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNo = 1;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm");
this.handleQuery();
},
/** 新增按钮操作 */
handleAdd() {
this.reset();
this.open = true;
this.title = "添加优惠券模板";
},
/** 修改按钮操作 */
handleUpdate(row) {
this.reset();
const id = row.id;
get(id).then(response => {
this.form = response.data;
this.open = true;
this.title = "修改优惠券模板";
});
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate(valid => {
if (!valid) {
return;
}
//
if (this.form.id != null) {
update(this.form).then(response => {
this.$modal.msgSuccess("修改成功");
this.open = false;
this.getList();
});
return;
}
//
create(this.form).then(response => {
this.$modal.msgSuccess("新增成功");
this.open = false;
this.getList();
});
});
},
/** 删除按钮操作 */
handleDelete(row) {
const id = row.id;
this.$modal.confirm('是否确认删除优惠券模板编号为"' + id + '"的数据项?').then(function() {
return deleteCouponTemplete(id);
}).then(() => {
this.getList();
this.$modal.msgSuccess("删除成功");
}).catch(() => {});
},
/** 导出按钮操作 */
handleExport() {
//
let params = {...this.queryParams};
params.pageNo = undefined;
params.pageSize = undefined;
this.$modal.confirm('是否确认导出所有优惠券模板数据项?').then(() => {
this.exportLoading = true;
return exportExcel(params);
}).then(response => {
this.$download.excel(response, '优惠券模板.xls');
this.exportLoading = false;
}).catch(() => {});
}
}
};
</script>