更新密码找回uniapp

This commit is contained in:
hero920103 committed 2026-11-16 17:22:50 +08:00
1 parent 7f9a66da0f
commit 3fdda89833
1304 files changed
+3503 -26132

No files matched your search

+2 -29
View File
@@ -22,7 +22,6 @@ import (
beego "github.com/beego/beego/v2/server/web"
)
// PlatformPaymentController 平台端支付管理(渠道配置 / 支付订单 / 兜底退回 / 渠道回调)
type PlatformPaymentController struct {
beego.Controller
}
@@ -31,7 +30,6 @@ func (c *PlatformPaymentController) platformClaims() (*jwtutil.Claims, error) {
return paymentPlatformClaims(&c.Controller)
}
// paymentPlatformClaims 平台端鉴权(支付相关控制器共用),传各控制器内嵌的 &c.Controller
func paymentPlatformClaims(c *beego.Controller) (*jwtutil.Claims, error) {
return identity.Claims(c.Ctx.Request.Header.Get("Authorization"), identity.EndPlatform)
}
@@ -47,7 +45,6 @@ func (c *PlatformPaymentController) ok(data interface{}) {
_ = c.ServeJSON()
}
// channelSecretKeys 各渠道的敏感参数键(接口回显时只回掩码;提交掩码/空串表示不修改)
var channelSecretKeys = map[string][]string{
payment.ChannelWechat: {"api_v3_key"},
payment.ChannelAlipay: {"app_private_key"},
@@ -80,7 +77,6 @@ func channelRowDTO(row *models.PlatformPaymentChannel) map[string]interface{} {
}
}
// maskedConfigView 解密配置并掩码敏感字段,供前端回显
func maskedConfigView(cfg *payment.ChannelConfig, row *models.PlatformPaymentChannel) map[string]interface{} {
view := map[string]interface{}{}
for k, v := range cfg.Params {
@@ -114,7 +110,6 @@ type paymentChannelPayload struct {
Extra map[string]any `json:"extra"`
}
// loadMergedConfig 加载已存配置并把「新填写且非掩码」的值合并进去(用于保存与测试连接共用)
func loadMergedConfig(channel string, p *paymentChannelPayload) (*payment.ChannelConfig, error) {
cfg, err := payment.LoadChannelConfig(channel)
if err != nil {
@@ -126,7 +121,7 @@ func loadMergedConfig(channel string, p *paymentChannelPayload) (*payment.Channe
for k, v := range p.Config {
v = strings.TrimSpace(v)
if v == "" || payment.IsMasked(v) {
continue // 空串 / 掩码 = 保持原值
continue
}
cfg.Params[k] = v
}
@@ -136,7 +131,6 @@ func loadMergedConfig(channel string, p *paymentChannelPayload) (*payment.Channe
return cfg, nil
}
// ListChannels GET /platform/payment/channels 渠道概览
func (c *PlatformPaymentController) ListChannels() {
if _, err := c.platformClaims(); err != nil {
code := identity.Status(err)
@@ -162,7 +156,6 @@ func (c *PlatformPaymentController) ListChannels() {
c.ok(map[string]interface{}{"list": list, "total": len(list)})
}
// GetChannel GET /platform/payment/channels/:channel 渠道配置详情(敏感字段掩码)
func (c *PlatformPaymentController) GetChannel() {
if _, err := c.platformClaims(); err != nil {
code := identity.Status(err)
@@ -187,7 +180,6 @@ func (c *PlatformPaymentController) GetChannel() {
c.ok(dto)
}
// SaveChannel POST /platform/payment/channels/:channel 保存渠道配置(敏感字段留空/掩码表示不修改)
func (c *PlatformPaymentController) SaveChannel() {
claims, err := c.platformClaims()
if err != nil {
@@ -268,7 +260,6 @@ func (c *PlatformPaymentController) SaveChannel() {
c.ok(channelRowDTO(row))
}
// TestChannel POST /platform/payment/channels/:channel/test 测试连接(支持未保存参数)
func (c *PlatformPaymentController) TestChannel() {
if _, err := c.platformClaims(); err != nil {
code := identity.Status(err)
@@ -278,7 +269,7 @@ func (c *PlatformPaymentController) TestChannel() {
channel := c.Ctx.Input.Param(":channel")
body, _ := io.ReadAll(c.Ctx.Request.Body)
var p paymentChannelPayload
_ = json.Unmarshal(body, &p) // 允许空 body:只测已保存配置
_ = json.Unmarshal(body, &p)
merged, err := loadMergedConfig(channel, &p)
if err != nil {
@@ -309,7 +300,6 @@ func (c *PlatformPaymentController) TestChannel() {
c.ok(map[string]interface{}{"message": result})
}
// ToggleChannel POST /platform/payment/channels/:channel/status 启用/停用
func (c *PlatformPaymentController) ToggleChannel() {
if _, err := c.platformClaims(); err != nil {
code := identity.Status(err)
@@ -351,9 +341,6 @@ func b2i(v bool) int8 {
return 0
}
// UploadCertificate POST /platform/payment/channels/:channel/certificate 上传渠道证书
// 证书文件保存在服务端 certs/payment/<channel>/ 下(0600 权限,不对外提供访问),
// 文件路径写入 cert_json,密钥内容绝不入库、不回显。
func (c *PlatformPaymentController) UploadCertificate() {
if _, err := c.platformClaims(); err != nil {
code := identity.Status(err)
@@ -376,8 +363,6 @@ func (c *PlatformPaymentController) UploadCertificate() {
}
defer func() { _ = file.Close() }()
// 落盘目录:payment_cert_dir 配置优先,未配置时用相对工作目录的 certs/payment/<渠道>。
// 入库保持相对路径——本地开发与线上可能共用同一个库,存绝对路径会互相覆盖对方环境。
dir := payment.CertDir(channel)
if err := os.MkdirAll(dir, 0o700); err != nil {
c.jsonErr(500, 500, "创建证书目录失败: "+err.Error())
@@ -402,7 +387,6 @@ func (c *PlatformPaymentController) UploadCertificate() {
}
_ = out.Close()
// 更新 cert_json
cfg, err := payment.LoadChannelConfig(channel)
if err != nil {
c.jsonErr(500, 500, err.Error())
@@ -414,7 +398,6 @@ func (c *PlatformPaymentController) UploadCertificate() {
certKey := certType + "_path"
cfg.CertPaths[certKey] = savePath
if _, err := os.Stat(savePath); err == nil {
// 同步补充对应关系:cert -> cert_path,key -> key_path
if certType == "cert" {
cfg.CertPaths["cert_path"] = savePath
} else {
@@ -431,8 +414,6 @@ func (c *PlatformPaymentController) UploadCertificate() {
c.ok(map[string]interface{}{"file": header.Filename, "path": savePath, "cert_type": certType})
}
/* ---------------- 支付订单 ---------------- */
func paymentOrderDTO(row *models.PlatformPaymentOrder) map[string]interface{} {
return map[string]interface{}{
"id": row.ID, "pay_no": row.PayNo, "out_trade_no": row.OutTradeNo,
@@ -450,7 +431,6 @@ func paymentOrderDTO(row *models.PlatformPaymentOrder) map[string]interface{} {
}
}
// ListOrders GET /platform/payment/orders 支付单列表
func (c *PlatformPaymentController) ListOrders() {
if _, err := c.platformClaims(); err != nil {
code := identity.Status(err)
@@ -511,7 +491,6 @@ func (c *PlatformPaymentController) ListOrders() {
c.ok(map[string]interface{}{"list": list, "total": total, "page": page, "pageSize": pageSize})
}
// OrderDetail GET /platform/payment/orders/:payNo 支付单详情(含状态流转 + 最近回调原文)
func (c *PlatformPaymentController) OrderDetail() {
if _, err := c.platformClaims(); err != nil {
code := identity.Status(err)
@@ -526,7 +505,6 @@ func (c *PlatformPaymentController) OrderDetail() {
}
dto := paymentOrderDTO(row)
// 状态流转记录
var logs []models.PlatformPaymentOrderLog
_, _ = models.Orm.QueryTable(new(models.PlatformPaymentOrderLog)).
Filter("pay_no", payNo).
@@ -542,7 +520,6 @@ func (c *PlatformPaymentController) OrderDetail() {
}
dto["records"] = records
// 最近一次成功回调的原文(来自 yz_platform_payment_callback_log.raw_body)
var cb models.PlatformPaymentCallbackLog
err = models.Orm.QueryTable(new(models.PlatformPaymentCallbackLog)).
Filter("pay_no", payNo).
@@ -556,7 +533,6 @@ func (c *PlatformPaymentController) OrderDetail() {
c.ok(dto)
}
// QueryOrder POST /platform/payment/orders/:payNo/query 手动查询渠道状态(兜底回调丢失)
func (c *PlatformPaymentController) QueryOrder() {
if _, err := c.platformClaims(); err != nil {
code := identity.Status(err)
@@ -583,7 +559,6 @@ func (c *PlatformPaymentController) QueryOrder() {
c.ok(paymentOrderDTO(row))
}
// Refund POST /platform/payment/refund 手动原路退回(兜底能力)
func (c *PlatformPaymentController) Refund() {
claims, err := c.platformClaims()
if err != nil {
@@ -621,8 +596,6 @@ func (c *PlatformPaymentController) Refund() {
})
}
// Notify POST /platform/payment/callback/:channel 渠道异步通知入口(渠道服务器调用,无平台鉴权)
// 处理成功时按渠道约定返回:微信 {"code":"SUCCESS"} / 支付宝 success / 银联与 PayPal ok / 200 空体。
func (c *PlatformPaymentController) Notify() {
channel := c.Ctx.Input.Param(":channel")
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)