/** * 获取页面的初始化信息 * * @param int $brokerId * @param int $cityId * @param AJKRequest $request * @return array */ public static function preparePageParam($brokerId, $cityId, $request) { /** 获取房源发布&编辑页面的示例URL */ $pageParams = Bll_House_EsfPublish::getExampleURL($cityId); /** 是否需要显示备案信息 */ $pageParams['houseRecordNumberConfig'] = static::getHouseRecordNumberConfig($cityId); $pageParams['priceMentionUrl'] = static::getPriceMentionUrl($cityId); $pageParams['publishHouseProtocolUrl'] = static::getPublishHouseProtocolUrl($cityId); $pageParams['brokerId'] = $brokerId; $pageParams['cityId'] = $cityId; /** 装修情况 */ $pageParams['fitmentList'] = Model_House_FitmentType::getFitment($cityId); /** 房屋类型 */ $pageParams['useTypeList'] = Model_Community_UseType::getUseTypeByCityId($cityId); /** 房屋朝向 */ $pageParams['orientateList'] = APF::get_instance()->get_config('house_orientate', 'house'); /** 经纪人已经发不过的小区 */ $pageParams['publishedCommunityList'] = static::getPublishedCommunityList($brokerId); /** 获取小区和房源公共标签 */ $pageParams['privateTagList'] = static::getPrivateTagList(); /** 获取上传图片服务器 */ $pageParams['uploadImgService'] = static::getUploadImageServer(); $pageParams['picData'] = array('UPDROOM' => array(), 'ALLMODEL' => array(), 'ALLCOMM' => array()); /** 最低首付配置 */ $miniPayDownConfig = static::getMiniPayDownConfig($cityId); if (Bll_Broker_HzBroker::isPpcBroker($brokerId)) { $pageParams['canSpread'] = Bll_Broker_HzBroker::ajkPpcBrokerCanSpreadHouse($cityId, $brokerId); $pageParams['brokerActionTip'] = '推广房源已满,只能保存到未推广房源'; } if (Bll_Broker_HzBroker::isComboBroker($brokerId)) { $checkCanSpreadResult = Bll_Combo_HouseRelation::housePublishComboCheck($brokerId, $cityId, Bll_Combo_HouseRelation::SITE_TYPE_AJK); $pageParams['canSpread'] = $checkCanSpreadResult['status'] == 1; $pageParams['brokerActionTip'] = $checkCanSpreadResult['msg']; } return array_merge($pageParams, $miniPayDownConfig); }
/** * 页面数据预加载模块 */ public function beforePost() { // 初始化页面变量 $this->ctx = Bll_House_HzPublish::initPageVariables($this->ctx); if ($this->ctx['proId']) { $propInfo = Bll_House_HzHouse::getPropInfo($this->ctx['proId'], $this->ctx['cityId']); // 房源不存在 if (!$propInfo['status']) { $this->redirect2Result(Const_PublishCode::HOUSE_NOT_EXIST, $this->site, $this->action, $this->ctx['proId']); } $tmpProId = $this->ctx['proId']; if ($propInfo['status']) { $this->ctx = array_merge($this->ctx, $propInfo['msg']); } // fix 大json里proid存成0的问题 if (!$this->ctx['proId']) { $this->ctx['proId'] = $tmpProId; } // 非自己房子 if ($propInfo['msg']['userid'] != $this->ctx['hzBrokerId']) { $this->redirect2Result(Const_PublishCode::NOT_OWN_HOUSE, $this->site, $this->action, $this->ctx['proId']); } } // 区域 $this->ctx['areaArr'] = Model_City_HzArea::getAreasByCityId($this->ctx['cityId']); // 板块 $this->ctx['blockArr'] = Model_City_HzArea::getBlockByAreaId($this->ctx['areaid']); // 房屋类型 $this->ctx['propTypeArr'] = Bll_House_HzHouse::getPropType($this->ctx['cityId']); // 装修类型 $this->ctx['fitmentArr'] = Bll_House_HzHouse::getFitment($this->ctx['cityId']); // 朝向 $this->ctx['towardArr'] = Bll_House_HzHouse::getToward(); // 房屋配置 $this->ctx['deploymentArr'] = Bll_House_HzHouse::getDeployment(); // 付款类型 $this->ctx['payTypeArr'] = Bll_House_HzHouse::getRentDepositAndCycle($this->ctx['cityId']); // 合租类型 $this->ctx['shareType'] = Bll_House_HzHouse::getShareType(); // 合租性别 $this->ctx['shareSexArr'] = Bll_House_HzHouse::getShareSex(); // 检查低价城市 $this->ctx['checkLowPriceCity'] = Bll_House_HzHouse::getCheckLowPriceCity(); // 获取图片 $this->ctx['images'] = Bll_Image_HzHouseImage::getImagesByHouseIds($this->ctx['proId'], true); $this->ctx['picData'] = Bll_House_HzPublish::buildImagesForPage($this->ctx['images']); $this->ctx['isShowCommPic'] = in_array($this->ctx['cityId'], array(11)) ? 0 : 1; $this->ctx['publishHouseProtocolUrl'] = Bll_House_EsfPublish::getPublishHouseProtocolUrl($this->ctx['cityId']); // 房源是否可以推广信息 $this->ctx = Bll_House_HzPublish::getSpreadFlagInfo($this->ctx); // 获取图片服务器host $this->ctx['picUploadServerDomain'] = Bll_Image_HzHouseImage::getPicUpdServerDomain(); if ($this->ctx['isEdit']) { $this->action = 'edit'; } // inject $this->ctx = Bll_House_HzPublish::beforePostInjectAfter($this->ctx); // debug $this->ctx['debug'] == 'all' && (print_r($this->ctx) && die); if (isset($this->ctx['file'])) { unset($this->ctx['file']); } return $this->ctx; }
public function handlePost() { $this->request = APF::get_instance()->get_request(); $brokerId = $this->request->getBrokerId(); $cityId = $this->request->getBrokerCityId(); $params = $this->request->get_parameters(); $params['broker_id'] = $brokerId; $result = array(); try { if ($this->action == 'edit') { $houseInfo = Bll_House_EsfEdit::getHouseBaseInfo($this->houseId); /** 违规房源不可以编辑 */ if (isset($houseInfo['isIllegal']) && $houseInfo['isIllegal']) { $this->redirect2Result(Const_PublishCode::UNKNOWN_ERROR, 'ajk', 'edit', $this->houseId, '已违规房源不可编辑'); } $result = Bll_House_EsfEdit::saveHouseInfo($brokerId, $cityId, $this->houseId, $params); } if ($this->action == 'publish') { $result = Bll_House_EsfPublish::saveHouseInfo($brokerId, $params, $this->isComboBroker); if ($result['status'] == 'ok') { $this->houseId = $result['houseId']; } } /** 委托房源发布 */ if ($this->action == 'commission') { $result = Bll_House_EsfCommission::saveHouseInfo($brokerId, $cityId, $this->commissionId, $params, $this->isComboBroker); if ($result['status'] == 'ok') { $this->houseId = $result['houseId']; } } if ($result['status'] != 'ok') { $this->redirect2Result(Const_PublishCode::PUBLISH_PROP_ERROR, 'ajk', $this->action, $this->houseId, $result['info']); } } catch (Exception $e) { $params['brokerId'] = self::$intBrokerID; APF::get_instance()->get_nlogger()->log(__CLASS__, $params); $this->redirect2Result(Const_PublishCode::PUBLISH_PROP_ERROR, 'ajk', $this->action, $this->houseId, $e->getMessage()); } /** 立即推广 */ if (isset($params['broker_action']) && $params['broker_action'] == 'publish') { /** 套餐推广 */ if ($this->isComboBroker) { $spreadResult = Bll_Combo_HouseRelation::houseStartComboSpreadV2($brokerId, $cityId, array($this->houseId), Bll_Combo_HouseRelation::SITE_TYPE_AJK); if ($spreadResult['status'] != 1) { switch ($spreadResult['status']) { /** 没有套餐 */ case -1: case -2: $this->redirect2Result(Const_PublishCode::SPREAD_PROP_NO_COMBO, 'ajk', $this->action, $this->houseId, $spreadResult['msg']); break; /** 套餐未生效 */ /** 套餐未生效 */ case -3: $this->redirect2Result(Const_PublishCode::SPREAD_PROP_COMBO_ACTIVE, 'ajk', $this->action, $this->houseId, $spreadResult['msg']); break; /** 推广房源数已满 */ /** 推广房源数已满 */ case -4: case -5: $this->redirect2Result(Const_PublishCode::SPREAD_PROP_COMBO_LIMIT, 'ajk', $this->action, $this->houseId, $spreadResult['msg']); break; default: $this->redirect2Result(Const_PublishCode::SPREAD_PROP_COMBO_FAIL, 'ajk', $this->action, $this->houseId, $spreadResult['msg']); } } } else { /** 定价推广 */ if ($this->action == 'edit') { /** 定价推广失败 房源已经推广 */ if (BLL_Plan_EsfPropFixedPlanRelation::isHouseOnline($cityId, $this->houseId)) { $this->redirect2Result(Const_PublishCode::SPREAD_PROP_PLAN_IN, 'ajk', $this->action, $this->houseId, '房源已经推广'); } } $fixPlanList = BLL_Plan_EsfPropFixedPlanRelation::getBrokerValidPlan($brokerId); if (empty($fixPlanList)) { $this->redirect2Result(Const_PublishCode::UNKNOWN_ERROR, 'ajk', $this->action, $this->houseId, '获取定价计划信息失败'); } $fixPlan = $fixPlanList[0]; /** 定价推广失败 已经超出推广房源上限 */ if (!Bll_Broker_HzBroker::ajkPpcBrokerCanSpreadHouse($cityId, $brokerId)) { $this->redirect2Result(Const_PublishCode::SPREAD_PROP_OUT_LIMIT, 'ajk', $this->action, $this->houseId, '已经超出推广房源上限'); } $spreadResult = Bll_Ppc_ServiceAPI::fixPlanAddHouse($brokerId, $this->houseId, $fixPlan['id'], '23532'); if (isset($spreadResult['status'])) { if ($spreadResult['status'] != 'ok') { $this->redirect2Result(Const_PublishCode::API_ERROR, 'ajk', $this->action, $this->houseId, $spreadResult['info']); } } else { $this->redirect2Result(Const_PublishCode::API_ERROR, 'ajk', $this->action, $this->houseId, '系统繁忙(推广房源超时)'); } /** 定价推广失败 计划已经手动停止 */ if ($fixPlan['viewTime'] == 1861891200) { /** 定价推广失败 认证未通过 */ $brokerCheckState = Bll_Broker_BrokerCheckInfo::getCheckStateByBrokerId($brokerId); if ($brokerCheckState != 1) { $this->redirect2Result(Const_PublishCode::SPREAD_PROP_AUDITED_ERROR, 'ajk', $this->action, $this->houseId, '认证未通过'); } $this->redirect2Result(Const_PublishCode::SPREAD_PROP_HANDLE_STOP, 'ajk', $this->action, $this->houseId, '计划已经手动停止'); } /** 定价推广失败 账户余额不足,充值后自动推广 */ if ($fixPlan['viewTime'] == 1893427200) { $this->redirect2Result(Const_PublishCode::SPREAD_PROP_BALANCE_ERROR, 'ajk', $this->action, $this->houseId, '账户余额不足,充值后自动推广'); } } /** 推广成功 */ $this->redirect2Result(Const_PublishCode::HOUSE_SPREAD_SUCCESS, 'ajk', $this->action, $this->houseId); } /** 发布成功 */ $this->redirect2Result(Const_PublishCode::HOUSE_SAVE_SUCCESS, 'ajk', $this->action, $this->houseId); }
public function handle_request_internal() { $request = APF::get_instance()->get_request(); $params = $request->get_parameters(); $fields = array('commId', 'roomNum', 'hallNum', 'toiletNum', 'houseOri'); $apiParams = array(); foreach ($fields as $field) { if (!isset($params[$field])) { $this->responseJSON('error', array(), '参数不全'); return; } $apiParams[$field] = $params[$field]; } $data = array('MODELPIC' => array(), 'COMMPIC' => array()); $apiParams['houseOri'] = Bll_House_EsfPublish::getPropOrigin($apiParams['houseOri']); try { /** * @var $result Bll_Service_Client_HttpResponse */ $result = Bll_Service_Image::esfGetImgInfo($apiParams); if ($result->isFailed()) { $this->responseJSON('error', $data, '调用API超时'); return; } if ($result['status'] != 'ok') { $this->responseJSON('error', $data, '调用API失败'); return; } /** 房型图 */ $modelPicAIds = array(); if (isset($result['publicPicResult']['fineImg']['count']) && isset($result['publicPicResult']['fineImg']['list'])) { foreach ($result['publicPicResult']['fineImg']['list'] as $imageInfo) { $modelPicAIds[] = $imageInfo['Aid']; } } if (isset($result['publicPicResult']['readyImg']['count']) && isset($result['publicPicResult']['readyImg']['list'])) { foreach ($result['publicPicResult']['readyImg']['list'] as $imageInfo) { $modelPicAIds[] = $imageInfo['Aid']; } } if (!empty($modelPicAIds)) { $modelImageList = Model_Community_Attachment::getImageInfoById($modelPicAIds, array('aid', 'fileName', 'hostId')); foreach ($modelImageList as $imageInfo) { $imageInfo['AID'] = intval($imageInfo['aid']); $imageInfo['commPicId'] = intval($imageInfo['aid']); $imageInfo['IMGURL'] = Util_ImageUtils::getResizeURL($imageInfo['fileName'], $imageInfo['hostId'], 100, 75); $imageInfo['BIGIMGURL'] = Util_ImageUtils::getResizeURL($imageInfo['fileName'], $imageInfo['hostId'], 600, 600); $data['MODELPIC'][] = $imageInfo; } } if (isset($result['publicPicResult']['othResult']['count']) && isset($result['publicPicResult']['othResult']['attachmentsComm'])) { foreach ($result['publicPicResult']['othResult']['attachmentsComm'] as $imageInfo) { $imageInfo['AID'] = intval($imageInfo['Aid']); $imageInfo['commPicId'] = intval($imageInfo['Aid']); $imageInfo['IMGURL'] = Util_ImageUtils::getResizeURL($imageInfo['FileName'], $imageInfo['host_id'], 100, 75); $imageInfo['BIGIMGURL'] = Util_ImageUtils::getResizeURL($imageInfo['FileName'], $imageInfo['host_id'], 600, 600); $data['MODELPIC'][] = $imageInfo; } } /** 小区图 */ if (isset($result['publicPicResult']['commPic']['count']) && isset($result['publicPicResult']['commPic']['attachmentsComm'])) { foreach ($result['publicPicResult']['commPic']['attachmentsComm'] as $imageInfo) { $imageInfo['AID'] = intval($imageInfo['Aid']); $imageInfo['commPicId'] = intval($imageInfo['Aid']); $imageInfo['IMGURL'] = Util_ImageUtils::getResizeURL($imageInfo['FileName'], $imageInfo['host_id'], 100, 75); $imageInfo['BIGIMGURL'] = Util_ImageUtils::getResizeURL($imageInfo['FileName'], $imageInfo['host_id'], 600, 600); $data['COMMPIC'][] = $imageInfo; } } $data['MODELPIC'] = array_slice($data['MODELPIC'], 0, 10); $data['COMMPIC'] = array_slice($data['COMMPIC'], 0, 20); $this->responseJSON('ok', $data, ''); } catch (Exception $e) { $this->responseJSON('error', $data, $e->getMessage()); } }
public static function saveHouseInfo($brokerId, $cityId, $commissionId, $params, $isComboBroker) { /** 验证小区 */ $communityId = $params['CommId']; if (!Bll_House_EsfPublish::verifyCommunity($cityId, $communityId)) { return array('status' => 'error', 'info' => '小区不存在'); } $field = Bll_House_EsfPublish::prepareApiParam($brokerId, $params); /** * @var $result Bll_Service_Client_HttpResponse */ if ($isComboBroker) { $result = Bll_Service_House::esfAddHouseCombo($field); } else { $result = Bll_Service_House::esfAddHousePPC($field); } if ($result->isFailed()) { return array('status' => 'error', 'info' => '调用API超时'); } if ($result['status'] != 'ok') { return array('status' => 'error', 'code' => $result['code'], 'info' => $result['info']); } $houseId = $result['action']['proid']; //todo 更新委托房源信息 static::insertCommissionSaleLog($brokerId, $cityId, $commissionId, $houseId); $saveImageResult = Bll_House_EsfPublish::saveImage($houseId, $params); $saveImageResult['houseId'] = $houseId; return $saveImageResult; }
/** * 房源编辑保存房源信息 * * @param $brokerId * @param $cityId * @param $houseId * @param $params * @return array */ public static function saveHouseInfo($brokerId, $cityId, $houseId, $params) { $params['broker_id'] = $brokerId; $fields = static::prepareApiParam($houseId, $params); /** * @var $result Bll_Service_Client_HttpResponse */ if (Bll_Broker_HzBroker::isComboBroker($brokerId)) { $result = Bll_Service_House::esfUpdateHouseCombo($fields); } else { $result = Bll_Service_House::esfUpdateHousePPC($fields); } if (!$result->isSucceeded()) { return array('status' => 'error', 'info' => '调用API超时'); } if ($result['status'] != 'ok') { return array('status' => 'error', 'code' => $result['code'], 'info' => $result['info']); } $saveImageResult = Bll_House_EsfPublish::saveImage($houseId, $params); return $saveImageResult; }