event_inform_dividends_expected_service.go 2.3 KB
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
}