goods.go
3.1 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
102
103
104
105
106
107
108
109
package domain
import "time"
// 订单商品实体
type Good struct {
// 商品id
GoodId int64 `json:"goodId"`
// 预定的货品数量
GoodNum int `json:"goodNum"`
// 商品分红支付信息
GoodDividend *Dividend `json:"goodDividend"`
// 商品分红支付状态
GoodDividendStatus int `json:"goodDividendStatus"`
// 商品名称
GoodName string `json:"goodName"`
// 商品单价
GoodTotalPrice float64 `json:"goodTotalPrice"`
// 备注
Remarks string `json:"remarks"`
// 订单编号
OrderNo string `json:"orderNo"`
// 商品详情
GoodDetail string `json:"goodDetail"`
// 创建时间
CreateAt time.Time `json:"createAt"`
// 更新时间
UpdateAt time.Time `json:"updateAt"`
// 删除时间
DeleteAt time.Time `json:"deleteAt"`
}
type GoodRepository interface {
Save(good *Good) (*Good, error)
Remove(good *Good) (*Good, error)
FindOne(queryOptions map[string]interface{}) (*Good, error)
Find(queryOptions map[string]interface{}) (int64, []*Good, error)
}
func (good *Good) Identify() interface{} {
if good.GoodId == 0 {
return nil
}
return good.GoodId
}
func (good *Good) Update(data map[string]interface{}) error {
if goodId, ok := data["goodId"]; ok {
good.GoodId = goodId.(int64)
}
if goodNum, ok := data["goodNum"]; ok {
good.GoodNum = goodNum.(int)
}
if planBonus, ok := data["planBonus"]; ok {
good.GoodDividend.PlanBonus = planBonus.(float64)
}
if useBonus, ok := data["useBonus"]; ok {
good.GoodDividend.UseBonus = useBonus.(float64)
}
if bonusHas, ok := data["bonusHas"]; ok {
good.GoodDividend.BonusHas = bonusHas.(float64)
}
if bonusNot, ok := data["bonusNot"]; ok {
good.GoodDividend.BonusNot = bonusNot.(float64)
}
if bonusExpense, ok := data["bonusExpense"]; ok {
good.GoodDividend.BonusExpense = bonusExpense.(float64)
}
if bonusStatus, ok := data["bonusStatus"]; ok {
good.GoodDividend.BonusStatus = bonusStatus.(int)
}
if partnerBonusPercent, ok := data["partnerBonusPercent"]; ok {
good.GoodDividend.PartnerBonusPercent = partnerBonusPercent.(float64)
}
if salesmanBonusPercent, ok := data["salesmanBonusPercent"]; ok {
good.GoodDividend.SalesmanBonusPercent = salesmanBonusPercent.(float64)
}
if salesmanBonus, ok := data["salesmanBonus"]; ok {
good.GoodDividend.SalesmanBonus = salesmanBonus.(float64)
}
if goodDividendStatus, ok := data["goodDividendStatus"]; ok {
good.GoodDividendStatus = goodDividendStatus.(int)
}
if goodName, ok := data["goodName"]; ok {
good.GoodName = goodName.(string)
}
if goodTotalPrice, ok := data["goodTotalPrice"]; ok {
good.GoodTotalPrice = goodTotalPrice.(float64)
}
if remarks, ok := data["remarks"]; ok {
good.Remarks = remarks.(string)
}
if orderNo, ok := data["orderNo"]; ok {
good.OrderNo = orderNo.(string)
}
if goodDetail, ok := data["goodDetail"]; ok {
good.GoodDetail = goodDetail.(string)
}
if createAt, ok := data["createAt"]; ok {
good.CreateAt = createAt.(time.Time)
}
if updateAt, ok := data["updateAt"]; ok {
good.UpdateAt = updateAt.(time.Time)
}
if deleteAt, ok := data["deleteAt"]; ok {
good.DeleteAt = deleteAt.(time.Time)
}
return nil
}