f
This commit is contained in:
@@ -28,13 +28,13 @@ func (s *SignFlowService) UpdateConfig(config *Config) {
|
||||
// 创建包含多个签署人的签署流程,支持自动盖章和手动签署
|
||||
func (s *SignFlowService) Create(req *CreateSignFlowRequest) (string, error) {
|
||||
fmt.Println("开始创建签署流程...")
|
||||
fmt.Println("(将创建包含甲方自动盖章和乙方手动签署的流程)")
|
||||
fmt.Println("(将创建包含甲方手动签署和乙方自动盖章的流程)")
|
||||
|
||||
// 构建甲方签署人信息(自动盖章)
|
||||
partyASigner := s.buildPartyASigner(req.FileID)
|
||||
// 构建甲方签署人信息(手动签署)
|
||||
partyASigner := s.buildPartyASigner(req.FileID, req.SignerAccount, req.SignerName, req.TransactorPhone, req.TransactorName, req.TransactorIDCardNum)
|
||||
|
||||
// 构建乙方签署人信息(手动签署)
|
||||
partyBSigner := s.buildPartyBSigner(req.FileID, req.SignerAccount, req.SignerName, req.TransactorPhone, req.TransactorName, req.TransactorIDCardNum)
|
||||
// 构建乙方签署人信息(自动盖章)
|
||||
partyBSigner := s.buildPartyBSigner(req.FileID)
|
||||
|
||||
signers := []SignerInfo{partyASigner, partyBSigner}
|
||||
|
||||
@@ -128,34 +128,11 @@ func (s *SignFlowService) GetSignURL(signFlowID, psnAccount, orgName string) (st
|
||||
return response.Data.Url, response.Data.ShortUrl, nil
|
||||
}
|
||||
|
||||
// buildPartyASigner 构建甲方签署人信息(自动盖章)
|
||||
func (s *SignFlowService) buildPartyASigner(fileID string) SignerInfo {
|
||||
return SignerInfo{
|
||||
SignConfig: &SignConfig{SignOrder: 1},
|
||||
SignerType: SignerTypeOrg,
|
||||
SignFields: []SignField{
|
||||
{
|
||||
CustomBizNum: "甲方签章",
|
||||
FileId: fileID,
|
||||
NormalSignFieldConfig: &NormalSignFieldConfig{
|
||||
AutoSign: true,
|
||||
SignFieldStyle: SignFieldStyleNormal,
|
||||
SignFieldPosition: &SignFieldPosition{
|
||||
PositionPage: "8",
|
||||
PositionX: 200,
|
||||
PositionY: 430,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// buildPartyBSigner 构建乙方签署人信息(手动签署)
|
||||
func (s *SignFlowService) buildPartyBSigner(fileID, signerAccount, signerName, transactorPhone, transactorName, transactorIDCardNum string) SignerInfo {
|
||||
// buildPartyASigner 构建甲方签署人信息(手动签署)
|
||||
func (s *SignFlowService) buildPartyASigner(fileID, signerAccount, signerName, transactorPhone, transactorName, transactorIDCardNum string) SignerInfo {
|
||||
return SignerInfo{
|
||||
SignConfig: &SignConfig{
|
||||
SignOrder: 2,
|
||||
SignOrder: 1,
|
||||
},
|
||||
AuthConfig: &AuthConfig{
|
||||
PsnAvailableAuthModes: []string{AuthModeMobile3},
|
||||
@@ -182,15 +159,15 @@ func (s *SignFlowService) buildPartyBSigner(fileID, signerAccount, signerName, t
|
||||
},
|
||||
SignFields: []SignField{
|
||||
{
|
||||
CustomBizNum: "乙方签章",
|
||||
CustomBizNum: "甲方签章",
|
||||
FileId: fileID,
|
||||
NormalSignFieldConfig: &NormalSignFieldConfig{
|
||||
AutoSign: false,
|
||||
SignFieldStyle: SignFieldStyleNormal,
|
||||
SignFieldPosition: &SignFieldPosition{
|
||||
PositionPage: "8",
|
||||
PositionX: 450,
|
||||
PositionY: 430,
|
||||
PositionPage: "10",
|
||||
PositionX: 165,
|
||||
PositionY: 197,
|
||||
},
|
||||
OrgSealBizTypes: "PUBLIC",
|
||||
},
|
||||
@@ -199,6 +176,41 @@ func (s *SignFlowService) buildPartyBSigner(fileID, signerAccount, signerName, t
|
||||
}
|
||||
}
|
||||
|
||||
// buildPartyBSigner 构建乙方签署人信息(自动盖章)
|
||||
func (s *SignFlowService) buildPartyBSigner(fileID string) SignerInfo {
|
||||
return SignerInfo{
|
||||
SignConfig: &SignConfig{SignOrder: 2},
|
||||
SignerType: SignerTypeOrg,
|
||||
SignFields: []SignField{
|
||||
{
|
||||
CustomBizNum: "乙方签章",
|
||||
FileId: fileID,
|
||||
NormalSignFieldConfig: &NormalSignFieldConfig{
|
||||
AutoSign: true,
|
||||
SignFieldStyle: SignFieldStyleNormal,
|
||||
SignFieldPosition: &SignFieldPosition{
|
||||
PositionPage: "10",
|
||||
PositionX: 403,
|
||||
PositionY: 197,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
CustomBizNum: "乙方骑缝章", // 建议设唯一标识,便于调试
|
||||
FileId:fileID,
|
||||
NormalSignFieldConfig: &NormalSignFieldConfig{
|
||||
AutoSign: true, // 骑缝章也支持自动签署
|
||||
SignFieldStyle: SignFieldStyleSeam, // 必须为 2(Edges)
|
||||
SignFieldPosition: &SignFieldPosition{
|
||||
AcrossPageMode: "ALL", // 覆盖全部页面(推荐)
|
||||
PositionY:694.0, // 您指定的 Y 坐标(float64)
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// buildSignFlowConfig 构建签署流程配置
|
||||
func (s *SignFlowService) buildSignFlowConfig() SignFlowConfig {
|
||||
return SignFlowConfig{
|
||||
|
||||
@@ -170,6 +170,7 @@ type NormalSignFieldConfig struct {
|
||||
|
||||
// SignFieldPosition 签署区位置
|
||||
type SignFieldPosition struct {
|
||||
AcrossPageMode string `json:"acrossPageMode"` // 跨页模式:ALL-全部页面
|
||||
PositionPage string `json:"positionPage"` // 页码
|
||||
PositionX float64 `json:"positionX"` // X坐标
|
||||
PositionY float64 `json:"positionY"` // Y坐标
|
||||
|
||||
@@ -15,12 +15,17 @@ import (
|
||||
)
|
||||
|
||||
type AlipayConfig struct {
|
||||
AppID string
|
||||
PrivateKey string
|
||||
AlipayPublicKey string
|
||||
IsProduction bool
|
||||
NotifyUrl string
|
||||
ReturnURL string // 同步回调地址
|
||||
AppID string
|
||||
Mode string
|
||||
PrivateKey string
|
||||
AlipayPublicKey string
|
||||
AppCertPath string
|
||||
AlipayCertPath string
|
||||
AlipayRootCertPath string
|
||||
EncryptKey string
|
||||
IsProduction bool
|
||||
NotifyUrl string
|
||||
ReturnURL string // 同步回调地址
|
||||
}
|
||||
type AliPayService struct {
|
||||
config AlipayConfig
|
||||
@@ -34,11 +39,30 @@ func NewAliPayService(config AlipayConfig) *AliPayService {
|
||||
panic(fmt.Sprintf("创建支付宝客户端失败: %v", err))
|
||||
}
|
||||
|
||||
// 加载支付宝公钥
|
||||
err = client.LoadAliPayPublicKey(config.AlipayPublicKey)
|
||||
if err != nil {
|
||||
panic(fmt.Sprintf("加载支付宝公钥失败: %v", err))
|
||||
if config.Mode == "cert" {
|
||||
// 证书模式:加载应用公钥证书、支付宝公钥证书、支付宝根证书
|
||||
if err = client.LoadAppCertPublicKeyFromFile(config.AppCertPath); err != nil {
|
||||
panic(fmt.Sprintf("加载应用公钥证书失败: %v", err))
|
||||
}
|
||||
if err = client.LoadAlipayCertPublicKeyFromFile(config.AlipayCertPath); err != nil {
|
||||
panic(fmt.Sprintf("加载支付宝公钥证书失败: %v", err))
|
||||
}
|
||||
if err = client.LoadAliPayRootCertFromFile(config.AlipayRootCertPath); err != nil {
|
||||
panic(fmt.Sprintf("加载根证书失败: %v", err))
|
||||
}
|
||||
} else {
|
||||
// 默认密钥模式:加载支付宝公钥
|
||||
err = client.LoadAliPayPublicKey(config.AlipayPublicKey)
|
||||
if err != nil {
|
||||
panic(fmt.Sprintf("加载支付宝公钥失败: %v", err))
|
||||
}
|
||||
}
|
||||
|
||||
// 可选:开启支付宝接口内容加密(AES)
|
||||
if config.EncryptKey != "" {
|
||||
client.SetEncryptKey(config.EncryptKey)
|
||||
}
|
||||
|
||||
return &AliPayService{
|
||||
config: config,
|
||||
AlipayClient: client,
|
||||
|
||||
Reference in New Issue
Block a user