作者 陈志颖

fix:数据精度处理

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 TransformToDividendsEstimateDomainModelFromPgModels(dividendsEstimateModel *models.DividendsEstimate) (*domain.DividendsEstimate, error) {
dividendsAmount, _ := decimal.NewFromFloatWithExponent(dividendsEstimateModel.DividendsAmount, -2).Float64()
return &domain.DividendsEstimate{
DividendsEstimateId: dividendsEstimateModel.DividendsEstimateId,
DividendsAccountStatus: dividendsEstimateModel.DividendsAccountStatus,
DividendsAmount: dividendsEstimateModel.DividendsAmount,
DividendsAmount: dividendsAmount,
DividendsEstimateOrderNumber: dividendsEstimateModel.DividendsEstimateOrderNumber,
DividendsEstimateTime: dividendsEstimateModel.DividendsEstimateTime,
DividendsParticipateType: dividendsEstimateModel.DividendsParticipateType,
... ...
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"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/utils"
... ... @@ -8,10 +9,11 @@ import (
func TransformToMoneyIncentivesRuleDomainModelFromPgModels(moneyIncentivesRuleModel *models.MoneyIncentivesRule) (*domain.MoneyIncentivesRule, error) {
stageString := utils.NumberToCNNumber(int(moneyIncentivesRuleModel.MoneyIncentivesStage))
moneyIncentivesAmount, _ := decimal.NewFromFloatWithExponent(moneyIncentivesRuleModel.MoneyIncentivesAmount, -2).Float64()
return &domain.MoneyIncentivesRule{
MoneyIncentivesRuleId: moneyIncentivesRuleModel.MoneyIncentivesRuleId,
CooperationContractNumber: moneyIncentivesRuleModel.CooperationContractNumber,
MoneyIncentivesAmount: moneyIncentivesRuleModel.MoneyIncentivesAmount,
MoneyIncentivesAmount: moneyIncentivesAmount,
MoneyIncentivesStage: moneyIncentivesRuleModel.MoneyIncentivesStage,
MoneyIncentivesStageCN: stageString,
MoneyIncentivesStageEnd: moneyIncentivesRuleModel.MoneyIncentivesStageEnd,
... ...
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: orderGoodModel.OrderGoodAmount,
OrderGoodAmount: orderGoodAmount,
OrderGoodName: orderGoodModel.OrderGoodName,
OrderGoodPrice: orderGoodModel.OrderGoodPrice,
OrderGoodQuantity: orderGoodModel.OrderGoodQuantity,
... ...