plugin/dctw/v1/api/card/code.go

41 lines
1.2 KiB
Go
Raw Normal View History

2024-11-14 18:33:56 +08:00
package card
2024-11-15 10:34:36 +08:00
import "encoding/json"
2024-11-14 18:33:56 +08:00
2024-11-15 10:34:36 +08:00
type Code json.Number
const (
CodeSuccess Code = "2000"
CodeSuccess2 Code = "0000"
)
2024-11-14 18:33:56 +08:00
var ResMessageMap = map[Code]string{
2024-11-15 10:34:36 +08:00
CodeSuccess: "成功",
"1000": "Ip limit(ip未绑定或绑定失败)",
"1001": "Missing parameters(参数异常)",
"1002": "Invalid merchant(无效商户信息)",
"1003": "Invalid signature(签名校验失败)",
"1004": "Request expiration(请求时间过期)",
"1005": "Order repeat(订单重复)",
"1006": "Invalid item(商品未开通)",
"1007": "Item price invalid(商品价格无效)",
"1008": "Insufficient Balance(余额不足)",
"1009": "Interface adjustment(商品映射无效)",
"1010": "Interface price adjustment(映射价格无效)",
"1011": "Account format matching(充值账号格式不匹配)",
"1012": "no order(无订单信息)",
"1999": "unknown error(异常错误,建议人工处理或查询订单状态)",
2024-11-14 18:33:56 +08:00
}
2024-11-15 10:34:36 +08:00
func (c Code) IsSuccess() bool {
// 根据沟通对接,两种都是请求成功
return c == CodeSuccess || c == CodeSuccess2
2024-11-14 18:33:56 +08:00
}
func (c Code) GetMessage() string {
if message, ok := ResMessageMap[c]; ok {
return message
}
2024-11-15 10:34:36 +08:00
return "未知错误,请联系平台"
2024-11-14 18:33:56 +08:00
}