合并分支 'dev' 到 'test'
Dev 查看合并请求 !85
正在显示
11 个修改的文件
包含
253 行增加
和
39 行删除
@@ -7,6 +7,7 @@ import ( | @@ -7,6 +7,7 @@ import ( | ||
7 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/cooperationApplication/command" | 7 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/cooperationApplication/command" |
8 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/cooperationApplication/dto" | 8 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/cooperationApplication/dto" |
9 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/cooperationApplication/query" | 9 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/cooperationApplication/query" |
10 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/event/subscriber" | ||
10 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/factory" | 11 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/factory" |
11 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain" | 12 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain" |
12 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain/service" | 13 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain/service" |
@@ -346,6 +347,32 @@ func (cooperationApplicationService *CooperationApplicationService) BatchApprova | @@ -346,6 +347,32 @@ func (cooperationApplicationService *CooperationApplicationService) BatchApprova | ||
346 | cooperationApplicationRepository = value | 347 | cooperationApplicationRepository = value |
347 | } | 348 | } |
348 | 349 | ||
350 | + // 同意共创申请消息推送领域服务初始化 | ||
351 | + var agreeContractApplicationService service.AgreeContractApplicationService | ||
352 | + if value, err := factory.CreateAgreeContractApplicationService(map[string]interface{}{ | ||
353 | + //"transactionContext": transactionContext, | ||
354 | + }); err != nil { | ||
355 | + return []interface{}{}, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
356 | + } else { | ||
357 | + agreeContractApplicationService = value | ||
358 | + _ = agreeContractApplicationService.Subscribe(&subscriber.MessageServiceSubscriber{ | ||
359 | + //TransactionContext: transactionContext.(*pgTransaction.TransactionContext), | ||
360 | + }) | ||
361 | + } | ||
362 | + | ||
363 | + // 拒绝共创申请消息推送领域服务初始化 | ||
364 | + var rejectContractApplicationService service.RejectContractApplicationService | ||
365 | + if value, err := factory.CreateRejectContractApplicationService(map[string]interface{}{ | ||
366 | + //"transactionContext": transactionContext, | ||
367 | + }); err != nil { | ||
368 | + return []interface{}{}, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
369 | + } else { | ||
370 | + rejectContractApplicationService = value | ||
371 | + _ = rejectContractApplicationService.Subscribe(&subscriber.MessageServiceSubscriber{ | ||
372 | + //TransactionContext: transactionContext.(*pgTransaction.TransactionContext), | ||
373 | + }) | ||
374 | + } | ||
375 | + | ||
349 | // 共创申请ID类型转换 | 376 | // 共创申请ID类型转换 |
350 | cooperationApplicationIds, err := utils.SliceAtoi(batchApprovalCooperationApplicationCommand.CooperationApplicationIds) | 377 | cooperationApplicationIds, err := utils.SliceAtoi(batchApprovalCooperationApplicationCommand.CooperationApplicationIds) |
351 | if err != nil { | 378 | if err != nil { |
@@ -379,7 +406,7 @@ func (cooperationApplicationService *CooperationApplicationService) BatchApprova | @@ -379,7 +406,7 @@ func (cooperationApplicationService *CooperationApplicationService) BatchApprova | ||
379 | for i, cooperationApplication := range cooperationApplications { | 406 | for i, cooperationApplication := range cooperationApplications { |
380 | // 校验共创申请是否已经审核过 | 407 | // 校验共创申请是否已经审核过 |
381 | if cooperationApplication.CooperationApplicationStatus != 1 { | 408 | if cooperationApplication.CooperationApplicationStatus != 1 { |
382 | - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "改申请已经审核过") | 409 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "该申请已经审核过") |
383 | } | 410 | } |
384 | // 更新共创申请数据 | 411 | // 更新共创申请数据 |
385 | cooperationApplications[i].CooperationApplicationVerifyDescription = batchApprovalCooperationApplicationCommand.CooperationApplicationVerifyDescription | 412 | cooperationApplications[i].CooperationApplicationVerifyDescription = batchApprovalCooperationApplicationCommand.CooperationApplicationVerifyDescription |
@@ -392,13 +419,45 @@ func (cooperationApplicationService *CooperationApplicationService) BatchApprova | @@ -392,13 +419,45 @@ func (cooperationApplicationService *CooperationApplicationService) BatchApprova | ||
392 | cooperationApplications[i].CooperationApplicationVerifyTime = time.Now() | 419 | cooperationApplications[i].CooperationApplicationVerifyTime = time.Now() |
393 | cooperationApplications[i].IsCanceled = 1 | 420 | cooperationApplications[i].IsCanceled = 1 |
394 | } | 421 | } |
422 | + | ||
395 | cooperationApplicationsApproved, err := cooperationApplicationRepository.UpdateMany(cooperationApplications) | 423 | cooperationApplicationsApproved, err := cooperationApplicationRepository.UpdateMany(cooperationApplications) |
396 | if err != nil { | 424 | if err != nil { |
397 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 425 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
398 | } | 426 | } |
427 | + | ||
399 | if err := transactionContext.CommitTransaction(); err != nil { | 428 | if err := transactionContext.CommitTransaction(); err != nil { |
400 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 429 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
401 | } | 430 | } |
431 | + | ||
432 | + // 推送消息 | ||
433 | + for _, cooperationApplicationApproved := range cooperationApplicationsApproved { | ||
434 | + if cooperationApplicationApproved.CooperationApplicationStatus == 2 { | ||
435 | + if err1 := agreeContractApplicationService.Agree( | ||
436 | + cooperationApplicationApproved.CooperationProject.CooperationProjectId, | ||
437 | + cooperationApplicationApproved.CooperationProject.CooperationProjectName, | ||
438 | + cooperationApplicationApproved.CooperationProject.CooperationProjectNumber, | ||
439 | + cooperationApplicationApproved.CooperationApplicationApplicant.UserId, | ||
440 | + cooperationApplicationApproved.CooperationApplicationApplicant.UserBaseId, | ||
441 | + cooperationApplicationApproved.CooperationProject.Org.OrgId, | ||
442 | + cooperationApplicationApproved.CooperationProject.Company.CompanyId, | ||
443 | + ); err1 != nil { | ||
444 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err1.Error()) | ||
445 | + } | ||
446 | + } else if cooperationApplicationApproved.CooperationApplicationStatus == 3 { | ||
447 | + if err2 := rejectContractApplicationService.Reject( | ||
448 | + cooperationApplicationApproved.CooperationProject.CooperationProjectId, | ||
449 | + cooperationApplicationApproved.CooperationProject.CooperationProjectName, | ||
450 | + cooperationApplicationApproved.CooperationProject.CooperationProjectNumber, | ||
451 | + cooperationApplicationApproved.CooperationApplicationApplicant.UserId, | ||
452 | + cooperationApplicationApproved.CooperationApplicationApplicant.UserBaseId, | ||
453 | + cooperationApplicationApproved.CooperationProject.Org.OrgId, | ||
454 | + cooperationApplicationApproved.CooperationProject.Company.CompanyId, | ||
455 | + ); err2 != nil { | ||
456 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err2.Error()) | ||
457 | + } | ||
458 | + } | ||
459 | + } | ||
460 | + | ||
402 | return map[string]interface{}{ | 461 | return map[string]interface{}{ |
403 | "cooperationApplications": cooperationApplicationsApproved, | 462 | "cooperationApplications": cooperationApplicationsApproved, |
404 | }, nil | 463 | }, nil |
@@ -1019,14 +1019,14 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC | @@ -1019,14 +1019,14 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC | ||
1019 | CooperationContractNumber: cooperationContract.CooperationContractNumber, | 1019 | CooperationContractNumber: cooperationContract.CooperationContractNumber, |
1020 | UserId: relevantDomain.UserId, | 1020 | UserId: relevantDomain.UserId, |
1021 | UserBaseId: relevantDomain.UserBaseId, | 1021 | UserBaseId: relevantDomain.UserBaseId, |
1022 | - Org: relevantDomain.Org, | 1022 | + Org: organization, |
1023 | Orgs: relevantDomain.Orgs, | 1023 | Orgs: relevantDomain.Orgs, |
1024 | Department: relevantDomain.Department, | 1024 | Department: relevantDomain.Department, |
1025 | Roles: relevantDomain.Roles, | 1025 | Roles: relevantDomain.Roles, |
1026 | UserInfo: relevantDomain.UserInfo, | 1026 | UserInfo: relevantDomain.UserInfo, |
1027 | UserType: relevantDomain.UserType, | 1027 | UserType: relevantDomain.UserType, |
1028 | Status: relevantDomain.Status, | 1028 | Status: relevantDomain.Status, |
1029 | - Company: relevantDomain.Company, | 1029 | + Company: company, |
1030 | }) | 1030 | }) |
1031 | } | 1031 | } |
1032 | 1032 | ||
@@ -1114,7 +1114,7 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC | @@ -1114,7 +1114,7 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC | ||
1114 | CooperationContractNumber: cooperationContract.CooperationContractNumber, | 1114 | CooperationContractNumber: cooperationContract.CooperationContractNumber, |
1115 | CooperationContractId: cooperationContract.CooperationContractId, | 1115 | CooperationContractId: cooperationContract.CooperationContractId, |
1116 | UserBaseId: undertakerDomain.UserBaseId, | 1116 | UserBaseId: undertakerDomain.UserBaseId, |
1117 | - Org: undertakerDomain.Org, | 1117 | + Org: organization, |
1118 | Orgs: undertakerDomain.Orgs, | 1118 | Orgs: undertakerDomain.Orgs, |
1119 | Department: undertakerDomain.Department, | 1119 | Department: undertakerDomain.Department, |
1120 | Roles: undertakerDomain.Roles, | 1120 | Roles: undertakerDomain.Roles, |
@@ -1123,7 +1123,7 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC | @@ -1123,7 +1123,7 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC | ||
1123 | Referrer: referrerDomain, | 1123 | Referrer: referrerDomain, |
1124 | Salesman: salesmanDomain, | 1124 | Salesman: salesmanDomain, |
1125 | Status: undertakerDomain.Status, | 1125 | Status: undertakerDomain.Status, |
1126 | - Company: undertakerDomain.Company, | 1126 | + Company: company, |
1127 | ContractAttachment: contractAttachments, | 1127 | ContractAttachment: contractAttachments, |
1128 | }) | 1128 | }) |
1129 | } | 1129 | } |
@@ -1275,7 +1275,7 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC | @@ -1275,7 +1275,7 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC | ||
1275 | for _, rule := range cooperationContractFound.DividendsIncentivesRules { | 1275 | for _, rule := range cooperationContractFound.DividendsIncentivesRules { |
1276 | jsons, errs := json.Marshal(rule) | 1276 | jsons, errs := json.Marshal(rule) |
1277 | if errs != nil { | 1277 | if errs != nil { |
1278 | - (errs.Error()) | 1278 | + fmt.Printf(errs.Error()) |
1279 | } | 1279 | } |
1280 | cooperationContractFoundBytes = append(cooperationContractFoundBytes, jsons...) | 1280 | cooperationContractFoundBytes = append(cooperationContractFoundBytes, jsons...) |
1281 | } | 1281 | } |
@@ -1288,7 +1288,7 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC | @@ -1288,7 +1288,7 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC | ||
1288 | for _, rule := range cooperationContract.DividendsIncentivesRules { | 1288 | for _, rule := range cooperationContract.DividendsIncentivesRules { |
1289 | jsons, errs := json.Marshal(rule) | 1289 | jsons, errs := json.Marshal(rule) |
1290 | if errs != nil { | 1290 | if errs != nil { |
1291 | - (errs.Error()) | 1291 | + fmt.Printf(errs.Error()) |
1292 | } | 1292 | } |
1293 | cooperationContractBytes = append(cooperationContractBytes, jsons...) | 1293 | cooperationContractBytes = append(cooperationContractBytes, jsons...) |
1294 | } | 1294 | } |
@@ -1331,7 +1331,7 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC | @@ -1331,7 +1331,7 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC | ||
1331 | for _, rule := range cooperationContractFound.MoneyIncentivesRules { | 1331 | for _, rule := range cooperationContractFound.MoneyIncentivesRules { |
1332 | jsons, errs := json.Marshal(rule) | 1332 | jsons, errs := json.Marshal(rule) |
1333 | if errs != nil { | 1333 | if errs != nil { |
1334 | - (errs.Error()) | 1334 | + fmt.Printf(errs.Error()) |
1335 | } | 1335 | } |
1336 | cooperationContractFoundBytes = append(cooperationContractFoundBytes, jsons...) | 1336 | cooperationContractFoundBytes = append(cooperationContractFoundBytes, jsons...) |
1337 | } | 1337 | } |
@@ -1344,7 +1344,7 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC | @@ -1344,7 +1344,7 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC | ||
1344 | for _, rule := range cooperationContract.MoneyIncentivesRules { | 1344 | for _, rule := range cooperationContract.MoneyIncentivesRules { |
1345 | jsons, errs := json.Marshal(rule) | 1345 | jsons, errs := json.Marshal(rule) |
1346 | if errs != nil { | 1346 | if errs != nil { |
1347 | - (errs.Error()) | 1347 | + fmt.Printf(errs.Error()) |
1348 | } | 1348 | } |
1349 | cooperationContractBytes = append(cooperationContractBytes, jsons...) | 1349 | cooperationContractBytes = append(cooperationContractBytes, jsons...) |
1350 | } | 1350 | } |
@@ -1388,7 +1388,7 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC | @@ -1388,7 +1388,7 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC | ||
1388 | for _, undertaker := range cooperationContractFound.Undertakers { | 1388 | for _, undertaker := range cooperationContractFound.Undertakers { |
1389 | jsons, errs := json.Marshal(undertaker) | 1389 | jsons, errs := json.Marshal(undertaker) |
1390 | if errs != nil { | 1390 | if errs != nil { |
1391 | - (errs.Error()) | 1391 | + fmt.Printf(errs.Error()) |
1392 | } | 1392 | } |
1393 | cooperationContractFoundBytes = append(cooperationContractFoundBytes, jsons...) | 1393 | cooperationContractFoundBytes = append(cooperationContractFoundBytes, jsons...) |
1394 | } | 1394 | } |
@@ -1400,7 +1400,7 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC | @@ -1400,7 +1400,7 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC | ||
1400 | for _, undertaker := range cooperationContract.Undertakers { | 1400 | for _, undertaker := range cooperationContract.Undertakers { |
1401 | jsons, errs := json.Marshal(undertaker) //转换成JSON返回的是byte[] | 1401 | jsons, errs := json.Marshal(undertaker) //转换成JSON返回的是byte[] |
1402 | if errs != nil { | 1402 | if errs != nil { |
1403 | - (errs.Error()) | 1403 | + fmt.Printf(errs.Error()) |
1404 | } | 1404 | } |
1405 | cooperationContractBytes = append(cooperationContractBytes, jsons...) | 1405 | cooperationContractBytes = append(cooperationContractBytes, jsons...) |
1406 | } | 1406 | } |
@@ -1441,7 +1441,7 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC | @@ -1441,7 +1441,7 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC | ||
1441 | UserPhone: "", | 1441 | UserPhone: "", |
1442 | } | 1442 | } |
1443 | } | 1443 | } |
1444 | - undertakersOriginal = undertakersOriginal + strconv.FormatInt(int64(i+1), 10) + "(" + undertaker.UserInfo.UserName + "," + undertaker.Referrer.UserName + "," + undertaker.Salesman.UserName + ")" | 1444 | + undertakersOriginal = undertakersOriginal + strconv.FormatInt(int64(i+1), 10) + "(" + undertaker.UserInfo.UserName + "," + undertaker.Referrer.UserName + "," + undertaker.Salesman.UserName + ")" |
1445 | } | 1445 | } |
1446 | undertakerChangeTmp1 := "【" + undertakersOriginal + "】" | 1446 | undertakerChangeTmp1 := "【" + undertakersOriginal + "】" |
1447 | 1447 | ||
@@ -1478,7 +1478,7 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC | @@ -1478,7 +1478,7 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC | ||
1478 | UserPhone: "", | 1478 | UserPhone: "", |
1479 | } | 1479 | } |
1480 | } | 1480 | } |
1481 | - undertakersChanged = undertakersChanged + strconv.FormatInt(int64(i+1), 10) + "(" + undertaker.UserInfo.UserName + "," + undertaker.Referrer.UserName + "," + undertaker.Salesman.UserName + ")" | 1481 | + undertakersChanged = undertakersChanged + strconv.FormatInt(int64(i+1), 10) + "(" + undertaker.UserInfo.UserName + "," + undertaker.Referrer.UserName + "," + undertaker.Salesman.UserName + ")" |
1482 | } | 1482 | } |
1483 | undertakerChangeTemp2 := "【" + undertakersChanged + "】" | 1483 | undertakerChangeTemp2 := "【" + undertakersChanged + "】" |
1484 | // 拼接承接人变更记录 | 1484 | // 拼接承接人变更记录 |
@@ -1501,9 +1501,11 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC | @@ -1501,9 +1501,11 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC | ||
1501 | } | 1501 | } |
1502 | 1502 | ||
1503 | // 保存共创合约变更记录 | 1503 | // 保存共创合约变更记录 |
1504 | + if newCooperationContractChangeLog.IncentivesRule != "" || newCooperationContractChangeLog.IncentivesRuleDetail != "" || newCooperationContractChangeLog.Undertakers != "" { | ||
1504 | if _, err20 := cooperationContractChangeLogRepository.Save(newCooperationContractChangeLog); err20 != nil { | 1505 | if _, err20 := cooperationContractChangeLogRepository.Save(newCooperationContractChangeLog); err20 != nil { |
1505 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err20.Error()) | 1506 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err20.Error()) |
1506 | } | 1507 | } |
1508 | + } | ||
1507 | if err21 := transactionContext.CommitTransaction(); err21 != nil { | 1509 | if err21 := transactionContext.CommitTransaction(); err21 != nil { |
1508 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err21.Error()) | 1510 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err21.Error()) |
1509 | } | 1511 | } |
@@ -2,14 +2,13 @@ package subscriber | @@ -2,14 +2,13 @@ package subscriber | ||
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | coreDomain "github.com/linmadan/egglib-go/core/domain" | 4 | coreDomain "github.com/linmadan/egglib-go/core/domain" |
5 | - pgTransaction "github.com/linmadan/egglib-go/transaction/pg" | ||
6 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/factory" | 5 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/factory" |
7 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain/event" | 6 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain/event" |
8 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/log" | 7 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/log" |
9 | ) | 8 | ) |
10 | 9 | ||
11 | type MessageServiceSubscriber struct { | 10 | type MessageServiceSubscriber struct { |
12 | - TransactionContext *pgTransaction.TransactionContext | 11 | + //TransactionContext *pgTransaction.TransactionContext |
13 | } | 12 | } |
14 | 13 | ||
15 | func (subscriber *MessageServiceSubscriber) HandleEvent(domainEvent coreDomain.DomainEvent) error { | 14 | func (subscriber *MessageServiceSubscriber) HandleEvent(domainEvent coreDomain.DomainEvent) error { |
@@ -53,3 +53,21 @@ func CreateCancelDividendsEstimateService(options map[string]interface{}) (*doma | @@ -53,3 +53,21 @@ func CreateCancelDividendsEstimateService(options map[string]interface{}) (*doma | ||
53 | } | 53 | } |
54 | return domain_service.NewCancelDividendsEstimateService(transactionContext) | 54 | return domain_service.NewCancelDividendsEstimateService(transactionContext) |
55 | } | 55 | } |
56 | + | ||
57 | +func CreateAgreeContractApplicationService(options map[string]interface{}) (*domain_service.AgreeContractApplicationService, error) { | ||
58 | + //var transactionContext *pgTransaction.TransactionContext | ||
59 | + //if value, ok := options["transactionContext"]; ok { | ||
60 | + // transactionContext = value.(*pgTransaction.TransactionContext) | ||
61 | + //} | ||
62 | + //return domain_service.NewAgreeContractApplicationService(transactionContext) | ||
63 | + return domain_service.NewAgreeContractApplicationService(nil) | ||
64 | +} | ||
65 | + | ||
66 | +func CreateRejectContractApplicationService(options map[string]interface{}) (*domain_service.RejectContractApplicationService, error) { | ||
67 | + //var transactionContext *pgTransaction.TransactionContext | ||
68 | + //if value, ok := options["transactionContext"]; ok { | ||
69 | + // transactionContext = value.(*pgTransaction.TransactionContext) | ||
70 | + //} | ||
71 | + //return domain_service.NewRejectContractApplicationService(transactionContext) | ||
72 | + return domain_service.NewRejectContractApplicationService(nil) | ||
73 | +} |
@@ -4,5 +4,5 @@ import coreDomain "github.com/linmadan/egglib-go/core/domain" | @@ -4,5 +4,5 @@ import coreDomain "github.com/linmadan/egglib-go/core/domain" | ||
4 | 4 | ||
5 | type AgreeContractApplicationService interface { | 5 | type AgreeContractApplicationService interface { |
6 | coreDomain.DomainEventPublisher | 6 | coreDomain.DomainEventPublisher |
7 | - Agree() error | 7 | + Agree(creationProjectId int64, creationProjectName string, creationProjectNumber string, userId int64, userBaseId int64, orgId int64, companyId int64) error |
8 | } | 8 | } |
@@ -4,5 +4,5 @@ import coreDomain "github.com/linmadan/egglib-go/core/domain" | @@ -4,5 +4,5 @@ import coreDomain "github.com/linmadan/egglib-go/core/domain" | ||
4 | 4 | ||
5 | type RejectContractApplicationService interface { | 5 | type RejectContractApplicationService interface { |
6 | coreDomain.DomainEventPublisher | 6 | coreDomain.DomainEventPublisher |
7 | - Reject() error | 7 | + Reject(creationProjectId int64, creationProjectName string, creationProjectNumber string, userId int64, userBaseId int64, orgId int64, companyId int64) error |
8 | } | 8 | } |
1 | +package domain_service | ||
2 | + | ||
3 | +import ( | ||
4 | + coreDomain "github.com/linmadan/egglib-go/core/domain" | ||
5 | + pgTransaction "github.com/linmadan/egglib-go/transaction/pg" | ||
6 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain/event" | ||
7 | +) | ||
8 | + | ||
9 | +type AgreeContractApplicationService struct { | ||
10 | + coreDomain.BaseEventPublisher | ||
11 | + //transactionContext *pgTransaction.TransactionContext | ||
12 | +} | ||
13 | + | ||
14 | +func (service *AgreeContractApplicationService) Agree(creationProjectId int64, creationProjectName string, creationProjectNumber string, userId int64, userBaseId int64, orgId int64, companyId int64) error { | ||
15 | + cooperationApplicationAgreedEvent := new(event.CooperationApplicationAgreed) | ||
16 | + cooperationApplicationAgreedEvent.CreationProjectId = creationProjectId | ||
17 | + cooperationApplicationAgreedEvent.CreationProjectName = creationProjectName | ||
18 | + cooperationApplicationAgreedEvent.CreationProjectNumber = creationProjectNumber | ||
19 | + cooperationApplicationAgreedEvent.UserId = userId | ||
20 | + cooperationApplicationAgreedEvent.UserBaseId = userBaseId | ||
21 | + cooperationApplicationAgreedEvent.OrgId = orgId | ||
22 | + cooperationApplicationAgreedEvent.CompanyId = companyId | ||
23 | + if err := service.Publish(cooperationApplicationAgreedEvent); err != nil { | ||
24 | + return err | ||
25 | + } | ||
26 | + return nil | ||
27 | +} | ||
28 | + | ||
29 | +func NewAgreeContractApplicationService(transactionContext *pgTransaction.TransactionContext) (*AgreeContractApplicationService, error) { | ||
30 | + //if transactionContext == nil { | ||
31 | + // return nil, fmt.Errorf("transactionContext参数不能为nil") | ||
32 | + //} else { | ||
33 | + // return &AgreeContractApplicationService{ | ||
34 | + // transactionContext: transactionContext, | ||
35 | + // }, nil | ||
36 | + //} | ||
37 | + return &AgreeContractApplicationService{}, nil | ||
38 | +} |
1 | +package domain_service | ||
2 | + | ||
3 | +import ( | ||
4 | + coreDomain "github.com/linmadan/egglib-go/core/domain" | ||
5 | + pgTransaction "github.com/linmadan/egglib-go/transaction/pg" | ||
6 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain/event" | ||
7 | +) | ||
8 | + | ||
9 | +type RejectContractApplicationService struct { | ||
10 | + coreDomain.BaseEventPublisher | ||
11 | + //transactionContext *pgTransaction.TransactionContext | ||
12 | +} | ||
13 | + | ||
14 | +func (service *RejectContractApplicationService) Reject(creationProjectId int64, creationProjectName string, creationProjectNumber string, userId int64, userBaseId int64, orgId int64, companyId int64) error { | ||
15 | + cooperationApplicationRejectedEvent := new(event.CooperationApplicationRejected) | ||
16 | + cooperationApplicationRejectedEvent.CreationProjectId = creationProjectId | ||
17 | + cooperationApplicationRejectedEvent.CreationProjectName = creationProjectName | ||
18 | + cooperationApplicationRejectedEvent.CreationProjectNumber = creationProjectNumber | ||
19 | + cooperationApplicationRejectedEvent.UserId = userId | ||
20 | + cooperationApplicationRejectedEvent.UserBaseId = userBaseId | ||
21 | + cooperationApplicationRejectedEvent.OrgId = orgId | ||
22 | + cooperationApplicationRejectedEvent.CompanyId = companyId | ||
23 | + if err := service.Publish(cooperationApplicationRejectedEvent); err != nil { | ||
24 | + return err | ||
25 | + } | ||
26 | + return nil | ||
27 | +} | ||
28 | + | ||
29 | +func NewRejectContractApplicationService(transactionContext *pgTransaction.TransactionContext) (*RejectContractApplicationService, error) { | ||
30 | + //if transactionContext == nil { | ||
31 | + // return nil, fmt.Errorf("transactionContext参数不能为nil") | ||
32 | + //} else { | ||
33 | + // return &RejectContractApplicationService{ | ||
34 | + // transactionContext: transactionContext, | ||
35 | + // }, nil | ||
36 | + //} | ||
37 | + return &RejectContractApplicationService{}, nil | ||
38 | +} |
@@ -82,6 +82,7 @@ func TransformToCooperationContractDomainModelFromPgModels( | @@ -82,6 +82,7 @@ func TransformToCooperationContractDomainModelFromPgModels( | ||
82 | undertakersDomain = append(undertakersDomain, &domain.Undertaker{ | 82 | undertakersDomain = append(undertakersDomain, &domain.Undertaker{ |
83 | UndertakerId: undertaker.CooperationContractUndertakerId, | 83 | UndertakerId: undertaker.CooperationContractUndertakerId, |
84 | CooperationContractNumber: undertaker.CooperationContractNumber, | 84 | CooperationContractNumber: undertaker.CooperationContractNumber, |
85 | + CooperationContractId: undertaker.CooperationContractId, | ||
85 | UserId: undertaker.UserId, | 86 | UserId: undertaker.UserId, |
86 | UserBaseId: undertaker.UserBaseId, | 87 | UserBaseId: undertaker.UserBaseId, |
87 | Org: undertaker.Org, | 88 | Org: undertaker.Org, |
@@ -327,9 +327,9 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai | @@ -327,9 +327,9 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai | ||
327 | var cooperationContractRelevantPeopleToAdd []*domain.Relevant | 327 | var cooperationContractRelevantPeopleToAdd []*domain.Relevant |
328 | for _, relevant := range cooperationContract.RelevantPeople { | 328 | for _, relevant := range cooperationContract.RelevantPeople { |
329 | if relevant.RelevantId != 0 { | 329 | if relevant.RelevantId != 0 { |
330 | - cooperationContractRelevantPeopleToUpdate = append(cooperationContractRelevantPeopleToUpdate, relevant) | 330 | + cooperationContractRelevantPeopleToUpdate = append(cooperationContractRelevantPeopleToUpdate, relevant) // 提取待更新的相关人 |
331 | } else { | 331 | } else { |
332 | - cooperationContractRelevantPeopleToAdd = append(cooperationContractRelevantPeopleToAdd, relevant) | 332 | + cooperationContractRelevantPeopleToAdd = append(cooperationContractRelevantPeopleToAdd, relevant) // 提取待添加的相关人 |
333 | } | 333 | } |
334 | } | 334 | } |
335 | 335 | ||
@@ -379,13 +379,41 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai | @@ -379,13 +379,41 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai | ||
379 | // 待更新的相关人id | 379 | // 待更新的相关人id |
380 | relevantIdsToUpdate := utils.Intersect(cooperationContractRelevantIdsFetched, cooperationContractRelevantPeopleToUpdateOrDeleteIds) | 380 | relevantIdsToUpdate := utils.Intersect(cooperationContractRelevantIdsFetched, cooperationContractRelevantPeopleToUpdateOrDeleteIds) |
381 | var relevantModelsToUpdate []*models.CooperationContractRelevant | 381 | var relevantModelsToUpdate []*models.CooperationContractRelevant |
382 | + var relevantDomainsToUpdate []*domain.Relevant | ||
382 | for _, id := range relevantIdsToUpdate { | 383 | for _, id := range relevantIdsToUpdate { |
383 | - for _, relevantModel := range cooperationContractRelevantModelsFetched { | ||
384 | - if relevantModel.CooperationContractRelevantId == id { | ||
385 | - relevantModelsToUpdate = append(relevantModelsToUpdate, relevantModel) | 384 | + //for _, relevantModel := range cooperationContractRelevantModelsFetched { |
385 | + // if relevantModel.CooperationContractRelevantId == id { | ||
386 | + // relevantModelsToUpdate = append(relevantModelsToUpdate, relevantModel) | ||
387 | + // } | ||
388 | + //} | ||
389 | + for _, relevantDomain := range cooperationContract.RelevantPeople { | ||
390 | + if relevantDomain.RelevantId == id { | ||
391 | + relevantDomainsToUpdate = append(relevantDomainsToUpdate, relevantDomain) | ||
386 | } | 392 | } |
387 | } | 393 | } |
388 | } | 394 | } |
395 | + | ||
396 | + // domain to model | ||
397 | + for _, relevantDomainToUpdate := range relevantDomainsToUpdate { | ||
398 | + relevantModelsToUpdate = append(relevantModelsToUpdate, &models.CooperationContractRelevant{ | ||
399 | + CooperationContractRelevantId: relevantDomainToUpdate.RelevantId, | ||
400 | + CooperationContractNumber: relevantDomainToUpdate.CooperationContractNumber, | ||
401 | + UserId: relevantDomainToUpdate.UserId, | ||
402 | + UserBaseId: relevantDomainToUpdate.UserBaseId, | ||
403 | + Org: relevantDomainToUpdate.Org, | ||
404 | + Orgs: relevantDomainToUpdate.Orgs, | ||
405 | + Department: relevantDomainToUpdate.Department, | ||
406 | + Roles: relevantDomainToUpdate.Roles, | ||
407 | + UserInfo: relevantDomainToUpdate.UserInfo, | ||
408 | + UserType: relevantDomainToUpdate.UserType, | ||
409 | + Status: relevantDomainToUpdate.Status, | ||
410 | + Company: relevantDomainToUpdate.Company, | ||
411 | + UpdatedAt: time.Now(), | ||
412 | + DeletedAt: time.Time{}, | ||
413 | + CreatedAt: time.Time{}, | ||
414 | + }) | ||
415 | + } | ||
416 | + | ||
389 | if len(relevantModelsToUpdate) > 0 { | 417 | if len(relevantModelsToUpdate) > 0 { |
390 | if _, err := tx.Model(&relevantModelsToUpdate).WherePK().Update(); err != nil { | 418 | if _, err := tx.Model(&relevantModelsToUpdate).WherePK().Update(); err != nil { |
391 | return nil, err | 419 | return nil, err |
@@ -410,6 +438,7 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai | @@ -410,6 +438,7 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai | ||
410 | return nil, err | 438 | return nil, err |
411 | } | 439 | } |
412 | } | 440 | } |
441 | + /***************************************************************/ | ||
413 | 442 | ||
414 | /************************* 更新承接人 ****************************/ | 443 | /************************* 更新承接人 ****************************/ |
415 | // 获取承接人列表 | 444 | // 获取承接人列表 |
@@ -431,6 +460,7 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai | @@ -431,6 +460,7 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai | ||
431 | 460 | ||
432 | // 待更新相关人 | 461 | // 待更新相关人 |
433 | var cooperationContractUndertakersToUpdate []*domain.Undertaker | 462 | var cooperationContractUndertakersToUpdate []*domain.Undertaker |
463 | + | ||
434 | // 待添加相关人 | 464 | // 待添加相关人 |
435 | var cooperationContractUndertakersToAdd []*domain.Undertaker | 465 | var cooperationContractUndertakersToAdd []*domain.Undertaker |
436 | for _, undertaker := range cooperationContract.Undertakers { | 466 | for _, undertaker := range cooperationContract.Undertakers { |
@@ -554,6 +584,7 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai | @@ -554,6 +584,7 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai | ||
554 | return nil, err | 584 | return nil, err |
555 | } | 585 | } |
556 | } | 586 | } |
587 | + /*****************************************************************/ | ||
557 | 588 | ||
558 | /************************ 更新分红激励规则 **************************/ | 589 | /************************ 更新分红激励规则 **************************/ |
559 | // 获取分红激励规则列表 | 590 | // 获取分红激励规则列表 |
@@ -687,6 +718,7 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai | @@ -687,6 +718,7 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai | ||
687 | return nil, err | 718 | return nil, err |
688 | } | 719 | } |
689 | } | 720 | } |
721 | + /***************************************************************/ | ||
690 | 722 | ||
691 | /********************** 更新金额激励规则 **************************/ | 723 | /********************** 更新金额激励规则 **************************/ |
692 | var moneyIncentivesRulesFetched []*models.MoneyIncentivesRule | 724 | var moneyIncentivesRulesFetched []*models.MoneyIncentivesRule |
@@ -12,22 +12,35 @@ import ( | @@ -12,22 +12,35 @@ import ( | ||
12 | 12 | ||
13 | // Intersect 返回两个数组的交集 | 13 | // Intersect 返回两个数组的交集 |
14 | func Intersect(nums1 []int64, nums2 []int64) []int64 { | 14 | func Intersect(nums1 []int64, nums2 []int64) []int64 { |
15 | - if len(nums1) > len(nums2) { | ||
16 | - return Intersect(nums2, nums1) | 15 | + //if len(nums1) > len(nums2) { |
16 | + // return Intersect(nums2, nums1) | ||
17 | + //} | ||
18 | + //m := map[int64]int64{} | ||
19 | + //for _, num := range nums1 { | ||
20 | + // m[num]++ | ||
21 | + //} | ||
22 | + // | ||
23 | + //var intersection []int64 | ||
24 | + //for _, num := range nums2 { | ||
25 | + // if m[num] > 0 { | ||
26 | + // intersection = append(intersection, num) | ||
27 | + // m[num]-- | ||
28 | + // } | ||
29 | + //} | ||
30 | + //return intersection | ||
31 | + m := make(map[int64]int) | ||
32 | + nn := make([]int64, 0) | ||
33 | + for _, v := range nums1 { | ||
34 | + m[v]++ | ||
17 | } | 35 | } |
18 | - m := map[int64]int64{} | ||
19 | - for _, num := range nums1 { | ||
20 | - m[num]++ | 36 | + for _, v := range nums2 { |
37 | + times, _ := m[v] | ||
38 | + if times > 0 { | ||
39 | + nn = append(nn, v) | ||
21 | } | 40 | } |
22 | - | ||
23 | - var intersection []int64 | ||
24 | - for _, num := range nums2 { | ||
25 | - if m[num] > 0 { | ||
26 | - intersection = append(intersection, num) | ||
27 | - m[num]-- | ||
28 | } | 41 | } |
29 | - } | ||
30 | - return intersection | 42 | + return nn |
43 | + | ||
31 | } | 44 | } |
32 | 45 | ||
33 | // Intersect32 返回两个数组的交集 | 46 | // Intersect32 返回两个数组的交集 |
@@ -52,20 +65,34 @@ func Intersect32(nums1 []int32, nums2 []int32) []int32 { | @@ -52,20 +65,34 @@ func Intersect32(nums1 []int32, nums2 []int32) []int32 { | ||
52 | 65 | ||
53 | // Difference 求差集 slice1-并集 | 66 | // Difference 求差集 slice1-并集 |
54 | func Difference(slice1, slice2 []int64) []int64 { | 67 | func Difference(slice1, slice2 []int64) []int64 { |
68 | + //m := make(map[int64]int) | ||
69 | + //nn := make([]int64, 0) | ||
70 | + //inter := Intersect(slice1, slice2) | ||
71 | + //for _, v := range inter { | ||
72 | + // m[v]++ | ||
73 | + //} | ||
74 | + // | ||
75 | + //for _, value := range slice1 { | ||
76 | + // times, _ := m[value] | ||
77 | + // if times == 0 { | ||
78 | + // nn = append(nn, value) | ||
79 | + // } | ||
80 | + //} | ||
81 | + //return nn | ||
55 | m := make(map[int64]int) | 82 | m := make(map[int64]int) |
56 | nn := make([]int64, 0) | 83 | nn := make([]int64, 0) |
57 | inter := Intersect(slice1, slice2) | 84 | inter := Intersect(slice1, slice2) |
58 | for _, v := range inter { | 85 | for _, v := range inter { |
59 | m[v]++ | 86 | m[v]++ |
60 | } | 87 | } |
61 | - | ||
62 | - for _, value := range slice1 { | ||
63 | - times, _ := m[value] | 88 | + for _, v := range slice1 { |
89 | + times, _ := m[v] | ||
64 | if times == 0 { | 90 | if times == 0 { |
65 | - nn = append(nn, value) | 91 | + nn = append(nn, v) |
66 | } | 92 | } |
67 | } | 93 | } |
68 | return nn | 94 | return nn |
95 | + | ||
69 | } | 96 | } |
70 | 97 | ||
71 | // SliceAtoi 字符创数组转数字数组 | 98 | // SliceAtoi 字符创数组转数字数组 |
-
请 注册 或 登录 后发表评论