예제 #1
0
 public function dealTask($solrOnProId)
 {
     $brokerId = 0;
     $houseInfo = Bll_House_EsfHouse::getHouseInfoById($solrOnProId, $this->cityId);
     if (!empty($houseInfo)) {
         if ($this->isSowooHouse($houseInfo)) {
             printf('房源 %d 是机器抓取的不做处理' . PHP_EOL, $solrOnProId);
             return true;
         }
         if ($onlineComboRelation = Bll_Combo_HouseRelation::getOnlineRelationByHouseId($solrOnProId, Bll_Combo_HouseRelation::SITE_TYPE_AJK)) {
             printf('房源 %s 已经在套餐推广中, 不用通知solr下' . PHP_EOL, $solrOnProId);
             return true;
         }
         $brokerId = $onlineComboRelation['brokerId'];
     }
     // 房源没有或者不在线 通知solr下
     //$this->addPriceQueueByAPI($onlineComboRelation['brokerId'], $this->cityId, $solrOnProId, 2, 0, 0);
     $result = Bll_Combo_NoticeSolrUpDown::noticeComboSolrAjkAPI($this->cityId, $brokerId, $solrOnProId, Bll_Combo_NoticeSolrUpDown::SOLR_ACTION_DOWN, Bll_Combo_NoticeSolrUpDown::HLSFromComboCheckNotice);
     printf('房源 %s 没有在套餐推广中, 需要通知solr下' . PHP_EOL, $solrOnProId);
     printf('房源 %s 通知中间件返回的结果status=%s ; message=%s' . PHP_EOL, $solrOnProId, $result['status'], $result['message']);
     return true;
 }
예제 #2
0
 /**
  * 新加竞价
  *
  * @param $hz_broker_id
  * @param $prop_id
  * @param $price
  * @param $amount
  * @param $block_id
  * @param $city_id
  * @param $sn
  * @param $ajk_broker_id
  * @return array
  */
 public static function add_plan($hz_broker_id, $prop_id, $price, $amount, $block_id, $city_id, $sn, $ajk_broker_id = 0)
 {
     $propSearchInfo = Model_House_HzPropSearch::get_prop_by_prop_id($city_id, $prop_id);
     if (empty($propSearchInfo)) {
         return array('error_code' => Bll_Plan_Bid_Choice::BID_FAIL_OTHER, 'error_message' => '房源不存在。');
     }
     $prop_status = $propSearchInfo['status'];
     /** 检查 经纪人是不是 已经满足10套 */
     $onlinePlanCount = Model_Plan_HzPlanBasic::count_online_bid_plan_ex($ajk_broker_id);
     if ($onlinePlanCount >= Bll_Plan_Bid_Choice::ALL_ZF_PLAN_NUM) {
         return array('error_code' => Bll_Plan_Bid_Choice::BID_FAIL_OTHER, 'error_message' => '您最多可以对' . Bll_Plan_Bid_Choice::ALL_ZF_PLAN_NUM . '套房源做竞价推广,请确认数量是否已经达到上限');
     }
     /** 判断房源是否已经在竞价计划中了 */
     $propBidInfo = Model_Plan_HzPlanning::getPropBidPlan($prop_id);
     if (!empty($propBidInfo)) {
         $planBasic = Model_Plan_HzPlanBasic::get_plan_by_id($propBidInfo['plan_id']);
         if ($planBasic['bid_version'] == Const_HzPlan::BID_VERSION_CHOICE && $planBasic['flag'] != 0 && $planBasic['status'] != Const_HzPlan::DELETE) {
             return array('error_code' => Bll_Plan_Bid_Choice::BID_FAIL_OTHER, 'error_message' => '该房源已经处于精选状态,请先删除');
         }
     }
     /** 判断是否是精选开放城市 */
     if (!Bll_City::isChoiceIndependentCity($city_id, Const_Site::ANJUKE)) {
         /** 判断房源是否在套餐推广中 */
         if (!Bll_Combo_HouseRelation::getOnlineRelationByHouseId($prop_id, Bll_Combo_HouseRelation::SITE_TYPE_HZ)) {
             return array('err_no' => Bll_Plan_Bid_Choice::BID_FAIL_OTHER, 'err_msg' => '房源必须套餐推广才能参与精选推广');
         }
     }
     /** 更新房源状态 */
     $propPlanStatus = Bll_Ppc_HzProp::updatePropStatus($city_id, $prop_id, 2, 1);
     self::updateSpreadType($city_id, $prop_id, 4);
     $planId = self::insertBidPlan($hz_broker_id, $prop_id, $price, $amount, $block_id, $city_id, $sn, $ajk_broker_id);
     if ($planId == 0) {
         return array('error_code' => Bll_Plan_Bid_Choice::BID_FAIL_OTHER, 'error_message' => '创建计划失败');
     }
     // Bll_Ppc_HzProp::luceneUpdate($city_id, $prop_id, $propPlanStatus, 4);
     Bll_Log_EffectPropLog::addEffectPropLog($prop_id, Const_HaoPanLog::BIDPLANSTART, $hz_broker_id, 0, $prop_status, 1, 0, $planId);
     return array("error_code" => 0, "error_message" => '', 'planId' => $planId);
 }
예제 #3
0
 public function dealTask($task)
 {
     $solrOnProId = $task['id'];
     // 只下经纪人
     //1:老端口房源(安居客经纪人发的租房房源)
     //3:租房经纪人房源
     //0:个人房源
     $from = $task['from'];
     if ($from != 3) {
         printf('非经纪人房源 %s 不用处理' . PHP_EOL, $solrOnProId);
         return true;
     }
     if ($onlineComboRelation = Bll_Combo_HouseRelation::getOnlineRelationByHouseId($solrOnProId, Bll_Combo_HouseRelation::SITE_TYPE_HZ)) {
         printf('房源 %s 已经在套餐推广中, 不用通知solr下' . PHP_EOL, $solrOnProId);
         return true;
     }
     // 房源没有或者不在线 通知solr下
     //Dao_Broker_HzProp::into_prop_lucene($solrOnProId, $this->cityId, 2);
     $result = Bll_Combo_NoticeSolrUpDown::noticeComboSolrHzAPI($this->cityId, $onlineComboRelation['brokerId'], $solrOnProId, 2);
     printf('房源 %s 没有在套餐推广中, 需要通知solr下' . PHP_EOL, $solrOnProId);
     printf('房源 %s 通知中间件返回的结果status=%s ; message=%s' . PHP_EOL, $solrOnProId, $result['status'], $result['message']);
     return true;
 }
예제 #4
0
 /**
  * 判断房源是否可以参加精选房源推广
  *
  * @param $ajkBrokerId
  * @param $cityId
  * @param $propId
  * @return array
  */
 public static function checkPropCanChoice($ajkBrokerId, $cityId, $propId)
 {
     $propSearch = Model_House_HzPropSearch::get_prop_by_prop_id($cityId, $propId);
     if (empty($propSearch)) {
         return self::buildReturn(Bll_Plan_Bid_Choice::BID_FAIL_OTHER, '房源不存在');
     }
     /** 判断房源是否是当前经纪人的房源 */
     if ($propSearch['ajkBrokerId'] != $ajkBrokerId) {
         return self::buildReturn(Bll_Plan_Bid_Choice::BID_FAIL_OTHER, '房源不存在(code:-10086)');
     }
     /** 判断是否是精选开放城市 */
     if (!Bll_City::isChoiceIndependentCity($cityId, Const_Site::HAOZU)) {
         /** 判断房源是否在套餐推广中 */
         if (!Bll_Combo_HouseRelation::getOnlineRelationByHouseId($propId, Bll_Combo_HouseRelation::SITE_TYPE_HZ)) {
             return array('err_no' => Bll_Plan_Bid_Choice::BID_FAIL_OTHER, 'err_msg' => '房源必须套餐推广才能参与精选推广');
         }
     }
     /** 判断房源是否多图 */
     if ($propSearch['islabel'] == 0) {
         return self::buildReturn(Bll_Plan_Bid_Choice::BID_FAIL_QUALITY_OR_NEW, '多图、新发15天房源才能参与精选推广');
     }
     /** 判断房源是否是在15天内发布的 */
     if (date('ymd', strtotime('-16 days')) > date('Ymd', $propSearch['created'])) {
         return self::buildReturn(Bll_Plan_Bid_Choice::BID_FAIL_QUALITY_OR_NEW, '多图、新发15天房源才能参与精选推广');
     }
     /** 判断房源是否已经在竞价计划中了 取master */
     $propBidInfo = Model_Plan_HzPlanning::getPropBidPlan($propId, true);
     if (!empty($propBidInfo)) {
         $planBasic = Model_Plan_HzPlanBasic::get_plan_by_id($propBidInfo['plan_id'], true);
         if ($planBasic['bid_version'] == Const_HzPlan::BID_VERSION_CHOICE && in_array($planBasic['status'], array(Const_HzPlan::SPREAD, Const_HzPlan::WAITING))) {
             return self::buildReturn(Bll_Plan_Bid_Choice::BID_FAIL_OTHER, '该房源已经处于精选状态,请先删除');
         }
     }
     return array('err_no' => 0, 'err_msg' => '');
 }
 private function dealFailureHouse()
 {
     $houseIdList = file($this->_failureHouseIdFile);
     if (empty($houseIdList)) {
         $this->logMsg('没有需要处理的房源。');
         return;
     }
     foreach ($houseIdList as $houseId) {
         /** 再判断一下房源是否应该在线,预防将该下的房源通知上了 */
         $onlineHouseRelation = Bll_Combo_HouseRelation::getOnlineRelationByHouseId($houseId, Bll_Combo_HouseRelation::SITE_TYPE_AJK);
         if (empty($onlineHouseRelation)) {
             $this->logMsg(sprintf('房源[%d]已经下线, 不予处理。', $houseId));
             continue;
         }
         $this->logMsg(sprintf('调用参数:cityId=%d, brokerId=%d, houseId=%d', $onlineHouseRelation['cityId'], $onlineHouseRelation['brokerId'], $onlineHouseRelation['houseId']));
         $apiResponse = Bll_Combo_NoticeSolrUpDown::noticeComboSolrAjkAPI($onlineHouseRelation['cityId'], $onlineHouseRelation['brokerId'], $onlineHouseRelation['houseId'], Bll_Combo_NoticeSolrUpDown::SOLR_ACTION_UP, Bll_Combo_NoticeSolrUpDown::NOTICE_FROM_TYPE_CHECK_HOUSE_FOR_SOLR);
         if (is_null($apiResponse) || !isset($apiResponse['status']) || strcasecmp('ok', $apiResponse['status']) != 0) {
             $this->logMsg(sprintf('调用API失败。res: %s', json_encode($apiResponse)));
             continue;
         }
         $this->logMsg(sprintf('调用API成功。res: %s', json_encode($apiResponse)));
     }
     file_put_contents($this->_doneFile, 'DONE');
 }
예제 #6
0
 /**
  * 金铺-精选房源设置
  *
  * @param $ajkBrokerId
  * @param $cityId
  * @param $propId
  * @param array $params
  * @return array
  */
 public static function jp_setting_post($ajkBrokerId, $cityId, $propId, $params = array())
 {
     $jpBrokerInfo = Model_Broker_JpBroker::getJpBrokerInfoByAjkBrokerId($ajkBrokerId);
     //check房源是否已经加入精选推广
     $bidObj = Model_Plan_Jp::getBidPlanByHouseIdEx($ajkBrokerId, $propId, true);
     if (!empty($bidObj)) {
         if ($bidObj['status'] == Model_Plan_Jp::ENUM_STATUS_ONLINE || $bidObj['status'] == Model_Plan_Jp::ENUM_STATUS_CHOICE_HOLD) {
             return array('err_no' => self::BID_HOUSE_ALREADY_IN_BID, 'err_msg' => '房源已经加入精选推广');
         } elseif ($bidObj['status'] == Model_Plan_Jp::ENUM_STATUS_HOLD) {
             return array('err_no' => self::BID_FAIL_OTHER, 'err_msg' => '房源正在结算中,请稍后...');
         }
     }
     $bidChoiceCount = Model_Plan_Jp::getBidChoiceInfoEx($cityId, $ajkBrokerId);
     //获取精选推广预算
     $brokerInfo = Bll_BrokerBaseBll::get_instance()->get_broker_info($ajkBrokerId);
     $brokerCompanyId = $brokerInfo['BaseInfo']['COMPANYID'];
     $choiceSet = APF::get_instance()->get_config('choice_set');
     if (isset($choiceSet[$brokerCompanyId]) && !empty($choiceSet[$brokerCompanyId])) {
         $min_budget = $choiceSet[$brokerCompanyId]['jp']['JP_CHOICE_MIN_BUDGET'];
         $max_budget = $choiceSet[$brokerCompanyId]['jp']['JP_CHOICE_MAX_BUDGET'];
     } else {
         $min_budget = $choiceSet['default']['jp']['JP_CHOICE_MIN_BUDGET'];
         $max_budget = $choiceSet['default']['jp']['JP_CHOICE_MAX_BUDGET'];
     }
     if ($params['budget'] < $min_budget || $params['budget'] > $max_budget) {
         return array('err_no' => self::BID_FAIL_OTHER, 'err_msg' => '推广预算最低' . $min_budget . '安币,最高' . $max_budget . '安币');
     }
     $status = isset($bidObj['status']) ? $bidObj['status'] : 0;
     if (count($bidChoiceCount) >= self::ALL_JP_PLAN_NUM && $status != 4) {
         return array('err_no' => self::BID_FAIL_OTHER, 'err_msg' => '精选推广房源已经超过' . self::ALL_JP_PLAN_NUM . '套');
     }
     if (0 == $jpBrokerInfo) {
         return array('err_no' => self::BID_FAIL_OTHER, 'err_msg' => '您不是金铺经纪人');
     }
     /** 获取房源基本信息 */
     $propInfo = Bll_House_JpHouseInfo::getHouseInfoById($propId);
     if (empty($propInfo)) {
         return array('err_no' => self::BID_FAIL_OTHER, 'err_msg' => '房源不存在');
     }
     if ($propInfo['base']['memberId'] != $jpBrokerInfo['id']) {
         return array('err_no' => self::BID_FAIL_OTHER, 'err_msg' => '房源不属于该经纪人');
     }
     /** 判断是否是精选开放城市 */
     if (!Bll_City::isChoiceIndependentCity($cityId, Const_Site::JINPU)) {
         /** 判断房源是否在套餐推广 */
         $propCombos = Bll_Combo_HouseRelation::getOnlineRelationByHouseId($propId, Bll_Combo_HouseRelation::SITE_TYPE_JP);
         if (empty($propCombos)) {
             return array('err_no' => self::BID_FAIL_OTHER, 'err_msg' => '房源必须在套餐推广才能参与精选');
         }
     }
     if (false == $propInfo['info']['isExquisite']) {
         return array('err_no' => self::BID_FAIL_QUALITY_OR_NEW, 'err_msg' => '精品、新发15天房源才能参与精选推广', 'params' => array('site' => 'jp'));
     }
     $limitDay = intval(date('Ymd', strtotime('-15 days')));
     $postDay = intval(date('Ymd', strtotime($propInfo['base']['createTime'])));
     if ($limitDay > $postDay) {
         return array('err_no' => self::BID_FAIL_QUALITY_OR_NEW, 'err_msg' => '精品、新发15天房源才能参与精选推广', 'params' => array('site' => 'jp'));
     }
     /** 获取板块信息 **/
     $blockArr = Bll_House_JpHouseInfo::getBlock($propInfo['base']['houseType'], $propInfo['info']);
     if (!$blockArr['blockId'] && !$blockArr['newBlockId']) {
         return array('err_no' => self::BID_HOUSE_ALREADY_IN_BID, 'err_msg' => '房源缺少板块信息');
     }
     /** 获取价格信息 **/
     $arrPrice = Bll_House_JpHouseInfo::getPrice($cityId, $propInfo['base']['houseType'], $propInfo['info']);
     if (empty($arrPrice['price_id'])) {
         return array('err_no' => self::BID_FAIL_OTHER, 'err_msg' => '缺少价格段信息');
     }
     /** 获取点击单价开始 */
     try {
         $apiParams = array('brokerId' => $ajkBrokerId, 'cityId' => $cityId, 'price' => $arrPrice['price'] ?: 0, 'blockId' => $blockArr['blockId'] ?: 0, 'newBlockId' => $blockArr['newBlockId'] ?: 0, 'houseType' => $propInfo['base']['houseType']);
         /**
          * @var Bll_Service_Client_HttpResponse $clickPrice
          */
         for ($i = 0; $i < 3; $i++) {
             $clickPrice = Bll_Service_Choice::jpClickPrice($apiParams);
             if ($clickPrice->isSucceeded()) {
                 break;
             }
         }
         if (!$clickPrice->isSucceeded() || $clickPrice['status'] == 'error') {
             return array('err_no' => self::BID_FAIL_OTHER, 'err_msg' => '系统繁忙(code:-1000)');
         }
         if ($params['budget'] * 100 < $clickPrice['realTradeAmount']) {
             return array('err_no' => self::BID_FAIL_OTHER, 'err_msg' => '推广预算不能小于点击单价');
         }
         /** 点击单价不能小于当前系统内的单价 防止恶意操作 */
         if ($params['price'] < $clickPrice['realTradeAmount'] / 100) {
             return array('err_no' => self::BID_FAIL_OTHER, 'err_msg' => '点击单价错误');
         }
     } catch (Exception $e) {
         return array('err_no' => self::BID_FAIL_OTHER, 'err_msg' => '系统繁忙(code:-2000)');
     }
     /** 防并发 */
     if (false === self::rejectSameRequest(Bll_Plan_Bid_Choice::SITE_JP, $ajkBrokerId, $propId)) {
         return array('err_no' => self::BID_FAIL_OTHER, 'err_msg' => '系统繁忙(code:-906)');
     }
     /** 往冻结队列里添加记录,获取request id*/
     $bidFreezeOrder = new Bll_Plan_BidFreezeOrderNum(date('Y'));
     $ajk_user_id = Bll_Broker_MainBusiness::getDataByEsfId($ajkBrokerId)->memberId;
     $requestId = $bidFreezeOrder->getRequestId(Bll_Plan_BidFreezeOrderNum::JP, $ajk_user_id, date('Y'), 0, $propId);
     /** 冻结金额 **/
     $freezeResult = self::bid_freeze($ajkBrokerId, $params['budget'] * 100, $requestId, sprintf('金铺精选房源冻结,房源ID是: %d', $propId), Const_PaymentApp::JP_CHOICE);
     /** 判断是否冻结成功 **/
     $freezeResponse = $freezeResult->getResponse();
     if (!$freezeResult->isSucceeded() || $freezeResponse['status'] == 'error') {
         return array('err_no' => self::BID_FAIL_OTHER, 'err_msg' => isset($freezeResult['info']) ? $freezeResult['info'] . "code:" . $freezeResult['code'] : '冻结金额失败');
     }
     //检查是否有坑位 坑位+1
     $bucketStatus = Model_Choice_JPBidBucket::incrementUsedNum($blockArr['blockId'], $blockArr['newBlockId'], $propInfo['base']['houseType'], $arrPrice['price_id']);
     if (!$bucketStatus) {
         return array('err_no' => self::BID_WAIT_FAIL, 'err_msg' => '精选推广已满,请稍后再试');
     }
     /** 获取最小竞价单元的精选信息 **/
     $bucketInfo = Model_Choice_JPBidBucket::getBucketInfo($blockArr['blockId'], $blockArr['newBlockId'], $propInfo['base']['houseType'], $arrPrice['price_id']);
     /** 根据最小竞价单位里面的房源数判断当前的房源应该是排队还是推广中 **/
     /*
     if ($bucketInfo['usedNum'] > $bucketInfo['maxOnlineNum']) {
         $planStatus = Model_Plan_Jp::ENUM_STATUS_CHOICE_HOLD;
     } else {
         $planStatus = Model_Plan_Jp::ENUM_STATUS_ONLINE;
     }
     */
     $planStatus = Model_Plan_Jp::ENUM_STATUS_CHOICE_HOLD;
     /** 如果计划已经存在删除该计划**/
     if (isset($bidObj['status']) && $bidObj['status'] == 4) {
         Model_Plan_Jp::data_access()->set_field('isDelete', 1)->filter('id', $bidObj['id'])->update();
     }
     /** 构造计划数据 创建计划**/
     $planData = self::buildJpPlanData($cityId, $jpBrokerInfo['id'], $params['budget'], $freezeResult['data']['sn'], $propId, $blockArr['blockId'], $blockArr['newBlockId'], $arrPrice['price_id'], $propInfo['base']['houseType'], $planStatus);
     $planData['ajkBrokerId'] = $ajkBrokerId;
     $PlanObj = Model_Plan_Jp::create($planData);
     $PlanObj->save();
     if (empty($PlanObj->id)) {
         /** 坑位-1 **/
         Model_Choice_JPBidBucket::decrementUsedNum($blockArr['blockId'], $blockArr['newBlockId'], $propInfo['base']['houseType'], $arrPrice['price_id']);
         Model_Plan_Jp::data_access()->set_field('isDelete', 0)->filter('id', $bidObj['id'])->update();
         return array('err_no' => self::BID_FAIL_OTHER, 'err_msg' => '创建计划失败');
     }
     /** 更新房源里面的竞价计划id **/
     $propInfo['base']->bidSpreadId = $PlanObj->id;
     $propInfo['base']->save();
     /** 更新房源分表信息 **/
     //$propInfo['info']->isList = 1;
     $propInfo['info']->spreadOffer = $clickPrice['realTradeAmount'];
     $propInfo['info']->spreadOfferTime = time();
     $propInfo['info']->save();
     /** 构建精选动作处理数据 **/
     $choiceData = self::buildJpChoiceData($ajkBrokerId, Model_Choice_ActionQueue::ENUM_BEGIN_BY_HAND, $PlanObj->id, '经纪人手动推广', $propId);
     /** 插入到精选动作处理队列表 **/
     Model_Choice_ActionQueue::create($choiceData, date('m'))->save();
     $bidFreezeOrder->updateRequestComplete($requestId, $freezeResult['data']['sn'], $PlanObj->id);
     if ($bucketInfo['usedNum'] > $bucketInfo['maxOnlineNum']) {
         $rank = $bucketInfo['usedNum'] - $bucketInfo['maxOnlineNum'];
         return array('err_no' => self::BID_WAIT_SUCCESS, 'err_msg' => '精选排队成功', 'rank' => $rank);
     } else {
         return array('err_no' => self::BID_SHOW_SUCCESS, 'err_msg' => '精选推广成功');
     }
 }
예제 #7
0
 /**
  * 开启精选计划
  *
  * @param $brokerId int 经纪人id
  * @param $propId int 房源id
  * @param $budget int 预算,单位元
  */
 public function startChoice($brokerId, $propId, $budget)
 {
     try {
         //获取经纪人基本信息
         $brokerBaseInfo = Model_Broker_AjkBrokerExtend::findWithBrokerId($brokerId);
         if (empty($brokerBaseInfo)) {
             $this->error(self::EMPTY_BROKER_ERROR, self::EMPTY_BROKER_ERROR_MSG);
         }
         $cityId = $brokerBaseInfo->cityId;
         $userId = $brokerBaseInfo->userId;
         //判断经纪人城市是否开通精选
         if (!$this->checkChoiceOpen($brokerBaseInfo->cityId)) {
             $this->error(self::CHOICE_CLOSE_ERROR, self::CHOICE_CLOSE_ERROR_MSG);
         }
         //判断预算的合法性
         if ($budget < Bll_Plan_Bid_Choice::ESF_CHOICE_MIN_BUDGET || $budget > Bll_Plan_Bid_Choice::ESF_CHOICE_MAX_BUDGET) {
             $this->error(self::BUDGET_INVALID_ERROR, self::BUDGET_INVALID_ERROR_MSG);
         }
         //判断余额是否足够
         $balanceResponse = Bll_Service_Payment::balance(Bll_Service_Payment::SITE_ANJUKE, array('userId' => $brokerBaseInfo->userId));
         if ($balanceResponse['status'] == 'error') {
             throw new Exception(self::SYSTEM_BUSY_ERROR, self::SYSTEM_BUSY_ERROR_MSG);
         }
         $balance = $balanceResponse['data']['balance'];
         if ($balance / 100 < $budget) {
             $this->error(self::BANANCE_LESS_BUDGET, self::BANANCE_LESS_BUDGET_MSG);
         }
         //获取房源信息
         $houseInfo = Bll_House_EsfHouse::getHouseBaseInfo($propId, $cityId);
         if (empty($houseInfo)) {
             $this->error(self::PROP_NOT_EXIST_ERROR, self::PROP_NOT_EXIST_ERROR_MSG);
         }
         $houseInfo = $houseInfo[0];
         //操作人验证
         if ($houseInfo->userId != $userId) {
             $this->error(self::PROP_OPREATE_ACCESS_INVALID_ERROR, self::PROP_OPREATE_ACCESS_INVALID_ERROR_MSG);
         }
         //房源是否可以精选验证
         if ($houseInfo->isVisible != 1) {
             //违规验证
             $this->error(self::PROP_CHOICE_NOT_FIT_ISVISIBLE_ERROR, self::PROP_CHOICE_NOT_FIT_ISVISIBLE_ERROR_MSG);
         }
         if ($houseInfo->isHighQulity == 0) {
             //多图验证
             $this->error(self::PROP_CHOICE_NOT_FIT_ISHIGHQULITY_ERROR, self::PROP_CHOICE_NOT_FIT_ISHIGHQULITY_ERROR_MSG);
         }
         if (date('Ymd', strtotime('-16 days')) > date('Ymd', $houseInfo->postDate)) {
             //发布时间验证
             $this->error(self::PROP_CHOICE_NOT_FIT_POSTDATE_ERROR, self::PROP_CHOICE_NOT_FIT_POSTDATE_ERROR_MSG);
         }
         $planInfo = Model_Plan_EsfAjkPropSpread::getChoicePlanInfoByHouseid($propId);
         if (!empty($planInfo)) {
             $reBid = 1;
         }
         //判断当前经纪人已经精选推广的房源数
         if ($reBid) {
             if (Bll_Plan_Bid_Choice::checkEsfBidChoiceFull($brokerId, $cityId, 1)) {
                 $this->error(self::MAX_CHOICE_NUM_ERROR, sprintf(self::MAX_CHOICE_NUM_ERROR_MSG, Bll_Plan_Bid_Choice::$all_esf_plan_num));
             }
         } else {
             if (Bll_Plan_Bid_Choice::checkEsfBidChoiceFull($brokerId, $cityId)) {
                 $this->error(self::MAX_CHOICE_NUM_ERROR, sprintf(self::MAX_CHOICE_NUM_ERROR_MSG, Bll_Plan_Bid_Choice::$all_esf_plan_num));
             }
         }
         //套餐经纪人 还是ppc经纪人
         /*$IsComboCity = Bll_Broker_HzBroker::isComboBroker($brokerId);
                     if ($IsComboCity)
                     {
                         //是否套餐推广
                         $comboHouseRelation = Model_Combo_HouseRelation::getOnlineHousebyHouseId($brokerId, $propId, $cityId, Model_Combo_HouseRelation::SITE_TYPE_AJK);
                         if(empty($comboHouseRelation))
                         {
                             $this->error(self::PROP_NO_COMBO, self::PROP_NO_COMBO_MSG);
                         }
         
                     } else
                     {
                         //判断房源的定价计划状态
                         $fixPlanBll = new Bll_FixedSpread_PropFixedPlanRelation();
                         $fixPlanRelationStatus = $fixPlanBll->getProSpreadRelationByProId($propId, $cityId);
                         if ($fixPlanRelationStatus['Status'] != 1) {
                             $this->error(self::PROP_CHOICE_NOT_FIT_FIXED_ERROR, self::PROP_CHOICE_NOT_FIT_FIXED_ERROR_MSG);
                         }
                     }*/
         /** 判断是否是精选开放城市 */
         if (!Bll_City::isChoiceIndependentCity($cityId, Const_Site::ANJUKE)) {
             /** 判断是在套餐推广中 */
             $houseState = Bll_Combo_HouseRelation::getOnlineRelationByHouseId($propId, Bll_Combo_HouseRelation::SITE_TYPE_AJK);
             if (empty($houseState)) {
                 $this->error(self::PROP_NO_COMBO, self::PROP_NO_COMBO_MSG);
             }
         }
         /** 防并发 */
         if (false === Bll_Plan_Bid_Choice::rejectSameRequest(Bll_Plan_Bid_Choice::SITE_AJK, $brokerId, $propId)) {
             $this->error(self::OPERATION_TIME_ERROR, self::OPERATION_TIME_ERROR_MSG);
         }
         //判断是否已在竞价计划中
         if ($reBid) {
             if ($planInfo->status == Model_Plan_EsfAjkPropSpread::ONLINE || $planInfo->status == Model_Plan_EsfAjkPropSpread::ONQUEUE) {
                 $this->error(self::PROP_CHOICE_NOT_FIT_CHOICED_ERROR, self::PROP_CHOICE_NOT_FIT_CHOICED_ERROR_MSG);
             }
         } else {
             if (!empty($planInfo) || $planInfo->status == Model_Plan_EsfAjkPropSpread::ONLINE || $planInfo->status == Model_Plan_EsfAjkPropSpread::ONQUEUE) {
                 $this->error(self::PROP_CHOICE_NOT_FIT_CHOICED_ERROR, self::PROP_CHOICE_NOT_FIT_CHOICED_ERROR_MSG);
             }
         }
         //重新推广,判断结算状态
         if ($reBid) {
             if ($planInfo->tradestatus != Model_Plan_EsfAjkPropSpread::COMPLETETTRADESTATU) {
                 $this->error(self::PROP_CHOICE_NOT_SETTLE_ERROR, self::PROP_CHOICE_NOT_SETTLE_ERROR_MSG);
             }
         }
         $housePrice = intval($houseInfo->proPrice * 10000);
         $priceIntervalInfo = Model_House_EsfPrice::get_price($cityId, $housePrice);
         if (empty($priceIntervalInfo)) {
             $this->error(self::PROP_PRICE_UNKNOW_ERROR, self::PROP_PRICE_UNKNOW_ERROR_MSG);
         }
         $priceId = $priceIntervalInfo['id'];
         $minPrice = $priceIntervalInfo['minPrice'];
         $maxPrice = $priceIntervalInfo['maxPrice'];
         //查询坑情况
         $bucketInfo = Model_Choice_EsfBidBucket::get_bucket_info($houseInfo->commId, $priceId);
         if (empty($bucketInfo)) {
             if (Model_Choice_EsfBidBucket::init_bucket_info($houseInfo->commId, $priceId, $cityId)) {
                 $bucketInfo = array('communityId' => $houseInfo->commId, 'priceId' => $priceId, 'totalNum' => Model_Choice_EsfBidBucket::TOTALNUM, 'usedNum' => 0, 'maxOnlineNum' => Model_Choice_EsfBidBucket::MAXONLINENUM);
             } else {
                 $this->error(self::SYSTEM_BUSY_ERROR, self::SYSTEM_BUSY_ERROR_MSG);
             }
         }
         //预判断坑位
         if ($bucketInfo['usedNum'] >= $bucketInfo['totalNum']) {
             $this->error(self::CHOICE_QUEUE_FULL, self::CHOICE_QUEUE_FULL_MSG);
         }
         //按照最大坑位数目更新
         if (!Model_Choice_EsfBidBucket::increment_used_num($houseInfo->commId, $priceId, 0)) {
             $this->error(self::SYSTEM_BUSY_ERROR, self::SYSTEM_BUSY_ERROR_MSG);
         }
         //获取reuqestid
         $year = date('Y');
         $bll = new Bll_Plan_BidFreezeOrderNum($year);
         $requestId = $bll->getRequestId(Bll_Plan_BidFreezeOrderNum::ESF, $userId, $year, 0, $propId);
         //冻结金额
         $amount = $budget * 100;
         $note = sprintf("二手房精选房源冻结,propId: %d", $propId);
         if (($freezeResult = Bll_Plan_Bid_Choice::bid_freeze($brokerId, $amount, $requestId, $note, Const_PaymentApp::AJK_CHOICE)) === false) {
             $this->error(self::SYSTEM_BUSY_ERROR, self::SYSTEM_BUSY_ERROR_MSG);
         }
         if (!$freezeResult->isSucceeded()) {
             $this->error(self::SYSTEM_BUSY_ERROR, self::SYSTEM_BUSY_ERROR_MSG);
         }
         if ($freezeResult['status'] == 'error') {
             $this->error(self::CHOICE_FREEZE_ERROR, self::CHOICE_FREEZE_ERROR_MSG);
         }
         $snNum = $freezeResult['data']['sn'];
         //重新推广,将原来的推广计划置为删除状态
         if ($reBid) {
             $planInfo->status = Model_Plan_EsfAjkPropSpread::DELETE;
             if (!$planInfo->save()) {
                 $this->error(self::SYSTEM_BUSY_ERROR, self::SYSTEM_BUSY_ERROR_MSG);
             }
         }
         for ($i = 0; $i < 3; $i++) {
             //价格
             $clickPrice = Bll_Service_Choice::ajkClickPrice(array('brokerId' => $brokerId, 'cityId' => $cityId, 'price' => $housePrice, 'commId' => $houseInfo->commId));
             if ($clickPrice->isSucceeded()) {
                 break;
             }
         }
         if (empty($clickPrice) || $clickPrice['status'] != 'ok') {
             $this->error(self::SYSTEM_BUSY_ERROR, self::SYSTEM_BUSY_ERROR_MSG);
         }
         $priceUnit = round($clickPrice['realTradeAmount'] / 100, 2);
         //新建计划
         $time = time();
         $offer = $priceUnit * 100;
         $stopTime = $time + Bll_Plan_Bid_Choice::ESF_AUTO_STOP_TIME;
         $endTime = time() + Model_Plan_EsfAjkPropSpread::CHOICELASTINGTIME;
         $arrAddInfo['serialnumber'] = $snNum;
         $arrAddInfo['propId'] = $propId;
         $arrAddInfo['cityId'] = $cityId;
         $arrAddInfo['commId'] = $houseInfo->commId;
         $arrAddInfo['brokerId'] = $brokerId;
         $arrAddInfo['userId'] = $userId;
         $arrAddInfo['budget'] = $amount;
         $arrAddInfo['balance'] = $amount;
         $arrAddInfo['spreadstartdate'] = $time;
         $arrAddInfo['spreadenddate'] = $endTime;
         $arrAddInfo['bigprice'] = $maxPrice;
         $arrAddInfo['smallprice'] = $minPrice;
         $arrAddInfo['propriceint'] = $housePrice;
         $arrAddInfo['status'] = Model_Plan_EsfAjkPropSpread::ONQUEUE;
         $arrAddInfo['isreserve'] = Model_Plan_EsfAjkPropSpread::RESERVE;
         $arrAddInfo['bidVersion'] = Model_Plan_EsfAjkPropSpread::CHOICEVERSION;
         $arrAddInfo['areacode'] = $houseInfo->areaCode;
         $arrAddInfo['stoptime'] = $stopTime;
         $arrAddInfo['createtime'] = $time;
         $arrAddInfo['offer'] = $offer;
         //排名系数,请直接绕过 +_+
         $hpratioABll = new Bll_Plan_Bid_EsfHpratioA();
         $arrAddInfo['qulityScore'] = $hpratioABll->getHouseMass($propId, $brokerId, $cityId, $houseInfo->commId, $houseInfo->hasRoomPic, $houseInfo->isHighQulity, $houseInfo->postDate, $houseInfo->unitPrice);
         $commScore = round($hpratioABll->getCommScore($houseInfo->commId), 5);
         $arrAddInfo['commScore'] = $commScore;
         $userActionScore = $hpratioABll->getUserActionScore($propId, $cityId);
         $arrAddInfo['behaviorScore'] = $userActionScore;
         $arrAddInfo['hpratioA'] = $hpratioABll->getHpraio($offer, $arrAddInfo['qulityScore'], $userActionScore);
         $hpratioNorm = $hpratioABll->getPpcNormHpratio($arrAddInfo['hpratioA'], $houseInfo->commId, false, $minPrice, $maxPrice, $houseInfo->areaCode);
         $arrAddInfo['commsHpratioA'] = round($commScore * $hpratioNorm, 5);
         if (($planId = Model_Plan_EsfAjkPropSpread::insertLayer($arrAddInfo)) === false) {
             $this->error(self::SYSTEM_BUSY_ERROR, self::SYSTEM_BUSY_ERROR_MSG);
         }
         //新精选队列插入记录
         if (!Bll_Plan_Bid_EsfChoiceQueue::insert($brokerId, $planId, Model_Choice_ActionQueue::ENUM_BEGIN_BY_HAND, date('m'), $brokerId, '经纪人手动开始推广', APF::get_instance()->get_request()->get_client_ip())) {
             $this->error(self::SYSTEM_BUSY_ERROR, self::SYSTEM_BUSY_ERROR_MSG);
         }
         //插入自动停止队列
         $stopType = Model_Plan_EsfAjkPropspreadQueue::AUTOSTOP;
         Model_Plan_EsfAjkPropspreadQueue::insertOne($planId, $stopTime, $stopType);
         //记录log表
         $remark = sprintf("PROP_ID:null=>%d;CITY_ID:null=>%d;COMM_ID:null=>%d;BROKER_ID:null=>%d;USER_ID:null=>%d;BUDGET:null=>%d;SPREADSTARTDATE:null=>%d;SPREADENDDATE:null=>%d;STATUS:null=>%d;ISRESERVE:null=>%d;SERIALNUMBER:null=>%d;TRADETYPE:0=>1;BALANCE:0=>%d;PROPRICEINT:0=>%d;BIGPRICE:0=>%d;SMALLPRICE:0=>%d", $propId, $cityId, $houseInfo->commId, $brokerId, $userId, $amount, $time, $endTime, Model_Plan_EsfAjkPropSpread::ONQUEUE, Model_Plan_EsfAjkPropSpread::RESERVE, $snNum, $amount, $housePrice, $maxPrice, $minPrice);
         Model_Plan_LogAjkPropspread::addNewLog($planId, $brokerId, Model_Plan_LogAjkPropspread::ADD, $remark);
         //更新reuqest id完成
         if (!$bll->updateRequestComplete($requestId)) {
             $this->error(self::SYSTEM_BUSY_ERROR, self::SYSTEM_BUSY_ERROR_MSG);
         }
         $rankNum = Bll_Plan_Bid_Choice::getEsfOnlineAndOnQueueNum($planId, $houseInfo->commId, $minPrice, $maxPrice);
         if ($rankNum <= $bucketInfo['maxOnlineNum']) {
             return array('status' => self::START_CHOICE_TO_ONLINE, 'statusMsg' => self::START_CHOICE_TO_ONLINE_MSG);
         } else {
             return array('status' => self::START_CHOICE_TO_ONQUEUE, 'statusMsg' => self::START_CHOICE_TO_ONQUEUE_MSG);
         }
     } catch (Exception $e) {
         if ($e instanceof Exception_BllErrorException) {
             $this->errorCode = $e->getCode();
         } else {
             $this->errorCode = self::UNKNOW_ERROR;
         }
         $this->errorMsg = $e->getMessage();
         return false;
     }
 }
예제 #8
0
 /**
  * 110 房源图片信息变更
  * 查询房源信息是否存在
  *   如果不存在 返回结束
  *   如果有效 记录房源编辑日志 type=2
  *   记录房源更新日志 type=4 后续由job rebuild
  *   //处理竞价 (多图判断)
  */
 private function change_prop_pic()
 {
     $this->writePropLog(2, '图片信息变更');
     if ($this->params['isComboCity']) {
         if (!($comboRelation = Bll_Combo_HouseRelation::getOnlineRelationByHouseId($this->params['pro_id']))) {
             return $this->allReturn[] = "房源{$this->params['pro_id']}套餐关系为空";
         }
     } else {
         // 查询定价关系
         if (!($fixPlanning = Model_Plan_HzPlanning::getPropFixPlan($this->params['pro_id']))) {
             return $this->allReturn[] = "房源{$this->params['pro_id']}定价关系为空";
         }
     }
     //$this->writePropLog(4, '更新');
     $this->tempDoBid();
 }
예제 #9
0
 public function dealTask($solrOnProId)
 {
     if ($onlineComboRelation = Bll_Combo_HouseRelation::getOnlineRelationByHouseId($solrOnProId, Bll_Combo_HouseRelation::SITE_TYPE_JP)) {
         printf('房源 %s 已经在套餐推广中, 不用通知solr下' . PHP_EOL, $solrOnProId);
         return true;
     }
     // 房源没有或者不在线 通知solr下
     //Bll_House_JpHouseInfo::updateHouseToSolr(1, $solrOnProId, 1);
     $result = Bll_Combo_NoticeSolrUpDown::noticeComboSolrJpAPI($this->cityId, $onlineComboRelation['brokerId'], $solrOnProId, 1, 2, Bll_Combo_NoticeSolrUpDown::HLSFromComboCheckNotice);
     printf('房源 %s 没有在套餐推广中, 需要通知solr下' . PHP_EOL, $solrOnProId);
     printf('房源 %s 通知中间件返回的结果status=%s ; message=%s' . PHP_EOL, $solrOnProId, $result['status'], $result['message']);
     return true;
 }
예제 #10
0
 public function dealTask($solrOnProId)
 {
     $houseInfo = Model_House_JpHouseIdx::data_access()->filter('id', $solrOnProId)->get_row();
     $brokerInfo = Model_Broker_JpBroker::data_access()->filter('id', $houseInfo['memberId'])->get_row();
     if ($houseInfo['isDelete'] == 1) {
         if ($this->dealFlag) {
             $result = Bll_Combo_NoticeSolrUpDown::noticeComboSolrJpAPI($this->cityId, $brokerInfo['ajkMemberId'], $solrOnProId, $houseInfo['houseType'], 2);
             $this->setLog(sprintf('房源 %s 通知中间件返回的结果status=%s ; message=%s' . PHP_EOL, $solrOnProId, $result['status'], $result['message']));
         }
         $this->setLog(sprintf('房源 %s 已经删除, 需要通知solr下' . PHP_EOL, $solrOnProId));
         return true;
     }
     //查询城市配置信息
     $ComboConfig = DAO_My_ComboConfig::getComboConfigByCityId($houseInfo['cityId']);
     if ($ComboConfig && $ComboConfig['type'] == 0) {
         //套餐城市
         if (!Bll_Combo_HouseRelation::getOnlineRelationByHouseId($solrOnProId, Bll_Combo_HouseRelation::SITE_TYPE_JP)) {
             if ($this->dealFlag) {
                 $result = Bll_Combo_NoticeSolrUpDown::noticeComboSolrJpAPI($this->cityId, $brokerInfo['ajkMemberId'], $solrOnProId, $houseInfo['houseType'], 2);
                 $this->setLog(sprintf('房源 %s 通知中间件返回的结果status=%s ; message=%s' . PHP_EOL, $solrOnProId, $result['status'], $result['message']));
             }
             $this->setLog(sprintf('房源 %s 不在套餐推广中, 需要通知solr下' . PHP_EOL, $solrOnProId));
             return true;
         }
         return true;
     } else {
         //ppc城市
         if ($houseInfo['spreadId'] != 0) {
             $spreadInfo = Model_Plan_Jp::data_access()->filter('id', $houseInfo['spreadId'])->filter('type', Model_Plan_Jp::ENUM_TYPE_FIX)->filter('isDelete', Model_Plan_Jp::ENUM_IS_DELETE_NO)->get_row();
             if ($spreadInfo && $spreadInfo['status'] == 2) {
                 return true;
             }
         }
         if ($this->dealFlag) {
             $result = Bll_Combo_NoticeSolrUpDown::noticeComboSolrJpAPI($this->cityId, $brokerInfo['ajkMemberId'], $solrOnProId, $houseInfo['houseType'], 2);
             $this->setLog(sprintf('房源 %s 通知中间件返回的结果status=%s ; message=%s' . PHP_EOL, $solrOnProId, $result['status'], $result['message']));
         }
         $this->setLog(sprintf('房源 %s 不在定价推广中, 需要通知solr下' . PHP_EOL, $solrOnProId));
         return true;
     }
 }
예제 #11
0
 /**
  * 判断该task的房子  不在线则通知上
  * @param $task
  * @return bool
  * @throws Exception
  */
 public function dealTask($task)
 {
     $houseInfo = $task;
     $proId = $houseInfo['id'];
     $cityId = $houseInfo['cityId'];
     $brokerInfo = Model_Broker_JpBroker::data_access()->filter('id', $houseInfo['memberId'])->get_row();
     //查询城市配置信息
     $ComboConfig = DAO_My_ComboConfig::getComboConfigByCityId($cityId);
     // 判断solr是否在线  不在线通知上
     if ($ComboConfig && $ComboConfig['type'] == 0) {
         //套餐城市
         if (Bll_Combo_HouseRelation::getOnlineRelationByHouseId($proId, Bll_Combo_HouseRelation::SITE_TYPE_JP)) {
             $result = Bll_Combo_NoticeSolrUpDown::noticeComboSolrJpAPI($cityId, $brokerInfo['ajkMemberId'], $proId, $houseInfo['houseType'], 1);
             $this->setLog(sprintf('房源 %s 通知中间件返回的结果status=%s ; message=%s' . PHP_EOL, $proId, $result['status'], $result['message']));
             $this->setLog(sprintf('房源 %s 在套餐推广中, 需要通知solr上' . PHP_EOL, $proId));
             return true;
         }
         return true;
     } else {
         //ppc城市
         if ($houseInfo['fixSpreadId'] != 0) {
             $spreadInfo = Model_Plan_Jp::data_access()->filter('id', $houseInfo['fixSpreadId'])->filter('type', Model_Plan_Jp::ENUM_TYPE_FIX)->filter('isDelete', Model_Plan_Jp::ENUM_IS_DELETE_NO)->get_row();
             if ($spreadInfo && $spreadInfo['status'] == 2) {
                 // 定价在线 需要通知上
                 $result = Bll_Combo_NoticeSolrUpDown::noticeComboSolrJpAPI($cityId, $brokerInfo['ajkMemberId'], $proId, $houseInfo['houseType'], 1);
                 $this->setLog(sprintf('房源 %s 通知中间件返回的结果status=%s ; message=%s' . PHP_EOL, $proId, $result['status'], $result['message']));
                 $this->setLog(sprintf('房源 %s 在定价推广中, 需要通知solr上' . PHP_EOL, $proId));
                 return true;
             }
         }
         return true;
     }
 }
예제 #12
0
 /**
  * 获取页面的初始化信息
  *
  * @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);
 }
예제 #13
0
 /**
  * 二手房-板块精选房源设置页面
  *
  * @param int $brokerId
  * @param int $cityId
  * @param int $houseId
  * @param array $params
  *
  * @return array
  */
 public static function esf_setting($brokerId, $cityId, $houseId, $userId, $params = array())
 {
     $pageAttribute = array();
     //获取精选推广预算
     $brokerInfo = Bll_BrokerBaseBll::get_instance()->get_broker_info($brokerId);
     $brokerCompanyId = $brokerInfo['BaseInfo']['COMPANYID'];
     $choiceSet = APF::get_instance()->get_config('block_choice_set');
     //根据经纪人公司不同有不同的预算
     if (isset($choiceSet[$brokerCompanyId]) && !empty($choiceSet[$brokerCompanyId])) {
         $pageAttribute['min_budget'] = $choiceSet[$brokerCompanyId]['ajk']['ESF_CHOICE_MIN_BUDGET'];
         $pageAttribute['max_budget'] = $choiceSet[$brokerCompanyId]['ajk']['ESF_CHOICE_MAX_BUDGET'];
     } else {
         $pageAttribute['min_budget'] = $choiceSet['default']['ajk']['ESF_CHOICE_MIN_BUDGET'];
         $pageAttribute['max_budget'] = $choiceSet['default']['ajk']['ESF_CHOICE_MAX_BUDGET'];
     }
     self::setChoiceNum($cityId);
     //判断当前经纪人已经精选推广的房源数
     if (isset($params['act']) && isset($params['rebid'])) {
         if (self::checkEsfBidChoiceFull($brokerId, $cityId, 1)) {
             //检查二手房精选是否达到最大
             return array('err_no' => self::BID_FAIL_OTHER, 'err_msg' => '最多精选推广' . self::$all_esf_plan_num . '套房源');
         }
     } else {
         if (self::checkEsfBidChoiceFull($brokerId, $cityId)) {
             return array('err_no' => self::BID_FAIL_OTHER, 'err_msg' => '最多精选推广' . self::$all_esf_plan_num . '套房源');
         }
     }
     /** 经纪人重新推广房源 */
     if (isset($params['act']) && isset($params['rebid'])) {
         //在精选管理页就已经设置时候是重新推广
         $planInfo = Model_Plan_EsfAjkPropSpread::getChoicePlanInfoByHouseid($houseId);
         if ($planInfo->status == Model_Plan_EsfAjkPropSpread::ONLINE || $planInfo->status == Model_Plan_EsfAjkPropSpread::ONQUEUE) {
             return array('err_no' => self::BID_FAIL_OTHER, 'err_msg' => '房源已经精选');
         }
         $pageAttribute['plan_id'] = $params['plan_id'];
         $pageAttribute['rebid'] = true;
     }
     $balance = self::get_broker_balance_by_broker_id($brokerId);
     //获取经纪人账户余额
     $pageAttribute['balance'] = $balance;
     if ($balance > 0) {
         $balance = sprintf('%.2f', $balance / 100);
     }
     $pageAttribute['balance_fmt'] = $balance;
     //获取房源信息
     $pageAttribute['housesInfo'] = Bll_House_EsfHouse::getHouseBaseInfo($houseId, $cityId);
     if (empty($pageAttribute['housesInfo'])) {
         return array('err_no' => self::BID_FAIL_OTHER, 'err_msg' => '房源不存在!');
     }
     $houseInfo = $pageAttribute['housesInfo'][0];
     if ($houseInfo->userId != $userId) {
         return array('err_no' => self::BID_FAIL_QUALITY_OR_NEW, 'err_msg' => '房源不属于当前操作人');
     }
     if ($houseInfo->isVisible != 1) {
         return array('err_no' => self::BID_FAIL_QUALITY_OR_NEW, 'err_msg' => '房源是违规房源,不可以参加精选房源推广');
     }
     if ($houseInfo->isHighQulity == 0) {
         return array('err_no' => self::BID_FAIL_QUALITY_OR_NEW, 'err_msg' => '多图、新发15天房源才能参与精选推广');
     }
     if (date('Ymd', strtotime('-15 days')) > date('Ymd', $houseInfo->postDate)) {
         return array('err_no' => self::BID_FAIL_QUALITY_OR_NEW, 'err_msg' => '多图、新发15天房源才能参与精选推广');
     }
     /** 判断是否是精选开放城市 */
     if (!Bll_City::isChoiceIndependentCity($cityId, Const_Site::ANJUKE)) {
         /** 判断是在套餐推广中 */
         $houseState = Bll_Combo_HouseRelation::getOnlineRelationByHouseId($houseId, Bll_Combo_HouseRelation::SITE_TYPE_AJK);
         if (empty($houseState)) {
             return array('err_no' => self::BID_FAIL_QUALITY_OR_NEW, 'err_msg' => '该房源不在推广中');
         }
     }
     //判断是否已在竞价计划中
     $planInfo = Model_Plan_EsfAjkPropSpread::getChoicePlanInfoByHouseid($houseId);
     if (!empty($planInfo) && !isset($params['act']) && !isset($params['rebid'])) {
         return array('err_no' => self::BID_FAIL_OTHER, 'err_msg' => '房源已经精选');
     }
     $block = Bll_Commtype_Api::getInfoByTypeCode($houseInfo->areaCode);
     $area = Bll_Commtype_Api::getInfoByTypeId($block['parentId']);
     $pageAttribute['areaBlock'] = $area['typeName'] . " " . $block['typeName'];
     $pageAttribute['title'] = sprintf("%s,%s,%d室%d厅%d卫,%d平,%.2f万", $pageAttribute['areaBlock'], $houseInfo->commName, $houseInfo->roomNum, $houseInfo->hallNum, $houseInfo->toiletNum, intval($houseInfo->areaNum), $houseInfo->proPrice);
     $pageAttribute['community_name'] = $houseInfo->commName;
     $housePrice = intval($houseInfo->proPrice * 10000);
     if (strlen($houseInfo->areaCode) < 12) {
         return array('err_no' => self::BID_FAIL_OTHER, 'err_msg' => '房源不能精选');
     }
     //获取坑位信息
     $bucketInfo = Bll_Choice_EsfBlockBidBucket::get_bucket_info($houseInfo->areaCode, $cityId, $housePrice);
     //获取坑位信息
     if (empty($bucketInfo)) {
         Bll_Choice_EsfBlockBidBucket::init_bucket_info($houseInfo->areaCode, $cityId, $housePrice);
         $bucketInfo = Bll_Choice_EsfBlockBidBucket::get_bucket_info($houseInfo->areaCode, $cityId, $housePrice);
     }
     if ($bucketInfo['usedNum'] < $bucketInfo['maxOnlineNum']) {
         $pageAttribute['hidden']['show'] = 1;
     }
     $pageAttribute['bucket_total'] = $bucketInfo['totalNum'];
     $pageAttribute['bucket_used'] = $bucketInfo['usedNum'];
     $pageAttribute['bucket_used_num'] = $bucketInfo['usedNum'];
     $pageAttribute['bucket_total_num'] = $bucketInfo['totalNum'];
     $pageAttribute['bucket_max_online_num'] = $bucketInfo['maxOnlineNum'];
     $priceInfo = Model_House_EsfPrice::get_price_by_id($bucketInfo['priceId']);
     $pageAttribute['price_title'] = sprintf("%d-%d万", intval($priceInfo['minPrice'] / 10000), intval($priceInfo['maxPrice'] / 10000));
     //价格
     $clickPrice = Bll_Service_BlockChoice::ajkBlockClickPrice(array('brokerId' => $brokerId, 'cityId' => $cityId, 'price' => $housePrice, 'blockId' => $block['typeId']));
     if ($clickPrice['status'] == 'error') {
         return array('err_no' => self::BID_FAIL_OTHER, 'err_msg' => '服务器繁忙,请重试(code: -' . __LINE__ . ')');
     }
     if ($clickPrice['realTradeAmount'] != $clickPrice['shouldTradeAmount']) {
         $pageAttribute['favorable'] = true;
         $pageAttribute['price'] = round($clickPrice['realTradeAmount'] / 100, 2);
         $pageAttribute['origin_price'] = round($clickPrice['shouldTradeAmount'] / 100, 2);
         $pageAttribute['favorable_end_time'] = date('Y-m-d', strtotime($clickPrice['rebateEndTime']));
     } else {
         $pageAttribute['favorable'] = false;
         $pageAttribute['price'] = round($clickPrice['realTradeAmount'] / 100, 2);
     }
     //         $clickAndBudget = Bll_Choice_EsfBlockBidBucket::getBucketAverageClickBudget($houseInfo->areaCode, $cityId, $housePrice);  //获取坑位的平均点击的预算
     //        if (!empty($clickAndBudget)) {
     //            $pageAttribute['averageClick'] = $clickAndBudget['averageClick'];
     //            $pageAttribute['averageBudget'] = $clickAndBudget['averageBudget'] / 100;
     //        }
     /**重组区域精选url**/
     $bidPlanList = Bll_Plan_Bid_AjkPlan::getBrokerValidPlanListByhouseId($houseId, $brokerId, $cityId, true);
     $bidPlanList = $bidPlanList[0];
     if (isset($bidPlanList)) {
         $blockInfo['bidStatus'] = $bidPlanList['status'];
         if ($bidPlanList['status'] == 1) {
             $bidUrl = '/ajkbroker/user/choice/manage/ajk/#' . $houseId;
         } elseif ($bidPlanList['status'] == 11) {
             $bidUrl = '/ajkbroker/user/choice/manage/ajk/#' . $houseId;
         } else {
             if ($bidPlanList['status'] != 2) {
                 $bidUrl = "/ajkbroker/user/choice/set/ajk/" . $houseInfo['proId'] . '/?act=1&rebid=1&plan_id=' . $bidPlanList['id'];
             }
         }
     } else {
         $bidUrl = "/ajkbroker/user/choice/set/ajk/" . $houseInfo['proId'];
     }
     $pageAttribute['bidUrl'] = $bidUrl;
     return $pageAttribute;
 }