order

package
v1.14.21 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 24, 2026 License: GPL-3.0 Imports: 37 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Epay            = "epay"
	AlipayF2f       = "alipay_f2f"
	StripeAlipay    = "stripe_alipay"
	StripeWeChatPay = "stripe_wechat_pay"
	Balance         = "balance"

	// MaxOrderAmount Order amount limits
	MaxOrderAmount    = 2147483647 // int32 max value (2.1 billion)
	MaxRechargeAmount = 2000000000 // 2 billion, slightly lower for safety
	MinRechargeAmount = 100        // minimum recharge amount in minor currency units
	MaxQuantity       = 1000       // Maximum quantity per order
)
View Source
const (
	CloseOrderTimeMinutes = 15
)

Variables

View Source
var ErrIdempotencyKeyReused = stdErrors.New("idempotency key reused with a different request")

ErrIdempotencyKeyReused is handled as HTTP 409 by the V2 handler. It is a distinct transport condition: the original order remains intact.

Functions

This section is empty.

Types

type CloseOrderLogic

type CloseOrderLogic struct {
	logger.Logger
	// contains filtered or unexported fields
}

func NewCloseOrderLogic

func NewCloseOrderLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CloseOrderLogic

NewCloseOrderLogic Close order

func (*CloseOrderLogic) CloseOrder

func (l *CloseOrderLogic) CloseOrder(req *dto.CloseOrderRequest) error

type PreCreateOrderLogic

type PreCreateOrderLogic struct {
	logger.Logger
	// contains filtered or unexported fields
}

func NewPreCreateOrderLogic

func NewPreCreateOrderLogic(ctx context.Context, svcCtx *svc.ServiceContext) *PreCreateOrderLogic

NewPreCreateOrderLogic creates a new pre-create order logic instance for order preview operations. It initializes the logger with context and sets up the service context for database operations.

func (*PreCreateOrderLogic) PreCreateOrder

func (l *PreCreateOrderLogic) PreCreateOrder(req *dto.PurchaseOrderRequest) (resp *dto.PreOrderResponse, err error)

PreCreateOrder calculates order pricing preview including discounts, coupons, gift amounts, and fees without actually creating an order. It validates subscription plans, coupons, and payment methods to provide accurate pricing information for the frontend order preview.

type PurchaseLogic

type PurchaseLogic struct {
	logger.Logger
	// contains filtered or unexported fields
}

func NewPurchaseLogic

func NewPurchaseLogic(ctx context.Context, svcCtx *svc.ServiceContext) *PurchaseLogic

NewPurchaseLogic creates a new purchase logic instance for subscription purchase operations. It initializes the logger with context and sets up the service context for database operations.

func (*PurchaseLogic) Purchase

func (l *PurchaseLogic) Purchase(req *dto.PurchaseOrderRequest) (resp *dto.PurchaseOrderResponse, err error)

Purchase processes new subscription purchase orders including validation, discount calculation, coupon processing, gift amount deduction, fee calculation, and order creation with database transaction. It handles the complete purchase workflow from user validation to order creation and task scheduling.

type QueryOrderDetailLogic

type QueryOrderDetailLogic struct {
	logger.Logger
	// contains filtered or unexported fields
}

func NewQueryOrderDetailLogic

func NewQueryOrderDetailLogic(ctx context.Context, svcCtx *svc.ServiceContext) *QueryOrderDetailLogic

Get order

func (*QueryOrderDetailLogic) QueryOrderDetail

func (l *QueryOrderDetailLogic) QueryOrderDetail(req *dto.QueryOrderDetailRequest) (resp *dto.OrderDetail, err error)

type QueryOrderListLogic

type QueryOrderListLogic struct {
	logger.Logger
	// contains filtered or unexported fields
}

func NewQueryOrderListLogic

func NewQueryOrderListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *QueryOrderListLogic

Get order list

func (*QueryOrderListLogic) QueryOrderList

func (l *QueryOrderListLogic) QueryOrderList(req *dto.QueryOrderListRequest) (resp *dto.QueryOrderListResponse, err error)

type RechargeLogic

type RechargeLogic struct {
	logger.Logger
	// contains filtered or unexported fields
}

func NewRechargeLogic

func NewRechargeLogic(ctx context.Context, svcCtx *svc.ServiceContext) *RechargeLogic

Recharge

func (*RechargeLogic) Recharge

func (l *RechargeLogic) Recharge(req *dto.RechargeOrderRequest) (resp *dto.RechargeOrderResponse, err error)

type RenewalLogic

type RenewalLogic struct {
	logger.Logger
	// contains filtered or unexported fields
}

func NewRenewalLogic

func NewRenewalLogic(ctx context.Context, svcCtx *svc.ServiceContext) *RenewalLogic

NewRenewalLogic creates a new renewal logic instance for subscription renewal operations

func (*RenewalLogic) Renewal

func (l *RenewalLogic) Renewal(req *dto.RenewalOrderRequest) (resp *dto.RenewalOrderResponse, err error)

Renewal processes subscription renewal orders including discount calculation, coupon validation, gift amount deduction, fee calculation, and order creation

type ResetTrafficLogic

type ResetTrafficLogic struct {
	logger.Logger
	// contains filtered or unexported fields
}

func NewResetTrafficLogic

func NewResetTrafficLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ResetTrafficLogic

Reset traffic

func (*ResetTrafficLogic) ResetTraffic

type V2OrderLogic added in v1.14.19

type V2OrderLogic struct {
	logger.Logger
	// contains filtered or unexported fields
}

func NewV2OrderLogic added in v1.14.19

func NewV2OrderLogic(ctx context.Context, svcCtx *svc.ServiceContext) *V2OrderLogic

func (*V2OrderLogic) AuthorizeEventTicket added in v1.14.19

func (l *V2OrderLogic) AuthorizeEventTicket(orderNo, ticket string) (*orderEntity.Order, error)

AuthorizeEventTicket validates the self-contained stream capability against the current order row. It deliberately does not require a long-lived bearer token in the EventSource URL.

func (*V2OrderLogic) Checkout added in v1.14.19

func (l *V2OrderLogic) Checkout(orderNo string, req *dto.V2CheckoutOrderRequest) (*dto.V2OrderResponse, error)

func (*V2OrderLogic) CreateAndCheckout added in v1.14.19

func (l *V2OrderLogic) CreateAndCheckout(req *dto.V2CreateOrderRequest, idempotencyKey string) (*dto.V2OrderResponse, error)

CreateAndCheckout is the V2 orchestration boundary. Existing domain creators still own pricing, inventory and coupon policy; this method only gives them an idempotency context and immediately starts checkout.

func (*V2OrderLogic) EventTicket added in v1.14.19

func (l *V2OrderLogic) EventTicket(orderNo, checkoutToken string) (*dto.V2EventTicketResponse, error)

func (*V2OrderLogic) EventTicketExpiresAt added in v1.14.19

func (l *V2OrderLogic) EventTicketExpiresAt(ticket string) (time.Time, error)

func (*V2OrderLogic) GetOrder added in v1.14.19

func (l *V2OrderLogic) GetOrder(orderNo, checkoutToken string) (*dto.V2OrderResponse, error)

func (*V2OrderLogic) Session added in v1.14.19

func (l *V2OrderLogic) Session(orderNo, checkoutToken string) (*dto.V2OrderSessionResponse, error)

Session exchanges the durable guest checkout capability for an ordinary session after activation has created the account. It is intentionally a separate JSON endpoint: a long-lived access token must never appear in a browser-visible EventSource URL or SSE event payload.

func (*V2OrderLogic) Snapshot added in v1.14.19

func (l *V2OrderLogic) Snapshot(orderInfo *orderEntity.Order) dto.V2OrderSnapshot

Snapshot exposes the event-stream's current-state payload without granting access by itself; callers must authorize the ticket before using it.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL