parent
2dd6d5b9fa
commit
47cee996a0
@ -0,0 +1,33 @@
|
||||
package enums;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* @Author: yawei.huang
|
||||
* @Package: enums
|
||||
* @Project: luoo_parent
|
||||
* @Date: 2024/7/19 20:09
|
||||
* @Filename: MembershipEnums
|
||||
* @Describe:
|
||||
*/
|
||||
@Getter
|
||||
public enum MembershipEnums {
|
||||
CREATED(1, "已生成"),
|
||||
BIND(2, "已绑定"),
|
||||
REFUND(3, "已退款"),
|
||||
DISCARD(4, "已废弃"),
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
;
|
||||
private final Integer code;
|
||||
private final String description;
|
||||
|
||||
MembershipEnums(int code, String description) {
|
||||
this.code = code;
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
package enums;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* @Author: yawei.huang
|
||||
* @Package: enums
|
||||
* @Project: luoo_parent
|
||||
* @Date: 2024/7/19 20:31
|
||||
* @Filename: UserVipStatusEnum
|
||||
* @Describe: 用户会员状态
|
||||
*/
|
||||
@Getter
|
||||
public enum UserVipStatusEnum {
|
||||
|
||||
INITIAL(0, "未开通"),
|
||||
ACTIVE(1, "生效中"),
|
||||
EXPIRED(2, "已过期"),
|
||||
|
||||
;
|
||||
|
||||
private final Integer code;
|
||||
private final String description;
|
||||
|
||||
UserVipStatusEnum(int code, String description) {
|
||||
this.code = code;
|
||||
this.description = description;
|
||||
}
|
||||
}
|
@ -0,0 +1,54 @@
|
||||
package com.luoo.user.controller;
|
||||
|
||||
import annotation.GlobalInterceptor;
|
||||
import api.Result;
|
||||
import com.luoo.user.service.MembershipCodeService;
|
||||
import controller.BaseController;
|
||||
import io.swagger.annotations.*;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* @Author: yawei.huang
|
||||
* @Package: com.luoo.user.controller
|
||||
* @Project: luoo_parent
|
||||
* @Date: 2024/7/19 19:51
|
||||
* @Filename: MembershipController
|
||||
* @Describe:
|
||||
*/
|
||||
@RestController
|
||||
@Slf4j
|
||||
@RequestMapping("/membership")
|
||||
@Api(tags = "会员模块")
|
||||
public class MembershipController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
private MembershipCodeService membershipCodeService;
|
||||
|
||||
@ApiOperation(value = "1.生成会员码", notes = "仅限admin权限用户调用")
|
||||
@GetMapping("/code/generate")
|
||||
@GlobalInterceptor(checkAdminLogin = true)
|
||||
@ApiImplicitParams(value = {
|
||||
@ApiImplicitParam(name = "duration", value = "会员时长(天)", required = true, dataType = "Integer", paramType = "query")
|
||||
})
|
||||
public Result<String> generateMembershipCode(@RequestHeader(value = "Authorization", required = true) String authorization,
|
||||
@NotNull Integer duration) {
|
||||
return Result.success(membershipCodeService.generateMembershipCode(authorization, duration));
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation(value = "2.绑定会员码", notes = "仅限app用户调用")
|
||||
@PostMapping("/code/bind")
|
||||
@GlobalInterceptor(checkAppUserLogin = true)
|
||||
@ApiImplicitParams(value = {
|
||||
@ApiImplicitParam(name = "code", value = "会员码", required = true, dataType = "String", paramType = "query")
|
||||
})
|
||||
public Result<Void> bindMembershipCode(@RequestHeader(value = "Authorization", required = true) String authorization,
|
||||
@NotNull String code) {
|
||||
membershipCodeService.bindMembershipCode(authorization, code);
|
||||
return Result.success();
|
||||
}
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
package com.luoo.user.dao;
|
||||
|
||||
import com.luoo.user.pojo.MembershipCode;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
|
||||
/**
|
||||
* @Author: yawei.huang
|
||||
* @Package: com.luoo.user.dao
|
||||
* @Project: luoo_parent
|
||||
* @Date: 2024/7/19 19:53
|
||||
* @Filename: MembershipCodeDao
|
||||
* @Describe:
|
||||
*/
|
||||
public interface MembershipCodeDao extends JpaRepository<MembershipCode, String>, JpaSpecificationExecutor<MembershipCode> {
|
||||
|
||||
public MembershipCode findMembershipCodeByCodeAndStatus(String code, Integer status);
|
||||
}
|
@ -0,0 +1,75 @@
|
||||
package com.luoo.user.pojo;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.*;
|
||||
import org.hibernate.annotations.DynamicInsert;
|
||||
import org.hibernate.annotations.DynamicUpdate;
|
||||
import org.springframework.data.annotation.CreatedDate;
|
||||
import org.springframework.data.annotation.LastModifiedDate;
|
||||
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import javax.persistence.*;
|
||||
import javax.validation.constraints.Size;
|
||||
import java.io.Serializable;
|
||||
import java.time.Instant;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode
|
||||
@Builder
|
||||
@Entity
|
||||
@DynamicInsert
|
||||
@DynamicUpdate
|
||||
@Table(name = "tb_membership_code")
|
||||
@EntityListeners(AuditingEntityListener.class)
|
||||
public class MembershipCode implements Serializable {
|
||||
@Id
|
||||
@Size(max = 20)
|
||||
@Column(name = "id", nullable = false, length = 20)
|
||||
@ApiModelProperty(value = "主键")
|
||||
private String id;
|
||||
|
||||
@Size(max = 50)
|
||||
@Column(name = "code", length = 50)
|
||||
@ApiModelProperty(value = "会员码")
|
||||
private String code;
|
||||
|
||||
@Column(name = "status")
|
||||
@ApiModelProperty(value = "状态 1-已生成 2-已绑定 3-已退款 4-已废弃")
|
||||
private Integer status;
|
||||
|
||||
@Column(name = "duration")
|
||||
@ApiModelProperty(value = "时长")
|
||||
private Integer duration;
|
||||
|
||||
@Size(max = 20)
|
||||
@Column(name = "user_id", length = 20)
|
||||
@ApiModelProperty(value = "用户id")
|
||||
private String userId;
|
||||
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@ApiModelProperty("创建时间")
|
||||
@CreatedDate
|
||||
private Instant createTime;
|
||||
|
||||
@ApiModelProperty("修改时间")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@LastModifiedDate
|
||||
private Instant updateTime;
|
||||
|
||||
@Size(max = 20)
|
||||
@Column(name = "create_user", length = 20)
|
||||
@ApiModelProperty(value = "创建人")
|
||||
private String createUser;
|
||||
|
||||
@Size(max = 20)
|
||||
@Column(name = "update_user", length = 20)
|
||||
@ApiModelProperty(value = "更新人")
|
||||
private String updateUser;
|
||||
|
||||
}
|
@ -0,0 +1,75 @@
|
||||
package com.luoo.user.pojo;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.*;
|
||||
import org.hibernate.annotations.DynamicInsert;
|
||||
import org.hibernate.annotations.DynamicUpdate;
|
||||
import org.springframework.data.annotation.CreatedDate;
|
||||
import org.springframework.data.annotation.LastModifiedDate;
|
||||
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import javax.persistence.*;
|
||||
import javax.validation.constraints.Size;
|
||||
import java.io.Serializable;
|
||||
import java.time.Instant;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode
|
||||
@Builder
|
||||
@Entity
|
||||
@DynamicInsert
|
||||
@DynamicUpdate
|
||||
@Table(name = "tb_user_point_log")
|
||||
@EntityListeners(AuditingEntityListener.class)
|
||||
public class UserPointLog implements Serializable {
|
||||
@Id
|
||||
@Size(max = 20)
|
||||
@Column(name = "id", nullable = false, length = 20)
|
||||
@ApiModelProperty(value = "主键")
|
||||
private String id;
|
||||
|
||||
@Column(name = "score")
|
||||
@ApiModelProperty(value = "积分")
|
||||
private Integer score;
|
||||
|
||||
@Column(name = "type")
|
||||
@ApiModelProperty(value = "类型 1-增加 2-减少")
|
||||
private Integer type;
|
||||
|
||||
@Size(max = 20)
|
||||
@Column(name = "user_id", length = 20)
|
||||
@ApiModelProperty(value = "用户id")
|
||||
private String userId;
|
||||
|
||||
@Size(max = 255)
|
||||
@Column(name = "description")
|
||||
@ApiModelProperty(value = "事件描述")
|
||||
private String description;
|
||||
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@ApiModelProperty("创建时间")
|
||||
@CreatedDate
|
||||
private Instant createTime;
|
||||
|
||||
@ApiModelProperty("修改时间")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@LastModifiedDate
|
||||
private Instant updateTime;
|
||||
|
||||
@Size(max = 20)
|
||||
@Column(name = "create_user", length = 20)
|
||||
@ApiModelProperty(value = "创建人")
|
||||
private String createUser;
|
||||
|
||||
@Size(max = 20)
|
||||
@Column(name = "update_user", length = 20)
|
||||
@ApiModelProperty(value = "更新人")
|
||||
private String updateUser;
|
||||
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
create table tb_membership_code
|
||||
(
|
||||
id varchar(20) not null comment 'id'
|
||||
primary key,
|
||||
code varchar(50) null comment '会员码',
|
||||
status tinyint null comment '状态 1-已生成 2-已绑定 3-已退款 4-已废弃',
|
||||
duration int null comment '会员时长(天)',
|
||||
user_id varchar(20) null comment '使用用户',
|
||||
create_time datetime null comment '创建时间',
|
||||
update_time datetime null comment '修改时间',
|
||||
create_user varchar(20) null comment '创建人',
|
||||
update_user varchar(20) null comment '修改人'
|
||||
)
|
||||
comment '会员码';
|
||||
|
||||
|
||||
create table tb_user_point_log
|
||||
(
|
||||
id varchar(20) not null comment 'id'
|
||||
primary key,
|
||||
score int null comment '分数',
|
||||
type tinyint null comment '1- 增加 2-减少',
|
||||
user_id varchar(20) null comment '所属用户',
|
||||
description varchar(255) null comment '事件描述',
|
||||
create_time datetime null comment '创建时间',
|
||||
update_time datetime null comment '修改时间',
|
||||
create_user varchar(20) null comment '创建人',
|
||||
update_user varchar(20) null comment '修改人'
|
||||
)
|
||||
comment '积分记录表';
|
||||
|
||||
alter table tb_user_info
|
||||
add vip_status tinyint default 0 not null comment '会员状态 0-未开通 1-生效中 2-已过期';
|
||||
|
||||
alter table tb_user_info
|
||||
add vip_expire_time date null comment '会员到期时间';
|
Loading…
Reference in new issue