添加文件: intelligence_finance_v1/errors.go
This commit is contained in:
parent
442047e5f0
commit
ddef2d51a7
|
|
@ -0,0 +1,91 @@
|
|||
package intelligence_finance_v1
|
||||
|
||||
import "fmt"
|
||||
|
||||
// ErrorCode 表示 API 返回的错误码
|
||||
type ErrorCode int
|
||||
|
||||
// APIError 表示 API 调用返回的业务错误
|
||||
type APIError struct {
|
||||
Code int `json:"code"`
|
||||
Message string `json:"msg"`
|
||||
}
|
||||
|
||||
// Error 实现 error 接口
|
||||
func (e *APIError) Error() string {
|
||||
return fmt.Sprintf("API error: code=%d, msg=%s", e.Code, e.Message)
|
||||
}
|
||||
|
||||
// NewAPIError 创建一个新的 APIError
|
||||
func NewAPIError(code int, msg string) *APIError {
|
||||
return &APIError{
|
||||
Code: code,
|
||||
Message: msg,
|
||||
}
|
||||
}
|
||||
|
||||
// 开票状态常量
|
||||
const (
|
||||
InvoiceStatusNotInvoiced = 0 // 未开票
|
||||
InvoiceStatusInvoicing = 1 // 开票中
|
||||
InvoiceStatusPartiallyFailed = 2 // 部分失败
|
||||
InvoiceStatusSuccess = 3 // 开票成功
|
||||
InvoiceStatusFailed = 4 // 开票失败
|
||||
InvoiceStatusPartiallyUnsent = 5 // 部分未开
|
||||
InvoiceStatusNoAccount = 6 // 未配置数电账号
|
||||
InvoiceStatusNoAutoConfig = 7 // 未配置自动开票配置
|
||||
)
|
||||
|
||||
// 发票类型常量
|
||||
const (
|
||||
InvoiceTypeSpecial = 1 // 专用发票
|
||||
InvoiceTypeNormal = 2 // 普通发票
|
||||
InvoiceTypeNormalElectronic = 3 // 普通发票(电子)
|
||||
InvoiceTypeSpecialElectronic = 4 // 专用发票(电子)
|
||||
InvoiceTypeDigitalSpecial = 8 // 数电专票
|
||||
InvoiceTypeDigitalNormal = 9 // 数电普票
|
||||
)
|
||||
|
||||
// 支付状态常量
|
||||
const (
|
||||
PaymentStatusSuccess = "SUCCESS" // 支付成功
|
||||
PaymentStatusFail = "FAIL" // 支付失败
|
||||
PaymentStatusTerminate = "TERMINATE" // 支付取消
|
||||
PaymentStatusWaitPay = "WAIT_PAY" // 待支付
|
||||
PaymentStatusPaying = "PAYING" // 支付中
|
||||
PaymentStatusPartSuccess = "PART_SUCCESS" // 部分支付成功
|
||||
PaymentStatusRefund = "REFUND" // 退款
|
||||
)
|
||||
|
||||
// 账户类型常量
|
||||
const (
|
||||
AccountTypeAlipay = "ALIPAY" // 支付宝
|
||||
AccountTypeBankCard = "BANKCARD" // 银行卡
|
||||
AccountTypeCorpBankCard = "CORP_BANK_CARD" // 对公银行卡
|
||||
AccountTypePersonalBankCard = "PERSONAL_BANK_CARD" // 对私银行卡
|
||||
)
|
||||
|
||||
// 通知响应常量
|
||||
const (
|
||||
NotificationSuccess = "SUCCESS"
|
||||
NotificationFailed = "FAILED"
|
||||
)
|
||||
|
||||
// 发票状态常量(发票自身状态)
|
||||
const (
|
||||
InvStatusNormal = "1" // 正常
|
||||
InvStatusRedacted = "2" // 已红冲
|
||||
InvStatusVoided = "3" // 已作废
|
||||
)
|
||||
|
||||
// 开票类型
|
||||
const (
|
||||
IssueTypeNormal = "0" // 正数票
|
||||
IssueTypeNegative = "1" // 负数票(红冲)
|
||||
)
|
||||
|
||||
// 来源枚举
|
||||
const (
|
||||
SourceApproval = "approval" // 审批单
|
||||
SourceOpenAPI = "openapi" // 开发接口
|
||||
)
|
||||
Loading…
Reference in New Issue