灵活用工
This commit is contained in:
@@ -9,7 +9,10 @@ class UserInfo extends BaseController
|
||||
{
|
||||
parent::__construct();
|
||||
$this->load->model('agent/pingan/pingan_users_data_model', 'userData');
|
||||
$this->load->model('agent/pingan/pingan_users_model');
|
||||
$this->load->model('agent/users_auth_model');
|
||||
$this->load->helper('image');
|
||||
$this->load->library('carHome/daiFu');
|
||||
}
|
||||
|
||||
public function index_get()
|
||||
@@ -26,6 +29,21 @@ class UserInfo extends BaseController
|
||||
}
|
||||
$row['id'] = $dataId;
|
||||
}
|
||||
$where = [
|
||||
'userId' => $userId,
|
||||
'type' => Users_auth_model::TYPE_PING_AN,
|
||||
'status' => Users_auth_model::STATUS_NORMAL
|
||||
];
|
||||
$authRows = $this->users_auth_model->select($where, 'id desc');
|
||||
$authRow = $authRows ? $authRows[0] : [];
|
||||
$signStatus = $authStatus = '未提交认证';
|
||||
if ($authRow) {
|
||||
$authStatus = Users_auth_model::AUTH_TYPE_LIST[$authRow['authStatus']] ?: '未知状态';
|
||||
$signStatus = Users_auth_model::SIGN_TYPE_LIST[$authRow['signStatus']] ?: '';
|
||||
if ($authRow['authStatus'] == Users_auth_model::AUTH_TYPE_IDENTIFY_FAIL) {
|
||||
$authStatus .= " ({$authRow['failReason']})";
|
||||
}
|
||||
}
|
||||
$data = [
|
||||
'id' => $row['id'],
|
||||
'cardId' => $row['cardId'] ?: '',
|
||||
@@ -34,6 +52,8 @@ class UserInfo extends BaseController
|
||||
'cardA' => $row['cardA'] ? changeImg(explode(',', $row['cardA'])) : [],
|
||||
'cardB' => $row['cardB'] ? changeImg(explode(',', $row['cardB'])) : [],
|
||||
'mobile' => $row['mobile'],
|
||||
'authStatus' => $authStatus,
|
||||
'signStatus' => $signStatus,
|
||||
'cti' => $row['cti']
|
||||
];
|
||||
$this->return_response($data);
|
||||
@@ -42,9 +62,30 @@ class UserInfo extends BaseController
|
||||
public function index_put()
|
||||
{
|
||||
$userId = $_SESSION['id'];
|
||||
$authStatusList = [Users_auth_model::AUTH_TYPE_ACCEPT, Users_auth_model::AUTH_TYPE_IDENTIFY_SUCCESS];
|
||||
$authStatus = implode("','", $authStatusList);
|
||||
$where = [
|
||||
'userId' => $userId,
|
||||
'type' => Users_auth_model::TYPE_PING_AN,
|
||||
"authStatus in('{$authStatus}')" => null,
|
||||
'status' => Users_auth_model::STATUS_NORMAL
|
||||
];
|
||||
$row = $this->users_auth_model->get($where);
|
||||
if ($row) {
|
||||
$this->return_json("当前状态无法修改");
|
||||
}
|
||||
$user = $this->pingan_users_model->get(['id' => $userId]);
|
||||
$mobile = $user['mobile'];
|
||||
$username = $user['username'];
|
||||
if (!$mobile) {
|
||||
$this->return_json("手机号未绑定");
|
||||
}
|
||||
$params = $this->input_param();
|
||||
$cardA = getImageFromArray($params['cardA']);
|
||||
$cardB = getImageFromArray($params['cardB']);
|
||||
if (!valid_id_card($params['cardId'])) {
|
||||
$this->return_json("请输入正确身份证号");
|
||||
}
|
||||
$upData = [
|
||||
'cardId' => $params['cardId'],
|
||||
'bankCardNum' => $params['bankCardNum'],
|
||||
@@ -56,6 +97,39 @@ class UserInfo extends BaseController
|
||||
if (!$res) {
|
||||
$this->return_json("更新失败");
|
||||
}
|
||||
//提交实名认证签约
|
||||
$daiFu = new DaiFu();
|
||||
$requestId = create_order_no(350200, 'pingan');
|
||||
$frontImageUrl = build_qiniu_image_url($upData['cardA']);
|
||||
$backImageUrl = build_qiniu_image_url($upData['cardB']);
|
||||
$idCard = $upData['cardId'];
|
||||
$realName = $username;
|
||||
$cellPhone = $mobile;
|
||||
$bankName = $upData['bankName'];
|
||||
$bankCard = $upData['bankCardNum'];
|
||||
$req = $daiFu->uploadIdCardImage($requestId, $frontImageUrl, $backImageUrl, $idCard, $realName, $cellPhone, $bankName, $bankCard);
|
||||
if (!$req->isSuccess()) {
|
||||
$this->return_json($req->getMessage());
|
||||
}
|
||||
$reqData = $req->getData();
|
||||
$userAuthData = [
|
||||
'requestId' => $requestId,
|
||||
'userId' => $userId,
|
||||
'realName' => $realName,
|
||||
'idCard' => $idCard,
|
||||
'frontImage' => $upData['cardA'],
|
||||
'backImage' => $upData['cardB'],
|
||||
'bankCard' => $bankCard,
|
||||
'bankName' => $bankName,
|
||||
'cellphone' => $cellPhone,
|
||||
'type' => Users_auth_model::TYPE_PING_AN,
|
||||
'authStatus' => Users_auth_model::AUTH_TYPE_ACCEPT,
|
||||
'signStatus' => Users_auth_model::SIGN_TYPE_UN_SING,
|
||||
];
|
||||
$resLog = $this->users_auth_model->add($userAuthData);
|
||||
if (!$resLog) {
|
||||
$this->return_json("保存认证失败");
|
||||
}
|
||||
$this->return_response();
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,102 @@
|
||||
<?php
|
||||
|
||||
class UserAuth extends HD_Controller
|
||||
{
|
||||
private $dir;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->load->model('agent/users_auth_model');
|
||||
$this->users_auth_model->set_db('agentdb');
|
||||
|
||||
$this->load->library('carHome/daiFu');
|
||||
$this->load->library('myResponse');
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
$redis = &load_cache();
|
||||
$redisKey = 'UserAuthPlanPage';
|
||||
$page = $redis->get($redisKey) ?: 1;
|
||||
$pageSize = 20;
|
||||
$where = [
|
||||
'status' => Users_auth_model::STATUS_NORMAL,
|
||||
'authStatus' => Users_auth_model::AUTH_TYPE_ACCEPT,
|
||||
];
|
||||
$rows = $this->users_auth_model->select($where, 'id asc', $page, $pageSize);
|
||||
if (!$rows) {
|
||||
$redis->delete($redisKey);
|
||||
|
||||
exit();
|
||||
}
|
||||
$daiFu = new DaiFu();
|
||||
foreach ($rows as $key => $val) {
|
||||
$requestId = create_order_no(350200, 'pingan');
|
||||
$idCard = $val['idCard'];
|
||||
$req = $daiFu->queryIdCardImage($requestId, $idCard);
|
||||
if ($req->isSuccess() && $req->getData()) {
|
||||
$reqData = $req->getData();
|
||||
$updateData = [
|
||||
'authStatus' => $reqData['status']
|
||||
];
|
||||
$reqData['fail_reason'] && $updateData['failReason'] = $reqData['fail_reason'];
|
||||
$this->users_auth_model->update($updateData, ['id' => $val['id']]);
|
||||
}
|
||||
}
|
||||
$redis->save($redisKey, $page + 1, 24 * 3600);//保存最后id
|
||||
echo "执行完成";
|
||||
}
|
||||
|
||||
/**
|
||||
* 图片上传处理结果回调地址
|
||||
* @return void
|
||||
*/
|
||||
public function notify()
|
||||
{
|
||||
$filePath = "agentAuthNotify.log";
|
||||
$params = $this->input->post();
|
||||
$jsonData = file_get_contents('php://input');
|
||||
debug_log("post数据:" . json_encode($params, JSON_UNESCAPED_UNICODE), $filePath);
|
||||
debug_log("json数据:" . $jsonData, $filePath);
|
||||
$returnData = [
|
||||
"name" => "REGISTER", "code" => 0,
|
||||
"message" => "", "data" => []
|
||||
];
|
||||
echo json_encode($returnData, JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户实名认证
|
||||
* @return void
|
||||
*/
|
||||
public function autoUser()
|
||||
{
|
||||
$this->load->model('agent/pingan/pingan_users_data_model');
|
||||
$this->load->model('agent/pingan/pingan_users_model');
|
||||
$this->pingan_users_model->set_db('agentdb');
|
||||
$this->pingan_users_data_model->set_db('agentdb');
|
||||
$page = 1;
|
||||
$size = 20;
|
||||
$offset = ($page - 1) * $size;
|
||||
$limit = $size;
|
||||
$table = 'lc_auto_user';
|
||||
$table2 = 'lc_auto_user_data';
|
||||
$where = [
|
||||
"{$table2}.bankCardNum !=''" => null,
|
||||
"{$table2}.bankName !=''" => null,
|
||||
"{$table2}.bankImg !=''" => null,
|
||||
"{$table2}.bankMobile !=''" => null,
|
||||
"{$table2}.status" => 1
|
||||
];
|
||||
$this->pingan_users_model->db->from($table);
|
||||
$this->pingan_users_model->db->join($table2, "{$table2}.userId = {$table}.id", 'left');
|
||||
$this->pingan_users_model->db->select("{$table}.*");
|
||||
$this->pingan_users_model->db->where($where);
|
||||
$this->pingan_users_model->db->limit($limit, $offset);
|
||||
$this->pingan_users_model->db->order_by('id', 'desc');
|
||||
$lists = $this->pingan_users_model->db->get()->result_array();
|
||||
print_r($lists);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
@@ -1247,4 +1247,17 @@ if (!function_exists('ems_sms')) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证18位中国大陆身份证号码
|
||||
*/
|
||||
if (!function_exists('valid_id_card')) {
|
||||
function valid_id_card($id_card)
|
||||
{
|
||||
if (!preg_match('/^[1-9]\d{5}(19|20)\d{2}((0[1-9])|(1[0-2]))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/', $id_card)) {
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
defined('BASEPATH') or exit('No direct script access allowed');
|
||||
|
||||
class Users_auth_model extends HD_Model
|
||||
{
|
||||
private $table_name = 'lc_users_auth';
|
||||
const STATUS_DISABLE = 0; //禁用
|
||||
const STATUS_NORMAL = 1; //正常
|
||||
|
||||
const TYPE_PING_AN = 0; //平安后台用户
|
||||
|
||||
const AUTH_TYPE_ACCEPT = 'ACCEPT';
|
||||
const AUTH_TYPE_IDENTIFY_SUCCESS = 'IDENTIFY_SUCCESS';
|
||||
const AUTH_TYPE_IDENTIFY_FAIL = 'IDENTIFY_FAIL';
|
||||
const AUTH_TYPE_NULL = 'NULL';
|
||||
const AUTH_TYPE_UN_IDENTIFY = 'UN_IDENTIFY';
|
||||
|
||||
|
||||
const AUTH_TYPE_LIST = [
|
||||
self::AUTH_TYPE_ACCEPT => '已受理',
|
||||
self::AUTH_TYPE_IDENTIFY_SUCCESS => '认证通过',
|
||||
self::AUTH_TYPE_IDENTIFY_FAIL => '认证失败',
|
||||
self::AUTH_TYPE_NULL => '纳税人信息不存在',
|
||||
self::AUTH_TYPE_UN_IDENTIFY => '证照未上传'
|
||||
];
|
||||
|
||||
const SIGN_TYPE_SING = 'SIGN';
|
||||
const SIGN_TYPE_UN_SING = 'UN_SIGN';
|
||||
const SIGN_TYPE_LIST = [
|
||||
self::SIGN_TYPE_SING => '已签约',
|
||||
self::SIGN_TYPE_UN_SING => '未签约'
|
||||
];
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct($this->table_name, 'default');
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user