add-api-accident_ins

This commit is contained in:
lccsw
2023-02-07 17:41:15 +08:00
parent e91b2be754
commit 7e3d329a9a
2 changed files with 47 additions and 4 deletions
+25 -4
View File
@@ -47,7 +47,7 @@ class Cusorderdata extends Wxapp{
'img' => build_qiniu_image_url($row_data['register_img'])
];
}
$destory_img = $mut_wx_img = $wx_img = $delivery_ck_img = $bill_ck_img = $business_img = $insurance_img = [];
$accident_img = $destory_img = $mut_wx_img = $wx_img = $delivery_ck_img = $bill_ck_img = $business_img = $insurance_img = [];
$d_ins_info = json_decode($row_data['insurance_img'],true);
if($d_ins_info){
$insurance_img = [
@@ -68,6 +68,16 @@ class Cusorderdata extends Wxapp{
'date' => $d_ins_img['date'] ? $d_ins_img['date'] : '',
];
}
$d_accident_info = json_decode($row_data['accident_img'],true);
if($d_accident_info){
$accident_img = [
'value' => $d_accident_info['img'],
'img' => build_qiniu_image_url($d_accident_info['img']),
'product' => $d_accident_info['product'] ? $d_accident_info['product'] : '',
'price' => $d_accident_info['price'] ? $d_accident_info['price'] : 0,
'date' => $d_accident_info['date'] ? $d_accident_info['date'] : '',
];
}
$bill_img_json = json_decode($row_data['bill_ck_img'],true);
if($bill_img_json){
foreach ($bill_img_json as $item) {
@@ -98,6 +108,7 @@ class Cusorderdata extends Wxapp{
'img' => build_qiniu_image_url($row_data['destory_img'])
];
}
$jsondata = json_decode($row_data['jsondata'],true);
$imgs = [
'cardida' => [],
'cardidb' => [],
@@ -108,6 +119,7 @@ class Cusorderdata extends Wxapp{
'other_img' => [],
'insurance_img' => $insurance_img,
'business_img' => $business_img,
'accident_img' => $accident_img,
'bill_ck_img' => $bill_ck_img,
'wx_img' => $wx_img,
'mut_wx_img' => $mut_wx_img,
@@ -196,6 +208,7 @@ class Cusorderdata extends Wxapp{
$other_imgs = $this->input_param('other_imgs');
$insurance_img = $this->input_param('insurance_img');
$business_img = $this->input_param('business_img');
$accident_img = $this->input_param('accident_img');
$delivery_ck_img = $this->input_param('delivery_ck_img');
$wx_img = $this->input_param('wx_img');
$mut_wx_img = $this->input_param('mut_wx_img');
@@ -250,6 +263,8 @@ class Cusorderdata extends Wxapp{
$update['insurance_img'] = json_encode(['img'=>$insurance_img],JSON_UNESCAPED_UNICODE);
} elseif($business_img){
$update['business_img'] = json_encode(['img'=>$business_img],JSON_UNESCAPED_UNICODE);
} elseif($accident_img){
$update['accident_img'] = json_encode(['img'=>$accident_img],JSON_UNESCAPED_UNICODE);
}elseif(is_array($other_imgs)){
$update['other_img'] = json_encode($other_imgs,JSON_UNESCAPED_UNICODE);
}else{
@@ -291,9 +306,9 @@ class Cusorderdata extends Wxapp{
}
$res = $this->receiver_order_datas_model->update($update,['o_id'=>$id]);
if($res){
if($insurance_img || $business_img){ //保单识别图片保存数据
if($insurance_img || $business_img || $accident_img){ //保单识别图片保存数据
$res = $this->order_datas_entity->orc_ins_img_2($id);
if(!$res){
if(!$res && !$accident_img){//意外险不需要识别成功
throw new Exception('图片识别失败,请重新上传', ERR_PARAMS_ERROR);
}
}
@@ -316,12 +331,18 @@ class Cusorderdata extends Wxapp{
if(!$data_row){
throw new Exception('数据不存在', ERR_PARAMS_ERROR);
}
if($type){ //交强险图片
if($type==1){ //交强险图片
$jsondata = json_decode($data_row['insurance_img'],true);
$jsondata['product'] = $product;
$jsondata['price'] = $price;
$jsondata['date'] = $date;
$update['insurance_img'] = json_encode($jsondata,JSON_UNESCAPED_UNICODE);
}elseif($type==2){ //意外险图片
$jsondata = json_decode($data_row['accident_img'],true);
$jsondata['product'] = $product;
$jsondata['price'] = $price;
$jsondata['date'] = $date;
$update['accident_img'] = json_encode($jsondata,JSON_UNESCAPED_UNICODE);
}else{ //商业险图片
if($price<1000){
throw new Exception('金额有误,请重新填写', ERR_PARAMS_ERROR);
@@ -267,6 +267,7 @@ class Order_datas_entity{
$row = $this->ci->receiver_order_datas_model->get(['o_id'=>$oid]);
$insurance_img = json_decode($row['insurance_img'],true);
$business_img = json_decode($row['business_img'],true);
$accident_img = json_decode($row['accident_img'],true);
$jsondata = json_decode($row['jsondata'],true);
$ins_info = $jsondata['ins_info'] ? $jsondata['ins_info'] : [];
if($insurance_img['img']){
@@ -311,10 +312,31 @@ class Order_datas_entity{
}
}
}
if($accident_img['img']){
$url = build_qiniu_image_url($accident_img['img']);
$ins_key = md5($url);
if(!$ins_info[$ins_key]){
$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;
$accident_img['price'] = floatval($result['data']['premium']);
$accident_img['date'] = $result['data']['policyStartDate'];
$accident_img['product'] = $result['data']['companyName'];
}else{
$ins_info[$ins_key]['msg'] = $result['msg'];
$ins_info[$ins_key]['img_url'] = $url;
return false;
}
}
}
$update = [
'jsondata' => json_encode($jsondata,JSON_UNESCAPED_UNICODE),
'insurance_img' => json_encode($insurance_img,JSON_UNESCAPED_UNICODE),
'business_img' => json_encode($business_img,JSON_UNESCAPED_UNICODE),
'accident_img' => json_encode($accident_img,JSON_UNESCAPED_UNICODE),
];
$res = $this->ci->receiver_order_datas_model->update($update,['id'=>$row['id']]);