【积分银行】积分

This commit is contained in:
2026-02-06 17:49:43 +08:00
parent 173eaa1b60
commit 80d1cebc0f
30 changed files with 1487 additions and 15 deletions
@@ -12,5 +12,5 @@ public interface HealthBankConstants {
/**
*积分变化-扣减积分
*/
Integer CHANGE_TYPE_DEDUCT_ = 2;
Integer CHANGE_TYPE_DEDUCT = 2;
}
@@ -9,7 +9,8 @@ import lombok.Getter;
*/
@Getter
public enum PointsSourceEnum {
TYPE_1_SURVEY(1, "积分打卡", "survey"),
// 积分变更类型
TYPE_1_SURVEY(1, "survey", "积分打卡"),
TYPE_2_USE(2, "use", "礼品兑换"),
TYPE_2_VIOLATION(2, "violation", "违规扣除"),
TYPE_2_EXPIRED(2, "expired", "过期清除");
@@ -31,4 +32,13 @@ public enum PointsSourceEnum {
this.source = source;
this.desc = desc;
}
public static PointsSourceEnum getBySource(String source) {
for (PointsSourceEnum value : PointsSourceEnum.values()) {
if (value.source.equals(source)) {
return value;
}
}
return null;
}
}
@@ -0,0 +1,25 @@
package com.renkang.bank.model.dto;
import com.renkang.bank.model.po.PointsRule;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.jeecg.base.PageInfo;
/**
* @author pj
* @version 1.0
* @description: 积分规则分页dto
* @date 2026/2/5 18:11
*/
@Data
public class PointsRulePageDTO extends PageInfo<PointsRule> {
@Schema(title = "健康分类")
private Integer ruleCategory;
@Schema(title = "健康行为")
private String ruleDesc;
@Schema(title = "状态1-启用,2停用")
private Integer status;
}
@@ -0,0 +1,40 @@
package com.renkang.bank.model.dto;
import lombok.Data;
import java.math.BigDecimal;
/**
* @author pj
* @version 1.0
* @description: 更新用户积分DTO
* @date 2026/2/6 9:00
*/
@Data
public class UpdUserPointsDTO {
/**
* 积分标识(积分打卡:survey,礼品兑换:use,违规扣除:violation,过期清除:expired)
*/
private String sourceType;
/**
* 业务ID(积分任务id,兑换商品id等)
*/
private Long businessId;
/**
* 操作积分(扣减)
*/
private BigDecimal points;
/**
* 操作备注(扣减积分的说明等)
*/
private String remark;
/**
* 用户id(扣减的目标用户id)
*/
private String userId;
}
@@ -0,0 +1,42 @@
package com.renkang.bank.model.dto;
import com.renkang.bank.model.po.PointsRule;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.jeecg.base.PageInfo;
/**
* @author pj
* @version 1.0
* @description: 积分规则分页dto
* @date 2026/2/5 18:11
*/
@Data
public class UserPointsPageDTO extends PageInfo<PointsRule> {
@Schema(title = "姓名")
private String realName;
@Schema(title = "员工编号")
private String workNo;
@Schema(title = "所属单位")
private String orgCode;
@Schema(title = "所属部门")
private String deptCode;
@Schema(title = "1收入,2支出")
private Integer changeType;
@Schema(title = "健康行为")
private String ruleDesc;
@Schema(title = "打卡日期(开始)")
private String startDate;
@Schema(title = "打卡日期(结束)")
private String endDate;
private String userId;
}
@@ -0,0 +1,22 @@
package com.renkang.bank.model.dto;
import com.renkang.bank.model.po.PointsRule;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.jeecg.base.PageInfo;
/**
* @author pj
* @version 1.0
* @description: 积分规则分页dto
* @date 2026/2/5 18:11
*/
@EqualsAndHashCode(callSuper = true)
@Data
public class UserPointsRankingDTO extends PageInfo<PointsRule> {
@Schema(title = "榜单类型,0总榜,1周榜,2月榜")
private String rankType;
}
@@ -11,6 +11,8 @@ import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.FieldNameConstants;
import org.jeecg.common.aspect.annotation.Dict;
import org.jeecgframework.poi.excel.annotation.Excel;
import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable;
@@ -39,23 +41,28 @@ public class PointsRule implements Serializable {
@JsonFormat(shape = JsonFormat.Shape.STRING)
private Long id;
@Excel(name = "行为周期", width = 15, replace = {"次_1", "日_2", "周_3", "月_4", "季度_5", "年_6"}, orderNum = "3")
@Schema(title = "问答频次(1-单次,2-日/次,3-周/次,4-月/次,5-季度/次,6-年/次)")
private Integer frequency;
@Excel(name = "健康分类", width = 15, dicCode = "points_rule_category", orderNum = "1")
@Dict(dicCode = "points_rule_category")
@Schema(title = "规则类别")
private Integer ruleCategory;
@Excel(name = "健康行为", width = 15, orderNum = "2")
@Schema(title = "规则描述")
private String ruleDesc;
@Schema(title = "图标")
private String icon;
@Excel(name = "奖励积分", width = 15, orderNum = "4")
@Schema(title = "奖励积分")
private BigDecimal points;
@Schema(title = "状态0-启用,1停用")
private Integer status = 0;
@Schema(title = "状态1-启用,2停用")
private Integer status = 1;
@Schema(title = "删除标识0-正常,1已删除")
@TableLogic
@@ -14,6 +14,7 @@ import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
/**
* 用户积分汇总表 -产生过积分的用户每人一条数据
*
@@ -45,24 +46,33 @@ public class UserPoints implements Serializable {
@Schema(title = "历史获得的积分总和")
private BigDecimal addPointsSum;
/**
* 记录所有扣除积分的总和,包含兑换消耗、手动扣除的积分
*/
@Schema(title = "历史扣除积分总和")
private BigDecimal deductPointsSum;
@Schema(title = "状态(0-正常,1-冻结)")
private Integer status = 0;
/**
* 积分兑换记录总和,只记录积分兑换
*/
@Schema(title = "历史兑换积分总和")
private BigDecimal exchangePointsSum;
@Schema(title = "状态(1-正常,2-冻结)")
private Integer status = 1;
/**
* 注意:该字段记录最后一次获得积分当天收获的积分总和,该归档字段的更新会减少后期对积分明细表的查询次数
*/
@Schema(title = "最新一天获取积分的总和")
private BigDecimal latestAddDaySum;
/**
*注意:该字段记录最后一次消费积分当天收获的积分总和,该归档字段的更新会减少后期对积分明细表的查询次数
* 注意:该字段记录最后一次消费积分当天收获的积分总和,该归档字段的更新会减少后期对积分明细表的查询次数
*/
@Schema(title = "最新一天消耗积分的总和")
private BigDecimal latestDeductDaySum;
@DateTimeFormat(pattern = "yyyy-MM-dd")
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@Schema(title = "最新获得积分的日期")
private Date lastAddDate;
@@ -25,7 +25,7 @@ import java.util.Date;
@Data
@NoArgsConstructor
@AllArgsConstructor
@TableName("bank_user_points")
@TableName("bank_user_points_details")
@Schema(title = "用户积分详情表", description = "用户积分详情表")
public class UserPointsDetails implements Serializable {
private static final long serialVersionUID = 1L;
@@ -56,7 +56,7 @@ public class UserPointsDetails implements Serializable {
/**
* @see PointsSourceEnum 来源详见枚举类
*/
@Schema(title = "来源(survey-问卷积分,use-礼品兑换,violation-违规扣除,expired-过期清除)")
@Schema(title = "来源(survey-积分打卡,use-礼品兑换,violation-违规扣除,expired-过期清除)")
private String source;
@Schema(title = "关联业务ID(规则ID,礼品兑换订单Id等)")
@@ -0,0 +1,40 @@
package com.renkang.bank.model.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.math.BigDecimal;
/**
* @author pj
* @version 1.0
* @description: 用户积分榜单VO
* @date 2026/2/6 10:41
*/
@Data
public class UserPointRankingVO {
@Schema(title = "排名")
private Integer ranking;
@Schema(title = "用户id")
private String userId;
@Schema(title = "姓名")
private String realName;
@Schema(title = "头像")
private String avatar;
@Schema(title = "单位名称")
private String orgName;
@Schema(title = "部门名称")
private String deptName;
@Schema(title = "性别")
private Integer sex;
@Schema(title = "积分")
private BigDecimal pointSum;
}
@@ -0,0 +1,44 @@
package com.renkang.bank.model.vo;
import cn.hutool.core.date.DateUtil;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.math.BigDecimal;
import java.util.Date;
/**
* @author pj
* @version 1.0
* @description: 用户积分明细VO
* @date 2026/2/6 10:41
*/
@Data
public class UserPointRecordVO {
@Schema(title = "记录id")
private Long id;
@Schema(title = "得分说明")
private String businessInfo;
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@Schema(title = "创建时间")
private Date createTime;
@Schema(title = "本次积分变化")
private BigDecimal points;
@Schema(title = "补充信息")
private String remark;
public String getCreateMonthStr() {
if (createTime != null) {
return DateUtil.format(createTime, "yyyy年-MM月");
}
return null;
}
}
@@ -0,0 +1,42 @@
package com.renkang.bank.model.vo;
import com.fasterxml.jackson.annotation.JsonSetter;
import com.fasterxml.jackson.annotation.Nulls;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.math.BigDecimal;
/**
* @author pj
* @version 1.0
* @description: 用户积分信息vo
* @date 2026/2/6 9:31
*/
@Data
public class UserPointsInfoVO {
@Schema(title = "可用积分")
@JsonSetter(nulls = Nulls.SKIP)
private BigDecimal points = BigDecimal.ZERO;
@Schema(title = "累计积分")
@JsonSetter(nulls = Nulls.SKIP)
private BigDecimal addPointsSum = BigDecimal.ZERO;
@Schema(title = "累计兑换")
@JsonSetter(nulls = Nulls.SKIP)
private BigDecimal exchangePointsSum = BigDecimal.ZERO;
public BigDecimal getPoints() {
return points == null ? BigDecimal.ZERO : points;
}
public BigDecimal getAddPointsSum() {
return addPointsSum == null ? BigDecimal.ZERO : addPointsSum;
}
public BigDecimal getExchangePointsSum() {
return exchangePointsSum == null ? BigDecimal.ZERO : exchangePointsSum;
}
}
@@ -0,0 +1,35 @@
package com.renkang.bank.model.vo;
import com.renkang.bank.model.po.UserPoints;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* @author pj
* @version 1.0
* @description: 用户积分信息列表VO
* @date 2026/2/5 18:51
*/
@EqualsAndHashCode(callSuper = true)
@Data
public class UserPointsListVO extends UserPoints {
@Schema(title = "姓名")
private String realName;
@Schema(title = "员工编号")
private String workNo;
@Schema(title = "所属单位名称")
private String orgName;
@Schema(title = "所属部门名称")
private String deptName;
@Schema(title = "性别")
private String sexName;
@Schema(title = "年龄")
private Integer age;
}
@@ -0,0 +1,53 @@
package com.renkang.bank.model.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.math.BigDecimal;
import java.util.Date;
/**
* @author pj
* @version 1.0
* @description: 员工打卡监测VO
* @date 2026/2/5 18:51
*/
@Data
public class UserPointsMonitorVO {
@Schema(title = "用户id")
private String userId;
@Schema(title = "姓名")
private String realName;
@Schema(title = "员工编号")
private String workNo;
@Schema(title = "所属单位名称")
private String orgName;
@Schema(title = "所属部门名称")
private String deptName;
@Schema(title = "性别")
private String sexName;
@Schema(title = "年龄")
private Integer age;
@Schema(title = "健康行为")
private String businessInfo;
@Schema(title = "补充信息")
private String remark;
@Schema(title = "周期")
private Integer frequency;
@Schema(title = "获取积分")
private BigDecimal points;
@Schema(title = "打卡时间")
private Date createTime;
}
@@ -0,0 +1,39 @@
package com.renkang.bank.model.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.jeecg.common.aspect.annotation.Dict;
import java.math.BigDecimal;
/**
* @author pj
* @version 1.0
* @description: 用户积分任务VO
* @date 2026/2/6 9:54
*/
@Data
public class UserPointsTaskVO {
@Schema(title = "规则id")
private Long ruleId;
@Schema(title = "问答频次(1-单次,2-日/次,3-周/次,4-月/次,5-季度/次,6-年/次)")
private Integer frequency;
@Dict(dicCode = "points_rule_category")
@Schema(title = "规则类别")
private Integer ruleCategory;
@Schema(title = "规则描述")
private String ruleDesc;
@Schema(title = "图标")
private String icon;
@Schema(title = "奖励积分")
private BigDecimal points;
@Schema(title = "打卡状态,0未打卡,1已打卡")
private Integer clockInStatus;
}