Syj.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. namespace App\Http\Controllers\Fpdx;
  3. use App\Http\Controllers\Controller;
  4. use App\Http\Controllers\Core\Auth;
  5. use App\Models\User\UserModel;
  6. use App\Models\Fpdx\SyjUserModel;
  7. class Syj extends Controller
  8. {
  9. /**
  10. * 检验是否是时遇记用户
  11. * @param string $phone
  12. * @return array
  13. * @throws \Tymon\JWTAuth\Exceptions\JWTException
  14. */
  15. public function sync(string $phone)
  16. {
  17. $uid = Auth::auth();
  18. $user = UserModel::find($uid);
  19. if ($user->phone != $phone) {
  20. return array(
  21. 'code' => 400,
  22. 'message' => "无权限"
  23. );
  24. } else {
  25. $syj = SyjUserModel::where('phone', $phone)->whereNull('bind')->first();
  26. if (collect($syj)->isEmpty()) {
  27. return array(
  28. 'code' => 202,
  29. 'message' => '无用户信息'
  30. );
  31. } else {
  32. $syj->bind = $uid;
  33. $syj->save();
  34. return array(
  35. 'code' => 200,
  36. 'message' => 'success',
  37. 'data' => $syj
  38. );
  39. }
  40. }
  41. }
  42. }