Example #1
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);
 }
Example #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;
 }