feat(汇率查询): 添加汇率查询日志记录
All checks were successful
Build docker and publish / build (20.15.1) (push) Successful in 5m18s
All checks were successful
Build docker and publish / build (20.15.1) (push) Successful in 5m18s
在汇率查询逻辑中添加日志记录,包括目标货币、货币单位和是否有AccessKey的信息。当AccessKey为空时,添加跳过转换的日志提示
This commit is contained in:
parent
657c2930b1
commit
b10d0d22e1
@ -423,17 +423,19 @@ func (l *PurchaseCheckoutLogic) queryExchangeRate(to string, src int64) (amount
|
||||
}{}
|
||||
tool.SystemConfigSliceReflectToStruct(currency, &configs)
|
||||
|
||||
// Skip conversion if no exchange rate API key configured
|
||||
if configs.AccessKey == "" {
|
||||
l.Infow("queryExchangeRate", logger.Field("to", to), logger.Field("unit", configs.CurrencyUnit), logger.Field("hasAccessKey", strings.TrimSpace(configs.AccessKey) != ""))
|
||||
|
||||
if strings.TrimSpace(configs.AccessKey) == "" {
|
||||
l.Infof("[PurchaseCheckout] AccessKey is empty, skip conversion")
|
||||
return amount, nil
|
||||
}
|
||||
|
||||
// Convert currency if system currency differs from target currency
|
||||
if configs.CurrencyUnit != to {
|
||||
result, err := exchangeRate.GetExchangeRete(configs.CurrencyUnit, to, configs.AccessKey, 1)
|
||||
if strings.TrimSpace(configs.CurrencyUnit) != strings.TrimSpace(to) {
|
||||
result, err := exchangeRate.GetExchangeRete(configs.CurrencyUnit, to, strings.TrimSpace(configs.AccessKey), 1)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
l.Infow("exchangeRate", logger.Field("from", configs.CurrencyUnit), logger.Field("to", to), logger.Field("rate", result))
|
||||
amount = result * amount
|
||||
}
|
||||
return amount, nil
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user