order_good.go
2.4 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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
package domain
//OrderGood 订单中的货品
type OrderGood struct {
//货品id
Id int64
// 公司id
CompanyId int64 `json:"companyId"`
//所属订单id
OrderId int64
//货品名称 长度可能较长
GoodName string
//预计的货品数量
PlanGoodNumber int
//货品单价
Price float64
//预计的货品总额
PlanAmount float64
//调整后的货品数量
UseGoodNumber int
//调整后的货品总额
UseAmount float64
//合伙人分红比例
PartnerBonusPercent float64
//预计的合伙人分红
PlanPartnerBonus float64
//合伙人应收分红调整 (初始值=-1)
UsePartnerBonus float64
//合伙人已收分红
PartnerBonusHas float64
//合伙人未收分红
PartnerBonusNot float64
//合伙人分红支出
PartnerBonusExpense float64
//分红状态
BonusStatus int
//备注信息
Remark string
// 数据来源
DataFrom *OrderDataFrom
// 备注原因
RemarkReason string
}
func (g *OrderGood) Status() GoodStatus {
if g.BonusStatus == BonusWaitPay && g.UseGoodNumber >= 0 && g.UseGoodNumber < g.PlanGoodNumber {
return goodStatusWithGoodsReturn
}
if g.BonusStatus == BonusWaitPay {
return goodStatusWait
}
if g.BonusStatus == BonusPaid && g.UseGoodNumber >= 0 && g.UseGoodNumber < g.PlanGoodNumber {
return goodStatusPayWithGoodsReturn
}
if g.BonusStatus == BonusPaid {
return goodStatusPay
}
return goodStatusWait
}
type GoodStatus int
const (
// 待支付
goodStatusWait GoodStatus = GoodStatus(iota + 1)
// 已支付
goodStatusPay
// 已支付退货
goodStatusPayWithGoodsReturn
// 待支付退货
goodStatusWithGoodsReturn
)
func (m *OrderGood) Identify() interface{} {
if m.Id == 0 {
return nil
}
return m.Id
}
func (m *OrderGood) OrderBonusStatic() *OrderStatics {
return &OrderStatics{
BonusStatus: int8(m.BonusStatus),
PlanOrderCount: m.PlanGoodNumber,
PlanOrderAmount: m.PlanAmount,
UseOrderCount: m.UseGoodNumber,
UseOrderAmount: m.UseAmount,
PlanPartnerBonus: m.PlanPartnerBonus,
UsePartnerBonus: m.UsePartnerBonus,
PartnerBonusHas: m.PartnerBonusHas,
PartnerBonusNot: m.PartnerBonusNot,
PartnerBonusExpense: m.PartnerBonusExpense,
}
}
type OrderGoodRepository interface {
Save(dm *OrderGood) (*OrderGood, error)
Remove(dm *OrderGood) (*OrderGood, error)
FindOne(queryOptions map[string]interface{}) (*OrderGood, error)
Find(queryOptions map[string]interface{}) (int64, []*OrderGood, error)
}