order_good.go
2.6 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
package domain
import "time"
const (
TO_BE_DIVIDENDED = iota + 1 // 待分红
DIVIDENDED // 已分红
)
// OrderGood 订单产品领域实体(包括分红订单、分红退货单)
type OrderGood struct {
// 订单产品
OrderGoodId int64 `json:"orderGoodId,string"`
// 订单产品金额
OrderGoodAmount float64 `json:"orderGoodAmount"`
// 订单产品名称
OrderGoodName string `json:"orderGoodName"`
// 订单产品单价
OrderGoodPrice float64 `json:"orderGoodPrice"`
// 订单产品数量
OrderGoodQuantity float64 `json:"orderGoodQuantity,string"`
// 关联分红订单号
DividendsOrderNumber string `json:"dividendsOrderNumber"`
// 关联的分红退货单号
DividendsReturnedOrderNumber string `json:"dividendsReturnedOrderNumber"`
// 关联的共创合约编号
CooperationContractNumber string `json:"cooperationContractNumber"`
// 订单产品支出费用
OrderGoodExpense float64 `json:"orderGoodExpense"`
// 订单产品分红状态, 1待分红,2已分红
OrderGoodDividendsStatus int32 `json:"OrderGoodDividendsStatus"`
// 组织机构ID
OrgId int64 `json:"orgId"`
// 公司ID
CompanyId int64 `json:"companyId"`
// 创建时间
CreatedAt time.Time `json:"createdAt"`
// 删除时间
DeletedAt time.Time `json:"deletedAt"`
// 更新时间
UpdatedAt time.Time `json:"updatedAt"`
}
type OrderGoodRepository interface {
Save(orderGood *OrderGood) (*OrderGood, error)
UpdateMany(orderGoods []*OrderGood) ([]*OrderGood, error)
Remove(orderGood *OrderGood) (*OrderGood, error)
FindOne(queryOptions map[string]interface{}) (*OrderGood, error)
Find(queryOptions map[string]interface{}) (int64, []*OrderGood, error)
}
func (orderGood *OrderGood) Identify() interface{} {
if orderGood.OrderGoodId == 0 {
return nil
}
return orderGood.OrderGoodId
}
func (orderGood *OrderGood) Update(data map[string]interface{}) error {
if orderGoodAmount, ok := data["orderGoodAmount"]; ok {
orderGood.OrderGoodAmount = orderGoodAmount.(float64)
}
if orderGoodName, ok := data["orderGoodName"]; ok {
orderGood.OrderGoodName = orderGoodName.(string)
}
if orderGoodPrice, ok := data["orderGoodPrice"]; ok {
orderGood.OrderGoodPrice = orderGoodPrice.(float64)
}
if orderGoodQuantity, ok := data["orderGoodQuantity"]; ok {
orderGood.OrderGoodQuantity = orderGoodQuantity.(float64)
}
if cooperationContractNumber, ok := data["cooperationContractNumber"]; ok {
orderGood.CooperationContractNumber = cooperationContractNumber.(string)
}
if orderGoodExpense, ok := data["orderGoodExpense"]; ok {
orderGood.OrderGoodExpense = orderGoodExpense.(float64)
}
return nil
}