add-tcorc-veh
This commit is contained in:
@@ -819,6 +819,16 @@ class Orders extends HD_Controller
|
||||
$update = [
|
||||
$field => $value
|
||||
];
|
||||
//识别行驶证
|
||||
if($field=='car_img'){
|
||||
$result = $this->tcorc->VehicleLicense(build_qiniu_image_url($value));
|
||||
if (!$result['code']) {
|
||||
return $this->show_json(SYS_CODE_FAIL, '图片识别失败,请重新上传');
|
||||
}
|
||||
$jsondata = json_decode($re_data['jsondata'],true);
|
||||
$jsondata['car_info'] = $result['data']['FrontInfo'];
|
||||
$update['jsondata'] = json_encode($jsondata,JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
$res = $this->receiver_order_datas_model->update($update,['id'=>$re_data_id]);
|
||||
if($res){
|
||||
$this->orders_status_entity->set_status($id,6,1);
|
||||
|
||||
@@ -12,8 +12,10 @@ class Order extends CI_Controller{
|
||||
$this->load->model('receiver/order/receiver_orders_model');
|
||||
$this->load->model('receiver/order/receiver_orders_v2_model');
|
||||
$this->load->model('receiver/order/receiver_order_status_model');
|
||||
$this->load->model('receiver/order/receiver_order_datas_model');
|
||||
|
||||
$this->load->model('app/liche/app_liche_orders_model');
|
||||
$this->load->library('receiver/order_datas_entity');
|
||||
}
|
||||
|
||||
public function index(){
|
||||
@@ -250,4 +252,26 @@ class Order extends CI_Controller{
|
||||
debug_log("订单过期执行完毕",$this->log_file,$this->log_dir);
|
||||
}
|
||||
}
|
||||
|
||||
//更新行驶证
|
||||
public function car_img(){
|
||||
$oid = $this->input->get('oid');
|
||||
$page = $this->input->get('page');
|
||||
$size = $this->input->get('size');
|
||||
!$page && $page = 1;
|
||||
!$size && $size = 10;
|
||||
$where = [
|
||||
"car_img <> ''" => null
|
||||
];
|
||||
$oid && $where['o_id'] = $oid;
|
||||
$rows = $this->receiver_order_datas_model->select($where,'id asc',$page,$size);
|
||||
if($rows){
|
||||
foreach ($rows as $item) {
|
||||
$res = $this->order_datas_entity->orc_car_img($item['o_id']);
|
||||
echo "{$item['o_id']}执行结果:{$res}";
|
||||
}
|
||||
}else{
|
||||
echo "no data";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -119,7 +119,9 @@ class Cusorderdata extends Wxapp{
|
||||
if(!$row){
|
||||
throw new Exception('参数错误', ERR_PARAMS_ERROR);
|
||||
}
|
||||
if(!$this->receiver_order_datas_model->get(['o_id'=>$id])){
|
||||
$data_row = $this->receiver_order_datas_model->get(['o_id'=>$id]);
|
||||
$jsondata = json_decode($data_row['jsondata'],true);
|
||||
if(!$data_row){
|
||||
$this->receiver_order_datas_model->add(['o_id'=>$id]);
|
||||
}
|
||||
$cardida = $this->input_param('cardida');
|
||||
@@ -173,9 +175,15 @@ class Cusorderdata extends Wxapp{
|
||||
$key = 'cardidb';
|
||||
$img = $cardidb;
|
||||
}
|
||||
if($car_img){
|
||||
if($car_img){ //图片识别行驶证
|
||||
$key = 'car_img';
|
||||
$img = $car_img;
|
||||
$result = $this->tcorc->VehicleLicense(build_qiniu_image_url($car_img));
|
||||
if (!$result['code']) {
|
||||
throw new Exception('行驶证识别失败,请重新上传', ERR_PARAMS_ERROR);
|
||||
}
|
||||
$jsondata['car_info'] = $result['data']['FrontInfo'];
|
||||
$update['jsondata'] = json_encode($jsondata,JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
if($register_img){
|
||||
$key = 'register_img';
|
||||
|
||||
@@ -16,6 +16,7 @@ use TencentCloud\Ocr\V20181119\OcrClient;
|
||||
use TencentCloud\Ocr\V20181119\Models\IDCardOCRRequest;
|
||||
use TencentCloud\Ocr\V20181119\Models\BizLicenseOCRRequest;
|
||||
use TencentCloud\Ocr\V20181119\Models\CarInvoiceOCRRequest;
|
||||
use TencentCloud\Ocr\V20181119\Models\VehicleLicenseOCRRequest;
|
||||
class TcOrc{
|
||||
|
||||
private $accessKeyId;
|
||||
@@ -190,4 +191,53 @@ class TcOrc{
|
||||
return ['code'=>0,'msg'=>'图片识别失败'];
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 行驶证识别
|
||||
* Desc: 腾讯官方地址:https://cloud.tencent.com/document/product/866/36209
|
||||
* @param $imageUrl string 行驶证照图片url
|
||||
* @param return array 返回值参考官方文档
|
||||
*/
|
||||
public function VehicleLicense($imageUrl){
|
||||
//dev测试
|
||||
if($this->is_dev){
|
||||
$this->ci->load->library('mycurl');
|
||||
$debug_url = 'http://104.194.86.23:8889/veh.php';
|
||||
$params = [
|
||||
'ImageUrl' => $imageUrl,
|
||||
];
|
||||
$result = $this->ci->mycurl->httpGet($debug_url,$params);
|
||||
$result = json_decode($result,true);
|
||||
return $result;
|
||||
}
|
||||
try {
|
||||
$cred = new Credential($this->accessKeyId, $this->accessKeySecret);
|
||||
$httpProfile = new HttpProfile();
|
||||
$httpProfile->setEndpoint("ocr.tencentcloudapi.com");
|
||||
|
||||
$clientProfile = new ClientProfile();
|
||||
$clientProfile->setHttpProfile($httpProfile);
|
||||
$client = new OcrClient($cred, "ap-guangzhou", $clientProfile);
|
||||
|
||||
$req = new VehicleLicenseOCRRequest();
|
||||
|
||||
$params = array(
|
||||
"ImageUrl" => $imageUrl,
|
||||
);
|
||||
$req->fromJsonString(json_encode($params));
|
||||
|
||||
$resp = $client->VehicleLicenseOCR($req);
|
||||
|
||||
debug_log("function:".__FUNCTION__.$resp->toJsonString(),'success.log',$this->dir);
|
||||
$result = json_decode($resp->toJsonString(),true);
|
||||
if($result['Error']){
|
||||
return ['code'=>0,'msg'=>$result['Error']['Message']];
|
||||
}else{
|
||||
return ['code'=>1,'msg'=>'图片识别成功','data'=>$result];
|
||||
}
|
||||
}
|
||||
catch(TencentCloudSDKException $e) {
|
||||
debug_log($e,$this->log_file,$this->dir);
|
||||
return ['code'=>0,'msg'=>'图片识别失败'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -123,4 +123,29 @@ class Order_datas_entity{
|
||||
$res = $this->ci->receiver_order_datas_model->update($data,['o_id'=>$oid]);
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 识别行驶证
|
||||
* @param $oid
|
||||
* @return bool
|
||||
*/
|
||||
public function orc_car_img($oid){
|
||||
$row = $this->ci->receiver_order_datas_model->get(['o_id'=>$oid]);
|
||||
if(!$row['car_img']){
|
||||
return false;
|
||||
}
|
||||
$img_url = build_qiniu_image_url($row['car_img']);
|
||||
$this->ci->load->library('TcOrc');
|
||||
$result = $this->ci->tcorc->VehicleLicense($img_url);
|
||||
if (!$result['code']) {
|
||||
return false;
|
||||
}
|
||||
$jsondata = json_decode($row['jsondata'],true);
|
||||
$jsondata['car_info'] = $result['data']['FrontInfo'];
|
||||
$update = [
|
||||
'jsondata' => json_encode($jsondata,JSON_UNESCAPED_UNICODE)
|
||||
];
|
||||
$res = $this->ci->receiver_order_datas_model->update($update,['id'=>$row['id']]);
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user