예제 #1
0
 public static function extendChoiceInfo($fixHouseList, $choiceHouseList, $cityId)
 {
     $priceSegmentList = Model_House_EsfPrice::getAllPriceInterval($cityId, Model_House_EsfPrice::TRADE_TYPE_SALE);
     // TODO 附加精选相关的信息 精选链接 精选提示
     foreach ($fixHouseList as $houseId => &$houseInfo) {
         $houseInfo['choiceNotice'] = '';
         if (isset($choiceHouseList[$houseId])) {
             $houseInfo['bidStatus'] = $choiceHouseList[$houseId]['status'];
             if ($choiceHouseList[$houseId]['status'] == 1) {
                 $houseInfo['bidUrl'] = '/ajkbroker/user/choice/manage/ajk/#' . $houseId;
                 $houseInfo['choiceNotice'] = '已精选';
                 continue;
             } elseif ($choiceHouseList[$houseId]['status'] == 11) {
                 $houseInfo['bidUrl'] = '/ajkbroker/user/choice/manage/ajk/#' . $houseId;
                 $houseInfo['choiceNotice'] = '排队中';
                 continue;
             } else {
                 if ($choiceHouseList[$houseId]['status'] != 2) {
                     $houseInfo['bidUrl'] = "/ajkbroker/user/choice/set/ajk/" . $houseInfo['proId'] . '/?act=1&rebid=1&plan_id=' . $choiceHouseList[$houseId]['id'];
                 }
                 $houseInfo['choiceNotice'] = $houseInfo['expiredDay'] >= 75 ? '可精选' : '';
             }
         }
         if (!$houseInfo['isHighQulity']) {
             continue;
         }
         if ($houseInfo['expiredDay'] < 75) {
             continue;
         }
         $houseInfo['choiceNotice'] = '可精选';
         foreach ($priceSegmentList as $priceSegment) {
             $housePrice = $houseInfo['proPrice'] * 10000;
             if ($priceSegment['minPrice'] < $housePrice && $housePrice <= $priceSegment['maxPrice']) {
                 $houseInfo['proPriceId'] = $priceSegment['id'];
                 break;
             }
         }
         $bucketInfo = Bll_Choice_EsfBidBucket::getBucketInfo($houseInfo['commId'], $houseInfo['cityId'], $houseInfo['proPriceId']);
         // $bucketInfo = Bll_Choice_EsfBidBucket::get_bucket_info($houseInfo['commId'], $houseInfo['cityId'], $houseInfo['proPriceInt']);
         if (false === $bucketInfo || empty($bucketInfo)) {
             continue;
         }
         if ($bucketInfo['usedNum'] == $bucketInfo['totalNum']) {
             $houseInfo['choiceNotice'] = '已排满';
         } elseif ($bucketInfo['usedNum'] < $bucketInfo['totalNum'] && $bucketInfo['usedNum'] >= $bucketInfo['maxOnlineNum']) {
             $houseInfo['choiceNotice'] = '可排队';
         } else {
             $houseInfo['choiceNotice'] = '可精选';
         }
     }
     return $fixHouseList;
 }
예제 #2
0
 public function handle_request_internal()
 {
     /**
      * @var $request AJKRequest
      */
     $request = APF::get_instance()->get_request();
     /**
      * @var $response AJKResponse
      */
     $response = APF::get_instance()->get_response();
     $response->set_content_type('application/json', 'utf-8');
     $houseIds = $request->get_parameter('houseIds');
     if (empty($houseIds)) {
         echo json_encode($this->buildResponse('error', null, '请输入房源ID'));
         return;
     }
     if (!is_array($houseIds)) {
         $houseIds = explode(',', $houseIds);
     }
     $brokerId = static::$intBrokerID;
     $cityId = static::$intBrokerCityID;
     if (!Bll_City::isChoiceCity($cityId)) {
         echo json_encode($this->buildResponse('error', null, '只有精选城市才有这个功能'));
         return;
     }
     /**  获取房源信息 */
     $tempHouseBaseInfoList = Bll_House_EsfHouse::getHouseInfoByHouseIdEx($brokerId, $houseIds, $cityId, array('proId', 'commId', 'proPriceId', 'proPrice', 'isVisible', 'isHighQulity', 'postDate'));
     /** 过滤掉不能精选的房源 */
     $houseBaseInfoList = $this->filterCanChoiceHouseList($tempHouseBaseInfoList);
     if (empty($houseBaseInfoList)) {
         echo json_encode($this->buildResponse('error', null, '没有获取到房源信息'));
         return;
     }
     /** 房源的精选推广状态 */
     $houseChoiceStateList = $this->initHouseChoiceState($houseIds);
     /** 获取城市价格段信息 */
     $priceSegmentList = Model_House_EsfPrice::getAllPriceInterval($cityId, Model_House_EsfPrice::TRADE_TYPE_SALE);
     if (empty($priceSegmentList)) {
         echo json_encode($this->buildResponse('error', null, '获取城市房源价格段信息失败'));
         return;
     }
     /** 修正房源价格段ID, 对房源按小区和价格段ID分组 */
     $groupCommunityPriceSegmentList = $this->groupCommunityPriceSegment($houseBaseInfoList, $priceSegmentList);
     /** 获取坑位信息  */
     $bucketInfoList = array();
     foreach ($groupCommunityPriceSegmentList as $key => $propIds) {
         list($communityId, $priceId) = explode('_', $key);
         $bucketInfo = Bll_Choice_EsfBidBucket::getBucketInfo($communityId, $cityId, $priceId);
         $bucketInfoList[$key] = $bucketInfo['usedNum'] < $bucketInfo['maxOnlineNum'];
     }
     //优先说明  3=低价 2=促销 1=推荐  低价>促销(折扣)>推荐(主营、热门、抢置顶)
     $brokerMarkHouseIds = $this->initBrokerMarkHouse($groupCommunityPriceSegmentList, $bucketInfoList);
     $result = array();
     foreach ($houseIds as $key => $houseId) {
         if (!isset($brokerMarkHouseIds[$houseId])) {
             continue;
         }
         $reasonStr = '';
         // from来源初始化
         $query = array('from' => '');
         if ($brokerMarkHouseIds[$houseId]['type'] == 1) {
             //推荐房源
             $query['from'] = 'recommendsite';
             if (!empty($brokerMarkHouseIds[$houseId]['rc_reason'])) {
                 switch ($brokerMarkHouseIds[$houseId]['rc_reason']) {
                     case 1:
                         $reasonStr = '主营小区';
                         break;
                     case 2:
                         $reasonStr = '热门小区';
                         break;
                     case 3:
                         $reasonStr = '精选即可置顶';
                         break;
                     case 4:
                         $reasonStr = '主营、热门小区';
                         break;
                     case 5:
                         $reasonStr = '主营、精选即可置顶';
                         break;
                     case 6:
                         $reasonStr = '热门、精选即可置顶';
                         break;
                     case 7:
                         $reasonStr = '主营、热门、精选即可置顶';
                         break;
                 }
             }
         } elseif ($brokerMarkHouseIds[$houseId]['type'] == 2) {
             //促销房源
             $query['from'] = 'promotionsite';
             if (!empty($brokerMarkHouseIds[$houseId]['zhekou'])) {
                 $zk = $brokerMarkHouseIds[$houseId]['zhekou'] / 10;
                 $reasonStr = '限时降价' . $zk . '折';
             } else {
                 $reasonStr = '限时降价';
             }
         } elseif ($brokerMarkHouseIds[$houseId]['type'] == 3) {
             //低价房源
             $query['from'] = 'lowpricesite';
             $reasonStr = '价格便宜';
         }
         if ($houseChoiceStateList[$houseId] > 0) {
             $query['act'] = 1;
             $query['rebid'] = 1;
             $query['plan_id'] = $houseChoiceStateList[$houseId];
         }
         $result[$key] = array('id' => $houseId, 'url' => sprintf('/ajkbroker/user/choice/set/ajk/%d/?%s', $houseId, http_build_query($query)), 'recommend' => $brokerMarkHouseIds[$houseId]['type']);
         $result[$key]['reason'] = $reasonStr;
     }
     if (count($result) > 15) {
         $resultSlice = array_slice($result, 0, 15);
     } else {
         $resultSlice = $result;
     }
     foreach ($resultSlice as $key => $val) {
         if ($houseChoiceStateList[$val['id']] == -1) {
             unset($resultSlice[$key]);
         }
     }
     $params = array();
     foreach ($resultSlice as $key => $val) {
         if ($brokerMarkHouseIds[$val['id']]['type'] == 1) {
             //推荐房源
             $rcReason = $brokerMarkHouseIds[$val['id']]['rc_reason'];
         } elseif ($brokerMarkHouseIds[$val['id']]['type'] == 2) {
             //促销房源
             $rcReason = '折扣';
         } elseif ($brokerMarkHouseIds[$val['id']]['type'] == 3) {
             //低价房源
             $rcReason = '';
         }
         $params[] = array('brokerId' => $brokerId, 'cityId' => $cityId, 'proId' => $val['id'], 'type' => $val['recommend'], 'rcReason' => $rcReason, 'createTime' => $brokerMarkHouseIds[$val['id']]['createTime']);
     }
     if (!empty($params)) {
         $params = json_encode($params);
         APF::get_instance()->get_nlogger()->log('brokerMark', $params, true);
     }
     echo json_encode($this->buildResponse('ok', array_values($resultSlice), ''));
 }
예제 #3
0
 /**
  * 获取精选状态和精选推荐
  * @param $priceSegmentList
  * @param $propSpreadInfo
  * @param $prop
  * @param int $cityIsChoice
  * @param int $cityIsChoiceIndependent
  * @return array
  */
 public static function getEsfChoiceStatusAndRecommend($priceSegmentList, $propSpreadInfo, $prop, $cityIsChoice = 0, $cityIsChoiceIndependent = 0)
 {
     $proPriceId = 0;
     $result = array('choiceStatus' => 0, 'choiceStatusName' => '', 'choiceRecommend' => 0);
     if (empty($prop) || !$cityIsChoice) {
         return $result;
     }
     //计算expiredDay
     $housePostTime = strtotime(date('Y-m-d 00:00:00', $prop['postDate']));
     $currentTimestamp = strtotime(date('Y-m-d 00:00:00'));
     $expiredDay = max(0, 90 - floor(($currentTimestamp - $housePostTime) / 86400));
     //精选状态: 可精选;可排队;精选中;排队中
     if (!empty($propSpreadInfo)) {
         if ($propSpreadInfo[$prop['proId']]->status == 1) {
             $result['choiceStatus'] = 3;
             $result['choiceStatusName'] = '精选中';
             return $result;
         } elseif ($propSpreadInfo[$prop['proId']]->status == 11) {
             $result['choiceStatus'] = 4;
             $result['choiceStatusName'] = '排队中';
             return $result;
         }
     }
     if ($prop['isHighQulity'] && $expiredDay >= 75) {
         $result['choiceStatus'] = 1;
         $result['choiceStatusName'] = '可精选';
         //修正价格段ID
         foreach ($priceSegmentList as $priceSegment) {
             $propPrice = $prop['proPrice'] * 10000;
             if ($priceSegment['minPrice'] < $propPrice && $propPrice <= $priceSegment['maxPrice']) {
                 $proPriceId = $priceSegment['id'];
                 break;
             }
         }
         $bucketInfo = Bll_Choice_EsfBidBucket::getBucketInfo($prop['commId'], $prop['cityId'], $proPriceId);
         if (false === $bucketInfo || empty($bucketInfo)) {
             return $result;
         }
         if ($bucketInfo['usedNum'] == $bucketInfo['totalNum']) {
             $result['choiceStatus'] = 0;
             $result['choiceStatusName'] = '';
         } elseif ($bucketInfo['usedNum'] < $bucketInfo['totalNum'] && $bucketInfo['usedNum'] >= $bucketInfo['maxOnlineNum']) {
             $result['choiceStatus'] = 2;
             $result['choiceStatusName'] = '可排队';
         }
         //精选推荐:低价>促销(折扣)>推荐(主营、热门、抢置顶);只有可精选,可排队的房源才有精选推荐;
         if (($bucket = $bucketInfo['usedNum'] < $bucketInfo['maxOnlineNum']) == true) {
             $markList = Bll_Stats_BrokerMark::getLastRowByCommIdAndSpId($prop['commId'], $proPriceId);
             if (!empty($markList)) {
                 $markListByType = array();
                 foreach ($markList as $mark) {
                     $markListByType[$mark['type']] = $mark;
                 }
                 if (isset($markListByType[1]) && $markListByType[1]['type'] == 1) {
                     $result['choiceRecommend'] = 1;
                 }
                 if (isset($markListByType[2]) && $markListByType[2]['type'] == 2) {
                     $result['choiceRecommend'] = 2;
                 }
                 if (isset($markListByType[3]) && $markListByType[3]['type'] == 3) {
                     $result['choiceRecommend'] = 3;
                 }
             }
         }
     }
     //如果是待推广房源,并且该城市套餐精选未分离,则不能有‘可精选’’可排队‘,精选推荐也必须为0
     if (empty($propSpreadInfo)) {
         if (!$cityIsChoiceIndependent) {
             $result['choiceRecommend'] = 0;
             if ($result['choiceStatus'] == 1 || $result['choiceStatus'] == 2) {
                 $result['choiceStatus'] = 0;
                 $result['choiceStatusName'] = '';
             }
         }
     }
     return $result;
 }
예제 #4
0
 public function handle_request_internal()
 {
     /**
      * @var $request AJKRequest
      */
     $request = APF::get_instance()->get_request();
     /**
      * @var $response AJKResponse
      */
     $response = APF::get_instance()->get_response();
     $response->set_content_type('application/json', 'utf-8');
     $houseIds = $request->get_parameter('houseIds');
     if (empty($houseIds)) {
         echo json_encode($this->buildResponse('error', null, '请输入房源ID'));
         return;
     }
     if (!is_array($houseIds)) {
         $houseIds = explode(',', $houseIds);
     }
     $brokerId = static::$intBrokerID;
     $cityId = static::$intBrokerCityID;
     if (!Bll_City::isChoiceCity($cityId)) {
         echo json_encode($this->buildResponse('error', null, '只有精选城市才有这个功能'));
         return;
     }
     /**  获取房源信息 */
     $tempHouseBaseInfoList = Bll_House_EsfHouse::getHouseInfoByHouseIdEx($brokerId, $houseIds, $cityId, array('proId', 'commId', 'proPriceId', 'proPrice', 'isVisible', 'isHighQulity', 'postDate'));
     /** 过滤掉不能精选的房源 */
     $houseBaseInfoList = $this->filterCanChoiceHouseList($tempHouseBaseInfoList);
     if (empty($houseBaseInfoList)) {
         echo json_encode($this->buildResponse('error', null, '没有获取到房源信息'));
         return;
     }
     /** 房源的精选推广状态 */
     $houseChoiceStateList = $this->initHouseChoiceState($houseIds);
     /** 获取城市价格段信息 */
     $priceSegmentList = Model_House_EsfPrice::getAllPriceInterval($cityId, Model_House_EsfPrice::TRADE_TYPE_SALE);
     if (empty($priceSegmentList)) {
         echo json_encode($this->buildResponse('error', null, '获取城市房源价格段信息失败'));
         return;
     }
     /** 修正房源价格段ID, 对房源按小区和价格段ID分组 */
     $groupCommunityPriceSegmentList = $this->groupCommunityPriceSegment($houseBaseInfoList, $priceSegmentList);
     /** 获取坑位休息  */
     $bucketInfoList = array();
     foreach ($groupCommunityPriceSegmentList as $key => $propIds) {
         list($communityId, $priceId) = explode('_', $key);
         $bucketInfo = Bll_Choice_EsfBidBucket::getBucketInfo($communityId, $cityId, $priceId);
         $bucketInfoList[$key] = $bucketInfo['usedNum'] < $bucketInfo['maxOnlineNum'];
     }
     //优先说明,一元精选 > 抢置顶 > 最划算
     /** 一元精选房源 */
     $unitaryHouseIds = $this->initUnitaryHouse($groupCommunityPriceSegmentList, $bucketInfoList);
     /** 抢置顶房源 */
     $topHouseIds = $this->initTopHouse($groupCommunityPriceSegmentList, $bucketInfoList);
     /** 最划算房源 */
     $cheapestHouseIds = $this->initCheapestHouse($groupCommunityPriceSegmentList, $bucketInfoList);
     //合并数据 + 数组的值去重
     $unitaryTopCheapHouseIds = array_unique(array_merge($unitaryHouseIds, $cheapestHouseIds, $topHouseIds));
     $result = array();
     foreach ($unitaryTopCheapHouseIds as $HouseId) {
         if ($houseChoiceStateList[$HouseId] == -1) {
             continue;
         }
         // recommend、from来源初始化
         $query = array('from' => '');
         $recommend = -1;
         if (in_array($HouseId, $unitaryHouseIds)) {
             //一元精选房源
             $query['from'] = 'unitarysite';
             $recommend = 3;
         } elseif (in_array($HouseId, $topHouseIds)) {
             //抢置顶房源
             $query['from'] = 'topsite';
             $recommend = 1;
         } elseif (in_array($HouseId, $cheapestHouseIds)) {
             //最划算房源
             $query['from'] = 'cheapsite';
             $recommend = 2;
         }
         if ($houseChoiceStateList[$HouseId] > 0) {
             $query['act'] = 1;
             $query['rebid'] = 1;
             $query['plan_id'] = $houseChoiceStateList[$HouseId];
         }
         $result[] = array('id' => $HouseId, 'url' => sprintf('/ajkbroker/user/choice/set/ajk/%d/?%s', $HouseId, http_build_query($query)), 'recommend' => $recommend);
     }
     echo json_encode($this->buildResponse('ok', array_values($result), ''));
 }