diff --git a/internal/logic/orderservice/utils.go b/internal/logic/orderservice/utils.go index ac30a7d..02c79fa 100644 --- a/internal/logic/orderservice/utils.go +++ b/internal/logic/orderservice/utils.go @@ -2,8 +2,23 @@ package orderservicelogic import ( "github.com/shopspring/decimal" + "github.com/zeromicro/go-zero/core/logx" ) +func decimalPtrFromString(val string) *decimal.Decimal { + if val == "" { + return nil + } + dec, err := decimal.NewFromString(val) + if err != nil { + logx.Errorf("Failed to convert string to decimal: %v", err) + + return nil + } + + return &dec +} + // getInt64Value 將 *int64 的值返回,如果為 nil 則返回 0 func getInt64Value(val *int64) int64 { if val == nil {