From 7e3d329a9a61cef4075794f78afa68070c9aff81 Mon Sep 17 00:00:00 2001 From: lccsw <805383944@qq.com> Date: Tue, 7 Feb 2023 17:41:15 +0800 Subject: [PATCH] add-api-accident_ins --- api/controllers/wxapp/licheb/Cusorderdata.php | 29 ++++++++++++++++--- .../libraries/receiver/Order_datas_entity.php | 22 ++++++++++++++ 2 files changed, 47 insertions(+), 4 deletions(-) diff --git a/api/controllers/wxapp/licheb/Cusorderdata.php b/api/controllers/wxapp/licheb/Cusorderdata.php index 06dbf2a2..e859bb6f 100644 --- a/api/controllers/wxapp/licheb/Cusorderdata.php +++ b/api/controllers/wxapp/licheb/Cusorderdata.php @@ -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); diff --git a/common/libraries/receiver/Order_datas_entity.php b/common/libraries/receiver/Order_datas_entity.php index e618657a..96c32810 100644 --- a/common/libraries/receiver/Order_datas_entity.php +++ b/common/libraries/receiver/Order_datas_entity.php @@ -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']]);