灵活用工
This commit is contained in:
@@ -3,6 +3,9 @@
|
||||
use GuzzleHttp\Client;
|
||||
use GuzzleHttp\Exception\RequestException;
|
||||
|
||||
/**
|
||||
* 灵活用工接口
|
||||
*/
|
||||
class DaiFu
|
||||
{
|
||||
const METHOD_GET = 'GET';
|
||||
@@ -24,7 +27,6 @@ class DaiFu
|
||||
$this->ci = &get_instance();
|
||||
if (!is_product()) { //测试环境
|
||||
$this->baseUrl = 'https://app-uat.zkzs6.com/api/v1';
|
||||
// $this->baseUrl = 'https://api.ss.haodian.cn/plan/callBack/test';
|
||||
$this->clientKey = "808641732177002496";
|
||||
$this->privateKey = "5d8fd442a18da9ae3f39916d6504127k";
|
||||
$this->agentParentId = "655342131023806464";
|
||||
@@ -51,21 +53,33 @@ class DaiFu
|
||||
* 证件上传
|
||||
* @return MyResponse
|
||||
*/
|
||||
public function uploadIdCardImage()
|
||||
public function uploadIdCardImage($requestId, $frontImageUrl, $backImageUrl, $idCard, $realName, $cellPhone,
|
||||
$bankName = '', $bankCard = '', $autoSign = 1)
|
||||
{
|
||||
try {
|
||||
$baseData = $this->getCommonData(self::UPLOAD_ID_CARD_IMAGE);
|
||||
$imgUrl = "https://img.liche.cn/liche/2025/09/b6ef0ca29d6f1485/4d49f2821472034e.png";
|
||||
$frontImage = $this->urlToBase64($imgUrl);
|
||||
$frontImgData = $this->urlToBase64($frontImageUrl);
|
||||
if (!$frontImgData->isSuccess() || !$frontImgData->getData()['data']) {
|
||||
throw new Exception("获取身份证正面图片失败");
|
||||
}
|
||||
$backImgData = $this->urlToBase64($backImageUrl);
|
||||
if (!$backImgData->isSuccess() || !$backImgData->getData()['data']) {
|
||||
throw new Exception("获取身份证反面图片失败");
|
||||
}
|
||||
$frontImage = $frontImgData->getData()['data'];
|
||||
$backImage = $backImgData->getData()['data'];
|
||||
$data = [
|
||||
'request_id' => time(),
|
||||
'id_card' => '350802199111298215',
|
||||
'real_name' => '林聪聪',
|
||||
'cellphone' => '18350451617',
|
||||
'request_id' => $requestId,
|
||||
'id_card' => $idCard,
|
||||
'real_name' => $realName,
|
||||
'cellphone' => $cellPhone,
|
||||
'upload_way' => 'DIRECT', //求方式:DIRECT(直接上传),目前仅支持 DIRECT
|
||||
'front_image' => $frontImage,
|
||||
'back_image' => $frontImage,
|
||||
'back_image' => $backImage,
|
||||
'auto_sign' => $autoSign
|
||||
];
|
||||
$bankName && $data['bank_name'] = $bankName;
|
||||
$bankCard && $data['bank_card'] = $bankCard;
|
||||
$baseData['data'] = $data;
|
||||
$reqData = [
|
||||
'req' => json_encode($baseData, JSON_UNESCAPED_UNICODE)
|
||||
@@ -86,15 +100,17 @@ class DaiFu
|
||||
}
|
||||
|
||||
/**
|
||||
* 证件照处理结果查询接口
|
||||
* @param $requestId
|
||||
* @param $idCard
|
||||
* @return MyResponse
|
||||
*/
|
||||
public function queryIdCardImage($idCard)
|
||||
public function queryIdCardImage($requestId, $idCard)
|
||||
{
|
||||
try {
|
||||
$baseData = $this->getCommonData(self::QUERY_ID_CARD_IMAGE);
|
||||
$data = [
|
||||
'request_id' => time(),
|
||||
'request_id' => $requestId,
|
||||
'id_card' => $idCard
|
||||
];
|
||||
$baseData['data'] = $data;
|
||||
@@ -228,27 +244,30 @@ class DaiFu
|
||||
}
|
||||
|
||||
/**
|
||||
* 简化版:网络图片URL转Base64编码
|
||||
* @param string $url 图片URL
|
||||
* @return string|false 转换结果
|
||||
* 网络图片URL转Base64编码
|
||||
* * @param string $url 图片URL
|
||||
* @return MyResponse
|
||||
*/
|
||||
public function urlToBase64($url)
|
||||
{
|
||||
// 设置超时时间
|
||||
$context = stream_context_create([
|
||||
'http' => ['timeout' => 10],
|
||||
'ssl' => ['verify_peer' => false] // 跳过SSL验证
|
||||
]);
|
||||
|
||||
// 获取图片内容
|
||||
$imageData = @file_get_contents($url, false, $context);
|
||||
if (!$imageData) return false;
|
||||
|
||||
// 获取MIME类型
|
||||
$finfo = new finfo(FILEINFO_MIME_TYPE);
|
||||
$mime = $finfo->buffer($imageData);
|
||||
|
||||
// 生成Base64字符串
|
||||
return 'data:' . $mime . ';base64,' . base64_encode($imageData);
|
||||
try {
|
||||
// 设置超时时间
|
||||
$context = stream_context_create([
|
||||
'http' => ['timeout' => 10],
|
||||
'ssl' => ['verify_peer' => false] // 跳过SSL验证
|
||||
]);
|
||||
// 获取图片内容
|
||||
$imageData = @file_get_contents($url, false, $context);
|
||||
if (!$imageData) {
|
||||
throw new Exception("无法获取图片内容");
|
||||
}
|
||||
// 获取MIME类型
|
||||
$finfo = new finfo(FILEINFO_MIME_TYPE);
|
||||
$mime = $finfo->buffer($imageData);
|
||||
$responseData['data'] = 'data:' . $mime . ';base64,' . base64_encode($imageData);
|
||||
return new MyResponse(EXIT_SUCCESS, '操作成功', $responseData);
|
||||
} catch (Exception $e) {
|
||||
return new MyResponse(EXIT_ERROR, $e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user