<?php
// +----------------------------------------------------------------------
// | WindSNS 国内领先企业级社交开源SNS框架系统
// +----------------------------------------------------------------------
// | Copyright (c) 2017~2020 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
// +----------------------------------------------------------------------
namespace app\index\controller;
use app\common\controller\Frontend;
use think\Config;
use think\Hook;
use think\Db;
use think\Request;


class Shop extends Frontend
{

    protected $noNeedLogin = '*';
    protected $noNeedRight = '*';
    protected $layout = '';
	/**
	 * 协议
	 * @author   Devil
	 * @blog     http://www.weinuo.net
	 * @version  0.0.1
	 * @datetime 2021-1-01
	 */
    public function index()
    {
    
        $this->view->assign('title', __('商城'));
    	$windsnsmallshoplist = Db::name('windsnsmall_shoplist')->
	    alias('a')->join('ws_windsnsmalltype w','a.widsnsmallshopstypeid = w.windsnsmalltypeid') ->
	    where(['widsnsmallshopshotid'=>2,'widsnsmallshopsokid'=>1]) ->
	    order('widsnsmallshopsxuhao', 'desc')->paginate(4); 
	    $page = $windsnsmallshoplist->render();
		$this->assign('windsnsmallshoplist', $windsnsmallshoplist);
    	$windsnsmallshoplista = Db::name('windsnsmall_shoplist')->
	    alias('a')->join('ws_windsnsmalltype w','a.widsnsmallshopstypeid = w.windsnsmalltypeid') ->
	    where(['widsnsmallshopsokid'=>1]) ->
	    order('widsnsmallshopsxuhao', 'desc')->paginate(40); 
	    $page = $windsnsmallshoplista->render();
		$this->assign('windsnsmallshoplista', $windsnsmallshoplista);
        return $this->view->fetch('windsns_shop');
    }

    public function goods()
    {
     $getgoodsid  =  input('get.goodsid'); 
     $pcgoods_banner = Db::name('windsnsmall_shopbanner') -> where(['windsns_mallgoodsid'=>$getgoodsid]) ->select();
     $this->assign('pcgoods_banner', $pcgoods_banner);
     $sqgoodsid   = Db::name('windsnsmall_shoplist')-> where(['windsnsmallshopsid'=>$getgoodsid])->find();
     $worldnames =  $sqgoodsid['widsnsmallshopslittle'];
     $worldtypeid =  $sqgoodsid['widsnsmallshopstypeid'];
     $this->assign('worldnames', $worldnames);
     $this->view->assign('title', __($worldnames));
     $sqgoodstypeinfosid   = Db::name('windsnsmall_shoplist')->where(['windsnsmallshopsid'=>$getgoodsid,'widsnsmallshopstypeid'=>$worldtypeid,])->find();
     $sqgoodsokid   = Db::name('windsnsmall_shoplist')->where(['windsnsmallshopsid'=>$getgoodsid,'widsnsmallshopsokid'=>1])->find();
     $sqtypeid   = Db::name('windsnsmalltype')->where(['windsnsmalltypeid'=>$worldtypeid])->find();
        $windsnsshopgoodsinfo = Db::name('windsnsmall_shoplist')->
	    alias('a')->join('ws_windsnsmalltype w','a.widsnsmallshopstypeid = w.windsnsmalltypeid') ->
	    where(['windsnsmallshopsid'=>$getgoodsid,'widsnsmallshopsokid'=>1]) -> select(); 
		$this->assign('windsnsshopgoodsinfo', $windsnsshopgoodsinfo);
		if(!$sqgoodsid){
		 	return $this->view->fetch('windsnserrors_nogoodshop');
		  }elseif(!$sqtypeid){
	     	return $this->view->fetch('windsnserrors_nogoodstype');
	     }elseif(!$sqgoodstypeinfosid){
	     	return $this->view->fetch('windsnserrors_nogoodshop');
	     }elseif(!$sqgoodsokid){
	     	return $this->view->fetch('windsnserrors_nogoodshopxiajia');
	     }else{

	     	 $liulansum = Db::name('windsnsmall_shoplist')-> where(['windsnsmallshopsid'=>$getgoodsid])->setInc('widsnsmallshopsliulansum', 1);//浏览次数+1
	     	 return $this->view->fetch('windsns_shopgoods');
	     }

    	
    }


}
