CompanyService.php 94 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: michaelwu
  5. * Date: 2018/10/31
  6. * Time: 10:03
  7. */
  8. namespace App\Services\Company;
  9. use App\Exceptions\ResponseException;
  10. use App\Models\Category;
  11. use App\Models\Company;
  12. use App\Models\CompanyContact;
  13. use App\Models\Jobs;
  14. use App\Models\JobsContact;
  15. use App\Models\MemberInfo;
  16. use App\Models\Resume;
  17. use App\Repositories\CompanyInterviewRepository;
  18. use App\Repositories\CompanyRepository;
  19. use App\Repositories\JobsRepository;
  20. use App\Repositories\MemberLogRepository;
  21. use App\Repositories\MemberMsgtipRepository;
  22. use App\Repositories\MemberPointRepository;
  23. use App\Repositories\MsgRepository;
  24. use App\Repositories\OauthRepository;
  25. use App\Repositories\PersonalJobsApplyRepository;
  26. use App\Repositories\PersonFocusComRepository;
  27. use App\Repositories\CompanyImgRepository;
  28. use App\Repositories\CategoryRepository;
  29. use App\Repositories\MemberSetmealRepository;
  30. use App\Repositories\CategoryDistrictRepository;
  31. use App\Repositories\CompanyStatisticsRepository;
  32. use App\Repositories\PmsRepository;
  33. use App\Repositories\SubsiteRepository;
  34. use App\Repositories\TaskLogRepository;
  35. use App\Repositories\ThirdloginRepository;
  36. use App\Services\Common\TaskService;
  37. use http\Env\Response;
  38. use Illuminate\Support\Facades\DB;
  39. use Illuminate\Support\Facades\Hash;
  40. use Illuminate\Support\Facades\Cache;
  41. use App\Repositories\CompanyContactRepository;
  42. use Illuminate\Support\Facades\Log;
  43. class CompanyService
  44. {
  45. protected $companyRepository;
  46. protected $jobsRepository;
  47. protected $oauthRepository;
  48. protected $taskService;
  49. protected $personalJobsApplyRepository;
  50. protected $personFocusComRepository;
  51. protected $companyImgRepository;
  52. protected $categoryRepository;
  53. protected $memberSetmealRepository;
  54. protected $categoryDistrictRepository;
  55. protected $companyStatisticsRepository;
  56. protected $taskLogRepository;
  57. protected $memberPointRepository;
  58. protected $companyInterviewRepository;
  59. protected $memberLogRepository;
  60. protected $pmsRepository;
  61. protected $memberMsgtipRepository;
  62. protected $msgRepository;
  63. protected $subsiteRepository;
  64. protected $thirdloginRepository;
  65. protected $companyContactRepository;
  66. /**
  67. * CompanyService constructor.
  68. * @param CompanyRepository $companyRepository
  69. * @param MemberMsgtipRepository $memberMsgtipRepository
  70. * @param PmsRepository $pmsRepository
  71. * @param MemberLogRepository $memberLogRepository
  72. * @param CompanyInterviewRepository $companyInterviewRepository
  73. * @param MemberPointRepository $memberPointRepository
  74. * @param JobsRepository $jobsRepository
  75. * @param OauthRepository $oauthRepository
  76. * @param TaskService $taskService
  77. * @param TaskLogRepository $taskLogRepository
  78. * @param PersonalJobsApplyRepository $personalJobsApplyRepository
  79. * @param PersonFocusComRepository $personFocusComRepository
  80. * @param CompanyImgRepository $companyImgRepository
  81. * @param CategoryRepository $categoryRepository
  82. * @param MemberSetmealRepository $memberSetmealRepository
  83. * @param CategoryDistrictRepository $categoryDistrictRepository
  84. * @param CompanyStatisticsRepository $companyStatisticsRepository
  85. * @param MsgRepository $msgRepository
  86. * @param SubsiteRepository $subsiteRepository
  87. * @param ThirdloginRepository $thirdloginRepository
  88. * @param CompanyContactRepository $companyContactRepository
  89. */
  90. public function __construct(CompanyRepository $companyRepository, ThirdloginRepository $thirdloginRepository, MemberMsgtipRepository $memberMsgtipRepository, SubsiteRepository $subsiteRepository, PmsRepository $pmsRepository, MemberLogRepository $memberLogRepository, CompanyInterviewRepository $companyInterviewRepository, MemberPointRepository $memberPointRepository, JobsRepository $jobsRepository, OauthRepository $oauthRepository, TaskService $taskService, TaskLogRepository $taskLogRepository, PersonalJobsApplyRepository $personalJobsApplyRepository, PersonFocusComRepository $personFocusComRepository, CompanyImgRepository $companyImgRepository, CategoryRepository $categoryRepository, MemberSetmealRepository $memberSetmealRepository, CategoryDistrictRepository $categoryDistrictRepository, CompanyStatisticsRepository $companyStatisticsRepository, MsgRepository $msgRepository, CompanyContactRepository $companyContactRepository)
  91. {
  92. $this->companyRepository = $companyRepository;
  93. $this->jobsRepository = $jobsRepository;
  94. $this->oauthRepository = $oauthRepository;
  95. $this->taskService = $taskService;
  96. $this->personalJobsApplyRepository = $personalJobsApplyRepository;
  97. $this->personFocusComRepository = $personFocusComRepository;
  98. $this->companyRepository = $companyRepository;
  99. $this->companyImgRepository = $companyImgRepository;
  100. $this->categoryRepository = $categoryRepository;
  101. $this->memberSetmealRepository = $memberSetmealRepository;
  102. $this->categoryDistrictRepository = $categoryDistrictRepository;
  103. $this->companyStatisticsRepository = $companyStatisticsRepository;
  104. $this->taskLogRepository = $taskLogRepository;
  105. $this->memberPointRepository = $memberPointRepository;
  106. $this->companyInterviewRepository = $companyInterviewRepository;
  107. $this->memberLogRepository = $memberLogRepository;
  108. $this->pmsRepository = $pmsRepository;
  109. $this->memberMsgtipRepository = $memberMsgtipRepository;
  110. $this->msgRepository = $msgRepository;
  111. $this->subsiteRepository = $subsiteRepository;
  112. $this->thirdloginRepository = $thirdloginRepository;
  113. $this->companyContactRepository = $companyContactRepository;
  114. }
  115. /**
  116. * 企业会员中心页
  117. * @return array
  118. */
  119. public function index($user)
  120. {
  121. $myPoints = $this->memberPointRepository->getPointsOne($user->id, $user->utype); //我的积分
  122. $mySetmeal = $this->memberSetmealRepository->getSetmealByUid($user->id, 1);
  123. //套餐临近到期提醒
  124. $setmealMsg = '';
  125. session(["setmeal_message" => ""]);
  126. if ($mySetmeal->endtime != 0) {
  127. $days = (strtotime($mySetmeal->endtime) - time()) / 86400;
  128. $meal_min_remind = config('aix.companyset.setmeal_com.setmeal_com_set.meal_min_remind');
  129. if ($meal_min_remind > 0 && $days <= $meal_min_remind) {
  130. $setmealMsg = "提醒:您的套餐快到期,为避免造成不必要的麻烦,请升级套餐";
  131. }
  132. if (strtotime($mySetmeal->endtime) < time() && $mySetmeal->endtime != 0) {
  133. $setmealMsg = "提醒:您的套餐已到期,请及时到我的套餐处升级套餐";
  134. }
  135. session(["setmeal_message" => $setmealMsg]);
  136. }
  137. //招聘中的职位数
  138. $condition = [
  139. 'company_id' => $user->id,
  140. 'valid' => 1,
  141. 'display' => 1,
  142. ];
  143. if (config('aix.companyset.comset.show_set.jobs_display') == 1) {
  144. $condition[] = ['audit', '=', 1];
  145. } else {
  146. $condition[] = ['audit', '<>', 3];
  147. }
  148. $jobsing = $this->jobsRepository->getJobCount($condition);
  149. //待处理简历
  150. $condition1 = [
  151. 'is_reply' => 0,
  152. 'company_id' => $user->id,
  153. ];
  154. $resumes = $this->personalJobsApplyRepository->resumesCount($condition1);
  155. //面试邀请
  156. $condition2 = [
  157. 'company_id' => $user->id,
  158. 'result' => 0,
  159. ];
  160. $interview = $this->companyInterviewRepository->interviewCount($condition2);
  161. //谁关注我
  162. $condition3 = [
  163. 'company_id' => $user->id,
  164. ];
  165. $concern = $this->personFocusComRepository->getFansCount($condition3);
  166. //我的消息
  167. /* $condition4 = [
  168. 'msgtouid' => $user->id,
  169. 'utype' => $user->utype,
  170. 'new' => 1,
  171. ];
  172. $pms = $this->pmsRepository->getPmsCount($condition4);*/
  173. //是否已签到
  174. $isSign = $this->taskLogRepository->getTaskLogCount($user->id, 18, $user->utype);
  175. $res = [
  176. 'week' => array('日', '一', '二', '三', '四', '五', '六'),
  177. 'mypoints' => $myPoints,
  178. 'user' => $user,
  179. 'jobsing' => $jobsing,
  180. 'resumesCount' => $resumes,
  181. 'interview' => $interview,
  182. 'isSign' => $isSign,
  183. 'concern' => $concern,
  184. /* 'pms'=>$pms,*/
  185. 'mySetmeal' => $mySetmeal,
  186. 'setmealMsg' => $setmealMsg,
  187. ];
  188. return $res;
  189. }
  190. public function ajaxSms($user)
  191. {
  192. //获取当天
  193. //当天开始时间
  194. $start_time = strtotime(date("Y-m-d", time()));
  195. //当天结束之间
  196. $end_time = $start_time + 60 * 60 * 24;
  197. $condit[] = ['new', 1];
  198. $condit[] = ['msgtouid', $user->id];
  199. $condit[] = ['utype', $user->utype];
  200. $condit[] = ['msgtype', 2];
  201. $condit[] = ['msgfromuid', 0];
  202. $condit[] = ['msgfrom', 'admin'];
  203. /*$condit[] = ['started_at', '<=', time()];
  204. $condit[] = ['ended_at', '>=', time()];*/
  205. $condit[] = ['started_at', '<=', $start_time];
  206. $condit[] = ['ended_at', '>=', $start_time];
  207. $message = $this->pmsRepository->findFirstPms($condit);;
  208. $info = '';
  209. $id = '';
  210. if ($message) {
  211. $order = array("\r\n", "\n", "\r");
  212. $replace = '<br/>';
  213. $info = $message->message;
  214. $id = $message->id;
  215. }
  216. return ['message' => $info, 'id' => $id];
  217. }
  218. public function setMatchJob($data, $company)
  219. {
  220. $job_id = array_get($data, 'job_id');
  221. $type = array_get($data, 'type');
  222. $jids = session('match_jobs_' . $company->id, array());
  223. if ($jids) {
  224. $jids[] = $job_id;
  225. } else {
  226. $jids = array($job_id);
  227. }
  228. if ($job_id) {
  229. session(['match_jobs_' . $company->id => $jids]);
  230. }
  231. //判断当前企业是否有其它职位,如果没有则清空过滤的session
  232. $job = $this->getMatchJob($company);
  233. if (!$job) {
  234. session(['match_jobs_' . $company->id => null]);
  235. }
  236. }
  237. //获取推荐简历需要匹配的职位
  238. public function getMatchJob($company)
  239. {
  240. $job_where = array(
  241. array('company_id', '=', $company->id),
  242. array('valid', '=', 1),
  243. array('deadline', '>=', time())
  244. );
  245. if (config('aix.companyset.comset.show_set.jobs_display') == 1) {
  246. $job_where[] = array('audit', '=', 1);
  247. } else {
  248. $job_where[] = array('audit', '<>', 3);
  249. }
  250. //排除已推荐过的职位
  251. $has_jids = session('match_jobs_' . $company->id, array());
  252. $where_notIn = array();
  253. if ($has_jids) {
  254. $where_notIn = ['id' => $has_jids];
  255. }
  256. $orderby = array('stime' => 'DESC', 'refresh_time' => 'DESC', 'click' => 'DESC');
  257. $jobinfo = $this->jobsRepository->getMatchJob($job_where, $where_notIn, $orderby);
  258. if ($jobinfo) {
  259. return $jobinfo;
  260. } else {
  261. return array();
  262. }
  263. }
  264. //获取推荐简历排序
  265. public function getRecommendOrder($user = array())
  266. {
  267. $order = array();
  268. $order = array('click' => 'desc', 'stime' => 'desc', 'updated_at' => 'desc');
  269. return $order;
  270. }
  271. public function getRecommendWhere($user)
  272. {
  273. $where = array();
  274. if ($user && $user->utype == 1) {
  275. //获取发布中的职位
  276. $job_where = array(
  277. array('company_id', '=', $user->id),
  278. array('valid', '=', 1),
  279. array('deadline', '>=', time())
  280. );
  281. if (config('aix.companyset.comset.show_set.jobs_display') == 1) {
  282. $job_where[] = array('audit', '=', 1);
  283. } else {
  284. $job_where[] = array('audit', '<>', 3);
  285. }
  286. $orderby = array('stime' => 'DESC', 'refresh_time' => 'DESC', 'click' => 'DESC');
  287. $jobs = $this->jobsRepository->fliterJobs($job_where, array(), $orderby);
  288. if ($jobs->isNotEmpty()) {
  289. $or_where = array();
  290. foreach ($jobs as $k => $v) {
  291. $or_where[] = $this->getRecommendResumeWhere($v);
  292. }
  293. $and_where[] = array('display', '=', 1);
  294. if (config('aix.personal_set.per_set.show_set.resume_display') == 1) {
  295. $and_where[] = array('audit', '=', 2);
  296. } else {
  297. $and_where[] = array('audit', '<>', 0);
  298. }
  299. $where['or'] = $or_where;
  300. }
  301. return $where;
  302. } else {
  303. $where[] = array('display', '=', 1);
  304. if (config('aix.personal_set.per_set.show_set.resume_display') == 1) {
  305. $where[] = array('audit', '=', 2);
  306. } else {
  307. $where[] = array('audit', '<>', 0);
  308. }
  309. return $where;
  310. }
  311. }
  312. //获取推荐简历
  313. public function getRecommendResumeWhere($job)
  314. {
  315. $where = array();
  316. //简历公开、简历审核状态、默认简历通过审核
  317. $where[] = array('display', '=', 1);
  318. //$where[] = array('def','=',1);
  319. if (config('aix.personal_set.per_set.show_set.resume_display') == 1) {
  320. $where[] = array('audit', '=', 2);
  321. } else {
  322. $where[] = array('audit', '<>', 0);
  323. }
  324. if (auth('web-company')->check()) {
  325. //获取企业信息
  326. $company = auth('web-company')->user();
  327. if ($job) {
  328. //匹配年龄、工作性质、期望行业、期望职位、工作地区、期望薪资
  329. //匹配学历
  330. $education = $job->education;
  331. if ($education) {
  332. $where[] = array('education', '>=', $education);
  333. }
  334. //匹配工作经验
  335. $experience = $job->experience;
  336. if ($experience) {
  337. $where[] = array('experience', '>=', $experience);
  338. }
  339. //匹配性别
  340. $sex = $job->sex;
  341. if ($sex) {
  342. $where[] = array('sex', '=', $sex);
  343. }
  344. //匹配年龄
  345. $age = $job->age;
  346. if (array_get($age, 0) || array_get($age, 1)) {
  347. if (is_numeric(array_get($age, 0))) {
  348. $birthday_min = date("Y") - $age[0];
  349. $where[] = array('member_infos.birthday', '<=', $birthday_min);
  350. }
  351. if (is_numeric(array_get($age, 1))) {
  352. $birthday_max = date("Y") - $age[1];
  353. $where[] = array('member_infos.birthday', '>=', $birthday_max);
  354. }
  355. }
  356. //匹配工作性质
  357. $nature = $job->nature;
  358. $where[] = array('nature', '=', $nature);
  359. //匹配期望行业
  360. /*$trade = $company->trade;
  361. $where[] = array('trade','=',$trade);*/
  362. //匹配工作地区 - 判断三级地区是否存在,如果不存在则判断二级地区
  363. $district = $job->district;
  364. if ($district) {
  365. if (!strpos($district, ".")) {
  366. $where[] = array('district', '=', $district);
  367. } else {
  368. $district_arr = explode('.', $district);
  369. if (array_has($district_arr, 2) && array_get($district_arr, 2) > 0) {
  370. $where[] = array('district', '=', $district_arr[2]);
  371. } else {
  372. $where[] = array('district', '=', $district_arr[1]);
  373. }
  374. }
  375. }
  376. //匹配期望薪资
  377. if ($job->wage >= -1) {
  378. $where[] = array('wage_min', '>=', $job->wage_min);
  379. $where[] = array('wage_max', '<=', $job->wage_max);
  380. }
  381. //期望职位 - intention_jobs_id
  382. $category = $job->category;
  383. if ($category) {
  384. $where[] = array('intention_jobs_id', '=', $category);
  385. }
  386. }
  387. }
  388. $where[] = array('subsite_ids', '=', get_subsite_id());
  389. return $where;
  390. }
  391. public function ajaxGetStatistics($request, $user)
  392. {
  393. $where['company_id'] = $user->id;
  394. $type = $request['type'] ? $request['type'] : 'visitor';
  395. switch ($type) {
  396. case 'visitor':
  397. $where['apply'] = 0;
  398. break;
  399. case 'apply':
  400. $where['apply'] = 1;
  401. break;
  402. case 'viewjobs':
  403. $where['apply'] = 0;
  404. $where[] = ['job_id', '>', 0];
  405. break;
  406. }
  407. $settr = $request['settr'] ? $request['settr'] : 7;
  408. $today = date('Y-m-d');
  409. $where[] = ['created_at', '<', $today];
  410. if ($settr > 0) {
  411. $settr_tmp = strtotime($today) - $settr * 3600 * 24;
  412. $where[] = ['created_at', '>=', date('Y-m-d H:i:s', $settr_tmp)];
  413. $where[] = ['created_at', '<', $today];
  414. }
  415. $category = [];
  416. $set_total = $set_login = [];
  417. for ($i = $settr_tmp; $i < strtotime($today); $i = $i + 3600 * 24) {
  418. $category[] = date('Y-m-d', $i);
  419. $set_total[$i] = 0;
  420. $set_login[$i] = 0;
  421. }
  422. $uidArr = [];
  423. $statistics_list = $this->companyStatisticsRepository->findWhere($where);
  424. foreach ($statistics_list as $key => $value) {
  425. if ($value['uid'] > 0) {
  426. $set_login[strtotime(date('Y-m-d', strtotime($value['created_at'])))]++;
  427. }
  428. $set_total[strtotime(date('Y-m-d', strtotime($value['created_at'])))]++;
  429. }
  430. $line_xml = '<chart palettecolors="#0075c2,#1aaf5d" bgcolor="#ffffff" showborder="0" showshadow="0" showcanvasborder="0" useplotgradientcolor="0" legendborderalpha="0" legendshadow="0" showaxislines="0" showalternatehgridcolor="0" divlinethickness="1" divlinedashed="1" divlinedashlen="1" showvalues="0">';
  431. $line_xml .= '<categories>';
  432. foreach ($category as $key => $value) {
  433. $line_xml .= '<category label="' . $value . '" />';
  434. }
  435. $line_xml .= '</categories>';
  436. if ($where['apply'] == 1) {
  437. $line_xml .= '<dataset seriesname="用户应聘次数">';
  438. foreach ($set_login as $key => $value) {
  439. $line_xml .= '<set value="' . $value . '" />';
  440. }
  441. $line_xml .= '</dataset>';
  442. } else {
  443. $line_xml .= '<dataset seriesname="总浏览次数">';
  444. foreach ($set_total as $key => $value) {
  445. $line_xml .= '<set value="' . $value . '" />';
  446. }
  447. $line_xml .= '</dataset>';
  448. $line_xml .= '<dataset seriesname="登录用户浏览次数">';
  449. foreach ($set_login as $key => $value) {
  450. $line_xml .= '<set value="' . $value . '" />';
  451. }
  452. $line_xml .= '</dataset>';
  453. }
  454. $line_xml .= '</chart>';
  455. $res = [
  456. 'line_xml' => $line_xml,
  457. ];
  458. return response()->json(['data' => view('app.company.ajax.ajax_statistics', $res)->render()]);
  459. }
  460. public function mobileCompanySave($data, $user)
  461. {
  462. $id = $data['id'];
  463. $updateData['short_name'] = $data['short_name'];
  464. $updateData['nature'] = $data['nature'];
  465. $updateData['scale'] = $data['scale'];
  466. $updateData['trade'] = $data['trade'];
  467. $updateData['district'] = $data['district'];
  468. $updateData['district_cn'] = get_district_cn($data['district']);
  469. $updateData['contents'] = $data['contents'];
  470. $updateData['address'] = $data['address'];
  471. $updateData['contact'] = $data['contact'];
  472. $updateData['mobile'] = $data['mobile'];
  473. $updateData['email'] = $data['email'];
  474. $updateData['map_x'] = $data['map_x'] ? $data['map_x'] : 0;
  475. $updateData['map_y'] = $data['map_y'] ? $data['map_y'] : 0;
  476. $updateData['map_zoom'] = $data['map_zoom'] ? $data['map_zoom'] : 0;
  477. $updateData['tag'] = explode(',', $data['tag']);
  478. $updateData['landline_tel'] = $data['landline_tel_first'] . '-' . $data['landline_tel_next'] . '-' . $data['landline_tel_last'];
  479. !empty($data['landline_tel_first']) ? $updateData['landline_tel'] = $data['landline_tel_first'] : $updateData['landline_tel'] = "";
  480. !empty($data['landline_tel_next']) ? $updateData['landline_tel'] = $updateData['landline_tel'] . "-" . $data['landline_tel_next'] : "";
  481. !empty($data['landline_tel_last']) ? $updateData['landline_tel'] = $updateData['landline_tel'] . "-" . $data['landline_tel_last'] : "";
  482. $updateData['organization_code'] = $data['organization_code'];
  483. $updateData['unit_character'] = $data['unit_character'];
  484. $updateData['unit_character_cn'] = get_category($data['unit_character']);
  485. $updateData['industry'] = $data['industry'];
  486. $updateData['industry_cn'] = get_category($data['industry']);
  487. $updateData['economy'] = $data['economy'];
  488. $updateData['economy_cn'] = get_category($data['economy']);
  489. $company_audit = $this->companyRepository->find($id, ['audit']);
  490. if ($company_audit->audit != 0) {
  491. if (config('aix.companyset.audit.audit_type.audit_edit_com') != 1) {
  492. $updateData['audit'] = 2;
  493. }
  494. }
  495. DB::beginTransaction();
  496. try {
  497. if (!$this->companyRepository->companySave($updateData, $user->id)) {
  498. throw new \Exception('企业信息修改失败');
  499. }
  500. event_search_update(Company::class, (string)$id, 'update');
  501. DB::commit();
  502. $taskid = 27;
  503. $dotask = $this->taskService->doTask($taskid, $id, 1);
  504. if ($updateData['map_x'] && $updateData['map_y']) {
  505. $this->taskService->doTask(29, $id, 1);
  506. }
  507. if ($dotask['code']) {
  508. $html = view('app.company.ajax.ajax_com_info_saved', ['points' => $dotask['data']['points']])->render();
  509. return ['status' => 1, 'msg' => '企业信息修改成功', 'html' => $html, 'data' => $dotask['data']['points']];
  510. } else {
  511. $html = view('app.company.ajax.ajax_com_info_saved')->render();
  512. return ['status' => 1, 'msg' => '企业信息修改成功', 'html' => $html, 'data' => ''];
  513. }
  514. } catch (\Exception $e) {
  515. DB::rollback();
  516. return ['status' => 0, 'msg' => $e->getMessage()];
  517. }
  518. }
  519. /**
  520. * @param $data
  521. * @return array
  522. * @throws \Throwable
  523. */
  524. public function companySave($data, $user)
  525. {
  526. if ($data['legal_idcard'] && !isCreditNo($data['legal_idcard'])) {
  527. return ['status' => 0, 'msg' => '法人代表身份证格式不正确'];
  528. }
  529. if (empty($data['address'])) {
  530. return ['status' => 0, 'msg' => '联系地址不能为空'];
  531. }
  532. $apiAddress = apiAddress($data['address']);
  533. if (!$apiAddress) {
  534. return ['status' => 0, 'msg' => '联系地址定位不准确'];
  535. }
  536. $id = $user->id;
  537. $updateData['nature'] = $data['nature'];
  538. $updateData['scale'] = $data['scale'];
  539. $updateData['trade'] = $data['trade'];
  540. $updateData['registered'] = $data['registered'];
  541. $city = getCityInfo($data['district']);
  542. $updateData['district'] = $city['district'];
  543. $updateData['district_cn'] = $city['district_cn_all'];
  544. $updateData['website'] = $data['website'];
  545. $updateData['currency'] = $data['currency'];
  546. $updateData['contents'] = $data['contents'];
  547. $updateData['address'] = $data['address'];
  548. $updateData['contact'] = $data['contact'];
  549. $updateData['mobile'] = $data['mobile'];
  550. $updateData['email'] = $data['email'];
  551. $updateData['legal'] = $data['legal'];
  552. $updateData['legal_idcard'] = $data['legal_idcard'];
  553. $updateData['qq'] = $data['qq'] ? $data['qq'] : '';
  554. $updateData['map_x'] = $apiAddress['lng'];
  555. $updateData['map_y'] = $apiAddress['lat'];
  556. $updateData['map_zoom'] = $data['map_zoom'] ? $data['map_zoom'] : 0;
  557. $updateData['contact_show'] = $data['contact_show'];
  558. $updateData['telephone_show'] = $data['telephone_show'];
  559. $updateData['email_show'] = $data['email_show'];
  560. $updateData['landline_tel_show'] = $data['landline_tel_show'];
  561. $updateData['tag'] = explode(',', $data['tag']);
  562. !empty($data['landline_tel_first']) ? $updateData['landline_tel'] = $data['landline_tel_first'] : $updateData['landline_tel'] = "";
  563. !empty($data['landline_tel_next']) ? $updateData['landline_tel'] = $updateData['landline_tel'] . "-" . $data['landline_tel_next'] : "";
  564. !empty($data['landline_tel_last']) ? $updateData['landline_tel'] = $updateData['landline_tel'] . "-" . $data['landline_tel_last'] : "";
  565. $updateData['logo'] = $data['logo'];
  566. $updateData['short_name'] = $data['short_name'];
  567. $updateData['organization_code'] = $data['organization_code'];
  568. $company_audit = $this->companyRepository->find($id, ['audit']);
  569. if ($company_audit->audit != 0) {
  570. if (config('aix.companyset.audit.audit_type.audit_edit_com') != 1) {
  571. $updateData['audit'] = 2;
  572. }
  573. }
  574. $jobsData['map_x'] = $data['map_x'];
  575. $jobsData['map_y'] = $data['map_y'];
  576. $jobsData['map_zoom'] = $data['map_zoom'] ? $data['map_zoom'] : '';
  577. DB::beginTransaction();
  578. try {
  579. if ($data['sync'] == 1) {
  580. $jobs_id = Jobs::where(['company_id' => $user->id])->pluck('id')->toArray();
  581. $contact = [];
  582. if ($jobs_id) {
  583. $contact['telephone'] = $data['mobile'];
  584. $contact['email'] = $data['email'];
  585. $contact['contact'] = $data['contact'];
  586. $contact['qq'] = $data['qq'];
  587. $contact['landline_tel'] = $updateData['landline_tel'];
  588. $contact['address'] = $data['address'];
  589. $contact['contact_show'] = $data['contact_show'];
  590. $contact['telephone_show'] = $data['telephone_show'];
  591. $contact['email_show'] = $data['email_show'];
  592. $contact['landline_tel_show'] = $data['landline_tel_show'];
  593. JobsContact::whereIn('job_id', $jobs_id)->update($contact);
  594. }
  595. }
  596. if (!$this->companyRepository->companySave($updateData, $id)) {
  597. throw new \Exception('企业信息修改失败');
  598. }
  599. if (!$this->jobsRepository->getJobsByUid($id)->isEmpty()) {
  600. if (!$this->jobsRepository->updateMap($id, $jobsData)) {
  601. throw new \Exception('修改联系方式同步到职位失败!');
  602. }
  603. }
  604. event_search_update(Company::class, (string)$id, 'update');
  605. DB::commit();
  606. if ($jobsData['map_x'] && $jobsData['map_y']) {
  607. $this->taskService->doTask(29, $id, 1);
  608. }
  609. $taskid = 27;
  610. $dotask = $this->taskService->doTask($taskid, $id, 1);
  611. $user = auth('web-company')->user();
  612. $this->memberLogRepository->createLog($user, 1004, "");
  613. if ($dotask['code']) {
  614. $html = view('app.company.ajax.ajax_com_info_saved', ['points' => $dotask['data']['points']])->render();
  615. return ['status' => 1, 'msg' => '企业信息修改成功', 'html' => $html, 'data' => $dotask['data']['points']];
  616. } else {
  617. $html = view('app.company.ajax.ajax_com_info_saved')->render();
  618. return ['status' => 1, 'msg' => '企业信息修改成功', 'html' => $html, 'data' => ''];
  619. }
  620. } catch (\Exception $e) {
  621. DB::rollback();
  622. return ['status' => 0, 'msg' => $e->getMessage()];
  623. }
  624. }
  625. /**保存logo
  626. * @param $request
  627. * @return \Illuminate\Http\JsonResponse
  628. * @throws \Prettus\Validator\Exceptions\ValidatorException
  629. */
  630. public function saveLogo($request, $user)
  631. {
  632. $logo = $request['logo'];
  633. $companyInfo = $this->companyRepository->getCompanyInfoByID($user->id);
  634. //就是重新认证
  635. if (config('aix.companyset.audit.audit_type.audit_edit_com') == 2) {
  636. if (!empty($companyInfo->certificate_img)) {//只要企业的营业执照不为空,那企业就是未认证
  637. $data['audit'] = 2;
  638. } else {
  639. $data['audit'] = 0;
  640. }
  641. }
  642. $data['logo'] = $logo;
  643. if (!$this->companyRepository->companySave($data, $user->id)) {
  644. return response()->json(['status' => 0, 'msg' => "LOGO保存失败!"]);
  645. }
  646. $dotask = $this->taskService->doTask(19, $user->id, 1);
  647. if ($dotask['code']) {
  648. return response()->json(['status' => 1, 'msg' => "LOGO保存成功!", 'data' => ['path' => upload_asset($logo), 'points' => $dotask['data']['points']]]);
  649. } else {
  650. return response()->json(['status' => 1, 'msg' => "LOGO保存成功!", 'data' => ['path' => upload_asset($logo)]]);
  651. }
  652. }
  653. /**删除logo
  654. * @return \Illuminate\Http\JsonResponse
  655. * @throws \Prettus\Validator\Exceptions\ValidatorException
  656. */
  657. public function logoDel($user)
  658. {
  659. $data['logo'] = '';
  660. if (!$this->companyRepository->companySave($data, $user->id)) {
  661. return response()->json(['status' => 0, 'msg' => "LOGO删除失败!"]);
  662. }
  663. return response()->json(['status' => 1, 'msg' => "LOGO删除成功!"]);
  664. }
  665. /**
  666. * 企业资料页面
  667. * @return array
  668. * @throws ResponseException
  669. */
  670. public function companyInfo($user)
  671. {
  672. $companyInfo = $this->companyRepository->getCompanyInfoByID($user->id);
  673. if ($companyInfo->subsite_id) {
  674. $subsiteInfo = $this->subsiteRepository->find($companyInfo->subsite_id);
  675. } else {
  676. $subsiteInfo = '';
  677. }
  678. $companyInfo->subsite_name = $subsiteInfo ? $subsiteInfo->sitename : '总站';
  679. //企业性质
  680. $companyType = Category::categoryType('AIX_company_type');
  681. //企业规模
  682. $scale = Category::categoryType('AIX_scale');
  683. //企业行业
  684. $trade = Category::categoryType('AIX_trade');
  685. //单位性质
  686. $unit_character = Category::categoryType('AIX_dwxz');
  687. $industry = Category::categoryType('AIX_cylb');
  688. $economy = Category::categoryType('AIX_jjlx');
  689. if ($jump_certificate = config('aix.companyset.audit.checkset.login_com_audit_certificate') == 1 && $companyInfo->audit == 0) {
  690. $jump_certificate = 1;
  691. } else {
  692. $jump_certificate = 0;
  693. }
  694. $res = [
  695. 'companyInfo' => $companyInfo,
  696. 'companyType' => $companyType,
  697. 'scale' => $scale,
  698. 'trade' => $trade,
  699. 'unit_character' => $unit_character,
  700. 'industry' => $industry,
  701. 'economy' => $economy,
  702. 'jump_certificate' => $jump_certificate,
  703. ];
  704. return $res;
  705. }
  706. /**
  707. * 获取企业基本信息
  708. * @return mixed
  709. * @throws ResponseException
  710. */
  711. public function getInfoById($user)
  712. {
  713. return $this->companyRepository->getCompanyInfoByID($user->id);
  714. }
  715. /**
  716. * 获取企业基本信息
  717. * @return mixed
  718. * @throws ResponseException
  719. */
  720. public function getCompInfo($id)
  721. {
  722. $where = ['id' => $id];
  723. return $this->companyRepository->getCompanyInfo($where);
  724. }
  725. /**
  726. * 账号安全
  727. * @return array
  728. * @throws ResponseException
  729. */
  730. public function companySecurity($user)
  731. {
  732. $companyInfo = $this->companyRepository->getCompanyInfoByID($user->id);
  733. $thirdBindQq = $this->thirdloginRepository->checkBind($user, ['1']); //qq
  734. $thirdBindWechat = $this->thirdloginRepository->checkBind($user, ['2', '3', '4']); //微信
  735. $isBind_qq = 0;
  736. $isBind_weixin = 0;
  737. if ($thirdBindQq) {
  738. $isBind_qq = 1;
  739. }
  740. if ($thirdBindWechat) {
  741. $isBind_weixin = 1;
  742. }
  743. $res = [
  744. 'companyInfo' => $companyInfo,
  745. 'qq' => $isBind_qq,
  746. 'weixin' => $isBind_weixin,
  747. ];
  748. return $res;
  749. }
  750. public function unBindThird($alias, $user)
  751. {
  752. $type = [];
  753. switch ($alias) {
  754. case 'qq':
  755. $type = ['1'];
  756. break;
  757. case 'weixin':
  758. $type = ['2', '3', '4'];
  759. break;
  760. }
  761. if (!$type) {
  762. return response()->json(['status' => 0, 'msg' => "参数错误"]);
  763. }
  764. if (!$this->thirdloginRepository->checkBind($user, $type)) {
  765. return response()->json(['status' => 0, 'msg' => "参数错误"]);
  766. }
  767. if ($this->thirdloginRepository->unBind($type, $user)) {
  768. return response()->json(['status' => 1, 'msg' => "解绑成功!"]);
  769. }
  770. return response()->json(['status' => 0, 'msg' => "解绑失败!"]);
  771. }
  772. /**
  773. * 修改用户名
  774. * @param $request
  775. * @return bool
  776. * @throws \Prettus\Validator\Exceptions\ValidatorException
  777. */
  778. public function saveUsername($username, $user)
  779. {
  780. if (!$this->companyRepository->save(['username' => $username], $user->id)) {
  781. return false;
  782. }
  783. return true;
  784. }
  785. public function modifyUserName($user)
  786. {
  787. return $this->companyRepository->getCompanyColumn($user->id, ['username']);
  788. }
  789. /**
  790. * 修改密码
  791. * @param $oldpassword
  792. * @param $pwd
  793. * @param $pwd1
  794. * @return bool
  795. * @throws ResponseException
  796. * @throws \Prettus\Validator\Exceptions\ValidatorException
  797. */
  798. public function savePwd($user, $oldpassword, $pwd, $pwd1)
  799. {
  800. $com_info = $this->companyRepository->getCompanyColumn($user->id, ['password']);
  801. if (!Hash::check($oldpassword, $com_info['password'])) {
  802. throw new ResponseException('原密码不正确!');
  803. }
  804. if ($oldpassword == $pwd) {
  805. throw new ResponseException('新密码与原密码一致!');
  806. }
  807. if ($pwd != $pwd1) {
  808. throw new ResponseException('新密码与确认密码不一致');
  809. }
  810. if (!$this->companyRepository->save(['password' => bcrypt($pwd)], $user->id)) {
  811. return false;
  812. }
  813. return true;
  814. }
  815. /**
  816. * 验证手机
  817. * @return mixed
  818. */
  819. public function authMobile($user)
  820. {
  821. return $this->companyRepository->getCompanyColumn($user->id, ['mobile', 'mobile_audit']);
  822. }
  823. public function checkMobileAudit($id, $mobile)
  824. {
  825. return $this->companyRepository->findByField(['id' => $id, 'mobile' => $mobile, 'mobile_audit' => 1]);
  826. }
  827. /**
  828. * 认证手机
  829. * @param $request
  830. * @return \Illuminate\Http\JsonResponse
  831. */
  832. public function verifyCode($mobile, $user)
  833. {
  834. $data['mobile'] = $mobile;
  835. $data['mobile_audit'] = 1;
  836. if (!$this->companyRepository->verifyCode($data, $user->id)) {
  837. return ['status' => 0, 'msg' => '手机认证失败'];
  838. }
  839. $taskRes = $this->taskService->doTask(22, $user->id, 1);
  840. if (!$taskRes['code']) {
  841. return ['status' => 1, 'msg' => '你的手机已经通过验证!'];
  842. }
  843. return ['status' => 1, 'msg' => '你的手机已经通过验证', 'data' => $taskRes['data']];
  844. }
  845. /**
  846. * 验证email
  847. * @return mixed
  848. */
  849. public function authEmail($user)
  850. {
  851. return $this->companyRepository->getCompanyColumn($user->id, ['email', 'email_audit']);
  852. }
  853. public function checkEmailAudit($id, $email)
  854. {
  855. return $this->companyRepository->findByField(['id' => $id, 'email' => $email, 'email_audit' => 1]);
  856. }
  857. /**
  858. * 企业登录日志
  859. * @return mixed
  860. */
  861. public function companyLoginLog($user)
  862. {
  863. return $this->memberLogRepository->getMemberLog($user->id, 1, 1001);
  864. }
  865. /**
  866. * @param $request
  867. * @return mixed
  868. * @throws \Prettus\Validator\Exceptions\ValidatorException
  869. */
  870. public function certificate($certificate_img_up, $user)
  871. {
  872. $data['audit'] = 2;
  873. $data['certificate_img'] = $certificate_img_up;
  874. if (!$this->companyRepository->save($data, $user->id)) {
  875. return response()->json(['status' => 0, 'msg' => '营业执照保存失败']);
  876. }
  877. //写入日志
  878. $this->memberLogRepository->createLog($user, 1005, "");
  879. return response()->json(['status' => 1, 'msg' => '营业执照保存成功']);
  880. }
  881. //获取企业详细信息页面内容
  882. public function getCompanyInfo($where)
  883. {
  884. $where[] = array('user_status', '=', 1);
  885. //获取企业信息
  886. $company = $this->companyRepository->getCompanyInfo($where);
  887. if (!$company) {
  888. throw new ResponseException('企业不存在', [], 404);
  889. }
  890. //处理企业地址和介绍、logo
  891. $company->company_url = route(url_rewrite('AIX_companyshow'), array('id' => $company->id));
  892. $company->company_profile = htmlspecialchars_decode($company->contents, ENT_QUOTES);
  893. if ($company->logo) {
  894. $company->logo = upload_asset($company->logo);
  895. } else {
  896. $company->logo = public_data_path('data/upload/no_logo.png');
  897. }
  898. //简历处理率、统计近两周企业简历处理率、如果收到的简历是0份,则简历处理率为0%
  899. $app_where[] = array('company_id', '=', $company->id);
  900. $app_where[] = array('created_at', '>', date('Y-m-d H:i:s', strtotime("-14day")));
  901. $apply = $this->personalJobsApplyRepository->getJobsApply($app_where);
  902. $reply = 0;
  903. $reply_time = 0;
  904. foreach ($apply as $key => $val) {
  905. if ($val->is_reply) {
  906. $reply++;
  907. $val['reply_time'] && $reply_time += $val->reply_time - strtotime($val->created_at);
  908. }
  909. }
  910. if ($apply->toArray()) {
  911. $company->reply_ratio = intval($reply / count($apply) * 100);
  912. if ($reply_time) {
  913. $company->reply_time = sub_day(intval($reply_time / count($apply)), 0);
  914. } else {
  915. $company->reply_time = '0天';
  916. }
  917. } else {
  918. $company->reply_ratio = 0;
  919. $company->reply_time = '0天';
  920. }
  921. //登录时间
  922. if (!$company->last_login_time) {
  923. $company->last_login_time = '未登录';
  924. } else {
  925. $company->last_login_time = date('Y-m-d H:i', $company->last_login_time);
  926. }
  927. //获取在招职位信息(职位显示规则)
  928. $jobs_display = config('aix.companyset.comset.show_set.jobs_display');
  929. $job_count_map = array(array('company_id', '=', $company->id), array('valid', '=', 1), array('display', '=', 1));
  930. if ($jobs_display == 1) {
  931. $job_count_map[] = array('audit', '=', '1');
  932. } else {
  933. $job_count_map[] = array('audit', '<>', '3');
  934. }
  935. $jobs_count = $this->jobsRepository->getJobsCount($job_count_map);
  936. $company->jobs_count = $jobs_count;
  937. //企业网址
  938. if ($company->website) {
  939. $company->website_ = $company->website;
  940. if ((strstr($company->website, "http://") === false) && (strstr($company->website, "https://") === false)) {
  941. $company->website = "http://" . $company->website;
  942. } else {
  943. if (strstr($company->website, "http://") === false) {
  944. $company->website_ = str_replace("https://", "", $company->website_);
  945. } else {
  946. $company->website_ = str_replace("http://", "", $company->website_);
  947. }
  948. }
  949. }
  950. //获取粉丝数量
  951. $fan_where = array('company_id' => $company->id);
  952. $fans = $this->personFocusComRepository->getFansCount($fan_where);
  953. $company->fans = $fans;
  954. $company->preview = 0;
  955. if (auth('web-company')->check()) {
  956. if (auth('web-company')->user()->id == $company->id) {
  957. $company->preview = 1;
  958. }
  959. }
  960. $company->focus = 0;
  961. //个人用户登录时判断是否关注过当前企业
  962. if (auth('web-member')->check()) {
  963. $focus_where = array(
  964. 'uid' => auth('web-member')->user()->id,
  965. 'company_id' => $company->id
  966. );
  967. $focus_rst = $this->personFocusComRepository->getFocus($focus_where);
  968. if ($focus_rst) {
  969. $company->focus = 1;
  970. }
  971. }
  972. //企业风采
  973. $img_where = array(
  974. array('company_id', '=', $company->id)
  975. );
  976. $companyimg_display = config('aix.companyset.comset.show_set.companyimg_display');
  977. if ($companyimg_display == 1) {
  978. $img_where[] = array('audit', '=', 1);
  979. } else {
  980. $img_where[] = array('audit', '<>', 3);
  981. }
  982. $company_images = $this->companyImgRepository->getImages($img_where);
  983. if ($company_images->toArray()) {
  984. foreach ($company_images as $key => $value) {
  985. $company_images[$key]->img = upload_asset($value->image);
  986. }
  987. } else {
  988. $company_images = null;
  989. }
  990. $company->img = $company_images;
  991. //亮点tag
  992. $tag_arr = array();
  993. $other_categories = $this->categoryRepository->getCategories();
  994. if (implode(',', $company->tag)) {
  995. $tag_ids = $company->tag;
  996. if ($other_categories) {
  997. $tag_category = array_get($other_categories, 'AIX_jobtag');
  998. if ($tag_category) {
  999. foreach ($tag_ids as $k => $v) {
  1000. if (array_get($tag_category, $v)) {
  1001. $tag_arr[] = array_get($tag_category, $v);
  1002. }
  1003. }
  1004. }
  1005. }
  1006. }
  1007. $company->tag_arr = $tag_arr;
  1008. //企业性质/行业/规模/地区/注册资金
  1009. $company->nature_cn = '';
  1010. $company->trade_cn = '';
  1011. $company->scale_cn = '';
  1012. $company->district_cn = '';
  1013. if ($other_categories) {
  1014. $company_types = array_get($other_categories, 'AIX_company_type');
  1015. $company_trades = array_get($other_categories, 'AIX_trade');
  1016. $company_scales = array_get($other_categories, 'AIX_scale');
  1017. if ($company_types) {
  1018. $type_cn = array_get($company_types, $company->nature);
  1019. if ($type_cn) {
  1020. $company->nature_cn = $type_cn['demand'];
  1021. }
  1022. }
  1023. $company_trades = array_get($other_categories, 'AIX_trade');
  1024. if ($company_trades) {
  1025. $trade_cn = array_get($company_trades, $company->trade);
  1026. if ($trade_cn) {
  1027. $company->trade_cn = $trade_cn['demand'];
  1028. }
  1029. }
  1030. $company_scales = array_get($other_categories, 'AIX_scale');
  1031. if ($company_scales) {
  1032. $scale_cn = array_get($company_scales, $company->scale);
  1033. if ($scale_cn) {
  1034. $company->scale_cn = $scale_cn['demand'];
  1035. }
  1036. }
  1037. }
  1038. $city_cates = Cache::get('city_cate_list');
  1039. if (null === $city_cates) {
  1040. $city_cates = $this->categoryDistrictRepository->cityCateCache();
  1041. Cache::put('city_cate_list', $city_cates, '86400');
  1042. }
  1043. if (!strpos($company->district, ".")) { //直接读取地区信息
  1044. $district_cn = array_get($city_cates['id'], $company->district);
  1045. if ($district_cn) {
  1046. $company->district_cn = $district_cn['name'];
  1047. }
  1048. } else {//处理地区信息
  1049. $c_district = explode('.', $company->district);
  1050. $district_cn = array();
  1051. foreach ($c_district as $k => $v) {
  1052. if ($v) {
  1053. $district_info = array_get($city_cates['id'], $v);
  1054. if ($district_info) {
  1055. $district_cn[] = $district_info['name'];
  1056. }
  1057. }
  1058. }
  1059. $district_cn = implode('/', $district_cn);
  1060. $company->district_cn = $district_cn;
  1061. }
  1062. ///会员套餐
  1063. $setmeal = $this->memberSetmealRepository->getSetmealByUid($company->id, $company->utype);
  1064. $company->setmeal = $setmeal;
  1065. $company->setmeal_id = $setmeal->id;
  1066. $company->setmeal_name = $setmeal->setmeal_name;
  1067. $company->setmeal_img = $setmeal->setmeal_img;
  1068. ///联系方式
  1069. /*判断查看联系方式设置
  1070. 如果设置成游客
  1071. 判断企业中心的联系方式设置 公开 完全显示,
  1072. 不公开 显示‘企业设置不公开’
  1073. 设置成登陆会员
  1074. 游客:
  1075. 企业中心的联系方式设置 公开 *******
  1076. 不公开 显示‘企业设置不公开’
  1077. 已登录用户:
  1078. 企业中心的联系方式设置 公开 完全显示
  1079. 不公开 显示‘企业设置不公开’
  1080. 如果设置成下载后可见
  1081. 判断企业中心的联系方式设置 公开 *******,
  1082. 不公开 显示‘企业设置不公开’
  1083. *
  1084. */
  1085. /// 处理固定电话
  1086. if (strstr($company->landline_tel, '-')) {
  1087. $landline_tel_arr = explode('-', $company->landline_tel);
  1088. foreach ($landline_tel_arr as $k => $v) {
  1089. if (!(int)$v) {
  1090. unset($landline_tel_arr[$k]);
  1091. }
  1092. }
  1093. } elseif (strstr($company->landline_tel, ' ')) {
  1094. $landline_tel_arr = explode(' ', $company->landline_tel);
  1095. foreach ($landline_tel_arr as $k => $v) {
  1096. if (!(int)$v) {
  1097. unset($landline_tel_arr[$k]);
  1098. }
  1099. }
  1100. } else {
  1101. $landline_tel_arr = (array)$company->landline_tel;
  1102. }
  1103. if ($landline_tel_arr) {
  1104. $landline_tel = implode('-', $landline_tel_arr);
  1105. } else {
  1106. $landline_tel = '';
  1107. }
  1108. $company->landline_tel = $landline_tel;
  1109. $hide = true;
  1110. if (config('aix.companyset.comset.contact_set.showjobcontact') == 0) { //游客
  1111. $hide = false;
  1112. } elseif (config('aix.companyset.comset.contact_set.showjobcontact') == 1) { //已登录会员
  1113. if (auth('web-member')->check() || auth('web-company')->check()) {
  1114. $hide = false;
  1115. }
  1116. }
  1117. if ($hide) {
  1118. if ($company->mobile) {
  1119. $company->mobile = contact_hide($company->mobile, 2);
  1120. }
  1121. if ($company->landline_tel) {
  1122. $company->landline_tel = contact_hide($landline_tel, 1);
  1123. }
  1124. if ($company->email) {
  1125. $company->email = contact_hide($company->email, 3);
  1126. }
  1127. }
  1128. if (!$company->contact_show) {
  1129. $company->contact = '企业设置不公开';
  1130. }
  1131. //联系方式展现方式
  1132. $pwdhash = config('aix.system.site_other.site_other.pwb_hash');
  1133. if (config('aix.companyset.comset.contact_type_set.contact_img_com') == 2) {
  1134. if (!$company->telephone_show) {
  1135. $company->mobile = '企业设置不公开';
  1136. } else {
  1137. if ($company->mobile) {
  1138. $company->mobile = "<img src='" . route('common.contact_img', array('text' => encrypt($company->mobile, $pwdhash), 'type' => 'phone')) . "' />";
  1139. }
  1140. }
  1141. if (!$company->landline_tel_show) {
  1142. $company->landline_tel = '企业设置不公开';
  1143. } else {
  1144. if ($company->landline_tel) {
  1145. $company->landline_tel = "<img src='" . route('common.contact_img', array('text' => encrypt($company->landline_tel, $pwdhash), 'type' => 'phone')) . "' />";
  1146. }
  1147. }
  1148. if (!$company->email_show) {
  1149. $company->email = '企业设置不公开';
  1150. } else {
  1151. if ($company->email) {
  1152. $company->email = "<img src='" . route('common.contact_img', array('text' => encrypt($company->email, $pwdhash), 'type' => 'email')) . "' />";
  1153. }
  1154. }
  1155. } else {
  1156. //判断企业中心设置
  1157. if (!$company->telephone_show) {
  1158. $company->mobile = '企业设置不公开';
  1159. }
  1160. if (!$company->landline_tel_show) {
  1161. $company->landline_tel = '企业设置不公开';
  1162. }
  1163. if (!$company->email_show) {
  1164. $company->email = '企业设置不公开';
  1165. }
  1166. }
  1167. $company->hide = $hide;
  1168. $company->setmeal_id = $setmeal->setmeal_id;
  1169. $company->setmeal_name = $setmeal->setmeal_name;
  1170. //来源分站名称
  1171. $subsites = Cache::get('subsites_list');
  1172. if (array_has($subsites, $company->subsite_id)) {
  1173. $company->subsite_cn = $subsites[$company->subsite_id]['sitename'];
  1174. } else {
  1175. $company->subsite_cn = '';
  1176. }
  1177. return $company;
  1178. }
  1179. //关注/取消关注
  1180. public function focusCompany($company_id, $person_id)
  1181. {
  1182. $focus_where = array(
  1183. 'uid' => $person_id,
  1184. 'company_id' => $company_id
  1185. );
  1186. $has = $this->personFocusComRepository->getFocus($focus_where);
  1187. if ($has) {
  1188. //取消关注
  1189. $rst = $this->personFocusComRepository->deleteFocus($focus_where);
  1190. if ($rst) {
  1191. return array('status' => 1, 'msg' => '已取消关注!', 'data' => array('html' => '关注', 'op' => 2));
  1192. } else {
  1193. return array('status' => 0, 'msg' => '取消关注失败!');
  1194. }
  1195. } else {
  1196. //关注
  1197. $stime = date('Y-m-d H:i:s', time());
  1198. $focus_data = array(
  1199. 'uid' => $person_id,
  1200. 'company_id' => $company_id,
  1201. 'created_at' => $stime,
  1202. 'updated_at' => $stime
  1203. );
  1204. $rst = $this->personFocusComRepository->addFocus($focus_data);
  1205. if ($rst) {
  1206. return array('status' => 1, 'msg' => '已关注!', 'data' => array('html' => '取消关注', 'op' => 1));
  1207. } else {
  1208. return array('status' => 0, 'msg' => '关注失败!');
  1209. }
  1210. }
  1211. }
  1212. //添加企业访客统计
  1213. public function addStatistics($company_id, $job_id = 0, $user = array(), $apply = 0, $source = 1)
  1214. {
  1215. $uid = 0;
  1216. $utype = 0;
  1217. $source = $source;
  1218. if ($user) {
  1219. $utype = $user->utype;
  1220. $uid = $user->id;
  1221. }
  1222. if ($job_id) {
  1223. $apply = 1;
  1224. }
  1225. $time = date('Y-m-d H:i:s', time());
  1226. $add_data = array(
  1227. 'company_id' => (int)$company_id,
  1228. 'uid' => $uid,
  1229. 'utype' => $utype,
  1230. 'job_id' => $job_id,
  1231. 'source' => $source,
  1232. 'apply' => $apply,
  1233. 'created_at' => $time,
  1234. 'updated_at' => $time
  1235. );
  1236. return $this->companyStatisticsRepository->addRecord($add_data);
  1237. }
  1238. //获取其它公司
  1239. public function getSetmailCompanies($where, $limit = 20)
  1240. {
  1241. $except_id = array_get($where, 'except_id');
  1242. if (array_has($where, 'except_id')) {
  1243. unset($where['except_id']);
  1244. }
  1245. if ($limit > 20) {
  1246. $limit = 20;
  1247. }
  1248. $order = 'real_refreshtime desc,id desc';
  1249. $field = '*,if(refresh_time>UNIX_TIMESTAMP(NOW()),(refresh_time-100000000),refresh_time) as real_refreshtime';
  1250. //处理trade
  1251. $map = array();
  1252. $trade = array_get($where, 'trade');
  1253. $trade_in = array();
  1254. if ($trade) {
  1255. if (strpos($trade, ',')) {
  1256. $arr = explode(',', $trade);
  1257. $sqlin = implode(',', array_slice($arr, 0, $limit));
  1258. if (preg_match('/^(\d{1,10},)*(\d{1,10})$/', $sqlin) === 1) {
  1259. $trade_in = explode(',', $sqlin);
  1260. }
  1261. } else {
  1262. $map[] = array('trade', '=', intval($trade));
  1263. }
  1264. }
  1265. if ($except_id) {
  1266. $map[] = array('id', '<>', intval($except_id));
  1267. }
  1268. $map[] = array('subsite_id', '=', get_subsite_id());
  1269. $result = $this->companyRepository->getTradeCompanies($map, $trade_in, $field, $order, $limit);
  1270. $job_where = array(
  1271. array('valid', '=', 1),
  1272. array('display', '=', 1),
  1273. );
  1274. if (config('aix.companyset.comset.show_set.jobs_display') == 1) {
  1275. $job_where[] = array('audit', '=', 1);
  1276. } else {
  1277. $job_where[] = array('audit', '<>', 3);
  1278. }
  1279. $order_by = array('refresh_time' => 'desc');
  1280. $com_arr = ['com_id'=>[]];
  1281. if ($result->toArray()) {
  1282. foreach ($result as $key => $value) {
  1283. $row = $value;
  1284. $row->companyname_ = $row->companyname;
  1285. $row->refreshtime_cn = $row->refresh_time > time() ? daterange(time(), $row->real_refreshtime) : daterange(time(), $row->refresh_time);
  1286. $row->url = route(url_rewrite('AIX_companyshow'), array('id' => $row->id));
  1287. $row->comjobs_url = route('jobs.company.jobs', array('id' => $row->id));
  1288. $row->briefly = strip_tags($row->contents);
  1289. if ($row->logo) {
  1290. $row->logo = upload_asset($row->logo);
  1291. } else {
  1292. $row->logo = public_data_path('data/upload/no_logo.png');
  1293. }
  1294. $com_arr['com_id'][] = $row->id;
  1295. $com_arr[$row->id]['logo'] = $row->logo;
  1296. $com_arr[$row->id]['companyname_'] = $row->companyname_;
  1297. $com_arr[$row->id]['comjobs_url'] = $row->comjobs_url;
  1298. $com_arr[$row->id]['url'] = $row->url;
  1299. //$list[] = $row;
  1300. }
  1301. }
  1302. $job_where_in = array('company_id' => $com_arr['com_id']);
  1303. $jobs_list = $this->jobsRepository->getCompanyJobs($job_where, $job_where_in, $order_by, 16);
  1304. if ($jobs_list->isNotEmpty()) {
  1305. foreach ($jobs_list as $k => $val) {
  1306. $subsite_id = get_jobs_subsite_id($val);
  1307. $val->logo = isset($com_arr[$val->company_id]['logo']) ? $com_arr[$val->company_id]['logo'] : '';
  1308. $val->companyname_ = isset($com_arr[$val->company_id]['companyname_']) ? $com_arr[$val->company_id]['companyname_'] : '';
  1309. $val->comjobs_url = isset($com_arr[$val->company_id]['comjobs_url']) ? $com_arr[$val->company_id]['comjobs_url'] : '';
  1310. $val->url = isset($com_arr[$val->company_id]['url']) ? $com_arr[$val->company_id]['url'] : '';
  1311. $val->jobs_url = route(url_rewrite('AIX_jobsshow', null, $subsite_id), array('id'=>$val['id']));
  1312. //薪资待遇
  1313. if ($val->wage > 0) {
  1314. $wage_category = $this->categoryRepository->getOriginCategory(array('alias'=>'AIX_wage','id'=>$val->wage));
  1315. if ($wage_category && preg_match_all('(\d+)', $wage_category->demand, $reg)) {
  1316. $reg = $reg[0];
  1317. if (config('aix.system.site_other.site_other.site_salary') == 1) {
  1318. $val->minwage = $reg[0]%1000==0?(($reg[0]/1000).'K'):(round($reg[0]/1000, 1).'K');
  1319. $val->maxwage = array_has($reg, 1)?($reg[1]%1000==0?(($reg[1]/1000).'K'):(round($reg[1]/1000, 1).'K')):0;
  1320. } elseif (config('aix.system.site_other.site_other.site_salary') == 2) {
  1321. if ($reg[0] >= 10000) {
  1322. if ($reg[0]%10000 == 0) {
  1323. $val->minwage = ($reg[0]/10000).'万';
  1324. } else {
  1325. $minwage = round($reg[0]/10000, 1);
  1326. $val->minwage = strpos($minwage, '.') ? str_replace('.', '万', $minwage) : $minwage.'万';
  1327. }
  1328. } else {
  1329. if ($reg[0]%1000 == 0) {
  1330. $val->minwage = ($reg[0]/1000).'千';
  1331. } else {
  1332. $minwage = round($reg[0]/1000, 1);
  1333. $val->minwage = strpos($minwage, '.') ? str_replace('.', '千', $minwage) : $minwage.'千';
  1334. }
  1335. }
  1336. if (array_has($reg, 1)) {
  1337. if ($reg[1] >= 10000) {
  1338. if ($reg[1]%10000 == 0) {
  1339. $val->maxwage = ($reg[1]/10000).'万';
  1340. } else {
  1341. $maxwage = round($reg[1]/10000, 1);
  1342. $val->maxwage = strpos($maxwage, '.') ? str_replace('.', '万', $maxwage) : $maxwage.'万';
  1343. }
  1344. } elseif ($reg[1]) {
  1345. if ($reg[1]%1000 == 0) {
  1346. $val->maxwage = ($reg[1]/1000).'千';
  1347. } else {
  1348. $maxwage = round($reg[1]/1000, 1);
  1349. $val->maxwage = strpos($maxwage, '.') ? str_replace('.', '千', $maxwage) : $maxwage.'千';
  1350. }
  1351. } else {
  1352. $val->maxwage = 0;
  1353. }
  1354. } else {
  1355. $val->maxwage = 0;
  1356. }
  1357. }
  1358. } else {
  1359. $val->maxwage = 0;
  1360. }
  1361. if ($val->minwage == $val->maxwage) {
  1362. $val->wage_cn = $val->minwage.'/月';
  1363. } else {
  1364. if ($val->minwage>0 && $val->maxwage==0) {
  1365. $val->wage_cn = $val->minwage.'以上/月';
  1366. } else {
  1367. $val->wage_cn = $val->minwage.'~'.$val->maxwage.'/月';
  1368. }
  1369. }
  1370. } elseif ($val->wage == -1) {
  1371. $val->wage_cn = '面议';
  1372. } else {
  1373. //自定义薪资
  1374. $maxwage = $val->wage_max;
  1375. $minwage = $val->wage_min;
  1376. if ($val->ygxs == '363') {
  1377. $val->wage_cn = $val->wage_min . '元/小时';
  1378. } else {
  1379. if (config('aix.system.site_other.site_other.site_salary') == 1) {
  1380. $val->minwage = $minwage % 1000 == 0 ? (($minwage / 1000) . 'K') : (round($minwage / 1000, 1) . 'K');
  1381. if ($minwage == 0) {
  1382. $val->maxwage = '以上';
  1383. } else {
  1384. $val->maxwage = $maxwage % 1000 == 0 ? (($maxwage / 1000) . 'K') : (round($maxwage / 1000, 1) . 'K');
  1385. }
  1386. } elseif (config('aix.system.site_other.site_other.site_salary') == 2) {
  1387. if ($minwage >= 10000) {
  1388. if ($minwage % 10000 == 0) {
  1389. $val->minwage = ($minwage / 10000) . '万';
  1390. } else {
  1391. $minwage = round($minwage / 10000, 1);
  1392. $val->minwage = strpos($minwage, '.') ? str_replace('.', '万', $minwage) : $minwage . '万';
  1393. }
  1394. } else {
  1395. if ($minwage % 1000 == 0) {
  1396. $val->minwage = ($minwage / 1000) . '千';
  1397. } else {
  1398. $minwage = round($minwage / 1000, 1);
  1399. $val->minwage = strpos($minwage, '.') ? str_replace('.', '千', $minwage) : $minwage . '千';
  1400. }
  1401. }
  1402. if ($maxwage > 0) {
  1403. if ($maxwage >= 10000) {
  1404. if ($maxwage % 10000 == 0) {
  1405. $val->maxwage = ($maxwage / 10000) . '万';
  1406. } else {
  1407. $maxwage = round($maxwage / 10000, 1);
  1408. $val->maxwage = strpos($maxwage, '.') ? str_replace('.', '万', $maxwage) : $maxwage . '万';
  1409. }
  1410. } elseif ($maxwage) {
  1411. if ($maxwage % 1000 == 0) {
  1412. $val->maxwage = ($maxwage / 1000) . '千';
  1413. } else {
  1414. $maxwage = round($maxwage / 1000, 1);
  1415. $val->maxwage = strpos($maxwage, '.') ? str_replace('.', '千', $maxwage) : $maxwage . '千';
  1416. }
  1417. } else {
  1418. $val->maxwage = '0';
  1419. }
  1420. } else {
  1421. $val->maxwage = '0';
  1422. }
  1423. }
  1424. if ($val->minwage == $val->maxwage) {
  1425. $val->wage_cn = $val->minwage . '/月';
  1426. } else {
  1427. if ($val->minwage > 0 && $val->maxwage == 0) {
  1428. $val->wage_cn = $val->minwage . '以上/月';
  1429. } else {
  1430. $val->wage_cn = $val->minwage . '~' . $val->maxwage . '/月';
  1431. }
  1432. }
  1433. }
  1434. }
  1435. //工作经验
  1436. $other_categories = $this->categoryRepository->getCategories();
  1437. $job_experience = array_get($other_categories, 'AIX_experience');
  1438. if ($job_experience) {
  1439. $experience_cn = array_get($job_experience, $val->experience);
  1440. }
  1441. if ($experience_cn) {
  1442. $val->experience_cn = $experience_cn['demand'];
  1443. } else {
  1444. $val->experience_cn = '不限';
  1445. }
  1446. //学历要求
  1447. $job_education = array_get($other_categories, 'AIX_education');
  1448. if ($job_education) {
  1449. $education_cn = array_get($job_education, $val->education);
  1450. }
  1451. if ($education_cn) {
  1452. $val->education_cn = $education_cn['demand'];
  1453. } else {
  1454. $val->education_cn = '不限';
  1455. }
  1456. //工作地点
  1457. $city_cates = Cache::get('city_cate_list');
  1458. if (null === $city_cates) {
  1459. $city_cates = $this->categoryDistrictRepository->cityCateCache();
  1460. Cache::put('city_cate_list', $city_cates, '86400');
  1461. }
  1462. if (!strpos($val->district, ".")) {
  1463. if (array_get($city_cates['id'], $val->district)) {
  1464. $val->district_cn = $city_cates['id'][$val->district]['name'];
  1465. if ($city_cates['id'][$val->district]['parent_id'] > 0) {
  1466. $parent_district = array_get($city_cates['id'], $city_cates['id'][$val->district]['parent_id']);
  1467. if ($parent_district) {
  1468. $val->district_cn = $parent_district['name'].$val->district_cn;
  1469. if ($parent_district['parent_id'] > 0) {
  1470. $pp_district = array_get($city_cates['id'], $parent_district['parent_id']);
  1471. if ($pp_district) {
  1472. $val->district_cn = $pp_district['name'].$val->district_cn;
  1473. }
  1474. }
  1475. }
  1476. }
  1477. }
  1478. } else {
  1479. $city_district = explode('.', $val->district);
  1480. $city_district_cn = array();
  1481. foreach ($city_district as $k => $v) {
  1482. if ($v) {
  1483. $district_info = array_get($city_cates['id'], $v);
  1484. if ($district_info) {
  1485. $city_district_cn[] = $district_info['name'];
  1486. }
  1487. }
  1488. }
  1489. $val->district_cn = implode('/', $city_district_cn);
  1490. }
  1491. }
  1492. }
  1493. return $jobs_list;
  1494. }
  1495. //获取其它公司
  1496. public function getOtherCompanies($where, $limit = 10)
  1497. {
  1498. $except_id = array_get($where, 'except_id');
  1499. if (array_has($where, 'except_id')) {
  1500. unset($where['except_id']);
  1501. }
  1502. if ($limit > 20) {
  1503. $limit = 20;
  1504. }
  1505. $order = 'real_refreshtime desc,id desc';
  1506. $field = '*,if(refresh_time>UNIX_TIMESTAMP(NOW()),(refresh_time-100000000),refresh_time) as real_refreshtime';
  1507. //处理trade
  1508. $map = array();
  1509. $trade = array_get($where, 'trade');
  1510. $trade_in = array();
  1511. if ($trade) {
  1512. if (strpos($trade, ',')) {
  1513. $arr = explode(',', $trade);
  1514. $sqlin = implode(',', array_slice($arr, 0, $limit));
  1515. if (preg_match('/^(\d{1,10},)*(\d{1,10})$/', $sqlin) === 1) {
  1516. $trade_in = explode(',', $sqlin);
  1517. }
  1518. } else {
  1519. $map[] = array('trade', '=', intval($trade));
  1520. }
  1521. }
  1522. if ($except_id) {
  1523. $map[] = array('id', '<>', intval($except_id));
  1524. }
  1525. $map[] = array('subsite_id', '=', get_subsite_id());
  1526. $result = $this->companyRepository->getTradeCompanies($map, $trade_in, $field, $order, $limit);
  1527. $list = array();
  1528. if ($result->toArray()) {
  1529. foreach ($result as $key => $value) {
  1530. $row = $value;
  1531. $row->companyname_ = $row->companyname;
  1532. $row->refreshtime_cn = $row->refresh_time > time() ? daterange(time(), $row->real_refreshtime) : daterange(time(), $row->refresh_time);
  1533. $row->url = route(url_rewrite('AIX_companyshow'), array('id' => $row->id));
  1534. //$row['comjobs_url'] = url_rewrite('QS_companyjobs',array('id'=>$row['id']));
  1535. $row->comjobs_url = route('jobs.company.jobs', array('id' => $row->id));
  1536. $row->contents = str_replace('&nbsp;', '', $row->contents);
  1537. $row->briefly = strip_tags($row->contents);
  1538. if ($row->logo) {
  1539. $row->logo = upload_asset($row->logo);
  1540. } else {
  1541. $row->logo = public_data_path('data/upload/no_logo.png');
  1542. }
  1543. $row->jobs_count = $this->getCompanyValidJobs($row->id);
  1544. $list[] = $row;
  1545. }
  1546. }
  1547. return $list;
  1548. }
  1549. /**
  1550. * 根据查询条件获取企业
  1551. * @param $where
  1552. * @param int $limit
  1553. */
  1554. public function getCompaniesByConditions($where,$limit = 10){
  1555. if ($limit > 20) {
  1556. $limit = 20;
  1557. }
  1558. $order = 'real_refreshtime desc,id desc';
  1559. $field = '*,if(refresh_time>UNIX_TIMESTAMP(NOW()),(refresh_time-100000000),refresh_time) as real_refreshtime';
  1560. //处理trade
  1561. $map = array();
  1562. $map[] = array('subsite_id', '=', $where['subsite_id']);
  1563. $result = $this->companyRepository->getTradeCompanies($map, [], $field, $order, $limit);
  1564. $job_where = array(
  1565. array('valid', '=', 1),
  1566. array('display', '=', 1),
  1567. );
  1568. if (config('aix.companyset.comset.show_set.jobs_display') == 1) {
  1569. $job_where[] = array('audit', '=', 1);
  1570. } else {
  1571. $job_where[] = array('audit', '<>', 3);
  1572. }
  1573. $order_by = array('refresh_time' => 'desc');
  1574. if ($result->toArray()) {
  1575. $result = $result->toArray();
  1576. foreach ($result as $key => $value) {
  1577. $result[$key]['companyname'] = $value['companyname'];
  1578. $result[$key]['refreshtime_cn'] = $value['refresh_time'] > time() ? daterange(time(), $value['real_refreshtime']) : daterange(time(), $value['refresh_time']);
  1579. $result[$key]['url'] = route(url_rewrite('AIX_companyshow'), array('id' => $value['id']));
  1580. $result[$key]['comjobs_url'] = route('jobs.company.jobs', array('id' => $value['id']));
  1581. $result[$key]['briefly'] = strip_tags($value['contents']);
  1582. if ($value['logo']) {
  1583. $result[$key]['logo'] = upload_asset($value['logo']);
  1584. } else {
  1585. $result[$key]['logo'] = public_data_path('data/upload/no_logo.png');
  1586. }
  1587. $job_where_in = array('company_id'=>array($value['id']));
  1588. $jobs_list = $this->jobsRepository->getCompanyJobs($job_where, $job_where_in, $order_by,16);
  1589. $result[$key]['jobs'] = $jobs_list->toArray();
  1590. //$list[] = $row;
  1591. }
  1592. }
  1593. return $result;
  1594. }
  1595. //获取企业在招职位
  1596. public function getCompanyValidJobs($company_id)
  1597. {
  1598. $jobs_display = config('aix.companyset.comset.show_set.jobs_display');
  1599. $job_count_map = array(
  1600. array('company_id', '=', $company_id),
  1601. array('valid', '=', 1)
  1602. );
  1603. if ($jobs_display == 1) {
  1604. $job_count_map[] = array('audit', '=', '1');
  1605. } else {
  1606. $job_count_map[] = array('audit', '<>', '3');
  1607. }
  1608. return $this->jobsRepository->getJobsCount($job_count_map);
  1609. }
  1610. //获取企业会员积分
  1611. public function getPoint($uid, $utype)
  1612. {
  1613. return $this->memberPointRepository->getPointsById($uid, $utype);
  1614. }
  1615. /**签到
  1616. * @return array
  1617. */
  1618. public function signIn($user)
  1619. {
  1620. $signCount = $this->taskLogRepository->getTaskLogCount($user->id, 18, $user->utype);
  1621. if ($signCount) {
  1622. return ['code' => 0, 'msg' => '您今天已经签到过了!', 'info' => ''];
  1623. } else {
  1624. $res = $this->taskService->doTask(18, $user->id, 1);
  1625. if ($res['code'] == 1) {
  1626. $this->memberLogRepository->createLog($user, 8003, "");
  1627. return ['code' => 1, 'msg' => '签到成功', 'info' => $res['data']['points']];
  1628. } else {
  1629. return ['code' => 1, 'msg' => $res['info'], 'info' => ''];
  1630. }
  1631. }
  1632. }
  1633. /**企业中心======我的消息(系统消息)
  1634. * @param $request
  1635. * @return array
  1636. */
  1637. public function comPms($data, $user)
  1638. {
  1639. $where = [];
  1640. $new = isset($data['new']) ? $data['new'] : '';
  1641. $settr = isset($data['settr']) ? $data['settr'] : '';
  1642. if ($new) {
  1643. $where['new'] = $new;
  1644. }
  1645. if ($settr) {
  1646. $where[] = ['created_at', '<=', date('Y-m-d H:i:s', strtotime("{$settr} day"))];
  1647. }
  1648. $param_array = array('new', 'settr');
  1649. $params = array();
  1650. if ($data) {
  1651. foreach ($data as $k => $v) {
  1652. if (in_array($k, $param_array)) {
  1653. $params[$k] = $v;
  1654. }
  1655. }
  1656. }
  1657. $where['msgtouid'] = $user->id;
  1658. $where['utype'] = $user->utype;
  1659. $pms = $this->pmsRepository->comPms($where);
  1660. $res = [
  1661. 'companyInfo' => $user,
  1662. 'pms' => $pms,
  1663. 'params' => $params,
  1664. ];
  1665. return $res;
  1666. }
  1667. public function pmsRead($id)
  1668. {
  1669. if (!$id) {
  1670. return response()->json(['status' => 0, 'msg' => '参数错误']);
  1671. }
  1672. return $this->pmsRepository->update(['new' => 2], $id);
  1673. }
  1674. public function msgSend($user, $input)
  1675. {
  1676. $data = [];
  1677. if (empty($input['parent_id'])) {
  1678. throw new ResponseException('数据异常!');
  1679. }
  1680. if (empty($input['to_uid'])) {
  1681. throw new ResponseException('个人信息不存在!');
  1682. }
  1683. if (empty($input['message'])) {
  1684. throw new ResponseException('回复信息不能为空!');
  1685. }
  1686. if (mb_strlen($input['message'], 'utf-8') > 200) {
  1687. throw new ResponseException('回复信息不能超过200个字。');
  1688. }
  1689. $data['parent_id'] = $input['parent_id'];
  1690. $data['utype'] = $user->utype;
  1691. $data['from_uid'] = $user->id;
  1692. $data['to_uid'] = $input['to_uid'];
  1693. $data['message'] = $input['message'];
  1694. $res = $this->msgRepository->msgSend($data);
  1695. $this->memberLogRepository->createLog($user, 1026, [$input['parent_id'], $input['to_uid'], $input['message']]);
  1696. if ($res) {
  1697. $member = MemberInfo::where(['uid' => $data['to_uid']])->select('realname')->first();
  1698. if ($member) {
  1699. $res->personName = $member->realname;
  1700. } else {
  1701. $res->personName = '';
  1702. }
  1703. }
  1704. return $res;
  1705. }
  1706. public function msgDelete($input)
  1707. {
  1708. if (empty($input['parent_id'])) {
  1709. throw new ResponseException('请选择要删除的咨询消息!');
  1710. }
  1711. return $this->msgRepository->msgDelete($input['parent_id']);
  1712. }
  1713. /**消息设为查看
  1714. * @param $request
  1715. * @return bool|\Illuminate\Http\JsonResponse
  1716. * @throws \Throwable
  1717. */
  1718. public function companyPmsCheck($request)
  1719. {
  1720. $user = auth('web-company')->user();
  1721. if ($request->method() == 'POST') {
  1722. return true;
  1723. }
  1724. $id = $request->id;
  1725. if (!$id) {
  1726. return response()->json(['status' => 0, 'msg' => '请选择查看的消息!']);
  1727. }
  1728. $ids = is_array($id) ? $id : explode(',', $id);
  1729. //设置消息为已读
  1730. $res = $this->msgCheck($ids, $user);
  1731. if ($res['state']) {
  1732. $html = view('app.company.ajax.ajax_show_msg', ['msg' => $res['data']])->render();
  1733. return response()->json(['status' => 1, 'msg' => '获取消息成功!', 'data' => $html]);
  1734. }
  1735. return response()->json(['status' => 0, 'msg' => $res['error']]);
  1736. }
  1737. public function companyPmsConsult($user)
  1738. {
  1739. $res = $this->msgRepository->msg($user->utype, $user->id);
  1740. if ($res->total()) {
  1741. foreach ($res as $key => $val) {
  1742. $utype = explode(',', $val->result);
  1743. foreach ($utype as $key1 => $val1) {
  1744. $utype1 = explode(':', $val1);
  1745. if ($utype1[0] == 1) {
  1746. $company = Company::where(['id' => $utype1[1]])->select('companyname')->first();
  1747. // $member = MemberInfo::where(['uid'=>$utype1[2]])->select('images')->first();
  1748. $member = MemberInfo::with(['resumes' => function ($query) {
  1749. $query->where('def', 1);
  1750. }])->where(['uid' => $utype1[2]])->select('images', 'uid')->first();
  1751. $res[$key]->result = str_replace($utype1[2], isset($member->resumes[0]->id) ? $member->resumes[0]->id : 0, $res[$key]->result);
  1752. if ($company) {
  1753. $res[$key]->companyName = $company->companyname;
  1754. } else {
  1755. $res[$key]->companyName = '';
  1756. }
  1757. if ($member) {
  1758. $res[$key]->images = $member->images;
  1759. $res[$key]->personName = isset($member->resumes[0]->fullname) ? $member->resumes[0]->fullname : 0;
  1760. } else {
  1761. $res[$key]->images = '';
  1762. }
  1763. break;
  1764. } else {
  1765. $company = Company::where(['id' => $utype1[2]])->select('companyname')->first();
  1766. // $member = MemberInfo::where(['uid'=>$utype1[1]])->select('images')->first();
  1767. $member = MemberInfo::with(['resumes' => function ($query) {
  1768. $query->where('def', 1);
  1769. }])->where(['uid' => $utype1[1]])->select('images', 'uid')->first();
  1770. $res[$key]->result = str_replace($utype1[1], isset($member->resumes[0]->id) ? $member->resumes[0]->id : 0, $res[$key]->result);
  1771. if ($company) {
  1772. $res[$key]->companyName = $company->companyname;
  1773. } else {
  1774. $res[$key]->companyName = '';
  1775. }
  1776. if ($member) {
  1777. $res[$key]->images = $member->images;
  1778. $res[$key]->personName = isset($member->resumes[0]->fullname) ? $member->resumes[0]->fullname : 0;
  1779. } else {
  1780. $res[$key]->images = '';
  1781. }
  1782. break;
  1783. }
  1784. }
  1785. }
  1786. }
  1787. return $res;
  1788. }
  1789. public function companyPmsDel($request, $user)
  1790. {
  1791. if (!$id = $request->id) {
  1792. return response()->json(['status' => 0, 'msg' => "请选择删除的消息!"]);
  1793. }
  1794. $ids = is_array($id) ? $id : explode(',', $id);
  1795. if (!$this->pmsRepository->deleteAll($ids, $user->id)) {
  1796. return response()->json(['status' => 0, 'msg' => "删除消息失败!"]);
  1797. }
  1798. if (!$this->memberLogRepository->createLog($user, 1025, $ids)) {
  1799. throw new \Exception("日志记录失败!");
  1800. }
  1801. return response()->json(['status' => 1, 'msg' => "删除消息成功!"]);
  1802. }
  1803. public function getContactInfo($id, $user)
  1804. {
  1805. if (!$id) {
  1806. return ['status' => 0, 'msg' => "请选择查看的联系信息!"];
  1807. }
  1808. $companyContact = CompanyContact::find($id);
  1809. if (!$companyContact) {
  1810. return ['status' => 0, 'msg' => "联系信息不存在"];
  1811. }
  1812. if ($companyContact->company_id != $user->id) {
  1813. return ['status' => 0, 'msg' => "联系信息不存在"];
  1814. }
  1815. $contact_info = $this->companyContactRepository->getContact(['id' => $id]);
  1816. if ($contact_info) {
  1817. $landline_tel_cn = explode('-', $contact_info->landline_tel);
  1818. $contact_info->landline_tel_one = array_get($landline_tel_cn, 0);
  1819. $contact_info->landline_tel_two = array_get($landline_tel_cn, 1);
  1820. $contact_info->landline_tel_three = array_get($landline_tel_cn, 2);
  1821. return ['status' => 1, 'contact' => $contact_info];
  1822. } else {
  1823. return ['status' => 0, 'msg' => "联系信息不存在"];
  1824. }
  1825. }
  1826. public function companyContactDel($ids, $user)
  1827. {
  1828. if (!$ids) {
  1829. return response()->json(['status' => 0, 'msg' => "请选择删除的联系信息!"]);
  1830. }
  1831. $companyContact = CompanyContact::whereIn('id', $ids)->get();
  1832. if (!$companyContact->toArray()) {
  1833. return ['status' => 0, 'msg' => "联系信息不存在"];
  1834. }
  1835. $id_M = array_column($companyContact->toArray(), 'company_id');
  1836. foreach ($id_M as $key => $val) {
  1837. if ($val != $user->id) {
  1838. return ['status' => 0, 'msg' => "联系信息不存在"];
  1839. }
  1840. }
  1841. if (!$this->companyContactRepository->deleteContact([], ['id' => $ids])) {
  1842. return response()->json(['status' => 0, 'msg' => "删除失败!"]);
  1843. }
  1844. return response()->json(['status' => 1, 'msg' => "删除成功!"]);
  1845. }
  1846. public function updateContact($data, $user)
  1847. {
  1848. $id = $data['id'];
  1849. $landline_tel = '';
  1850. $tel_first = array_get($data, 'tel_first', '-');
  1851. $tel_next = array_get($data, 'tel_next', '-');
  1852. $tel_last = array_get($data, 'tel_last', '-');
  1853. $landline_tel = implode('-', [$tel_first ? $tel_first : '', $tel_next ? $tel_next : '', $tel_last ? $tel_last : '']);
  1854. $update_data = array(
  1855. 'contact' => array_has($data, 'contact') ? $data['contact'] : '',
  1856. 'telephone' => array_has($data, 'telephone') ? $data['telephone'] : '',
  1857. 'landline_tel' => $landline_tel,
  1858. 'email' => array_has($data, 'email') ? $data['email'] : '',
  1859. 'qq' => array_has($data, 'qq') ? $data['qq'] : '',
  1860. 'address' => array_has($data, 'contact') ? $data['address'] : ''
  1861. );
  1862. return $this->companyContactRepository->ContactUpdate(['company_id' => $user->id, 'id' => $id], $update_data);
  1863. }
  1864. protected function msgCheck($ids, $user)
  1865. {
  1866. $msg = $this->pmsRepository->findMsg($ids);
  1867. $where['msgtouid'] = $user->id;
  1868. $where['utype'] = $user->utype;
  1869. $where['new'] = 1;
  1870. $data['new'] = 2;
  1871. if (false === $count = $this->pmsRepository->updateNew($ids, $where, $data)) {
  1872. return ['state' => 0, 'error' => '消息已删除或不存在'];
  1873. }
  1874. //写日志
  1875. return array('state' => 1, 'data' => $msg);
  1876. }
  1877. /**
  1878. * 检查字段惟一性
  1879. * @param $key
  1880. * @param $value
  1881. * @param $id
  1882. * @return mixed
  1883. */
  1884. public function checkUnique($key, $value, $id)
  1885. {
  1886. return $this->checkUnique($key, $value, $id);
  1887. }
  1888. /**
  1889. * 认证邮件发送成功回调
  1890. * @param $newEmail
  1891. * @param $company
  1892. */
  1893. public function sendAuthEmailHook($newEmail, $company)
  1894. {
  1895. Cache::put($newEmail, $company, 24 * 60);
  1896. }
  1897. /**
  1898. * 邮箱验证
  1899. * @param $newEmail
  1900. * @return bool
  1901. */
  1902. public function verifyEmail($newEmail)
  1903. {
  1904. $company = Cache::pull($newEmail, null);
  1905. if ($company) {
  1906. $this->companyRepository->changeEmail($company->id, $newEmail);
  1907. return true;
  1908. }
  1909. return false;
  1910. }
  1911. //更新短信数量
  1912. public function incSms($uid, $type, $num)
  1913. {
  1914. return $this->companyRepository->updataSmsNum($uid, $type, $num);
  1915. }
  1916. //最新招聘
  1917. public function getNewestCompanies($params)
  1918. {
  1919. $lists = Cache::get('newest_jobs_company_list_s' . get_subsite_id());
  1920. if ($lists === null) {
  1921. $lists = $this->getSeatmealCompanies($params);
  1922. Cache::put('newest_jobs_company_list_' . get_subsite_id(), $lists, '1800');
  1923. }
  1924. return $lists;
  1925. }
  1926. //知名企业(非免费会员、有发布中的职位的企业信息 处理企业logo、企业名称长度、企业数量限制 页面显示的职位数量限制、处理职位名称和路由)
  1927. public function getSeatmealCompanies($params)
  1928. {
  1929. $list = array();
  1930. //获取有正在发布职位的企业
  1931. $where = array();
  1932. $where = array(
  1933. array('valid', '=', 1),
  1934. array('display', '=', 1),
  1935. );
  1936. if (config('aix.companyset.comset.show_set.jobs_display') == 1) {
  1937. $where[] = array('audit', '=', 1);
  1938. } else {
  1939. $where[] = array('audit', '<>', 3);
  1940. }
  1941. if (array_has($params, 'seatmeal')) {
  1942. $where[] = array('setmeal_id', '>', $params['seatmeal']);
  1943. }
  1944. $where[] = array('deadline', '>', time());
  1945. $order_by = array('refresh_time' => 'desc');
  1946. $limit = '';
  1947. if (array_has($params, 'size')) {
  1948. $limit = $params['size'];
  1949. }
  1950. $rst = $this->jobsRepository->getJobCompanies($where, $order_by, $limit);
  1951. if ($rst) {
  1952. $com_rst = $rst->pluck('jobs_num', 'company_id');
  1953. $cid = $rst->pluck('company_id')->toArray();
  1954. //获取企业信息
  1955. $com_whereIn['id'] = $cid;
  1956. $companyInfo = $this->companyRepository->getCompanyies(array(), $com_whereIn, $order_by);
  1957. $cids = array();
  1958. $company = array();
  1959. if ($companyInfo->isNotEmpty()) {
  1960. foreach ($companyInfo as $key => $val) {
  1961. $company[$val->id] = $companyInfo[$key];
  1962. if ($val->logo) {
  1963. $company[$val->id]->logo = upload_asset($val->logo);
  1964. } else {
  1965. $company[$val->id]->logo = public_data_path('data/upload/no_logo.png');
  1966. }
  1967. $company[$val->id]->jobs_num = $com_rst[$val->id];
  1968. $company[$val->id]->company_url = route(url_rewrite('AIX_companyshow'), array('id' => $val->id));
  1969. $company[$val->id]->company_jobs_url = route(url_rewrite('AIX_companyjobs'), array('id' => $val->id));
  1970. $company[$val->id]->refreshtime_cn = daterange(time(), $val->refresh_time, 'm-d', "#FF3300");
  1971. $company[$val->id]->jobs_list = array();
  1972. if (array_has($params, 'companynamelen')) {
  1973. $dot = '...';
  1974. if (array_has($params, 'dot')) {
  1975. $dot = $params['dot'];
  1976. }
  1977. $company[$val->id]->companyname = cut_str($val->companyname, $params['companynamelen'], 0, $dot);
  1978. }
  1979. $cids[] = $val['id'];
  1980. }
  1981. if ($cids) {
  1982. //获取当前所选企业的所有职位信息
  1983. $job_where = array(
  1984. array('valid', '=', 1),
  1985. array('display', '=', 1),
  1986. array('deadline', '>', time())
  1987. );
  1988. if (config('aix.companyset.comset.show_set.jobs_display') == 1) {
  1989. $job_where[] = array('audit', '=', 1);
  1990. } else {
  1991. $job_where[] = array('audit', '<>', 3);
  1992. }
  1993. $job_where_in = array('company_id' => $cids);
  1994. $jobs = $this->jobsRepository->getCompanyJobs($job_where, $job_where_in, $order_by);
  1995. if ($jobs) {
  1996. foreach ($jobs as $k => $v) {
  1997. if (array_has($params, 'jobs_num')) {
  1998. if (count($company[$v->company_id]->jobs_list) >= $params['jobs_num']) {
  1999. continue;
  2000. }
  2001. }
  2002. //添加职位信息
  2003. $jobs_list = $company[$v->company_id]->jobs_list;
  2004. $jobs_list[] = $v;
  2005. $company[$v->company_id]->jobs_list = $jobs_list;
  2006. }
  2007. }
  2008. }
  2009. }
  2010. $list = $company;
  2011. }
  2012. return $list;
  2013. }
  2014. public function dealCompanyFields($list)
  2015. {
  2016. if ($list) {
  2017. $other_categories = $this->categoryRepository->getCategories();
  2018. $company_types = array();
  2019. $company_trades = array();
  2020. $company_scale = array();
  2021. if ($other_categories) {
  2022. $company_types = array_has($other_categories, 'AIX_company_type') ? $other_categories['AIX_company_type'] : array();
  2023. $company_trades = array_has($other_categories, 'AIX_trade') ? $other_categories['AIX_trade'] : array();
  2024. $company_scale = array_has($other_categories, 'AIX_scale') ? $other_categories['AIX_scale'] : array();
  2025. }
  2026. $jobs_display = config('aix.companyset.comset.show_set.jobs_display');
  2027. foreach ($list as $key => $val) {
  2028. $list[$key]->company_url = route(url_rewrite('AIX_companyshow'), array('id' => $val->id));
  2029. $list[$key]->contents = htmlspecialchars_decode($val->contents, ENT_QUOTES);
  2030. if ($val->logo) {
  2031. $list[$key]->logo = upload_asset($val->logo);
  2032. } else {
  2033. $list[$key]->logo = public_data_path('data/upload/no_logo.png');
  2034. }
  2035. $content = str_replace('&nbsp;', '', $val->contents);
  2036. $content = cut_str(strip_tags($content), 130, 0, '...');
  2037. $list[$key]->contents = $content;
  2038. $list[$key]->comjobs_url = route('jobs.company.jobs', array('id' => $val->id));
  2039. $list[$key]->nature_cn = '';
  2040. $list[$key]->trade_cn = '';
  2041. $list[$key]->scale_cn = '';
  2042. if ($company_types && array_has($company_types, $val->nature)) {
  2043. $list[$key]->nature_cn = $company_types[$val->nature]['demand'];
  2044. }
  2045. if ($company_trades && array_has($company_trades, $val->trade)) {
  2046. $list[$key]->trade_cn = $company_trades[$val->trade]['demand'];
  2047. }
  2048. if ($company_scale && array_has($company_scale, $val->scale)) {
  2049. $list[$key]->scale_cn = $company_scale[$val->scale]['demand'];
  2050. }
  2051. //在招职位数量
  2052. $job_count_map = array(array('company_id', '=', $val->id), array('valid', '=', 1));
  2053. if ($jobs_display == 1) {
  2054. $job_count_map[] = array('audit', '=', '1');
  2055. } else {
  2056. $job_count_map[] = array('audit', '<>', '3');
  2057. }
  2058. $jobs_count = $this->jobsRepository->getJobsCount($job_count_map);
  2059. $list[$key]->jobs_count = $jobs_count;
  2060. }
  2061. }
  2062. return $list;
  2063. }
  2064. //处理名企信息
  2065. public function dealSetmealCompany($companyInfo, $params)
  2066. {
  2067. $list = array();
  2068. $order_by = array('refresh_time' => 'desc');
  2069. $company = array();
  2070. $cids = [];
  2071. if (array_has($params, 'size')) {
  2072. $limit = $params['size'];
  2073. }
  2074. foreach ($companyInfo as $key => $val) {
  2075. if ($limit && count($company) >= $limit) {
  2076. break;
  2077. }
  2078. $company[$val->id] = $companyInfo[$key];
  2079. if ($val->logo) {
  2080. $company[$val->id]->logo = upload_asset($val->logo);
  2081. } else {
  2082. $company[$val->id]->logo = public_data_path('data/upload/no_logo.png');
  2083. }
  2084. if ($val->job->count() == 0) {
  2085. unset($company[$val->id]);
  2086. continue;
  2087. }
  2088. $company[$val->id]->jobs_num = $val->job->count();
  2089. $company[$val->id]->company_url = route(url_rewrite('AIX_companyshow'), array('id' => $val->id));
  2090. $company[$val->id]->company_jobs_url = route(url_rewrite('AIX_companyjobs'), array('id' => $val->id));
  2091. $company[$val->id]->refreshtime_cn = daterange(time(), $val->refresh_time, 'm-d', "#FF3300");
  2092. $company[$val->id]->jobs_list = array();
  2093. if (array_has($params, 'companynamelen')) {
  2094. $dot = '...';
  2095. if (array_has($params, 'dot')) {
  2096. $dot = $params['dot'];
  2097. }
  2098. $company[$val->id]->companyname = cut_str($val->companyname, $params['companynamelen'], 0, $dot);
  2099. }
  2100. $cids[] = $val['id'];
  2101. //$jobs = $val->job;
  2102. $job_count_map = array(array('valid', '=', 1), array('display', '=', 1));
  2103. if (config('aix.companyset.comset.show_set.jobs_display') == 1) {
  2104. $job_count_map[] = array('audit', '=', '1');
  2105. } else {
  2106. $job_count_map[] = array('audit', '<>', '3');
  2107. }
  2108. $jobs = $val->job()->where($job_count_map)->orderBy('refresh_time', 'desc')->get();
  2109. if ($jobs) {
  2110. $jobs_arr = $jobs->toArray();
  2111. $company[$val->id]->newst_job_refresh = $jobs_arr[0]['refresh_time'];
  2112. foreach ($jobs as $k => $v) {
  2113. if (array_has($params, 'jobs_num')) {
  2114. if (count($company[$v->company_id]->jobs_list) >= $params['jobs_num']) {
  2115. continue;
  2116. }
  2117. }
  2118. //添加职位信息
  2119. $jobs_list = $company[$v->company_id]->jobs_list;
  2120. $jobs_list[] = $v;
  2121. $company[$v->company_id]->jobs_list = $jobs_list;
  2122. }
  2123. }
  2124. }
  2125. if ($company) {
  2126. $list = $company;
  2127. }
  2128. return $list;
  2129. }
  2130. //获取企业基本信息
  2131. public function getCompany($where)
  2132. {
  2133. return $this->companyRepository->getCompanyInfo($where);
  2134. }
  2135. //获取企业联系人信息
  2136. public function companyContact($company, $page_num = '')
  2137. {
  2138. $where = array('company_id' => $company->id);
  2139. $rsts = $this->companyContactRepository->getList($where, $page_num);
  2140. return $rsts;
  2141. }
  2142. public function addContact($data)
  2143. {
  2144. return $this->companyContactRepository->create($data);
  2145. }
  2146. //发送短信回调事件
  2147. public function sendSMSCallBack($user_id)
  2148. {
  2149. //减少短信条数
  2150. $this->companyRepository->SetSmsReduce($user_id);
  2151. }
  2152. }