93 lines
2.0 KiB
Go
93 lines
2.0 KiB
Go
package controllers
|
|
|
|
/***************************************************
|
|
** @Desc : This file for ...收银台对接快一
|
|
** @Time : 2018-8-27 13:50
|
|
** @Author : Joker
|
|
** @File : home_action
|
|
** @Last Modified by : Joker
|
|
** @Last Modified time: 2018-08-29 17:59:48
|
|
** @Software: GoLand
|
|
****************************************************/
|
|
|
|
import (
|
|
"github.com/beego/beego/v2/core/logs"
|
|
"github.com/beego/beego/v2/server/web"
|
|
"github.com/rs/xid"
|
|
)
|
|
|
|
type HomeAction struct {
|
|
web.Controller
|
|
}
|
|
|
|
// Notify /*通知*/
|
|
func (c *HomeAction) Notify() {
|
|
logs.Error("Notify")
|
|
c.Ctx.WriteString("success")
|
|
}
|
|
|
|
func (c *HomeAction) TestPay() {
|
|
//取值
|
|
siteName, _ := web.AppConfig.String("siteName")
|
|
orderNo := xid.New().String()
|
|
productName := "测试应用-支付功能体验(非商品消费)"
|
|
|
|
//数据回显
|
|
c.Data["siteName"] = siteName
|
|
c.Data["pname"] = productName
|
|
c.Data["orderNo"] = orderNo
|
|
c.Data["paykey"] = ""
|
|
c.TplName = "test.html"
|
|
}
|
|
|
|
// ShowHome /*加载首页及数据*/
|
|
func (c *HomeAction) ShowHome() {
|
|
siteName, _ := web.AppConfig.String("siteName")
|
|
|
|
orderId := c.GetString("orderId")
|
|
|
|
if orderId == "" {
|
|
flash := web.NewFlash()
|
|
flash.Error("订单ID不能为空")
|
|
flash.Store(&c.Controller)
|
|
c.Redirect("/error.html", 302)
|
|
}
|
|
|
|
orderNo := orderId
|
|
productName := "测试应用-支付功能体验(非商品消费)"
|
|
|
|
sign := c.GetString("sign")
|
|
|
|
if sign == "" {
|
|
flash := web.NewFlash()
|
|
flash.Error("交易签名不能为空")
|
|
flash.Store(&c.Controller)
|
|
c.Redirect("/error.html", 302)
|
|
}
|
|
|
|
c.Data["sign"] = sign
|
|
|
|
//数据回显
|
|
c.Data["siteName"] = siteName
|
|
c.Data["pname"] = productName
|
|
c.Data["orderNo"] = orderNo
|
|
|
|
c.TplName = "index.html"
|
|
}
|
|
|
|
// ShowOK /*加载首页及数据*/
|
|
func (c *HomeAction) ShowOK() {
|
|
//取值
|
|
siteName, _ := web.AppConfig.String("siteName")
|
|
//数据回显
|
|
c.Data["siteName"] = siteName
|
|
c.TplName = "ok.html"
|
|
}
|
|
|
|
func (c *HomeAction) ErrorPage() {
|
|
flash := web.ReadFromRequest(&c.Controller)
|
|
e := flash.Data["error"]
|
|
c.Data["error"] = e
|
|
c.TplName = "error.html"
|
|
}
|