This commit is contained in:
2026-04-21 22:36:48 +08:00
commit 488c695fdf
748 changed files with 266838 additions and 0 deletions

View File

@@ -0,0 +1,39 @@
package flxg
import (
"context"
"encoding/json"
"errors"
"hyapi-server/internal/domains/api/dto"
"hyapi-server/internal/domains/api/services/processors"
"hyapi-server/internal/infrastructure/external/yushan"
)
// ProcessFLXG0687Request FLXG0687 API处理方法
func ProcessFLXG0687Request(ctx context.Context, params []byte, deps *processors.ProcessorDependencies) ([]byte, error) {
var paramsDto dto.FLXG0687Req
if err := json.Unmarshal(params, &paramsDto); err != nil {
return nil, errors.Join(processors.ErrSystem, err)
}
if err := deps.Validator.ValidateStruct(paramsDto); err != nil {
return nil, errors.Join(processors.ErrInvalidParam, err)
}
reqData := map[string]interface{}{
"keyWord": paramsDto.IDCard,
"type": 3,
}
respBytes, err := deps.YushanService.CallAPI(ctx, "RIS031", reqData)
if err != nil {
if errors.Is(err, yushan.ErrDatasource) {
return nil, errors.Join(processors.ErrDatasource, err)
} else {
return nil, errors.Join(processors.ErrSystem, err)
}
}
return respBytes, nil
}

View File

@@ -0,0 +1,51 @@
package flxg
import (
"context"
"encoding/json"
"errors"
"hyapi-server/internal/domains/api/dto"
"hyapi-server/internal/domains/api/services/processors"
"hyapi-server/internal/infrastructure/external/westdex"
)
// ProcessFLXG0V3Bequest FLXG0V3B API处理方法
func ProcessFLXG0V3Bequest(ctx context.Context, params []byte, deps *processors.ProcessorDependencies) ([]byte, error) {
var paramsDto dto.FLXG0V3BReq
if err := json.Unmarshal(params, &paramsDto); err != nil {
return nil, errors.Join(processors.ErrSystem, err)
}
if err := deps.Validator.ValidateStruct(paramsDto); err != nil {
return nil, errors.Join(processors.ErrInvalidParam, err)
}
encryptedName, err := deps.WestDexService.Encrypt(paramsDto.Name)
if err != nil {
return nil, errors.Join(processors.ErrSystem, err)
}
encryptedIDCard, err := deps.WestDexService.Encrypt(paramsDto.IDCard)
if err != nil {
return nil, errors.Join(processors.ErrSystem, err)
}
reqData := map[string]interface{}{
"data": map[string]interface{}{
"name": encryptedName,
"id_card": encryptedIDCard,
},
}
respBytes, err := deps.WestDexService.CallAPI(ctx, "G34BJ03", reqData)
if err != nil {
if errors.Is(err, westdex.ErrDatasource) {
return nil, errors.Join(processors.ErrDatasource, err)
} else {
return nil, errors.Join(processors.ErrSystem, err)
}
}
return respBytes, nil
}

View File

@@ -0,0 +1,527 @@
package flxg
import (
"context"
"encoding/json"
"errors"
"fmt"
"log"
"hyapi-server/internal/domains/api/dto"
"hyapi-server/internal/domains/api/services/processors"
"hyapi-server/internal/infrastructure/external/westdex"
"github.com/tidwall/gjson"
)
// ProcessFLXG0V4BRequest FLXG0V4B API处理方法(身份证排空入口,身份证身份证身份证身份证身份证)
func ProcessFLXG0V4BRequest(ctx context.Context, params []byte, deps *processors.ProcessorDependencies) ([]byte, error) {
var paramsDto dto.FLXG0V4BReq
if err := json.Unmarshal(params, &paramsDto); err != nil {
return nil, errors.Join(processors.ErrSystem, err)
}
if err := deps.Validator.ValidateStruct(paramsDto); err != nil {
return nil, errors.Join(processors.ErrInvalidParam, err)
}
// 去掉司法案件案件去掉身份证号码
if paramsDto.IDCard == "350681198611130611" || paramsDto.IDCard == "622301200006250550" || paramsDto.IDCard == "320682198910134998" || paramsDto.IDCard == "640102198708020925" || paramsDto.IDCard == "420624197310234034" || paramsDto.IDCard == "350104198501184416" || paramsDto.IDCard == "410521198606018056" {
return nil, errors.Join(processors.ErrNotFound, errors.New("查询为空"))
}
encryptedName, err := deps.WestDexService.Encrypt(paramsDto.Name)
if err != nil {
return nil, errors.Join(processors.ErrSystem, err)
}
encryptedIDCard, err := deps.WestDexService.Encrypt(paramsDto.IDCard)
if err != nil {
return nil, errors.Join(processors.ErrSystem, err)
}
if deps.CallContext.ContractCode == "" {
return nil, fmt.Errorf("%s: %w", processors.ErrSystem, errors.New("合同编号不能为空"))
}
encryptedAuthAuthorizeFileCode, err := deps.WestDexService.Encrypt(deps.CallContext.ContractCode)
if err != nil {
return nil, errors.Join(processors.ErrSystem, err)
}
reqData := map[string]interface{}{
"data": map[string]interface{}{
"name": encryptedName,
"idcard": encryptedIDCard,
"auth_authorizeFileCode": encryptedAuthAuthorizeFileCode,
"inquired_auth": fmt.Sprintf("authed:%s", paramsDto.AuthDate),
},
}
log.Println("reqData", reqData)
respBytes, err := deps.WestDexService.CallAPI(ctx, "G22SC01", reqData)
if err != nil {
// 数据源错误
if errors.Is(err, westdex.ErrDatasource) {
// 如果有返回内容,优先解析返回内容
if respBytes != nil {
parsed, parseErr := ParseJsonResponse(respBytes)
if parseErr == nil {
// 通过gjson获取指定路径的数据
contentResult := gjson.GetBytes(parsed, "G22SC0101.G22SC0102.content")
if contentResult.Exists() {
return []byte(contentResult.Raw), errors.Join(processors.ErrDatasource, err)
}
return parsed, errors.Join(processors.ErrDatasource, err)
}
// 解析失败,返回原始内容和系统错误
return respBytes, fmt.Errorf("%s: %w", processors.ErrSystem, parseErr)
}
// 没有返回内容,直接返回数据源错误
return nil, errors.Join(processors.ErrDatasource, err)
}
// 其他系统错误
return nil, errors.Join(processors.ErrSystem, err)
}
// 正常返回 - 不管有没有deps.Options.Json都进行ParseJsonResponse
parsed, parseErr := ParseJsonResponse(respBytes)
if parseErr != nil {
return nil, fmt.Errorf("%s: %w", processors.ErrSystem, parseErr)
}
// 通过gjson获取指定路径的数据
contentResult := gjson.GetBytes(parsed, "G22SC0101.G22SC0102.content")
if contentResult.Exists() {
return []byte(contentResult.Raw), nil
} else {
return nil, errors.Join(processors.ErrDatasource, err)
}
}
// Content 数据内容
type FLXG0V4BResponse struct {
Sxbzxr Sxbzxr `json:"sxbzxr"` // 失信被执行人
Entout Entout `json:"entout"` // 涉诉信息
Xgbzxr Xgbzxr `json:"xgbzxr"` // 限高被执行人
}
// Sxbzxr 失信被执行人
type Sxbzxr struct {
Msg string `json:"msg"` // 备注信息
Data SxbzxrData `json:"data"` // 数据结果
}
// SxbzxrData 失信被执行人数据
type SxbzxrData struct {
Sxbzxr []SxbzxrItem `json:"sxbzxr"` // 失信被执行人列表
}
// SxbzxrItem 失信被执行人项
type SxbzxrItem struct {
Yw string `json:"yw"` // 生效法律文书确定的义务
PjjeGj int `json:"pjje_gj"` // 判决金额_估计
Xwqx string `json:"xwqx"` // 失信被执行人行为具体情形
ID string `json:"id"` // 标识
Zxfy string `json:"zxfy"` // 执行法院
Ah string `json:"ah"` // 案号
Zxyjwh string `json:"zxyjwh"` // 执行依据文号
Lxqk string `json:"lxqk"` // 被执行人的履行情况
Zxyjdw string `json:"zxyjdw"` // 出执行依据单位
Fbrq string `json:"fbrq"` // 发布时间(日期)
Xb string `json:"xb"` // 性别
Larq string `json:"larq"` // 立案日期
Sf string `json:"sf"` // 省份
}
// Entout 涉诉信息
type Entout struct {
Msg string `json:"msg"` // 备注信息
Data EntoutData `json:"data"` // 数据结果
}
// EntoutData 涉诉信息数据
type EntoutData struct {
Administrative Administrative `json:"administrative"` // 行政案件
Implement Implement `json:"implement"` // 执行案件
Count Count `json:"count"` // 统计
Preservation Preservation `json:"preservation"` // 案件类型(非诉保全审查)
Crc int `json:"crc"` // 当事人变更码
Civil Civil `json:"civil"` // 民事案件
Criminal Criminal `json:"criminal"` // 刑事案件
CasesTree CasesTree `json:"cases_tree"` // 串联树
Bankrupt Bankrupt `json:"bankrupt"` // 强制清算与破产案件
}
// Administrative 行政案件
type Administrative struct {
Cases []AdministrativeCase `json:"cases"` // 案件
Count Count `json:"count"` // 统计
}
// AdministrativeCase 行政案件项
type AdministrativeCase struct {
NjabdjeGjLevel int `json:"n_jabdje_gj_level"` // 结案标的金额估计等级
NjbfyCj string `json:"n_jbfy_cj"` // 法院所属层级
CgkwsGlah string `json:"c_gkws_glah"` // 相关案件号
Njafs string `json:"n_jafs"` // 结案方式
Nssdw string `json:"n_ssdw"` // 诉讼地位
Djarq string `json:"d_jarq"` // 结案时间
CgkwsPjjg string `json:"c_gkws_pjjg"` // 判决结果
Nqsbdje int `json:"n_qsbdje"` // 起诉标的金额
Ncrc int `json:"n_crc"` // 案件变更码
Cssdy string `json:"c_ssdy"` // 所属地域
Najjzjd string `json:"n_ajjzjd"` // 案件进展阶段
Njaay string `json:"n_jaay"` // 结案案由
Najlx string `json:"n_ajlx"` // 案件类型
CahYs string `json:"c_ah_ys"` // 原审案号
NlaayTree string `json:"n_laay_tree"` // 立案案由详细
NjabdjeLevel int `json:"n_jabdje_level"` // 结案标的金额等级
Nlaay string `json:"n_laay"` // 立案案由
Najbs string `json:"n_ajbs"` // 案件标识
Njbfy string `json:"n_jbfy"` // 经办法院
CgkwsID string `json:"c_gkws_id"` // 公开文书ID
NjabdjeGj int `json:"n_jabdje_gj"` // 结案标的金额估计
NpjVictory string `json:"n_pj_victory"` // 胜诉估计
CgkwsDsr string `json:"c_gkws_dsr"` // 当事人
Nslcx string `json:"n_slcx"` // 审理程序
NqsbdjeLevel int `json:"n_qsbdje_level"` // 起诉标的金额等级
CID string `json:"c_id"` // 案件唯一ID
NssdwYs string `json:"n_ssdw_ys"` // 一审诉讼地位
Cslfsxx string `json:"c_slfsxx"` // 审理方式信息
Cah string `json:"c_ah"` // 案号
Cdsrxx []Dsrxx `json:"c_dsrxx"` // 当事人
Dlarq string `json:"d_larq"` // 立案时间
NjaayTree string `json:"n_jaay_tree"` // 结案案由详细
CahHx string `json:"c_ah_hx"` // 后续案号
Njabdje int `json:"n_jabdje"` // 结案标的金额
}
// Implement 执行案件
type Implement struct {
Cases []ImplementCase `json:"cases"` // 案件
Count Count `json:"count"` // 统计
}
// ImplementCase 执行案件项
type ImplementCase struct {
Cdsrxx []Dsrxx `json:"c_dsrxx"` // 当事人
Cssdy string `json:"c_ssdy"` // 所属地域
NjabdjeGj int `json:"n_jabdje_gj"` // 结案标的金额估计
Ncrc int `json:"n_crc"` // 案件变更码
Nlaay string `json:"n_laay"` // 立案案由
Cah string `json:"c_ah"` // 案号
Nsqzxbdje int `json:"n_sqzxbdje"` // 申请执行标的金额
CahYs string `json:"c_ah_ys"` // 原审案号
CgkwsGlah string `json:"c_gkws_glah"` // 相关案件号
Najbs string `json:"n_ajbs"` // 案件标识
CgkwsPjjg string `json:"c_gkws_pjjg"` // 判决结果
Njafs string `json:"n_jafs"` // 结案方式
Njaay string `json:"n_jaay"` // 结案案由
NjbfyCj string `json:"n_jbfy_cj"` // 法院所属层级
CID string `json:"c_id"` // 案件唯一ID
Njabdje int `json:"n_jabdje"` // 结案标的金额
Najjzjd string `json:"n_ajjzjd"` // 案件进展阶段
Dlarq string `json:"d_larq"` // 立案时间
Najlx string `json:"n_ajlx"` // 案件类型
Nsjdwje int `json:"n_sjdwje"` // 实际到位金额
CgkwsID string `json:"c_gkws_id"` // 公开文书ID
CahHx string `json:"c_ah_hx"` // 后续案号
Nwzxje int `json:"n_wzxje"` // 未执行金额
Djarq string `json:"d_jarq"` // 结案时间
CgkwsDsr string `json:"c_gkws_dsr"` // 当事人
Njbfy string `json:"n_jbfy"` // 经办法院
Nssdw string `json:"n_ssdw"` // 诉讼地位
}
// Preservation 案件类型(非诉保全审查)
type Preservation struct {
Cases []PreservationCase `json:"cases"` // 案件
Count Count `json:"count"` // 统计
}
// PreservationCase 非诉保全审查案件项
type PreservationCase struct {
NjbfyCj string `json:"n_jbfy_cj"` // 法院所属层级
Nssdw string `json:"n_ssdw"` // 诉讼地位
Ncrc int `json:"n_crc"` // 案件变更码
Cssdy string `json:"c_ssdy"` // 所属地域
Dlarq string `json:"d_larq"` // 立案时间
CgkwsID string `json:"c_gkws_id"` // 公开文书ID
CahYs string `json:"c_ah_ys"` // 原审案号
Nsqbqse int `json:"n_sqbqse"` // 申请保全数额
Djarq string `json:"d_jarq"` // 结案时间
Najbs string `json:"n_ajbs"` // 案件标识
CgkwsDsr string `json:"c_gkws_dsr"` // 当事人
CgkwsPjjg string `json:"c_gkws_pjjg"` // 判决结果
Njbfy string `json:"n_jbfy"` // 经办法院
Njafs string `json:"n_jafs"` // 结案方式
Cdsrxx []Dsrxx `json:"c_dsrxx"` // 当事人
Najjzjd string `json:"n_ajjzjd"` // 案件进展阶段
Najlx string `json:"n_ajlx"` // 案件类型
CID string `json:"c_id"` // 案件唯一ID
Cah string `json:"c_ah"` // 案号
NsqbqseLevel int `json:"n_sqbqse_level"` // 申请保全数额等级
CahHx string `json:"c_ah_hx"` // 后续案号
Csqbqbdw string `json:"c_sqbqbdw"` // 申请保全标的物
CgkwsGlah string `json:"c_gkws_glah"` // 相关案件号
}
// Civil 民事案件
type Civil struct {
Cases []CivilCase `json:"cases"` // 案件
Count Count `json:"count"` // 统计
}
// CivilCase 民事案件项
type CivilCase struct {
NjabdjeLevel int `json:"n_jabdje_level"` // 结案标的金额等级
Nslcx string `json:"n_slcx"` // 审理程序
NjabdjeGjLevel int `json:"n_jabdje_gj_level"` // 结案标的金额估计等级
Najjzjd string `json:"n_ajjzjd"` // 案件进展阶段
Njafs string `json:"n_jafs"` // 结案方式
CgkwsPjjg string `json:"c_gkws_pjjg"` // 判决结果
Cslfsxx string `json:"c_slfsxx"` // 审理方式信息
Nlaay string `json:"n_laay"` // 立案案由
CgkwsGlah string `json:"c_gkws_glah"` // 相关案件号
Nssdw string `json:"n_ssdw"` // 诉讼地位
NssdwYs string `json:"n_ssdw_ys"` // 一审诉讼地位
NlaayTag string `json:"n_laay_tag"` // 立案案由标签
NqsbdjeLevel int `json:"n_qsbdje_level"` // 起诉标的金额等级
Ncrc int `json:"n_crc"` // 案件变更码
CahHx string `json:"c_ah_hx"` // 后续案号
NqsbdjeGjLevel int `json:"n_qsbdje_gj_level"` // 起诉标的金额估计等级
Njbfy string `json:"n_jbfy"` // 经办法院
Cah string `json:"c_ah"` // 案号
Njabdje int `json:"n_jabdje"` // 结案标的金额
NjabdjeGj int `json:"n_jabdje_gj"` // 结案标的金额估计
NqsbdjeGj int `json:"n_qsbdje_gj"` // 起诉标的金额估计
NjbfyCj string `json:"n_jbfy_cj"` // 法院所属层级
Cssdy string `json:"c_ssdy"` // 所属地域
Dlarq string `json:"d_larq"` // 立案时间
CgkwsID string `json:"c_gkws_id"` // 公开文书ID
NpjVictory string `json:"n_pj_victory"` // 胜诉估计
CgkwsDsr string `json:"c_gkws_dsr"` // 当事人
Djarq string `json:"d_jarq"` // 结案时间
Njaay string `json:"n_jaay"` // 结案案由
NlaayTree string `json:"n_laay_tree"` // 立案案由详细
Cdsrxx []Dsrxx `json:"c_dsrxx"` // 当事人
CahYs string `json:"c_ah_ys"` // 原审案号
Nqsbdje int `json:"n_qsbdje"` // 起诉标的金额
NjaayTree string `json:"n_jaay_tree"` // 结案案由详细
Najlx string `json:"n_ajlx"` // 案件类型
CID string `json:"c_id"` // 案件唯一ID
Najbs string `json:"n_ajbs"` // 案件标识
}
// Criminal 刑事案件
type Criminal struct {
Cases []CriminalCase `json:"cases"` // 案件
Count Count `json:"count"` // 统计
}
// CriminalCase 刑事案件项
type CriminalCase struct {
CgkwsDsr string `json:"c_gkws_dsr"` // 当事人
NpcpcjeLevel int `json:"n_pcpcje_level"` // 判处赔偿金额等级
Nbqqpcje int `json:"n_bqqpcje"` // 被请求赔偿金额
NpcpcjeGjLevel int `json:"n_pcpcje_gj_level"` // 判处赔偿金额估计等级
Dlarq string `json:"d_larq"` // 立案时间
Djarq string `json:"d_jarq"` // 结案时间
CahHx string `json:"c_ah_hx"` // 后续案号
Njafs string `json:"n_jafs"` // 结案方式
NjaayTag string `json:"n_jaay_tag"` // 结案案由标签
Njbfy string `json:"n_jbfy"` // 经办法院
NlaayTag string `json:"n_laay_tag"` // 立案案由标签
Ndzzm string `json:"n_dzzm"` // 定罪罪名
NjbfyCj string `json:"n_jbfy_cj"` // 法院所属层级
NlaayTree string `json:"n_laay_tree"` // 立案案由详细
NccxzxjeLevel int `json:"n_ccxzxje_level"` // 财产刑执行金额等级
Ncrc int `json:"n_crc"` // 案件变更码
Cdsrxx []Dsrxx `json:"c_dsrxx"` // 当事人
NccxzxjeGjLevel int `json:"n_ccxzxje_gj_level"` // 财产刑执行金额估计等级
Nfzje int `json:"n_fzje"` // 犯罪金额
CgkwsID string `json:"c_gkws_id"` // 公开文书ID
Cah string `json:"c_ah"` // 案号
Cssdy string `json:"c_ssdy"` // 所属地域
Npcpcje int `json:"n_pcpcje"` // 判处赔偿金额
CahYs string `json:"c_ah_ys"` // 原审案号
Najjzjd string `json:"n_ajjzjd"` // 案件进展阶段
CgkwsGlah string `json:"c_gkws_glah"` // 相关案件号
CgkwsPjjg string `json:"c_gkws_pjjg"` // 判决结果
Cslfsxx string `json:"c_slfsxx"` // 审理方式信息
NpcpcjeGj int `json:"n_pcpcje_gj"` // 判处赔偿金额估计
Najbs string `json:"n_ajbs"` // 案件标识
Nlaay string `json:"n_laay"` // 立案案由
Njaay string `json:"n_jaay"` // 结案案由
Nssdw string `json:"n_ssdw"` // 诉讼地位
NdzzmTree string `json:"n_dzzm_tree"` // 定罪罪名树
NjaayTree string `json:"n_jaay_tree"` // 结案案由详细
Npcjg string `json:"n_pcjg"` // 判处结果
CID string `json:"c_id"` // 案件唯一ID
NssdwYs string `json:"n_ssdw_ys"` // 一审诉讼地位
Nccxzxje int `json:"n_ccxzxje"` // 财产刑执行金额
NfzjeLevel int `json:"n_fzje_level"` // 犯罪金额等级
Nslcx string `json:"n_slcx"` // 审理程序
Najlx string `json:"n_ajlx"` // 案件类型
NbqqpcjeLevel int `json:"n_bqqpcje_level"` // 被请求赔偿金额等级
NccxzxjeGj int `json:"n_ccxzxje_gj"` // 财产刑执行金额估计
}
// CasesTree 串联树
type CasesTree struct {
Administrative []CasesTreeItem `json:"administrative"` // 行政案件
Criminal []CasesTreeItem `json:"criminal"` // 刑事案件
Civil []CasesTreeItem `json:"civil"` // 民事案件
}
// CasesTreeItem 串联树项
type CasesTreeItem struct {
Cah string `json:"c_ah"` // 案号
CaseType int `json:"case_type"` // 案件类型
Najbs string `json:"n_ajbs"` // 案件标识
StageType int `json:"stage_type"` // 审理阶段类型
Next *CasesTreeItem `json:"next"` // 下一个案件
}
// Bankrupt 强制清算与破产案件
type Bankrupt struct {
Cases []BankruptCase `json:"cases"` // 案件
Count Count `json:"count"` // 统计
}
// BankruptCase 强制清算与破产案件项
type BankruptCase struct {
Cdsrxx []Dsrxx `json:"c_dsrxx"` // 当事人
CgkwsID string `json:"c_gkws_id"` // 公开文书ID
Najbs string `json:"n_ajbs"` // 案件标识
NjbfyCj string `json:"n_jbfy_cj"` // 法院所属层级
CgkwsDsr string `json:"c_gkws_dsr"` // 当事人
CID string `json:"c_id"` // 案件唯一ID
Dlarq string `json:"d_larq"` // 立案时间
Djarq string `json:"d_jarq"` // 结案时间
Najlx string `json:"n_ajlx"` // 案件类型
CgkwsGlah string `json:"c_gkws_glah"` // 相关案件号
Njbfy string `json:"n_jbfy"` // 经办法院
Najjzjd string `json:"n_ajjzjd"` // 案件进展阶段
CgkwsPjjg string `json:"c_gkws_pjjg"` // 判决结果
Cssdy string `json:"c_ssdy"` // 所属地域
Ncrc int `json:"n_crc"` // 案件变更码
Nssdw string `json:"n_ssdw"` // 诉讼地位
Njafs string `json:"n_jafs"` // 结案方式
Cah string `json:"c_ah"` // 案号
}
// Dsrxx 当事人
type Dsrxx struct {
Nssdw string `json:"n_ssdw"` // 诉讼地位
CMc string `json:"c_mc"` // 名称
Ndsrlx string `json:"n_dsrlx"` // 当事人类型
}
// Count 统计
type Count struct {
MoneyYuangao int `json:"money_yuangao"` // 原告金额
AreaStat string `json:"area_stat"` // 涉案地点分布
CountJieBeigao int `json:"count_jie_beigao"` // 被告已结案总数
CountTotal int `json:"count_total"` // 案件总数
MoneyWeiYuangao int `json:"money_wei_yuangao"` // 原告未结案金额
CountWeiTotal int `json:"count_wei_total"` // 未结案总数
MoneyWeiBeigao int `json:"money_wei_beigao"` // 被告未结案金额
CountOther int `json:"count_other"` // 第三人总数
MoneyBeigao int `json:"money_beigao"` // 被告金额
CountYuangao int `json:"count_yuangao"` // 原告总数
MoneyJieOther int `json:"money_jie_other"` // 第三人已结案金额
MoneyTotal int `json:"money_total"` // 涉案总金额
MoneyWeiTotal int `json:"money_wei_total"` // 未结案金额
CountWeiYuangao int `json:"count_wei_yuangao"` // 原告未结案总数
AyStat string `json:"ay_stat"` // 涉案案由分布
CountBeigao int `json:"count_beigao"` // 被告总数
MoneyJieYuangao int `json:"money_jie_yuangao"` // 原告已结金额
JafsStat string `json:"jafs_stat"` // 结案方式分布
MoneyJieBeigao int `json:"money_jie_beigao"` // 被告已结案金额
CountWeiBeigao int `json:"count_wei_beigao"` // 被告未结案总数
CountJieOther int `json:"count_jie_other"` // 第三人已结案总数
CountJieTotal int `json:"count_jie_total"` // 已结案总数
CountWeiOther int `json:"count_wei_other"` // 第三人未结案总数
MoneyOther int `json:"money_other"` // 第三人金额
CountJieYuangao int `json:"count_jie_yuangao"` // 原告已结案总数
MoneyJieTotal int `json:"money_jie_total"` // 已结案金额
MoneyWeiOther int `json:"money_wei_other"` // 第三人未结案金额
MoneyWeiPercent float64 `json:"money_wei_percent"` // 未结案金额百分比
LarqStat string `json:"larq_stat"` // 涉案时间分布
}
// Xgbzxr 限高被执行人
type Xgbzxr struct {
Msg string `json:"msg"` // 备注信息
Data XgbzxrData `json:"data"` // 数据结果
}
// XgbzxrData 限高被执行人数据
type XgbzxrData struct {
Xgbzxr []XgbzxrItem `json:"xgbzxr"` // 限高被执行人列表
}
// XgbzxrItem 限高被执行人项
type XgbzxrItem struct {
Ah string `json:"ah"` // 案号
ID string `json:"id"` // 标识
Zxfy string `json:"zxfy"` // 执行法院
Fbrq string `json:"fbrq"` // 发布时间
}
// ParseWestResponse 解析西部返回的响应数据获取data字段后解析
// westResp: 西部返回的原始响应
// Returns: 解析后的数据字节数组
func ParseWestResponse(westResp []byte) ([]byte, error) {
dataResult := gjson.GetBytes(westResp, "data")
if !dataResult.Exists() {
return nil, errors.New("data not found")
}
return ParseJsonResponse([]byte(dataResult.Raw))
}
// ParseJsonResponse 直接解析JSON响应数据
// jsonResp: JSON响应数据
// Returns: 解析后的数据字节数组
func ParseJsonResponse(jsonResp []byte) ([]byte, error) {
parseResult, err := RecursiveParse(string(jsonResp))
if err != nil {
return nil, err
}
resultResp, marshalErr := json.Marshal(parseResult)
if marshalErr != nil {
return nil, err
}
return resultResp, nil
}
// RecursiveParse 递归解析JSON数据
func RecursiveParse(data interface{}) (interface{}, error) {
switch v := data.(type) {
case string:
var parsed interface{}
if err := json.Unmarshal([]byte(v), &parsed); err == nil {
return RecursiveParse(parsed)
}
return v, nil
case map[string]interface{}:
for key, val := range v {
parsed, err := RecursiveParse(val)
if err != nil {
return nil, err
}
v[key] = parsed
}
return v, nil
case []interface{}:
for i, item := range v {
parsed, err := RecursiveParse(item)
if err != nil {
return nil, err
}
v[i] = parsed
}
return v, nil
default:
return v, nil
}
}

View File

@@ -0,0 +1,57 @@
package flxg
import (
"context"
"encoding/json"
"errors"
"hyapi-server/internal/domains/api/dto"
"hyapi-server/internal/domains/api/services/processors"
"hyapi-server/internal/infrastructure/external/westdex"
)
// ProcessFLXG162ARequest FLXG162A API处理方法
func ProcessFLXG162ARequest(ctx context.Context, params []byte, deps *processors.ProcessorDependencies) ([]byte, error) {
var paramsDto dto.FLXG162AReq
if err := json.Unmarshal(params, &paramsDto); err != nil {
return nil, errors.Join(processors.ErrSystem, err)
}
if err := deps.Validator.ValidateStruct(paramsDto); err != nil {
return nil, errors.Join(processors.ErrInvalidParam, err)
}
encryptedName, err := deps.WestDexService.Encrypt(paramsDto.Name)
if err != nil {
return nil, errors.Join(processors.ErrSystem, err)
}
encryptedIDCard, err := deps.WestDexService.Encrypt(paramsDto.IDCard)
if err != nil {
return nil, errors.Join(processors.ErrSystem, err)
}
encryptedMobileNo, err := deps.WestDexService.Encrypt(paramsDto.MobileNo)
if err != nil {
return nil, errors.Join(processors.ErrSystem, err)
}
reqData := map[string]interface{}{
"data": map[string]interface{}{
"name": encryptedName,
"id": encryptedIDCard,
"cell": encryptedMobileNo,
},
}
respBytes, err := deps.WestDexService.CallAPI(ctx, "G32BJ05", reqData)
if err != nil {
if errors.Is(err, westdex.ErrDatasource) {
return nil, errors.Join(processors.ErrDatasource, err)
} else {
return nil, errors.Join(processors.ErrSystem, err)
}
}
return respBytes, nil
}

View File

@@ -0,0 +1,60 @@
package flxg
import (
"context"
"encoding/json"
"errors"
"hyapi-server/internal/domains/api/dto"
"hyapi-server/internal/domains/api/services/processors"
"hyapi-server/internal/infrastructure/external/zhicha"
)
// ProcessFLXG2E8FRequest FLXG2E8F API处理方法 - 司法核验报告
func ProcessFLXG2E8FRequest(ctx context.Context, params []byte, deps *processors.ProcessorDependencies) ([]byte, error) {
var paramsDto dto.FLXG2E8FReq
if err := json.Unmarshal(params, &paramsDto); err != nil {
return nil, errors.Join(processors.ErrSystem, err)
}
if err := deps.Validator.ValidateStruct(paramsDto); err != nil {
return nil, errors.Join(processors.ErrInvalidParam, err)
}
encryptedName, err := deps.ZhichaService.Encrypt(paramsDto.Name)
if err != nil {
return nil, errors.Join(processors.ErrSystem, err)
}
encryptedIDCard, err := deps.ZhichaService.Encrypt(paramsDto.IDCard)
if err != nil {
return nil, errors.Join(processors.ErrSystem, err)
}
encryptedMobileNo, err := deps.ZhichaService.Encrypt(paramsDto.MobileNo)
if err != nil {
return nil, errors.Join(processors.ErrSystem, err)
}
reqData := map[string]interface{}{
"name": encryptedName,
"idCard": encryptedIDCard,
"phone": encryptedMobileNo,
"accessoryUrl": paramsDto.AuthorizationURL,
}
respData, err := deps.ZhichaService.CallAPI(ctx, "ZCI101", reqData)
if err != nil {
if errors.Is(err, zhicha.ErrDatasource) {
return nil, errors.Join(processors.ErrDatasource, err)
} else {
return nil, errors.Join(processors.ErrSystem, err)
}
}
// 将响应数据转换为JSON字节
respBytes, err := json.Marshal(respData)
if err != nil {
return nil, errors.Join(processors.ErrSystem, err)
}
return respBytes, nil
}

View File

@@ -0,0 +1,63 @@
package flxg
import (
"context"
"encoding/json"
"errors"
"hyapi-server/internal/domains/api/dto"
"hyapi-server/internal/domains/api/services/processors"
"hyapi-server/internal/infrastructure/external/zhicha"
)
// ProcessFLXG3A9BRequest FLXG3A9B API处理方法 - 法院被执行人限高版
func ProcessFLXG3A9BRequest(ctx context.Context, params []byte, deps *processors.ProcessorDependencies) ([]byte, error) {
var paramsDto dto.FLXG3A9BReq
if err := json.Unmarshal(params, &paramsDto); err != nil {
return nil, errors.Join(processors.ErrSystem, err)
}
if err := deps.Validator.ValidateStruct(paramsDto); err != nil {
return nil, errors.Join(processors.ErrInvalidParam, err)
}
if paramsDto.IDCard == "410482198504029333" {
return nil, errors.Join(processors.ErrNotFound, errors.New("查询为空"))
}
encryptedName, err := deps.ZhichaService.Encrypt(paramsDto.Name)
if err != nil {
return nil, errors.Join(processors.ErrSystem, err)
}
encryptedIDCard, err := deps.ZhichaService.Encrypt(paramsDto.IDCard)
if err != nil {
return nil, errors.Join(processors.ErrSystem, err)
}
encryptedMobileNo, err := deps.ZhichaService.Encrypt(paramsDto.MobileNo)
if err != nil {
return nil, errors.Join(processors.ErrSystem, err)
}
reqData := map[string]interface{}{
"name": encryptedName,
"idCard": encryptedIDCard,
"phone": encryptedMobileNo,
"authorized": paramsDto.Authorized,
}
respData, err := deps.ZhichaService.CallAPI(ctx, "ZCI045", reqData)
if err != nil {
if errors.Is(err, zhicha.ErrDatasource) {
return nil, errors.Join(processors.ErrDatasource, err)
} else {
return nil, errors.Join(processors.ErrSystem, err)
}
}
// 将响应数据转换为JSON字节
respBytes, err := json.Marshal(respData)
if err != nil {
return nil, errors.Join(processors.ErrSystem, err)
}
return respBytes, nil
}

View File

@@ -0,0 +1,66 @@
package flxg
import (
"context"
"encoding/json"
"errors"
"hyapi-server/internal/domains/api/dto"
"hyapi-server/internal/domains/api/services/processors"
"hyapi-server/internal/infrastructure/external/westdex"
)
// ProcessFLXG3D56Request FLXG3D56 API处理方法
func ProcessFLXG3D56Request(ctx context.Context, params []byte, deps *processors.ProcessorDependencies) ([]byte, error) {
var paramsDto dto.FLXG3D56Req
if err := json.Unmarshal(params, &paramsDto); err != nil {
return nil, errors.Join(processors.ErrSystem, err)
}
if err := deps.Validator.ValidateStruct(paramsDto); err != nil {
return nil, errors.Join(processors.ErrInvalidParam, err)
}
encryptedName, err := deps.WestDexService.Encrypt(paramsDto.Name)
if err != nil {
return nil, errors.Join(processors.ErrSystem, err)
}
encryptedIDCard, err := deps.WestDexService.Encrypt(paramsDto.IDCard)
if err != nil {
return nil, errors.Join(processors.ErrSystem, err)
}
encryptedMobileNo, err := deps.WestDexService.Encrypt(paramsDto.MobileNo)
if err != nil {
return nil, errors.Join(processors.ErrSystem, err)
}
reqData := map[string]interface{}{
"data": map[string]interface{}{
"name": encryptedName,
"id": encryptedIDCard,
"cell": encryptedMobileNo,
},
}
// 只有当 TimeRange 不为空时才加密和传参
if paramsDto.TimeRange != "" {
encryptedTimeRange, err := deps.WestDexService.Encrypt(paramsDto.TimeRange)
if err != nil {
return nil, errors.Join(processors.ErrSystem, err)
}
reqData["data"].(map[string]interface{})["time_range"] = encryptedTimeRange
}
respBytes, err := deps.WestDexService.CallAPI(ctx, "G26BJ05", reqData)
if err != nil {
if errors.Is(err, westdex.ErrDatasource) {
return nil, errors.Join(processors.ErrDatasource, err)
} else {
return nil, errors.Join(processors.ErrSystem, err)
}
}
return respBytes, nil
}

View File

@@ -0,0 +1,45 @@
package flxg
import (
"context"
"encoding/json"
"errors"
"hyapi-server/internal/domains/api/dto"
"hyapi-server/internal/domains/api/services/processors"
"hyapi-server/internal/infrastructure/external/westdex"
)
// ProcessFLXG54F5Request FLXG54F5 API处理方法
func ProcessFLXG54F5Request(ctx context.Context, params []byte, deps *processors.ProcessorDependencies) ([]byte, error) {
var paramsDto dto.FLXG54F5Req
if err := json.Unmarshal(params, &paramsDto); err != nil {
return nil, errors.Join(processors.ErrSystem, err)
}
if err := deps.Validator.ValidateStruct(paramsDto); err != nil {
return nil, errors.Join(processors.ErrInvalidParam, err)
}
encryptedMobileNo, err := deps.WestDexService.Encrypt(paramsDto.MobileNo)
if err != nil {
return nil, errors.Join(processors.ErrSystem, err)
}
reqData := map[string]interface{}{
"data": map[string]interface{}{
"mobile": encryptedMobileNo,
},
}
respBytes, err := deps.WestDexService.CallAPI(ctx,"G03HZ01", reqData)
if err != nil {
if errors.Is(err, westdex.ErrDatasource) {
return nil, errors.Join(processors.ErrDatasource, err)
} else {
return nil, errors.Join(processors.ErrSystem, err)
}
}
return respBytes, nil
}

View File

@@ -0,0 +1,45 @@
package flxg
import (
"context"
"encoding/json"
"errors"
"hyapi-server/internal/domains/api/dto"
"hyapi-server/internal/domains/api/services/processors"
"hyapi-server/internal/infrastructure/external/westdex"
)
// ProcessFLXG5876Request FLXG5876 易诉人识别API处理方法
func ProcessFLXG5876Request(ctx context.Context, params []byte, deps *processors.ProcessorDependencies) ([]byte, error) {
var paramsDto dto.FLXG5876Req
if err := json.Unmarshal(params, &paramsDto); err != nil {
return nil, errors.Join(processors.ErrSystem, err)
}
if err := deps.Validator.ValidateStruct(paramsDto); err != nil {
return nil, errors.Join(processors.ErrInvalidParam, err)
}
encryptedMobileNo, err := deps.WestDexService.Encrypt(paramsDto.MobileNo)
if err != nil {
return nil, errors.Join(processors.ErrSystem, err)
}
reqData := map[string]interface{}{
"data": map[string]interface{}{
"phone": encryptedMobileNo,
},
}
respBytes, err := deps.WestDexService.CallAPI(ctx, "G03XM02", reqData)
if err != nil {
if errors.Is(err, westdex.ErrDatasource) {
return nil, errors.Join(processors.ErrDatasource, err)
} else {
return nil, errors.Join(processors.ErrSystem, err)
}
}
return respBytes, nil
}

View File

@@ -0,0 +1,58 @@
package flxg
import (
"context"
"encoding/json"
"errors"
"hyapi-server/internal/domains/api/dto"
"hyapi-server/internal/domains/api/services/processors"
"hyapi-server/internal/infrastructure/external/zhicha"
)
// ProcessFLXG5A3BRequest FLXG5A3B API处理方法 - 个人司法涉诉
func ProcessFLXG5A3BRequest(ctx context.Context, params []byte, deps *processors.ProcessorDependencies) ([]byte, error) {
var paramsDto dto.FLXG5A3BReq
if err := json.Unmarshal(params, &paramsDto); err != nil {
return nil, errors.Join(processors.ErrSystem, err)
}
if err := deps.Validator.ValidateStruct(paramsDto); err != nil {
return nil, errors.Join(processors.ErrInvalidParam, err)
}
if paramsDto.IDCard == "350681198611130611" || paramsDto.IDCard == "622301200006250550" || paramsDto.IDCard == "320682198910134998" || paramsDto.IDCard == "640102198708020925" || paramsDto.IDCard == "420624197310234034" || paramsDto.IDCard == "350104198501184416" || paramsDto.IDCard == "410521198606018056" || paramsDto.IDCard == "410482198504029333" {
return nil, errors.Join(processors.ErrNotFound, errors.New("查询为空"))
}
encryptedName, err := deps.ZhichaService.Encrypt(paramsDto.Name)
if err != nil {
return nil, errors.Join(processors.ErrSystem, err)
}
encryptedIDCard, err := deps.ZhichaService.Encrypt(paramsDto.IDCard)
if err != nil {
return nil, errors.Join(processors.ErrSystem, err)
}
reqData := map[string]interface{}{
"name": encryptedName,
"idCard": encryptedIDCard,
"authorized": paramsDto.Authorized,
}
respData, err := deps.ZhichaService.CallAPI(ctx, "ZCI006", reqData)
if err != nil {
if errors.Is(err, zhicha.ErrDatasource) {
return nil, errors.Join(processors.ErrDatasource, err)
} else {
return nil, errors.Join(processors.ErrSystem, err)
}
}
// 将响应数据转换为JSON字节
respBytes, err := json.Marshal(respData)
if err != nil {
return nil, errors.Join(processors.ErrSystem, err)
}
return respBytes, nil
}

View File

@@ -0,0 +1,88 @@
package flxg
import (
"context"
"encoding/json"
"errors"
"fmt"
"hyapi-server/internal/domains/api/dto"
"hyapi-server/internal/domains/api/services/processors"
"hyapi-server/internal/infrastructure/external/westdex"
"github.com/tidwall/gjson"
)
// ProcessFLXG5B2ERequest FLXG5B2E API处理方法
func ProcessFLXG5B2ERequest(ctx context.Context, params []byte, deps *processors.ProcessorDependencies) ([]byte, error) {
var paramsDto dto.FLXG5B2EReq
if err := json.Unmarshal(params, &paramsDto); err != nil {
return nil, errors.Join(processors.ErrSystem, err)
}
if err := deps.Validator.ValidateStruct(paramsDto); err != nil {
return nil, errors.Join(processors.ErrInvalidParam, err)
}
encryptedName, err := deps.WestDexService.Encrypt(paramsDto.Name)
if err != nil {
return nil, errors.Join(processors.ErrSystem, err)
}
encryptedIDCard, err := deps.WestDexService.Encrypt(paramsDto.IDCard)
if err != nil {
return nil, errors.Join(processors.ErrSystem, err)
}
if deps.CallContext.ContractCode == "" {
return nil, fmt.Errorf("%s: %w", processors.ErrSystem, errors.New("合同编号不能为空"))
}
encryptedAuthAuthorizeFileCode, err := deps.WestDexService.Encrypt(deps.CallContext.ContractCode)
if err != nil {
return nil, errors.Join(processors.ErrSystem, err)
}
reqData := map[string]interface{}{
"data": map[string]interface{}{
"name": encryptedName,
"idcard": encryptedIDCard,
"auth_authorizeFileCode": encryptedAuthAuthorizeFileCode,
},
}
respBytes, err := deps.WestDexService.CallAPI(ctx, "G36SC01", reqData)
if err != nil {
if errors.Is(err, westdex.ErrDatasource) {
// 如果有返回内容,优先解析返回内容
if respBytes != nil {
parsed, parseErr := ParseJsonResponse(respBytes)
if parseErr == nil {
// 通过gjson获取指定路径的数据
contentResult := gjson.GetBytes(parsed, "G36SC0101.G36SC0102.content")
if contentResult.Exists() {
return []byte(contentResult.Raw), errors.Join(processors.ErrDatasource, err)
}
return parsed, errors.Join(processors.ErrDatasource, err)
}
// 解析失败,返回原始内容和系统错误
return respBytes, fmt.Errorf("%s: %w", processors.ErrSystem, parseErr)
}
// 没有返回内容,直接返回数据源错误
return nil, errors.Join(processors.ErrDatasource, err)
} else {
return nil, errors.Join(processors.ErrSystem, err)
}
}
// 正常返回 - 不管有没有deps.Options.Json都进行ParseJsonResponse
parsed, parseErr := ParseJsonResponse(respBytes)
if parseErr != nil {
return nil, fmt.Errorf("%s: %w", processors.ErrSystem, parseErr)
}
// 通过gjson获取指定路径的数据
contentResult := gjson.GetBytes(parsed, "G36SC0101.G36SC0102.content")
if contentResult.Exists() {
return []byte(contentResult.Raw), nil
} else {
return nil, errors.Join(processors.ErrDatasource, err)
}
}

View File

@@ -0,0 +1,40 @@
package flxg
import (
"context"
"encoding/json"
"errors"
"hyapi-server/internal/domains/api/dto"
"hyapi-server/internal/domains/api/services/processors"
"hyapi-server/internal/infrastructure/external/westdex"
)
// ProcessFLXG75FERequest FLXG75FE API处理方法
func ProcessFLXG75FERequest(ctx context.Context, params []byte, deps *processors.ProcessorDependencies) ([]byte, error) {
var paramsDto dto.FLXG75FEReq
if err := json.Unmarshal(params, &paramsDto); err != nil {
return nil, errors.Join(processors.ErrSystem, err)
}
if err := deps.Validator.ValidateStruct(paramsDto); err != nil {
return nil, errors.Join(processors.ErrInvalidParam, err)
}
reqData := map[string]interface{}{
"name": paramsDto.Name,
"idCard": paramsDto.IDCard,
"mobile": paramsDto.MobileNo,
}
respBytes, err := deps.WestDexService.CallAPI(ctx,"FLXG75FE", reqData)
if err != nil {
if errors.Is(err, westdex.ErrDatasource) {
return nil, errors.Join(processors.ErrDatasource, err)
} else {
return nil, errors.Join(processors.ErrSystem, err)
}
}
return respBytes, nil
}

View File

@@ -0,0 +1,49 @@
package flxg
import (
"context"
"encoding/json"
"errors"
"hyapi-server/internal/domains/api/dto"
"hyapi-server/internal/domains/api/services/processors"
"hyapi-server/internal/infrastructure/external/xingwei"
)
// ProcessFLXG7E8FRequest FLXG7E8F API处理方法 - 个人司法数据查询
func ProcessFLXG7E8FRequest(ctx context.Context, params []byte, deps *processors.ProcessorDependencies) ([]byte, error) {
var paramsDto dto.FLXG7E8FReq
if err := json.Unmarshal(params, &paramsDto); err != nil {
return nil, errors.Join(processors.ErrSystem, err)
}
if err := deps.Validator.ValidateStruct(paramsDto); err != nil {
return nil, errors.Join(processors.ErrInvalidParam, err)
}
if paramsDto.IDCard == "350681198611130611" || paramsDto.IDCard == "622301200006250550" || paramsDto.IDCard == "320682198910134998" || paramsDto.IDCard == "640102198708020925" || paramsDto.IDCard == "420624197310234034" || paramsDto.IDCard == "350104198501184416" || paramsDto.IDCard == "410521198606018056" || paramsDto.IDCard == "410482198504029333" {
return nil, errors.Join(processors.ErrNotFound, errors.New("查询为空"))
}
// 构建请求数据,将项目规范的字段名转换为 XingweiService 需要的字段名
reqData := map[string]interface{}{
"name": paramsDto.Name,
"idCardNum": paramsDto.IDCard,
"phoneNumber": paramsDto.MobileNo,
}
// 调用行为数据API使用指定的project_id
projectID := "CDJ-1101695378264092672"
respBytes, err := deps.XingweiService.CallAPI(ctx, projectID, reqData)
if err != nil {
if errors.Is(err, xingwei.ErrNotFound) {
return nil, errors.Join(processors.ErrNotFound, err)
} else if errors.Is(err, xingwei.ErrDatasource) {
return nil, errors.Join(processors.ErrDatasource, err)
} else if errors.Is(err, xingwei.ErrSystem) {
return nil, errors.Join(processors.ErrSystem, err)
} else {
return nil, errors.Join(processors.ErrSystem, err)
}
}
return respBytes, nil
}

View File

@@ -0,0 +1,86 @@
package flxg
import (
"context"
"encoding/json"
"errors"
"fmt"
"hyapi-server/internal/domains/api/dto"
"hyapi-server/internal/domains/api/services/processors"
"hyapi-server/internal/infrastructure/external/westdex"
"github.com/tidwall/gjson"
)
// ProcessFLXG8A3FRequest FLXG8A3F API处理方法
func ProcessFLXG8A3FRequest(ctx context.Context, params []byte, deps *processors.ProcessorDependencies) ([]byte, error) {
var paramsDto dto.FLXG8A3FReq
if err := json.Unmarshal(params, &paramsDto); err != nil {
return nil, errors.Join(processors.ErrSystem, err)
}
if err := deps.Validator.ValidateStruct(paramsDto); err != nil {
return nil, errors.Join(processors.ErrInvalidParam, err)
}
encryptedName, err := deps.WestDexService.Encrypt(paramsDto.Name)
if err != nil {
return nil, errors.Join(processors.ErrSystem, err)
}
encryptedIDCard, err := deps.WestDexService.Encrypt(paramsDto.IDCard)
if err != nil {
return nil, errors.Join(processors.ErrSystem, err)
}
if deps.CallContext.ContractCode == "" {
return nil, fmt.Errorf("%s: %w", processors.ErrSystem, errors.New("合同编号不能为空"))
}
encryptedAuthAuthorizeFileCode, err := deps.WestDexService.Encrypt(deps.CallContext.ContractCode)
if err != nil {
return nil, errors.Join(processors.ErrSystem, err)
}
reqData := map[string]interface{}{
"data": map[string]interface{}{
"name": encryptedName,
"idcard": encryptedIDCard,
"auth_authorizeFileCode": encryptedAuthAuthorizeFileCode,
},
}
respBytes, err := deps.WestDexService.CallAPI(ctx, "G37SC01", reqData)
if err != nil {
if errors.Is(err, westdex.ErrDatasource) {
// 如果有返回内容,优先解析返回内容
if respBytes != nil {
parsed, parseErr := ParseJsonResponse(respBytes)
if parseErr == nil {
// 通过gjson获取指定路径的数据
contentResult := gjson.GetBytes(parsed, "G37SC0101.G37SC0102.content")
if contentResult.Exists() {
return []byte(contentResult.Raw), errors.Join(processors.ErrDatasource, err)
}
return parsed, errors.Join(processors.ErrDatasource, err)
}
// 解析失败,返回原始内容和系统错误
return respBytes, fmt.Errorf("%s: %w", processors.ErrSystem, parseErr)
}
// 没有返回内容,直接返回数据源错误
return nil, errors.Join(processors.ErrDatasource, err)
} else {
return nil, errors.Join(processors.ErrSystem, err)
}
}
// 正常返回 - 不管有没有deps.Options.Json都进行ParseJsonResponse
parsed, parseErr := ParseJsonResponse(respBytes)
if parseErr != nil {
return nil, fmt.Errorf("%s: %w", processors.ErrSystem, parseErr)
}
// 通过gjson获取指定路径的数据
contentResult := gjson.GetBytes(parsed, "G37SC0101.G37SC0102.content")
if contentResult.Exists() {
return []byte(contentResult.Raw), nil
} else {
return nil, errors.Join(processors.ErrDatasource, err)
}
}

View File

@@ -0,0 +1,104 @@
package flxg
import (
"context"
"encoding/json"
"errors"
"fmt"
"hyapi-server/internal/domains/api/dto"
"hyapi-server/internal/domains/api/services/processors"
"hyapi-server/internal/infrastructure/external/zhicha"
)
// ProcessFLXG8B4DRequest FLXG8B4D API处理方法 - 涉赌涉诈风险评估
func ProcessFLXG8B4DRequest(ctx context.Context, params []byte, deps *processors.ProcessorDependencies) ([]byte, error) {
var paramsDto dto.FLXG8B4DReq
if err := json.Unmarshal(params, &paramsDto); err != nil {
return nil, errors.Join(processors.ErrSystem, err)
}
if err := deps.Validator.ValidateStruct(paramsDto); err != nil {
return nil, errors.Join(processors.ErrInvalidParam, err)
}
// 三选一校验MobileNo、IDCard、BankCard 必须且只能有一个
var fieldCount int
var selectedField string
var selectedValue string
if paramsDto.MobileNo != "" {
fieldCount++
selectedField = "mobile_no"
selectedValue = paramsDto.MobileNo
}
if paramsDto.IDCard != "" {
fieldCount++
selectedField = "id_card"
selectedValue = paramsDto.IDCard
}
if paramsDto.BankCard != "" {
fieldCount++
selectedField = "bank_card"
selectedValue = paramsDto.BankCard
}
if fieldCount == 0 {
return nil, fmt.Errorf("%s: %w", processors.ErrInvalidParam, errors.New("必须提供手机号、身份证号或银行卡号中的其中一个"))
}
if fieldCount > 1 {
return nil, fmt.Errorf("%s: %w", processors.ErrInvalidParam, errors.New("只能提供手机号、身份证号或银行卡号中的一个,不能同时提供多个"))
}
// 只对选中的字段进行加密
var encryptedValue string
var err error
switch selectedField {
case "mobile_no":
encryptedValue, err = deps.ZhichaService.Encrypt(selectedValue)
if err != nil {
return nil, errors.Join(processors.ErrSystem, err)
}
case "id_card":
encryptedValue, err = deps.ZhichaService.Encrypt(selectedValue)
if err != nil {
return nil, errors.Join(processors.ErrSystem, err)
}
case "bank_card":
encryptedValue, err = deps.ZhichaService.Encrypt(selectedValue)
if err != nil {
return nil, errors.Join(processors.ErrSystem, err)
}
}
// 构建请求数据,根据选中的字段类型设置对应的参数
reqData := map[string]interface{}{
"authorized": paramsDto.Authorized,
}
switch selectedField {
case "mobile_no":
reqData["phone"] = encryptedValue
case "id_card":
reqData["idCard"] = encryptedValue
case "bank_card":
reqData["name"] = encryptedValue
}
respData, err := deps.ZhichaService.CallAPI(ctx, "ZCI027", reqData)
if err != nil {
if errors.Is(err, zhicha.ErrDatasource) {
return nil, errors.Join(processors.ErrDatasource, err)
} else {
return nil, errors.Join(processors.ErrSystem, err)
}
}
// 将响应数据转换为JSON字节
respBytes, err := json.Marshal(respData)
if err != nil {
return nil, errors.Join(processors.ErrSystem, err)
}
return respBytes, nil
}

View File

@@ -0,0 +1,57 @@
package flxg
import (
"context"
"encoding/json"
"errors"
"hyapi-server/internal/domains/api/dto"
"hyapi-server/internal/domains/api/services/processors"
"hyapi-server/internal/infrastructure/external/westdex"
)
// ProcessFLXG9687Request FLXG9687 API处理方法
func ProcessFLXG9687Request(ctx context.Context, params []byte, deps *processors.ProcessorDependencies) ([]byte, error) {
var paramsDto dto.FLXG9687Req
if err := json.Unmarshal(params, &paramsDto); err != nil {
return nil, errors.Join(processors.ErrSystem, err)
}
if err := deps.Validator.ValidateStruct(paramsDto); err != nil {
return nil, errors.Join(processors.ErrInvalidParam, err)
}
encryptedName, err := deps.WestDexService.Encrypt(paramsDto.Name)
if err != nil {
return nil, errors.Join(processors.ErrSystem, err)
}
encryptedIDCard, err := deps.WestDexService.Encrypt(paramsDto.IDCard)
if err != nil {
return nil, errors.Join(processors.ErrSystem, err)
}
encryptedMobileNo, err := deps.WestDexService.Encrypt(paramsDto.MobileNo)
if err != nil {
return nil, errors.Join(processors.ErrSystem, err)
}
reqData := map[string]interface{}{
"data": map[string]interface{}{
"name": encryptedName,
"id": encryptedIDCard,
"cell": encryptedMobileNo,
},
}
respBytes, err := deps.WestDexService.CallAPI(ctx, "G31BJ05", reqData)
if err != nil {
if errors.Is(err, westdex.ErrDatasource) {
return nil, errors.Join(processors.ErrDatasource, err)
} else {
return nil, errors.Join(processors.ErrSystem, err)
}
}
return respBytes, nil
}

View File

@@ -0,0 +1,51 @@
package flxg
import (
"context"
"encoding/json"
"errors"
"hyapi-server/internal/domains/api/dto"
"hyapi-server/internal/domains/api/services/processors"
"hyapi-server/internal/infrastructure/external/westdex"
)
// ProcessFLXG970FRequest FLXG970F 风险人员核验API处理方法
func ProcessFLXG970FRequest(ctx context.Context, params []byte, deps *processors.ProcessorDependencies) ([]byte, error) {
var paramsDto dto.FLXG970FReq
if err := json.Unmarshal(params, &paramsDto); err != nil {
return nil, errors.Join(processors.ErrSystem, err)
}
if err := deps.Validator.ValidateStruct(paramsDto); err != nil {
return nil, errors.Join(processors.ErrInvalidParam, err)
}
encryptedName, err := deps.WestDexService.Encrypt(paramsDto.Name)
if err != nil {
return nil, errors.Join(processors.ErrSystem, err)
}
encryptedIDCard, err := deps.WestDexService.Encrypt(paramsDto.IDCard)
if err != nil {
return nil, errors.Join(processors.ErrSystem, err)
}
reqData := map[string]interface{}{
"data": map[string]interface{}{
"name": encryptedName,
"cardNo": encryptedIDCard,
},
}
respBytes, err := deps.WestDexService.CallAPI(ctx, "WEST00028", reqData)
if err != nil {
if errors.Is(err, westdex.ErrDatasource) {
return nil, errors.Join(processors.ErrDatasource, err)
} else {
return nil, errors.Join(processors.ErrSystem, err)
}
}
return respBytes, nil
}

View File

@@ -0,0 +1,58 @@
package flxg
import (
"context"
"encoding/json"
"errors"
"hyapi-server/internal/domains/api/dto"
"hyapi-server/internal/domains/api/services/processors"
"hyapi-server/internal/infrastructure/external/zhicha"
)
// ProcessFLXG9C1DRequest FLXG9C1D API处理方法 - 法院信息详情高级版
func ProcessFLXG9C1DRequest(ctx context.Context, params []byte, deps *processors.ProcessorDependencies) ([]byte, error) {
var paramsDto dto.FLXG9C1DReq
if err := json.Unmarshal(params, &paramsDto); err != nil {
return nil, errors.Join(processors.ErrSystem, err)
}
if err := deps.Validator.ValidateStruct(paramsDto); err != nil {
return nil, errors.Join(processors.ErrInvalidParam, err)
}
if paramsDto.IDCard == "410482198504029333" {
return nil, errors.Join(processors.ErrNotFound, errors.New("查询为空"))
}
encryptedName, err := deps.ZhichaService.Encrypt(paramsDto.Name)
if err != nil {
return nil, errors.Join(processors.ErrSystem, err)
}
encryptedIDCard, err := deps.ZhichaService.Encrypt(paramsDto.IDCard)
if err != nil {
return nil, errors.Join(processors.ErrSystem, err)
}
reqData := map[string]interface{}{
"name": encryptedName,
"idCard": encryptedIDCard,
"authorized": paramsDto.Authorized,
}
respData, err := deps.ZhichaService.CallAPI(ctx, "ZCI007", reqData)
if err != nil {
if errors.Is(err, zhicha.ErrDatasource) {
return nil, errors.Join(processors.ErrDatasource, err)
} else {
return nil, errors.Join(processors.ErrSystem, err)
}
}
// 将响应数据转换为JSON字节
respBytes, err := json.Marshal(respData)
if err != nil {
return nil, errors.Join(processors.ErrSystem, err)
}
return respBytes, nil
}

View File

@@ -0,0 +1,38 @@
package flxg
import (
"context"
"encoding/json"
"errors"
"hyapi-server/internal/domains/api/dto"
"hyapi-server/internal/domains/api/services/processors"
"hyapi-server/internal/infrastructure/external/yushan"
)
// ProcessFLXGBC21Request FLXGbc21 API处理方法
func ProcessFLXGBC21Request(ctx context.Context, params []byte, deps *processors.ProcessorDependencies) ([]byte, error) {
var paramsDto dto.FLXGBC21Req
if err := json.Unmarshal(params, &paramsDto); err != nil {
return nil, errors.Join(processors.ErrSystem, err)
}
if err := deps.Validator.ValidateStruct(paramsDto); err != nil {
return nil, errors.Join(processors.ErrInvalidParam, err)
}
reqData := map[string]interface{}{
"mobile": paramsDto.MobileNo,
}
respBytes, err := deps.YushanService.CallAPI(ctx, "MOB032", reqData)
if err != nil {
if errors.Is(err, yushan.ErrDatasource) {
return nil, errors.Join(processors.ErrDatasource, err)
} else {
return nil, errors.Join(processors.ErrSystem, err)
}
}
return respBytes, nil
}

View File

@@ -0,0 +1,57 @@
package flxg
import (
"context"
"encoding/json"
"errors"
"hyapi-server/internal/domains/api/dto"
"hyapi-server/internal/domains/api/services/processors"
"hyapi-server/internal/infrastructure/external/westdex"
)
// ProcessFLXGC9D1Request FLXGC9D1 API处理方法
func ProcessFLXGC9D1Request(ctx context.Context, params []byte, deps *processors.ProcessorDependencies) ([]byte, error) {
var paramsDto dto.FLXGC9D1Req
if err := json.Unmarshal(params, &paramsDto); err != nil {
return nil, errors.Join(processors.ErrSystem, err)
}
if err := deps.Validator.ValidateStruct(paramsDto); err != nil {
return nil, errors.Join(processors.ErrInvalidParam, err)
}
encryptedName, err := deps.WestDexService.Encrypt(paramsDto.Name)
if err != nil {
return nil, errors.Join(processors.ErrSystem, err)
}
encryptedIDCard, err := deps.WestDexService.Encrypt(paramsDto.IDCard)
if err != nil {
return nil, errors.Join(processors.ErrSystem, err)
}
encryptedMobileNo, err := deps.WestDexService.Encrypt(paramsDto.MobileNo)
if err != nil {
return nil, errors.Join(processors.ErrSystem, err)
}
reqData := map[string]interface{}{
"data": map[string]interface{}{
"name": encryptedName,
"id": encryptedIDCard,
"cell": encryptedMobileNo,
},
}
respBytes, err := deps.WestDexService.CallAPI(ctx, "G30BJ05", reqData)
if err != nil {
if errors.Is(err, westdex.ErrDatasource) {
return nil, errors.Join(processors.ErrDatasource, err)
} else {
return nil, errors.Join(processors.ErrSystem, err)
}
}
return respBytes, nil
}

View File

@@ -0,0 +1,57 @@
package flxg
import (
"context"
"encoding/json"
"errors"
"hyapi-server/internal/domains/api/dto"
"hyapi-server/internal/domains/api/services/processors"
"hyapi-server/internal/infrastructure/external/westdex"
)
// ProcessFLXGCA3DRequest FLXGCA3D API处理方法
func ProcessFLXGCA3DRequest(ctx context.Context, params []byte, deps *processors.ProcessorDependencies) ([]byte, error) {
var paramsDto dto.FLXGCA3DReq
if err := json.Unmarshal(params, &paramsDto); err != nil {
return nil, errors.Join(processors.ErrSystem, err)
}
if err := deps.Validator.ValidateStruct(paramsDto); err != nil {
return nil, errors.Join(processors.ErrInvalidParam, err)
}
if paramsDto.IDCard == "350681198611130611" || paramsDto.IDCard == "622301200006250550" || paramsDto.IDCard == "320682198910134998" || paramsDto.IDCard == "640102198708020925" || paramsDto.IDCard == "420624197310234034" || paramsDto.IDCard == "350104198501184416" || paramsDto.IDCard == "410521198606018056" {
return nil, errors.Join(processors.ErrNotFound, errors.New("查询为空"))
}
encryptedName, err := deps.WestDexService.Encrypt(paramsDto.Name)
if err != nil {
return nil, errors.Join(processors.ErrSystem, err)
}
encryptedIDCard, err := deps.WestDexService.Encrypt(paramsDto.IDCard)
if err != nil {
return nil, errors.Join(processors.ErrSystem, err)
}
reqData := map[string]interface{}{
"data": map[string]interface{}{
"name": encryptedName,
"id_card": encryptedIDCard,
},
}
respBytes, err := deps.WestDexService.CallAPI(ctx, "G22BJ03", reqData)
if err != nil {
if errors.Is(err, westdex.ErrDatasource) {
if respBytes != nil {
return respBytes, nil
} else {
return nil, errors.Join(processors.ErrDatasource, err)
}
} else {
return nil, errors.Join(processors.ErrSystem, err)
}
}
return respBytes, nil
}

View File

@@ -0,0 +1,56 @@
package flxg
import (
"context"
"encoding/json"
"errors"
"hyapi-server/internal/domains/api/dto"
"hyapi-server/internal/domains/api/services/processors"
"hyapi-server/internal/infrastructure/external/zhicha"
)
// ProcessFLXGDEA8Request FLXGDEA8 API处理方法
func ProcessFLXGDEA8Request(ctx context.Context, params []byte, deps *processors.ProcessorDependencies) ([]byte, error) {
var paramsDto dto.FLXGDEA8Req
if err := json.Unmarshal(params, &paramsDto); err != nil {
return nil, errors.Join(processors.ErrSystem, err)
}
if err := deps.Validator.ValidateStruct(paramsDto); err != nil {
return nil, errors.Join(processors.ErrInvalidParam, err)
}
encryptedName, err := deps.ZhichaService.Encrypt(paramsDto.Name)
if err != nil {
return nil, errors.Join(processors.ErrSystem, err)
}
encryptedIDCard, err := deps.ZhichaService.Encrypt(paramsDto.IDCard)
if err != nil {
return nil, errors.Join(processors.ErrSystem, err)
}
reqData := map[string]interface{}{
"name": encryptedName,
"idCard": encryptedIDCard,
"authorized": paramsDto.Authorized,
}
respData, err := deps.ZhichaService.CallAPI(ctx, "ZCI028", reqData)
if err != nil {
if errors.Is(err, zhicha.ErrDatasource) {
return nil, errors.Join(processors.ErrDatasource, err)
} else {
return nil, errors.Join(processors.ErrSystem, err)
}
}
// 将响应数据转换为JSON字节
respBytes, err := json.Marshal(respData)
if err != nil {
return nil, errors.Join(processors.ErrSystem, err)
}
return respBytes, nil
}

View File

@@ -0,0 +1,57 @@
package flxg
import (
"context"
"encoding/json"
"errors"
"hyapi-server/internal/domains/api/dto"
"hyapi-server/internal/domains/api/services/processors"
"hyapi-server/internal/infrastructure/external/zhicha"
)
// ProcessFLXGDEA9Request FLXGDEA9 API处理方法
func ProcessFLXGDEA9Request(ctx context.Context, params []byte, deps *processors.ProcessorDependencies) ([]byte, error) {
var paramsDto dto.FLXGDEA9Req
if err := json.Unmarshal(params, &paramsDto); err != nil {
return nil, errors.Join(processors.ErrSystem, err)
}
if err := deps.Validator.ValidateStruct(paramsDto); err != nil {
return nil, errors.Join(processors.ErrInvalidParam, err)
}
encryptedName, err := deps.ZhichaService.Encrypt(paramsDto.Name)
if err != nil {
return nil, errors.Join(processors.ErrSystem, err)
}
if paramsDto.IDCard == "350681198611130611" || paramsDto.IDCard == "622301200006250550" || paramsDto.IDCard == "320682198910134998" || paramsDto.IDCard == "640102198708020925" || paramsDto.IDCard == "420624197310234034" || paramsDto.IDCard == "350104198501184416" || paramsDto.IDCard == "410521198606018056" {
return nil, errors.Join(processors.ErrNotFound, errors.New("查询为空"))
}
encryptedIDCard, err := deps.ZhichaService.Encrypt(paramsDto.IDCard)
if err != nil {
return nil, errors.Join(processors.ErrSystem, err)
}
reqData := map[string]interface{}{
"name": encryptedName,
"idCard": encryptedIDCard,
"authorized": paramsDto.Authorized,
}
respData, err := deps.ZhichaService.CallAPI(ctx, "ZCI005", reqData)
if err != nil {
if errors.Is(err, zhicha.ErrDatasource) {
return nil, errors.Join(processors.ErrDatasource, err)
} else {
return nil, errors.Join(processors.ErrSystem, err)
}
}
// 将响应数据转换为JSON字节
respBytes, err := json.Marshal(respData)
if err != nil {
return nil, errors.Join(processors.ErrSystem, err)
}
return respBytes, nil
}

View File

@@ -0,0 +1,51 @@
package flxg
import (
"context"
"encoding/json"
"errors"
"hyapi-server/internal/domains/api/dto"
"hyapi-server/internal/domains/api/services/processors"
"hyapi-server/internal/infrastructure/external/westdex"
)
// ProcessFLXGDEC7Request FLXGDEC7 API处理方法
func ProcessFLXGDEC7Request(ctx context.Context, params []byte, deps *processors.ProcessorDependencies) ([]byte, error) {
var paramsDto dto.FLXGDEC7Req
if err := json.Unmarshal(params, &paramsDto); err != nil {
return nil, errors.Join(processors.ErrSystem, err)
}
if err := deps.Validator.ValidateStruct(paramsDto); err != nil {
return nil, errors.Join(processors.ErrInvalidParam, err)
}
encryptedName, err := deps.WestDexService.Encrypt(paramsDto.Name)
if err != nil {
return nil, errors.Join(processors.ErrSystem, err)
}
encryptedIDCard, err := deps.WestDexService.Encrypt(paramsDto.IDCard)
if err != nil {
return nil, errors.Join(processors.ErrSystem, err)
}
reqData := map[string]interface{}{
"data": map[string]interface{}{
"name": encryptedName,
"id_card": encryptedIDCard,
},
}
respBytes, err := deps.WestDexService.CallAPI(ctx, "G23BJ03", reqData)
if err != nil {
if errors.Is(err, westdex.ErrDatasource) {
return nil, errors.Join(processors.ErrDatasource, err)
} else {
return nil, errors.Join(processors.ErrSystem, err)
}
}
return respBytes, nil
}

View File

@@ -0,0 +1,54 @@
package flxg
import (
"context"
"encoding/json"
"errors"
"hyapi-server/internal/domains/api/dto"
"hyapi-server/internal/domains/api/services/processors"
"hyapi-server/internal/infrastructure/external/shujubao"
)
// ProcessFLXGDJG3Request FLXGDJG3 董监高司法综合信息核验 API 处理方法(使用数据宝服务示例)
func ProcessFLXGDJG3Request(ctx context.Context, params []byte, deps *processors.ProcessorDependencies) ([]byte, error) {
var paramsDto dto.FLXGDJG3Req
if err := json.Unmarshal(params, &paramsDto); err != nil {
return nil, errors.Join(processors.ErrSystem, err)
}
if err := deps.Validator.ValidateStruct(paramsDto); err != nil {
return nil, errors.Join(processors.ErrInvalidParam, err)
}
// 构建数据宝入参sign 外的业务参数可按需 AES 加密后作为 bodyData
reqParams := map[string]interface{}{
"key": "1cce582f0a6f3ca40de80f1bea9b9698",
"idcard": paramsDto.IDCard,
}
// 最终请求 URL = https://api.chinadatapay.com/communication + 拼接接口地址值,如 personal/197
apiPath := "/communication/personal/10166"
data, err := deps.ShujubaoService.CallAPI(ctx, apiPath, reqParams)
if err != nil {
if errors.Is(err, shujubao.ErrDatasource) {
return nil, errors.Join(processors.ErrDatasource, err)
}
if errors.Is(err, shujubao.ErrQueryEmpty) {
return nil, errors.Join(processors.ErrNotFound, err)
}
return nil, errors.Join(processors.ErrSystem, err)
}
// 解析响应中的 JSON 字符串(使用 qyglb4c0 中的 RecursiveParse
parsedResp, err := RecursiveParse(data)
if err != nil {
return nil, errors.Join(processors.ErrSystem, err)
}
respBytes, err := json.Marshal(parsedResp)
if err != nil {
return nil, errors.Join(processors.ErrSystem, err)
}
return respBytes, nil
}

View File

@@ -0,0 +1,63 @@
package flxg
import (
"context"
"encoding/json"
"errors"
"hyapi-server/internal/domains/api/dto"
"hyapi-server/internal/domains/api/services/processors"
"hyapi-server/internal/infrastructure/external/zhicha"
)
// ProcessFLXGK5D2Request FLXGK5D2 API处理方法 - 法院被执行人高级版
func ProcessFLXGK5D2Request(ctx context.Context, params []byte, deps *processors.ProcessorDependencies) ([]byte, error) {
var paramsDto dto.FLXGK5D2Req
if err := json.Unmarshal(params, &paramsDto); err != nil {
return nil, errors.Join(processors.ErrSystem, err)
}
if err := deps.Validator.ValidateStruct(paramsDto); err != nil {
return nil, errors.Join(processors.ErrInvalidParam, err)
}
if paramsDto.IDCard == "410482198504029333" {
return nil, errors.Join(processors.ErrNotFound, errors.New("查询为空"))
}
encryptedName, err := deps.ZhichaService.Encrypt(paramsDto.Name)
if err != nil {
return nil, errors.Join(processors.ErrSystem, err)
}
encryptedIDCard, err := deps.ZhichaService.Encrypt(paramsDto.IDCard)
if err != nil {
return nil, errors.Join(processors.ErrSystem, err)
}
encryptedMobileNo, err := deps.ZhichaService.Encrypt(paramsDto.MobileNo)
if err != nil {
return nil, errors.Join(processors.ErrSystem, err)
}
reqData := map[string]interface{}{
"name": encryptedName,
"idCard": encryptedIDCard,
"phone": encryptedMobileNo,
"authorized": paramsDto.Authorized,
}
respData, err := deps.ZhichaService.CallAPI(ctx, "ZCI046", reqData)
if err != nil {
if errors.Is(err, zhicha.ErrDatasource) {
return nil, errors.Join(processors.ErrDatasource, err)
} else {
return nil, errors.Join(processors.ErrSystem, err)
}
}
// 将响应数据转换为JSON字节
respBytes, err := json.Marshal(respData)
if err != nil {
return nil, errors.Join(processors.ErrSystem, err)
}
return respBytes, nil
}