order_payment.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
package domain
import "time"
const (
BonusWaitPay = iota + 1 //等待支付分红
BonusPaid //已经支付分红
)
type OrderPaymentRepository interface {
Save(dm *OrderPayment) (*OrderPayment, error)
Remove(dm *OrderPayment) (*OrderPayment, error)
FindOne(queryOptions map[string]interface{}) (*OrderPayment, error)
Find(queryOptions map[string]interface{}) (int64, []*OrderPayment, error)
}
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"`
}
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
}