智慧食堂
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.

hdl_call_back.go 1.9 KiB

1 年之前
1 年之前
1 年之前
1 年之前
1 年之前
1 年之前
1 年之前
1 年之前
1 年之前
1 年之前
1 年之前
1 年之前
1 年之前
1 年之前
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. package hdl
  2. import (
  3. "applet/app/admin/lib/validate"
  4. "applet/app/customer/md"
  5. "applet/app/customer/svc"
  6. "applet/app/db"
  7. "applet/app/e"
  8. "applet/app/enum"
  9. "encoding/json"
  10. "fmt"
  11. "github.com/gin-gonic/gin"
  12. "github.com/wechatpay-apiv3/wechatpay-go/utils"
  13. )
  14. func AlipayJsApiCallBack(c *gin.Context) {
  15. data := svc.CheckAllCallbackParams(c)
  16. if data == nil {
  17. e.OutErr(c, e.ERR_INVALID_ARGS)
  18. return
  19. }
  20. c.Set("callback", data)
  21. args, ok := data.(*md.AliPayCallback)
  22. if !ok {
  23. fmt.Println("反射ok失败")
  24. e.OutErr(c, e.ERR_INVALID_ARGS, "反射失败")
  25. return
  26. }
  27. if args.GmtRefund != "" {
  28. //TODO::退款通知不需要处理
  29. c.String(200, "success")
  30. return
  31. }
  32. _, err := svc.DealCentralKitchenForSchoolOrderCallBack(args.OutTradeNo, args.TradeStatus)
  33. if err != nil {
  34. e.OutErr(c, e.ERR, err.Error())
  35. return
  36. }
  37. //TODO::此处需要直接输出 success,避免支付宝重复回调
  38. //c.Header("Content-Type", "text/html; charset=utf-8")
  39. c.String(200, "success")
  40. }
  41. func WxJsApiCallBack(c *gin.Context) {
  42. var req md.WxPayCallback
  43. err := c.ShouldBindJSON(&req)
  44. if err != nil {
  45. err = validate.HandleValidateErr(err)
  46. err1 := err.(e.E)
  47. e.OutErr(c, err1.Code, err1.Error())
  48. return
  49. }
  50. sysCfgDb := db.SysCfgDb{}
  51. sysCfgDb.Set()
  52. sysCfg := sysCfgDb.SysCfgFindWithDb(enum.WxSpMchApiV3Key)
  53. //TODO::进行解密
  54. decryptString, err := utils.DecryptAES256GCM(sysCfg[enum.WxSpMchApiV3Key], req.Resource.AssociatedData, req.Resource.Nonce, req.Resource.Ciphertext)
  55. if err != nil {
  56. e.OutErr(c, e.ERR, "解密失败")
  57. return
  58. }
  59. fmt.Println(">>>>>>>>>>", decryptString)
  60. var resp md.WxPayDecryptAesCallback
  61. err = json.Unmarshal([]byte(decryptString), &resp)
  62. if err != nil {
  63. e.OutErr(c, e.ERR, err.Error())
  64. return
  65. }
  66. _, err = svc.DealCentralKitchenForSchoolOrderCallBackForWx(resp.OutTradeNo, resp.TransactionId, resp.TradeState)
  67. if err != nil {
  68. e.OutErr(c, e.ERR, err.Error())
  69. return
  70. }
  71. e.OutSuc(c, "success", nil)
  72. }