|
@@ -200,6 +200,12 @@ func getCompanyType(name string) (company_type string) {
|
|
|
}
|
|
|
|
|
|
top_bases, _ := Mgo181.FindOne("company_base", topwhere)
|
|
|
+ if top_bases == nil && len(*top_bases) == 0 {
|
|
|
+ if strings.Contains(par_name, "(") && strings.Contains(par_name, ")") {
|
|
|
+ par_name = strings.ReplaceAll(par_name, ")", ")")
|
|
|
+ par_name = strings.ReplaceAll(par_name, "(", "(")
|
|
|
+ }
|
|
|
+ }
|
|
|
if top_bases != nil && len(*top_bases) > 0 {
|
|
|
top_company_type := util.ObjToString((*top_bases)["company_type"])
|
|
|
if strings.Contains(top_company_type, "国有独资") || strings.Contains(top_company_type, "国有控股") ||
|
|
@@ -271,8 +277,7 @@ func getMarketType(name string) (stype string) {
|
|
|
}
|
|
|
|
|
|
// getTop 获取最上级公司
|
|
|
-// getTop 获取最上级公司;isCompany true 必须是企业类型,含有公司;
|
|
|
-func getTop(name string, isCompany bool) (top string) {
|
|
|
+func getTop(name string) (top string) {
|
|
|
if name == "" {
|
|
|
return
|
|
|
}
|
|
@@ -283,7 +288,7 @@ func getTop(name string, isCompany bool) (top string) {
|
|
|
visited[currName] = true
|
|
|
|
|
|
for {
|
|
|
- topTmp := getParentsByPartner(currName)
|
|
|
+ topTmp := getParentsByPartner1(currName)
|
|
|
topName := util.ObjToString(topTmp["stock_name"])
|
|
|
|
|
|
// 第一次查找就失败,直接返回空
|
|
@@ -302,11 +307,9 @@ func getTop(name string, isCompany bool) (top string) {
|
|
|
return currName
|
|
|
}
|
|
|
|
|
|
- if isCompany {
|
|
|
- // 如果 topName 不符合要求,比如不含“公司”,也返回当前
|
|
|
- if !strings.Contains(topName, "公司") {
|
|
|
- return currName
|
|
|
- }
|
|
|
+ // 如果 topName 不符合要求,比如不含“公司”,也返回当前
|
|
|
+ if !strings.Contains(topName, "公司") && !strings.Contains(topName, "集团") {
|
|
|
+ return currName
|
|
|
}
|
|
|
|
|
|
// 更新当前公司名,继续向上找
|
|
@@ -315,6 +318,30 @@ func getTop(name string, isCompany bool) (top string) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+// getParentsByPartner1 返回投资比例50%以上的上级企业
|
|
|
+func getParentsByPartner1(companyName string) (res map[string]interface{}) {
|
|
|
+ q := map[string]interface{}{"company_name": companyName, "use_flag": 0, "is_history": 0, "is_personal": 0}
|
|
|
+ info, _ := Mgo181.Find("company_partner", q, nil, nil, false, -1, -1)
|
|
|
+
|
|
|
+ if info == nil || len(*info) == 0 {
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ for _, v := range *info {
|
|
|
+ // 不是法人企业,直接跳过
|
|
|
+ if !strings.Contains(util.ObjToString(v["stock_type"]), "法人") {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+
|
|
|
+ // 投资比例 必须 0.5以上
|
|
|
+ stock_proportion := util.Float64All(v["stock_proportion"])
|
|
|
+ if stock_proportion >= 0.5 {
|
|
|
+ return v
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
// getParentsByPartner 获取母公司,返回投资比例最大的企业
|
|
|
func getParentsByPartner(companyName string) (res map[string]interface{}) {
|
|
|
q := map[string]interface{}{"company_name": companyName, "use_flag": 0, "is_history": 0, "is_personal": 0}
|