CompanyController.php 30 KB

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