<?php // +---------------------------------------------------------------------- // | bronet [ 以客户为中心 以奋斗者为本 ] // +---------------------------------------------------------------------- // | Copyright (c) 2013-2017 http://www.bronet.cn All rights reserved. // +---------------------------------------------------------------------- // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) // +---------------------------------------------------------------------- namespace app\portal\controller; use app\portal\service\LikeService; use cmf\controller\HomeBaseController; use cmf\controller\WeChatBaseController; use EasyWeChat\Foundation\Application; use think\Db; class UserController extends WeChatBaseController { public function _initialize() { parent::_initialize(); $this->checkWeChatUserLogin(); } //兑奖记录 public function prizeRecord(){ $status=$this->request->param('status'); $where['p.status']=!empty($status)?$status:0; $data=Db::name('prize_order') ->alias('po') ->join('prize p'.'po.prize_id=p.id') ->where($where) ->select(); $this->assign('list',$data); return $this->fetch(); } //个人首页 public function userIndex(){ $last = Db::name('users_score_log')->where(['users_id' => session('wechat_user')['users_id'], 'action' => '签到'])->max('create_time'); if (date('Ymd', time()) > date('Ymd', $last)) { $is_qiandao=0; }else{ $is_qiandao=1; } $data=Db::name('users')->where('id',session('wechat_user')['users_id'])->find(); $this->assign('list',$data); $this->assign('qiandao',$is_qiandao); return $this->fetch(); } public function scoreRecord(){ $score=Db::name('users')->where('id',session('wechat_user')['users_id'])->find()['score']; $data=Db::name('users_score_log')->where('users_id',session('wechat_user')['users_id'])->select(); $this->assign('score',$score); $this->assign('list',$data); return $this->fetch(); } //每日签到功能 public function qiandao(){ $last = Db::name('users_score_log')->where(['users_id' => session('wechat_user')['users_id'], 'action' => '签到'])->max('create_time'); if (date('Ymd', time()) > date('Ymd', $last)) { $data['score'] = 10; $data['users_id'] = session('users_id'); $data['create_time'] = time(); $data['action'] = '签到'; Db::name('users_score_log')->insert($data); Db::name('users')->where('id', session('wechat_user')['users_id'])->setInc('score', 10); return 1; } else { return 0; } } }