202 lines
8.0 KiB
PHP
202 lines
8.0 KiB
PHP
<?php
|
|
/**
|
|
* Created by PhpStorm.
|
|
* User: lcc
|
|
* Date: 2022/1/18
|
|
* Time: 17:13
|
|
*/
|
|
require_once APPPATH.'controllers/wxapp/Wxapp.php';
|
|
class Cusorderdata extends Wxapp{
|
|
|
|
function __construct($inputs, $app_key){
|
|
parent::__construct($inputs, $app_key);
|
|
|
|
$this->login_white = array();//登录白名单
|
|
$this->check_status = array();//用户状态校验
|
|
$this->check_mobile = array();//需要手机号
|
|
$this->check_headimg =array();//授权微信信息
|
|
|
|
$this->load->model('receiver/order/receiver_orders_v2_model','orders_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/orders_status_entity');
|
|
$this->load->library('TcOrc');
|
|
}
|
|
|
|
protected function get(){
|
|
$id = $this->input_param('id');
|
|
//$row = $this->receiver_order_status_model->get(['o_id'=>$id,'status'=>1,'pid_status'=>0]);
|
|
$is_pay = $this->app_liche_orders_model->count(['o_id'=>$id,'status'=>1]);
|
|
$data = [];
|
|
if($is_pay){
|
|
$data['img_status'] = 1;
|
|
$row_data = $this->receiver_order_datas_model->get(['o_id'=>$id]);
|
|
$cardidb = $cardida = $business_licence = $register_img = $car_img = [];
|
|
if($row_data['car_img']){
|
|
$car_img = [
|
|
'value' => $row_data['car_img'],
|
|
'img' => build_qiniu_image_url($row_data['car_img'])
|
|
];
|
|
}
|
|
if($row_data['register_img']){
|
|
$register_img = [
|
|
'value' => $row_data['register_img'],
|
|
'img' => build_qiniu_image_url($row_data['register_img'])
|
|
];
|
|
}
|
|
$data['imgs'] = [
|
|
'cardida' => [],
|
|
'cardidb' => [],
|
|
'business_licence' => [],
|
|
'car_img' => $car_img,
|
|
'register_img' => $register_img,
|
|
'ins_img' => [],
|
|
'other_img' => []
|
|
];
|
|
|
|
if($row['main_type']){
|
|
if($row_data['business_licence']){
|
|
$business_licence = [
|
|
'value' => $row_data['business_licence'],
|
|
'img' => build_qiniu_image_url($row_data['business_licence'])
|
|
];
|
|
}
|
|
$data['imgs']['business_licence'] = $business_licence;
|
|
}else{
|
|
if($row_data['cardida']){
|
|
$cardida = [
|
|
'value' => $row_data['cardida'],
|
|
'img' => build_qiniu_image_url($row_data['cardida'])
|
|
];
|
|
}
|
|
if($row_data['cardidb']){
|
|
$cardidb = [
|
|
'value' => $row_data['cardidb'],
|
|
'img' => build_qiniu_image_url($row_data['cardidb'])
|
|
];
|
|
}
|
|
$data['imgs']['cardida'] = $cardida;
|
|
$data['imgs']['cardidb'] = $cardidb;
|
|
}
|
|
if($row_data['ins_img']){
|
|
$ins_img = json_decode($row_data['ins_img'],true);
|
|
$imgs = [];
|
|
foreach ($ins_img as $item) {
|
|
$imgs[] = [
|
|
'value' => $item,
|
|
'img' => build_qiniu_image_url($item)
|
|
];
|
|
}
|
|
$data['imgs']['ins_img'] = $imgs;
|
|
}
|
|
if($row_data['other_img']){
|
|
$other_img = json_decode($row_data['other_img'],true);
|
|
$imgs = [];
|
|
foreach ($other_img as $item) {
|
|
$imgs[] = [
|
|
'value' => $item,
|
|
'img' => build_qiniu_image_url($item)
|
|
];
|
|
}
|
|
$data['imgs']['other_img'] = $imgs;
|
|
}
|
|
if($row_data['bill_img']){ //开票
|
|
$imgs = [];
|
|
$data['imgs']['bill_img'] = $imgs;
|
|
}
|
|
}else{
|
|
$data['img_status'] = 0;
|
|
|
|
}
|
|
return $data;
|
|
}
|
|
|
|
protected function put(){
|
|
$id = $this->input_param('id');
|
|
$row = $this->orders_model->get(['id'=>$id]);
|
|
if(!$row){
|
|
throw new Exception('参数错误', ERR_PARAMS_ERROR);
|
|
}
|
|
$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');
|
|
$cardidb = $this->input_param('cardidb');
|
|
$car_img = $this->input_param('car_img');
|
|
$register_img = $this->input_param('register_img');
|
|
$business_licence = $this->input_param('business_licence');
|
|
$ins_imgs = $this->input_param('ins_imgs');
|
|
$other_imgs = $this->input_param('other_imgs');
|
|
$update = [];
|
|
if($cardida){
|
|
$full_cardida = build_qiniu_image_url($cardida);
|
|
$result = $this->tcorc->IdentityCard($full_cardida);
|
|
if(!$result['code']){
|
|
$res_data['code'] = API_CODE_ORC_FAIL;
|
|
$res_data['data'] = [
|
|
['caridA' => false,'errmsg'=>$result['msg']],
|
|
['caridB' => true,'errmsg'=>''],
|
|
];
|
|
return $res_data;
|
|
}
|
|
$userinfo = $result['data'];
|
|
|
|
//校验订单客户和身份证姓名
|
|
if($userinfo['Name'] != $row['owner_name']){
|
|
$res_data['code'] = API_CODE_ORC_FAIL;
|
|
$res_data['data'] = [
|
|
['caridA' => false,'errmsg'=>'身份证姓名与客户不一致'],
|
|
['caridB' => true,'errmsg'=>''],
|
|
];
|
|
return $res_data;
|
|
}
|
|
$update['cardida'] = $cardida;
|
|
}elseif ($business_licence){
|
|
$full_business_licence = build_qiniu_image_url($business_licence);
|
|
$result = $this->tcorc->BizLicense($full_business_licence);
|
|
if(!$result['code']){
|
|
$res_data['code'] = API_CODE_ORC_FAIL;
|
|
$res_data['data'] = [
|
|
['business_licence' => false,'errmsg'=>$result['msg']],
|
|
];
|
|
return $res_data;
|
|
}
|
|
$update['business_licence'] = $business_licence;
|
|
}elseif($ins_imgs || $other_imgs){
|
|
$file_name = $ins_imgs ? 'ins_img' : 'other_img';
|
|
$imgs = $ins_imgs ? $ins_imgs : $other_imgs;
|
|
$update[$file_name] = json_encode($imgs,JSON_UNESCAPED_UNICODE);
|
|
}else{
|
|
if($cardidb){
|
|
$key = 'cardidb';
|
|
$img = $cardidb;
|
|
}
|
|
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';
|
|
$img = $register_img;
|
|
}
|
|
$key && $update[$key] = $img;
|
|
}
|
|
$res = $this->receiver_order_datas_model->update($update,['o_id'=>$id]);
|
|
if($res){
|
|
throw new Exception('修改成功', API_CODE_SUCCESS);
|
|
}else{
|
|
throw new Exception('修改失败', ERR_PARAMS_ERROR);
|
|
}
|
|
}
|
|
}
|