<?php
// +----------------------------------------------------------------------
// | WindSNS 、微版本 :国内领先企业级社交开源SNS框架系统
// +----------------------------------------------------------------------
// | Copyright (c) 2017~2028 http://windsns.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: 常州微诺信息科技有限公司 http://www.weinuo.net
// +----------------------------------------------------------------------
// | E-mail: open@weinuo.net
// +----------------------------------------------------------------------
// | 微信客服: weinuogroup
// +----------------------------------------------------------------------
namespace app\index\controller;
use app\common\controller\Frontend;
use think\Config;
use think\Hook;
use think\Db;
use think\Request;

class Activities extends Frontend
{

    protected $noNeedLogin = '*';
    protected $noNeedRight = '*';
    protected $layout = '';
	/**
	 * 协议
	 * @author   常州微诺信息科技有限公司
	 * @blog     http://www.weinuo.net
	 * @version  0.0.1
	 * @datetime 2020-12-13
	 */
    public function index()
    {
    	$this->view->assign('title', __('活动'));
       
        $windsnsactivitysum = Db::name('windsnsactivity')->count();//活动总发布数量
  	    $this->assign('windsnsactivitysum', $windsnsactivitysum);
       
       
        $windsnsactivitylist = Db::name('windsnsactivity')->
        alias('a')->join('ws_windsnsactivity_types w','a.windsnsactivitytypenumber = w.activitytypeid') ->
        order('windsnsactivityshunxu', 'desc')->paginate(20); //列表
        $page = $windsnsactivitylist->render();
    	$this->assign('windsnsactivitylist', $windsnsactivitylist);
        $this->assign('page', $page);
       if($windsnsactivitysum > 0 or $windsnsactivitysum == 1){
        	return $this->view->fetch('windsns_index');
       }else{
        	return $this->view->fetch('windsns_activitiesnull');
        }
       
    
    }
    
    
    public function hdbm()//报名中
    {
    	$this->view->assign('title', __('活动'));
       
        $windsnsactivitysum = Db::name('windsnsactivity')->count();//活动总发布数量
  	    $this->assign('windsnsactivitysum', $windsnsactivitysum);
       
       
        $windsnsactivitylist = Db::name('windsnsactivity')->
        alias('a')->join('ws_windsnsactivity_types w','a.windsnsactivitytypenumber = w.activitytypeid') ->
        
        where(['windsnsactivityopentype'=>1]) ->
        order('windsnsactivityshunxu', 'desc')->paginate(20); //列表
        $page = $windsnsactivitylist->render();
    	$this->assign('windsnsactivitylist', $windsnsactivitylist);
        $this->assign('page', $page);
       if($windsnsactivitysum > 0 or $windsnsactivitysum == 1){
        	return $this->view->fetch('windsns_activitiesbm');
       }else{
        	return $this->view->fetch('windsns_activitiesnull');
       }
    
    }
    
        public function hdbmnow()//已经开始
    {
    	$this->view->assign('title', __('活动'));
       
        $windsnsactivitysum = Db::name('windsnsactivity')->count();//活动总发布数量
  	    $this->assign('windsnsactivitysum', $windsnsactivitysum);
       
       
        $windsnsactivitylist = Db::name('windsnsactivity')->
        alias('a')->join('ws_windsnsactivity_types w','a.windsnsactivitytypenumber = w.activitytypeid') ->
        
        where(['windsnsactivityopentype'=>2]) ->
        order('windsnsactivityshunxu', 'desc')->paginate(20); //列表
        $page = $windsnsactivitylist->render();
    	$this->assign('windsnsactivitylist', $windsnsactivitylist);
        $this->assign('page', $page);
       if($windsnsactivitysum > 0 or $windsnsactivitysum == 1){
        	return $this->view->fetch('windsns_activitiesbmnow');
       }else{
        	return $this->view->fetch('windsns_activitiesnull');
       }
    
    }
    
        public function hdbmnend()//已经结束
    {
    	$this->view->assign('title', __('活动'));
       
        $windsnsactivitysum = Db::name('windsnsactivity')->count();//活动总发布数量
  	    $this->assign('windsnsactivitysum', $windsnsactivitysum);
       
       
        $windsnsactivitylist = Db::name('windsnsactivity')->
        alias('a')->join('ws_windsnsactivity_types w','a.windsnsactivitytypenumber = w.activitytypeid') ->
        
        where(['windsnsactivityopentype'=>3]) ->
        order('windsnsactivityshunxu', 'desc')->paginate(20); //列表
        $page = $windsnsactivitylist->render();
    	$this->assign('windsnsactivitylist', $windsnsactivitylist);
        $this->assign('page', $page);
       if($windsnsactivitysum > 0 or $windsnsactivitysum == 1){
        	return $this->view->fetch('windsns_activitiesbmend');
       }else{
        	return $this->view->fetch('windsns_activitiesnull');
       }
    
    }
    
	/**
	 * 协议
	 * @author   常州微诺信息科技有限公司
	 * @blog     http://www.weinuo.net
	 * @version  0.0.1
	 * @datetime 2020-03-03
	 */
    public function windsnsactivitiesinfos()
    {

        $getactivitiesypeid  =  input('get.activitiestype');
    	$getactivitiesid  =  input('get.activitiesid'); 
    	
    	$sqtypeid   = Db::name('windsnsactivity_types')->where(['activitytypeid'=>$getactivitiesypeid])->find();//查询该栏目类型ID是否存在
    	$sqactivitiesid = Db::name('windsnsactivity')->where(['windsnsactivityid'=>$getactivitiesid])->find();//查询该文章ID是否存在
    	
    	
    	$sqinfosid = Db::name('windsnsactivity')->where(['windsnsactivityid'=>$getactivitiesid,'windsnsactivitytypenumber'=>$getactivitiesypeid])->find();//查询该文章对应的该栏目信息是否存在
    	$worldnames =  $sqinfosid['windsnsactivitylittle'];
    	$this->view->assign('title', __($worldnames));
  
    	//已经报名的用户打印
    	$windsns_users = Db::name('windsnsactivity_paylist')->
    	alias('a')->join('ws_user w','a.user_id = w.id') ->
    	where(['windsns_hdid'=>$getactivitiesid,'windsns_hdid'=>$getactivitiesid,'windsns_hdbaomingzhuangtai'=>1])->order('user_id', 'desc')->select(); //用户列表
    	$this->assign('windsns_users', $windsns_users);
    	
    	
    	
    	if(!$sqtypeid){
			return $this->view->fetch('windsns_activitiesinfoserrorsa');
			}elseif(!$sqactivitiesid){
			return $this->view->fetch('windsns_activitiesinfoserrorsb');
			}elseif(!$sqinfosid){
			return $this->view->fetch('windsns_activitiesinfoserrorsc');
			}else{
			$sqlliulan = Db::name('windsnsactivity')->where('windsnsactivityid',$getactivitiesid)->setInc('windsnsactivityliulanshu', 1);//浏览次数+1
		    $windsns_activityinfos = Db::name('windsnsactivity')-> alias('a')->join('ws_windsnsactivity_types w','a.windsnsactivitytypenumber = w.activitytypeid') -> where(['windsnsactivityid'=>$getactivitiesid,'windsnsactivitytypenumber'=>$getactivitiesypeid])->select();//打印这个模板产品的信息--- phpwind模板
            $this->assign('windsns_activityinfos', $windsns_activityinfos);

				return $this->view->fetch('windsns_activitiesinfos');
			}
      
    }

	/**
	 * 协议
	 * @author   常州微诺信息科技有限公司
	 * @blog     http://www.weinuo.net
	 * @version  0.0.1
	 * @datetime 2020-03-03
	 */
}
