2025-07-11 21:05:58 +08:00
|
|
|
package enums
|
|
|
|
|
|
|
|
|
|
// CertificationStatus 认证状态枚举
|
|
|
|
|
type CertificationStatus string
|
|
|
|
|
|
|
|
|
|
const (
|
|
|
|
|
// 主流程状态
|
2025-07-20 20:53:26 +08:00
|
|
|
StatusPending CertificationStatus = "pending" // 待认证
|
|
|
|
|
StatusInfoSubmitted CertificationStatus = "info_submitted" // 已提交企业信息
|
|
|
|
|
StatusEnterpriseVerified CertificationStatus = "enterprise_verified" // 已企业认证
|
|
|
|
|
StatusContractApplied CertificationStatus = "contract_applied" // 已申请签署合同
|
|
|
|
|
StatusContractSigned CertificationStatus = "contract_signed" // 已签署合同
|
2025-07-11 21:05:58 +08:00
|
|
|
StatusCompleted CertificationStatus = "completed" // 认证完成
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// IsValidStatus 检查状态是否有效
|
|
|
|
|
func IsValidStatus(status CertificationStatus) bool {
|
|
|
|
|
validStatuses := []CertificationStatus{
|
2025-07-20 20:53:26 +08:00
|
|
|
StatusPending, StatusInfoSubmitted, StatusEnterpriseVerified,
|
|
|
|
|
StatusContractApplied, StatusContractSigned, StatusCompleted,
|
2025-07-11 21:05:58 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for _, validStatus := range validStatuses {
|
|
|
|
|
if status == validStatus {
|
|
|
|
|
return true
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return false
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// GetStatusName 获取状态的中文名称
|
|
|
|
|
func GetStatusName(status CertificationStatus) string {
|
|
|
|
|
statusNames := map[CertificationStatus]string{
|
2025-07-20 20:53:26 +08:00
|
|
|
StatusPending: "待认证",
|
|
|
|
|
StatusInfoSubmitted: "已提交企业信息",
|
|
|
|
|
StatusEnterpriseVerified: "已企业认证",
|
|
|
|
|
StatusContractApplied: "已申请合同",
|
|
|
|
|
StatusContractSigned: "已签署合同",
|
|
|
|
|
StatusCompleted: "认证完成",
|
2025-07-11 21:05:58 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if name, exists := statusNames[status]; exists {
|
|
|
|
|
return name
|
|
|
|
|
}
|
|
|
|
|
return string(status)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// IsFinalStatus 判断是否为最终状态
|
|
|
|
|
func IsFinalStatus(status CertificationStatus) bool {
|
2025-07-20 20:53:26 +08:00
|
|
|
return status == StatusCompleted
|
|
|
|
|
}
|
2025-07-11 21:05:58 +08:00
|
|
|
|
2025-07-20 20:53:26 +08:00
|
|
|
// GetStatusCategory 获取状态分类
|
|
|
|
|
func GetStatusCategory(status CertificationStatus) string {
|
|
|
|
|
switch status {
|
|
|
|
|
case StatusPending:
|
|
|
|
|
return "initial"
|
|
|
|
|
case StatusInfoSubmitted, StatusEnterpriseVerified, StatusContractApplied, StatusContractSigned:
|
|
|
|
|
return "processing"
|
|
|
|
|
case StatusCompleted:
|
|
|
|
|
return "completed"
|
|
|
|
|
default:
|
|
|
|
|
return "unknown"
|
2025-07-11 21:05:58 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-07-20 20:53:26 +08:00
|
|
|
// GetStatusPriority 获取状态优先级(用于排序)
|
|
|
|
|
func GetStatusPriority(status CertificationStatus) int {
|
|
|
|
|
priorities := map[CertificationStatus]int{
|
|
|
|
|
StatusPending: 0,
|
|
|
|
|
StatusInfoSubmitted: 1,
|
|
|
|
|
StatusEnterpriseVerified: 2,
|
|
|
|
|
StatusContractApplied: 3,
|
|
|
|
|
StatusContractSigned: 4,
|
|
|
|
|
StatusCompleted: 5,
|
2025-07-11 21:05:58 +08:00
|
|
|
}
|
|
|
|
|
|
2025-07-20 20:53:26 +08:00
|
|
|
if priority, exists := priorities[status]; exists {
|
|
|
|
|
return priority
|
2025-07-11 21:05:58 +08:00
|
|
|
}
|
2025-07-20 20:53:26 +08:00
|
|
|
return 999
|
2025-07-11 21:05:58 +08:00
|
|
|
}
|