审查视图

pkg/infrastructure/pg/models/business_bonus.go 1.1 KB
唐旭辉 authored
1 2 3 4 5 6 7 8 9 10 11 12 13
package models

import (
	"context"
	"time"

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

// 业务分红信息
type BusinessBonus struct {
	tableName struct{} `pg:"business_bonus"`
	//	唯一标识
唐旭辉 authored
14
	Id int64 `pg:",pk"`
唐旭辉 authored
15 16 17
	//	公司编号
	CompanyId int64
	//	合伙人信息Id
唐旭辉 authored
18
	PartnerInfoId int64
唐旭辉 authored
19
	//	应收分红
唐旭辉 authored
20
	Bonus float64 `pg:",use_zero"`
唐旭辉 authored
21
	//	未收分红
22
	BonusNot float64 `pg:",use_zero"`
唐旭辉 authored
23
	//	分红支出
24
	BonusExpense float64 `pg:",use_zero"`
唐旭辉 authored
25
	//已收分红
26
	BonusHas float64 `pg:",use_zero"`
唐旭辉 authored
27 28
	//是否有效【0;无效】【1:有效】
	IsDisable int8 `pg:",use_zero"`
唐旭辉 authored
29
	//	分红状态 1:待支付分红 2:已支付分红
唐旭辉 authored
30
	BonusStatus int8 `pg:",use_zero"`
唐旭辉 authored
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
	//	创建时间
	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
}