public function handle_request() { $limit = 1000; $offset = 0; while ($offset < $limit) { $data = Bll_Mobile_RedisToDb::readBrokerCommunitySign(); if ($data) { $sign = Model_Broker_CommunitySign::create(array('brokerId' => $data['brokerId'], 'communityId' => $data['communityId'], 'lat' => $data['lat'], 'lng' => $data['lng'], 'signTime' => $data['signTime']), date('Ym', time())); $sign->save(); ++$offset; } else { break; } } }
private static function initRedis() { $apf = APF::get_instance(); $config = $apf->get_config('redis_to_db', 'redis'); //本地redis,测试用 //$config['host'] = '192.168.190.69'; //$config['port'] = '6379'; if (!isset($config['host']) || !isset($config['port'])) { throw new RedisException('Host and port are needed to connect redis server.'); } self::$redis = new Redis(); if (!self::$redis->connect($config['host'], $config['port'])) { throw new RedisException("Failed to connect redis server: {$config['host']}:{$config['port']}"); } self::$redis->setOption(4, 1); // retry when we get no keys back }
public function handle_request() { $limit = 1000; $offset = 0; while ($offset < $limit) { $brokerId = array(); $data = Bll_Mobile_RedisToDb::readCommSignStatistics(); if ($data) { //判断记录是否存在 $brokerId = Model_Broker_CommunitySignStatistics::data_access()->filter('brokerId', $data['brokerId'])->get_row(); if (empty($brokerId)) { $SignStatistics = Model_Broker_CommunitySignStatistics::create(array('brokerId' => $data['brokerId'], 'signCount' => $data['signCount'], 'maxSignCount' => $data['maxSignCount'], 'createTime' => date('Y-m-d H:i:s'))); $SignStatistics->save(); } else { $SignStatistics = Model_Broker_CommunitySignStatistics::data_access(); //$SignStatistics->set_field('id',$data['id']); $SignStatistics->set_field('signCount', $data['signCount']); $SignStatistics->set_field('maxSignCount', $data['maxSignCount']); $SignStatistics->set_field('updateTime', $data['updateTime']); $SignStatistics->filter('brokerId', $data['brokerId'])->update(); } //发送微聊信息 if ($data['sendFlag']) { //获取chat信息 $chatInfo = Bll_Mobile_ChatInfoBll::getInstance()->getChatInfo($data['brokerId'], 1); if ($chatInfo['status'] == 'ok') { $chatId = $chatInfo['data']['chatId']; // 发送欢迎信息 Bll_Mobile_ChatInfoBll::getInstance()->sendPublicMsg($chatId, '您已连续签到' . $data['signCount'] . '天,最长连续签到' . $data['maxSignCount'] . '天。'); } } ++$offset; } else { break; } } }
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; } } }