diff --git a/admin/controllers/app/liche/Main.php b/admin/controllers/app/liche/Main.php index 4fc91282..4220d562 100644 --- a/admin/controllers/app/liche/Main.php +++ b/admin/controllers/app/liche/Main.php @@ -141,7 +141,7 @@ class Main extends HD_Controller ); $this->load->model('auto/auto_introduce_model', 'mdAutoIntroduce'); - $value = $this->mdAutoIntroduce->count(["status<>-1" => null]); + $value = $this->mdAutoIntroduce->count(["status<>-1" => null, 'brand_id in (select id from lc_auto_brand where status > -1)' => null]); $list[] = array( 'title' => '车型介绍(条)', 'value' => $value, diff --git a/admin/controllers/auto/Attr.php b/admin/controllers/auto/Attr.php index 452065eb..6f1435dc 100644 --- a/admin/controllers/auto/Attr.php +++ b/admin/controllers/auto/Attr.php @@ -32,6 +32,7 @@ class Attr extends HD_Controller $where["status > -1"] = null; $params['title'] && $where["title like '%{$params['title']}%'"] = null; + $where['s_id in (select id from lc_auto_series where brand_id in (select id from lc_auto_brand where status > -1))'] = null; if ($params['s_id']) { $where['s_id'] = $params['s_id']; } @@ -68,7 +69,7 @@ class Attr extends HD_Controller //获取品牌map $where_brand = array('status > -1' => null); - $map_brand = $this->auto_brand_model->map('id', 'name', $where_brand, 'id desc', 0, 0, 'id, name'); + $map_brand = $this->auto_brand_model->map_brand($where_brand); $list = []; if ($rows) { @@ -93,7 +94,7 @@ class Attr extends HD_Controller $this->data['type_arr'] = $type_arr; $this->data['lists'] = $list; $this->data['params'] = $params; - $this->data['brandAry'] = $map_brand; + $this->data['brandAry'] = $this->auto_brand_model->map_brand_list($map_brand); $this->data['pager'] = array('count' => ceil($count / $size), 'curr' => $page, 'totle' => $count); $this->data['_title'] = '属性管理'; $this->show_view('auto/attr/lists', true); diff --git a/admin/controllers/auto/Brand.php b/admin/controllers/auto/Brand.php index bbf1d6e7..6adcf8e1 100644 --- a/admin/controllers/auto/Brand.php +++ b/admin/controllers/auto/Brand.php @@ -38,7 +38,7 @@ class Brand extends HD_Controller{ } $count = $this->auto_brand_model->count($where); - $rows = $this->auto_brand_model->select($where, 'id desc', $page, $size); + $rows = $this->auto_brand_model->select($where, 'status desc, id asc', $page, $size); $status_arr = $this->auto_brand_model->get_status(); $list = []; if($rows){ @@ -184,7 +184,12 @@ class Brand extends HD_Controller{ $title && $where["name like '%{$title}%'"] = null; $un_ids && $where["id not in({$un_ids})"] = null; if(strlen($status) > 0){ - $where['status'] = $status; + if (strpos($status,'>') !== false || strpos($status,'<') !== false || strpos($status,'in') !== false){ + $where["status {$status}"] = null; + } + else{ + $where['status'] = $status; + } } else { $where['status > -1'] = null; } @@ -193,13 +198,13 @@ class Brand extends HD_Controller{ $lists = array(); if($total){ - $orderby = 'id desc'; + $orderby = 'status desc, id asc'; $select = 'id, name'; $rows = $this->auto_brand_model->select($where, $orderby, $page, $size, $select); foreach($rows as $v){ $lists[] = array( - 'id' => $v['id'], + 'id' => strlen($status) > 0 ? $v['id'] : " " . $v['id'], 'name' => $v['name'], ); } diff --git a/admin/controllers/auto/Business.php b/admin/controllers/auto/Business.php index 289e71ff..8135b190 100644 --- a/admin/controllers/auto/Business.php +++ b/admin/controllers/auto/Business.php @@ -25,6 +25,7 @@ class Business extends HD_Controller{ !isset($params['month']) && $params['month'] = ''; $where = array(); + $where['brand_id in (select id from lc_auto_brand where status = 1)'] = null; if($params['brand_id']){ $where['brand_id'] = $params['brand_id']; } else{ @@ -70,8 +71,8 @@ class Business extends HD_Controller{ $size = !$size ? 20 : $size; //获取品牌map - $where_brand = array('status > -1' => null); - $map_brand = $this->auto_brand_model->map('id', 'name', $where_brand, 'id desc', 0 , 0, 'id, name'); + $where_brand = array('status = 1' => null); + $map_brand = $this->auto_brand_model->map_brand($where_brand); //状态 $statusAry = array('0' => '关闭', '1' => '开启'); @@ -134,7 +135,7 @@ class Business extends HD_Controller{ $this->data['params'] = $params; $this->data['lists'] = $lists; $this->data['statusAry'] = $statusAry; - $this->data['brandAry'] = $map_brand; + $this->data['brandAry'] = $this->auto_brand_model->map_brand_list($map_brand); $this->data['cityAry'] = $this->sys_city_model->select(['status'=>1],'id desc',0,0,'city_id,name'); $this->data['yearAry'] = $this->auto_business_model->year(); $this->data['monthAry'] = $this->auto_business_model->month(); diff --git a/admin/controllers/auto/Cars.php b/admin/controllers/auto/Cars.php index 6c952448..f3eddca0 100644 --- a/admin/controllers/auto/Cars.php +++ b/admin/controllers/auto/Cars.php @@ -29,6 +29,7 @@ class Cars extends HD_Controller{ $params = $this->input->get(); $where = array(); + $where['brand_id in (select id from lc_auto_brand where status > -1)'] = null; if($params['brand_id']){ $where['brand_id'] = $params['brand_id']; } else{ @@ -58,7 +59,7 @@ class Cars extends HD_Controller{ //获取品牌map $where_brand = array('status > -1' => null); - $map_brand = $this->auto_brand_model->map('id', 'name', $where_brand, 'id desc', 0 , 0, 'id, name'); + $map_brand = $this->auto_brand_model->map_brand($where_brand); //状态 $statusAry = array('0' => '关闭', '1' => '开启'); @@ -109,7 +110,7 @@ class Cars extends HD_Controller{ $this->data['params'] = $params; $this->data['lists'] = $lists; $this->data['statusAry'] = $statusAry; - $this->data['brandAry'] = $map_brand; + $this->data['brandAry'] = $this->auto_brand_model->map_brand_list($map_brand); $this->data['pager'] = array('count' => ceil($total / $size), 'curr' => $page, 'totle' => $total); $this->data['_title'] = '车型库管理'; $this->show_view('auto/cars/lists',true); diff --git a/admin/controllers/auto/Introduce.php b/admin/controllers/auto/Introduce.php index 08eaed82..be7e3878 100644 --- a/admin/controllers/auto/Introduce.php +++ b/admin/controllers/auto/Introduce.php @@ -35,6 +35,7 @@ class Introduce extends HD_Controller if (strlen($params['status'])) { $where['status'] = $params['status']; } + $where['brand_id in (select id from lc_auto_brand where status > -1)'] = null; $count = $this->mdAutoIntroduce->count($where); if ($count) { $res = $this->mdAutoIntroduce->select($where, "id desc", $params['page'], $params['size']); diff --git a/admin/controllers/auto/Series.php b/admin/controllers/auto/Series.php index 7dc305f6..44dfa717 100644 --- a/admin/controllers/auto/Series.php +++ b/admin/controllers/auto/Series.php @@ -26,6 +26,7 @@ class Series extends HD_Controller{ $size = 20; $where["status > -1"] = null; $params['title'] && $where["name like '%{$params['title']}%'"] = null; + $where['brand_id in (select id from lc_auto_brand where status > -1)'] = null; if($params['brand_id']){ $where['brand_id'] = $params['brand_id']; } else { @@ -48,7 +49,7 @@ class Series extends HD_Controller{ //获取品牌map $where_brand = array('status > -1' => null); - $map_brand = $this->auto_brand_model->map('id', 'name', $where_brand, 'id desc', 0 , 0, 'id, name'); + $map_brand = $this->auto_brand_model->map_brand($where_brand); if($rows){ foreach($rows as $key=>$val){ @@ -68,7 +69,7 @@ class Series extends HD_Controller{ $this->data['status_arr'] = $status_arr_list; $this->data['lists'] = $list; $this->data['params'] = $params; - $this->data['brandAry'] = $map_brand; + $this->data['brandAry'] = $this->auto_brand_model->map_brand_list($map_brand); $this->data['pager'] = array('count' => ceil($count / $size), 'curr' => $page, 'totle' => $count); $this->data['_title'] = '车系列表'; $this->show_view('auto/series/lists', true); diff --git a/admin/controllers/items/Cost.php b/admin/controllers/items/Cost.php index 1e8dd3c9..0f6eda75 100644 --- a/admin/controllers/items/Cost.php +++ b/admin/controllers/items/Cost.php @@ -29,6 +29,7 @@ class Cost extends HD_Controller{ //lc_items //品牌 车系 车型 $where_items = $where_items_default = '1 = 1'; + $where["item_id in (select id from lc_items where brand_id in (select id from lc_auto_brand where status > -1))"] = null; if ($params['brand_id']) {//品牌 //$where["brand_id"] = $params['brand_id']; $where_items = $where_items." and brand_id = ".$params['brand_id']; @@ -202,7 +203,8 @@ class Cost extends HD_Controller{ } $show_info['bizTypeAry'] = $this->biz_model->type_ary();//门店类型 $this->data['show_info'] = $show_info; - $autoList[1] = $this->mdAutoBrand->select(array('status' => 1), 'id desc', 0, 0, 'id,name'); + #$autoList[1] = $this->mdAutoBrand->select(array('status' => 1), 'id desc', 0, 0, 'id,name'); + $autoList[1] = $this->mdAutoBrand->map_brand(array('status > -1' => null), false); $this->data['lists'] = $lists; $this->data['pager'] = array('count' => ceil($count / $size), 'curr' => $page, 'totle' => $count); $this->data['autoList'] = $autoList; diff --git a/admin/controllers/items/Stock.php b/admin/controllers/items/Stock.php index fdfc81df..4312a0a5 100644 --- a/admin/controllers/items/Stock.php +++ b/admin/controllers/items/Stock.php @@ -37,6 +37,7 @@ class Stock extends HD_Controller } else { $order = "id desc"; } + $where['brand_id in (select id from lc_auto_brand where status > -1)'] = null; if ($params['brand_id']) { $where['brand_id'] = $params['brand_id']; } @@ -69,7 +70,8 @@ class Stock extends HD_Controller $time[0] && $where["log_date>="] = $time[0]; $time[1] && $where["log_date<="] = $time[1]; } - $autoList[1] = $this->mdAutoBrand->select(array('status' => 1), "id desc", 0, 0, 'id,name'); + //$autoList[1] = $this->mdAutoBrand->select(array('status' => 1), "id desc", 0, 0, 'id,name'); + $autoList[1] = $this->mdAutoBrand->map_brand(array('status > -1' => null), false); if ($params['brand_id']) { $autoList[2] = $this->mdAutoSeries->select(array('status' => 1, 'brand_id' => $params['brand_id']), 'id desc', 0, 0, 'id,name'); } diff --git a/admin/controllers/items/Transfer.php b/admin/controllers/items/Transfer.php index a6b71941..d7e5deb6 100644 --- a/admin/controllers/items/Transfer.php +++ b/admin/controllers/items/Transfer.php @@ -39,7 +39,8 @@ class Transfer extends HD_Controller $params['page'] = $params['page'] ? intval($params['page']) : 1; $params['size'] = $params['size'] ? intval($params['size']) : 20; $re = $this->dataSelect($params); - $autoList[1] = $this->mdAutoBrand->select(array('status' => 1), 'id desc', 0, 0, 'id,name'); + //$autoList[1] = $this->mdAutoBrand->select(array('status' => 1), 'id desc', 0, 0, 'id,name'); + $autoList[1] = $this->mdAutoBrand->map_brand(array('status > -1' => null), false); if ($params['brand_id']) { $autoList[2] = $this->mdAutoSeries->select(array('status' => 1, 'brand_id' => $params['brand_id']), 'id desc', 0, 0, 'id,name'); } @@ -156,6 +157,7 @@ class Transfer extends HD_Controller $c_time[0] && $where["c_time >="] = strtotime($c_time[0] . ' 00:00:00'); $c_time[1] && $where["c_time <="] = strtotime($c_time[1] . ' 23:59:59'); } + $where['item_id in (select id from lc_items where brand_id in (select id from lc_auto_brand where status > -1))'] = null; $total = $this->mdTransfer->count($where); $lists = array(); if ($total) { diff --git a/admin/controllers/items/goods/Goods.php b/admin/controllers/items/goods/Goods.php index 89e76921..4b14c1fc 100644 --- a/admin/controllers/items/goods/Goods.php +++ b/admin/controllers/items/goods/Goods.php @@ -32,8 +32,16 @@ class Goods extends HD_Controller public function lists() { $params = $this->input->get(); - $page = $params['page'] = $params['page'] ? intval($params['page']) : 1; - $size = $params['size'] = $params['size'] ? intval($params['size']) : 20; + $params['page'] = $params['page'] ? intval($params['page']) : 1; + $params['size'] = $params['size'] ? intval($params['size']) : 20; + $this->data = $this->dataSelect($params); + $view = $this->data['view']; + return $this->show_view($view, true); + } + + private function dataSelect($params){ + $page = $params['page']; + $size = $params['size']; $where = array('id<>1' => null, 'status>' => 0); $where_1 = $where_2 = $where_3 = array('m.id<>1' => null); $autoList = array(); @@ -148,6 +156,10 @@ class Goods extends HD_Controller $where_3["m.bill_time<>'0000-00-00 00:00:00'"] = null; $view = '/items/goods/lists_sold'; $_title = '已售车辆'; + $where['brand_id in (select id from lc_auto_brand where status >- 1)'] = null; + $where_1['brand_id in (select id from lc_auto_brand where status >- 1)'] = null; + $where_2['m.brand_id in (select id from lc_auto_brand where status >- 1)'] = null; + $where_3['m.brand_id in (select id from lc_auto_brand where status >- 1)'] = null; } else { $where["bill_time"] = '0000-00-00 00:00:00'; $where_1["m.bill_time"] = '0000-00-00 00:00:00'; @@ -155,6 +167,10 @@ class Goods extends HD_Controller $where_3["m.bill_time"] = '0000-00-00 00:00:00'; $view = '/items/goods/lists'; $_title = '库存车辆'; + $where['brand_id in (select id from lc_auto_brand where status = 1)'] = null; + $where_1['brand_id in (select id from lc_auto_brand where status = 1)'] = null; + $where_2['m.brand_id in (select id from lc_auto_brand where status = 1)'] = null; + $where_3['m.brand_id in (select id from lc_auto_brand where status = 1)'] = null; } if ($params['vin']) { @@ -223,7 +239,14 @@ class Goods extends HD_Controller $params['sort'] = $sort; } - $autoList[1] = $this->mdAutoBrand->select(array('status' => 1), 'id desc', 0, 0, 'id,name'); + #$autoList[1] = $this->mdAutoBrand->select(array('status' => 1), 'id desc', 0, 0, 'id,name'); + if (1 == $params['sold']){ + $autoList[1] = $this->mdAutoBrand->map_brand(array('status > -1' => null), false); + } + else{ + $autoList[1] = $this->mdAutoBrand->map_brand(array('status = 1' => null), false); + } + switch ($search_type) { case 1://精品筛选 $count = $this->mdItems->count_fine($where_1); @@ -387,7 +410,8 @@ class Goods extends HD_Controller $this->data['autoList'] = $autoList; $this->data['statusAry'] = $statusAry; $this->data['_title'] = $_title; - return $this->show_view($view, true); + $this->data['view'] = $view; + return $this->data; } public function get() @@ -849,6 +873,46 @@ class Goods extends HD_Controller //导出数据列表 public function export() + { + $params = $this->input->get(); + $params['page'] = 1; + $params['size'] = 10000; + $this->data = $this->dataSelect($params); + + $fileName = "车辆明细"; + $indexs = array( + 'id' => 'ID', + 'brand_name' => '品牌', + 's_name' => '车系', + 'v_name' => '车型', + 'cor_name' => '车身颜色', + 'incor_name' => '内饰颜色', + 'ori_price' => '指导价', + 'sale_price' => '售价', + 'bill_price' => '开票金额', + 'buy_price' => '采购成本', + 'dis_price' => '折扣价', + 'discount' => '折扣百分比', + 'city_name' => '城市名', + 'county_name' => '行政区', + 'address' => '存放地址', + 'vin' => '车架号', + 'engine_num' => '发动机号', + 'stdard_num' => '合格证号', + 'bill_num' => '开票号', + 'auto_fine' => '精品加装', + 'company_name' => '公司归属', + 'status' => '状态', + 'in_time' => '入库时间', + 'out_time' => '出库时间', + 'bill_time' => '开票时间', + ); + $lists = $this->data['lists']; + array_unshift($lists, $indexs); + $this->load->library('excel'); + $this->excel->out_csv($lists, $indexs, $fileName . "_" . date('YmdHis')); + } + public function export_() { $params = $this->input->get(); $where = $where_1 = $where_2 = $where_3 = $autoList = array(); diff --git a/admin/controllers/items/goods/Logs.php b/admin/controllers/items/goods/Logs.php index 73ed5b5a..7c7a4044 100644 --- a/admin/controllers/items/goods/Logs.php +++ b/admin/controllers/items/goods/Logs.php @@ -43,6 +43,7 @@ class Logs extends HD_Controller { $lists = $autoList = array(); $where = array('id<>1' => null, 'status>' => 0); + $where['brand_id in (select id from lc_auto_brand where status > -1)'] = null; if ($params['brand_id']) { $where['brand_id'] = $params['brand_id']; $autoList[2] = $this->mdAutoSeries->select(array('status' => 1, 'brand_id' => $params['brand_id']), 'id desc', 0, 0, 'id,name'); @@ -98,7 +99,8 @@ class Logs extends HD_Controller } else { $params['sold'] = ''; } - $autoList[1] = $this->mdAutoBrand->select(array('status' => 1), 'id desc', 0, 0, 'id,name'); + //$autoList[1] = $this->mdAutoBrand->select(array('status' => 1), 'id desc', 0, 0, 'id,name'); + $autoList[1] = $this->mdAutoBrand->map_brand(array('status > -1' => null), false); $statusAry = $this->statusAry; $soldAry = $this->soldAry; $count = $this->mdItems->count($where); diff --git a/admin/controllers/receiver/Owners.php b/admin/controllers/receiver/Owners.php index d8bf590e..0b68d967 100644 --- a/admin/controllers/receiver/Owners.php +++ b/admin/controllers/receiver/Owners.php @@ -97,6 +97,7 @@ class Owners extends HD_Controller if ($params['sex']) { $where["a.sex"] = $params['sex']; } + $where['a.brand_id in (select id from lc_auto_brand where status > -1)'] = null; if ($params['brand_id']) { $where["a.brand_id"] = $params['brand_id']; } diff --git a/admin/libraries/Ordersv2List.php b/admin/libraries/Ordersv2List.php index 16b83225..501ef4ce 100644 --- a/admin/libraries/Ordersv2List.php +++ b/admin/libraries/Ordersv2List.php @@ -210,6 +210,7 @@ class Ordersv2List $where["{$this->t1}.over_time<="] = date('Y-m-d',time()+$e_day*24*60*60); } } + $where["{$this->t1}.brand_id in (select id from lc_auto_brand where status > -1)"] = null; if ($params['brand_id']) {//品牌 $where["{$this->t1}.brand_id"] = $params['brand_id']; } else { diff --git a/admin/views/auto/introduce/lists.php b/admin/views/auto/introduce/lists.php index 094a6b35..3f82b813 100644 --- a/admin/views/auto/introduce/lists.php +++ b/admin/views/auto/introduce/lists.php @@ -36,6 +36,7 @@
| ID | 车型 | 创建时间 | 状态 | @@ -46,6 +47,7 @@
|---|---|---|---|
| = $v['id'] ?> | = $v['title'] ?> | = $v['c_time'] ?> | = $v['status_name'] ?> | diff --git a/admin/views/auto/series/lists.php b/admin/views/auto/series/lists.php index 2b6b4cdd..f930114a 100755 --- a/admin/views/auto/series/lists.php +++ b/admin/views/auto/series/lists.php @@ -106,9 +106,8 @@ methods:{}, watch:{} }); + }); - - diff --git a/admin/views/receiver/orderv2/lists.php b/admin/views/receiver/orderv2/lists.php index 5b475d45..4469ea3a 100644 --- a/admin/views/receiver/orderv2/lists.php +++ b/admin/views/receiver/orderv2/lists.php @@ -409,7 +409,7 @@ url: '/auto/brand/json_lists', type: 'post', dataType: 'json', - data: {status: 1}, + data: {status: '> -1'}, // data: {status: 1}, beforeSend: function () { }, success: function (data) { diff --git a/admin/views/receiver/owners/lists.php b/admin/views/receiver/owners/lists.php index 6f8ffe90..5bec8ec3 100644 --- a/admin/views/receiver/owners/lists.php +++ b/admin/views/receiver/owners/lists.php @@ -318,7 +318,7 @@ url: '/auto/brand/json_lists', type: 'post', dataType: 'json', - data: {status: 1}, + data: {status: '> -1'}, // data: {status: 1}, beforeSend: function () { }, success: function (data) { diff --git a/api/controllers/wxapp/app/Series.php b/api/controllers/wxapp/app/Series.php index 1d1d3277..b55f6a95 100644 --- a/api/controllers/wxapp/app/Series.php +++ b/api/controllers/wxapp/app/Series.php @@ -72,9 +72,13 @@ class Series extends Wxapp{ ]; return $data; } - + //获取车型列表 protected function get_cars(){ + if ($this->app_id == 1){ + return $this->get_cars_by_brand_id(); // liche根据brand_id取数据 + } + $uid = $this->session['uid']; $id = $this->input_param('id'); //车系id @@ -123,6 +127,42 @@ class Series extends Wxapp{ } return $list; } + 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'); diff --git a/api/controllers/wxapp/content/liche/Sub_cms.php b/api/controllers/wxapp/content/liche/Sub_cms.php index 53c8e618..8d73238a 100644 --- a/api/controllers/wxapp/content/liche/Sub_cms.php +++ b/api/controllers/wxapp/content/liche/Sub_cms.php @@ -44,6 +44,7 @@ class Sub_cms extends Wxapp ); if (is_numeric($position)) { $where['position'] = $position; + $position == 2 && $where['target_id in (select id from lc_auto_brand where status = 1)'] = null; } else { $where["position in ({$position})"] = null; } diff --git a/api/controllers/wxapp/liche/Auto.php b/api/controllers/wxapp/liche/Auto.php index 673a68c5..e3f9b639 100644 --- a/api/controllers/wxapp/liche/Auto.php +++ b/api/controllers/wxapp/liche/Auto.php @@ -30,7 +30,8 @@ class Auto extends Wxapp $this->load->model("biz/biz_model", 'mdBiz'); $id = intval($this->input_param('id')); $biz_id = intval($this->input_param('biz_id')); - $re = $this->mdAutoIntroduce->get(array('id' => $id, 'status' => 1)); + //$re = $this->mdAutoIntroduce->get(array('id' => $id, 'status' => 1)); + $re = $this->mdAutoIntroduce->get(array('id' => $id, 'status' => 1, 'brand_id in (select id from lc_auto_brand where status = 1)' => null)); if (!$re || empty($re)) { throw new Exception('车型介绍不存在!', API_CODE_FAIL); } @@ -74,7 +75,8 @@ class Auto extends Wxapp $this->load->model('receiver/receiver_customers_model', 'mdCustomers'); $this->load->model("biz/biz_model", 'mdBiz'); $this->load->model('auto/auto_introduce_model', 'mdAutoIntroduce'); - $re = $this->mdAutoIntroduce->get(array('id' => $id, 'status' => 1)); + //$re = $this->mdAutoIntroduce->get(array('id' => $id, 'status' => 1)); + $re = $this->mdAutoIntroduce->get(array('id' => $id, 'status' => 1, 'brand_id in (select id from lc_auto_brand where status = 1)' => null)); if (!$re || empty($re)) { throw new Exception('车型介绍不存在!', API_CODE_SUCCESS); } diff --git a/common/models/auto/Auto_brand_model.php b/common/models/auto/Auto_brand_model.php index 06e7db12..70cdfc7b 100644 --- a/common/models/auto/Auto_brand_model.php +++ b/common/models/auto/Auto_brand_model.php @@ -38,6 +38,35 @@ class Auto_brand_model extends HD_Model } return $rows; } + + /** + * 品牌字典 + * @param array + * @param bool + * @return array + */ + public function map_brand($where=array(), $map=true){ + if ($map){ + $map_brand = $this->map('id', 'name', $where, 'status desc, id asc', 0 , 0, 'id, name'); + } + else{ + $map_brand = $this->select($where, "status desc, id asc", 0, 0, 'id, name'); + } + return $map_brand; + } + /** + * 品牌字典带排序,用于select控件 + * @param array + * @return array + */ + public function map_brand_list($map_brand){ + $map_brand_list = array(); + foreach ($map_brand as $key=>$val){ + $map_brand_list[" " . $key] = $val; + } + return $map_brand_list; + } + //获取状态 public function get_status(){ return $this->status_arr;