Ver código fonte

爱签开发测试完成

zhou.xiaoning 2 anos atrás
pai
commit
ce1b3442a0
8 arquivos alterados com 267 adições e 34 exclusões
  1. 28 7
      api/v1/account/certification.go
  2. 1 1
      config.j2
  3. 1 0
      config.yaml
  4. 1 0
      config/asign.go
  5. 18 0
      py/Api.py
  6. 2 0
      py/Enter.py
  7. 71 3
      service/asign/asign.go
  8. 145 23
      service/sign/sign.go

+ 28 - 7
api/v1/account/certification.go

@@ -1,6 +1,7 @@
 package account
 
 import (
+	"errors"
 	"mtp20access/global"
 	"mtp20access/model/account/request"
 	"mtp20access/model/common/response"
@@ -117,7 +118,7 @@ func SignCompleted(c *gin.Context) {
 	}
 
 	if err := signService.SignCompleted(claims.UserID); err == nil {
-		response.OkWithMessage("操作成功", g.C)
+		response.OkWithMessage("提交成功", g.C)
 	} else {
 		global.M2A_LOG.Error(err.Error(), zap.Error(err))
 		response.FailWithMessage(err.Error(), c)
@@ -127,16 +128,36 @@ func SignCompleted(c *gin.Context) {
 // POST
 func HandleASignCompleted(c *gin.Context) {
 	g := utils.GinUtils{C: c}
-	r := request.HandleASignCompletedReq{}
-	g.BindJsonReq(&r)
-	if g.Err != nil {
+
+	action, ok := g.C.GetPostForm("action")
+	if !ok {
+		err := errors.New("[HandleASignCompleted] 获取action失败")
+		response.FailWithMessage(err.Error(), c)
+		return
+	}
+	contractNo, ok := g.C.GetPostForm("contractNo")
+	if !ok {
+		err := errors.New("[HandleASignCompleted] 获取contractNo失败")
+		response.FailWithMessage(err.Error(), c)
+		return
+	}
+	status, ok := g.C.GetPostForm("status")
+	if !ok {
+		err := errors.New("[HandleASignCompleted] 获取status失败")
+		response.FailWithMessage(err.Error(), c)
 		return
 	}
 
-	if err := signService.HandleASignCompleted(r); err == nil {
-		g.C.String(http.StatusOK, "%s", "ok")
+	if action == "signCompleted" {
+		if err := signService.HandleASignCompleted(contractNo, status); err == nil {
+			g.C.String(http.StatusOK, "%s", "ok")
+		} else {
+			global.M2A_LOG.Error(err.Error(), zap.Error(err))
+			response.FailWithMessage(err.Error(), c)
+		}
 	} else {
-		global.M2A_LOG.Error(err.Error(), zap.Error(err))
+		err := errors.New("[HandleASignCompleted] 暂不支持的action")
 		response.FailWithMessage(err.Error(), c)
 	}
+
 }

+ 1 - 1
config.j2

@@ -57,7 +57,7 @@ asign:
   appId: '{{asign_appId}}'
   privateKey: '{{asign_privateKey}}'
   notifyUrl: '{{asign_notifyUrl}}'
-
+  openApiUrl: '{{asign_openApiUrl}}'
 
 # 跨域配置
 # 需要配合 server/initialize/router.go#L32 使用

+ 1 - 0
config.yaml

@@ -57,6 +57,7 @@ asign:
   appId: '290912417'
   privateKey: 'MIIBUwIBADANBgkqhkiG9w0BAQEFAASCAT0wggE5AgEAAkEAkMD+72J6iAF0ZNV+3t628lsRHfJ80nKZWK5/C7Pg+AZmOIzJlwHsKhRzCvxoxqYHQprhiFzW9l73v9vD9l1JYwIDAQABAkBVijccr01JYdKuY5t9iI8D2NzcnZc1pZMI3NUmzT18Uyg7b9CUvGHlLeg/gdT4QtVd7wIzHYCY4letEcEMh54BAiEAwzNWusj5XiLmty7PI0Hbakx4HtcND1+P0UHLEWqWOuECIQC91zQuL7nStgGzT3HvaeBB5Ouapa39fHRm2nCjHaxwwwIgRR2XdvmUOj23XWMomr5F14SN/7V7fVcD0D8wjNElsmECIDYavV5kb7tj7/wgqkInlKhzC8rZaUsTS0F9BBkY/eptAiAQJ8Saz8YlMIESdHMxANGSog01fECbcZqLFMuNf8SorA=='
   notifyUrl: 'http://218.17.158.45:15105/api/Account/HandleASignCompleted'
+  openApiUrl: 'http://192.168.31.202:5015/mtp2-onlineopen'
 
 # 跨域配置
 # 需要配合 server/initialize/router.go#L32 使用

+ 1 - 0
config/asign.go

@@ -5,4 +5,5 @@ type Asign struct {
 	AppId      string `mapstructure:"appId" json:"appId" yaml:"appId"`                // AppId
 	PrivateKey string `mapstructure:"privateKey" json:"privateKey" yaml:"privateKey"` // 应用私钥
 	NotifyUrl  string `mapstructure:"notifyUrl" json:"notifyUrl" yaml:"notifyUrl"`    // 合同签署完成异步通知
+	OpenApiUrl string `mapstructure:"openApiUrl" json:"openApiUrl" yaml:"openApiUrl"` // JAVA开户地址
 }

+ 18 - 0
py/Api.py

@@ -101,4 +101,22 @@ def downloadContract(inputData):
     #请求地址
     Result = HttpUtils.HttpUtils.doPOST(apiUrl, reqBodyData, appId, appKey)
 
+    return Result
+
+# 查询合同状态 https://{host}/contract/status
+def contractStatus(inputData):
+    # 从输入数据中获取调用接口
+    contractNo = inputData["contractNo"]
+    
+    appId = inputData["appId"]
+    appKey = inputData["appKey"]
+    apiUrl = inputData["apiUrl"]
+
+    # 组装参数
+    reqBodyData = {
+        "contractNo": contractNo
+    }
+    #请求地址
+    Result = HttpUtils.HttpUtils.doPOST(apiUrl, reqBodyData, appId, appKey)
+
     return Result

+ 2 - 0
py/Enter.py

@@ -21,6 +21,8 @@ def main():
         result = Api.addSigner(inputData)
     elif (api == "downloadContract"):
         result = Api.downloadContract(inputData)
+    elif (api == "contractStatus"):
+        result = Api.contractStatus(inputData)
     else:
         result = ""
 

+ 71 - 3
service/asign/asign.go

@@ -112,7 +112,7 @@ import (
 // }
 
 type AsignData interface {
-	AddPersonalUserData | CreateContractData | AddSignerData | DownloadContractData
+	AddPersonalUserData | CreateContractData | AddSignerData | DownloadContractData | ContractStatusData
 }
 
 // AsignRsp 爱签响应参数
@@ -264,6 +264,10 @@ func AddPersonalUserBy(account, name, idCard, mobile string, idCardType *int) (r
 	}
 	// 结果
 	rspBody := stdoutBuf.String()
+	// 正确返回
+	// {"code":100000,"msg":"�ɹ�","data":{"id":null,"userId":null,"partnerId":null,"type":null,"sealType":null,"sealTypeOfUser":null,"sealName":null,"sealCode":null,"startTime":null,"endTime":null,"sealNo":"9a82d2da479b4430b1da6f7f7cd96aee","sealPassword":null,"sealFont":null,"version":null,"caType":null,"certNo":null,"path":null,"isDefault":null,"status":null,"color":null,"fontSize":null,"imageWidth":null,"imageHeight":null,"imageShape":null,"signTimes":null,"logicDel":null,"createTime":null,"modifyTime":null}}
+	// 错误返回
+	// {"code":100021,"msg":"�û��Ѵ��ڣ�����֤�����ظ�","data":{"id":null,"partnerId":null,"account":"100000007","companyAccount":null,"name":null,"companyName":null,"userType":null,"mobile":null,"bankCard":null,"email":null,"idCard":"360428200007287603","idCardType":null,"creditCode":null,"contactName":null,"contactPhone":null,"contactIdCard":null,"isNotice":null,"isAutoSign":null,"signPwd":null,"identifyStatus":null,"identifyMobile":null,"identifyType":null,"userStatus":null,"needSeal":null,"remark":null,"createTime":null,"modifyTime":null,"sealType":null,"authType":null,"serialNo":null}}
 	if err = json.Unmarshal([]byte(rspBody), &rspData); err != nil {
 		global.M2A_LOG.Error("[AddPersonalUserBy] 反序列化body失败", zap.Error(err))
 		return
@@ -332,6 +336,7 @@ func CreateContract(contractNo, contractName, templateNo string) (rspData AsignR
 	}
 	// 结果
 	rspBody := stdoutBuf.String()
+	// 正确返回:CreateContract 标准输出: {"code":100000,"msg":" ɹ ","data":{"pageSizeMap":{},"signUser":[],"previewUrl":"https://pre.asign.cn/m/#/mobile/previewApiContract/QhUqHj669cOmXIPrJ7eOhSfWh6_oDGlmQ53lOD5OVAvJRvTVpenYICiMWnvbCi4swvNWUIVuO1zPsTvIvHPGuE1fTZ-AQyCeUyWWu7f56Jg?expired=10800000","contractFiles":[]}}
 	if err = json.Unmarshal([]byte(rspBody), &rspData); err != nil {
 		global.M2A_LOG.Error("[CreateContract] 反序列化body失败", zap.Error(err))
 		return
@@ -376,7 +381,9 @@ func AddSigner(contractNo, account string) (rspData AsignRsp[AddSignerData], err
 	reqData["account"] = account
 	reqData["signType"] = 3
 	reqData["signStrategyList"] = []map[string]interface{}{
-		{"attachNo": 1, "locationMode": 4, "signKey": "key1"}}
+		{"attachNo": 1, "locationMode": 4, "signKey": "key_sign_name"},
+		{"attachNo": 1, "locationMode": 4, "signKey": "key_sign_date"},
+	}
 
 	reqData["api"] = "addSigner"
 	reqData["appId"] = global.M2A_CONFIG.Asign.AppId
@@ -409,6 +416,8 @@ func AddSigner(contractNo, account string) (rspData AsignRsp[AddSignerData], err
 		return
 	}
 	// 结果
+	// 正确返回:AddSigner 标准输出: {"code":100000,"msg":"�ɹ�","data":{"contractNo":"100000008_20230815145538_10","pageSizeMap":{},"contractName":"���ݲ�Ҷ������ʾ�飨10.31���հ棩","signOrder":1,"validityTime":"2023-09-14","signUser":[{"account":"100000008","signUrl":"https://h5.asign.cn/web/short/eE7zmq515512","signOrder":1,"name":"����̼��","idCard":"110101200007285605","mobile":"15914012153"}],"previewUrl":"https://pre.asign.cn/m/#/mobile/previewApiContract/QhUqHj669cOmXIPrJ7eOhSfWh6_oDGlmQ53lOD5OVAvJRvTVpenYICiMWnvbCi4sS_knh8JQ124Lwf_uxqXkF0-n1uuC18qLy5B8TfAF88g?expired=10800000","contractFiles":[]}}
+	// 错误返回:AddSigner 标准输出: {"code":100617,"msg":"ģ  IJ       [key_sign_name]      ","data":null}
 	rspBody := stdoutBuf.String()
 	if err = json.Unmarshal([]byte(rspBody), &rspData); err != nil {
 		global.M2A_LOG.Error("[AddSigner] 反序列化body失败", zap.Error(err))
@@ -418,7 +427,7 @@ func AddSigner(contractNo, account string) (rspData AsignRsp[AddSignerData], err
 	return
 }
 
-// 添加签署方响应数据
+// 下载合同响应数据
 type DownloadContractData struct {
 	FileName string `json:"fileName"` // 文件名
 	MD5      string `json:"md5"`      // 文件md5值
@@ -478,3 +487,62 @@ func DownloadContract(contractNo string) (rspData AsignRsp[DownloadContractData]
 
 	return
 }
+
+// 查询合同状态响应数据
+type ContractStatusData struct {
+	ContractNo   string `json:"contractNo"`   // 合同唯一编号
+	ContractName string `json:"contractName"` // 合同名称
+	Status       int    `json:"status"`       // 合同状态:0:等待签约 1:签约中 2:已签约 3:过期 4:拒签 6:作废 -2:状态异常
+}
+
+/*
+ContractStatus 查询合同状态
+
+contractNo 合同ID,合同唯一编号
+*/
+func ContractStatus(contractNo string) (rspData AsignRsp[ContractStatusData], err error) {
+	apiUrl := global.M2A_CONFIG.Asign.URL + "contract/status"
+
+	// 构建请求数据结构
+	reqData := make(map[string]interface{})
+	reqData["contractNo"] = contractNo
+
+	reqData["api"] = "contractStatus"
+	reqData["appId"] = global.M2A_CONFIG.Asign.AppId
+	reqData["appKey"] = global.M2A_CONFIG.Asign.PrivateKey
+	reqData["apiUrl"] = apiUrl
+
+	// 将请求数据转换为JSON字符串
+	reqJSON, err := json.Marshal(reqData)
+	if err != nil {
+		global.M2A_LOG.Error("[ContractStatus] 构建请求参数失败", zap.Error(err))
+		return
+	}
+	// 要执行的Python脚本命令
+	pythonScriptPath := "./py/Enter.py"
+	// 创建一个命令对象
+	cmd := exec.Command("py", pythonScriptPath)
+	// 设置标准输入为JSON字符串
+	cmd.Stdin = strings.NewReader(string(reqJSON))
+	// 创建一个字节缓冲区来捕获命令的输出
+	var stdoutBuf, stderrBuf bytes.Buffer
+	cmd.Stdout = &stdoutBuf
+	cmd.Stderr = &stderrBuf
+	// 执行命令
+	err = cmd.Run()
+	// 输出标准输出和标准错误
+	fmt.Println("ContractStatus 标准输出:", stdoutBuf.String())
+	fmt.Println("ContractStatus 标准错误:", stderrBuf.String())
+	if err != nil {
+		global.M2A_LOG.Error("[ContractStatus] 请求失败", zap.Error(err))
+		return
+	}
+	// 结果
+	rspBody := stdoutBuf.String()
+	if err = json.Unmarshal([]byte(rspBody), &rspData); err != nil {
+		global.M2A_LOG.Error("[DownloadContract] 反序列化body失败", zap.Error(err))
+		return
+	}
+
+	return
+}

+ 145 - 23
service/sign/sign.go

@@ -1,14 +1,18 @@
 package sign
 
 import (
+	"bytes"
 	"encoding/json"
 	"errors"
 	"fmt"
+	"io"
 	"mtp20access/global"
 	"mtp20access/model/account"
 	"mtp20access/model/account/request"
 	"mtp20access/model/account/response"
 	"mtp20access/service/asign"
+	"mtp20access/utils"
+	"net/http"
 	"os"
 	"strconv"
 	"time"
@@ -140,7 +144,8 @@ func CreateContractAndAddSigner(req request.CreateContractAndAddSignerReq, userI
 			// 将返回的合同编号写入数据库
 			sql := fmt.Sprintf(`
 				UPDATE useresignrecord 
-				SET SIGNURL = '%v', 
+				SET RECORDSTATUS = 2, 
+					SIGNURL = '%v', 
 					UPDATETIME = SYSDATE
 				WHERE RECORDID = %v
 			`, useresignrecord.SIGNURL, useresignrecord.RECORDID)
@@ -165,13 +170,135 @@ func SignCompleted(userId int) (err error) {
 		global.M2A_LOG.Error("SignCompleted 获取用户电子签记录失败", zap.Error(err))
 		return
 	}
-	for _, item := range datas {
-		if item.RECORDSTATUS != 3 {
+
+	// mgk
+	var record *account.Useresignrecord
+	for i, item := range datas {
+		if item.TEMPLATETYPE == 1 {
+			record = &datas[i]
+		}
+		// 如果是签署中状态,则查询一下合同状态
+		if item.RECORDSTATUS == 2 {
+			rspCTStatus, e := asign.ContractStatus(item.CONTRACTNO)
+			if e != nil {
+				err = e
+				global.M2A_LOG.Error("[SignCompleted] 查询合同状态失败", zap.Error(err))
+				return
+			}
+			if rspCTStatus.Data.Status == 2 {
+				// 已签约
+				// 下载合同
+				r, e := asign.DownloadContract(item.CONTRACTNO)
+				if e != nil {
+					err = e
+					return
+				}
+				if r.Code != 100000 {
+					err = errors.New(strconv.Itoa(r.Code))
+					global.M2A_LOG.Error("[SignCompleted] 下载合同接口调用失败", zap.Error(err))
+					return
+				}
+				if r.Data.Data != "" {
+					// 获取网上开户地址(用于客户端下载文件)
+					openconfig := account.Wskhopenaccountconfig{CONFIGID: 6}
+					has, e := openconfig.Get()
+					if e != nil || !has {
+						err = e
+						global.M2A_LOG.Error("[SignCompleted] 获取网上开户地址失败", zap.Error(err))
+						return
+					}
+					// 将Base64写入目标文件
+					uid, _ := uuid.NewV4()
+					fileName := fmt.Sprintf("%v.pdf", uid.String())
+					// openconfig.CONFIGVALUE = "./" // FIXME: - 测试代码
+					folderPath := "sign/" + time.Now().Format("20060102")
+					savePath := openconfig.CONFIGVALUE + "/uploadFile/" + folderPath
+					if exist, _ := utils.PathExists(savePath); !exist {
+						os.MkdirAll(savePath, os.ModePerm)
+					}
+					f, e := os.OpenFile(savePath+"/"+fileName, os.O_RDWR|os.O_CREATE, os.ModePerm)
+					if e != nil {
+						err = e
+						global.M2A_LOG.Error("【HandleASignCompleted】 获取网上开户地址失败", zap.Error(err))
+						return
+					}
+					defer f.Close()
+
+					// 更新数据库记录
+					contractfileaddr := fmt.Sprintf("./uploadFile/%v/%v", folderPath, fileName)
+					sql := fmt.Sprintf(`
+						UPDATE useresignrecord
+						SET RECORDSTATUS = 3,
+							UPDATETIME = SYSDATE,
+							CONTRACTFILEADDR = '%v'
+						WHERE CONTRACTNO = '%v'  
+					`, contractfileaddr, item.CONTRACTNO)
+					if _, err = global.M2A_DB.Exec(sql); err != nil {
+						global.M2A_LOG.Error("【HandleASignCompleted】 更新用户电子签记录失败", zap.Error(err))
+						return
+					}
+				}
+			}
+		} else if item.RECORDSTATUS != 3 && item.RECORDSTATUS != 2 {
 			err = errors.New("未完成所有合同签署")
+			global.M2A_LOG.Error(err.Error())
 			return
 		}
 	}
 
+	// 获取临时存储的用户信息
+	if record == nil || record.AUTHINFO == "" {
+		global.M2A_LOG.Error("[SignCompleted] 获取实名认证信息失败", zap.Error(err))
+		return
+	}
+	// {"name":"甘肃碳交","idCard":"360428200007287603","idCardType":1,"idCardPhoto":"./uploadFile/20230812/202308121518494929.png","idCardPhotoBackURL":"./uploadFile/20230812/202308121518529223.png","mobile":"15914012151"}
+	cacheMap := make(map[string]interface{})
+	err = json.Unmarshal([]byte(record.AUTHINFO), &cacheMap)
+	if err != nil {
+		global.M2A_LOG.Error("[SignCompleted] 反序列化临时存储用户信息失败", zap.Error(err))
+		return
+	}
+
+	// 调用JAVA实名认证接口
+	reqParam := make(map[string]interface{})
+	reqParam["userid"] = userId
+	reqParam["cardnum"] = cacheMap["idCard"]
+	reqParam["username"] = cacheMap["name"]
+	reqParam["cardtype"] = 0 // 目前写死证件类型为身份证 - 0
+	reqParam["cardfrontphotourl"] = cacheMap["idCardPhoto"]
+	reqParam["cardbackphotourl"] = cacheMap["idCardPhotoBackURL"]
+	reqParam["userinfotype"] = 1 // 目前写死为个人 - 1
+	jsonParam, err := json.Marshal(&reqParam)
+	if err != nil {
+		global.M2A_LOG.Error("[SignCompleted] 反序列化JAVA实名认证入参失败", zap.Error(err))
+		return
+	}
+
+	// 构建请求
+	javaUrl := global.M2A_CONFIG.Asign.OpenApiUrl + "/onlineopen/userInfo/addAuth"
+	req, err := http.NewRequest("POST", javaUrl, bytes.NewReader(jsonParam))
+	// 设置请求头
+	req.Header.Set("Content-Type", "application/json; charset=utf-8")
+
+	client := &http.Client{}
+	rsp, err := client.Do(req)
+	if err != nil {
+		global.M2A_LOG.Error("[SignCompleted] 请求失败", zap.Error(err))
+		return
+	}
+	defer rsp.Body.Close()
+	body, err := io.ReadAll(rsp.Body)
+	if err != nil {
+		global.M2A_LOG.Error("[SignCompleted] 获取body失败", zap.Error(err))
+		return
+	}
+	rspData := make(map[string]interface{})
+	if err = json.Unmarshal(body, &rspData); err != nil {
+		global.M2A_LOG.Error("[SignCompleted] 反序列化java body失败", zap.Error(err))
+		return
+	}
+	fmt.Println("rspData:", rspData)
+
 	return
 }
 
@@ -180,7 +307,7 @@ handleASignCompleted 处理爱签合同签署完成后回调通知
 
 req 异步推送参数
 */
-func HandleASignCompleted(req request.HandleASignCompletedReq) (err error) {
+func HandleASignCompleted(contractNo, status string) (err error) {
 	/*
 		// 合同签署完成后回调通知示例
 		String publickey = "MFwwDQcccccxxxxmEz/nw27Ln6AP90ZCMPi+iNF1m9mhNECAwEAAQ==";
@@ -204,19 +331,19 @@ func HandleASignCompleted(req request.HandleASignCompletedReq) (err error) {
 	*/
 
 	// 获取合同编号
-	if req.ContractNo == "" {
-		global.M2A_LOG.Error("【HandleASignCompleted】 获取合同编号失败", zap.Any("req", req))
+	if contractNo == "" {
+		global.M2A_LOG.Error("【HandleASignCompleted】 获取合同编号失败")
 		return
 	}
 	// 获取合同状态
-	if req.Status == "" {
-		global.M2A_LOG.Error("【HandleASignCompleted】 获取获取合同状态失败", zap.Any("req", req))
+	if status == "" {
+		global.M2A_LOG.Error("【HandleASignCompleted】 获取获取合同状态失败")
 		return
 	}
-	if req.Status == "2" {
+	if status == "2" {
 		// 已签约
 		// 下载合同
-		r, e := asign.DownloadContract(req.ContractNo)
+		r, e := asign.DownloadContract(contractNo)
 		if e != nil {
 			err = e
 			return
@@ -237,11 +364,13 @@ func HandleASignCompleted(req request.HandleASignCompletedReq) (err error) {
 			}
 			// 将Base64写入目标文件
 			uid, _ := uuid.NewV4()
-			fileName := fmt.Sprintf("%v_%v.pdf", r.Data.FileName, uid.String())
-			openconfig.CONFIGVALUE = "./" // FIXME: - 测试代码
+			fileName := fmt.Sprintf("%v.pdf", uid.String())
+			// openconfig.CONFIGVALUE = "./" // FIXME: - 测试代码
 			folderPath := "sign/" + time.Now().Format("20060102")
 			savePath := openconfig.CONFIGVALUE + "/uploadFile/" + folderPath
-			fmt.Println(savePath + "/" + fileName)
+			if exist, _ := utils.PathExists(savePath); !exist {
+				os.MkdirAll(savePath, os.ModePerm)
+			}
 			f, e := os.OpenFile(savePath+"/"+fileName, os.O_RDWR|os.O_CREATE, os.ModePerm)
 			if e != nil {
 				err = e
@@ -249,23 +378,16 @@ func HandleASignCompleted(req request.HandleASignCompletedReq) (err error) {
 				return
 			}
 			defer f.Close()
+
 			// 更新数据库记录
-			// 获取用户电子签记录
-			// useresignrecord := new(account.Useresignrecord)
-			// has, e = global.M2A_DB.Where("CONTRACTNO = ?", req.ContractNo).Get(useresignrecord)
-			// if e != nil || !has {
-			// 	err = e
-			// 	global.M2A_LOG.Error("【HandleASignCompleted】 获取用户电子签记录失败", zap.Error(err))
-			// 	return
-			// }
 			contractfileaddr := fmt.Sprintf("./uploadFile/%v/%v", folderPath, fileName)
 			sql := fmt.Sprintf(`
 				UPDATE useresignrecord
 				SET RECORDSTATUS = 3,
 					UPDATETIME = SYSDATE,
 					CONTRACTFILEADDR = '%v'
-				WHERE CONTRACTNO = %v  
-			`, contractfileaddr, req.ContractNo)
+				WHERE CONTRACTNO = '%v'  
+			`, contractfileaddr, contractNo)
 			if _, err = global.M2A_DB.Exec(sql); err != nil {
 				global.M2A_LOG.Error("【HandleASignCompleted】 更新用户电子签记录失败", zap.Error(err))
 				return