From ddef2d51a7efc37d3807760efcffccf7a1be0318 Mon Sep 17 00:00:00 2001 From: renzhiyuan <465386466@qq.com> Date: Mon, 17 Aug 2026 15:48:47 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=96=87=E4=BB=B6:=20intelli?= =?UTF-8?q?gence=5Ffinance=5Fv1/errors.go?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- intelligence_finance_v1/errors.go | 91 +++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 intelligence_finance_v1/errors.go diff --git a/intelligence_finance_v1/errors.go b/intelligence_finance_v1/errors.go new file mode 100644 index 0000000..9b08575 --- /dev/null +++ b/intelligence_finance_v1/errors.go @@ -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" // 开发接口 +) \ No newline at end of file