ledger

package
v1.21.4 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2026 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Overview

Package ledger writes the wallet movement records of the billing module: every gift-credit and balance change an order makes is recorded here, with the same shape, timestamp and remark vocabulary. Callers pass the transaction-scoped log repository so a record commits with the movement it describes.

Index

Constants

View Source
const (
	RemarkPurchaseDeduction     = "Purchase order deduction"
	RemarkRenewalDeduction      = "Renewal order deduction"
	RemarkResetTrafficDeduction = "Reset traffic order deduction"
	RemarkBalancePayment        = "Purchase payment"
	RemarkCancellationRefund    = "Order cancellation refund"
)

Remarks of gift-credit movements, shown to administrators in the gift log.

Variables

This section is empty.

Functions

func PayWithBalance

func PayWithBalance(ctx context.Context, logs LogWriter, entry Balance) error

PayWithBalance records balance spent to pay an order.

func Recharge

func Recharge(ctx context.Context, logs LogWriter, entry Balance) error

Recharge records balance credited by a recharge order.

func RefundGift

func RefundGift(ctx context.Context, logs LogWriter, entry Gift) error

RefundGift records gift credit returned to the wallet by an order.

func SpendGift

func SpendGift(ctx context.Context, logs LogWriter, entry Gift) error

SpendGift records gift credit an order consumed.

Types

type Balance

type Balance struct {
	UserID  int64
	OrderNo string
	// Amount is the balance moved; Balance is the balance afterwards.
	Amount  int64
	Balance int64
}

Balance describes a balance movement of one wallet for an order.

type Gift

type Gift struct {
	UserID  int64
	OrderNo string
	// Amount is the credit moved; Balance is the gift balance afterwards.
	Amount  int64
	Balance int64
	Remark  string
}

Gift describes a gift-credit movement of one wallet for an order.

type LogWriter

type LogWriter interface {
	Insert(ctx context.Context, data *logEntity.SystemLog) error
}

LogWriter appends audit records; the platform log repository satisfies it.

Jump to

Keyboard shortcuts

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