正在显示
18 个修改的文件
包含
469 行增加
和
59 行删除
| @@ -6,6 +6,7 @@ import ( | @@ -6,6 +6,7 @@ import ( | ||
| 6 | "github.com/linmadan/egglib-go/utils/tool_funs" | 6 | "github.com/linmadan/egglib-go/utils/tool_funs" |
| 7 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/creditAccount/command" | 7 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/creditAccount/command" |
| 8 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/creditAccount/query" | 8 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/creditAccount/query" |
| 9 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/event/subscriber" | ||
| 9 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/factory" | 10 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/factory" |
| 10 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain" | 11 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain" |
| 11 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain/service" | 12 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain/service" |
| @@ -103,6 +104,17 @@ func (creditAccountService *CreditAccountService) CreateCreditAccount(createCred | @@ -103,6 +104,17 @@ func (creditAccountService *CreditAccountService) CreateCreditAccount(createCred | ||
| 103 | creditAccountDao = value | 104 | creditAccountDao = value |
| 104 | } | 105 | } |
| 105 | 106 | ||
| 107 | + // 账期结算消息推送领域服务初始化 | ||
| 108 | + var estimateDividendsService service.EstimateDividendsService | ||
| 109 | + if value, err := factory.CreateEstimateDividendsService(map[string]interface{}{}); err != nil { | ||
| 110 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 111 | + } else { | ||
| 112 | + estimateDividendsService = value | ||
| 113 | + _ = estimateDividendsService.Subscribe(&subscriber.MessageServiceSubscriber{ | ||
| 114 | + //TransactionContext: transactionContext.(*pgTransaction.TransactionContext), | ||
| 115 | + }) | ||
| 116 | + } | ||
| 117 | + | ||
| 106 | // 分红预算单仓储初始化 | 118 | // 分红预算单仓储初始化 |
| 107 | var dividendsEstimateRepository domain.DividendsEstimateRepository | 119 | var dividendsEstimateRepository domain.DividendsEstimateRepository |
| 108 | if value, err10 := factory.CreateDividendsEstimateRepository(map[string]interface{}{ | 120 | if value, err10 := factory.CreateDividendsEstimateRepository(map[string]interface{}{ |
| @@ -221,6 +233,23 @@ func (creditAccountService *CreditAccountService) CreateCreditAccount(createCred | @@ -221,6 +233,23 @@ func (creditAccountService *CreditAccountService) CreateCreditAccount(createCred | ||
| 221 | if err14 := transactionContext.CommitTransaction(); err14 != nil { | 233 | if err14 := transactionContext.CommitTransaction(); err14 != nil { |
| 222 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err14.Error()) | 234 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err14.Error()) |
| 223 | } | 235 | } |
| 236 | + | ||
| 237 | + // 消息推送 | ||
| 238 | + var accountData []service.EstimateData | ||
| 239 | + for _, detail := range creditAccount.AccountDetail { | ||
| 240 | + accountData = append(accountData, service.EstimateData{ | ||
| 241 | + CreditAccountOrderNum: creditAccount.CreditAccountOrderNum, | ||
| 242 | + SettlementAmount: fmt.Sprint(creditAccount.SettlementAmount), | ||
| 243 | + CreditAccountId: creditAccount.CreditAccountId, | ||
| 244 | + DividendsEstimateId: detail.DividendsEstimateOrderId, | ||
| 245 | + DividendsEstimateOrderNumber: detail.DividendsEstimateOrderNumber, | ||
| 246 | + UserId: creditAccount.Participator.UserId, | ||
| 247 | + UserBaseId: creditAccount.Participator.UserBaseId, | ||
| 248 | + OrgId: creditAccount.Org.OrgId, | ||
| 249 | + CompanyId: creditAccount.Company.CompanyId, | ||
| 250 | + }) | ||
| 251 | + } | ||
| 252 | + | ||
| 224 | return creditAccount, nil | 253 | return creditAccount, nil |
| 225 | } | 254 | } |
| 226 | } | 255 | } |
| @@ -361,6 +390,17 @@ func (creditAccountService *CreditAccountService) PayCreditAccount(payCreditAcco | @@ -361,6 +390,17 @@ func (creditAccountService *CreditAccountService) PayCreditAccount(payCreditAcco | ||
| 361 | dividendsEstimateRepository = value | 390 | dividendsEstimateRepository = value |
| 362 | } | 391 | } |
| 363 | 392 | ||
| 393 | + // 账期支付消息推送领域服务初始化 | ||
| 394 | + var payCreditAccountService service.PayCreditAccountService | ||
| 395 | + if value, err := factory.CreatePayCreditAccountService(map[string]interface{}{}); err != nil { | ||
| 396 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 397 | + } else { | ||
| 398 | + payCreditAccountService = value | ||
| 399 | + _ = payCreditAccountService.Subscribe(&subscriber.MessageServiceSubscriber{ | ||
| 400 | + //TransactionContext: transactionContext.(*pgTransaction.TransactionContext), | ||
| 401 | + }) | ||
| 402 | + } | ||
| 403 | + | ||
| 364 | // 获取待支付的账期结算单 | 404 | // 获取待支付的账期结算单 |
| 365 | creditAccount, err := creditAccountRepository.FindOne(map[string]interface{}{ | 405 | creditAccount, err := creditAccountRepository.FindOne(map[string]interface{}{ |
| 366 | "creditAccountId": creditAccountId, | 406 | "creditAccountId": creditAccountId, |
| @@ -406,6 +446,21 @@ func (creditAccountService *CreditAccountService) PayCreditAccount(payCreditAcco | @@ -406,6 +446,21 @@ func (creditAccountService *CreditAccountService) PayCreditAccount(payCreditAcco | ||
| 406 | if err3 := transactionContext.CommitTransaction(); err3 != nil { | 446 | if err3 := transactionContext.CommitTransaction(); err3 != nil { |
| 407 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err3.Error()) | 447 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err3.Error()) |
| 408 | } | 448 | } |
| 449 | + | ||
| 450 | + // 支付消息推送 | ||
| 451 | + var payData []service.PayData | ||
| 452 | + payData = append(payData, service.PayData{ | ||
| 453 | + CreditAccountOrderNum: creditAccountSaved.CreditAccountOrderNum, | ||
| 454 | + SettlementAmount: fmt.Sprint(creditAccountSaved.SettlementAmount), | ||
| 455 | + CreditAccountId: creditAccountSaved.CreditAccountId, | ||
| 456 | + DividendsEstimateId: 0, | ||
| 457 | + DividendsEstimateOrderNumber: "", | ||
| 458 | + UserId: creditAccountSaved.Participator.UserId, | ||
| 459 | + UserBaseId: creditAccountSaved.Participator.UserBaseId, | ||
| 460 | + OrgId: creditAccountSaved.Org.OrgId, | ||
| 461 | + CompanyId: creditAccountSaved.Company.CompanyId, | ||
| 462 | + }) | ||
| 463 | + | ||
| 409 | return creditAccountSaved, nil | 464 | return creditAccountSaved, nil |
| 410 | } | 465 | } |
| 411 | } | 466 | } |
| @@ -3,7 +3,6 @@ package service | @@ -3,7 +3,6 @@ package service | ||
| 3 | import ( | 3 | import ( |
| 4 | "fmt" | 4 | "fmt" |
| 5 | "github.com/linmadan/egglib-go/core/application" | 5 | "github.com/linmadan/egglib-go/core/application" |
| 6 | - pgTransaction "github.com/linmadan/egglib-go/transaction/pg" | ||
| 7 | "github.com/linmadan/egglib-go/utils/tool_funs" | 6 | "github.com/linmadan/egglib-go/utils/tool_funs" |
| 8 | "github.com/shopspring/decimal" | 7 | "github.com/shopspring/decimal" |
| 9 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/dividendsEstimate/command" | 8 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/dividendsEstimate/command" |
| @@ -542,6 +541,17 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent | @@ -542,6 +541,17 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent | ||
| 542 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 541 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
| 543 | } | 542 | } |
| 544 | 543 | ||
| 544 | + // 预算消息推送领域服务初始化 | ||
| 545 | + var informDividendsExpectedService service.InformDividendsExpectedService | ||
| 546 | + if value, err := factory.CreateInformDividendsExpectedService(map[string]interface{}{}); err != nil { | ||
| 547 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 548 | + } else { | ||
| 549 | + informDividendsExpectedService = value | ||
| 550 | + _ = informDividendsExpectedService.Subscribe(&subscriber.MessageServiceSubscriber{ | ||
| 551 | + //TransactionContext: transactionContext.(*pgTransaction.TransactionContext), | ||
| 552 | + }) | ||
| 553 | + } | ||
| 554 | + | ||
| 545 | // 公司REST服务初始化 | 555 | // 公司REST服务初始化 |
| 546 | var companyService service.CompanyService | 556 | var companyService service.CompanyService |
| 547 | if value, err := factory.CreateCompanyService(map[string]interface{}{}); err != nil { | 557 | if value, err := factory.CreateCompanyService(map[string]interface{}{}); err != nil { |
| @@ -656,6 +666,16 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent | @@ -656,6 +666,16 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent | ||
| 656 | cooperationContractRepository = value | 666 | cooperationContractRepository = value |
| 657 | } | 667 | } |
| 658 | 668 | ||
| 669 | + // 共创项目仓储初始化 | ||
| 670 | + var cooperationProjectRepository domain.CooperationProjectRepository | ||
| 671 | + if value, err := factory.CreateCooperationProjectRepository(map[string]interface{}{ | ||
| 672 | + "transactionContext": transactionContext, | ||
| 673 | + }); err != nil { | ||
| 674 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 675 | + } else { | ||
| 676 | + cooperationProjectRepository = value | ||
| 677 | + } | ||
| 678 | + | ||
| 659 | // 初始化确认业绩激励分红预算领域服务 | 679 | // 初始化确认业绩激励分红预算领域服务 |
| 660 | var confirmDividendsIncentivesEstimateService service.ConfirmDividendsIncentivesEstimateService | 680 | var confirmDividendsIncentivesEstimateService service.ConfirmDividendsIncentivesEstimateService |
| 661 | if value, err := factory.CreateConfirmDividendsIncentivesEstimateService(map[string]interface{}{ | 681 | if value, err := factory.CreateConfirmDividendsIncentivesEstimateService(map[string]interface{}{ |
| @@ -664,9 +684,6 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent | @@ -664,9 +684,6 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent | ||
| 664 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 684 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
| 665 | } else { | 685 | } else { |
| 666 | confirmDividendsIncentivesEstimateService = value | 686 | confirmDividendsIncentivesEstimateService = value |
| 667 | - _ = confirmDividendsIncentivesEstimateService.Subscribe(&subscriber.DividendsEstimateSubscriber{ | ||
| 668 | - TransactionContext: transactionContext.(*pgTransaction.TransactionContext), | ||
| 669 | - }) | ||
| 670 | } | 687 | } |
| 671 | 688 | ||
| 672 | // 统计成功预算的分红订单 | 689 | // 统计成功预算的分红订单 |
| @@ -689,14 +706,21 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent | @@ -689,14 +706,21 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent | ||
| 689 | 706 | ||
| 690 | var cooperationContractNumbers []string | 707 | var cooperationContractNumbers []string |
| 691 | 708 | ||
| 709 | + orderGoodsMap := make(map[int64]*domain.OrderGood, 0) | ||
| 710 | + | ||
| 692 | // 获取订单产品合约编号 | 711 | // 获取订单产品合约编号 |
| 693 | for _, orderGood := range orderGoods { | 712 | for _, orderGood := range orderGoods { |
| 694 | cooperationContractNumbers = append(cooperationContractNumbers, orderGood.CooperationContractNumber) | 713 | cooperationContractNumbers = append(cooperationContractNumbers, orderGood.CooperationContractNumber) |
| 714 | + orderGoodsMap[orderGood.OrderGoodId] = orderGood | ||
| 695 | } | 715 | } |
| 696 | 716 | ||
| 697 | newCooperationContractNumbers := utils.RemoveDuplicationString(cooperationContractNumbers) | 717 | newCooperationContractNumbers := utils.RemoveDuplicationString(cooperationContractNumbers) |
| 698 | 718 | ||
| 699 | cooperationContractsMap := make(map[string]*domain.CooperationContract, 0) | 719 | cooperationContractsMap := make(map[string]*domain.CooperationContract, 0) |
| 720 | + cooperationProjectsMap := make(map[string]*domain.CooperationProject, 0) | ||
| 721 | + | ||
| 722 | + // 共创项目编号 | ||
| 723 | + var cooperationProjectNumbers []string | ||
| 700 | 724 | ||
| 701 | // 查询共创合约 | 725 | // 查询共创合约 |
| 702 | startQueryContracts := time.Now() | 726 | startQueryContracts := time.Now() |
| @@ -712,6 +736,7 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent | @@ -712,6 +736,7 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent | ||
| 712 | if count > 0 { | 736 | if count > 0 { |
| 713 | for _, cooperationContractFound := range cooperationContractsFound { | 737 | for _, cooperationContractFound := range cooperationContractsFound { |
| 714 | cooperationContractsMap[cooperationContractFound.CooperationContractNumber] = cooperationContractFound | 738 | cooperationContractsMap[cooperationContractFound.CooperationContractNumber] = cooperationContractFound |
| 739 | + cooperationProjectNumbers = append(cooperationProjectNumbers, cooperationContractFound.CooperationProjectNumber) | ||
| 715 | } | 740 | } |
| 716 | } | 741 | } |
| 717 | } | 742 | } |
| @@ -720,6 +745,9 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent | @@ -720,6 +745,9 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent | ||
| 720 | "report": fmt.Sprintf("已完成0单订单分红预算,生成0单分红预算,失败原因:产品未关联合约"), | 745 | "report": fmt.Sprintf("已完成0单订单分红预算,生成0单分红预算,失败原因:产品未关联合约"), |
| 721 | }, nil | 746 | }, nil |
| 722 | } | 747 | } |
| 748 | + | ||
| 749 | + newCooperationProjectNumbers := utils.RemoveDuplicationString(cooperationProjectNumbers) | ||
| 750 | + | ||
| 723 | fmt.Println("查询共创合约耗时:", time.Since(startQueryContracts)) | 751 | fmt.Println("查询共创合约耗时:", time.Since(startQueryContracts)) |
| 724 | 752 | ||
| 725 | // 统计当前企业分红预算单数 | 753 | // 统计当前企业分红预算单数 |
| @@ -996,6 +1024,24 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent | @@ -996,6 +1024,24 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent | ||
| 996 | 1024 | ||
| 997 | fmt.Println("更新退货单耗时:", time.Since(startUpdateReturnedOrder)) | 1025 | fmt.Println("更新退货单耗时:", time.Since(startUpdateReturnedOrder)) |
| 998 | 1026 | ||
| 1027 | + // 查询共创项目 | ||
| 1028 | + if len(newCooperationProjectNumbers) > 0 { | ||
| 1029 | + if countProject, cooperationProjectsFound, errFind := cooperationProjectRepository.Find(map[string]interface{}{ | ||
| 1030 | + "cooperationProjectNumbers": newCooperationProjectNumbers, | ||
| 1031 | + "companyId": confirmDividendsIncentivesEstimateCommand.CompanyId, | ||
| 1032 | + "orgId": confirmDividendsIncentivesEstimateCommand.OrgId, | ||
| 1033 | + "offsetLimit": false, | ||
| 1034 | + }); errFind != nil { | ||
| 1035 | + return nil, errFind | ||
| 1036 | + } else { | ||
| 1037 | + if countProject > 0 { | ||
| 1038 | + for _, cooperationProjectFound := range cooperationProjectsFound { | ||
| 1039 | + cooperationProjectsMap[cooperationProjectFound.CooperationProjectNumber] = cooperationProjectFound | ||
| 1040 | + } | ||
| 1041 | + } | ||
| 1042 | + } | ||
| 1043 | + } | ||
| 1044 | + | ||
| 999 | startCommit := time.Now() | 1045 | startCommit := time.Now() |
| 1000 | if err := transactionContext.CommitTransaction(); err != nil { | 1046 | if err := transactionContext.CommitTransaction(); err != nil { |
| 1001 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 1047 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
| @@ -1019,6 +1065,30 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent | @@ -1019,6 +1065,30 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent | ||
| 1019 | 1065 | ||
| 1020 | fmt.Println("函数执行完毕:", time.Since(start)) | 1066 | fmt.Println("函数执行完毕:", time.Since(start)) |
| 1021 | 1067 | ||
| 1068 | + // 消息通知 | ||
| 1069 | + var expectedData []service.ExpectedData | ||
| 1070 | + for _, dividendsEstimateSaved := range dividendsEstimatesSaved { | ||
| 1071 | + if dividendsEstimateSaved.DividendsParticipateType == 1 { | ||
| 1072 | + expectedData = append(expectedData, service.ExpectedData{ | ||
| 1073 | + CreationContractId: cooperationContractsMap[dividendsEstimateSaved.CooperationContractNumber].CooperationContractId, | ||
| 1074 | + CreationContractName: cooperationContractsMap[dividendsEstimateSaved.CooperationContractNumber].CooperationContractName, | ||
| 1075 | + CreationContractNumber: cooperationContractsMap[dividendsEstimateSaved.CooperationContractNumber].CooperationContractNumber, | ||
| 1076 | + CreationProjectId: cooperationProjectsMap[cooperationContractsMap[dividendsEstimateSaved.CooperationContractNumber].CooperationProjectNumber].CooperationProjectId, | ||
| 1077 | + CreationProjectName: cooperationProjectsMap[cooperationContractsMap[dividendsEstimateSaved.CooperationContractNumber].CooperationProjectNumber].CooperationProjectName, | ||
| 1078 | + ProductName: orderGoodsMap[dividendsEstimateSaved.OrderGoodId].OrderGoodName, | ||
| 1079 | + UserId: dividendsEstimateSaved.DividendsUser.UserId, | ||
| 1080 | + UserBaseId: dividendsEstimateSaved.DividendsUser.UserBaseId, | ||
| 1081 | + OrgId: dividendsEstimateSaved.Org.OrgId, | ||
| 1082 | + CompanyId: dividendsEstimateSaved.Company.CompanyId, | ||
| 1083 | + DividendsEstimateId: dividendsEstimateSaved.DividendsEstimateId, | ||
| 1084 | + DividendsAmount: fmt.Sprint(dividendsEstimateSaved.DividendsAmount), | ||
| 1085 | + }) | ||
| 1086 | + } | ||
| 1087 | + } | ||
| 1088 | + if err := informDividendsExpectedService.Expect(expectedData); err != nil { | ||
| 1089 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 1090 | + } | ||
| 1091 | + | ||
| 1022 | return map[string]interface{}{ | 1092 | return map[string]interface{}{ |
| 1023 | "report": fmt.Sprintf("已完成%d单订单分红预算,生成%d单分红预算,%d笔订单分红预算失败,失败原因:%s", len(estimateSuccessfullyDividendsOrders), successfullyCount, len(estimateFailedDividendsOrders), failedReasonStr), | 1093 | "report": fmt.Sprintf("已完成%d单订单分红预算,生成%d单分红预算,%d笔订单分红预算失败,失败原因:%s", len(estimateSuccessfullyDividendsOrders), successfullyCount, len(estimateFailedDividendsOrders), failedReasonStr), |
| 1024 | }, nil | 1094 | }, nil |
| @@ -1050,8 +1120,16 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmMoneyIncentives | @@ -1050,8 +1120,16 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmMoneyIncentives | ||
| 1050 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 1120 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
| 1051 | } else { | 1121 | } else { |
| 1052 | confirmMoneyIncentivesEstimateService = value | 1122 | confirmMoneyIncentivesEstimateService = value |
| 1053 | - _ = confirmMoneyIncentivesEstimateService.Subscribe(&subscriber.DividendsEstimateSubscriber{ | ||
| 1054 | - TransactionContext: transactionContext.(*pgTransaction.TransactionContext), | 1123 | + } |
| 1124 | + | ||
| 1125 | + // 预算消息推送领域服务初始化 | ||
| 1126 | + var informDividendsExpectedService service.InformDividendsExpectedService | ||
| 1127 | + if value, err := factory.CreateInformDividendsExpectedService(map[string]interface{}{}); err != nil { | ||
| 1128 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 1129 | + } else { | ||
| 1130 | + informDividendsExpectedService = value | ||
| 1131 | + _ = informDividendsExpectedService.Subscribe(&subscriber.MessageServiceSubscriber{ | ||
| 1132 | + //TransactionContext: transactionContext.(*pgTransaction.TransactionContext), | ||
| 1055 | }) | 1133 | }) |
| 1056 | } | 1134 | } |
| 1057 | 1135 | ||
| @@ -1065,6 +1143,16 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmMoneyIncentives | @@ -1065,6 +1143,16 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmMoneyIncentives | ||
| 1065 | cooperationContractRepository = value | 1143 | cooperationContractRepository = value |
| 1066 | } | 1144 | } |
| 1067 | 1145 | ||
| 1146 | + // 共创项目仓储初始化 | ||
| 1147 | + var cooperationProjectRepository domain.CooperationProjectRepository | ||
| 1148 | + if value, err := factory.CreateCooperationProjectRepository(map[string]interface{}{ | ||
| 1149 | + "transactionContext": transactionContext, | ||
| 1150 | + }); err != nil { | ||
| 1151 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 1152 | + } else { | ||
| 1153 | + cooperationProjectRepository = value | ||
| 1154 | + } | ||
| 1155 | + | ||
| 1068 | // 分红预算单DAO初始化 | 1156 | // 分红预算单DAO初始化 |
| 1069 | var dividendsEstimateDao *dao.DividendsEstimateDao | 1157 | var dividendsEstimateDao *dao.DividendsEstimateDao |
| 1070 | if value, err := factory.CreateDividendsEstimateDao(map[string]interface{}{ | 1158 | if value, err := factory.CreateDividendsEstimateDao(map[string]interface{}{ |
| @@ -1138,6 +1226,20 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmMoneyIncentives | @@ -1138,6 +1226,20 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmMoneyIncentives | ||
| 1138 | return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", strconv.FormatInt(cooperationContractId, 10))) | 1226 | return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", strconv.FormatInt(cooperationContractId, 10))) |
| 1139 | } | 1227 | } |
| 1140 | 1228 | ||
| 1229 | + // 获取共创项目 | ||
| 1230 | + cooperationProject, err := cooperationProjectRepository.FindOne(map[string]interface{}{ | ||
| 1231 | + "cooperationProjectNumber": cooperationContract.CooperationProjectNumber, | ||
| 1232 | + "orgId": organization.OrgId, | ||
| 1233 | + "companyId": company.CompanyId, | ||
| 1234 | + }) | ||
| 1235 | + if err != nil { | ||
| 1236 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 1237 | + } | ||
| 1238 | + if cooperationProject == nil { | ||
| 1239 | + return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", cooperationContract.CooperationProjectNumber)) | ||
| 1240 | + } | ||
| 1241 | + | ||
| 1242 | + // 分红预算单 | ||
| 1141 | var dividendsEstimates []*domain.DividendsEstimate | 1243 | var dividendsEstimates []*domain.DividendsEstimate |
| 1142 | 1244 | ||
| 1143 | // 统计当前分红预算单数 | 1245 | // 统计当前分红预算单数 |
| @@ -1203,6 +1305,31 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmMoneyIncentives | @@ -1203,6 +1305,31 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmMoneyIncentives | ||
| 1203 | if err := transactionContext.CommitTransaction(); err != nil { | 1305 | if err := transactionContext.CommitTransaction(); err != nil { |
| 1204 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 1306 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
| 1205 | } | 1307 | } |
| 1308 | + | ||
| 1309 | + // 消息通知 | ||
| 1310 | + var expectedData []service.ExpectedData | ||
| 1311 | + for _, dividendsEstimateSaved := range dividendsEstimatesSaved { | ||
| 1312 | + if dividendsEstimateSaved.DividendsParticipateType == 1 { | ||
| 1313 | + expectedData = append(expectedData, service.ExpectedData{ | ||
| 1314 | + CreationContractId: cooperationContract.CooperationContractId, | ||
| 1315 | + CreationContractName: cooperationContract.CooperationContractName, | ||
| 1316 | + CreationContractNumber: cooperationContract.CooperationContractNumber, | ||
| 1317 | + CreationProjectId: cooperationProject.CooperationProjectId, | ||
| 1318 | + CreationProjectName: cooperationProject.CooperationProjectName, | ||
| 1319 | + ProductName: "", | ||
| 1320 | + UserId: dividendsEstimateSaved.DividendsUser.UserId, | ||
| 1321 | + UserBaseId: dividendsEstimateSaved.DividendsUser.UserBaseId, | ||
| 1322 | + OrgId: dividendsEstimateSaved.Org.OrgId, | ||
| 1323 | + CompanyId: dividendsEstimateSaved.Company.CompanyId, | ||
| 1324 | + DividendsEstimateId: dividendsEstimateSaved.DividendsEstimateId, | ||
| 1325 | + DividendsAmount: fmt.Sprint(dividendsEstimateSaved.DividendsAmount), | ||
| 1326 | + }) | ||
| 1327 | + } | ||
| 1328 | + } | ||
| 1329 | + if err := informDividendsExpectedService.Expect(expectedData); err != nil { | ||
| 1330 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 1331 | + } | ||
| 1332 | + | ||
| 1206 | return dividendsEstimatesSaved, nil | 1333 | return dividendsEstimatesSaved, nil |
| 1207 | } | 1334 | } |
| 1208 | return dividendsEstimatesSaved, nil | 1335 | return dividendsEstimatesSaved, nil |
| 1 | -package subscriber | ||
| 2 | - | ||
| 3 | -import ( | ||
| 4 | - coreDomain "github.com/linmadan/egglib-go/core/domain" | ||
| 5 | - pgTransaction "github.com/linmadan/egglib-go/transaction/pg" | ||
| 6 | -) | ||
| 7 | - | ||
| 8 | -type DividendsEstimateSubscriber struct { | ||
| 9 | - TransactionContext *pgTransaction.TransactionContext | ||
| 10 | -} | ||
| 11 | - | ||
| 12 | -func (subscriber *DividendsEstimateSubscriber) HandleEvent(domainEvent coreDomain.DomainEvent) error { | ||
| 13 | - return nil | ||
| 14 | -} | ||
| 15 | - | ||
| 16 | -func (subscriber *DividendsEstimateSubscriber) SubscribedToEventTypes() []string { | ||
| 17 | - return []string{ | ||
| 18 | - //event.CONFERENCE_MESSAGE, // 日程预约消息通知 | ||
| 19 | - } | ||
| 20 | -} |
| @@ -140,10 +140,10 @@ func (subscriber *MessageServiceSubscriber) HandleEvent(domainEvent coreDomain.D | @@ -140,10 +140,10 @@ func (subscriber *MessageServiceSubscriber) HandleEvent(domainEvent coreDomain.D | ||
| 140 | } | 140 | } |
| 141 | } | 141 | } |
| 142 | break | 142 | break |
| 143 | - case event.DIVIDENDS_INFORM_EXPECTED: // 分红预算 | ||
| 144 | - dividendsInformExpectedEvent := domainEvent.(*event.DividendsInformExpected) | ||
| 145 | - for _, expectedData := range dividendsInformExpectedEvent.DividendsInformExpectedData { | ||
| 146 | - data, err6 := messageServiceGateway.InformExpectedDividends( | 143 | + case event.INFORM_DIVIDENDS_EXPECTED: // 分红预算 |
| 144 | + dividendsInformExpectedEvent := domainEvent.(*event.InformDividendsExpected) | ||
| 145 | + for _, expectedData := range dividendsInformExpectedEvent.DividendsExpectedInformData { | ||
| 146 | + data, err6 := messageServiceGateway.InformDividendsExpected( | ||
| 147 | expectedData.CreationContractId, | 147 | expectedData.CreationContractId, |
| 148 | expectedData.CreationContractName, | 148 | expectedData.CreationContractName, |
| 149 | expectedData.CreationContractNumber, | 149 | expectedData.CreationContractNumber, |
| @@ -166,7 +166,6 @@ func (subscriber *MessageServiceSubscriber) HandleEvent(domainEvent coreDomain.D | @@ -166,7 +166,6 @@ func (subscriber *MessageServiceSubscriber) HandleEvent(domainEvent coreDomain.D | ||
| 166 | log.Logger.Info("推送数据返回", data) | 166 | log.Logger.Info("推送数据返回", data) |
| 167 | } | 167 | } |
| 168 | } | 168 | } |
| 169 | - | ||
| 170 | break | 169 | break |
| 171 | } | 170 | } |
| 172 | return nil | 171 | return nil |
| @@ -179,6 +178,6 @@ func (subscriber *MessageServiceSubscriber) SubscribedToEventTypes() []string { | @@ -179,6 +178,6 @@ func (subscriber *MessageServiceSubscriber) SubscribedToEventTypes() []string { | ||
| 179 | event.COOPERATION_APPLICATION_REJECTED, // 拒绝共创申请 | 178 | event.COOPERATION_APPLICATION_REJECTED, // 拒绝共创申请 |
| 180 | event.CREDIT_ACCOUNT_PAID, // 账期支付 | 179 | event.CREDIT_ACCOUNT_PAID, // 账期支付 |
| 181 | event.DIVIDENDS_ESTIMATED, // 账期结算 | 180 | event.DIVIDENDS_ESTIMATED, // 账期结算 |
| 182 | - event.DIVIDENDS_INFORM_EXPECTED, // 分红预算 | 181 | + event.INFORM_DIVIDENDS_EXPECTED, // 分红预算 |
| 183 | } | 182 | } |
| 184 | } | 183 | } |
| @@ -73,5 +73,37 @@ func CreateRejectContractApplicationService(options map[string]interface{}) (*do | @@ -73,5 +73,37 @@ func CreateRejectContractApplicationService(options map[string]interface{}) (*do | ||
| 73 | } | 73 | } |
| 74 | 74 | ||
| 75 | func CreateInformJoinCreationContractService(options map[string]interface{}) (*domain_service.InformJoinCreationContractService, error) { | 75 | func CreateInformJoinCreationContractService(options map[string]interface{}) (*domain_service.InformJoinCreationContractService, error) { |
| 76 | + //var transactionContext *pgTransaction.TransactionContext | ||
| 77 | + //if value, ok := options["transactionContext"]; ok { | ||
| 78 | + // transactionContext = value.(*pgTransaction.TransactionContext) | ||
| 79 | + //} | ||
| 80 | + //return domain_service.NewInformJoinCreationContractService(transactionContext) | ||
| 76 | return domain_service.NewInformJoinCreationContractService(nil) | 81 | return domain_service.NewInformJoinCreationContractService(nil) |
| 77 | } | 82 | } |
| 83 | + | ||
| 84 | +func CreateEstimateDividendsService(options map[string]interface{}) (*domain_service.EstimateDividendsService, error) { | ||
| 85 | + //var transactionContext *pgTransaction.TransactionContext | ||
| 86 | + //if value, ok := options["transactionContext"]; ok { | ||
| 87 | + // transactionContext = value.(*pgTransaction.TransactionContext) | ||
| 88 | + //} | ||
| 89 | + //return domain_service.NewEstimateDividendsService(transactionContext) | ||
| 90 | + return domain_service.NewEstimateDividendsService(nil) | ||
| 91 | +} | ||
| 92 | + | ||
| 93 | +func CreateInformDividendsExpectedService(options map[string]interface{}) (*domain_service.InformDividendsExpectedService, error) { | ||
| 94 | + //var transactionContext *pgTransaction.TransactionContext | ||
| 95 | + //if value, ok := options["transactionContext"]; ok { | ||
| 96 | + // transactionContext = value.(*pgTransaction.TransactionContext) | ||
| 97 | + //} | ||
| 98 | + //return domain_service.NewInformDividendsExpectedService(transactionContext) | ||
| 99 | + return domain_service.NewInformDividendsExpectedService(nil) | ||
| 100 | +} | ||
| 101 | + | ||
| 102 | +func CreatePayCreditAccountService(options map[string]interface{}) (*domain_service.PayCreditAccountService, error) { | ||
| 103 | + //var transactionContext *pgTransaction.TransactionContext | ||
| 104 | + //if value, ok := options["transactionContext"]; ok { | ||
| 105 | + // transactionContext = value.(*pgTransaction.TransactionContext) | ||
| 106 | + //} | ||
| 107 | + //return domain_service.NewPayCreditAccountService(transactionContext) | ||
| 108 | + return domain_service.NewPayCreditAccountService(nil) | ||
| 109 | +} |
| @@ -2,9 +2,9 @@ package event | @@ -2,9 +2,9 @@ package event | ||
| 2 | 2 | ||
| 3 | import coreDomain "github.com/linmadan/egglib-go/core/domain" | 3 | import coreDomain "github.com/linmadan/egglib-go/core/domain" |
| 4 | 4 | ||
| 5 | -const DIVIDENDS_INFORM_EXPECTED = "dividends-inform-expected" | 5 | +const INFORM_DIVIDENDS_EXPECTED = "inform-dividends-expected" |
| 6 | 6 | ||
| 7 | -type DividendsInformExpectedData struct { | 7 | +type DividendsExpectedInformData struct { |
| 8 | // 共创合约ID | 8 | // 共创合约ID |
| 9 | CreationContractId int64 `json:"creationContractId"` | 9 | CreationContractId int64 `json:"creationContractId"` |
| 10 | // 共创合约名称 | 10 | // 共创合约名称 |
| @@ -31,11 +31,11 @@ type DividendsInformExpectedData struct { | @@ -31,11 +31,11 @@ type DividendsInformExpectedData struct { | ||
| 31 | DividendsAmount string `json:"dividendsAmount"` | 31 | DividendsAmount string `json:"dividendsAmount"` |
| 32 | } | 32 | } |
| 33 | 33 | ||
| 34 | -type DividendsInformExpected struct { | 34 | +type InformDividendsExpected struct { |
| 35 | coreDomain.BaseEvent | 35 | coreDomain.BaseEvent |
| 36 | - DividendsInformExpectedData []DividendsInformExpectedData `json:"dividendsInformExpectedData"` | 36 | + DividendsExpectedInformData []DividendsExpectedInformData `json:"dividendsExpectedInformData"` |
| 37 | } | 37 | } |
| 38 | 38 | ||
| 39 | -func (event *DividendsInformExpected) EventType() string { | ||
| 40 | - return DIVIDENDS_ESTIMATED | 39 | +func (event *InformDividendsExpected) EventType() string { |
| 40 | + return INFORM_DIVIDENDS_EXPECTED | ||
| 41 | } | 41 | } |
pkg/domain/service/estimate_dividends.go
0 → 100644
| 1 | +package service | ||
| 2 | + | ||
| 3 | +import coreDomain "github.com/linmadan/egglib-go/core/domain" | ||
| 4 | + | ||
| 5 | +type EstimateData struct { | ||
| 6 | + CreditAccountOrderNum string | ||
| 7 | + SettlementAmount string | ||
| 8 | + CreditAccountId int64 | ||
| 9 | + DividendsEstimateId int64 | ||
| 10 | + DividendsEstimateOrderNumber string | ||
| 11 | + UserId int64 | ||
| 12 | + UserBaseId int64 | ||
| 13 | + OrgId int64 | ||
| 14 | + CompanyId int64 | ||
| 15 | +} | ||
| 16 | + | ||
| 17 | +type EstimateDividendsService interface { | ||
| 18 | + coreDomain.DomainEventPublisher | ||
| 19 | + Estimate([]EstimateData) error | ||
| 20 | +} |
| 1 | +package service | ||
| 2 | + | ||
| 3 | +import coreDomain "github.com/linmadan/egglib-go/core/domain" | ||
| 4 | + | ||
| 5 | +type ExpectedData struct { | ||
| 6 | + CreationContractId int64 | ||
| 7 | + CreationContractName string | ||
| 8 | + CreationContractNumber string | ||
| 9 | + CreationProjectId int64 | ||
| 10 | + CreationProjectName string | ||
| 11 | + ProductName string | ||
| 12 | + UserId int64 | ||
| 13 | + UserBaseId int64 | ||
| 14 | + OrgId int64 | ||
| 15 | + CompanyId int64 | ||
| 16 | + DividendsEstimateId int64 | ||
| 17 | + DividendsAmount string | ||
| 18 | +} | ||
| 19 | + | ||
| 20 | +type InformDividendsExpectedService interface { | ||
| 21 | + coreDomain.DomainEventPublisher | ||
| 22 | + Expect([]ExpectedData) error | ||
| 23 | +} |
pkg/domain/service/pay_credit_account.go
0 → 100644
| 1 | +package service | ||
| 2 | + | ||
| 3 | +import coreDomain "github.com/linmadan/egglib-go/core/domain" | ||
| 4 | + | ||
| 5 | +type PayData struct { | ||
| 6 | + CreditAccountOrderNum string | ||
| 7 | + SettlementAmount string | ||
| 8 | + CreditAccountId int64 | ||
| 9 | + DividendsEstimateId int64 | ||
| 10 | + DividendsEstimateOrderNumber string | ||
| 11 | + UserId int64 | ||
| 12 | + UserBaseId int64 | ||
| 13 | + OrgId int64 | ||
| 14 | + CompanyId int64 | ||
| 15 | +} | ||
| 16 | + | ||
| 17 | +type PayCreditAccountService interface { | ||
| 18 | + coreDomain.DomainEventPublisher | ||
| 19 | + Pay([]PayData) error | ||
| 20 | +} |
| @@ -12,6 +12,7 @@ type AgreeContractApplicationService struct { | @@ -12,6 +12,7 @@ type AgreeContractApplicationService struct { | ||
| 12 | //transactionContext *pgTransaction.TransactionContext | 12 | //transactionContext *pgTransaction.TransactionContext |
| 13 | } | 13 | } |
| 14 | 14 | ||
| 15 | +// 同意申请 | ||
| 15 | func (service *AgreeContractApplicationService) Agree(data []service.AgreeData) error { | 16 | func (service *AgreeContractApplicationService) Agree(data []service.AgreeData) error { |
| 16 | cooperationApplicationAgreedEvent := new(event.CooperationApplicationAgreed) | 17 | cooperationApplicationAgreedEvent := new(event.CooperationApplicationAgreed) |
| 17 | for _, cooperationApplicationAgreedData := range data { | 18 | for _, cooperationApplicationAgreedData := range data { |
| 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 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain/service" | ||
| 8 | +) | ||
| 9 | + | ||
| 10 | +type EstimateDividendsService struct { | ||
| 11 | + coreDomain.BaseEventPublisher | ||
| 12 | + //transactionContext *pgTransaction.TransactionContext | ||
| 13 | +} | ||
| 14 | + | ||
| 15 | +// 账期结算 | ||
| 16 | +func (service *EstimateDividendsService) Estimate(data []service.EstimateData) error { | ||
| 17 | + dividendsEstimatedEvent := new(event.DividendsEstimated) | ||
| 18 | + for _, dividendsEstimatedData := range data { | ||
| 19 | + dividendsEstimatedEvent.DividendsEstimatedData = append(dividendsEstimatedEvent.DividendsEstimatedData, event.DividendsEstimatedData{ | ||
| 20 | + CreditAccountOrderNum: dividendsEstimatedData.CreditAccountOrderNum, | ||
| 21 | + SettlementAmount: dividendsEstimatedData.SettlementAmount, | ||
| 22 | + CreditAccountId: dividendsEstimatedData.CreditAccountId, | ||
| 23 | + DividendsEstimateId: dividendsEstimatedData.DividendsEstimateId, | ||
| 24 | + DividendsEstimateOrderNumber: dividendsEstimatedData.DividendsEstimateOrderNumber, | ||
| 25 | + UserId: dividendsEstimatedData.UserId, | ||
| 26 | + UserBaseId: dividendsEstimatedData.UserBaseId, | ||
| 27 | + OrgId: dividendsEstimatedData.OrgId, | ||
| 28 | + CompanyId: dividendsEstimatedData.CompanyId, | ||
| 29 | + }) | ||
| 30 | + } | ||
| 31 | + if err := service.Publish(dividendsEstimatedEvent); err != nil { | ||
| 32 | + return err | ||
| 33 | + } | ||
| 34 | + return nil | ||
| 35 | +} | ||
| 36 | + | ||
| 37 | +func NewEstimateDividendsService(transactionContext *pgTransaction.TransactionContext) (*EstimateDividendsService, error) { | ||
| 38 | + //if transactionContext == nil { | ||
| 39 | + // return nil, fmt.Errorf("transactionContext参数不能为nil") | ||
| 40 | + //} else { | ||
| 41 | + // return &EstimateDividendsService{ | ||
| 42 | + // transactionContext: transactionContext, | ||
| 43 | + // }, nil | ||
| 44 | + //} | ||
| 45 | + return &EstimateDividendsService{}, nil | ||
| 46 | +} |
| 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 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain/service" | ||
| 8 | +) | ||
| 9 | + | ||
| 10 | +type InformDividendsExpectedService struct { | ||
| 11 | + coreDomain.BaseEventPublisher | ||
| 12 | + //transactionContext *pgTransaction.TransactionContext | ||
| 13 | +} | ||
| 14 | + | ||
| 15 | +// 分红预算 | ||
| 16 | +func (service *InformDividendsExpectedService) Expect(data []service.ExpectedData) error { | ||
| 17 | + dividendsExpectedInformEvent := new(event.InformDividendsExpected) | ||
| 18 | + for _, dividendsExpectedInformedData := range data { | ||
| 19 | + dividendsExpectedInformEvent.DividendsExpectedInformData = append(dividendsExpectedInformEvent.DividendsExpectedInformData, event.DividendsExpectedInformData{ | ||
| 20 | + CreationContractId: dividendsExpectedInformedData.CreationContractId, | ||
| 21 | + CreationContractName: dividendsExpectedInformedData.CreationContractName, | ||
| 22 | + CreationContractNumber: dividendsExpectedInformedData.CreationContractNumber, | ||
| 23 | + CreationProjectId: dividendsExpectedInformedData.CreationProjectId, | ||
| 24 | + CreationProjectName: dividendsExpectedInformedData.CreationProjectName, | ||
| 25 | + ProductName: dividendsExpectedInformedData.ProductName, | ||
| 26 | + UserId: dividendsExpectedInformedData.UserId, | ||
| 27 | + UserBaseId: dividendsExpectedInformedData.UserBaseId, | ||
| 28 | + OrgId: dividendsExpectedInformedData.OrgId, | ||
| 29 | + CompanyId: dividendsExpectedInformedData.CompanyId, | ||
| 30 | + DividendsEstimateId: dividendsExpectedInformedData.DividendsEstimateId, | ||
| 31 | + DividendsAmount: dividendsExpectedInformedData.DividendsAmount, | ||
| 32 | + }) | ||
| 33 | + } | ||
| 34 | + if err := service.Publish(dividendsExpectedInformEvent); err != nil { | ||
| 35 | + return err | ||
| 36 | + } | ||
| 37 | + return nil | ||
| 38 | +} | ||
| 39 | + | ||
| 40 | +func NewInformDividendsExpectedService(transactionContext *pgTransaction.TransactionContext) (*InformDividendsExpectedService, error) { | ||
| 41 | + //if transactionContext == nil { | ||
| 42 | + // return nil, fmt.Errorf("transactionContext参数不能为nil") | ||
| 43 | + //} else { | ||
| 44 | + // return &InformDividendsExpectedService{ | ||
| 45 | + // transactionContext: transactionContext, | ||
| 46 | + // }, nil | ||
| 47 | + //} | ||
| 48 | + return &InformDividendsExpectedService{}, nil | ||
| 49 | +} |
| @@ -11,6 +11,7 @@ type InformJoinCreationContractService struct { | @@ -11,6 +11,7 @@ type InformJoinCreationContractService struct { | ||
| 11 | coreDomain.BaseEventPublisher | 11 | coreDomain.BaseEventPublisher |
| 12 | } | 12 | } |
| 13 | 13 | ||
| 14 | +// 承接人加入共创 | ||
| 14 | func (service *InformJoinCreationContractService) Join(data []service.JoinData) error { | 15 | func (service *InformJoinCreationContractService) Join(data []service.JoinData) error { |
| 15 | creationContractInformJointEvent := new(event.CreationContractInformJoint) | 16 | creationContractInformJointEvent := new(event.CreationContractInformJoint) |
| 16 | for _, creationContractInformJointData := range data { | 17 | for _, creationContractInformJointData := range data { |
| @@ -34,5 +35,12 @@ func (service *InformJoinCreationContractService) Join(data []service.JoinData) | @@ -34,5 +35,12 @@ func (service *InformJoinCreationContractService) Join(data []service.JoinData) | ||
| 34 | } | 35 | } |
| 35 | 36 | ||
| 36 | func NewInformJoinCreationContractService(transactionContext *pgTransaction.TransactionContext) (*InformJoinCreationContractService, error) { | 37 | func NewInformJoinCreationContractService(transactionContext *pgTransaction.TransactionContext) (*InformJoinCreationContractService, error) { |
| 38 | + //if transactionContext == nil { | ||
| 39 | + // return nil, fmt.Errorf("transactionContext参数不能为nil") | ||
| 40 | + //} else { | ||
| 41 | + // return &InformJoinCreationContractService{ | ||
| 42 | + // transactionContext: transactionContext, | ||
| 43 | + // }, nil | ||
| 44 | + //} | ||
| 37 | return &InformJoinCreationContractService{}, nil | 45 | return &InformJoinCreationContractService{}, nil |
| 38 | } | 46 | } |
| 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 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain/service" | ||
| 8 | +) | ||
| 9 | + | ||
| 10 | +type PayCreditAccountService struct { | ||
| 11 | + coreDomain.BaseEventPublisher | ||
| 12 | + //transactionContext *pgTransaction.TransactionContext | ||
| 13 | +} | ||
| 14 | + | ||
| 15 | +// 账期支付 | ||
| 16 | +func (service *PayCreditAccountService) Pay(data []service.PayData) error { | ||
| 17 | + creditAccountPaidEvent := new(event.CreditAccountPaid) | ||
| 18 | + for _, creditAccountPaidData := range data { | ||
| 19 | + creditAccountPaidEvent.CreditAccountPaidData = append(creditAccountPaidEvent.CreditAccountPaidData, event.CreditAccountPaidData{ | ||
| 20 | + CreditAccountOrderNum: creditAccountPaidData.CreditAccountOrderNum, | ||
| 21 | + SettlementAmount: creditAccountPaidData.SettlementAmount, | ||
| 22 | + CreditAccountId: creditAccountPaidData.CreditAccountId, | ||
| 23 | + DividendsEstimateId: creditAccountPaidData.DividendsEstimateId, | ||
| 24 | + DividendsEstimateOrderNumber: creditAccountPaidData.DividendsEstimateOrderNumber, | ||
| 25 | + UserId: creditAccountPaidData.UserId, | ||
| 26 | + UserBaseId: creditAccountPaidData.UserBaseId, | ||
| 27 | + OrgId: creditAccountPaidData.OrgId, | ||
| 28 | + CompanyId: creditAccountPaidData.CompanyId, | ||
| 29 | + }) | ||
| 30 | + } | ||
| 31 | + if err := service.Publish(creditAccountPaidEvent); err != nil { | ||
| 32 | + return err | ||
| 33 | + } | ||
| 34 | + return nil | ||
| 35 | +} | ||
| 36 | + | ||
| 37 | +func NewPayCreditAccountService(transactionContext *pgTransaction.TransactionContext) (*PayCreditAccountService, error) { | ||
| 38 | + //if transactionContext == nil { | ||
| 39 | + // return nil, fmt.Errorf("transactionContext参数不能为nil") | ||
| 40 | + //} else { | ||
| 41 | + // return &PayCreditAccountService{ | ||
| 42 | + // transactionContext: transactionContext, | ||
| 43 | + // }, nil | ||
| 44 | + //} | ||
| 45 | + return &PayCreditAccountService{}, nil | ||
| 46 | +} |
| @@ -12,6 +12,7 @@ type RejectContractApplicationService struct { | @@ -12,6 +12,7 @@ type RejectContractApplicationService struct { | ||
| 12 | //transactionContext *pgTransaction.TransactionContext | 12 | //transactionContext *pgTransaction.TransactionContext |
| 13 | } | 13 | } |
| 14 | 14 | ||
| 15 | +// 拒绝申请 | ||
| 15 | func (service *RejectContractApplicationService) Reject(data []service.RejectData) error { | 16 | func (service *RejectContractApplicationService) Reject(data []service.RejectData) error { |
| 16 | cooperationApplicationRejectedEvent := new(event.CooperationApplicationRejected) | 17 | cooperationApplicationRejectedEvent := new(event.CooperationApplicationRejected) |
| 17 | for _, cooperationApplicationRejectedData := range data { | 18 | for _, cooperationApplicationRejectedData := range data { |
| @@ -259,6 +259,9 @@ func (repository *CooperationProjectRepository) Find(queryOptions map[string]int | @@ -259,6 +259,9 @@ func (repository *CooperationProjectRepository) Find(queryOptions map[string]int | ||
| 259 | if cooperationProjectNumber, ok := queryOptions["cooperationProjectNumber"]; ok && cooperationProjectNumber != "" { | 259 | if cooperationProjectNumber, ok := queryOptions["cooperationProjectNumber"]; ok && cooperationProjectNumber != "" { |
| 260 | query.Where("cooperation_project_number ilike ?", fmt.Sprintf("%%%s%%", cooperationProjectNumber)) | 260 | query.Where("cooperation_project_number ilike ?", fmt.Sprintf("%%%s%%", cooperationProjectNumber)) |
| 261 | } | 261 | } |
| 262 | + if cooperationProjectNumbers, ok := queryOptions["cooperationProjectNumbers"]; ok && len(cooperationProjectNumbers.([]string)) != 0 { | ||
| 263 | + query.Where("cooperation_project_number in (?)", pg.In(cooperationProjectNumbers)) | ||
| 264 | + } | ||
| 262 | if keyword, ok := queryOptions["keyword"]; ok && keyword != "" { | 265 | if keyword, ok := queryOptions["keyword"]; ok && keyword != "" { |
| 263 | query.Where("cooperation_project_description like ?", fmt.Sprintf("%%%s%%", keyword)) | 266 | query.Where("cooperation_project_description like ?", fmt.Sprintf("%%%s%%", keyword)) |
| 264 | } | 267 | } |
| @@ -76,36 +76,32 @@ func (serviceGateway *HttplibBasicServiceGateway) RejectCooperationApplication( | @@ -76,36 +76,32 @@ func (serviceGateway *HttplibBasicServiceGateway) RejectCooperationApplication( | ||
| 76 | return data, err | 76 | return data, err |
| 77 | } | 77 | } |
| 78 | 78 | ||
| 79 | -// InformExpectedDividends 分红预算消息 | ||
| 80 | -func (serviceGateway *HttplibBasicServiceGateway) InformExpectedDividends( | 79 | +// InformJoinCreationContract 确认共创 |
| 80 | +func (serviceGateway *HttplibBasicServiceGateway) InformJoinCreationContract( | ||
| 81 | creationContractId int64, | 81 | creationContractId int64, |
| 82 | creationContractName string, | 82 | creationContractName string, |
| 83 | creationContractNumber string, | 83 | creationContractNumber string, |
| 84 | creationProjectId int64, | 84 | creationProjectId int64, |
| 85 | + creationProjectNumber string, | ||
| 85 | creationProjectName string, | 86 | creationProjectName string, |
| 86 | - productName string, | ||
| 87 | userId int64, | 87 | userId int64, |
| 88 | userBaseId int64, | 88 | userBaseId int64, |
| 89 | orgId int64, | 89 | orgId int64, |
| 90 | companyId int64, | 90 | companyId int64, |
| 91 | - dividendsEstimateId int64, | ||
| 92 | - dividendsAmount string, | ||
| 93 | ) (map[string]interface{}, error) { | 91 | ) (map[string]interface{}, error) { |
| 94 | - url := strings.Join([]string{serviceGateway.baseURL, "notice-personal/inform-expected-dividends"}, "/") | 92 | + url := strings.Join([]string{serviceGateway.baseURL, "notice-personal/inform-join-creation-contract"}, "/") |
| 95 | request := serviceGateway.createRequest(url, "post") | 93 | request := serviceGateway.createRequest(url, "post") |
| 96 | options := make(map[string]interface{}) | 94 | options := make(map[string]interface{}) |
| 97 | options["creationContractId"] = creationContractId | 95 | options["creationContractId"] = creationContractId |
| 98 | options["creationContractName"] = creationContractName | 96 | options["creationContractName"] = creationContractName |
| 99 | options["creationContractNumber"] = creationContractNumber | 97 | options["creationContractNumber"] = creationContractNumber |
| 100 | options["creationProjectId"] = creationProjectId | 98 | options["creationProjectId"] = creationProjectId |
| 99 | + options["creationProjectNumber"] = creationProjectNumber | ||
| 101 | options["creationProjectName"] = creationProjectName | 100 | options["creationProjectName"] = creationProjectName |
| 102 | - options["productName"] = productName | ||
| 103 | options["userId"] = userId | 101 | options["userId"] = userId |
| 104 | options["userBaseId"] = userBaseId | 102 | options["userBaseId"] = userBaseId |
| 105 | options["orgId"] = orgId | 103 | options["orgId"] = orgId |
| 106 | options["companyId"] = companyId | 104 | options["companyId"] = companyId |
| 107 | - options["dividendsEstimateId"] = dividendsEstimateId | ||
| 108 | - options["dividendsAmount"] = dividendsAmount | ||
| 109 | _, err2 := request.JSONBody(options) | 105 | _, err2 := request.JSONBody(options) |
| 110 | if err2 != nil { | 106 | if err2 != nil { |
| 111 | return nil, err2 | 107 | return nil, err2 |
| @@ -119,32 +115,36 @@ func (serviceGateway *HttplibBasicServiceGateway) InformExpectedDividends( | @@ -119,32 +115,36 @@ func (serviceGateway *HttplibBasicServiceGateway) InformExpectedDividends( | ||
| 119 | return data, err | 115 | return data, err |
| 120 | } | 116 | } |
| 121 | 117 | ||
| 122 | -// InformJoinCreationContract 确认共创 | ||
| 123 | -func (serviceGateway *HttplibBasicServiceGateway) InformJoinCreationContract( | 118 | +// InformExpectedDividends 分红预算消息 |
| 119 | +func (serviceGateway *HttplibBasicServiceGateway) InformDividendsExpected( | ||
| 124 | creationContractId int64, | 120 | creationContractId int64, |
| 125 | creationContractName string, | 121 | creationContractName string, |
| 126 | creationContractNumber string, | 122 | creationContractNumber string, |
| 127 | creationProjectId int64, | 123 | creationProjectId int64, |
| 128 | - creationProjectNumber string, | ||
| 129 | creationProjectName string, | 124 | creationProjectName string, |
| 125 | + productName string, | ||
| 130 | userId int64, | 126 | userId int64, |
| 131 | userBaseId int64, | 127 | userBaseId int64, |
| 132 | orgId int64, | 128 | orgId int64, |
| 133 | companyId int64, | 129 | companyId int64, |
| 130 | + dividendsEstimateId int64, | ||
| 131 | + dividendsAmount string, | ||
| 134 | ) (map[string]interface{}, error) { | 132 | ) (map[string]interface{}, error) { |
| 135 | - url := strings.Join([]string{serviceGateway.baseURL, "notice-personal/inform-join-creation-contract"}, "/") | 133 | + url := strings.Join([]string{serviceGateway.baseURL, "notice-personal/inform-expected-dividends"}, "/") |
| 136 | request := serviceGateway.createRequest(url, "post") | 134 | request := serviceGateway.createRequest(url, "post") |
| 137 | options := make(map[string]interface{}) | 135 | options := make(map[string]interface{}) |
| 138 | options["creationContractId"] = creationContractId | 136 | options["creationContractId"] = creationContractId |
| 139 | options["creationContractName"] = creationContractName | 137 | options["creationContractName"] = creationContractName |
| 140 | options["creationContractNumber"] = creationContractNumber | 138 | options["creationContractNumber"] = creationContractNumber |
| 141 | options["creationProjectId"] = creationProjectId | 139 | options["creationProjectId"] = creationProjectId |
| 142 | - options["creationProjectNumber"] = creationProjectNumber | ||
| 143 | options["creationProjectName"] = creationProjectName | 140 | options["creationProjectName"] = creationProjectName |
| 141 | + options["productName"] = productName | ||
| 144 | options["userId"] = userId | 142 | options["userId"] = userId |
| 145 | options["userBaseId"] = userBaseId | 143 | options["userBaseId"] = userBaseId |
| 146 | options["orgId"] = orgId | 144 | options["orgId"] = orgId |
| 147 | options["companyId"] = companyId | 145 | options["companyId"] = companyId |
| 146 | + options["dividendsEstimateId"] = dividendsEstimateId | ||
| 147 | + options["dividendsAmount"] = dividendsAmount | ||
| 148 | _, err2 := request.JSONBody(options) | 148 | _, err2 := request.JSONBody(options) |
| 149 | if err2 != nil { | 149 | if err2 != nil { |
| 150 | return nil, err2 | 150 | return nil, err2 |
| @@ -158,8 +158,8 @@ func (serviceGateway *HttplibBasicServiceGateway) InformJoinCreationContract( | @@ -158,8 +158,8 @@ func (serviceGateway *HttplibBasicServiceGateway) InformJoinCreationContract( | ||
| 158 | return data, err | 158 | return data, err |
| 159 | } | 159 | } |
| 160 | 160 | ||
| 161 | -// PayCreditAccount 账期支付 | ||
| 162 | -func (serviceGateway *HttplibBasicServiceGateway) PayCreditAccount( | 161 | +// DividendsEstimate 账期结算 |
| 162 | +func (serviceGateway *HttplibBasicServiceGateway) DividendsEstimate( | ||
| 163 | creditAccountOrderNum string, | 163 | creditAccountOrderNum string, |
| 164 | settlementAmount string, | 164 | settlementAmount string, |
| 165 | creditAccountId int64, | 165 | creditAccountId int64, |
| @@ -170,7 +170,7 @@ func (serviceGateway *HttplibBasicServiceGateway) PayCreditAccount( | @@ -170,7 +170,7 @@ func (serviceGateway *HttplibBasicServiceGateway) PayCreditAccount( | ||
| 170 | orgId int64, | 170 | orgId int64, |
| 171 | companyId int64, | 171 | companyId int64, |
| 172 | ) (map[string]interface{}, error) { | 172 | ) (map[string]interface{}, error) { |
| 173 | - url := strings.Join([]string{serviceGateway.baseURL, "notice-personal/notice-personal/credit-account/payment"}, "/") | 173 | + url := strings.Join([]string{serviceGateway.baseURL, "notice-personal/credit-account/dividends-estimate"}, "/") |
| 174 | request := serviceGateway.createRequest(url, "post") | 174 | request := serviceGateway.createRequest(url, "post") |
| 175 | options := make(map[string]interface{}) | 175 | options := make(map[string]interface{}) |
| 176 | options["creditAccountOrderNum"] = creditAccountOrderNum | 176 | options["creditAccountOrderNum"] = creditAccountOrderNum |
| @@ -195,8 +195,8 @@ func (serviceGateway *HttplibBasicServiceGateway) PayCreditAccount( | @@ -195,8 +195,8 @@ func (serviceGateway *HttplibBasicServiceGateway) PayCreditAccount( | ||
| 195 | return data, err | 195 | return data, err |
| 196 | } | 196 | } |
| 197 | 197 | ||
| 198 | -// DividendsEstimate 分红预算 | ||
| 199 | -func (serviceGateway *HttplibBasicServiceGateway) DividendsEstimate( | 198 | +// PayCreditAccount 账期支付 |
| 199 | +func (serviceGateway *HttplibBasicServiceGateway) PayCreditAccount( | ||
| 200 | creditAccountOrderNum string, | 200 | creditAccountOrderNum string, |
| 201 | settlementAmount string, | 201 | settlementAmount string, |
| 202 | creditAccountId int64, | 202 | creditAccountId int64, |
| @@ -207,7 +207,7 @@ func (serviceGateway *HttplibBasicServiceGateway) DividendsEstimate( | @@ -207,7 +207,7 @@ func (serviceGateway *HttplibBasicServiceGateway) DividendsEstimate( | ||
| 207 | orgId int64, | 207 | orgId int64, |
| 208 | companyId int64, | 208 | companyId int64, |
| 209 | ) (map[string]interface{}, error) { | 209 | ) (map[string]interface{}, error) { |
| 210 | - url := strings.Join([]string{serviceGateway.baseURL, "notice-personal/credit-account/dividends-estimate"}, "/") | 210 | + url := strings.Join([]string{serviceGateway.baseURL, "notice-personal/notice-personal/credit-account/payment"}, "/") |
| 211 | request := serviceGateway.createRequest(url, "post") | 211 | request := serviceGateway.createRequest(url, "post") |
| 212 | options := make(map[string]interface{}) | 212 | options := make(map[string]interface{}) |
| 213 | options["creditAccountOrderNum"] = creditAccountOrderNum | 213 | options["creditAccountOrderNum"] = creditAccountOrderNum |
| @@ -15,7 +15,7 @@ type UserServiceGateway interface { | @@ -15,7 +15,7 @@ type UserServiceGateway interface { | ||
| 15 | type BasicServiceGateway interface { | 15 | type BasicServiceGateway interface { |
| 16 | AgreeCooperationApplication(creationProjectId int64, creationProjectName string, creationProjectNumber string, userId int64, userBaseId int64, orgId int64, companyId int64) (map[string]interface{}, error) | 16 | AgreeCooperationApplication(creationProjectId int64, creationProjectName string, creationProjectNumber string, userId int64, userBaseId int64, orgId int64, companyId int64) (map[string]interface{}, error) |
| 17 | RejectCooperationApplication(creationProjectId int64, creationProjectName string, creationProjectNumber string, userId int64, userBaseId int64, orgId int64, companyId int64) (map[string]interface{}, error) | 17 | RejectCooperationApplication(creationProjectId int64, creationProjectName string, creationProjectNumber string, userId int64, userBaseId int64, orgId int64, companyId int64) (map[string]interface{}, error) |
| 18 | - InformExpectedDividends(creationContractId int64, creationContractName string, creationContractNumber string, creationProjectId int64, creationProjectName string, productName string, userId int64, userBaseId int64, orgId int64, companyId int64, dividendsEstimateId int64, dividendsAmount string) (map[string]interface{}, error) | 18 | + InformDividendsExpected(creationContractId int64, creationContractName string, creationContractNumber string, creationProjectId int64, creationProjectName string, productName string, userId int64, userBaseId int64, orgId int64, companyId int64, dividendsEstimateId int64, dividendsAmount string) (map[string]interface{}, error) |
| 19 | InformJoinCreationContract(creationContractId int64, creationContractName string, creationContractNumber string, creationProjectId int64, creationProjectNumber string, creationProjectName string, userId int64, userBaseId int64, orgId int64, companyId int64) (map[string]interface{}, error) | 19 | InformJoinCreationContract(creationContractId int64, creationContractName string, creationContractNumber string, creationProjectId int64, creationProjectNumber string, creationProjectName string, userId int64, userBaseId int64, orgId int64, companyId int64) (map[string]interface{}, error) |
| 20 | PayCreditAccount(creditAccountOrderNum string, settlementAmount string, creditAccountId int64, dividendsEstimateId int64, dividendsEstimateOrderNumber string, userId int64, userBaseId int64, orgId int64, companyId int64) (map[string]interface{}, error) | 20 | PayCreditAccount(creditAccountOrderNum string, settlementAmount string, creditAccountId int64, dividendsEstimateId int64, dividendsEstimateOrderNumber string, userId int64, userBaseId int64, orgId int64, companyId int64) (map[string]interface{}, error) |
| 21 | DividendsEstimate(creditAccountOrderNum string, settlementAmount string, creditAccountId int64, dividendsEstimateId int64, dividendsEstimateOrderNumber string, userId int64, userBaseId int64, orgId int64, companyId int64) (map[string]interface{}, error) | 21 | DividendsEstimate(creditAccountOrderNum string, settlementAmount string, creditAccountId int64, dividendsEstimateId int64, dividendsEstimateOrderNumber string, userId int64, userBaseId int64, orgId int64, companyId int64) (map[string]interface{}, error) |
-
请 注册 或 登录 后发表评论