Files
liche/api/controllers/wxapp/licheb/Protocol.php
T
2021-07-22 15:46:18 +08:00

105 lines
4.8 KiB
PHP

<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Created by Vim
* User: lcc
* Date: 2021/07/07
* Time: 14:08
*/
class Protocol extends CI_Controller{
public function __construct($inputs, $app_key){
parent::__construct($inputs, $app_key);
$this->load->model('receiver/order/receiver_orders_model','orders_model');
$this->load->model('receiver/order/receiver_order_contracts_model','contracts_model');
$this->load->model('auto/auto_series_model');
$this->load->model('auto/auto_brand_model');
$this->load->model("items/items_model");
}
//整车合同
public function car(){
$wxapp = $this->input->get('wxapp');
$id = $this->input->get('id');
$row = $this->orders_model->get(['id'=>$id]);
$contract = $this->contracts_model->get(['o_id'=>$id,'type'=>0]);
if($row){
$brand = $this->auto_brand_model->get(['id'=>$row['brand_id']],'name');
$series = $this->auto_series_model->get(['id'=>$row['s_id']],'name');
$car_json = json_decode($row['car_json'],true);
$color = isset($car_json['color']) ? $car_json['color']['title'] : '';
$version = isset($car_json['version']) ? $car_json['version']['title'] : '';
$row['brand_name'] = $brand['name'].$series['name'].' '.$version;
$row['color'] = $color;
}
$row['day'] = $contract ? date('Y年m月d日',$contract['c_time']):date('Y年m月d日');
$row['price_rmb'] = num_to_rmb($row['price']);
$row['cid'] = $contract['cid'];
$folder = $wxapp ? 'protocol' : 'html2pdf';
$this->load->view("wxapp/licheb/{$folder}/car",$row);
}
//代理合同
public function agent(){
$wxapp = $this->input->get('wxapp');
$id = $this->input->get('id');
$row = $this->orders_model->get(['id'=>$id]);
$contract = $this->contracts_model->get(['o_id'=>$id,'type'=>1]);
$row['day'] = $contract ? date('Y年m月d日',$contract['c_time']):date('Y年m月d日');
$row['cid'] = $contract['cid'];
$folder = $wxapp ? 'protocol' : 'html2pdf';
$this->load->view("wxapp/licheb/{$folder}/agent",$row);
}
//车辆信息确认单
public function car_ck(){
$wxapp = $this->input->get('wxapp');
$this->load->model('receiver/order/receiver_order_ckcars_model','ckcars_model');
$id = $this->input->get('id');
$row = $this->orders_model->get(['id'=>$id]);
if($row){
$brand = $this->auto_brand_model->get(['id'=>$row['brand_id']],'name');
$series = $this->auto_series_model->get(['id'=>$row['s_id']],'name');
$car_json = json_decode($row['car_json'],true);
$version = isset($car_json['version']) ? $car_json['version']['title'] : '';
$row['brand_name'] = $brand['name'].$series['name'].' '.$version;
}
$contract = $this->contracts_model->get(['o_id'=>$id,'type'=>2]);
$items = $this->items_model->get(['id'=>$row['item_id']],'vin');
$row['day'] = $contract ? date('Y年m月d日',$contract['c_time']):date('Y年m月d日');
$row['cid'] = $contract['cid'];
$row['vin'] = $items['vin'];
$folder = $wxapp ? 'protocol' : 'html2pdf';
$this->load->view("wxapp/licheb/{$folder}/car_ck",$row);
}
//车辆交接信息
public function car_fh(){
$wxapp = $this->input->get('wxapp');
$id = $this->input->get('id');
$row = $this->orders_model->get(['id'=>$id]);
$this->load->model('receiver/order/receiver_order_agents_model','agents_model');
$this->load->model('receiver/order/receiver_order_loans_model','loans_model');
$row['agent'] = $this->agents_model->get(['o_id'=>$id]);
$contract = $this->contracts_model->get(['o_id'=>$id,'type'=>3]);
$items = $this->items_model->get(['id'=>$row['item_id']],'vin');
if($row){
//贷款
if(!$row['payway']){
$row['loan'] = $this->loans_model->get(['o_id'=>$id]);
}
$brand = $this->auto_brand_model->get(['id'=>$row['brand_id']],'name');
$series = $this->auto_series_model->get(['id'=>$row['s_id']],'name');
$car_json = json_decode($row['car_json'],true);
$color = isset($car_json['color']) ? $car_json['color']['title'] : '';
$version = isset($car_json['version']) ? $car_json['version']['title'] : '';
$row['brand_name'] = $brand['name'].$series['name'].' '.$version;
$row['color'] = $color;
}
$row['day'] = $contract ? date('Y年m月d日',$contract['c_time']):date('Y年m月d日');
$row['cid'] = $contract['cid'];
$row['vin'] = $items['vin'];
$folder = $wxapp ? 'protocol' : 'html2pdf';
$this->load->view("wxapp/licheb/{$folder}/car_fh",$row);
}
}