Files
pay/internal/router/router.go
T
wangjia 6da6964451 初始提交:岩美 pay 收款服务(支付宝当面付 + 多商户多渠道架构)
- Go/Gin/GORM + 纯 Go SQLite(无 cgo)
- Channel 多渠道接口:支付宝当面付(precreate)/电脑网站支付(page.pay) 已实现,微信占位
- 多商户 merchants 表,回调验签+金额核对+幂等+查单兜底
- 收款页/结果页/二维码端点;docs/ 设计文档与部署 Runbook
- 密钥走环境变量/Bitwarden,不入库

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-25 07:21:48 +08:00

37 lines
1022 B
Go

package router
import (
"github.com/gin-gonic/gin"
"gorm.io/gorm"
"github.com/wangjia/pay/config"
"github.com/wangjia/pay/internal/channel"
"github.com/wangjia/pay/internal/handler"
"github.com/wangjia/pay/internal/service"
)
// Setup 装配路由。返回 OrderService 供 main 启动查单兜底任务。
func Setup(r *gin.Engine, db *gorm.DB, reg *channel.Registry) *service.OrderService {
orderSvc := service.NewOrderService(db, reg, config.C.Server.BaseURL)
orderH := handler.NewOrderHandler(orderSvc)
pageH := handler.NewPageHandler(db, "web")
r.GET("/health", func(c *gin.Context) { c.JSON(200, gin.H{"status": "ok"}) })
// 页面
r.GET("/", pageH.PayPage)
r.GET("/result", pageH.ResultPage)
r.GET("/qrcode", pageH.QRCode)
v1 := r.Group("/api/v1")
{
v1.GET("/products", pageH.ListProducts)
v1.POST("/orders", orderH.Create)
v1.POST("/orders/qr", orderH.CreateQR)
v1.GET("/orders/:out_trade_no", orderH.GetStatus)
v1.POST("/notify/alipay", orderH.AlipayNotify)
}
return orderSvc
}