QrcodeController.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: ZhangHao
  5. * Date: 2019/7/24
  6. * Time: 16:21
  7. */
  8. namespace App\Http\Controllers\Api\Common;
  9. use App\Http\Controllers\Api\ApiBaseController;
  10. use Illuminate\Support\Facades\Cache;
  11. use App\Repositories\Jobfair\JobfairRepository;
  12. class QrcodeController extends ApiBaseController
  13. {
  14. /**
  15. * @var JobfairRepository
  16. */
  17. protected $jobfairRepository;
  18. /**
  19. * JobfairRepository constructor.
  20. * @param JobfairRepository $jobfairRepository
  21. */
  22. public function __construct(JobfairRepository $jobfairRepository)
  23. {
  24. $this->jobfairRepository = $jobfairRepository;
  25. }
  26. public function qrcode()
  27. {
  28. $hashid = request()->input('hashid');
  29. if(Cache::pull($hashid)){
  30. $res = hashid_decode($hashid);
  31. $where = [
  32. ['holddate_start', '<', strtotime("+60 minute")],
  33. ['holddate_end', '>', time()],
  34. ['display', '=', 1],
  35. ['subsite_id', '=', get_subsite_id()],
  36. ];
  37. $compant_where = [
  38. 'company_id' => $res['id']
  39. ];
  40. $jobfair = $this->jobfairRepository->getOneCompanyOpenJobfair($where,$compant_where);
  41. if($jobfair){
  42. $data = [
  43. 'status'=>1,
  44. 'jobfair_id'=>$jobfair->id
  45. ];
  46. return $this->sendSuccessResponse($data);
  47. }else{
  48. $data = [
  49. 'status'=>2,
  50. ];
  51. return $this->sendSuccessResponse($data);
  52. }
  53. } else {
  54. $data = [
  55. 'status'=>0,
  56. ];
  57. return $this->sendSuccessResponse($data);
  58. }
  59. }
  60. }