event_pay_credit_account_service.go
1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
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
}