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