YouChuKoffee/app/constants/errorcode/error_code.go

98 lines
2.1 KiB
Go

package errorcode
const (
//请求失败
Fail = 0
//成功
Success = 200
//参数错误
ParamError = 400
//未经授权
NotAuth = 401
//请求被禁止
Forbidden = 403
//找不到页面
NotFound = 404
//系统错误
SystemError = 500
//未登录
NotLogin = 1000
//抽奖中
OrderLottery = 1001
//商品不存在
OrderProductNotExist = 1002
//兴业下单失败
XINYEOrderFAIL = 1003
//商品库存不足
ProductStockFAIL = 1004
//订单不允许退款
OrderNOTAuthREFUND = 2001
// 订单更新失败
OrderRefundUpdateFail = 2002
//退款失败
OrderRefundFail = 2003
//邮储服务异常
YouChuOrderRefundFail = 2004
//用户不存在
UserNotExist = 2005
ProdcutDiscard = 2006
// 更新失败
InsertUserFail = 3001
//邮储code解析失败
YouChuCodeFail = 4001
//客户号为空
YouChuCustNoEmpty = 4002
)
var MsgEN = map[int]string{
Success: "success",
ParamError: "param error",
NotAuth: "not authorized",
Forbidden: "forbidden",
NotFound: "not found",
SystemError: "system error",
}
var MsgZH = map[int]string{
SystemError: "系统错误",
Success: "请求成功",
ParamError: "参数错误",
NotFound: "数据不存在",
NotAuth: "未经授权",
NotLogin: "未登录",
OrderLottery: "兑换中",
OrderProductNotExist: "商品不存在",
XINYEOrderFAIL: "三方下单失败",
OrderNOTAuthREFUND: "该订单暂不支持退款",
OrderRefundUpdateFail: "订单更新失败",
OrderRefundFail: "退款失败",
YouChuOrderRefundFail: "邮储服务异常",
ProductStockFAIL: "库存不足",
InsertUserFail: "用户新增失败",
UserNotExist: "产品不存在",
Fail: "请求失败",
YouChuCodeFail: "Code解析失败",
YouChuCustNoEmpty: "客户编号为空",
ProdcutDiscard: "产品已下架",
}
var MsgMap map[string]map[int]string = map[string]map[int]string{"en": MsgZH}
func GetMsg(code int, local string) string {
if local == "" {
local = "en"
}
if msg, ok := MsgMap[local][code]; ok {
return msg
}
return ""
}