order.go
5.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
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
package domain
import "time"
// 订单类型
const (
ORDER_TYPE_ACTUAL = iota + 1 //实际订单
ORDER_TYPE_INTENTION // 意向订单
)
// 订单状态
const (
ORDER_STATUS_SHIPPED = iota + 1 // 已发货
ORDER_STATUS_TRANSIT // 待收货
ORDER_STATUS_RECEIVED // 已收货
ORDER_STATUS_RETURNED // 已退货
ORDER_STATUS_CANCELED // 已取消
ORDER_STATUS_CLOSED // 已关闭
)
// 订单实体
type Order struct {
// 订单id
OrderId int64 `json:"orderId"`
// 买家信息
Buyer *BuyerInfo `json:"buyer"`
// 公司Id
CompanyId int64 `json:"companyId"`
// 合伙人id
PartnerId int64 `json:"partnerId"`
// 发货单号
DeliveryCode string `json:"deliveryCode"`
// 是否关闭订单标志
IsDisable int `json:"isDisable"`
// 订单编号
OrderNo string `json:"orderNo"`
// 订单详情
OrderDetail *OrderDetail `json:"orderDetail"`
// 订单分红信息
OrderDividend *Dividend `json:"orderDividend"`
// 订单分红支付状态
OrderDividendStatus int `json:"orderDividendStatus"`
// 订单货品
OrderGoods []*Goods `json:"orderGoods"`
// 订单数据来源
OrderSource *OrderSource `json:"orderSource"`
// 订单类型(1.实际订单;2.意向订单)
OrderType int `json:"orderType"`
// 订单状态(1.发货;2.收货;3.退货;4.取消;5.完成)
OrderStatus int `json:"orderStatus"`
// 订单总价
TotalPrice float64 `json:"totalPrice"`
// 订单区域信息
RegionInfo *RegionInfo `json:"regionInfo"`
// 备注
Remarks string `json:"remarks"`
// 创建时间
CreateAt time.Time `json:"createAt"`
// 更新时间
UpdateAt time.Time `json:"updateAt"`
// 软删
DeleteAt time.Time `json:"deleteAt"`
}
type OrderRepository interface {
Save(order *Order) (*Order, error)
Remove(order *Order) (*Order, error)
FindOne(queryOptions map[string]interface{}) (*Order, error)
Find(queryOptions map[string]interface{}) (int64, []*Order, error)
}
func (order *Order) Identify() interface{} {
if order.OrderId == 0 {
return nil
}
return order.OrderId
}
func (order *Order) Update(data map[string]interface{}) error {
if orderId, ok := data["orderId"]; ok {
order.OrderId = orderId.(int64)
}
if buyerName, ok := data["buyerName"]; ok {
order.Buyer.BuyerName = buyerName.(string)
}
if contactInfo, ok := data["contactInfo"]; ok {
order.Buyer.ContactInfo = contactInfo.(string)
}
if shippingAddress, ok := data["shippingAddress"]; ok {
order.Buyer.ShippingAddress = shippingAddress.(string)
}
if companyId, ok := data["companyId"]; ok {
order.CompanyId = companyId.(int64)
}
if partnerId, ok := data["partnerId"]; ok {
order.PartnerId = partnerId.(int64)
}
if deliveryCode, ok := data["deliveryCode"]; ok {
order.DeliveryCode = deliveryCode.(string)
}
if isDisable, ok := data["isDisable"]; ok {
order.IsDisable = isDisable.(int)
}
if orderNo, ok := data["orderNo"]; ok {
order.OrderNo = orderNo.(string)
}
if orderDetailId, ok := data["orderDetailId"]; ok {
order.OrderDetail.OrderDetailId = orderDetailId.(int64)
}
if orderNo, ok := data["orderNo"]; ok {
order.OrderDetail.OrderNo = orderNo.(string)
}
if orderNum, ok := data["orderNum"]; ok {
order.OrderDetail.OrderNum = orderNum.(int)
}
if totalPrice, ok := data["totalPrice"]; ok {
order.OrderDetail.TotalPrice = totalPrice.(float64)
}
if adjustedNum, ok := data["adjustedNum"]; ok {
order.OrderDetail.AdjustedNum = adjustedNum.(int)
}
if adjustedTotalPrice, ok := data["adjustedTotalPrice"]; ok {
order.OrderDetail.AdjustedTotalPrice = adjustedTotalPrice.(float64)
}
if planBonus, ok := data["planBonus"]; ok {
order.OrderDividend.PlanBonus = planBonus.(float64)
}
if useBonus, ok := data["useBonus"]; ok {
order.OrderDividend.UseBonus = useBonus.(float64)
}
if bonusHas, ok := data["bonusHas"]; ok {
order.OrderDividend.BonusHas = bonusHas.(float64)
}
if bonusNot, ok := data["bonusNot"]; ok {
order.OrderDividend.BonusNot = bonusNot.(float64)
}
if bonusExpense, ok := data["bonusExpense"]; ok {
order.OrderDividend.BonusExpense = bonusExpense.(float64)
}
if bonusStatus, ok := data["bonusStatus"]; ok {
order.OrderDividend.BonusStatus = bonusStatus.(int)
}
if partnerBonusPercent, ok := data["partnerBonusPercent"]; ok {
order.OrderDividend.PartnerBonusPercent = partnerBonusPercent.(float64)
}
if salesmanBonusPercent, ok := data["salesmanBonusPercent"]; ok {
order.OrderDividend.SalesmanBonusPercent = salesmanBonusPercent.(float64)
}
if salesmanBonus, ok := data["salesmanBonus"]; ok {
order.OrderDividend.SalesmanBonus = salesmanBonus.(float64)
}
if orderDividendStatus, ok := data["orderDividendStatus"]; ok {
order.OrderDividendStatus = orderDividendStatus.(int)
}
if orderGoods, ok := data["orderGoods"]; ok {
order.OrderGoods = orderGoods.([]*Goods)
}
if dataSourceId, ok := data["dataSourceId"]; ok {
order.OrderSource.DataSourceId = dataSourceId.(int64)
}
if platform, ok := data["platform"]; ok {
order.OrderSource.Platform = platform.(string)
}
if createAt, ok := data["createAt"]; ok {
order.OrderSource.CreateAt = createAt.(time.Time)
}
if orderType, ok := data["orderType"]; ok {
order.OrderType = orderType.(int)
}
if orderStatus, ok := data["orderStatus"]; ok {
order.OrderStatus = orderStatus.(int)
}
if totalPrice, ok := data["totalPrice"]; ok {
order.TotalPrice = totalPrice.(float64)
}
if regionName, ok := data["regionName"]; ok {
order.RegionInfo.RegionName = regionName.(string)
}
if remarks, ok := data["remarks"]; ok {
order.Remarks = remarks.(string)
}
if createAt, ok := data["createAt"]; ok {
order.CreateAt = createAt.(time.Time)
}
if updateAt, ok := data["updateAt"]; ok {
order.UpdateAt = updateAt.(time.Time)
}
if deleteAt, ok := data["deleteAt"]; ok {
order.DeleteAt = deleteAt.(time.Time)
}
return nil
}