public function handle_request_internal()
 {
     $this->brokerId = $this->_params['brokerId'];
     $this->propId = $this->_params['propId'];
     // 获取经纪人映射
     $mapping = Model_Broker_MainBusiness::getMainBusinessByAjkBrokerId($this->brokerId);
     if (!$mapping) {
         throw new Exception_BrokerNotFoundException();
     }
     $hzBrokerId = $mapping['hzBrokerid'];
     $this->broker = Model_Broker_AjkBrokerExtend::findWithBrokerId($this->brokerId);
     $cityId = $this->broker['cityId'];
     // 非精选城市
     if (!Bll_City::isChoiceCity($cityId, Const_Site::HAOZU)) {
         throw new Exception('非精选城市', Const_APIStatus::E_NOT_CHOICE_CITY);
     }
     // 获取房源信息
     $this->prop = Model_House_HzProp::findByPropId($this->propId);
     if (!$this->prop) {
         throw new Exception_PropertyNotFoundException('房源不存在', Const_APIStatus::E_PROP_NOT_EXISTS);
     }
     // 检查房源是否属于当前经纪人
     if (!$this->prop->belongToBroker($hzBrokerId)) {
         throw new Exception('房源不属于经纪人', Const_APIStatus::E_PROP_NOT_EXISTS);
     }
     $price = $this->prop->getContentBasic('pricenum');
     $blockId = $this->prop->getContentBasic('blockid');
     // 获取精选推广位
     $this->bucket = Bll_Choice_HzBidBucket::get_bucket_info($blockId, $cityId, $price);
     $this->bucketId = $this->bucket['id'];
     // 检查房源是否可以添加精选推广位订阅
     if (($result = $this->hasAddChoiceRemindPermission()) !== true) {
         throw new Exception($result['msg'], intval($result['code']));
     }
     // 创建订阅
     $subscription = Model_Choice_Subscription::data_access()->filter('site', Model_Choice_Subscription::SITE_RENT)->filter('brokerId', $this->brokerId)->filter('propId', $this->propId)->filter('bucketId', $this->bucketId)->find_only();
     if (!$subscription) {
         Model_Choice_Subscription::create(array(Model_Choice_Subscription::SITE => Model_Choice_Subscription::SITE_RENT, Model_Choice_Subscription::BROKER_ID => $this->brokerId, Model_Choice_Subscription::PROP_ID => $this->propId, Model_Choice_Subscription::BUCKET_ID => $this->bucketId, Model_Choice_Subscription::STATUS => Model_Choice_Subscription::SUBSCRIPTION_START, Model_Choice_Subscription::CREATE_TIME => date('Y-m-d H:i:s'), Model_Choice_Subscription::UPDATE_TIME => date('Y-m-d H:i:s')))->save();
     } else {
         $subscription->status = Model_Choice_Subscription::SUBSCRIPTION_START;
         $subscription->save();
     }
     return array('status' => Const_APIStatus::RETURN_CODE_OK, 'data' => array('remindStatus' => 1, 'remindStatusMsg' => '取消推广位提醒'));
 }
示例#2
0
 /**
  * 精选房源设置页面
  *
  * @param int $ajk_broker_id
  * @param int $city_id
  * @param int $prop_id
  * @param array $params
  *
  * @return array
  */
 public static function hz_setting($ajk_broker_id, $city_id, $prop_id, $params = array())
 {
     $pageAttribute = array('broker_id' => $ajk_broker_id, 'prop_id' => $prop_id);
     //获取精选推广预算
     $brokerInfo = Bll_BrokerBaseBll::get_instance()->get_broker_info($ajk_broker_id);
     $brokerCompanyId = $brokerInfo['BaseInfo']['COMPANYID'];
     $choiceSet = APF::get_instance()->get_config('choice_set');
     if (isset($choiceSet[$brokerCompanyId]) && !empty($choiceSet[$brokerCompanyId])) {
         $pageAttribute['min_budget'] = $choiceSet[$brokerCompanyId]['hz']['HZ_CHOICE_MIN_BUDGET'];
         $pageAttribute['max_budget'] = $choiceSet[$brokerCompanyId]['hz']['HZ_CHOICE_MAX_BUDGET'];
     } else {
         $pageAttribute['min_budget'] = $choiceSet['default']['hz']['HZ_CHOICE_MIN_BUDGET'];
         $pageAttribute['max_budget'] = $choiceSet['default']['hz']['HZ_CHOICE_MAX_BUDGET'];
     }
     $hz_broker_id = Model_Broker_HzMapping::get_hz_broker_id($ajk_broker_id);
     if (0 == $hz_broker_id) {
         return array('err_no' => self::BID_FAIL_OTHER, 'err_msg' => '您不是好租经纪人');
     }
     /** 经纪人重新推广房源 */
     if (isset($params['act']) && $params['act'] == 'rebid') {
         $planInfo = Model_Plan_HzPlanBasic::get_plan_by_id($params['plan_id']);
         if ($planInfo['plan_type'] != 2 || $planInfo['bid_version'] != 2) {
             return array('err_no' => self::BID_FAIL_OTHER, 'err_msg' => '房源所在的计划不是精选房源计划');
         }
         if ($planInfo['status'] == Const_HzPlan::WAITING || $planInfo['status'] == Const_HzPlan::SPREAD) {
             return array('err_no' => self::BID_FAIL_OTHER, 'err_msg' => '房源已经精选');
         }
         $pageAttribute['plan_id'] = $params['plan_id'];
         $pageAttribute['rebid'] = true;
     } else {
         $propPlan = Model_Plan_HzPlanning::getPropBidPlan($prop_id);
         if (!empty($propPlan)) {
             $planInfo = Model_Plan_HzPlanBasic::get_plan_by_id($propPlan['plan_id']);
             if ($planInfo['bid_version'] == Const_HzPlan::BID_VERSION_CHOICE && ($planInfo['status'] == Const_HzPlan::WAITING || $planInfo['status'] == Const_HzPlan::SPREAD)) {
                 return array('err_no' => self::BID_FAIL_OTHER, 'err_msg' => '房源已经精选');
             }
             if ($planInfo['bid_version'] == Const_HzPlan::BID_VERSION_CHOICE && $propPlan['is_valid'] != 0 && $planInfo['status'] != Const_HzPlan::DELETE && $planInfo['flag'] == 1) {
                 $pageAttribute['plan_id'] = $propPlan['plan_id'];
                 $pageAttribute['rebid'] = true;
             } else {
                 /** 检查 经纪人是不是 已经满足10套 */
                 $onlinePlanCount = Model_Plan_HzPlanBasic::count_online_bid_plan_ex($ajk_broker_id);
                 if ($onlinePlanCount >= self::ALL_ZF_PLAN_NUM) {
                     return array('err_no' => Bll_Plan_Bid_Choice::BID_FAIL_OTHER, 'err_msg' => '您最多可以对' . self::ALL_ZF_PLAN_NUM . '套房源做精选推广,请确认数量是否已经达到上限');
                 }
             }
         }
     }
     /** 获取房源基本信息 */
     $propInfo = Model_House_HzProp::get_prop_info_by_prop_id($prop_id);
     if (empty($propInfo)) {
         return array('err_no' => self::BID_FAIL_OTHER, 'err_msg' => '房源不存在(code:-3)');
     }
     if (empty($propInfo['contentBasic']) || !isset($propInfo['contentBasic']['userid']) || $propInfo['contentBasic']['userid'] != $hz_broker_id) {
         return array('err_no' => self::BID_FAIL_OTHER, 'err_msg' => '房源不存在(code:-2)');
     }
     if (false == $propInfo['contentBasic']['quality']) {
         return array('err_no' => self::BID_FAIL_QUALITY_OR_NEW, 'err_msg' => '多图、新发15天房源才能参与精选推广');
     }
     if (date('Ymd', strtotime('-15 days')) > date('Ymd', $propInfo['contentBasic']['created'])) {
         return array('err_no' => self::BID_FAIL_QUALITY_OR_NEW, 'err_msg' => '多图、新发15天房源才能参与精选推广');
     }
     /** 判断是否是精选开放城市 */
     if (!Bll_City::isChoiceIndependentCity($city_id, Const_Site::HAOZU)) {
         /** 判断房源是否在套餐推广 */
         $propCombos = Bll_Combo_HouseRelation::getOnlineRelationByHouseId($prop_id, Bll_Combo_HouseRelation::SITE_TYPE_HZ);
         if (empty($propCombos)) {
             return array('err_no' => self::BID_FAIL_OTHER, 'err_msg' => '房源必须在套餐推广才能参与精选');
         }
     }
     $balance = self::get_broker_balance_by_broker_id($ajk_broker_id);
     $pageAttribute['balance'] = $balance;
     if ($balance > 0) {
         $balance = sprintf('%.2f', $balance / 100);
     }
     $pageAttribute['balance_fmt'] = $balance;
     /**
      * renttype: 1整租 2合租
      */
     if (empty($propInfo['contentBasic'])) {
         return array('err_no' => self::BID_FAIL_QUALITY_OR_NEW, 'err_msg' => '房源不存在(code:-4)');
     }
     /** 出租方式 */
     $rent_type = $propInfo['contentBasic']['renttype'] == 1 ? '整租' : '合租';
     /** 房屋类型 */
     $house_type_config = APF::get_instance()->get_config('housetype', 'house');
     $house_type = isset($house_type_config[$city_id]) ? $house_type_config[$city_id] : $house_type_config[0];
     $prop_type = isset($house_type[$propInfo['contentBasic']['protype']]) ? $house_type[$propInfo['contentBasic']['protype']] : '其他';
     /** 户型 */
     $room_amount = $propInfo['contentBasic']['roomnum'];
     $hall_amount = $propInfo['contentBasic']['hallnum'];
     $toilet_amount = $propInfo['contentBasic']['toilnetnum'];
     /** 出租面积 */
     $area_amount = $propInfo['contentBasic']['areanum'];
     /** 租金 */
     $price = $propInfo['contentBasic']['pricenum'];
     $title = $propInfo['contentBasic']['commname'];
     $blockInfo = Model_City_HzArea::getAreaById($propInfo['contentBasic']['blockid']);
     if (empty($blockInfo)) {
         $blockName = $title;
     } else {
         $blockName = $blockInfo['typeName'];
     }
     $pageAttribute['community_name'] = $blockName;
     /** 设置标题 */
     $pageAttribute['title'] = sprintf('%s,%d室%d厅%d卫,%d平,%s,%s,%d元/月', $title, $room_amount, $hall_amount, $toilet_amount, $area_amount, $rent_type, $prop_type, $price);
     $bucketInfo = Bll_Choice_HzBidBucket::get_bucket_info($propInfo['contentBasic']['blockid'], $city_id, $propInfo['contentBasic']['pricenum']);
     $pageAttribute['bucket_total'] = $bucketInfo['totalNum'];
     $pageAttribute['bucket_used'] = $bucketInfo['usedNum'];
     // 取出area的areacode  取查询  (由于dw存的blockid是areacode)
     $area = Model_City_HzArea::getAreaById($propInfo['contentBasic']['blockid']);
     $averageClickAndBudget = Bll_Choice_HzBidBucket::getBucketAverageClickBudget($area['typeCode'], $city_id, $propInfo['contentBasic']['pricenum']);
     if (!empty($averageClickAndBudget)) {
         $pageAttribute['averageClick'] = $averageClickAndBudget['averageClick'];
         $pageAttribute['averageBudget'] = $averageClickAndBudget['averageBudget'] / 100;
     }
     /** 获取点击单价 */
     try {
         $clickPrice = Bll_Service_Choice::hzClickPrice(array('brokerId' => $ajk_broker_id, 'cityId' => $city_id, 'price' => (int) $propInfo['contentBasic']['pricenum'], 'blockId' => $propInfo['contentBasic']['blockid']));
         if ($clickPrice['status'] == 'error') {
             return array('err_no' => self::BID_FAIL_OTHER, 'err_msg' => '系统繁忙(code:-1)');
         }
     } catch (Exception $e) {
         return array('err_no' => self::BID_FAIL_OTHER, 'err_msg' => '系统繁忙(code:-33)');
     }
     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'] = isset($clickPrice['rebateEndTime']) ? $clickPrice['rebateEndTime'] : '';
     } else {
         $pageAttribute['favorable'] = false;
         $pageAttribute['price'] = round($clickPrice['realTradeAmount'] / 100, 2);
     }
     $pageAttribute['bucket_used_num'] = $bucketInfo['usedNum'];
     $pageAttribute['bucket_total_num'] = $bucketInfo['totalNum'];
     $pageAttribute['bucket_max_online_num'] = $bucketInfo['maxOnlineNum'];
     $pageAttribute['hidden']['show'] = $bucketInfo['maxOnlineNum'] > $bucketInfo['usedNum'] ? 1 : 0;
     $priceInfo = Model_House_HzPriceChoice::get_price_by_id($bucketInfo['priceId']);
     if (($pos = strpos('以', $priceInfo['title'])) !== false) {
         $priceInfo['title'] = substr($priceInfo['title'], 0, $pos) . '元' . substr($priceInfo['title'], $pos);
     } else {
         $priceInfo['title'] = $priceInfo['title'] . '元';
     }
     $pageAttribute['price_title'] = $priceInfo['title'];
     return $pageAttribute;
 }
示例#3
0
 /**
  * 获取好租的坑位信息
  *
  * @param array $params
  * @return array
  */
 private function do_bucket_info_hz($params)
 {
     $request = APF::get_instance()->get_request();
     $propInfo = Model_House_HzProp::get_prop_info_by_prop_id($params['prop_id']);
     if (empty($propInfo)) {
         return array('error' => -1, 'msg' => '房源不存在!');
     }
     $city_id = $request->getBrokerCityId();
     $brock_id = Model_Broker_HzMapping::get_hz_broker_id($request->getBrokerId());
     if ($brock_id != $propInfo['contentBasic']['userid']) {
         return array('error' => -1, 'msg' => '房源不存在。');
     }
     $block_id = $propInfo['contentBasic']['blockid'];
     $price = $propInfo['contentBasic']['pricenum'];
     $bucketInfo = Bll_Choice_HzBidBucket::get_bucket_info($block_id, $city_id, $price);
     if (false === $bucketInfo) {
         return array('error' => -1, 'msg' => '板块价格段不存在。', 'price' => $price);
     }
     if (empty($bucketInfo)) {
         return array('error' => -1, 'msg' => '当前板块没有展示位。', 'block_id' => $block_id);
     }
     return array('error' => 0, 'bucket' => $bucketInfo);
 }