68 lines
1.8 KiB
PHP
68 lines
1.8 KiB
PHP
<?php
|
|
|
|
namespace app\api\controller;
|
|
|
|
use fastphp\base\Controller;
|
|
use app\api\model\User;
|
|
use alipay\Aliverify;
|
|
|
|
class Test extends Controller
|
|
{
|
|
|
|
public function aliverify()
|
|
{
|
|
$temp = json_decode(file_get_contents("php://input"),true);
|
|
$info = Aliverify::initVerify($temp);
|
|
$user = new User;
|
|
$data = [];
|
|
$user_one_info = $user->getOne(['Id'=>$this->userinfo['UserId']]);
|
|
if ($user_one_info['is_verify'] == 1){
|
|
$data = [
|
|
'Code'=>20000
|
|
];
|
|
echo json_encode($data);
|
|
die;
|
|
}
|
|
if($info){
|
|
$update_one['certify_id'] = $info['certifyId'];
|
|
$update_one['Name'] = $temp['name'];
|
|
$update_one['id_code'] = $temp['id_code'];
|
|
$data['certify_id'] = $info['certifyId'];
|
|
$data['url'] = $info['url'];
|
|
if($user->updateOne(['Id'=>$this->userinfo['UserId']],$update_one)){
|
|
$data['Code'] = 10000;
|
|
} else {
|
|
$data = [
|
|
'Code'=>-10000
|
|
];
|
|
}
|
|
} else {
|
|
$data = [
|
|
'Code'=>-10000
|
|
];
|
|
}
|
|
echo json_encode($data);
|
|
}
|
|
|
|
public function aliGetResult()
|
|
{
|
|
$user = new User;
|
|
$user_one_info = $user->getOne(['Id'=>$this->userinfo['UserId']]);
|
|
$info = Aliverify::getResult($user_one_info['certify_id']);
|
|
$data = [];
|
|
if($info){
|
|
$user_data['is_verify'] = 1;
|
|
if($user->updateOne(['Id'=>$this->userinfo['UserId']],$user_data)){
|
|
$data = [
|
|
'Code'=>10000
|
|
];
|
|
}
|
|
} else {
|
|
$data = [
|
|
'Code'=>-10000
|
|
];
|
|
}
|
|
echo json_encode($data);
|
|
}
|
|
|
|
} |