| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 | 
							- <?php
 
- namespace App\Services\Statistics;
 
- use App\Exceptions\ResponseException;
 
- use App\Repositories\CompanyRepository;
 
- use App\Repositories\CategoryRepository;
 
- use Illuminate\Support\Facades\Cache;
 
- class CompanyService
 
- {
 
-     protected $companyRepository;
 
-     protected $categoryRepository;
 
-     /**
 
-      * CompanyService constructor.
 
-      */
 
-     public function __construct(CompanyRepository $companyRepository, CategoryRepository $categoryRepository)
 
-     {
 
-         $this->companyRepository = $companyRepository;
 
-         $this->categoryRepository = $categoryRepository;
 
-     }
 
-     //获取指定条件的企业数量
 
-     public function getCompanyNums($where)
 
-     {
 
-         $time_condition = [];
 
-         if (array_has($where, 'time_condition')) {
 
-             $time_condition = $where['time_condition'];
 
-             unset($where['time_condition']);
 
-         }
 
-         return $this->companyRepository->getCompanyNumByTime($where, $time_condition);
 
-     }
 
-     public function getCategories($filter_data = array())
 
-     {
 
-         $list = array();
 
-         if ($filter_data) {
 
-             $cates =  $this->categoryRepository->getCategories();
 
-             if ($cates) {
 
-                 foreach ($cates as $key => $val) {
 
-                     if ($key == 'AIX_wage') {
 
-                         foreach ($val as $k => $v) {
 
-                             if (config('aix.system.site_other.site_other.site_salary') == 1) {
 
-                                 $cates[$key][$k]['demand'] = $v['k_demand'];
 
-                             } else {
 
-                                 $cates[$key][$k]['demand'] = $v['c_demand'];
 
-                             }
 
-                         }
 
-                     }
 
-                 }
 
-             }
 
-             foreach ($filter_data as $k => $v) {
 
-                 if (array_key_exists($k, $cates)) {
 
-                     $list[$k] = array_slice($cates[$k], 0, 3);
 
-                     if ($v) {
 
-                         $list[$k] = array_slice($cates[$k], 0, $v, true);
 
-                     } else {
 
-                         $list[$k] = $cates[$k];
 
-                     }
 
-                 } else {
 
-                     $list[$k] = array();
 
-                 }
 
-             }
 
-         }
 
-         return $list;
 
-     }
 
-     public function getCompanyNumsGroup($where, $fields, $group_by)
 
-     {
 
-         $rst = $this->companyRepository->getCompanyNumsByGroup($where, $fields, $group_by);
 
-         return $rst->toArray();
 
-     }
 
- }
 
 
  |