🐛生成订单页面订单号和唤醒链接挪到前面

This commit is contained in:
sunxiaolong
2024-01-18 20:01:45 +08:00
parent e57efd24d7
commit b4721048d3
2 changed files with 12 additions and 11 deletions

View File

@@ -1,6 +1,7 @@
package controllers
import (
"fmt"
beego "github.com/beego/beego/v2/server/web"
"github.com/rs/xid"
"merchant/models/merchant"
@@ -23,14 +24,14 @@ func (c *GenLink) ShowGenLinkUI() {
payLink = "http://localhost:12305/"
}
orderParams := order.OrderParams{
orderParams := order.Params{
PayKey: u.MerchantKey,
GeneratedTime: time.Now(),
GeneratedTime: time.Now().Unix(),
OrderNo: xid.New().String(),
Duration: 24,
NotifyUrl: fmt.Sprintf("%s%s", payLink, "shop/notify"),
}
//获取账号数据签名
c.Data["payLink"] = payLink + "?sign=" + orderParams.Encrypt()
c.TplName = "gen_link.html"

View File

@@ -5,17 +5,17 @@ import (
"encoding/json"
"github.com/beego/beego/v2/server/web"
"merchant/utils"
"time"
)
type OrderParams struct {
PayKey string `json:"payKey"` // 支付明文秘钥
OrderNo string `json:"orderNo"`
GeneratedTime time.Time `json:"generatedTime"` // 过期时间
Duration int `json:"duration"` // 存续时间(小时)
type Params struct {
PayKey string `json:"payKey"` // 支付明文秘钥
OrderNo string `json:"orderNo"`
GeneratedTime int64 `json:"generatedTime"` // 过期时间
NotifyUrl string `json:"notifyUrl"` // 回调地址
Duration int `json:"duration"` // 存续时间(小时)
}
func (p *OrderParams) Encrypt() string {
func (p *Params) Encrypt() string {
prepareData := p.String()
if prepareData == "" {
@@ -39,7 +39,7 @@ func (p *OrderParams) Encrypt() string {
return hex.EncodeToString(result)
}
func (p *OrderParams) String() string {
func (p *Params) String() string {
r, err := json.Marshal(p)
if err != nil {