dto.go
8.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
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"` //合约状态
CreateTtime int `json:"createTtime"`
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"` //组织结构
}
func ToCooperationContractItem(param *allied_creation_cooperation.CooperationContract) *CooperationContractItem {
data := CooperationContractItem{
CooperationContractId: param.CooperationContractId,
CooperationProjectNumber: param.CooperationContractNumber,
CooperationContractName: param.CooperationContractName,
CooperationContractNumber: param.CooperationContractNumber,
Status: param.Status,
CreateTtime: int(param.CreatedAt.Unix()),
}
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"`
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"`
CooperationContractNumber string `json:"cooperationContractNumber"` // 关联的项目合约编号
ReferrerPercentage float64 `json:"referrerPercentage"` // 推荐人抽成比例
SalesmanPercentage float64 `json:"salesmanPercentage"` // 业务员抽成比例
DividendsIncentivesPercentage float64 `json:"dividendsIncentivesPercentage"` // 分红规则激励百分点
DividendsIncentivesStage int `json:"dividendsIncentivesStage,string"` // 分红规则激励阶段,
DividendsIncentivesStageEnd int64 `json:"dividendsIncentivesStageEnd"` // 分红规则激励阶段结束
DividendsIncentivesStageStart int64 `json:"dividendsIncentivesStageStart"` // 分红规则激励阶段开始
}
type Relevant struct {
UserId int `json:"userId"`
UserInfo domain.UserInfo `json:"userInfo"`
Department domain.Department `json:"department"`
}
type ContractUndertaker struct {
Attachment []domain.Attachment `json:"attachment"`
Department domain.Department `json:"department"`
HasReferrer bool `json:"hasReferrer"`
HasSalesman bool `json:"hasSalesman"`
ReferrerUser domain.UserInfo `json:"referrerUser"`
SalesmanUser domain.UserInfo `json:"salesmanUser"`
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"`
}
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,
DividendsIncentivesPercentage: v.DividendsIncentivesPercentage,
DividendsIncentivesStage: v.DividendsIncentivesStage,
DividendsIncentivesStageEnd: v.DividendsIncentivesStageEnd.Unix(),
DividendsIncentivesStageStart: v.DividendsIncentivesStageStart.Unix(),
}
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.Unix(),
ReferrerPercentage: v.ReferrerPercentage,
SalesmanPercentage: v.SalesmanPercentage,
}
moneyIncentivesRules = append(moneyIncentivesRules, r)
}
for _, v := range param.Undertakers {
u := ContractUndertaker{
Attachment: v.ContractAttachment,
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,
ReferrerUser: domain.UserInfo{
UsersName: v.Referrer.UserInfo.UserName,
Phone: v.Referrer.UserInfo.UserPhone,
UsersId: v.Referrer.UserId,
// UserCode :v.
},
SalesmanUser: domain.UserInfo{
UsersName: v.Salesman.UserInfo.UserName,
UsersId: v.Salesman.UserId,
Phone: v.Salesman.UserInfo.UserPhone,
},
UserInfo: domain.UserInfo{
UsersName: v.UserInfo.UserName,
UsersId: v.UserId,
Phone: v.UserInfo.UserPhone,
},
}
contractUndertaker = append(contractUndertaker, u)
}
data := CooperationContractInfo{
CooperationContract: *ToCooperationContractItem(param),
Relevant: relevants,
DividendsIncentivesRules: dividendsIncentivesRules,
MoneyIncentivesRules: moneyIncentivesRules,
ContractUndertaker: contractUndertaker,
}
return &data
}