protected function _initialize() { //初始化积分 $loginstatus = is_login(); if ($loginstatus) { //用户自动升级 $userid = session('P.id'); Credits::init($userid); //更新用户资料 $newinfo = api('Wxuser/get_info', array('id' => $userid)); if (!empty($newinfo)) { session('P', null); session('P', $newinfo); } } //初始化主题 参数 A('Amangotheme')->init_config(); //初始化公众号网站配置 A('Amangotheme')->get_account(); global $_K; $locationurl = __SELF__; if ($_K['DEFAULT']['account_getuserinfo'] != '0') { A('Amangotheme')->weixin_get_info($locationurl); } if (!empty($_GET['ucusername']) && !empty($_GET['ucpassword']) && $loginstatus == 0) { $this->auto_login($_GET['ucusername'], $_GET['ucpassword']); //判断是否存在 $replace_list = array(); $urldepr = C('URL_PATHINFO_DEPR'); if (!empty($_GET['ucusername'])) { $replace_list[$urldepr . 'ucusername' . $urldepr . $_GET['ucusername']] = ''; } if (!empty($_GET['ucpassword'])) { $replace_list[$urldepr . 'ucpassword' . $urldepr . $_GET['ucpassword']] = ''; } //提取后缀前 $redirect_url = strtr($locationurl, $replace_list); redirect($redirect_url); } if (!empty($param)) { $suffix = C('TMPL_TEMPLATE_SUFFIX'); $parse_url = explode($suffix, $locationurl); redirect($parse_url[0] . $suffix); } }
public function vip_home() { $vipinfo = $this->getViplist(); $uid = session('user_auth.uid'); $this->assign('nickname', $vipinfo[0]); $this->assign('Title', '我的积分'); $this->assign('score', Credits::getUserCredits($uid)); $this->assign('name', $vipinfo[1]); $this->assign('progress', $vipinfo[3]); self::setHeader(true); $this->display(); }
public function gethongbao() { $this->is_login(); $userinfo = session('P'); //读取微信红包领取配置 $wxpay_config = $this->ag_hongbao_config(); //是否限制红包兑换 if (empty($wxpay_config['hb_dh_auth'])) { $this->error('亲,暂时无法领取红包~'); } $wxpay_user_score = $wxpay_config['hb_leiji'][$userinfo['cate_group']]; //用户组是否可以领红包 if (empty($wxpay_user_score)) { $this->error('亲,您所在的用户组暂时无法领取红包~'); } //兑换比例因子 $id = I('get.id'); $time = time(); $map['start_time'] = array('lt', $time); $map['end_time'] = array('gt', $time); $map['credits'] = array('gt', 1); $map['status'] = 1; $map['id'] = $id; $info = M('wxpay_hongbao')->where($map)->find(); //判断今日红包兑换面值是否超过 $nowdate = strtotime(date('Y-m-d')); $oldmap['create_time'] = array('egt', $nowdate); $oldmap['userid'] = $userinfo['id']; $all_value = M('wxpay_userhongbao')->where($oldmap)->field('hb_value')->sum('hb_value'); $now_value = $info['value'] + $all_value; if ($wxpay_user_score < $now_value) { $this->error('亲,改天再来吧,您今天兑换面值已经超过咯~'); } $socre = Credits::getUserCredits($userinfo['id']); $socre = empty($socre) ? 0 : $socre; //兑换积分 if (!empty($info) && $info['credits'] <= $socre) { $nowscore = $socre - $info['credits']; $data['userid'] = $userinfo['id']; $data['hongbaoid'] = $info['id']; //获取红包详情 $data['hb_star'] = $info['start_time']; $data['hb_end'] = $info['end_time']; $data['hb_title'] = $info['title']; $data['hb_pic'] = $info['img']; $data['hb_value'] = $info['value']; $data['type'] = '1'; $data['create_time'] = time(); $data['status'] = 1; //TODO 统一积分接口 api('Wxuser/update_info_id', array('id' => $userinfo['id'], 'data' => array('score' => $nowscore))); M('wxpay_userhongbao')->add($data); $this->success('恭喜您,兑换红包成功', U('hongbaoprofile', array('status' => 1))); } else { $this->error('该红包已经过期咯~'); } }