fix:十二分制-奖惩规则

This commit is contained in:
wangff
2025-11-07 15:12:25 +08:00
parent 85a411bc9a
commit a3d0f9572c
41 changed files with 1534 additions and 38 deletions

View File

@@ -232,4 +232,7 @@ public class CommonConstants {
public static final int REFRESH_TOKEN_EXPIRE = 30 * 24 * 60 * 60;
public static final int BATCH_SIZE = 200;
public static final Integer INDEX_ZERO = 0;
public static final Integer INDEX_ONE = 1;
}

View File

@@ -315,6 +315,16 @@ public enum ErrorCodeEnum {
JOIN_MODE_NOT_ALLOW_OPERATE(1610012,"加盟部人员只能新建加盟店或联营店,请确认!",null),
STORE_NOT_FIND(1610013,"门店不存在",null),
/**
* 181 十二分制
*/
TP_NOT_EXIST_RULE(1810000, "不存在该规则", null),
TP_MONTH_EXIST_APPLY(1810001, "该门店一个月内存在相同项目的加分申请", null),
TP_SCORE_EQUAL_TWELVE(1810002, "该门店已满12分无法申请加分", null),
TP_NOT_EXIST_PENDING_AUDIT(1810003, "申请单不存在待审批记录", null),
TP_NOT_EXIST_APPLY_FORM(1810004, "不存在申请单", null),
TP_APPLY_AUDIT_COMPLETED(1810005, "该申请单已审批", null),
TP_EXISTS_PENDING_APPLY(1810006, "存在待审批的申请单", null),
;

View File

@@ -0,0 +1,38 @@
package com.cool.store.enums.tp;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* <p>
* 十二分制-单据状态 枚举类
* </p>
*
* @author wangff
* @since 2025/11/5
*/
@Getter
@AllArgsConstructor
public enum TpFormStatusEnum {
PENDING("pending", "审批中"),
PASS("pass", "审批通过"),
REJECT("reject", "审批拒绝"),
EFFECTIVE("effective", "已生效"),
CANCEL("cancel", "已作废"),
;
private final String status;
private final String msg;
public static String getMsgByStatus(String status) {
for (TpFormStatusEnum value : values()) {
if (value.status.equals(status)) {
return value.msg;
}
}
return null;
}
}

View File

@@ -0,0 +1,44 @@
package com.cool.store.enums.tp;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* <p>
* 十二分制-单据类型 枚举类
* </p>
*
* @author wangff
* @since 2025/11/6
*/
@Getter
@AllArgsConstructor
public enum TpFormTypeEnum {
REWARD(0, "加分申请单"),
WARNING(1, "警告书"),
PENALTY(2, "处罚书"),
;
private final Integer type;
private final String msg;
public static String getMsgByType(Integer type) {
for (TpFormTypeEnum value : values()) {
if (value.type.equals(type)) {
return value.msg;
}
}
return null;
}
public static TpFormTypeEnum getByType(Integer type) {
for (TpFormTypeEnum value : values()) {
if (value.type.equals(type)) {
return value;
}
}
return null;
}
}

View File

@@ -0,0 +1,35 @@
package com.cool.store.enums.tp;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* <p>
* 十二分制-缴费状态 枚举类
* </p>
*
* @author wangff
* @since 2025/11/5
*/
@Getter
@AllArgsConstructor
public enum TpPayStatusEnum {
UNPAID(0, "未缴费"),
NO_NEED_PAY(1, "无需缴费"),
PAID(2, "已缴费")
;
private final Integer status;
private final String msg;
public static String getMsgByStatus(Integer status) {
for (TpPayStatusEnum value : values()) {
if (value.status.equals(status)) {
return value.msg;
}
}
return null;
}
}

View File

@@ -1,5 +1,7 @@
package com.cool.store.utils;
import com.cool.store.enums.tp.TpFormTypeEnum;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
@@ -15,16 +17,30 @@ public class TpHelper {
private final static DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyMMddHHmmssSSS");
/**
* 生成惩处单号
* 生成奖惩规则编码
* @param isReward 是否为加分规则
* @return 规则编码
*/
public static String generatePenaltyRuleCode() {
return "CC" + generateCode();
public static String generateRuleNo(boolean isReward) {
return (isReward ? "JR" : "CR") + generateCode();
}
/**
* 生成加分单
* 生成积分流水
*/
public static String generateRewardRuleCode() {
return "JF" + generateCode();
public static String generateScoreJournalNo() {
return "LS" + generateCode();
}
/**
* 生成申请单号
* @param applyType 单据类型
* @return 申请单号
*/
public static String generateApplyNo(Integer applyType) {
TpFormTypeEnum type = TpFormTypeEnum.getByType(applyType);
if (type == null) return null;
return (TpFormTypeEnum.REWARD.equals(type) ? "JF" : TpFormTypeEnum.PENALTY.equals(type) ? "CF" : "JG") + generateCode();
}
private static String generateCode() {