package wechatrepoimpl

import (
	"fmt"
	"voucher/internal/biz/vo"
)

const CodeSuccess = 200

type CpnStatus string

const (
	CpnStatusAvailable = "SENDED"
	CpnStatusUsed      = "USED"
	CpnStatusExpired   = "EXPIRED"
)

var CpnStatusTextMap = map[CpnStatus]string{
	CpnStatusAvailable: "可用",
	CpnStatusUsed:      "已实扣",
	CpnStatusExpired:   "已过期",
}

var CpnStatusMap = map[CpnStatus]vo.OrderWechatStatus{
	CpnStatusAvailable: vo.OrderWechatStatusSuccess,
	CpnStatusUsed:      vo.OrderWechatStatusUse,
	CpnStatusExpired:   vo.OrderWechatStatusExpired,
}

func (o CpnStatus) GetText() string {
	if msg, ok := CpnStatusTextMap[o]; !ok {
		return msg
	}
	return "未知"
}

func (o CpnStatus) GetStatus() (vo.OrderWechatStatus, error) {
	if resultStatus, ok := CpnStatusMap[o]; ok {
		return resultStatus, nil
	}
	return 0, fmt.Errorf("CpnStatus[%s]未定义", o)
}
