package errorcode

const (
	//成功
	Success = 200

	//参数错误
	ParamError = 400

	//未经授权
	NotAuth = 401

	//请求被禁止
	Forbidden = 403

	//找不到页面
	NotFound = 404

	//系统错误
	SystemError = 500

	//请求超时
	RequestTimeOut = 600

	//未登录
	NotLogin = 1000

	// 商户
	MerchantNotFound = 1100

	// app
	AppNotFound   = 1200
	AppDisabled   = 1201
	AppIpNotAllow = 1202

	//渠道
	PayChannelNotFound = 1300
)

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{
	Success:          "请求成功",
	ParamError:       "参数错误",
	NotFound:         "数据不存在",
	NotAuth:          "未经授权",
	NotLogin:         "未登录",
	RequestTimeOut:   "请求超时",
	MerchantNotFound: "商户不存在",
	AppNotFound:      "app_id未找到",
	AppDisabled:      "app通道关闭",
	AppIpNotAllow:    "ip不在白名单内",
	PayChannelNotFound: "支付方式不存在",
}
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 ""
}