コード例 #1
0
ファイル: PublishAjk.php プロジェクト: emilymwang8/ajk-broker
 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);
 }
コード例 #2
0
ファイル: EsfEdit.php プロジェクト: emilymwang8/ajk-broker
 /**
  * 获取页面的初始化信息
  *
  * @param int $brokerId
  * @param int $cityId
  * @param int $houseId
  * @param AJKRequest $request
  * @throws Exception
  * @return array
  */
 public static function preparePageParam($brokerId, $cityId, $houseId, $request)
 {
     /** 获取房源发布&编辑页面的示例URL */
     $pageParams = Bll_House_EsfPublish::getExampleURL($cityId);
     /** 是否需要显示备案信息 */
     $pageParams['houseRecordNumberConfig'] = Bll_House_EsfPublish::getHouseRecordNumberConfig($cityId);
     $pageParams['priceMentionUrl'] = Bll_House_EsfPublish::getPriceMentionUrl($cityId);
     $pageParams['publishHouseProtocolUrl'] = Bll_House_EsfPublish::getPublishHouseProtocolUrl($cityId);
     $pageParams['brokerId'] = $brokerId;
     $pageParams['cityId'] = $cityId;
     $pageParams['houseId'] = $houseId;
     /** 装修情况 */
     $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['privateTagList'] = Bll_House_EsfPublish::getPrivateTagList();
     /** 获取上传图片服务器 */
     $pageParams['uploadImgService'] = Bll_House_EsfPublish::getUploadImageServer();
     $pageParams['picData'] = static::getHouseImageEx($brokerId, $houseId);
     /** 最低首付配置 */
     $miniPayDownConfig = Bll_House_EsfPublish::getMiniPayDownConfig($cityId);
     $houseInfo = Bll_House_EsfEdit::getHouseBaseInfo($houseId);
     $pageParams['houseInfo'] = $houseInfo;
     if ($houseInfo['commissionType'] == 2 || $houseInfo['commissionType'] == 3) {
         $commissionInfo = Bll_House_EsfCommission::getCommissionByBrokerHouseId($houseId, $brokerId);
         $commissionHouseInfo = Bll_House_EsfCommission::getCommissionHouseInfo($commissionInfo['house']);
         $pageParams['commissionHouseInfo'] = $commissionHouseInfo;
     }
     $selectTagList = Model_House_AjkPrivateTag::getHouseTagById($houseInfo['ProPrivateTag']);
     foreach ($pageParams['privateTagList']['commTag'] as &$commTag) {
         if (in_array($commTag['tagId'], $houseInfo['ProPrivateTag'])) {
             $commTag['enable'] = false;
         }
     }
     foreach ($pageParams['privateTagList']['houseTag'] as &$subType) {
         foreach ($subType as &$houseTag) {
             if (in_array($houseTag['tagId'], $houseInfo['ProPrivateTag'])) {
                 $houseTag['enable'] = false;
             }
         }
     }
     $pageParams['selectTagList'] = $selectTagList;
     $pageParams['canSpread'] = true;
     $pageParams['brokerActionTip'] = '推广房源已满,只能保存到未推广房源';
     $pageParams['houseIsSpreading'] = false;
     if (Bll_Broker_HzBroker::isPpcBroker($brokerId)) {
         $pageParams['houseIsSpreading'] = BLL_Plan_EsfPropFixedPlanRelation::isHouseOnline($cityId, $houseId);
         if (!$pageParams['houseIsSpreading']) {
             $pageParams['canSpread'] = Bll_Broker_HzBroker::ajkPpcBrokerCanSpreadHouse($cityId, $brokerId);
         } else {
             $pageParams['canSpread'] = false;
         }
     }
     if (Bll_Broker_HzBroker::isComboBroker($brokerId)) {
         $pageParams['houseIsSpreading'] = false;
         $houseRelation = Bll_Combo_HouseRelation::getOnlineRelationByHouseId($houseId, Bll_Combo_HouseRelation::SITE_TYPE_AJK);
         if (!empty($houseRelation)) {
             $pageParams['houseIsSpreading'] = true;
             $pageParams['canSpread'] = false;
         }
         if (!$pageParams['houseIsSpreading']) {
             $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);
 }