feat: add wechat pay
This commit is contained in:
479
backend/database/fields/orders.gen.go
Normal file
479
backend/database/fields/orders.gen.go
Normal file
@@ -0,0 +1,479 @@
|
||||
// Code generated by go-enum DO NOT EDIT.
|
||||
// Version: -
|
||||
// Revision: -
|
||||
// Build Date: -
|
||||
// Built By: -
|
||||
|
||||
package fields
|
||||
|
||||
import (
|
||||
"database/sql/driver"
|
||||
"errors"
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
const (
|
||||
// OrderStatusPending is a OrderStatus of type Pending.
|
||||
OrderStatusPending OrderStatus = iota
|
||||
// OrderStatusPaid is a OrderStatus of type Paid.
|
||||
OrderStatusPaid
|
||||
// OrderStatusRefunding is a OrderStatus of type Refunding.
|
||||
OrderStatusRefunding
|
||||
// OrderStatusRefunded is a OrderStatus of type Refunded.
|
||||
OrderStatusRefunded
|
||||
// OrderStatusCancelled is a OrderStatus of type Cancelled.
|
||||
OrderStatusCancelled
|
||||
)
|
||||
|
||||
var ErrInvalidOrderStatus = fmt.Errorf("not a valid OrderStatus, try [%s]", strings.Join(_OrderStatusNames, ", "))
|
||||
|
||||
const _OrderStatusName = "PendingPaidRefundingRefundedCancelled"
|
||||
|
||||
var _OrderStatusNames = []string{
|
||||
_OrderStatusName[0:7],
|
||||
_OrderStatusName[7:11],
|
||||
_OrderStatusName[11:20],
|
||||
_OrderStatusName[20:28],
|
||||
_OrderStatusName[28:37],
|
||||
}
|
||||
|
||||
// OrderStatusNames returns a list of possible string values of OrderStatus.
|
||||
func OrderStatusNames() []string {
|
||||
tmp := make([]string, len(_OrderStatusNames))
|
||||
copy(tmp, _OrderStatusNames)
|
||||
return tmp
|
||||
}
|
||||
|
||||
// OrderStatusValues returns a list of the values for OrderStatus
|
||||
func OrderStatusValues() []OrderStatus {
|
||||
return []OrderStatus{
|
||||
OrderStatusPending,
|
||||
OrderStatusPaid,
|
||||
OrderStatusRefunding,
|
||||
OrderStatusRefunded,
|
||||
OrderStatusCancelled,
|
||||
}
|
||||
}
|
||||
|
||||
var _OrderStatusMap = map[OrderStatus]string{
|
||||
OrderStatusPending: _OrderStatusName[0:7],
|
||||
OrderStatusPaid: _OrderStatusName[7:11],
|
||||
OrderStatusRefunding: _OrderStatusName[11:20],
|
||||
OrderStatusRefunded: _OrderStatusName[20:28],
|
||||
OrderStatusCancelled: _OrderStatusName[28:37],
|
||||
}
|
||||
|
||||
// String implements the Stringer interface.
|
||||
func (x OrderStatus) String() string {
|
||||
if str, ok := _OrderStatusMap[x]; ok {
|
||||
return str
|
||||
}
|
||||
return fmt.Sprintf("OrderStatus(%d)", x)
|
||||
}
|
||||
|
||||
// IsValid provides a quick way to determine if the typed value is
|
||||
// part of the allowed enumerated values
|
||||
func (x OrderStatus) IsValid() bool {
|
||||
_, ok := _OrderStatusMap[x]
|
||||
return ok
|
||||
}
|
||||
|
||||
var _OrderStatusValue = map[string]OrderStatus{
|
||||
_OrderStatusName[0:7]: OrderStatusPending,
|
||||
_OrderStatusName[7:11]: OrderStatusPaid,
|
||||
_OrderStatusName[11:20]: OrderStatusRefunding,
|
||||
_OrderStatusName[20:28]: OrderStatusRefunded,
|
||||
_OrderStatusName[28:37]: OrderStatusCancelled,
|
||||
}
|
||||
|
||||
// ParseOrderStatus attempts to convert a string to a OrderStatus.
|
||||
func ParseOrderStatus(name string) (OrderStatus, error) {
|
||||
if x, ok := _OrderStatusValue[name]; ok {
|
||||
return x, nil
|
||||
}
|
||||
return OrderStatus(0), fmt.Errorf("%s is %w", name, ErrInvalidOrderStatus)
|
||||
}
|
||||
|
||||
var errOrderStatusNilPtr = errors.New("value pointer is nil") // one per type for package clashes
|
||||
|
||||
// Scan implements the Scanner interface.
|
||||
func (x *OrderStatus) Scan(value interface{}) (err error) {
|
||||
if value == nil {
|
||||
*x = OrderStatus(0)
|
||||
return
|
||||
}
|
||||
|
||||
// A wider range of scannable types.
|
||||
// driver.Value values at the top of the list for expediency
|
||||
switch v := value.(type) {
|
||||
case int64:
|
||||
*x = OrderStatus(v)
|
||||
case string:
|
||||
*x, err = ParseOrderStatus(v)
|
||||
if err != nil {
|
||||
// try parsing the integer value as a string
|
||||
if val, verr := strconv.Atoi(v); verr == nil {
|
||||
*x, err = OrderStatus(val), nil
|
||||
}
|
||||
}
|
||||
case []byte:
|
||||
*x, err = ParseOrderStatus(string(v))
|
||||
if err != nil {
|
||||
// try parsing the integer value as a string
|
||||
if val, verr := strconv.Atoi(string(v)); verr == nil {
|
||||
*x, err = OrderStatus(val), nil
|
||||
}
|
||||
}
|
||||
case OrderStatus:
|
||||
*x = v
|
||||
case int:
|
||||
*x = OrderStatus(v)
|
||||
case *OrderStatus:
|
||||
if v == nil {
|
||||
return errOrderStatusNilPtr
|
||||
}
|
||||
*x = *v
|
||||
case uint:
|
||||
*x = OrderStatus(v)
|
||||
case uint64:
|
||||
*x = OrderStatus(v)
|
||||
case *int:
|
||||
if v == nil {
|
||||
return errOrderStatusNilPtr
|
||||
}
|
||||
*x = OrderStatus(*v)
|
||||
case *int64:
|
||||
if v == nil {
|
||||
return errOrderStatusNilPtr
|
||||
}
|
||||
*x = OrderStatus(*v)
|
||||
case float64: // json marshals everything as a float64 if it's a number
|
||||
*x = OrderStatus(v)
|
||||
case *float64: // json marshals everything as a float64 if it's a number
|
||||
if v == nil {
|
||||
return errOrderStatusNilPtr
|
||||
}
|
||||
*x = OrderStatus(*v)
|
||||
case *uint:
|
||||
if v == nil {
|
||||
return errOrderStatusNilPtr
|
||||
}
|
||||
*x = OrderStatus(*v)
|
||||
case *uint64:
|
||||
if v == nil {
|
||||
return errOrderStatusNilPtr
|
||||
}
|
||||
*x = OrderStatus(*v)
|
||||
case *string:
|
||||
if v == nil {
|
||||
return errOrderStatusNilPtr
|
||||
}
|
||||
*x, err = ParseOrderStatus(*v)
|
||||
if err != nil {
|
||||
// try parsing the integer value as a string
|
||||
if val, verr := strconv.Atoi(*v); verr == nil {
|
||||
*x, err = OrderStatus(val), nil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// Value implements the driver Valuer interface.
|
||||
func (x OrderStatus) Value() (driver.Value, error) {
|
||||
return int64(x), nil
|
||||
}
|
||||
|
||||
// Set implements the Golang flag.Value interface func.
|
||||
func (x *OrderStatus) Set(val string) error {
|
||||
v, err := ParseOrderStatus(val)
|
||||
*x = v
|
||||
return err
|
||||
}
|
||||
|
||||
// Get implements the Golang flag.Getter interface func.
|
||||
func (x *OrderStatus) Get() interface{} {
|
||||
return *x
|
||||
}
|
||||
|
||||
// Type implements the github.com/spf13/pFlag Value interface.
|
||||
func (x *OrderStatus) Type() string {
|
||||
return "OrderStatus"
|
||||
}
|
||||
|
||||
type NullOrderStatus struct {
|
||||
OrderStatus OrderStatus
|
||||
Valid bool
|
||||
}
|
||||
|
||||
func NewNullOrderStatus(val interface{}) (x NullOrderStatus) {
|
||||
x.Scan(val) // yes, we ignore this error, it will just be an invalid value.
|
||||
return
|
||||
}
|
||||
|
||||
// Scan implements the Scanner interface.
|
||||
func (x *NullOrderStatus) Scan(value interface{}) (err error) {
|
||||
if value == nil {
|
||||
x.OrderStatus, x.Valid = OrderStatus(0), false
|
||||
return
|
||||
}
|
||||
|
||||
err = x.OrderStatus.Scan(value)
|
||||
x.Valid = (err == nil)
|
||||
return
|
||||
}
|
||||
|
||||
// Value implements the driver Valuer interface.
|
||||
func (x NullOrderStatus) Value() (driver.Value, error) {
|
||||
if !x.Valid {
|
||||
return nil, nil
|
||||
}
|
||||
// driver.Value accepts int64 for int values.
|
||||
return int64(x.OrderStatus), nil
|
||||
}
|
||||
|
||||
type NullOrderStatusStr struct {
|
||||
NullOrderStatus
|
||||
}
|
||||
|
||||
func NewNullOrderStatusStr(val interface{}) (x NullOrderStatusStr) {
|
||||
x.Scan(val) // yes, we ignore this error, it will just be an invalid value.
|
||||
return
|
||||
}
|
||||
|
||||
// Value implements the driver Valuer interface.
|
||||
func (x NullOrderStatusStr) Value() (driver.Value, error) {
|
||||
if !x.Valid {
|
||||
return nil, nil
|
||||
}
|
||||
return x.OrderStatus.String(), nil
|
||||
}
|
||||
|
||||
const (
|
||||
// OrderTypeCharge is a OrderType of type Charge.
|
||||
OrderTypeCharge OrderType = iota
|
||||
// OrderTypeConsume is a OrderType of type Consume.
|
||||
OrderTypeConsume
|
||||
// OrderTypeRefund is a OrderType of type Refund.
|
||||
OrderTypeRefund
|
||||
)
|
||||
|
||||
var ErrInvalidOrderType = fmt.Errorf("not a valid OrderType, try [%s]", strings.Join(_OrderTypeNames, ", "))
|
||||
|
||||
const _OrderTypeName = "ChargeConsumeRefund"
|
||||
|
||||
var _OrderTypeNames = []string{
|
||||
_OrderTypeName[0:6],
|
||||
_OrderTypeName[6:13],
|
||||
_OrderTypeName[13:19],
|
||||
}
|
||||
|
||||
// OrderTypeNames returns a list of possible string values of OrderType.
|
||||
func OrderTypeNames() []string {
|
||||
tmp := make([]string, len(_OrderTypeNames))
|
||||
copy(tmp, _OrderTypeNames)
|
||||
return tmp
|
||||
}
|
||||
|
||||
// OrderTypeValues returns a list of the values for OrderType
|
||||
func OrderTypeValues() []OrderType {
|
||||
return []OrderType{
|
||||
OrderTypeCharge,
|
||||
OrderTypeConsume,
|
||||
OrderTypeRefund,
|
||||
}
|
||||
}
|
||||
|
||||
var _OrderTypeMap = map[OrderType]string{
|
||||
OrderTypeCharge: _OrderTypeName[0:6],
|
||||
OrderTypeConsume: _OrderTypeName[6:13],
|
||||
OrderTypeRefund: _OrderTypeName[13:19],
|
||||
}
|
||||
|
||||
// String implements the Stringer interface.
|
||||
func (x OrderType) String() string {
|
||||
if str, ok := _OrderTypeMap[x]; ok {
|
||||
return str
|
||||
}
|
||||
return fmt.Sprintf("OrderType(%d)", x)
|
||||
}
|
||||
|
||||
// IsValid provides a quick way to determine if the typed value is
|
||||
// part of the allowed enumerated values
|
||||
func (x OrderType) IsValid() bool {
|
||||
_, ok := _OrderTypeMap[x]
|
||||
return ok
|
||||
}
|
||||
|
||||
var _OrderTypeValue = map[string]OrderType{
|
||||
_OrderTypeName[0:6]: OrderTypeCharge,
|
||||
_OrderTypeName[6:13]: OrderTypeConsume,
|
||||
_OrderTypeName[13:19]: OrderTypeRefund,
|
||||
}
|
||||
|
||||
// ParseOrderType attempts to convert a string to a OrderType.
|
||||
func ParseOrderType(name string) (OrderType, error) {
|
||||
if x, ok := _OrderTypeValue[name]; ok {
|
||||
return x, nil
|
||||
}
|
||||
return OrderType(0), fmt.Errorf("%s is %w", name, ErrInvalidOrderType)
|
||||
}
|
||||
|
||||
var errOrderTypeNilPtr = errors.New("value pointer is nil") // one per type for package clashes
|
||||
|
||||
// Scan implements the Scanner interface.
|
||||
func (x *OrderType) Scan(value interface{}) (err error) {
|
||||
if value == nil {
|
||||
*x = OrderType(0)
|
||||
return
|
||||
}
|
||||
|
||||
// A wider range of scannable types.
|
||||
// driver.Value values at the top of the list for expediency
|
||||
switch v := value.(type) {
|
||||
case int64:
|
||||
*x = OrderType(v)
|
||||
case string:
|
||||
*x, err = ParseOrderType(v)
|
||||
if err != nil {
|
||||
// try parsing the integer value as a string
|
||||
if val, verr := strconv.Atoi(v); verr == nil {
|
||||
*x, err = OrderType(val), nil
|
||||
}
|
||||
}
|
||||
case []byte:
|
||||
*x, err = ParseOrderType(string(v))
|
||||
if err != nil {
|
||||
// try parsing the integer value as a string
|
||||
if val, verr := strconv.Atoi(string(v)); verr == nil {
|
||||
*x, err = OrderType(val), nil
|
||||
}
|
||||
}
|
||||
case OrderType:
|
||||
*x = v
|
||||
case int:
|
||||
*x = OrderType(v)
|
||||
case *OrderType:
|
||||
if v == nil {
|
||||
return errOrderTypeNilPtr
|
||||
}
|
||||
*x = *v
|
||||
case uint:
|
||||
*x = OrderType(v)
|
||||
case uint64:
|
||||
*x = OrderType(v)
|
||||
case *int:
|
||||
if v == nil {
|
||||
return errOrderTypeNilPtr
|
||||
}
|
||||
*x = OrderType(*v)
|
||||
case *int64:
|
||||
if v == nil {
|
||||
return errOrderTypeNilPtr
|
||||
}
|
||||
*x = OrderType(*v)
|
||||
case float64: // json marshals everything as a float64 if it's a number
|
||||
*x = OrderType(v)
|
||||
case *float64: // json marshals everything as a float64 if it's a number
|
||||
if v == nil {
|
||||
return errOrderTypeNilPtr
|
||||
}
|
||||
*x = OrderType(*v)
|
||||
case *uint:
|
||||
if v == nil {
|
||||
return errOrderTypeNilPtr
|
||||
}
|
||||
*x = OrderType(*v)
|
||||
case *uint64:
|
||||
if v == nil {
|
||||
return errOrderTypeNilPtr
|
||||
}
|
||||
*x = OrderType(*v)
|
||||
case *string:
|
||||
if v == nil {
|
||||
return errOrderTypeNilPtr
|
||||
}
|
||||
*x, err = ParseOrderType(*v)
|
||||
if err != nil {
|
||||
// try parsing the integer value as a string
|
||||
if val, verr := strconv.Atoi(*v); verr == nil {
|
||||
*x, err = OrderType(val), nil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// Value implements the driver Valuer interface.
|
||||
func (x OrderType) Value() (driver.Value, error) {
|
||||
return int64(x), nil
|
||||
}
|
||||
|
||||
// Set implements the Golang flag.Value interface func.
|
||||
func (x *OrderType) Set(val string) error {
|
||||
v, err := ParseOrderType(val)
|
||||
*x = v
|
||||
return err
|
||||
}
|
||||
|
||||
// Get implements the Golang flag.Getter interface func.
|
||||
func (x *OrderType) Get() interface{} {
|
||||
return *x
|
||||
}
|
||||
|
||||
// Type implements the github.com/spf13/pFlag Value interface.
|
||||
func (x *OrderType) Type() string {
|
||||
return "OrderType"
|
||||
}
|
||||
|
||||
type NullOrderType struct {
|
||||
OrderType OrderType
|
||||
Valid bool
|
||||
}
|
||||
|
||||
func NewNullOrderType(val interface{}) (x NullOrderType) {
|
||||
x.Scan(val) // yes, we ignore this error, it will just be an invalid value.
|
||||
return
|
||||
}
|
||||
|
||||
// Scan implements the Scanner interface.
|
||||
func (x *NullOrderType) Scan(value interface{}) (err error) {
|
||||
if value == nil {
|
||||
x.OrderType, x.Valid = OrderType(0), false
|
||||
return
|
||||
}
|
||||
|
||||
err = x.OrderType.Scan(value)
|
||||
x.Valid = (err == nil)
|
||||
return
|
||||
}
|
||||
|
||||
// Value implements the driver Valuer interface.
|
||||
func (x NullOrderType) Value() (driver.Value, error) {
|
||||
if !x.Valid {
|
||||
return nil, nil
|
||||
}
|
||||
// driver.Value accepts int64 for int values.
|
||||
return int64(x.OrderType), nil
|
||||
}
|
||||
|
||||
type NullOrderTypeStr struct {
|
||||
NullOrderType
|
||||
}
|
||||
|
||||
func NewNullOrderTypeStr(val interface{}) (x NullOrderTypeStr) {
|
||||
x.Scan(val) // yes, we ignore this error, it will just be an invalid value.
|
||||
return
|
||||
}
|
||||
|
||||
// Value implements the driver Valuer interface.
|
||||
func (x NullOrderTypeStr) Value() (driver.Value, error) {
|
||||
if !x.Valid {
|
||||
return nil, nil
|
||||
}
|
||||
return x.OrderType.String(), nil
|
||||
}
|
||||
19
backend/database/fields/orders.go
Normal file
19
backend/database/fields/orders.go
Normal file
@@ -0,0 +1,19 @@
|
||||
package fields
|
||||
|
||||
// swagger:enum OrderType
|
||||
// ENUM( Charge, Consume, Refund)
|
||||
type OrderType int16
|
||||
|
||||
// swagger:enum OrderStatus
|
||||
// ENUM( Pending, Paid, Refunding, Refunded, Cancelled)
|
||||
type OrderStatus int16
|
||||
|
||||
type OrderMeta struct {
|
||||
ObjectID int64 `json:"object_id"`
|
||||
Price int64 `json:"price"`
|
||||
Discount int16 `json:"discount"`
|
||||
Coupons []struct {
|
||||
ID int64 `json:"id"`
|
||||
Description string `json:"description"`
|
||||
} `json:"coupons"`
|
||||
}
|
||||
Reference in New Issue
Block a user