credit_account.go
1.8 KB
package transform
import (
"github.com/shopspring/decimal"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/pg/models"
)
func TransformToCreditAccountDomainModelFromPgModels(creditAccountModel *models.CreditAccount) (*domain.CreditAccount, error) {
settlementAmount, _ := decimal.NewFromFloatWithExponent(creditAccountModel.SettlementAmount, -2).Float64()
return &domain.CreditAccount{
CreditAccountId: creditAccountModel.CreditAccountId,
ActuallyPaidAmount: creditAccountModel.ActuallyPaidAmount,
CreditAccountOrderNum: creditAccountModel.CreditAccountOrderNum,
PaymentStatus: creditAccountModel.PaymentStatus,
PaymentTime: creditAccountModel.PaymentTime,
SettlementAmount: settlementAmount,
SettlementTime: creditAccountModel.SettlementTime,
CooperationContractNumber: creditAccountModel.CooperationContractNumber,
Participator: creditAccountModel.Participator,
ParticipateType: creditAccountModel.ParticipateType,
AccountDetail: creditAccountModel.AccountDetail,
GoodAmountCount: creditAccountModel.GoodAmountCount,
PaymentDocumentAttachments: creditAccountModel.PaymentDocumentAttachments,
Org: creditAccountModel.Org,
Company: creditAccountModel.Company,
Operator: creditAccountModel.Operator,
OperateTime: creditAccountModel.OperateTime,
CreatedAt: creditAccountModel.CreatedAt,
DeletedAt: creditAccountModel.DeletedAt,
UpdatedAt: creditAccountModel.UpdatedAt,
Remarks: creditAccountModel.Remarks,
}, nil
}