edit-common-finish_pdf

This commit is contained in:
lccsw
2022-09-15 14:40:05 +08:00
parent 9bc904cbce
commit 2b300d95e2
3 changed files with 124 additions and 16 deletions
+18 -5
View File
@@ -37,6 +37,7 @@ class Orders extends HD_Controller
$this->load->library('qyrobot');
$this->load->library('TcOrc');
$this->load->library('qiniuorc');
$this->load->library('tcmarket');
}
public function index()
@@ -312,7 +313,12 @@ class Orders extends HD_Controller
$img_jsondata = json_decode($img_data['jsondata'],true);
$business_img_key = md5(build_qiniu_image_url($business_img['img']));
$business_img_orc = $img_jsondata['ins_info'][$business_img_key];
$agent['business_time'] = $business_img_orc['data']['投保日期'];
if($business_img_orc['data']['投保日期']){
$agent['business_time'] = $business_img_orc['data']['投保日期'];
}else{
$agent['business_time'] = $business_img_orc['data']['coverYears'];
}
}
$row['agent'] = $agent;
//获取销售员
@@ -984,15 +990,22 @@ class Orders extends HD_Controller
if($field=='insurance_img'||$field=='business_img'){
$jsondata = json_decode($re_data['jsondata'],true);
$img_url = build_qiniu_image_url($value);
$result = $this->qiniuorc->car_insure($img_url);
// $result = $this->qiniuorc->car_insure($img_url);
$result = $this->tcmarket->autoInsurance($img_url);
if (!$result['code']) {
return $this->show_json(SYS_CODE_FAIL, '图片识别失败,请重新上传');
}
// $img_jsondata = [
// 'img' => $value,
// 'date' => $result['data']['投保确认时间'],
// 'price' => floatval($result['data']['合计保费']),
// 'product' => $result['data']['保险公司']
// ];
$img_jsondata = [
'img' => $value,
'date' => $result['data']['投保确认时间'],
'price' => floatval($result['data']['合计保费']),
'product' => $result['data']['保险公司']
'date' => $result['data']['policyStartDate'],
'price' => floatval($result['data']['premium']),
'product' => $result['data']['companyName']
];
$jsondata['ins_info'][md5($img_url)] = $result;
$update[$field] = json_encode($img_jsondata,JSON_UNESCAPED_UNICODE);
+92
View File
@@ -0,0 +1,92 @@
<?php
/**
* Created by Vim
* User: lcc
* Desc: 腾讯云图片识别
* Date: 2021-07-20
* Time: 16:49
*/
class Tcmarket{
private $secretId;
private $secretKey;
private $source;
private $ci;
private $dir = 'tcmarket';
private $log_file = 'info.log';
public function __construct(){
$this->secretId = 'AKIDggwqp02pqewr9k3walN70j6c89i80957qnh1';
$this->secretKey = '5Ao8l7pTbUh4h4fun55ndkFoxhqo2k49Z1R6gz23';
$this->source = 'market';
$this->ci = & get_instance();
}
/**
* 保单识别 (文档地址:https://market.cloud.tencent.com/products/27659)
* @param $imgUrl
* @param $imgBase64
* @return array|void
*/
public function autoInsurance($imgUrl,$imgBase64=''){
if(!$imgUrl && !$imgBase64){
return ['code'=>0,'msg'=>'参数错误'];
}
// 签名
$datetime = gmdate('D, d M Y H:i:s T');
$signStr = sprintf("x-date: %s\nx-source: %s", $datetime, $this->source);
$sign = base64_encode(hash_hmac('sha1', $signStr, $this->secretKey, true));
$auth = sprintf('hmac id="%s", algorithm="hmac-sha1", headers="x-date x-source", signature="%s"', $this->secretId, $sign);
// body参数(POST方法下)
$bodyParams = array (
'imgBase64' => $imgBase64,
'imgUrl' => $imgUrl,
);
// url参数拼接
$url = 'https://service-krag1mbm-1303991992.gz.apigw.tencentcs.com/release/autoInsurance';
$result = $this->http_curl($datetime,$auth,$url,$bodyParams);
debug_log("图片识别结果:".json_encode($result,JSON_UNESCAPED_UNICODE),$this->log_file,$this->dir);
if($result['status']==200){
return ['code'=>1,'data'=>$result['data'],'msg'=>'识别成功'];
}else{
return ['code'=>0,'msg'=>$result['message']];
}
}
private function http_curl($datetime,$auth,$url,$bodyParams){
// 请求方法
$method = 'POST';
// 请求头
$headers = array(
'X-Source' => $this->source,
'X-Date' => $datetime,
'Authorization' => $auth,
);
// url参数拼接
// $url = 'https://service-krag1mbm-1303991992.gz.apigw.tencentcs.com/release/autoInsurance';
// if (count($queryParams) > 0) {
// $url .= '?' . http_build_query($queryParams);
// }
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 60);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);
curl_setopt($ch, CURLOPT_HTTPHEADER, array_map(function ($v, $k) {
return $k . ': ' . $v;
}, array_values($headers), array_keys($headers)));
if (in_array($method, array('POST', 'PUT', 'PATCH'), true)) {
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($bodyParams));
}
$data = curl_exec($ch);
if (curl_errno($ch)) {
$data = ['status'=>400,'message'=>curl_errno($ch)];
}else{
$data = json_decode($data,true);
}
curl_close($ch);
return $data;
}
}
@@ -9,9 +9,9 @@ class Order_datas_entity{
private $ci;
private $wd_config = [ //网点配置
350100 => ['name'=>'福州狸车销售有限公司','code'=>'FJ0011'],
350200 => ['name'=>'厦门狸车销售有限公司','code'=>'FJ0007'],
350500 => ['name'=>'泉州狸车销售有限公司','code'=>'FJ0009'],
350100 => ['name'=>'福州狸车汽车销售有限公司','code'=>'FJ0011'],
350200 => ['name'=>'厦门狸车汽车销售有限公司','code'=>'FJ0007'],
350500 => ['name'=>'泉州狸车汽车销售有限公司','code'=>'FJ0009'],
];
const COLOR_UN_UPLOAD = '#f9394d'; //未传
const COLOR_IS_UPLOAD = '#fd9737'; //已传
@@ -39,6 +39,7 @@ class Order_datas_entity{
$this->ci->load->library('TcOrc');
$this->ci->load->library('qiniuorc');
$this->ci->load->library('tcmarket');
$this->ci->load->library('pdftk');
$this->ci->load->library('pdf');
}
@@ -264,15 +265,16 @@ class Order_datas_entity{
$url = build_qiniu_image_url($insurance_img['img']);
$ins_key = md5($url);
if(!$ins_info[$ins_key]){
$result = $this->ci->qiniuorc->car_insure($url);
// $result = $this->ci->qiniuorc->car_insure($url);
$result = $this->ci->tcmarket->autoInsurance($url);
if ($result['code']) {
$ins_info[$ins_key]['msg'] = $result['msg'];
$ins_info[$ins_key]['data'] = $result['data'];
$ins_info[$ins_key]['img_url'] = $url;
$jsondata['ins_info'] = $ins_info;
$insurance_img['price'] = floatval($result['data']['合计保费']);
$insurance_img['date'] = $result['data']['投保确认时间'];
$insurance_img['product'] = $result['data']['保险公司'];
$insurance_img['price'] = floatval($result['data']['premium']);
$insurance_img['date'] = $result['data']['policyStartDate'];
$insurance_img['product'] = $result['data']['companyName'];
}else{
$ins_info[$ins_key]['msg'] = $result['msg'];
$ins_info[$ins_key]['img_url'] = $url;
@@ -284,15 +286,16 @@ class Order_datas_entity{
$url = build_qiniu_image_url($business_img['img']);
$ins_key = md5($url);
if(!$ins_info[$ins_key]){
$result = $this->ci->qiniuorc->car_insure($url);
// $result = $this->ci->qiniuorc->car_insure($url);
$result = $this->ci->tcmarket->autoInsurance($url);
if ($result['code']) {
$ins_info[$ins_key]['msg'] = $result['msg'];
$ins_info[$ins_key]['data'] = $result['data'];
$ins_info[$ins_key]['img_url'] = $url;
$jsondata['ins_info'] = $ins_info;
$business_img['price'] = floatval($result['data']['合计保费']);
$business_img['date'] = $result['data']['投保确认时间'];
$business_img['product'] = $result['data']['保险公司'];
$business_img['price'] = floatval($result['data']['premium']);
$business_img['date'] = $result['data']['policyStartDate'];
$business_img['product'] = $result['data']['companyName'];
}else{
$ins_info[$ins_key]['msg'] = $result['msg'];
$ins_info[$ins_key]['img_url'] = $url;