Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
phsl
/
new-api
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
12ea0c19
authored
Sep 16, 2025
by
Little Write
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
完善 订单处理,以及 优化 ui
parent
edf46c70
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
30 additions
and
3 deletions
+30
-3
controller/topup_creem.go
+0
-0
model/option.go
+3
-0
model/topup.go
+25
-3
setting/payment_creem.go
+1
-0
web/src/components/settings/PaymentSetting.js
+1
-0
web/src/pages/Setting/Payment/SettingsPaymentGatewayCreem.js
+0
-0
No files found.
controller/topup_creem.go
View file @
12ea0c19
This diff is collapsed.
Click to expand it.
model/option.go
View file @
12ea0c19
...
...
@@ -84,6 +84,7 @@ func InitOptionMap() {
common
.
OptionMap
[
"CreemApiKey"
]
=
setting
.
CreemApiKey
common
.
OptionMap
[
"CreemProducts"
]
=
setting
.
CreemProducts
common
.
OptionMap
[
"CreemTestMode"
]
=
strconv
.
FormatBool
(
setting
.
CreemTestMode
)
common
.
OptionMap
[
"CreemWebhookSecret"
]
=
setting
.
CreemWebhookSecret
common
.
OptionMap
[
"TopupGroupRatio"
]
=
common
.
TopupGroupRatio2JSONString
()
common
.
OptionMap
[
"Chats"
]
=
setting
.
Chats2JsonString
()
common
.
OptionMap
[
"AutoGroups"
]
=
setting
.
AutoGroups2JsonString
()
...
...
@@ -335,6 +336,8 @@ func updateOptionMap(key string, value string) (err error) {
setting
.
CreemProducts
=
value
case
"CreemTestMode"
:
setting
.
CreemTestMode
=
value
==
"true"
case
"CreemWebhookSecret"
:
setting
.
CreemWebhookSecret
=
value
case
"TopupGroupRatio"
:
err
=
common
.
UpdateTopupGroupRatioByJSONString
(
value
)
case
"GitHubClientId"
:
...
...
model/topup.go
View file @
12ea0c19
...
...
@@ -99,7 +99,7 @@ func Recharge(referenceId string, customerId string) (err error) {
return
nil
}
func
RechargeCreem
(
referenceId
string
)
(
err
error
)
{
func
RechargeCreem
(
referenceId
string
,
customerEmail
string
,
customerName
string
)
(
err
error
)
{
if
referenceId
==
""
{
return
errors
.
New
(
"未提供支付单号"
)
}
...
...
@@ -131,7 +131,29 @@ func RechargeCreem(referenceId string) (err error) {
// Creem 直接使用 Amount 作为充值额度
quota
=
float64
(
topUp
.
Amount
)
err
=
tx
.
Model
(
&
User
{})
.
Where
(
"id = ?"
,
topUp
.
UserId
)
.
Update
(
"quota"
,
gorm
.
Expr
(
"quota + ?"
,
quota
))
.
Error
// 构建更新字段,优先使用邮箱,如果邮箱为空则使用用户名
updateFields
:=
map
[
string
]
interface
{}{
"quota"
:
gorm
.
Expr
(
"quota + ?"
,
quota
),
}
// 如果有客户邮箱,尝试更新用户邮箱(仅当用户邮箱为空时)
if
customerEmail
!=
""
{
// 先检查用户当前邮箱是否为空
var
user
User
err
=
tx
.
Where
(
"id = ?"
,
topUp
.
UserId
)
.
First
(
&
user
)
.
Error
if
err
!=
nil
{
return
err
}
// 如果用户邮箱为空,则更新为支付时使用的邮箱
if
user
.
Email
==
""
{
updateFields
[
"email"
]
=
customerEmail
fmt
.
Printf
(
"更新用户邮箱:用户ID %d, 新邮箱 %s
\n
"
,
topUp
.
UserId
,
customerEmail
)
}
}
err
=
tx
.
Model
(
&
User
{})
.
Where
(
"id = ?"
,
topUp
.
UserId
)
.
Updates
(
updateFields
)
.
Error
if
err
!=
nil
{
return
err
}
...
...
@@ -143,7 +165,7 @@ func RechargeCreem(referenceId string) (err error) {
return
errors
.
New
(
"充值失败,"
+
err
.
Error
())
}
RecordLog
(
topUp
.
UserId
,
LogTypeTopup
,
fmt
.
Sprintf
(
"使用Creem充值成功,充值额度: %v,支付金额:%.2f
"
,
common
.
FormatQuota
(
int
(
quota
)),
topUp
.
Money
))
RecordLog
(
topUp
.
UserId
,
LogTypeTopup
,
fmt
.
Sprintf
(
"使用Creem充值成功,充值额度: %v,支付金额:%.2f
,客户邮箱:%s"
,
common
.
FormatQuota
(
int
(
quota
)),
topUp
.
Money
,
customerEmail
))
return
nil
}
setting/payment_creem.go
View file @
12ea0c19
...
...
@@ -3,3 +3,4 @@ package setting
var
CreemApiKey
=
""
var
CreemProducts
=
"[]"
var
CreemTestMode
=
false
var
CreemWebhookSecret
=
""
web/src/components/settings/PaymentSetting.js
View file @
12ea0c19
...
...
@@ -28,6 +28,7 @@ const PaymentSetting = () => {
StripeMinTopUp
:
1
,
CreemApiKey
:
''
,
CreemWebhookSecret
:
''
,
CreemProducts
:
'[]'
,
});
...
...
web/src/pages/Setting/Payment/SettingsPaymentGatewayCreem.js
View file @
12ea0c19
This diff is collapsed.
Click to expand it.
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