智慧食堂
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

пре 1 година
пре 1 година
пре 1 година
пре 1 година
пре 1 година
пре 1 година
пре 1 година
пре 1 година
пре 1 година
пре 1 година
пре 1 година
пре 1 година
пре 1 година
пре 1 година
пре 1 година
пре 1 година
пре 1 година
пре 1 година
пре 1 година
пре 1 година
пре 1 година
пре 1 година
пре 1 година
пре 1 година
пре 1 година
пре 1 година
пре 1 година
пре 1 година
пре 1 година
пре 1 година
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. package hdl
  2. import (
  3. "applet/app/admin/lib/validate"
  4. svc2 "applet/app/admin/svc/enterprise_manage"
  5. "applet/app/customer/md"
  6. "applet/app/customer/svc"
  7. "applet/app/db"
  8. "applet/app/db/model"
  9. "applet/app/e"
  10. "applet/app/enum"
  11. svc3 "applet/app/svc"
  12. "context"
  13. "github.com/chromedp/chromedp"
  14. "github.com/chromedp/chromedp/device"
  15. "github.com/gin-gonic/gin"
  16. "github.com/wechatpay-apiv3/wechatpay-go/core"
  17. "github.com/wechatpay-apiv3/wechatpay-go/services/certificates"
  18. "github.com/wechatpay-apiv3/wechatpay-go/services/partnerpayments/jsapi"
  19. "io/ioutil"
  20. "strconv"
  21. "time"
  22. )
  23. func CurlAlipayPlanetEcocampusApiRosterSignUpInfo(c *gin.Context) {
  24. var req md.CurlAlipayPlanetEcocampusApiRosterSignUpInfoReq
  25. err := c.ShouldBindJSON(&req)
  26. if err != nil {
  27. err = validate.HandleValidateErr(err)
  28. err1 := err.(e.E)
  29. e.OutErr(c, err1.Code, err1.Error())
  30. return
  31. }
  32. err, resp := svc.CurlAlipayPlanetEcocampusApiRosterSignUpInfo(req)
  33. if err != nil {
  34. e.OutErr(c, e.ERR, err.Error())
  35. return
  36. }
  37. e.OutSuc(c, resp, nil)
  38. return
  39. }
  40. func DownloadCertificates(c *gin.Context) {
  41. client, err := svc3.NewWxPayClient(c)
  42. if err != nil {
  43. e.OutErr(c, e.ERR, err.Error())
  44. return
  45. }
  46. // 发送请求,以下载微信支付平台证书为例
  47. apiSvc := certificates.CertificatesApiService{Client: client}
  48. resp, result, err := apiSvc.DownloadCertificates(c)
  49. if err != nil {
  50. e.OutErr(c, e.ERR, err.Error())
  51. return
  52. }
  53. println("status=%d resp=%s", result.Response.StatusCode, resp)
  54. e.OutSuc(c, map[string]interface{}{
  55. "resp": resp,
  56. }, nil)
  57. return
  58. }
  59. func WxPay(c *gin.Context) {
  60. client, err := svc3.NewWxPayClient(c)
  61. if err != nil {
  62. e.OutErr(c, e.ERR, err.Error())
  63. return
  64. }
  65. wxSvc := jsapi.JsapiApiService{Client: client}
  66. sysCfgDb := db.SysCfgDb{}
  67. sysCfgDb.Set()
  68. sysCfg := sysCfgDb.SysCfgFindWithDb(enum.WxSpAppId, enum.WxSpMchId, enum.WxAppletAppId, enum.WxMchId)
  69. resp, result, err := wxSvc.Prepay(c,
  70. jsapi.PrepayRequest{
  71. SpAppid: core.String(sysCfg[enum.WxSpAppId]),
  72. SpMchid: core.String(sysCfg[enum.WxSpMchId]),
  73. SubAppid: core.String(sysCfg[enum.WxAppletAppId]),
  74. SubMchid: core.String(sysCfg[enum.WxMchId]),
  75. Description: core.String("Image形象店-深圳腾大-QQ公仔"),
  76. OutTradeNo: core.String(strconv.FormatInt(time.Now().Unix(), 10)),
  77. TimeExpire: core.Time(time.Now()),
  78. Attach: core.String("自定义数据说明"),
  79. NotifyUrl: core.String("https://www.weixin.qq.com/wxpay/pay.php"),
  80. Amount: &jsapi.Amount{
  81. Currency: core.String("CNY"),
  82. Total: core.Int64(100),
  83. },
  84. Payer: &jsapi.Payer{
  85. //SpOpenid: core.String("oUpF8uMuAJO_M2pxb1Q9zNjWeS6o"),
  86. SubOpenid: core.String("o0mnM4nlX9W5HXbagffM9eTDHaPo"),
  87. },
  88. },
  89. )
  90. if err != nil {
  91. // 处理错误
  92. e.OutErr(c, e.ERR, err.Error())
  93. return
  94. } else {
  95. // 处理返回结果
  96. println("status=%d resp=%s", result.Response.StatusCode, resp)
  97. }
  98. return
  99. }
  100. func Demo(c *gin.Context) {
  101. sysCfgDb := db.SysCfgDb{}
  102. sysCfgDb.Set()
  103. sysCfg := sysCfgDb.SysCfgFindWithDb(enum.OpenAppletAppid, enum.OpenAppletAppPrivateKey, enum.OpenAppletPublicKey)
  104. err, info := svc.CurlEducateSceneTokenQueryV2(md.CurlEducateSceneTokenReq{
  105. Config: struct {
  106. AliAppId string `json:"ali_app_id" label:"支付宝开放平台-小程序-appid"`
  107. AliPrivateKey string `json:"ali_private_key" label:"支付宝开放平台-小程序-应用私钥"`
  108. AliPublicKey string `json:"ali_public_key" label:"支付宝开放平台-小程序-支付宝公钥"`
  109. }{
  110. AliAppId: sysCfg[enum.OpenAppletAppid],
  111. AliPrivateKey: sysCfg[enum.OpenAppletAppPrivateKey],
  112. AliPublicKey: sysCfg[enum.OpenAppletPublicKey],
  113. },
  114. CertType: "A",
  115. CertNo: "440881201010205523",
  116. StudentName: "龙佩滢",
  117. OutUserId: "1001",
  118. SchoolStdCode: "12440403MB2D752515",
  119. }, &model.UserIdentity{}, "", "")
  120. if err != nil {
  121. e.OutErr(c, e.ERR, err.Error())
  122. return
  123. }
  124. e.OutSuc(c, info, nil)
  125. return
  126. ordNo := c.DefaultQuery("ord_no", "")
  127. svc2.JudgePackageOrdOrdState(ordNo)
  128. e.OutSuc(c, nil, nil)
  129. return
  130. }
  131. func SanHu(c *gin.Context) { //实现网页截图
  132. url := c.DefaultQuery("url", "")
  133. if url == "" {
  134. e.OutErr(c, e.ERR_NO_DATA, "网址不能为空")
  135. return
  136. }
  137. ctx, cancel := chromedp.NewContext(context.Background())
  138. defer cancel()
  139. var b1, b2 []byte
  140. if err := chromedp.Run(ctx,
  141. // emulate iPhone 7 landscape
  142. chromedp.Emulate(device.IPhone8Plus),
  143. chromedp.Navigate(url),
  144. chromedp.CaptureScreenshot(&b1),
  145. // reset
  146. chromedp.Emulate(device.Reset),
  147. // set really large viewport
  148. chromedp.EmulateViewport(1920, 2000),
  149. chromedp.Navigate(url),
  150. chromedp.CaptureScreenshot(&b2),
  151. ); err != nil {
  152. e.OutErr(c, e.ERR, err.Error())
  153. return
  154. }
  155. if err := ioutil.WriteFile("./static/template/sanHu/IPhone8Plus.png", b1, 0777); err != nil {
  156. e.OutErr(c, e.ERR, err.Error())
  157. return
  158. }
  159. if err := ioutil.WriteFile("./static/template/sanHu/Pc.png", b2, 0777); err != nil {
  160. e.OutErr(c, e.ERR, err.Error())
  161. return
  162. }
  163. e.OutSuc(c, map[string]interface{}{
  164. "iphone8_plus": "https://zs.zehaochi.net/template/sanHu/IPhone8Plus.png",
  165. "Pc": "https://zs.zehaochi.net/template/sanHu/Pc.png",
  166. }, nil)
  167. return
  168. }