fix:合并
This commit is contained in:
@@ -1,25 +1,19 @@
|
||||
package order
|
||||
|
||||
import (
|
||||
"fusenapi/constants"
|
||||
"fusenapi/model/gmodel"
|
||||
"strconv"
|
||||
)
|
||||
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 *gmodel.AmountCurrency) (*float64, error) {
|
||||
// 汇率换算
|
||||
func GetAmountCurrency(req *AmountCurrency) error {
|
||||
if req.CurrentCurrency == req.OriginalCurrency {
|
||||
req.CurrentAmount = req.OriginalAmount
|
||||
} else {
|
||||
f1, err1 := strconv.ParseFloat(string(req.OriginalAmount), 64)
|
||||
if err1 != nil {
|
||||
return nil, err1
|
||||
}
|
||||
f2, err2 := strconv.ParseFloat(string(req.OriginalAmount), 64)
|
||||
if err2 != nil {
|
||||
return nil, err2
|
||||
}
|
||||
result := f1 * f2
|
||||
req.CurrentAmount = constants.AmountUnit(strconv.FormatFloat(result, 'f', -1, 64))
|
||||
req.CurrentAmount = req.OriginalAmount * req.ExchangeRate
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user