package vo

import "fmt"

type OrderWechatStatus uint8

const (
	OrderWechatStatusWait OrderWechatStatus = iota + 1
	OrderWechatStatusSuccess
	OrderWechatStatusFail
	OrderWechatStatusUse
	OrderWechatStatusExpired
)

func (s OrderWechatStatus) GetValue() uint8 {
	return uint8(s)
}

func (s OrderWechatStatus) IsWait() bool {
	return s == OrderWechatStatusWait
}

func (s OrderWechatStatus) IsSuccess() bool {
	return s == OrderWechatStatusSuccess
}

func (s OrderWechatStatus) IsFail() bool {
	return s == OrderWechatStatusFail
}

func (s OrderWechatStatus) IsUse() bool {
	return s == OrderWechatStatusUse
}

func (s OrderWechatStatus) CanNotify() bool {
	return s.IsSuccess() || s.IsUse()
}

var OrderWechatStatusMap = map[OrderWechatStatus]string{
	OrderWechatStatusWait:    "待发放",
	OrderWechatStatusSuccess: "发放成功",
	OrderWechatStatusFail:    "发放失败",
	OrderWechatStatusUse:     "已使用",
	OrderWechatStatusExpired: "已过期",
}

var OrderStatusMapCmbStatus = map[OrderWechatStatus]CmbStatus{
	OrderWechatStatusSuccess: CmbStatusSuccess,
	OrderWechatStatusUse:     CmbStatusUse,
}

func (s OrderWechatStatus) GetCmbStatusText() (CmbStatus, error) {
	if t, ok := OrderStatusMapCmbStatus[s]; ok {
		return t, nil
	}
	return "", fmt.Errorf("CmbStatus[%s]未定义", s)
}

func (s OrderWechatStatus) GetText() string {
	if t, ok := OrderWechatStatusMap[s]; ok {
		return t
	}
	return "未知状态"
}
