189 lines
9.1 KiB
PHP
189 lines
9.1 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(){
|
|
parent::__construct();
|
|
$this->load->model('receiver/order/receiver_orders_model','orders_model');
|
|
$this->load->model('receiver/order/receiver_order_contracts_model','contracts_model');
|
|
$this->load->model('receiver/order/receiver_order_agents_model','agents_model');
|
|
$this->load->model('receiver/order/receiver_order_loans_model','loans_model');
|
|
$this->load->model('receiver/order/receiver_order_ckcars_model','ckcars_model');
|
|
$this->load->model('receiver/receiver_service_package_model','package_model');
|
|
$this->load->model('receiver/receiver_services_model','services_model');
|
|
|
|
$this->load->model('auto/auto_series_model');
|
|
$this->load->model('auto/auto_brand_model');
|
|
$this->load->model('auto/auto_cars_model');
|
|
|
|
$this->load->model("biz/biz_model");
|
|
$this->load->model('area_model');
|
|
$this->load->model("sys/sys_company_model");
|
|
$this->load->model("items/items_model");
|
|
$this->load->model('apporder/order_purchase_model','purchase_model');
|
|
$this->load->model('app/liche/app_liche_orders_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);
|
|
$row['color'] = isset($car_json['color']) ? $car_json['color']['title'] : '';
|
|
$row['incolor'] = isset($car_json['incolor']) ? $car_json['incolor']['title'] : '';
|
|
$row['version'] = isset($car_json['version']) ? $car_json['version']['title'] : '';
|
|
$row['brand_name'] = $brand['name'];
|
|
$row['series_name'] = $series['name'];
|
|
//获取门店信息
|
|
$biz = $this->biz_model->get(['id'=>$row['biz_id']]);
|
|
$city = $this->area_model->get(['county_id'=>$biz['county_id']],'city_name,county_name');
|
|
$row['address'] = $city['city_name'].$city['county_name'].' '.$biz['address'] .'  '. $biz['biz_name'];
|
|
$company = $this->sys_company_model->get(['id'=>$biz['company_id']]);
|
|
$row['company'] = $company;
|
|
//获取选择代办包
|
|
$pack_row = $this->package_model->get(['id'=>$row['pack_id']],'srv_ids');
|
|
$srv_total = count(explode(',',$pack_row['srv_ids']));
|
|
if($srv_total==4){
|
|
$row['give_time'] = 30;
|
|
}elseif($srv_total==3){
|
|
$row['give_time'] = 45;
|
|
}else{
|
|
$row['give_time'] = 60;
|
|
}
|
|
}
|
|
$row['info_json'] = json_decode($row['info_json'],true);
|
|
$row['price_rmb'] = num_to_rmb($row['price']);
|
|
$row['cid'] = $contract['cid'];
|
|
$row['day'] = $contract ? date('Y年m月d日',$contract['c_time']):date('Y年m月d日');
|
|
$row['dep_price'] = number_format($row['deposit'],2); //定金
|
|
$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]);
|
|
$total_price = 0;
|
|
$services = [];
|
|
if($row){
|
|
$money_json = json_decode($row['money_json'],true);
|
|
//获取门店信息
|
|
$biz = $this->biz_model->get(['id'=>$row['biz_id']]);
|
|
$row['company'] = $this->sys_company_model->get(["title like '%服务%'"=>null,'status'=>1]);
|
|
//获取选择代办包
|
|
$pack_row = $this->package_model->get(['id'=>$row['pack_id']],'srv_ids');
|
|
if($pack_row['srv_ids']){
|
|
$services = $this->services_model->select(["id in ({$pack_row['srv_ids']})"=>null],'','','','title');
|
|
}
|
|
$this->load->library('receiver/orders_entity');
|
|
$srv_price = $this->orders_entity->order_srv_money($row['id']);
|
|
$total_price = $srv_price + $money_json['price_insure'];
|
|
}
|
|
$row['services'] = $services;
|
|
$row['total_price'] = $total_price;
|
|
$row['info_json'] = json_decode($row['info_json'],true);
|
|
$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');
|
|
$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;
|
|
//获取门店信息
|
|
$biz = $this->biz_model->get(['id'=>$row['biz_id']]);
|
|
$company = $this->sys_company_model->get(['id'=>$biz['company_id']]);
|
|
$row['company'] = $company;
|
|
}
|
|
$contract = $this->contracts_model->get(['o_id'=>$id,'type'=>2]);
|
|
$items = $this->items_model->get(['id'=>$row['item_id']],'vin');
|
|
$row['info_json'] = json_decode($row['info_json'],true);
|
|
$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(){
|
|
$this->load->model('app/licheb/app_licheb_users_model');
|
|
$wxapp = $this->input->get('wxapp');
|
|
$id = $this->input->get('id');
|
|
|
|
$row = $this->orders_model->get(['id'=>$id]);
|
|
$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');
|
|
$total_price = 0;
|
|
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);
|
|
$money_json = json_decode($row['money_json'],true);
|
|
$row['info_json'] = $info_json = json_decode($row['info_json'],true);
|
|
$row['color'] = isset($car_json['color']) ? $car_json['color']['title'] : '';
|
|
$row['incolor'] = isset($car_json['incolor']) ? $car_json['incolor']['title'] : '';
|
|
$row['version'] = isset($car_json['version']) ? $car_json['version']['title'] : '';
|
|
$row['brand_name'] = $brand['name'];
|
|
$row['series_name'] = $series['name'];
|
|
$row['cardid'] = $info_json['cardid'];
|
|
//获取门店信息
|
|
$biz = $this->biz_model->get(['id'=>$row['biz_id']]);
|
|
$company = $this->sys_company_model->get(['id'=>$biz['company_id']]);
|
|
$row['company'] = $company;
|
|
$p_row = $this->app_liche_orders_model->get(['o_id'=>$row['id'],'pid'=>0,'status>='=>0],'id');
|
|
$where = [
|
|
'o_id' => $row['id'],
|
|
'status' => 1,
|
|
'type in (1,2,4)' => null
|
|
];
|
|
$pay = $this->app_liche_orders_model->sum('total_price',$where);
|
|
//尾款
|
|
$where = [
|
|
'o_id' => $row['id'],
|
|
'status' => 1,
|
|
'type' => 3,
|
|
'pid!=' => $p_row['id']
|
|
];
|
|
$last_pay = $this->app_liche_orders_model->sum('total_price',$where);
|
|
$row['pay_price'] = $pay['total_price'] + $last_pay['total_price'];
|
|
$this->load->library('receiver/orders_entity');
|
|
$total_price = $this->orders_entity->order_srv_money($row['id']);
|
|
}
|
|
$row['total_price'] = $total_price;
|
|
$row['agent'] = $agent;
|
|
$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);
|
|
}
|
|
}
|