2024-10-27 16:01:55 +00:00
|
|
|
|
package orderservicelogic
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"github.com/shopspring/decimal"
|
|
|
|
|
)
|
|
|
|
|
|
2024-10-27 17:27:25 +00:00
|
|
|
|
// getInt64Value 將 *int64 的值返回,如果為 nil 則返回 0
|
|
|
|
|
func getInt64Value(val *int64) int64 {
|
|
|
|
|
if val == nil {
|
|
|
|
|
return 0
|
|
|
|
|
}
|
2024-10-27 17:54:05 +00:00
|
|
|
|
|
2024-10-27 17:27:25 +00:00
|
|
|
|
return *val
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// stringToDecimalPtr 將 *string 轉換為 *decimal.Decimal,如果解析失敗或值為 nil 則返回 nil
|
|
|
|
|
func stringToDecimalPtr(s *string) *decimal.Decimal {
|
|
|
|
|
if s == nil {
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
dec, err := decimal.NewFromString(*s)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil // 解析失敗時返回 nil,或根據需求記錄錯誤
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return &dec
|
|
|
|
|
}
|