diff --git a/internal/domains/api/services/processors/qygl/qygl3f8e_processor.go b/internal/domains/api/services/processors/qygl/qygl3f8e_processor.go index 0248010..512b14a 100644 --- a/internal/domains/api/services/processors/qygl/qygl3f8e_processor.go +++ b/internal/domains/api/services/processors/qygl/qygl3f8e_processor.go @@ -93,6 +93,7 @@ type CompanyInfo struct { Data gjson.Result Name string CreditCode string + Relationship []string RelationshipVal int // 关系权重值 RelationCount int // 关系数量 AdminPenalty int // 行政处罚数量 @@ -206,13 +207,17 @@ func parseCompaniesFrom6S1BResponse(response []byte) ([]CompanyInfo, error) { // 根据企业来源计算关系权重 // legRepInfoList(法人) > shareholderList(股东) > ryPosPerList(高管) relationshipVal := 0 + relationship := []string{} switch companyWithSource.source { case "legRepInfoList": relationshipVal = 6 // 法人关系 - 权重最高 + relationship = append(relationship, "lp") case "shareholderList": relationshipVal = 5 // 股东关系 - 权重次高 + relationship = append(relationship, "sh") case "ryPosPerList": relationshipVal = 4 // 高管关系 - 权重较低 + relationship = append(relationship, "tm") } companies = append(companies, CompanyInfo{ @@ -220,6 +225,7 @@ func parseCompaniesFrom6S1BResponse(response []byte) ([]CompanyInfo, error) { Data: companyJson, Name: name, CreditCode: creditCode, + Relationship: relationship, RelationshipVal: relationshipVal, RelationCount: relationCount, 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个) if enriched, exists := processedMap[company.Index]; exists { // 已处理的企业,添加详细信息