作者 陈志颖

合并分支 'dev' 到 'test'

Dev



查看合并请求 !87
正在显示 28 个修改的文件 包含 851 行增加166 行删除
... ... @@ -430,32 +430,38 @@ func (cooperationApplicationService *CooperationApplicationService) BatchApprova
}
// 推送消息
var agreedDataSlices []service.AgreeData
var rejectedDataSlices []service.RejectData
for _, cooperationApplicationApproved := range cooperationApplicationsApproved {
if cooperationApplicationApproved.CooperationApplicationStatus == 2 {
if err1 := agreeContractApplicationService.Agree(
cooperationApplicationApproved.CooperationProject.CooperationProjectId,
cooperationApplicationApproved.CooperationProject.CooperationProjectName,
cooperationApplicationApproved.CooperationProject.CooperationProjectNumber,
cooperationApplicationApproved.CooperationApplicationApplicant.UserId,
cooperationApplicationApproved.CooperationApplicationApplicant.UserBaseId,
cooperationApplicationApproved.CooperationProject.Org.OrgId,
cooperationApplicationApproved.CooperationProject.Company.CompanyId,
); err1 != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err1.Error())
}
agreedDataSlices = append(agreedDataSlices, service.AgreeData{
CreationProjectId: cooperationApplicationApproved.CooperationProject.CooperationProjectId,
CreationProjectName: cooperationApplicationApproved.CooperationProject.CooperationProjectName,
CreationProjectNumber: cooperationApplicationApproved.CooperationProject.CooperationProjectNumber,
UserId: cooperationApplicationApproved.CooperationApplicationApplicant.UserId,
UserBaseId: cooperationApplicationApproved.CooperationApplicationApplicant.UserBaseId,
OrgId: cooperationApplicationApproved.CooperationProject.Org.OrgId,
CompanyId: cooperationApplicationApproved.CooperationProject.Company.CompanyId,
})
} else if cooperationApplicationApproved.CooperationApplicationStatus == 3 {
if err2 := rejectContractApplicationService.Reject(
cooperationApplicationApproved.CooperationProject.CooperationProjectId,
cooperationApplicationApproved.CooperationProject.CooperationProjectName,
cooperationApplicationApproved.CooperationProject.CooperationProjectNumber,
cooperationApplicationApproved.CooperationApplicationApplicant.UserId,
cooperationApplicationApproved.CooperationApplicationApplicant.UserBaseId,
cooperationApplicationApproved.CooperationProject.Org.OrgId,
cooperationApplicationApproved.CooperationProject.Company.CompanyId,
); err2 != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err2.Error())
rejectedDataSlices = append(rejectedDataSlices, service.RejectData{
CreationProjectId: cooperationApplicationApproved.CooperationProject.CooperationProjectId,
CreationProjectName: cooperationApplicationApproved.CooperationProject.CooperationProjectName,
CreationProjectNumber: cooperationApplicationApproved.CooperationProject.CooperationProjectNumber,
UserId: cooperationApplicationApproved.CooperationApplicationApplicant.UserId,
UserBaseId: cooperationApplicationApproved.CooperationApplicationApplicant.UserBaseId,
OrgId: cooperationApplicationApproved.CooperationProject.Org.OrgId,
CompanyId: cooperationApplicationApproved.CooperationProject.Company.CompanyId,
})
}
}
if err1 := agreeContractApplicationService.Agree(agreedDataSlices); err1 != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err1.Error())
}
if err2 := rejectContractApplicationService.Reject(rejectedDataSlices); err2 != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err2.Error())
}
return map[string]interface{}{
... ...
... ... @@ -10,6 +10,7 @@ import (
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/cooperationContract/command"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/cooperationContract/dto"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/cooperationContract/query"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/event/subscriber"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/factory"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain/service"
... ... @@ -48,6 +49,29 @@ func (cooperationContractService *CooperationContractService) CreateCooperationC
userService = value
}
// 共创项目仓储初始化
var cooperationProjectRepository domain.CooperationProjectRepository
if value, err := factory.CreateCooperationProjectRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
cooperationProjectRepository = value
}
// 共创确认消息推送领域服务初始化
var informJoinCreationContractService service.InformJoinCreationContractService
if value, err := factory.CreateInformJoinCreationContractService(map[string]interface{}{
//"transactionContext": transactionContext,
}); err != nil {
return []interface{}{}, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
informJoinCreationContractService = value
_ = informJoinCreationContractService.Subscribe(&subscriber.MessageServiceSubscriber{
//TransactionContext: transactionContext.(*pgTransaction.TransactionContext),
})
}
// 获取操作人
var operator *domain.User
if data, err := userService.OperatorFrom(createCooperationContractCommand.CompanyId, createCooperationContractCommand.OrgId, createCooperationContractCommand.UserId); err != nil {
... ... @@ -144,6 +168,19 @@ func (cooperationContractService *CooperationContractService) CreateCooperationC
return nil, application.ThrowError(application.TRANSACTION_ERROR, "新增共创合约异常")
}
// 获取共创项目
cooperationProject, err := cooperationProjectRepository.FindOne(map[string]interface{}{
"cooperationProjectNumber": createCooperationContractCommand.CooperationProjectNumber,
"orgId": organization.OrgId,
"companyId": company.CompanyId,
})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "共创项目不存在")
}
if cooperationProject == nil {
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", createCooperationContractCommand.CooperationProjectNumber))
}
// 承接人
var undertakers []*domain.Undertaker
for _, undertaker := range createCooperationContractCommand.Undertakers {
... ... @@ -367,6 +404,27 @@ func (cooperationContractService *CooperationContractService) CreateCooperationC
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
// 消息推送
var jointDataSlices []service.JoinData
for _, undertaker := range cooperationContract.Undertakers {
jointDataSlices = append(jointDataSlices, service.JoinData{
CreationContractId: cooperationContract.CooperationContractId,
CreationContractName: cooperationContract.CooperationContractName,
CreationContractNumber: cooperationContract.CooperationContractNumber,
CreationProjectId: cooperationProject.CooperationProjectId,
CreationProjectNumber: cooperationProject.CooperationProjectNumber,
CreationProjectName: cooperationProject.CooperationProjectName,
UserId: undertaker.UserId,
UserBaseId: undertaker.UserBaseId,
OrgId: undertaker.Org.OrgId,
CompanyId: undertaker.Company.CompanyId,
})
}
if err3 := informJoinCreationContractService.Join(jointDataSlices); err3 != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err3.Error())
}
return cooperationContract, nil
}
}
... ... @@ -899,6 +957,16 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC
companyService = value
}
// 共创项目仓储初始化
var cooperationProjectRepository domain.CooperationProjectRepository
if value, err := factory.CreateCooperationProjectRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
cooperationProjectRepository = value
}
// 获取公司信息
var company *domain.Company
if data, err4 := companyService.CompanyFrom(updateCooperationContractCommand.CompanyId); err4 != nil {
... ... @@ -915,6 +983,19 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC
organizationService = value
}
// 共创确认消息推送领域服务初始化
var informJoinCreationContractService service.InformJoinCreationContractService
if value, err := factory.CreateInformJoinCreationContractService(map[string]interface{}{
//"transactionContext": transactionContext,
}); err != nil {
return []interface{}{}, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
informJoinCreationContractService = value
_ = informJoinCreationContractService.Subscribe(&subscriber.MessageServiceSubscriber{
//TransactionContext: transactionContext.(*pgTransaction.TransactionContext),
})
}
// 获取组织机构信息
var organization *domain.Org
if data, err6 := organizationService.OrgFrom(updateCooperationContractCommand.CompanyId, updateCooperationContractCommand.OrgId); err6 != nil {
... ... @@ -974,6 +1055,19 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC
sponsor = data
}
// 获取共创项目
cooperationProject, err := cooperationProjectRepository.FindOne(map[string]interface{}{
"cooperationProjectNumber": cooperationContractFound.CooperationProjectNumber,
"orgId": organization.OrgId,
"companyId": company.CompanyId,
})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "共创项目不存在")
}
if cooperationProject == nil {
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", cooperationContractFound.CooperationProjectNumber))
}
// 获取操作人
var operator *domain.User
if data, err := userService.OperatorFrom(updateCooperationContractCommand.CompanyId, updateCooperationContractCommand.OrgId, updateCooperationContractCommand.UserId); err != nil {
... ... @@ -1127,6 +1221,15 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC
ContractAttachment: contractAttachments,
})
}
// 获取待添加的承接人
var undertakersToAdd []*domain.Undertaker
for _, undertaker := range undertakers {
if undertaker.UndertakerId == 0 {
undertakersToAdd = append(undertakersToAdd, undertaker)
}
}
// 更新承接人
cooperationContract.Undertakers = undertakers
... ... @@ -1509,6 +1612,29 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC
if err21 := transactionContext.CommitTransaction(); err21 != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err21.Error())
}
// 推送消息
if len(undertakersToAdd) > 0 {
var jointDataSlices []service.JoinData
for _, undertakerToAdd := range undertakersToAdd {
jointDataSlices = append(jointDataSlices, service.JoinData{
CreationContractId: cooperationContract.CooperationContractId,
CreationContractName: cooperationContract.CooperationContractName,
CreationContractNumber: cooperationContract.CooperationContractNumber,
CreationProjectId: cooperationProject.CooperationProjectId,
CreationProjectNumber: cooperationProject.CooperationProjectNumber,
CreationProjectName: cooperationProject.CooperationProjectName,
UserId: undertakerToAdd.UserId,
UserBaseId: undertakerToAdd.UserBaseId,
OrgId: undertakerToAdd.Org.OrgId,
CompanyId: undertakerToAdd.Company.CompanyId,
})
}
if err14 := informJoinCreationContractService.Join(jointDataSlices); err14 != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err14.Error())
}
}
return cooperationContractSaved, nil
}
}
... ...
... ... @@ -6,6 +6,7 @@ import (
"github.com/linmadan/egglib-go/utils/tool_funs"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/creditAccount/command"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/creditAccount/query"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/event/subscriber"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/factory"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain/service"
... ... @@ -103,6 +104,17 @@ func (creditAccountService *CreditAccountService) CreateCreditAccount(createCred
creditAccountDao = value
}
// 账期结算消息推送领域服务初始化
var estimateDividendsService service.EstimateDividendsService
if value, err := factory.CreateEstimateDividendsService(map[string]interface{}{}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
estimateDividendsService = value
_ = estimateDividendsService.Subscribe(&subscriber.MessageServiceSubscriber{
//TransactionContext: transactionContext.(*pgTransaction.TransactionContext),
})
}
// 分红预算单仓储初始化
var dividendsEstimateRepository domain.DividendsEstimateRepository
if value, err10 := factory.CreateDividendsEstimateRepository(map[string]interface{}{
... ... @@ -221,6 +233,26 @@ func (creditAccountService *CreditAccountService) CreateCreditAccount(createCred
if err14 := transactionContext.CommitTransaction(); err14 != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err14.Error())
}
// 消息推送
var accountData []service.EstimateData
for _, detail := range creditAccount.AccountDetail {
accountData = append(accountData, service.EstimateData{
CreditAccountOrderNum: creditAccount.CreditAccountOrderNum,
SettlementAmount: fmt.Sprint(creditAccount.SettlementAmount),
CreditAccountId: creditAccount.CreditAccountId,
DividendsEstimateId: detail.DividendsEstimateOrderId,
DividendsEstimateOrderNumber: detail.DividendsEstimateOrderNumber,
UserId: creditAccount.Participator.UserId,
UserBaseId: creditAccount.Participator.UserBaseId,
OrgId: creditAccount.Org.OrgId,
CompanyId: creditAccount.Company.CompanyId,
})
}
if err15 := estimateDividendsService.Estimate(accountData); err15 != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err15.Error())
}
return creditAccount, nil
}
}
... ... @@ -361,6 +393,17 @@ func (creditAccountService *CreditAccountService) PayCreditAccount(payCreditAcco
dividendsEstimateRepository = value
}
// 账期支付消息推送领域服务初始化
var payCreditAccountService service.PayCreditAccountService
if value, err := factory.CreatePayCreditAccountService(map[string]interface{}{}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
payCreditAccountService = value
_ = payCreditAccountService.Subscribe(&subscriber.MessageServiceSubscriber{
//TransactionContext: transactionContext.(*pgTransaction.TransactionContext),
})
}
// 获取待支付的账期结算单
creditAccount, err := creditAccountRepository.FindOne(map[string]interface{}{
"creditAccountId": creditAccountId,
... ... @@ -406,6 +449,23 @@ func (creditAccountService *CreditAccountService) PayCreditAccount(payCreditAcco
if err3 := transactionContext.CommitTransaction(); err3 != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err3.Error())
}
// 支付消息推送
var payData []service.PayData
payData = append(payData, service.PayData{
CreditAccountOrderNum: creditAccountSaved.CreditAccountOrderNum,
SettlementAmount: fmt.Sprint(creditAccountSaved.SettlementAmount),
ActuallyPaidAmount: fmt.Sprint(creditAccountSaved.ActuallyPaidAmount),
CreditAccountId: creditAccountSaved.CreditAccountId,
UserId: creditAccountSaved.Participator.UserId,
UserBaseId: creditAccountSaved.Participator.UserBaseId,
OrgId: creditAccountSaved.Org.OrgId,
CompanyId: creditAccountSaved.Company.CompanyId,
})
if err5 := payCreditAccountService.Pay(payData); err5 != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err5.Error())
}
return creditAccountSaved, nil
}
}
... ...
... ... @@ -3,7 +3,6 @@ package service
import (
"fmt"
"github.com/linmadan/egglib-go/core/application"
pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
"github.com/linmadan/egglib-go/utils/tool_funs"
"github.com/shopspring/decimal"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/dividendsEstimate/command"
... ... @@ -542,6 +541,17 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
// 预算消息推送领域服务初始化
var informDividendsExpectedService service.InformDividendsExpectedService
if value, err := factory.CreateInformDividendsExpectedService(map[string]interface{}{}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
informDividendsExpectedService = value
_ = informDividendsExpectedService.Subscribe(&subscriber.MessageServiceSubscriber{
//TransactionContext: transactionContext.(*pgTransaction.TransactionContext),
})
}
// 公司REST服务初始化
var companyService service.CompanyService
if value, err := factory.CreateCompanyService(map[string]interface{}{}); err != nil {
... ... @@ -656,6 +666,16 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
cooperationContractRepository = value
}
// 共创项目仓储初始化
var cooperationProjectRepository domain.CooperationProjectRepository
if value, err := factory.CreateCooperationProjectRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
cooperationProjectRepository = value
}
// 初始化确认业绩激励分红预算领域服务
var confirmDividendsIncentivesEstimateService service.ConfirmDividendsIncentivesEstimateService
if value, err := factory.CreateConfirmDividendsIncentivesEstimateService(map[string]interface{}{
... ... @@ -664,9 +684,6 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
confirmDividendsIncentivesEstimateService = value
_ = confirmDividendsIncentivesEstimateService.Subscribe(&subscriber.DividendsEstimateSubscriber{
TransactionContext: transactionContext.(*pgTransaction.TransactionContext),
})
}
// 统计成功预算的分红订单
... ... @@ -689,14 +706,21 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
var cooperationContractNumbers []string
orderGoodsMap := make(map[int64]*domain.OrderGood, 0)
// 获取订单产品合约编号
for _, orderGood := range orderGoods {
cooperationContractNumbers = append(cooperationContractNumbers, orderGood.CooperationContractNumber)
orderGoodsMap[orderGood.OrderGoodId] = orderGood
}
newCooperationContractNumbers := utils.RemoveDuplicationString(cooperationContractNumbers)
cooperationContractsMap := make(map[string]*domain.CooperationContract, 0)
cooperationProjectsMap := make(map[string]*domain.CooperationProject, 0)
// 共创项目编号
var cooperationProjectNumbers []string
// 查询共创合约
startQueryContracts := time.Now()
... ... @@ -712,6 +736,7 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
if count > 0 {
for _, cooperationContractFound := range cooperationContractsFound {
cooperationContractsMap[cooperationContractFound.CooperationContractNumber] = cooperationContractFound
cooperationProjectNumbers = append(cooperationProjectNumbers, cooperationContractFound.CooperationProjectNumber)
}
}
}
... ... @@ -720,6 +745,9 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
"report": fmt.Sprintf("已完成0单订单分红预算,生成0单分红预算,失败原因:产品未关联合约"),
}, nil
}
newCooperationProjectNumbers := utils.RemoveDuplicationString(cooperationProjectNumbers)
fmt.Println("查询共创合约耗时:", time.Since(startQueryContracts))
// 统计当前企业分红预算单数
... ... @@ -996,6 +1024,24 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
fmt.Println("更新退货单耗时:", time.Since(startUpdateReturnedOrder))
// 查询共创项目
if len(newCooperationProjectNumbers) > 0 {
if countProject, cooperationProjectsFound, errFind := cooperationProjectRepository.Find(map[string]interface{}{
"cooperationProjectNumbers": newCooperationProjectNumbers,
"companyId": confirmDividendsIncentivesEstimateCommand.CompanyId,
"orgId": confirmDividendsIncentivesEstimateCommand.OrgId,
"offsetLimit": false,
}); errFind != nil {
return nil, errFind
} else {
if countProject > 0 {
for _, cooperationProjectFound := range cooperationProjectsFound {
cooperationProjectsMap[cooperationProjectFound.CooperationProjectNumber] = cooperationProjectFound
}
}
}
}
startCommit := time.Now()
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
... ... @@ -1019,6 +1065,31 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
fmt.Println("函数执行完毕:", time.Since(start))
// 消息通知
var expectedData []service.ExpectedData
for _, dividendsEstimateSaved := range dividendsEstimatesSaved {
if dividendsEstimateSaved.DividendsParticipateType == 1 {
expectedData = append(expectedData, service.ExpectedData{
CreationContractId: cooperationContractsMap[dividendsEstimateSaved.CooperationContractNumber].CooperationContractId,
CreationContractName: cooperationContractsMap[dividendsEstimateSaved.CooperationContractNumber].CooperationContractName,
CreationContractNumber: cooperationContractsMap[dividendsEstimateSaved.CooperationContractNumber].CooperationContractNumber,
CreationProjectId: cooperationProjectsMap[cooperationContractsMap[dividendsEstimateSaved.CooperationContractNumber].CooperationProjectNumber].CooperationProjectId,
CreationProjectName: cooperationProjectsMap[cooperationContractsMap[dividendsEstimateSaved.CooperationContractNumber].CooperationProjectNumber].CooperationProjectName,
CreationProjectNumber: cooperationProjectsMap[cooperationContractsMap[dividendsEstimateSaved.CooperationContractNumber].CooperationProjectNumber].CooperationProjectNumber,
ProductName: orderGoodsMap[dividendsEstimateSaved.OrderGoodId].OrderGoodName,
UserId: dividendsEstimateSaved.DividendsUser.UserId,
UserBaseId: dividendsEstimateSaved.DividendsUser.UserBaseId,
OrgId: dividendsEstimateSaved.Org.OrgId,
CompanyId: dividendsEstimateSaved.Company.CompanyId,
DividendsEstimateId: dividendsEstimateSaved.DividendsEstimateId,
DividendsAmount: fmt.Sprint(dividendsEstimateSaved.DividendsAmount),
})
}
}
if err := informDividendsExpectedService.Expect(expectedData); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
return map[string]interface{}{
"report": fmt.Sprintf("已完成%d单订单分红预算,生成%d单分红预算,%d笔订单分红预算失败,失败原因:%s", len(estimateSuccessfullyDividendsOrders), successfullyCount, len(estimateFailedDividendsOrders), failedReasonStr),
}, nil
... ... @@ -1050,8 +1121,16 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmMoneyIncentives
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
confirmMoneyIncentivesEstimateService = value
_ = confirmMoneyIncentivesEstimateService.Subscribe(&subscriber.DividendsEstimateSubscriber{
TransactionContext: transactionContext.(*pgTransaction.TransactionContext),
}
// 预算消息推送领域服务初始化
var informDividendsExpectedService service.InformDividendsExpectedService
if value, err := factory.CreateInformDividendsExpectedService(map[string]interface{}{}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
informDividendsExpectedService = value
_ = informDividendsExpectedService.Subscribe(&subscriber.MessageServiceSubscriber{
//TransactionContext: transactionContext.(*pgTransaction.TransactionContext),
})
}
... ... @@ -1065,6 +1144,16 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmMoneyIncentives
cooperationContractRepository = value
}
// 共创项目仓储初始化
var cooperationProjectRepository domain.CooperationProjectRepository
if value, err := factory.CreateCooperationProjectRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
cooperationProjectRepository = value
}
// 分红预算单DAO初始化
var dividendsEstimateDao *dao.DividendsEstimateDao
if value, err := factory.CreateDividendsEstimateDao(map[string]interface{}{
... ... @@ -1138,6 +1227,20 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmMoneyIncentives
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", strconv.FormatInt(cooperationContractId, 10)))
}
// 获取共创项目
cooperationProject, err := cooperationProjectRepository.FindOne(map[string]interface{}{
"cooperationProjectNumber": cooperationContract.CooperationProjectNumber,
"orgId": organization.OrgId,
"companyId": company.CompanyId,
})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if cooperationProject == nil {
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", cooperationContract.CooperationProjectNumber))
}
// 分红预算单
var dividendsEstimates []*domain.DividendsEstimate
// 统计当前分红预算单数
... ... @@ -1203,6 +1306,32 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmMoneyIncentives
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
// 消息通知
var expectedData []service.ExpectedData
for _, dividendsEstimateSaved := range dividendsEstimatesSaved {
if dividendsEstimateSaved.DividendsParticipateType == 1 {
expectedData = append(expectedData, service.ExpectedData{
CreationContractId: cooperationContract.CooperationContractId,
CreationContractName: cooperationContract.CooperationContractName,
CreationContractNumber: cooperationContract.CooperationContractNumber,
CreationProjectId: cooperationProject.CooperationProjectId,
CreationProjectName: cooperationProject.CooperationProjectName,
CreationProjectNumber: cooperationProject.CooperationProjectNumber,
ProductName: "",
UserId: dividendsEstimateSaved.DividendsUser.UserId,
UserBaseId: dividendsEstimateSaved.DividendsUser.UserBaseId,
OrgId: dividendsEstimateSaved.Org.OrgId,
CompanyId: dividendsEstimateSaved.Company.CompanyId,
DividendsEstimateId: dividendsEstimateSaved.DividendsEstimateId,
DividendsAmount: fmt.Sprint(dividendsEstimateSaved.DividendsAmount),
})
}
}
if err := informDividendsExpectedService.Expect(expectedData); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
return dividendsEstimatesSaved, nil
}
return dividendsEstimatesSaved, nil
... ...
package subscriber
import (
coreDomain "github.com/linmadan/egglib-go/core/domain"
pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
)
type DividendsEstimateSubscriber struct {
TransactionContext *pgTransaction.TransactionContext
}
func (subscriber *DividendsEstimateSubscriber) HandleEvent(domainEvent coreDomain.DomainEvent) error {
return nil
}
func (subscriber *DividendsEstimateSubscriber) SubscribedToEventTypes() []string {
return []string{
//event.CONFERENCE_MESSAGE, // 日程预约消息通知
}
}
... ... @@ -23,14 +23,15 @@ func (subscriber *MessageServiceSubscriber) HandleEvent(domainEvent coreDomain.D
switch domainEvent.EventType() {
case event.COOPERATION_APPLICATION_AGREED: // 共创申请审核通过
cooperationApplicationAgreedEvent := domainEvent.(*event.CooperationApplicationAgreed)
for _, agreedData := range cooperationApplicationAgreedEvent.CooperationApplicationAgreedData {
data, err1 := messageServiceGateway.AgreeCooperationApplication(
cooperationApplicationAgreedEvent.CreationProjectId,
cooperationApplicationAgreedEvent.CreationProjectName,
cooperationApplicationAgreedEvent.CreationProjectNumber,
cooperationApplicationAgreedEvent.UserId,
cooperationApplicationAgreedEvent.UserBaseId,
cooperationApplicationAgreedEvent.OrgId,
cooperationApplicationAgreedEvent.CompanyId,
agreedData.CreationProjectId,
agreedData.CreationProjectName,
agreedData.CreationProjectNumber,
agreedData.UserId,
agreedData.UserBaseId,
agreedData.OrgId,
agreedData.CompanyId,
)
if err1 != nil {
log.Logger.Error("推送消息错误", map[string]interface{}{
... ... @@ -40,19 +41,22 @@ func (subscriber *MessageServiceSubscriber) HandleEvent(domainEvent coreDomain.D
} else {
log.Logger.Info("推送数据返回", data)
}
}
break
case event.CREATION_CONTRACT_INFORM_JOINT: // 共创确认
creationContractInformJointEvent := domainEvent.(*event.CreationContractInformJoint)
for _, jointData := range creationContractInformJointEvent.CreationContractInformJointData {
data, err2 := messageServiceGateway.InformJoinCreationContract(
creationContractInformJointEvent.CreationContractId,
creationContractInformJointEvent.CreationContractName,
creationContractInformJointEvent.CreationContractNumber,
creationContractInformJointEvent.CreationProjectId,
creationContractInformJointEvent.CreationProjectName,
creationContractInformJointEvent.UserId,
creationContractInformJointEvent.UserBaseId,
creationContractInformJointEvent.OrgId,
creationContractInformJointEvent.CompanyId,
jointData.CreationContractId,
jointData.CreationContractName,
jointData.CreationContractNumber,
jointData.CreationProjectId,
jointData.CreationProjectNumber,
jointData.CreationProjectName,
jointData.UserId,
jointData.UserBaseId,
jointData.OrgId,
jointData.CompanyId,
)
if err2 != nil {
log.Logger.Error("推送消息错误", map[string]interface{}{
... ... @@ -62,17 +66,19 @@ func (subscriber *MessageServiceSubscriber) HandleEvent(domainEvent coreDomain.D
} else {
log.Logger.Info("推送数据返回", data)
}
}
break
case event.COOPERATION_APPLICATION_REJECTED: // 共创申请审核拒绝
cooperationApplicationRejectedEvent := domainEvent.(*event.CooperationApplicationRejected)
for _, rejectedData := range cooperationApplicationRejectedEvent.CooperationApplicationRejectedData {
data, err3 := messageServiceGateway.RejectCooperationApplication(
cooperationApplicationRejectedEvent.CreationProjectId,
cooperationApplicationRejectedEvent.CreationProjectName,
cooperationApplicationRejectedEvent.CreationProjectNumber,
cooperationApplicationRejectedEvent.UserId,
cooperationApplicationRejectedEvent.UserBaseId,
cooperationApplicationRejectedEvent.OrgId,
cooperationApplicationRejectedEvent.CompanyId,
rejectedData.CreationProjectId,
rejectedData.CreationProjectName,
rejectedData.CreationProjectNumber,
rejectedData.UserId,
rejectedData.UserBaseId,
rejectedData.OrgId,
rejectedData.CompanyId,
)
if err3 != nil {
log.Logger.Error("推送消息错误", map[string]interface{}{
... ... @@ -82,19 +88,21 @@ func (subscriber *MessageServiceSubscriber) HandleEvent(domainEvent coreDomain.D
} else {
log.Logger.Info("推送数据返回", data)
}
}
break
case event.CREDIT_ACCOUNT_PAID: // 账期结算支付
creditAccountPaidEvent := domainEvent.(*event.CreditAccountPaid)
for _, paidData := range creditAccountPaidEvent.CreditAccountPaidData {
data, err4 := messageServiceGateway.PayCreditAccount(
creditAccountPaidEvent.CreditAccountOrderNum,
creditAccountPaidEvent.SettlementAmount,
creditAccountPaidEvent.CreditAccountId,
creditAccountPaidEvent.DividendsEstimateId,
creditAccountPaidEvent.DividendsEstimateOrderNumber,
creditAccountPaidEvent.UserId,
creditAccountPaidEvent.UserBaseId,
creditAccountPaidEvent.OrgId,
creditAccountPaidEvent.CompanyId,
paidData.CreditAccountOrderNum,
paidData.SettlementAmount,
paidData.ActuallyPaidAmount,
paidData.CreditAccountId,
paidData.UserId,
paidData.UserBaseId,
paidData.OrgId,
paidData.CompanyId,
)
if err4 != nil {
log.Logger.Error("推送消息错误", map[string]interface{}{
... ... @@ -104,19 +112,22 @@ func (subscriber *MessageServiceSubscriber) HandleEvent(domainEvent coreDomain.D
} else {
log.Logger.Info("推送数据返回", data)
}
}
break
case event.DIVIDENDS_ESTIMATED: // 账期结算
dividendsEstimatedEvent := domainEvent.(*event.DividendsEstimated)
for _, estimatedData := range dividendsEstimatedEvent.DividendsEstimatedData {
data, err5 := messageServiceGateway.DividendsEstimate(
dividendsEstimatedEvent.CreditAccountOrderNum,
dividendsEstimatedEvent.SettlementAmount,
dividendsEstimatedEvent.CreditAccountId,
dividendsEstimatedEvent.DividendsEstimateId,
dividendsEstimatedEvent.DividendsEstimateOrderNumber,
dividendsEstimatedEvent.UserId,
dividendsEstimatedEvent.UserBaseId,
dividendsEstimatedEvent.OrgId,
dividendsEstimatedEvent.CompanyId,
estimatedData.CreditAccountOrderNum,
estimatedData.SettlementAmount,
estimatedData.CreditAccountId,
estimatedData.DividendsEstimateId,
estimatedData.DividendsEstimateOrderNumber,
estimatedData.UserId,
estimatedData.UserBaseId,
estimatedData.OrgId,
estimatedData.CompanyId,
)
if err5 != nil {
log.Logger.Error("推送消息错误", map[string]interface{}{
... ... @@ -126,22 +137,25 @@ func (subscriber *MessageServiceSubscriber) HandleEvent(domainEvent coreDomain.D
} else {
log.Logger.Info("推送数据返回", data)
}
}
break
case event.DIVIDENDS_INFORM_EXPECTED: // 分红预算
dividendsInformExpectedEvent := domainEvent.(*event.DividendsInformExpected)
data, err6 := messageServiceGateway.InformExpectedDividends(
dividendsInformExpectedEvent.CreationContractId,
dividendsInformExpectedEvent.CreationContractName,
dividendsInformExpectedEvent.CreationContractNumber,
dividendsInformExpectedEvent.CreationProjectId,
dividendsInformExpectedEvent.CreationProjectName,
dividendsInformExpectedEvent.ProductName,
dividendsInformExpectedEvent.UserId,
dividendsInformExpectedEvent.UserBaseId,
dividendsInformExpectedEvent.OrgId,
dividendsInformExpectedEvent.CompanyId,
dividendsInformExpectedEvent.DividendsEstimateId,
dividendsInformExpectedEvent.DividendsAmount,
case event.INFORM_DIVIDENDS_EXPECTED: // 分红预算
dividendsInformExpectedEvent := domainEvent.(*event.InformDividendsExpected)
for _, expectedData := range dividendsInformExpectedEvent.DividendsExpectedInformData {
data, err6 := messageServiceGateway.InformDividendsExpected(
expectedData.CreationContractId,
expectedData.CreationContractName,
expectedData.CreationContractNumber,
expectedData.CreationProjectId,
expectedData.CreationProjectName,
expectedData.CreationProjectNumber,
expectedData.ProductName,
expectedData.UserId,
expectedData.UserBaseId,
expectedData.OrgId,
expectedData.CompanyId,
expectedData.DividendsEstimateId,
expectedData.DividendsAmount,
)
if err6 != nil {
log.Logger.Error("推送消息错误", map[string]interface{}{
... ... @@ -151,6 +165,7 @@ func (subscriber *MessageServiceSubscriber) HandleEvent(domainEvent coreDomain.D
} else {
log.Logger.Info("推送数据返回", data)
}
}
break
}
return nil
... ... @@ -163,6 +178,6 @@ func (subscriber *MessageServiceSubscriber) SubscribedToEventTypes() []string {
event.COOPERATION_APPLICATION_REJECTED, // 拒绝共创申请
event.CREDIT_ACCOUNT_PAID, // 账期支付
event.DIVIDENDS_ESTIMATED, // 账期结算
event.DIVIDENDS_INFORM_EXPECTED, // 分红预算
event.INFORM_DIVIDENDS_EXPECTED, // 分红预算
}
}
... ...
... ... @@ -71,3 +71,39 @@ func CreateRejectContractApplicationService(options map[string]interface{}) (*do
//return domain_service.NewRejectContractApplicationService(transactionContext)
return domain_service.NewRejectContractApplicationService(nil)
}
func CreateInformJoinCreationContractService(options map[string]interface{}) (*domain_service.InformJoinCreationContractService, error) {
//var transactionContext *pgTransaction.TransactionContext
//if value, ok := options["transactionContext"]; ok {
// transactionContext = value.(*pgTransaction.TransactionContext)
//}
//return domain_service.NewInformJoinCreationContractService(transactionContext)
return domain_service.NewInformJoinCreationContractService(nil)
}
func CreateEstimateDividendsService(options map[string]interface{}) (*domain_service.EstimateDividendsService, error) {
//var transactionContext *pgTransaction.TransactionContext
//if value, ok := options["transactionContext"]; ok {
// transactionContext = value.(*pgTransaction.TransactionContext)
//}
//return domain_service.NewEstimateDividendsService(transactionContext)
return domain_service.NewEstimateDividendsService(nil)
}
func CreateInformDividendsExpectedService(options map[string]interface{}) (*domain_service.InformDividendsExpectedService, error) {
//var transactionContext *pgTransaction.TransactionContext
//if value, ok := options["transactionContext"]; ok {
// transactionContext = value.(*pgTransaction.TransactionContext)
//}
//return domain_service.NewInformDividendsExpectedService(transactionContext)
return domain_service.NewInformDividendsExpectedService(nil)
}
func CreatePayCreditAccountService(options map[string]interface{}) (*domain_service.PayCreditAccountService, error) {
//var transactionContext *pgTransaction.TransactionContext
//if value, ok := options["transactionContext"]; ok {
// transactionContext = value.(*pgTransaction.TransactionContext)
//}
//return domain_service.NewPayCreditAccountService(transactionContext)
return domain_service.NewPayCreditAccountService(nil)
}
... ...
... ... @@ -4,8 +4,7 @@ import coreDomain "github.com/linmadan/egglib-go/core/domain"
const COOPERATION_APPLICATION_AGREED = "=cooperation-application-agreed"
type CooperationApplicationAgreed struct {
coreDomain.BaseEvent
type CooperationApplicationAgreedData struct {
// 共创项目ID
CreationProjectId int64 `json:"creationProjectId"`
// 共创项目名称
... ... @@ -22,6 +21,11 @@ type CooperationApplicationAgreed struct {
CompanyId int64 `json:"companyId"`
}
type CooperationApplicationAgreed struct {
coreDomain.BaseEvent
CooperationApplicationAgreedData []CooperationApplicationAgreedData `json:"cooperationApplicationAgreedData"`
}
func (event *CooperationApplicationAgreed) EventType() string {
return COOPERATION_APPLICATION_AGREED
}
... ...
... ... @@ -4,8 +4,7 @@ import coreDomain "github.com/linmadan/egglib-go/core/domain"
const COOPERATION_APPLICATION_REJECTED = "cooperation-application-rejected"
type CooperationApplicationRejected struct {
coreDomain.BaseEvent
type CooperationApplicationRejectedData struct {
// 共创项目ID
CreationProjectId int64 `json:"creationProjectId"`
// 共创项目名称
... ... @@ -22,6 +21,11 @@ type CooperationApplicationRejected struct {
CompanyId int64 `json:"companyId"`
}
type CooperationApplicationRejected struct {
coreDomain.BaseEvent
CooperationApplicationRejectedData []CooperationApplicationRejectedData `json:"cooperationApplicationRejectedData"`
}
func (event *CooperationApplicationRejected) EventType() string {
return COOPERATION_APPLICATION_REJECTED
}
... ...
... ... @@ -4,8 +4,7 @@ import coreDomain "github.com/linmadan/egglib-go/core/domain"
const CREATION_CONTRACT_INFORM_JOINT = "creation-contract-inform-joint"
type CreationContractInformJoint struct {
coreDomain.BaseEvent
type CreationContractInformJointData struct {
// 共创合约ID
CreationContractId int64 `json:"creationContractId"`
// 共创合约名称
... ... @@ -14,6 +13,8 @@ type CreationContractInformJoint struct {
CreationContractNumber string `json:"creationContractNumber"`
// 共创项目ID
CreationProjectId int64 `json:"creationProjectId"`
// 共创项目编号
CreationProjectNumber string `json:"creationProjectNumber"`
// 共创项目名称
CreationProjectName string `json:"creationProjectName"`
// 申请人ID
... ... @@ -26,6 +27,11 @@ type CreationContractInformJoint struct {
CompanyId int64 `json:"companyId"`
}
type CreationContractInformJoint struct {
coreDomain.BaseEvent
CreationContractInformJointData []CreationContractInformJointData `json:"creationContractInformJointData"`
}
func (event *CreationContractInformJoint) EventType() string {
return CREATION_CONTRACT_INFORM_JOINT
}
... ...
... ... @@ -4,18 +4,15 @@ import coreDomain "github.com/linmadan/egglib-go/core/domain"
const CREDIT_ACCOUNT_PAID = "credit-account-paid"
type CreditAccountPaid struct {
coreDomain.BaseEvent
type CreditAccountPaidData struct {
// 账期结算单编号
CreditAccountOrderNum string `json:"creditAccountOrderNum"`
// 结算金额
SettlementAmount string `json:"settlementAmount"`
// 实际支付金额
ActuallyPaidAmount string `json:"actuallyPaidAmount"`
// 账期结算单ID
CreditAccountId int64 `json:"creditAccountId"`
// 分红预算单ID
DividendsEstimateId int64 `json:"dividendsEstimateId"`
// 分红预算单编号
DividendsEstimateOrderNumber string `json:"dividendsEstimateOrderNumber"`
// 申请人ID
UserId int64 `json:"userId"`
// 申请人基础ID
... ... @@ -26,6 +23,11 @@ type CreditAccountPaid struct {
CompanyId int64 `json:"companyId"`
}
type CreditAccountPaid struct {
coreDomain.BaseEvent
CreditAccountPaidData []CreditAccountPaidData `json:"creditAccountPaidData"`
}
func (event *CreditAccountPaid) EventType() string {
return CREDIT_ACCOUNT_PAID
}
... ...
... ... @@ -4,8 +4,7 @@ import coreDomain "github.com/linmadan/egglib-go/core/domain"
const DIVIDENDS_ESTIMATED = "dividends-estimated"
type DividendsEstimated struct {
coreDomain.BaseEvent
type DividendsEstimatedData struct {
// 账期结算单编号
CreditAccountOrderNum string `json:"creditAccountOrderNum"`
// 结算金额
... ... @@ -26,6 +25,11 @@ type DividendsEstimated struct {
CompanyId int64 `json:"companyId"`
}
type DividendsEstimated struct {
coreDomain.BaseEvent
DividendsEstimatedData []DividendsEstimatedData `json:"dividendsEstimatedData"`
}
func (event *DividendsEstimated) EventType() string {
return DIVIDENDS_ESTIMATED
}
... ...
... ... @@ -2,10 +2,9 @@ package event
import coreDomain "github.com/linmadan/egglib-go/core/domain"
const DIVIDENDS_INFORM_EXPECTED = "dividends-inform-expected"
const INFORM_DIVIDENDS_EXPECTED = "inform-dividends-expected"
type DividendsInformExpected struct {
coreDomain.BaseEvent
type DividendsExpectedInformData struct {
// 共创合约ID
CreationContractId int64 `json:"creationContractId"`
// 共创合约名称
... ... @@ -16,6 +15,8 @@ type DividendsInformExpected struct {
CreationProjectId int64 `json:"creationProjectId"`
// 共创项目名称
CreationProjectName string `json:"creationProjectName"`
// 共创项目编号
CreationProjectNumber string `json:"creationProjectNumber"`
// 产品名称
ProductName string `json:"productName"`
// 申请人ID
... ... @@ -32,6 +33,11 @@ type DividendsInformExpected struct {
DividendsAmount string `json:"dividendsAmount"`
}
func (event *DividendsInformExpected) EventType() string {
return DIVIDENDS_ESTIMATED
type InformDividendsExpected struct {
coreDomain.BaseEvent
DividendsExpectedInformData []DividendsExpectedInformData `json:"dividendsExpectedInformData"`
}
func (event *InformDividendsExpected) EventType() string {
return INFORM_DIVIDENDS_EXPECTED
}
... ...
... ... @@ -2,7 +2,17 @@ package service
import coreDomain "github.com/linmadan/egglib-go/core/domain"
type AgreeData struct {
CreationProjectId int64
CreationProjectName string
CreationProjectNumber string
UserId int64
UserBaseId int64
OrgId int64
CompanyId int64
}
type AgreeContractApplicationService interface {
coreDomain.DomainEventPublisher
Agree(creationProjectId int64, creationProjectName string, creationProjectNumber string, userId int64, userBaseId int64, orgId int64, companyId int64) error
Agree([]AgreeData) error
}
... ...
package service
import coreDomain "github.com/linmadan/egglib-go/core/domain"
type EstimateData struct {
CreditAccountOrderNum string
SettlementAmount string
CreditAccountId int64
DividendsEstimateId int64
DividendsEstimateOrderNumber string
UserId int64
UserBaseId int64
OrgId int64
CompanyId int64
}
type EstimateDividendsService interface {
coreDomain.DomainEventPublisher
Estimate([]EstimateData) error
}
... ...
package service
import coreDomain "github.com/linmadan/egglib-go/core/domain"
type ExpectedData struct {
CreationContractId int64
CreationContractName string
CreationContractNumber string
CreationProjectId int64
CreationProjectName string
CreationProjectNumber string
ProductName string
UserId int64
UserBaseId int64
OrgId int64
CompanyId int64
DividendsEstimateId int64
DividendsAmount string
}
type InformDividendsExpectedService interface {
coreDomain.DomainEventPublisher
Expect([]ExpectedData) error
}
... ...
package service
import coreDomain "github.com/linmadan/egglib-go/core/domain"
type JoinData struct {
CreationContractId int64
CreationContractName string
CreationContractNumber string
CreationProjectId int64
CreationProjectNumber string
CreationProjectName string
UserId int64
UserBaseId int64
OrgId int64
CompanyId int64
}
type InformJoinCreationContractService interface {
coreDomain.DomainEventPublisher
Join([]JoinData) error
}
... ...
package service
import coreDomain "github.com/linmadan/egglib-go/core/domain"
type PayData struct {
CreditAccountOrderNum string
SettlementAmount string
ActuallyPaidAmount string
CreditAccountId int64
UserId int64
UserBaseId int64
OrgId int64
CompanyId int64
}
type PayCreditAccountService interface {
coreDomain.DomainEventPublisher
Pay([]PayData) error
}
... ...
... ... @@ -2,7 +2,17 @@ package service
import coreDomain "github.com/linmadan/egglib-go/core/domain"
type RejectData struct {
CreationProjectId int64
CreationProjectName string
CreationProjectNumber string
UserId int64
UserBaseId int64
OrgId int64
CompanyId int64
}
type RejectContractApplicationService interface {
coreDomain.DomainEventPublisher
Reject(creationProjectId int64, creationProjectName string, creationProjectNumber string, userId int64, userBaseId int64, orgId int64, companyId int64) error
Reject([]RejectData) error
}
... ...
... ... @@ -4,6 +4,7 @@ import (
coreDomain "github.com/linmadan/egglib-go/core/domain"
pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain/event"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain/service"
)
type AgreeContractApplicationService struct {
... ... @@ -11,15 +12,20 @@ type AgreeContractApplicationService struct {
//transactionContext *pgTransaction.TransactionContext
}
func (service *AgreeContractApplicationService) Agree(creationProjectId int64, creationProjectName string, creationProjectNumber string, userId int64, userBaseId int64, orgId int64, companyId int64) error {
// 同意申请
func (service *AgreeContractApplicationService) Agree(data []service.AgreeData) error {
cooperationApplicationAgreedEvent := new(event.CooperationApplicationAgreed)
cooperationApplicationAgreedEvent.CreationProjectId = creationProjectId
cooperationApplicationAgreedEvent.CreationProjectName = creationProjectName
cooperationApplicationAgreedEvent.CreationProjectNumber = creationProjectNumber
cooperationApplicationAgreedEvent.UserId = userId
cooperationApplicationAgreedEvent.UserBaseId = userBaseId
cooperationApplicationAgreedEvent.OrgId = orgId
cooperationApplicationAgreedEvent.CompanyId = companyId
for _, cooperationApplicationAgreedData := range data {
cooperationApplicationAgreedEvent.CooperationApplicationAgreedData = append(cooperationApplicationAgreedEvent.CooperationApplicationAgreedData, event.CooperationApplicationAgreedData{
CreationProjectId: cooperationApplicationAgreedData.CreationProjectId,
CreationProjectName: cooperationApplicationAgreedData.CreationProjectName,
CreationProjectNumber: cooperationApplicationAgreedData.CreationProjectNumber,
UserId: cooperationApplicationAgreedData.UserId,
UserBaseId: cooperationApplicationAgreedData.UserBaseId,
OrgId: cooperationApplicationAgreedData.OrgId,
CompanyId: cooperationApplicationAgreedData.CompanyId,
})
}
if err := service.Publish(cooperationApplicationAgreedEvent); err != nil {
return err
}
... ...
package domain_service
import (
coreDomain "github.com/linmadan/egglib-go/core/domain"
pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain/event"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain/service"
)
type EstimateDividendsService struct {
coreDomain.BaseEventPublisher
//transactionContext *pgTransaction.TransactionContext
}
// 账期结算
func (service *EstimateDividendsService) Estimate(data []service.EstimateData) error {
dividendsEstimatedEvent := new(event.DividendsEstimated)
for _, dividendsEstimatedData := range data {
dividendsEstimatedEvent.DividendsEstimatedData = append(dividendsEstimatedEvent.DividendsEstimatedData, event.DividendsEstimatedData{
CreditAccountOrderNum: dividendsEstimatedData.CreditAccountOrderNum,
SettlementAmount: dividendsEstimatedData.SettlementAmount,
CreditAccountId: dividendsEstimatedData.CreditAccountId,
DividendsEstimateId: dividendsEstimatedData.DividendsEstimateId,
DividendsEstimateOrderNumber: dividendsEstimatedData.DividendsEstimateOrderNumber,
UserId: dividendsEstimatedData.UserId,
UserBaseId: dividendsEstimatedData.UserBaseId,
OrgId: dividendsEstimatedData.OrgId,
CompanyId: dividendsEstimatedData.CompanyId,
})
}
if err := service.Publish(dividendsEstimatedEvent); err != nil {
return err
}
return nil
}
func NewEstimateDividendsService(transactionContext *pgTransaction.TransactionContext) (*EstimateDividendsService, error) {
//if transactionContext == nil {
// return nil, fmt.Errorf("transactionContext参数不能为nil")
//} else {
// return &EstimateDividendsService{
// transactionContext: transactionContext,
// }, nil
//}
return &EstimateDividendsService{}, nil
}
... ...
package domain_service
import (
coreDomain "github.com/linmadan/egglib-go/core/domain"
pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain/event"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain/service"
)
type InformDividendsExpectedService struct {
coreDomain.BaseEventPublisher
//transactionContext *pgTransaction.TransactionContext
}
// 分红预算
func (service *InformDividendsExpectedService) Expect(data []service.ExpectedData) error {
dividendsExpectedInformEvent := new(event.InformDividendsExpected)
for _, dividendsExpectedInformedData := range data {
dividendsExpectedInformEvent.DividendsExpectedInformData = append(dividendsExpectedInformEvent.DividendsExpectedInformData, event.DividendsExpectedInformData{
CreationContractId: dividendsExpectedInformedData.CreationContractId,
CreationContractName: dividendsExpectedInformedData.CreationContractName,
CreationContractNumber: dividendsExpectedInformedData.CreationContractNumber,
CreationProjectId: dividendsExpectedInformedData.CreationProjectId,
CreationProjectName: dividendsExpectedInformedData.CreationProjectName,
CreationProjectNumber: dividendsExpectedInformedData.CreationProjectNumber,
ProductName: dividendsExpectedInformedData.ProductName,
UserId: dividendsExpectedInformedData.UserId,
UserBaseId: dividendsExpectedInformedData.UserBaseId,
OrgId: dividendsExpectedInformedData.OrgId,
CompanyId: dividendsExpectedInformedData.CompanyId,
DividendsEstimateId: dividendsExpectedInformedData.DividendsEstimateId,
DividendsAmount: dividendsExpectedInformedData.DividendsAmount,
})
}
if err := service.Publish(dividendsExpectedInformEvent); err != nil {
return err
}
return nil
}
func NewInformDividendsExpectedService(transactionContext *pgTransaction.TransactionContext) (*InformDividendsExpectedService, error) {
//if transactionContext == nil {
// return nil, fmt.Errorf("transactionContext参数不能为nil")
//} else {
// return &InformDividendsExpectedService{
// transactionContext: transactionContext,
// }, nil
//}
return &InformDividendsExpectedService{}, nil
}
... ...
package domain_service
import (
coreDomain "github.com/linmadan/egglib-go/core/domain"
pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain/event"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain/service"
)
type InformJoinCreationContractService struct {
coreDomain.BaseEventPublisher
}
// 承接人加入共创
func (service *InformJoinCreationContractService) Join(data []service.JoinData) error {
creationContractInformJointEvent := new(event.CreationContractInformJoint)
for _, creationContractInformJointData := range data {
creationContractInformJointEvent.CreationContractInformJointData = append(creationContractInformJointEvent.CreationContractInformJointData, event.CreationContractInformJointData{
CreationContractId: creationContractInformJointData.CreationContractId,
CreationContractName: creationContractInformJointData.CreationContractName,
CreationContractNumber: creationContractInformJointData.CreationContractNumber,
CreationProjectId: creationContractInformJointData.CreationProjectId,
CreationProjectNumber: creationContractInformJointData.CreationProjectNumber,
CreationProjectName: creationContractInformJointData.CreationProjectName,
UserId: creationContractInformJointData.UserId,
UserBaseId: creationContractInformJointData.UserBaseId,
OrgId: creationContractInformJointData.OrgId,
CompanyId: creationContractInformJointData.CompanyId,
})
}
if err := service.Publish(creationContractInformJointEvent); err != nil {
return err
}
return nil
}
func NewInformJoinCreationContractService(transactionContext *pgTransaction.TransactionContext) (*InformJoinCreationContractService, error) {
//if transactionContext == nil {
// return nil, fmt.Errorf("transactionContext参数不能为nil")
//} else {
// return &InformJoinCreationContractService{
// transactionContext: transactionContext,
// }, nil
//}
return &InformJoinCreationContractService{}, nil
}
... ...
package domain_service
import (
coreDomain "github.com/linmadan/egglib-go/core/domain"
pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain/event"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain/service"
)
type PayCreditAccountService struct {
coreDomain.BaseEventPublisher
//transactionContext *pgTransaction.TransactionContext
}
// 账期支付
func (service *PayCreditAccountService) Pay(data []service.PayData) error {
creditAccountPaidEvent := new(event.CreditAccountPaid)
for _, creditAccountPaidData := range data {
creditAccountPaidEvent.CreditAccountPaidData = append(creditAccountPaidEvent.CreditAccountPaidData, event.CreditAccountPaidData{
CreditAccountOrderNum: creditAccountPaidData.CreditAccountOrderNum,
SettlementAmount: creditAccountPaidData.SettlementAmount,
CreditAccountId: creditAccountPaidData.CreditAccountId,
UserId: creditAccountPaidData.UserId,
UserBaseId: creditAccountPaidData.UserBaseId,
OrgId: creditAccountPaidData.OrgId,
CompanyId: creditAccountPaidData.CompanyId,
})
}
if err := service.Publish(creditAccountPaidEvent); err != nil {
return err
}
return nil
}
func NewPayCreditAccountService(transactionContext *pgTransaction.TransactionContext) (*PayCreditAccountService, error) {
//if transactionContext == nil {
// return nil, fmt.Errorf("transactionContext参数不能为nil")
//} else {
// return &PayCreditAccountService{
// transactionContext: transactionContext,
// }, nil
//}
return &PayCreditAccountService{}, nil
}
... ...
... ... @@ -4,6 +4,7 @@ import (
coreDomain "github.com/linmadan/egglib-go/core/domain"
pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain/event"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain/service"
)
type RejectContractApplicationService struct {
... ... @@ -11,15 +12,20 @@ type RejectContractApplicationService struct {
//transactionContext *pgTransaction.TransactionContext
}
func (service *RejectContractApplicationService) Reject(creationProjectId int64, creationProjectName string, creationProjectNumber string, userId int64, userBaseId int64, orgId int64, companyId int64) error {
// 拒绝申请
func (service *RejectContractApplicationService) Reject(data []service.RejectData) error {
cooperationApplicationRejectedEvent := new(event.CooperationApplicationRejected)
cooperationApplicationRejectedEvent.CreationProjectId = creationProjectId
cooperationApplicationRejectedEvent.CreationProjectName = creationProjectName
cooperationApplicationRejectedEvent.CreationProjectNumber = creationProjectNumber
cooperationApplicationRejectedEvent.UserId = userId
cooperationApplicationRejectedEvent.UserBaseId = userBaseId
cooperationApplicationRejectedEvent.OrgId = orgId
cooperationApplicationRejectedEvent.CompanyId = companyId
for _, cooperationApplicationRejectedData := range data {
cooperationApplicationRejectedEvent.CooperationApplicationRejectedData = append(cooperationApplicationRejectedEvent.CooperationApplicationRejectedData, event.CooperationApplicationRejectedData{
CreationProjectId: cooperationApplicationRejectedData.CreationProjectId,
CreationProjectName: cooperationApplicationRejectedData.CreationProjectName,
CreationProjectNumber: cooperationApplicationRejectedData.CreationProjectNumber,
UserId: cooperationApplicationRejectedData.UserId,
UserBaseId: cooperationApplicationRejectedData.UserBaseId,
OrgId: cooperationApplicationRejectedData.OrgId,
CompanyId: cooperationApplicationRejectedData.CompanyId,
})
}
if err := service.Publish(cooperationApplicationRejectedEvent); err != nil {
return err
}
... ...
... ... @@ -259,6 +259,9 @@ func (repository *CooperationProjectRepository) Find(queryOptions map[string]int
if cooperationProjectNumber, ok := queryOptions["cooperationProjectNumber"]; ok && cooperationProjectNumber != "" {
query.Where("cooperation_project_number ilike ?", fmt.Sprintf("%%%s%%", cooperationProjectNumber))
}
if cooperationProjectNumbers, ok := queryOptions["cooperationProjectNumbers"]; ok && len(cooperationProjectNumbers.([]string)) != 0 {
query.Where("cooperation_project_number in (?)", pg.In(cooperationProjectNumbers))
}
if keyword, ok := queryOptions["keyword"]; ok && keyword != "" {
query.Where("cooperation_project_description like ?", fmt.Sprintf("%%%s%%", keyword))
}
... ...
... ... @@ -76,36 +76,32 @@ func (serviceGateway *HttplibBasicServiceGateway) RejectCooperationApplication(
return data, err
}
// InformExpectedDividends 分红预算消息
func (serviceGateway *HttplibBasicServiceGateway) InformExpectedDividends(
// InformJoinCreationContract 确认共创
func (serviceGateway *HttplibBasicServiceGateway) InformJoinCreationContract(
creationContractId int64,
creationContractName string,
creationContractNumber string,
creationProjectId int64,
creationProjectNumber string,
creationProjectName string,
productName string,
userId int64,
userBaseId int64,
orgId int64,
companyId int64,
dividendsEstimateId int64,
dividendsAmount string,
) (map[string]interface{}, error) {
url := strings.Join([]string{serviceGateway.baseURL, "notice-personal/inform-expected-dividends"}, "/")
url := strings.Join([]string{serviceGateway.baseURL, "notice-personal/inform-join-creation-contract"}, "/")
request := serviceGateway.createRequest(url, "post")
options := make(map[string]interface{})
options["creationContractId"] = creationContractId
options["creationContractName"] = creationContractName
options["creationContractNumber"] = creationContractNumber
options["creationProjectId"] = creationProjectId
options["creationProjectNumber"] = creationProjectNumber
options["creationProjectName"] = creationProjectName
options["productName"] = productName
options["userId"] = userId
options["userBaseId"] = userBaseId
options["orgId"] = orgId
options["companyId"] = companyId
options["dividendsEstimateId"] = dividendsEstimateId
options["dividendsAmount"] = dividendsAmount
_, err2 := request.JSONBody(options)
if err2 != nil {
return nil, err2
... ... @@ -119,19 +115,23 @@ func (serviceGateway *HttplibBasicServiceGateway) InformExpectedDividends(
return data, err
}
// InformJoinCreationContract 确认共创
func (serviceGateway *HttplibBasicServiceGateway) InformJoinCreationContract(
// InformExpectedDividends 分红预算消息
func (serviceGateway *HttplibBasicServiceGateway) InformDividendsExpected(
creationContractId int64,
creationContractName string,
creationContractNumber string,
creationProjectId int64,
creationProjectName string,
creationProjectNumber string,
productName string,
userId int64,
userBaseId int64,
orgId int64,
companyId int64,
dividendsEstimateId int64,
dividendsAmount string,
) (map[string]interface{}, error) {
url := strings.Join([]string{serviceGateway.baseURL, "notice-personal/inform-join-creation-contract"}, "/")
url := strings.Join([]string{serviceGateway.baseURL, "notice-personal/inform-expected-dividends"}, "/")
request := serviceGateway.createRequest(url, "post")
options := make(map[string]interface{})
options["creationContractId"] = creationContractId
... ... @@ -139,10 +139,14 @@ func (serviceGateway *HttplibBasicServiceGateway) InformJoinCreationContract(
options["creationContractNumber"] = creationContractNumber
options["creationProjectId"] = creationProjectId
options["creationProjectName"] = creationProjectName
options["creationProjectNumber"] = creationProjectNumber
options["productName"] = productName
options["userId"] = userId
options["userBaseId"] = userBaseId
options["orgId"] = orgId
options["companyId"] = companyId
options["dividendsEstimateId"] = dividendsEstimateId
options["dividendsAmount"] = dividendsAmount
_, err2 := request.JSONBody(options)
if err2 != nil {
return nil, err2
... ... @@ -156,8 +160,8 @@ func (serviceGateway *HttplibBasicServiceGateway) InformJoinCreationContract(
return data, err
}
// PayCreditAccount 账期支付
func (serviceGateway *HttplibBasicServiceGateway) PayCreditAccount(
// DividendsEstimate 账期结算
func (serviceGateway *HttplibBasicServiceGateway) DividendsEstimate(
creditAccountOrderNum string,
settlementAmount string,
creditAccountId int64,
... ... @@ -168,7 +172,7 @@ func (serviceGateway *HttplibBasicServiceGateway) PayCreditAccount(
orgId int64,
companyId int64,
) (map[string]interface{}, error) {
url := strings.Join([]string{serviceGateway.baseURL, "notice-personal/notice-personal/credit-account/payment"}, "/")
url := strings.Join([]string{serviceGateway.baseURL, "notice-personal/credit-account/dividends-estimate"}, "/")
request := serviceGateway.createRequest(url, "post")
options := make(map[string]interface{})
options["creditAccountOrderNum"] = creditAccountOrderNum
... ... @@ -193,26 +197,24 @@ func (serviceGateway *HttplibBasicServiceGateway) PayCreditAccount(
return data, err
}
// DividendsEstimate 分红预算
func (serviceGateway *HttplibBasicServiceGateway) DividendsEstimate(
// PayCreditAccount 账期支付
func (serviceGateway *HttplibBasicServiceGateway) PayCreditAccount(
creditAccountOrderNum string,
settlementAmount string,
actuallyPaidAmount string,
creditAccountId int64,
dividendsEstimateId int64,
dividendsEstimateOrderNumber string,
userId int64,
userBaseId int64,
orgId int64,
companyId int64,
) (map[string]interface{}, error) {
url := strings.Join([]string{serviceGateway.baseURL, "notice-personal/credit-account/dividends-estimate"}, "/")
url := strings.Join([]string{serviceGateway.baseURL, "notice-personal/notice-personal/credit-account/payment"}, "/")
request := serviceGateway.createRequest(url, "post")
options := make(map[string]interface{})
options["creditAccountOrderNum"] = creditAccountOrderNum
options["settlementAmount"] = settlementAmount
options["actuallyPaidAmount"] = actuallyPaidAmount
options["creditAccountId"] = creditAccountId
options["dividendsEstimateId"] = dividendsEstimateId
options["dividendsEstimateOrderNumber"] = dividendsEstimateOrderNumber
options["userId"] = userId
options["userBaseId"] = userBaseId
options["orgId"] = orgId
... ...
... ... @@ -15,8 +15,8 @@ type UserServiceGateway interface {
type BasicServiceGateway interface {
AgreeCooperationApplication(creationProjectId int64, creationProjectName string, creationProjectNumber string, userId int64, userBaseId int64, orgId int64, companyId int64) (map[string]interface{}, error)
RejectCooperationApplication(creationProjectId int64, creationProjectName string, creationProjectNumber string, userId int64, userBaseId int64, orgId int64, companyId int64) (map[string]interface{}, error)
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)
InformJoinCreationContract(creationContractId int64, creationContractName string, creationContractNumber string, creationProjectId int64, creationProjectName string, userId int64, userBaseId int64, orgId int64, companyId int64) (map[string]interface{}, error)
PayCreditAccount(creditAccountOrderNum string, settlementAmount string, creditAccountId int64, dividendsEstimateId int64, dividendsEstimateOrderNumber string, userId int64, userBaseId int64, orgId int64, companyId int64) (map[string]interface{}, error)
InformDividendsExpected(creationContractId int64, creationContractName string, creationContractNumber string, creationProjectId int64, creationProjectName string, creationProjectNumber string, productName string, userId int64, userBaseId int64, orgId int64, companyId int64, dividendsEstimateId int64, dividendsAmount string) (map[string]interface{}, error)
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)
PayCreditAccount(creditAccountOrderNum string, settlementAmount string, actuallyPaidAmount string, creditAccountId int64, userId int64, userBaseId int64, orgId int64, companyId int64) (map[string]interface{}, error)
DividendsEstimate(creditAccountOrderNum string, settlementAmount string, creditAccountId int64, dividendsEstimateId int64, dividendsEstimateOrderNumber string, userId int64, userBaseId int64, orgId int64, companyId int64) (map[string]interface{}, error)
}
... ...