cooperation_contract.go
5.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
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
package domain
import (
"time"
)
const (
TYPE_DIVIDNEDS_INCENTIVES = iota + 1
TYPE_MONEY_INCENTIVES
)
type IncentivesType int32
const (
DividendsIncentives IncentivesType = 1
MoneyIncentives IncentivesType = 2
)
func (p IncentivesType) String() string {
switch p {
case DividendsIncentives:
return "业绩分红"
case MoneyIncentives:
return "金额激励"
default:
return "未知类型"
}
}
func (cooperationContract *CooperationContract) ReturnIncentivesName(p IncentivesType) string {
return p.String()
}
// CooperationContract 共创项目合约实体
type CooperationContract struct {
// 共创合约ID
CooperationContractId int64 `json:"cooperationContractId,string"`
// 共创合约描述
CooperationContractDescription string `json:"cooperationContractDescription"`
// 共创合约名称
CooperationContractName string `json:"cooperationContractName"`
// 共创合约编号
CooperationContractNumber string `json:"cooperationContractNumber"`
// 共创项目编号
CooperationProjectNumber string `json:"cooperationProjectNumber"`
// 共创合约承接对象,1员工,2共创用户,3公开
CooperationContractUndertakerTypes []int32 `json:"cooperationContractUndertakerTypes"`
// 共创合约发起人
CooperationContractSponsor *User `json:"cooperationContractSponsor"`
// 共创模式或者合伙模式
CooperationMode *CooperationMode `json:"cooperationMode"`
// 合约状态,1恢复,2暂停
Status int32 `json:"status"`
// 数据所属组织机构
Org *Org `json:"org"`
// 公司
Company *Company `json:"company"`
// 共创合约发起部门
Department *Department `json:"department"`
// 操作人
Operator *User `json:"operator"`
// 分红激励规则
DividendsIncentivesRules []*DividendsIncentivesRule `json:"dividendsIncentivesRules"`
// 金额激励规则
MoneyIncentivesRules []*MoneyIncentivesRule `json:"moneyIncentivesRules"`
// 激励方式,1业绩分红激励,2金额激励
IncentivesType int32 `json:"incentivesType"`
// 共创承接人列表
Undertakers []*Undertaker `json:"undertakers"`
// 共创合约相关人列表
RelevantPeople []*Relevant `json:"relevantPeople"`
// 操作时间
OperateTime time.Time `json:"operateTime"`
// 创建时间
CreatedAt time.Time `json:"createdAt"`
// 删除时间
DeletedAt time.Time `json:"deletedAt"`
// 更新时间
UpdatedAt time.Time `json:"updatedAt"`
}
type CooperationContractRepository interface {
Save(cooperationContract *CooperationContract) (*CooperationContract, error)
UpdateOne(cooperationContract *CooperationContract) (*CooperationContract, error)
UpdateMany(cooperationContracts []*CooperationContract) ([]*CooperationContract, error)
Remove(cooperationContract *CooperationContract) (*CooperationContract, error)
BatchRemove(cooperationContracts []*CooperationContract) ([]*CooperationContract, error)
FindOne(queryOptions map[string]interface{}) (*CooperationContract, error)
Find(queryOptions map[string]interface{}) (int64, []*CooperationContract, error)
}
func (cooperationContract *CooperationContract) Identify() interface{} {
if cooperationContract.CooperationContractId == 0 {
return nil
}
return cooperationContract.CooperationContractId
}
func (cooperationContract *CooperationContract) Update(data map[string]interface{}) error {
if cooperationContractDescription, ok := data["cooperationContractDescription"]; ok {
cooperationContract.CooperationContractDescription = cooperationContractDescription.(string)
}
if cooperationContractName, ok := data["cooperationContractName"]; ok {
cooperationContract.CooperationContractName = cooperationContractName.(string)
}
if cooperationProjectNumber, ok := data["cooperationProjectNumber"]; ok {
cooperationContract.CooperationProjectNumber = cooperationProjectNumber.(string)
}
if cooperationContractNumber, ok := data["cooperationContractNumber"]; ok {
cooperationContract.CooperationContractNumber = cooperationContractNumber.(string)
}
if cooperationContractUndertakerTypes, ok := data["cooperationContractUndertakerTypes"]; ok {
cooperationContract.CooperationContractUndertakerTypes = cooperationContractUndertakerTypes.([]int32)
}
if status, ok := data["status"]; ok {
cooperationContract.Status = status.(int32)
}
if action, ok := data["action"]; ok {
cooperationContract.Status = action.(int32)
}
if operateTime, ok := data["operateTime"]; ok {
cooperationContract.OperateTime = operateTime.(time.Time)
}
cooperationContract.UpdatedAt = time.Now()
return nil
}
// UndertakerSliceEqualBCE 判断承接人Slice是否一样
func (cooperationContract *CooperationContract) UndertakerSliceEqualBCE(a, b []*Undertaker) bool {
if len(a) != len(b) {
return false
}
if (a == nil) != (b == nil) {
return false
}
b = b[:len(a)]
for i, v := range a {
if v != b[i] {
return false
}
}
return true
}
// DividendsIncentivesRuleSliceEqualBCE 判断业绩分红激励规则Slice是否一样
func (cooperationContract *CooperationContract) DividendsIncentivesRuleSliceEqualBCE(a, b []*DividendsIncentivesRule) bool {
if len(a) != len(b) {
return false
}
if (a == nil) != (b == nil) {
return false
}
b = b[:len(a)]
for i, v := range a {
if v != b[i] {
return false
}
}
return true
}
// MoneyIncentivesRuleSliceEqualBCE 判断金额激励规则Slice是否一样
func (cooperationContract *CooperationContract) MoneyIncentivesRuleSliceEqualBCE(a, b []*MoneyIncentivesRule) bool {
if len(a) != len(b) {
return false
}
if (a == nil) != (b == nil) {
return false
}
b = b[:len(a)]
for i, v := range a {
if v != b[i] {
return false
}
}
return true
}