FindMemberIdController.php 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <?php
  2. namespace Themes\kbgolf\pro\app\Http\Controllers\Auth;
  3. use App\Http\Controllers\Controller;
  4. use App\Services\CallApiService;
  5. use Illuminate\Support\Facades\Validator;
  6. use App\Events\UserCreated;
  7. class FindMemberIdController extends Controller
  8. {
  9. private $callApiService;
  10. public function __construct(CallApiService $callApiService)
  11. {
  12. $this->callApiService = $callApiService;
  13. }
  14. public function index()
  15. {
  16. $smsCert = session('smsCert');
  17. if (empty($smsCert) || empty($smsCert['code'])) {
  18. notify()->error('잘못된 접근입니다', 'Error', 'bottomRight');
  19. return redirect()->route('find-member-id-verify.index');
  20. }
  21. if ($smsCert['code'] !== 201) {
  22. notify()->error('인증실패', 'Error', 'bottomRight');
  23. return redirect()->route('find-member-id-verify.index');
  24. }
  25. if (date('YmdHis') - $smsCert['date'] > 500) {
  26. session()->forget('smsCert');
  27. notify()->error('인증 시간이 만료되었습니다', 'Error', 'bottomRight');
  28. return redirect()->route('find-member-id-verify.index');
  29. }
  30. $mobileNo = formatPhone($smsCert['mobile_no']);
  31. $memberExtPage = $this->callApiService->callApi([
  32. 'url' => 'member-ext-page',
  33. 'data' => [
  34. 'PageVars' => [
  35. 'Query' => "mobile_no = '$mobileNo'",
  36. 'Desc' => 'Id',
  37. 'Limit' => 99999,
  38. 'Offset' => 0
  39. ]
  40. ]
  41. ]);
  42. if ($this->callApiService->verifyApiError($memberExtPage)) {
  43. notify()->error($memberExtPage['body'], 'Error', 'bottomRight');
  44. return redirect()->back();
  45. }
  46. $memExtIds = collect($memberExtPage['Page'])->pluck('Id')->implode(',');
  47. $memberPage = $this->callApiService->callApi([
  48. 'url' => 'member-page',
  49. 'data' => [
  50. 'PageVars' => [
  51. 'Query' => "id IN ($memExtIds)",
  52. 'Desc' => 'Id',
  53. 'Limit' => 99999,
  54. 'Offset' => 0
  55. ]
  56. ]
  57. ]);
  58. if ($this->callApiService->verifyApiError($memberPage)) {
  59. notify()->error($memberPage['body'], 'Error', 'bottomRight');
  60. return redirect()->back();
  61. }
  62. // dump($memberPage);
  63. return view('views.auth.find-member-id', compact('memberPage'))->with('codeTitle', [
  64. "status('member')",
  65. ]);
  66. }
  67. }