This commit is contained in:
Mrx
2026-01-21 18:00:38 +08:00
parent 0d3a006c46
commit 0036180979

View File

@@ -93,6 +93,7 @@ type CompanyInfo struct {
Data gjson.Result Data gjson.Result
Name string Name string
CreditCode string CreditCode string
Relationship []string
RelationshipVal int // 关系权重值 RelationshipVal int // 关系权重值
RelationCount int // 关系数量 RelationCount int // 关系数量
AdminPenalty int // 行政处罚数量 AdminPenalty int // 行政处罚数量
@@ -206,13 +207,17 @@ func parseCompaniesFrom6S1BResponse(response []byte) ([]CompanyInfo, error) {
// 根据企业来源计算关系权重 // 根据企业来源计算关系权重
// legRepInfoList(法人) > shareholderList(股东) > ryPosPerList(高管) // legRepInfoList(法人) > shareholderList(股东) > ryPosPerList(高管)
relationshipVal := 0 relationshipVal := 0
relationship := []string{}
switch companyWithSource.source { switch companyWithSource.source {
case "legRepInfoList": case "legRepInfoList":
relationshipVal = 6 // 法人关系 - 权重最高 relationshipVal = 6 // 法人关系 - 权重最高
relationship = append(relationship, "lp")
case "shareholderList": case "shareholderList":
relationshipVal = 5 // 股东关系 - 权重次高 relationshipVal = 5 // 股东关系 - 权重次高
relationship = append(relationship, "sh")
case "ryPosPerList": case "ryPosPerList":
relationshipVal = 4 // 高管关系 - 权重较低 relationshipVal = 4 // 高管关系 - 权重较低
relationship = append(relationship, "tm")
} }
companies = append(companies, CompanyInfo{ companies = append(companies, CompanyInfo{
@@ -220,6 +225,7 @@ func parseCompaniesFrom6S1BResponse(response []byte) ([]CompanyInfo, error) {
Data: companyJson, Data: companyJson,
Name: name, Name: name,
CreditCode: creditCode, CreditCode: creditCode,
Relationship: relationship,
RelationshipVal: relationshipVal, RelationshipVal: relationshipVal,
RelationCount: relationCount, RelationCount: relationCount,
AdminPenalty: adminPenalty, AdminPenalty: adminPenalty,
@@ -652,6 +658,100 @@ func buildFinalResponse(enrichedCompanies []EnrichedCompanyInfo, allCompanies []
} }
} }
// 关系字段(必填,若无则返回空数组)
if len(company.Relationship) == 0 {
companyMap["relationship"] = []string{}
} else {
companyMap["relationship"] = company.Relationship
}
hasRel := func(target string) bool {
for _, r := range company.Relationship {
if r == target {
return true
}
}
return false
}
// basicInfo 分组(按前端数据格式)
getVal := func(keys ...string) interface{} {
for _, k := range keys {
if v, ok := companyMap[k]; ok && v != nil {
return v
}
}
return nil
}
basicInfo := map[string]interface{}{}
if v := getVal("regStatus"); v != nil {
basicInfo["regStatus"] = v
}
if v := getVal("creditCode", "creditNo"); v != nil {
basicInfo["creditCode"] = v
}
if v := getVal("regCapital"); v != nil {
basicInfo["regCapital"] = v
}
if v := getVal("regCapitalCurrency"); v != nil {
basicInfo["regCapitalCurrency"] = v
}
if v := getVal("estiblishTime"); v != nil {
basicInfo["estiblishTime"] = v
}
if v := getVal("regNumber", "regNo"); v != nil {
basicInfo["regNumber"] = v
}
if v := getVal("entType"); v != nil {
basicInfo["entType"] = v
}
if v := getVal("industry"); v != nil {
basicInfo["industry"] = v
}
if v := getVal("regInstitute"); v != nil {
basicInfo["regInstitute"] = v
}
if v := getVal("approvedTime"); v != nil {
basicInfo["approvedTime"] = v
}
if v := getVal("legalPersonName"); v != nil {
basicInfo["legalPersonName"] = v
}
if v := getVal("phone"); v != nil {
basicInfo["phone"] = v
}
if v := getVal("email"); v != nil {
basicInfo["email"] = v
}
if v := getVal("website"); v != nil {
basicInfo["website"] = v
}
if v := getVal("regAddress"); v != nil {
basicInfo["regAddress"] = v
}
companyMap["basicInfo"] = basicInfo
// stockHolderItem仅股东关系时整理
if hasRel("sh") {
stockHolderItem := map[string]interface{}{}
if v := getVal("orgHolderName", "holderName", "shareholderName"); v != nil {
stockHolderItem["orgHolderName"] = v
}
if v := getVal("orgHolderType", "holderType"); v != nil {
stockHolderItem["orgHolderType"] = v
}
if v := getVal("subscriptAmt", "investAmount", "contributionAmount"); v != nil {
stockHolderItem["subscriptAmt"] = v
}
if v := getVal("investRate", "shareRate"); v != nil {
stockHolderItem["investRate"] = v
}
if v := getVal("investDate", "contributionDate"); v != nil {
stockHolderItem["investDate"] = v
}
companyMap["stockHolderItem"] = stockHolderItem
}
// 检查是否是已处理的企业前3个 // 检查是否是已处理的企业前3个
if enriched, exists := processedMap[company.Index]; exists { if enriched, exists := processedMap[company.Index]; exists {
// 已处理的企业,添加详细信息 // 已处理的企业,添加详细信息