|
|
@@ -366,19 +366,6 @@ func CreateContract(req CreateContractReq) (rsp CreateContractRsp, err error) {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- // // 获取电子签模板字段配置信息
|
|
|
- // fields := make([]models.Esigntemplatefield, 0)
|
|
|
- // if err = db.GetEngine().Where("TEMPLATECONFIGID = ?", record.TEMPLATECONFIGID).Find(&fields); err != nil {
|
|
|
- // logger.GetLogger().Error("获取电子签模板字段配置信息失败, err", err)
|
|
|
- // err = errors.New("获取电子签模板字段配置信息失败")
|
|
|
- // return
|
|
|
- // }
|
|
|
- // if len(fields) == 0 {
|
|
|
- // err = errors.New("获取电子签模板字段配置信息异常")
|
|
|
- // logger.GetLogger().Error("获取电子签模板字段配置信息异常, templateconfigid:", record.TEMPLATECONFIGID)
|
|
|
- // return
|
|
|
- // }
|
|
|
-
|
|
|
// 调用爱签接口 - 查询模板列表
|
|
|
apiReq := APITemplateListReq{Page: 1, Rows: 10}
|
|
|
apiRsp, err := APITemplateList(apiReq)
|
|
|
@@ -470,14 +457,26 @@ func CreateContract(req CreateContractReq) (rsp CreateContractRsp, err error) {
|
|
|
}
|
|
|
|
|
|
// 添加签署方 - 甲方 - 交易所
|
|
|
+ // appAddSignerReq1 := APIAddSignerReq{
|
|
|
+ // ContractNo: contractNo,
|
|
|
+ // Account: "ZR_LEGAL",
|
|
|
+ // SignType: 2, // 无感知签约(需要开通权限)
|
|
|
+ // SignStrategyList: []APISignStrategy{
|
|
|
+ // {AttachNo: 1, LocationMode: 4, SignKey: "PARTYA_SIGNATURE", SignType: 1}, // 甲方签章
|
|
|
+ // {AttachNo: 1, LocationMode: 4, SignKey: "PARTYA_DATE", SignType: 2}, // 甲方签署时间
|
|
|
+ // },
|
|
|
+ // }
|
|
|
appAddSignerReq1 := APIAddSignerReq{
|
|
|
ContractNo: contractNo,
|
|
|
- Account: "ZR_LEGAL",
|
|
|
+ Account: "EX_LEGAL",
|
|
|
SignType: 2, // 无感知签约(需要开通权限)
|
|
|
- SignStrategyList: []APISignStrategy{
|
|
|
- {AttachNo: 1, LocationMode: 4, SignKey: "PARTYA_SIGNATURE", SignType: 1}, // 甲方签章
|
|
|
- {AttachNo: 1, LocationMode: 4, SignKey: "PARTYA_DATE", SignType: 2}, // 甲方签署时间
|
|
|
- },
|
|
|
+ }
|
|
|
+ signStrategyListPartyA, err := buildStrategyByPartyA(int(record.TEMPLATECONFIGID))
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if len(signStrategyListPartyA) > 0 {
|
|
|
+ appAddSignerReq1.SignStrategyList = signStrategyListPartyA
|
|
|
}
|
|
|
|
|
|
// 获取临时存储的用户认证信息
|
|
|
@@ -499,31 +498,40 @@ func CreateContract(req CreateContractReq) (rsp CreateContractRsp, err error) {
|
|
|
SignType: 3,
|
|
|
ValidateType: 3,
|
|
|
}
|
|
|
- // 签章策略
|
|
|
- signStrategyList := make([]APISignStrategy, 0)
|
|
|
- // 接收方模板填充策略
|
|
|
- receiverFillStrategyList := make([]APIReceiverFillStrategy, 0)
|
|
|
- if userInfo.Userinfotype == 1 { // 个人
|
|
|
- // 乙方签章
|
|
|
- signStrategyList = append(signStrategyList, APISignStrategy{AttachNo: 1, LocationMode: 4, SignKey: "P_PARTYB_SIGNATURE", SignType: 1})
|
|
|
- // 乙方签署时间
|
|
|
- signStrategyList = append(signStrategyList, APISignStrategy{AttachNo: 1, LocationMode: 4, SignKey: "P_PARTYB_DATE", SignType: 2})
|
|
|
-
|
|
|
- // 身份证号
|
|
|
- receiverFillStrategyList = append(receiverFillStrategyList, APIReceiverFillStrategy{AttachNo: 1, Key: "P_PARTYB_ID", Value: cacheMap["idCardNo"].(string)})
|
|
|
- // 联系方式
|
|
|
- receiverFillStrategyList = append(receiverFillStrategyList, APIReceiverFillStrategy{AttachNo: 1, Key: "P_PARTYB_MOBILE", Value: cacheMap["mobile"].(string)})
|
|
|
- } else { // 企业
|
|
|
- // 乙方签章
|
|
|
- signStrategyList = append(signStrategyList, APISignStrategy{AttachNo: 1, LocationMode: 4, SignKey: "E_PARTYB_SIGNATURE", SignType: 1})
|
|
|
- // 乙方签署时间
|
|
|
- signStrategyList = append(signStrategyList, APISignStrategy{AttachNo: 1, LocationMode: 4, SignKey: "E_PARTYB_DATE", SignType: 2})
|
|
|
-
|
|
|
- // 法定代表人名称
|
|
|
- receiverFillStrategyList = append(receiverFillStrategyList, APIReceiverFillStrategy{AttachNo: 1, Key: "E_PARTYB_LEGAL", Value: cacheMap["realName"].(string)})
|
|
|
+ // // 签章策略
|
|
|
+ // signStrategyList := make([]APISignStrategy, 0)
|
|
|
+ // // 接收方模板填充策略
|
|
|
+ // receiverFillStrategyList := make([]APIReceiverFillStrategy, 0)
|
|
|
+ // if userInfo.Userinfotype == 1 { // 个人
|
|
|
+ // // 乙方签章
|
|
|
+ // signStrategyList = append(signStrategyList, APISignStrategy{AttachNo: 1, LocationMode: 4, SignKey: "P_PARTYB_SIGNATURE", SignType: 1})
|
|
|
+ // // 乙方签署时间
|
|
|
+ // signStrategyList = append(signStrategyList, APISignStrategy{AttachNo: 1, LocationMode: 4, SignKey: "P_PARTYB_DATE", SignType: 2})
|
|
|
+ // // 身份证号
|
|
|
+ // receiverFillStrategyList = append(receiverFillStrategyList, APIReceiverFillStrategy{AttachNo: 1, Key: "P_PARTYB_ID", Value: cacheMap["idCardNo"].(string)})
|
|
|
+ // // 联系方式
|
|
|
+ // receiverFillStrategyList = append(receiverFillStrategyList, APIReceiverFillStrategy{AttachNo: 1, Key: "P_PARTYB_MOBILE", Value: cacheMap["mobile"].(string)})
|
|
|
+ // } else { // 企业
|
|
|
+ // // 乙方签章
|
|
|
+ // signStrategyList = append(signStrategyList, APISignStrategy{AttachNo: 1, LocationMode: 4, SignKey: "E_PARTYB_SIGNATURE", SignType: 1})
|
|
|
+ // // 乙方签署时间
|
|
|
+ // signStrategyList = append(signStrategyList, APISignStrategy{AttachNo: 1, LocationMode: 4, SignKey: "E_PARTYB_DATE", SignType: 2})
|
|
|
+
|
|
|
+ // // 法定代表人名称
|
|
|
+ // receiverFillStrategyList = append(receiverFillStrategyList, APIReceiverFillStrategy{AttachNo: 1, Key: "E_PARTYB_LEGAL", Value: cacheMap["realName"].(string)})
|
|
|
+ // }
|
|
|
+ // appAddSignerReq2.SignStrategyList = signStrategyList
|
|
|
+ // appAddSignerReq2.ReceiverFillStrategyList = receiverFillStrategyList
|
|
|
+ signStrategyList, receiverFillStrategyList, err := buildStrategyByPartyB(int(record.TEMPLATECONFIGID), int(userInfo.Userinfotype), cacheMap)
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if len(signStrategyList) > 0 {
|
|
|
+ appAddSignerReq2.SignStrategyList = signStrategyList
|
|
|
+ }
|
|
|
+ if len(receiverFillStrategyList) > 0 {
|
|
|
+ appAddSignerReq2.ReceiverFillStrategyList = receiverFillStrategyList
|
|
|
}
|
|
|
- appAddSignerReq2.SignStrategyList = signStrategyList
|
|
|
- appAddSignerReq2.ReceiverFillStrategyList = receiverFillStrategyList
|
|
|
apiAddSignerRsp, err := APIAddSigner([]APIAddSignerReq{appAddSignerReq1, appAddSignerReq2})
|
|
|
if err != nil {
|
|
|
return
|
|
|
@@ -557,6 +565,70 @@ func CreateContract(req CreateContractReq) (rsp CreateContractRsp, err error) {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
+// 构建甲方签章策略
|
|
|
+func buildStrategyByPartyA(templateConfigId int) (signStrategyList []APISignStrategy, err error) {
|
|
|
+ signStrategyList = make([]APISignStrategy, 0)
|
|
|
+
|
|
|
+ // 获取电子签模板字段配置
|
|
|
+ fields := make([]models.Esigntemplatefield, 0)
|
|
|
+ if err = db.GetEngine().Where("TEMPLATECONFIGID = ?", templateConfigId).Find(&fields); err != nil {
|
|
|
+ logger.GetLogger().Error("获取电子签模板字段配置失败, err", err)
|
|
|
+ err = errors.New("获取电子签模板字段配置失败")
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if len(fields) == 0 {
|
|
|
+ err = errors.New("获取电子签模板字段配置信息异常")
|
|
|
+ logger.GetLogger().Error("获取电子签模板字段配置异常, templateconfigid:", templateConfigId)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ for _, item := range fields {
|
|
|
+ switch item.FIELDKEY {
|
|
|
+ case "PARTYA_SIGNATURE": // 甲方签章(企业印章)
|
|
|
+ signStrategyList = append(signStrategyList, APISignStrategy{AttachNo: 1, LocationMode: 4, SignKey: "PARTYA_SIGNATURE", SignType: 1})
|
|
|
+ case "PARTYA_DATE": // 甲方签署时间
|
|
|
+ signStrategyList = append(signStrategyList, APISignStrategy{AttachNo: 1, LocationMode: 4, SignKey: "PARTYA_DATE", SignType: 2})
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
+// cacheMap {"realName":"邓志明","idCardNo":"430426198507087670","bankCard":"6221885840097492396","mobile":"18033442829","idCardPhoto":"./uploadFile/20231227/202312271427518530.jpg","idCardPhotoBackURL":"./uploadFile/20231227/202312271427544764.jpg","bankId":"403100000004"}
|
|
|
+// 构建乙方签章策略和模板填充策略
|
|
|
+func buildStrategyByPartyB(templateConfigId int, fieldUserType int, cacheMap map[string]interface{}) (signStrategyList []APISignStrategy, receiverFillStrategyList []APIReceiverFillStrategy, err error) {
|
|
|
+ signStrategyList = make([]APISignStrategy, 0)
|
|
|
+ receiverFillStrategyList = make([]APIReceiverFillStrategy, 0)
|
|
|
+
|
|
|
+ // 获取电子签模板字段配置
|
|
|
+ fields := make([]models.Esigntemplatefield, 0)
|
|
|
+ if err = db.GetEngine().Where("TEMPLATECONFIGID = ? AND FIELDUSERTYPE = ?", templateConfigId, fieldUserType).Find(&fields); err != nil {
|
|
|
+ logger.GetLogger().Error("获取电子签模板字段配置失败, err", err)
|
|
|
+ err = errors.New("获取电子签模板字段配置失败")
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if len(fields) == 0 {
|
|
|
+ err = errors.New("获取电子签模板字段配置信息异常")
|
|
|
+ logger.GetLogger().Error("获取电子签模板字段配置异常, templateconfigid:", templateConfigId)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ for _, item := range fields {
|
|
|
+ switch item.FIELDKEY {
|
|
|
+ case "P_PARTYB_NAME": // 乙方名称
|
|
|
+ receiverFillStrategyList = append(receiverFillStrategyList, APIReceiverFillStrategy{AttachNo: 1, Key: "P_PARTYB_NAME", Value: cacheMap["realName"].(string)})
|
|
|
+ case "P_PARTYB_ID": // 乙方证件号码
|
|
|
+ receiverFillStrategyList = append(receiverFillStrategyList, APIReceiverFillStrategy{AttachNo: 1, Key: "P_PARTYB_ID", Value: cacheMap["idCardNo"].(string)})
|
|
|
+ case "P_PARTYB_SIGNATURE": // 乙方签章(个人)
|
|
|
+ signStrategyList = append(signStrategyList, APISignStrategy{AttachNo: 1, LocationMode: 4, SignKey: "P_PARTYB_SIGNATURE", SignType: 1})
|
|
|
+ case "P_PARTYB_DATE": // 乙方签署时间
|
|
|
+ signStrategyList = append(signStrategyList, APISignStrategy{AttachNo: 1, LocationMode: 4, SignKey: "P_PARTYB_DATE", SignType: 2})
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
func ASignCompleted(contractNo, status string) (err error) {
|
|
|
/*
|
|
|
// 合同签署完成后回调通知示例
|