45 lines
1.5 KiB
Go
45 lines
1.5 KiB
Go
package sdk_LinkedMall
|
|
|
|
import "fmt"
|
|
|
|
// APIError 表示API返回的业务错误
|
|
type APIError struct {
|
|
Code string `json:"Code"` // 错误码
|
|
Message string `json:"Message"` // 错误信息
|
|
SubCode string `json:"SubCode"` // 子错误码
|
|
SubMessage string `json:"SubMessage"` // 子错误信息
|
|
RequestId string `json:"RequestId"` // 请求ID
|
|
}
|
|
|
|
func (e *APIError) Error() string {
|
|
return fmt.Sprintf("linkedmall API error: code=%s, message=%s, subCode=%s, subMessage=%s, requestId=%s",
|
|
e.Code, e.Message, e.SubCode, e.SubMessage, e.RequestId)
|
|
}
|
|
|
|
// IsSuccess 判断是否业务成功
|
|
func (e *APIError) IsSuccess() bool {
|
|
return e.Code == "SUCCESS"
|
|
}
|
|
|
|
// 预定义错误码常量
|
|
const (
|
|
ErrCodeShopTypeInvalid = "ShopTypeInvalid"
|
|
ErrCodeSkuPriceNotLatest = "SkuPriceUnique"
|
|
ErrCodePurchaseOrderNotFound = "PurchaseOrderNotFound"
|
|
ErrCodeRefundNumberExceed = "RefundNumberMustLessThanOrder"
|
|
ErrCodeRefundAmountExceed = "RefundAmountMustLessThanOrder"
|
|
ErrCodeNoPrivilege = "HasNoPrivilege"
|
|
ErrCodeOrderNotFound = "OrderNotFound"
|
|
ErrCodeShopNotFound = "ShopNotFind"
|
|
ErrCodeSavePurchaseOrderError = "SavePurchaseOrderError"
|
|
ErrCodeOuterPurchaseOrderIdExist = "OuterPurchaseOrderIdExist"
|
|
)
|
|
|
|
// ErrResp 用于解析错误响应
|
|
type ErrResp struct {
|
|
Code string `json:"Code"`
|
|
Message string `json:"Message"`
|
|
SubCode string `json:"SubCode"`
|
|
SubMessage string `json:"SubMessage"`
|
|
RequestId string `json:"RequestId"`
|
|
} |