xintegral

package
v0.3.8 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: BSD-3-Clause-Clear Imports: 8 Imported by: 0

Documentation

Overview

用户积分模块

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateHistory

func CreateHistory(id uint, bal int, desc string, call bool) error

创建积分变动信息

id		积分账户ID
bal		变动金额
desc	变动描述
call	是否回写主账户

func CreateHistoryTime added in v0.0.19

func CreateHistoryTime(id uint, bal int, desc string, call bool, endT time.Duration) error

创建积分变动信息

id		积分账户ID
bal		变动金额
desc	变动描述
call	是否回写主账户
endT	结束时间【time.xxx * xxx的形式,此处使用 time.Now().Add().Format()进行存储】
endT参数描述:
0		表示参照默认
-1		表示永久有效(默认有效期到2099-12-31年)
1~11	表示往后x月有效(含11)
12~20	表示往后x-11年有效(含20)

func CreateIntegral

func CreateIntegral(c *Integral) error

创建/修改积分信息

c	积分主表存储的信息

func CreateType added in v0.0.21

func CreateType(c *IntegralType) error

创建/修改积分隔离类信息

c	积分隔离分类存储的信息

func Cron

func Cron()

定时脚本,由外部挂载程序进行调用,用于重置积分中的即将过期的积分

func Regedit

func Regedit(c *Config)

入口配置

Types

type Config

type Config struct {
	DB                      *gorm.DB
	IntegralName            string // 积分主表名称
	IntegralHistoryName     string // 积分明细名称
	IntegralTypeName        string // 积分隔离表表名,用于隔离自身积分或者群积分、VIP积分等
	HookIntegralEdit        string // 积分变动后的通知钩子【NSQ队列通知,此处填写NSQ的路由下标,空表示不推送,推送数据格式:<Integral>】
	HookIntegralHistoryEdit string // 积分明细记录后的通知钩子【NSQ队列通知,此处填写NSQ的路由下标,空表示不推送,推送数据格式:<IntegralHistory>】
}

配置项

type Integral

type Integral struct {
	Id     uint `gorm:"column:id;primaryKey;not null;autoIncrement" json:"id" form:"id"` // 条目ID
	UserId uint `gorm:"column:user_id;comment:用户ID" json:"user_id" form:"user_id"`       // 用户ID
	TypeId uint ``                                                                       // 积分隔离ID
	/* 131-byte string literal not displayed */
	Name string `gorm:"column:name;type:VARCHAR(50);comment:积分名称" json:"name" form:"name"`  // 积分名称
	Desc string `gorm:"column:desc;type:VARCHAR(200);comment:积分详情" json:"desc" form:"desc"` // 积分详情
	Type uint   ``                                                                          // 积分类型 1-每一条有单独的有效期 2-固定期限 3-无限期 4-x年后的固定月、日有效期
	/* 182-byte string literal not displayed */
	Balance       uint   `gorm:"column:balance;comment:积分余额" json:"balance" form:"balance"`                                        // 积分余额
	ExpireBalance uint   `gorm:"column:expire_balance;comment:即将过期积分【3天内最近的】" json:"expire_balance" form:"expire_balance"`         // 即将过期积分【3天内最近的】
	ExpireDays    uint   `gorm:"column:expire_days;comment:默认过期时间【type=1-天 type=4-年】" json:"expire_days" form:"expire_days"`       // 默认过期时间【type=1-天 type=4-年】
	IsDeleted     uint8  `gorm:"column:is_deleted;type:TINYINT UNSIGNED;comment:是否删除 0-否 1-是" json:"is_deleted" form:"is_deleted"` // 是否删除 0-否 1-是
	EndDate       string `gorm:"column:end_date;type:DATE;comment:过期时间【2-统一有效期 4-x月x日有效】" json:"end_date" form:"end_date"`         // 过期时间【2-统一有效期 4-x月x日有效】
	CreatedAt     string `gorm:"column:created_at;type:DATETIME;comment:创建时间" json:"created_at" form:"created_at"`                 // 创建时间
	UpdatedAt     string `gorm:"column:updated_at;type:DATETIME;comment:更新时间" json:"updated_at" form:"updated_at"`                 // 更新时间
}

积分主表

func Info

func Info(id uint) (*Integral, error)

获取积分详情信息

id	积分条目ID

func List

func List(uid, typ uint) ([]Integral, error)

获取积分账户列表

uid	用户ID
typ	积分类型

func (*Integral) TableName

func (c *Integral) TableName() string

获取表名

type IntegralHistory

type IntegralHistory struct {
	Id         uint   `gorm:"column:id;primaryKey;not null;autoIncrement" json:"id" form:"id"`                  // 条目ID
	IntegralId uint   `gorm:"column:integral_id;comment:积分ID" json:"integral_id" form:"integral_id"`            // 积分ID
	Balance    int    `gorm:"column:balance;type:INT;comment:积分变动金额" json:"balance" form:"balance"`             // 积分变动金额
	EndDate    string `gorm:"column:end_date;type:DATE;comment:过期时间" json:"end_date" form:"end_date"`           // 过期时间
	EndBalance uint   `gorm:"column:end_balance;comment:剩余未使用积分" json:"end_balance" form:"end_balance"`         // 剩余未使用积分
	Desc       string `gorm:"column:desc;type:VARCHAR(200);comment:积分变动描述" json:"desc" form:"desc"`             // 积分变动描述
	CreatedAt  string `gorm:"column:created_at;type:DATETIME;comment:创建时间" json:"created_at" form:"created_at"` // 创建时间
}

积分明细表

func ListHistory added in v0.1.9

func ListHistory(integral_id uint, offset, limit int) (int64, []IntegralHistory, error)

func (*IntegralHistory) TableName

func (c *IntegralHistory) TableName() string

获取表名

type IntegralType added in v0.0.21

type IntegralType struct {
	Id        uint   `gorm:"column:id;primaryKey;not null;autoIncrement" json:"id" form:"id"`                  // 条目ID
	Name      string `gorm:"column:name;type:VARCHAR(50);comment:积分名称" json:"name" form:"name"`                // 隔离类型名称
	Desc      string `gorm:"column:desc;type:VARCHAR(200);comment:积分详情" json:"desc" form:"desc"`               // 隔离类型详情
	FileId    uint   `gorm:"column:file_id;comment:文件ID" json:"file_id" form:"file_id"`                        // 所属文件ID
	UserId    uint   `gorm:"column:user_id;comment:用户ID" json:"user_id" form:"user_id"`                        // 创建人ID
	CreatedAt string `gorm:"column:created_at;type:DATETIME;comment:创建时间" json:"created_at" form:"created_at"` // 创建时间
	UpdatedAt string `gorm:"column:updated_at;type:DATETIME;comment:更新时间" json:"updated_at" form:"updated_at"` // 更新时间
}

积分隔离备注表

func InfoType added in v0.0.21

func InfoType(id uint) (*IntegralType, error)

获取积分隔离详情信息

id	积分隔离条目ID

func ListType added in v0.1.9

func ListType(uid uint) ([]IntegralType, error)

积分分类表

uid	用户ID

func (*IntegralType) TableName added in v0.0.21

func (c *IntegralType) TableName() string

获取表名

Jump to

Keyboard shortcuts

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