Compare commits

...

2 Commits

Author SHA1 Message Date
59d26ac08e fix 2025-09-21 21:44:44 +08:00
8dc4cb19fc fix 2025-09-21 21:35:14 +08:00
2 changed files with 49 additions and 13 deletions

View File

@@ -196,6 +196,7 @@ var requestProcessors = map[string]func(*ApiRequestService, []byte) ([]byte, err
"JRZQ4B6C": (*ApiRequestService).ProcessJRZQ4B6CRequest,
"JRZQ09J8": (*ApiRequestService).ProcessJRZQ09J8Request,
"JRZQ5E9F": (*ApiRequestService).ProcessJRZQ5E9FRequest,
"QYGL3F8E": (*ApiRequestService).ProcessQYGL3F8ERequest,
}
// PreprocessRequestApi 调用指定的请求处理函数
@@ -1308,6 +1309,7 @@ func (a *ApiRequestService) ProcessJRZQ4B6CRequest(params []byte) ([]byte, error
"name": name.String(),
"id_card": idCard.String(),
"mobile_no": mobile.String(),
"authorized": "1",
})
if err != nil {
@@ -1377,6 +1379,33 @@ func (a *ApiRequestService) ProcessJRZQ5E9FRequest(params []byte) ([]byte, error
return nil, err
}
respBytes, err := convertTianyuanResponse(resp)
if err != nil {
return nil, err
}
// 重新编码为 JSON
data, err := json.Marshal(respBytes)
if err != nil {
return nil, fmt.Errorf("编码修改后的 data 失败: %v", err)
}
return data, nil
}
// ProcessQYGL3F8ERequest 人企关系加强版2
func (a *ApiRequestService) ProcessQYGL3F8ERequest(params []byte) ([]byte, error) {
idCard := gjson.GetBytes(params, "id_card")
if !idCard.Exists() {
return nil, errors.New("api请求, QYGL3F8E, 获取相关参数失败")
}
resp, err := a.tianyuanapi.CallInterface("QYGL3F8E", map[string]interface{}{
"id_card": idCard.String(),
})
if err != nil {
return nil, err
}
respBytes, err := convertTianyuanResponse(resp)
if err != nil {
return nil, err

View File

@@ -107,34 +107,33 @@ func (s *AuthorizationService) generatePDFContent(userInfo map[string]interface{
pdf := gofpdf.New("P", "mm", "A4", "")
pdf.AddPage()
// 添加中文字体支持 - 使用项目字体文件
// 添加中文字体支持 - 参考imageService的路径处理方式
fontPaths := []string{
"static/SIMHEI.TTF", // 相对于工作目录的路径与imageService一致
"/app/static/SIMHEI.TTF", // Docker容器内的字体文件
"../../static/SIMHEI.TTF", // 开发环境字体文件(相对于当前工作目录)
"app/main/api/static/SIMHEI.TTF", // 开发环境字体文件(绝对路径)
"app/main/api/static/SIMHEI.TTF", // 开发环境备用路径
}
wd, wdErr := os.Getwd()
if wdErr != nil {
logx.Errorf("获取工作目录失败: %v", wdErr)
}
logx.Infof("当前工作目录: %s", wd)
// 尝试添加字体
fontAdded := false
for _, fontPath := range fontPaths {
if _, err := os.Stat(fontPath); err == nil {
pdf.AddUTF8Font("ChineseFont", "", fontPath)
pdf.SetFont("ChineseFont", "", 12)
fontAdded = true
logx.Infof("成功加载字体: %s", fontPath)
break
} else {
logx.Debugf("字体文件不存在: %s", fontPath)
logx.Debugf("字体文件不存在: %s, 错误: %v", fontPath, err)
}
}
// 如果没有找到字体文件,使用默认字体
// 如果没有找到字体文件,使用默认字体,并记录警告
if !fontAdded {
pdf.SetFont("Arial", "", 12)
logx.Errorf("未找到中文字体文件使用默认Arial字体可能无法正确显示中文")
} else {
// 设置默认字体
pdf.SetFont("ChineseFont", "", 12)
}
// 获取用户信息
@@ -145,14 +144,22 @@ func (s *AuthorizationService) generatePDFContent(userInfo map[string]interface{
currentDate := time.Now().Format("2006年1月2日")
// 设置标题样式 - 大字体、居中
pdf.SetFont("ChineseFont", "", 20) // 使用20号字体
if fontAdded {
pdf.SetFont("ChineseFont", "", 20) // 使用20号字体
} else {
pdf.SetFont("Arial", "", 20)
}
pdf.CellFormat(0, 15, "授权书", "", 1, "C", false, 0, "")
// 添加空行
pdf.Ln(5)
// 设置正文样式 - 正常字体
pdf.SetFont("ChineseFont", "", 12)
if fontAdded {
pdf.SetFont("ChineseFont", "", 12)
} else {
pdf.SetFont("Arial", "", 12)
}
// 构建授权书内容(去掉标题部分)
content := fmt.Sprintf(`海南天远大数据科技有限公司: