private function getClickInfoAction($brokerId, $cityId, $params) { if (!isset($params['plan_type']) || !isset($params['propIds'])) { return $this->buildResponse('error', array(), '非法请求。'); } $houseIds = is_array($params['propIds']) ? $params['propIds'] : explode(',', $params['propIds']); $houseClickInfo = array_fill_keys($houseIds, 0); /** 获取套餐推广的房源的点击量 */ if ($params['plan_type'] == 'combo') { $houseClickInfo = Bll_House_EsfHouse::getHouseTodayComboClick($houseIds); if (isset($params['type']) && $params['type'] == 'today') { $bidHouseClickInfo = Bll_Plan_Bid_AjkPlan::getHouseBidClick($houseIds, $cityId, date('Ymd')); foreach ($bidHouseClickInfo as $houseId => $click) { $houseClickInfo[$houseId] += $click; } return $this->buildResponse('ok', $houseClickInfo, '获取房源今日点击量成功。'); } if (isset($params['type']) && $params['type'] == 'all') { $houseAccumulateClickInfo = Bll_House_EsfHouse::getComboHouseAccumulateClick($brokerId, $houseIds, $cityId); foreach ($houseAccumulateClickInfo as $houseId => $click) { $houseClickInfo[$houseId] += $click; } $houseChoiceClickList = Model_Choice_PropClickCount::getChoiceClickInfo($brokerId, $cityId, $houseIds); foreach ($houseChoiceClickList as $houseChoiceClick) { $houseClickInfo[$houseChoiceClick['propId']] += $houseChoiceClick['count']; } return $this->buildResponse('ok', $houseClickInfo, '获取房源累计点击量成功。'); } } if ($params['plan_type'] == 'bid') { return $this->buildResponse('ok', Bll_Plan_Bid_AjkPlan::getHouseBidClick($houseIds, $cityId, date('Ymd')), ''); } return $this->buildResponse('ok', $houseClickInfo, '请求失败。'); }
public function handle_request_internal() { $request = APF::get_instance()->get_request(); $houseIds = $request->get_parameter('propIds'); /** * type: today, all */ $type = $request->get_parameter('type'); /** * plan_type: bid, fix */ $planType = $request->get_parameter('plan_type'); $rtn = array_fill_keys($houseIds, 0); if (strcasecmp($planType, 'fix') === 0) { /** * 定价房源点击量 */ if (strcasecmp($type, 'today') == 0 && !empty($houseIds)) { /** * 房源今日点击量 */ $date = date('Ymd'); // $houseClickInfoList = Bll_Ppc_ServiceAPI::getHouseClickInfo($houseIds, strtotime(date('Y-m-d 00:00:00')), time(), static::$intBrokerID); $houseClickInfoList = Bll_Ppc_ServiceAPI::getHouseClickInfoNew(static::$intBrokerID, $houseIds, $date, $date); foreach ($houseClickInfoList as $houseClickInfo) { $rtn[$houseClickInfo['propId']] += max(0, $houseClickInfo['clickNum']); } /** * 精选点击 */ $choiceClickList = Bll_Plan_Bid_AjkPlan::getHouseBidClick($houseIds, static::$intBrokerCityID, date('Ymd')); foreach ($choiceClickList as $houseId => $clickCount) { $rtn[$houseId] += $clickCount; } } else { /** * 房源累计点击量 */ $fixPlanIdList = Bll_Plan_Fix_AjkPlan::getBrokerPlanList(static::$intBrokerID); if (empty($fixPlanIdList)) { $rtn = array(); } else { $fixPlanId = $fixPlanIdList[0]['id']; $houseClickInfoList = Bll_Ppc_ServiceAPI::propFixClickNum(static::$intBrokerID, $houseIds, $fixPlanId); foreach ($houseClickInfoList as $houseClickInfo) { $rtn[$houseClickInfo['propId']] = max(0, $houseClickInfo['clickNum']); } } $houseChoiceClickList = Model_Choice_PropClickCount::getChoiceClickInfo(static::$intBrokerID, static::$intBrokerCityID, $houseIds); foreach ($houseChoiceClickList as $houseChoiceClick) { $rtn[$houseChoiceClick['propId']] += $houseChoiceClick['count']; } } } else { /** * 竞价今日点击量 */ $rtn = Bll_Plan_Bid_AjkPlan::getHouseBidClick($houseIds, static::$intBrokerCityID, date('Ymd')); } echo json_encode($rtn, JSON_FORCE_OBJECT); return false; }