Пример #1
0
 private function _sendDownloadMessage($pid, $fid)
 {
     $File = D('FileView');
     $map['id'] = $fid;
     $info = $File->where($map)->field('use_id,phone,name')->find();
     if ($info['phone'] && $info['name']) {
         unset($info['phone']);
         if (mb_strlen($info['name']) > 18) {
             $info['name'] = mb_substr($info['name'], 0, 18);
         }
         $phone = get_phone_by_id($info['use_id']);
         $info['user_name'] = M('User')->getFieldById($info['use_id'], 'name');
         unset($info['use_id']);
         $info['info'] = $info['name'];
         $info['status'] = '已下载';
         $SMS = new \Vendor\Sms();
         if ($SMS->noticeUser($phone, $info)) {
             return true;
         } else {
             return false;
         }
     } else {
         return false;
     }
 }
Пример #2
0
 public function notifyUsers()
 {
     //identify
     $verify_key = I('get.key');
     if ($verify_key != C('VERIFY_KEY')) {
         return;
     }
     $condition['_string'] = '(file.status=2 AND copies=0) OR file.status=4';
     $condition['time'] = array('lt', date('Y-m-d h:i:s', time() - 3600 * 24));
     $NotifyUser = D('NotifyUser');
     $result = array();
     $result1 = $NotifyUser->field('user_id,stu_num,phone,use_name,file_name,count("use_name") as count,$status')->where($condition)->group('use_name')->select();
     $result3 = $NotifyUser->field('user_id,stu_num,phone,use_name,file_name,status')->where($condition)->select();
     for ($i = 0; $i < count($result1); $i++) {
         $item1 = $result1[$i];
         if ($item1['count'] == 1) {
             array_push($result, array($item1['phone'], $item1['use_name'], $item1['file_name'], "已经下载", $item1['user_id'], $item1['stu_num']));
         } else {
             if ($item1['count'] > 1) {
                 $count = 0;
                 $info = "";
                 for ($k = 0; $k < count($result3); $k++) {
                     $item3 = $result3[$k];
                     if ($item3['user_id'] == $item1['user_id']) {
                         $count++;
                         $info = $info . substr($item3['file_name'], 0, 8) . "..";
                         if ($count == 2) {
                             break;
                         } else {
                             $info = $info . "、";
                         }
                     }
                 }
                 $info = $info . "等" . $item1['count'] . "个文件";
                 array_push($result, array($item1['phone'], $item1['use_name'], $info, "已经下载", $item1['user_id'], $item1['stu_num']));
             }
         }
     }
     echo "<meta http-equiv='Content-Type'' content='text/html; charset=utf-8'>";
     $SMS = new \Vendor\Sms();
     for ($i = 0; $i < count($result); $i++) {
         $item = $result[$i];
         import('Common.Encrypt', COMMON_PATH, '.php');
         $phone = decrypt_phone($item[0], $item[5], $item[4]);
         echo $phone;
         if (!empty($phone)) {
             $msgInfo = array("user_name" => $item[1], "info" => $item[2], "status" => $item[3]);
             if ($SMS->noticeUser($phone, $msgInfo)) {
                 echo "提醒信息已经发送";
             } else {
                 echo "发送不成功";
             }
             echo $phone . "\t\t" . $msgInfo["user_name"] . "\t\t" . $msgInfo["info"] . "\t\t" . $msgInfo["status"];
         }
     }
 }