37 Star 192 Fork 80

史蒂芬-库外/dongfeng-pay

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
pay.go 1.99 KB
一键复制 编辑 原始数据 按行查看 历史
史蒂芬-库外 提交于 2019-12-19 14:47 +08:00 . 提交新项目
/***************************************************
** @Desc : This file for ...
** @Time : 2019/12/18 17:16
** @Author : yuebin
** @File : pay
** @Last Modified by : yuebin
** @Last Modified time: 2019/12/18 17:16
** @Software: GoLand
****************************************************/
package controllers
import (
"github.com/astaxie/beego"
"github.com/astaxie/beego/logs"
"strconv"
"strings"
)
type PayController struct {
beego.Controller
}
func (c *PayController) Pay() {
orderNo := strings.TrimSpace(c.GetString("orderid"))
flash := beego.NewFlash()
if orderNo == "" {
flash.Error("订单号为空")
flash.Store(&c.Controller)
c.Redirect("/error.html", 302)
return
}
amount := strings.TrimSpace(c.GetString("amount"))
if !c.judgeAmount(amount) {
flash.Error("金额有误")
flash.Store(&c.Controller)
c.Redirect("/error.html", 302)
return
}
isScan := strings.TrimSpace(c.GetString("SCAN"))
isH5 := strings.TrimSpace(c.GetString("H5"))
isKj := strings.TrimSpace(c.GetString("KJ"))
if strings.Contains(isScan, "SCAN") {
//扫码
scanShop := new(ScanShopController)
scanShop.Prepare()
scanShop.Params["orderPrice"] = amount
scanShop.Params["payWayCode"] = isScan
scanShop.Params["orderNo"] = orderNo
response := scanShop.Shop(c.Ctx.Request.Host)
if response.Code == 200 {
str := "/scan.html?" + "orderNo=" + orderNo + "&orderPrice=" + amount + "&qrCode=" + response.Qrcode + "&payWayCode=" + isScan
c.Redirect(str, 302)
} else {
flash.Error("请求失败,生成二维码失败")
flash.Store(&c.Controller)
c.Redirect("/error.html", 302)
}
} else if strings.Contains(isH5, "H5") {
} else if strings.Contains(isKj, "FAST") {
} else {
flash.Error("不存在这样的支付类型")
flash.Store(&c.Controller)
c.Redirect("/error.html", 302)
return
}
}
func (c *PayController) judgeAmount(amount string) bool {
_, err := strconv.ParseFloat(amount, 64)
if err != nil {
logs.Error("输入金额有误")
return false
}
return true
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/kongyuebin/dongfeng-pay.git
git@gitee.com:kongyuebin/dongfeng-pay.git
kongyuebin
dongfeng-pay
dongfeng-pay
8d4382cc82da

搜索帮助