fusenapi/utils/order/order.go

20 lines
638 B
Go
Raw Normal View History

2023-09-15 02:35:13 +00:00
package order
2023-09-15 09:58:45 +00:00
2023-09-15 10:30:45 +00:00
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"` // 原始货币
}
2023-09-15 09:58:45 +00:00
2023-09-15 10:30:45 +00:00
// 汇率换算
func GetAmountCurrency(req *AmountCurrency) error {
2023-09-15 09:58:45 +00:00
if req.CurrentCurrency == req.OriginalCurrency {
req.CurrentAmount = req.OriginalAmount
} else {
2023-09-15 10:30:45 +00:00
req.CurrentAmount = req.OriginalAmount * req.ExchangeRate
2023-09-15 09:58:45 +00:00
}
return nil
}