plugin/dctw/v1/api/direct/status.go

58 lines
1.2 KiB
Go
Raw Normal View History

2024-11-14 18:33:56 +08:00
package direct
import (
"gitea.cdlsxd.cn/sdk/plugin/proto"
)
type OrderStatus string
const (
OrderSuccess OrderStatus = "01" // 充值成功
OrderPending OrderStatus = "02" // 充值处理中
OrderFail OrderStatus = "03" // 充值失败
OrderAbnormal OrderStatus = "04" // 充值异常,处理中
)
var orderStatusMap = map[OrderStatus]proto.Status{
OrderSuccess: proto.Status_SUCCESS,
OrderPending: proto.Status_ING,
OrderFail: proto.Status_FAIL,
}
2024-11-15 15:03:52 +08:00
var orderStatusTextMap = map[OrderStatus]string{
OrderSuccess: "充值成功",
OrderPending: "充值处理中",
OrderFail: "充值失败",
OrderAbnormal: "充值异常,处理中",
}
2024-11-14 18:33:56 +08:00
func (o OrderStatus) IsSuccess() bool {
return o == OrderSuccess
}
func (o OrderStatus) IsPending() bool {
return o == OrderPending
}
func (o OrderStatus) IsFail() bool {
return o == OrderFail
}
func (o OrderStatus) IsAbnormal() bool {
return o == OrderAbnormal
}
func (o OrderStatus) GetOrderStatus() proto.Status {
if resultStatus, ok := orderStatusMap[o]; ok {
return resultStatus
}
return proto.Status_ING
}
2024-11-15 15:03:52 +08:00
func (o OrderStatus) GetOrderStatusText() string {
if text, ok := orderStatusTextMap[o]; ok {
return text
}
return ""
}