Example #1
0
 public function doMobileCenter()
 {
     global $_W, $_GPC;
     if (empty($_GPC['openid'])) {
         $from_user = $_W['fans']['from_user'];
     } else {
         $from_user = $_GPC['openid'];
     }
     $this->tryLink();
     yload()->classs('quick_center', 'fans');
     $_fans = new Fans();
     $fans = $_fans->refresh($_W['weid'], $from_user);
     $uplevelfans = $_fans->getUplevelFans($_W['weid'], $from_user);
     $groupid = empty($_GPC['groupid']) ? 1 : intval($_GPC['groupid']);
     $list = pdo_fetchall("SELECT * FROM " . tablename(self::$t_bind) . " WHERE weid=:weid AND enable=1 ORDER BY groupid, displayorder", array(':weid' => $_W['weid']));
     $list = $this->buildCallbackParam($list);
     yload()->classs('quick_center', 'menubuilder');
     $menus = MenuBuilder::build($list);
     $title = empty($this->module['config']['title']) ? $_W['account']['name'] : $this->module['config']['title'];
     $share = array();
     $share['disable'] = true;
     $vip_kv = unserialize($this->module['config']['vip']);
     $fans['vipname'] = $vip_kv[$fans['vip']];
     yload()->classs('quick_center', 'template');
     $_template = new Template($this->module['name']);
     $_W['account']['template'] = $this->getTemplateName();
     include $_template->template('center');
 }
 /**
  * 增加一次助力记录
  *      如果from, to 已经存在, 失败
  *   id uniacid from to dateline  
  * 
  * @param $entity 助力结构 from, to, dateline
  * @return int|error
  */
 public function createHelp($entity)
 {
     global $_W;
     $rec = array_elements(array('from', 'to', 'dateline'), $entity);
     $rec['uniacid'] = $_W['uniacid'];
     require_once MB_ROOT . '/source/Fans.class.php';
     $f = new Fans();
     $fromExists = $f->getOne($entity['from']);
     $toExists = $f->getOne($entity['to']);
     if (!empty($fromExists) && !empty($toExists)) {
         $pars = array();
         $pars[':uniacid'] = $_W['uniacid'];
         $pars[':from'] = $rec['from'];
         $pars[':to'] = $rec['to'];
         $sqll = 'SELECT * FROM ' . tablename('mbrp_helps') . ' WHERE `uniacid`=:uniacid AND `from`=:from AND `to` =:to';
         $exists = pdo_fetch($sqll, $pars);
         if (!empty($exists)) {
             return error(-3, '已经助力过了');
         }
         $ret = pdo_insert('mbrp_helps', $rec);
         if (!empty($ret)) {
             return pdo_insertid();
         } else {
             return error(-2, '数据保存失败, 请稍后重试');
         }
     } else {
         return error(-1, '用户不存在');
     }
 }
Example #3
0
 /**
  * 增加一次助力记录
  *      如果owner, helper 已经存在, 失败
  *   id uniacid owner helper dateline
  *
  * @param $entity 助力结构 owner, helper, dateline
  * @return int|error
  */
 public function createHelp($entity)
 {
     global $_W;
     $rec = array_elements(array('owner', 'helper', 'dateline'), $entity);
     $rec['uniacid'] = $_W['uniacid'];
     $rec['activity'] = $this->activity['actid'];
     require_once MB_ROOT . '/source/Fans.class.php';
     $f = new Fans();
     $ownerExists = $f->getOne($entity['owner']);
     $helperExists = $f->getOne($entity['helper']);
     if (!empty($ownerExists) && !empty($helperExists)) {
         $pars = array();
         $pars[':uniacid'] = $_W['uniacid'];
         $pars[':activity'] = $this->activity['actid'];
         $pars[':helper'] = $rec['helper'];
         if (!empty($this->activity['tag']['limit'])) {
             $sql = 'SELECT COUNT(*) FROM ' . tablename('mbrp_helps') . ' WHERE `uniacid`=:uniacid AND `activity`=:activity AND `helper` =:helper';
             $count = pdo_fetchcolumn($sql, $pars);
             if ($this->activity['tag']['limit'] <= $count) {
                 return error(-1, "超过次数限制, 本次活动限制每人帮助好友次数不能超过 {$this->activity['tag']['limit']} 次");
             }
         }
         $pars[':owner'] = $rec['owner'];
         $sql = 'SELECT * FROM ' . tablename('mbrp_helps') . ' WHERE `uniacid`=:uniacid AND `activity`=:activity AND `owner`=:owner AND `helper` =:helper';
         $exists = pdo_fetch($sql, $pars);
         if (!empty($exists)) {
             return error(-3, '已经帮助过这位好友了');
         }
         $ret = pdo_insert('mbrp_helps', $rec);
         if (!empty($ret)) {
             return pdo_insertid();
         } else {
             return error(-2, '数据保存失败, 请稍后重试');
         }
     } else {
         return error(-1, '用户不存在');
     }
 }
Example #4
0
<?php

global $_W, $_GPC;
$modulePublic = '../addons/microb_redpack/static/';
require_once MB_ROOT . '/source/Activity.class.php';
require_once MB_ROOT . '/source/Fans.class.php';
require_once MB_ROOT . '/source/Shared.class.php';
$a = new Activity();
$f = new Fans();
$user = $this->auth();
$id = $_GPC['actid'];
$id = intval($id);
$activity = $a->getOne($id);
$prepare = $this->prepareActivity($activity, array('user' => $user));
if (is_error($prepare)) {
    header('Location: ' . $this->createMobileUrl('activity', array('actid' => $activity['actid'])));
    exit;
}
$uid = intval($_GPC['owner']);
$owner = $f->getOne($uid);
if (empty($owner)) {
    message('访问错误', $activity['guide'], 'info');
}
if ($owner['uid'] == $user['uid']) {
    header('Location: ' . $this->createMobileUrl('activity', array('actid' => $activity['actid'])));
    exit;
}
require_once MB_ROOT . '/source/Shared.class.php';
$s = new Shared($activity);
if ($_W['ispost']) {
    $input = array();
Example #5
0
 public function doWebRedSend()
 {
     global $_W, $_GPC;
     require_once WWX_FXXT_ROOT . '/class/Fans.class.php';
     $f = new Fans();
     $uid = intval($_GPC['uid']);
     $user = $f->getOne($uid);
     /**FANS:3.根据用户UID或OPENID查询记录中的用户信息**/
     if (empty($user)) {
         exit('错误的访问');
     }
     $ret = $this->redsend($user);
     if (is_error($ret)) {
         exit($ret['message']);
     } else {
         exit('success');
     }
 }
Example #6
0
 public function getTrades($filters, $pindex = 0, $psize = 20, &$total = 0)
 {
     global $_W;
     $condition = '`t`.`uniacid`=:uniacid';
     $pars = array();
     $pars[':uniacid'] = $_W['uniacid'];
     if (!empty($filters['activity'])) {
         $condition .= ' AND `t`.`activity`=:activity';
         $pars[':activity'] = $filters['activity'];
     }
     if (!empty($filters['owner'])) {
         $condition .= ' AND `t`.`uid`=:owner';
         $pars[':owner'] = $filters['owner'];
     }
     if (!empty($filters['nickname'])) {
         $condition .= ' AND `f`.`nickname` LIKE :nickname';
         $pars[':nickname'] = "%{$filters['nickname']}%";
     }
     if (!empty($filters['status'])) {
         if ($filters['status'] == 'valid') {
             $condition .= " AND `t`.`status`!='created'";
         } else {
             $condition .= ' AND `t`.`status`=:status';
             $pars[':status'] = $filters['status'];
         }
     }
     $fields = "`t`.`id`,`f`.`openid`, `f`.`proxy`, `f`.`nickname`, `f`.`gender`, `f`.`state`, `f`.`city`, `f`.`avatar`, `t`.`uid`, `t`.`activity`, `t`.`item`, `t`.`paid`, `t`.`status`, `t`.`created`, `t`.`completed`";
     $sql = "SELECT {$fields} FROM " . tablename('mbrp_trades') . " AS `t` LEFT JOIN " . tablename('mbrp_fans') . " AS `f` ON (`t`.`uid` = `f`.`uid`)";
     $sql .= " WHERE {$condition} ORDER BY `completed` DESC, `created` DESC";
     if ($pindex > 0) {
         $sql = "SELECT COUNT(*) FROM " . tablename('mbrp_trades') . " AS `t` LEFT JOIN " . tablename('mbrp_fans') . " AS `f` ON (`t`.`uid` = `f`.`uid`)";
         $sql .= " WHERE {$condition}";
         $total = pdo_fetchcolumn($sql, $pars);
         $start = ($pindex - 1) * $psize;
         $sql = "SELECT {$fields} FROM" . tablename('mbrp_trades') . " AS `t` LEFT JOIN " . tablename('mbrp_fans') . " AS `f` ON (`t`.`uid` = `f`.`uid`)";
         $sql .= " WHERE {$condition} ORDER BY `completed` DESC, `created` DESC LIMIT {$start},{$psize}";
     }
     $ds = pdo_fetchall($sql, $pars);
     if (!empty($ds)) {
         require_once MB_ROOT . '/source/Fans.class.php';
         $f = new Fans();
         foreach ($ds as &$row) {
             $row['profile'] = $f->getProfile($row['uid']);
         }
     }
     return $ds;
 }
Example #7
0
 public function getRecords($filters, $pindex = 0, $psize = 20, &$total = 0)
 {
     global $_W;
     $condition = '`r`.`uniacid`=:uniacid';
     $pars = array();
     $pars[':uniacid'] = $_W['uniacid'];
     if (!empty($filters['activity'])) {
         $condition .= ' AND `r`.`activity`=:activity';
         $pars[':activity'] = $filters['activity'];
     }
     if (!empty($filters['owner'])) {
         $condition .= ' AND `r`.`uid`=:owner';
         $pars[':owner'] = $filters['owner'];
     }
     if (!empty($filters['nickname'])) {
         $condition .= ' AND `f`.`nickname` LIKE :nickname';
         $pars[':nickname'] = "%{$filters['nickname']}%";
     }
     if (!empty($filters['status'])) {
         $condition .= ' AND `r`.`status`=:status';
         $pars[':status'] = $filters['status'];
     }
     $fields = "`r`.`id`,`f`.`openid`, `f`.`proxy`, `f`.`nickname`, `f`.`gender`, `f`.`state`, `f`.`city`, `f`.`avatar`, `r`.`uid`, `r`.`activity`, `r`.`gift`, `r`.`fee`, `r`.`log`, `r`.`status`, `r`.`created`, `r`.`completed`";
     $sql = "SELECT {$fields} FROM " . tablename('wwx_fxxt_red_records') . " AS `r` LEFT JOIN " . tablename('wwx_fxxt_red_fans') . " AS `f` ON (`r`.`uid` = `f`.`uid`)";
     $sql .= " WHERE {$condition} ORDER BY `completed` DESC, `created` DESC";
     if ($pindex > 0) {
         $sql = "SELECT COUNT(*) FROM " . tablename('wwx_fxxt_red_records') . " AS `r` LEFT JOIN " . tablename('wwx_fxxt_red_fans') . " AS `f` ON (`r`.`uid` = `f`.`uid`)";
         $sql .= " WHERE {$condition}";
         $total = pdo_fetchcolumn($sql, $pars);
         $start = ($pindex - 1) * $psize;
         $sql = "SELECT {$fields} FROM" . tablename('wwx_fxxt_red_records') . " AS `r` LEFT JOIN " . tablename('wwx_fxxt_red_fans') . " AS `f` ON (`r`.`uid` = `f`.`uid`)";
         $sql .= " WHERE {$condition} ORDER BY `completed` DESC, `created` DESC LIMIT {$start},{$psize}";
     }
     $ds = pdo_fetchall($sql, $pars);
     if (!empty($ds)) {
         require_once WWX_FXXT_ROOT . '/class/Gift.class.php';
         require_once WWX_FXXT_ROOT . '/class/Fans.class.php';
         $g = new Gift();
         $f = new Fans();
         foreach ($ds as &$row) {
             $row['gift'] = $g->getOne($row['gift']);
             /**GIFT:1.根据ID查询活动礼品分类**/
             $row['profile'] = $f->getProfile($row['uid']);
             /**FANS:1.根据用户UID查询用户信息**/
         }
     }
     return $ds;
 }
Example #8
0
     }
 }
 public function doMobileAuth()
 {
     global $_GPC, $_W;
     session_start();
     $api = $this->module['config']['api'];
     if (empty($api)) {
         message('系统还未开放');
     }
     $code = $_GPC['code'];
     load()->func('communication');
     $url = "https://api.weixin.qq.com/sns/oauth2/access_token?appid={$api['appid']}&secret={$api['secret']}&code={$code}&grant_type=authorization_code";
     $resp = ihttp_get($url);
     if (is_error($resp)) {
         message('系统错误, 详情: ' . $resp['message']);
     }
     $auth = @json_decode($resp['content'], true);
     if (is_array($auth) && !empty($auth['openid'])) {
         $url = "https://api.weixin.qq.com/sns/userinfo?access_token={$auth['access_token']}&openid={$auth['openid']}&lang=zh_CN";
         $resp = ihttp_get($url);
         if (is_error($resp)) {
             message('系统错误');
         }
         $info = @json_decode($resp['content'], true);
         if (is_array($info) && !empty($info['openid'])) {
             $user = array();
             $user['uniacid'] = $_W['uniacid'];
             $user['openid'] = $info['openid'];
             $user['unionid'] = $info['unionid'];
             $user['nickname'] = $info['nickname'];
             $user['gender'] = $info['sex'];
             $user['city'] = $info['city'];
             $user['state'] = $info['province'];
             $user['avatar'] = $info['headimgurl'];
             $user['country'] = $info['country'];
             if (!empty($user['avatar'])) {
                 $user['avatar'] = rtrim($user['avatar'], '0');
                 $user['avatar'] .= '132';
             }
             require_once MB_ROOT . '/source/Fans.class.php';
             $f = new Fans();
             $f->save($user);
             $_SESSION['__:proxy:openid'] = $user['openid'];
             $forward = $_SESSION['__:proxy:forward'];
             header('Location: ' . $forward);
             exit;
         }
     }
Example #9
0
 /**
  * 通过粉丝组ID 更改粉丝所属组(支持批量).
  *
  * @param Array $ids       粉丝自增ID
  * @param Int   $toGroupId 粉丝组group_id
  */
 public function moveFanGroupByGroupid($accountId, $fromGroupId, $toGroupId)
 {
     //根据粉丝ID查询
     return $this->model->where('account_id', $accountId)->where('group_id', $fromGroupId)->update(['group_id' => $toGroupId]);
 }
Example #10
0
 public function doWebSend()
 {
     global $_W, $_GPC;
     require_once MB_ROOT . '/source/Fans.class.php';
     $f = new Fans();
     $uid = intval($_GPC['uid']);
     $user = $f->getOne($uid);
     if (empty($user)) {
         exit('错误的访问');
     }
     $activity = $this->getActivity(true, array('user' => $user));
     if (is_error($activity)) {
         message($activity['message']);
     }
     $ret = $this->send($user);
     if (is_error($ret)) {
         exit($ret['message']);
     } else {
         exit('success');
     }
 }
Example #11
0
<?php

global $_W, $_GPC;
$user = $this->auth();
$foo = $_GPC['foo'];
$foos = array('profile', 'history');
$foo = in_array($foo, $foos) ? $foo : 'list';
require_once MB_ROOT . '/source/Fans.class.php';
$f = new Fans();
if ($foo == 'profile') {
    exit('success');
    if ($_W['ispost']) {
        if ($_GPC['code'] != $_SESSION['code']) {
            exit('手机验证码不正确');
        }
        $input = array();
        $input['name'] = trim($_GPC['name']);
        $input['phone'] = trim($_GPC['phone']);
        $titles = array();
        $titles['name'] = '姓名';
        $titles['phone'] = '手机号';
        foreach ($input as $k => $v) {
            $r = array();
            $r['uniacid'] = $_W['uniacid'];
            $r['uid'] = $user['uid'];
            $r['name'] = $k;
            $r['title'] = $titles[$k];
            $r['value'] = $v;
            $sql = 'SELECT * FROM ' . tablename('mbrl_profiles') . ' WHERE `uniacid`=:uniacid AND `uid`=:uid AND `name`=:name';
            $pars = array();
            $pars[':uniacid'] = $_W['uniacid'];