currency

package
v0.15.0 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package currency 提供定义货币支付的相关功能

Index

Constants

This section is empty.

Variables

Functions

func ErrBalanceNotEnough

func ErrBalanceNotEnough() error

ErrBalanceNotEnough 余额不足

func TypeValidator

func TypeValidator(v Type) bool

Types

type Currency added in v0.13.0

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

func Install

func Install(mod *user.Users, id string) *Currency

Install 安装当前的环境

func New added in v0.13.0

func New(u *user.Users, id string) *Currency

New 声明 Currency

u 所属的模块; id 该货币的 ID;

func (*Currency) Add added in v0.13.0

func (m *Currency) Add(tx *orm.Tx, uid int64, val uint, memo string, expire time.Time) error

Add 添加金额

expire 如果不为空值,表示该积分在到达该时间还未被使用时,将不能再使用。

func (*Currency) Del added in v0.13.0

func (m *Currency) Del(tx *orm.Tx, uid int64, val uint, memo string) error

Del 减少金额

func (*Currency) Freeze added in v0.13.0

func (m *Currency) Freeze(tx *orm.Tx, u *user.User, val uint, memo string) error

Freeze 冻结资金

会过期的资金无法冻结

func (*Currency) GetLogs added in v0.13.0

func (m *Currency) GetLogs(u *user.User, q *LogQuery) (*query.Page[LogPO], error)

GetLogs 查询日志

func (*Currency) GetOverview added in v0.13.0

func (m *Currency) GetOverview(uid int64, expire time.Time) (*OverviewVO, error)

GetOverview 获取用户 u 的摘要信息

expire Expire 字段返回在此之前过期的积分,如果为空,则 Expire 不返回;

func (*Currency) GetOverviews added in v0.13.0

func (m *Currency) GetOverviews(q *query.Text) (*query.Page[OverviewsVO], error)

GetOverviews 获取所有用户的摘要信息

func (*Currency) Unfreeze added in v0.13.0

func (m *Currency) Unfreeze(tx *orm.Tx, u *user.User, val int64, memo string) error

type LogPO added in v0.7.11

type LogPO struct {
	ID  int64 `orm:"name(id);ai" json:"-" yaml:"-" cbor:"-"`
	UID int64 `orm:"name(uid)" json:"-" yaml:"-" cbor:"-"`

	Created time.Time `orm:"name(created)" json:"created" yaml:"created" cbor:"created"`
	Before  int64     `orm:"name(before)" json:"before" yaml:"before" cbor:"before" comment:"currency value before action"`
	After   int64     `orm:"name(after)" json:"after" yaml:"after" cbor:"after" comment:"currency value after action"`
	Value   int64     `orm:"name(value)" json:"value" yaml:"value" cbor:"value" comment:"add currency value"`
	Memo    string    `orm:"name(memo);len(1000)" json:"memo" yaml:"memo" cbor:"memo" comment:"memo of action"`
	Type    Type      `orm:"name(type);len(10)" json:"type" yaml:"type" cbor:"type" comment:"type of action"`
}

LogPO 货币花费明细

func (*LogPO) BeforeInsert added in v0.7.11

func (p *LogPO) BeforeInsert() error

func (*LogPO) TableName added in v0.7.11

func (p *LogPO) TableName() string

type LogQuery

type LogQuery struct {
	query.Text
	Types []Type `query:"type,normal"`
}

type OverviewExpireVO

type OverviewExpireVO struct {
	Value int64     `json:"value" yaml:"value" cbor:"value"`
	Date  time.Time `json:"date" yaml:"date" cbor:"date"`
}

type OverviewVO

type OverviewVO struct {
	Available int64               `json:"available" yaml:"available" cbor:"available"`
	Freeze    int64               `json:"freeze" yaml:"freeze" cbor:"freeze"`
	Used      int64               `json:"used" yaml:"used" cbor:"used"`
	Expire    []*OverviewExpireVO `json:"expire,omitempty" yaml:"expire,omitempty" cbor:"expire,omitempty"`
}

type OverviewsVO added in v0.7.11

type OverviewsVO struct {
	UID      int64  `json:"uid" yaml:"uid" cbor:"uid"`
	NO       string `json:"no" yaml:"no" cbor:"no"`
	Username string `json:"username" yaml:"username" cbor:"username"`

	Available int64 `json:"available" yaml:"available" cbor:"available"`
	Freeze    int64 `json:"freeze" yaml:"freeze" cbor:"freeze"`
	Used      int64 `json:"used" yaml:"used" cbor:"used"`
}

type Type

type Type int8

Type 日志类型

const (
	TypeNormal Type = iota
	TypeFreeze
	TypeUnfreeze
)

func ParseType

func ParseType(v string) (Type, error)

func (Type) IsValid

func (t Type) IsValid() bool

func (Type) MarshalCBOR added in v0.8.14

func (t Type) MarshalCBOR() ([]byte, error)

func (Type) MarshalText

func (t Type) MarshalText() ([]byte, error)

func (Type) OpenAPISchema

func (Type) OpenAPISchema(s *openapi.Schema)

func (Type) PrimitiveType

func (Type) PrimitiveType() core.PrimitiveType

func (*Type) Scan

func (t *Type) Scan(src any) error

Scan sql.Scanner

func (Type) String

func (t Type) String() string

String fmt.Stringer

func (*Type) UnmarshalCBOR added in v0.8.14

func (t *Type) UnmarshalCBOR(p []byte) error

func (*Type) UnmarshalText

func (t *Type) UnmarshalText(p []byte) error

func (Type) Value

func (t Type) Value() (driver.Value, error)

Value driver.Valuer

Jump to

Keyboard shortcuts

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