|
@@ -9,6 +9,7 @@ import ( |
|
@@ -9,6 +9,7 @@ import ( |
9
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/factory"
|
9
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/factory"
|
10
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain"
|
10
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain"
|
11
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain/service"
|
11
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain/service"
|
|
|
12
|
+ "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/dao"
|
12
|
"strconv"
|
13
|
"strconv"
|
13
|
"time"
|
14
|
"time"
|
14
|
)
|
15
|
)
|
|
@@ -90,6 +91,30 @@ func (cooperationContractService *CooperationContractService) CreateCooperationC |
|
@@ -90,6 +91,30 @@ func (cooperationContractService *CooperationContractService) CreateCooperationC |
90
|
organization = data
|
91
|
organization = data
|
91
|
}
|
92
|
}
|
92
|
|
93
|
|
|
|
94
|
+ // 共创合约DAO初始化
|
|
|
95
|
+ var cooperationContractDao *dao.CooperationContractDao
|
|
|
96
|
+ if value, err := factory.CreateCooperationContractDao(map[string]interface{}{
|
|
|
97
|
+ "transactionContext": transactionContext,
|
|
|
98
|
+ }); err != nil {
|
|
|
99
|
+ return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
100
|
+ } else {
|
|
|
101
|
+ cooperationContractDao = value
|
|
|
102
|
+ }
|
|
|
103
|
+ // 生成共创合约编号
|
|
|
104
|
+ contractNumber, err2 := cooperationContractDao.GenerateContractNumber()
|
|
|
105
|
+ if err2 != nil {
|
|
|
106
|
+ return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
107
|
+ }
|
|
|
108
|
+ // 校验共创合约编号是否唯一
|
|
|
109
|
+ numberAvailable, _ := cooperationContractDao.CheckContractNumberAvailable(map[string]interface{}{
|
|
|
110
|
+ "companyId": createCooperationContractCommand.CompanyId,
|
|
|
111
|
+ "orgId": createCooperationContractCommand.OrgId,
|
|
|
112
|
+ "cooperationContractNumber": contractNumber,
|
|
|
113
|
+ })
|
|
|
114
|
+ if !numberAvailable {
|
|
|
115
|
+ return nil, application.ThrowError(application.TRANSACTION_ERROR, "新增共创合约异常")
|
|
|
116
|
+ }
|
|
|
117
|
+
|
93
|
// 获取承接人
|
118
|
// 获取承接人
|
94
|
var undertakers []*domain.Undertaker
|
119
|
var undertakers []*domain.Undertaker
|
95
|
for _, undertaker := range createCooperationContractCommand.Undertakers {
|
120
|
for _, undertaker := range createCooperationContractCommand.Undertakers {
|
|
@@ -122,7 +147,7 @@ func (cooperationContractService *CooperationContractService) CreateCooperationC |
|
@@ -122,7 +147,7 @@ func (cooperationContractService *CooperationContractService) CreateCooperationC |
122
|
undertakers = append(undertakers, &domain.Undertaker{
|
147
|
undertakers = append(undertakers, &domain.Undertaker{
|
123
|
UndertakerId: 0,
|
148
|
UndertakerId: 0,
|
124
|
UserId: undertakerDomain.UserId,
|
149
|
UserId: undertakerDomain.UserId,
|
125
|
- CooperationContractNumber: createCooperationContractCommand.CooperationContractNumber,
|
150
|
+ CooperationContractNumber: contractNumber,
|
126
|
UserBaseId: undertakerDomain.UserBaseId,
|
151
|
UserBaseId: undertakerDomain.UserBaseId,
|
127
|
Org: undertakerDomain.Org,
|
152
|
Org: undertakerDomain.Org,
|
128
|
Orgs: undertakerDomain.Orgs,
|
153
|
Orgs: undertakerDomain.Orgs,
|
|
@@ -150,7 +175,7 @@ func (cooperationContractService *CooperationContractService) CreateCooperationC |
|
@@ -150,7 +175,7 @@ func (cooperationContractService *CooperationContractService) CreateCooperationC |
150
|
}
|
175
|
}
|
151
|
relevantPeople = append(relevantPeople, &domain.Relevant{
|
176
|
relevantPeople = append(relevantPeople, &domain.Relevant{
|
152
|
RelevantId: 0,
|
177
|
RelevantId: 0,
|
153
|
- CooperationContractNumber: createCooperationContractCommand.CooperationContractNumber,
|
178
|
+ CooperationContractNumber: contractNumber,
|
154
|
UserId: relevantDomain.UserId,
|
179
|
UserId: relevantDomain.UserId,
|
155
|
UserBaseId: relevantDomain.UserBaseId,
|
180
|
UserBaseId: relevantDomain.UserBaseId,
|
156
|
Org: relevantDomain.Org,
|
181
|
Org: relevantDomain.Org,
|
|
@@ -169,7 +194,7 @@ func (cooperationContractService *CooperationContractService) CreateCooperationC |
|
@@ -169,7 +194,7 @@ func (cooperationContractService *CooperationContractService) CreateCooperationC |
169
|
for _, dividendsIncentivesRule := range createCooperationContractCommand.DividendsIncentivesRules {
|
194
|
for _, dividendsIncentivesRule := range createCooperationContractCommand.DividendsIncentivesRules {
|
170
|
dividendsIncentivesRules = append(dividendsIncentivesRules, &domain.DividendsIncentivesRule{
|
195
|
dividendsIncentivesRules = append(dividendsIncentivesRules, &domain.DividendsIncentivesRule{
|
171
|
DividendsIncentivesRuleId: 0,
|
196
|
DividendsIncentivesRuleId: 0,
|
172
|
- CooperationContractNumber: createCooperationContractCommand.CooperationContractNumber,
|
197
|
+ CooperationContractNumber: contractNumber,
|
173
|
ReferrerPercentage: dividendsIncentivesRule.ReferrerPercentage,
|
198
|
ReferrerPercentage: dividendsIncentivesRule.ReferrerPercentage,
|
174
|
SalesmanPercentage: dividendsIncentivesRule.SalesmanPercentage,
|
199
|
SalesmanPercentage: dividendsIncentivesRule.SalesmanPercentage,
|
175
|
DividendsIncentivesPercentage: dividendsIncentivesRule.DividendsIncentivesPercentage,
|
200
|
DividendsIncentivesPercentage: dividendsIncentivesRule.DividendsIncentivesPercentage,
|
|
@@ -189,7 +214,7 @@ func (cooperationContractService *CooperationContractService) CreateCooperationC |
|
@@ -189,7 +214,7 @@ func (cooperationContractService *CooperationContractService) CreateCooperationC |
189
|
for _, moneyIncentivesRule := range createCooperationContractCommand.MoneyIncentivesRules {
|
214
|
for _, moneyIncentivesRule := range createCooperationContractCommand.MoneyIncentivesRules {
|
190
|
moneyIncentivesRules = append(moneyIncentivesRules, &domain.MoneyIncentivesRule{
|
215
|
moneyIncentivesRules = append(moneyIncentivesRules, &domain.MoneyIncentivesRule{
|
191
|
MoneyIncentivesRuleId: 0,
|
216
|
MoneyIncentivesRuleId: 0,
|
192
|
- CooperationContractNumber: createCooperationContractCommand.CooperationContractNumber,
|
217
|
+ CooperationContractNumber: contractNumber,
|
193
|
MoneyIncentivesAmount: float64(moneyIncentivesRule.MoneyIncentivesAmount),
|
218
|
MoneyIncentivesAmount: float64(moneyIncentivesRule.MoneyIncentivesAmount),
|
194
|
MoneyIncentivesStage: int64(moneyIncentivesRule.MoneyIncentivesStage),
|
219
|
MoneyIncentivesStage: int64(moneyIncentivesRule.MoneyIncentivesStage),
|
195
|
MoneyIncentivesStageEnd: moneyIncentivesRule.MoneyIncentivesStageEnd,
|
220
|
MoneyIncentivesStageEnd: moneyIncentivesRule.MoneyIncentivesStageEnd,
|
|
@@ -224,7 +249,7 @@ func (cooperationContractService *CooperationContractService) CreateCooperationC |
|
@@ -224,7 +249,7 @@ func (cooperationContractService *CooperationContractService) CreateCooperationC |
224
|
newCooperationContract := &domain.CooperationContract{
|
249
|
newCooperationContract := &domain.CooperationContract{
|
225
|
CooperationContractDescription: createCooperationContractCommand.CooperationContractDescription,
|
250
|
CooperationContractDescription: createCooperationContractCommand.CooperationContractDescription,
|
226
|
CooperationContractName: createCooperationContractCommand.CooperationContractName,
|
251
|
CooperationContractName: createCooperationContractCommand.CooperationContractName,
|
227
|
- CooperationContractNumber: createCooperationContractCommand.CooperationContractNumber,
|
252
|
+ CooperationContractNumber: contractNumber,
|
228
|
CooperationContractUndertakerTypes: createCooperationContractCommand.CooperationContractUndertakerTypes,
|
253
|
CooperationContractUndertakerTypes: createCooperationContractCommand.CooperationContractUndertakerTypes,
|
229
|
CooperationContractSponsor: sponsor,
|
254
|
CooperationContractSponsor: sponsor,
|
230
|
CooperationMode: cooperationMode,
|
255
|
CooperationMode: cooperationMode,
|