178 lines
6.8 KiB
PHP
178 lines
6.8 KiB
PHP
<?php
|
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
|
|
|
class Toole extends CI_Controller {
|
|
|
|
public function __construct(){
|
|
parent::__construct();
|
|
$this->load->model('receiver/order/receiver_orders_model','orders_model');
|
|
$this->load->model('receiver/order/receiver_order_signs_model','order_signs_model');
|
|
$this->load->model('receiver/order/receiver_order_loans_model','order_loans_model');
|
|
$this->load->model('receiver/order/receiver_order_ckcars_model','order_ckcars_model');
|
|
$this->load->model('receiver/order/receiver_order_bills_model','order_bills_model');
|
|
$this->load->model('receiver/order/receiver_order_agents_model','order_agents_model');
|
|
$this->load->model('receiver/order/receiver_order_deliverys_model','order_deliverys_model');
|
|
$this->load->model('receiver/order/receiver_order_contracts_model','order_contracts_model');
|
|
}
|
|
|
|
public function index(){
|
|
$data['mobile'] = $mobile = $this->input->get('mobile');
|
|
if($mobile){
|
|
$data['status_name'] = $this->orders_model->get_status();
|
|
$data['lists'] = $this->orders_model->select(['mobile'=>$mobile],'id desc',0,0,'id,name,mobile,status');
|
|
}
|
|
$this->load->view('/h5/toole/index',$data);
|
|
}
|
|
public function detail(){
|
|
$id = $this->input->get('id');
|
|
$row = $this->orders_model->get(['id'=>$id]);
|
|
if($row['status']>=2){
|
|
$ckcar = $this->order_ckcars_model->get(['o_id'=>$id],'status');
|
|
$row['ckcar_status'] = $ckcar['status'];
|
|
}
|
|
if($row['status']>=3){
|
|
$bill = $this->order_bills_model->get(['o_id'=>$id],'status');
|
|
$row['bill_status'] = $bill['status'];
|
|
}
|
|
if($row['status']>=4){
|
|
$agent = $this->order_agents_model->get(['o_id'=>$id],'status');
|
|
$row['agent_status'] = $agent['status'];
|
|
}
|
|
$data['row'] = $row;
|
|
$this->load->view('/h5/toole/detail',$data);
|
|
}
|
|
|
|
//一键完成分期
|
|
public function fh_loan(){
|
|
$id = $this->input->post('id');
|
|
$row = $this->orders_model->get(['id'=>$id]);
|
|
if(!$row){
|
|
$this->show_json(0,'参数错误');
|
|
}
|
|
if($row['status']!=1){
|
|
$this->show_json(0,'该订单未到分期状态');
|
|
}
|
|
$result = $this->order_loans_model->update(['status'=>1],['o_id'=>$row['id']]);
|
|
if($result){
|
|
$this->orders_model->update(['status'=>2],['id'=>$row['id']]);
|
|
$ckcar = $this->order_ckcars_model->get(['o_id'=>$row['id']]);
|
|
$replace = [
|
|
'o_id' => $row['id'],
|
|
'status' => 0,
|
|
'c_time' => time()
|
|
];
|
|
$ckcar && $replace['id'] = $ckcar['id'];
|
|
$this->order_ckcars_model->replace($replace);
|
|
$this->show_json(1,'修改成功');
|
|
}else{
|
|
$this->show_json(0,'修改失败');
|
|
}
|
|
}
|
|
//一键完成配车
|
|
public function fh_ckcar(){
|
|
$this->load->model("items/items_model");
|
|
$id = $this->input->post('id');
|
|
$row = $this->orders_model->get(['id'=>$id]);
|
|
if(!$row){
|
|
$this->show_json(0,'参数错误');
|
|
}
|
|
if($row['status']>=3){
|
|
$this->show_json(0,'用户确认,不能修改');
|
|
}
|
|
$where = [
|
|
's_id' => $row['s_id'],
|
|
'v_id' => $row['v_id'],
|
|
'cor_id' => $row['cor_id'],
|
|
'incor_id' => $row['incor_id'],
|
|
];
|
|
$item = $this->items_model->get($where);
|
|
if(!$item){
|
|
unset($where['incor_id']);
|
|
$item = $this->items_model->get($where);
|
|
if(!$item){
|
|
unset($where['cor_id']);
|
|
$item = $this->items_model->get($where);
|
|
if(!$item){
|
|
unset($where['v_id']);
|
|
$item = $this->items_model->get($where);
|
|
}
|
|
}
|
|
}
|
|
if(!$item){
|
|
$this->show_json(0,'未找到车辆信息');
|
|
}
|
|
$item_id = $item['id'];
|
|
$this->orders_model->update(['item_id'=>$item_id],['id'=>$id]);
|
|
$ckcars = $this->order_ckcars_model->get(['o_id'=>$id]);
|
|
if(!$ckcars){
|
|
$add_data = [
|
|
'o_id' => $id,
|
|
'status' => 1,
|
|
'c_time' => time()
|
|
];
|
|
$result = $this->order_ckcars_model->add($add_data);
|
|
}else{
|
|
$result = $this->order_ckcars_model->update(['status'=>1],['id'=>$ckcars['id']]);
|
|
}
|
|
if($result){
|
|
$this->show_json(1,'修改成功');
|
|
}else{
|
|
$this->show_json(0,'修改失败');
|
|
}
|
|
}
|
|
//一键完成开票信息
|
|
public function fh_bill(){
|
|
$id = $this->input->post('id');
|
|
$row = $this->orders_model->get(['id'=>$id]);
|
|
if(!$row){
|
|
$this->show_json(0,'参数错误');
|
|
}
|
|
if($row['status']!=3){
|
|
$this->show_json(0,'修改失败,该订单不处于开票阶段');
|
|
}
|
|
$result = $this->order_bills_model->update(['status'=>2,'file'=>'liche/2021/08/1337ff6686152d45/f30b803379255919.jpeg'],['o_id'=>$id]);
|
|
$this->orders_model->update(['status'=>4],['id'=>$row['id']]);
|
|
if(!$this->order_agents_model->get(['o_id'=>$id])){
|
|
$this->order_agents_model->add(['o_id'=>$id,'c_time'=>time]);
|
|
}
|
|
$this->show_json(1,'修改成功');
|
|
|
|
}
|
|
//一键完成代办信息
|
|
public function fh_agent(){
|
|
$id = $this->input->post('id');
|
|
$row = $this->orders_model->get(['id'=>$id]);
|
|
if(!$row){
|
|
$this->show_json(0,'参数错误');
|
|
}
|
|
if($row['status']!=4){
|
|
$this->show_json(0,'修改失败,该订单不处于代办阶段');
|
|
}
|
|
$agent = $this->order_agents_model->get(['o_id'=>$id]);
|
|
$up_data = [
|
|
'car_num' => '闽DXXXXXX',
|
|
'car_img' => 'liche/2021/08/4e3bbf015016a9be/6ae15d0a363cc527.jpeg',
|
|
'ins_img' => json_encode(['liche/2021/08/538fbf6c419d5958/5e4b8a5af1fbd4b6.jpeg']),
|
|
'ins_time' => '2022-12-12',
|
|
'status' => 1,
|
|
];
|
|
if($agent){
|
|
$this->order_agents_model->update($up_data,['o_id'=>$id]);
|
|
}else{
|
|
$up_data['o_id'] = $row['id'];
|
|
$up_data['c_time'] = time();
|
|
$this->order_agents_model->add($add_data);
|
|
}
|
|
$this->orders_model->update(['status'=>5],['id'=>$id]);
|
|
if(!$this->order_deliverys_model->count(['o_id'=>$id])){
|
|
$this->order_deliverys_model->add(['o_id'=>$id,'c_time'=>time]);
|
|
}
|
|
$this->show_json(1,'修改成功');
|
|
}
|
|
private function show_json($code,$msg){
|
|
$data['code'] = $code;
|
|
$data['msg'] = $msg;
|
|
die(json_encode($data,JSON_UNESCAPED_UNICODE));
|
|
}
|
|
}
|