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; }