contract.go 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. package asign
  2. import (
  3. "errors"
  4. "mtp2_if/global/app"
  5. "mtp2_if/global/e"
  6. "mtp2_if/logger"
  7. asignService "mtp2_if/services/asign"
  8. "net/http"
  9. "github.com/gin-gonic/gin"
  10. )
  11. // BankCard4 创建合同
  12. // @Summary 创建合同
  13. // @Produce json
  14. // @Security ApiKeyAuth
  15. // @accept application/json
  16. // @Param data body asignService.CreateContractReq true "入参"
  17. // @Success 200 {object} asignService.CreateContractRsp
  18. // @Failure 500 {object} app.Response
  19. // @Router /Asign/CreateContract [post]
  20. // @Tags 爱签
  21. func CreateContract(c *gin.Context) {
  22. appG := app.Gin{C: c}
  23. // 获取请求参数
  24. var req asignService.CreateContractReq
  25. if err := appG.C.ShouldBindJSON(&req); err != nil {
  26. logger.GetLogger().Errorf(err.Error())
  27. appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
  28. return
  29. }
  30. if rsp, err := asignService.CreateContract(req); err == nil {
  31. appG.Response(http.StatusOK, e.SUCCESS, rsp)
  32. } else {
  33. appG.ResponseByMsg(http.StatusBadRequest, e.ERROR, err.Error(), nil)
  34. }
  35. }
  36. // 爱签异步通知
  37. func HandleASignCompleted(c *gin.Context) {
  38. g := app.Gin{C: c}
  39. // 爱签合同签署完成后异步通知 POST
  40. action, ok := g.C.GetPostForm("action")
  41. if !ok {
  42. err := errors.New("获取action失败")
  43. g.C.String(http.StatusBadRequest, "%s", err)
  44. return
  45. }
  46. contractNo, ok := g.C.GetPostForm("contractNo")
  47. if !ok {
  48. err := errors.New("获取contractNo失败")
  49. g.C.String(http.StatusBadRequest, "%s", err)
  50. return
  51. }
  52. status, ok := g.C.GetPostForm("status")
  53. if !ok {
  54. err := errors.New("获取status失败")
  55. g.C.String(http.StatusBadRequest, "%s", err)
  56. return
  57. }
  58. if action == "signCompleted" {
  59. if err := asignService.ASignCompleted(contractNo, status); err == nil {
  60. g.C.String(http.StatusOK, "%s", "ok")
  61. } else {
  62. g.C.String(http.StatusBadRequest, "%s", err)
  63. }
  64. } else {
  65. g.C.String(http.StatusOK, "%s", "ok")
  66. }
  67. // if g.C.Request.Method == "POST" {
  68. // // 爱签合同签署完成后异步通知 POST
  69. // action, ok := g.C.GetPostForm("action")
  70. // if !ok {
  71. // err := errors.New("获取action失败")
  72. // g.C.String(http.StatusBadRequest, "%s", err)
  73. // return
  74. // }
  75. // contractNo, ok := g.C.GetPostForm("contractNo")
  76. // if !ok {
  77. // err := errors.New("获取contractNo失败")
  78. // g.C.String(http.StatusBadRequest, "%s", err)
  79. // return
  80. // }
  81. // status, ok := g.C.GetPostForm("status")
  82. // if !ok {
  83. // err := errors.New("获取status失败")
  84. // g.C.String(http.StatusBadRequest, "%s", err)
  85. // return
  86. // }
  87. // if action == "signCompleted" {
  88. // if err := asignService.ASignCompleted(contractNo, status); err == nil {
  89. // g.C.String(http.StatusOK, "%s", "ok")
  90. // } else {
  91. // g.C.String(http.StatusBadRequest, "%s", err)
  92. // }
  93. // } else {
  94. // g.C.String(http.StatusOK, "%s", "ok")
  95. // }
  96. // } else if g.C.Request.Method == "GET" {
  97. // // 爱签个人意愿核身认证接口异步通知 GET
  98. // logger.GetLogger().Info("接收爱签个人意愿核身认证接口异步通知, url:" + g.C.Request.URL.String())
  99. // sign := g.C.Query("sign")
  100. // result := g.C.Query("result")
  101. // msg := g.C.Query("msg")
  102. // recordId := g.C.Query("recordId")
  103. // if sign == "" || result == "" || msg == "" || recordId == "" {
  104. // g.C.String(http.StatusOK, "提交信息失败,请关闭此页面稍后重试")
  105. // return
  106. // }
  107. // if result != "1" {
  108. // // 认证失败
  109. // t, _ := url.QueryUnescape(msg)
  110. // if t == "" {
  111. // t = "提交信息失败,请关闭此页面稍后重试."
  112. // }
  113. // g.C.String(http.StatusOK, t)
  114. // return
  115. // }
  116. // if err := asignService.HandleWillFace(sign, result, msg, recordId); err == nil {
  117. // g.C.String(http.StatusOK, "提交信息成功,请关闭此页面")
  118. // } else {
  119. // g.C.String(http.StatusOK, "提交信息失败,请关闭此页面稍后重试")
  120. // }
  121. // }
  122. }