public function handle_request_internal() { //组织POST参数 $params = array(); if (!isset($this->_params['brokerId'])) { return Util_MobileAPI::error(Const_APIStatus::E_BROKER_PARAM_MISS); } else { $broker_id = $this->_params["brokerId"]; } if (!isset($this->_params["cityId"])) { return Util_MobileAPI::error(Const_APIStatus::E_PARAM_CITYID_MISS); } if (!isset($this->_params["propId"])) { return Util_MobileAPI::error(Const_APIStatus::E_PROP_ID_MISS); } if (!isset($this->_params["offer"])) { return Util_MobileAPI::error(Const_APIStatus::E_PROP_BID_PRICE_MISS); } if (!Bll_City::isBidCity($this->_params["cityId"])) { $error_code = Const_HzErrorInfo::NOBIDCITY; return array('status' => 'error', 'errcode' => $error_code, 'message' => Bll_HzFixPlan::get_message_from_code($error_code)); } $search = new Util_SearchUtil(); $prop = Bll_HzProp::get_prop($this->_params["propId"]); $blockid = $prop['blockid']; $price = $prop['pricenum']; $price_block = Bll_HzBidPlan::get_price_block($this->_params["cityId"], $price); $ajkid = Bll_HzProp::get_subregion_id($prop['commId'], $this->_params["propId"]); $rank = $search->getHpRankByProp($this->_params["cityId"], $ajkid, $this->_params["propId"], $price_block['LOWER'], $price_block['UPPER'], $this->_params['offer']); $return = array(); $return["status"] = "ok"; $return["data"] = $rank; return $return; }
private static function preparePropInfo(&$out) { // 获取房源 $propResult = Bll_House_HzHouse::getPropInfo($out['proId'], $out['cityId'], 3); if (!$propResult['status']) { throw new Exception($propResult['msg']); } $propInfo = $propResult['msg']; // 检查并拼接违规信息 $illegalInfo = Bll_HzProp::checkAndGetPropsIllegalInfos(array($out['proId'] => $propInfo)); $propInfo = $illegalInfo[$out['proId']]; // 获取剩余时间 $propInfo['leftDays'] = Bll_House_HzHouse::getLeftDays($propInfo['created']); // 获取房源图片数 $imageInfo = Bll_House_HzHouse::getPropImages($out['proId']); $propInfo['imageInfo'] = $imageInfo; // 房源默认图片 (默认优先封面图 -》 第一张室内图 -》 房型) //$propInfo['propDefaultImg'] = Bll_House_HzHouse::getPropDefaultImgWithUrl($out['proId']); $propInfo['propDefaultImg'] = self::getThumbImg($imageInfo); // 获取房源可优化项 $propInfo['canImproveItems'] = self::getPropCanImproveItems($propInfo, $imageInfo); // 是否手机发房 $propInfo['isMobile'] = isset($propInfo['from']) ? Bll_House_HzHouse::isMobileProp($propInfo['from']) : false; // 此房源全部点击数据 $propInfo['propAllClick'] = Model_Stats_PropClick::getPropAllClicks($out['proId'], $out['hzBrokerId'], $out['cityId']); // 此房源全部曝光数据 $propInfo['propAllShow'] = Bll_House_HzHouse::getPropShow($out['proId'], $out['cityId']); // 此房源质量 $propQuality = Model_Stats_HzPropQuality::getPropsquality($out['proId']); $propInfo['propsQuality'] = $propQuality ? $propQuality[$out['proId']] : array(); // 根据blockid 获取对应code $areaInfo = Model_City_HzArea::getAreaById($propInfo['blockid']); $propInfo['typeCode'] = $areaInfo['typeCode']; return $propInfo; }
public function handle_request_internal() { $brokerId = $this->_params['brokerId']; $propIds = $this->_params['propIds']; $cityId = $this->_params['cityId']; $paramsApi['from'] = APF::get_instance()->get_config('java_api_from'); $paramsApi['proids'] = $propIds; $paramsApi['proid'] = $propIds; $paramsApi['token'] = $this->_params['token']; $paramsApi['brokerId'] = $brokerId; $paramsApi['tradeType'] = 2; if (Bll_Broker_HzBroker::isComboBroker($brokerId)) { $paramsApi['isComboBroker'] = true; $api_url = 'rent/properties/deletes?json'; $data = Util_CallAPI::callJavaInternalApi($api_url, $paramsApi, false); if ($data['data']['status'] === 'ok') { $ret = array('status' => 'ok', 'data' => array()); } else { $ret = Util_MobileAPI::error(Const_APIStatus::E_PROP_DEL_FAILED); } return $ret; } else { $brokerId_hz = Bll_HzBroker::get_brokerid_by_ajk_brokerid($brokerId); $ret = Bll_HzProp::delete_prop($brokerId_hz, $cityId, $propIds); if ($ret) { $return = array('status' => 'ok', 'data' => array()); } else { $return = Util_MobileAPI::error(Const_APIStatus::E_PROP_DEL_FAILED); } return $return; } }
/** * Job执行逻辑 */ public function handle_request() { // check if (!($this->checkParams() && $this->isActionNotDone() && $this->isPreFinished())) { return false; } $actionId = $this->actionId; // 获取该actionid的Nocomms $nocomms = Bll_Cms_BlockChange::getNocommsByAction(Bll_Cms_BlockChange::getActionWithCommunity($this->actionId)); if (empty($nocomms)) { $this->writeLog('nocomms is empty'); Bll_Cms_BlockChange::updateDoList($actionId, 5, 2); // 更新action完成 Bll_Cms_BlockChange::updateAction($actionId, 1); return false; } $commsValus = array_values($nocomms); $cityId = $commsValus[0]['city_id']; // 取游标 $beginId = @(int) file_get_contents($this->idFile); // 标记处理状态 Bll_Cms_BlockChange::updateDoList($actionId, 5, 1, 'action:' . $actionId . ' list_id:5 处理中..房子:' . $beginId); //更新租房房源信息并重新定竞价 $result = Bll_HzProp::dealPropCommidZero($beginId, $nocomms, $cityId, $this->idFile); // 如果返回空 重置游标 if (!$result['status'] && $result['msg'] == 'empty') { $result['msg'] = array(); $result['msg'][] = "action: " . $actionId . ",is finished"; file_put_contents($this->idFile, 'END'); foreach ($nocomms as $nocomm) { // 更新状态 Bll_Cms_BlockChange::updateNocomm($nocomm['id'], 1); } // 更新dolist Bll_Cms_BlockChange::updateDoList($actionId, 5, 2); // 更新action完成 Bll_Cms_BlockChange::updateAction($actionId, 1); } // 记录log if ($result['msg'] && is_array($result['msg'])) { foreach ($result['msg'] as $msg) { $this->writeLog($msg); } } }
public function handle_request_internal() { if (!isset($this->_params['propId'])) { return Util_MobileAPI::error(Const_APIStatus::E_PROP_ID_MISS); } //获取租房房信息 $propInfo = Bll_HzProp::get_prop($this->_params['propId']); /* 备案编号:fileNo 小区ID:commId 小区名字:commName 房间数:roomNum 厅数:hallNum 卫生间数:toiletNum 面积:area 房源所在的楼层: proFloor 总楼层: floorNum 装修:fitment 朝向:exposure 标题:title 描述:description 小区图:commImg 室内图:roomImg 房型图:moduleImg */ if (!empty($propInfo)) { $return = array(); $return["status"] = "ok"; $community = Bll_Community_APIComm::getInstance()->getInfoByIdMapping($propInfo['commid'], 2); $return["data"]['propInfo']['fileNo'] = $propInfo['houseCard']; $return["data"]['propInfo']['commId'] = $propInfo['commid']; $return["data"]['propInfo']['commName'] = $propInfo['commname']; $return["data"]['propInfo']['commAddress'] = $community['commLocal']; $return["data"]['propInfo']['roomNum'] = $propInfo['roomnum']; $return["data"]['propInfo']['hallNum'] = $propInfo['hallnum']; $return["data"]['propInfo']['toiletNum'] = $propInfo['toilnetnum']; $return["data"]['propInfo']['area'] = round($propInfo['areanum']); $return["data"]['propInfo']['floor'] = $propInfo['floor']; $return["data"]['propInfo']['floorNum'] = $propInfo['totalfloor']; // 装修类型 $fitments_unify = APF::get_instance()->get_config('ajk_fitment_unify', 'zu_house'); $fitments = APF::get_instance()->get_config('ajk_fitment', 'zu_house'); $fitment = array_keys($fitments[$propInfo['cityid']]); $fitment_unify = array_keys($fitments_unify[$propInfo['cityid']]); $key = array_search($propInfo['fitment'], $fitment); $return["data"]['propInfo']['fitment'] = $fitment_unify[$key]; //朝向 $toward = APF::get_instance()->get_config('toward', 'zu_house'); $return["data"]['propInfo']['exposure'] = $toward[$propInfo['toward']]; //$return["data"]['propInfo']['exposure'] = $propInfo['toward']; $return["data"]['propInfo']['title'] = $propInfo['title']; $return["data"]['propInfo']['description'] = $propInfo['descript']; $return["data"]['propInfo']['price'] = $propInfo['pricenum']; $return["data"]['propInfo']['style'] = $propInfo['protype']; $return["data"]['propInfo']['shareRent'] = $propInfo['renttype']; $return["data"]['propInfo']['shareSex'] = $propInfo['sharesex']; $return["data"]['propInfo']['shareType'] = $propInfo['sharetype']; $prop_imgs = Bll_HzProp::get_images($this->_params['propId'], 1, false, false); $return["data"]["propInfo"]["roomImg"] = array(); $return["data"]["propInfo"]["commImg"] = array(); $return["data"]["propInfo"]["moduleImg"] = array(); if (count($prop_imgs)) { foreach ($prop_imgs as $k => $img) { $ajkcid = intval($img['ajkcid']); if ($ajkcid > 0) { $b_src = Bll_Image_UtilsImage::show_a_img_size($img['hostid'], $img['imageid'], $ajkcid, '420x315'); } else { $b_src = 'http://pic' . $img['hostid'] . '.ajkimg.com/display/hz/' . $img['imageid'] . '/420x315.jpg'; } $prop_imgs = array('imgId' => $img['id'], 'imgUrl' => $b_src, 'default' => $img['default']); if (1 == $img['type']) { $return["data"]['propInfo']['roomImg'][] = $prop_imgs; } else { if (2 == $img['type']) { $return["data"]['propInfo']['moduleImg'][] = $prop_imgs; } else { $return["data"]['propInfo']['commImg'][] = $prop_imgs; } } } } } else { return Util_MobileAPI::error(Const_APIStatus::E_CALL_API_ERROR); } return $return; }
/** * 从slor获取竞价排名 */ public static function get_bid_rank($prop, $city_id) { $price_block = self::get_price_block($city_id, $prop['pricenum']); $ajkid = Bll_HzProp::get_subregion_id($prop['commid'], $prop['proid']); $rank = Util_SearchUtil::getHpCurrentRank($city_id, $ajkid, $prop['proid'], $price_block['LOWER'], $price_block['UPPER'], $prop['unit_price']); return $rank; }
/** * 处理comms业务功能 * @param $action */ public static function dealActionComms($action) { $allResult = array(); //添加去重数组,为更新租房commid=0的数据做准备 $blockInfoArr = array(); foreach ($action['comms'] as $comm) { $blockInof = Bll_HzProp::getBlockByTypeCode($comm['new_block_code'], array(0, 1), true); // 判断小区solr是否ok $ajkBlock = Dao_Broker_HzProp::getAjkBlockInfo($comm['new_block_code']); if (!$ajkBlock) { return self::buildReturn(0, '二手房没有该板块:' . $comm['new_block_code']); } if (!Bll_HzProp::isCommSolrUpdated($ajkBlock['TypeId'], $ajkBlock['ParentId'], $blockInof['cityid'], $comm['community_id'], $comm['community_name'])) { return self::buildReturn(0, '租房小区solr还没更新完,动作id:' . $action['id'] . ' 小区id:' . $comm['community_id']); } if ($blockInof) { $result = Bll_HzProp::updatePropBlock($blockInof['id'], $blockInof['parentid'], $blockInof['cityid'], $comm['community_id']); if (!$result['status']) { // 更新动作表 if (!Bll_Cms_BlockChange::updateCommAction($comm['s_id'], $action['id'], 3, '处理失败')) { return self::buildReturn(0, '更新动作表失败,动作id:' . $action['id']); } return $result; } $allResult = array_merge($allResult, $result['msg']); } // 更新动作表 if (!Bll_Cms_BlockChange::updateCommAction($comm['s_id'], $action['id'], 1, '处理成功')) { return self::buildReturn(0, '更新动作表失败,动作id:' . $action['id']); } $temp = array(); $temp['new_code'] = $comm['new_block_code']; $temp['old_code'] = $comm['block_code']; $temp['city_id'] = $comm['city_id']; $blockInfoArr[$temp['old_code'] . '_' . $temp['new_code']] = $temp; } if (!empty($blockInfoArr)) { Bll_Cms_BlockChange::insertCommList($blockInfoArr); } return self::buildReturn(1, $allResult); }
public static function prepareOutList(&$out) { $illegalList = array(); $out['outList'] = $out['props']; // 过滤套餐推广 if (count($out['comboList']) > 0) { foreach ($out['comboList'] as $combo) { if (in_array($combo['houseId'], array_keys($out['props']))) { unset($out['outList'][$combo['houseId']]); } } } // 过滤竞价 已经是精选了,以下逻辑可删除 /*** * if (isset($out['bidProIds']) && count($out['bidProIds']) > 0) { * if (in_array($combo['houseId'], array_values($out['bidProIds']))) { * unset($out['outList'][$combo['houseId']]); * } * } */ // 获取如是违规房源 拼接违规原因 $out['outList'] = Bll_HzProp::checkAndGetPropsIllegalInfos($out['outList']); // 创建时间倒叙 usort($out['outList'], function ($a, $b) { return $a['created'] < $b['created'] ? 1 : -1; }); if (count($out['outList']) < 1) { return; } foreach ($out['outList'] as $k => $v) { if ($v['status'] != 6) { continue; } $illegalList[] = $v; unset($out['outList'][$k]); } $out['outList'] = array_merge($illegalList, $out['outList']); }
/** * 108 房源价格变更 * 查选房源信息是否存在 * 如果不存在 返回结束 * 如果存在 记录房源编辑日志 type=2 * 查询该房源的计划关系 * 如果不存在 返回结束 * 如果存在,重新计算定价的底价并更新计划关系表中的底价 * 查询计划 * 如果计划不在推广 返回结束 * 如果计划正在推广或者第二天推广, 记录房源更新日志 type=4 * 处理竞价 */ private function change_prop_price() { $data = self::build_prop_log($this->params, 2, "房源修改价格", $this->params['broker_id']); $houseStatus = json_decode($this->params['remark'], true); $data['remark'] = json_encode(array('oldPrice' => $houseStatus['oldPrice'], 'newPrice' => $houseStatus['price'], 'msg' => $data['remark'])); if (!Model_Log_HouseLogNew::create($data, date('Ymd'))->save()) { throw new Exception_BllErrorException("房源{$this->params['broker_id']}修改价格日志写入失败"); } else { $this->allReturn[] = "房源{$this->params['broker_id']}修改价格日志写入"; } if ($this->params['isComboCity']) { if (!($comboRelation = Bll_Combo_HouseRelation::getOnlineRelationByHouseId($this->params['pro_id']))) { return $this->allReturn[] = "房源{$this->params['pro_id']}套餐关系为空"; } //$this->writePropLog(4, '更新'); } else { // 查询定价关系 if (!($fixPlanning = Model_Plan_HzPlanning::getPropFixPlan($this->params['pro_id']))) { return $this->allReturn[] = "房源{$this->params['pro_id']}定价关系为空"; } // 重新计算低价并更新 $prop = Bll_HzProp::get_prop($this->params['pro_id']); $priceNum = $prop['pricenum']; $cityId = $prop['cityid']; $priceLevel = Model_House_HzPriceChoice::get_price($cityId, $priceNum); $bottomPrice = $priceLevel['price']; Model_Plan_HzPlanning::updatePropPlan($fixPlanning['id'], array('unit_price' => $bottomPrice)); if (in_array($fixPlanning['is_valid'], array(Const_HzPlan::SPREAD, Const_HzPlan::AUTOOVER))) { //$this->writePropLog(4, '更新'); } } $this->tempDoBid(); }
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); } $rstList = array(); if (empty($comboInfos)) { return array('status' => Const_APIStatus::RETURN_CODE_OK, 'data' => array('list' => $rstList, '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('list' => $rstList, '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; //精选状态 if ($plan['status'] == 1) { $propertyList[$propId]['choiceStatus'] = 3; $propertyList[$propId]['choiceStatusName'] = '精选中'; } elseif ($plan['status'] == 13) { $propertyList[$propId]['choiceStatus'] = 4; $propertyList[$propId]['choiceStatusName'] = '排队中'; } } 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); //城市是否开通精选 $cityIsChoice = Bll_City::isChoiceCity($cityId, Const_Site::HAOZU); 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']); //是否委托 $isEntrust = Bll_Zufang_Choice::isCommissionHouse($list['propId'], $ajkBrokerId, Model_House_Commission::TYPE_RENT); $row['isEntrust'] = $isEntrust ? 1 : 0; if (isset($list['choiceStatus']) && isset($list['choiceStatusName']) && $cityIsChoice) { $row['choiceStatus'] = $list['choiceStatus']; $row['choiceStatusName'] = $list['choiceStatusName']; } else { $choiceStatus = Bll_HzProp::getZuFangChoiceStatus($list, $cityId, $cityIsChoice); $row['choiceStatus'] = $choiceStatus['choiceStatus']; $row['choiceStatusName'] = $choiceStatus['choiceStatusName']; } $rstList[] = $row; } return array('status' => Const_APIStatus::RETURN_CODE_OK, 'data' => array('list' => $rstList, 'surplus' => $surplus - $currentSpreadHouseCount, 'hasCombo' => $hasCombo)); }
/** * 计算竞价房源排名 * @param $proId * @param $commId * @param $priceNum * @param $unitPrice * @param $cityId * @return int */ public static function getBidRank($proId, $commId, $priceNum, $unitPrice, $cityId) { // 获取价格段 $priceBlock = Bll_HzBidPlan::get_price_block($cityId, $priceNum); // 板块id $ajkid = Bll_HzProp::get_subregion_id($commId, $proId); $rank = Util_SearchUtil::getHpCurrentRank($cityId, $ajkid, $proId, $priceBlock['LOWER'], $priceBlock['UPPER'], $unitPrice); if ($rank > 5) { $rank = '排队中'; } return $rank; }
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)); }
/** * 处理小区id为0的情况 * @param $beginId * @param $nocomms * @param $cityId * @param int $limit * @return array */ public function dealPropCommidZero($beginId, $nocomms, $cityId, $limit = 100) { $allReturn = array(); if (empty($nocomms)) { return array('status' => 0, 'msg' => 'nocomms is empty'); } $searchProps = Bll_HzProp::getSearchProps(array('where' => 'status in (1,2,5,6,9,11,12,13,14,15) and cityid=? and proid>? limit ' . $limit, 'params' => array($cityId, $beginId)), $cityId); if (empty($searchProps)) { return array('status' => 0, 'msg' => 'empty'); } foreach ($searchProps as $searchProp) { $proId = $this->cursor = $searchProp['proid']; if ($searchProp['commid']) { continue; } $prop = Bll_HzProp::get_prop($proId); foreach ($nocomms as $index => $nocomm) { $blockInofNew = Bll_HzProp::getBlockByTypeCode($nocomm['new_code']); $blockInofOld = Bll_HzProp::getBlockByTypeCode($nocomm['old_code']); if (!$blockInofNew || !$blockInofOld) { return array('status' => 0, 'msg' => 'block info is empty'); } if ($prop['blockid'] == $blockInofOld['id'] && $prop['areaid'] == $blockInofOld['parentid']) { // 更新房源信息 $result = $this->changePropBlock($proId, $blockInofNew['id'], $blockInofNew['parentid'], $cityId, $searchProp['ajk_brokerid']); if ($result['status'] == 0) { $this->setLog('租房房源区域板块更新失败 id:[ ' . $proId . ' ]' . ' info:' . $result['msg']); } else { $this->setLog('租房房源区域板块更新成功 id:[ ' . $proId . ' ]'); //通知上下架队列 $param['prop_id'] = $proId; $param['spread_id'] = 0; // $param['ajk_broker_id'] = $searchProp['ajk_brokerid']; $param['from'] = 'cms_' . __FUNCTION__; $param['time'] = time(); $param['operate_id'] = 0; $param['site_type'] = 2; $param['remark'] = json_encode(array('cityId' => $cityId, 'old' => $nocomm['old_code'], 'new' => $nocomm['new_code'])); $param['type'] = 'community_area_change_ex'; $getRes = $this->action_collect_Api_new($param); $res = json_decode($getRes, true); if ($res['status'] == 'err') { $this->setLog('调用上下架队列api失败,租房房源id:[ ' . $proId . ' ] info:' . $res['msg']); } else { $this->setLog('调用上下架队列api成功,租房房源id:[ ' . $proId . ' ] info:' . $res['msg']); } } $allReturn = array_merge($allReturn, $result['msg']); } } } return array('status' => 1, 'msg' => $allReturn); }
/** * 组装未推广列表 取出所有-有效定价房源 * @param $out * @return array */ private static function prepareOutList(&$out) { $outList = array(); $outPropIds = array(); $fixProIds = array_keys($out['props']); // 取出经纪人所有非删除房源 (分表) $allSearchProps = Model_House_HzPropSearch::getPropLists($out['cityId'], array(array('ajkBrokerId', '=', $out['ajkBrokerId']), array('status', '<>', Const_HzStatus::DELETE), array('status', '<>', Const_HzStatus::OFFLINE), array('status', '<>', Const_HzStatus::OUTPORT), array('status', '<>', Const_HzStatus::HIBERNATE), array('status', '<>', Const_HzStatus::REMOVE), array('status', '<>', Const_HzStatus::EXPIRED)), 1000, array('created', 'desc')); if (empty($allSearchProps)) { return array(); } // 获取城市价格段 $allPrices = Model_House_HzPriceChoice::getAllPriceByCityId($out['cityId']); $out['getQualityProIds'] = array(); foreach ($allSearchProps as $allSearchProp) { $proId = $allSearchProp['proid']; $out['getQualityProIds'][] = $proId; // 过滤非删除状态定价 if (in_array($proId, $fixProIds)) { continue; } $outList[$proId] = $allSearchProp; // 获取剩余时间 $outList[$proId]['leftDays'] = Bll_House_HzHouse::getLeftDays($allSearchProp['created']); $outPropIds[] = $proId; } // 获取改经纪人所有房源质量 $out['propsQuality'] = Model_Stats_HzPropQuality::getPropsquality($out['getQualityProIds']); // 获取如是违规房源 拼接违规原因 $outList = Bll_HzProp::checkAndGetPropsIllegalInfos($outList); // 批量获取主表信息 if (empty($outPropIds)) { return array(); } $props = Model_House_HzProp::getPropsByPropIds($outPropIds); if (!$props) { return array(); } // 房源主分表信息合并 foreach ($outList as $proId => $outProp) { $outList[$proId] = array_merge($outList[$proId], $props[$proId]); // 计算点击价格 if (!empty($allPrices)) { foreach ($allPrices as $priceInfo) { if ($priceInfo['lower'] < $outList[$proId]['pricenum'] && $priceInfo['upper'] >= $outList[$proId]['pricenum']) { $outList[$proId]['unitPrice'] = $priceInfo['price']; break; } } } } return $outList; }
/** * 处理小区id为0的情况 * @param $beginId * @param $nocomms * @param $cityId * @param $youBiaoFile * @param int $limit * @return array */ public static function dealPropCommidZero($beginId, $nocomms, $cityId, $youBiaoFile, $limit = 1000) { $allReturn = array(); if (empty($nocomms)) { return self::buildReturn(0, 'nocomms is empty'); } // sql commid=0去掉 $searchProps = Bll_HzProp::getSearchProps(array('where' => 'status in (1,2,5,6,9,11,12,13,14,15) and cityid=? and proid>? limit ' . $limit, 'params' => array($cityId, $beginId)), $cityId); if (empty($searchProps)) { return self::buildReturn(0, 'empty'); } foreach ($searchProps as $searchProp) { $proId = $searchProp['proid']; file_put_contents($youBiaoFile, $proId); if ($searchProp['commid']) { continue; } $prop = self::get_prop($proId); foreach ($nocomms as $index => $nocomm) { $blockInofNew = Bll_HzProp::getBlockByTypeCode($nocomm['new_code']); $blockInofOld = Bll_HzProp::getBlockByTypeCode($nocomm['old_code']); if (!$blockInofNew || !$blockInofOld) { return self::buildReturn(0, 'block info is empty'); } if ($prop['blockid'] == $blockInofOld['id'] && $prop['areaid'] == $blockInofOld['parentid']) { // 更新房源信息 $result = self::changePropBlock($proId, $blockInofNew['id'], $blockInofNew['parentid'], $cityId); if (!$result['status']) { return $result; } $allReturn = array_merge($allReturn, $result['msg']); } /*else { $allReturn[] = "proid: " . $proId . ",不需要更新"; }*/ } } return self::buildReturn(1, $allReturn); }