dividends_order.go
3.5 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
package domain
import (
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/dividendsOrder/command"
"time"
)
const (
TO_BE_DIVIDEND = iota + 1
ALL_DIVIDENDED
PART_DIVIDENDED
)
// DividendsOrder 分红订单实体
type DividendsOrder struct {
// 分红订单ID
DividendsOrderId int64 `json:"dividendsOrderId,string"`
// 分红订单号
DividendsOrderNumber string `json:"dividendsOrderNumber"`
// 分红订单原单号
DividendsOriginalOrderNum string `json:"dividendsOriginalOrderNum"`
// 分红订单金额
DividendsOrderAmount float64 `json:"dividendsOrderAmount"`
// 订单日期
OrderTime time.Time `json:"orderTime"`
// 分红订单分红时间
DividendTime time.Time `json:"dividendTime"`
// 分红订单分红状态,1待分红,2已分红,3部分分红
DividendStatus int32 `json:"dividendStatus"`
// 区域
Region *RegionInfo `json:"region"`
// 客户姓名
CustomerName string `json:"customerName"`
// 订单产品列表
Goods []*OrderGood `json:"goods"`
// 数据所属组织机构
Org *Org `json:"org"`
// 公司
Company *Company `json:"company"`
// 创建时间
CreatedAt time.Time `json:"createdAt"`
// 删除时间
DeletedAt time.Time `json:"deletedAt"`
// 更新时间
UpdatedAt time.Time `json:"updatedAt"`
// 操作时间
OperateTime time.Time `json:"operateTime"`
// 操作人
Operator *User `json:"operator"`
// 备注
Remarks string `json:"remarks"`
}
// ImportInfo 导入错误信息
type ImportInfo struct {
Error error `json:"error"`
LineNumbers []int `json:"lineNumbers"`
GoodLine map[int]string `json:"goodLine"`
}
// FailInfo 返回的失败信息
type FailInfo struct {
FailReason string `json:"failReason"`
*command.ImportDividendsOrderData
}
type DividendsOrderRepository interface {
Save(dividendsOrder *DividendsOrder) (*DividendsOrder, error)
SaveMany(dividendsOrders []*DividendsOrder) ([]*DividendsOrder, error)
UpdateMany(dividendsOrders []*DividendsOrder) ([]*DividendsOrder, error)
Remove(dividendsOrder *DividendsOrder) (*DividendsOrder, error)
BatchRemove(dividendsOrders []*DividendsOrder) ([]*DividendsOrder, error)
FindOne(queryOptions map[string]interface{}) (*DividendsOrder, error)
Find(queryOptions map[string]interface{}) (int64, []*DividendsOrder, error)
}
func (dividendsOrder *DividendsOrder) Identify() interface{} {
if dividendsOrder.DividendsOrderId == 0 {
return nil
}
return dividendsOrder.DividendsOrderId
}
func (dividendsOrder *DividendsOrder) Update(data map[string]interface{}) error {
if dividendsOrderNumber, ok := data["dividendsOrderNumber"]; ok {
dividendsOrder.DividendsOrderNumber = dividendsOrderNumber.(string)
}
if dividendsOriginalOrderNum, ok := data["dividendsOriginalOrderNum"]; ok {
dividendsOrder.DividendsOriginalOrderNum = dividendsOriginalOrderNum.(string)
}
if dividendsOrderAmount, ok := data["dividendsOrderAmount"]; ok {
dividendsOrder.DividendsOrderAmount = dividendsOrderAmount.(float64)
}
if dividendTime, ok := data["dividendTime"]; ok {
dividendsOrder.DividendTime = dividendTime.(time.Time)
}
if dividendStatus, ok := data["dividendStatus"]; ok {
dividendsOrder.DividendStatus = dividendStatus.(int32)
}
if regionNumber, ok := data["regionNumber"]; ok {
dividendsOrder.Region.RegionNumber = regionNumber.(string)
}
if regionName, ok := data["regionName"]; ok {
dividendsOrder.Region.RegionName = regionName.(string)
}
if customerName, ok := data["customerName"]; ok {
dividendsOrder.CustomerName = customerName.(string)
}
dividendsOrder.UpdatedAt = time.Now()
return nil
}