Example #1
0
 /**
  * @method send
  *
  * @author 云小印[yunyin.org]
  *
  * @param $pid,$fid
  */
 public function send()
 {
     $pid = pri_id(U('Index/index'));
     if ($pid) {
         $fid = I('fid', null, 'intval');
         $map['pri_id'] = $pid;
         $map['id'] = $fid;
         $map['status'] = array('eq', C('FILE_PRINTED'));
         $map['sended'] = 0;
         $File = D('FileView');
         $info = $File->where($map)->field('use_id,phone,name')->find();
         $Printer = M('Printer');
         $info['pri_name'] = M('Printer')->getFieldById($pid, 'name');
         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']);
             unset($info['use_id']);
             $info['fid'] = $fid;
             $SMS = new \Vendor\Sms();
             if ($SMS->printed($phone, $info)) {
                 $File = M('File');
                 $map['id'] = $fid;
                 $result = $File->where($map)->setField('sended', 1);
                 $this->success('提醒信息已发送');
             } else {
                 $this->error('发送不成功');
             }
         } else {
             $this->success('已发送');
         }
     } else {
         $this->error('请先登录');
     }
 }
Example #2
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;
     }
 }
Example #3
0
 /**
  * getPhone()
  * 查看手机号码
  */
 public function getPhone()
 {
     $uid = use_id();
     if (!$uid) {
         $this->error('请登录!');
     }
     $phone = get_phone_by_id($uid);
     if (IS_AJAX) {
         $this->success(array('phone' => $phone));
     } else {
         echo $phone;
     }
 }
Example #4
0
 /**
  * 失主尚未加入平台,或已加入平台但未绑定信息
  * 向微博、人人平台发送消息
  * @param send_msg		要发送的信息
  * @param add_msg                        附加消息
  */
 public function send()
 {
     $uid = use_id('/');
     /*判断是否有接收者*/
     $receiver = session('receiver');
     if (!$receiver) {
         $this->error('禁止乱发信息!!!', '/Card');
     }
     /*判断尝试次数*/
     $cache_name = 'send_' . $uid;
     $times = S($cache_name);
     $User = M('User');
     if ($times > 5) {
         \Think\Log::record('第三方平台发送失败:ip:' . get_client_ip() . ',find_id' . $find_id);
         $this->error('发送次数过多!', '/Card');
     } else {
         S($cache_name, $times + 1, 3600);
     }
     /*添加到丢失记录*/
     $receiver_id = $receiver['uid'] ? $receiver['uid'] : 0;
     $log = array('find_id' => $uid, 'lost_id' => $receiver_id, 'status' => 0);
     $msg_id = M('Cardlog')->add($log);
     $finder = $User->field('sch_id,name')->getById($uid);
     //是否匿名
     $finder_name = I('anonymity') ? '云小印' : $finder['name'];
     //是否公开手机
     $finder_phone = I('add_phone') ? get_phone_by_id($uid) : '';
     $finder_school = M('School')->cache(true)->getFieldById($finder['sch_id'], 'name');
     /*$msg_info = array(
     		'card_number' => $receiver['number'],
     		'card_name' => '[' . $msg_id . ']' . $receiver['name'],
     		'card_school' => $School->cache(true)->getFieldById($receiver['sch_id'], 'name'),
     		'finder_name' => $finder_name,
     		'finder_school' => $School->cache(true)->getFieldById($finder['sch_id'], 'name'),
     		'msg' => I('add_msg'),
     		);
     		$msg = L('CARD_MSG_IN', $msg_info);*/
     /*post数据到API*/
     $url = 'https://newfuturepy.sinaapp.com/broadcast';
     $data = array('key' => C('WEIBO_API_PWD'), 'school' => $receiver['sch_id'], 'card_id' => $receiver['number'], 'name' => $receiver['name'], 'contact_name' => $finder_name . '【' . $msg_id . '】', 'contact_phone' => $finder_phone, 'msg' => I('add_msg'));
     $result = json_decode($this->_post($url, $data));
     if ($result) {
         session('receiver', null);
         $result_info = '人人发送成功(' . $result->renren . ')条;微博发送成功(' . $result->weibo . ')条;BBS发送' . ($result->bbs ? '成功' : '失败');
         $this->success($result_info, '/Card/log');
     } else {
         M('Cardlog')->where('id=%d', $msg_id)->delete();
         $this->error('发送失败,请通过其他方式寻找失主或联系我们');
     }
 }