diff --git a/admin/controllers/items/goods/Goods.php b/admin/controllers/items/goods/Goods.php index cb6552df..cdd30150 100644 --- a/admin/controllers/items/goods/Goods.php +++ b/admin/controllers/items/goods/Goods.php @@ -31,27 +31,33 @@ class Goods extends HD_Controller $params = $this->input->get(); $page = $params['page'] = $params['page'] ? intval($params['page']) : 1; $size = $params['size'] = $params['size'] ? intval($params['size']) : 20; - $where = $autoList = array(); + $where = $where_fine = $autoList = array(); + $search_type = 0; if ($params['brand_id']) { $where['brand_id'] = $params['brand_id']; + $where_fine['brand_id'] = $params['brand_id']; $autoList[2] = $this->mdAutoSeries->select(array('status' => 1, 'brand_id' => $params['brand_id']), 'id desc', 0, 0, 'id,name'); } if ($params['s_id']) { $where['s_id'] = $params['s_id']; + $where_fine['s_id'] = $params['s_id']; $autoList[3] = $this->mdAutoAttr->select(array('type' => 1, 's_id' => $params['s_id']), 'id desc', 0, 0, 'id,title as name'); } if ($params['v_id']) { $where['v_id'] = $params['v_id']; + $where_fine['v_id'] = $params['v_id']; } //车身颜色 if ($params['cor_id']) { $where['cor_id'] = $params['cor_id']; + $where_fine['cor_id'] = $params['cor_id']; } else { $params['cor_id'] = ''; } if($params['addr_id']){ $where['addr_id'] = $params['addr_id']; + $where_fine['addr_id'] = $params['addr_id']; } else if($params['city_id']){ $where_addr = array('status>0' => null, 'city_id' => $params['city_id']); if($params['county_id']){ @@ -63,8 +69,10 @@ class Goods extends HD_Controller if($rows_addr){ $str_ids = implode(',', array_column($rows_addr, 'id')); $where["addr_id in ({$str_ids})"] = null; + $where_fine["addr_id in ({$str_ids})"] = null; } else { $where['addr_id'] = -1; + $where_fine['addr_id'] = -1; } } else { $params['city_id'] = ''; @@ -73,29 +81,62 @@ class Goods extends HD_Controller } if(strlen($params['status'])>0){ $where['status'] = $params['status']; + $where_fine['m.status'] = $params['status']; } else { $params['status'] = ''; } if($params['vin']){ $where["vin like '%{$params['vin']}%'"] = null; + $where_fine["vin like '%{$params['vin']}%'"] = null; } //精品筛选 if($params['fine_ids']){ - $fine_count = substr_count($params['fine_ids'], ',') + 1; - $sql = "select item_id from lc_items_relate where type=1 and status=1 and type_id in ({$params['fine_ids']}) group by item_id having count(item_id)={$fine_count}"; - $where["id in ($sql)"] = null; + $fine_num = substr_count($params['fine_ids'], ',') + 1; + $where_fine["type_id in ({$params['fine_ids']})"] = null; + $where_fine["having"] = "fine_num={$fine_num}"; + $search_type = 1; } else { $params['fine_ids'] = ''; } + $order = 'id'; + if('fine_num' == $params['order']){ + $order = $params['order']; + $search_type = 1; + } else if($params['order']){ + $order = $params['order']; + } else { + $params['order'] = $order; + } + $sort = 'desc'; + if($params['sort']){ + $sort = $params['sort']; + } else { + $params['sort'] = $sort; + } + $autoList[1] = $this->mdAutoBrand->select(array('status' => 1), 'id desc', 0, 0, 'id,name'); - $count = $this->mdItems->count($where); + if(1 == $search_type){ + //精品筛选 + $count = $this->mdItems->count_fine($where_fine); + } else { + $count = $this->mdItems->count($where); + } $lists = array(); $fine_ids = array(); if ($count) { - $fileds = 'id,brand_id,s_id,vin,v_id,cor_id,incor_id,in_time,addr_id'; - $rows = $this->mdItems->select($where, 'id desc', $page, $size, $fileds); + if(1 == $search_type){ + //精品筛选 + $fileds = 'id,brand_id,s_id,vin,v_id,cor_id,incor_id,in_time,addr_id,count(type_id) as fine_num'; + $orderby = "{$order} {$sort}"; + $rows = $this->mdItems->select_fine($where_fine, $orderby, $page, $size, $fileds); + } else { + $fileds = 'id,brand_id,s_id,vin,v_id,cor_id,incor_id,in_time,addr_id'; + $orderby = "{$order} {$sort}"; + $rows = $this->mdItems->select($where, $orderby, $page, $size, $fileds); + } + $brand_id_arr = array(); $addr_ids = array(); $ids = array(); diff --git a/admin/views/items/goods/lists.php b/admin/views/items/goods/lists.php index a2a9fc22..5c877472 100644 --- a/admin/views/items/goods/lists.php +++ b/admin/views/items/goods/lists.php @@ -35,10 +35,63 @@ white-space: normal; line-height: 1.4; } + .order-on { + border-bottom: 2px solid #e61773; + height: 40px; + } + + .order-none{ + height: 38px; + } + + .order { + width: 150px; + display: table-cell; + position: relative; + } + + .order a{ + display: block; + overflow: hidden; + width: 100%; + height: 30px; + line-height: 30px; + text-align: center; + color: #5e5e5e; + } + + .angle_top { + content: ''; + width: 0; + height: 0; + display: block; + border-style: solid; + border-width: 0 6px 6px; + border-color: transparent transparent #5e5e5e; + position: absolute; + transform: rotate(180deg); + bottom: 14px; + right: 17px; + } + + .angle_bottom { + content: ''; + width: 0; + height: 0; + display: block; + border-style: solid; + border-width: 0 6px 6px; + border-color: transparent transparent #5e5e5e; + position: absolute; + top: 10px; + right: 17px; + }