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
package domain
import "time"
// 订单商品实体
type Goods struct {
// 商品id
GoodsId int64 `json:"goodsId"`
// 预定的货品数量
GoodsNum int `json:"goodsNum"`
// 商品分红支付信息
GoodsDividend *Dividend `json:"goodsDividend"`
// 商品分红支付状态
GoodsDividendStatus int `json:"goodsDividendStatus"`
// 商品名称
GoodsName string `json:"goodsName"`
// 商品单价
GoodsTotalPrice float64 `json:"goodsTotalPrice"`
// 备注
Remarks string `json:"remarks"`
// 订单编号
OrderNo string `json:"orderNo"`
GoodsDetail string `json:"goodsDetail"`
// 创建时间
CreateAt time.Time `json:"createAt"`
// 更新时间
UpdateAt time.Time `json:"updateAt"`
// 删除时间
DeleteAt time.Time `json:"deleteAt"`
}
type GoodsRepository interface {
Save(goods *Goods) (*Goods, error)
Remove(goods *Goods) (*Goods, error)
FindOne(queryOptions map[string]interface{}) (*Goods, error)
Find(queryOptions map[string]interface{}) (int64, []*Goods, error)
}
func (goods *Goods) Identify() interface{} {
if goods.GoodsId == 0 {
return nil
}
return goods.GoodsId
}
func (goods *Goods) Update(data map[string]interface{}) error {
if goodsId, ok := data["goodsId"]; ok {
goods.GoodsId = goodsId.(int64)
}
if goodsNum, ok := data["goodsNum"]; ok {
goods.GoodsNum = goodsNum.(int)
}
if planBonus, ok := data["planBonus"]; ok {
goods.GoodsDividend.PlanBonus = planBonus.(float64)
}
if useBonus, ok := data["useBonus"]; ok {
goods.GoodsDividend.UseBonus = useBonus.(float64)
}
if bonusHas, ok := data["bonusHas"]; ok {
goods.GoodsDividend.BonusHas = bonusHas.(float64)
}
if bonusNot, ok := data["bonusNot"]; ok {
goods.GoodsDividend.BonusNot = bonusNot.(float64)
}
if bonusExpense, ok := data["bonusExpense"]; ok {
goods.GoodsDividend.BonusExpense = bonusExpense.(float64)
}
if bonusStatus, ok := data["bonusStatus"]; ok {
goods.GoodsDividend.BonusStatus = bonusStatus.(int)
}
if partnerBonusPercent, ok := data["partnerBonusPercent"]; ok {
goods.GoodsDividend.PartnerBonusPercent = partnerBonusPercent.(float64)
}
if salesmanBonusPercent, ok := data["salesmanBonusPercent"]; ok {
goods.GoodsDividend.SalesmanBonusPercent = salesmanBonusPercent.(float64)
}
if salesmanBonus, ok := data["salesmanBonus"]; ok {
goods.GoodsDividend.SalesmanBonus = salesmanBonus.(float64)
}
if goodsDividendStatus, ok := data["goodsDividendStatus"]; ok {
goods.GoodsDividendStatus = goodsDividendStatus.(int)
}
if goodsName, ok := data["goodsName"]; ok {
goods.GoodsName = goodsName.(string)
}
if goodsTotalPrice, ok := data["goodsTotalPrice"]; ok {
goods.GoodsTotalPrice = goodsTotalPrice.(float64)
}
if remarks, ok := data["remarks"]; ok {
goods.Remarks = remarks.(string)
}
if orderNo, ok := data["orderNo"]; ok {
goods.OrderNo = orderNo.(string)
}
if goodsDetail, ok := data["goodsDetail"]; ok {
goods.GoodsDetail = goodsDetail.(string)
}
if createAt, ok := data["createAt"]; ok {
goods.CreateAt = createAt.(time.Time)
}
if updateAt, ok := data["updateAt"]; ok {
goods.UpdateAt = updateAt.(time.Time)
}
if deleteAt, ok := data["deleteAt"]; ok {
goods.DeleteAt = deleteAt.(time.Time)
}
return nil
}