Ejemplo n.º 1
0
 public function index($manifest = '')
 {
     // 更新用户token(临时,新版本客户端主动触发registerPush接口)
     $user = get_user();
     if ($user && M('common_push_device')->where(['mobile' => $user['mobile']])->count() < 1) {
         $xg = new \Common\Util\XgPush();
         $xg->syncUserToken($user['mobile']);
     }
     // 顶部广告
     $ads = M('app_advertisement')->where(['status' => ['egt', 1]])->order('sort asc,id desc')->field('id,pic,title,url')->select();
     foreach ($ads as &$vo) {
         $vo['url'] = $vo['url'] ?: '/public/page/type/app_ad/id/' . $vo['id'];
     }
     $this->assign('ad_list', $ads);
     // 模块
     $modules = M('app_module')->where(['status' => ['egt', 1]])->order('sort asc,id desc')->field('id,pic,name,url,background')->select();
     foreach ($ads as &$vo) {
         $vo['url'] = $vo['url'] ?: '/public/page/type/app_ad/id/' . $vo['id'];
     }
     $modules[0]['size'] = 'big';
     $modules[1]['size'] = 'wide';
     $modules[2]['size'] = 'wide';
     $modules[3]['size'] = 'mid';
     $modules[4]['size'] = 'mid';
     $modules[5]['size'] = 'mid';
     $modules[6]['size'] = 'wide';
     $modules[7]['size'] = 'wide';
     $this->assign('modules', $modules);
     if ($manifest) {
         $this->assign('tag', md5(serialize($ads + $modules)));
         $this->display('manifest', 'utf-8', 'text/cache-manifest');
     } else {
         $this->display();
     }
 }
Ejemplo n.º 2
0
 /**
  * @title 获取“校园”配置
  *
  * @method get
  */
 public function campus()
 {
     $data = [];
     // 顶部广告
     $ads = M('app_advertisement')->where(['status' => 1])->order('sort asc,id desc')->field('id,pic,title,url')->select();
     foreach ($ads as &$vo) {
         $vo['url'] = $vo['url'] ?: U('/public/page/type/app_ad/id/' . $vo['id'] . '@mobile');
         unset($vo['id']);
     }
     $data['banner'] = $ads;
     // 模块
     $modules = M('app_module')->where(['status' => 1])->order('sort asc,id desc')->field('id,pic,name title,url_v2 url,background')->limit(10)->select();
     foreach ($modules as &$vo) {
         unset($vo['id']);
     }
     $data['module'] = $modules;
     // 预留的校园webview链接
     $data['url'] = '';
     // 更新用户token(临时,新版本客户端主动触发registerPush接口)
     $user = get_user();
     if ($user && M('common_push_device')->where(['mobile' => $user['mobile']])->count() < 1) {
         $xg = new \Common\Util\XgPush();
         $xg->syncUserToken($user['mobile']);
     }
     ajax_success($data);
 }
 /**
  * @title 修复数据
  *
  * @method get
  */
 public function fix_loan_tag()
 {
     $start = I('start', 0);
     $size = 100;
     $xg = new \Common\Util\XgPush();
     $mobiles = M('loan_order')->where(['status' => 11, 'loan_money' => ['gt', 0]])->distinct('mobile')->order('mobile')->limit($start, $size)->getField('mobile', true) or die('done');
     foreach ($mobiles as $mobile) {
         $xg->updateTagByAccount($mobile, 'loan_order_finish');
     }
     echo '<script>location.href="?start=' . ($start + $size) . '";</script>';
 }
Ejemplo n.º 4
0
 /**
  * 更新用户的学校信息标签
  *
  * @param string $uid 用户编号
  * @return boolean
  */
 public function updateUniversityTag($uid)
 {
     $user = get_user($uid);
     $user_info = M('user_info')->find($uid);
     if (!$user || !$user_info) {
         $this->error = '找不到此用户信息!';
         return false;
     }
     // 获取此用户所有的设备
     $tokens = M('common_push_device')->where(['mobile' => $user['mobile']])->getField('token', true);
     // 检查每一个设备的token
     $xg = new \Common\Util\XgPush();
     foreach ($tokens as $token) {
         $xg->updateTag($token, ['university_' . $user_info['university_id'], 'university_campus_' . $user_info['campus_id'], 'university_start_year_' . $user_info['start_year']], 'set', 'university_');
     }
     return true;
 }
Ejemplo n.º 5
0
 public function add()
 {
     if (IS_POST) {
         $title = I('title', '', 'trim') or $this->error('请输入标题!');
         $content = I('content', '', 'trim') or $this->error('请输入说明文字!');
         $url = I('url', '', 'trim') or $this->error('请输入页面链接!');
         $pusher = new \Common\Util\XgPush();
         // 组装标签
         $tag = I('tag');
         $tag or $this->error('请选择标签!');
         M('job_push')->add(['title' => $title, 'content' => $content, 'url' => $url, 'created' => time(), 'tag' => implode(',', $tag), 'uid' => $this->_user['uid']]);
         $pusher->sendTag($tag, ['title' => $title, 'content' => $content, 'url' => $url]);
         $this->success('推送成功!', U('index'));
         exit;
     }
     $this->assign('meta_title', '新增推送');
     $this->display();
 }
Ejemplo n.º 6
0
 protected function _push_salesman($order, $title)
 {
     $order_id = $order['id'];
     $model = M()->table('zj_loan_order_salesman s')->join('zj_loan_salesman u on u.uid=s.uid');
     $mobile = $model->where(['s.order_id' => $order_id])->getField('u.mobile');
     if ($mobile) {
         $pusher = new \Common\Util\XgPush('zjsd');
         $pusher->sendMessage($mobile, ['title' => $title, 'order_id' => $order_id, 'content' => $order['id'] . ',' . $order['title'] . ',' . $order['realname']]);
     }
     // 发送短信给商家
     $company = M()->table('zj_loan_order o')->join('zj_loan_company c on c.id=o.company_id')->where(['o.type' => 3, 'o.id' => $order_id])->field('c.telephone')->find();
     if ($company && strlen($company['telephone']) == 11) {
         sms($company['telephone'], $title, '指尖分期');
     }
 }
Ejemplo n.º 7
0
/**
 * 推送APP信息
 *
 * @param int $uid 用户编号
 * @param string $tag 标签
 */
function app_push($uid, $content, $app = 'zjdx')
{
    $user = get_user($uid);
    if ($user) {
        $xg = new \Common\Util\XgPush($app);
        $xg->sendMessage($user['mobile'], $content);
    }
}
Ejemplo n.º 8
0
 public function add()
 {
     if (IS_POST) {
         $title = I('title', '', 'trim') or $this->error('请输入标题!');
         $content = I('content', '', 'trim') or $this->error('请输入说明文字!');
         $url = I('url', '', 'trim') or $this->error('请输入页面链接!');
         $pusher = new \Common\Util\XgPush();
         $limit_type = I('limit_type') or $this->error('请选择推送范围!');
         in_array($limit_type, ['ALL', 'AND', 'OR', 'MOBILE', 'REG']) or $this->error('请选择正确的推送范围!');
         if ($limit_type === 'ALL') {
             M('common_push')->add(['created' => time(), 'type' => 2, 'title' => $title, 'content' => $content, 'url' => $url, 'uid' => $this->_user['uid'], 'uname' => $this->_user['uname']]);
             $pusher->sendAll(['title' => $title, 'content' => $content, 'url' => $url]);
         } else {
             if ($limit_type === 'MOBILE') {
                 $mobile = [];
                 foreach (preg_split('/\\D/i', I('mobile')) as $vo) {
                     if (!$vo) {
                         continue;
                     }
                     preg_match('/\\d{11}/', $vo) or $this->error('手机号格式错误:' . $vo);
                     $mobile[] = $vo;
                 }
                 $mobile or $this->error('请输入手机号!');
                 M('common_push')->add(['created' => time(), 'type' => 1, 'title' => $title, 'content' => $content, 'url' => $url, 'tag' => implode(',', $mobile), 'uid' => $this->_user['uid'], 'uname' => $this->_user['uname']]);
                 $pusher->sendAccountList($mobile, ['title' => $title, 'content' => $content, 'url' => $url]);
             } else {
                 if ($limit_type === 'REG') {
                     $start = I('reg_start');
                     $end = I('reg_end');
                     $where = [];
                     if ($start) {
                         $where[] = ['egt', strtotime($start)];
                     }
                     if ($end) {
                         $where[] = ['elt', strtotime($end . ' 23:59:59')];
                     }
                     $where = $where ? ['created' => $where] : [];
                     M('user')->where($where)->count() <= 10000 or $this->error('暂只支持每次10000个用户发送,请缩小范围!');
                     $mobile = M('user')->where($where)->getField('mobile', true);
                     $mobile or $this->error('此范围内无用户!');
                     debug($mobile);
                     M('common_push')->add(['created' => time(), 'type' => 1, 'title' => $title, 'content' => $content, 'url' => $url, 'tag' => $start . ' - ' . $end, 'uid' => $this->_user['uid'], 'uname' => $this->_user['uname']]);
                     $pusher->sendAccountList($mobile, ['title' => $title, 'content' => $content, 'url' => $url]);
                 } else {
                     // 组装标签
                     $tag = I('tag');
                     foreach (array_filter(I('android_version', [], 'trim')) as $vo) {
                         $tag[] = 'platform_android_' . $vo;
                     }
                     foreach (array_filter(I('ios_version', [], 'trim')) as $vo) {
                         $tag[] = 'platform_ios_' . $vo;
                     }
                     $tag or $this->error('请选择条件!');
                     M('common_push')->add(['created' => time(), 'type' => 3, 'title' => $title, 'content' => $content, 'url' => $url, 'tag' => implode(',', $tag), 'tag_op' => $limit_type, 'uid' => $this->_user['uid'], 'uname' => $this->_user['uname']]);
                     $pusher->sendTag($tag, ['title' => $title, 'content' => $content, 'url' => $url], $limit_type);
                 }
             }
         }
         $this->success('推送成功!', U('index'));
         exit;
     }
     // 获取所有学校信息
     $university = M('university')->field('id,name')->where('status=1')->select();
     // 获取所有校区信息
     $campus = M('university_campus')->field('id,name,university_name')->where('status=1')->select();
     // 获取所有入学年份
     $start_year = M('user_info')->distinct(true)->field('start_year')->where('start_year>0')->order('start_year asc')->select();
     $this->assign('meta_title', '新增推送');
     $this->assign('_university', $university);
     $this->assign('_campus', $campus);
     $this->assign('_start_year', $start_year);
     $this->display();
 }
Ejemplo n.º 9
0
 public function _userMyResumeSave($data)
 {
     if (M('job_user_resume')->where(['uid' => $this->user->self('uid')])->count() == 0) {
         M('job_user_resume')->add(array_merge(['uid' => $this->user->self('uid'), 'mobile' => $this->user->self('mobile')], $data));
         // 给此用户打上推送标签,表明其参与过兼职业务
         $xg = new \Common\Util\XgPush();
         $xg->updateTagByAccount(get_user()['mobile'], 'job_resume');
     } else {
         M('job_user_resume')->where(['uid' => $this->user->self('uid')])->save($data);
     }
 }
Ejemplo n.º 10
0
 public function checkApply()
 {
     $id = I('get.id', 0, 'intval');
     $status = I('get.status', 0, 'intval');
     in_array($status, [-1, 1]) or $this->error('未知的处理状态:' . $status);
     $model = M('job_apply a')->join('__USER__ u on a.uid = u.uid');
     $apply = $model->find($id) or $this->error('找不到此报名信息!');
     $job_id = $apply['job_id'];
     $joinModel = M('job_join');
     $pusher = new \Common\Util\XgPush();
     if ($status == -1) {
         // 审核不能通过
         M('job_apply')->where('id=' . $id)->save(['reject_comment' => I('post.reject-comment', ''), 'close_time' => time(), 'status' => $status]);
         $pusher->sendMessage($apply['mobile'], ['title' => '不好意思,您的兼职报名未通过审核!', 'content' => I('post.reject-comment', '点击查看详情...'), 'url' => U('/job/user_my_apply_detail/id/' . $id . '@mobile')]);
     } elseif ($status == 1) {
         // 审核通过
         M('job_apply')->where('id=' . $id)->save(['close_time' => time(), 'status' => $status]);
         $pusher->sendMessage($apply['mobile'], ['title' => '您的兼职报名通过审核啦~', 'content' => '点击查看详情...', 'url' => U('/job/user_my_apply_detail/id/' . $id . '@mobile')]);
         if ($joinModel->where('job_id=' . $job_id . ' AND uid=' . $apply['uid'])->count() < 1) {
             $joinModel->add(['job_id' => $job_id, 'created' => time(), 'uid' => $apply['uid'], 'uname' => $apply['uname'], 'from_type' => 1, 'status' => 1]);
         }
     }
     // 更新待审数数及通过数
     $this->_updateStat($job_id);
     // 后退
     $this->success('操作成功!', $_SERVER['HTTP_REFERER']);
 }
Ejemplo n.º 11
0
 protected function _push($mobile, $title, $content = null)
 {
     $pusher = new \Common\Util\XgPush();
     $pusher->sendMessage($mobile, ['title' => $title, 'content' => $content ?: '点击查看详情...', 'url' => U('/user/contract/@loan')]);
 }