251 lines
11 KiB
PHP
251 lines
11 KiB
PHP
<?php
|
|
/**
|
|
* Created by PhpStorm.
|
|
* User: lcc
|
|
* Date: 2022/1/10
|
|
* Time: 16:11
|
|
*/
|
|
class Order_datas_entity{
|
|
|
|
private $ci;
|
|
const COLOR_UN_UPLOAD = '#f9394d'; //未传
|
|
const COLOR_IS_UPLOAD = '#fd9737'; //已传
|
|
const COLOR_UN_CHECK = '#f9394d'; //未通过
|
|
const COLOR_CHECK = '#36afa2'; //通过
|
|
|
|
|
|
public function __construct(){
|
|
$this->ci = & get_instance();
|
|
$this->ci->load->model('receiver/order/receiver_order_datas_model');
|
|
$this->ci->load->model('receiver/order/receiver_order_agents_model');
|
|
$this->ci->load->model('app/app_checkdata_model');
|
|
$this->ci->load->library('TcOrc');
|
|
$this->ci->load->library('qiniuorc');
|
|
}
|
|
|
|
public function data_status($o_data){
|
|
$result = [
|
|
'cardida' => ['text'=>'未传','type'=>1,'color'=>self::COLOR_UN_UPLOAD], //身份证
|
|
'business_licence' => ['text'=>'未传','type'=>1,'color'=>self::COLOR_UN_UPLOAD], //营业执照
|
|
'register_img' => ['text'=>'未传','type'=>2,'color'=>self::COLOR_UN_UPLOAD], //登记证
|
|
'car_img' => ['text'=>'未传','type'=>3,'color'=>self::COLOR_UN_UPLOAD], //行驶证
|
|
'ins_img' => ['text'=>'未传','type'=>4,'color'=>self::COLOR_UN_UPLOAD], //保单证
|
|
'other_img' => ['text'=>'未传','type'=>5,'color'=>self::COLOR_UN_UPLOAD], //交车合照
|
|
];
|
|
// $where = ['cf_id'=>$o_data['id'],'app_id'=>2,'type in (1,2,3,4,5)'=>null,'datatype'=>'img'];
|
|
// $check_data = $this->ci->app_checkdata_model->map('type','',$where,'','','','id,cf_id,type,ifcheck');
|
|
foreach ($result as $key=>$item) {
|
|
if($o_data[$key]){
|
|
$result[$key]['text'] = '已传';
|
|
$result[$key]['color'] = self::COLOR_IS_UPLOAD;
|
|
// if($check_data[$item['type']][0]['ifcheck']==1){
|
|
// $result[$key]['text'] = '已通过';
|
|
// $result[$key]['color'] = self::COLOR_CHECK;
|
|
// }
|
|
// if($check_data[$item['type']][0]['ifcheck']==-1){
|
|
// $result[$key]['text'] = '未通过';
|
|
// $result[$key]['color'] = self::COLOR_UN_CHECK;
|
|
// }
|
|
}
|
|
}
|
|
return $result;
|
|
}
|
|
|
|
//获取图片审核状态
|
|
public function data_ckinfo($o_data,$main_type=0){
|
|
if($main_type){
|
|
$result = [
|
|
'business_licence' => ['text'=>'营业执照','type'=>1,'up_status'=>0,'status'=>0,'status_cn'=>'未审核','imgs' => []], //公司营业执照
|
|
'register_img' => ['text'=>'登记证','type'=>2,'up_status'=>0,'status'=>0,'status_cn'=>'未审核','imgs' => []], //登记证
|
|
'car_img' => ['text'=>'行驶证','type'=>3,'up_status'=>0,'status'=>0,'status_cn'=>'未审核','imgs'=>[]], //行驶证
|
|
'ins_img' => ['text'=>'保单证','type'=>4,'up_status'=>0,'status'=>0,'status_cn'=>'未审核','imgs'=>[]], //保单证
|
|
'other_img' => ['text'=>'交车合照','type'=>5,'up_status'=>0,'status'=>0,'status_cn'=>'未审核','imgs'=>[]], //交车合照
|
|
];
|
|
}else{
|
|
$result = [
|
|
'cardida' => ['text'=>'身份证正面','type'=>1,'up_status'=>0,'status'=>0,'status_cn'=>'未审核','imgs' => []], //身份证
|
|
'register_img' => ['text'=>'登记证','type'=>2,'up_status'=>0,'status'=>0,'status_cn'=>'未审核','imgs' => []], //登记证
|
|
'car_img' => ['text'=>'行驶证','type'=>3,'up_status'=>0,'status'=>0,'status_cn'=>'未审核','imgs'=>[]], //行驶证
|
|
'ins_img' => ['text'=>'保单证','type'=>4,'up_status'=>0,'status'=>0,'status_cn'=>'未审核','imgs'=>[]], //保单证
|
|
'other_img' => ['text'=>'交车合照','type'=>5,'up_status'=>0,'status'=>0,'status_cn'=>'未审核','imgs'=>[]], //交车合照
|
|
];
|
|
}
|
|
$where = [
|
|
'cf_id'=>$o_data['id'],
|
|
'app_id'=>2,
|
|
'type in (1,2,3,4,5)'=>null,
|
|
'datatype'=>'img'
|
|
];
|
|
$check_data = $this->ci->app_checkdata_model->map('type','',$where,'','','','id,cf_id,type,ifcheck');
|
|
foreach ($result as $key=>$item) {
|
|
$result[$key]['up_status'] = 1;
|
|
$ifcheck = $check_data[$item['type']][0]['ifcheck'];
|
|
$imgs = [];
|
|
if($key=='ins_img'||$key=='other_img'){
|
|
$img_data = json_decode($o_data[$key],true);
|
|
if(is_array($img_data)){
|
|
foreach ($img_data as $v) {
|
|
$imgs[] = build_qiniu_image_url($v);
|
|
}
|
|
}
|
|
}else{
|
|
$o_data[$key] && $imgs[] = build_qiniu_image_url($o_data[$key]);
|
|
if($key=='cardida' && $o_data['cardidb']){
|
|
$imgs[1] = build_qiniu_image_url($o_data['cardidb']);
|
|
}
|
|
}
|
|
$result[$key]['imgs'] = $imgs;
|
|
if($ifcheck==1){
|
|
$result[$key]['status_cn'] = '已通过';
|
|
$result[$key]['status'] = 1;
|
|
}elseif($ifcheck==-1){
|
|
$result[$key]['status_cn'] = '未通过';
|
|
$result[$key]['status'] = -1;
|
|
}else{
|
|
$result[$key]['status_cn'] = '未审核';
|
|
$result[$key]['status'] = 0;
|
|
}
|
|
}
|
|
return $result;
|
|
}
|
|
|
|
/**
|
|
* 更新数据
|
|
* @param $oid
|
|
* @param $data
|
|
* @return void
|
|
*/
|
|
public function up_data($oid,$data){
|
|
if(!$data){
|
|
return false;
|
|
}
|
|
$row = $this->ci->receiver_order_datas_model->get(['o_id'=>$oid]);
|
|
if(!$row){
|
|
$this->ci->receiver_order_datas_model->add(['o_id'=>$oid,'c_time'=>time()]);
|
|
}
|
|
$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']);
|
|
$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;
|
|
}
|
|
|
|
/**
|
|
* 识别保单图片
|
|
* @param $oid
|
|
* @return false
|
|
*/
|
|
public function orc_ins_img($oid){
|
|
$row = $this->ci->receiver_order_datas_model->get(['o_id'=>$oid]);
|
|
$ins_img = json_decode($row['ins_img'],true);
|
|
$jsondata = json_decode($row['jsondata'],true);
|
|
$ins_info = $jsondata['ins_info'] ? $jsondata['ins_info'] : [];
|
|
if($ins_img){
|
|
$img_keys = [];
|
|
foreach ($ins_img as $key=>$value) {
|
|
$value && $url = build_qiniu_image_url($value);
|
|
$url && $img_keys[] = md5($url);
|
|
$ins_key = md5($url);
|
|
if($url && !$ins_info[$ins_key]){
|
|
$result = $this->ci->qiniuorc->car_insure($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;
|
|
}else{
|
|
$ins_info[$ins_key]['msg'] = $result['msg'];
|
|
$ins_info[$ins_key]['img_url'] = $url;
|
|
}
|
|
}
|
|
}
|
|
$ins_time = $company = '';
|
|
$ins_risk = $business_risk = 0;
|
|
foreach ($ins_info as $key=>$value) {
|
|
if(!in_array($key,$img_keys)){
|
|
unset($ins_info[$key]);
|
|
}else{
|
|
$money = floatval($value['data']['合计保费']);
|
|
if($money==950){
|
|
$ins_risk = $money;
|
|
}else{
|
|
$company = $value['data']['保险公司'];
|
|
$ins_time = date('Y-m-d',strtotime($value['data']['投保确认时间'])+365*12*24*60*60);
|
|
$business_risk += $money;
|
|
}
|
|
}
|
|
}
|
|
$agent = $this->ci->receiver_order_agents_model->get(['o_id'=>$oid]);
|
|
$agent_jsondata = $agent ? json_decode($agent['jsondata'],true) : [];
|
|
$company && $agent_jsondata['company'] = $company;
|
|
$ins_risk && $agent_jsondata['ins_risk'] = $ins_risk;
|
|
$business_risk && $agent_jsondata['business_risk'] = $business_risk;
|
|
if(!$agent){
|
|
$add = [
|
|
'o_id' => $oid,
|
|
'jsondata' => json_encode($agent_jsondata,JSON_UNESCAPED_UNICODE),
|
|
'c_time' => time(),
|
|
];
|
|
$ins_time && $add['ins_time'] = $ins_time;
|
|
$this->ci->receiver_order_agents_model->add($add);
|
|
}else{
|
|
$update['jsondata'] = json_encode($agent_jsondata,JSON_UNESCAPED_UNICODE);
|
|
$ins_time && $update['ins_time'] = $ins_time;
|
|
$this->ci->receiver_order_agents_model->update($update,['id'=>$agent['id']]);
|
|
}
|
|
}
|
|
$jsondata['ins_info'] = $ins_info;
|
|
$update = [
|
|
'jsondata' => json_encode($jsondata,JSON_UNESCAPED_UNICODE)
|
|
];
|
|
$res = $this->ci->receiver_order_datas_model->update($update,['id'=>$row['id']]);
|
|
return $res;
|
|
}
|
|
|
|
/**
|
|
* 更新车牌号
|
|
* @return void
|
|
*/
|
|
public function up_car_num($oid){
|
|
$row = $this->ci->receiver_order_datas_model->get(['o_id'=>$oid]);
|
|
$jsondata = json_decode($row['jsondata'],true);
|
|
$car_num = $jsondata['car_info']['PlateNo'];
|
|
$res = false;
|
|
if($car_num){
|
|
$agent = $this->ci->receiver_order_agents_model->get(['o_id'=>$oid]);
|
|
if(!$agent){
|
|
$add = [
|
|
'o_id' => $oid,
|
|
'car_num' => $car_num,
|
|
'c_time' => time(),
|
|
];
|
|
$res = $this->ci->receiver_order_agents_model->add($add);
|
|
}else{
|
|
$update['car_num'] = $car_num;
|
|
$res = $this->ci->receiver_order_agents_model->update($update,['id'=>$agent['id']]);
|
|
}
|
|
}
|
|
return $res;
|
|
}
|
|
}
|