refactor: migrate legacy API routes to /legacy prefix for backward compatibility

This commit is contained in:
line-6000
2026-04-02 03:34:12 +08:00
parent 4f250098f9
commit 99c4e5e072
6 changed files with 241 additions and 18 deletions
+9 -2
View File
@@ -7,12 +7,19 @@ import (
"github.com/labstack/echo/v4"
)
// CreateTransaction 创建交易
func (c *BaseCommController) CreateTransaction(ctx echo.Context) (err error) {
// LegecyCreateTransaction 创建交易
func (c *BaseCommController) LegecyCreateTransaction(ctx echo.Context) (err error) {
req := new(request.CreateTransactionRequest)
if err = ctx.Bind(req); err != nil {
return c.FailJson(ctx, constant.ParamsMarshalErr)
}
// 兼容旧版本插件:如果未传递 token 和 currency,使用默认值
if req.Token == "" {
req.Token = "usdt"
}
if req.Currency == "" {
req.Currency = "cny"
}
if err = c.ValidateStruct(ctx, req); err != nil {
return c.FailJson(ctx, err)
}
+9 -7
View File
@@ -1,17 +1,18 @@
package comm
import (
"html/template"
"net/http"
"path/filepath"
"github.com/assimon/luuu/config"
"github.com/assimon/luuu/model/response"
"github.com/assimon/luuu/model/service"
"github.com/labstack/echo/v4"
"html/template"
"net/http"
"path/filepath"
)
// CheckoutCounter 收银台
func (c *BaseCommController) CheckoutCounter(ctx echo.Context) (err error) {
// LegecyCheckoutCounter 收银台
func (c *BaseCommController) LegecyCheckoutCounter(ctx echo.Context) (err error) {
tradeId := ctx.Param("trade_id")
resp, err := service.GetCheckoutCounterByTradeId(tradeId)
if err != nil {
@@ -21,11 +22,12 @@ func (c *BaseCommController) CheckoutCounter(ctx echo.Context) (err error) {
if err != nil {
return ctx.String(http.StatusOK, err.Error())
}
resp.Token = resp.ReceiveAddress // only for legacy checkout counter, token is the receive address
return tmpl.Execute(ctx.Response(), resp)
}
// CheckStatus 支付状态检测
func (c *BaseCommController) CheckStatus(ctx echo.Context) (err error) {
// LegecyCheckStatus 支付状态检测
func (c *BaseCommController) LegecyCheckStatus(ctx echo.Context) (err error) {
tradeId := ctx.Param("trade_id")
order, err := service.GetOrderInfoByTradeId(tradeId)
if err != nil {