238 lines
7.9 KiB
PHP
238 lines
7.9 KiB
PHP
<?php
|
|
//defined('WXAPP_APP') OR exit('No direct script access allowed');
|
|
|
|
/**
|
|
* Created by Vim
|
|
* User: lcc
|
|
* Desc: 车系信息
|
|
* Date: 2021.06.23
|
|
* Time: 14:08
|
|
*/
|
|
require_once APPPATH.'controllers/wxapp/Wxapp.php';
|
|
class Series 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('auto/auto_brand_model');
|
|
$this->load->model('auto/auto_series_model');
|
|
$this->load->model('auto/auto_cars_model');
|
|
$this->load->model("biz/biz_model");
|
|
}
|
|
//获取车系
|
|
protected function get(){
|
|
$page = $this->input_param('page');
|
|
$size = $this->input_param('size');
|
|
$brand_id = $this->input_param('brand_id');
|
|
!$page && $page = 1;
|
|
!$size && $size = 100;
|
|
|
|
$where = [
|
|
'status' => 1
|
|
];
|
|
$brand_id && $where['brand_id']=$brand_id;
|
|
$count = $this->auto_series_model->count($where);
|
|
$list = $this->auto_series_model->select($where,'id desc',$page,$size,'id,name');
|
|
$data = [
|
|
'list' => $list,
|
|
'total' => $count
|
|
];
|
|
return $data;
|
|
}
|
|
|
|
//获取品牌
|
|
protected function get_brands(){
|
|
$page = $this->input_param('page');
|
|
$size = $this->input_param('size');
|
|
!$page && $page = 1;
|
|
!$size && $size = 100;
|
|
|
|
$where = [
|
|
'status' => 1
|
|
];
|
|
$count = $this->auto_brand_model->count($where);
|
|
$list = $this->auto_brand_model->select($where,'initial asc',$page,$size,'id,name');
|
|
$data = [
|
|
'list' => $list,
|
|
'total' => $count
|
|
];
|
|
return $data;
|
|
}
|
|
|
|
//获取品牌
|
|
protected function get_mbrand(){
|
|
$keyword = $this->input_param('keyword');
|
|
$where = ['status' => 1];
|
|
$keyword && $where["name like '%{$keyword}%'"] = null;
|
|
|
|
$count = $this->auto_brand_model->count($where);
|
|
$list = $this->auto_brand_model->select($where,'initial asc', 0, 0, 'id,name');
|
|
$data = [
|
|
'list' => $list,
|
|
'total' => $count
|
|
];
|
|
|
|
return $data;
|
|
}
|
|
|
|
//获取车型列表
|
|
protected function get_cars(){
|
|
$page = $this->input_param('page');
|
|
$size = $this->input_param('size');
|
|
$series_id = $this->input_param('series_id');
|
|
!$page && $page = 1;
|
|
!$size && $size = 100;
|
|
|
|
$where = [
|
|
'status' => 1
|
|
];
|
|
$series_id && $where['series_id']=$series_id;
|
|
$count = $this->auto_cars_model->count($where);
|
|
$list = $this->auto_cars_model->select($where,'id desc',$page,$size,'id,name');
|
|
$data = [
|
|
'list' => $list,
|
|
'total' => $count
|
|
];
|
|
return $data;
|
|
}
|
|
protected function get_cars_by_brand_id(){
|
|
$id = $this->input_param('id');
|
|
$id = $id ? $id : 0;
|
|
$where = [
|
|
'status' => 1,
|
|
'brand_id' => $id
|
|
];
|
|
$rows = $this->auto_series_model->select($where,'',1,20,'id,brand_id,name');
|
|
$list = [];
|
|
if($rows){
|
|
$first = [];
|
|
$brand_arr = array_unique(array_column($rows,'brand_id'));
|
|
$brand_ids = implode(',',$brand_arr);
|
|
if($brand_ids){
|
|
$where = [
|
|
"id in ({$brand_ids})" => null,
|
|
];
|
|
$brand_rows = $this->auto_brand_model->map('id','',$where,'','','','id,name');
|
|
}
|
|
foreach($rows as $key=>$val){
|
|
$brand_name = isset($brand_rows[$val['brand_id']]) ? $brand_rows[$val['brand_id']][0]['name'] : '';
|
|
$temp = [
|
|
'id' => $val['id'],
|
|
'title' => $brand_name.$val['name'],
|
|
];
|
|
if($val['id']==$id){
|
|
$first[] = $temp;
|
|
}else{
|
|
$list[] = $temp;
|
|
}
|
|
}
|
|
$list = array_merge($first,$list);
|
|
}
|
|
return $list;
|
|
}
|
|
|
|
//获取车系属性
|
|
protected function get_attrs(){
|
|
$s_id = $this->input_param('id');
|
|
$type = $this->input_param('type');
|
|
$page = $this->input_param('page');
|
|
$size = $this->input_param('size');
|
|
|
|
!$page && $page = 0;
|
|
!$size && $size = 0;
|
|
|
|
$lists = [];
|
|
if($type==2 || $type==1){ //1颜色 2内饰颜色
|
|
$type = $type==1 ? 0 : $type;
|
|
$where = [
|
|
's_id' => $s_id,
|
|
'type' => $type,
|
|
'status' => 1
|
|
];
|
|
$count = $this->auto_attr_model->count($where);
|
|
$lists = $this->auto_attr_model->select($where,'',$page,$size,'id,title');
|
|
}else{ //车辆级别
|
|
$city_id = '';
|
|
$biz_id = $this->session['new_biz_id'] ? $this->session['new_biz_id'] : intval($this->session['biz_id']);
|
|
if($biz_id){
|
|
$biz = $this->biz_model->get(['id'=>$biz_id],'city_id');
|
|
$city_id = $biz['city_id'];
|
|
}
|
|
$where = [
|
|
's_id' => $s_id,
|
|
];
|
|
if($city_id=='350900'){ //宁德市特殊判断
|
|
$where['(status=1 or id=30)'] = null;
|
|
}else{
|
|
$where['status'] = 1;
|
|
}
|
|
$rows = $this->auto_cars_model->select($where,'id desc',$page,$size,'id,s_id,v_id');
|
|
if($rows){
|
|
$target_arr = array_unique(array_column($rows,'v_id'));
|
|
$attrs = $this->auto_attr_model->get_map_by_ids($target_arr,'id,title',1);
|
|
foreach($attrs as $key => $val){
|
|
$lists[] = [
|
|
'id' => $key,
|
|
'title' => $val[0]['title']
|
|
];
|
|
}
|
|
}
|
|
$count = count($lists);
|
|
}
|
|
$data = [
|
|
'list' => $lists,
|
|
'total' => $count
|
|
];
|
|
return $data;
|
|
}
|
|
|
|
//获取车型信息信息
|
|
protected function get_info(){
|
|
$biz_id = $this->session['new_biz_id'] ? $this->session['new_biz_id'] : intval($this->session['biz_id']);
|
|
$s_id = $this->input_param('car_id');
|
|
$v_id = $this->input_param('v_id');
|
|
|
|
if(!$s_id || !$v_id){
|
|
throw new Exception('参数错误', ERR_PARAMS_ERROR);
|
|
}
|
|
$city_id = '';
|
|
if($biz_id){
|
|
$biz = $this->biz_model->get(['id'=>$biz_id],'city_id');
|
|
$city_id = $biz['city_id'];
|
|
}
|
|
|
|
$where_car = array(
|
|
's_id'=>$s_id,
|
|
'v_id' => $v_id,
|
|
);
|
|
if($v_id!=113) { //哪吒 U 2021款Pro400巡航版 不判断状态
|
|
$where_car['status'] = 1;
|
|
}
|
|
$car = $this->auto_cars_model->get($where_car,'',$city_id);
|
|
$biz_id == 70 && $car['price_book'] = 2000; //蕉城辉科写死定金
|
|
if(!$car){
|
|
throw new Exception('当前车型暂无库存', ERR_PARAMS_ERROR);
|
|
}
|
|
$dis_fine_money = $car['price_fine_floor']>0 && $car['price_fine']-$car['price_fine_floor']>0 ? $car['price_fine']-$car['price_fine_floor'] : 0;
|
|
$dis_fine_money_list = [500,1000,1500];
|
|
$dis_money = $car['price_car'] - $car['price_floor'];
|
|
$dis_money_list = [500,1000,2000];
|
|
$data = [
|
|
'price' => $car['price_car'] ? floatval($car['price_car']) : 0,
|
|
'deposit' => $car['price_book'] ? floatval($car['price_book']) : 0,
|
|
'dis_money' => $dis_money,
|
|
'dis_money_list' => $dis_money_list,
|
|
'fine_money' => floatval($car['price_fine']),
|
|
'dis_fine_money' => $dis_fine_money,
|
|
'dis_fine_money_list' => $dis_fine_money_list,
|
|
'deposit_list' => [2000,3000,5000],
|
|
];
|
|
return $data;
|
|
}
|
|
|
|
}
|