Exemplo n.º 1
0
 function actionRecommendItems()
 {
     header('Content-type: application/json');
     if (!IjoyPlusServiceUtils::validateAPPKey()) {
         IjoyPlusServiceUtils::exportServiceError(Constants::APP_KEY_INVALID);
         return;
     }
     $page_size = Yii::app()->request->getParam("page_size");
     $page_num = Yii::app()->request->getParam("page_num");
     if (!(isset($page_size) && is_numeric($page_size))) {
         $page_size = 10;
         $page_num = 1;
     } else {
         if (!(isset($page_num) && is_numeric($page_num))) {
             $page_num = 1;
         }
     }
     $vod_type = Yii::app()->request->getParam("vod_type");
     if ($vod_type === '1') {
         $top_id = '7280';
     } else {
         if ($vod_type === '2') {
             $top_id = '7282';
         } else {
             if ($vod_type === '131') {
                 $top_id = '7284';
             }
         }
     }
     if (!isset($top_id) || is_null($top_id)) {
         IjoyPlusServiceUtils::exportServiceError(Constants::PARAM_IS_INVALID);
         return;
     }
     try {
         $lists = SearchManager::listItems($top_id, $page_size, $page_size * ($page_num - 1));
         if (isset($lists) && is_array($lists)) {
             IjoyPlusServiceUtils::exportEntity(array('items' => $lists));
         } else {
             IjoyPlusServiceUtils::exportEntity(array('items' => array()));
         }
     } catch (Exception $e) {
         Yii::log(CJSON::encode($e), "error");
         IjoyPlusServiceUtils::exportServiceError(Constants::SYSTEM_ERROR);
     }
 }
Exemplo n.º 2
0
 public static function listsByProdType($userid, $limit, $offset, $type, $prodType)
 {
     $device = IjoyPlusServiceUtils::getDevice();
     $where = '';
     if ($device === false) {
         $key = SearchManager::CACHE_LISTS_BY_TYPE_LIMIT_OFFSET . '_USER_' . $userid . '_LIMIT_' . $limit . '_OFFSET_' . $offset . '_type_' . $prodType;
     } else {
         $where = ' AND (can_search_device like \'%' . $device . '%\' or can_search_device is null or can_search_device =\'\' ) ';
         $key = SearchManager::CACHE_LISTS_BY_TYPE_LIMIT_OFFSET . '_USER_' . $userid . '_LIMIT_' . $limit . '_OFFSET_' . $offset . '_type_' . $prodType . '_DEVICE_' . $device;
     }
     $lists = CacheManager::getValueFromCache($key);
     if ($lists) {
         return $lists;
     }
     if ($userid > 0) {
         $lists = Yii::app()->db->createCommand()->select('t_id as id, t_name as name, t_type as prod_type, 	t_pic as pic_url,t_des as content')->from('mac_vod_topic ')->where('t_userid=:t_userid and t_id>4 and t_type in (' . $prodType . ')' . $where, array(':t_userid' => $userid))->order('t_sort desc,create_date desc ')->limit($limit)->offset($offset)->queryAll();
     } else {
         $lists = Yii::app()->db->createCommand()->select('t_id as id, t_name as name, t_type as prod_type, 	t_pic as pic_url,t_des as content')->from('mac_vod_topic ')->where('t_flag=:t_flag and t_id>4 and t_bdtype=:type and t_type in (' . $prodType . ')' . $where, array(':t_flag' => 1, ':type' => $type))->order('t_sort desc,create_date desc ')->limit($limit)->offset($offset)->queryAll();
     }
     $temp = array();
     if (isset($lists) && is_array($lists)) {
         foreach ($lists as $list) {
             $items = SearchManager::listItems($list['id'], SearchManager::USER_TOPS_LIST_ITEM_NUM, 0);
             if (isset($items) && is_array($items) && count($items) > 0) {
                 $list['items'] = $items;
                 if (!(isset($list['pic_url']) && is_null($list['pic_url']))) {
                     $list['pic_url'] = $items[0]['prod_pic_url'];
                 }
                 $list['big_pic_url'] = $items[0]['big_prod_pic_url'];
             }
             $temp[] = $list;
         }
         if (count($temp) > 0) {
             $prodExpired = CacheManager::getExpireByCache(CacheManager::CACHE_PARAM_EXPIRED_POPULAR_PROGRAM);
             CacheManager::setValueToCache($key, $temp, $prodExpired);
         }
     }
     return $temp;
 }