order_payment.go
1.8 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
72
73
74
75
76
package domain
import "time"
const (
BonusWaitPay = iota + 1 //等待支付分红
BonusPaid //已经支付分红
)
type OrderPayment struct {
//编号
Id int64 `json:"id"`
//订单编号
OrderId int64 `json:"orderId"`
//合伙人编号
PartnerId int64 `json:"partnerId"`
//支付货款
PaymentAmount float64 `json:"paymentAmount"`
//分红金额
BonusAmount float64 `json:"bonusAmount"`
//分红状态 1.等待支付分红 2.已支付分红
BonusStatus int `json:"bonusStatus"`
//创建时间
CreateAt time.Time `json:"createAt"`
//更新时间
UpdateAt time.Time `json:"updateAt"`
//扩展
PartnerBonusPercent float64 `json:"-"`
}
func (m *OrderPayment) Identify() interface{} {
if m.Id == 0 {
return nil
}
return m.Id
}
func (m *OrderPayment) Update(data map[string]interface{}) error {
if m.BonusStatus != BonusWaitPay {
return nil
}
if paymentAmount, ok := data["paymentAmount"]; ok && paymentAmount != 0 {
m.PaymentAmount = paymentAmount.(float64)
}
if bonusAmount, ok := data["bonusAmount"]; ok && bonusAmount != 0 {
m.BonusAmount = bonusAmount.(float64)
}
if bonusStatus, ok := data["bonusStatus"]; ok && bonusStatus != 0 {
m.BonusStatus = bonusStatus.(int)
}
m.UpdateAt = time.Now()
return nil
}
type OrderPaymentFindOneQuery struct {
Id int64
OrderId int64
PaymentId int
}
type OrderPaymentQuery struct {
Offset int
Limit int
OrderId int64
//PartnerCategory []int //合伙人类型
//RegionInfo *RegionInfo //区域
//PartnerName string //合伙人姓名
}
type OrderPaymentRepository interface {
Save(dm *OrderPayment) (*OrderPayment, error)
FindOne(queryOptions OrderPaymentFindOneQuery) (*OrderPayment, error)
Find(queryOptions OrderPaymentQuery) ([]*OrderPayment, error)
CountAll(queryOptions OrderPaymentQuery) (int, error)
}