Authored by whb

修改bug

@@ -203,11 +203,14 @@ EOT; @@ -203,11 +203,14 @@ EOT;
203 if($this->_platform == 'android' || $this->_platform == 'iphone') 203 if($this->_platform == 'android' || $this->_platform == 'iphone')
204 { 204 {
205 $exceptTags = array('视频'); 205 $exceptTags = array('视频');
206 - $news[] = Facade_News::getSameNewsById($id, $exceptTags);  
207 - $temp = Facade_News::getList(array(), 0, 5, $exceptTags);  
208 - unset($temp[$id]);  
209 - $news = array_merge($news, $temp);  
210 - $news = array_slice(array_filter($news), 0, 3); 206 + $temp = Facade_News::getSameNewsById($id, $exceptTags);
  207 + $temp2 = Facade_News::getLatestNews(array(), 0, 5, $exceptTags);
  208 + unset($temp2[$id]);
  209 + if(!empty($temp))
  210 + {
  211 + $news = array($temp['id'] => $temp);
  212 + }
  213 + $news = array_slice(array_filter($news + $temp2), 0, 3);
211 } 214 }
212 $info['title'] = strip_tags($info['title']); 215 $info['title'] = strip_tags($info['title']);
213 $info['pics'] = array_filter(explode('|', $info['pics'])); 216 $info['pics'] = array_filter(explode('|', $info['pics']));
@@ -231,11 +234,14 @@ EOT; @@ -231,11 +234,14 @@ EOT;
231 $tag = '视频'; 234 $tag = '视频';
232 $exceptTags = array('手机视频'); 235 $exceptTags = array('手机视频');
233 $recom = array(); 236 $recom = array();
234 - $recom[] = Facade_News::getSameNewsById($id, $exceptTags);  
235 - $temp = Facade_News::getList(array(), 0, 5, $exceptTags);  
236 - unset($temp[$id]);  
237 - $recom = array_merge($recom, $temp);  
238 - $recom = array_slice(array_filter($recom), 0, 3); 237 + $temp = Facade_News::getSameNewsById($id, $exceptTags);
  238 + $temp2 = Facade_News::getLatestNews(array(), 0, 5, $exceptTags);
  239 + unset($temp2[$id]);
  240 + if(!empty($temp))
  241 + {
  242 + $recom = array($temp['id'] => $temp);
  243 + }
  244 + $recom = array_slice(array_filter($recom + $temp2), 0, 3);
239 $hotVideo = array_values(Facade_News::getListByDateHits($tag, 0, 5, $exceptTags)); 245 $hotVideo = array_values(Facade_News::getListByDateHits($tag, 0, 5, $exceptTags));
240 $lastVideo = array_values(Facade_News::getLatestNews($tag, 0, 5, $exceptTags)); 246 $lastVideo = array_values(Facade_News::getLatestNews($tag, 0, 5, $exceptTags));
241 $list['recom'] = $recom; 247 $list['recom'] = $recom;
@@ -273,7 +273,7 @@ class Facade_News @@ -273,7 +273,7 @@ class Facade_News
273 $news = array(); 273 $news = array();
274 if(!empty($ids)) 274 if(!empty($ids))
275 { 275 {
276 - $news = self::service()->getNewsByOrderId($ids, $exceptTags); 276 + $news = self::service()->getNewsByIds($ids, $exceptTags);
277 } 277 }
278 return $news; 278 return $news;
279 } 279 }
@@ -256,7 +256,7 @@ class Service_News extends Lib_Service @@ -256,7 +256,7 @@ class Service_News extends Lib_Service
256 * @param array $exceptTags 256 * @param array $exceptTags
257 * @return int 257 * @return int
258 */ 258 */
259 - public function getNewsByOrderId($ids, $exceptTags) 259 + public function getNewsByIds($ids, $exceptTags)
260 { 260 {
261 $exceptWhere = "1"; 261 $exceptWhere = "1";
262 if(is_numeric($ids)) 262 if(is_numeric($ids))
@@ -269,7 +269,7 @@ class Service_News extends Lib_Service @@ -269,7 +269,7 @@ class Service_News extends Lib_Service
269 $exceptTags = implode("','", $exceptTags); 269 $exceptTags = implode("','", $exceptTags);
270 $exceptWhere = " `tag` NOT IN ('$exceptTags') "; 270 $exceptWhere = " `tag` NOT IN ('$exceptTags') ";
271 } 271 }
272 - return self::service(self::ROUTER)->tag(self::$_tag)->fetchRow('getNewsByOrderId', array('order_ids' => $ids), 272 + return self::service(self::ROUTER)->tag(self::$_tag)->fetchRow('getNewsByIds', array(),
273 array('where'=> $exceptWhere, 'ids'=> $ids)); 273 array('where'=> $exceptWhere, 'ids'=> $ids));
274 } 274 }
275 275
@@ -284,7 +284,8 @@ class Service_News extends Lib_Service @@ -284,7 +284,8 @@ class Service_News extends Lib_Service
284 */ 284 */
285 public static function getLatestNews($tag, $offset, $limit, $exceptTags = array()) 285 public static function getLatestNews($tag, $offset, $limit, $exceptTags = array())
286 { 286 {
287 - $exceptWhere = "1"; 287 + $exceptWhere = '1';
  288 + $where = '1';
288 if(is_array($exceptTags) && !empty($exceptTags)) 289 if(is_array($exceptTags) && !empty($exceptTags))
289 { 290 {
290 $exceptTags = implode("','", $exceptTags); 291 $exceptTags = implode("','", $exceptTags);
@@ -45,8 +45,8 @@ @@ -45,8 +45,8 @@
45 <select id="getListByHits"> 45 <select id="getListByHits">
46 SELECT * FROM tbl_news WHERE `tag` = :tag AND #where# ORDER BY hits DESC LIMIT :offset, :limit 46 SELECT * FROM tbl_news WHERE `tag` = :tag AND #where# ORDER BY hits DESC LIMIT :offset, :limit
47 </select> 47 </select>
48 - <select id="getNewsByOrderId">  
49 - SELECT * FROM tbl_news WHERE #where# AND id IN (#ids#) ORDER BY FIND_IN_SET(id, :order_ids) 48 + <select id="getNewsByIds">
  49 + SELECT * FROM tbl_news WHERE #where# AND id IN (#ids#) ORDER BY create_time DESC
50 </select> 50 </select>
51 <select id="getLatestNews"> 51 <select id="getLatestNews">
52 SELECT * FROM `tbl_news` #where# order by create_time DESC LIMIT :offset, :limit 52 SELECT * FROM `tbl_news` #where# order by create_time DESC LIMIT :offset, :limit