Esempio n. 1
0
 public function handle_request_internal()
 {
     $brokerId = $this->_params['brokerId'];
     $lng = $this->_params['lng'];
     $lat = $this->_params['lat'];
     // 更新经纪人位置
     $needLog = false;
     $location = Model_Broker_Location::data_access()->filter('brokerId', $brokerId)->find_only();
     if (!$location) {
         $location = Model_Broker_Location::create(array('brokerId' => $brokerId, 'lng' => $lng, 'lat' => $lat, 'sourceType' => Model_Broker_Location::SOURCE_TYPE_UPDATE_LOCATION, 'updateTime' => date('Y-m-d H:i:s')));
         $location->save();
         $needLog = true;
     }
     if (!($location['lat'] == $lat && $location['lng'] == $lng && $location['sourceType'] == Model_Broker_Location::SOURCE_TYPE_UPDATE_LOCATION)) {
         $location['lat'] = $lat;
         $location['lng'] = $lng;
         $location['sourceType'] = Model_Broker_Location::SOURCE_TYPE_UPDATE_LOCATION;
         $location['updateTime'] = date('Y-m-d H:i:s');
         $location->save();
         $needLog = true;
     }
     // 记录位置变更日志
     if ($needLog) {
         $locationLog = Model_Broker_LocationLog::create(array('brokerId' => $brokerId, 'lng' => $lng, 'lat' => $lat, 'updateTime' => date('Y-m-d H:i:s')), date('Ym'));
         $locationLog->save();
     }
     return array('status' => Const_APIStatus::RETURN_CODE_OK);
 }
Esempio n. 2
0
 public function handle_request()
 {
     $limit = 1000;
     $offset = 0;
     while ($offset < $limit) {
         $data = Bll_Mobile_RedisToDb::readBrokerLocation();
         if ($data) {
             $needLog = false;
             // 是否需要记录位置更新日志
             $location = Model_Broker_Location::data_access()->filter('brokerId', $data['brokerId'])->find_only();
             //没有位置信息,插入数据
             if (!$location) {
                 $location = Model_Broker_Location::create(array('brokerId' => $data['brokerId'], 'lng' => $data['lng'], 'lat' => $data['lat'], 'sourceType' => Model_Broker_Location::SOURCE_TYPE_COMMUNITY_SIGN, 'updateTime' => $data['updateTime']));
                 $location->save();
                 $needLog = true;
             }
             //位置信息改变,插入数据
             if (!($location['lat'] == $data['lat'] && $location['lng'] == $data['lng'] && $location['sourceType'] == Model_Broker_Location::SOURCE_TYPE_COMMUNITY_SIGN)) {
                 $location['lat'] = $data['lat'];
                 $location['lng'] = $data['lng'];
                 $location['sourceType'] = Model_Broker_Location::SOURCE_TYPE_COMMUNITY_SIGN;
                 $location['updateTime'] = $data['updateTime'];
                 $location->save();
                 $needLog = true;
             }
             // 记录位置变更日志
             if ($needLog) {
                 $locationLog = Model_Broker_LocationLog::create(array('brokerId' => $data['brokerId'], 'lng' => $data['lng'], 'lat' => $data['lat'], 'updateTime' => $data['updateTime']), date('Ym'));
                 $locationLog->save();
             }
             ++$offset;
         } else {
             break;
         }
     }
 }
Esempio n. 3
0
 public static function createLocationLog($broker_id, $lng, $lat)
 {
     $return = Model_Broker_LocationLog::create(array('brokerId' => $broker_id, 'lng' => $lng, 'lat' => $lat), date('Ym'));
     $re = $return->save();
     return $re;
 }