public function handle_request_internal() { $brokerId = $this->_params['brokerId']; $hzBrokerId = Model_Broker_MainBusiness::getHzBrokerIdByAjkBrokerId($brokerId); $brokerInfo = Model_Broker_AjkBrokerExtend::findWithBrokerId($brokerId); if (!$brokerInfo) { throw new Exception_BrokerNotFoundException('经纪人不存在', Const_APIStatus::E_BROKER_NOT_EXISTS); } $cityId = $brokerInfo->cityId; if (!Bll_City::isChoiceCity($cityId, Const_Site::HAOZU)) { return array('status' => Const_APIStatus::RETURN_CODE_ERROR, 'errcode' => Const_APIStatus::E_NOT_CHOICE_CITY, 'message' => '非精选城市'); } $bllChoice = new Bll_Zufang_Choice(); $today = date('Ymd'); $choiceInfo = $bllChoice->get_choice_info($hzBrokerId, $today, $cityId); $todayClicks = intval($choiceInfo[0]['bidClicks']); $todayConsume = intval($choiceInfo[0]['bidConsume']) / 100; // 获取精选推广房源数(精选计划和房源一一对应) $plansIds = array(); $plans = $bllChoice->get_active_choice_plans($hzBrokerId, array(1, 13, 2, 3, 7, 8)); foreach ($plans as $plan) { $plansIds[] = $plan->id; } $props = array(); if ($plansIds) { $props = $bllChoice->get_prop($plansIds); } $totalProps = count($props); //将精选状态变化数目归零 $keyData = array('brokerId' => $brokerId, 'bizType' => Model_Mobile_PropRedDot::TYPE_CHOICE_STATUS); $data = array('num' => 0); Bll_Mobile_PropRedDot::getInstance()->updateData($keyData, $data); return array('status' => Const_APIStatus::RETURN_CODE_OK, 'data' => array('todayClicks' => $todayClicks, 'todayConsume' => Util_Formatter::formatTodayConsume($todayConsume), 'todayConsumeUnit' => '元', 'totalProps' => $totalProps)); }
/** * 判断经纪人是否可以添加房源精选订阅 * * 1. 是否已精选房源 * 2. 是否已设提醒房源 * 3. 是否具有精选资格房源:定价,多图,新发15天 * 4. 是否推广位已满 */ protected function hasAddChoiceRemindPermission() { // 是否已精选 $bllChoice = new Bll_Zufang_Choice(); $planInfo = $bllChoice->get_plan_by_proid($this->propId); if (!empty($planInfo)) { $planId = $planInfo->plan_id; $basicPlanInfo = $bllChoice->get_plan($planId); if ($basicPlanInfo[0]->status == 1 || $basicPlanInfo[0]->status == 13) { return array('code' => '', 'msg' => '房源已精选'); } } // 是否已订阅 $subscription = Model_Choice_Subscription::data_access()->filter('site', Model_Choice_Subscription::SITE_RENT)->filter('propId', $this->propId)->filter('bucketId', $this->bucket['id'])->find_only(); if ($subscription && $subscription['status'] == Model_Choice_Subscription::SUBSCRIPTION_START) { return array('code' => '', 'msg' => '推广位已订阅'); } // 是否可精选 // - 是否已定价/套餐 // - 是否多图 // - 是否新发15天 //套餐经纪人 还是ppc经纪人 /*$IsComboBroker = Bll_Broker_HzBroker::isComboBroker($this->brokerId); if ($IsComboBroker) { //是否套餐推广 $comboHouseRelation = Model_Combo_HouseRelation::getOnlineHousebyHouseId($this->brokerId, $this->propId, $this->broker['cityId'], Model_Combo_HouseRelation::SITE_TYPE_HZ); if(empty($comboHouseRelation)) { return array( 'code' => '', // TODO 'msg' => '不满足精选推广添加:套餐推广', ); } } else { //PPC经纪人 判定定价计划 $fixPlan = $this->prop->getFixPlan(); if(empty($fixPlan)) { return array( 'code' => '', // TODO 'msg' => '不满足精选推广添加:定价推广', ); } }*/ if (!Bll_City::isChoiceIndependentCity($this->broker['cityId'], Const_Site::ANJUKE)) { //是否套餐推广 $comboHouseRelation = Model_Combo_HouseRelation::getOnlineHousebyHouseId($this->brokerId, $this->propId, $this->broker['cityId'], Model_Combo_HouseRelation::SITE_TYPE_HZ); if (empty($comboHouseRelation)) { return array('code' => '', 'msg' => '不满足精选推广添加:套餐推广'); } } if (!($this->prop->isMultiImages() && $this->prop->getPublishedDays() <= 15)) { return array('code' => '', 'msg' => '不满足精选推广添加:多图,新发15天'); } // 是否推广位已满 if (!($this->bucket['usedNum'] >= $this->bucket['totalNum'])) { return array('code' => '', 'msg' => '推广位未满'); } return true; }
public function handle_request_internal() { $brokerId = $this->_params['brokerId']; $propId = $this->_params['propId']; // 获取Broker Mapping $brokerMapping = Model_Broker_MainBusiness::getMainBusinessByAjkBrokerId($brokerId); if (!$brokerMapping) { throw new Exception('经纪人不存在', Const_APIStatus::E_BROKER_NOT_EXISTS); } // 获取房源信息 $prop = Model_House_HzProp::findByPropId($propId); if (!$prop) { throw new Exception('房源不存在', Const_APIStatus::E_PROP_NOT_EXISTS); } // 判断房源和经纪人关联关系 $contentBasic = $prop->getContentBasic(); if ($contentBasic['userid'] != $brokerMapping['hzBrokerid']) { throw new Exception('房源不属于该经纪人', Const_APIStatus::E_PROP_NOT_EXISTS); } $data = array(); $area_id = $contentBasic['areaid']; $block_id = $contentBasic['blockid']; $areaInfo = Model_City_HzArea::getAreaById($area_id); $area_name = $areaInfo['typeName']; $blockInfo = Model_City_HzArea::getAreaById($block_id); $block_name = $blockInfo['typeName']; $data['areaname'] = $area_name; $data['blockname'] = $block_name; $data['propId'] = $propId; $data['url'] = $this->build_base_url($contentBasic['cityid'], $propId); $data['title'] = $contentBasic['title']; $data['imgUrl'] = $prop->getDefaultImageUrl(); $data['commId'] = $contentBasic['commid']; $data['commName'] = $contentBasic['commname']; $data['roomNum'] = $contentBasic['roomnum']; $data['hallNum'] = $contentBasic['hallnum']; $data['toiletNum'] = $contentBasic['toilnetnum']; $data['area'] = round($contentBasic['areanum']); $data['price'] = round($contentBasic['pricenum']); $data['priceUnit'] = '元/月'; $data['isVisible'] = intval(!$prop->isIllegal()); $data['isMoreImg'] = intval($prop->isMultiImages()); $data['isBid'] = intval($prop->isBid()); $data['isChoice'] = intval($prop->isChoice()); $data['isPhonePub'] = intval($prop->isFromMobile()); $data['publishDays'] = $prop->getPublishedDays(); $data['publishDaysMsg'] = $prop->getPublishedDays() > 0 ? "{$data['publishDays']}天前发布" : '今天发布'; $data['createTime'] = date('Y-m-d H:i:s', $contentBasic['created']); $data['updateTime'] = date('Y-m-d H:i:s', $contentBasic['updated']); //增加委托房源标签 $isEntrust = Bll_Zufang_Choice::isCommissionHouse($propId, $brokerId, Model_House_Commission::TYPE_RENT); if ($isEntrust) { $data['isEntrust'] = 1; } else { $data['isEntrust'] = 0; } return array('status' => Const_APIStatus::RETURN_CODE_OK, 'data' => $data); }
public function handle_request_internal() { //根据安居客经纪人ID获取好租经纪人ID $brokerId = $this->_params['brokerId']; $brokerId_hz = Bll_HzBroker::get_brokerid_by_ajk_brokerid($this->_params['brokerId']); $city_id = $this->_params['cityId']; //get bid flg for city $choiceCityFlag = Bll_City::isChoiceCity($city_id, Const_Site::HAOZU); if ($choiceCityFlag) { return array('status' => 'ok', 'data' => array('propertyList' => array(), 'codeNum' => Const_HzErrorInfo::NOBIDCITY)); } $result = Bll_HzBidPlan::get_broker_bidprop($brokerId_hz, $city_id); if (!empty($result)) { $props = array(); foreach ($result as $key => $prop) { $prop_basic['id'] = $prop['proid']; $prop_basic['title'] = $prop['prop']['content_basic']['title']; $prop_basic['commId'] = $prop['prop']['content_basic']['commid']; $prop_basic['commName'] = $prop['prop']['content_basic']['commname']; $prop_basic['roomNum'] = $prop['prop']['content_basic']['roomnum']; $prop_basic['hallNum'] = $prop['prop']['content_basic']['hallnum']; $prop_basic['toiletNum'] = $prop['prop']['content_basic']['toilnetnum']; $prop_basic['area'] = round($prop['prop']['content_basic']['areanum']); $prop_basic['price'] = round($prop['prop']['content_basic']['pricenum']); $prop_basic['priceUnit'] = "元"; $prop_basic['bidStatus'] = $prop['plan']['status']; $prop_basic['index'] = $prop['rank']; $prop_basic['clickNum'] = $prop['clicks']; $prop_basic['offer'] = $prop['offer']; $prop_basic['budget'] = $prop['reconsume']; $prop_basic['yusuan'] = $prop['consume']; if ($prop['plan']['status'] != 1) { $prop_basic['yusuan'] = 20; $prop_basic['bidStatus'] = 3; //@todo 此处是个坑,后续要改 } //增加委托房源标签 $isEntrust = Bll_Zufang_Choice::isCommissionHouse($prop['proid'], $brokerId, Model_House_Commission::TYPE_RENT); if ($isEntrust) { $prop_basic['isEntrust'] = 1; } else { $prop_basic['isEntrust'] = 0; } $prop_basic['planId'] = $key; $props['propertyList'][] = $prop_basic; } } else { $props['propertyList'] = array(); } $ret = array('status' => 'ok', 'data' => $props); return $ret; }
public function handle_request_combo() { $brokerId = $this->brokerId; $cityId = $this->cityId; $hzBrokerId = Bll_HzBroker::get_brokerid_by_ajk_brokerid($brokerId); //获取所有有效房源 $props = Bll_House_HzHouse::getValidPropsByBrokerId($hzBrokerId, $cityId); $propertyList = array(); if (!empty($props)) { //获取套餐推广房源列表 $comboList = Bll_Combo_HouseRelation::getHouseRelations($brokerId, Bll_Combo_HouseRelation::SITE_TYPE_HZ, 1); //所有有效房源-套餐推广房源 = 套餐未推广房源 if (!empty($comboList)) { foreach ($comboList as $row) { unset($props[$row['houseId']]); } } if (!empty($props)) { // 批量获取房源的默认图片 $defaultImages = Model_Image_HzImage::getDefaultImagesByHouseIds(array_keys($props)); if (!empty($defaultImages)) { foreach ($defaultImages as $defaultImage) { $props[$defaultImage['proid']]['imgUrl'] = $defaultImage->imageUrl(); } } foreach ($props as $list) { $row = array(); $row['id'] = $row['propId'] = $list['propId']; $row['title'] = $list['title']; $row['imgUrl'] = $list['imgUrl'] ?: ''; $row['commId'] = $list['commid']; $row['commName'] = $list['commname']; $row['roomNum'] = $list['roomnum']; $row['hallNum'] = $list['hallnum']; $row['toiletNum'] = $list['toilnetnum']; $row['area'] = round($list['areanum']); $row['price'] = round($list['pricenum']); $row['priceUnit'] = '元/月'; $row['todayClicks'] = $row['totalClicks'] = $row['isBid'] = $row['isChoice'] = 0; $row['isVisible'] = (int) ($list['status'] != 6); $row['isMoreImg'] = (int) $list['quality']; $row['isPhonePub'] = (int) (isset($list['from']) && $list['from'] == 'mobile-ajk-broker'); $isEntrust = Bll_Zufang_Choice::isCommissionHouse($list['propId'], $brokerId, Model_House_Commission::TYPE_RENT); $row['isEntrust'] = $isEntrust ? 1 : 0; $row['createTime'] = date('Y-m-d H:i:s', $list['created']); $propertyList[] = $row; } } } return array('status' => Const_APIStatus::RETURN_CODE_OK, 'data' => array('propertyList' => $propertyList)); }
/** * 构造房源数据。 * @param str $proid_str * @param int $brokerId * @param array $props * @return array */ private function get_prop_info_new($proid_str, $brokerId, $props) { $effects = Bll_Prop::get_ajk_prop_effect($brokerId, $proid_str); $effect_info = array(); foreach ($effects as $effect) { $effect_info[$effect['propId']] = $effect; } $return = array(); foreach ($props as $prop) { $rooms = $halls = $toilets = $temp_b = 0; if ($prop['propInfo']['propModel']) { $model = $prop['propInfo']['propModel']; $temp_b = 0; list($rooms, $temp_a) = explode('室', $model); if ($temp_a) { list($halls, $temp_b) = explode('厅', $temp_a); } if ($temp_b) { list($toilets, $temp_c) = explode('卫', $temp_b); } } $ret = array('id' => $prop['propId'], 'title' => $prop['propInfo']['propTitle'], 'commName' => $prop['propInfo']['commName'], 'roomNum' => $rooms, 'hallNum' => $halls, 'toiletNum' => $toilets, 'area' => $prop['propInfo']['propArea'], 'price' => round($prop['propInfo']['propPrice'] / 10000, 2), 'priceUnit' => '万', 'bidStatus' => $prop['planState']['state'], 'index' => $prop['index'], 'clickNum' => $effect_info[$prop['propId']]['hpClickAmount'], 'offer' => $prop['offer'] / 100, 'budget' => $prop['balance'] / 100, 'yusuan' => $prop['budget'] / 100); //增加委托房源标签 $isEntrust = Bll_Zufang_Choice::isCommissionHouse($prop['propId'], $brokerId); if ($prop['propInfo']['commitionType'] == 2) { $ret['isEntrust'] = 1; } else { $ret['isEntrust'] = 0; } if ($prop['planState']['state'] != 1) { $ret['yusuan'] = 20; } $return[] = $ret; } return $return; }
public function handle_request_internal() { $brokerId = $this->_params['brokerId']; $houseId = $this->_params['propId']; $brokerInfo = Model_Broker_AjkBrokerExtend::findWithBrokerId($brokerId); if (!$brokerInfo) { throw new Exception_BrokerNotFoundException('经纪人不存在', Const_APIStatus::E_BROKER_NOT_EXISTS); } $cityId = $brokerInfo->cityId; $isDisplaySummary = 0; if (!Bll_City::isChoiceCity($cityId, Const_Site::HAOZU)) { $data = array('totalClicks' => 0, 'balance' => 0, 'balanceUnit' => '元', 'todayClicks' => 0, 'todayConsume' => 0, 'todayConsumeUnit' => '元', 'clickPrice' => 0, 'clickPriceUnit' => '元', 'maxBucketNum' => 0, 'usedBucketNum' => 0, 'bucketId' => '', 'status' => bll_choice_EsfAPPAPIChoice::PROP_ACTIONTYPE_CHOICE_NOTFIT, 'statusMsg' => '你所在城市未开通精选业务', 'remindStatus' => -1, 'remindStatusMsg' => '不符合精选订阅条件', 'minChoicePrice' => 0, 'minChoicePriceUnit' => '元', 'maxChoicePrice' => 0, 'maxChoicePriceUnit' => '元', 'isDisplaySummary' => $isDisplaySummary); return array('status' => Const_APIStatus::RETURN_CODE_OK, 'data' => $data); } $isDisplaySummary = 1; //获取该房子的精选计划 $bllChoice = new Bll_Zufang_Choice(); $planInfo = $bllChoice->get_plan_by_proid($houseId); $amount = 0; $totalConsume = 0; if ($planInfo) { $planId = $planInfo->plan_id; $planBasicInfo = $bllChoice->get_plan($planId); $amount = $planBasicInfo[0]->amount; $totalConsume = $planBasicInfo[0]->total_consume; } //获取 blockId, priceId $propInfo = $bllChoice->get_prop_content($houseId); if (empty($propInfo)) { return array('status' => Const_APIStatus::RETURN_CODE_ERROR, 'errcode' => '', 'message' => '房源不存在'); } $content = json_decode($propInfo[0]->contentBasic, true); $price = intval($content['pricenum']); $blockId = $content['blockid']; $priceInfo = Bll_Choice_HzBidBucket::getPriceIntervalInfo($cityId, $price); $priceId = $priceInfo['id']; //获取坑位信息 $bucketInfo = Bll_Choice_HzBidBucket::getBucketInfo($blockId, $priceId); // 获取点击单价 try { $clickPriceInfo = Bll_Service_Choice::hzClickPrice(array('cityId' => $cityId, 'price' => (int) $price, 'blockId' => $blockId, 'brokerId' => $brokerId)); if ($clickPriceInfo['status'] == 'error') { return array('status' => Const_APIStatus::RETURN_CODE_ERROR, 'errcode' => '', 'message' => '系统繁忙(code:-33)'); } } catch (Exception $e) { return array('status' => Const_APIStatus::RETURN_CODE_ERROR, 'errcode' => '', 'message' => '系统繁忙(code:-33)'); } $clickPrice = $clickPriceInfo['realTradeAmount'] / 100; $remindStatus = -1; // -1 不符合精选订阅条件 $remindStatusMsg = '不符合精选订阅条件'; if ($planInfo && $planInfo->is_valid == 1) { $date = date('Ymd'); $propChoice = $bllChoice->get_prop_choice_info($houseId, $date, $cityId); $todayClicks = intval($propChoice[0]['bidClicks']); $todayConsume = intval($propChoice[0]['bidConsume']) / 100; $totalClicksInfo = $bllChoice->get_prop_choice_clicks($houseId, $cityId); $totalClicks = intval($totalClicksInfo[0]['bidClicks']); $balance = $amount - $totalConsume; return array('status' => Const_APIStatus::RETURN_CODE_OK, 'data' => array('todayClicks' => $todayClicks, 'todayConsume' => round($todayConsume, 2), 'todayConsumeUnit' => '元', 'totalClicks' => $totalClicks, 'balance' => round($balance, 2), 'balanceUnit' => '元', 'clickPrice' => round($clickPrice, 2), 'clickPriceUnit' => '元', 'maxBucketNum' => 20, 'usedBucketNum' => $bucketInfo['usedNum'], 'minChoicePrice' => 20, 'minChoicePriceUnit' => '元', 'maxChoicePrice' => 50, 'maxChoicePriceUnit' => '元', 'status' => '1-1', 'statusMsg' => '推广中', 'remindStatus' => $remindStatus, 'remindStatusMsg' => $remindStatusMsg, 'isDisplaySummary' => $isDisplaySummary)); } else { if ($planInfo && $planInfo->is_valid == 13) { $totalClicksInfo = $bllChoice->get_prop_choice_clicks($houseId, $cityId); $totalClicks = intval($totalClicksInfo[0]['bidClicks']); $rank = Bll_Plan_Bid_HzBid::getChoiceWaitPosition($planInfo->plan_id, $cityId, $blockId, $priceId); return array('status' => Const_APIStatus::RETURN_CODE_OK, 'data' => array('clickPrice' => round($clickPrice, 2), 'clickPriceUnit' => '元', 'totalClicks' => $totalClicks, 'balance' => round($amount, 2), 'balanceUnit' => '元', 'maxBucketNum' => 20, 'usedBucketNum' => $bucketInfo['usedNum'], 'minChoicePrice' => 20, 'minChoicePriceUnit' => '元', 'maxChoicePrice' => 50, 'maxChoicePriceUnit' => '元', 'status' => '1-2', 'statusMsg' => "{$rank}", 'remindStatus' => $remindStatus, 'remindStatusMsg' => $remindStatusMsg, 'isDisplaySummary' => $isDisplaySummary)); } else { //判断是否符合精选条件 多图 + 新发15天 if (false == $content['quality'] || date('Ymd', strtotime('-16 days')) > date('Ymd', $content['created'])) { return array('status' => Const_APIStatus::RETURN_CODE_OK, 'data' => array('clickPrice' => round($clickPrice, 2), 'clickPriceUnit' => '元', 'maxBucketNum' => 20, 'usedBucketNum' => $bucketInfo['usedNum'], 'minChoicePrice' => 20, 'minChoicePriceUnit' => '元', 'maxChoicePrice' => 50, 'maxChoicePriceUnit' => '元', 'status' => '3-2', 'statusMsg' => '精选推广条件:多图+新发15天', 'remindStatus' => $remindStatus, 'remindStatusMsg' => $remindStatusMsg, 'isDisplaySummary' => $isDisplaySummary)); } } } if ($bucketInfo['usedNum'] >= $bucketInfo['totalNum']) { $status = '2-1'; $statusMsg = '推广位已满'; } else { if ($bucketInfo['usedNum'] >= $bucketInfo['maxOnlineNum']) { $status = '2-2'; $statusMsg = '可立即排队'; } else { $status = '2-3'; $statusMsg = '可立即推广'; } } // 如果推广位已满,判断推广位是否已订阅 if ($status == '2-1') { $subscription = Model_Choice_Subscription::data_access()->filter('site', Model_Choice_Subscription::SITE_RENT)->filter('brokerId', $brokerId)->filter('propId', $houseId)->filter('bucketId', $bucketInfo['id'])->filter('status', Model_Choice_Subscription::SUBSCRIPTION_START)->find_only(); if ($subscription) { $remindStatus = 1; // 1 已订阅 $remindStatusMsg = '取消推广位提醒'; } else { $remindStatus = 0; // 0 未订阅 $remindStatusMsg = '有推广位了提醒我'; } } return array('status' => Const_APIStatus::RETURN_CODE_OK, 'data' => array('clickPrice' => round($clickPrice, 2), 'clickPriceUnit' => '元', 'bucketId' => $bucketInfo['id'], 'maxBucketNum' => $bucketInfo['totalNum'], 'usedBucketNum' => $bucketInfo['usedNum'], 'minChoicePrice' => 20, 'minChoicePriceUnit' => '元', 'maxChoicePrice' => 50, 'maxChoicePriceUnit' => '元', 'status' => $status, 'statusMsg' => $statusMsg, 'remindStatus' => $remindStatus, 'remindStatusMsg' => $remindStatusMsg, 'isDisplaySummary' => $isDisplaySummary)); }
public function handle_request_internal() { $brokerId = $this->_params['brokerId']; $cityId = $this->_params['cityId']; $planId = $this->_params['planId']; // 获取Broker Mapping $brokerMapping = Model_Broker_MainBusiness::getMainBusinessByAjkBrokerId($brokerId); if (!$brokerMapping) { throw new Exception('经纪人不存在', Const_APIStatus::E_BROKER_NOT_EXISTS); } // 判断计划和经纪人关联关系 $plan = Model_Plan_HzPlanBasic::get_plan_by_id($planId); if ($plan['user_id'] != $brokerMapping['hzBrokerid']) { throw new Exception('计划不属于该经纪人', Const_APIStatus::E_PLAN_NOT_BELONG_BROKER); } // 获取定价推广房源列表 $propertyList = array(); $props = Bll_HzFixPlan::get_plan_props($planId, $cityId); if (isset($props[$planId]) && isset($props[$planId]['props'])) { $propIds = array(); foreach ($props[$planId]['props'] as $prop) { $propId = $prop['proid']; $propIds[] = $propId; $row = array(); $row['propId'] = $row['id'] = $propId; $row['title'] = $prop['content_basic']['title']; $row['imgUrl'] = ''; $row['commId'] = $prop['content_basic']['commid']; $row['commName'] = $prop['content_basic']['commname']; $row['roomNum'] = $prop['content_basic']['roomnum']; $row['hallNum'] = $prop['content_basic']['hallnum']; $row['toiletNum'] = $prop['content_basic']['toilnetnum']; $row['area'] = round($prop['content_basic']['areanum']); $row['price'] = round($prop['content_basic']['pricenum']); $row['priceUnit'] = '元/月'; $row['todayClicks'] = $prop['fix_click']; $row['totalClicks'] = $prop['fix_total_click']; $row['isBid'] = 0; $row['isChoice'] = 0; $row['isVisible'] = (int) ($prop['content_basic']['status'] != 6); $row['isMoreImg'] = (int) $prop['content_basic']['quality']; $row['isPhonePub'] = (int) (isset($prop['content_basic']['from']) && $prop['content_basic']['from'] == 'mobile-ajk-broker'); $row['publishDays'] = floor((time() - $prop['content_basic']['created']) / 86400); $row['publishDaysMsg'] = $row['publishDays'] > 0 ? "{$row['publishDays']}天前发布" : '今天发布'; $row['createTime'] = date('Y-m-d H:i:s', $prop['content_basic']['created']); $row['updateTime'] = date('Y-m-d H:i:s', $prop['content_basic']['updated']); //增加委托房源标签 $isEntrust = Bll_Zufang_Choice::isCommissionHouse($propId, $brokerId, Model_House_Commission::TYPE_RENT); if ($isEntrust) { $row['isEntrust'] = 1; } else { $row['isEntrust'] = 0; } $propertyList[$propId] = $row; } if ($propIds) { // 批量获取房源的默认图片 $defaultImages = Model_Image_HzImage::getDefaultImagesByHouseIds($propIds); foreach ($defaultImages as $defaultImage) { $propertyList[$defaultImage['proid']]['imgUrl'] = $defaultImage->imageUrl(); } // 批量获取房源和竞价计划的关联记录(精选是竞价2.0)(只取推广中和排队中的关系) $relations = Model_Plan_HzPlanning::getBidRelationsByHouseIds($propIds, array(Const_HzPlan::SPREAD, Const_HzPlan::WAITING)); // 批量获取房源竞价计划 $planIds = array(); $planPropMap = array(); foreach ($relations as $relation) { $planIds[] = $relation['plan_id']; $planPropMap[$relation['plan_id']] = $relation['proid']; } if ($planIds) { $plans = Model_Plan_HzPlanBasic::getPlansByIds($planIds); foreach ($plans as $plan) { // 忽略已删除计划 if ($plan->flag == 0) { continue; } // 精选 if ($plan->bid_version == 2) { $propId = $planPropMap[$plan['id']]; $propertyList[$propId]['isChoice'] = 1; } else { // 竞价 $propId = $planPropMap[$plan['id']]; $propertyList[$propId]['isBid'] = 1; } } } } } // 排序 • 按发布时间倒序 usort($propertyList, function ($a, $b) { if ($a['createTime'] == $b['createTime']) { return 0; } return strtotime($a['createTime']) > strtotime($b['createTime']) ? -1 : 1; }); // 分组 $newList = array(); $oldList = array(); foreach ($propertyList as $property) { if ($property['publishDays'] > 30) { $oldList[] = $property; } else { $newList[] = $property; } } return array('status' => Const_APIStatus::RETURN_CODE_OK, 'data' => array('newList' => $newList, 'oldList' => $oldList)); }
public function handle_request_combo() { $ajkBrokerId = $this->brokerId; $cityId = $this->cityId; $siteType = Bll_Combo_Broker_BrokerComboInfo::SITE_TYPE_HZ; //首先获取套餐关系房源列表 ---- 那房源到主表去除status 已删除的房源 -----在房源主表获取房源基本信息 $comboList = Bll_Combo_HouseRelation::getHouseRelations($ajkBrokerId, $siteType, 1); $surplus = $hasCombo = 0; //获取套餐信息-首先判断经纪人有无套餐 $comboInfos = Bll_Combo_Broker_BrokerComboInfo::getComboListBySite($ajkBrokerId, $siteType); if (count($comboInfos) > 0) { $index = Bll_Combo_Broker_BrokerComboInfo::getComboIndexBySiteType($siteType); $currentTime = time(); foreach ($comboInfos as $combo) { if ($combo[$index] == 0) { continue; } if (strtotime($combo['endTime']) > $currentTime && strtotime($combo['startTime']) < $currentTime) { $currentCombo = $combo; } } if (!empty($currentCombo)) { $surplus = $currentCombo['rentPropNum']; if (Bll_Combo_Broker_BrokerComboInfo::isOpenUp($currentCombo)) { //商业地产没打通 $surplus = $currentCombo['rentPropNum'] + $currentCombo['salePropNum']; } $hasCombo = 1; } } //获取当前已推广套餐数量 if (Bll_Combo_Broker_BrokerComboInfo::isOpenUp($currentCombo)) { $currentSpreadHouseCount = Bll_Combo_HouseRelation::getHouseCount($ajkBrokerId, $siteType, true); } else { $currentSpreadHouseCount = Bll_Combo_HouseRelation::getHouseCountEx($ajkBrokerId, $cityId, $siteType); } $oldList = $newList = array(); if (empty($comboInfos)) { return array('status' => Const_APIStatus::RETURN_CODE_OK, 'data' => array('newList' => $newList, 'oldList' => $oldList, 'surplus' => $surplus - $currentSpreadHouseCount, 'hasCombo' => $hasCombo)); } $propIds = array(); foreach ($comboList as $row) { $propIds[] = $row['houseId']; } $hzBrokerId = Bll_HzBroker::get_brokerid_by_ajk_brokerid($ajkBrokerId); $comboPropList = Model_House_HzPropSearch::getPropList($propIds, $hzBrokerId, $this->cityId); foreach ($comboPropList as $key => $list) { if (in_array($list['status'], array(Const_HzStatus::VERIFY, Const_HzStatus::REMOVE, Const_HzStatus::EXPIRED))) { unset($comboPropList[$key]); } } //fix bug45133 if (empty($comboPropList)) { return array('status' => Const_APIStatus::RETURN_CODE_OK, 'data' => array('newList' => $newList, 'oldList' => $oldList, 'surplus' => $surplus - $currentSpreadHouseCount, 'hasCombo' => $hasCombo)); } $propIds = array(); foreach ($comboPropList as $row) { $propIds[] = $row['proid']; } //从主表获取房源信息 $propertyList = Model_House_HzProp::getPropsByPropIds($propIds); //获取是否精选或者竞价 $relations = Model_Plan_HzPlanning::getBidRelationsByHouseIds($propIds, array(Const_HzPlan::SPREAD, Const_HzPlan::WAITING)); if (!empty($relations)) { $planPropMap = array(); foreach ($relations as $relation) { $planIds[] = $relation['plan_id']; $planPropMap[$relation['plan_id']] = $relation['proid']; } if (!empty($planIds)) { $plans = Model_Plan_HzPlanBasic::getPlansByIds($planIds); foreach ($plans as $plan) { if ($plan->flag == 0) { continue; } if ($plan->bid_version == 2) { $propId = $planPropMap[$plan['id']]; $propertyList[$propId]['isChoice'] = 1; } else { $propId = $planPropMap[$plan['id']]; $propertyList[$propId]['isBid'] = 1; } } } } // 批量获取房源的默认图片 $defaultImages = Model_Image_HzImage::getDefaultImagesByHouseIds($propIds); if (!empty($defaultImages)) { foreach ($defaultImages as $defaultImage) { $propertyList[$defaultImage['proid']]['imgUrl'] = $defaultImage->imageUrl(); } } krsort($propertyList); $startDate = $endDate = date('Ymd'); $todayClicks = Bll_Combo_Broker_BrokerComboInfo::getHouseComboClickEx($propIds, $startDate, $endDate, Model_Ppc_NewPackageStatsHouseDay::SITE_TYPE_HZ); $totalClicks = Bll_House_HzHouse::getComboHouseAccumulateClick($ajkBrokerId, $propIds, $cityId); foreach ($propertyList as $list) { $row = array(); $row['id'] = $list['propId']; $row['propId'] = $list['propId']; $row['title'] = $list['title']; $row['imgUrl'] = $list['imgUrl'] ?: ''; $row['commId'] = $list['commid']; $row['commName'] = $list['commname']; $row['roomNum'] = $list['roomnum']; $row['hallNum'] = $list['hallnum']; $row['toiletNum'] = $list['toilnetnum']; $row['area'] = round($list['areanum']); $row['price'] = round($list['pricenum']); $row['priceUnit'] = '元/月'; $row['todayClicks'] = $todayClicks[$list['propId']][$startDate] ?: 0; $row['totalClicks'] = $totalClicks[$list['propId']] ?: 0; $row['totalClicks'] = $row['totalClicks'] + $row['todayClicks']; $row['isBid'] = isset($list['isBid']) ? $list['isBid'] : 0; $row['isChoice'] = isset($list['isChoice']) ? $list['isChoice'] : 0; $row['isVisible'] = (int) ($list['status'] != 6); $row['isMoreImg'] = (int) $list['quality']; $row['isPhonePub'] = (int) (isset($list['from']) && $list['from'] == 'mobile-ajk-broker'); $row['publishDays'] = floor((time() - $list['created']) / 86400); $row['publishDaysMsg'] = $row['publishDays'] > 0 ? "{$row['publishDays']}天前发布" : '今天发布'; $row['createTime'] = date('Y-m-d H:i:s', $list['created']); //$row['updateTime'] = date('Y-m-d H:i:s', $list['updated']); //是否委托 $isEntrust = Bll_Zufang_Choice::isCommissionHouse($list['propId'], $ajkBrokerId, Model_House_Commission::TYPE_RENT); $row['isEntrust'] = $isEntrust ? 1 : 0; $row['publishDays'] > 30 ? $oldList[] = $row : ($newList[] = $row); } return array('status' => Const_APIStatus::RETURN_CODE_OK, 'data' => array('newList' => $newList, 'oldList' => $oldList, 'surplus' => $surplus - $currentSpreadHouseCount, 'hasCombo' => $hasCombo)); }
public function handle_request_internal() { $brokerId = $this->_params['brokerId']; $houseId = $this->_params['propId']; $budget = $this->_params['budget']; if ($budget < 20 || $budget > 50) { return array('status' => Const_APIStatus::RETURN_CODE_ERROR, 'errcode' => '', 'message' => '请输入20~50之间的整数'); } $brokerInfo = Model_Broker_AjkBrokerExtend::findWithBrokerId($brokerId); if (!$brokerInfo) { throw new Exception_BrokerNotFoundException('经纪人不存在', Const_APIStatus::E_BROKER_NOT_EXISTS); } $cityId = $brokerInfo->cityId; if (!Bll_City::isChoiceCity($cityId, Const_Site::HAOZU)) { return array('status' => Const_APIStatus::RETURN_CODE_ERROR, 'errcode' => Const_APIStatus::E_NOT_CHOICE_CITY, 'message' => '非精选城市'); } // 获取房源基本信息 $propInfo = Model_House_HzProp::get_prop_info_by_prop_id($houseId); $block_id = $propInfo['contentBasic']['blockid']; // 获取点击单价 try { $clickPriceInfo = Bll_Service_Choice::hzClickPrice(array('cityId' => $cityId, 'price' => (int) $propInfo['contentBasic']['pricenum'], 'blockId' => $block_id, 'brokerId' => $brokerId)); if ($clickPriceInfo['status'] == 'error') { return array('status' => Const_APIStatus::RETURN_CODE_ERROR, 'errcode' => '', 'message' => '系统繁忙(code:-33)'); } } catch (Exception $e) { return array('status' => Const_APIStatus::RETURN_CODE_ERROR, 'errcode' => '', 'message' => '系统繁忙(code:-33)'); } $params = array(); $params['price'] = $clickPriceInfo['realTradeAmount'] / 100; // 点击单价单位转换:分 -> 元; $params['show'] = 0; $params['budget'] = $budget; $params['ip'] = $this->_request->get_client_ip(); // 判断是否是重新推广 $bllChoice = new Bll_Zufang_Choice(); $planInfo = $bllChoice->get_plan_by_proid($houseId); //planning表中查找精选计划 if (!empty($planInfo)) { $planId = $planInfo->plan_id; $basicPlanInfo = $bllChoice->get_plan($planId); if (!empty($basicPlanInfo)) { if ($basicPlanInfo[0]->status == 1 || $basicPlanInfo[0]->status == 13) { return array('status' => Const_APIStatus::RETURN_CODE_ERROR, 'errcode' => '', 'message' => '该房源已做精选推广!'); } if ($basicPlanInfo[0]->status != Const_HzPlan::DELETE) { $params['plan_id'] = $planInfo->plan_id; } } } // 开始精选推广 $result = Bll_Plan_Bid_Choice::hz_setting_post($brokerId, $cityId, $houseId, $params); if ($result['err_no'] != Bll_Plan_Bid_Choice::BID_WAIT_SUCCESS) { return array('status' => Const_APIStatus::RETURN_CODE_ERROR, 'errcode' => '', 'message' => $result['err_msg']); } if ($result['rank'] > 10) { $status = 2; $msg = "排在第{$result['rank']}位"; } else { $status = 1; $msg = "精选推广成功"; } return array('status' => Const_APIStatus::RETURN_CODE_OK, 'data' => array('status' => $status, 'statusMsg' => $msg)); }
public function handle_request_internal() { $brokerId = $this->_params['brokerId']; $cityId = $this->_params['cityId']; // 获取未推广房源列表 $hzBrokerId = Bll_HzBroker::get_brokerid_by_ajk_brokerid($brokerId); //APP套餐城市调错API了 需要做一下套餐城市的兼容处理 $isComboBroker = Bll_Broker_HzBroker::isComboBroker($brokerId); if (!$isComboBroker) { $props = Bll_HzFixPlan::get_outline_list($hzBrokerId, $cityId, 1); $propIds = array(); $propertyList = array(); foreach ($props as $prop) { $propId = $prop['proid']; $propIds[] = $propId; $row = array(); $row['propId'] = $row['id'] = $propId; $row['title'] = $prop['content_basic']['title']; $row['imgUrl'] = ''; $row['commId'] = $prop['content_basic']['commid']; $row['commName'] = $prop['content_basic']['commname']; $row['roomNum'] = $prop['content_basic']['roomnum']; $row['hallNum'] = $prop['content_basic']['hallnum']; $row['toiletNum'] = $prop['content_basic']['toilnetnum']; $row['area'] = round($prop['content_basic']['areanum']); $row['price'] = round($prop['content_basic']['pricenum']); $row['priceUnit'] = '元/月'; $row['isBid'] = 0; $row['isChoice'] = 0; $row['isVisible'] = intval($prop['content_basic']['status'] != 6); $row['isMoreImg'] = intval($prop['content_basic']['quality']); $row['isPhonePub'] = intval(isset($prop['content_basic']['from']) && $prop['content_basic']['from'] == 'mobile-ajk-broker'); $row['publishDays'] = floor((time() - $prop['content_basic']['created']) / 86400); $row['publishDaysMsg'] = $row['publishDays'] > 0 ? "{$row['publishDays']}天前发布" : '今天发布'; $row['createTime'] = date('Y-m-d H:i:s', $prop['content_basic']['created']); $row['updateTime'] = date('Y-m-d H:i:s', $prop['content_basic']['updated']); //增加委托房源标签 $isEntrust = Bll_Zufang_Choice::isCommissionHouse($propId, $brokerId, Model_House_Commission::TYPE_RENT); $row['isEntrust'] = $isEntrust ? 1 : 0; $propertyList[$propId] = $row; } if ($propIds) { // 批量获取房源的默认图片 $defaultImages = Model_Image_HzImage::getDefaultImagesByHouseIds($propIds); foreach ($defaultImages as $defaultImage) { $propertyList[$defaultImage['proid']]['imgUrl'] = $defaultImage->imageUrl(); } } $result = array(); $result['status'] = Const_APIStatus::RETURN_CODE_OK; $result['data']['propertyList'] = array_values($propertyList); return $result; } else { //获取所有有效房源 $props = Bll_House_HzHouse::getValidPropsByBrokerId($hzBrokerId, $cityId); $propertyList = array(); if (!empty($props)) { //获取套餐推广房源列表 $comboList = Bll_Combo_HouseRelation::getHouseRelations($brokerId, Bll_Combo_HouseRelation::SITE_TYPE_HZ, 1); //所有有效房源-套餐推广房源 = 套餐未推广房源 if (!empty($comboList)) { foreach ($comboList as $row) { unset($props[$row['houseId']]); } } if (!empty($props)) { // 批量获取房源的默认图片 $defaultImages = Model_Image_HzImage::getDefaultImagesByHouseIds(array_keys($props)); if (!empty($defaultImages)) { foreach ($defaultImages as $defaultImage) { $props[$defaultImage['proid']]['imgUrl'] = $defaultImage->imageUrl(); } } foreach ($props as $list) { $row = array(); $row['id'] = $row['propId'] = $list['propId']; $row['title'] = $list['title']; $row['imgUrl'] = $list['imgUrl'] ?: ''; $row['commId'] = $list['commid']; $row['commName'] = $list['commname']; $row['roomNum'] = $list['roomnum']; $row['hallNum'] = $list['hallnum']; $row['toiletNum'] = $list['toilnetnum']; $row['area'] = round($list['areanum']); $row['price'] = round($list['pricenum']); $row['priceUnit'] = '元/月'; $row['todayClicks'] = $row['totalClicks'] = $row['isBid'] = $row['isChoice'] = 0; $row['isVisible'] = (int) ($list['status'] != 6); $row['isMoreImg'] = (int) $list['quality']; $row['isPhonePub'] = (int) (isset($list['from']) && $list['from'] == 'mobile-ajk-broker'); $isEntrust = Bll_Zufang_Choice::isCommissionHouse($list['propId'], $brokerId, Model_House_Commission::TYPE_RENT); $row['isEntrust'] = $isEntrust ? 1 : 0; $row['createTime'] = date('Y-m-d H:i:s', $list['created']); $propertyList[] = $row; } } } return array('status' => Const_APIStatus::RETURN_CODE_OK, 'data' => array('propertyList' => $propertyList)); } }
public function handle_request_internal() { $brokerId = $this->_params['brokerId']; $bllChoice = new Bll_Zufang_Choice(); $hzBrokerId = $bllChoice->get_hz_broker_id($brokerId); $brokerInfo = $bllChoice->get_broker_info($brokerId); $cityId = $brokerInfo[0]->cityId; if (!Bll_City::isChoiceCity($cityId, Const_Site::HAOZU)) { return array('status' => Const_APIStatus::RETURN_CODE_ERROR, 'errcode' => Const_APIStatus::E_NOT_CHOICE_CITY, 'message' => '非精选城市'); } $result = array('status' => Const_APIStatus::RETURN_CODE_OK, 'data' => array('OnlinePropertyList' => array(), 'QueuedPropertyList' => array(), 'OfflinePropertyList' => array())); // 获取所有的计划 $plans = $bllChoice->get_active_choice_plans($hzBrokerId, array(1, 13, 2, 3, 7, 8)); if (empty($plans)) { return $result; } $keyedPlans = array(); foreach ($plans as $plan) { $keyedPlans[$plan->id] = $plan; } // 获取所有的房源和计划的关系 $choiceRelations = $bllChoice->get_prop(array_keys($keyedPlans)); $propIds = array(); $propPlanMap = array(); $propUpdateTime = array(); foreach ($choiceRelations as $choiceRelation) { $propIds[] = $choiceRelation->proid; $propPlanMap[$choiceRelation->proid] = $keyedPlans[$choiceRelation->plan_id]; $propUpdateTime[$choiceRelation->proid] = $choiceRelation->last_update; } // 获取所有房源 if (empty($propIds)) { return $result; } $props = $bllChoice->get_prop_content($propIds); // 拼装房源数据 $propertyList = array(); foreach ($props as $prop) { $row = array(); $content = json_decode($prop->contentBasic, true); $row['propId'] = $prop->propId; $row['title'] = $content['title']; $row['imgUrl'] = ''; $row['commId'] = $content['commid']; $row['commName'] = $content['commname']; $row['roomNum'] = $content['roomnum']; $row['hallNum'] = $content['hallnum']; $row['toiletNum'] = $content['toilnetnum']; $row['price'] = round($content['pricenum']); $row['priceUnit'] = '元/月'; $row['isVisible'] = $prop->isIllegal() ? 0 : 1; $row['isBid'] = 0; $row['isChoice'] = 1; $row['isMoreImg'] = intval($prop->isMultiImages()); $row['isPhonePub'] = intval($prop->isFromMobile()); //pmt21181 bug标记 文档上为createTime $row['choiceTime'] = $propPlanMap[$prop->propId]->created; $row['updateTime'] = $propUpdateTime[$prop->propId]; $totalClicks = $bllChoice->get_prop_choice_clicks($prop->propId, $cityId); // TODO 待定 $row['totalClicks'] = $totalClicks[0]['bidClicks']; //增加委托房源标签 $isEntrust = Bll_Zufang_Choice::isCommissionHouse($prop->propId, $brokerId, Model_House_Commission::TYPE_RENT); if ($isEntrust) { $row['isEntrust'] = 1; } else { $row['isEntrust'] = 0; } $propertyList[$prop->propId] = $row; } if ($propIds) { // 批量获取房源的默认图片 $defaultImages = Model_Image_HzImage::getDefaultImagesByHouseIds($propIds); foreach ($defaultImages as $defaultImage) { $propertyList[$defaultImage['proid']]['imgUrl'] = $defaultImage->imageUrl(); } } // 排序 /*usort($propertyList, function ($a, $b) { if ($a['choiceTime'] == $b['choiceTime']) { return 0; } return ($a['choiceTime'] > $b['choiceTime']) ? -1 : 1; }); */ usort($propertyList, function ($a, $b) { if (strtotime($a['updateTime']) == strtotime($b['updateTime'])) { return 0; } return strtotime($a['updateTime']) > strtotime($b['updateTime']) ? -1 : 1; }); // 分组 $onlinePropertyList = array(); //推广中列表 $waitPropertyList = array(); //排队中列表 $offlinePropertyList = array(); //推广结束列表 foreach ($propertyList as $property) { switch ($propPlanMap[$property['propId']]->status) { case '1': $property['choiceStatus'] = 1; $property['choiceStatusName'] = '精选中'; $onlinePropertyList[] = $property; break; case '13': $property['choiceStatus'] = 2; $property['choiceStatusName'] = '排队中'; $waitPropertyList[] = $property; break; default: $property['isChoice'] = 0; $property['choiceStatus'] = 3; $property['choiceStatusName'] = '已结束'; $offlinePropertyList[] = $property; } } return array('status' => Const_APIStatus::RETURN_CODE_OK, 'data' => array('OnlinePropertyList' => $onlinePropertyList, 'QueuedPropertyList' => $waitPropertyList, 'OfflinePropertyList' => $offlinePropertyList)); }
public function handle_request_internal() { $brokerId = $this->_params['brokerId']; // 判断经纪人是否存在 $broker = Model_Broker_AjkBrokerExtend::findWithBrokerId($brokerId); $hzBrokerId = Model_Broker_MainBusiness::getHzBrokerIdByAjkBrokerId($brokerId); if (!$hzBrokerId || !$broker) { throw new Exception_Broker_NotFound('BrokerId: ' . $brokerId); } // 判断城市是否开通竞价业务 $cityId = $broker['cityId']; if (!Bll_City::isBidCity($cityId)) { throw new Exception_City_NotBidCity('CityId: ' . $cityId); } // 获取竞价房源 $finalProps = array(); $bidProps = Bll_HzBidPlan::get_broker_bidprop($hzBrokerId, $cityId); foreach ($bidProps as $bidProp) { $row = array(); $row['propId'] = $bidProp['proid']; $row['title'] = $bidProp['prop']['content_basic']['title']; $row['imgUrl'] = ''; $row['commId'] = $bidProp['prop']['content_basic']['commid']; $row['commName'] = $bidProp['prop']['content_basic']['commname']; $row['roomNum'] = $bidProp['prop']['content_basic']['roomnum']; $row['hallNum'] = $bidProp['prop']['content_basic']['hallnum']; $row['toiletNum'] = $bidProp['prop']['content_basic']['toilnetnum']; $row['area'] = round($bidProp['prop']['content_basic']['areanum']); $row['price'] = round($bidProp['prop']['content_basic']['pricenum']); $row['priceUnit'] = "元/月"; $row['totalClicks'] = 0; $row['isBid'] = 1; $row['isChoice'] = 0; $row['isVisible'] = (int) ($bidProp['content_basic']['status'] != 6); $row['isMoreImg'] = (int) $bidProp['content_basic']['quality']; $row['isPhonePub'] = (int) (isset($bidProp['content_basic']['from']) && $bidProp['content_basic']['from'] == 'mobile-ajk-broker'); // TODO 批量判定 增加委托房源标签 $isEntrust = Bll_Zufang_Choice::isCommissionHouse($bidProp['proid'], $brokerId, Model_House_Commission::TYPE_RENT); if ($isEntrust) { $row['isEntrust'] = 1; } else { $row['isEntrust'] = 0; } // 确认房源分组 // TODO 基于Rank获取分组可能对页面速度有一定影响 $row['rank'] = $bidProp['rank']; if ($row['rank'] === '已暂停') { $row['group'] = 'offline'; } elseif ($row['rank'] === '排队中') { $row['group'] = 'queued'; } else { $row['group'] = 'online'; } $finalProps[$row['propId']] = $row; } if ($finalProps) { $propIds = array_keys($finalProps); // 批量获取房源的默认图片 $defaultImages = Model_Image_HzImage::getDefaultImagesByHouseIds($propIds); foreach ($defaultImages as $defaultImage) { $finalProps[$defaultImage['proid']]['imgUrl'] = $defaultImage->imageUrl(); } // 批量获取房源的竞价总点击 $bidClicks = Model_Stats_PropClick::getPropAllClicks($propIds, $brokerId, $cityId); $bidClickSums = Model_Stats_PropClick::calculateClickSumsGroupByPropId($bidClicks, 'bid'); foreach ($bidClickSums as $propId => $bidClickSum) { $finalProps[$propId]['totalClicks'] = $bidClickSum; } } // 排序 • 按ID倒序 ksort($finalProps); // 分组 $props = array('onlinePropertyList' => array(), 'queuedPropertyList' => array(), 'offlinePropertyList' => array()); foreach ($finalProps as $finalProp) { switch ($finalProp['group']) { case 'online': $props['onlinePropertyList'][] = $finalProp; break; case 'queued': $props['queuedPropertyList'][] = $finalProp; break; case 'offline': $props['offlinePropertyList'][] = $finalProp; break; } } return array('status' => Const_APIStatus::RETURN_CODE_OK, 'data' => $props); }
public function handle_request_combo() { $brokerId = $this->brokerId; $cityId = $this->cityId; $hzBrokerId = Bll_HzBroker::get_brokerid_by_ajk_brokerid($brokerId); //获取所有有效房源 $props = Bll_House_HzHouse::getValidPropsByBrokerId($hzBrokerId, $cityId); $propertyList = array(); if (!empty($props)) { //获取套餐推广房源列表 $comboList = Bll_Combo_HouseRelation::getHouseRelations($brokerId, Bll_Combo_HouseRelation::SITE_TYPE_HZ, 1); //获取精选房源列表 $bllChoice = new Bll_Zufang_Choice(); $choices = $bllChoice->get_active_choice_plans($hzBrokerId, array(1, 13, 2, 3, 7, 8)); $choicePropIds = array(); if (!empty($choices)) { $keyedPlans = array(); foreach ($choices as $choice) { $keyedPlans[$choice->id] = $choice; } // 获取所有的房源和精选的关系 $choiceRelations = $bllChoice->get_prop(array_keys($keyedPlans)); foreach ($choiceRelations as $choiceRelation) { $choicePropIds[] = $choiceRelation->proid; } } //所有有效房源-套餐推广房源-精选推广房源 = 待推广房源 if (!empty($comboList)) { foreach ($comboList as $row) { unset($props[$row['houseId']]); } } if (!empty($choicePropIds)) { foreach ($choicePropIds as $k => $v) { unset($props[$v]); } } if (!empty($props)) { // 批量获取房源的默认图片 $defaultImages = Model_Image_HzImage::getDefaultImagesByHouseIds(array_keys($props)); if (!empty($defaultImages)) { foreach ($defaultImages as $defaultImage) { $props[$defaultImage['proid']]['imgUrl'] = $defaultImage->imageUrl(); } } //是否是精选城市,城市是否精选分离 $cityIsChoice = Bll_City::isChoiceCity($cityId, Const_Site::HAOZU); $cityIsChoiceIndependent = Bll_City::isChoiceIndependentCity($cityId, Const_Site::HAOZU); foreach ($props as $list) { $row = array(); $row['id'] = $row['propId'] = $list['propId']; $row['title'] = $list['title']; $row['imgUrl'] = $list['imgUrl'] ?: ''; $row['commId'] = $list['commid']; $row['commName'] = $list['commname']; $row['roomNum'] = $list['roomnum']; $row['hallNum'] = $list['hallnum']; $row['toiletNum'] = $list['toilnetnum']; $row['area'] = round($list['areanum']); $row['price'] = round($list['pricenum']); $row['priceUnit'] = '元/月'; $row['todayClicks'] = $row['totalClicks'] = $row['isBid'] = $row['isChoice'] = 0; $row['isVisible'] = (int) ($list['status'] != 6); $row['isMoreImg'] = (int) $list['quality']; $row['isPhonePub'] = (int) (isset($list['from']) && $list['from'] == 'mobile-ajk-broker'); $isEntrust = Bll_Zufang_Choice::isCommissionHouse($list['propId'], $brokerId, Model_House_Commission::TYPE_RENT); $row['isEntrust'] = $isEntrust ? 1 : 0; $row['createTime'] = date('Y-m-d H:i:s', $list['created']); //精选状态 $choiceStatus = Bll_HzProp::getZuFangChoiceStatus($list, $cityId, $cityIsChoice); if (!$cityIsChoiceIndependent && $choiceStatus['choiceStatus']) { //城市未精选分离 $choiceStatus['choiceStatus'] = 0; $choiceStatus['choiceStatusName'] = ''; } $row['choiceStatus'] = $choiceStatus['choiceStatus']; $row['choiceStatusName'] = $choiceStatus['choiceStatusName']; $propertyList[] = $row; } } } return array('status' => Const_APIStatus::RETURN_CODE_OK, 'data' => array('propertyList' => $propertyList)); }