188 lines
7.4 KiB
PHP
188 lines
7.4 KiB
PHP
<?php
|
|
defined('WXAPP_APP') OR exit('No direct script access allowed');
|
|
|
|
/**
|
|
* Created by Vim
|
|
* Desc: 身份证图片识别
|
|
* User: lcc
|
|
* Date: 2021/07/16
|
|
* Time: 14:08
|
|
*/
|
|
require_once APPPATH.'controllers/wxapp/Wxapp.php';
|
|
class Idcard extends Wxapp{
|
|
|
|
public function __construct($inputs, $app_key){
|
|
parent::__construct($inputs, $app_key);
|
|
|
|
$this->login_white = array();//登录白名单
|
|
$this->check_status = array();//用户状态校验
|
|
$this->check_mobile = array();//需要手机号
|
|
$this->check_headimg =array();//授权微信信息
|
|
$this->load->model('receiver/order/receiver_order_loans_model','order_loans_model');
|
|
$this->load->model('receiver/order/receiver_orders_model','orders_model');
|
|
$this->load->model('receiver/order/receiver_order_bills_model','order_bills_model');
|
|
|
|
$this->load->library('TcOrc');
|
|
$this->load->library('receiver/orders_entity');
|
|
}
|
|
|
|
protected function put(){
|
|
$id = $this->input_param('id');
|
|
$cardidA = $this->input_param('cardidA');
|
|
$cardidB = $this->input_param('cardidB');
|
|
$business_licence = $this->input_param('business_licence');
|
|
$row = $this->order_bills_model->get(['id'=>$id]);
|
|
$order = $this->orders_model->get(['id'=>$row['o_id']]);
|
|
if(!$row){
|
|
throw new Exception('参数错误', ERR_PARAMS_ERROR);
|
|
}
|
|
$jsondata = json_decode($row['jsondata'],true);
|
|
if($order['main_type']){ //购车主体公司
|
|
if(!$business_licence){
|
|
throw new Exception('参数错误', ERR_PARAMS_ERROR);
|
|
}
|
|
$full_business_licence = build_qiniu_image_url($business_licence);
|
|
$result = $this->tcorc->BizLicense($full_business_licence);
|
|
if(!$result['code']){
|
|
$res_data['code'] = API_CODE_ORC_FAIL;
|
|
$res_data['data'] = [
|
|
['business_licence' => false,'errmsg'=>$result['msg']],
|
|
];
|
|
return $res_data;
|
|
}
|
|
$jsondata['business_licence']['data'] = $result['data'];
|
|
$update = [
|
|
'business_licence' => $business_licence,
|
|
'status' => 1
|
|
];
|
|
|
|
}else{ //购车主体个人
|
|
if(!$cardidA || !$cardidB){
|
|
throw new Exception('参数错误', ERR_PARAMS_ERROR);
|
|
}
|
|
$full_cardidA = build_qiniu_image_url($cardidA);
|
|
$this->load->library('TcOrc');
|
|
$result = $this->tcorc->IdentityCard($full_cardidA);
|
|
if(!$result['code']){
|
|
$res_data['code'] = API_CODE_ORC_FAIL;
|
|
$res_data['data'] = [
|
|
['caridA' => false,'errmsg'=>$result['msg']],
|
|
['caridB' => true,'errmsg'=>''],
|
|
];
|
|
return $res_data;
|
|
}
|
|
|
|
$userinfo = $result['data'];
|
|
|
|
//校验订单客户和身份证姓名
|
|
$row_order = $this->orders_model->get(['id' => $row['o_id']]);
|
|
if($userinfo['Name'] != $row_order['name']){
|
|
throw new Exception('身份证姓名与客户不一致', ERR_PARAMS_ERROR);
|
|
}
|
|
$jsondata['cardidA']['data'] = $userinfo;
|
|
$update = [
|
|
'cardidA' => $cardidA,
|
|
'cardidB' => $cardidB,
|
|
'status' => 1
|
|
];
|
|
}
|
|
|
|
$jsondata && $update['jsondata'] = json_encode($jsondata,JSON_UNESCAPED_UNICODE);
|
|
$result = $this->order_bills_model->update($update,['id'=>$row['id']]);
|
|
if($result){
|
|
if($order['main_type']){
|
|
$order_jsondata = json_decode($order['info_json'],true);
|
|
$order_jsondata['c_credit'] = $jsondata['business_licence']['data']['RegNum'];
|
|
$this->orders_model->update(['info_json'=>json_encode($order_jsondata,JSON_UNESCAPED_UNICODE)],['id'=>$row['o_id']]);
|
|
}else{
|
|
$this->orders_entity->up_info($row['o_id'],$userinfo);
|
|
}
|
|
throw new Exception('修改成功', API_CODE_SUCCESS);
|
|
}else{
|
|
throw new Exception('修改失败', ERR_PARAMS_ERROR);
|
|
}
|
|
}
|
|
|
|
protected function post(){
|
|
$oid = $this->input_param('oid');
|
|
$cardidA = $this->input_param('cardidA');
|
|
$cardidB = $this->input_param('cardidB');
|
|
$business_licence = $this->input_param('business_licence');
|
|
$bill = $this->order_bills_model->count(['o_id'=>$oid]);
|
|
if($bill){
|
|
throw new Exception('创建失败', ERR_PARAMS_ERROR);
|
|
}
|
|
$row = $this->orders_model->get(['id'=>$oid]);
|
|
if(!$row){
|
|
throw new Exception('参数错误', ERR_PARAMS_ERROR);
|
|
}
|
|
if($row['main_type']){
|
|
if(!$business_licence){
|
|
throw new Exception('参数错误', ERR_PARAMS_ERROR);
|
|
}
|
|
$full_business_licence = build_qiniu_image_url($business_licence);
|
|
$result = $this->tcorc->BizLicense($full_business_licence);
|
|
if(!$result['code']){
|
|
$res_data['code'] = API_CODE_ORC_FAIL;
|
|
$res_data['data'] = [
|
|
['business_licence' => false,'errmsg'=>$result['msg']],
|
|
];
|
|
return $res_data;
|
|
}
|
|
$jsondata['business_licence']['data'] = $result['data'];
|
|
$add_data = [
|
|
'o_id' => $oid,
|
|
'business_licence' => $business_licence,
|
|
'c_time' => time(),
|
|
'status' => 1
|
|
];
|
|
}else{
|
|
if(!$cardidA || !$cardidB){
|
|
throw new Exception('参数错误', ERR_PARAMS_ERROR);
|
|
}
|
|
$full_cardidA = build_qiniu_image_url($cardidA);
|
|
$result = $this->tcorc->IdentityCard($full_cardidA);
|
|
if(!$result['code']){
|
|
$res_data['code'] = API_CODE_ORC_FAIL;
|
|
$res_data['data'] = [
|
|
['caridA' => false,'errmsg'=>$result['msg']],
|
|
['caridB' => true,'errmsg'=>''],
|
|
];
|
|
return $res_data;
|
|
}
|
|
$userinfo = $result['data'];
|
|
//校验订单客户和身份证姓名
|
|
if($userinfo['Name'] != $row['name']){
|
|
throw new Exception('身份证姓名与客户不一致', ERR_PARAMS_ERROR);
|
|
}
|
|
|
|
$jsondata['cardidA']['data'] = $userinfo;
|
|
$add_data = [
|
|
'o_id' => $oid,
|
|
'cardidA' => $cardidA,
|
|
'cardidB' => $cardidB,
|
|
'c_time' => time(),
|
|
'status' => 1
|
|
];
|
|
}
|
|
$jsondata && $add_data['jsondata'] = json_encode($jsondata,JSON_UNESCAPED_UNICODE);
|
|
$l_id = $this->order_bills_model->add($add_data);
|
|
if($l_id){
|
|
if($row['main_type']){
|
|
$order_jsondata = json_decode($row['info_json'],true);
|
|
$order_jsondata['c_credit'] = $jsondata['business_licence']['data']['RegNum'];
|
|
$this->orders_model->update(['info_json'=>json_encode($order_jsondata,JSON_UNESCAPED_UNICODE)],['id'=>$row['id']]);
|
|
}else{
|
|
$this->orders_entity->up_info($oid,$userinfo);
|
|
}
|
|
$data = [
|
|
'id' => $l_id,
|
|
];
|
|
return $data;
|
|
}else{
|
|
throw new Exception('创建失败', ERR_PARAMS_ERROR);
|
|
}
|
|
|
|
}
|
|
}
|