currency

package
v0.7.9 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

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

Index

Constants

This section is empty.

Variables

Functions

func ErrBalanceNotEnough

func ErrBalanceNotEnough() error

ErrBalanceNotEnough 余额不足

func Install

func Install(mod *user.Module, id string)

Install 安装当前的环境

func TypeValidator

func TypeValidator(v Type) bool

Types

type LogQuery

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

type Module

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

func Load

func Load(u *user.Module, id string) *Module

Load 加载模块

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

func (*Module) Add

func (m *Module) Add(tx *orm.Tx, u *user.User, val uint, memo string, expire time.Time) error

Add 添加金额

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

func (*Module) Del

func (m *Module) Del(tx *orm.Tx, u *user.User, val uint64, memo string) error

Del 减少金额

func (*Module) Freeze

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

Freeze 冻结资金

会过期的资金无法冻结

func (*Module) GetLogs

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

GetLogs 查询日志

func (*Module) GetUserOverview

func (m *Module) GetUserOverview(u *user.User, expire time.Time) (*OverviewVO, error)

GetUserOverview 获取用户 u 的摘要信息

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

func (*Module) Unfreeze

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

type OverviewExpireVO

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

type OverviewVO

type OverviewVO struct {
	XMLName struct{} `json:"-" yaml:"-" cbor:"-" xml:"overview"`

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

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) MarshalText

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

MarshalText encoding.TextMarshaler

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) UnmarshalText

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

UnmarshalText encoding.TextUnmarshaler

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