Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
陈曦
sub2api
Commits
1e6912ea
Commit
1e6912ea
authored
Apr 14, 2026
by
erio
Browse files
fix: gofmt formatting across all Go source files
parent
9e0d12d3
Changes
18
Show whitespace changes
Inline
Side-by-side
backend/internal/handler/admin/setting_handler.go
View file @
1e6912ea
backend/internal/handler/dto/settings.go
View file @
1e6912ea
backend/internal/handler/dto/types.go
View file @
1e6912ea
backend/internal/payment/load_balancer_test.go
View file @
1e6912ea
backend/internal/payment/provider/alipay_test.go
View file @
1e6912ea
backend/internal/service/account.go
View file @
1e6912ea
...
...
@@ -1533,39 +1533,48 @@ func (a *Account) QuotaNotifyConfig(dim string) (enabled bool, threshold float64
}
func
(
a
*
Account
)
GetQuotaNotifyDailyEnabled
()
bool
{
e
,
_
,
_
:=
a
.
QuotaNotifyConfig
(
quotaDimDaily
);
return
e
e
,
_
,
_
:=
a
.
QuotaNotifyConfig
(
quotaDimDaily
)
return
e
}
func
(
a
*
Account
)
GetQuotaNotifyDailyThreshold
()
float64
{
_
,
t
,
_
:=
a
.
QuotaNotifyConfig
(
quotaDimDaily
);
return
t
_
,
t
,
_
:=
a
.
QuotaNotifyConfig
(
quotaDimDaily
)
return
t
}
func
(
a
*
Account
)
GetQuotaNotifyDailyThresholdType
()
string
{
_
,
_
,
tt
:=
a
.
QuotaNotifyConfig
(
quotaDimDaily
);
return
tt
_
,
_
,
tt
:=
a
.
QuotaNotifyConfig
(
quotaDimDaily
)
return
tt
}
func
(
a
*
Account
)
GetQuotaNotifyWeeklyEnabled
()
bool
{
e
,
_
,
_
:=
a
.
QuotaNotifyConfig
(
quotaDimWeekly
);
return
e
e
,
_
,
_
:=
a
.
QuotaNotifyConfig
(
quotaDimWeekly
)
return
e
}
func
(
a
*
Account
)
GetQuotaNotifyWeeklyThreshold
()
float64
{
_
,
t
,
_
:=
a
.
QuotaNotifyConfig
(
quotaDimWeekly
);
return
t
_
,
t
,
_
:=
a
.
QuotaNotifyConfig
(
quotaDimWeekly
)
return
t
}
func
(
a
*
Account
)
GetQuotaNotifyWeeklyThresholdType
()
string
{
_
,
_
,
tt
:=
a
.
QuotaNotifyConfig
(
quotaDimWeekly
);
return
tt
_
,
_
,
tt
:=
a
.
QuotaNotifyConfig
(
quotaDimWeekly
)
return
tt
}
func
(
a
*
Account
)
GetQuotaNotifyTotalEnabled
()
bool
{
e
,
_
,
_
:=
a
.
QuotaNotifyConfig
(
quotaDimTotal
);
return
e
e
,
_
,
_
:=
a
.
QuotaNotifyConfig
(
quotaDimTotal
)
return
e
}
func
(
a
*
Account
)
GetQuotaNotifyTotalThreshold
()
float64
{
_
,
t
,
_
:=
a
.
QuotaNotifyConfig
(
quotaDimTotal
);
return
t
_
,
t
,
_
:=
a
.
QuotaNotifyConfig
(
quotaDimTotal
)
return
t
}
func
(
a
*
Account
)
GetQuotaNotifyTotalThresholdType
()
string
{
_
,
_
,
tt
:=
a
.
QuotaNotifyConfig
(
quotaDimTotal
);
return
tt
_
,
_
,
tt
:=
a
.
QuotaNotifyConfig
(
quotaDimTotal
)
return
tt
}
// nextFixedDailyReset 计算在 after 之后的下一个每日固定重置时间点
...
...
backend/internal/service/balance_notify_email_body_test.go
View file @
1e6912ea
backend/internal/service/domain_constants.go
View file @
1e6912ea
backend/internal/service/payment_config_plans_validation_test.go
View file @
1e6912ea
backend/internal/service/payment_config_providers.go
View file @
1e6912ea
...
...
@@ -30,6 +30,7 @@ type ProviderInstanceResponse struct {
Limits
string
`json:"limits"`
Enabled
bool
`json:"enabled"`
RefundEnabled
bool
`json:"refund_enabled"`
AllowUserRefund
bool
`json:"allow_user_refund"`
SortOrder
int
`json:"sort_order"`
PaymentMode
string
`json:"payment_mode"`
}
...
...
@@ -46,8 +47,8 @@ func (s *PaymentConfigService) ListProviderInstancesWithConfig(ctx context.Conte
resp
:=
ProviderInstanceResponse
{
ID
:
int64
(
inst
.
ID
),
ProviderKey
:
inst
.
ProviderKey
,
Name
:
inst
.
Name
,
SupportedTypes
:
splitTypes
(
inst
.
SupportedTypes
),
Limits
:
inst
.
Limits
,
Enabled
:
inst
.
Enabled
,
RefundEnabled
:
inst
.
RefundEnabled
,
SortOrder
:
inst
.
SortOrder
,
PaymentMode
:
inst
.
PaymentMode
,
Enabled
:
inst
.
Enabled
,
RefundEnabled
:
inst
.
RefundEnabled
,
AllowUserRefund
:
inst
.
AllowUserRefund
,
SortOrder
:
inst
.
SortOrder
,
PaymentMode
:
inst
.
PaymentMode
,
}
resp
.
Config
,
err
=
s
.
decryptAndMaskConfig
(
inst
.
Config
)
if
err
!=
nil
{
...
...
@@ -110,10 +111,12 @@ func (s *PaymentConfigService) CreateProviderInstance(ctx context.Context, req C
if
err
!=
nil
{
return
nil
,
err
}
allowUserRefund
:=
req
.
AllowUserRefund
&&
req
.
RefundEnabled
return
s
.
entClient
.
PaymentProviderInstance
.
Create
()
.
SetProviderKey
(
req
.
ProviderKey
)
.
SetName
(
req
.
Name
)
.
SetConfig
(
enc
)
.
SetSupportedTypes
(
typesStr
)
.
SetEnabled
(
req
.
Enabled
)
.
SetPaymentMode
(
req
.
PaymentMode
)
.
SetSortOrder
(
req
.
SortOrder
)
.
SetLimits
(
req
.
Limits
)
.
SetRefundEnabled
(
req
.
RefundEnabled
)
.
SetAllowUserRefund
(
allowUserRefund
)
.
Save
(
ctx
)
}
...
...
@@ -221,6 +224,21 @@ func (s *PaymentConfigService) UpdateProviderInstance(ctx context.Context, id in
}
if
req
.
RefundEnabled
!=
nil
{
u
.
SetRefundEnabled
(
*
req
.
RefundEnabled
)
// Cascade: turning off refund_enabled also disables allow_user_refund
if
!*
req
.
RefundEnabled
{
u
.
SetAllowUserRefund
(
false
)
}
}
if
req
.
AllowUserRefund
!=
nil
{
// Only allow enabling when refund_enabled is true
if
*
req
.
AllowUserRefund
{
inst
,
err
:=
s
.
entClient
.
PaymentProviderInstance
.
Get
(
ctx
,
id
)
if
err
==
nil
&&
inst
.
RefundEnabled
{
u
.
SetAllowUserRefund
(
true
)
}
}
else
{
u
.
SetAllowUserRefund
(
false
)
}
}
if
req
.
PaymentMode
!=
nil
{
u
.
SetPaymentMode
(
*
req
.
PaymentMode
)
...
...
@@ -228,6 +246,23 @@ func (s *PaymentConfigService) UpdateProviderInstance(ctx context.Context, id in
return
u
.
Save
(
ctx
)
}
// GetUserRefundEligibleInstanceIDs returns provider instance IDs that allow user refund.
func
(
s
*
PaymentConfigService
)
GetUserRefundEligibleInstanceIDs
(
ctx
context
.
Context
)
([]
string
,
error
)
{
instances
,
err
:=
s
.
entClient
.
PaymentProviderInstance
.
Query
()
.
Where
(
paymentproviderinstance
.
AllowUserRefundEQ
(
true
),
paymentproviderinstance
.
RefundEnabledEQ
(
true
),
)
.
Select
(
paymentproviderinstance
.
FieldID
)
.
All
(
ctx
)
if
err
!=
nil
{
return
nil
,
err
}
ids
:=
make
([]
string
,
0
,
len
(
instances
))
for
_
,
inst
:=
range
instances
{
ids
=
append
(
ids
,
strconv
.
FormatInt
(
int64
(
inst
.
ID
),
10
))
}
return
ids
,
nil
}
func
(
s
*
PaymentConfigService
)
mergeConfig
(
ctx
context
.
Context
,
id
int64
,
newConfig
map
[
string
]
string
)
(
map
[
string
]
string
,
error
)
{
inst
,
err
:=
s
.
entClient
.
PaymentProviderInstance
.
Get
(
ctx
,
id
)
if
err
!=
nil
{
...
...
backend/internal/service/payment_config_providers_test.go
View file @
1e6912ea
backend/internal/service/payment_config_service.go
View file @
1e6912ea
...
...
@@ -114,6 +114,7 @@ type CreateProviderInstanceRequest struct {
SortOrder
int
`json:"sort_order"`
Limits
string
`json:"limits"`
RefundEnabled
bool
`json:"refund_enabled"`
AllowUserRefund
bool
`json:"allow_user_refund"`
}
type
UpdateProviderInstanceRequest
struct
{
...
...
@@ -125,6 +126,7 @@ type UpdateProviderInstanceRequest struct {
SortOrder
*
int
`json:"sort_order"`
Limits
*
string
`json:"limits"`
RefundEnabled
*
bool
`json:"refund_enabled"`
AllowUserRefund
*
bool
`json:"allow_user_refund"`
}
type
CreatePlanRequest
struct
{
GroupID
int64
`json:"group_id"`
...
...
backend/internal/service/setting_service_public_test.go
View file @
1e6912ea
backend/internal/service/setting_service_update_test.go
View file @
1e6912ea
backend/internal/service/settings_view.go
View file @
1e6912ea
backend/internal/service/usage_billing.go
View file @
1e6912ea
...
...
@@ -100,9 +100,22 @@ func valueOrZero(v *int64) int64 {
return
*
v
}
// AccountQuotaState holds the post-increment quota state returned by the DB transaction.
// All values are post-update (i.e., already include the increment).
type
AccountQuotaState
struct
{
TotalUsed
float64
TotalLimit
float64
DailyUsed
float64
DailyLimit
float64
WeeklyUsed
float64
WeeklyLimit
float64
}
type
UsageBillingApplyResult
struct
{
Applied
bool
APIKeyQuotaExhausted
bool
NewBalance
*
float64
// post-deduction balance (nil = no balance deduction)
QuotaState
*
AccountQuotaState
// post-increment quota state (nil = no quota increment)
}
type
UsageBillingRepository
interface
{
...
...
backend/internal/service/user.go
View file @
1e6912ea
backend/internal/service/user_service.go
View file @
1e6912ea
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment