feat:优惠券
This commit is contained in:
1 parent
39976c1368
commit
62150787d0
13 files changed
+533
No files matched your search
+37
@@ -0,0 +1,37 @@
|
||||
package com.bsd.pjcloud.wallet.api.constant.act;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* 优惠券限领类型
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum ActCouponLimitTypeEnum {
|
||||
|
||||
ONCE("1", "活动期间一次"),
|
||||
EVERY_DAY("2", "每天"),
|
||||
EVERY_WEEK("3", "每周"),
|
||||
EVERY_MONTH("4", "每月"),
|
||||
EVERY_YEAR("5", "每年"),
|
||||
;
|
||||
private final String code;
|
||||
private final String desc;
|
||||
|
||||
public static ActCouponLimitTypeEnum valueOfByType(String code) {
|
||||
return Arrays.stream(ActCouponLimitTypeEnum.values())
|
||||
.filter(v -> ObjectUtil.equal(v.getCode(), code))
|
||||
.findFirst().orElse(null);
|
||||
}
|
||||
|
||||
public static ActCouponLimitTypeEnum descOf(String description) {
|
||||
return Arrays.stream(ActCouponLimitTypeEnum.values())
|
||||
.filter(v -> ObjectUtil.equal(v.getDesc(), description))
|
||||
.findFirst().orElse(null);
|
||||
}
|
||||
|
||||
}
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
package com.bsd.pjcloud.wallet.api.constant.act;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* 优惠券状态
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum ActCouponStatusEnum {
|
||||
CAOGAO("1", "草稿"),
|
||||
JINXINGZHONG("2", "进行中"),
|
||||
YIJIESHU("3", "已结束"),
|
||||
YIZUOFEI("4", "已作废"),
|
||||
;
|
||||
|
||||
private final String code;
|
||||
private final String desc;
|
||||
|
||||
public static ActCouponStatusEnum valueOfByType(String code) {
|
||||
return Arrays.stream(ActCouponStatusEnum.values())
|
||||
.filter(v -> ObjectUtil.equal(v.getCode(), code))
|
||||
.findFirst().orElse(null);
|
||||
}
|
||||
|
||||
public static ActCouponStatusEnum descOf(String description) {
|
||||
return Arrays.stream(ActCouponStatusEnum.values())
|
||||
.filter(v -> ObjectUtil.equal(v.getDesc(), description))
|
||||
.findFirst().orElse(null);
|
||||
}
|
||||
|
||||
}
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
package com.bsd.pjcloud.wallet.api.constant.act;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* 优惠券类型
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum ActCouponTypeEnum {
|
||||
MANJIAN_QUAN("1", "满减券"),
|
||||
ZHEKOU_QUAN("2", "折扣券"),
|
||||
LIJIAN_QUAN("3", "立减券"),
|
||||
DUIHUAN_QUAN("4", "兑换券"),
|
||||
;
|
||||
private final String code;
|
||||
private final String desc;
|
||||
|
||||
public static ActCouponTypeEnum valueOfByType(String code) {
|
||||
return Arrays.stream(ActCouponTypeEnum.values())
|
||||
.filter(v -> ObjectUtil.equal(v.getCode(), code))
|
||||
.findFirst().orElse(null);
|
||||
}
|
||||
|
||||
public static ActCouponTypeEnum descOf(String description) {
|
||||
return Arrays.stream(ActCouponTypeEnum.values())
|
||||
.filter(v -> ObjectUtil.equal(v.getDesc(), description))
|
||||
.findFirst().orElse(null);
|
||||
}
|
||||
}
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
package com.bsd.pjcloud.wallet.api.constant.act;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* 优惠券适用范围
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum ActCouponUseScopeTypeEnum {
|
||||
ALL_USE("1", "全场通用"),
|
||||
SPECIFIED_MERCHANT("2", "指定商户"),
|
||||
SPECIFIED_CATEGORY("3", "指定商户分类"),
|
||||
;
|
||||
private final String code;
|
||||
private final String desc;
|
||||
|
||||
public static ActCouponUseScopeTypeEnum valueOfByType(String code) {
|
||||
return Arrays.stream(ActCouponUseScopeTypeEnum.values())
|
||||
.filter(v -> ObjectUtil.equal(v.getCode(), code))
|
||||
.findFirst().orElse(null);
|
||||
}
|
||||
|
||||
public static ActCouponUseScopeTypeEnum descOf(String description) {
|
||||
return Arrays.stream(ActCouponUseScopeTypeEnum.values())
|
||||
.filter(v -> ObjectUtil.equal(v.getDesc(), description))
|
||||
.findFirst().orElse(null);
|
||||
}
|
||||
}
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
package com.bsd.pjcloud.wallet.api.constant.act;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* 优惠券有效期类型
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum ActCouponValidTypeEnum {
|
||||
FIXED_DATE("1", "固定日期"),
|
||||
AFTER_RECEIVE("2", "领取后生效"),
|
||||
;
|
||||
private final String code;
|
||||
private final String desc;
|
||||
|
||||
public static ActCouponValidTypeEnum valueOfByType(String code) {
|
||||
return Arrays.stream(ActCouponValidTypeEnum.values())
|
||||
.filter(v -> ObjectUtil.equal(v.getCode(), code))
|
||||
.findFirst().orElse(null);
|
||||
}
|
||||
|
||||
public static ActCouponValidTypeEnum descOf(String description) {
|
||||
return Arrays.stream(ActCouponValidTypeEnum.values())
|
||||
.filter(v -> ObjectUtil.equal(v.getDesc(), description))
|
||||
.findFirst().orElse(null);
|
||||
}
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
package com.bsd.pjcloud.wallet.api.dto.act;
|
||||
|
||||
import com.bsd.pjcloud.wallet.api.entity.act.ActCouponEntity;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class ActCouponDto extends ActCouponEntity {
|
||||
}
|
||||
+167
@@ -0,0 +1,167 @@
|
||||
package com.bsd.pjcloud.wallet.api.entity.act;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import com.baomidou.mybatisplus.extension.activerecord.Model;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import com.bsd.pjcloud.common.core.util.TenantTable;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 优惠券活动
|
||||
*/
|
||||
@Data
|
||||
@TenantTable
|
||||
@TableName("act_coupon")
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Schema(description = "优惠券活动")
|
||||
public class ActCouponEntity extends Model<ActCouponEntity> {
|
||||
|
||||
|
||||
/**
|
||||
* 优惠券ID
|
||||
*/
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
@Schema(description = "优惠券ID")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 优惠券名称
|
||||
*/
|
||||
@Schema(description = "优惠券名称")
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 优惠券类型 (1:满减券 2:折扣券 3:立减券 4:兑换券)
|
||||
*/
|
||||
@Schema(description = "优惠券类型 (1:满减券 2:折扣券 3:立减券 4:兑换券)")
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* 面额/折扣 (满减/立减单位:分, 折扣单位:百分比)
|
||||
*/
|
||||
@Schema(description = "面额/折扣(满减/立减单位:分,折扣单位:百分比)")
|
||||
private Integer faceValue;
|
||||
|
||||
/**
|
||||
* 使用门槛 (满多少分可用, 0表示无门槛)
|
||||
*/
|
||||
@Schema(description = "使用门槛(满多少分可用,null表示无门槛)")
|
||||
private Integer minPoint;
|
||||
|
||||
/**
|
||||
* 发行总量 (-1表示不限量)
|
||||
*/
|
||||
@Schema(description = "发行总量(null表示不限量)")
|
||||
private Integer totalCount;
|
||||
|
||||
/**
|
||||
* 剩余数量
|
||||
*/
|
||||
@Schema(description = "剩余数量")
|
||||
private Integer surplusCount;
|
||||
|
||||
/**
|
||||
* 每人限领数量
|
||||
*/
|
||||
@Schema(description = "每人限领数量")
|
||||
private Integer limitCount;
|
||||
|
||||
/**
|
||||
* 限领类型 (once:活动期间一次 day:每天 week:每周 month:每月 year:每年)
|
||||
*/
|
||||
@Schema(description = "限领类型 (once:活动期间一次 day:每天 week:每周 month:每月 year:每年)")
|
||||
private String limitType;
|
||||
|
||||
/**
|
||||
* 有效期类型 (1:固定日期 2:领取后生效)
|
||||
*/
|
||||
@Schema(description = "有效期类型 (1:固定日期 2:领取后生效)")
|
||||
private String validType;
|
||||
|
||||
/**
|
||||
* 有效期开始时间
|
||||
*/
|
||||
@Schema(description = "有效期开始时间")
|
||||
private LocalDateTime validStartTime;
|
||||
|
||||
/**
|
||||
* 有效期结束时间
|
||||
*/
|
||||
@Schema(description = "有效期结束时间")
|
||||
private LocalDateTime validEndTime;
|
||||
|
||||
/**
|
||||
* 领取后有效天数
|
||||
*/
|
||||
@Schema(description = "领取后有效天数")
|
||||
private Integer validDays;
|
||||
|
||||
/**
|
||||
* 适用范围 (1:全场通用 2:指定商户 3:指定分类 4:指定商品)
|
||||
*/
|
||||
@Schema(description = "适用范围 (0:全场通用 1:指定商户 2:指定分类 3:指定商品)")
|
||||
private String useScopeType;
|
||||
|
||||
/**
|
||||
* 适用范围ID集合 (商户ID/分类ID/商品ID, 逗号分隔)
|
||||
*/
|
||||
@Schema(description = "适用范围ID集合 (商户ID/分类ID/商品ID, 逗号分隔)")
|
||||
private String scopeId;
|
||||
|
||||
/**
|
||||
* 状态(1:草稿2:进行中3:已结束4:已作废)
|
||||
*/
|
||||
@Schema(description = "状态(1:草稿2:进行中3:已结束4:已作废)")
|
||||
private String status;
|
||||
|
||||
/**
|
||||
* 使用说明
|
||||
*/
|
||||
@Schema(description = "使用说明")
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
@Schema(description = "创建人")
|
||||
private String createBy;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
@Schema(description = "创建时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
* 修改人
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||
@Schema(description = "修改人")
|
||||
private String updateBy;
|
||||
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||
@Schema(description = "修改时间")
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
/**
|
||||
* 删除标记
|
||||
*/
|
||||
@TableLogic
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
@Schema(description = "删除标记")
|
||||
private String delFlag;
|
||||
|
||||
/**
|
||||
* 租户ID
|
||||
*/
|
||||
@Schema(description = "租户ID")
|
||||
private Long tenantId;
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
package com.bsd.pjcloud.wallet.api.vo.act;
|
||||
|
||||
import com.bsd.pjcloud.wallet.api.dto.act.ActCouponDto;
|
||||
import com.bsd.pjcloud.wallet.api.entity.act.ActCouponEntity;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class ActCouponVo extends ActCouponEntity {
|
||||
|
||||
}
|
||||
+101
@@ -0,0 +1,101 @@
|
||||
package com.bsd.pjcloud.wallet.controller.act;
|
||||
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.bsd.pjcloud.common.core.util.R;
|
||||
import com.bsd.pjcloud.common.log.annotation.SysLog;
|
||||
import com.bsd.pjcloud.wallet.api.dto.act.ActCouponDto;
|
||||
import com.bsd.pjcloud.wallet.api.entity.act.ActCouponEntity;
|
||||
import com.bsd.pjcloud.wallet.service.ActCouponService;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import com.bsd.pjcloud.common.excel.annotation.ResponseExcel;
|
||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||
import org.springdoc.core.annotations.ParameterObject;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 优惠券活动
|
||||
*/
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping("/act-coupon")
|
||||
@Tag(description = "act-coupon", name = "优惠券活动管理")
|
||||
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
|
||||
public class ActCouponController {
|
||||
|
||||
private final ActCouponService actCouponService;
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*/
|
||||
@Operation(summary = "分页查询", description = "分页查询")
|
||||
@GetMapping("/page")
|
||||
@PreAuthorize("@pms.hasPermission('wallet_actCoupon_view')")
|
||||
public R getActCouponPage(@ParameterObject Page page, @ParameterObject ActCouponDto dto) {
|
||||
LambdaQueryWrapper<ActCouponEntity> wrapper = Wrappers.lambdaQuery();
|
||||
return R.ok(actCouponService.page(page, wrapper));
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id查询优惠券活动
|
||||
*/
|
||||
@Operation(summary = "通过id查询", description = "通过id查询")
|
||||
@GetMapping("/{id}")
|
||||
@PreAuthorize("@pms.hasPermission('wallet_actCoupon_view')")
|
||||
public R getById(@PathVariable("id") Long id) {
|
||||
return R.ok(actCouponService.getById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增优惠券活动
|
||||
*/
|
||||
@Operation(summary = "新增优惠券活动", description = "新增优惠券活动")
|
||||
@SysLog("新增优惠券活动")
|
||||
@PostMapping
|
||||
@PreAuthorize("@pms.hasPermission('wallet_actCoupon_add')")
|
||||
public R save(@RequestBody ActCouponEntity actCoupon) {
|
||||
return R.ok(actCouponService.save(actCoupon));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改优惠券活动
|
||||
*/
|
||||
@Operation(summary = "修改优惠券活动", description = "修改优惠券活动")
|
||||
@SysLog("修改优惠券活动")
|
||||
@PutMapping
|
||||
@PreAuthorize("@pms.hasPermission('wallet_actCoupon_edit')")
|
||||
public R updateById(@RequestBody ActCouponEntity actCoupon) {
|
||||
return R.ok(actCouponService.updateById(actCoupon));
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id删除优惠券活动
|
||||
*/
|
||||
@Operation(summary = "通过id删除优惠券活动", description = "通过id删除优惠券活动")
|
||||
@SysLog("通过id删除优惠券活动")
|
||||
@DeleteMapping
|
||||
@PreAuthorize("@pms.hasPermission('wallet_actCoupon_del')")
|
||||
public R removeById(@RequestBody Long[] ids) {
|
||||
return R.ok(actCouponService.removeBatchByIds(CollUtil.toList(ids)));
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出excel 表格
|
||||
*/
|
||||
@ResponseExcel
|
||||
@GetMapping("/export")
|
||||
@PreAuthorize("@pms.hasPermission('wallet_actCoupon_export')")
|
||||
public List<ActCouponEntity> export(ActCouponEntity actCoupon, Long[] ids) {
|
||||
return actCouponService.list(Wrappers.lambdaQuery(actCoupon).in(ArrayUtil.isNotEmpty(ids), ActCouponEntity::getId, ids));
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
package com.bsd.pjcloud.wallet.mapper.act;
|
||||
|
||||
import com.bsd.pjcloud.common.data.datascope.PjcloudBaseMapper;
|
||||
import com.bsd.pjcloud.wallet.api.entity.act.ActCouponEntity;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface ActCouponMapper extends PjcloudBaseMapper<ActCouponEntity> {
|
||||
|
||||
}
|
||||
pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/service/ActCouponService.java
Executable
+8
@@ -0,0 +1,8 @@
|
||||
package com.bsd.pjcloud.wallet.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.bsd.pjcloud.wallet.api.entity.act.ActCouponEntity;
|
||||
|
||||
public interface ActCouponService extends IService<ActCouponEntity> {
|
||||
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
package com.bsd.pjcloud.wallet.service.impl.act;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.bsd.pjcloud.wallet.api.entity.act.ActCouponEntity;
|
||||
import com.bsd.pjcloud.wallet.mapper.act.ActCouponMapper;
|
||||
import com.bsd.pjcloud.wallet.service.ActCouponService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 优惠券活动
|
||||
*/
|
||||
@Service
|
||||
public class ActCouponServiceImpl extends ServiceImpl<ActCouponMapper, ActCouponEntity> implements ActCouponService {
|
||||
|
||||
}
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
|
||||
<mapper namespace="com.bsd.pjcloud.wallet.service.impl.act.ActCouponServiceImpl">
|
||||
|
||||
<sql id="selectA">
|
||||
select a.id,
|
||||
a.name,
|
||||
a.type,
|
||||
a.face_value,
|
||||
a.min_point,
|
||||
a.total_count,
|
||||
a.surplus_count,
|
||||
a.limit_count,
|
||||
a.limit_type,
|
||||
a.valid_type,
|
||||
a.valid_start_time,
|
||||
a.valid_end_time,
|
||||
a.valid_days,
|
||||
a.use_scope_type,
|
||||
a.scope_id,
|
||||
a.status,
|
||||
a.description,
|
||||
a.create_by,
|
||||
a.create_time,
|
||||
a.update_by,
|
||||
a.update_time,
|
||||
a.del_flag,
|
||||
a.tenant_id
|
||||
</sql>
|
||||
|
||||
<sql id="whereA">
|
||||
a.del_flag = '0'
|
||||
<if test="dto.name != null">
|
||||
and a.name LIKE CONCAT('%',#{dto.name},'%')
|
||||
</if>
|
||||
<if test="dto.type != null and dto.type != '' ">
|
||||
and a.type = #{dto.type}
|
||||
</if>
|
||||
</sql>
|
||||
|
||||
</mapper>
|
||||
Reference in new issue
Block a user