OrganziationService.php 80 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: michaelwu
  5. * Date: 2018/10/31
  6. * Time: 10:03
  7. */
  8. namespace App\Services\Organization;
  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 OrganizationService
  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 = 10)
  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. $list = array();
  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'] = url_rewrite('QS_companyjobs',array('id'=>$row['id']));
  1288. $row->comjobs_url = route('jobs.company.jobs', array('id'=>$row->id));
  1289. $row->contents=str_replace('&nbsp;', '', $row->contents);
  1290. $row->briefly=strip_tags($row->contents);
  1291. if ($row->logo) {
  1292. $row->logo=upload_asset($row->logo);
  1293. } else {
  1294. $row->logo=public_data_path('data/upload/no_logo.png');
  1295. }
  1296. $job_where_in = array('company_id'=>array($row->id));
  1297. $row->jobs = $this->jobsRepository->getCompanyJobs($job_where, $job_where_in, $order_by);
  1298. $list[] = $row;
  1299. }
  1300. }
  1301. return $list;
  1302. }
  1303. //获取其它公司
  1304. public function getOtherCompanies($where, $limit = 10)
  1305. {
  1306. $except_id = array_get($where, 'except_id');
  1307. if (array_has($where, 'except_id')) {
  1308. unset($where['except_id']);
  1309. }
  1310. if ($limit > 20) {
  1311. $limit = 20;
  1312. }
  1313. $order = 'real_refreshtime desc,id desc';
  1314. $field = '*,if(refresh_time>UNIX_TIMESTAMP(NOW()),(refresh_time-100000000),refresh_time) as real_refreshtime';
  1315. //处理trade
  1316. $map = array();
  1317. $trade = array_get($where, 'trade');
  1318. $trade_in = array();
  1319. if ($trade) {
  1320. if (strpos($trade, ',')) {
  1321. $arr = explode(',', $trade);
  1322. $sqlin = implode(',', array_slice($arr, 0, $limit));
  1323. if (preg_match('/^(\d{1,10},)*(\d{1,10})$/', $sqlin)===1) {
  1324. $trade_in = explode(',', $sqlin);
  1325. }
  1326. } else {
  1327. $map[] = array('trade', '=', intval($trade));
  1328. }
  1329. }
  1330. if ($except_id) {
  1331. $map[] = array('id', '<>', intval($except_id));
  1332. }
  1333. $map[] = array('subsite_id', '=', get_subsite_id());
  1334. $result = $this->companyRepository->getTradeCompanies($map, $trade_in, $field, $order, $limit);
  1335. $list = array();
  1336. if ($result->toArray()) {
  1337. foreach ($result as $key => $value) {
  1338. $row = $value;
  1339. $row->companyname_=$row->companyname;
  1340. $row->refreshtime_cn = $row->refresh_time>time()?daterange(time(), $row->real_refreshtime):daterange(time(), $row->refresh_time);
  1341. $row->url = route(url_rewrite('AIX_companyshow'), array('id'=>$row->id));
  1342. //$row['comjobs_url'] = url_rewrite('QS_companyjobs',array('id'=>$row['id']));
  1343. $row->comjobs_url = route('jobs.company.jobs', array('id'=>$row->id));
  1344. $row->contents=str_replace('&nbsp;', '', $row->contents);
  1345. $row->briefly=strip_tags($row->contents);
  1346. if ($row->logo) {
  1347. $row->logo=upload_asset($row->logo);
  1348. } else {
  1349. $row->logo=public_data_path('data/upload/no_logo.png');
  1350. }
  1351. $row->jobs_count = $this->getCompanyValidJobs($row->id);
  1352. $list[] = $row;
  1353. }
  1354. }
  1355. return $list;
  1356. }
  1357. //获取企业在招职位
  1358. public function getCompanyValidJobs($company_id)
  1359. {
  1360. $jobs_display = config('aix.companyset.comset.show_set.jobs_display');
  1361. $job_count_map = array(
  1362. array('company_id','=',$company_id),
  1363. array('valid','=',1)
  1364. );
  1365. if ($jobs_display == 1) {
  1366. $job_count_map[] = array('audit','=','1');
  1367. } else {
  1368. $job_count_map[] = array('audit','<>','3');
  1369. }
  1370. return $this->jobsRepository->getJobsCount($job_count_map);
  1371. }
  1372. //获取企业会员积分
  1373. public function getPoint($uid, $utype)
  1374. {
  1375. return $this->memberPointRepository->getPointsById($uid, $utype);
  1376. }
  1377. /**签到
  1378. * @return array
  1379. */
  1380. public function signIn($user)
  1381. {
  1382. $signCount = $this->taskLogRepository->getTaskLogCount($user->id, 18, $user->utype);
  1383. if ($signCount) {
  1384. return ['code'=>0,'msg'=>'您今天已经签到过了!', 'info'=>''];
  1385. } else {
  1386. $res = $this->taskService->doTask(18, $user->id, 1);
  1387. if ($res['code']==1) {
  1388. $this->memberLogRepository->createLog($user,8003,"");
  1389. return ['code'=>1,'msg'=>'签到成功', 'info'=>$res['data']['points']];
  1390. } else {
  1391. return ['code'=>1,'msg'=>$res['info'], 'info'=>''];
  1392. }
  1393. }
  1394. }
  1395. /**企业中心======我的消息(系统消息)
  1396. * @param $request
  1397. * @return array
  1398. */
  1399. public function comPms($data, $user)
  1400. {
  1401. $where = [];
  1402. $new= isset($data['new'])?$data['new']:'';
  1403. $settr= isset($data['settr'])?$data['settr']:'';
  1404. if ($new ) {
  1405. $where['new'] = $new;
  1406. }
  1407. if ($settr) {
  1408. $where[] = ['created_at', '<=',date('Y-m-d H:i:s', strtotime("{$settr} day"))];
  1409. }
  1410. $param_array = array('new','settr');
  1411. $params= array();
  1412. if ($data) {
  1413. foreach ($data as $k => $v) {
  1414. if (in_array($k, $param_array)) {
  1415. $params[$k] = $v;
  1416. }
  1417. }
  1418. }
  1419. $where['msgtouid'] = $user->id;
  1420. $where['utype'] = $user->utype;
  1421. $pms = $this->pmsRepository->comPms($where);
  1422. $res = [
  1423. 'companyInfo' => $user,
  1424. 'pms'=>$pms,
  1425. 'params'=>$params,
  1426. ];
  1427. return $res;
  1428. }
  1429. public function pmsRead($id)
  1430. {
  1431. if (!$id) {
  1432. return response()->json(['status'=>0,'msg'=>'参数错误']);
  1433. }
  1434. return $this->pmsRepository->update(['new'=>2], $id);
  1435. }
  1436. public function msgSend($user, $input)
  1437. {
  1438. $data = [];
  1439. if (empty($input['parent_id'])) {
  1440. throw new ResponseException('数据异常!');
  1441. }
  1442. if (empty($input['to_uid'])) {
  1443. throw new ResponseException('个人信息不存在!');
  1444. }
  1445. if (empty($input['message'])) {
  1446. throw new ResponseException('回复信息不能为空!');
  1447. }
  1448. if (mb_strlen($input['message'], 'utf-8')>200) {
  1449. throw new ResponseException('回复信息不能超过200个字。');
  1450. }
  1451. $data['parent_id'] = $input['parent_id'];
  1452. $data['utype'] = $user->utype;
  1453. $data['from_uid'] = $user->id;
  1454. $data['to_uid'] = $input['to_uid'];
  1455. $data['message'] = $input['message'];
  1456. $res = $this->msgRepository->msgSend($data);
  1457. $this->memberLogRepository->createLog($user,1026,[$input['parent_id'],$input['to_uid'],$input['message']]);
  1458. if ($res) {
  1459. $member = MemberInfo::where(['uid'=>$data['to_uid']])->select('realname')->first();
  1460. if ($member) {
  1461. $res->personName = $member->realname;
  1462. } else {
  1463. $res->personName = '';
  1464. }
  1465. }
  1466. return $res;
  1467. }
  1468. public function msgDelete($input)
  1469. {
  1470. if (empty($input['parent_id'])) {
  1471. throw new ResponseException('请选择要删除的咨询消息!');
  1472. }
  1473. return $this->msgRepository->msgDelete($input['parent_id']);
  1474. }
  1475. /**消息设为查看
  1476. * @param $request
  1477. * @return bool|\Illuminate\Http\JsonResponse
  1478. * @throws \Throwable
  1479. */
  1480. public function companyPmsCheck($request)
  1481. {
  1482. $user = auth('web-company')->user();
  1483. if ($request->method()== 'POST') {
  1484. return true;
  1485. }
  1486. $id = $request->id;
  1487. if (!$id) {
  1488. return response()->json(['status'=>0,'msg'=>'请选择查看的消息!']);
  1489. }
  1490. $ids = is_array($id)?$id:explode(',', $id);
  1491. //设置消息为已读
  1492. $res = $this->msgCheck($ids, $user);
  1493. if ($res['state']) {
  1494. $html = view('app.company.ajax.ajax_show_msg', ['msg'=>$res['data']])->render();
  1495. return response()->json(['status'=>1,'msg'=>'获取消息成功!','data'=>$html]);
  1496. }
  1497. return response()->json(['status'=>0,'msg'=>$res['error']]);
  1498. }
  1499. public function companyPmsConsult($user)
  1500. {
  1501. $res = $this->msgRepository->msg($user->utype, $user->id);
  1502. if ($res->total()) {
  1503. foreach ($res as $key => $val) {
  1504. $utype = explode(',', $val->result);
  1505. foreach ($utype as $key1 => $val1) {
  1506. $utype1 = explode(':', $val1);
  1507. if ($utype1[0]==1) {
  1508. $company = Company::where(['id'=>$utype1[1]])->select('companyname')->first();
  1509. // $member = MemberInfo::where(['uid'=>$utype1[2]])->select('images')->first();
  1510. $member = MemberInfo::with(['resumes'=>function ($query) {
  1511. $query->where('def', 1);
  1512. }])->where(['uid'=>$utype1[2]])->select('images', 'uid')->first();
  1513. $res[$key]->result = str_replace($utype1[2], isset($member->resumes[0]->id) ? $member->resumes[0]->id : 0, $res[$key]->result);
  1514. if ($company) {
  1515. $res[$key]->companyName = $company->companyname;
  1516. } else {
  1517. $res[$key]->companyName = '';
  1518. }
  1519. if ($member) {
  1520. $res[$key]->images = $member->images;
  1521. $res[$key]->personName = isset($member->resumes[0]->fullname) ? $member->resumes[0]->fullname : 0;
  1522. } else {
  1523. $res[$key]->images = '';
  1524. }
  1525. break;
  1526. } else {
  1527. $company = Company::where(['id'=>$utype1[2]])->select('companyname')->first();
  1528. // $member = MemberInfo::where(['uid'=>$utype1[1]])->select('images')->first();
  1529. $member = MemberInfo::with(['resumes'=>function ($query) {
  1530. $query->where('def', 1);
  1531. }])->where(['uid'=>$utype1[1]])->select('images', 'uid')->first();
  1532. $res[$key]->result = str_replace($utype1[1], isset($member->resumes[0]->id) ? $member->resumes[0]->id : 0, $res[$key]->result);
  1533. if ($company) {
  1534. $res[$key]->companyName = $company->companyname;
  1535. } else {
  1536. $res[$key]->companyName = '';
  1537. }
  1538. if ($member) {
  1539. $res[$key]->images = $member->images;
  1540. $res[$key]->personName = isset($member->resumes[0]->fullname) ? $member->resumes[0]->fullname : 0;
  1541. } else {
  1542. $res[$key]->images = '';
  1543. }
  1544. break;
  1545. }
  1546. }
  1547. }
  1548. }
  1549. return $res;
  1550. }
  1551. public function companyPmsDel($request,$user)
  1552. {
  1553. if (!$id = $request->id) {
  1554. return response()->json(['status'=>0, 'msg'=>"请选择删除的消息!"]);
  1555. }
  1556. $ids = is_array($id)?$id:explode(',', $id);
  1557. if (!$this->pmsRepository->deleteAll($ids,$user->id)) {
  1558. return response()->json(['status'=>0, 'msg'=>"删除消息失败!"]);
  1559. }
  1560. if(!$this->memberLogRepository->createLog($user,1025,$ids)){
  1561. throw new \Exception("日志记录失败!");
  1562. }
  1563. return response()->json(['status'=>1, 'msg'=>"删除消息成功!"]);
  1564. }
  1565. public function getContactInfo($id, $user)
  1566. {
  1567. if (!$id) {
  1568. return ['status'=>0, 'msg'=>"请选择查看的联系信息!"];
  1569. }
  1570. $companyContact = CompanyContact::find($id);
  1571. if(!$companyContact){
  1572. return ['status'=>0, 'msg'=>"联系信息不存在"];
  1573. }
  1574. if($companyContact->company_id != $user->id){
  1575. return ['status'=>0, 'msg'=>"联系信息不存在"];
  1576. }
  1577. $contact_info = $this->companyContactRepository->getContact(['id'=>$id]);
  1578. if ($contact_info) {
  1579. $landline_tel_cn = explode('-', $contact_info->landline_tel);
  1580. $contact_info->landline_tel_one = array_get($landline_tel_cn,0);
  1581. $contact_info->landline_tel_two = array_get($landline_tel_cn,1);
  1582. $contact_info->landline_tel_three = array_get($landline_tel_cn,2);
  1583. return ['status'=>1, 'contact'=>$contact_info];
  1584. } else {
  1585. return ['status'=>0, 'msg'=>"联系信息不存在"];
  1586. }
  1587. }
  1588. public function companyContactDel($ids, $user)
  1589. {
  1590. if (!$ids) {
  1591. return response()->json(['status'=>0, 'msg'=>"请选择删除的联系信息!"]);
  1592. }
  1593. $companyContact = CompanyContact::whereIn('id',$ids)->get();
  1594. if(!$companyContact->toArray()){
  1595. return ['status'=>0, 'msg'=>"联系信息不存在"];
  1596. }
  1597. $id_M = array_column($companyContact->toArray(),'company_id');
  1598. foreach ($id_M as $key =>$val){
  1599. if($val!=$user->id){
  1600. return ['status'=>0, 'msg'=>"联系信息不存在"];
  1601. }
  1602. }
  1603. if (!$this->companyContactRepository->deleteContact([], ['id'=>$ids])) {
  1604. return response()->json(['status'=>0, 'msg'=>"删除失败!"]);
  1605. }
  1606. return response()->json(['status'=>1, 'msg'=>"删除成功!"]);
  1607. }
  1608. public function updateContact($data,$user)
  1609. {
  1610. $id = $data['id'];
  1611. $landline_tel = '';
  1612. $tel_first = array_get($data, 'tel_first', '-');
  1613. $tel_next = array_get($data, 'tel_next', '-');
  1614. $tel_last = array_get($data, 'tel_last', '-');
  1615. $landline_tel = implode('-', [$tel_first?$tel_first:'',$tel_next?$tel_next:'',$tel_last?$tel_last:'']);
  1616. $update_data = array(
  1617. 'contact' => array_has($data, 'contact')?$data['contact']:'',
  1618. 'telephone' => array_has($data, 'telephone')?$data['telephone']:'',
  1619. 'landline_tel' => $landline_tel,
  1620. 'email' => array_has($data, 'email')?$data['email']:'',
  1621. 'qq' => array_has($data, 'qq')?$data['qq']:'',
  1622. 'address' => array_has($data, 'contact')?$data['address']:''
  1623. );
  1624. return $this->companyContactRepository->ContactUpdate(['company_id'=>$user->id,'id'=>$id],$update_data);
  1625. }
  1626. protected function msgCheck($ids, $user)
  1627. {
  1628. $msg = $this->pmsRepository->findMsg($ids);
  1629. $where['msgtouid'] = $user->id;
  1630. $where['utype'] = $user->utype;
  1631. $where['new'] = 1;
  1632. $data['new'] = 2;
  1633. if (false === $count = $this->pmsRepository->updateNew($ids, $where, $data)) {
  1634. return ['state'=>0,'error'=>'消息已删除或不存在'];
  1635. }
  1636. //写日志
  1637. return array('state'=>1,'data'=>$msg);
  1638. }
  1639. /**
  1640. * 检查字段惟一性
  1641. * @param $key
  1642. * @param $value
  1643. * @param $id
  1644. * @return mixed
  1645. */
  1646. public function checkUnique($key, $value, $id)
  1647. {
  1648. return $this->checkUnique($key, $value, $id);
  1649. }
  1650. /**
  1651. * 认证邮件发送成功回调
  1652. * @param $newEmail
  1653. * @param $org
  1654. */
  1655. public function sendAuthEmailHook($newEmail, $org)
  1656. {
  1657. Cache::put($newEmail, $org, 24*60);
  1658. }
  1659. /**
  1660. * 邮箱验证
  1661. * @param $newEmail
  1662. * @return bool
  1663. */
  1664. public function verifyEmail($newEmail)
  1665. {
  1666. $company=Cache::pull($newEmail, null);
  1667. if ($company) {
  1668. $this->companyRepository->changeEmail($company->id, $newEmail);
  1669. return true;
  1670. }
  1671. return false;
  1672. }
  1673. //更新短信数量
  1674. public function incSms($uid, $type, $num)
  1675. {
  1676. return $this->companyRepository->updataSmsNum($uid, $type, $num);
  1677. }
  1678. //最新招聘
  1679. public function getNewestCompanies($params)
  1680. {
  1681. $lists = Cache::get('newest_jobs_company_list_s'.get_subsite_id());
  1682. if ($lists === null) {
  1683. $lists = $this->getSeatmealCompanies($params);
  1684. Cache::put('newest_jobs_company_list_'.get_subsite_id(), $lists, '1800');
  1685. }
  1686. return $lists;
  1687. }
  1688. //知名企业(非免费会员、有发布中的职位的企业信息 处理企业logo、企业名称长度、企业数量限制 页面显示的职位数量限制、处理职位名称和路由)
  1689. public function getSeatmealCompanies($params)
  1690. {
  1691. $list = array();
  1692. //获取有正在发布职位的企业
  1693. $where = array();
  1694. $where = array(
  1695. array('valid', '=', 1),
  1696. array('display', '=', 1),
  1697. );
  1698. if (config('aix.companyset.comset.show_set.jobs_display')==1) {
  1699. $where[] = array('audit','=',1);
  1700. } else {
  1701. $where[] = array('audit','<>',3);
  1702. }
  1703. if (array_has($params, 'seatmeal')) {
  1704. $where[] = array('setmeal_id','>',$params['seatmeal']);
  1705. }
  1706. $where[] = array('deadline','>',time());
  1707. $order_by = array('refresh_time'=>'desc');
  1708. $limit = '';
  1709. if (array_has($params, 'size')) {
  1710. $limit = $params['size'];
  1711. }
  1712. $rst = $this->jobsRepository->getJobCompanies($where, $order_by, $limit);
  1713. if ($rst) {
  1714. $com_rst = $rst->pluck('jobs_num', 'company_id');
  1715. $cid = $rst->pluck('company_id')->toArray();
  1716. //获取企业信息
  1717. $com_whereIn['id'] = $cid;
  1718. $companyInfo = $this->companyRepository->getCompanyies(array(), $com_whereIn, $order_by);
  1719. $cids = array();
  1720. $company = array();
  1721. if ($companyInfo->isNotEmpty()) {
  1722. foreach ($companyInfo as $key => $val) {
  1723. $company[$val->id] = $companyInfo[$key];
  1724. if ($val->logo) {
  1725. $company[$val->id]->logo=upload_asset($val->logo);
  1726. } else {
  1727. $company[$val->id]->logo = public_data_path('data/upload/no_logo.png');
  1728. }
  1729. $company[$val->id]->jobs_num = $com_rst[$val->id];
  1730. $company[$val->id]->company_url=route(url_rewrite('AIX_companyshow'), array('id'=>$val->id));
  1731. $company[$val->id]->company_jobs_url=route(url_rewrite('AIX_companyjobs'), array('id'=>$val->id));
  1732. $company[$val->id]->refreshtime_cn=daterange(time(), $val->refresh_time, 'm-d', "#FF3300");
  1733. $company[$val->id]->jobs_list = array();
  1734. if (array_has($params, 'companynamelen')) {
  1735. $dot = '...';
  1736. if (array_has($params, 'dot')) {
  1737. $dot = $params['dot'];
  1738. }
  1739. $company[$val->id]->companyname = cut_str($val->companyname, $params['companynamelen'], 0, $dot);
  1740. }
  1741. $cids[] = $val['id'];
  1742. }
  1743. if ($cids) {
  1744. //获取当前所选企业的所有职位信息
  1745. $job_where = array(
  1746. array('valid', '=', 1),
  1747. array('display', '=', 1),
  1748. array('deadline','>',time())
  1749. );
  1750. if (config('aix.companyset.comset.show_set.jobs_display')==1) {
  1751. $job_where[] = array('audit','=',1);
  1752. } else {
  1753. $job_where[] = array('audit','<>',3);
  1754. }
  1755. $job_where_in = array('company_id'=>$cids);
  1756. $jobs = $this->jobsRepository->getCompanyJobs($job_where, $job_where_in, $order_by);
  1757. if ($jobs) {
  1758. foreach ($jobs as $k => $v) {
  1759. if (array_has($params, 'jobs_num')) {
  1760. if (count($company[$v->company_id]->jobs_list) >= $params['jobs_num']) {
  1761. continue;
  1762. }
  1763. }
  1764. //添加职位信息
  1765. $jobs_list = $company[$v->company_id]->jobs_list;
  1766. $jobs_list[] = $v;
  1767. $company[$v->company_id]->jobs_list = $jobs_list;
  1768. }
  1769. }
  1770. }
  1771. }
  1772. $list = $company;
  1773. }
  1774. return $list;
  1775. }
  1776. public function dealCompanyFields($list)
  1777. {
  1778. if ($list) {
  1779. $other_categories = $this->categoryRepository->getCategories();
  1780. $company_types = array();
  1781. $company_trades = array();
  1782. $company_scale = array();
  1783. if ($other_categories) {
  1784. $company_types = array_has($other_categories, 'AIX_company_type')?$other_categories['AIX_company_type']:array();
  1785. $company_trades = array_has($other_categories, 'AIX_trade')?$other_categories['AIX_trade']:array();
  1786. $company_scale = array_has($other_categories, 'AIX_scale')?$other_categories['AIX_scale']:array();
  1787. }
  1788. $jobs_display = config('aix.companyset.comset.show_set.jobs_display');
  1789. foreach ($list as $key => $val) {
  1790. $list[$key]->company_url = route(url_rewrite('AIX_companyshow'), array('id'=>$val->id));
  1791. $list[$key]->contents=htmlspecialchars_decode($val->contents, ENT_QUOTES);
  1792. if ($val->logo) {
  1793. $list[$key]->logo=upload_asset($val->logo);
  1794. } else {
  1795. $list[$key]->logo = public_data_path('data/upload/no_logo.png');
  1796. }
  1797. $content = str_replace('&nbsp;', '', $val->contents);
  1798. $content = cut_str(strip_tags($content), 130, 0, '...');
  1799. $list[$key]->contents = $content;
  1800. $list[$key]->comjobs_url = route('jobs.company.jobs', array('id'=>$val->id));
  1801. $list[$key]->nature_cn = '';
  1802. $list[$key]->trade_cn = '';
  1803. $list[$key]->scale_cn = '';
  1804. if ($company_types && array_has($company_types, $val->nature)) {
  1805. $list[$key]->nature_cn = $company_types[$val->nature]['demand'];
  1806. }
  1807. if ($company_trades && array_has($company_trades, $val->trade)) {
  1808. $list[$key]->trade_cn = $company_trades[$val->trade]['demand'];
  1809. }
  1810. if ($company_scale && array_has($company_scale, $val->scale)) {
  1811. $list[$key]->scale_cn = $company_scale[$val->scale]['demand'];
  1812. }
  1813. //在招职位数量
  1814. $job_count_map = array(array('company_id','=',$val->id),array('valid','=',1));
  1815. if ($jobs_display == 1) {
  1816. $job_count_map[] = array('audit','=','1');
  1817. } else {
  1818. $job_count_map[] = array('audit','<>','3');
  1819. }
  1820. $jobs_count = $this->jobsRepository->getJobsCount($job_count_map);
  1821. $list[$key]->jobs_count = $jobs_count;
  1822. }
  1823. }
  1824. return $list;
  1825. }
  1826. //处理名企信息
  1827. public function dealSetmealCompany($companyInfo, $params)
  1828. {
  1829. $list = array();
  1830. $order_by = array('refresh_time'=>'desc');
  1831. $company = array();
  1832. $cids = [];
  1833. if (array_has($params, 'size')) {
  1834. $limit = $params['size'];
  1835. }
  1836. foreach ($companyInfo as $key => $val) {
  1837. if ($limit && count($company)>=$limit) {
  1838. break;
  1839. }
  1840. $company[$val->id] = $companyInfo[$key];
  1841. if ($val->logo) {
  1842. $company[$val->id]->logo=upload_asset($val->logo);
  1843. } else {
  1844. $company[$val->id]->logo = public_data_path('data/upload/no_logo.png');
  1845. }
  1846. if ($val->job->count() == 0) {
  1847. unset($company[$val->id]);
  1848. continue;
  1849. }
  1850. $company[$val->id]->jobs_num = $val->job->count();
  1851. $company[$val->id]->company_url=route(url_rewrite('AIX_companyshow'), array('id'=>$val->id));
  1852. $company[$val->id]->company_jobs_url=route(url_rewrite('AIX_companyjobs'), array('id'=>$val->id));
  1853. $company[$val->id]->refreshtime_cn=daterange(time(), $val->refresh_time, 'm-d', "#FF3300");
  1854. $company[$val->id]->jobs_list = array();
  1855. if (array_has($params, 'companynamelen')) {
  1856. $dot = '...';
  1857. if (array_has($params, 'dot')) {
  1858. $dot = $params['dot'];
  1859. }
  1860. $company[$val->id]->companyname = cut_str($val->companyname, $params['companynamelen'], 0, $dot);
  1861. }
  1862. $cids[] = $val['id'];
  1863. //$jobs = $val->job;
  1864. $job_count_map = array(array('valid','=',1),array('display','=',1));
  1865. if (config('aix.companyset.comset.show_set.jobs_display')==1) {
  1866. $job_count_map[] = array('audit','=','1');
  1867. } else {
  1868. $job_count_map[] = array('audit','<>','3');
  1869. }
  1870. $jobs = $val->job()->where($job_count_map)->orderBy('refresh_time', 'desc')->get();
  1871. if ($jobs) {
  1872. $jobs_arr = $jobs->toArray();
  1873. $company[$val->id]->newst_job_refresh = $jobs_arr[0]['refresh_time'];
  1874. foreach ($jobs as $k => $v) {
  1875. if (array_has($params, 'jobs_num')) {
  1876. if (count($company[$v->company_id]->jobs_list) >= $params['jobs_num']) {
  1877. continue;
  1878. }
  1879. }
  1880. //添加职位信息
  1881. $jobs_list = $company[$v->company_id]->jobs_list;
  1882. $jobs_list[] = $v;
  1883. $company[$v->company_id]->jobs_list = $jobs_list;
  1884. }
  1885. }
  1886. }
  1887. if ($company) {
  1888. $list = $company;
  1889. }
  1890. return $list;
  1891. }
  1892. //获取企业基本信息
  1893. public function getCompany($where)
  1894. {
  1895. return $this->companyRepository->getCompanyInfo($where);
  1896. }
  1897. //获取企业联系人信息
  1898. public function companyContact($company, $page_num = '')
  1899. {
  1900. $where = array('company_id'=>$company->id);
  1901. $rsts = $this->companyContactRepository->getList($where, $page_num);
  1902. return $rsts;
  1903. }
  1904. public function addContact($data)
  1905. {
  1906. return $this->companyContactRepository->create($data);
  1907. }
  1908. //发送短信回调事件
  1909. public function sendSMSCallBack($user_id){
  1910. //减少短信条数
  1911. $this->companyRepository->SetSmsReduce($user_id);
  1912. }
  1913. /**
  1914. * 根据条件获取企业信息
  1915. */
  1916. public function getCompanies($where, $page = '', $limit = 20){
  1917. }
  1918. }