作者 陈志颖

feat:增加新增合约消息推送

... ... @@ -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
}
}
... ...
... ... @@ -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,22 @@ 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.CreditAccountId,
paidData.DividendsEstimateId,
paidData.DividendsEstimateOrderNumber,
paidData.UserId,
paidData.UserBaseId,
paidData.OrgId,
paidData.CompanyId,
)
if err4 != nil {
log.Logger.Error("推送消息错误", map[string]interface{}{
... ... @@ -104,19 +113,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 +138,24 @@ func (subscriber *MessageServiceSubscriber) HandleEvent(domainEvent coreDomain.D
} else {
log.Logger.Info("推送数据返回", data)
}
}
break
case event.DIVIDENDS_INFORM_EXPECTED: // 分红预算
dividendsInformExpectedEvent := domainEvent.(*event.DividendsInformExpected)
for _, expectedData := range dividendsInformExpectedEvent.DividendsInformExpectedData {
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,
expectedData.CreationContractId,
expectedData.CreationContractName,
expectedData.CreationContractNumber,
expectedData.CreationProjectId,
expectedData.CreationProjectName,
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,8 @@ func (subscriber *MessageServiceSubscriber) HandleEvent(domainEvent coreDomain.D
} else {
log.Logger.Info("推送数据返回", data)
}
}
break
}
return nil
... ...
... ... @@ -71,3 +71,7 @@ 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) {
return domain_service.NewInformJoinCreationContractService(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,8 +4,7 @@ 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"`
// 结算金额
... ... @@ -26,6 +25,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
}
... ...
... ... @@ -4,8 +4,7 @@ import coreDomain "github.com/linmadan/egglib-go/core/domain"
const DIVIDENDS_INFORM_EXPECTED = "dividends-inform-expected"
type DividendsInformExpected struct {
coreDomain.BaseEvent
type DividendsInformExpectedData struct {
// 共创合约ID
CreationContractId int64 `json:"creationContractId"`
// 共创合约名称
... ... @@ -32,6 +31,11 @@ type DividendsInformExpected struct {
DividendsAmount string `json:"dividendsAmount"`
}
type DividendsInformExpected struct {
coreDomain.BaseEvent
DividendsInformExpectedData []DividendsInformExpectedData `json:"dividendsInformExpectedData"`
}
func (event *DividendsInformExpected) EventType() string {
return DIVIDENDS_ESTIMATED
}
... ...
... ... @@ -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 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
}
... ...
... ... @@ -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,19 @@ 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 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) {
return &InformJoinCreationContractService{}, 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,19 @@ 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
}
... ...
... ... @@ -125,6 +125,7 @@ func (serviceGateway *HttplibBasicServiceGateway) InformJoinCreationContract(
creationContractName string,
creationContractNumber string,
creationProjectId int64,
creationProjectNumber string,
creationProjectName string,
userId int64,
userBaseId int64,
... ... @@ -138,6 +139,7 @@ func (serviceGateway *HttplibBasicServiceGateway) InformJoinCreationContract(
options["creationContractName"] = creationContractName
options["creationContractNumber"] = creationContractNumber
options["creationProjectId"] = creationProjectId
options["creationProjectNumber"] = creationProjectNumber
options["creationProjectName"] = creationProjectName
options["userId"] = userId
options["userBaseId"] = userBaseId
... ...
... ... @@ -16,7 +16,7 @@ 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)
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, creditAccountId int64, dividendsEstimateId int64, dividendsEstimateOrderNumber string, 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)
}
... ...