refactor: Improve channel status update logic and clean up code

- Simplified conditional checks in UpdateChannelStatusById function in channel.go to enhance readability.
- Commented out unused image number check in relay-gemini.go for clarity.
- Updated JSON field in en.json for currency consistency, changing "元" from "RMB/CNY" to "CNY" and added a space in "实付金额:" for formatting.
This commit is contained in:
CalciumIon
2024-12-17 15:33:16 +08:00
parent 70e7860838
commit 2d865eb735
3 changed files with 14 additions and 13 deletions

View File

@@ -292,19 +292,20 @@ func (channel *Channel) Delete() error {
}
var channelStatusLock sync.Mutex
func UpdateChannelStatusById(id int, status int, reason string) {
if (common.MemoryCacheEnabled) {
if common.MemoryCacheEnabled {
channelStatusLock.Lock()
channelCache, err := CacheGetChannel(id)
// 如果缓存渠道存在,且状态已是目标状态,直接返回
if channelCache != nil && channelCache.Status == status {
channelCache, _ := CacheGetChannel(id)
// 如果缓存渠道存在,且状态已是目标状态,直接返回
if channelCache != nil && channelCache.Status == status {
channelStatusLock.Unlock()
return
return
}
// 如果缓存渠道不存在(说明已经被禁用),且要设置的状态不为启用,直接返回
if channelCache == nil && status != common.ChannelStatusEnabled {
// 如果缓存渠道不存在(说明已经被禁用),且要设置的状态不为启用,直接返回
if channelCache == nil && status != common.ChannelStatusEnabled {
channelStatusLock.Unlock()
return
return
}
CacheUpdateChannelStatus(id, status)
channelStatusLock.Unlock()