orderLogic

package
v1.2.4 Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2025 License: GPL-3.0 Imports: 22 Imported by: 0

Documentation

Overview

Package orderLogic provides order processing logic for handling various types of orders including subscription purchases, renewals, traffic resets, and balance recharges.

Index

Constants

View Source
const (
	OrderTypeSubscribe    = 1 // New subscription purchase
	OrderTypeRenewal      = 2 // Subscription renewal
	OrderTypeResetTraffic = 3 // Traffic quota reset
	OrderTypeRecharge     = 4 // Balance recharge
)

Order type constants define the different types of orders that can be processed

View Source
const (
	OrderStatusPending  = 1 // Order created but not paid
	OrderStatusPaid     = 2 // Order paid and ready for processing
	OrderStatusClose    = 3 // Order closed/cancelled
	OrderStatusFailed   = 4 // Order processing failed
	OrderStatusFinished = 5 // Order successfully completed
)

Order status constants define the lifecycle states of an order

Variables

View Source
var (
	ErrInvalidOrderStatus = fmt.Errorf("invalid order status")
	ErrInvalidOrderType   = fmt.Errorf("invalid order type")
)

Predefined error variables for common error conditions

Functions

This section is empty.

Types

type ActivateOrderLogic

type ActivateOrderLogic struct {
	// contains filtered or unexported fields
}

ActivateOrderLogic handles the activation and processing of paid orders

func NewActivateOrderLogic

func NewActivateOrderLogic(svc *svc.ServiceContext) *ActivateOrderLogic

NewActivateOrderLogic creates a new instance of ActivateOrderLogic

func (*ActivateOrderLogic) NewPurchase

func (l *ActivateOrderLogic) NewPurchase(ctx context.Context, orderInfo *order.Order) error

NewPurchase handles new subscription purchase including user creation, subscription setup, commission processing, cache updates, and notifications

func (*ActivateOrderLogic) ProcessTask

func (l *ActivateOrderLogic) ProcessTask(ctx context.Context, task *asynq.Task) error

ProcessTask is the main entry point for processing order activation tasks. It handles the complete workflow of activating a paid order including validation, processing based on order type, and finalization.

func (*ActivateOrderLogic) Recharge

func (l *ActivateOrderLogic) Recharge(ctx context.Context, orderInfo *order.Order) error

Recharge handles balance recharge orders including balance updates, transaction logging, and notifications

func (*ActivateOrderLogic) Renewal

func (l *ActivateOrderLogic) Renewal(ctx context.Context, orderInfo *order.Order) error

Renewal handles subscription renewal including subscription extension, traffic reset (if configured), commission processing, and notifications

func (*ActivateOrderLogic) ResetTraffic

func (l *ActivateOrderLogic) ResetTraffic(ctx context.Context, orderInfo *order.Order) error

ResetTraffic handles traffic quota reset for existing subscriptions

type DeferCloseOrderLogic

type DeferCloseOrderLogic struct {
	// contains filtered or unexported fields
}

func NewDeferCloseOrderLogic

func NewDeferCloseOrderLogic(svc *svc.ServiceContext) *DeferCloseOrderLogic

func (*DeferCloseOrderLogic) ProcessTask

func (l *DeferCloseOrderLogic) ProcessTask(ctx context.Context, task *asynq.Task) error

Jump to

Keyboard shortcuts

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