zhou.xiaoning před 2 roky
rodič
revize
138bdf2370
1 změnil soubory, kde provedl 10 přidání a 30 odebrání
  1. 10 30
      service/sign/sign.go

+ 10 - 30
service/sign/sign.go

@@ -31,8 +31,15 @@ func QueryUserESignRecord(userId int) (rsp []account.Useresignrecord, err error)
 	for i := range rsp {
 		data := &rsp[i]
 		if data.TEMPLATETYPE == 2 && data.RECORDSTATUS == 2 {
+			// 去爱签同步合同状态
+			rspCTStatus, e := asign.ContractStatus(data.CONTRACTNO)
+			if e != nil {
+				err = e
+				global.M2A_LOG.Error("[SignCompleted] 查询合同状态失败", zap.Error(err))
+				return
+			}
 			// 下载合同并修改合同状态
-			e := modifyContractStatus(data.CONTRACTNO, strconv.Itoa(int(data.RECORDSTATUS)))
+			e = modifyContractStatus(data.CONTRACTNO, strconv.Itoa(rspCTStatus.Data.Status))
 			if e != nil {
 				// 从新获取记录
 				data = new(account.Useresignrecord)
@@ -279,7 +286,7 @@ func SignCompleted(userId int) (err error) {
 		global.M2A_LOG.Error("[SignCompleted] 反序列化java body失败", zap.Error(err))
 		return
 	}
-	fmt.Println("rspData:", rspData)
+	global.M2A_LOG.Info("[SignCompleted] 调用JAVA实名认证接口返回", zap.Any("rspData", rspData))
 	code, ok := rspData["code"]
 	if !ok {
 		err = errors.New("实名认证失败,请稍后重试")
@@ -339,6 +346,7 @@ func HandleASignCompleted(contractNo, status string) (err error) {
 }
 
 // modifyContractStatus 爱签异步推送和查询合同状态后调用
+// 注意传入的status是爱签的合同状态
 // 合同状态:
 // 0:等待签约
 // 1:签约中
@@ -518,31 +526,3 @@ func HandleWillFace(sign, result, msg, recordId string) (err error) {
 
 	return
 }
-
-// GetUserESignRecord 获取电子签记录,如果是合同类型并状态为2,则会去爱签同步合同状态和下载合同
-func GetUserESignRecord(req request.GetUserESignRecordReq, userId int) (data *account.Useresignrecord, err error) {
-	// 获取用户电子签记录
-	data = new(account.Useresignrecord)
-	has, e := global.M2A_DB.Where("RECORDID = ? AND USERID = ?", req.Recordid, userId).Get(data)
-	if e != nil || !has {
-		err = e
-		global.M2A_LOG.Error("【HandleWillFace】 获取用户电子签记录失败", zap.Error(err))
-		return
-	}
-	if data.TEMPLATETYPE == 2 && data.RECORDSTATUS == 2 {
-		// 下载合同并修改合同状态
-		e := modifyContractStatus(data.CONTRACTNO, strconv.Itoa(int(data.RECORDSTATUS)))
-		if e != nil {
-			// 从新获取记录
-			data = new(account.Useresignrecord)
-			has, e := global.M2A_DB.Where("RECORDID = ? AND USERID = ?", req.Recordid, userId).Get(data)
-			if e != nil || !has {
-				err = e
-				global.M2A_LOG.Error("【HandleWillFace】 获取用户电子签记录失败", zap.Error(err))
-				return
-			}
-		}
-	}
-
-	return
-}