CompanyController.php 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: michaelwu
  5. * Date: 2018/10/31
  6. * Time: 10:02
  7. */
  8. namespace App\Http\Controllers\Jkq\Company;
  9. use Aix\Sms\Contracts\Smser;
  10. use App\Http\Controllers\Jkq\JkqBaseController;
  11. use App\Repositories\AuditReasonsRepository;
  12. use App\Repositories\MemberLogRepository;
  13. use App\Services\Common\EmailService;
  14. use App\Services\Common\SmsService;
  15. use App\Services\Common\TaskService;
  16. use App\Services\Company\CompanyConsultantService;
  17. use App\Services\Company\CompanyImgService;
  18. use App\Services\Company\CompanyService;
  19. use App\Services\Company\JobsService;
  20. use App\Services\Common\SearchService;
  21. use App\Services\Organization\OrganizationService;
  22. use App\Services\Organization\ServiceService;
  23. use App\Services\Company\DispensingService;
  24. use App\Validators\CompanyValidatorRequest;
  25. use Illuminate\Http\Request;
  26. use Illuminate\Support\Facades\Cache;
  27. class CompanyController extends JkqBaseController
  28. {
  29. protected $companyService;
  30. protected $companyImgService;
  31. protected $auditReasonsRepository;
  32. protected $emailService;
  33. protected $smsService;
  34. protected $jobsService;
  35. protected $taskService;
  36. protected $searchService;
  37. protected $recommend_limit;
  38. protected $recommend_need_limit;
  39. protected $companyConsultantService;
  40. protected $memberLogRepository;
  41. protected $organizationService;
  42. protected $serviceService;
  43. protected $dispensingService;
  44. /**
  45. * CompanyController constructor.
  46. * @param $companyService
  47. * @param $companyImgService
  48. * @param $auditReasonsRepository
  49. * @param $emailService
  50. * @param $smsService
  51. * @param $jobsService
  52. * @param $taskService
  53. * @param $searchService
  54. */
  55. public function __construct(MemberLogRepository $memberLogRepository,CompanyService $companyService, TaskService $taskService, JobsService $jobsService, SmsService $smsService, EmailService $emailService, CompanyImgService $companyImgService, AuditReasonsRepository $auditReasonsRepository, SearchService $searchService, CompanyConsultantService $companyConsultantService,OrganizationService $organizationService,ServiceService $serviceService, DispensingService $dispensingService)
  56. {
  57. $this->companyService = $companyService;
  58. $this->companyImgService= $companyImgService;
  59. $this->auditReasonsRepository = $auditReasonsRepository;
  60. $this->emailService = $emailService;
  61. $this->smsService = $smsService;
  62. $this->jobsService = $jobsService;
  63. $this->taskService = $taskService;
  64. $this->searchService = $searchService;
  65. $this->recommend_limit = 10;
  66. $this->recommend_need_limit = 50;
  67. $this->companyConsultantService = $companyConsultantService;
  68. $this->memberLogRepository=$memberLogRepository;
  69. $this->organizationService = $organizationService;
  70. $this->serviceService = $serviceService;
  71. $this->dispensingService = $dispensingService;
  72. }
  73. //会员中心
  74. public function index()
  75. {
  76. $user = auth('web-company')->user();
  77. $res = $this->companyService->index($user);
  78. $jobs_total = $this->jobsService->jobsTotal($user->id);
  79. if (Cache::has('recommend_click_resumes_'.get_subsite_id())) {
  80. Cache::forget('recommend_click_resumes_'.get_subsite_id());
  81. }
  82. //用于匹配简历的职位
  83. $recommend_rst = $this->getRecommendResumes($this->recommend_limit); //获取推荐简历
  84. $res['recommend_resumes'] = $recommend_rst['resumes'];
  85. $res['match_job'] = $recommend_rst['match_job'];
  86. $res['jobsCount'] = $jobs_total;
  87. $res['has_job'] = $recommend_rst['has_job'];
  88. $res['consultant'] = $this->companyConsultantService->getCompanyConsultant(auth('web-company')->user());
  89. return view('jkq.company.company_index', $res);
  90. }
  91. public function ajaxSms()
  92. {
  93. $res = $this->companyService->ajaxSms(auth('web-company')->user());
  94. if($res['id']){
  95. $html = view('jkq.company.ajax.ajax_sms',['info'=>$res['message']])->render();
  96. $res['message'] = $html;
  97. return response()->json($res);
  98. }
  99. return response()->json($res);
  100. }
  101. public function getRecommendResumes($limit = 10)
  102. {
  103. $need_limit = $this->recommend_need_limit;
  104. $list = array();
  105. $user = auth('web-company')->user();
  106. $has_job = 1;
  107. $recommend_order = $this->companyService->getRecommendorder($user);
  108. $recommend_where = $this->companyService->getRecommendWhere($user);
  109. if ($recommend_where) {
  110. //添加30天的时间限制
  111. $recommend_where['and'][] = ['updated_at','>=', date('Y-m-d H:i:s', strtotime(date("Y-m-d", strtotime("-30 day"))))];
  112. $recommend_resume_lists = $this->searchService->getRecommends($user, 'Resume', $recommend_where, $recommend_order, '', $limit);
  113. $rids = $recommend_resume_lists->pluck('id')->toArray();
  114. if ($recommend_resume_lists->total() >= $limit) {
  115. $list = array_slice($recommend_resume_lists->items(), 0, $limit);
  116. } else {
  117. //获取点击量高的简历
  118. $click_where = $this->companyService->getRecommendResumeWhere(array());
  119. $click_resumes = $this->searchService->search('Resume', $click_where, $recommend_order, '', $need_limit);
  120. $click_resumes = $click_resumes->items();
  121. Cache::forever('recommend_click_resumes_'.get_subsite_id(), $click_resumes);
  122. //去除已有简历
  123. if ($click_resumes && $rids) {
  124. foreach ($click_resumes as $k => $v) {
  125. if (in_array($v->id, $rids)) {
  126. unset($click_resumes[$k]);
  127. }
  128. }
  129. }
  130. $recommend_resumes = $recommend_resume_lists->items();
  131. $recommend_total = $recommend_resume_lists->total();
  132. $need_resumes = array_slice($click_resumes, 0, $need_limit - $recommend_total);
  133. $all_resumes = array_merge($recommend_resumes, $need_resumes);
  134. $list = array_slice($all_resumes, 0, $limit);
  135. }
  136. } else {
  137. //没有可匹配的职位
  138. $has_job = 0;
  139. }
  140. return array(
  141. 'resumes' => $list,
  142. 'match_job' => array(),
  143. 'has_job' => $has_job
  144. );
  145. }
  146. public function ajaxGetRecommendResumes(Request $request)
  147. {
  148. $limit = $this->recommend_limit;
  149. $need_limit = $this->recommend_need_limit;
  150. $page = $request->input('page');
  151. $has_job = 1;
  152. $user = auth('web-company')->user();
  153. $order_by = $this->companyService->getRecommendorder($user);
  154. $list = array();
  155. $recommend_where = $this->companyService->getRecommendWhere($user);
  156. if ($recommend_where) {
  157. $recommend_where['and'][] = ['updated_at','>=', date('Y-m-d H:i:s', strtotime(date("Y-m-d", strtotime("-30 day"))))];
  158. $recommend_resume_lists = $this->searchService->getRecommends($user, 'Resume', $recommend_where, $order_by, '', $need_limit, 1);
  159. $rids = $recommend_resume_lists->pluck('id')->toArray();
  160. $next_page = (int)$page + 1;
  161. if ($recommend_resume_lists->total() >= $next_page*$limit) {
  162. $list = array_slice($recommend_resume_lists->items(), $page*$limit, $limit);
  163. } else {
  164. $click_resumes = Cache::get('recommend_click_resumes_'.get_subsite_id());
  165. if ($click_resumes === null) {
  166. $click_resumes = $this->searchService->getClickResumes($order_by, array(), $need_limit);
  167. Cache::forever('recommend_click_resumes_'.get_subsite_id(), $click_resumes);
  168. }
  169. if ($click_resumes && $rids) {
  170. foreach ($click_resumes as $k => $v) {
  171. if (in_array($v->id, $rids)) {
  172. unset($click_resumes[$k]);
  173. }
  174. }
  175. }
  176. $recommend_resumes = $recommend_resume_lists->items();
  177. $recommend_total = $recommend_resume_lists->total();
  178. $need_resumes = array_slice($click_resumes, 0, $need_limit - $recommend_total);
  179. $all_resumes = array_merge($recommend_resumes, $need_resumes);
  180. $list = array_slice($all_resumes, $page*$limit, $limit);
  181. if (!$list) {
  182. $list = array_slice($all_resumes, 0, $limit);
  183. $next_page = 1;
  184. }
  185. }
  186. } else {
  187. $has_job = 0;
  188. }
  189. $match_job =0;
  190. $recommend_rst['resumes'] = $list;
  191. $recommend_rst['has_job'] = $has_job;
  192. $html = view('jkq.company.ajax.ajax_resume_list', $recommend_rst)->render();
  193. $return_data = array( 'status'=>1, 'html' => $html,'match_job'=>$match_job,'page'=>$next_page);
  194. return response()->json($return_data);
  195. }
  196. public function ajaxGetStatistics(Request $request)
  197. {
  198. $user = auth('web-company')->user();
  199. return $this->companyService->ajaxGetStatistics($request->all(), $user);
  200. }
  201. /**
  202. *企业会员中心首页一键刷新职位
  203. */
  204. public function jobsRefreshAll()
  205. {
  206. $user = auth('web-company')->user();
  207. return $this->jobsService->jobsRefreshAll($user);
  208. }
  209. /**企业信息
  210. * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
  211. * @throws \App\Exceptions\ResponseException
  212. */
  213. public function companyInfo()
  214. {
  215. $user = auth('web-company')->user();
  216. $companyInfo = $this->companyService->companyInfo($user);
  217. return view('jkq.company.company_info', $companyInfo);
  218. }
  219. /**
  220. * @param CompanyValidatorRequest $request
  221. * @return \Illuminate\Http\JsonResponse
  222. * @throws \Throwable
  223. */
  224. public function companySave(CompanyValidatorRequest $request)
  225. {
  226. $data = $request->except('_method', '_token');
  227. $res = $this->companyService->companySave($data, auth('web-company')->user());
  228. return response()->json($res);
  229. }
  230. /**修改企业手机==企业中心
  231. * @param Request $request
  232. * @return \Illuminate\Http\JsonResponse
  233. * @throws \Throwable
  234. */
  235. public function modifyMobile(Request $request)
  236. {
  237. $user = auth('web-company')->user();
  238. if ($request->method() == 'GET') {
  239. $mobile = $this->companyService->authMobile($user);
  240. return response()->json(['status'=>1,'data'=>view('jkq.company.ajax.ajax_auth_mobile', $mobile)->render()]);
  241. }
  242. return $this->companyService->verifyCode($request->mobile, $user);
  243. }
  244. /**
  245. * @保存企业logo
  246. * @param Request $request
  247. * @return \Illuminate\Http\JsonResponse
  248. * @throws \Prettus\Validator\Exceptions\ValidatorException
  249. */
  250. public function attach(Request $request)
  251. {
  252. $user = auth('web-company')->user();
  253. return $this->companyService->saveLogo($request->all(), $user);
  254. }
  255. /**删除企业Logo
  256. * @param Request $request
  257. * @return \Illuminate\Http\JsonResponse
  258. * @throws \Prettus\Validator\Exceptions\ValidatorException
  259. */
  260. public function logoDel()
  261. {
  262. $user = auth('web-company')->user();
  263. return $this->companyService->logoDel($user);
  264. }
  265. /**企业风采
  266. * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
  267. */
  268. public function companyImg()
  269. {
  270. $user = auth('web-company')->user();
  271. $res = $this->companyImgService->list($user->id);
  272. return view('jkq.company.company_img', ['imgList'=>$res]);
  273. }
  274. /**
  275. * 保存企业风采
  276. * @param Request $request
  277. * @return mixed
  278. * @throws \Prettus\Validator\Exceptions\ValidatorException
  279. */
  280. public function saveImg(Request $request)
  281. {
  282. $user = auth('web-company')->user();
  283. return $this->companyImgService->saveImg($request->image, $user);
  284. }
  285. /**
  286. * 修改备注模态框
  287. * @param Request $request
  288. * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
  289. * @throws \Throwable
  290. */
  291. public function remark(Request $request)
  292. {
  293. $res = $this->companyImgService->companyImg($request->id);
  294. return $res;
  295. }
  296. /**
  297. * 保存备注
  298. * @param CompanyValidatorRequest $request
  299. * @return \Illuminate\Http\JsonResponse
  300. */
  301. public function saveRemark(CompanyValidatorRequest $request)
  302. {
  303. $user = auth('web-company')->user();
  304. return $this->companyImgService->saveRemark($request,$user);
  305. }
  306. /**
  307. * 删除企业风采
  308. * @param $id
  309. * @param Request $request
  310. * @return \Illuminate\Contracts\View\Factory|\Illuminate\Http\JsonResponse|\Illuminate\View\View
  311. */
  312. public function delImg($id, Request $request)
  313. {
  314. if ($request->type) {
  315. $user = auth('web-company')->user();
  316. return $this->companyImgService->delImg($id,$user);
  317. }
  318. $tip='被删除后将无法恢复,您确定要删除该风采照片吗?';
  319. return view('jkq.company.ajax.ajax_warning', ['tip'=>$tip]);
  320. }
  321. /**
  322. * 企业认证
  323. * @param $anew
  324. * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
  325. * @throws \App\Exceptions\ResponseException
  326. */
  327. public function companyAuth($anew = '')
  328. {
  329. $user = auth('web-company')->user();
  330. $companyInfo = $this->companyService->getInfoById($user);
  331. $companyInfo->reason = $this->auditReasonsRepository->getAuditReasons(auth('web-company')->user()->id, 8);
  332. if ($anew=='anew') {
  333. $companyInfo->audit = 0;
  334. }
  335. return view('jkq.company.company_auth', ['companyInfo'=>$companyInfo, 'anew'=>$anew]);
  336. }
  337. public function certificate(Request $request)
  338. {
  339. $user = auth('web-company')->user();
  340. return $this->companyService->certificate($request->certificate_img_up, $user);
  341. }
  342. /**
  343. * 账户安全
  344. * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
  345. * @throws \App\Exceptions\ResponseException
  346. */
  347. public function companySecurity()
  348. {
  349. $user = auth('web-company')->user();
  350. $companyInfo = $this->companyService->companySecurity($user);
  351. return view('jkq.company.company_security', $companyInfo);
  352. }
  353. /**企业登录日志
  354. * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
  355. * @throws \App\Exceptions\ResponseException
  356. */
  357. public function loginLog()
  358. {
  359. $user = auth('web-company')->user();
  360. $loginLog = $this->companyService->companyLoginLog($user);
  361. $companyInfo = $user;
  362. $companyInfo['loginLog'] = $loginLog;
  363. return view('jkq.company.login_log', ['companyInfo'=>$companyInfo]);
  364. }
  365. /**我的消息
  366. * @param $request
  367. * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
  368. */
  369. public function companyPms(Request $request)
  370. {
  371. $user = auth('web-company')->user();
  372. $data = $request->all();
  373. $res = $this->companyService->comPms($data, $user);
  374. return view('jkq.company.company_pms', $res);
  375. }
  376. public function pmsRead(Request $request)
  377. {
  378. $id = $request->id;
  379. return $this->companyService->pmsRead($id);
  380. }
  381. public function msgSend()
  382. {
  383. $res = $this->companyService->msgSend(auth('web-company')->user(), request()->all());
  384. if ($res) {
  385. $this->taskService->doTask(32);
  386. return $this->sendSuccessResponse($res);
  387. } else {
  388. return $this->sendErrorResponse('回复失败!');
  389. }
  390. }
  391. public function msgDelete()
  392. {
  393. if (request()->method()=='POST') {
  394. $res = $this->companyService->msgDelete(request()->all());
  395. if ($res) {
  396. return $this->sendSuccessResponse('删除成功!');
  397. } else {
  398. return $this->sendErrorResponse('删除失败!');
  399. }
  400. } else {
  401. return view('jkq.person.ajax.resume_delete', ['tpis'=>'删除后将无法恢复,您确定要删除选择的咨询消息吗?']);
  402. }
  403. }
  404. public function companyPmsDel(Request $request)
  405. {
  406. if ($request->method()== 'POST') {
  407. $user = auth('web-company')->user();
  408. return $this->companyService->companyPmsDel($request,$user);
  409. }
  410. $tip = "被删除后将无法恢复,您确定要删除选中的系统消息吗?";
  411. return response()->json(['status'=>1,'data'=>['html'=>view('jkq.company.ajax.ajax_warning', ['tip'=>$tip])->render()]]);
  412. }
  413. public function companyPmsCheck(Request $request)
  414. {
  415. return $this->companyService->companyPmsCheck($request);
  416. }
  417. /**
  418. *
  419. */
  420. public function companyPmsConsult()
  421. {
  422. $res = $this->companyService->companyPmsConsult(auth('web-company')->user());
  423. return view('jkq.company.company_pmsconsult', ['content'=>$res]);
  424. }
  425. /**
  426. * 修改用户名
  427. * */
  428. public function modifyUsername()
  429. {
  430. $user = auth('web-company')->user();
  431. $res = $this->companyService->modifyUserName($user);
  432. return view('jkq.company.ajax.username', $res);
  433. }
  434. /** 修改用户名
  435. * @param CompanyValidatorRequest $request
  436. * @return CompanyController|\Illuminate\Http\JsonResponse
  437. * @throws \Prettus\Validator\Exceptions\ValidatorException
  438. */
  439. public function saveUsername(CompanyValidatorRequest $request)
  440. {
  441. $user = auth('web-company')->user();
  442. if (!$this->companyService->saveUsername($request->username, $user)) {
  443. return $this->sendErrorResponse('用户名修改失败!');
  444. }
  445. return $this->sendSuccessResponse('用户名修改成功!');
  446. }
  447. /**修改密码
  448. * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
  449. */
  450. public function modifyPwd()
  451. {
  452. return view('jkq.company.ajax.ajax_modify_pwd');
  453. }
  454. /**修改密码======保存密码
  455. * @param CompanyValidatorRequest $request
  456. * @return CompanyController|\Illuminate\Http\JsonResponse
  457. * @throws \App\Exceptions\ResponseException
  458. * @throws \Prettus\Validator\Exceptions\ValidatorException
  459. */
  460. public function savePwd(CompanyValidatorRequest $request)
  461. {
  462. $user = auth('web-company')->user();
  463. if (!$this->companyService->savePwd($user, $request->oldpassword, $request->password, $request->password1)) {
  464. return $this->sendErrorResponse('密码修改失败!');
  465. }
  466. if ($user->mobile) {
  467. $this->smsService->sendSms($user->mobile, Smser::TEMPLATE_SMS_EDITPWD, ['sitename'=>subsite_config('aix.system.site.site.site_name'),'newpassword'=>$request->password]);
  468. }
  469. return $this->sendSuccessResponse('密码修改成功!');
  470. }
  471. /**
  472. * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
  473. * @手机认证弹窗
  474. */
  475. public function authMobile()
  476. {
  477. $user = auth('web-company')->user();
  478. $mobile = $this->companyService->authMobile($user);
  479. return view('jkq.company.ajax.ajax_auth_mobile', $mobile);
  480. }
  481. /**
  482. * @param CompanyValidatorRequest $request
  483. * @return \Illuminate\Http\JsonResponse
  484. * @throws \App\Exceptions\ResponseException
  485. */
  486. public function verifyCode(CompanyValidatorRequest $request)
  487. {
  488. $mobile = $request->mobile;
  489. $id = $request->id;
  490. if (!$this->companyService->checkMobileAudit($id, $mobile)->isEmpty()) {
  491. return response()->json(['status'=>0, 'msg'=>'手机已验证']);
  492. }
  493. $this->smsService->sendAuthSms($mobile, smser::TEMPLATE_AUTH_CHECK);
  494. return response()->json(['status'=>1]);
  495. }
  496. public function mobileAudit(CompanyValidatorRequest $request)
  497. {
  498. $user = auth('web-company')->user();
  499. $mobile = $request->mobile;
  500. $verifyCode = $request->verifycode;
  501. $res = $this->smsService->checkAuthSms($mobile, smser::TEMPLATE_AUTH_CHECK, $verifyCode);
  502. if (!$res) {
  503. return response()->json(['status'=>0,'msg'=>'验证码错误']);
  504. }
  505. $res = $this->companyService->verifyCode($mobile, $user);
  506. if ($res['status']==1) {
  507. $this->memberLogRepository->createLog($user,8002,"");
  508. if (isset($res['data'])) {
  509. return response()->json(['status'=>1,'msg'=>'手机认证成功','data'=>['mobile'=>$mobile, 'points'=>$res['data']['points']]]);
  510. } else {
  511. return response()->json(['status'=>1,'msg'=>'手机认证成功','data'=>['mobile'=>$mobile]]);
  512. }
  513. } else {
  514. return response()->json(['status'=>0,'msg'=>'手机认证失败']);
  515. }
  516. }
  517. /**邮箱认证
  518. * @return \Illuminate\Http\JsonResponse
  519. * @throws \Throwable
  520. */
  521. public function authEmail()
  522. {
  523. $user = auth('web-company')->user();
  524. if (!$email = $this->companyService->authEmail($user)) {
  525. return response()->json(['status'=>0,'msg'=>'参数错误!']);
  526. }
  527. return response()->json(['status'=>1,'msg'=>'查询成功!','data'=>view('jkq.company.ajax.ajax_auth_email', $email)->render()]);
  528. }
  529. /**认证Email 及修改状态
  530. * @param CompanyValidatorRequest $request
  531. * @return \Illuminate\Http\JsonResponse
  532. */
  533. public function emailSend(CompanyValidatorRequest $request)
  534. {
  535. $email = $request->email;
  536. $id = $request->id;
  537. if (!$this->companyService->checkEmailAudit($id, $email)->isEmpty()) {
  538. return response()->json(['status'=>0, 'msg'=>'email已验证!']);
  539. }
  540. $user = auth('web-company')->user();
  541. $this->memberLogRepository->createLog($user,8001,"");
  542. $this->emailService->setAuthTag('company')
  543. ->setCallback('App\Services\Company\CompanyService', 'sendAuthEmailHook', [$email, auth('web-company')->user()])
  544. ->sendAuthMail($email, EmailService::TEMPLATE_VALIDATION);
  545. return response()->json(['status'=>1]);
  546. }
  547. /**签到
  548. * @return \Illuminate\Http\JsonResponse
  549. */
  550. public function sign()
  551. {
  552. $user = auth('web-company')->user();
  553. $res = $this->companyService->signIn($user);
  554. return response()->json(['status'=>$res['code'],'msg'=>$res['msg'],'data'=>$res['info']]);
  555. }
  556. public function ajaxResumeSearch(Request $request)
  557. {
  558. $key = $request->input('key', '');
  559. $search_type = $request->input('search_type', 'precise');
  560. return response()->json(['status'=>1,'data'=>route(url_rewrite('AIX_resumelist'), ['key'=>$key, 'search_type'=>$search_type])]);
  561. }
  562. public function unBindThird(Request $request)
  563. {
  564. $alias = $request->alias;
  565. $user = auth('web-company')->user();
  566. return $this->companyService->unBindThird($alias, $user);
  567. }
  568. //企业联系人信息
  569. public function contact(Request $request)
  570. {
  571. $user = auth('web-company')->user();
  572. $contacts = $this->companyService->companyContact($user, 10);
  573. $return_data = array(
  574. 'contacts' => $contacts
  575. );
  576. return view('jkq.company.company_contact', $return_data);
  577. }
  578. //企业联系人信息ajax请求
  579. public function ContactAjax(){
  580. $user = auth('web-company')->user();
  581. $contacts = $this->companyService->companyContact($user, 10);
  582. return response()->json($contacts);
  583. }
  584. public function showContact(Request $request)
  585. {
  586. $id = $request->input('id');
  587. $rst = $this->companyService->getContactInfo($id, auth('web-company')->user());
  588. if (array_has($rst, 'status') && $rst['status'] == 1) {
  589. $contact = $rst['contact'];
  590. $landline_tel = dealContactPhone($contact->landline_tel);
  591. $html = view('jkq.company.ajax.show_contact', ['contact'=>$contact, 'landline_tel'=>$landline_tel])->render();
  592. $return_data = array( 'status'=>1, 'data' => $html);
  593. return response()->json($return_data);
  594. } else {
  595. return response()->json($rst);
  596. }
  597. }
  598. public function deleteContact(Request $request)
  599. {
  600. $id = $request->input('id');
  601. $ids = is_array($id)?$id:explode(",", $id);
  602. return $this->companyService->companyContactDel($ids, auth('web-company')->user());
  603. }
  604. public function editContact(Request $request)
  605. {
  606. if ($request->method() == 'POST') {
  607. $user = auth('web-company')->user();
  608. $id = $request->input('id');
  609. $data = $request->except('_token', '_method');
  610. $rst = $this->companyService->updateContact($data,$user);
  611. if ($rst) {
  612. $return_data = array('status'=>1, 'msg'=>'修改成功');
  613. } else {
  614. $return_data = array('status'=>0, 'msg'=>'修改失败');
  615. }
  616. return response()->json($return_data);
  617. } else {
  618. $id = $request->input('id');
  619. $rst = $this->companyService->getContactInfo($id, auth('web-company')->user());
  620. if (array_has($rst, 'status') == 1) {
  621. $return_data = ['contact' => $rst['contact']];
  622. $html = view('jkq.company.ajax.add_contact', $return_data)->render();
  623. $return_data = array( 'status'=>1, 'data' => $html);
  624. return response()->json($return_data);
  625. } else {
  626. return $rst;
  627. }
  628. }
  629. }
  630. public function addContact(Request $request)
  631. {
  632. if ($request->method() == 'POST') {
  633. $contact = $request->input('contact', '');
  634. $telephone = $request->input('telephone', '');
  635. $tel_first = $request->input('tel_first', '');
  636. $tel_next = $request->input('tel_next', '');
  637. $tel_last = $request->input('tel_last', '');
  638. $email = $request->input('email', '');
  639. $qq = $request->input('qq', '');
  640. $address = $request->input('address', '');
  641. if (!$contact) {
  642. $return_data = array( 'status'=>0, 'msg' => '请输入联系人信息');
  643. }
  644. //座机和手机号至少填写一项
  645. if (!$email) {
  646. $return_data = array( 'status'=>0, 'msg' => '请输入联系邮箱');
  647. }
  648. if (!$address) {
  649. $return_data = array( 'status'=>0, 'msg' => '请输入联系地址');
  650. }
  651. if (!empty($tel_first) && !empty($tel_next)){
  652. $landline_tel=$tel_first."-".$tel_next;
  653. if (!empty($tel_last)){ $landline_tel.="-".$tel_last; }
  654. }else{
  655. $landline_tel="";
  656. }
  657. $set_data = array(
  658. 'company_id' => (int)auth('web-company')->user()->id,
  659. 'contact' => $contact,
  660. 'telephone' => $telephone,
  661. 'landline_tel' => $landline_tel,
  662. 'email' => $email,
  663. 'qq' => $qq,
  664. 'address' => $address
  665. );
  666. $rst = $this->companyService->addContact($set_data);
  667. if ($rst) {
  668. $return_data = array('status'=>1, 'msg'=>'添加成功');
  669. } else {
  670. $return_data = array('status'=>0, 'msg'=>'添加失败');
  671. }
  672. return response()->json($return_data);
  673. } else {
  674. $return_data = ['contact'=>''];
  675. $html = view('jkq.company.ajax.add_contact', $return_data)->render();
  676. $return_data = array( 'status'=>1, 'data' => $html);
  677. return response()->json($return_data);
  678. }
  679. }
  680. public function myCode(Request $requset)
  681. {
  682. $id = $requset->id?$requset->id:0;
  683. $user = $this->getLoginUser();
  684. if ($user->id!=$id) {
  685. return response()->json(['status'=>0,'img'=>'企业不存在!']);
  686. }
  687. return response()->json(['status'=>1,'img'=>get_qrcode_html(route('mobile.firm.com.wzp.index',['id'=>$id]))]);
  688. }
  689. //服务广场
  690. public function square()
  691. {
  692. return view('jkq.company.company_square');
  693. }
  694. public function share()
  695. {
  696. $service_list = $this->serviceService->list();
  697. return view('jkq.company.company_share',['service_list'=>$service_list]);
  698. }
  699. public function dispensing()
  700. {
  701. return view('jkq.company.company_dispensing');
  702. }
  703. public function dispensingList()
  704. {
  705. $user = auth('web-company')->user();
  706. $dispensingList = $this->dispensingService->list($user);
  707. return view('jkq.company.company_dispensingList',['dispensing'=>$dispensingList]);
  708. }
  709. public function dispensingAdd(Request $request)
  710. {
  711. $data = $request->except('_method', '_token');
  712. return $this->dispensingService->save($data,auth('web-company')->user());
  713. }
  714. public function dispensingEdit(Request $request)
  715. {
  716. if(request()->method()=='POST'){
  717. $data = $request->except('_method', '_token');
  718. return $this->dispensingService->save($data,auth('web-company')->user());
  719. }else{
  720. $id = $request->input('id');
  721. $user = auth('web-company')->user();
  722. $where['id'] = $id;
  723. $where['uid'] = $user->id;
  724. $dispensingInfo = $this->dispensingService->dispensingInfo($where);
  725. if(!$dispensingInfo){
  726. return $this->showMessage('没有这个需求!', route('jkq.com.dispensingList'), true);
  727. }
  728. return view('jkq.company.company_dispensingEdit',['dispensing'=>$dispensingInfo]);
  729. }
  730. }
  731. public function dispensingDel(Request $request)
  732. {
  733. $id = $request->id;
  734. $user = auth('web-company')->user();
  735. return $this->dispensingService->dispensingDel($id, $user);
  736. }
  737. }