service.go
3.4 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
package service
import (
"github.com/linmadan/egglib-go/core/application"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/web/creditAccount/command"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/web/creditAccount/dto"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/web/creditAccount/query"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_cooperation"
)
type CreditAccountService struct{}
func NewCreditAccountService(option map[string]interface{}) CreditAccountService {
return CreditAccountService{}
}
//ListCreditAccount返回账期结算列表
func (srv *CreditAccountService) ListCreditAccount(listQuery *query.ListCreditAccountQuery) (int64, interface{}, error) {
creationCooperationGateway := allied_creation_cooperation.NewHttplibAlliedCreationCooperation(listQuery.Operator)
result, err := creationCooperationGateway.CreditAccountsSearch(allied_creation_cooperation.ReqCreditAccountsSearch{
PageNumber: int64(listQuery.PageNumber),
PageSize: int64(listQuery.PageSize),
CreditAccountOrderNum: listQuery.CreditAccountOrderNum,
ParticipatorName: listQuery.Participator,
})
if err != nil {
return 0, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
var listData []dto.CreditAccountItem
for i := range result.Grid.List {
item := dto.ToCreditAccountItem(&result.Grid.List[i])
listData = append(listData, *item)
}
return int64(result.Grid.Total), listData, nil
}
//GetCreditAccount 返回账期结算详情
func (srv *CreditAccountService) GetCreditAccount(getQuery *query.GetCreditAccountQuery) (interface{}, error) {
creationCooperationGateway := allied_creation_cooperation.NewHttplibAlliedCreationCooperation(getQuery.Operator)
result, err := creationCooperationGateway.CreditAccountGet(allied_creation_cooperation.ReqCreditAccountGet{
CreditAccountId: getQuery.CreditAccountId,
})
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
return dto.ToCreditAccountItem(&result.CreditAccount), nil
}
//PayCreditAccount 支付账期结算
func (srv *CreditAccountService) PayCreditAccount(payCommand *command.PayCreditAccountCommand) (interface{}, error) {
creationCooperationGateway := allied_creation_cooperation.NewHttplibAlliedCreationCooperation(payCommand.Operator)
_, err := creationCooperationGateway.CreditAccountsPay(allied_creation_cooperation.ReqCreditAccountsPay{
CreditAccountId: payCommand.CreditAccountId,
ActuallyPaidAmount: payCommand.ActuallyPaidAmount,
Remarks: payCommand.Remarks,
Attachment: payCommand.Attachment,
})
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
return payCommand, nil
}
//RemoveCreditAccount 删除账期结算
func (srv *CreditAccountService) RemoveCreditAccount(removeCommand *command.RemoveCreditAccountCommand) (interface{}, error) {
creationCooperationGateway := allied_creation_cooperation.NewHttplibAlliedCreationCooperation(removeCommand.Operator)
_, err := creationCooperationGateway.CreditAccountRemove(allied_creation_cooperation.ReqCreditAccountRemove{
CreditAccountId: removeCommand.CreditAccountId,
})
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
return removeCommand, nil
}