Explorar o código

海南丹农电子签配置

zhou.xiaoning hai 1 ano
pai
achega
3f61006292

+ 11 - 11
config/config.xml

@@ -13,11 +13,11 @@
     <DbAddress value="192.168.31.88"/>
     <DbName value="orcl"/>
     <DbPort value="1521"/>
-    <DbUser value="mtp2_test204"/>
+    <DbUser value="mtp2_test175"/>
     <DbPwd value="muchinfo"/>
   </DbSetting>
   <RedisSetting>
-    <Address value="192.168.31.204"/>
+    <Address value="192.168.31.175"/>
     <Port value="5007"/>
     <Timeout value="3"/>
     <ConnNum value="1"/>
@@ -25,11 +25,11 @@
     <Pwd value=""/>
   </RedisSetting>
   <MqSetting>
-    <Url value="amqp://guest:guest@192.168.31.204:5020/test"/>
+    <Url value="amqp://guest:guest@192.168.31.175:5020/test"/>
     <Exchange value="entry"/>
   </MqSetting>
   <MongoDBSetting>
-    <HostName value="192.168.31.204"/>
+    <HostName value="192.168.31.175"/>
     <Port value="5025"/>
     <DBName value="HistoryQuote"/>
     <Username value="quote_test01"/>
@@ -38,8 +38,8 @@
   <MySQLSetting>
     <Host value="192.168.30.72"/>
     <Port value="3306"/>
-    <DBName value="historyquote_test204"/>
-    <Username value="quote_test204"/>
+    <DBName value="historyquote_test175"/>
+    <Username value="quote_test175"/>
     <Password value="123456"/>
   </MySQLSetting>
   <Tencent>
@@ -47,12 +47,12 @@
     <SecretId value="AKyDwiyUUckpkct4igUy8lsS7SEqR6c7yR"/>
     <SecretKey value="SKwvG74cbV3OrAiJdjU5k4507vZwNYDbwT"/>
     <EndPoint value="essbasic.test.ess.tencent.cn"/>
-    <AppId value="yDwiuUUckpogfoa4UxhigrYChFMdSJQV"/>
-    <ProxyOrganizationName value="天津麦顿"/>
+    <AppId value="yDCN4UUckpvjuxkjUyOsCbrEv39yN90u"/>
+    <ProxyOrganizationName value="南海国际"/>
     <ProxyOrganizationOpenId value="TJMD"/>
-    <ProxyOperatorOpenId value="TJMD01"/>
-    <SignToken value="D586D270A51448179277A11729F37D3E"/>
-    <SignKey value="8774F484EA294C1E829EA6E2D7F99123"/>
+    <ProxyOperatorOpenId value="NHGJ_LEGAL"/>
+    <SignToken value="2184A0E978CF4AD28854DAC47FF81CB8"/>
+    <SignKey value="E7C6EA231F454BF1A5CF8C223D45C422"/>
   </Tencent>
   <Asign>
     <Url value="https://oapi.asign.cn"/>

+ 19 - 2
config/readme.md

@@ -1,11 +1,13 @@
 # GO查询服务
 
 ## 腾讯电子签配置说明
-
+腾讯电子签注册认证-入口:https://qian.tencent.com/console/company-register
+开发文档:https://qian.tencent.com/developers/company/overview
 Enabled="1" 表示启用腾讯电子签功能,如不需要则改为"0"
-SecretId 和 SecretKey 是腾讯电子签密钥信息,使用公司账号登录 https://qian.tencent.com/console/ 获取 (测试环境:https://beta.qian.tencent.cn/console/)
+SecretId 和 SecretKey 是腾讯电子签密钥信息,使用公司账号登录(SaaS控制台) https://qian.tencent.com/console/ 获取 (微信扫码登录 测试环境:https://beta.qian.tencent.cn/console/)
 EndPoint 腾讯电子签API接入地址,测试环境填 "essbasic.test.ess.tencent.cn" ,生产环境填 "essbasic.tencentcloudapi.com"
 AppId 子客第三方应用ID,使用公司账号登录 https://qian.tencent.com/console/ 设置和获取
+创建子客通过我方接口来完成:Tencent/CreateConsoleLoginUrl (实盘环境初始化时要求使用公司法人微信扫码登录,并要求法人在控制台网站添加企业电子印章和法人章(法人章非必要)) 
 ProxyOrganizationName 子客企业名称,生产环境应填写子客企业全名
 ProxyOrganizationOpenId 子客企业ID,与子客企业名称一一对应,由我方设置
 ProxyOperatorOpenId 子客企业管理员ID,生产环境应要求客户使用对方身份进行认证,TJMD_ADMIN TJMD_LEGAL
@@ -42,6 +44,21 @@ SignKey 腾讯电子签密回调通知密钥,用于解密,使用公司账号
   <SignKey value="34FD7C4496794788B569E84729601276"/>
 </Tencent>
 ```
+南海国际(海南丹农)测试环境:
+```xml
+<Tencent>
+  <Enabled value="1"/>
+  <SecretId value="AKyDwiyUUckpkct4igUy8lsS7SEqR6c7yR"/>
+  <SecretKey value="SKwvG74cbV3OrAiJdjU5k4507vZwNYDbwT"/>
+  <EndPoint value="essbasic.test.ess.tencent.cn"/>
+  <AppId value="yDCN4UUckpvjuxkjUyOsCbrEv39yN90u"/>
+  <ProxyOrganizationName value="南海国际"/>
+  <ProxyOrganizationOpenId value="TJMD"/>
+  <ProxyOperatorOpenId value="NHGJ_LEGAL"/>
+  <SignToken value="2184A0E978CF4AD28854DAC47FF81CB8"/>
+  <SignKey value="E7C6EA231F454BF1A5CF8C223D45C422"/>
+</Tencent>
+```
 ## 爱签配置说明
 爱签官网:https://www.asign.cn
 接入助手:https://web.asign.cn/platform/tools/helper

+ 2 - 25
controllers/asign/test.go

@@ -1,7 +1,6 @@
 package asign
 
 import (
-	"errors"
 	"mtp2_if/global/app"
 	"mtp2_if/global/e"
 	"mtp2_if/logger"
@@ -145,36 +144,14 @@ func TestGetUser(c *gin.Context) {
 		return
 	}
 
-	// 判断证件号码是否已经在爱签平台存在
-	// var getUserReq APIGetUserReq
-	// getUserReq.Account = strconv.Itoa(req.UserId)
 	getUserReq := asignService.APIReq[asignService.APIGetUserReq]{
-		Data: asignService.APIGetUserReq{Account: req.Account},
+		Data: req,
 	}
 	apiRsp, err := asignService.APIPost[asignService.APIGetUserReq, []asignService.APIGetUserRsp](getUserReq, asignService.APIURL_GetUser)
 	if err != nil {
 		appG.ResponseByMsg(http.StatusBadRequest, e.ERROR, err.Error(), nil)
 		return
 	}
-	if apiRsp.Code == asignService.CODE_SUCCESS {
-		err = errors.New("电子签平台用户编号已存在")
-		logger.GetLogger().Error("电子签平台用户编号已存在, apiRsp:", apiRsp)
-		appG.ResponseByMsg(http.StatusBadRequest, e.ERROR, err.Error(), nil)
-		return
-	}
-	getUserReq.Data.Account = ""
-	getUserReq.Data.IdCard = req.IdCard
-	apiRsp, err = asignService.APIPost[asignService.APIGetUserReq, []asignService.APIGetUserRsp](getUserReq, asignService.APIURL_GetUser)
-	if err != nil {
-		appG.ResponseByMsg(http.StatusBadRequest, e.ERROR, err.Error(), nil)
-		return
-	}
-	if apiRsp.Code == asignService.CODE_SUCCESS && len(apiRsp.Data) > 0 {
-		err = errors.New("电子签平台证件号码已存在")
-		logger.GetLogger().Error("电子签平台证件号码已存在, apiRsp:", apiRsp)
-		appG.ResponseByMsg(http.StatusBadRequest, e.ERROR, err.Error(), nil)
-		return
-	}
 
-	appG.Response(http.StatusOK, e.SUCCESS, "")
+	appG.Response(http.StatusOK, e.SUCCESS, apiRsp)
 }

+ 4 - 4
controllers/tencent/qian.go

@@ -89,12 +89,12 @@ func QianNotice(c *gin.Context) {
 					tencent.ProcessNotice(content)
 				} else {
 					logger.GetLogger().Errorf("QianNotice failed: 解密失败 %v", err)
-					appG.Response(http.StatusBadRequest, e.ERROR, "fail")
+					appG.Response(http.StatusOK, e.ERROR, "fail")
 					return
 				}
 			} else {
 				logger.GetLogger().Errorf("QianNotice failed: 验签失败")
-				appG.Response(http.StatusBadRequest, e.ERROR, "fail")
+				appG.Response(http.StatusOK, e.ERROR, "fail")
 				return
 			}
 
@@ -102,7 +102,7 @@ func QianNotice(c *gin.Context) {
 		}
 	} else {
 		logger.GetLogger().Errorf("QianNotice failed: 获取推送内容为空")
-		appG.Response(http.StatusBadRequest, e.ERROR, "fail")
+		appG.Response(http.StatusOK, e.ERROR, "fail")
 	}
 }
 
@@ -122,7 +122,7 @@ func CreateConsoleLoginUrl(c *gin.Context) {
 	proxyOrganizationName := SysConfig.SerCfg.TencentCfg.ProxyOrganizationName
 	response, _ := tencent.CreateConsoleLoginUrl(agent, proxyOrganizationName)
 
-	appG.Response(http.StatusOK, e.SUCCESS, response.ToJsonString())
+	appG.Response(http.StatusOK, e.SUCCESS, *response.Response.ConsoleUrl)
 }
 
 type InitTencentESSReq struct {

+ 43 - 0
controllers/tencent/test.go

@@ -0,0 +1,43 @@
+package tencent
+
+import (
+	"mtp2_if/global/app"
+	"mtp2_if/global/e"
+	"mtp2_if/logger"
+	"mtp2_if/services/tencent"
+	"net/http"
+
+	"github.com/gin-gonic/gin"
+)
+
+type GetTemplateInfoReq struct {
+	ContractName string `form:"contractName" binding:"required"` // 合同模块名称
+}
+
+// GetTemplateInfo 获取合同模板信息(测试)
+// @Summary  获取合同模板信息(测试)
+// @Produce  json
+// @Security ApiKeyAuth
+// @accept   application/json
+// @Param    contractName query    string true "合同模块名称"
+// @Success  200          {object} app.Response
+// @Failure  500          {object} app.Response
+// @Router   /Tencent/GetTemplateInfo [get]
+// @Tags     腾讯电子签
+func GetTemplateInfo(c *gin.Context) {
+	appG := app.Gin{C: c}
+
+	// 获取请求参数
+	var req GetTemplateInfoReq
+	if err := appG.C.ShouldBindQuery(&req); err != nil {
+		logger.GetLogger().Errorf("GetTemplateInfo failed: %s", err.Error())
+		appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
+		return
+	}
+
+	if rsp, err := tencent.GetTemplateInfo(&req.ContractName); err == nil {
+		appG.Response(http.StatusOK, e.SUCCESS, rsp)
+	} else {
+		appG.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil)
+	}
+}

+ 42 - 0
docs/docs.go

@@ -18852,6 +18852,48 @@ const docTemplate = `{
                 }
             }
         },
+        "/Tencent/GetTemplateInfo": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "consumes": [
+                    "application/json"
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "腾讯电子签"
+                ],
+                "summary": "获取合同模板信息(测试)",
+                "parameters": [
+                    {
+                        "type": "string",
+                        "description": "合同模块名称",
+                        "name": "contractName",
+                        "in": "query",
+                        "required": true
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
         "/Tencent/InitMdUserSwapProtocol": {
             "post": {
                 "security": [

+ 42 - 0
docs/swagger.json

@@ -18843,6 +18843,48 @@
                 }
             }
         },
+        "/Tencent/GetTemplateInfo": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "consumes": [
+                    "application/json"
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "腾讯电子签"
+                ],
+                "summary": "获取合同模板信息(测试)",
+                "parameters": [
+                    {
+                        "type": "string",
+                        "description": "合同模块名称",
+                        "name": "contractName",
+                        "in": "query",
+                        "required": true
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
         "/Tencent/InitMdUserSwapProtocol": {
             "post": {
                 "security": [

+ 26 - 0
docs/swagger.yaml

@@ -43083,6 +43083,32 @@ paths:
       summary: 获取合同状态
       tags:
       - 腾讯电子签
+  /Tencent/GetTemplateInfo:
+    get:
+      consumes:
+      - application/json
+      parameters:
+      - description: 合同模块名称
+        in: query
+        name: contractName
+        required: true
+        type: string
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            $ref: '#/definitions/app.Response'
+        "500":
+          description: Internal Server Error
+          schema:
+            $ref: '#/definitions/app.Response'
+      security:
+      - ApiKeyAuth: []
+      summary: 获取合同模板信息(测试)
+      tags:
+      - 腾讯电子签
   /Tencent/InitMdUserSwapProtocol:
     post:
       consumes:

+ 6 - 5
go.mod

@@ -48,7 +48,7 @@ require (
 	github.com/xormplus/xorm v0.0.0-20200912034818-5d90dcd4e3d6
 	golang.org/x/crypto v0.5.0 // indirect
 	golang.org/x/net v0.8.0 // indirect
-	golang.org/x/sys v0.6.0 // indirect
+	golang.org/x/sys v0.16.0 // indirect
 	golang.org/x/tools v0.7.0 // indirect
 	google.golang.org/protobuf v1.31.0
 	gopkg.in/flosch/pongo2.v3 v3.0.0-20141028000813-5e81b817a0c4 // indirect
@@ -68,8 +68,9 @@ require (
 	github.com/KyleBanks/depth v1.2.1 // indirect
 	github.com/PuerkitoBio/purell v1.1.1 // indirect
 	github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect
-	github.com/bytedance/sonic v1.8.0 // indirect
-	github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 // indirect
+	github.com/bytedance/sonic v1.10.2 // indirect
+	github.com/chenzhuoyu/base64x v0.0.0-20230717121745-296ad89f973d // indirect
+	github.com/chenzhuoyu/iasm v0.9.1 // indirect
 	github.com/fsnotify/fsnotify v1.4.7 // indirect
 	github.com/gin-contrib/sse v0.1.0 // indirect
 	github.com/go-openapi/jsonpointer v0.19.5 // indirect
@@ -80,14 +81,14 @@ require (
 	github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db // indirect
 	github.com/google/go-cmp v0.5.8 // indirect
 	github.com/josharian/intern v1.0.0 // indirect
-	github.com/klauspost/cpuid/v2 v2.0.9 // indirect
+	github.com/klauspost/cpuid/v2 v2.2.6 // indirect
 	github.com/konsorten/go-windows-terminal-sequences v1.0.1 // indirect
 	github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
 	github.com/modern-go/reflect2 v1.0.2 // indirect
 	github.com/pelletier/go-toml/v2 v2.0.6 // indirect
 	github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
 	github.com/ugorji/go/codec v1.2.9 // indirect
-	golang.org/x/arch v0.0.0-20210923205945-b76863e36670 // indirect
+	golang.org/x/arch v0.7.0 // indirect
 	golang.org/x/text v0.8.0 // indirect
 	golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
 	gopkg.in/yaml.v2 v2.4.0 // indirect

+ 16 - 0
go.sum

@@ -27,9 +27,17 @@ github.com/bwmarrin/snowflake v0.3.0/go.mod h1:NdZxfVWX+oR6y2K0o6qAYv6gIOP9rjG0/
 github.com/bytedance/sonic v1.5.0/go.mod h1:ED5hyg4y6t3/9Ku1R6dU/4KyJ48DZ4jPhfY1O2AihPM=
 github.com/bytedance/sonic v1.8.0 h1:ea0Xadu+sHlu7x5O3gKhRpQ1IKiMrSiHttPF0ybECuA=
 github.com/bytedance/sonic v1.8.0/go.mod h1:i736AoUSYt75HyZLoJW9ERYxcy6eaN6h4BZXU064P/U=
+github.com/bytedance/sonic v1.10.0-rc/go.mod h1:ElCzW+ufi8qKqNW0FY314xriJhyJhuoJ3gFZdAHF7NM=
+github.com/bytedance/sonic v1.10.2 h1:GQebETVBxYB7JGWJtLBi07OVzWwt+8dWA00gEVW2ZFE=
+github.com/bytedance/sonic v1.10.2/go.mod h1:iZcSUejdk5aukTND/Eu/ivjQuEL0Cu9/rf50Hi0u/g4=
 github.com/chenzhuoyu/base64x v0.0.0-20211019084208-fb5309c8db06/go.mod h1:DH46F32mSOjUmXrMHnKwZdA8wcEefY7UVqBKYGjpdQY=
 github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 h1:qSGYFH7+jGhDF8vLC+iwCD4WpbV1EBDSzWkJODFLams=
 github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311/go.mod h1:b583jCggY9gE99b6G5LEC39OIiVsWj+R97kbl5odCEk=
+github.com/chenzhuoyu/base64x v0.0.0-20230717121745-296ad89f973d h1:77cEq6EriyTZ0g/qfRdp61a3Uu/AWrgIq2s0ClJV1g0=
+github.com/chenzhuoyu/base64x v0.0.0-20230717121745-296ad89f973d/go.mod h1:8EPpVsBuRksnlj1mLy4AWzRNQYxauNi62uWcE3to6eA=
+github.com/chenzhuoyu/iasm v0.9.0/go.mod h1:Xjy2NpN3h7aUqeqM+woSuuvxmIe6+DDsiNLIrkAmYog=
+github.com/chenzhuoyu/iasm v0.9.1 h1:tUHQJXo3NhBqw6s33wkGn9SP3bvrWLdlVIJ3hQBL7P0=
+github.com/chenzhuoyu/iasm v0.9.1/go.mod h1:Xjy2NpN3h7aUqeqM+woSuuvxmIe6+DDsiNLIrkAmYog=
 github.com/clbanning/mxj v1.8.4 h1:HuhwZtbyvyOw+3Z1AowPkU87JkJUSv751ELWaiTpj8I=
 github.com/clbanning/mxj v1.8.4/go.mod h1:BVjHeAH+rl9rs6f+QIpeRl0tfu10SXn1pUSa5PVGJng=
 github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
@@ -92,6 +100,9 @@ github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnr
 github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
 github.com/klauspost/cpuid/v2 v2.0.9 h1:lgaqFMSdTdQYdZ04uHyN2d/eKdOMyi2YLSvlQIBFYa4=
 github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
+github.com/klauspost/cpuid/v2 v2.2.6 h1:ndNyv040zDGIDh8thGkXYjnFtiN02M1PVVF+JE/48xc=
+github.com/klauspost/cpuid/v2 v2.2.6/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws=
+github.com/knz/go-libedit v1.10.1/go.mod h1:MZTVkCWyz0oBc7JOWP3wNAzd002ZbM/5hgShxwh4x8M=
 github.com/konsorten/go-windows-terminal-sequences v1.0.1 h1:mweAR1A6xJ3oS2pRaGiHgQ4OO8tzTaLawm8vnODuwDk=
 github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
 github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
@@ -191,6 +202,8 @@ github.com/xormplus/xorm v0.0.0-20200912034818-5d90dcd4e3d6/go.mod h1:+v6b10b4x5
 github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
 golang.org/x/arch v0.0.0-20210923205945-b76863e36670 h1:18EFjUmQOcUvxNYSkA6jO9VAiXCnxFY6NyDX0bHDmkU=
 golang.org/x/arch v0.0.0-20210923205945-b76863e36670/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8=
+golang.org/x/arch v0.7.0 h1:pskyeJh/3AmoQ8CPE95vxHLqp1G1GfGNXTmcl9NEKTc=
+golang.org/x/arch v0.7.0/go.mod h1:FEVrYAQjsQXMVJ1nsMoVVXPZg6p2JE2mx8psSWTDQys=
 golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
 golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
 golang.org/x/crypto v0.5.0 h1:U/0M97KRkSFvyD/3FSmdP5W5swImpNgle/EHFhOsQPE=
@@ -221,6 +234,8 @@ golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBc
 golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
 golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ=
 golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/sys v0.16.0 h1:xWw16ngr6ZMtmxDyKyIgsE93KNKz5HKmMa3b8ALHidU=
+golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
 golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
 golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
 golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
@@ -266,4 +281,5 @@ gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C
 gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
 gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
 gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
+nullprogram.com/x/optparse v1.0.0/go.mod h1:KdyPE+Igbe0jQUrVfMqDMeJQIJZEuyV7pjYmp6pbG50=
 rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4=

+ 2 - 0
routers/router.go

@@ -844,6 +844,8 @@ func InitRouter() *gin.Engine {
 		tencentR.Use(token.Auth()).GET("GetFlowStatus", tencent.GetFlowStatus)
 		tencentR.Use(token.Auth()).POST("InitTencentESS", tencent.InitTencentESS)
 		tencentR.Use(token.Auth()).POST("InitMdUserSwapProtocol", tencent.InitMdUserSwapProtocol)
+
+		tencentR.Use(token.Auth()).GET("GetTemplateInfo", tencent.GetTemplateInfo)
 	}
 
 	// ************************* 爱签 *************************

+ 24 - 77
services/asign/api.go

@@ -10,8 +10,8 @@ import (
 	"crypto/x509"
 	"encoding/base64"
 	"encoding/hex"
-	"encoding/json"
 	"encoding/pem"
+	"errors"
 	"fmt"
 	"io"
 	"mime/multipart"
@@ -24,104 +24,50 @@ import (
 	"strings"
 	"time"
 
-	"github.com/fatih/structs"
+	"github.com/bytedance/sonic"
+	"github.com/bytedance/sonic/encoder"
 )
 
 func APIPost[T1 APIReqData, T2 APIRspData](req APIReq[T1], apiPort APIURL) (rsp *APIRsp[T2], err error) {
 	apiUrl := config.SerCfg.AsignCfg.Url + string(apiPort)
 
 	var rspBody []byte
-	if len(req.Datas) > 0 {
-		// 切片入参
-		reqArray := make([]map[string]interface{}, 0)
-		for _, item := range req.Datas {
-			reqArray = append(reqArray, structs.Map(item))
-		}
-		logger.GetLogger().Info("调用接口 "+apiUrl+" 请求, request:", reqArray)
-		rspBody, err = httpPost_Array(apiUrl, reqArray)
-	} else {
-		// 对象入参
-		reqMap := structs.Map(req.Data)
-		logger.GetLogger().Info("调用接口 "+apiUrl+" 请求, request:", reqMap)
-		rspBody, err = httpPost(apiUrl, reqMap)
-	}
-
+	rspBody, err = httpPost(apiUrl, req.Data)
 	if err != nil {
-		logger.GetLogger().Error("调用接口 "+apiUrl+" 错误, error:", err.Error())
 		return
 	}
 	rspStr := string(rspBody)
 	if len(rspStr) == 0 {
 		logger.GetLogger().Error("调用接口 " + apiUrl + " 错误, response为空")
+		err = errors.New("调用接口返回内容为空")
 		return
 	}
-	logger.GetLogger().Info("调用接口 "+apiUrl+" 返回, response:", rspStr)
 	rsp = new(APIRsp[T2])
-	err = json.Unmarshal(rspBody, rsp)
+	err = sonic.Unmarshal(rspBody, rsp)
 
 	return
 }
 
-func httpPost(apiUrl string, bizData map[string]interface{}) (rspBody []byte, err error) {
+func httpPost(apiUrl string, bizData ...interface{}) (rspBody []byte, err error) {
 	appId := config.SerCfg.AsignCfg.AppId
 	privateKey := fmt.Sprintf("-----BEGIN PRIVATE KEY-----\n%s\n-----END PRIVATE KEY-----", config.SerCfg.AsignCfg.PrivateKey)
 
 	// fuck asign dev.
 	timestamp := strconv.Itoa(int(time.Now().UnixMilli() + 10000*60))
 
-	// 签名
-	sortedData := sortMapByKey(bizData)
-	signature, err := getSignature(sortedData, appId, timestamp, privateKey)
-	if err != nil {
-		logger.GetLogger().Errorf("签名失败:" + err.Error())
-		return
+	// 排序key
+	var b []byte
+	if len(bizData) == 1 {
+		b, err = encoder.Encode(bizData[0], encoder.SortMapKeys)
+	} else {
+		b, err = encoder.Encode(bizData, encoder.SortMapKeys)
 	}
-
-	// 构建form-data请求参数
-	var requestBody bytes.Buffer
-	multipartWriter := multipart.NewWriter(&requestBody)
-	multipartWriter.WriteField("appId", appId)
-	multipartWriter.WriteField("timestamp", timestamp)
-	multipartWriter.WriteField("bizData", sortedData)
-	multipartWriter.Close()
-	// 构建请求
-	req, err := http.NewRequest("POST", apiUrl, &requestBody)
-	// 设置请求头
-	req.Header.Set("sign", signature)
-	req.Header.Set("timestamp", timestamp)
-	req.Header.Set("Content-Type", multipartWriter.FormDataContentType())
-
-	// 调用接口
-	client := &http.Client{}
-	rsp, err := client.Do(req)
 	if err != nil {
-		logger.GetLogger().Errorf("调用接口失败:" + err.Error())
+		logger.GetLogger().Errorf("处理入参排序失败:" + err.Error())
 		return
 	}
-	defer rsp.Body.Close()
-	rspBody, err = io.ReadAll(rsp.Body)
-
-	return
-}
-
-// bizData入参为数组
-func httpPost_Array(apiUrl string, bizData []map[string]interface{}) (rspBody []byte, err error) {
-	appId := config.SerCfg.AsignCfg.AppId
-	privateKey := fmt.Sprintf("-----BEGIN PRIVATE KEY-----\n%s\n-----END PRIVATE KEY-----", config.SerCfg.AsignCfg.PrivateKey)
-
-	// fuck asign dev.
-	timestamp := strconv.Itoa(int(time.Now().UnixMilli() + 10000*60))
-
+	sortedData := string(b)
 	// 签名
-	sortedData := "["
-	for i, item := range bizData {
-		if i > 0 {
-			sortedData += ","
-		}
-		sortedData += sortMapByKey(item)
-	}
-	sortedData += "]"
-
 	signature, err := getSignature(sortedData, appId, timestamp, privateKey)
 	if err != nil {
 		logger.GetLogger().Errorf("签名失败:" + err.Error())
@@ -143,14 +89,16 @@ func httpPost_Array(apiUrl string, bizData []map[string]interface{}) (rspBody []
 	req.Header.Set("Content-Type", multipartWriter.FormDataContentType())
 
 	// 调用接口
+	logger.GetLogger().Info("调用接口 "+apiUrl+" 请求, request:", sortedData)
 	client := &http.Client{}
 	rsp, err := client.Do(req)
 	if err != nil {
-		logger.GetLogger().Errorf("调用接口失败:" + err.Error())
+		logger.GetLogger().Error("调用接口 "+apiUrl+" 错误, error:", err.Error())
 		return
 	}
 	defer rsp.Body.Close()
 	rspBody, err = io.ReadAll(rsp.Body)
+	logger.GetLogger().Info("调用接口 "+apiUrl+" 返回, response:", string(rspBody))
 
 	return
 }
@@ -198,7 +146,6 @@ func getSignature(sortedData string, appId, timestamp, privateKey string) (signa
 	// 使用私钥进行签名
 	sign, err := rsa.SignPKCS1v15(rand.Reader, privateKey10, crypto.SHA1, sum)
 	if err != nil {
-		fmt.Println("Error signing:", err)
 		return
 	}
 
@@ -209,8 +156,8 @@ func getSignature(sortedData string, appId, timestamp, privateKey string) (signa
 	return
 }
 
-// sortMapByKey 按key排序map返回string
-func sortMapByKey(data map[string]interface{}) (sortedData string) {
+// SortMapByKey 按key排序map返回string -- 已经不使用的方法
+func SortMapByKey(data map[string]interface{}) (sortedData string) {
 	keys := make([]string, 0, len(data))
 	for k := range data {
 		keys = append(keys, k)
@@ -228,7 +175,7 @@ func sortMapByKey(data map[string]interface{}) (sortedData string) {
 			case *string:
 				sortedData += fmt.Sprintf(`"%s":"%s"`, k, *(data[k].(*string)))
 			case *map[string]interface{}:
-				sortedData += fmt.Sprintf(`"%s":%s`, k, sortMapByKey(*(data[k].(*map[string]interface{}))))
+				sortedData += fmt.Sprintf(`"%s":%s`, k, SortMapByKey(*(data[k].(*map[string]interface{}))))
 			case *[]interface{}:
 				list := data[k].([]interface{})
 				sortedData += fmt.Sprintf(`"%s":[`, k)
@@ -236,7 +183,7 @@ func sortMapByKey(data map[string]interface{}) (sortedData string) {
 					if j > 0 {
 						sortedData += ","
 					}
-					sortedData += sortMapByKey(item.(map[string]interface{}))
+					sortedData += SortMapByKey(item.(map[string]interface{}))
 				}
 				sortedData += "]"
 			default:
@@ -247,7 +194,7 @@ func sortMapByKey(data map[string]interface{}) (sortedData string) {
 			case string:
 				sortedData += fmt.Sprintf(`"%s":"%s"`, k, data[k].(string))
 			case map[string]interface{}:
-				sortedData += fmt.Sprintf(`"%s":%s`, k, sortMapByKey(data[k].(map[string]interface{})))
+				sortedData += fmt.Sprintf(`"%s":%s`, k, SortMapByKey(data[k].(map[string]interface{})))
 			case []interface{}:
 				list := data[k].([]interface{})
 				sortedData += fmt.Sprintf(`"%s":[`, k)
@@ -255,7 +202,7 @@ func sortMapByKey(data map[string]interface{}) (sortedData string) {
 					if j > 0 {
 						sortedData += ","
 					}
-					sortedData += sortMapByKey(item.(map[string]interface{}))
+					sortedData += SortMapByKey(item.(map[string]interface{}))
 				}
 				sortedData += "]"
 			default:

+ 1 - 2
services/asign/apiModels.go

@@ -5,8 +5,7 @@ type APIReqData interface {
 }
 
 type APIReq[T APIReqData] struct {
-	Data  T   // 请求数据
-	Datas []T // 数组类型请求数据
+	Data T // 请求数据
 }
 
 type APIRspData interface {

+ 3 - 1
services/asign/servcies.go

@@ -623,7 +623,9 @@ func CreateContract(req CreateContractReq) (rsp CreateContractRsp, err error) {
 	if len(receiverFillStrategyList) > 0 {
 		appAddSignerReq2.ReceiverFillStrategyList = receiverFillStrategyList
 	}
-	apiAddSignerRsp, err := APIPost[APIAddSignerReq, APIAddSignerRsp](APIReq[APIAddSignerReq]{Datas: []APIAddSignerReq{appAddSignerReq1, appAddSignerReq2}}, APIURL_AddSigner)
+	apiAddSignerReq := new(APIReq[[]APIAddSignerReq])
+	apiAddSignerReq.Data = []APIAddSignerReq{appAddSignerReq1, appAddSignerReq2}
+	apiAddSignerRsp, err := APIPost[[]APIAddSignerReq, APIAddSignerRsp](*apiAddSignerReq, APIURL_AddSigner)
 	if err != nil {
 		return
 	}

+ 5 - 10
services/tencent/ess.go

@@ -21,12 +21,6 @@ import (
 
 func CreateConsoleLoginUrl(agent *essbasic.Agent, proxyOrganizationName string) (response *essbasic.CreateConsoleLoginUrlResponse, err error) {
 	response, err = essapi.CreateConsoleLoginUrl(agent, proxyOrganizationName)
-
-	r := response.Response.ConsoleUrl
-
-	// 输出json格式的字符串回包
-	fmt.Println(*r)
-
 	return
 }
 
@@ -78,7 +72,7 @@ func CreateFlowByTemplateDirectly(tmplateName string, userType int,
 	record *models.Useresignrecord) (flowId, signUrl string, err error) {
 
 	// 获取模板信息
-	templateInfo, err := getTemplateInfo(&tmplateName)
+	templateInfo, err := GetTemplateInfo(&tmplateName)
 	if err != nil {
 		return
 	}
@@ -194,7 +188,8 @@ func UpdateMdUserSwapProtocol(flowId string) (err error) {
 		}
 		if flag {
 			// 获取对应用户掉期协议签署记录
-			datas, err := models.QueryMdUserSwapProtocol(int(record.USERID), &record.AREAUSERID)
+			var datas []models.Mduserswapprotocol
+			datas, err = models.QueryMdUserSwapProtocol(int(record.USERID), &record.AREAUSERID)
 			if err == nil {
 				if len(datas) > 0 {
 					data := datas[0]
@@ -221,8 +216,8 @@ func UpdateMdUserSwapProtocol(flowId string) (err error) {
 	return
 }
 
-// getTemplateInfo 获取模板信息
-func getTemplateInfo(contractName *string) (templateInfo *essbasic.TemplateInfo, err error) {
+// GetTemplateInfo 获取模板信息
+func GetTemplateInfo(contractName *string) (templateInfo *essbasic.TemplateInfo, err error) {
 	agent := utils.SetAgent()
 	templatesResp, err := essapi.DescribeTemplates(agent, contractName)
 	if err == nil {

BIN=BIN
services/tencent/templates/南海国际/交收端入市协议.docx


BIN=BIN
services/tencent/templates/南海国际/海南丹农风险提示书.docx


BIN=BIN
services/tencent/templates/南海国际/海南丹农(会员)入市签署材料.docx