This commit is contained in:
2026-07-21 15:53:29 +08:00
parent 024b6614ba
commit c943f575d5
40 changed files with 5362 additions and 275 deletions

View File

@@ -154,6 +154,59 @@ func (h *CertificationHandler) ConfirmAuth(c *gin.Context) {
h.response.Success(c, result, "状态确认成功")
}
// ListSignPlatforms 可选签署平台列表
func (h *CertificationHandler) ListSignPlatforms(c *gin.Context) {
result, err := h.appService.ListSignPlatforms(c.Request.Context())
if err != nil {
h.response.BadRequest(c, err.Error())
return
}
h.response.Success(c, result, "获取签署平台列表成功")
}
// SelectSignPlatform 选择签署平台并生成企业认证链接
func (h *CertificationHandler) SelectSignPlatform(c *gin.Context) {
var cmd commands.SelectSignPlatformCommand
cmd.UserID = h.getCurrentUserID(c)
if cmd.UserID == "" {
h.response.Unauthorized(c, "用户未登录")
return
}
if err := c.ShouldBindJSON(&cmd); err != nil {
h.response.BadRequest(c, "请求参数错误")
return
}
result, err := h.appService.SelectSignPlatform(c.Request.Context(), &cmd)
if err != nil {
h.logger.Error("选择签署平台失败", zap.Error(err), zap.String("user_id", cmd.UserID))
h.response.BadRequest(c, err.Error())
return
}
h.response.Success(c, result, "已选择签署平台")
}
// HandleFadadaCallback 法大大回调
func (h *CertificationHandler) HandleFadadaCallback(c *gin.Context) {
headers := make(map[string]string)
for key, values := range c.Request.Header {
if len(values) > 0 {
headers[key] = values[0]
}
}
body, err := io.ReadAll(c.Request.Body)
if err != nil {
h.logger.Error("读取法大大回调失败", zap.Error(err))
c.String(400, "fail")
return
}
if err := h.appService.HandleFadadaCallback(c.Request.Context(), headers, body); err != nil {
h.logger.Error("处理法大大回调失败", zap.Error(err))
c.String(400, "fail")
return
}
c.Data(200, "application/json", []byte(`{"msg":"success"}`))
}
// ConfirmSign 前端确认是否完成签署
// @Summary 前端确认签署状态
// @Description 前端轮询确认合同签署是否完成
@@ -219,6 +272,61 @@ func (h *CertificationHandler) ApplyContract(c *gin.Context) {
h.response.Success(c, result, "合同申请成功")
}
// RefreshContractSignURL 刷新合同签署 iframe 长链
// @Summary 刷新合同签署链接
// @Description 重新获取可供 iframe 嵌入的签署长链(法大大约 10 分钟/单次有效)
// @Tags 认证管理
// @Accept json
// @Produce json
// @Security Bearer
// @Success 200 {object} responses.ContractSignUrlResponse "刷新成功"
// @Failure 400 {object} map[string]interface{} "请求参数错误"
// @Failure 401 {object} map[string]interface{} "未认证"
// @Router /api/v1/certifications/refresh-contract-sign-url [post]
func (h *CertificationHandler) RefreshContractSignURL(c *gin.Context) {
userID := h.getCurrentUserID(c)
if userID == "" {
h.response.Unauthorized(c, "用户未登录")
return
}
result, err := h.appService.RefreshContractSignURL(c.Request.Context(), userID)
if err != nil {
h.logger.Error("刷新签署链接失败", zap.Error(err), zap.String("user_id", userID))
h.response.BadRequest(c, err.Error())
return
}
h.response.Success(c, result, "签署链接已刷新")
}
// RefreshContractPreviewURL 刷新合同预览链接
// @Summary 刷新合同预览链接
// @Description 获取签署任务预览链接(法大大 /sign-task/get-preview-url
// @Tags 认证管理
// @Accept json
// @Produce json
// @Security Bearer
// @Success 200 {object} responses.ContractPreviewUrlResponse "刷新成功"
// @Failure 400 {object} map[string]interface{} "请求参数错误"
// @Router /api/v1/certifications/refresh-contract-preview-url [post]
func (h *CertificationHandler) RefreshContractPreviewURL(c *gin.Context) {
userID := h.getCurrentUserID(c)
if userID == "" {
h.response.Unauthorized(c, "用户未登录")
return
}
result, err := h.appService.RefreshContractPreviewURL(c.Request.Context(), userID)
if err != nil {
h.logger.Error("刷新合同预览链接失败", zap.Error(err), zap.String("user_id", userID))
h.response.BadRequest(c, err.Error())
return
}
h.response.Success(c, result, "预览链接已刷新")
}
// RecognizeBusinessLicense OCR识别营业执照
// @Summary OCR识别营业执照
// @Description 上传营业执照图片进行OCR识别自动填充企业信息

View File

@@ -65,10 +65,17 @@ func (r *CertificationRoutes) Register(router *http.GinRouter) {
// 3. 申请合同签署
authGroup.POST("/apply-contract", r.handler.ApplyContract)
// 刷新签署 iframe 长链(法大大 EmbedURL 短期有效)
authGroup.POST("/refresh-contract-sign-url", r.handler.RefreshContractSignURL)
authGroup.POST("/refresh-contract-preview-url", r.handler.RefreshContractPreviewURL)
// 前端确认是否完成认证
authGroup.POST("/confirm-auth", r.handler.ConfirmAuth)
// 签署平台选择(审核通过后、企业认证前)
authGroup.GET("/sign-platforms", r.handler.ListSignPlatforms)
authGroup.POST("/select-sign-platform", r.handler.SelectSignPlatform)
// 前端确认是否完成签署
authGroup.POST("/confirm-sign", r.handler.ConfirmSign)
@@ -95,7 +102,8 @@ func (r *CertificationRoutes) Register(router *http.GinRouter) {
// 回调路由(不需要认证,但需要验证签名)
callbackGroup := certificationGroup.Group("/callbacks")
{
callbackGroup.POST("/esign", r.handler.HandleEsignCallback) // e签宝回调(统一处理企业认证和合同签署回调)
callbackGroup.POST("/esign", r.handler.HandleEsignCallback) // e签宝回调
callbackGroup.POST("/fadada", r.handler.HandleFadadaCallback) // 法大大回调
}
}