mirror of
https://github.com/Wei-Shaw/sub2api.git
synced 2026-11-21 15:09:21 +00:00
Replace iframe-based external payment with native implementation: Backend (Go): - 5 new Ent schemas: PaymentOrder, PaymentAuditLog, PaymentChannel, SubscriptionPlan, PaymentProviderInstance - 5 SQL migrations (090-094) - Payment provider interface + registry + load balancer - 4 provider implementations (EasyPay, Alipay, WxPay, Stripe) - PaymentService (order lifecycle, fulfillment, refund 3-phase) - PaymentConfigService (settings, instance/channel/plan CRUD) - 31 API endpoints (9 user + 4 webhook + 18 admin) - Wire DI integration Frontend (Vue3): - Payment types, API modules, store, router changes - Sidebar: payment_enabled controls visibility, new menu items - User pages: PaymentView (replace iframe), QR payment, Stripe, result page, order list - Admin pages: Order management (4 tabs), provider instance mgmt - Settings: new payment tab, removed old purchase iframe config - i18n: full payment namespace (en + zh) Docs: - PAYMENT_FRONTEND_MIGRATION_PLAN.md - PAYMENT_BACKEND_MIGRATION_PLAN.md - PAYMENT_IMPLEMENTATION_ROADMAP.md
224 lines
7.9 KiB
Go
224 lines
7.9 KiB
Go
// Code generated by ent, DO NOT EDIT.
|
|
|
|
package ent
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
"time"
|
|
|
|
"entgo.io/ent"
|
|
"entgo.io/ent/dialect/sql"
|
|
"github.com/Wei-Shaw/sub2api/ent/paymentchannel"
|
|
)
|
|
|
|
// PaymentChannel is the model entity for the PaymentChannel schema.
|
|
type PaymentChannel struct {
|
|
config `json:"-"`
|
|
// ID of the ent.
|
|
ID int64 `json:"id,omitempty"`
|
|
// GroupID holds the value of the "group_id" field.
|
|
GroupID *int64 `json:"group_id,omitempty"`
|
|
// Name holds the value of the "name" field.
|
|
Name string `json:"name,omitempty"`
|
|
// Platform holds the value of the "platform" field.
|
|
Platform string `json:"platform,omitempty"`
|
|
// RateMultiplier holds the value of the "rate_multiplier" field.
|
|
RateMultiplier float64 `json:"rate_multiplier,omitempty"`
|
|
// Description holds the value of the "description" field.
|
|
Description string `json:"description,omitempty"`
|
|
// Models holds the value of the "models" field.
|
|
Models string `json:"models,omitempty"`
|
|
// Features holds the value of the "features" field.
|
|
Features string `json:"features,omitempty"`
|
|
// SortOrder holds the value of the "sort_order" field.
|
|
SortOrder int `json:"sort_order,omitempty"`
|
|
// Enabled holds the value of the "enabled" field.
|
|
Enabled bool `json:"enabled,omitempty"`
|
|
// CreatedAt holds the value of the "created_at" field.
|
|
CreatedAt time.Time `json:"created_at,omitempty"`
|
|
// UpdatedAt holds the value of the "updated_at" field.
|
|
UpdatedAt time.Time `json:"updated_at,omitempty"`
|
|
selectValues sql.SelectValues
|
|
}
|
|
|
|
// scanValues returns the types for scanning values from sql.Rows.
|
|
func (*PaymentChannel) scanValues(columns []string) ([]any, error) {
|
|
values := make([]any, len(columns))
|
|
for i := range columns {
|
|
switch columns[i] {
|
|
case paymentchannel.FieldEnabled:
|
|
values[i] = new(sql.NullBool)
|
|
case paymentchannel.FieldRateMultiplier:
|
|
values[i] = new(sql.NullFloat64)
|
|
case paymentchannel.FieldID, paymentchannel.FieldGroupID, paymentchannel.FieldSortOrder:
|
|
values[i] = new(sql.NullInt64)
|
|
case paymentchannel.FieldName, paymentchannel.FieldPlatform, paymentchannel.FieldDescription, paymentchannel.FieldModels, paymentchannel.FieldFeatures:
|
|
values[i] = new(sql.NullString)
|
|
case paymentchannel.FieldCreatedAt, paymentchannel.FieldUpdatedAt:
|
|
values[i] = new(sql.NullTime)
|
|
default:
|
|
values[i] = new(sql.UnknownType)
|
|
}
|
|
}
|
|
return values, nil
|
|
}
|
|
|
|
// assignValues assigns the values that were returned from sql.Rows (after scanning)
|
|
// to the PaymentChannel fields.
|
|
func (_m *PaymentChannel) assignValues(columns []string, values []any) error {
|
|
if m, n := len(values), len(columns); m < n {
|
|
return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
|
|
}
|
|
for i := range columns {
|
|
switch columns[i] {
|
|
case paymentchannel.FieldID:
|
|
value, ok := values[i].(*sql.NullInt64)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field id", value)
|
|
}
|
|
_m.ID = int64(value.Int64)
|
|
case paymentchannel.FieldGroupID:
|
|
if value, ok := values[i].(*sql.NullInt64); !ok {
|
|
return fmt.Errorf("unexpected type %T for field group_id", values[i])
|
|
} else if value.Valid {
|
|
_m.GroupID = new(int64)
|
|
*_m.GroupID = value.Int64
|
|
}
|
|
case paymentchannel.FieldName:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field name", values[i])
|
|
} else if value.Valid {
|
|
_m.Name = value.String
|
|
}
|
|
case paymentchannel.FieldPlatform:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field platform", values[i])
|
|
} else if value.Valid {
|
|
_m.Platform = value.String
|
|
}
|
|
case paymentchannel.FieldRateMultiplier:
|
|
if value, ok := values[i].(*sql.NullFloat64); !ok {
|
|
return fmt.Errorf("unexpected type %T for field rate_multiplier", values[i])
|
|
} else if value.Valid {
|
|
_m.RateMultiplier = value.Float64
|
|
}
|
|
case paymentchannel.FieldDescription:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field description", values[i])
|
|
} else if value.Valid {
|
|
_m.Description = value.String
|
|
}
|
|
case paymentchannel.FieldModels:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field models", values[i])
|
|
} else if value.Valid {
|
|
_m.Models = value.String
|
|
}
|
|
case paymentchannel.FieldFeatures:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field features", values[i])
|
|
} else if value.Valid {
|
|
_m.Features = value.String
|
|
}
|
|
case paymentchannel.FieldSortOrder:
|
|
if value, ok := values[i].(*sql.NullInt64); !ok {
|
|
return fmt.Errorf("unexpected type %T for field sort_order", values[i])
|
|
} else if value.Valid {
|
|
_m.SortOrder = int(value.Int64)
|
|
}
|
|
case paymentchannel.FieldEnabled:
|
|
if value, ok := values[i].(*sql.NullBool); !ok {
|
|
return fmt.Errorf("unexpected type %T for field enabled", values[i])
|
|
} else if value.Valid {
|
|
_m.Enabled = value.Bool
|
|
}
|
|
case paymentchannel.FieldCreatedAt:
|
|
if value, ok := values[i].(*sql.NullTime); !ok {
|
|
return fmt.Errorf("unexpected type %T for field created_at", values[i])
|
|
} else if value.Valid {
|
|
_m.CreatedAt = value.Time
|
|
}
|
|
case paymentchannel.FieldUpdatedAt:
|
|
if value, ok := values[i].(*sql.NullTime); !ok {
|
|
return fmt.Errorf("unexpected type %T for field updated_at", values[i])
|
|
} else if value.Valid {
|
|
_m.UpdatedAt = value.Time
|
|
}
|
|
default:
|
|
_m.selectValues.Set(columns[i], values[i])
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// Value returns the ent.Value that was dynamically selected and assigned to the PaymentChannel.
|
|
// This includes values selected through modifiers, order, etc.
|
|
func (_m *PaymentChannel) Value(name string) (ent.Value, error) {
|
|
return _m.selectValues.Get(name)
|
|
}
|
|
|
|
// Update returns a builder for updating this PaymentChannel.
|
|
// Note that you need to call PaymentChannel.Unwrap() before calling this method if this PaymentChannel
|
|
// was returned from a transaction, and the transaction was committed or rolled back.
|
|
func (_m *PaymentChannel) Update() *PaymentChannelUpdateOne {
|
|
return NewPaymentChannelClient(_m.config).UpdateOne(_m)
|
|
}
|
|
|
|
// Unwrap unwraps the PaymentChannel entity that was returned from a transaction after it was closed,
|
|
// so that all future queries will be executed through the driver which created the transaction.
|
|
func (_m *PaymentChannel) Unwrap() *PaymentChannel {
|
|
_tx, ok := _m.config.driver.(*txDriver)
|
|
if !ok {
|
|
panic("ent: PaymentChannel is not a transactional entity")
|
|
}
|
|
_m.config.driver = _tx.drv
|
|
return _m
|
|
}
|
|
|
|
// String implements the fmt.Stringer.
|
|
func (_m *PaymentChannel) String() string {
|
|
var builder strings.Builder
|
|
builder.WriteString("PaymentChannel(")
|
|
builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID))
|
|
if v := _m.GroupID; v != nil {
|
|
builder.WriteString("group_id=")
|
|
builder.WriteString(fmt.Sprintf("%v", *v))
|
|
}
|
|
builder.WriteString(", ")
|
|
builder.WriteString("name=")
|
|
builder.WriteString(_m.Name)
|
|
builder.WriteString(", ")
|
|
builder.WriteString("platform=")
|
|
builder.WriteString(_m.Platform)
|
|
builder.WriteString(", ")
|
|
builder.WriteString("rate_multiplier=")
|
|
builder.WriteString(fmt.Sprintf("%v", _m.RateMultiplier))
|
|
builder.WriteString(", ")
|
|
builder.WriteString("description=")
|
|
builder.WriteString(_m.Description)
|
|
builder.WriteString(", ")
|
|
builder.WriteString("models=")
|
|
builder.WriteString(_m.Models)
|
|
builder.WriteString(", ")
|
|
builder.WriteString("features=")
|
|
builder.WriteString(_m.Features)
|
|
builder.WriteString(", ")
|
|
builder.WriteString("sort_order=")
|
|
builder.WriteString(fmt.Sprintf("%v", _m.SortOrder))
|
|
builder.WriteString(", ")
|
|
builder.WriteString("enabled=")
|
|
builder.WriteString(fmt.Sprintf("%v", _m.Enabled))
|
|
builder.WriteString(", ")
|
|
builder.WriteString("created_at=")
|
|
builder.WriteString(_m.CreatedAt.Format(time.ANSIC))
|
|
builder.WriteString(", ")
|
|
builder.WriteString("updated_at=")
|
|
builder.WriteString(_m.UpdatedAt.Format(time.ANSIC))
|
|
builder.WriteByte(')')
|
|
return builder.String()
|
|
}
|
|
|
|
// PaymentChannels is a parsable slice of PaymentChannel.
|
|
type PaymentChannels []*PaymentChannel
|