order

package
v1.20.3 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2026 License: GPL-3.0 Imports: 19 Imported by: 0

Documentation

Overview

Package order contains task adapters for the billing workflow.

Index

Constants

View Source
const (
	OrderTypeSubscribe    = 1
	OrderTypeRenewal      = 2
	OrderTypeResetTraffic = 3
	OrderTypeRecharge     = 4
	OrderStatusPending    = 1
	OrderStatusPaid       = 2
	OrderStatusClose      = 3
	OrderStatusFailed     = 4
	OrderStatusFinished   = 5
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ActivateOrderLogic

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

func NewActivateOrderLogic

func NewActivateOrderLogic(activator PaidOrderActivator) *ActivateOrderLogic

func (*ActivateOrderLogic) ProcessTask

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

type CleanupOrderEventsLogic

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

CleanupOrderEventsLogic removes only events that have already reached Redis and are older than the replay contract. Unpublished events are never deleted, even if an outage lasts longer than the normal retention period.

func NewCleanupOrderEventsLogic

func NewCleanupOrderEventsLogic(deps Dependencies) *CleanupOrderEventsLogic

func (*CleanupOrderEventsLogic) ProcessTask

func (l *CleanupOrderEventsLogic) ProcessTask(ctx context.Context, _ *asynq.Task) error

type DailyOrderReportLogic

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

DailyOrderReportLogic posts the previous day's settlement summary into the admin group's notification topic. It reports yesterday because it runs after midnight, when the day it summarises is complete.

func NewDailyOrderReportLogic

func NewDailyOrderReportLogic(deps Dependencies) *DailyOrderReportLogic

func (*DailyOrderReportLogic) ProcessTask

func (l *DailyOrderReportLogic) ProcessTask(ctx context.Context, _ *asynq.Task) error

type DeferCloseOrderLogic

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

func NewDeferCloseOrderLogic

func NewDeferCloseOrderLogic(deps Dependencies) *DeferCloseOrderLogic

func (*DeferCloseOrderLogic) ProcessTask

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

type Dependencies

type Dependencies struct {
	Store        repository.Store
	Redis        *redis.Client
	Queue        *taskqueue.Client
	Inspector    *asynq.Inspector
	Billing      billing.Service
	Subscription subscription.Service
	Notification notification.Service
	Telegram     func() config.Telegram
}

type PaidOrderActivator

type PaidOrderActivator interface {
	ActivatePaidOrder(context.Context, string) error
}

type PublishOrderEventsLogic

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

PublishOrderEventsLogic drains the durable order event outbox. Publishing is intentionally separate from writing the event: a Redis outage may delay a notification but can never roll back a committed payment state.

func NewPublishOrderEventsLogic

func NewPublishOrderEventsLogic(deps Dependencies) *PublishOrderEventsLogic

func (*PublishOrderEventsLogic) ProcessTask

func (l *PublishOrderEventsLogic) ProcessTask(ctx context.Context, _ *asynq.Task) error

type ReconcilePaidOrdersLogic

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

ReconcilePaidOrdersLogic treats the durable Paid state as an activation outbox. It repairs the database/Redis gap if a callback committed payment but Redis was unavailable before the activation task could be inserted.

func NewReconcilePaidOrdersLogic

func NewReconcilePaidOrdersLogic(deps Dependencies) *ReconcilePaidOrdersLogic

func (*ReconcilePaidOrdersLogic) ProcessTask

func (l *ReconcilePaidOrdersLogic) ProcessTask(ctx context.Context, _ *asynq.Task) error

type ReconcilePendingOrdersLogic

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

ReconcilePendingOrdersLogic is a durable fallback for deferred close tasks. State transitions in CloseOrder remain conditional, so a late callback can safely race this scan without turning a paid order back into a close order.

func NewReconcilePendingOrdersLogic

func NewReconcilePendingOrdersLogic(deps Dependencies) *ReconcilePendingOrdersLogic

func (*ReconcilePendingOrdersLogic) ProcessTask

func (l *ReconcilePendingOrdersLogic) ProcessTask(ctx context.Context, _ *asynq.Task) error

Jump to

Keyboard shortcuts

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