package originalJd

import "kami/internal/consts"

// HttpStatus 定义枚举类型
type HttpStatus int

// 枚举值
const (
	Success                    HttpStatus = 0     // 成功
	NormalError                HttpStatus = 10002 // 通用错误
	CkError                    HttpStatus = 10003 // ck 错误
	FacePriceError             HttpStatus = 10001 // 面值错误
	OrderTypeNotSupportedError HttpStatus = 10004 // 不支持的订单类型
	OrderExpiredError          HttpStatus = 10005 // 订单过期
	StockError                 HttpStatus = 10006 // 库存错误
	InternalError              HttpStatus = 5004  // 内部错误
	RiskError                  HttpStatus = 10007 // 风控失败
)

// String 方法用于返回枚举值的名称
func (h HttpStatus) String() string {
	switch h {
	case Success:
		return "Success"
	case NormalError:
		return "NormalError"
	case CkError:
		return "CkError"
	case FacePriceError:
		return "FacePriceError"
	case OrderTypeNotSupportedError:
		return "OrderTypeNotSupportedError"
	case OrderExpiredError:
		return "OrderExpiredError"
	case InternalError:
		return "InternalError"
	case StockError:
		return "StockError"
	default:
		return "Unknown"
	}
}

func (h HttpStatus) JDOrderStatus() consts.CardCookieJDOrderStatus {
	switch h {
	case Success:
		return consts.CardCookieJDStatusSuccess
	case NormalError:
		return consts.CardCookieJDStatusNormalFailed
	case CkError:
		return consts.CardCookieJDStatusCkFailed
	case FacePriceError:
		return consts.CardCookieJDStatusWrongFacePrice
	case OrderTypeNotSupportedError:
		return consts.CardCookieJDStatusNormalFailed
	case OrderExpiredError:
		return consts.CardCookieJDStatusExpired
	case InternalError:
		return consts.CardCookieJDStatusNormalFailed
	case StockError:
		return consts.CardCookieJDStatusStockError
	case RiskError:
		return consts.CardCookieJDStatusRiskFailed
	default:
		return consts.CardCookieJDStatusNormalFailed
	}
}
