public function handle_request_internal()
 {
     $brokerId = $this->_params['brokerId'];
     //连续签到统计
     $signStatistics = Model_Broker_CommunitySignStatistics::data_access()->filter('brokerId', $brokerId)->find_only();
     if ($signStatistics) {
         if (date('Y-m-d', strtotime($signStatistics['updateTime'])) == date('Y-m-d', time()) || date('Y-m-d', strtotime($signStatistics['updateTime'])) == date('Y-m-d', strtotime('yesterday'))) {
             return array('status' => Const_APIStatus::RETURN_CODE_OK, 'data' => array('signCount' => $signStatistics['signCount'], 'maxSignCount' => $signStatistics['maxSignCount']));
         } else {
             return array('status' => Const_APIStatus::RETURN_CODE_OK, 'data' => array('signCount' => 0, 'maxSignCount' => $signStatistics['maxSignCount']));
         }
     } else {
         return array('status' => Const_APIStatus::RETURN_CODE_OK, 'data' => array('signCount' => 1, 'maxSignCount' => 1));
     }
 }
 public function handle_request()
 {
     $this->cursor = $this->getFlag();
     if (empty($this->cursor)) {
         $this->cursor['id'] = 0;
         $this->setFlag($this->cursor, "");
     }
     $SignStatistics = Model_Broker_CommunitySignStatistics::data_access()->filter_by_op('id', '>', $this->cursor['id'])->limit(50)->get_all();
     if (empty($SignStatistics)) {
         $this->setStop();
     }
     foreach ($SignStatistics as $key => $value) {
         Bll_Commsign::setSignStatistics($value['brokerId'], $value);
         $this->cursor['id'] = $value['id'];
     }
     $this->setFlag($this->cursor);
 }
 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;
         }
     }
 }
Exemple #4
0
 public static function testRedis()
 {
     $redis = self::getRedisConnect();
     //测试程序/////////////////////////////////////////////////
     $currentSignRange = Bll_Broker_CommunitySign::getCurrentSignRange();
     $redis->flushDB();
     $SignStatistics = Model_Broker_CommunitySignStatistics::data_access()->filter_by_op('id', '>=', 0)->limit(500)->get_all();
     //var_dump($SignStatistics);die;
     $redis->select(1);
     $arr = $redis->keys(self::$SignStatistics . '*');
     foreach ($arr as $k) {
         //var_dump(self::getKey($k));
     }
     $redis->select(0);
     exit;
     $id = 100;
     for ($i = 1; $i <= 10; ++$i) {
         $brokerId = intval('1111' . $i);
         $commId = intval('200' . $i);
         $id = $id + 1;
         $sign = array('id' => $id, 'brokerId' => $brokerId, 'communityId' => $commId, 'lat' => floatval('31.' . $i), 'lng' => floatval('121.' . $i), 'signTime' => date('Y-m-d H:i:s'), 'sourceType' => Model_Broker_Location::SOURCE_TYPE_COMMUNITY_SIGN, 'updateTime' => date('Y-m-d H:i:s'), 'currentSignRange' => $currentSignRange[0]);
         Bll_Commsign::Signed($brokerId, $commId, $currentSignRange[0], $sign);
         //Bll_Commsign::setLocationInfo($brokerId,$sign);
     }
     //var_dump($redis->keys('*'));exit;
     //测试结束//////////////////////////////////////////////////////////////////
 }