智慧食堂
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

hdl_demo.go 7.3 KiB

il y a 1 an
il y a 1 an
il y a 1 an
il y a 1 an
il y a 1 an
il y a 1 an
il y a 1 an
il y a 1 an
il y a 1 an
il y a 1 an
il y a 1 an
il y a 1 an
il y a 1 an
il y a 1 an
il y a 1 an
il y a 1 an
il y a 1 an
il y a 1 an
il y a 1 an
il y a 1 an
il y a 1 an
il y a 1 an
il y a 1 an
il y a 1 an
il y a 1 an
il y a 1 an
il y a 1 an
il y a 1 an
il y a 8 mois
il y a 1 an
il y a 9 mois
il y a 9 mois
il y a 9 mois
il y a 9 mois
il y a 1 an
il y a 9 mois
il y a 9 mois
il y a 9 mois
il y a 1 an
il y a 1 an
il y a 1 an
il y a 1 an
il y a 1 an
il y a 1 an
il y a 1 an
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  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. "applet/app/utils"
  13. "context"
  14. "fmt"
  15. "github.com/chromedp/chromedp"
  16. "github.com/chromedp/chromedp/device"
  17. "github.com/gin-gonic/gin"
  18. "github.com/wechatpay-apiv3/wechatpay-go/core"
  19. "github.com/wechatpay-apiv3/wechatpay-go/services/certificates"
  20. "github.com/wechatpay-apiv3/wechatpay-go/services/partnerpayments/jsapi"
  21. "io/ioutil"
  22. "strconv"
  23. "time"
  24. )
  25. func CurlAlipayPlanetEcocampusApiRosterSignUpInfo(c *gin.Context) {
  26. //查询出所有的用户身份
  27. selfSupportForUserFaceInfoDb := db.SelfSupportForUserFaceInfoDb{}
  28. selfSupportForUserFaceInfoDb.Set(0)
  29. list, err2 := selfSupportForUserFaceInfoDb.FindSchoolFacePaymentStatus(18, "OPEN")
  30. if err2 != nil {
  31. e.OutErr(c, e.ERR, err2.Error())
  32. return
  33. }
  34. userIdentityDb := db.UserIdentityDb{}
  35. userIdentityDb.Set(0)
  36. for _, v := range *list {
  37. identity, err := userIdentityDb.GetUserIdentity(v.UserIdentityId)
  38. if err != nil {
  39. e.OutErr(c, e.ERR, err.Error())
  40. return
  41. }
  42. var req = md.CurlAlipayPlanetEcocampusApiRosterSignUpInfoReq{
  43. FaceUid: v.UserId,
  44. ParentUid: v.ParentUserId,
  45. ParentLogonId: v.ParentLogonId,
  46. RosterName: identity.Name,
  47. OutRosterCode: utils.IntToStr(identity.Id),
  48. SchoolCode: v.SchoolCode,
  49. SchoolName: "珠海市斗门区第二实验小学",
  50. ScanFacePayStatus: "ON",
  51. FaceOpenStatus: "ON",
  52. }
  53. err, resp := svc.CurlAlipayPlanetEcocampusApiRosterSignUpInfo(req)
  54. if err != nil {
  55. e.OutErr(c, e.ERR, err.Error())
  56. return
  57. }
  58. if err != nil {
  59. e.OutErr(c, e.ERR, err.Error())
  60. return
  61. }
  62. fmt.Println(">>>>>>>>>>>>>>>>>>>>>>>>>", utils.SerializeStr(resp))
  63. }
  64. e.OutSuc(c, "success", nil)
  65. return
  66. var req md.CurlAlipayPlanetEcocampusApiRosterSignUpInfoReq
  67. err := c.ShouldBindJSON(&req)
  68. if err != nil {
  69. err = validate.HandleValidateErr(err)
  70. err1 := err.(e.E)
  71. e.OutErr(c, err1.Code, err1.Error())
  72. return
  73. }
  74. err, resp := svc.CurlAlipayPlanetEcocampusApiRosterSignUpInfo(req)
  75. if err != nil {
  76. e.OutErr(c, e.ERR, err.Error())
  77. return
  78. }
  79. e.OutSuc(c, resp, nil)
  80. return
  81. }
  82. func DownloadCertificates(c *gin.Context) {
  83. client, err := svc3.NewWxPayClient(c)
  84. if err != nil {
  85. e.OutErr(c, e.ERR, err.Error())
  86. return
  87. }
  88. // 发送请求,以下载微信支付平台证书为例
  89. apiSvc := certificates.CertificatesApiService{Client: client}
  90. resp, result, err := apiSvc.DownloadCertificates(c)
  91. if err != nil {
  92. e.OutErr(c, e.ERR, err.Error())
  93. return
  94. }
  95. println("status=%d resp=%s", result.Response.StatusCode, resp)
  96. e.OutSuc(c, map[string]interface{}{
  97. "resp": resp,
  98. }, nil)
  99. return
  100. }
  101. func WxPay(c *gin.Context) {
  102. client, err := svc3.NewWxPayClient(c)
  103. if err != nil {
  104. e.OutErr(c, e.ERR, err.Error())
  105. return
  106. }
  107. wxSvc := jsapi.JsapiApiService{Client: client}
  108. sysCfgDb := db.SysCfgDb{}
  109. sysCfgDb.Set()
  110. sysCfg := sysCfgDb.SysCfgFindWithDb(enum.WxSpAppId, enum.WxSpMchId, enum.WxAppletAppId, enum.WxMchId)
  111. resp, result, err := wxSvc.Prepay(c,
  112. jsapi.PrepayRequest{
  113. SpAppid: core.String(sysCfg[enum.WxSpAppId]),
  114. SpMchid: core.String(sysCfg[enum.WxSpMchId]),
  115. SubAppid: core.String(sysCfg[enum.WxAppletAppId]),
  116. SubMchid: core.String(sysCfg[enum.WxMchId]),
  117. Description: core.String("Image形象店-深圳腾大-QQ公仔"),
  118. OutTradeNo: core.String(strconv.FormatInt(time.Now().Unix(), 10)),
  119. TimeExpire: core.Time(time.Now()),
  120. Attach: core.String("自定义数据说明"),
  121. NotifyUrl: core.String("https://www.weixin.qq.com/wxpay/pay.php"),
  122. Amount: &jsapi.Amount{
  123. Currency: core.String("CNY"),
  124. Total: core.Int64(100),
  125. },
  126. Payer: &jsapi.Payer{
  127. //SpOpenid: core.String("oUpF8uMuAJO_M2pxb1Q9zNjWeS6o"),
  128. SubOpenid: core.String("o0mnM4nlX9W5HXbagffM9eTDHaPo"),
  129. },
  130. },
  131. )
  132. if err != nil {
  133. // 处理错误
  134. e.OutErr(c, e.ERR, err.Error())
  135. return
  136. } else {
  137. // 处理返回结果
  138. println("status=%d resp=%s", result.Response.StatusCode, resp)
  139. }
  140. return
  141. }
  142. func Demo(c *gin.Context) {
  143. _, err := svc.DealCentralKitchenForSchoolOrderCallBackForWx("141271708763327845", "4200002114202402240122111525", "SUCCESS")
  144. if err != nil {
  145. e.OutErr(c, e.ERR, err.Error())
  146. return
  147. }
  148. e.OutSuc(c, "success", nil)
  149. return
  150. sysCfgDb := db.SysCfgDb{}
  151. sysCfgDb.Set()
  152. sysCfg := sysCfgDb.SysCfgFindWithDb(enum.OpenAppletAppid, enum.OpenAppletAppPrivateKey, enum.OpenAppletPublicKey)
  153. //err, info := svc.CurlEducateFacepayApply(md.CurlEducateFacepayApplyReq{
  154. // Config: struct {
  155. // AliAppId string `json:"ali_app_id" label:"支付宝开放平台-小程序-appid"`
  156. // AliPrivateKey string `json:"ali_private_key" label:"支付宝开放平台-小程序-应用私钥"`
  157. // AliPublicKey string `json:"ali_public_key" label:"支付宝开放平台-小程序-支付宝公钥"`
  158. // }{
  159. // AliAppId: sysCfg[enum.OpenAppletAppid],
  160. // AliPrivateKey: sysCfg[enum.OpenAppletAppPrivateKey],
  161. // AliPublicKey: sysCfg[enum.OpenAppletPublicKey],
  162. // },
  163. // FaceUid: "2088930289907324",
  164. // FaceOpenId: "",
  165. // SchoolStdCode: "3144003844",
  166. //})
  167. //if err != nil {
  168. // e.OutErr(c, e.ERR, err.Error())
  169. // return
  170. //}
  171. //e.OutSuc(c, info, nil)
  172. //return
  173. err, info := svc.CurlEducateSceneTokenQueryV2(md.CurlEducateSceneTokenReq{
  174. Config: struct {
  175. AliAppId string `json:"ali_app_id" label:"支付宝开放平台-小程序-appid"`
  176. AliPrivateKey string `json:"ali_private_key" label:"支付宝开放平台-小程序-应用私钥"`
  177. AliPublicKey string `json:"ali_public_key" label:"支付宝开放平台-小程序-支付宝公钥"`
  178. }{
  179. AliAppId: sysCfg[enum.OpenAppletAppid],
  180. AliPrivateKey: sysCfg[enum.OpenAppletAppPrivateKey],
  181. AliPublicKey: sysCfg[enum.OpenAppletPublicKey],
  182. },
  183. CertType: "1",
  184. CertNo: "440402201102199098",
  185. StudentName: "陈子豪",
  186. OutUserId: "16141",
  187. SchoolStdCode: "3144003844",
  188. }, &model.UserIdentity{}, "", "")
  189. if err != nil {
  190. e.OutErr(c, e.ERR, err.Error())
  191. return
  192. }
  193. e.OutSuc(c, info, nil)
  194. return
  195. ordNo := c.DefaultQuery("ord_no", "")
  196. svc2.JudgePackageOrdOrdState(ordNo)
  197. e.OutSuc(c, nil, nil)
  198. return
  199. }
  200. func SanHu(c *gin.Context) { //实现网页截图
  201. url := c.DefaultQuery("url", "")
  202. if url == "" {
  203. e.OutErr(c, e.ERR_NO_DATA, "网址不能为空")
  204. return
  205. }
  206. ctx, cancel := chromedp.NewContext(context.Background())
  207. defer cancel()
  208. var b1, b2 []byte
  209. if err := chromedp.Run(ctx,
  210. // emulate iPhone 7 landscape
  211. chromedp.Emulate(device.IPhone8Plus),
  212. chromedp.Navigate(url),
  213. chromedp.CaptureScreenshot(&b1),
  214. // reset
  215. chromedp.Emulate(device.Reset),
  216. // set really large viewport
  217. chromedp.EmulateViewport(1920, 2000),
  218. chromedp.Navigate(url),
  219. chromedp.CaptureScreenshot(&b2),
  220. ); err != nil {
  221. e.OutErr(c, e.ERR, err.Error())
  222. return
  223. }
  224. if err := ioutil.WriteFile("./static/template/sanHu/IPhone8Plus.png", b1, 0777); err != nil {
  225. e.OutErr(c, e.ERR, err.Error())
  226. return
  227. }
  228. if err := ioutil.WriteFile("./static/template/sanHu/Pc.png", b2, 0777); err != nil {
  229. e.OutErr(c, e.ERR, err.Error())
  230. return
  231. }
  232. e.OutSuc(c, map[string]interface{}{
  233. "iphone8_plus": "https://zs.zehaochi.net/template/sanHu/IPhone8Plus.png",
  234. "Pc": "https://zs.zehaochi.net/template/sanHu/Pc.png",
  235. }, nil)
  236. return
  237. }