Esempio n. 1
0
 public function get_event_list_for_announce($event_template = 0, $event_tag = 0)
 {
     $time = time();
     $event_list = array();
     $sql = "select * from event_master where announce_date_tail > {$time} or announce_date_tail < 86400";
     # 已经结束的活动不缓存,小于86400的意味每日活动
     $records = $this->select_all($sql, $this->get_cache_key(array('event_master' => 1), $this->prefix_event_master));
     foreach ($records as $record) {
         if (empty($record['event_status'])) {
             continue;
         }
         # 过滤掉下线活动
         if (!empty($event_template) && $record['event_template'] != $event_template) {
             continue;
         }
         # 过滤掉不需要的其它event_template类活动
         if (!empty($event_tag) && $record['event_tag'] != $event_tag) {
             continue;
         }
         # 过滤掉不需要的其它event_tag类活动
         if (empty($record['week_frequency'])) {
             # 非每日活动
             if ($time >= $record['announce_date_head'] && $time <= $record['announce_date_tail']) {
                 $event_list[] = $record;
             }
         } else {
             # 每日活动
             if (Com_Util::check_week_frequency($time, $record['week_frequency'])) {
                 # 已开启
                 $date_start = Com_Util::get_date_start($time);
                 if ($time >= $record['announce_date_head'] + $date_start && $time <= $record['announce_date_tail'] + $date_start) {
                     # 修正每日活动的相关时间
                     $record['announce_date_head'] += $date_start;
                     $record['announce_date_tail'] += $date_start;
                     $record['open_date_head'] += $date_start;
                     $record['open_date_tail'] += $date_start;
                     $record['reward_date_head'] += $date_start;
                     $record['reward_date_tail'] += $date_start;
                     $event_list[] = $record;
                 }
             }
         }
     }
     return $event_list;
 }