package asign import ( "errors" "mtp2_if/global/app" "mtp2_if/global/e" "mtp2_if/logger" asignService "mtp2_if/services/asign" "net/http" "net/url" "github.com/gin-gonic/gin" ) // BankCard4 创建合同 // @Summary 创建合同 // @Produce json // @Security ApiKeyAuth // @accept application/json // @Param data body asignService.CreateContractReq true "入参" // @Success 200 {object} asignService.CreateContractRsp // @Failure 500 {object} app.Response // @Router /Asign/CreateContract [post] // @Tags 爱签 func CreateContract(c *gin.Context) { appG := app.Gin{C: c} // 获取请求参数 var req asignService.CreateContractReq if err := appG.C.ShouldBindJSON(&req); err != nil { logger.GetLogger().Errorf(err.Error()) appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil) return } if rsp, err := asignService.CreateContract(req); err == nil { appG.Response(http.StatusOK, e.SUCCESS, rsp) } else { appG.ResponseByMsg(http.StatusBadRequest, e.ERROR, err.Error(), nil) } } // 爱签异步通知 func HandleASignCompleted(c *gin.Context) { g := app.Gin{C: c} if g.C.Request.Method == "POST" { // 爱签合同签署完成后异步通知 POST action, ok := g.C.GetPostForm("action") if !ok { err := errors.New("获取action失败") g.C.String(http.StatusBadRequest, "%s", err) return } contractNo, ok := g.C.GetPostForm("contractNo") if !ok { err := errors.New("获取contractNo失败") g.C.String(http.StatusBadRequest, "%s", err) return } status, ok := g.C.GetPostForm("status") if !ok { err := errors.New("获取status失败") g.C.String(http.StatusBadRequest, "%s", err) return } if action == "signCompleted" { if err := asignService.ASignCompleted(contractNo, status); err == nil { g.C.String(http.StatusOK, "%s", "ok") } else { g.C.String(http.StatusBadRequest, "%s", err) } } else { g.C.String(http.StatusOK, "%s", "ok") } } else if g.C.Request.Method == "GET" { // 爱签个人意愿核身认证接口异步通知 GET logger.GetLogger().Info("接收爱签个人意愿核身认证接口异步通知, url:" + g.C.Request.URL.String()) sign := g.C.Query("sign") result := g.C.Query("result") msg := g.C.Query("msg") recordId := g.C.Query("recordId") if sign == "" || result == "" || msg == "" || recordId == "" { g.C.String(http.StatusOK, "提交信息失败,请关闭此页面稍后重试") return } if result != "1" { // 认证失败 t, _ := url.QueryUnescape(msg) if t == "" { t = "提交信息失败,请关闭此页面稍后重试." } g.C.String(http.StatusOK, t) return } if err := asignService.HandleWillFace(sign, result, msg, recordId); err == nil { g.C.String(http.StatusOK, "提交信息成功,请关闭此页面") } else { g.C.String(http.StatusOK, "提交信息失败,请关闭此页面稍后重试") } } }