187 lines
6.1 KiB
PHP
187 lines
6.1 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("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 = 20;
|
|
|
|
$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 = 20;
|
|
|
|
$where = [
|
|
'status' => 1
|
|
];
|
|
if($this->session['biz_id']){
|
|
$biz_id = $this->session['biz_id'];
|
|
$biz = $this->biz_model->get(['id'=>$biz_id],'jsondata');
|
|
$jsondata = json_decode($biz['jsondata'],true);
|
|
$auto_brands = $jsondata['auto_brands'] ? $jsondata['auto_brands'] : [0];
|
|
|
|
$str_brands = implode(',',$auto_brands);
|
|
$where["id in ($str_brands)"] = null;
|
|
}
|
|
$count = $this->auto_brand_model->count($where);
|
|
$list = $this->auto_brand_model->select($where,'id desc',$page,$size,'id,name');
|
|
$data = [
|
|
'list' => $list,
|
|
'total' => $count
|
|
];
|
|
return $data;
|
|
}
|
|
|
|
//获取车型列表
|
|
protected function get_cars(){
|
|
$uid = $this->session['uid'];
|
|
$id = $this->input_param('id'); //车系id
|
|
|
|
$where = [
|
|
'status' => 1
|
|
];
|
|
$user = $this->app_user_model->get(array('id' => $uid));
|
|
if(isset($user['biz_id'])){
|
|
$biz_id = $this->session['biz_id'];
|
|
$biz = $this->biz_model->get(['id'=>$biz_id],'jsondata');
|
|
$jsondata = json_decode($biz['jsondata'],true);
|
|
$auto_brands = $jsondata['auto_brands'] ? $jsondata['auto_brands'] : [0];
|
|
|
|
$str_brands = implode(',',$auto_brands);
|
|
$where["brand_id in ($str_brands)"] = null;
|
|
}
|
|
if($id){ //只显示相同品牌
|
|
$series = $this->auto_series_model->get(['id'=>$id],'brand_id');
|
|
$series['brand_id'] && $where['brand_id'] = $series['brand_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'));
|
|
$brands = [];
|
|
$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 = 1;
|
|
!$size && $size = 20;
|
|
|
|
$this->load->model('auto/auto_attr_model');
|
|
|
|
$where = [
|
|
's_id' => $s_id
|
|
];
|
|
strlen($type) && $where['type'] = $type;
|
|
$count = $this->auto_attr_model->count($where);
|
|
$rows = $this->auto_attr_model->select($where,'id desc',$page,$size,'id,title,type,jsondata');
|
|
$lists = [];
|
|
if($rows){
|
|
foreach($rows as $key=>$val){
|
|
$jsodnata = json_decode($val['jsondata'],true);
|
|
$temp = [
|
|
'id' => $val['id'],
|
|
'title' => $val['title']
|
|
];
|
|
$lists[] = $temp;
|
|
}
|
|
}
|
|
$data = [
|
|
'list' => $lists,
|
|
'total' => $count
|
|
];
|
|
return $data;
|
|
}
|
|
|
|
//获取车型信息信息
|
|
protected function get_info(){
|
|
$s_id = $this->input_param('car_id');
|
|
$v_id = $this->input_param('v_id');
|
|
$color_id = $this->input_param('color_id');
|
|
$incolor_id = $this->input_param('incolor_id');
|
|
$this->load->model('auto/auto_cars_model');
|
|
|
|
if(!$s_id || !$v_id || !$color_id || !$incolor_id){
|
|
throw new Exception('参数错误', ERR_PARAMS_ERROR);
|
|
}
|
|
|
|
$where_car = array(
|
|
's_id'=>$s_id,
|
|
'v_id' => $v_id,
|
|
'cor_id' => $color_id,
|
|
'incor_id' => $incolor_id
|
|
);
|
|
$car = $this->auto_cars_model->get($where_car);
|
|
$data = [
|
|
'price' => $car['price_car'] ? $car['price_car'] : 0,
|
|
'deposit' => $car['price_book'] ? $car['price_book'] : 0
|
|
];
|
|
return $data;
|
|
}
|
|
}
|