voucher/internal/biz/businesserr/cmb.go

61 lines
2.4 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package businesserr
// ThirdErrCode 表示发券接口失败时返回的第三方业务错误码
// 格式为 tecxxx用于统一抽象不同支付平台的错误
type ThirdErrCode string
// 定义具体的第三方错误码常量(微信/支付宝的都有)
const (
ThirdErrCodeDefault ThirdErrCode = "tec999" // 默认错误码
ThirdErrCodeStockNotEnough ThirdErrCode = "tec001" // 库存不足
ThirdErrCodeAdvanceFundingNotEnough ThirdErrCode = "tec002" // 垫资不足
ThirdErrCodeBatchNotStarted ThirdErrCode = "tec003" // 批次未开始
ThirdErrCodeBatchEnded ThirdErrCode = "tec004" // 批次已结束
ThirdErrCodeBatchOffline ThirdErrCode = "tec005" // 批次已下线
ThirdErrCodePaymentPlatformError ThirdErrCode = "tec006" // 微信/支付宝异常
ThirdErrCodeUserNotRealNameVerified ThirdErrCode = "tec007" // 用户没有实名认证
ThirdErrCodeUserNotFound ThirdErrCode = "tec008" // 用户账号不存在
ThirdErrCodeUserAccountFrozen ThirdErrCode = "tec009" // 用户账户被冻结
ThirdErrCodeUserHighRiskOrCheater ThirdErrCode = "tec010" // 用户为作弊用户或高风险用户
ThirdErrCodeUserNoMobileBound ThirdErrCode = "tec011" // 用户没有绑定手机号
ThirdErrCodeUserAccountAbnormal ThirdErrCode = "tec012" // 用户账号异常(没有明确的原因)
ThirdErrCodeUserParticipationExceeded ThirdErrCode = "tec013" // 用户参与次数超限
ThirdErrCodeAppIDOpenIDMismatch ThirdErrCode = "tec014" // appid与openid不匹配
ThirdErrCodeDailyLimit ThirdErrCode = "tec015" // 超批次当天限额
ThirdErrCodeCallHigh ThirdErrCode = "tec016" // 调用频率过高
)
// CmbAPIError 定义 API 错误结构体
type CmbAPIError struct {
StatusCode int `json:"status_code"`
ErrorCode ErrCode `json:"error_code"`
Description string `json:"description"`
Hint string `json:"hint"` // 解决方案
ThirdErrCode ThirdErrCode `json:"third_err_code"`
}
var CmbAPIPublicErrorMap = map[ErrCode][]CmbAPIError{
BATCH_NOT_STARTED: {
{
StatusCode: 400,
ErrorCode: BATCH_NOT_STARTED,
Description: "批次未开始",
Hint: "批次未开始",
ThirdErrCode: ThirdErrCodeDefault,
},
},
BATCH_ENDED: {
{
StatusCode: 400,
ErrorCode: BATCH_ENDED,
Description: "批次已结束",
Hint: "批次已结束",
ThirdErrCode: ThirdErrCodeDefault,
},
},
}