|  | @@ -11,11 +11,16 @@ use app\admin\model\Enterprise;
 | 
	
		
			
				|  |  |  class EnterpriseApi {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      public static function getOne($id) {
 | 
	
		
			
				|  |  | -        return Enterprise::findOrEmpty($id);
 | 
	
		
			
				|  |  | +        $ep = Enterprise::findOrEmpty($id);
 | 
	
		
			
				|  |  | +        if ($ep->delete == 1) {
 | 
	
		
			
				|  |  | +            return null;
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        return $ep;
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      public static function getSimpleList() {
 | 
	
		
			
				|  |  |          $where[] = ["active", "=", 1];
 | 
	
		
			
				|  |  | +        $where[] = ["delete", "=", 0];
 | 
	
		
			
				|  |  |          return $list = Enterprise::where($where)->order("name", 'asc')->field("name,id")->select()->toArray();
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -101,6 +106,7 @@ class EnterpriseApi {
 | 
	
		
			
				|  |  |          $enterpriseTag = urldecode(trim($request->param("enterpriseTag")));
 | 
	
		
			
				|  |  |          $enterpriseType = urldecode(trim($request->param("enterpriseType")));
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +        $where[] = ["delete", "=", 0];
 | 
	
		
			
				|  |  |          if ($name) {
 | 
	
		
			
				|  |  |              $where[] = ["name", "like", "%{$name}%"];
 | 
	
		
			
				|  |  |          }
 | 
	
	
		
			
				|  | @@ -198,7 +204,7 @@ class EnterpriseApi {
 | 
	
		
			
				|  |  |          $company_info = CompanyApi::getOne($companyId);
 | 
	
		
			
				|  |  |          $where = [];
 | 
	
		
			
				|  |  |          $whereRaw = "";
 | 
	
		
			
				|  |  | -        $where[] = ['type', '=', session('user')['type']];
 | 
	
		
			
				|  |  | +        $where[] = ['r.type', '=', session('user')['type']];
 | 
	
		
			
				|  |  |          if ($company_info['code'] != 'super' && !self::chkUserInSuperusers()) {
 | 
	
		
			
				|  |  |              if (session('user')['type'] == 1) {
 | 
	
		
			
				|  |  |                  $whr[] = ["companyId", "=", $companyId];
 | 
	
	
		
			
				|  | @@ -270,59 +276,60 @@ class EnterpriseApi {
 | 
	
		
			
				|  |  |          $checkState = trim($request->param("checkState"));
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          if ($oldName) {
 | 
	
		
			
				|  |  | -            $where[] = ["oldName", "like", "%{$oldName}%"];
 | 
	
		
			
				|  |  | +            $where[] = ["r.oldName", "like", "%{$oldName}%"];
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          if ($oldIdCard) {
 | 
	
		
			
				|  |  | -            $where[] = ["oldIdCard", "like", "%{$oldIdCard}%"];
 | 
	
		
			
				|  |  | +            $where[] = ["r.oldIdCard", "like", "%{$oldIdCard}%"];
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          if ($oldLegal) {
 | 
	
		
			
				|  |  | -            $where[] = ["oldLegal", "like", "%{$oldLegal}%"];
 | 
	
		
			
				|  |  | +            $where[] = ["r.oldLegal", "like", "%{$oldLegal}%"];
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          if ($oldStreet) {
 | 
	
		
			
				|  |  | -            $where[] = ["oldStreet", "=", "{$oldStreet}"];
 | 
	
		
			
				|  |  | +            $where[] = ["r.oldStreet", "=", "{$oldStreet}"];
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          if ($oldEnterpriseTag) {
 | 
	
		
			
				|  |  | -            $where[] = ["oldEnterpriseTag", "=", "{$oldEnterpriseTag}"];
 | 
	
		
			
				|  |  | +            $where[] = ["r.oldEnterpriseTag", "=", "{$oldEnterpriseTag}"];
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          if ($oldIndustryFieldNew) {
 | 
	
		
			
				|  |  | -            $where[] = ["oldIndustryFieldNew", "=", "{$oldIndustryFieldNew}"];
 | 
	
		
			
				|  |  | +            $where[] = ["r.oldIndustryFieldNew", "=", "{$oldIndustryFieldNew}"];
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          if ($newName) {
 | 
	
		
			
				|  |  | -            $where[] = ["newName", "like", "%{$newName}%"];
 | 
	
		
			
				|  |  | +            $where[] = ["r.newName", "like", "%{$newName}%"];
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          if ($newIdCard) {
 | 
	
		
			
				|  |  | -            $where[] = ["newIdCard", "like", "%{$newIdCard}%"];
 | 
	
		
			
				|  |  | +            $where[] = ["r.newIdCard", "like", "%{$newIdCard}%"];
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          if ($newAgentName) {
 | 
	
		
			
				|  |  | -            $where[] = ["newAgentName", "like", "%{$newAgentName}%"];
 | 
	
		
			
				|  |  | +            $where[] = ["r.newAgentName", "like", "%{$newAgentName}%"];
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          if ($checkState) {
 | 
	
		
			
				|  |  | -            $where[] = ["checkState", "=", "{$checkState}"];
 | 
	
		
			
				|  |  | +            $where[] = ["r.checkState", "=", "{$checkState}"];
 | 
	
		
			
				|  |  |          } else {
 | 
	
		
			
				|  |  | -            $where[] = ['checkState', '>', 1];
 | 
	
		
			
				|  |  | +            $where[] = ['r.checkState', '>', 1];
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          if ($newStreet) {
 | 
	
		
			
				|  |  | -            $where[] = ["newStreet", "=", "{$newStreet}"];
 | 
	
		
			
				|  |  | +            $where[] = ["r.newStreet", "=", "{$newStreet}"];
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          if ($newEnterpriseTag) {
 | 
	
		
			
				|  |  | -            $where[] = ["newEnterpriseTag", "=", "{$newEnterpriseTag}"];
 | 
	
		
			
				|  |  | +            $where[] = ["r.newEnterpriseTag", "=", "{$newEnterpriseTag}"];
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          if ($newIndustryFieldNew) {
 | 
	
		
			
				|  |  | -            $where[] = ["newIndustryFieldNew", "=", "{$newIndustryFieldNew}"];
 | 
	
		
			
				|  |  | +            $where[] = ["r.newIndustryFieldNew", "=", "{$newIndustryFieldNew}"];
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | +        $where[] = ["e.delete", "=", 0];
 | 
	
		
			
				|  |  |          if ($whereRaw) {
 | 
	
		
			
				|  |  | -            $count = EnterpriseRecord::where($where)->whereRaw($whereRaw)->count();
 | 
	
		
			
				|  |  | +            $count = EnterpriseRecord::alias("r")->leftJoin("un_enterprise e", "e.id=r.mainId")->where($where)->whereRaw($whereRaw)->count();
 | 
	
		
			
				|  |  |          } else {
 | 
	
		
			
				|  |  | -            $count = EnterpriseRecord::where($where)->count();
 | 
	
		
			
				|  |  | +            $count = EnterpriseRecord::alias("r")->leftJoin("un_enterprise e", "e.id=r.mainId")->where($where)->count();
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          if ($count > 0) {
 | 
	
		
			
				|  |  |              $talentTypeList = DictApi::selectByParentCode("enterprise_tag");
 | 
	
		
			
				|  |  |              $industryFieldNewList = DictApi::selectByParentCode("industry_field");
 | 
	
		
			
				|  |  |              $streetList = DictApi::selectByParentCode("street");
 | 
	
		
			
				|  |  |              if ($whereRaw) {
 | 
	
		
			
				|  |  | -                $list = EnterpriseRecord::where($where)->whereRaw($whereRaw)->limit($offset, $limit)->order("createTime", 'desc')->select()->toArray();
 | 
	
		
			
				|  |  | +                $list = EnterpriseRecord::alias("r")->leftJoin("un_enterprise e", "e.id=r.mainId")->field("r.*")->where($where)->whereRaw($whereRaw)->limit($offset, $limit)->order("r.createTime", 'desc')->select()->toArray();
 | 
	
		
			
				|  |  |              } else {
 | 
	
		
			
				|  |  | -                $list = EnterpriseRecord::where($where)->limit($offset, $limit)->order("createTime", 'desc')->select()->toArray();
 | 
	
		
			
				|  |  | +                $list = EnterpriseRecord::alias("r")->leftJoin("un_enterprise e", "e.id=r.mainId")->field("r.*")->where($where)->limit($offset, $limit)->order("r.createTime", 'desc')->select()->toArray();
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |              foreach ($list as $k => &$v) {
 | 
	
		
			
				|  |  |                  $v['oldStreetName'] = $streetList[$v['oldStreet']];
 | 
	
	
		
			
				|  | @@ -343,7 +350,7 @@ class EnterpriseApi {
 | 
	
		
			
				|  |  |          $company_info = CompanyApi::getOne($companyId);
 | 
	
		
			
				|  |  |          $where = [];
 | 
	
		
			
				|  |  |          $whereRaw = "";
 | 
	
		
			
				|  |  | -        $where[] = ['type', '=', session('user')['type']];
 | 
	
		
			
				|  |  | +        $where[] = ['r.type', '=', session('user')['type']];
 | 
	
		
			
				|  |  |          if ($company_info['code'] != 'super' && !self::chkUserInSuperusers()) {
 | 
	
		
			
				|  |  |              if (session('user')['type'] == 1) {
 | 
	
		
			
				|  |  |                  $whr[] = ["companyId", "=", $companyId];
 | 
	
	
		
			
				|  | @@ -442,9 +449,9 @@ class EnterpriseApi {
 | 
	
		
			
				|  |  |              $where[] = ["newAgentName", "like", "%{$newAgentName}%"];
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          if ($checkState) {
 | 
	
		
			
				|  |  | -            $where[] = ["checkState", "=", "{$checkState}"];
 | 
	
		
			
				|  |  | +            $where[] = ["r.checkState", "=", "{$checkState}"];
 | 
	
		
			
				|  |  |          } else {
 | 
	
		
			
				|  |  | -            $where[] = ['checkState', '>', 1];
 | 
	
		
			
				|  |  | +            $where[] = ['r.checkState', '>', 1];
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          if ($newStreet) {
 | 
	
		
			
				|  |  |              $where[] = ["newStreet", "=", "{$newStreet}"];
 | 
	
	
		
			
				|  | @@ -455,10 +462,11 @@ class EnterpriseApi {
 | 
	
		
			
				|  |  |          if ($newIndustryFieldNew) {
 | 
	
		
			
				|  |  |              $where[] = ["newIndustryFieldNew", "=", "{$newIndustryFieldNew}"];
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | +        $where[] = ["e.delete", "=", 0];
 | 
	
		
			
				|  |  |          if ($whereRaw) {
 | 
	
		
			
				|  |  | -            $count = EnterpriseRecord::where($where)->whereRaw($whereRaw)->count();
 | 
	
		
			
				|  |  | +            $count = EnterpriseRecord::alias("r")->leftJoin("un_enterprise e", "e.id=r.mainId")->where($where)->whereRaw($whereRaw)->count();
 | 
	
		
			
				|  |  |          } else {
 | 
	
		
			
				|  |  | -            $count = EnterpriseRecord::where($where)->count();
 | 
	
		
			
				|  |  | +            $count = EnterpriseRecord::alias("r")->leftJoin("un_enterprise e", "e.id=r.mainId")->where($where)->count();
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          if ($count > 0) {
 | 
	
		
			
				|  |  |              $organizationTagList = DictApi::selectByParentCode("organization_tag");
 | 
	
	
		
			
				|  | @@ -469,9 +477,9 @@ class EnterpriseApi {
 | 
	
		
			
				|  |  |              $streetList = DictApi::selectByParentCode("street");
 | 
	
		
			
				|  |  |              $agencyTypeList = DictApi::selectByParentCode("agency_type");
 | 
	
		
			
				|  |  |              if ($whereRaw) {
 | 
	
		
			
				|  |  | -                $list = EnterpriseRecord::where($where)->whereRaw($whereRaw)->order("createTime", 'desc')->select()->toArray();
 | 
	
		
			
				|  |  | +                $list = EnterpriseRecord::alias("r")->leftJoin("un_enterprise e", "e.id=r.mainId")->field("r.*")->where($where)->whereRaw($whereRaw)->order("createTime", 'desc')->select()->toArray();
 | 
	
		
			
				|  |  |              } else {
 | 
	
		
			
				|  |  | -                $list = EnterpriseRecord::where($where)->order("createTime", 'desc')->select()->toArray();
 | 
	
		
			
				|  |  | +                $list = EnterpriseRecord::alias("r")->leftJoin("un_enterprise e", "e.id=r.mainId")->field("r.*")->where($where)->order("createTime", 'desc')->select()->toArray();
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |              foreach ($list as $k => &$v) {
 | 
	
		
			
				|  |  |                  if ($v["special"] == 1) {
 |