123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116 |
- <?php
- namespace App\Http\Controllers\QYInfo;
- use App\Http\Controllers\Controller;
- use App\Models\QYCrownAuth;
- use App\Models\QYCrownDocumet;
- use App\Models\QYDocumet;
- use Illuminate\Http\Request;
- use Illuminate\Support\Facades\Auth;
- use Illuminate\Support\Facades\DB;
- use Carbon\Carbon;
- class QYInfoController extends Controller {
- /*
- * 校验是够认证
- * ***/
- public function CheckAuth(){
- $id=Auth::user()->id;
- return $this->success([]);
- $mobile=Auth::user()->mobile;
- if ($mobile==15286818088 || $mobile==15236877164 || $mobile==18638295271){
- $re=QYCrownAuth::where('status',1)->where('user_id',$id)->first();
- if (!$re){
- return $this->error(50021);
- }
- return $this->success([]);
- }else{
- return $this->success([]);
- }
- $re=QYCrownAuth::where('status',1)->where('user_id',$id)->first();
- if (!$re){
- return $this->error(50021);
- }
- return $this->success([]);
- }
- /*
- * 认证
- * **/
- public function Auth(){
- return $this->success(['url'=>'api.app.cliu.cc/api/gzh']);
- $id=Auth::user()->id;
- $re=QYCrownAuth::where('user_id',$id)->first();
- if (!$re){
- $result=$this->person(Auth::user()->mobile);
- $qyinfo=new QYCrownAuth();
- $qyinfo->user_id=$id;
- $qyinfo->authId=$result['result']['authId'];
- $qyinfo->authUrl=$result['result']['authUrl'];
- $qyinfo->mobile=Auth::user()->mobile;
- $qyinfo->time_out=Carbon::now()->addMinutes(5);
- $qyinfo->save();
- return $this->success(['url'=>$qyinfo->authUrl]);
- }else{
- if ($re->status==2){
- $result=$this->person(Auth::user()->mobile);
- $qyinfo=QYCrownAuth::where('user_id',$id)->first();
- $qyinfo->authId=$result['result']['authId'];
- $qyinfo->authUrl=$result['result']['authUrl'];
- $qyinfo->mobile=Auth::user()->mobile;
- $qyinfo->time_out=Carbon::now()->addMinutes(5);
- $qyinfo->save();
- return $this->success(['url'=>$qyinfo->authUrl]);
- }else{
- if ($re->time_out<Carbon::now()){
- $result=$this->person(Auth::user()->mobile);
- $qyinfo=QYCrownAuth::where('user_id',$id)->first();
- $qyinfo->authId=$result['result']['authId'];
- $qyinfo->authUrl=$result['result']['authUrl'];
- $qyinfo->mobile=Auth::user()->mobile;
- $qyinfo->time_out=Carbon::now()->addMinutes(5);
- $qyinfo->save();
- return $this->success(['url'=>$qyinfo->authUrl]);
- }else{
- return $this->success(['url'=>$re->authUrl]);
- }
- }
- }
- }
- public function person($phone){
- $sdkClient = \Util::getSDk();
- // 待认证的用户信息
- $user = new \User();
- $user->setContactType("MOBILE");
- $user->setContact($phone);
- $userAuthPageRequest = new \UserAuthPageRequest();
- $userAuthPageRequest->setUser($user);
- $userAuthPageRequest->setMode("DEFAULT");
- $userAuthPageRequest->setCallbackUrl('http://api.admin.app.jiuweiyun.cn/api/QYInfo/status');
- $result = $sdkClient->service($userAuthPageRequest);
- return $result;
- }
- /*
- * 查看合同
- * **/
- public function GetDocument(){
- $id=Auth::user()->id;
- $re=QYDocumet::where('user_id',$id)->orderByDesc('id')->get();
- return $this->success($re);
- }
- public function Pdf(Request $request){
- $id=$request->input('id');
- $link=QYDocumet::find($id);
- header('Content-Type:application/pdf');
- return file_get_contents($link->url);
- }
- }
|