public function handle_request() { //todo 时间限制打开 if (time() < strtotime("2013-12-16 00:00:00")) { APF::get_instance()->get_response()->redirect(Uri_ChristmasUrl::advance_url()); } //是否登录 $broker_id = APF::get_instance()->get_request()->getBrokerId(); if (!$broker_id) { $current_url = APF::get_instance()->get_request()->get_request_url(); $login_url = Uri_ChristmasUrl::login_url($current_url); $this->setAttribute('login_url', $login_url); } //愿望列表 $wish_list = Model_Christmas_BrokerWish::get_wish_list($broker_id); //愿望滚动列表 $limit = 100; $wish_list_scroll = Model_Christmas_BrokerWish::get_wish_list_scroll($limit); //获奖名单 //$award_list = Model_Christmas_WishAward::get_award_list(); $award_list = array('孙绍光 137****9280 (北京) 获得 移动电源', '叶剑锋 136****6215 (上海) 获得 移动电源', '王毓秀 151****0593 (苏州) 获得 移动电源', '谢超华 132****1293 (郑州) 获得 移动电源', '杨红伟 189****5973 (成都) 获得 移动电源', '曾美林 186****6391 (杭州) 获得 移动电源', '沈政 182****9657 (上海) 获得 剃须刀', '李淑园 139****4069 (大连) 获得 移动电源', '缪宏冰 137****1143 (福州) 获得 剃须刀', '林俊泉 136****8440 (深圳) 获得 移动电源', '周燕芳 186****1587 (长沙) 获得 移动电源', '杨玉梅 159****2794 (珠海) 获得 移动电源', '刘智聪 180****9828 (厦门) 获得 剃须刀', '王甲甲 135****9917 (青岛) 获得 移动电源', '冉学文 151****7214 (重庆) 获得 移动电源', '李红 182****8269 (南京) 获得 移动电源', '陈勇鑫 135****0959 (广州) 获得 剃须刀', '李彦龙 182****6207 (上海) 获得 移动电源', '李鑫博 155****4944 (天津) 获得 移动电源', '张海洋 182****1449 (北京) 获得 剃须刀'); //是否显示许愿框 //是否发表过 $my_wish = Model_Christmas_BrokerWish::get_my_wish($broker_id); $broker_flag = empty($my_wish) ? true : false; $this->setAttribute('broker_id', $broker_id); $this->setAttribute('wish_list', $wish_list['text']); $this->setAttribute('wish_list_scroll', $wish_list_scroll); $this->setAttribute('broker_flag', $broker_flag); $this->setAttribute('award_list', $award_list); return 'Christmas_Wish'; }
public function handle_request() { $is_christmas_test = APF::get_instance()->get_config('is_christmas_test', 'christmas'); if (!$is_christmas_test) { if (time() < strtotime("2013-12-16 00:00:00")) { APF::get_instance()->get_response()->redirect(Uri_ChristmasUrl::advance_url()); } } $isLoggedIn = $this->isBrokerLogin(); $this->setAttribute('BrokerIsLoggedIn', $isLoggedIn); // 获取缓存实例 $cache = APF_Cache_Factory::get_instance()->get_memcache(); // CurrentRoundTime & NextRoundTime $currentRoundTime = null; $nextRoundTime = null; $startDate = Util_Christmas::hammerRushStartDate(); $endDate = Util_Christmas::hammerRushEndDate(); if (!Util_Christmas::hammerRushStarted()) { $currentRoundTime = null; $nextRoundTime = date("{$startDate} 10:00:00"); } elseif (!Util_Christmas::hammerRushEnded()) { $currentHour = date('H'); if ($currentHour < 10) { if (date('Y-m-d') != $startDate) { $currentRoundTime = date('Y-m-d 18:00:00', strtotime('-1 day')); } $nextRoundTime = date('Y-m-d 10:00:00'); } elseif ($currentHour >= 10 && $currentHour < 14) { $currentRoundTime = date('Y-m-d 10:00:00'); $nextRoundTime = date('Y-m-d 14:00:00'); } elseif ($currentHour >= 14 && $currentHour < 18) { $currentRoundTime = date('Y-m-d 14:00:00'); $nextRoundTime = date('Y-m-d 18:00:00'); } elseif ($currentHour >= 18) { $currentRoundTime = date('Y-m-d 18:00:00'); if (date('Y-m-d') != $endDate) { $nextRoundTime = date('Y-m-d 10:00:00', strtotime('+1 day')); } } } $this->setAttribute('CurrentRoundTime', $currentRoundTime); $this->setAttribute('NextRoundTime', $nextRoundTime); // IsRushable $isRushable = false; // 当前在可抢时间范围内 if ($currentRoundTime && time() < strtotime($currentRoundTime) + 30 * 60) { $isRushable = true; } // 当前可抢开关 $result = $cache->get(Util_Christmas::hammerIsRushableCacheKey($currentRoundTime)); if ($result !== FALSE) { $isRushable = (bool) $result; } $this->setAttribute('IsRushable', $isRushable); $this->setAttribute('IsEnd', Util_Christmas::hammerRushEnded()); if ($isLoggedIn) { $brokerId = self::$intBrokerID; self::$BrokerInfo = Bll_BrokerBaseBll::get_instance()->get_broker_info($brokerId, true); $this->setAttribute('BrokerName', $this->request->getUserName()); $isCheckedState = isset(self::$BrokerInfo['BaseInfo'][strtoupper('checkstate')]) && self::$BrokerInfo['BaseInfo'][strtoupper('checkstate')]; $this->setAttribute('BrokerIsCheckedState', $isCheckedState); $gradeScore = isset(self::$BrokerInfo['BaseInfo'][strtoupper('gradescore')]) ? self::$BrokerInfo['BaseInfo'][strtoupper('gradescore')] : 0; $this->setAttribute('BrokerGradeScore', $gradeScore); $exchangeHammerNumber = Model_Christmas_HammerLog::data_access()->filter_by_op('brokerId', '=', $brokerId)->filter_by_op('type', '=', Model_Christmas_HammerLog::TYPE_GRADE_EXCHANGE)->count(); $isExchangeable = $exchangeHammerNumber < 3; $this->setAttribute('IsExchangeAble', $isExchangeable); $brokerHammer = Model_Christmas_BrokerHammer::fetchBrokerHammerByBrokerId($brokerId, true); $this->setAttribute('BrokerHammerNumber', $brokerHammer->number); } else { $this->setAttribute('BrokerLoginUrl', Uri_ChristmasUrl::login_url($this->request->get_request_url())); } return 'Christmas_Hammer'; }
public function handle_request() { $objRequest = APF::get_instance()->get_request(); //时间开关 $is_christmas_test = APF::get_instance()->get_config('is_christmas_test', 'christmas'); if (!$is_christmas_test) { if (time() < strtotime("2013-12-16 00:00:00")) { APF::get_instance()->get_response()->redirect(Uri_ChristmasUrl::advance_url()); } self::$intBrokerID = $objRequest->getBrokerId(); } else { self::$intBrokerID = $objRequest->getBrokerId(); } $bllBrokerHome = Bll_BrokerHomeBll::get_instance(); $BrokerName = $bllBrokerHome->get_broker_name(); //获取经纪人和锤子信息 $broker_hammer_obj = Model_Christmas_BrokerHammer::fetchBrokerHammerByBrokerId(self::$intBrokerID); //获取城市配置 $city_config = APF::get_instance()->get_config('cities', 'multicity'); //获取获奖信息 $win_prize_obj = Model_Christmas_PrizeLog::get_win_prize_info(); $win_prize_info = array(); foreach ($win_prize_obj as $win_prize) { if ($win_prize->type >= 8) { continue; } $prize_name = $this->get_prize_name($win_prize->type); $broker_name = mb_substr($win_prize->broker_name, 0, 1, 'utf8') . "XX"; $mobile = substr($win_prize->mobile, 0, 3) . "****" . substr($win_prize->mobile, -4); $type = $win_prize->type <= 3 ? 1 : 0; $win_prize_info[] = array("name" => $broker_name, "tel" => $mobile . "(" . $city_config[$win_prize->city_id] . ")", "prize" => $prize_name, "type" => $type); } //是否登陆 if (self::$intBrokerID) { $this->setAttribute('is_login', true); } else { $this->setAttribute('is_login', false); } //判断是不是活动时间 if (date("Ymd") == '20131225' || $is_christmas_test) { $this->setAttribute('is_begin', true); } else { $this->setAttribute('is_begin', false); } $this->setAttribute('BrokerName', $BrokerName); $this->setAttribute('broker_hammer_num', $broker_hammer_obj->number ? $broker_hammer_obj->number : 0); $this->setAttribute('win_prize_info', json_encode($win_prize_info)); $this->setAttribute('broker_id', self::$intBrokerID); if (time() > strtotime("2013-12-25 00:00:00") || $is_christmas_test) { //正是砸蛋的逻辑 //.... $pageName = "Christmas_GoldenEgg"; } else { //砸蛋预告页 $pageName = "Christmas_GoldenEggAdvance"; } /* * 前端开发暂用 */ return $pageName; }