service.go 2.2 KB
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/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) {

	return 0, nil, nil
}

//GetCreditAccount 返回账期结算详情
func (srv *CreditAccountService) GetCreditAccount(getQuery *query.GetCreditAccountQuery) (interface{}, error) {

	return nil, 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
}