refactor price var
This commit is contained in:
parent
e905eebf60
commit
fd72ba8a2b
|
|
@ -37,8 +37,8 @@ type Account struct {
|
||||||
StartDate string `json:"startDate"`
|
StartDate string `json:"startDate"`
|
||||||
Currency string `json:"currency,omitempty"` // 货币
|
Currency string `json:"currency,omitempty"` // 货币
|
||||||
CurrencySymbol string `json:"currencySymbol,omitempty"` // 货币符号
|
CurrencySymbol string `json:"currencySymbol,omitempty"` // 货币符号
|
||||||
ExRate string `json:"exRate,omitempty"` // 汇率
|
Price string `json:"price,omitempty"` // 汇率
|
||||||
ExDate string `json:"exDate,omitempty"` // 汇率日期
|
PriceDate string `json:"priceDate,omitempty"` // 汇率日期
|
||||||
IsAnotherCurrency bool `json:"isAnotherCurrency,omitempty"` // 其他币种标识
|
IsAnotherCurrency bool `json:"isAnotherCurrency,omitempty"` // 其他币种标识
|
||||||
IsCurrent bool `json:"isCurrent,omitempty"`
|
IsCurrent bool `json:"isCurrent,omitempty"`
|
||||||
Positions []AccountPosition `json:"positions,omitempty"`
|
Positions []AccountPosition `json:"positions,omitempty"`
|
||||||
|
|
@ -65,8 +65,8 @@ type LedgerCurrency struct {
|
||||||
Currency string `json:"currency"`
|
Currency string `json:"currency"`
|
||||||
Symbol string `json:"symbol"`
|
Symbol string `json:"symbol"`
|
||||||
Current bool `json:"current,omitempty"`
|
Current bool `json:"current,omitempty"`
|
||||||
ExRate string `json:"exRate,omitempty"`
|
Price string `json:"price,omitempty"`
|
||||||
Date string `json:"date,omitempty"`
|
PriceDate string `json:"priceDate,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetServerConfig() Config {
|
func GetServerConfig() Config {
|
||||||
|
|
@ -488,15 +488,15 @@ func RefreshLedgerCurrency(ledgerConfig *Config) []LedgerCurrency {
|
||||||
currencies := GetLedgerCurrency(ledgerConfig.Id)
|
currencies := GetLedgerCurrency(ledgerConfig.Id)
|
||||||
for _, c := range currencies {
|
for _, c := range currencies {
|
||||||
current := c.Currency == ledgerConfig.OperatingCurrency
|
current := c.Currency == ledgerConfig.OperatingCurrency
|
||||||
var exRate string
|
var price string
|
||||||
var date string
|
var date string
|
||||||
if current {
|
if current {
|
||||||
exRate = "1"
|
price = "1"
|
||||||
date = time.Now().Format("2006-01-02")
|
date = time.Now().Format("2006-01-02")
|
||||||
} else {
|
} else {
|
||||||
value, exists := existCurrencyMap[c.Currency]
|
value, exists := existCurrencyMap[c.Currency]
|
||||||
if exists {
|
if exists {
|
||||||
exRate = value.Value
|
price = value.Value
|
||||||
date = value.Date
|
date = value.Date
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -505,8 +505,8 @@ func RefreshLedgerCurrency(ledgerConfig *Config) []LedgerCurrency {
|
||||||
Currency: c.Currency,
|
Currency: c.Currency,
|
||||||
Symbol: c.Symbol,
|
Symbol: c.Symbol,
|
||||||
Current: current,
|
Current: current,
|
||||||
ExRate: exRate,
|
Price: price,
|
||||||
Date: date,
|
PriceDate: date,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
// 刷新账本货币缓存
|
// 刷新账本货币缓存
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,6 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func isWindows() bool {
|
func isWindows() bool {
|
||||||
return false
|
|
||||||
os := runtime.GOOS
|
os := runtime.GOOS
|
||||||
return os == "windows"
|
return os == "windows"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,8 +24,8 @@ func QueryValidAccount(c *gin.Context) {
|
||||||
currency, ok := currencyMap[account.Currency]
|
currency, ok := currencyMap[account.Currency]
|
||||||
if ok {
|
if ok {
|
||||||
account.CurrencySymbol = currency.Symbol
|
account.CurrencySymbol = currency.Symbol
|
||||||
account.ExRate = currency.ExRate
|
account.Price = currency.Price
|
||||||
account.ExDate = currency.Date
|
account.PriceDate = currency.PriceDate
|
||||||
account.IsAnotherCurrency = true
|
account.IsAnotherCurrency = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -72,8 +72,8 @@ func QueryAllAccount(c *gin.Context) {
|
||||||
currency, ok := currencyMap[account.Currency]
|
currency, ok := currencyMap[account.Currency]
|
||||||
if ok {
|
if ok {
|
||||||
account.CurrencySymbol = currency.Symbol
|
account.CurrencySymbol = currency.Symbol
|
||||||
account.ExRate = currency.ExRate
|
account.Price = currency.Price
|
||||||
account.ExDate = currency.Date
|
account.PriceDate = currency.PriceDate
|
||||||
account.IsAnotherCurrency = true
|
account.IsAnotherCurrency = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue