40 lines
1.0 KiB
Go
40 lines
1.0 KiB
Go
package comm
|
|
|
|
import (
|
|
"fmt"
|
|
"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"
|
|
)
|
|
|
|
// CheckoutCounter 收银台
|
|
func (c *BaseCommController) CheckoutCounter(ctx echo.Context) (err error) {
|
|
tradeId := ctx.Param("trade_id")
|
|
resp, err := service.GetCheckoutCounterByTradeId(tradeId)
|
|
if err != nil {
|
|
return ctx.String(http.StatusOK, err.Error())
|
|
}
|
|
tmpl, err := template.ParseFiles(fmt.Sprintf(".%s/%s", config.StaticPath, "index.html"))
|
|
if err != nil {
|
|
return ctx.String(http.StatusOK, err.Error())
|
|
}
|
|
return tmpl.Execute(ctx.Response(), resp)
|
|
}
|
|
|
|
// CheckStatus 支付状态检测
|
|
func (c *BaseCommController) CheckStatus(ctx echo.Context) (err error) {
|
|
tradeId := ctx.Param("trade_id")
|
|
order, err := service.GetOrderInfoByTradeId(tradeId)
|
|
if err != nil {
|
|
return c.FailJson(ctx, err)
|
|
}
|
|
resp := response.CheckStatusResponse{
|
|
TradeId: order.TradeId,
|
|
Status: order.Status,
|
|
}
|
|
return c.SucJson(ctx, resp)
|
|
}
|