dividends_order.go 2.3 KB
package transform

import (
	"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain"
	"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/pg/models"
)

func TransformToDividendsOrderDomainModelFromPgModels(dividendsOrderModel *models.DividendsOrder, goods []*models.OrderGood) (*domain.DividendsOrder, error) {
	var orderGoods []*domain.OrderGood
	for _, good := range goods {
		orderGoods = append(orderGoods, &domain.OrderGood{
			OrderGoodId:                  good.OrderGoodId,
			OrderGoodAmount:              good.OrderGoodAmount,
			OrderGoodName:                good.OrderGoodName,
			OrderGoodPrice:               good.OrderGoodPrice,
			OrderGoodQuantity:            good.OrderGoodQuantity,
			DividendsOrderNumber:         good.DividendsReturnedOrderNumber,
			DividendsReturnedOrderNumber: good.DividendsOrderNumber,
			CooperationContractNumber:    good.CooperationContractNumber,
			OrderGoodExpense:             good.OrderGoodExpense,
			CreatedAt:                    good.CreatedAt,
			DeletedAt:                    good.DeletedAt,
			UpdatedAt:                    good.UpdatedAt,
		})
	}
	return &domain.DividendsOrder{
		DividendsOrderId:          dividendsOrderModel.DividendsOrderId,
		DividendsOrderNumber:      dividendsOrderModel.DividendsOrderNumber,
		DividendsOriginalOrderNum: dividendsOrderModel.DividendsOriginalOrderNum,
		DividendsOrderAmount:      dividendsOrderModel.DividendsOrderAmount,
		OrderTime:                 dividendsOrderModel.OrderTime,
		DividendTime:              dividendsOrderModel.DividendTime,
		DividendStatus:            dividendsOrderModel.DividendStatus,
		Region:                    dividendsOrderModel.Region,
		CustomerName:              dividendsOrderModel.CustomerName,
		Org:                       dividendsOrderModel.Org,
		Goods:                     orderGoods,
		Company:                   dividendsOrderModel.Company,
		CreatedAt:                 dividendsOrderModel.CreatedAt,
		DeletedAt:                 dividendsOrderModel.DeletedAt,
		UpdatedAt:                 dividendsOrderModel.UpdatedAt,
		OperateTime:               dividendsOrderModel.OperateTime,
		Operator:                  dividendsOrderModel.Operator,
		Remarks:                   dividendsOrderModel.Remarks,
	}, nil
}