currency

package
v0.8.2 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 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 TypeValidator

func TypeValidator(v Type) bool

Types

type LogPO added in v0.7.11

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

	Created time.Time `orm:"name(created)" json:"created" yaml:"created" xml:"created" cbor:"created"`
	Before  int64     `orm:"name(before)" json:"before" yaml:"before" xml:"before" cbor:"before" comment:"currency value before action"`
	After   int64     `orm:"name(after)" json:"after" yaml:"after" xml:"after" cbor:"after" comment:"currency value after action"`
	Value   int64     `orm:"name(value)" json:"value" yaml:"value" xml:"value" cbor:"value" comment:"add currency value"`
	Memo    string    `orm:"name(memo);len(1000)" json:"memo" yaml:"memo" xml:"memo" cbor:"memo" comment:"memo of action"`
	Type    Type      `orm:"name(type);len(10)" json:"type" yaml:"type" xml:"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 Module

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

func Install

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

Install 安装当前的环境

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 uint, 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) GetOverview added in v0.7.11

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

GetOverview 获取用户 u 的摘要信息

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

func (*Module) GetOverviews added in v0.7.11

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

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

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 OverviewsVO added in v0.7.11

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

	UID      int64  `json:"uid" yaml:"uid" cbor:"uid" xml:"uid"`
	NO       string `json:"no" yaml:"no" cbor:"no" xml:"no"`
	Username string `json:"username" yaml:"username" cbor:"username" xml:"username"`

	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"`
}

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