Ejemplo n.º 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' => '删除失败!');
     }
 }
Ejemplo n.º 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' => '精选结束成功'));
 }
Ejemplo n.º 3
0
 public function handle_request_internal()
 {
     $brokerId = $this->_params['brokerId'];
     $cityId = $this->_params['cityId'];
     $planId = $this->_params['planId'];
     // 获取Broker Mapping
     $brokerMapping = Model_Broker_MainBusiness::getMainBusinessByAjkBrokerId($brokerId);
     if (!$brokerMapping) {
         throw new Exception('经纪人不存在', Const_APIStatus::E_BROKER_NOT_EXISTS);
     }
     // 判断计划和经纪人关联关系
     $plan = Model_Plan_HzPlanBasic::get_plan_by_id($planId);
     if ($plan['user_id'] != $brokerMapping['hzBrokerid']) {
         throw new Exception('计划不属于该经纪人', Const_APIStatus::E_PLAN_NOT_BELONG_BROKER);
     }
     // 获取定价推广房源列表
     $propertyList = array();
     $props = Bll_HzFixPlan::get_plan_props($planId, $cityId);
     if (isset($props[$planId]) && isset($props[$planId]['props'])) {
         $propIds = array();
         foreach ($props[$planId]['props'] as $prop) {
             $propId = $prop['proid'];
             $propIds[] = $propId;
             $row = array();
             $row['propId'] = $row['id'] = $propId;
             $row['title'] = $prop['content_basic']['title'];
             $row['imgUrl'] = '';
             $row['commId'] = $prop['content_basic']['commid'];
             $row['commName'] = $prop['content_basic']['commname'];
             $row['roomNum'] = $prop['content_basic']['roomnum'];
             $row['hallNum'] = $prop['content_basic']['hallnum'];
             $row['toiletNum'] = $prop['content_basic']['toilnetnum'];
             $row['area'] = round($prop['content_basic']['areanum']);
             $row['price'] = round($prop['content_basic']['pricenum']);
             $row['priceUnit'] = '元/月';
             $row['todayClicks'] = $prop['fix_click'];
             $row['totalClicks'] = $prop['fix_total_click'];
             $row['isBid'] = 0;
             $row['isChoice'] = 0;
             $row['isVisible'] = (int) ($prop['content_basic']['status'] != 6);
             $row['isMoreImg'] = (int) $prop['content_basic']['quality'];
             $row['isPhonePub'] = (int) (isset($prop['content_basic']['from']) && $prop['content_basic']['from'] == 'mobile-ajk-broker');
             $row['publishDays'] = floor((time() - $prop['content_basic']['created']) / 86400);
             $row['publishDaysMsg'] = $row['publishDays'] > 0 ? "{$row['publishDays']}天前发布" : '今天发布';
             $row['createTime'] = date('Y-m-d H:i:s', $prop['content_basic']['created']);
             $row['updateTime'] = date('Y-m-d H:i:s', $prop['content_basic']['updated']);
             //增加委托房源标签
             $isEntrust = Bll_Zufang_Choice::isCommissionHouse($propId, $brokerId, Model_House_Commission::TYPE_RENT);
             if ($isEntrust) {
                 $row['isEntrust'] = 1;
             } else {
                 $row['isEntrust'] = 0;
             }
             $propertyList[$propId] = $row;
         }
         if ($propIds) {
             // 批量获取房源的默认图片
             $defaultImages = Model_Image_HzImage::getDefaultImagesByHouseIds($propIds);
             foreach ($defaultImages as $defaultImage) {
                 $propertyList[$defaultImage['proid']]['imgUrl'] = $defaultImage->imageUrl();
             }
             // 批量获取房源和竞价计划的关联记录(精选是竞价2.0)(只取推广中和排队中的关系)
             $relations = Model_Plan_HzPlanning::getBidRelationsByHouseIds($propIds, array(Const_HzPlan::SPREAD, Const_HzPlan::WAITING));
             // 批量获取房源竞价计划
             $planIds = array();
             $planPropMap = array();
             foreach ($relations as $relation) {
                 $planIds[] = $relation['plan_id'];
                 $planPropMap[$relation['plan_id']] = $relation['proid'];
             }
             if ($planIds) {
                 $plans = Model_Plan_HzPlanBasic::getPlansByIds($planIds);
                 foreach ($plans as $plan) {
                     // 忽略已删除计划
                     if ($plan->flag == 0) {
                         continue;
                     }
                     // 精选
                     if ($plan->bid_version == 2) {
                         $propId = $planPropMap[$plan['id']];
                         $propertyList[$propId]['isChoice'] = 1;
                     } else {
                         // 竞价
                         $propId = $planPropMap[$plan['id']];
                         $propertyList[$propId]['isBid'] = 1;
                     }
                 }
             }
         }
     }
     // 排序 • 按发布时间倒序
     usort($propertyList, function ($a, $b) {
         if ($a['createTime'] == $b['createTime']) {
             return 0;
         }
         return strtotime($a['createTime']) > strtotime($b['createTime']) ? -1 : 1;
     });
     // 分组
     $newList = array();
     $oldList = array();
     foreach ($propertyList as $property) {
         if ($property['publishDays'] > 30) {
             $oldList[] = $property;
         } else {
             $newList[] = $property;
         }
     }
     return array('status' => Const_APIStatus::RETURN_CODE_OK, 'data' => array('newList' => $newList, 'oldList' => $oldList));
 }
Ejemplo n.º 4
0
 public function handle_request_combo()
 {
     $ajkBrokerId = $this->brokerId;
     $cityId = $this->cityId;
     $siteType = Bll_Combo_Broker_BrokerComboInfo::SITE_TYPE_HZ;
     //首先获取套餐关系房源列表 ---- 那房源到主表去除status 已删除的房源 -----在房源主表获取房源基本信息
     $comboList = Bll_Combo_HouseRelation::getHouseRelations($ajkBrokerId, $siteType, 1);
     $surplus = $hasCombo = 0;
     //获取套餐信息-首先判断经纪人有无套餐
     $comboInfos = Bll_Combo_Broker_BrokerComboInfo::getComboListBySite($ajkBrokerId, $siteType);
     if (count($comboInfos) > 0) {
         $index = Bll_Combo_Broker_BrokerComboInfo::getComboIndexBySiteType($siteType);
         $currentTime = time();
         foreach ($comboInfos as $combo) {
             if ($combo[$index] == 0) {
                 continue;
             }
             if (strtotime($combo['endTime']) > $currentTime && strtotime($combo['startTime']) < $currentTime) {
                 $currentCombo = $combo;
             }
         }
         if (!empty($currentCombo)) {
             $surplus = $currentCombo['rentPropNum'];
             if (Bll_Combo_Broker_BrokerComboInfo::isOpenUp($currentCombo)) {
                 //商业地产没打通
                 $surplus = $currentCombo['rentPropNum'] + $currentCombo['salePropNum'];
             }
             $hasCombo = 1;
         }
     }
     //获取当前已推广套餐数量
     if (Bll_Combo_Broker_BrokerComboInfo::isOpenUp($currentCombo)) {
         $currentSpreadHouseCount = Bll_Combo_HouseRelation::getHouseCount($ajkBrokerId, $siteType, true);
     } else {
         $currentSpreadHouseCount = Bll_Combo_HouseRelation::getHouseCountEx($ajkBrokerId, $cityId, $siteType);
     }
     $oldList = $newList = array();
     if (empty($comboInfos)) {
         return array('status' => Const_APIStatus::RETURN_CODE_OK, 'data' => array('newList' => $newList, 'oldList' => $oldList, 'surplus' => $surplus - $currentSpreadHouseCount, 'hasCombo' => $hasCombo));
     }
     $propIds = array();
     foreach ($comboList as $row) {
         $propIds[] = $row['houseId'];
     }
     $hzBrokerId = Bll_HzBroker::get_brokerid_by_ajk_brokerid($ajkBrokerId);
     $comboPropList = Model_House_HzPropSearch::getPropList($propIds, $hzBrokerId, $this->cityId);
     foreach ($comboPropList as $key => $list) {
         if (in_array($list['status'], array(Const_HzStatus::VERIFY, Const_HzStatus::REMOVE, Const_HzStatus::EXPIRED))) {
             unset($comboPropList[$key]);
         }
     }
     //fix bug45133
     if (empty($comboPropList)) {
         return array('status' => Const_APIStatus::RETURN_CODE_OK, 'data' => array('newList' => $newList, 'oldList' => $oldList, 'surplus' => $surplus - $currentSpreadHouseCount, 'hasCombo' => $hasCombo));
     }
     $propIds = array();
     foreach ($comboPropList as $row) {
         $propIds[] = $row['proid'];
     }
     //从主表获取房源信息
     $propertyList = Model_House_HzProp::getPropsByPropIds($propIds);
     //获取是否精选或者竞价
     $relations = Model_Plan_HzPlanning::getBidRelationsByHouseIds($propIds, array(Const_HzPlan::SPREAD, Const_HzPlan::WAITING));
     if (!empty($relations)) {
         $planPropMap = array();
         foreach ($relations as $relation) {
             $planIds[] = $relation['plan_id'];
             $planPropMap[$relation['plan_id']] = $relation['proid'];
         }
         if (!empty($planIds)) {
             $plans = Model_Plan_HzPlanBasic::getPlansByIds($planIds);
             foreach ($plans as $plan) {
                 if ($plan->flag == 0) {
                     continue;
                 }
                 if ($plan->bid_version == 2) {
                     $propId = $planPropMap[$plan['id']];
                     $propertyList[$propId]['isChoice'] = 1;
                 } else {
                     $propId = $planPropMap[$plan['id']];
                     $propertyList[$propId]['isBid'] = 1;
                 }
             }
         }
     }
     // 批量获取房源的默认图片
     $defaultImages = Model_Image_HzImage::getDefaultImagesByHouseIds($propIds);
     if (!empty($defaultImages)) {
         foreach ($defaultImages as $defaultImage) {
             $propertyList[$defaultImage['proid']]['imgUrl'] = $defaultImage->imageUrl();
         }
     }
     krsort($propertyList);
     $startDate = $endDate = date('Ymd');
     $todayClicks = Bll_Combo_Broker_BrokerComboInfo::getHouseComboClickEx($propIds, $startDate, $endDate, Model_Ppc_NewPackageStatsHouseDay::SITE_TYPE_HZ);
     $totalClicks = Bll_House_HzHouse::getComboHouseAccumulateClick($ajkBrokerId, $propIds, $cityId);
     foreach ($propertyList as $list) {
         $row = array();
         $row['id'] = $list['propId'];
         $row['propId'] = $list['propId'];
         $row['title'] = $list['title'];
         $row['imgUrl'] = $list['imgUrl'] ?: '';
         $row['commId'] = $list['commid'];
         $row['commName'] = $list['commname'];
         $row['roomNum'] = $list['roomnum'];
         $row['hallNum'] = $list['hallnum'];
         $row['toiletNum'] = $list['toilnetnum'];
         $row['area'] = round($list['areanum']);
         $row['price'] = round($list['pricenum']);
         $row['priceUnit'] = '元/月';
         $row['todayClicks'] = $todayClicks[$list['propId']][$startDate] ?: 0;
         $row['totalClicks'] = $totalClicks[$list['propId']] ?: 0;
         $row['totalClicks'] = $row['totalClicks'] + $row['todayClicks'];
         $row['isBid'] = isset($list['isBid']) ? $list['isBid'] : 0;
         $row['isChoice'] = isset($list['isChoice']) ? $list['isChoice'] : 0;
         $row['isVisible'] = (int) ($list['status'] != 6);
         $row['isMoreImg'] = (int) $list['quality'];
         $row['isPhonePub'] = (int) (isset($list['from']) && $list['from'] == 'mobile-ajk-broker');
         $row['publishDays'] = floor((time() - $list['created']) / 86400);
         $row['publishDaysMsg'] = $row['publishDays'] > 0 ? "{$row['publishDays']}天前发布" : '今天发布';
         $row['createTime'] = date('Y-m-d H:i:s', $list['created']);
         //$row['updateTime'] = date('Y-m-d H:i:s', $list['updated']);
         //是否委托
         $isEntrust = Bll_Zufang_Choice::isCommissionHouse($list['propId'], $ajkBrokerId, Model_House_Commission::TYPE_RENT);
         $row['isEntrust'] = $isEntrust ? 1 : 0;
         $row['publishDays'] > 30 ? $oldList[] = $row : ($newList[] = $row);
     }
     return array('status' => Const_APIStatus::RETURN_CODE_OK, 'data' => array('newList' => $newList, 'oldList' => $oldList, 'surplus' => $surplus - $currentSpreadHouseCount, 'hasCombo' => $hasCombo));
 }
Ejemplo n.º 5
0
 public function getComboPropsInOneComm($brokerId, $cityId, $commId = '')
 {
     $siteType = Bll_Combo_Broker_BrokerComboInfo::SITE_TYPE_HZ;
     $comboList = Bll_Combo_HouseRelation::getHouseRelations($brokerId, $siteType, 1);
     if (empty($comboList)) {
         return array();
     }
     $propIds = array();
     foreach ($comboList as $row) {
         $propIds[] = $row['houseId'];
     }
     $propertyList = Model_House_HzProp::getPropsByPropIds($propIds);
     //获取是否精选或者竞价
     $relations = Model_Plan_HzPlanning::getBidRelationsByHouseIds($propIds, array(Const_HzPlan::SPREAD, Const_HzPlan::WAITING));
     if (!empty($relations)) {
         $planPropMap = array();
         foreach ($relations as $relation) {
             $planIds[] = $relation['plan_id'];
             $planPropMap[$relation['plan_id']] = $relation['proid'];
         }
         if (!empty($planIds)) {
             $plans = Model_Plan_HzPlanBasic::getPlansByIds($planIds);
             foreach ($plans as $plan) {
                 if ($plan->flag == 0) {
                     continue;
                 }
                 if ($plan->bid_version == 2) {
                     $propId = $planPropMap[$plan['id']];
                     $propertyList[$propId]['isChoice'] = 1;
                 } else {
                     $propId = $planPropMap[$plan['id']];
                     $propertyList[$propId]['isBid'] = 1;
                 }
             }
         }
     }
     // 批量获取房源的默认图片
     $defaultImages = Model_Image_HzImage::getDefaultImagesByHouseIds($propIds);
     if (!empty($defaultImages)) {
         foreach ($defaultImages as $defaultImage) {
             $propertyList[$defaultImage['proid']]['imgUrl'] = $defaultImage->imageUrl();
         }
     }
     krsort($propertyList);
     $base_domain = APF::get_instance()->get_config('base_domain');
     $startDate = $endDate = date('Ymd');
     $todayClicks = Bll_Combo_Broker_BrokerComboInfo::getHouseComboClickEx($propIds, $startDate, $endDate, Model_Ppc_NewPackageStatsHouseDay::SITE_TYPE_HZ);
     $totalClicks = Bll_House_HzHouse::getComboHouseAccumulateClick($brokerId, $propIds, $cityId);
     foreach ($propertyList as $key => $prop) {
         if (in_array($prop['status'], array(Const_HzStatus::VERIFY, Const_HzStatus::REMOVE, Const_HzStatus::EXPIRED))) {
             continue;
         }
         $row = array();
         $row['id'] = $prop['propId'];
         $row['title'] = $prop['title'];
         $row['commId'] = $prop['commid'];
         $row['commName'] = $prop['commname'];
         $row['roomNum'] = $prop['roomnum'];
         $row['hallNum'] = $prop['hallnum'];
         $row['toiletNum'] = $prop['toilnetnum'];
         $row['area'] = round($prop['areanum']);
         $row['price'] = round($prop['pricenum']);
         $row['priceUnit'] = '元/月';
         $row['isVisible'] = (int) ($prop['status'] != 6);
         $row['imgUrl'] = $prop['imgUrl'] ?: '';
         $row['isMoreImg'] = (int) $prop['quality'];
         $row['isPhonePub'] = (int) (isset($prop['from']) && $prop['from'] == 'mobile-ajk-broker');
         $row['propUrl'] = 'http://' . $base_domain . '/web/rent/x/' . $prop['cityid'] . '/' . $prop['propId'] . '-3';
         $row['isBid'] = isset($prop['isBid']) ? $prop['isBid'] : 0;
         $row['isChoice'] = isset($prop['isChoice']) ? $prop['isChoice'] : 0;
         $todayClick = $todayClicks[$prop['propId']][$startDate] ?: 0;
         $row['totalClicks'] = $totalClicks[$prop['propId']] ?: 0;
         $row['totalClicks'] = $row['totalClicks'] + $todayClick;
         $row['createTime'] = date('Y-m-d H:i:s', $prop['created']);
         $row['updateTime'] = date('Y-m-d H:i:s', $prop['updated']);
         $commProps[$prop['commid']][$key] = $row;
     }
     // 如果是获取某单个小区房源列表
     if ($commId) {
         $ret['status'] = 'ok';
         $ret['data']['propertyList'] = isset($commProps[$commId]) && !empty($commProps[$commId]) ? array_values($commProps[$commId]) : array();
     } else {
         $ret = isset($commProps) && !empty($commProps) ? $commProps : array();
     }
     return $ret;
 }