SysPublicController.go 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. package partial
  2. import (
  3. "encoding/json"
  4. "fmt"
  5. "git.qianqiusoft.com/qianqiusoft/light-apiengine/entitys"
  6. "git.qianqiusoft.com/qianqiusoft/light-apiengine/models"
  7. "git.qianqiusoft.com/qianqiusoft/light-apiengine/third/wx"
  8. "github.com/silenceper/wechat/pay"
  9. "io/ioutil"
  10. //sysmodel "git.qianqiusoft.com/qianqiusoft/light-apiengine/models"
  11. //sysutils "git.qianqiusoft.com/qianqiusoft/light-apiengine/utils"
  12. //"git.qianqiusoft.com/qianqiusoft/light-apiengine/models"
  13. //__import_packages__
  14. )
  15. // _WxpayCallback
  16. // @Title _WxpayCallback
  17. // @Description 微信支付回调
  18. // @Success 200 {object} Account
  19. // @Failure 403 :id is empty
  20. func SysPublic_WxpayCallback(c *entitys.CtrlContext) {
  21. r := wx.CallWxPayCallbackHandler(c)
  22. if r.Code != 200{
  23. c.Ctx.JSON(500, r)
  24. }else{
  25. res := pay.NotifyResponse{}
  26. res.ReturnCode = "SUCCESS"
  27. res.ReturnMsg = "OK"
  28. c.Ctx.XML(200,&res)
  29. }
  30. }
  31. // _WxoauthParams
  32. // @Title _WxoauthParams
  33. // @Description 获取微信oauth配置
  34. // @Success 200 {object} Account
  35. // @Failure 403 :id is empty
  36. func SysPublic_WxoauthParams(c *entitys.CtrlContext) {
  37. contentBody, err := ioutil.ReadAll(c.Ctx.Request.Body)
  38. if err != nil{
  39. fmt.Println("读取body错误", err.Error())
  40. c.Ctx.JSON(500, models.SysReturn{500, err.Error(), ""})
  41. return
  42. }
  43. bmap := make(map[string]string)
  44. err = json.Unmarshal(contentBody, &bmap)
  45. if err != nil{
  46. fmt.Println("Unmarshal错误", err.Error())
  47. c.Ctx.JSON(500, models.SysReturn{500, err.Error(), ""})
  48. return
  49. }
  50. param, err := wx.GetOAuthParams(bmap)
  51. if err != nil{
  52. c.Ctx.JSON(500, models.SysReturn{500, "", ""})
  53. }else{
  54. c.Ctx.JSON(200, models.SysReturn{200, "", param})
  55. }
  56. }
  57. // _WxjssdkParams
  58. // @Title _WxjssdkParams
  59. // @Description 获取微信jssdk配置
  60. // @Success 200 {object} Account
  61. // @Failure 403 :id is empty
  62. func SysPublic_WxjssdkParams(c *entitys.CtrlContext) {
  63. url := c.Ctx.DefaultQuery("url", "")
  64. if url == ""{
  65. c.Ctx.JSON(200, models.SysReturn{500, "参数rul为空", ""})
  66. return
  67. }
  68. config, err := wx.GetJSSDKRarams(url)
  69. if err != nil{
  70. c.Ctx.JSON(200, models.SysReturn{500, err.Error(), ""})
  71. }else{
  72. c.Ctx.JSON(200, models.SysReturn{200, "", config})
  73. }
  74. }
  75. // _AlipayCallback
  76. // @Title _AlipayCallback
  77. // @Description 支付宝支付回调
  78. // @Success 200 {object} Account
  79. // @Failure 403 :id is empty
  80. func SysPublic_AlipayCallback(c *entitys.CtrlContext) {
  81. ret := __none_func_sys_public__()
  82. if ret{
  83. c.Ctx.String(200,"")
  84. }
  85. }
  86. func __none_func_sys_public__(params ... interface{}) bool{
  87. return true
  88. }