business_bonus.go 1.1 KB
package models

import (
	"context"
	"time"

	"github.com/go-pg/pg/v10"
)

// 业务分红信息
type BusinessBonus struct {
	tableName struct{} `pg:"business_bonus"`
	//	唯一标识
	Id int64 `pg:",pk"`
	//	公司编号
	CompanyId int64
	//	合伙人信息Id
	PartnerInfoId int64
	//	应收分红
	Bonus float64 `pg:",use_zero"`
	//	未收分红
	BonusNot float64 `pg:",use_zero"`
	//	分红支出
	BonusExpense float64 `pg:",use_zero"`
	//已收分红
	BonusHas float64 `pg:",use_zero"`
	//是否有效【0;无效】【1:有效】
	IsDisable int8 `pg:",use_zero"`
	//	分红状态 1:待支付分红 2:已支付分红
	BonusStatus int8 `pg:",use_zero"`
	//	创建时间
	CreateAt time.Time
	//	更新时间
	UpdateAt time.Time
	//	删除时间
	DeleteAt time.Time
}

var _ pg.BeforeUpdateHook = (*BusinessBonus)(nil)

func (bonus *BusinessBonus) BeforeUpdate(ctx context.Context) (context.Context, error) {
	bonus.UpdateAt = time.Now()
	return ctx, nil
}

var _ pg.BeforeInsertHook = (*BusinessBonus)(nil)

func (bonus *BusinessBonus) BeforeInsert(ctx context.Context) (context.Context, error) {
	bonus.CreateAt = time.Now()
	return ctx, nil
}