Documentation
¶
Index ¶
- Constants
- Variables
- type CloseOrderLogic
- type PreCreateOrderLogic
- type PurchaseLogic
- type QueryOrderDetailLogic
- type QueryOrderListLogic
- type RechargeLogic
- type RenewalLogic
- type ResetTrafficLogic
- type V2OrderLogic
- func (l *V2OrderLogic) AuthorizeEventTicket(orderNo, ticket string) (*orderEntity.Order, error)
- func (l *V2OrderLogic) Checkout(orderNo string, req *dto.V2CheckoutOrderRequest) (*dto.V2OrderResponse, error)
- func (l *V2OrderLogic) CreateAndCheckout(req *dto.V2CreateOrderRequest, idempotencyKey string) (*dto.V2OrderResponse, error)
- func (l *V2OrderLogic) EventTicket(orderNo, checkoutToken string) (*dto.V2EventTicketResponse, error)
- func (l *V2OrderLogic) EventTicketExpiresAt(ticket string) (time.Time, error)
- func (l *V2OrderLogic) GetOrder(orderNo, checkoutToken string) (*dto.V2OrderResponse, error)
- func (l *V2OrderLogic) Session(orderNo, checkoutToken string) (*dto.V2OrderSessionResponse, error)
- func (l *V2OrderLogic) Snapshot(orderInfo *orderEntity.Order) dto.V2OrderSnapshot
Constants ¶
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 )
const (
CloseOrderTimeMinutes = 15
)
Variables ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
func NewResetTrafficLogic ¶
func NewResetTrafficLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ResetTrafficLogic
Reset traffic
func (*ResetTrafficLogic) ResetTraffic ¶
func (l *ResetTrafficLogic) ResetTraffic(req *dto.ResetTrafficOrderRequest) (resp *dto.ResetTrafficOrderResponse, err error)
type V2OrderLogic ¶ added in v1.14.19
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.