QYInfoController.php 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. <?php
  2. namespace App\Http\Controllers\QYInfo;
  3. use App\Http\Controllers\Controller;
  4. use App\Models\QYCrownAuth;
  5. use App\Models\QYCrownDocumet;
  6. use App\Models\QYDocumet;
  7. use Illuminate\Http\Request;
  8. use Illuminate\Support\Facades\Auth;
  9. use Illuminate\Support\Facades\DB;
  10. use Carbon\Carbon;
  11. class QYInfoController extends Controller {
  12. /*
  13. * 校验是够认证
  14. * ***/
  15. public function CheckAuth(){
  16. $id=Auth::user()->id;
  17. return $this->success([]);
  18. $mobile=Auth::user()->mobile;
  19. if ($mobile==15286818088 || $mobile==15236877164 || $mobile==18638295271){
  20. $re=QYCrownAuth::where('status',1)->where('user_id',$id)->first();
  21. if (!$re){
  22. return $this->error(50021);
  23. }
  24. return $this->success([]);
  25. }else{
  26. return $this->success([]);
  27. }
  28. $re=QYCrownAuth::where('status',1)->where('user_id',$id)->first();
  29. if (!$re){
  30. return $this->error(50021);
  31. }
  32. return $this->success([]);
  33. }
  34. /*
  35. * 认证
  36. * **/
  37. public function Auth(){
  38. return $this->success(['url'=>'api.app.cliu.cc/api/gzh']);
  39. $id=Auth::user()->id;
  40. $re=QYCrownAuth::where('user_id',$id)->first();
  41. if (!$re){
  42. $result=$this->person(Auth::user()->mobile);
  43. $qyinfo=new QYCrownAuth();
  44. $qyinfo->user_id=$id;
  45. $qyinfo->authId=$result['result']['authId'];
  46. $qyinfo->authUrl=$result['result']['authUrl'];
  47. $qyinfo->mobile=Auth::user()->mobile;
  48. $qyinfo->time_out=Carbon::now()->addMinutes(5);
  49. $qyinfo->save();
  50. return $this->success(['url'=>$qyinfo->authUrl]);
  51. }else{
  52. if ($re->status==2){
  53. $result=$this->person(Auth::user()->mobile);
  54. $qyinfo=QYCrownAuth::where('user_id',$id)->first();
  55. $qyinfo->authId=$result['result']['authId'];
  56. $qyinfo->authUrl=$result['result']['authUrl'];
  57. $qyinfo->mobile=Auth::user()->mobile;
  58. $qyinfo->time_out=Carbon::now()->addMinutes(5);
  59. $qyinfo->save();
  60. return $this->success(['url'=>$qyinfo->authUrl]);
  61. }else{
  62. if ($re->time_out<Carbon::now()){
  63. $result=$this->person(Auth::user()->mobile);
  64. $qyinfo=QYCrownAuth::where('user_id',$id)->first();
  65. $qyinfo->authId=$result['result']['authId'];
  66. $qyinfo->authUrl=$result['result']['authUrl'];
  67. $qyinfo->mobile=Auth::user()->mobile;
  68. $qyinfo->time_out=Carbon::now()->addMinutes(5);
  69. $qyinfo->save();
  70. return $this->success(['url'=>$qyinfo->authUrl]);
  71. }else{
  72. return $this->success(['url'=>$re->authUrl]);
  73. }
  74. }
  75. }
  76. }
  77. public function person($phone){
  78. $sdkClient = \Util::getSDk();
  79. // 待认证的用户信息
  80. $user = new \User();
  81. $user->setContactType("MOBILE");
  82. $user->setContact($phone);
  83. $userAuthPageRequest = new \UserAuthPageRequest();
  84. $userAuthPageRequest->setUser($user);
  85. $userAuthPageRequest->setMode("DEFAULT");
  86. $userAuthPageRequest->setCallbackUrl('http://api.admin.app.jiuweiyun.cn/api/QYInfo/status');
  87. $result = $sdkClient->service($userAuthPageRequest);
  88. return $result;
  89. }
  90. /*
  91. * 查看合同
  92. * **/
  93. public function GetDocument(){
  94. $id=Auth::user()->id;
  95. $re=QYDocumet::where('user_id',$id)->orderByDesc('id')->get();
  96. return $this->success($re);
  97. }
  98. public function Pdf(Request $request){
  99. $id=$request->input('id');
  100. $link=QYDocumet::find($id);
  101. header('Content-Type:application/pdf');
  102. return file_get_contents($link->url);
  103. }
  104. }