CompanyController.php 31 KB

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