/** * 组装竞价列表 * @param $out * @return array */ private static function prepareBidList(&$out) { $out['bidList'] = array(); $out['bidProIds'] = array(); // 获取计划 $validBidPlans = Model_Plan_HzPlanBasic::getBidPlansByBrokerId($out['hzBrokerId']); if (empty($validBidPlans)) { return array(); } $planIds = array(); $allPlanIds = array(); foreach ($validBidPlans as $plan) { if ($plan['flag'] == 1 && $plan['status'] != Const_HzPlan::DELETE) { $planIds[] = $plan['id']; } $allPlanIds[] = $plan['id']; } // 获取关系 $bidPlannings = Model_Plan_HzPlanning::getPlanningByPlanIds($planIds); // 获取竞价消费信息 //$out['bidComsume'] = Bll_Plan_Bid_HzBid::getBidPlanConsumeAndClickInfos($allPlanIds, date('Ymd')); $out['bidComsume'] = Model_Stats_PropClick::getBillingInfo($out['hzBrokerId'], $out['cityId'], date('Ymd')); if (empty($bidPlannings)) { return array(); } // 组装 foreach ($validBidPlans as $plan) { $planId = $plan['id']; // 拼接关系 foreach ($bidPlannings as $bidPlanning) { $proId = $bidPlanning['proid']; if ($planId != $bidPlanning['plan_id']) { continue; } $out['bidList'][$planId] = $plan; $out['bidList'][$planId]['planning'] = $bidPlanning; // 拼接房子 $prop = isset($out['props'][$proId]) ? $out['props'][$proId] : array(); if (empty($prop)) { unset($out['bidList'][$planId]); continue; } $out['bidList'][$planId]['prop'] = $prop; // 算竞价排名 if ($plan['status'] == Const_HzPlan::SPREAD) { $rank = Bll_Plan_Bid_HzBid::getBidRank($prop['proid'], $prop['commid'], $prop['pricenum'], $bidPlanning['unit_price'], $out['cityId']); } else { $rank = '已暂停'; } $out['bidList'][$planId]['rank'] = $rank; $out['bidProIds'][] = $proId; } } // 排序 前5名 排队 停止 usort($out['bidList'], function ($a, $b) { return is_numeric($a['rank']) && !is_numeric($b['rank']) ? -1 : 1; }); usort($out['bidList'], function ($a, $b) { return $a['rank'] == '已暂停' && $b['rank'] != '已暂停' ? 1 : -1; }); foreach ($out['bidList'] as $k => $v) { $out['bidList'][$v['id']] = $v; unset($out['bidList'][$k]); } // 获取房源竞价点击 if (count($out['bidProIds']) > 0) { $out['bidClicks'] = Bll_Plan_Bid_HzBid::getPropsBidClick($out['bidProIds'], $out['cityId'], $out['hzBrokerId']); } }
public function handle_request_internal() { /* @params planId :计划id @params resType :默认为0,0表示不取计划房源信息,1为取房源信息 @params from :来源 @success return 该计划id的信息 */ if (!isset($this->_params['brokerId'])) { return Util_MobileAPI::error(Const_APIStatus::E_PLAN_PARAM_BROKERID_MISS); } $brokerId = $this->_params['brokerId']; //根据安居客经纪人ID获取好租经纪人ID $brokerId_hz = Bll_HzBroker::get_brokerid_by_ajk_brokerid($brokerId); if ($brokerId_hz) { $broker_info = Dao_Broker_HzPlan::get_hzbroker_info($brokerId_hz); if (!Bll_City::isBidCity($broker_info['cityid'])) { return array('status' => 'ok', 'data' => array('propertyList' => array())); } } if (Bll_Broker_HzBroker::isComboBroker($brokerId)) { //获取套餐推广房源列表 $comboList = Bll_Combo_HouseRelation::getHouseRelations($brokerId, Bll_Combo_HouseRelation::SITE_TYPE_HZ, 1); if (!empty($comboList)) { foreach ($comboList as $combo) { $comboIds[$combo['houseId']] = 1; } //获取竞价房源 去除竞价房源 $validBidPlans = Model_Plan_HzPlanBasic::getBidPlansByBrokerId($brokerId_hz); $planIds = array(); if (!empty($validBidPlans)) { foreach ($validBidPlans as $plan) { if ($plan['flag'] == 1 && $plan['status'] != Const_HzPlan::DELETE) { $planIds[] = $plan['id']; } } if (!empty($planIds)) { $bidPlannings = Model_Plan_HzPlanning::getPlanningByPlanIds($planIds); } if (!empty($bidPlannings)) { foreach ($bidPlannings as $bid) { unset($comboIds[$bid['proid']]); } } } //$propertyList = Model_House_HzProp::getPropsByPropIds(array_keys($comboIds)); $propertyList = Dao_Broker_HzProp::get_prop(array_keys($comboIds)); if (!empty($propertyList)) { foreach ($propertyList as $key => $list) { if ($list['content_basic']['quality'] != 1) { unset($propertyList[$key]); } } } $result = $propertyList; } else { $result = array(); } //去除竞价房源和非多图房源 } else { $result = Bll_HzBidPlan::get_canbid_props($brokerId_hz); } $return = array(); $return["status"] = "ok"; $return["data"]['propertyList'] = array(); if (!empty($result)) { $proprow = array(); foreach ($result as $propertyList) { $proprow["id"] = $propertyList['proid']; $proprow["title"] = $propertyList['content_basic']['title']; $proprow["commId"] = $propertyList['content_basic']['commid']; $proprow["commName"] = $propertyList['content_basic']['commname']; $proprow["roomNum"] = $propertyList['content_basic']['roomnum']; $proprow["hallNum"] = $propertyList['content_basic']['hallnum']; $proprow["toiletNum"] = $propertyList['content_basic']['toilnetnum']; $proprow["area"] = round($propertyList['content_basic']['areanum']); $proprow["price"] = round($propertyList['content_basic']['pricenum']); $proprow["isMoreImg"] = $propertyList['content_basic']['quality'] ? 1 : 0; $proprow["priceUnit"] = "元"; $return["data"]['propertyList'][] = $proprow; unset($proprow); } unset($result); } return $return; }