会员:增加会员等级增删改查

This commit is contained in:
owen 2023-08-20 15:54:06 +08:00
parent 9eca965dd6
commit e2032e7e97
42 changed files with 1924 additions and 3 deletions

121
sql/mysql/member_level.sql Normal file
View File

@ -0,0 +1,121 @@
-- 会员表增加字段
alter table member_user add column experience int not null default 0 comment '经验';
alter table member_user add column level_id bigint comment '等级编号';
-- 增加3张表
create table member_level
(
id bigint auto_increment comment '编号' primary key,
name varchar(30) default '' not null comment '等级名称',
experience int default 0 not null comment '升级经验',
level int default 0 not null comment '等级',
discount int(4) default 100 not null comment '享受折扣',
icon varchar(255) default '' not null comment '等级图标',
background_url varchar(255) default '' not null comment '等级背景图',
status tinyint default 0 not null comment '状态',
creator varchar(64) default '' null comment '创建者',
create_time datetime default CURRENT_TIMESTAMP not null comment '创建时间',
updater varchar(64) default '' null comment '更新者',
update_time datetime default CURRENT_TIMESTAMP not null on update CURRENT_TIMESTAMP comment '更新时间',
deleted bit default b'0' not null comment '是否删除',
tenant_id bigint default 0 not null comment '租户编号'
)
comment '会员等级';
create table member_level_log
(
id bigint auto_increment comment '编号' primary key,
user_id bigint default 0 not null comment '用户编号',
level_id bigint default 0 not null comment '等级编号',
level int default 0 not null comment '会员等级',
discount int(4) default 100 not null comment '享受折扣',
experience int(4) default 100 not null comment '升级经验',
user_experience int(4) default 100 not null comment '会员此时的经验',
remark varchar(255) default '' not null comment '备注',
description varchar(255) default '' not null comment '描述',
creator varchar(64) default '' null comment '创建者',
create_time datetime default CURRENT_TIMESTAMP not null comment '创建时间',
updater varchar(64) default '' null comment '更新者',
update_time datetime default CURRENT_TIMESTAMP not null on update CURRENT_TIMESTAMP comment '更新时间',
deleted bit default b'0' not null comment '是否删除',
tenant_id bigint default 0 not null comment '租户编号'
)
comment '会员等级记录';
create index idx_user_id on member_level_log (user_id) comment '会员等级记录-用户编号';
create table member_experience_log
(
id bigint auto_increment comment '编号' primary key,
user_id bigint default 0 not null comment '用户编号',
biz_id varchar(64) default '' not null comment '业务编号',
biz_type tinyint default 0 not null comment '业务类型',
title varchar(30) default '' not null comment '标题',
experience int default 0 not null comment '经验',
total_experience int default 0 not null comment '变更后的经验',
description varchar(512) default '' not null comment '描述',
creator varchar(64) default '' null comment '创建者',
create_time datetime default CURRENT_TIMESTAMP not null comment '创建时间',
updater varchar(64) default '' null comment '更新者',
update_time datetime default CURRENT_TIMESTAMP not null on update CURRENT_TIMESTAMP comment '更新时间',
deleted bit default b'0' not null comment '是否删除',
tenant_id bigint default 0 not null comment '租户编号'
)
comment '会员经验记录';
create index idx_user_id on member_experience_log (user_id) comment '会员经验记录-用户编号';
create index idx_user_biz_type on member_experience_log (user_id, biz_type) comment '会员经验记录-用户业务类型';
-- 增加字典
insert system_dict_type(name, type) values ('会员经验业务类型', 'member_experience_biz_type');
insert system_dict_data(dict_type, label, value, sort) values ('member_experience_biz_type', '系统', '0', 0);
insert system_dict_data(dict_type, label, value, sort) values ('member_experience_biz_type', '订单', '1', 1);
insert system_dict_data(dict_type, label, value, sort) values ('member_experience_biz_type', '签到', '2', 2);
-- 菜单 SQL
INSERT INTO system_menu(
name, permission, type, sort, parent_id,
path, icon, component, status, component_name
)
VALUES (
'会员等级', '', 2, 3, 2262,
'level', '', 'member/level/index', 0, 'MemberLevel'
);
-- 按钮父菜单ID
-- 暂时只支持 MySQL如果你是 OraclePostgreSQLSQLServer 的话需要手动修改 @parentId 的部分的代码
SELECT @parentId := LAST_INSERT_ID();
-- 按钮 SQL
INSERT INTO system_menu(
name, permission, type, sort, parent_id,
path, icon, component, status
)
VALUES (
'会员等级查询', 'member:level:query', 3, 1, @parentId,
'', '', '', 0
);
INSERT INTO system_menu(
name, permission, type, sort, parent_id,
path, icon, component, status
)
VALUES (
'会员等级创建', 'member:level:create', 3, 2, @parentId,
'', '', '', 0
);
INSERT INTO system_menu(
name, permission, type, sort, parent_id,
path, icon, component, status
)
VALUES (
'会员等级更新', 'member:level:update', 3, 3, @parentId,
'', '', '', 0
);
INSERT INTO system_menu(
name, permission, type, sort, parent_id,
path, icon, component, status
)
VALUES (
'会员等级删除', 'member:level:delete', 3, 4, @parentId,
'', '', '', 0
);

View File

@ -0,0 +1,15 @@
package cn.iocoder.yudao.module.member.enums;
/**
* Member 字典类型的枚举类
*
* @author owen
*/
public interface DictTypeConstants {
/**
* 会员经验记录 - 业务类型
*/
String MEMBER_EXPERIENCE_BIZ_TYPE = "member_experience_biz_type";
}

View File

@ -41,4 +41,9 @@ public interface ErrorCodeConstants {
ErrorCode TAG_NOT_EXISTS = new ErrorCode(1004006000, "会员标签不存在");
ErrorCode TAG_NAME_EXISTS = new ErrorCode(1004006001, "会员标签已经存在");
//========== 会员等级 1004007000 ==========
ErrorCode LEVEL_NOT_EXISTS = new ErrorCode(1004007000, "会员等级不存在");
ErrorCode LEVEL_LOG_NOT_EXISTS = new ErrorCode(1004007100, "会员等级记录不存在");
ErrorCode EXPERIENCE_LOG_NOT_EXISTS = new ErrorCode(1004007200, "会员经验记录不存在");
}

View File

@ -0,0 +1,24 @@
package cn.iocoder.yudao.module.member.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* 会员经验 - 业务类型
*
* @author owen
*/
@Getter
@AllArgsConstructor
public enum MemberExperienceBizTypeEnum {
/**
*
*/
SYSTEM(0, "系统"),
ORDER(1, "订单"),
SIGN_IN(2, "签到"),
;
private final int value;
private final String name;
}

View File

@ -0,0 +1,90 @@
package cn.iocoder.yudao.module.member.controller.admin.level;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
import cn.iocoder.yudao.module.member.controller.admin.level.vo.experience.MemberExperienceLogExcelVO;
import cn.iocoder.yudao.module.member.controller.admin.level.vo.experience.MemberExperienceLogExportReqVO;
import cn.iocoder.yudao.module.member.controller.admin.level.vo.experience.MemberExperienceLogPageReqVO;
import cn.iocoder.yudao.module.member.controller.admin.level.vo.experience.MemberExperienceLogRespVO;
import cn.iocoder.yudao.module.member.convert.level.MemberExperienceLogConvert;
import cn.iocoder.yudao.module.member.dal.dataobject.level.MemberExperienceLogDO;
import cn.iocoder.yudao.module.member.service.level.MemberExperienceLogService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.io.IOException;
import java.util.Collection;
import java.util.List;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT;
/**
* @author owen
*/
@Tag(name = "管理后台 - 会员经验记录")
@RestController
@RequestMapping("/member/experience-log")
@Validated
public class MemberExperienceLogController {
@Resource
private MemberExperienceLogService experienceLogService;
@DeleteMapping("/delete")
@Operation(summary = "删除会员经验记录")
@Parameter(name = "id", description = "编号", required = true)
@PreAuthorize("@ss.hasPermission('member:experience-log:delete')")
public CommonResult<Boolean> deleteExperienceLog(@RequestParam("id") Long id) {
experienceLogService.deleteExperienceLog(id);
return success(true);
}
@GetMapping("/get")
@Operation(summary = "获得会员经验记录")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('member:experience-log:query')")
public CommonResult<MemberExperienceLogRespVO> getExperienceLog(@RequestParam("id") Long id) {
MemberExperienceLogDO experienceLog = experienceLogService.getExperienceLog(id);
return success(MemberExperienceLogConvert.INSTANCE.convert(experienceLog));
}
@GetMapping("/list")
@Operation(summary = "获得会员经验记录列表")
@Parameter(name = "ids", description = "编号列表", required = true, example = "1024,2048")
@PreAuthorize("@ss.hasPermission('member:experience-log:query')")
public CommonResult<List<MemberExperienceLogRespVO>> getExperienceLogList(@RequestParam("ids") Collection<Long> ids) {
List<MemberExperienceLogDO> list = experienceLogService.getExperienceLogList(ids);
return success(MemberExperienceLogConvert.INSTANCE.convertList(list));
}
@GetMapping("/page")
@Operation(summary = "获得会员经验记录分页")
@PreAuthorize("@ss.hasPermission('member:experience-log:query')")
public CommonResult<PageResult<MemberExperienceLogRespVO>> getExperienceLogPage(@Valid MemberExperienceLogPageReqVO pageVO) {
PageResult<MemberExperienceLogDO> pageResult = experienceLogService.getExperienceLogPage(pageVO);
return success(MemberExperienceLogConvert.INSTANCE.convertPage(pageResult));
}
@GetMapping("/export-excel")
@Operation(summary = "导出会员经验记录 Excel")
@PreAuthorize("@ss.hasPermission('member:experience-log:export')")
@OperateLog(type = EXPORT)
public void exportExperienceLogExcel(@Valid MemberExperienceLogExportReqVO exportReqVO,
HttpServletResponse response) throws IOException {
List<MemberExperienceLogDO> list = experienceLogService.getExperienceLogList(exportReqVO);
// 导出 Excel
List<MemberExperienceLogExcelVO> datas = MemberExperienceLogConvert.INSTANCE.convertList02(list);
ExcelUtils.write(response, "会员经验记录.xls", "数据", MemberExperienceLogExcelVO.class, datas);
}
}

View File

@ -0,0 +1,95 @@
package cn.iocoder.yudao.module.member.controller.admin.level;
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.member.controller.admin.level.vo.*;
import cn.iocoder.yudao.module.member.convert.level.MemberLevelConvert;
import cn.iocoder.yudao.module.member.dal.dataobject.level.MemberLevelDO;
import cn.iocoder.yudao.module.member.service.level.MemberLevelService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.Collection;
import java.util.List;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
/**
* @author owen
*/
@Tag(name = "管理后台 - 会员等级")
@RestController
@RequestMapping("/member/level")
@Validated
public class MemberLevelController {
@Resource
private MemberLevelService levelService;
@PostMapping("/create")
@Operation(summary = "创建会员等级")
@PreAuthorize("@ss.hasPermission('member:level:create')")
public CommonResult<Long> createLevel(@Valid @RequestBody MemberLevelCreateReqVO createReqVO) {
return success(levelService.createLevel(createReqVO));
}
@PutMapping("/update")
@Operation(summary = "更新会员等级")
@PreAuthorize("@ss.hasPermission('member:level:update')")
public CommonResult<Boolean> updateLevel(@Valid @RequestBody MemberLevelUpdateReqVO updateReqVO) {
levelService.updateLevel(updateReqVO);
return success(true);
}
@DeleteMapping("/delete")
@Operation(summary = "删除会员等级")
@Parameter(name = "id", description = "编号", required = true)
@PreAuthorize("@ss.hasPermission('member:level:delete')")
public CommonResult<Boolean> deleteLevel(@RequestParam("id") Long id) {
levelService.deleteLevel(id);
return success(true);
}
@GetMapping("/get")
@Operation(summary = "获得会员等级")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('member:level:query')")
public CommonResult<MemberLevelRespVO> getLevel(@RequestParam("id") Long id) {
MemberLevelDO level = levelService.getLevel(id);
return success(MemberLevelConvert.INSTANCE.convert(level));
}
@GetMapping("/list")
@Operation(summary = "获得会员等级列表")
@Parameter(name = "ids", description = "编号列表", required = true, example = "1024,2048")
@PreAuthorize("@ss.hasPermission('member:level:query')")
public CommonResult<List<MemberLevelRespVO>> getLevelList(@RequestParam("ids") Collection<Long> ids) {
List<MemberLevelDO> list = levelService.getLevelList(ids);
return success(MemberLevelConvert.INSTANCE.convertList(list));
}
@GetMapping("/list-all-simple")
@Operation(summary = "获取会员等级精简信息列表", description = "只包含被开启的会员等级,主要用于前端的下拉选项")
public CommonResult<List<MemberLevelSimpleRespVO>> getSimpleUserList() {
// 获用户列表只要开启状态的
List<MemberLevelDO> list = levelService.getLevelListByStatus(CommonStatusEnum.ENABLE.getStatus());
// 排序后返回给前端
return success(MemberLevelConvert.INSTANCE.convertSimpleList(list));
}
@GetMapping("/page")
@Operation(summary = "获得会员等级分页")
@PreAuthorize("@ss.hasPermission('member:level:query')")
public CommonResult<PageResult<MemberLevelRespVO>> getLevelPage(@Valid MemberLevelPageReqVO pageVO) {
PageResult<MemberLevelDO> pageResult = levelService.getLevelPage(pageVO);
return success(MemberLevelConvert.INSTANCE.convertPage(pageResult));
}
}

View File

@ -0,0 +1,90 @@
package cn.iocoder.yudao.module.member.controller.admin.level;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
import cn.iocoder.yudao.module.member.controller.admin.level.vo.log.MemberLevelLogExcelVO;
import cn.iocoder.yudao.module.member.controller.admin.level.vo.log.MemberLevelLogExportReqVO;
import cn.iocoder.yudao.module.member.controller.admin.level.vo.log.MemberLevelLogPageReqVO;
import cn.iocoder.yudao.module.member.controller.admin.level.vo.log.MemberLevelLogRespVO;
import cn.iocoder.yudao.module.member.convert.level.MemberLevelLogConvert;
import cn.iocoder.yudao.module.member.dal.dataobject.level.MemberLevelLogDO;
import cn.iocoder.yudao.module.member.service.level.MemberLevelLogService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.io.IOException;
import java.util.Collection;
import java.util.List;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT;
/**
* @author owen
*/
@Tag(name = "管理后台 - 会员等级记录")
@RestController
@RequestMapping("/member/level-log")
@Validated
public class MemberLevelLogController {
@Resource
private MemberLevelLogService levelLogService;
@DeleteMapping("/delete")
@Operation(summary = "删除会员等级记录")
@Parameter(name = "id", description = "编号", required = true)
@PreAuthorize("@ss.hasPermission('member:level-log:delete')")
public CommonResult<Boolean> deleteLevelLog(@RequestParam("id") Long id) {
levelLogService.deleteLevelLog(id);
return success(true);
}
@GetMapping("/get")
@Operation(summary = "获得会员等级记录")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('member:level-log:query')")
public CommonResult<MemberLevelLogRespVO> getLevelLog(@RequestParam("id") Long id) {
MemberLevelLogDO levelLog = levelLogService.getLevelLog(id);
return success(MemberLevelLogConvert.INSTANCE.convert(levelLog));
}
@GetMapping("/list")
@Operation(summary = "获得会员等级记录列表")
@Parameter(name = "ids", description = "编号列表", required = true, example = "1024,2048")
@PreAuthorize("@ss.hasPermission('member:level-log:query')")
public CommonResult<List<MemberLevelLogRespVO>> getLevelLogList(@RequestParam("ids") Collection<Long> ids) {
List<MemberLevelLogDO> list = levelLogService.getLevelLogList(ids);
return success(MemberLevelLogConvert.INSTANCE.convertList(list));
}
@GetMapping("/page")
@Operation(summary = "获得会员等级记录分页")
@PreAuthorize("@ss.hasPermission('member:level-log:query')")
public CommonResult<PageResult<MemberLevelLogRespVO>> getLevelLogPage(@Valid MemberLevelLogPageReqVO pageVO) {
PageResult<MemberLevelLogDO> pageResult = levelLogService.getLevelLogPage(pageVO);
return success(MemberLevelLogConvert.INSTANCE.convertPage(pageResult));
}
@GetMapping("/export-excel")
@Operation(summary = "导出会员等级记录 Excel")
@PreAuthorize("@ss.hasPermission('member:level-log:export')")
@OperateLog(type = EXPORT)
public void exportLevelLogExcel(@Valid MemberLevelLogExportReqVO exportReqVO,
HttpServletResponse response) throws IOException {
List<MemberLevelLogDO> list = levelLogService.getLevelLogList(exportReqVO);
// 导出 Excel
List<MemberLevelLogExcelVO> datas = MemberLevelLogConvert.INSTANCE.convertList02(list);
ExcelUtils.write(response, "会员等级记录.xls", "数据", MemberLevelLogExcelVO.class, datas);
}
}

View File

@ -0,0 +1,51 @@
package cn.iocoder.yudao.module.member.controller.admin.level.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.hibernate.validator.constraints.Range;
import org.hibernate.validator.constraints.URL;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Positive;
/**
* 会员等级 Base VO提供给添加修改详细的子 VO 使用
* 如果子 VO 存在差异的字段请不要添加到这里影响 Swagger 文档生成
*
* @author owen
*/
@Data
public class MemberLevelBaseVO {
@Schema(description = "等级名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿")
@NotBlank(message = "等级名称不能为空")
private String name;
@Schema(description = "升级经验", requiredMode = Schema.RequiredMode.REQUIRED, example = "100")
@NotNull(message = "升级经验不能为空")
@Positive(message = "升级经验必须大于0")
private Integer experience;
@Schema(description = "等级", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
@NotNull(message = "等级不能为空")
private Integer level;
@Schema(description = "享受折扣", requiredMode = Schema.RequiredMode.REQUIRED, example = "98")
@NotNull(message = "享受折扣不能为空")
@Range(min = 0, max = 100, message = "享受折扣的范围为0-100")
private Integer discount;
@Schema(description = "等级图标", example = "https://www.iocoder.cn/yudao.jpg")
@URL(message = "等级图标 必须是 URL 格式")
private String icon;
@Schema(description = "等级背景图", example = "https://www.iocoder.cn/yudao.jpg")
@URL(message = "等级背景图 必须是 URL 格式")
private String backgroundUrl;
@Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
@NotNull(message = "状态不能为空")
private Integer status;
}

View File

@ -0,0 +1,17 @@
package cn.iocoder.yudao.module.member.controller.admin.level.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
/**
* @author owen
*/
@Schema(description = "管理后台 - 会员等级创建 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class MemberLevelCreateReqVO extends MemberLevelBaseVO {
}

View File

@ -0,0 +1,24 @@
package cn.iocoder.yudao.module.member.controller.admin.level.vo;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
/**
* @author owen
*/
@Schema(description = "管理后台 - 会员等级分页 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class MemberLevelPageReqVO extends PageParam {
@Schema(description = "等级名称", example = "芋艿")
private String name;
@Schema(description = "状态", example = "1")
private Integer status;
}

View File

@ -0,0 +1,25 @@
package cn.iocoder.yudao.module.member.controller.admin.level.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import java.time.LocalDateTime;
/**
* @author owen
*/
@Schema(description = "管理后台 - 会员等级 Response VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class MemberLevelRespVO extends MemberLevelBaseVO {
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "6103")
private Long id;
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
private LocalDateTime createTime;
}

View File

@ -0,0 +1,26 @@
package cn.iocoder.yudao.module.member.controller.admin.level.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
/**
* @author owen
*/
@Schema(description = "管理后台 - 会员等级 Response VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class MemberLevelSimpleRespVO extends MemberLevelBaseVO {
@Schema(description = "编号", example = "6103")
private Long id;
@Schema(description = "等级名称", example = "芋艿")
private String name;
@Schema(description = "等级图标", example = "https://www.iocoder.cn/yudao.jpg")
private String icon;
}

View File

@ -0,0 +1,23 @@
package cn.iocoder.yudao.module.member.controller.admin.level.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import javax.validation.constraints.NotNull;
/**
* @author owen
*/
@Schema(description = "管理后台 - 会员等级更新 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class MemberLevelUpdateReqVO extends MemberLevelBaseVO {
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "6103")
@NotNull(message = "编号不能为空")
private Long id;
}

View File

@ -0,0 +1,45 @@
package cn.iocoder.yudao.module.member.controller.admin.level.vo.experience;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import javax.validation.constraints.NotNull;
/**
* 会员经验记录 Base VO提供给添加修改详细的子 VO 使用
* 如果子 VO 存在差异的字段请不要添加到这里影响 Swagger 文档生成
*
* @author owen
*/
@Data
public class MemberExperienceLogBaseVO {
@Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "3638")
@NotNull(message = "用户编号不能为空")
private Long userId;
@Schema(description = "业务编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "12164")
@NotNull(message = "业务编号不能为空")
private String bizId;
@Schema(description = "业务类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
@NotNull(message = "业务类型不能为空")
private Integer bizType;
@Schema(description = "标题", requiredMode = Schema.RequiredMode.REQUIRED, example = "增加经验")
@NotNull(message = "标题不能为空")
private String title;
@Schema(description = "经验", requiredMode = Schema.RequiredMode.REQUIRED, example = "100")
@NotNull(message = "经验不能为空")
private Integer experience;
@Schema(description = "变更后的经验", requiredMode = Schema.RequiredMode.REQUIRED, example = "200")
@NotNull(message = "变更后的经验不能为空")
private Integer totalExperience;
@Schema(description = "描述", requiredMode = Schema.RequiredMode.REQUIRED, example = "下单增加100经验")
@NotNull(message = "描述不能为空")
private String description;
}

View File

@ -0,0 +1,48 @@
package cn.iocoder.yudao.module.member.controller.admin.level.vo.experience;
import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
import cn.iocoder.yudao.framework.excel.core.convert.DictConvert;
import cn.iocoder.yudao.module.member.enums.DictTypeConstants;
import com.alibaba.excel.annotation.ExcelProperty;
import lombok.Data;
import java.time.LocalDateTime;
/**
* 会员经验记录 Excel VO
*
* @author owen
*/
@Data
public class MemberExperienceLogExcelVO {
@ExcelProperty("编号")
private Long id;
@ExcelProperty("用户编号")
private Long userId;
@ExcelProperty(value = "业务类型", converter = DictConvert.class)
@DictFormat(DictTypeConstants.MEMBER_EXPERIENCE_BIZ_TYPE)
private Integer bizType;
@ExcelProperty("业务编号")
private String bizId;
@ExcelProperty("标题")
private String title;
@ExcelProperty("经验")
private Integer experience;
@ExcelProperty("变更后的经验")
private Integer totalExperience;
@ExcelProperty("描述")
private String description;
@ExcelProperty("创建时间")
private LocalDateTime createTime;
}

View File

@ -0,0 +1,34 @@
package cn.iocoder.yudao.module.member.controller.admin.level.vo.experience;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
/**
* @author owen
*/
@Schema(description = "管理后台 - 会员经验记录 Excel 导出 Request VO参数和 MemberExperienceLogPageReqVO 是一致的")
@Data
public class MemberExperienceLogExportReqVO {
@Schema(description = "用户编号", example = "3638")
private Long userId;
@Schema(description = "业务类型", example = "1")
private Integer bizType;
@Schema(description = "业务编号", example = "12164")
private String bizId;
@Schema(description = "标题", example = "增加经验")
private String title;
@Schema(description = "创建时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] createTime;
}

View File

@ -0,0 +1,39 @@
package cn.iocoder.yudao.module.member.controller.admin.level.vo.experience;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
/**
* @author owen
*/
@Schema(description = "管理后台 - 会员经验记录分页 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class MemberExperienceLogPageReqVO extends PageParam {
@Schema(description = "用户编号", example = "3638")
private Long userId;
@Schema(description = "业务编号", example = "12164")
private String bizId;
@Schema(description = "业务类型", example = "1")
private Integer bizType;
@Schema(description = "标题", example = "增加经验")
private String title;
@Schema(description = "创建时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] createTime;
}

View File

@ -0,0 +1,25 @@
package cn.iocoder.yudao.module.member.controller.admin.level.vo.experience;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import java.time.LocalDateTime;
/**
* @author owen
*/
@Schema(description = "管理后台 - 会员经验记录 Response VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class MemberExperienceLogRespVO extends MemberExperienceLogBaseVO {
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "19610")
private Long id;
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
private LocalDateTime createTime;
}

View File

@ -0,0 +1,49 @@
package cn.iocoder.yudao.module.member.controller.admin.level.vo.log;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import javax.validation.constraints.NotNull;
/**
* 会员等级记录 Base VO提供给添加修改详细的子 VO 使用
* 如果子 VO 存在差异的字段请不要添加到这里影响 Swagger 文档生成
*
* @author owen
*/
@Data
public class MemberLevelLogBaseVO {
@Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "25923")
@NotNull(message = "用户编号不能为空")
private Long userId;
@Schema(description = "等级编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "25985")
@NotNull(message = "等级编号不能为空")
private Long levelId;
@Schema(description = "会员等级", requiredMode = Schema.RequiredMode.REQUIRED)
@NotNull(message = "会员等级不能为空")
private Integer level;
@Schema(description = "享受折扣", requiredMode = Schema.RequiredMode.REQUIRED, example = "13319")
@NotNull(message = "享受折扣不能为空")
private Integer discount;
@Schema(description = "升级经验", requiredMode = Schema.RequiredMode.REQUIRED, example = "13319")
@NotNull(message = "升级经验不能为空")
private Integer experience;
@Schema(description = "会员此时的经验", requiredMode = Schema.RequiredMode.REQUIRED, example = "13319")
@NotNull(message = "会员此时的经验不能为空")
private Integer userExperience;
@Schema(description = "备注", requiredMode = Schema.RequiredMode.REQUIRED, example = "推广需要")
@NotNull(message = "备注不能为空")
private String remark;
@Schema(description = "描述", requiredMode = Schema.RequiredMode.REQUIRED, example = "升级为金牌会员")
@NotNull(message = "描述不能为空")
private String description;
}

View File

@ -0,0 +1,46 @@
package cn.iocoder.yudao.module.member.controller.admin.level.vo.log;
import com.alibaba.excel.annotation.ExcelProperty;
import lombok.Data;
import java.time.LocalDateTime;
/**
* 会员等级记录 Excel VO
*
* @author owen
*/
@Data
public class MemberLevelLogExcelVO {
@ExcelProperty("编号")
private Long id;
@ExcelProperty("用户编号")
private Long userId;
@ExcelProperty("等级编号")
private Long levelId;
@ExcelProperty("会员等级")
private Integer level;
@ExcelProperty("享受折扣")
private Integer discount;
@ExcelProperty("升级经验")
private Integer experience;
@ExcelProperty("会员此时的经验")
private Integer userExperience;
@ExcelProperty("备注")
private String remark;
@ExcelProperty("描述")
private String description;
@ExcelProperty("创建时间")
private LocalDateTime createTime;
}

View File

@ -0,0 +1,28 @@
package cn.iocoder.yudao.module.member.controller.admin.level.vo.log;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
/**
* @author owen
*/
@Schema(description = "管理后台 - 会员等级记录 Excel 导出 Request VO参数和 MemberLevelLogPageReqVO 是一致的")
@Data
public class MemberLevelLogExportReqVO {
@Schema(description = "用户编号", example = "25923")
private Long userId;
@Schema(description = "等级编号", example = "25985")
private Long levelId;
@Schema(description = "创建时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] createTime;
}

View File

@ -0,0 +1,33 @@
package cn.iocoder.yudao.module.member.controller.admin.level.vo.log;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
/**
* @author owen
*/
@Schema(description = "管理后台 - 会员等级记录分页 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class MemberLevelLogPageReqVO extends PageParam {
@Schema(description = "用户编号", example = "25923")
private Long userId;
@Schema(description = "等级编号", example = "25985")
private Long levelId;
@Schema(description = "创建时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] createTime;
}

View File

@ -0,0 +1,25 @@
package cn.iocoder.yudao.module.member.controller.admin.level.vo.log;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import java.time.LocalDateTime;
/**
* @author owen
*/
@Schema(description = "管理后台 - 会员等级记录 Response VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class MemberLevelLogRespVO extends MemberLevelLogBaseVO {
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "8741")
private Long id;
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
private LocalDateTime createTime;
}

View File

@ -0,0 +1,30 @@
package cn.iocoder.yudao.module.member.convert.level;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.member.controller.admin.level.vo.experience.MemberExperienceLogExcelVO;
import cn.iocoder.yudao.module.member.controller.admin.level.vo.experience.MemberExperienceLogRespVO;
import cn.iocoder.yudao.module.member.dal.dataobject.level.MemberExperienceLogDO;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
import java.util.List;
/**
* 会员经验记录 Convert
*
* @author owen
*/
@Mapper
public interface MemberExperienceLogConvert {
MemberExperienceLogConvert INSTANCE = Mappers.getMapper(MemberExperienceLogConvert.class);
MemberExperienceLogRespVO convert(MemberExperienceLogDO bean);
List<MemberExperienceLogRespVO> convertList(List<MemberExperienceLogDO> list);
PageResult<MemberExperienceLogRespVO> convertPage(PageResult<MemberExperienceLogDO> page);
List<MemberExperienceLogExcelVO> convertList02(List<MemberExperienceLogDO> list);
}

View File

@ -0,0 +1,35 @@
package cn.iocoder.yudao.module.member.convert.level;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.member.controller.admin.level.vo.MemberLevelCreateReqVO;
import cn.iocoder.yudao.module.member.controller.admin.level.vo.MemberLevelRespVO;
import cn.iocoder.yudao.module.member.controller.admin.level.vo.MemberLevelSimpleRespVO;
import cn.iocoder.yudao.module.member.controller.admin.level.vo.MemberLevelUpdateReqVO;
import cn.iocoder.yudao.module.member.dal.dataobject.level.MemberLevelDO;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
import java.util.List;
/**
* 会员等级 Convert
*
* @author owen
*/
@Mapper
public interface MemberLevelConvert {
MemberLevelConvert INSTANCE = Mappers.getMapper(MemberLevelConvert.class);
MemberLevelDO convert(MemberLevelCreateReqVO bean);
MemberLevelDO convert(MemberLevelUpdateReqVO bean);
MemberLevelRespVO convert(MemberLevelDO bean);
List<MemberLevelRespVO> convertList(List<MemberLevelDO> list);
PageResult<MemberLevelRespVO> convertPage(PageResult<MemberLevelDO> page);
List<MemberLevelSimpleRespVO> convertSimpleList(List<MemberLevelDO> list);
}

View File

@ -0,0 +1,30 @@
package cn.iocoder.yudao.module.member.convert.level;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.member.controller.admin.level.vo.log.MemberLevelLogExcelVO;
import cn.iocoder.yudao.module.member.controller.admin.level.vo.log.MemberLevelLogRespVO;
import cn.iocoder.yudao.module.member.dal.dataobject.level.MemberLevelLogDO;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
import java.util.List;
/**
* 会员等级记录 Convert
*
* @author owen
*/
@Mapper
public interface MemberLevelLogConvert {
MemberLevelLogConvert INSTANCE = Mappers.getMapper(MemberLevelLogConvert.class);
MemberLevelLogRespVO convert(MemberLevelLogDO bean);
List<MemberLevelLogRespVO> convertList(List<MemberLevelLogDO> list);
PageResult<MemberLevelLogRespVO> convertPage(PageResult<MemberLevelLogDO> page);
List<MemberLevelLogExcelVO> convertList02(List<MemberLevelLogDO> list);
}

View File

@ -0,0 +1,61 @@
package cn.iocoder.yudao.module.member.dal.dataobject.level;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
import cn.iocoder.yudao.module.member.enums.MemberExperienceBizTypeEnum;
import com.baomidou.mybatisplus.annotation.KeySequence;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.*;
/**
* 会员经验记录 DO
*
* @author owen
*/
@TableName("member_experience_log")
@KeySequence("member_experience_log_seq") // 用于 OraclePostgreSQLKingbaseDB2H2 数据库的主键自增如果是 MySQL 等数据库可不写
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class MemberExperienceLogDO extends BaseDO {
/**
* 编号
*/
@TableId
private Long id;
/**
* 用户编号
*/
private Long userId;
/**
* 业务类型
* <p>
* 枚举 {@link MemberExperienceBizTypeEnum}
*/
private Integer bizType;
/**
* 业务编号
*/
private String bizId;
/**
* 标题
*/
private String title;
/**
* 经验
*/
private Integer experience;
/**
* 变更后的经验
*/
private Integer totalExperience;
/**
* 描述
*/
private String description;
}

View File

@ -0,0 +1,61 @@
package cn.iocoder.yudao.module.member.dal.dataobject.level;
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
import com.baomidou.mybatisplus.annotation.KeySequence;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.*;
/**
* 会员等级 DO
*
* @author owen
*/
@TableName("member_level")
@KeySequence("member_level_seq") // 用于 OraclePostgreSQLKingbaseDB2H2 数据库的主键自增如果是 MySQL 等数据库可不写
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class MemberLevelDO extends BaseDO {
/**
* 编号
*/
@TableId
private Long id;
/**
* 等级名称
*/
private String name;
/**
* 升级经验
*/
private Integer experience;
/**
* 等级
*/
private Integer level;
/**
* 享受折扣
*/
private Integer discount;
/**
* 等级图标
*/
private String icon;
/**
* 等级背景图
*/
private String backgroundUrl;
/**
* 状态
* <p>
* 枚举 {@link CommonStatusEnum}
*/
private Integer status;
}

View File

@ -0,0 +1,62 @@
package cn.iocoder.yudao.module.member.dal.dataobject.level;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
import com.baomidou.mybatisplus.annotation.KeySequence;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.*;
/**
* 会员等级记录 DO
*
* @author owen
*/
@TableName("member_level_log")
@KeySequence("member_level_log_seq") // 用于 OraclePostgreSQLKingbaseDB2H2 数据库的主键自增如果是 MySQL 等数据库可不写
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class MemberLevelLogDO extends BaseDO {
/**
* 编号
*/
@TableId
private Long id;
/**
* 用户编号
*/
private Long userId;
/**
* 等级编号
*/
private Long levelId;
/**
* 会员等级
*/
private Integer level;
/**
* 享受折扣
*/
private Integer discount;
/**
* 升级经验
*/
private Integer experience;
/**
* 会员此时的经验
*/
private Integer userExperience;
/**
* 备注
*/
private String remark;
/**
* 描述
*/
private String description;
}

View File

@ -116,5 +116,14 @@ public class MemberUserDO extends TenantBaseDO {
@TableField(typeHandler = LongListTypeHandler.class)
private List<Long> tagIds;
// TODO 成长值会员等级等等
/**
* 会员级别编号
*/
private Long levelId;
/**
* 会员经验
*/
private Integer experience;
// TODO 积分等等
}

View File

@ -0,0 +1,41 @@
package cn.iocoder.yudao.module.member.dal.mysql.level;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.member.controller.admin.level.vo.experience.MemberExperienceLogExportReqVO;
import cn.iocoder.yudao.module.member.controller.admin.level.vo.experience.MemberExperienceLogPageReqVO;
import cn.iocoder.yudao.module.member.dal.dataobject.level.MemberExperienceLogDO;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
/**
* 会员经验记录 Mapper
*
* @author owen
*/
@Mapper
public interface MemberExperienceLogMapper extends BaseMapperX<MemberExperienceLogDO> {
default PageResult<MemberExperienceLogDO> selectPage(MemberExperienceLogPageReqVO reqVO) {
return selectPage(reqVO, new LambdaQueryWrapperX<MemberExperienceLogDO>()
.eqIfPresent(MemberExperienceLogDO::getUserId, reqVO.getUserId())
.eqIfPresent(MemberExperienceLogDO::getBizId, reqVO.getBizId())
.eqIfPresent(MemberExperienceLogDO::getBizType, reqVO.getBizType())
.eqIfPresent(MemberExperienceLogDO::getTitle, reqVO.getTitle())
.betweenIfPresent(MemberExperienceLogDO::getCreateTime, reqVO.getCreateTime())
.orderByDesc(MemberExperienceLogDO::getId));
}
default List<MemberExperienceLogDO> selectList(MemberExperienceLogExportReqVO reqVO) {
return selectList(new LambdaQueryWrapperX<MemberExperienceLogDO>()
.eqIfPresent(MemberExperienceLogDO::getUserId, reqVO.getUserId())
.eqIfPresent(MemberExperienceLogDO::getBizId, reqVO.getBizId())
.eqIfPresent(MemberExperienceLogDO::getBizType, reqVO.getBizType())
.eqIfPresent(MemberExperienceLogDO::getTitle, reqVO.getTitle())
.betweenIfPresent(MemberExperienceLogDO::getCreateTime, reqVO.getCreateTime())
.orderByDesc(MemberExperienceLogDO::getId));
}
}

View File

@ -0,0 +1,37 @@
package cn.iocoder.yudao.module.member.dal.mysql.level;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.member.controller.admin.level.vo.log.MemberLevelLogExportReqVO;
import cn.iocoder.yudao.module.member.controller.admin.level.vo.log.MemberLevelLogPageReqVO;
import cn.iocoder.yudao.module.member.dal.dataobject.level.MemberLevelLogDO;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
/**
* 会员等级记录 Mapper
*
* @author owen
*/
@Mapper
public interface MemberLevelLogMapper extends BaseMapperX<MemberLevelLogDO> {
default PageResult<MemberLevelLogDO> selectPage(MemberLevelLogPageReqVO reqVO) {
return selectPage(reqVO, new LambdaQueryWrapperX<MemberLevelLogDO>()
.eqIfPresent(MemberLevelLogDO::getUserId, reqVO.getUserId())
.eqIfPresent(MemberLevelLogDO::getLevelId, reqVO.getLevelId())
.betweenIfPresent(MemberLevelLogDO::getCreateTime, reqVO.getCreateTime())
.orderByDesc(MemberLevelLogDO::getId));
}
default List<MemberLevelLogDO> selectList(MemberLevelLogExportReqVO reqVO) {
return selectList(new LambdaQueryWrapperX<MemberLevelLogDO>()
.eqIfPresent(MemberLevelLogDO::getUserId, reqVO.getUserId())
.eqIfPresent(MemberLevelLogDO::getLevelId, reqVO.getLevelId())
.betweenIfPresent(MemberLevelLogDO::getCreateTime, reqVO.getCreateTime())
.orderByDesc(MemberLevelLogDO::getId));
}
}

View File

@ -0,0 +1,31 @@
package cn.iocoder.yudao.module.member.dal.mysql.level;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.member.controller.admin.level.vo.MemberLevelPageReqVO;
import cn.iocoder.yudao.module.member.dal.dataobject.level.MemberLevelDO;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
/**
* 会员等级 Mapper
*
* @author owen
*/
@Mapper
public interface MemberLevelMapper extends BaseMapperX<MemberLevelDO> {
default PageResult<MemberLevelDO> selectPage(MemberLevelPageReqVO reqVO) {
return selectPage(reqVO, new LambdaQueryWrapperX<MemberLevelDO>()
.likeIfPresent(MemberLevelDO::getName, reqVO.getName())
.eqIfPresent(MemberLevelDO::getStatus, reqVO.getStatus())
.orderByAsc(MemberLevelDO::getLevel));
}
default List<MemberLevelDO> selectListByStatus(Integer status) {
return selectList(MemberLevelDO::getStatus, status);
}
}

View File

@ -0,0 +1,57 @@
package cn.iocoder.yudao.module.member.service.level;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.member.controller.admin.level.vo.experience.MemberExperienceLogExportReqVO;
import cn.iocoder.yudao.module.member.controller.admin.level.vo.experience.MemberExperienceLogPageReqVO;
import cn.iocoder.yudao.module.member.dal.dataobject.level.MemberExperienceLogDO;
import java.util.Collection;
import java.util.List;
/**
* 会员经验记录 Service 接口
*
* @author owen
*/
public interface MemberExperienceLogService {
/**
* 删除会员经验记录
*
* @param id 编号
*/
void deleteExperienceLog(Long id);
/**
* 获得会员经验记录
*
* @param id 编号
* @return 会员经验记录
*/
MemberExperienceLogDO getExperienceLog(Long id);
/**
* 获得会员经验记录列表
*
* @param ids 编号
* @return 会员经验记录列表
*/
List<MemberExperienceLogDO> getExperienceLogList(Collection<Long> ids);
/**
* 获得会员经验记录分页
*
* @param pageReqVO 分页查询
* @return 会员经验记录分页
*/
PageResult<MemberExperienceLogDO> getExperienceLogPage(MemberExperienceLogPageReqVO pageReqVO);
/**
* 获得会员经验记录列表, 用于 Excel 导出
*
* @param exportReqVO 查询条件
* @return 会员经验记录列表
*/
List<MemberExperienceLogDO> getExperienceLogList(MemberExperienceLogExportReqVO exportReqVO);
}

View File

@ -0,0 +1,64 @@
package cn.iocoder.yudao.module.member.service.level;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.member.controller.admin.level.vo.experience.MemberExperienceLogExportReqVO;
import cn.iocoder.yudao.module.member.controller.admin.level.vo.experience.MemberExperienceLogPageReqVO;
import cn.iocoder.yudao.module.member.dal.dataobject.level.MemberExperienceLogDO;
import cn.iocoder.yudao.module.member.dal.mysql.level.MemberExperienceLogMapper;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource;
import java.util.Collection;
import java.util.List;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.module.member.enums.ErrorCodeConstants.EXPERIENCE_LOG_NOT_EXISTS;
/**
* 会员经验记录 Service 实现类
*
* @author owen
*/
@Service
@Validated
public class MemberExperienceLogServiceImpl implements MemberExperienceLogService {
@Resource
private MemberExperienceLogMapper experienceLogMapper;
@Override
public void deleteExperienceLog(Long id) {
// 校验存在
validateExperienceLogExists(id);
// 删除
experienceLogMapper.deleteById(id);
}
private void validateExperienceLogExists(Long id) {
if (experienceLogMapper.selectById(id) == null) {
throw exception(EXPERIENCE_LOG_NOT_EXISTS);
}
}
@Override
public MemberExperienceLogDO getExperienceLog(Long id) {
return experienceLogMapper.selectById(id);
}
@Override
public List<MemberExperienceLogDO> getExperienceLogList(Collection<Long> ids) {
return experienceLogMapper.selectBatchIds(ids);
}
@Override
public PageResult<MemberExperienceLogDO> getExperienceLogPage(MemberExperienceLogPageReqVO pageReqVO) {
return experienceLogMapper.selectPage(pageReqVO);
}
@Override
public List<MemberExperienceLogDO> getExperienceLogList(MemberExperienceLogExportReqVO exportReqVO) {
return experienceLogMapper.selectList(exportReqVO);
}
}

View File

@ -0,0 +1,57 @@
package cn.iocoder.yudao.module.member.service.level;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.member.controller.admin.level.vo.log.MemberLevelLogExportReqVO;
import cn.iocoder.yudao.module.member.controller.admin.level.vo.log.MemberLevelLogPageReqVO;
import cn.iocoder.yudao.module.member.dal.dataobject.level.MemberLevelLogDO;
import java.util.Collection;
import java.util.List;
/**
* 会员等级记录 Service 接口
*
* @author owen
*/
public interface MemberLevelLogService {
/**
* 删除会员等级记录
*
* @param id 编号
*/
void deleteLevelLog(Long id);
/**
* 获得会员等级记录
*
* @param id 编号
* @return 会员等级记录
*/
MemberLevelLogDO getLevelLog(Long id);
/**
* 获得会员等级记录列表
*
* @param ids 编号
* @return 会员等级记录列表
*/
List<MemberLevelLogDO> getLevelLogList(Collection<Long> ids);
/**
* 获得会员等级记录分页
*
* @param pageReqVO 分页查询
* @return 会员等级记录分页
*/
PageResult<MemberLevelLogDO> getLevelLogPage(MemberLevelLogPageReqVO pageReqVO);
/**
* 获得会员等级记录列表, 用于 Excel 导出
*
* @param exportReqVO 查询条件
* @return 会员等级记录列表
*/
List<MemberLevelLogDO> getLevelLogList(MemberLevelLogExportReqVO exportReqVO);
}

View File

@ -0,0 +1,64 @@
package cn.iocoder.yudao.module.member.service.level;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.member.controller.admin.level.vo.log.MemberLevelLogExportReqVO;
import cn.iocoder.yudao.module.member.controller.admin.level.vo.log.MemberLevelLogPageReqVO;
import cn.iocoder.yudao.module.member.dal.dataobject.level.MemberLevelLogDO;
import cn.iocoder.yudao.module.member.dal.mysql.level.MemberLevelLogMapper;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource;
import java.util.Collection;
import java.util.List;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.module.member.enums.ErrorCodeConstants.LEVEL_LOG_NOT_EXISTS;
/**
* 会员等级记录 Service 实现类
*
* @author owen
*/
@Service
@Validated
public class MemberLevelLogServiceImpl implements MemberLevelLogService {
@Resource
private MemberLevelLogMapper levelLogMapper;
@Override
public void deleteLevelLog(Long id) {
// 校验存在
validateLevelLogExists(id);
// 删除
levelLogMapper.deleteById(id);
}
private void validateLevelLogExists(Long id) {
if (levelLogMapper.selectById(id) == null) {
throw exception(LEVEL_LOG_NOT_EXISTS);
}
}
@Override
public MemberLevelLogDO getLevelLog(Long id) {
return levelLogMapper.selectById(id);
}
@Override
public List<MemberLevelLogDO> getLevelLogList(Collection<Long> ids) {
return levelLogMapper.selectBatchIds(ids);
}
@Override
public PageResult<MemberLevelLogDO> getLevelLogPage(MemberLevelLogPageReqVO pageReqVO) {
return levelLogMapper.selectPage(pageReqVO);
}
@Override
public List<MemberLevelLogDO> getLevelLogList(MemberLevelLogExportReqVO exportReqVO) {
return levelLogMapper.selectList(exportReqVO);
}
}

View File

@ -0,0 +1,74 @@
package cn.iocoder.yudao.module.member.service.level;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.member.controller.admin.level.vo.MemberLevelCreateReqVO;
import cn.iocoder.yudao.module.member.controller.admin.level.vo.MemberLevelPageReqVO;
import cn.iocoder.yudao.module.member.controller.admin.level.vo.MemberLevelUpdateReqVO;
import cn.iocoder.yudao.module.member.dal.dataobject.level.MemberLevelDO;
import javax.validation.Valid;
import java.util.Collection;
import java.util.List;
/**
* 会员等级 Service 接口
*
* @author owen
*/
public interface MemberLevelService {
/**
* 创建会员等级
*
* @param createReqVO 创建信息
* @return 编号
*/
Long createLevel(@Valid MemberLevelCreateReqVO createReqVO);
/**
* 更新会员等级
*
* @param updateReqVO 更新信息
*/
void updateLevel(@Valid MemberLevelUpdateReqVO updateReqVO);
/**
* 删除会员等级
*
* @param id 编号
*/
void deleteLevel(Long id);
/**
* 获得会员等级
*
* @param id 编号
* @return 会员等级
*/
MemberLevelDO getLevel(Long id);
/**
* 获得会员等级列表
*
* @param ids 编号
* @return 会员等级列表
*/
List<MemberLevelDO> getLevelList(Collection<Long> ids);
/**
* 获得会员等级分页
*
* @param pageReqVO 分页查询
* @return 会员等级分页
*/
PageResult<MemberLevelDO> getLevelPage(MemberLevelPageReqVO pageReqVO);
/**
* 获得指定状态的会员等级列表
*
* @param status 状态
* @return 会员等级列表
*/
List<MemberLevelDO> getLevelListByStatus(Integer status);
}

View File

@ -0,0 +1,85 @@
package cn.iocoder.yudao.module.member.service.level;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.member.controller.admin.level.vo.MemberLevelCreateReqVO;
import cn.iocoder.yudao.module.member.controller.admin.level.vo.MemberLevelPageReqVO;
import cn.iocoder.yudao.module.member.controller.admin.level.vo.MemberLevelUpdateReqVO;
import cn.iocoder.yudao.module.member.convert.level.MemberLevelConvert;
import cn.iocoder.yudao.module.member.dal.dataobject.level.MemberLevelDO;
import cn.iocoder.yudao.module.member.dal.mysql.level.MemberLevelMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource;
import java.util.Collection;
import java.util.List;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.module.member.enums.ErrorCodeConstants.LEVEL_NOT_EXISTS;
/**
* 会员等级 Service 实现类
*
* @author owen
*/
@Slf4j
@Service
@Validated
public class MemberLevelServiceImpl implements MemberLevelService {
@Resource
private MemberLevelMapper levelMapper;
@Override
public Long createLevel(MemberLevelCreateReqVO createReqVO) {
// 插入
MemberLevelDO level = MemberLevelConvert.INSTANCE.convert(createReqVO);
levelMapper.insert(level);
// 返回
return level.getId();
}
@Override
public void updateLevel(MemberLevelUpdateReqVO updateReqVO) {
// 校验存在
validateLevelExists(updateReqVO.getId());
// 更新
MemberLevelDO updateObj = MemberLevelConvert.INSTANCE.convert(updateReqVO);
levelMapper.updateById(updateObj);
}
@Override
public void deleteLevel(Long id) {
// 校验存在
validateLevelExists(id);
// 删除
levelMapper.deleteById(id);
}
private void validateLevelExists(Long id) {
if (levelMapper.selectById(id) == null) {
throw exception(LEVEL_NOT_EXISTS);
}
}
@Override
public MemberLevelDO getLevel(Long id) {
return levelMapper.selectById(id);
}
@Override
public List<MemberLevelDO> getLevelList(Collection<Long> ids) {
return levelMapper.selectBatchIds(ids);
}
@Override
public PageResult<MemberLevelDO> getLevelPage(MemberLevelPageReqVO pageReqVO) {
return levelMapper.selectPage(pageReqVO);
}
@Override
public List<MemberLevelDO> getLevelListByStatus(Integer status) {
return levelMapper.selectListByStatus(status);
}
}

View File

@ -0,0 +1,125 @@
package cn.iocoder.yudao.module.member.service.level;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest;
import cn.iocoder.yudao.module.member.controller.admin.level.vo.MemberLevelCreateReqVO;
import cn.iocoder.yudao.module.member.controller.admin.level.vo.MemberLevelPageReqVO;
import cn.iocoder.yudao.module.member.controller.admin.level.vo.MemberLevelUpdateReqVO;
import cn.iocoder.yudao.module.member.dal.dataobject.level.MemberLevelDO;
import cn.iocoder.yudao.module.member.dal.mysql.level.MemberLevelMapper;
import org.junit.jupiter.api.Test;
import org.springframework.context.annotation.Import;
import javax.annotation.Resource;
import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId;
import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals;
import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException;
import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomLongId;
import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo;
import static cn.iocoder.yudao.module.member.enums.ErrorCodeConstants.LEVEL_NOT_EXISTS;
import static org.junit.jupiter.api.Assertions.*;
/**
* {@link MemberLevelServiceImpl} 的单元测试类
*
* @author owen
*/
@Import(MemberLevelServiceImpl.class)
public class MemberLevelServiceImplTest extends BaseDbUnitTest {
@Resource
private MemberLevelServiceImpl levelService;
@Resource
private MemberLevelMapper levelMapper;
@Test
public void testCreateLevel_success() {
// 准备参数
MemberLevelCreateReqVO reqVO = randomPojo(MemberLevelCreateReqVO.class);
// 调用
Long levelId = levelService.createLevel(reqVO);
// 断言
assertNotNull(levelId);
// 校验记录的属性是否正确
MemberLevelDO level = levelMapper.selectById(levelId);
assertPojoEquals(reqVO, level);
}
@Test
public void testUpdateLevel_success() {
// mock 数据
MemberLevelDO dbLevel = randomPojo(MemberLevelDO.class);
levelMapper.insert(dbLevel);// @Sql: 先插入出一条存在的数据
// 准备参数
MemberLevelUpdateReqVO reqVO = randomPojo(MemberLevelUpdateReqVO.class, o -> {
o.setId(dbLevel.getId()); // 设置更新的 ID
});
// 调用
levelService.updateLevel(reqVO);
// 校验是否更新正确
MemberLevelDO level = levelMapper.selectById(reqVO.getId()); // 获取最新的
assertPojoEquals(reqVO, level);
}
@Test
public void testUpdateLevel_notExists() {
// 准备参数
MemberLevelUpdateReqVO reqVO = randomPojo(MemberLevelUpdateReqVO.class);
// 调用, 并断言异常
assertServiceException(() -> levelService.updateLevel(reqVO), LEVEL_NOT_EXISTS);
}
@Test
public void testDeleteLevel_success() {
// mock 数据
MemberLevelDO dbLevel = randomPojo(MemberLevelDO.class);
levelMapper.insert(dbLevel);// @Sql: 先插入出一条存在的数据
// 准备参数
Long id = dbLevel.getId();
// 调用
levelService.deleteLevel(id);
// 校验数据不存在了
assertNull(levelMapper.selectById(id));
}
@Test
public void testDeleteLevel_notExists() {
// 准备参数
Long id = randomLongId();
// 调用, 并断言异常
assertServiceException(() -> levelService.deleteLevel(id), LEVEL_NOT_EXISTS);
}
@Test
public void testGetLevelPage() {
// mock 数据
MemberLevelDO dbLevel = randomPojo(MemberLevelDO.class, o -> { // 等会查询到
o.setName("黄金会员");
o.setStatus(1);
});
levelMapper.insert(dbLevel);
// 测试 name 不匹配
levelMapper.insert(cloneIgnoreId(dbLevel, o -> o.setName(null)));
// 测试 status 不匹配
levelMapper.insert(cloneIgnoreId(dbLevel, o -> o.setStatus(null)));
// 准备参数
MemberLevelPageReqVO reqVO = new MemberLevelPageReqVO();
reqVO.setName("黄金会员");
reqVO.setStatus(1);
// 调用
PageResult<MemberLevelDO> pageResult = levelService.getLevelPage(reqVO);
// 断言
assertEquals(1, pageResult.getTotal());
assertEquals(1, pageResult.getList().size());
assertPojoEquals(dbLevel, pageResult.getList().get(0));
}
}

View File

@ -1,3 +1,4 @@
DELETE FROM "member_user";
DELETE FROM "member_address";
DELETE FROM "member_tag";
DELETE FROM "member_tag";
DELETE FROM "member_level";

View File

@ -44,4 +44,23 @@ CREATE TABLE IF NOT EXISTS "member_tag"
"deleted" bit NOT NULL DEFAULT FALSE,
"tenant_id" bigint NOT NULL default '0',
PRIMARY KEY ("id")
) COMMENT '会员标签';
) COMMENT '会员标签';
CREATE TABLE IF NOT EXISTS "member_level"
(
"id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY,
"name" varchar NOT NULL,
"experience" int NOT NULL,
"value" int NOT NULL,
"discount" int NOT NULL,
"icon" varchar NOT NULL,
"bg_url" varchar NOT NULL,
"creator" varchar DEFAULT '',
"create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updater" varchar DEFAULT '',
"update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
"deleted" bit NOT NULL DEFAULT FALSE,
"tenant_id" bigint not null default '0',
"status" int NOT NULL,
PRIMARY KEY ("id")
) COMMENT '会员等级';