修复platform的支付问题

This commit is contained in:
2026-09-16 10:35:55 +08:00
parent 71a14c46f9
commit 19687658e1
7 changed files with 415 additions and 148 deletions
+31 -2
View File
@@ -71,10 +71,23 @@ var channelSecretKeys = map[string][]string{
}
func channelRowDTO(row *models.PlatformPaymentChannel) map[string]interface{} {
hasConfig := (row.ConfigJSON != nil && *row.ConfigJSON != "" && *row.ConfigJSON != "{}") || row.MerchantNo != ""
if row.Channel == payment.ChannelCloudPay {
hasConfig = true
}
status := "unconfigured"
if row.Enabled == 1 {
status = "enabled"
} else if hasConfig {
status = "disabled"
}
return map[string]interface{}{
"id": row.ID, "channel": row.Channel, "name": row.Name,
"merchant_no": row.MerchantNo, "callback_url": row.CallbackURL,
"enabled": row.Enabled == 1,
"status": status,
"has_config": hasConfig,
"remark": row.Remark,
"last_test_time": row.LastTestTime, "last_test_result": row.LastTestResult,
"create_time": row.CreateTime, "update_time": row.UpdateTime,
@@ -223,13 +236,29 @@ func (c *PlatformPaymentController) SaveChannel() {
extraJSON = string(b)
}
merchantNo := strings.TrimSpace(p.MerchantNo)
if merchantNo == "" && merged != nil {
switch channel {
case payment.ChannelPayPal:
merchantNo = merged.Get("client_id")
case payment.ChannelWechat:
merchantNo = merged.Get("mch_id")
case payment.ChannelAlipay:
merchantNo = merged.Get("app_id")
case payment.ChannelUnionPay, payment.ChannelCloudPay:
merchantNo = merged.Get("mer_id")
}
}
now := time.Now()
updates := orm.Params{
"config_json": enc,
"merchant_no": strings.TrimSpace(p.MerchantNo),
"remark": strings.TrimSpace(p.Remark),
"merchant_no": merchantNo,
"update_time": now,
}
if p.Remark != "" {
updates["remark"] = strings.TrimSpace(p.Remark)
}
if p.Name != "" {
updates["name"] = strings.TrimSpace(p.Name)
}