order.go
1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
package models
import (
"context"
"time"
"github.com/go-pg/pg/v10"
"gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/domain"
)
type Order struct {
tableName struct{} `pg:"order"`
//id
Id int64 `pg:",pk"`
//订单类型 1:实际订单 2:意向订单
OrderType int `pg:",notnull,default:1"`
//订单编号
OrderCode string `pg:",unique,notnull`
//订单名称
OrderName string
//订单状态
OrderStatus int `pg:",notnull,default:1"`
//订单数量
OrderCount int
//实际订单数量
OrderActualCount int
//订单金额
OrderAmount float64
//订单实际金额
OrderActualAmount float64
//订单已支付金额(货款)
OrderPaymentAmount float64 `pg:",use_zero"`
//最后分红状态
BonusStatus int `pg:",default:1"`
//订单区域信息
OrderRegionInfo domain.RegionInfo
Buyer domain.Buyer
//合伙人编号
PartnerId int64
PartnerInfo PartnerInfo `pg:"fk:partner_id"`
//合伙人分红百分比
PartnerBonusPercent float64
//业务员分红百分比
SalesmanBonusPercent float64
//创建时间
CreateAt time.Time
//更新时间
UpdateAt time.Time
//上一次查看时间 已读情况
LastViewTime time.Time
//理由
Reason string
}
var _ pg.BeforeUpdateHook = (*Order)(nil)
func (or *Order) BeforeUpdate(ctx context.Context) (context.Context, error) {
or.UpdateAt = time.Now()
return ctx, nil
}
var _ pg.BeforeInsertHook = (*Order)(nil)
func (or *Order) BeforeInsert(ctx context.Context) (context.Context, error) {
or.CreateAt = time.Now()
or.UpdateAt = time.Now()
return ctx, nil
}