cooperation_contract.go
7.1 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
package transform
import (
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/pg/models"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/utils"
)
func TransformToCooperationContractDomainModelFromPgModels(
cooperationContractModel *models.CooperationContract,
cooperationMode *models.CooperationMode,
dividendsIncentivesRules []*models.DividendsIncentivesRule,
moneyIncentivesRules []*models.MoneyIncentivesRule,
relevantPeople []*models.CooperationContractRelevant,
undertakers []*models.CooperationContractUndertaker) (*domain.CooperationContract, error) {
// 分红激励规则
var dividendsIncentivesRulesDomain []*domain.DividendsIncentivesRule
for _, rule := range dividendsIncentivesRules {
stageString := utils.NumberToCNNumber(int(rule.DividendsIncentivesStage))
dividendsIncentivesRulesDomain = append(dividendsIncentivesRulesDomain, &domain.DividendsIncentivesRule{
DividendsIncentivesRuleId: rule.DividendsIncentivesRuleId,
CooperationContractNumber: rule.CooperationContractNumber,
ReferrerPercentage: rule.ReferrerPercentage,
SalesmanPercentage: rule.SalesmanPercentage,
DividendsIncentivesPercentage: rule.DividendsIncentivesPercentage,
DividendsIncentivesStage: rule.DividendsIncentivesStage,
DividendsIncentivesStageCN: stageString,
DividendsIncentivesStageEnd: rule.DividendsIncentivesStageEnd.Local(),
DividendsIncentivesStageStart: rule.DividendsIncentivesStageStart.Local(),
Org: rule.Org,
Company: rule.Company,
UpdatedAt: rule.UpdatedAt,
DeletedAt: rule.DeletedAt,
CreatedAt: rule.CreatedAt,
Remarks: rule.Remarks,
})
}
// 金额激励规则
var moneyIncentivesRulesDomain []*domain.MoneyIncentivesRule
for _, rule := range moneyIncentivesRules {
stageString := utils.NumberToCNNumber(int(rule.MoneyIncentivesStage))
moneyIncentivesRulesDomain = append(moneyIncentivesRulesDomain, &domain.MoneyIncentivesRule{
MoneyIncentivesRuleId: rule.MoneyIncentivesRuleId,
CooperationContractNumber: rule.CooperationContractNumber,
MoneyIncentivesAmount: rule.MoneyIncentivesAmount,
MoneyIncentivesStage: rule.MoneyIncentivesStage,
MoneyIncentivesStageCN: stageString,
MoneyIncentivesStageEnd: rule.MoneyIncentivesStageEnd,
MoneyIncentivesStageStart: rule.MoneyIncentivesStageStart,
MoneyIncentivesTime: rule.MoneyIncentivesTime.Local(),
ReferrerPercentage: rule.ReferrerPercentage,
SalesmanPercentage: rule.SalesmanPercentage,
Org: rule.Org,
Company: rule.Company,
UpdatedAt: rule.UpdatedAt,
DeletedAt: rule.DeletedAt,
CreatedAt: rule.CreatedAt,
Remarks: rule.Remarks,
})
}
// 相关人列表
var relevantPeopleDomain []*domain.Relevant
for _, relevant := range relevantPeople {
relevantPeopleDomain = append(relevantPeopleDomain, &domain.Relevant{
RelevantId: relevant.CooperationContractRelevantId,
CooperationContractNumber: relevant.CooperationContractNumber,
UserId: relevant.UserId,
UserBaseId: relevant.UserBaseId,
Org: relevant.Org,
Orgs: relevant.Orgs,
Department: relevant.Department,
Roles: relevant.Roles,
UserInfo: relevant.UserInfo,
UserType: relevant.UserType,
Status: relevant.Status,
Company: relevant.Company,
})
}
// 承接人列表
var undertakersDomain []*domain.Undertaker
for _, undertaker := range undertakers {
undertakersDomain = append(undertakersDomain, &domain.Undertaker{
UndertakerId: undertaker.CooperationContractUndertakerId,
CooperationContractNumber: undertaker.CooperationContractNumber,
CooperationContractId: undertaker.CooperationContractId,
UserId: undertaker.UserId,
UserBaseId: undertaker.UserBaseId,
Org: undertaker.Org,
Orgs: undertaker.Orgs,
Department: undertaker.Department,
Roles: undertaker.Roles,
Referrer: undertaker.Referrer,
Salesman: undertaker.Salesman,
UserInfo: undertaker.UserInfo,
UserType: undertaker.UserType,
Status: undertaker.Status,
Company: undertaker.Company,
ContractAttachment: undertaker.ContractAttachment,
})
}
return &domain.CooperationContract{
CooperationContractId: cooperationContractModel.CooperationContractId,
CooperationContractDescription: cooperationContractModel.CooperationContractDescription,
CooperationContractName: cooperationContractModel.CooperationContractName,
CooperationContractNumber: cooperationContractModel.CooperationContractNumber,
CooperationProjectNumber: cooperationContractModel.CooperationProjectNumber,
CooperationContractUndertakerTypes: cooperationContractModel.CooperationContractUndertakerTypes,
CooperationContractSponsor: cooperationContractModel.CooperationContractSponsor,
CooperationMode: &domain.CooperationMode{
CooperationModeId: cooperationMode.CooperationModeId,
CooperationModeNumber: cooperationMode.CooperationModeNumber,
CooperationModeName: cooperationMode.CooperationModeName,
Status: cooperationMode.Status,
Org: cooperationMode.Org,
Company: cooperationMode.Company,
Remarks: cooperationMode.Remarks,
Operator: cooperationMode.Operator,
OperateTime: cooperationMode.OperateTime,
UpdatedAt: cooperationMode.UpdatedAt,
DeletedAt: cooperationMode.DeletedAt,
CreatedAt: cooperationMode.CreatedAt,
},
DividendsIncentivesRules: dividendsIncentivesRulesDomain,
MoneyIncentivesRules: moneyIncentivesRulesDomain,
RelevantPeople: relevantPeopleDomain,
Undertakers: undertakersDomain,
Status: cooperationContractModel.Status,
IncentivesType: cooperationContractModel.IncentivesType,
Org: cooperationContractModel.Org,
Company: cooperationContractModel.Company,
Department: cooperationContractModel.Department,
Operator: cooperationContractModel.Operator,
OperateTime: cooperationContractModel.OperateTime,
CreatedAt: cooperationContractModel.CreatedAt,
DeletedAt: cooperationContractModel.DeletedAt,
UpdatedAt: cooperationContractModel.UpdatedAt,
CooperationProjectId: cooperationContractModel.CooperationProjectId,
}, nil
}