|
1 | 1 | package comm |
2 | 2 |
|
3 | 3 | import ( |
4 | | - "html/template" |
5 | 4 | "net/http" |
6 | | - "path/filepath" |
7 | 5 |
|
8 | | - "github.com/GMWalletApp/epusdt/config" |
9 | 6 | "github.com/GMWalletApp/epusdt/model/response" |
10 | 7 | "github.com/GMWalletApp/epusdt/model/service" |
11 | 8 | "github.com/labstack/echo/v4" |
12 | 9 | ) |
13 | 10 |
|
14 | 11 | // CheckoutCounter 收银台 |
15 | 12 | // @Summary Checkout counter page |
16 | | -// @Description Render the payment checkout counter HTML page for a given trade |
| 13 | +// @Description Render the payment checkout counter JSON response for a given trade |
17 | 14 | // @Tags Payment |
18 | | -// @Produce html |
| 15 | +// @Produce json |
19 | 16 | // @Param trade_id path string true "Trade ID" |
20 | | -// @Success 200 {string} string "HTML page" |
21 | | -// @Router /pay/checkout-counter/{trade_id} [get] |
| 17 | +// @Success 200 {object} response.CheckoutCounterResponse |
| 18 | +// @Router /pay/checkout-counter-resp/{trade_id} [get] |
22 | 19 | func (c *BaseCommController) CheckoutCounter(ctx echo.Context) (err error) { |
23 | 20 | tradeId := ctx.Param("trade_id") |
24 | 21 | resp, err := service.GetCheckoutCounterByTradeId(tradeId) |
25 | 22 | if err != nil { |
26 | 23 | if err == service.ErrOrder { |
27 | 24 | // Unknown trade id: render the page with empty payload |
28 | 25 | // (client side shows a friendly "order not found" screen). |
29 | | - tmpl, tmplErr := template.ParseFiles(filepath.Join(config.StaticFilePath, "index.html")) |
30 | | - if tmplErr != nil { |
31 | | - return ctx.String(http.StatusInternalServerError, tmplErr.Error()) |
32 | | - } |
33 | | - ctx.Response().Status = http.StatusNotFound |
34 | 26 | emptyResp := response.CheckoutCounterResponse{} |
35 | | - return tmpl.Execute(ctx.Response(), emptyResp) |
| 27 | + return c.SucJson(ctx, emptyResp) |
36 | 28 | } |
37 | 29 | return ctx.String(http.StatusInternalServerError, err.Error()) |
38 | 30 | } |
39 | | - tmpl, err := template.ParseFiles(filepath.Join(config.StaticFilePath, "index.html")) |
40 | | - if err != nil { |
41 | | - return ctx.String(http.StatusInternalServerError, err.Error()) |
42 | | - } |
43 | 31 |
|
44 | | - return tmpl.Execute(ctx.Response(), resp) |
| 32 | + return c.SucJson(ctx, resp) |
45 | 33 | } |
46 | 34 |
|
47 | 35 | // CheckStatus 支付状态检测 |
|
0 commit comments