Backend - setting/payment.go: introduce default `USDExchangeRate` (7.3) - model/option.go: • inject `USDExchangeRate` into `InitOptionMap` • persist & sync value in `updateOptionMap` - controller/misc.go: expose `usd_exchange_rate` via `/api/status` Frontend - OperationSetting.js & SettingsGeneral.js: • extend state/inputs with `USDExchangeRate` • add form field “美元汇率 (non-top-up rate, pricing only)” - ModelPricing.js already consumes `status.usd_exchange_rate`; no change needed API - Administrators can update the rate via `PUT /api/option` (key: `USDExchangeRate`) - All clients receive the latest rate through `GET /api/status` This closes the end-to-end flow for displaying model prices in both USD and CNY based on a configurable exchange rate.
47 lines
877 B
Go
47 lines
877 B
Go
package setting
|
|
|
|
import "encoding/json"
|
|
|
|
var PayAddress = ""
|
|
var CustomCallbackAddress = ""
|
|
var EpayId = ""
|
|
var EpayKey = ""
|
|
var Price = 7.3
|
|
var MinTopUp = 1
|
|
var USDExchangeRate = 7.3
|
|
|
|
var PayMethods = []map[string]string{
|
|
{
|
|
"name": "支付宝",
|
|
"color": "rgba(var(--semi-blue-5), 1)",
|
|
"type": "alipay",
|
|
},
|
|
{
|
|
"name": "微信",
|
|
"color": "rgba(var(--semi-green-5), 1)",
|
|
"type": "wxpay",
|
|
},
|
|
}
|
|
|
|
func UpdatePayMethodsByJsonString(jsonString string) error {
|
|
PayMethods = make([]map[string]string, 0)
|
|
return json.Unmarshal([]byte(jsonString), &PayMethods)
|
|
}
|
|
|
|
func PayMethods2JsonString() string {
|
|
jsonBytes, err := json.Marshal(PayMethods)
|
|
if err != nil {
|
|
return "[]"
|
|
}
|
|
return string(jsonBytes)
|
|
}
|
|
|
|
func ContainsPayMethod(method string) bool {
|
|
for _, payMethod := range PayMethods {
|
|
if payMethod["type"] == method {
|
|
return true
|
|
}
|
|
}
|
|
return false
|
|
}
|