💥编写完成产品编码代码
This commit is contained in:
@@ -7,6 +7,7 @@ import (
|
||||
"merchant/models/merchant"
|
||||
"merchant/models/order"
|
||||
"merchant/sys/enum"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
@@ -15,6 +16,17 @@ type GenLink struct {
|
||||
}
|
||||
|
||||
func (c *GenLink) ShowGenLinkUI() {
|
||||
c.TplName = "gen_link.html"
|
||||
}
|
||||
|
||||
func (c *GenLink) GenShopLink() {
|
||||
showMMValue, err := c.GetFloat("showMMValue")
|
||||
if err != nil {
|
||||
c.Data["errorMsg"] = "获取面额出错!"
|
||||
c.TplName = "error.html"
|
||||
return
|
||||
}
|
||||
productCode := strings.TrimSpace(c.GetString("productCode"))
|
||||
us := c.GetSession(enum.UserSession)
|
||||
u := us.(merchant.MerchantInfo)
|
||||
|
||||
@@ -29,10 +41,10 @@ func (c *GenLink) ShowGenLinkUI() {
|
||||
GeneratedTime: time.Now().Unix(),
|
||||
OrderNo: xid.New().String(),
|
||||
Duration: 24,
|
||||
ProductCode: productCode,
|
||||
ShowMMValue: showMMValue,
|
||||
NotifyUrl: fmt.Sprintf("%s%s", payLink, "shop/notify"),
|
||||
}
|
||||
|
||||
c.Data["payLink"] = payLink + "?sign=" + orderParams.Encrypt()
|
||||
|
||||
c.TplName = "gen_link.html"
|
||||
c.Redirect(payLink+"?sign="+orderParams.Encrypt(), 302)
|
||||
}
|
||||
|
||||
1
go.mod
1
go.mod
@@ -8,6 +8,7 @@ require (
|
||||
github.com/dchest/captcha v0.0.0-20200903113550-03f5f0333e1f
|
||||
github.com/go-redis/redis v6.14.2+incompatible
|
||||
github.com/go-sql-driver/mysql v1.6.0
|
||||
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b
|
||||
github.com/pkg/errors v0.9.1
|
||||
github.com/rs/xid v1.3.0
|
||||
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e
|
||||
|
||||
1
go.sum
1
go.sum
@@ -57,6 +57,7 @@ github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LB
|
||||
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
|
||||
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
|
||||
github.com/gogo/protobuf v1.3.1/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o=
|
||||
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b h1:VKtxabqXZkF25pY9ekfRL6a582T4P37/31XEstQ5p58=
|
||||
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
|
||||
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
|
||||
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
|
||||
@@ -8,29 +8,28 @@ import (
|
||||
)
|
||||
|
||||
type Params struct {
|
||||
PayKey string `json:"payKey"` // 支付明文秘钥
|
||||
OrderNo string `json:"orderNo"`
|
||||
GeneratedTime int64 `json:"generatedTime"` // 过期时间
|
||||
NotifyUrl string `json:"notifyUrl"` // 回调地址
|
||||
Duration int `json:"duration"` // 存续时间(小时)
|
||||
PayKey string `json:"payKey"` // 支付明文秘钥
|
||||
OrderNo string `json:"orderNo"`
|
||||
GeneratedTime int64 `json:"generatedTime"` // 过期时间
|
||||
NotifyUrl string `json:"notifyUrl"` // 回调地址
|
||||
Duration int `json:"duration"` // 存续时间(小时)
|
||||
ShowMMValue float64 `json:"showMMValue"` // 实际面额
|
||||
ProductCode string `json:"productCode"` // 产品编码
|
||||
}
|
||||
|
||||
func (p *Params) Encrypt() string {
|
||||
prepareData := p.String()
|
||||
|
||||
if prepareData == "" {
|
||||
return prepareData
|
||||
}
|
||||
|
||||
// 加密密码数据
|
||||
key, err := web.AppConfig.String("secret::key")
|
||||
|
||||
if err != nil {
|
||||
return ""
|
||||
}
|
||||
|
||||
iv, err := web.AppConfig.String("secret::iv")
|
||||
|
||||
if err != nil {
|
||||
return ""
|
||||
}
|
||||
@@ -41,7 +40,6 @@ func (p *Params) Encrypt() string {
|
||||
|
||||
func (p *Params) String() string {
|
||||
r, err := json.Marshal(p)
|
||||
|
||||
if err != nil {
|
||||
return ""
|
||||
}
|
||||
|
||||
@@ -60,6 +60,7 @@ func init() {
|
||||
beego.Router("/withdraw/list_record/?:params", &controllers.Withdraw{}, "*:WithdrawQueryAndListPage")
|
||||
|
||||
beego.Router("/gen_link/gen_link", &controllers.GenLink{}, "*:ShowGenLinkUI")
|
||||
beego.Router("/gen_link/shop", &controllers.GenLink{}, "*:GenShopLink")
|
||||
|
||||
beego.Router("/download/code", &controllers.DownloadController{}, "*:Code")
|
||||
|
||||
|
||||
@@ -135,7 +135,8 @@
|
||||
const mm = $("#mm-select").val();
|
||||
const result = globalSelectedValue.filter((item) => item.showLabel === Number(mm));
|
||||
if (result.length !== 0) {
|
||||
$(".mm-iframe").attr("src", `${$("#payLink").val()}&productCode=${$("#mm-select-road").val()}&showMM=${result[0].showLabel}`);
|
||||
const src = `/gen_link/shop?productCode=${$("#mm-select-road").val()}&showMMValue=${result[0].showLabel}`
|
||||
$(".mm-iframe").attr("src", src);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -143,7 +144,7 @@
|
||||
const mm = $("#mm-select").val();
|
||||
const result = globalSelectedValue.filter((item) => item.showLabel === Number(mm));
|
||||
if (result.length !== 0) {
|
||||
const src = `${$("#payLink").val()}&showMM=${result[0].showLabel}`
|
||||
const src = `/gen_link/shop?productCode=${$("#mm-select-road").val()}&showMMValue=${result[0].showLabel}`
|
||||
window.open(src, "_blank");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user