Ejemplo n.º 1
0
 public function handle_request()
 {
     //获取关注的微信用户
     $WechatInfoList = Model_Wechat_WechatUsers::getWechatInfoListById($this->id, $this->limit);
     //判断当前队列是否处理完成
     if (empty($WechatInfoList)) {
         //清空游标
         $this->setFlag(array('id' => 0));
         //停止shell调用
         $this->setStop();
         //写过程日志
         $this->setLog('处理完成');
         exit;
     }
     $WechatMbroker = new Bll_Wechat_Mbroker_WechatMbroker();
     //数据处理
     foreach ($WechatInfoList as $list) {
         $this->id = $list['id'];
         //判断微信是否关注
         if ($list['status'] != Model_Wechat_WechatUsers::subscribe) {
             $this->setLog(date('Y-m-d H:i:s') . ' openid:' . $list['openId'] . ' userid:' . $list['userId'] . ' 未关注');
             continue;
         }
         //判断关注账号是否绑定
         if (!$list['userId']) {
             $this->setLog(date('Y-m-d H:i:s') . ' openid:' . $list['openId'] . ' userid:' . $list['userId'] . ' 微信未绑定');
             continue;
         }
         //推送消息
         $WechatMbroker->setMbrokeNoticeFromTemplate($list['openId'], $list['userId'], $list['userType']);
         //记录游标
         $this->setFlag(array('id' => $this->id));
     }
     //休息10毫秒
     $this->setShCommonSleepTime(0.01);
 }