예제 #1
0
 public function handle_request_internal()
 {
     $ajkBrokerId = $this->_params['brokerId'];
     $propIds = $this->_params['propIds'];
     $arrPropId = explode(',', $propIds);
     $plans = Model_Plan_HzPlanning::getBidRelationsByHouseIds($arrPropId);
     $arrPlanId = array();
     foreach ($plans as $plan) {
         $arrPlanId[] = $plan->plan_id;
     }
     //删除已停止的精选计划
     //全部失败则返回调用失败,
     //只要有一个成功,则接口返回成功
     $flag = 0;
     foreach ($arrPlanId as $planId) {
         $rs = Bll_Plan_Bid_HzBid::deleteChoicePlan($ajkBrokerId, $planId);
         if ($rs['status'] == 'ok') {
             $flag = 1;
         }
     }
     if ($flag == 1) {
         return array('status' => Const_APIStatus::RETURN_CODE_OK, 'data' => array());
     } else {
         return array('status' => Const_APIStatus::RETURN_CODE_ERROR, 'errcode' => Const_APIStatus::E_SYS_ERR, 'message' => '删除失败!');
     }
 }
예제 #2
0
 public function handle_request_internal()
 {
     $ajkBrokerId = $this->_params['brokerId'];
     $propId = $this->_params['propId'];
     //通过房源获取计划
     $objPlan = Model_Plan_HzPlanning::getBidRelationsByHouseIds($propId);
     $objPlan = array_shift($objPlan);
     //获取IP
     $ip = $this->_request->get_client_ip();
     //停止精选计划
     if ($objPlan->is_valid == Const_HzPlan::SPREAD) {
         $rs = Bll_Plan_Bid_HzBid::stopChoicePlan($ajkBrokerId, $objPlan->plan_id, $ip);
     } elseif ($objPlan->is_valid == Const_HzPlan::WAITING) {
         $rs = Bll_Plan_Bid_HzBid::stopChoiceQueue($ajkBrokerId, $objPlan->plan_id, $ip);
     } else {
         $rs['status'] = 'error';
         $rs['msg'] = '计划状态错误!';
     }
     if ($rs['status'] != 'ok') {
         return array('status' => Const_APIStatus::RETURN_CODE_ERROR, 'errcode' => Const_APIStatus::E_SYS_ERR, 'message' => $rs['msg']);
     }
     return array('status' => Const_APIStatus::RETURN_CODE_OK, 'data' => array('msg' => '精选结束成功'));
 }
예제 #3
0
 public function handle_request_internal()
 {
     $brokerId = $this->_params['brokerId'];
     $houseId = $this->_params['propId'];
     $brokerInfo = Model_Broker_AjkBrokerExtend::findWithBrokerId($brokerId);
     if (!$brokerInfo) {
         throw new Exception_BrokerNotFoundException('经纪人不存在', Const_APIStatus::E_BROKER_NOT_EXISTS);
     }
     $cityId = $brokerInfo->cityId;
     $isDisplaySummary = 0;
     if (!Bll_City::isChoiceCity($cityId, Const_Site::HAOZU)) {
         $data = array('totalClicks' => 0, 'balance' => 0, 'balanceUnit' => '元', 'todayClicks' => 0, 'todayConsume' => 0, 'todayConsumeUnit' => '元', 'clickPrice' => 0, 'clickPriceUnit' => '元', 'maxBucketNum' => 0, 'usedBucketNum' => 0, 'bucketId' => '', 'status' => bll_choice_EsfAPPAPIChoice::PROP_ACTIONTYPE_CHOICE_NOTFIT, 'statusMsg' => '你所在城市未开通精选业务', 'remindStatus' => -1, 'remindStatusMsg' => '不符合精选订阅条件', 'minChoicePrice' => 0, 'minChoicePriceUnit' => '元', 'maxChoicePrice' => 0, 'maxChoicePriceUnit' => '元', 'isDisplaySummary' => $isDisplaySummary);
         return array('status' => Const_APIStatus::RETURN_CODE_OK, 'data' => $data);
     }
     $isDisplaySummary = 1;
     //获取该房子的精选计划
     $bllChoice = new Bll_Zufang_Choice();
     $planInfo = $bllChoice->get_plan_by_proid($houseId);
     $amount = 0;
     $totalConsume = 0;
     if ($planInfo) {
         $planId = $planInfo->plan_id;
         $planBasicInfo = $bllChoice->get_plan($planId);
         $amount = $planBasicInfo[0]->amount;
         $totalConsume = $planBasicInfo[0]->total_consume;
     }
     //获取 blockId, priceId
     $propInfo = $bllChoice->get_prop_content($houseId);
     if (empty($propInfo)) {
         return array('status' => Const_APIStatus::RETURN_CODE_ERROR, 'errcode' => '', 'message' => '房源不存在');
     }
     $content = json_decode($propInfo[0]->contentBasic, true);
     $price = intval($content['pricenum']);
     $blockId = $content['blockid'];
     $priceInfo = Bll_Choice_HzBidBucket::getPriceIntervalInfo($cityId, $price);
     $priceId = $priceInfo['id'];
     //获取坑位信息
     $bucketInfo = Bll_Choice_HzBidBucket::getBucketInfo($blockId, $priceId);
     // 获取点击单价
     try {
         $clickPriceInfo = Bll_Service_Choice::hzClickPrice(array('cityId' => $cityId, 'price' => (int) $price, 'blockId' => $blockId, 'brokerId' => $brokerId));
         if ($clickPriceInfo['status'] == 'error') {
             return array('status' => Const_APIStatus::RETURN_CODE_ERROR, 'errcode' => '', 'message' => '系统繁忙(code:-33)');
         }
     } catch (Exception $e) {
         return array('status' => Const_APIStatus::RETURN_CODE_ERROR, 'errcode' => '', 'message' => '系统繁忙(code:-33)');
     }
     $clickPrice = $clickPriceInfo['realTradeAmount'] / 100;
     $remindStatus = -1;
     // -1 不符合精选订阅条件
     $remindStatusMsg = '不符合精选订阅条件';
     if ($planInfo && $planInfo->is_valid == 1) {
         $date = date('Ymd');
         $propChoice = $bllChoice->get_prop_choice_info($houseId, $date, $cityId);
         $todayClicks = intval($propChoice[0]['bidClicks']);
         $todayConsume = intval($propChoice[0]['bidConsume']) / 100;
         $totalClicksInfo = $bllChoice->get_prop_choice_clicks($houseId, $cityId);
         $totalClicks = intval($totalClicksInfo[0]['bidClicks']);
         $balance = $amount - $totalConsume;
         return array('status' => Const_APIStatus::RETURN_CODE_OK, 'data' => array('todayClicks' => $todayClicks, 'todayConsume' => round($todayConsume, 2), 'todayConsumeUnit' => '元', 'totalClicks' => $totalClicks, 'balance' => round($balance, 2), 'balanceUnit' => '元', 'clickPrice' => round($clickPrice, 2), 'clickPriceUnit' => '元', 'maxBucketNum' => 20, 'usedBucketNum' => $bucketInfo['usedNum'], 'minChoicePrice' => 20, 'minChoicePriceUnit' => '元', 'maxChoicePrice' => 50, 'maxChoicePriceUnit' => '元', 'status' => '1-1', 'statusMsg' => '推广中', 'remindStatus' => $remindStatus, 'remindStatusMsg' => $remindStatusMsg, 'isDisplaySummary' => $isDisplaySummary));
     } else {
         if ($planInfo && $planInfo->is_valid == 13) {
             $totalClicksInfo = $bllChoice->get_prop_choice_clicks($houseId, $cityId);
             $totalClicks = intval($totalClicksInfo[0]['bidClicks']);
             $rank = Bll_Plan_Bid_HzBid::getChoiceWaitPosition($planInfo->plan_id, $cityId, $blockId, $priceId);
             return array('status' => Const_APIStatus::RETURN_CODE_OK, 'data' => array('clickPrice' => round($clickPrice, 2), 'clickPriceUnit' => '元', 'totalClicks' => $totalClicks, 'balance' => round($amount, 2), 'balanceUnit' => '元', 'maxBucketNum' => 20, 'usedBucketNum' => $bucketInfo['usedNum'], 'minChoicePrice' => 20, 'minChoicePriceUnit' => '元', 'maxChoicePrice' => 50, 'maxChoicePriceUnit' => '元', 'status' => '1-2', 'statusMsg' => "{$rank}", 'remindStatus' => $remindStatus, 'remindStatusMsg' => $remindStatusMsg, 'isDisplaySummary' => $isDisplaySummary));
         } else {
             //判断是否符合精选条件 多图 + 新发15天
             if (false == $content['quality'] || date('Ymd', strtotime('-16 days')) > date('Ymd', $content['created'])) {
                 return array('status' => Const_APIStatus::RETURN_CODE_OK, 'data' => array('clickPrice' => round($clickPrice, 2), 'clickPriceUnit' => '元', 'maxBucketNum' => 20, 'usedBucketNum' => $bucketInfo['usedNum'], 'minChoicePrice' => 20, 'minChoicePriceUnit' => '元', 'maxChoicePrice' => 50, 'maxChoicePriceUnit' => '元', 'status' => '3-2', 'statusMsg' => '精选推广条件:多图+新发15天', 'remindStatus' => $remindStatus, 'remindStatusMsg' => $remindStatusMsg, 'isDisplaySummary' => $isDisplaySummary));
             }
         }
     }
     if ($bucketInfo['usedNum'] >= $bucketInfo['totalNum']) {
         $status = '2-1';
         $statusMsg = '推广位已满';
     } else {
         if ($bucketInfo['usedNum'] >= $bucketInfo['maxOnlineNum']) {
             $status = '2-2';
             $statusMsg = '可立即排队';
         } else {
             $status = '2-3';
             $statusMsg = '可立即推广';
         }
     }
     // 如果推广位已满,判断推广位是否已订阅
     if ($status == '2-1') {
         $subscription = Model_Choice_Subscription::data_access()->filter('site', Model_Choice_Subscription::SITE_RENT)->filter('brokerId', $brokerId)->filter('propId', $houseId)->filter('bucketId', $bucketInfo['id'])->filter('status', Model_Choice_Subscription::SUBSCRIPTION_START)->find_only();
         if ($subscription) {
             $remindStatus = 1;
             // 1 已订阅
             $remindStatusMsg = '取消推广位提醒';
         } else {
             $remindStatus = 0;
             // 0 未订阅
             $remindStatusMsg = '有推广位了提醒我';
         }
     }
     return array('status' => Const_APIStatus::RETURN_CODE_OK, 'data' => array('clickPrice' => round($clickPrice, 2), 'clickPriceUnit' => '元', 'bucketId' => $bucketInfo['id'], 'maxBucketNum' => $bucketInfo['totalNum'], 'usedBucketNum' => $bucketInfo['usedNum'], 'minChoicePrice' => 20, 'minChoicePriceUnit' => '元', 'maxChoicePrice' => 50, 'maxChoicePriceUnit' => '元', 'status' => $status, 'statusMsg' => $statusMsg, 'remindStatus' => $remindStatus, 'remindStatusMsg' => $remindStatusMsg, 'isDisplaySummary' => $isDisplaySummary));
 }
예제 #4
0
 /**
  * 精选房源设置
  *
  * @param $ajk_broker_id
  * @param $city_id
  * @param $prop_id
  * @param array $params
  *
  * @return array
  */
 public static function hz_setting_post($ajk_broker_id, $city_id, $prop_id, $params = array())
 {
     //获取精选推广预算
     $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])) {
         $min_budget = $choiceSet[$brokerCompanyId]['hz']['HZ_CHOICE_MIN_BUDGET'];
         $max_budget = $choiceSet[$brokerCompanyId]['hz']['HZ_CHOICE_MAX_BUDGET'];
     } else {
         $min_budget = $choiceSet['default']['hz']['HZ_CHOICE_MIN_BUDGET'];
         $max_budget = $choiceSet['default']['hz']['HZ_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 . '安币');
     }
     $result = array();
     $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' => '您不是好租经纪人');
     }
     /** 判断房源是否可以精选 */
     $checkProp = Bll_HzBidPlan::checkPropCanChoice($ajk_broker_id, $city_id, $prop_id);
     if ($checkProp['err_no'] != 0) {
         return $checkProp;
     }
     /** 防并发 */
     if (false === self::rejectSameRequest(Bll_Plan_Bid_Choice::SITE_HAOZU, $ajk_broker_id, $prop_id)) {
         return array('err_no' => self::BID_FAIL_OTHER, 'err_msg' => '系统繁忙(code:-906)');
     }
     /** 获取房源基本信息 */
     $propInfo = Model_House_HzProp::get_prop_info_by_prop_id($prop_id);
     /** 获取点击单价 */
     try {
         /**
          * @var Bll_Service_Client_HttpResponse $clickPrice
          */
         for ($i = 0; $i < 3; $i++) {
             $clickPrice = Bll_Service_Choice::hzClickPrice(array('brokerId' => $ajk_broker_id, 'cityId' => $city_id, 'price' => (int) $propInfo['contentBasic']['pricenum'], 'blockId' => $propInfo['contentBasic']['blockid']));
             if ($clickPrice->isSucceeded()) {
                 break;
             }
         }
         if (!$clickPrice->isSucceeded() || $clickPrice['status'] == 'error') {
             return array('err_no' => self::BID_FAIL_OTHER, 'err_msg' => '系统繁忙(code:-' . __LINE__ . ')');
         }
         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:-' . __LINE__ . ')');
     }
     $block_id = $propInfo['contentBasic']['blockid'];
     $priceIntervalInfo = Model_House_HzPriceChoice::get_price($city_id, $propInfo['contentBasic']['pricenum']);
     if (empty($priceIntervalInfo)) {
         $logContent = sprintf('%s ajkBrokerId=%d hzBrokerId=%d cityId=%d propId=%d blockId=%d priceNum=%s %s', date('Y-m-d H:i:s'), $ajk_broker_id, $hz_broker_id, $city_id, $prop_id, $block_id, $propInfo['contentBasic']['pricenum'], '好租城市的价格段获取失败');
         APF::get_instance()->get_nlogger()->log('好租城市的价格段', $logContent);
         return array('err_no' => self::BID_FAIL_OTHER, 'err_msg' => '系统烦忙(code:-' . __LINE__ . ')');
     }
     /** 获取坑位信息 提前判断坑位状态 没有的话会自动初始化一个 */
     $bucketInfo = Bll_Choice_HzBidBucket::getBucketInfo($block_id, $priceIntervalInfo['id']);
     if (empty($bucketInfo)) {
         return array('err_no' => self::BID_WAIT_FAIL, 'err_msg' => '精选房源推广失败');
     }
     /** 精选房源展示推广 */
     if (isset($params['show']) && $params['show'] == 1) {
         $result = array('err_no' => self::BID_SHOW_SUCCESS, 'err_msg' => '精选房源推广成功');
         if ($bucketInfo['usedNum'] >= $bucketInfo['maxOnlineNum']) {
             return array('err_no' => self::BID_SHOW_FAIL, 'err_msg' => '精选房源推广失败');
         }
         /** 展示位 坑位自增 */
         $lockBucket = Model_Choice_HzBidBucket::increment_used_num_online($block_id, $priceIntervalInfo['id']);
         if (!$lockBucket) {
             return array('err_no' => self::BID_SHOW_FAIL, 'err_msg' => '精选房源推广失败');
         }
     } else {
         $result = array('err_no' => self::BID_WAIT_SUCCESS, 'err_msg' => '精选房源推广成功');
         if ($bucketInfo['usedNum'] >= $bucketInfo['totalNum']) {
             return array('err_no' => self::BID_WAIT_FAIL, 'err_msg' => '推广位已满!');
         }
         /** 排队位置 坑位自增 */
         $lockBucket = Model_Choice_HzBidBucket::increment_used_num($block_id, $priceIntervalInfo['id']);
         if (!$lockBucket) {
             return array('err_no' => self::BID_WAIT_FAIL, 'err_msg' => '精选房源推广失败');
         }
     }
     /** 往冻结队列里添加记录,获取request id*/
     $bidFreezeOrder = new Bll_Plan_BidFreezeOrderNum(date('Y'));
     $ajk_user_id = Bll_Broker_MainBusiness::getDataByEsfId($ajk_broker_id)->memberId;
     $requestId = $bidFreezeOrder->getRequestId(Bll_Plan_BidFreezeOrderNum::HZ, $ajk_user_id, date('Y'), 0, $prop_id);
     /** 冻结金额 */
     $freezeResult = self::hz_bid_freeze($ajk_broker_id, $params['budget'] * 100, $requestId, sprintf('好租精选房源冻结,propId: %d', $prop_id));
     if (!$freezeResult->isSucceeded() || $freezeResult['status'] == 'error') {
         Model_Choice_HzBidBucket::decrement_used_num($block_id, $priceIntervalInfo['id']);
         return array('err_no' => self::BID_FAIL_QUALITY_OR_NEW, 'err_msg' => isset($freezeResult['info']) ? $freezeResult['info'] : '冻结金额失败');
     }
     $sn = $freezeResult['data']['sn'];
     if (!isset($params['plan_id']) || empty($params['plan_id'])) {
         $createdRemark = sprintf('经纪人开始精选房源推广 SN:%s', $sn);
         $resultPlan = Bll_Plan_Bid_HzBid::add_plan($hz_broker_id, $prop_id, $params['price'], $params['budget'], $block_id, $city_id, $sn, $ajk_broker_id);
         /** 添加计划失败 */
         if ($resultPlan['error_code'] != 0) {
             Model_Choice_HzBidBucket::decrement_used_num($block_id, $priceIntervalInfo['id']);
             return array('err_no' => self::BID_FAIL_OTHER, 'err_msg' => $resultPlan['error_message']);
         }
         $planId = $resultPlan['planId'];
     } else {
         $createdRemark = sprintf('经纪人重新推广精选房源 SN:%s', $sn);
         /** 更新精选房源计划预算 */
         $planId = $params['plan_id'];
         $resultPlan = Bll_Plan_Bid_HzBid::update_bid($hz_broker_id, $planId, $prop_id, $params['price'], $params['budget'], $city_id, $sn, $ajk_broker_id);
         if ($resultPlan['error_code'] != 0) {
             Model_Choice_HzBidBucket::decrement_used_num($block_id, $priceIntervalInfo['id']);
             return array('err_no' => self::BID_FAIL_OTHER, 'err_msg' => $resultPlan['error_message']);
         }
         $planId = $resultPlan['planId'];
     }
     $result['rank'] = Bll_Plan_Bid_HzBid::getChoiceWaitPosition($planId, $city_id, $block_id, $priceIntervalInfo['id']);
     /** 精选房源成功 */
     $actionQueueData = array('siteType' => Model_Choice_ActionQueue::ENUM_HAOZU, 'brokerId' => $ajk_broker_id, 'planId' => $planId, 'proId' => $prop_id, 'actionId' => Model_Choice_ActionQueue::ENUM_BEGIN_BY_HAND, 'createTime' => time(), 'createRemark' => $createdRemark, 'operationId' => $ajk_broker_id, 'ip' => $params['ip']);
     Model_Choice_ActionQueue::addBidQueen($actionQueueData);
     $bidFreezeOrder->updateRequestComplete($requestId, $sn, $planId);
     return $result;
 }
예제 #5
0
 /**
  * 组装竞价列表
  * @param $out
  * @return array
  */
 private static function prepareBidList(&$out)
 {
     $out['bidList'] = array();
     $out['bidProIds'] = array();
     // 获取计划
     $validBidPlans = Model_Plan_HzPlanBasic::getBidPlansByBrokerId($out['hzBrokerId']);
     if (empty($validBidPlans)) {
         return array();
     }
     $planIds = array();
     $allPlanIds = array();
     foreach ($validBidPlans as $plan) {
         if ($plan['flag'] == 1 && $plan['status'] != Const_HzPlan::DELETE) {
             $planIds[] = $plan['id'];
         }
         $allPlanIds[] = $plan['id'];
     }
     // 获取关系
     $bidPlannings = Model_Plan_HzPlanning::getPlanningByPlanIds($planIds);
     // 获取竞价消费信息
     //$out['bidComsume'] = Bll_Plan_Bid_HzBid::getBidPlanConsumeAndClickInfos($allPlanIds, date('Ymd'));
     $out['bidComsume'] = Model_Stats_PropClick::getBillingInfo($out['hzBrokerId'], $out['cityId'], date('Ymd'));
     if (empty($bidPlannings)) {
         return array();
     }
     // 组装
     foreach ($validBidPlans as $plan) {
         $planId = $plan['id'];
         // 拼接关系
         foreach ($bidPlannings as $bidPlanning) {
             $proId = $bidPlanning['proid'];
             if ($planId != $bidPlanning['plan_id']) {
                 continue;
             }
             $out['bidList'][$planId] = $plan;
             $out['bidList'][$planId]['planning'] = $bidPlanning;
             // 拼接房子
             $prop = isset($out['props'][$proId]) ? $out['props'][$proId] : array();
             if (empty($prop)) {
                 unset($out['bidList'][$planId]);
                 continue;
             }
             $out['bidList'][$planId]['prop'] = $prop;
             // 算竞价排名
             if ($plan['status'] == Const_HzPlan::SPREAD) {
                 $rank = Bll_Plan_Bid_HzBid::getBidRank($prop['proid'], $prop['commid'], $prop['pricenum'], $bidPlanning['unit_price'], $out['cityId']);
             } else {
                 $rank = '已暂停';
             }
             $out['bidList'][$planId]['rank'] = $rank;
             $out['bidProIds'][] = $proId;
         }
     }
     // 排序 前5名 排队 停止
     usort($out['bidList'], function ($a, $b) {
         return is_numeric($a['rank']) && !is_numeric($b['rank']) ? -1 : 1;
     });
     usort($out['bidList'], function ($a, $b) {
         return $a['rank'] == '已暂停' && $b['rank'] != '已暂停' ? 1 : -1;
     });
     foreach ($out['bidList'] as $k => $v) {
         $out['bidList'][$v['id']] = $v;
         unset($out['bidList'][$k]);
     }
     // 获取房源竞价点击
     if (count($out['bidProIds']) > 0) {
         $out['bidClicks'] = Bll_Plan_Bid_HzBid::getPropsBidClick($out['bidProIds'], $out['cityId'], $out['hzBrokerId']);
     }
 }
예제 #6
0
 /**
  * 删除计划
  *
  * @param $params
  * @return array
  */
 private function do_hz_delete_plan($params)
 {
     if (!isset($params['planid']) || empty($params['planid'])) {
         return array('status' => 'error', 'msg' => '计划不存在。');
     }
     $request = APF::get_instance()->get_request();
     $cityId = $request->getBrokerCityId();
     $ajkBrokerId = $request->getBrokerId();
     return Bll_Plan_Bid_HzBid::deleteChoicePlan($ajkBrokerId, $params['planid']);
 }
예제 #7
0
 private static function preparePlanInfo(&$out)
 {
     $planInfo = array();
     $out['hasChoice'] = false;
     $out['hasBid'] = false;
     // 获取房源关系
     $planningsTemp = Model_Plan_HzPlanning::getPlanningLists(array(array('proid', '=', $out['proId']), array('is_valid', 'in', array(Const_HzPlan::SPREAD, Const_HzPlan::AUTOOVER, Const_HzPlan::MENUOVER, Const_HzPlan::UPPERLIMIT, Const_HzPlan::ENDTIME, Const_HzPlan::MANUALLY_PAUSE))));
     if (empty($planningsTemp)) {
         return array();
     }
     $out['hasBid'] = true;
     $planIds = array();
     foreach ($planningsTemp as $planning) {
         $planInfo[$planning['plan_type']]['planning'] = $planning;
         $planIds[] = $planning['plan_id'];
     }
     // 获取计划
     $plansTemp = Model_Plan_HzPlanBasic::getPlanLists(array(array('id', 'in', $planIds), array('flag', '=', 1)));
     if (empty($plansTemp)) {
         return array();
     }
     foreach ($plansTemp as $plan) {
         $planInfo[$plan['plan_type']]['plan'] = $plan;
         if ($plan['bid_version'] == Const_HzPlan::BID_VERSION_CHOICE) {
             $out['hasChoice'] = true;
         }
     }
     // 如有竞价
     if (($out['isBidCity'] || $out['isChoiceCity']) && isset($planInfo[2])) {
         // 算竞价排名
         if ($planInfo[2]['plan']['status'] == Const_HzPlan::SPREAD) {
             $rank = Bll_Plan_Bid_HzBid::getBidRank($out['proId'], $out['propInfo']['commid'], $out['propInfo']['pricenum'], $planInfo[2]['planning']['unit_price'], $out['cityId']);
         } else {
             $rank = '已暂停';
         }
         $planInfo[2]['plan']['rank'] = $rank;
     }
     // 是否展示定竞对比模块
     $out['isShowFixBidCompare'] = ($out['isBidCity'] || $out['isChoiceCity']) && count($planInfo) >= 2;
     // 是否展示竞价详细效果  逻辑判断60天内竞价过
     if ($out['isBidCity'] || $out['isChoiceCity']) {
         $out['isShowBidDetailEffect'] = Bll_Plan_Bid_HzBid::isIn60Bid($out['proId']);
     } else {
         $out['isShowBidDetailEffect'] = false;
     }
     return $planInfo;
 }
예제 #8
0
 /**
  * 组装竞价列表
  * @param $out
  * @return array
  */
 private static function prepareBidList(&$out)
 {
     $bidList = array();
     $out['bidProIds'] = array();
     // 获取计划
     $validBidPlans = Model_Plan_HzPlanBasic::getValidBidPlans($out['hzBrokerId']);
     if (empty($validBidPlans)) {
         return array();
     }
     $planIds = array();
     foreach ($validBidPlans as $plan) {
         $planIds[] = $plan['id'];
     }
     // 获取关系
     $bidPlannings = Model_Plan_HzPlanning::getPlanningByPlanIds($planIds);
     if (empty($bidPlannings)) {
         return array();
     }
     // 组装
     foreach ($validBidPlans as $plan) {
         $planId = $plan['id'];
         // 拼接关系
         foreach ($bidPlannings as $bidPlanning) {
             $proId = $bidPlanning['proid'];
             if ($planId != $bidPlanning['plan_id']) {
                 continue;
             }
             $bidList[$planId] = $plan;
             $bidList[$planId]['planning'] = $bidPlanning;
             // 拼接房子
             $prop = isset($out['props'][$proId]) ? $out['props'][$proId] : array();
             if (empty($prop)) {
                 unset($bidList[$planId]);
                 continue;
             }
             $bidList[$planId]['prop'] = $prop;
             // 算竞价排名
             if ($plan['status'] == Const_HzPlan::SPREAD) {
                 $rank = Bll_Plan_Bid_HzBid::getBidRank($prop['proId'], $prop['commId'], $prop['priceNum'], $bidPlanning['unit_price'], $out['cityId']);
             } else {
                 $rank = '已暂停';
             }
             $bidList[$planId]['rank'] = $rank;
             $out['bidProIds'][] = $proId;
         }
     }
     // 获取房源竞价点击
     if (count($out['bidProIds']) > 0) {
         $out['bidClicks'] = Bll_Plan_Bid_HzBid::getPropsBidClick($out['bidProIds'], $out['cityId'], $out['hzBrokerId']);
     }
     return $bidList;
 }