fusenapi/utils/order/order.go
2023-09-15 18:30:45 +08:00

20 lines
638 B
Go

package order
type AmountCurrency struct {
ExchangeRate float64 `json:"exchange_rate"` // 换算汇率
CurrentAmount float64 `json:"current_amount"` // 当前金额
OriginalAmount float64 `json:"original_amount"` // 原始金额
CurrentCurrency string `json:"current_currency"` // 当前货币
OriginalCurrency string `json:"original_currency"` // 原始货币
}
// 汇率换算
func GetAmountCurrency(req *AmountCurrency) error {
if req.CurrentCurrency == req.OriginalCurrency {
req.CurrentAmount = req.OriginalAmount
} else {
req.CurrentAmount = req.OriginalAmount * req.ExchangeRate
}
return nil
}