Ejemplo n.º 1
0
 public function handle_request_internal()
 {
     $fPropId = $this->_params['fPropId'];
     $userId = $this->_params['userId'];
     //获取房源库房源数据
     $fpropObj = Model_Fyk_PropLibrary::getDataById($fPropId);
     $fPropInfo = $fpropObj[0];
     $fPropInfoExtend = Bll_Fyk_Prop_Extend::getInstance()->getPropExtendInfo($fPropId);
     //查询用户是否购买这套房源
     $isBuy = $this->isBuyProp($userId, $fPropId);
     //组装数据
     $data = $this->dataCheck($fPropInfo, $fPropInfoExtend[$fPropId], $isBuy);
     $result = array('status' => 'ok', 'data' => $data);
     return $result;
 }
Ejemplo n.º 2
0
 public function handle_request()
 {
     /**取任务记录*/
     $props = $this->getProps();
     $recommendProps = $this->getRecommendProps($props);
     //房源id 为key
     //没有推荐房源
     if (empty($recommendProps)) {
         // 更新游标
         $id = array_pop($props);
         if (!empty($id)) {
             $this->cursor['id'] = $id->id;
             $this->setFlag($this->cursor);
         }
         return;
     }
     $propIds = array_keys($recommendProps);
     $propInfos = Model_Fyk_PropLibrary::getDataById($propIds);
     //没有找到房源信息
     if (empty($propInfos)) {
         // 更新游标
         $id = array_pop($props);
         $this->cursor['id'] = $id->id;
         $this->setFlag($this->cursor);
         return;
     }
     //房源userId  fyk_user_props表中查找;
     $userProps = $this->getUserProps($propIds);
     $keyPropInfos = array();
     $commIds = array();
     foreach ($propInfos as $propInfo) {
         $commIds[] = $propInfo['commId'];
         $keyPropInfos[$propInfo['id']] = $propInfo;
         // 房源id 为key 房源信息
     }
     //批量小区位置
     $commLations = $this->getCommLation($commIds);
     //小区id 为key  小区坐标
     /**逐条处理任务*/
     foreach ($props as $prop) {
         if (!isset($recommendProps[$prop->propId])) {
             // todo update cursor
         } else {
             //取房源坐标和经纪人坐标->找到相应经纪人;
             $commId = $keyPropInfos[$prop->propId]['commId'];
             $sosolat = $commLations[$commId]['sosolat'];
             $sosolng = $commLations[$commId]['sosolng'];
             $km = 2000;
             //该房源无效
             if (empty($sosolat) || empty($sosolng)) {
                 //log
                 $this->cursor['id'] = $prop['id'];
                 $this->setFlag($this->cursor);
                 continue;
             }
             if (!empty($_SERVER['PG_TEST'])) {
                 //PG
                 $testBrokerIds = APF::get_instance()->get_config('fyk_pg_test_brokerIds');
                 $testCommIds = APF::get_instance()->get_config('fyk_pg_test_commIds');
                 $testUserIds = APF::get_instance()->get_config('fyk_pg_test_userIds');
             } else {
                 //GA
                 $testBrokerIds = APF::get_instance()->get_config('fyk_ga_test_brokerIds');
                 $testCommIds = APF::get_instance()->get_config('fyk_ga_test_commIds');
                 $testUserIds = APF::get_instance()->get_config('fyk_ga_test_userIds');
             }
             if (in_array($commId, $testCommIds)) {
                 //如果是测试小区的房子,则推给测试经纪人
                 foreach ($testBrokerIds as $testBrokerId) {
                     $test = new Model_Broker_BrokerActionCenter();
                     $test->brokerId = $testBrokerId;
                     $allBrokers[$testBrokerId] = $test;
                 }
                 $brokerUserIds = $testUserIds;
             } else {
                 list($allBrokers, $brokerUserIds) = $this->getBrokersWithinScope($sosolat, $sosolng, $km, '');
                 //2 限制人数
             }
             /** pg 测试经纪人 broerkIds */
             if (empty($allBrokers)) {
                 $this->cursor['id'] = $prop['id'];
                 $this->setFlag($this->cursor);
                 continue;
             }
             //插入fyk_push_props表
             foreach ($allBrokers as $broker) {
                 $params = array();
                 $params['userId'] = $brokerUserIds[$broker->brokerId];
                 $params['propId'] = $prop->propId;
                 $params['createTime'] = date('Y-m-d H:i:s', time());
                 $params['updateTime'] = date('Y-m-d H:i:s', time());
                 if (empty($params['userId'])) {
                     continue;
                 }
                 if (in_array($params['userId'], $userProps[$prop->propId])) {
                     continue;
                 }
                 $res = Model_Broker_FykPushProps::insertFykPushProps($params);
                 if ($res) {
                     //经纪人新推房源数加1
                     $brokerPropCountInfo = Model_Fyk_PushPropsLatestCount::getBrokerPropCount($brokerUserIds[$broker->brokerId]);
                     if ($brokerPropCountInfo) {
                         $brokerPropCountInfo->count += 1;
                         $brokerPropCountInfo->save();
                     } else {
                         $data = new Model_Fyk_PushPropsLatestCount();
                         $data->count = 1;
                         $data->userId = $brokerUserIds[$broker->brokerId];
                         $data->updateTime = date('Y-m-d H:i:s', time());
                         $data->save();
                     }
                 }
             }
         }
         // 更新游标
         $this->cursor['id'] = $prop['id'];
         $this->setFlag($this->cursor);
     }
 }
Ejemplo n.º 3
0
 public function handle_request()
 {
     //监控fyk_push_props表 如果有新增记录 生成推送信息推送
     $props = $this->getPushedRecommendProps();
     if (empty($props)) {
         // 更新游标
         $id = array_pop($props);
         if (!empty($id)) {
             $this->cursor['id'] = $id->id;
             $this->setFlag($this->cursor);
         }
         return;
     }
     $propIds = array();
     foreach ($props as $prop) {
         $propIds[] = $prop->propId;
     }
     //房源库房源信息
     $commIds = array();
     $keyPropInfos = array();
     $propInfos = Model_Fyk_PropLibrary::getDataById($propIds);
     if (empty($propInfos)) {
         // 更新游标
         $id = array_pop($props);
         $this->cursor['id'] = $id->id;
         $this->setFlag($this->cursor);
         return;
     }
     foreach ($propInfos as $propInfo) {
         $commIds[] = $propInfo['commId'];
         $keyPropInfos[$propInfo['id']] = $propInfo;
         // 房源id 为key 房源信息
     }
     //批量小区信息
     $commInfos = $this->getCommInfo($commIds);
     //小区id 为key  小区坐标
     foreach ($props as $prop) {
         $userId = $prop->userId;
         $brokerInfo = Model_Broker_AjkBrokerExtend::getBrokerInfoByUserId($userId);
         if (empty($brokerInfo)) {
             //更新游标
             $this->cursor['id'] = $prop->id;
             $this->setFlag($this->cursor);
             continue;
         }
         $brokerId = $brokerInfo->brokerId;
         //获取房源小区
         $commId = $keyPropInfos[$prop->propId]['commId'];
         if (empty($commId)) {
             //更新游标
             $this->cursor['id'] = $prop->id;
             $this->setFlag($this->cursor);
             continue;
         }
         $msg = $commInfos[$commId]['commName'] . '出现新房源';
         /** 消息推送 */
         $result = $this->push($brokerId, $msg);
         //更新游标
         $this->cursor['id'] = $prop->id;
         $this->setFlag($this->cursor);
     }
 }