public function handle_request_internal() { //根据安居客经纪人ID获取好租经纪人ID $brokerId = $this->_params['brokerId']; $brokerId_hz = Bll_HzBroker::get_brokerid_by_ajk_brokerid($this->_params['brokerId']); $city_id = $this->_params['cityId']; //get bid flg for city $choiceCityFlag = Bll_City::isChoiceCity($city_id, Const_Site::HAOZU); if ($choiceCityFlag) { return array('status' => 'ok', 'data' => array('propertyList' => array(), 'codeNum' => Const_HzErrorInfo::NOBIDCITY)); } $result = Bll_HzBidPlan::get_broker_bidprop($brokerId_hz, $city_id); if (!empty($result)) { $props = array(); foreach ($result as $key => $prop) { $prop_basic['id'] = $prop['proid']; $prop_basic['title'] = $prop['prop']['content_basic']['title']; $prop_basic['commId'] = $prop['prop']['content_basic']['commid']; $prop_basic['commName'] = $prop['prop']['content_basic']['commname']; $prop_basic['roomNum'] = $prop['prop']['content_basic']['roomnum']; $prop_basic['hallNum'] = $prop['prop']['content_basic']['hallnum']; $prop_basic['toiletNum'] = $prop['prop']['content_basic']['toilnetnum']; $prop_basic['area'] = round($prop['prop']['content_basic']['areanum']); $prop_basic['price'] = round($prop['prop']['content_basic']['pricenum']); $prop_basic['priceUnit'] = "元"; $prop_basic['bidStatus'] = $prop['plan']['status']; $prop_basic['index'] = $prop['rank']; $prop_basic['clickNum'] = $prop['clicks']; $prop_basic['offer'] = $prop['offer']; $prop_basic['budget'] = $prop['reconsume']; $prop_basic['yusuan'] = $prop['consume']; if ($prop['plan']['status'] != 1) { $prop_basic['yusuan'] = 20; $prop_basic['bidStatus'] = 3; //@todo 此处是个坑,后续要改 } //增加委托房源标签 $isEntrust = Bll_Zufang_Choice::isCommissionHouse($prop['proid'], $brokerId, Model_House_Commission::TYPE_RENT); if ($isEntrust) { $prop_basic['isEntrust'] = 1; } else { $prop_basic['isEntrust'] = 0; } $prop_basic['planId'] = $key; $props['propertyList'][] = $prop_basic; } } else { $props['propertyList'] = array(); } $ret = array('status' => 'ok', 'data' => $props); return $ret; }
/** * 房源添加竞价/更新竞价 判断 */ public static function check_bid($proid, $broker_id, $offer, $amount, $ajkBrokerId = 0) { $proinfo = Dao_Broker_HzProp::get_prop($proid); $basic_info = $proinfo[$proid]['content_basic']; if (empty($basic_info)) { $flag_array['msg'] = Const_HzErrorInfo::PROPERROR; return $flag_array; } if ($basic_info['userid'] != $broker_id) { $flag_array['msg'] = Const_HzErrorInfo::PROPFAIL; return $flag_array; } if (!$basic_info['quality']) { $flag_array['msg'] = Const_HzErrorInfo::PROPPIC; return $flag_array; } $bid_min_offer = self::get_bid_minoffer($proid); if ((int) ($offer * 100) < (int) ($bid_min_offer * 100)) { $flag_array['msg'] = Const_HzErrorInfo::BIDOFFERFAIL; return $flag_array; } if ((int) ($offer * 100) > (int) ($amount * 100)) { $flag_array['msg'] = Const_HzErrorInfo::BIDOFFERTOP; return $flag_array; } if ($amount < 20) { $flag_array['msg'] = Const_HzErrorInfo::BIDAMOUNT; return $flag_array; } $bid_planning = Dao_Broker_HzPlan::get_prop_planning($proid, Const_HzPlan::BID_TYPE, '1'); if (!empty($bid_planning)) { $flag_array['msg'] = Const_HzErrorInfo::PROPBID; return $flag_array; } if ($ajkBrokerId) { //判断房源是否加入定价计划或者套餐 $isComboBroker = Bll_Broker_HzBroker::isComboBroker($ajkBrokerId); if ($isComboBroker) { //判断房源是否加入套餐 $comboInfo = Bll_Combo_HouseRelation::getHouseRelation($ajkBrokerId, $basic_info['cityid'], $proid, Bll_Combo_HouseRelation::SITE_TYPE_HZ); if (!(!empty($comboInfo) && $comboInfo[0]['state'] > 100 & $comboInfo[0]['state'] < 200)) { $flag_array['msg'] = Const_HzErrorInfo::NOCOMBOPROP; return $flag_array; } } else { $fix_planning = Dao_Broker_HzPlan::get_prop_planning($proid); if (empty($fix_planning)) { $flag_array['msg'] = Const_HzErrorInfo::PROPNOTFIX; return $flag_array; } } } else { $fix_planning = Dao_Broker_HzPlan::get_prop_planning($proid); if (empty($fix_planning)) { $flag_array['msg'] = Const_HzErrorInfo::PROPNOTFIX; return $flag_array; } } $bidprops = Bll_HzBidPlan::get_broker_bidprop($broker_id, $basic_info['cityid']); //@todo 此处是个坑,值得优化哦 //$plans = Dao_Broker_HzPlan::get_broker_plan($broker_id, '1,3,7,8', Const_HzPlan::BID_TYPE); if (count($bidprops) >= 10) { $flag_array['msg'] = Const_HzErrorInfo::PROPBIDTEN; return $flag_array; } $broker_info = Dao_Broker_HzPlan::get_hzbroker_info($broker_id); if ($broker_info['profile_verify'] != 2) { $flag_array['msg'] = Const_HzErrorInfo::BROKERCHECK; return $flag_array; } $balance = Bll_PayAccount::get_broker_balance($broker_id); if ((int) ($amount * 100) > (int) ($balance * 100)) { $flag_array['msg'] = Const_HzErrorInfo::BIDAMOUNTTOP; return $flag_array; } $flag_array['status'] = 1; return $flag_array; }
public function handle_request_internal() { $brokerId = $this->_params['brokerId']; // 判断经纪人是否存在 $broker = Model_Broker_AjkBrokerExtend::findWithBrokerId($brokerId); $hzBrokerId = Model_Broker_MainBusiness::getHzBrokerIdByAjkBrokerId($brokerId); if (!$hzBrokerId || !$broker) { throw new Exception_Broker_NotFound('BrokerId: ' . $brokerId); } // 判断城市是否开通竞价业务 $cityId = $broker['cityId']; if (!Bll_City::isBidCity($cityId)) { throw new Exception_City_NotBidCity('CityId: ' . $cityId); } // 获取竞价房源 $finalProps = array(); $bidProps = Bll_HzBidPlan::get_broker_bidprop($hzBrokerId, $cityId); foreach ($bidProps as $bidProp) { $row = array(); $row['propId'] = $bidProp['proid']; $row['title'] = $bidProp['prop']['content_basic']['title']; $row['imgUrl'] = ''; $row['commId'] = $bidProp['prop']['content_basic']['commid']; $row['commName'] = $bidProp['prop']['content_basic']['commname']; $row['roomNum'] = $bidProp['prop']['content_basic']['roomnum']; $row['hallNum'] = $bidProp['prop']['content_basic']['hallnum']; $row['toiletNum'] = $bidProp['prop']['content_basic']['toilnetnum']; $row['area'] = round($bidProp['prop']['content_basic']['areanum']); $row['price'] = round($bidProp['prop']['content_basic']['pricenum']); $row['priceUnit'] = "元/月"; $row['totalClicks'] = 0; $row['isBid'] = 1; $row['isChoice'] = 0; $row['isVisible'] = (int) ($bidProp['content_basic']['status'] != 6); $row['isMoreImg'] = (int) $bidProp['content_basic']['quality']; $row['isPhonePub'] = (int) (isset($bidProp['content_basic']['from']) && $bidProp['content_basic']['from'] == 'mobile-ajk-broker'); // TODO 批量判定 增加委托房源标签 $isEntrust = Bll_Zufang_Choice::isCommissionHouse($bidProp['proid'], $brokerId, Model_House_Commission::TYPE_RENT); if ($isEntrust) { $row['isEntrust'] = 1; } else { $row['isEntrust'] = 0; } // 确认房源分组 // TODO 基于Rank获取分组可能对页面速度有一定影响 $row['rank'] = $bidProp['rank']; if ($row['rank'] === '已暂停') { $row['group'] = 'offline'; } elseif ($row['rank'] === '排队中') { $row['group'] = 'queued'; } else { $row['group'] = 'online'; } $finalProps[$row['propId']] = $row; } if ($finalProps) { $propIds = array_keys($finalProps); // 批量获取房源的默认图片 $defaultImages = Model_Image_HzImage::getDefaultImagesByHouseIds($propIds); foreach ($defaultImages as $defaultImage) { $finalProps[$defaultImage['proid']]['imgUrl'] = $defaultImage->imageUrl(); } // 批量获取房源的竞价总点击 $bidClicks = Model_Stats_PropClick::getPropAllClicks($propIds, $brokerId, $cityId); $bidClickSums = Model_Stats_PropClick::calculateClickSumsGroupByPropId($bidClicks, 'bid'); foreach ($bidClickSums as $propId => $bidClickSum) { $finalProps[$propId]['totalClicks'] = $bidClickSum; } } // 排序 • 按ID倒序 ksort($finalProps); // 分组 $props = array('onlinePropertyList' => array(), 'queuedPropertyList' => array(), 'offlinePropertyList' => array()); foreach ($finalProps as $finalProp) { switch ($finalProp['group']) { case 'online': $props['onlinePropertyList'][] = $finalProp; break; case 'queued': $props['queuedPropertyList'][] = $finalProp; break; case 'offline': $props['offlinePropertyList'][] = $finalProp; break; } } return array('status' => Const_APIStatus::RETURN_CODE_OK, 'data' => $props); }