commonPayWx.go 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. package front
  2. import (
  3. "errors"
  4. "github.com/go-xweb/xweb"
  5. "jfw/wx"
  6. )
  7. /*
  8. 微信公众号支付公共页面
  9. */
  10. type WxPayCommon struct {
  11. *xweb.Action
  12. toCreateOrderPage xweb.Mapper `xweb:"/weixin/pay/checkout_(.*)"` //微信数据导出-支付页面
  13. paySuccess xweb.Mapper `xweb:"/weixin/(\\w+)/paySuccess"` //微信支付-支付完成
  14. }
  15. func init() {
  16. xweb.AddAction(&WxPayCommon{})
  17. }
  18. func (w *WxPayCommon) ToCreateOrderPage(doType string) error {
  19. orderCode := w.GetString("orderCode")
  20. if orderCode == "" || doType == "" {
  21. return errors.New("未知订单")
  22. }
  23. w.T["doType"] = doType
  24. w.T["orderCode"] = orderCode
  25. w.T["signature"] = wx.SignJSSDK(w.Site() + w.Url())
  26. return w.Render("/weixin/commonPay/checkout.html", &w.T)
  27. }
  28. func (w *WxPayCommon) PaySuccess(doType string) error {
  29. //获取参数
  30. w.T["orderCode"] = w.GetString("orderCode")
  31. w.T["payTime"] = w.GetString("payTime")
  32. w.T["email"] = w.GetString("email")
  33. if doType == "dataexport" {
  34. return w.Render("/weixin/dataExport/dataExport_paySuccess.html", &w.T)
  35. }
  36. w.T["doType"] = doType
  37. return w.Render("/weixin/commonPay/paySuccess.html", &w.T)
  38. }