コード例 #1
0
 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;
         }
     }
 }