order_good.go 1.4 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 TransformToOrderGoodDomainModelFromPgModels(orderGoodModel *models.OrderGood) (*domain.OrderGood, error) {
	orderGoodAmount, _ := decimal.NewFromFloatWithExponent(orderGoodModel.OrderGoodAmount, -2).Float64()
	return &domain.OrderGood{
		OrderGoodId:                  orderGoodModel.OrderGoodId,
		OrderGoodAmount:              orderGoodAmount,
		OrderGoodName:                orderGoodModel.OrderGoodName,
		OrderGoodPrice:               orderGoodModel.OrderGoodPrice,
		OrderGoodQuantity:            orderGoodModel.OrderGoodQuantity,
		DividendsOrderNumber:         orderGoodModel.DividendsOrderNumber,
		DividendsReturnedOrderNumber: orderGoodModel.DividendsReturnedOrderNumber,
		CooperationContractNumber:    orderGoodModel.CooperationContractNumber,
		OrderGoodExpense:             orderGoodModel.OrderGoodExpense,
		OrderGoodDividendsStatus:     orderGoodModel.OrderGoodDividendsStatus,
		OrgId:                        orderGoodModel.OrgId,
		CompanyId:                    orderGoodModel.CompanyId,
		CreatedAt:                    orderGoodModel.CreatedAt,
		DeletedAt:                    orderGoodModel.DeletedAt,
		UpdatedAt:                    orderGoodModel.UpdatedAt,
	}, nil
}