dto.go
11.2 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
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
package dto
import (
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_cooperation"
)
type CooperationContractItem struct {
CooperationContractId int `json:"cooperationContractId,string,"`
CooperationContractNumber string `json:"cooperationContractNumber"` //合约编号
CooperationProjectNumber string `json:"cooperationProjectNumber"` //项目编号
CooperationContractName string `json:"cooperationContractName"` //合约名称
Status int `json:"status"` //合约状态
CreateTime int `json:"createTime"`
Department domain.Department `json:"department"`
IncentivesType string `json:"incentivesType"` //Incentives激励方式
CooperationContractSponsor struct {
UserId int `json:"userId,string,"`
UserName string `json:"userName"`
} `json:"cooperationContractSponsor"` //共创发起人
CooperationMode domain.CooperationMode `json:"cooperationMode"` //共创模式
Org domain.Org `json:"org"` //组织结构
CooperationContractUndertakerType []int `json:"cooperationContractUndertakerType"` //共创合约承接对象,1员工,2共创用户,3公开
CooperationContractDescription string `json:"cooperationContractDescription"` //合约描述
}
func ToCooperationContractItem(param *allied_creation_cooperation.CooperationContract) *CooperationContractItem {
cooperationContractUndertakerType := param.CooperationContractUndertakerTypes
if len(cooperationContractUndertakerType) == 0 {
cooperationContractUndertakerType = []int{}
}
data := CooperationContractItem{
CooperationContractUndertakerType: cooperationContractUndertakerType,
CooperationContractDescription: param.CooperationContractDescription,
CooperationContractId: param.CooperationContractId,
CooperationProjectNumber: param.CooperationContractNumber,
CooperationContractName: param.CooperationContractName,
CooperationContractNumber: param.CooperationContractNumber,
Status: param.Status,
CreateTime: int(param.CreatedAt.UnixNano() / 1e6),
}
data.CooperationContractSponsor.UserId = param.CooperationContractSponsor.UserId
data.CooperationContractSponsor.UserName = param.CooperationContractSponsor.UserInfo.UserName
data.Department.DepartmentId = param.Department.DepartmentId
data.Department.DepartmentName = param.Department.DepartmentName
data.Org.OrgID = int(param.Org.OrgId)
data.Org.OrgName = param.Org.OrgName
data.CooperationMode.CooperationModeId = param.CooperationMode.CooperationModeId
data.CooperationMode.CooperationModeName = param.CooperationMode.CooperationModeName
data.CooperationMode.CooperationModeNumber = param.CooperationMode.CooperationModeNumber
if len(param.DividendsIncentivesRules) > 0 {
data.IncentivesType = "业绩分红"
} else if len(param.MoneyIncentivesRules) > 0 {
data.IncentivesType = "金额激励"
}
return &data
}
type MoneyIncentivesRule struct {
MoneyIncentivesRuleId int `json:"moneyIncentivesRuleId,string"`
CooperationContractNumber string `json:"cooperationContractNumber"` // 关联的共创合约编号
MoneyIncentivesAmount float64 `json:"moneyIncentivesAmount"` // 激励金额
MoneyIncentivesStage int `json:"moneyIncentivesStage"` // 金额激励阶段
MoneyIncentivesTime int64 `json:"moneyIncentivesTime"` // 金额激励规则时间
ReferrerPercentage float64 `json:"referrerPercentage"` // 推荐人抽成比例
SalesmanPercentage float64 `json:"salesmanPercentage"` // 业务员抽成比例
}
type DividendsIncentivesRule struct {
DividendsIncentivesRuleId int `json:"dividendsIncentivesRuleId,string"`
CooperationContractNumber string `json:"cooperationContractNumber"` // 关联的项目合约编号
ReferrerPercentage float64 `json:"referrerPercentage"` // 推荐人抽成比例
SalesmanPercentage float64 `json:"salesmanPercentage"` // 业务员抽成比例
DividendsPercentage float64 `json:"dividendsPercentage"` // 分红规则激励百分点
DividendsStage int `json:"dividendsStage,string"` // 分红规则激励阶段,
DividendsStageEnd int64 `json:"dividendsStageEnd"` // 分红规则激励阶段结束
DividendsStageStart int64 `json:"dividendsStageStart"` // 分红规则激励阶段开始
}
type Relevant struct {
UserId int `json:"userId"`
UserInfo domain.UserInfo `json:"userInfo"`
Department domain.Department `json:"department"`
}
type ContractUndertaker struct {
UndertakerId int `json:"undertakerId,string,"`
Attachment []domain.Attachment `json:"attachment"`
Department domain.Department `json:"department"`
HasReferrer bool `json:"hasReferrer"`
HasSalesman bool `json:"hasSalesman"`
ReferrerUser struct {
UserId int `json:"userId,string"`
UserInfo domain.UserInfo `json:"userInfo"`
} `json:"referrerUser"`
SalesmanUser struct {
UserId int `json:"userId,string"`
UserInfo domain.UserInfo `json:"userInfo"`
}
UserId int `json:"userId,string"`
UserInfo domain.UserInfo `json:"userInfo"`
}
type CooperationContractInfo struct {
CooperationContract CooperationContractItem `json:"cooperationContract"`
Relevant []Relevant `json:"relevant"`
DividendsIncentivesRules []DividendsIncentivesRule `json:"dividendsIncentivesRules"`
MoneyIncentivesRules []MoneyIncentivesRule `json:"moneyIncentivesRules"`
ContractUndertaker []ContractUndertaker `json:"contractUndertaker"`
UndertakerTypesUncheckedAvailable []int `json:"undertakerTypesUncheckedAvailable"` // 可以去除勾选的共创项目承接对象列表
}
func ToCooperationContractInfo(param *allied_creation_cooperation.CooperationContract) *CooperationContractInfo {
relevants := []Relevant{}
dividendsIncentivesRules := []DividendsIncentivesRule{}
moneyIncentivesRules := []MoneyIncentivesRule{}
contractUndertaker := []ContractUndertaker{}
for _, v := range param.RelevantPeople {
r := Relevant{
UserId: int(v.UserId),
UserInfo: domain.UserInfo{
UsersName: v.UserInfo.UsersName,
UsersId: v.UserInfo.UsersId,
UserCode: v.UserInfo.UserCode,
},
Department: domain.Department{
DepartmentNumber: v.Department.DepartmentNumber,
DepartmentId: int(v.Department.DepartmentId),
DepartmentName: v.Department.DepartmentName,
}}
relevants = append(relevants, r)
}
for _, v := range param.DividendsIncentivesRules {
r := DividendsIncentivesRule{
DividendsIncentivesRuleId: v.DividendsIncentivesRuleId,
CooperationContractNumber: v.CooperationContractNumber,
ReferrerPercentage: v.ReferrerPercentage,
SalesmanPercentage: v.SalesmanPercentage,
DividendsPercentage: v.DividendsIncentivesPercentage,
DividendsStage: v.DividendsIncentivesStage,
DividendsStageEnd: v.DividendsIncentivesStageEnd.UnixNano() / 1e6,
DividendsStageStart: v.DividendsIncentivesStageStart.UnixNano() / 1e6,
}
dividendsIncentivesRules = append(dividendsIncentivesRules, r)
}
for _, v := range param.MoneyIncentivesRules {
r := MoneyIncentivesRule{
MoneyIncentivesRuleId: v.MoneyIncentivesRuleId,
CooperationContractNumber: v.CooperationContractNumber,
MoneyIncentivesAmount: v.MoneyIncentivesAmount,
MoneyIncentivesStage: v.MoneyIncentivesStage,
MoneyIncentivesTime: v.MoneyIncentivesTime.UnixNano() / 1e6,
ReferrerPercentage: v.ReferrerPercentage,
SalesmanPercentage: v.SalesmanPercentage,
}
moneyIncentivesRules = append(moneyIncentivesRules, r)
}
for _, v := range param.Undertakers {
attachment := v.ContractAttachment
if len(attachment) == 0 {
attachment = []domain.Attachment{}
}
u := ContractUndertaker{
Attachment: attachment,
Department: domain.Department{
DepartmentNumber: v.Department.DepartmentNumber,
DepartmentId: int(v.Department.DepartmentId),
DepartmentName: v.Department.DepartmentName,
},
HasReferrer: v.Referrer.UserId > 0,
HasSalesman: v.Salesman.UserId > 0,
UndertakerId: v.UndertakerId,
UserId: v.UserId,
UserInfo: domain.UserInfo{
UsersName: v.UserInfo.UserName,
UsersId: v.UserId,
Phone: v.UserInfo.UserPhone,
},
}
u.SalesmanUser.UserId = v.Salesman.UserId
u.SalesmanUser.UserInfo.UsersId = v.Salesman.UserId
u.SalesmanUser.UserInfo.UsersName = v.Salesman.UserInfo.UserName
u.SalesmanUser.UserInfo.Phone = v.Salesman.UserInfo.UserPhone
u.ReferrerUser.UserId = v.Referrer.UserId
u.ReferrerUser.UserInfo.UsersId = v.Referrer.UserId
u.ReferrerUser.UserInfo.UsersName = v.Referrer.UserInfo.UserName
u.ReferrerUser.UserInfo.Phone = v.Referrer.UserInfo.UserPhone
contractUndertaker = append(contractUndertaker, u)
}
undertakerTypesUncheckedAvailable := param.UndertakerTypesUncheckedAvailable
if len(undertakerTypesUncheckedAvailable) == 0 {
undertakerTypesUncheckedAvailable = []int{}
}
data := CooperationContractInfo{
CooperationContract: *ToCooperationContractItem(param),
Relevant: relevants,
DividendsIncentivesRules: dividendsIncentivesRules,
MoneyIncentivesRules: moneyIncentivesRules,
ContractUndertaker: contractUndertaker,
UndertakerTypesUncheckedAvailable: undertakerTypesUncheckedAvailable,
}
return &data
}
type CooperationContractUndertake struct {
Undertaker struct {
UsersName string `json:"userName"`
Phone string `json:"phone"`
UserId int `json:"userId,string,"`
UserCode string `json:"userCode"`
} `json:"undertaker"`
CooperationContractDescription string `json:"cooperationContractDescription"`
CooperationContractId int `json:"cooperationContractId,string,"`
CooperationContractName string `json:"cooperationContractName"`
CooperationContractNumber string `json:"cooperationContractNumber"`
CooperationContractSponsor struct {
UsersName string `json:"userName"`
Phone string `json:"phone"`
UserId int `json:"userId,string,"`
UserCode string `json:"userCode"`
} `json:"cooperationContractSponsor"`
CooperationMode struct {
CooperationModeId int `json:"cooperationModeId,string"`
CooperationModeName string `json:"cooperationModeName"`
CooperationModeNumber string `json:"cooperationModeNumber"`
} `json:"cooperationMode"`
Org struct {
OrgName string `json:"orgName"`
} `json:"org"`
Attachment []domain.Attachment `json:"attachment"`
}
func ToCooperationContractUndertake(allied_creation_cooperation.DataCooperationContractSearchByUndertaker) *CooperationContractUndertake {
data := CooperationContractUndertake{}
return &data
}