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 ¶
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 ¶
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 ¶
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 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 ¶
NewUserPointsModel returns a model for the database table.
Click to show internal directories.
Click to hide internal directories.