package vo

import "fmt"

type OrderNotifyEvent uint8

const (
	OrderNotifyEventSendDEd OrderNotifyEvent = iota + 1
	OrderNotifyEventUsed
	OrderNotifyEventExpired
)

var OrderNotifyEventMap = map[OrderNotifyEvent]string{
	OrderNotifyEventSendDEd: "可用",
	OrderNotifyEventUsed:    "已实扣",
	OrderNotifyEventExpired: "已过期",
}

func (s OrderNotifyEvent) GetText() string {
	if t, ok := OrderNotifyEventMap[s]; ok {
		return t
	}
	return "未知通知事件"
}

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

func (s OrderNotifyEvent) IsSendDEd() bool {
	return s == OrderNotifyEventSendDEd
}

func (s OrderNotifyEvent) IsUsed() bool {
	return s == OrderNotifyEventUsed
}

func (s OrderNotifyEvent) IsExpired() bool {
	return s == OrderNotifyEventExpired
}

func (s OrderNotifyEvent) CanNotify() bool {
	return s.IsSendDEd() || s.IsUsed() || s.IsExpired()
}

var OrderNotifyEventMapCmbStatus = map[OrderNotifyEvent]CmbStatus{
	OrderNotifyEventSendDEd: CmbStatusSuccess,
	OrderNotifyEventUsed:    CmbStatusUse,
	OrderNotifyEventExpired: CmbStatusExpired,
}

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