/** * 获取经纪人app相关信息 * @param $brokerId * @param string $calDt * @return array|mixed|null */ public static function getInfoByBrokerId($brokerId, $calDt = '') { try { if (!$calDt) { $calDt = date('Y-m-d', strtotime('-1 day')); } return Model_WeiLiao_WeiLiao::data_access()->filter_by_op('brokerId', '=', $brokerId)->filter_by_op('calDt', '=', $calDt)->get_row(); } catch (Exception $e) { return array(); } }
public function handle_request() { // 是否登陆判断 if (!$this->isBrokerLogin()) { $current_url = $this->request->get_request_url(); $login_url = Uri_ChristmasUrl::login_url($current_url); $this->response->redirect($login_url); exit; } $this->out['brokerId'] = $this->request->getBrokerId(); $this->out['cityId'] = $this->request->getBrokerCityId(); $this->out['userId'] = $this->request->getUserId(); // 是否登陆判断 /*if(!$this->out['brokerId']){ $current_url = $this->request->get_request_url(); $login_url = Uri_ChristmasUrl::login_url($current_url); $this->response->redirect($login_url);exit; }*/ $weiLiaoInfo = Model_WeiLiao_WeiLiao::getInfoByBrokerId($this->out['brokerId']); // 是否参加城市 $this->out['isJoinCity'] = in_array($this->out['cityId'], $this->config['join_citys']); // 不参加城市跳转 if (in_array($this->out['cityId'], $this->config['no_join_citys'])) { $this->response->redirect('http://pages.anjuke.com/broker/flashman/flashman_noact.html'); } // 获取已申请位数 $hasApplysNum = Model_WeiLiao_FlashMan::getWeekHasApplysNum($this->out['cityId']); $hasApplys = Model_WeiLiao_FlashMan::getWeekApplys($this->out['cityId']); // 本轮是否参加过 $this->out['isNoJoin'] = true; if ($hasApplys) { foreach ($hasApplys as $key => $apply) { if ((int) $apply['brokerId'] == (int) $this->out['brokerId']) { $this->out['isNoJoin'] = false; $temp = date('H:i', $apply['startTime']) . '~' . date('H:i', $apply['endTime']) . ',' . date('H:i', $hasApplys[$key + 1]['startTime']) . '~' . date('H:i', $hasApplys[$key + 1]['endTime']); $this->out['isJointip'] = '展示时间 ' . date('m', strtotime($apply['onDay'])) . '月' . date('d', strtotime($apply['onDay'])) . '日:' . $temp; break; } } } $this->out['shengNum'] = $hasApplysNum ? 84 - $hasApplysNum : 84; // 活动是否开启 $this->out['isOpen'] = false; if (time() > strtotime($this->config['start_time']) && time() < strtotime($this->config['end_time'])) { if (isset($_GET['debug'])) { $this->out['isOpen'] = true; } else { if (date("w") == 5) { $this->out['isOpen'] = true; } } } // 是否闪电侠 $this->out['isFlashMan'] = $weiLiaoInfo && number_format($weiLiaoInfo['reply5minRate'], 3) >= 0.9 ? true : false; if (isset($_GET['debug'])) { print_r($this->out); } // ajax if (isset($_GET['method']) && $_GET['method'] == 'ajax') { if ($this->out['isOpen'] && $this->out['isFlashMan'] && $this->out['shengNum'] > 0 && $this->out['isJoinCity'] && $this->out['isNoJoin']) { // 申请 $this->doApply($hasApplys); } echo json_encode($this->out); die; } $this->setAttribute('out', $this->out); return 'WeiLiao_FlashMan'; }