201 lines
6.9 KiB
PHP
201 lines
6.9 KiB
PHP
<?php
|
|
defined('BASEPATH') or exit('No direct script access allowed');
|
|
|
|
class Common extends CI_Controller
|
|
{
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
$this->load->model('area_model');
|
|
}
|
|
|
|
/**
|
|
* 省市区数据
|
|
* @return void
|
|
*/
|
|
public function regionsData()
|
|
{
|
|
$req = $this->area_model->getDataByTree();
|
|
echo json_encode($req, JSON_UNESCAPED_UNICODE);
|
|
}
|
|
|
|
/**
|
|
* 获取品牌
|
|
* @return void
|
|
*/
|
|
public function autoBrand()
|
|
{
|
|
$this->load->model('auto/auto_brand_model', 'mdAutoBrand');
|
|
$this->mdAutoBrand->set_db('ssdb');
|
|
$where = [
|
|
'status>' => -1,
|
|
];
|
|
$lists = $this->mdAutoBrand->select($where, 'initial asc', 0, 0, 'id,name');
|
|
echo json_encode($lists, JSON_UNESCAPED_UNICODE);
|
|
}
|
|
|
|
/**
|
|
* 获取车系
|
|
* @return void
|
|
*/
|
|
public function autoSeries()
|
|
{
|
|
$this->load->model('auto/auto_series_model', 'mdAutoSeries');
|
|
$this->mdAutoSeries->set_db('ssdb');
|
|
$brandId = intval($this->input->get('brandId'));
|
|
$where = [
|
|
'status>' => -1,
|
|
'brand_id' => $brandId
|
|
];
|
|
$lists = $this->mdAutoSeries->select($where, 'id asc', 0, 0, 'id,name');
|
|
echo json_encode($lists, JSON_UNESCAPED_UNICODE);
|
|
}
|
|
|
|
/**
|
|
* 获取车型
|
|
* @return void
|
|
*/
|
|
public function autoCar()
|
|
{
|
|
$this->load->model('auto/auto_cars_model', 'mdAutoCar');
|
|
$this->mdAutoCar->set_db('ssdb');
|
|
$seriesId = intval($this->input->get('seriesId'));
|
|
$where = [
|
|
'status>' => -1,
|
|
'series_id' => $seriesId
|
|
];
|
|
$lists = $this->mdAutoCar->select($where, 'id asc', 0, 0, 'id,name');
|
|
echo json_encode($lists, JSON_UNESCAPED_UNICODE);
|
|
}
|
|
|
|
/**
|
|
* 获取所有门店
|
|
* @return void
|
|
*/
|
|
public function allBiz()
|
|
{
|
|
$this->load->model('biz/biz_model');
|
|
$this->load->model('biz/biz_car_brand_model');
|
|
$this->load->model('agent/auto_product_model');
|
|
$this->biz_model->set_db('ssdb');
|
|
$this->biz_car_brand_model->set_db('ssdb');
|
|
$productId = intval($this->input->get('productId'));
|
|
$types = Biz_model::BIZ_TYPE_4s . ',' . Biz_model::BIZ_TYPE_SPACE;
|
|
$where = [
|
|
'status' => 1,
|
|
];
|
|
if ($productId) {
|
|
$product = $this->auto_product_model->get(['id' => $productId]);
|
|
$brandId = $product['brandId'] ?: 0;
|
|
$brandBizList = $this->biz_car_brand_model->select(['brand_id' => $brandId], '', '', '', 'biz_id');
|
|
$bizIdArray = array_column($brandBizList, 'biz_id');
|
|
$bizIdString = $bizIdArray ? implode(',', $bizIdArray) : 0;
|
|
$where["(id in ({$bizIdString}) and type=" . Biz_model::BIZ_TYPE_4s . " or type=" . Biz_model::BIZ_TYPE_SPACE . ")"] = null;
|
|
} else {
|
|
$where["type in ({$types})"] = null;
|
|
}
|
|
$lists = $this->biz_model->select($where, 'id desc', 0, 0, 'id,biz_name as name,city_id');
|
|
echo json_encode($lists, JSON_UNESCAPED_UNICODE);
|
|
}
|
|
|
|
public function autoBrands()
|
|
{
|
|
$this->load->model('auto/auto_brand_model', 'mdAutoBrand');
|
|
$this->load->model('auto/auto_series_model', 'mdAutoSeries');
|
|
$this->load->model('auto/auto_cars_model', 'mdAutoCar');
|
|
$this->mdAutoBrand->set_db('ssdb');
|
|
$this->mdAutoSeries->set_db('ssdb');
|
|
$this->mdAutoCar->set_db('ssdb');
|
|
$redis = load_cache("redis");
|
|
$cKey = 'SYS_BRAND_TREE_DATA';
|
|
$cacheList = $redis->get($cKey);
|
|
if ($cacheList) {
|
|
die(json_encode($cacheList, JSON_UNESCAPED_UNICODE));
|
|
}
|
|
$where = ['status' => 1];
|
|
$brandRows = $this->mdAutoBrand->select($where, 'initial asc', 0, 0);
|
|
$seriesRows = $this->mdAutoSeries->map('brand_id', '', $where, 'id desc', 0, 0);
|
|
$carRows = $this->mdAutoCar->map('series_id', '', $where, 'id desc', 0, 0, 'id as value,name as label,series_id');
|
|
$lists = [];
|
|
foreach ($brandRows as $brandRow) {
|
|
$children = [];
|
|
$brand = [
|
|
'value' => $brandRow['id'],
|
|
'label' => $brandRow['name'],
|
|
];
|
|
if ($seriesRows[$brandRow['id']]) {
|
|
foreach ($seriesRows[$brandRow['id']] as $seriesRow) {
|
|
$seriesChildren = $carRows[$seriesRow['id']] ?: [];
|
|
$children[] = [
|
|
'value' => $seriesRow['id'],
|
|
'label' => $seriesRow['name'],
|
|
'children' => $seriesChildren
|
|
];
|
|
}
|
|
}
|
|
$brand['children'] = $children;
|
|
$lists[] = $brand;
|
|
}
|
|
$redis->save($cKey, $lists, 24 * 60 * 60);
|
|
echo json_encode($lists, JSON_UNESCAPED_UNICODE);
|
|
}
|
|
|
|
/**
|
|
* 获取所有门店
|
|
* @return void
|
|
*/
|
|
public function allProvinceBiz()
|
|
{
|
|
$this->load->model('area_model');
|
|
$this->load->model('biz/biz_model');
|
|
$this->load->model('agent/auto_product_model');
|
|
$this->biz_model->set_db('ssdb');
|
|
$this->area_model->set_db('ssdb');
|
|
$type = Biz_model::BIZ_TYPE_4s;
|
|
$where = [
|
|
'status' => 1,
|
|
'type' => $type
|
|
];
|
|
$lists = $this->biz_model->map('city_id', '', $where, 'id desc', 0, 0, 'id as value,biz_name as label,city_id');
|
|
$provinceTree = $this->area_model->getDataByTree();
|
|
$resList = [];
|
|
foreach ($provinceTree as $item) {
|
|
$children = $item['children'];
|
|
$newChildren = [];
|
|
foreach ($children as $key => $item2) {
|
|
if ($lists[$item2['value']]) {
|
|
$item2['children'] = $lists[$item2['value']];
|
|
$newChildren[] = $item2;
|
|
} else {
|
|
$children[$key]['children'] = [];
|
|
}
|
|
}
|
|
if ($newChildren) {
|
|
$resList[] = [
|
|
'value' => $item['value'],
|
|
'label' => $item['label'],
|
|
'children' => $newChildren
|
|
];
|
|
}
|
|
}
|
|
echo json_encode($resList, JSON_UNESCAPED_UNICODE);
|
|
}
|
|
|
|
/**
|
|
* 用户归属中心
|
|
* @return void
|
|
*/
|
|
public function centerList()
|
|
{
|
|
$this->load->model('agent/pingan/pingan_users_model');
|
|
$res = Pingan_users_model::TYPE_CENTER;
|
|
echo json_encode($res, JSON_UNESCAPED_UNICODE);
|
|
}
|
|
|
|
public function orgNameList()
|
|
{
|
|
$this->load->model('agent/pingan/pingan_users_model');
|
|
echo json_encode(Pingan_users_model::orgNameList, JSON_UNESCAPED_UNICODE);
|
|
}
|
|
}
|