model

package
v0.0.0-...-3414fa2 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2025 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = sqlx.ErrNotFound

Functions

This section is empty.

Types

type Coupons

type Coupons struct {
	Id        uint64       `db:"id"`         // 优惠券ID
	Name      string       `db:"name"`       // 优惠券�称
	Code      string       `db:"code"`       // 优惠券�
	Type      int64        `db:"type"`       // 优惠券类型 1:满� 2:折扣 3:立�
	Value     float64      `db:"value"`      // 优惠金�或折扣率
	MinAmount float64      `db:"min_amount"` // 最低使用金�
	Status    int64        `db:"status"`     // 状� 0:未开始 1:进行中 2:已结� 3:已失效
	StartTime sql.NullTime `db:"start_time"` // 开始时间
	EndTime   sql.NullTime `db:"end_time"`   // 结�时间
	Total     int64        `db:"total"`      // �行总�
	Received  int64        `db:"received"`   // 已领�数�
	Used      int64        `db:"used"`       // 已使用数�
	PerLimit  int64        `db:"per_limit"`  // 是��制�人领�数�
	UserLimit int64        `db:"user_limit"` // �人�领数�
	CreatedAt time.Time    `db:"created_at"` // 创建时间
	UpdatedAt time.Time    `db:"updated_at"` // 更新时间
}

type CouponsModel

type CouponsModel interface {
	Trans(ctx context.Context, fn func(context.Context, sqlx.Session) error) error
	Lock(ctx context.Context, session sqlx.Session, id uint64) error
	Unlock(ctx context.Context, session sqlx.Session, id uint64) error
	IncrReceived(ctx context.Context, id uint64) error
	DecrReceived(ctx context.Context, id uint64) error
	IncrUsed(ctx context.Context, id uint64) error
	FindMany(ctx context.Context, status int32, page, pageSize int32) ([]*Coupons, error)
	Count(ctx context.Context, status int32) (int64, error)
	FindManyByIds(ctx context.Context, ids []uint64) (map[uint64]*Coupons, error)
	// contains filtered or unexported methods
}

CouponsModel is an interface to be customized

func NewCouponsModel

func NewCouponsModel(conn sqlx.SqlConn, c cache.CacheConf, opts ...cache.Option) CouponsModel

NewCouponsModel returns a model for the database table.

type PointsRecords

type PointsRecords struct {
	Id        uint64         `db:"id"`         // 记录ID
	UserId    uint64         `db:"user_id"`    // 用户ID
	Points    int64          `db:"points"`     // 积分�动数�
	Type      int64          `db:"type"`       // 类型 1:获� 2:使用
	Source    string         `db:"source"`     // ��
	Remark    sql.NullString `db:"remark"`     // 备注
	OrderNo   sql.NullString `db:"order_no"`   // 订��
	CreatedAt time.Time      `db:"created_at"` // 创建时间
}

type PointsRecordsModel

type PointsRecordsModel interface {
	Trans(ctx context.Context, fn func(context.Context, sqlx.Session) error) error
	FindByUserId(ctx context.Context, userId int64, page, pageSize int32) ([]*PointsRecords, error)
	FindByOrderNo(ctx context.Context, orderNo string) ([]*PointsRecords, error)
	BatchInsert(ctx context.Context, records []*PointsRecords) error
	CountByUserId(ctx context.Context, userId int64) (int64, error)
	SumPointsByUserId(ctx context.Context, userId int64) (int64, error)
	FindByDateRange(ctx context.Context, userId int64, startTime, endTime time.Time) ([]*PointsRecords, error)
	// contains filtered or unexported methods
}

func NewPointsRecordsModel

func NewPointsRecordsModel(conn sqlx.SqlConn, c cache.CacheConf, opts ...cache.Option) PointsRecordsModel

type Promotions

type Promotions struct {
	Id        uint64       `db:"id"`         // 活动ID
	Name      string       `db:"name"`       // 活动�称
	Type      int64        `db:"type"`       // 活动类型 1:满� 2:折扣 3:秒�
	Rules     string       `db:"rules"`      // 促销规则
	Status    int64        `db:"status"`     // 状� 0:未开始 1:进行中 2:已结�
	StartTime sql.NullTime `db:"start_time"` // 开始时间
	EndTime   sql.NullTime `db:"end_time"`   // 结�时间
	CreatedAt time.Time    `db:"created_at"` // 创建时间
	UpdatedAt time.Time    `db:"updated_at"` // 更新时间
}

type PromotionsModel

type PromotionsModel interface {
	Trans(ctx context.Context, fn func(context.Context, sqlx.Session) error) error
	FindByStatus(ctx context.Context, status int32, page, pageSize int32) ([]*Promotions, error)
	FindActive(ctx context.Context) ([]*Promotions, error)
	UpdateStatus(ctx context.Context, id uint64, status int32) error
	FindByDateRange(ctx context.Context, startTime, endTime time.Time) ([]*Promotions, error)
	Count(ctx context.Context, status int32) (int64, error)
	BatchInsert(ctx context.Context, data []*Promotions) error
	// contains filtered or unexported methods
}

func NewPromotionsModel

func NewPromotionsModel(conn sqlx.SqlConn, c cache.CacheConf, opts ...cache.Option) PromotionsModel

type UserCoupons

type UserCoupons struct {
	Id        uint64         `db:"id"`         // ID
	UserId    uint64         `db:"user_id"`    // 用户ID
	CouponId  uint64         `db:"coupon_id"`  // 优惠券ID
	Status    int64          `db:"status"`     // 状� 0:未使用 1:已使用 2:已过期
	UsedTime  sql.NullTime   `db:"used_time"`  // 使用时间
	OrderNo   sql.NullString `db:"order_no"`   // 订��
	CreatedAt time.Time      `db:"created_at"` // 创建时间
}

type UserCouponsModel

type UserCouponsModel interface {
	Trans(ctx context.Context, fn func(context.Context, sqlx.Session) error) error
	FindByUserAndStatus(ctx context.Context, userId int64, status int32, page, pageSize int32) ([]*UserCoupons, error)
	CountByUser(ctx context.Context, userId int64, status int32) (int64, error)
	VerifyCoupon(ctx context.Context, userId, couponId int64) (*UserCoupons, error)
	UpdateStatus(ctx context.Context, id int64, status int32, orderNo string) error
	BatchInsert(ctx context.Context, coupons []*UserCoupons) error
	FindByOrderNo(ctx context.Context, orderNo string) (*UserCoupons, error)
	CountUserCoupon(ctx context.Context, userId, couponId int64) (int64, error)
	// contains filtered or unexported methods
}

UserCouponsModel is an interface to be customized, add more methods here, and implement the added methods in customUserCouponsModel.

func NewUserCouponsModel

func NewUserCouponsModel(conn sqlx.SqlConn, c cache.CacheConf, opts ...cache.Option) UserCouponsModel

NewUserCouponsModel returns a model for the database table.

type UserPoints

type UserPoints struct {
	UserId      uint64    `db:"user_id"`      // 用户ID
	Points      int64     `db:"points"`       // 积分余�
	TotalPoints int64     `db:"total_points"` // 累计获得积分
	UsedPoints  int64     `db:"used_points"`  // 已使用积分
	UpdatedAt   time.Time `db:"updated_at"`   // 更新时间
}

type UserPointsModel

type UserPointsModel interface {
	Trans(ctx context.Context, fn func(context.Context, sqlx.Session) error) error
	IncrPoints(ctx context.Context, userId int64, points int64) error
	DecrPoints(ctx context.Context, userId int64, points int64) error
	Lock(ctx context.Context, session sqlx.Session, userId int64) error
	Unlock(ctx context.Context, session sqlx.Session, userId int64) error
	GetBalance(ctx context.Context, userId int64) (int64, error)
	InitUserPoints(ctx context.Context, userId int64) error
	// contains filtered or unexported methods
}

UserPointsModel is an interface to be customized, add more methods here, and implement the added methods in customUserPointsModel.

func NewUserPointsModel

func NewUserPointsModel(conn sqlx.SqlConn, c cache.CacheConf, opts ...cache.Option) UserPointsModel

NewUserPointsModel returns a model for the database table.

Jump to

Keyboard shortcuts

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