315 lines
12 KiB
PHP
315 lines
12 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_model', 'orders_model');
|
|
$this->load->model('receiver/order/receiver_order_datas_model');
|
|
|
|
$this->load->library('receiver/order_datas_entity');
|
|
$this->load->library('TcOrc');
|
|
}
|
|
|
|
protected function get()
|
|
{
|
|
$id = $this->input_param('id');
|
|
$row = $this->orders_model->get(['id' => $id]);
|
|
$data = [];
|
|
$data['img_status'] = 1;
|
|
$row_data = $this->receiver_order_datas_model->get(['o_id' => $id]);
|
|
$cardidb = $cardida = $business_licence = $car_img = [];
|
|
if ($row_data['car_img']) {
|
|
$car_img = [
|
|
'value' => $row_data['car_img'],
|
|
'img' => build_qiniu_image_url($row_data['car_img'])
|
|
];
|
|
}
|
|
$bill_img = $car_auth_img = $equity_ck_img = $pay_img = $contract_img = $accident_img = $destory_img = $mut_wx_img = $wx_img = $delivery_ck_img = $bill_ck_img = $business_img = $insurance_img = [];
|
|
if ($row_data['insurance_img']) {
|
|
$insurance_img = [
|
|
'value' => $row_data['insurance_img'],
|
|
'img' => build_qiniu_image_url($row_data['insurance_img']),
|
|
];
|
|
}
|
|
if ($row_data['business_img']) {
|
|
$business_img = [
|
|
'value' => $row_data['business_img'],
|
|
'img' => build_qiniu_image_url($row_data['business_img']),
|
|
];
|
|
}
|
|
if ($row_data['delivery_ck_img']) {
|
|
$delivery_ck_img = [
|
|
'value' => $row_data['delivery_ck_img'],
|
|
'img' => build_qiniu_image_url($row_data['delivery_ck_img'])
|
|
];
|
|
}
|
|
if ($row_data['pay_img']) {
|
|
$pay_img = [
|
|
'value' => $row_data['pay_img'],
|
|
'img' => build_qiniu_image_url($row_data['pay_img'])
|
|
];
|
|
}
|
|
if ($row_data['equity_ck_img']) {
|
|
$equity_ck_img = [
|
|
'value' => $row_data['equity_ck_img'],
|
|
'img' => build_qiniu_image_url($row_data['equity_ck_img'])
|
|
];
|
|
}
|
|
if ($row_data['car_auth_img']) {
|
|
$car_auth_img = [
|
|
'value' => $row_data['car_auth_img'],
|
|
'img' => build_qiniu_image_url($row_data['car_auth_img'])
|
|
];
|
|
}
|
|
if ($row_data['bill_img']) {
|
|
$bill_img = [
|
|
'value' => $row_data['bill_img'],
|
|
'img' => build_qiniu_image_url($row_data['bill_img'])
|
|
];
|
|
}
|
|
if ($row_data['contract_img']) {
|
|
$contract_img_arr = explode(',', $row_data['contract_img']);
|
|
foreach ($contract_img_arr as $value) {
|
|
$contract_img[] = [
|
|
'value' => $value,
|
|
'img' => build_qiniu_image_url($value)
|
|
];
|
|
}
|
|
}
|
|
$imgs = [
|
|
'cardida' => [],
|
|
'cardidb' => [],
|
|
'business_licence' => [],
|
|
'car_img' => $car_img,
|
|
'ins_img' => [],
|
|
'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,
|
|
'destory_img' => $destory_img,
|
|
'pay_img' => $pay_img,
|
|
'contract_img' => $contract_img,
|
|
'equity_ck_img' => $equity_ck_img,
|
|
'bill_img' => $bill_img,
|
|
'car_auth_img' => $car_auth_img,
|
|
'delivery_ck_img' => $delivery_ck_img
|
|
];
|
|
$data['imgs'] = $imgs;
|
|
|
|
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;
|
|
}
|
|
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');
|
|
|
|
$business_licence = $this->input_param('business_licence');
|
|
$insurance_img = $this->input_param('insurance_img');
|
|
$business_img = $this->input_param('business_img');
|
|
$delivery_ck_img = $this->input_param('delivery_ck_img');
|
|
$contract_img = $this->input_param('contract_img');
|
|
$pay_img = $this->input_param('pay_img');
|
|
$equity_ck_img = $this->input_param('equity_ck_img');
|
|
$car_auth_img = $this->input_param('car_auth_img');
|
|
$bill_img = $this->input_param('bill_img');
|
|
$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['name']) {
|
|
$res_data['code'] = API_CODE_ORC_FAIL;
|
|
$res_data['data'] = [
|
|
['caridA' => false, 'errmsg' => '身份证姓名与客户不一致'],
|
|
['caridB' => true, 'errmsg' => ''],
|
|
];
|
|
return $res_data;
|
|
}
|
|
//个人核对身份证
|
|
if ($userinfo['IdNum'] != $row['card_id']) {
|
|
$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 ($insurance_img) {
|
|
$update['insurance_img'] = $insurance_img;
|
|
} elseif ($business_img) {
|
|
$update['business_img'] = $business_img;
|
|
} 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 ($delivery_ck_img) {
|
|
$key = 'delivery_ck_img';
|
|
$img = $delivery_ck_img;
|
|
}
|
|
if ($contract_img) {
|
|
$key = 'contract_img';
|
|
$img = $contract_img;
|
|
}
|
|
if ($pay_img) {
|
|
$key = 'pay_img';
|
|
$img = $pay_img;
|
|
}
|
|
if ($equity_ck_img) {
|
|
$key = 'equity_ck_img';
|
|
$img = $equity_ck_img;
|
|
}
|
|
if ($car_auth_img) {
|
|
$key = 'car_auth_img';
|
|
$img = $car_auth_img;
|
|
}
|
|
if ($bill_img) {
|
|
$key = 'bill_img';
|
|
$img = $bill_img;
|
|
//发票识别
|
|
$result = $this->order_datas_entity->orc_bill_img($id, build_qiniu_image_url($bill_img));
|
|
if (!$result['code']) {
|
|
throw new Exception($result['msg'], ERR_PARAMS_ERROR);
|
|
}
|
|
$jsondata['bill_info'] = $result['data'];
|
|
$update['jsondata'] = json_encode($jsondata, JSON_UNESCAPED_UNICODE);
|
|
}
|
|
$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);
|
|
}
|
|
}
|
|
|
|
public function put_info()
|
|
{
|
|
$id = $this->input_param('id');
|
|
$type = $this->input_param('type');
|
|
$product = $this->input_param('product');
|
|
$price = $this->input_param('price');
|
|
$date = $this->input_param('date');
|
|
$rebate = $this->input_param('rebate');//保险返点
|
|
$data_row = $this->receiver_order_datas_model->get(['o_id' => $id]);
|
|
if (!$data_row) {
|
|
throw new Exception('数据不存在', ERR_PARAMS_ERROR);
|
|
}
|
|
!$rebate && $rebate = 0;
|
|
if ($type == 1) { //交强险图片
|
|
$jsondata = json_decode($data_row['insurance_img'], true);
|
|
$jsondata['product'] = $product;
|
|
$jsondata['price'] = $price;
|
|
$jsondata['rebate'] = $rebate;
|
|
$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['rebate'] = $rebate;
|
|
$jsondata['date'] = $date;
|
|
$update['accident_img'] = json_encode($jsondata, JSON_UNESCAPED_UNICODE);
|
|
} else { //商业险图片
|
|
if ($price < 1000) {
|
|
throw new Exception('金额有误,请重新填写', ERR_PARAMS_ERROR);
|
|
}
|
|
$jsondata = json_decode($data_row['business_img'], true);
|
|
$jsondata['product'] = $product;
|
|
$jsondata['price'] = $price;
|
|
$jsondata['rebate'] = $rebate;
|
|
$jsondata['date'] = $date;
|
|
$update['business_img'] = json_encode($jsondata, JSON_UNESCAPED_UNICODE);
|
|
}
|
|
$this->receiver_order_datas_model->update($update, ['id' => $data_row['id']]);
|
|
throw new Exception('修改成功', API_CODE_SUCCESS);
|
|
}
|
|
}
|