You've already forked qlg.tsgz.moe
							
							Init Repo
This commit is contained in:
		
							
								
								
									
										76
									
								
								hyhproject/home/controller/Base.php
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										76
									
								
								hyhproject/home/controller/Base.php
									
									
									
									
									
										Executable file
									
								
							@@ -0,0 +1,76 @@
 | 
			
		||||
<?php
 | 
			
		||||
namespace wstmart\home\controller;
 | 
			
		||||
/**
 | 
			
		||||
 * ============================================================================
 | 
			
		||||
 * 基础控制器
 | 
			
		||||
 */
 | 
			
		||||
use think\Controller;
 | 
			
		||||
class Base extends Controller {
 | 
			
		||||
    protected $is_icp = 1;
 | 
			
		||||
	public function __construct(){
 | 
			
		||||
		
 | 
			
		||||
		parent::__construct();
 | 
			
		||||
		$this->assign("v",WSTConf('CONF.wstVersion')."_".WSTConf('CONF.wstPCStyleId'));
 | 
			
		||||
		
 | 
			
		||||
		hook('homeControllerBase');
 | 
			
		||||
		
 | 
			
		||||
		if(WSTConf('CONF.seoMallSwitch')==0){
 | 
			
		||||
			$this->redirect('home/switchs/index');
 | 
			
		||||
			exit;
 | 
			
		||||
		}
 | 
			
		||||
        $this->assign('is_icp',$this->is_icp);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	protected function fetch($template = '', $vars = [], $replace = [], $config = [])
 | 
			
		||||
    {
 | 
			
		||||
    	$style = WSTConf('CONF.wsthomeStyle')?WSTConf('CONF.wsthomeStyle'):'default';
 | 
			
		||||
    	$replace['__STYLE__'] = str_replace('/index.php','',\think\Request::instance()->root()).'/hyhproject/home/view/'.WSTConf('CONF.wsthomeStyle');
 | 
			
		||||
        return $this->view->fetch($style."/".$template, $vars, $replace, $config);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * 上传图片
 | 
			
		||||
	 */
 | 
			
		||||
	public function uploadPic(){
 | 
			
		||||
		return WSTUploadPic(0);
 | 
			
		||||
	}
 | 
			
		||||
	/**
 | 
			
		||||
    * 编辑器上传文件
 | 
			
		||||
    */
 | 
			
		||||
    public function editorUpload(){
 | 
			
		||||
           return WSTEditUpload(0);
 | 
			
		||||
    }
 | 
			
		||||
	
 | 
			
		||||
	/**
 | 
			
		||||
	 * 获取验证码
 | 
			
		||||
	 */
 | 
			
		||||
	public function getVerify(){
 | 
			
		||||
		WSTVerify();
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// 登录验证方法--用户
 | 
			
		||||
    protected function checkAuth(){
 | 
			
		||||
       	$USER = session('WST_USER');
 | 
			
		||||
        if(empty($USER)){
 | 
			
		||||
        	if(request()->isAjax()){
 | 
			
		||||
        		die('{"status":-999,"msg":"您还未登录"}');
 | 
			
		||||
        	}else{
 | 
			
		||||
        		$this->redirect('home/users/login');
 | 
			
		||||
        		exit;
 | 
			
		||||
        	}
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    //登录验证方法--商家
 | 
			
		||||
    protected function checkShopAuth(){
 | 
			
		||||
       	$USER = session('WST_USER');
 | 
			
		||||
        if(empty($USER) || $USER['userType']!=1){
 | 
			
		||||
        	if(request()->isAjax()){
 | 
			
		||||
        		die('{"status":-999,"msg":"您还未登录"}');
 | 
			
		||||
        	}else{
 | 
			
		||||
        		$this->redirect('home/shops/login');
 | 
			
		||||
        		exit;
 | 
			
		||||
        	}
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										706
									
								
								hyhproject/home/controller/Goods.php
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										706
									
								
								hyhproject/home/controller/Goods.php
									
									
									
									
									
										Executable file
									
								
							@@ -0,0 +1,706 @@
 | 
			
		||||
<?php
 | 
			
		||||
namespace wstmart\home\controller;
 | 
			
		||||
use wstmart\home\model\Goods as M;
 | 
			
		||||
use wstmart\common\model\Goods as CM;
 | 
			
		||||
/**
 | 
			
		||||
 * ============================================================================
 | 
			
		||||
 * 商品控制器
 | 
			
		||||
 */
 | 
			
		||||
class Goods extends Base{
 | 
			
		||||
    protected $beforeActionList = [
 | 
			
		||||
          'checkShopAuth' =>  ['except'=>'search,lists,detail,historybygoods,contrastgoods,contrastdel,contrast']
 | 
			
		||||
    ];
 | 
			
		||||
    /**
 | 
			
		||||
      * 批量删除商品
 | 
			
		||||
      */
 | 
			
		||||
     public function batchDel(){
 | 
			
		||||
        $m = new M();
 | 
			
		||||
        return $m->batchDel();
 | 
			
		||||
     }
 | 
			
		||||
    /**
 | 
			
		||||
     * 修改商品库存/价格
 | 
			
		||||
     */
 | 
			
		||||
    public function editGoodsBase(){
 | 
			
		||||
        $m = new M();
 | 
			
		||||
        return $m->editGoodsBase();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * 修改商品状态
 | 
			
		||||
	 */
 | 
			
		||||
	public function changSaleStatus(){
 | 
			
		||||
		$m = new M();
 | 
			
		||||
		return $m->changSaleStatus();
 | 
			
		||||
	}
 | 
			
		||||
	/**
 | 
			
		||||
	 * 修改商品店长推荐状态
 | 
			
		||||
	 */
 | 
			
		||||
	public function changStoreRecom(){
 | 
			
		||||
		$m = new M();
 | 
			
		||||
		return $m->changStoreRecom();
 | 
			
		||||
	}
 | 
			
		||||
	/**
 | 
			
		||||
	 * 批量修改商品状态 新品/精品/热销/推荐
 | 
			
		||||
	 */
 | 
			
		||||
	public function changeGoodsStatus(){
 | 
			
		||||
		$m = new M();
 | 
			
		||||
		return $m->changeGoodsStatus();
 | 
			
		||||
	}
 | 
			
		||||
	/**
 | 
			
		||||
	 * 批量修改商品状态 店长推荐
 | 
			
		||||
	 */
 | 
			
		||||
	public function changeStoreStatus(){
 | 
			
		||||
		$m = new M();
 | 
			
		||||
		return $m->changeStoreStatus();
 | 
			
		||||
	}
 | 
			
		||||
    /**
 | 
			
		||||
    *   批量上(下)架
 | 
			
		||||
    */
 | 
			
		||||
    public function changeSale(){
 | 
			
		||||
        $m = new M();
 | 
			
		||||
        return $m->changeSale();
 | 
			
		||||
    }
 | 
			
		||||
   /**
 | 
			
		||||
    *  上架商品列表
 | 
			
		||||
    */
 | 
			
		||||
	public function sale(){
 | 
			
		||||
		return $this->fetch('shops/goods/list_sale');
 | 
			
		||||
	}
 | 
			
		||||
	/**
 | 
			
		||||
	 * 获取上架商品列表
 | 
			
		||||
	 */
 | 
			
		||||
	public function saleByPage(){
 | 
			
		||||
		$m = new M();
 | 
			
		||||
		$rs = $m->saleByPage();
 | 
			
		||||
		$rs['status'] = 1;
 | 
			
		||||
		return $rs;
 | 
			
		||||
	}
 | 
			
		||||
	/**
 | 
			
		||||
	 * 仓库中商品
 | 
			
		||||
	 */
 | 
			
		||||
    public function store(){
 | 
			
		||||
		return $this->fetch('shops/goods/list_store');
 | 
			
		||||
	}
 | 
			
		||||
    /**
 | 
			
		||||
	 * 审核中的商品
 | 
			
		||||
	 */
 | 
			
		||||
    public function audit(){
 | 
			
		||||
		return $this->fetch('shops/goods/list_audit');
 | 
			
		||||
	}
 | 
			
		||||
	/**
 | 
			
		||||
	 * 获取审核中的商品
 | 
			
		||||
	 */
 | 
			
		||||
    public function auditByPage(){
 | 
			
		||||
		$m = new M();
 | 
			
		||||
		$rs = $m->auditByPage();
 | 
			
		||||
		$rs['status'] = 1;
 | 
			
		||||
		return $rs;
 | 
			
		||||
	}
 | 
			
		||||
	/**
 | 
			
		||||
	 * 获取仓库中的商品
 | 
			
		||||
	 */
 | 
			
		||||
    public function storeByPage(){
 | 
			
		||||
		$m = new M();
 | 
			
		||||
		$rs = $m->storeByPage();
 | 
			
		||||
		$rs['status'] = 1;
 | 
			
		||||
		return $rs;
 | 
			
		||||
	}
 | 
			
		||||
	/**
 | 
			
		||||
	 * 违规商品
 | 
			
		||||
	 */
 | 
			
		||||
    public function illegal(){
 | 
			
		||||
		return $this->fetch('shops/goods/list_illegal');
 | 
			
		||||
	}
 | 
			
		||||
	/*
 | 
			
		||||
     * 设置商品特定价格
 | 
			
		||||
     * */
 | 
			
		||||
	public function limitPrice(){
 | 
			
		||||
		$shopId=(int)session('WST_USER.shopId');
 | 
			
		||||
		$where['shopId'] = $shopId;
 | 
			
		||||
		$where['goodsStatus'] = 1;
 | 
			
		||||
		$where['dataFlag'] = 1;
 | 
			
		||||
		$where['isSale'] = 1;
 | 
			
		||||
		if (Request()->isPost()) {
 | 
			
		||||
			$goodsType = input('goodsType');
 | 
			
		||||
			if ($goodsType != '') $where['goodsType'] = (int)$goodsType;
 | 
			
		||||
			$c1Id = (int)input('cat1');
 | 
			
		||||
			$c2Id = (int)input('cat2');
 | 
			
		||||
			$goodsName = input('goodsName');
 | 
			
		||||
			if ($goodsName != '') {
 | 
			
		||||
				$where['goodsName'] = ['like', "%$goodsName%"];
 | 
			
		||||
			}
 | 
			
		||||
			if ($c2Id != 0 && $c1Id != 0) {
 | 
			
		||||
				$where['shopCatId2'] = $c2Id;
 | 
			
		||||
			} else if ($c1Id != 0) {
 | 
			
		||||
				$where['shopCatId1'] = $c1Id;
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		$lists=db('goods')->where($where)->field('goodsId,goodsName,goodsType')->select();
 | 
			
		||||
		//dump($lists);
 | 
			
		||||
		if (Request()->isAjax()) {
 | 
			
		||||
			//dump($lists);
 | 
			
		||||
			exit(json_encode(WSTReturn('',1,$lists)));
 | 
			
		||||
		}
 | 
			
		||||
		$this->assign('lists',$lists);
 | 
			
		||||
		return $this->fetch('shops/goods/list_limitprice');
 | 
			
		||||
	}
 | 
			
		||||
	//获取商品货号
 | 
			
		||||
	public function getGoodsProduct(){
 | 
			
		||||
		$goodsId = (int)input('goodsId');
 | 
			
		||||
		$res['specs'] = db('goods_specs')->where(['goodsId'=>$goodsId])->field('productNo,specIds')->select();
 | 
			
		||||
		$res['goods'] = db('goods')->where(['goodsId'=>$goodsId])->field('marketPrice')->find();
 | 
			
		||||
		// dump($res);die;
 | 
			
		||||
		exit(json_encode($res));
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	//获取商品规格
 | 
			
		||||
	public function getGoodsSpecs(){
 | 
			
		||||
		$productNo = input('productNo');
 | 
			
		||||
		$res = db('goods_specs')->where(['productNo'=>$productNo])->field('specIds,marketPrice')->find();
 | 
			
		||||
		$specs = explode(':',$res['specIds']);
 | 
			
		||||
		$data = db('spec_items')->where(['itemId'=>['in',$specs]])->select();
 | 
			
		||||
		$rs['itemName'] = implode(',',array_column($data,'itemName'));
 | 
			
		||||
		$rs['marketPrice'] = $res['marketPrice'];
 | 
			
		||||
		exit(json_encode($rs));
 | 
			
		||||
 | 
			
		||||
	}
 | 
			
		||||
	/**
 | 
			
		||||
	 * 获取违规的商品
 | 
			
		||||
	 */
 | 
			
		||||
	public function illegalByPage(){
 | 
			
		||||
		$m = new M();
 | 
			
		||||
		$rs = $m->illegalByPage();
 | 
			
		||||
		$rs['status'] = 1;
 | 
			
		||||
		return $rs;
 | 
			
		||||
	}
 | 
			
		||||
	/**
 | 
			
		||||
	 * 获取已设置限时价格的商品
 | 
			
		||||
	 */
 | 
			
		||||
	public function limitPriceByPage(){
 | 
			
		||||
		$m = new M();
 | 
			
		||||
		$rs = $m->limitPriceByPage();
 | 
			
		||||
		$rs['status'] = 1;
 | 
			
		||||
		return $rs;
 | 
			
		||||
	}
 | 
			
		||||
	/**
 | 
			
		||||
	 * 获取指定显示价格的商品的商品
 | 
			
		||||
	 */
 | 
			
		||||
	public function getLimitGoods(){
 | 
			
		||||
		$m = new M();
 | 
			
		||||
		$rs = $m->getLimitGoods();
 | 
			
		||||
		return $rs;
 | 
			
		||||
	}
 | 
			
		||||
	/**
 | 
			
		||||
	 * 跳去新增限时价格商品页面
 | 
			
		||||
	 */
 | 
			
		||||
	public function addLimitGoods(){
 | 
			
		||||
		$m = new M();
 | 
			
		||||
		$rs = $m->addLimitGoods();
 | 
			
		||||
		return $rs;
 | 
			
		||||
	}
 | 
			
		||||
	/**
 | 
			
		||||
	 * 跳去编辑限时价格商品页面
 | 
			
		||||
	 */
 | 
			
		||||
	public function editLimitGoods(){
 | 
			
		||||
		$m = new M();
 | 
			
		||||
		$rs = $m->editLimitGoods();
 | 
			
		||||
		return $rs;
 | 
			
		||||
	}
 | 
			
		||||
	/**
 | 
			
		||||
	 * 删除显示价格商品
 | 
			
		||||
	 */
 | 
			
		||||
	public function delLimitGoods(){
 | 
			
		||||
		$m = new M();
 | 
			
		||||
		$rs = $m->delLimitGoods();
 | 
			
		||||
		return $rs;
 | 
			
		||||
	}
 | 
			
		||||
	/**
 | 
			
		||||
	 * 跳去新增页面
 | 
			
		||||
	 */
 | 
			
		||||
    public function add(){
 | 
			
		||||
    	$m = new M();
 | 
			
		||||
    	$object = $m->getEModel('goods');
 | 
			
		||||
        $shopId=(int)session('WST_USER.shopId');
 | 
			
		||||
  //       $object['pay']=db('shop_pay')->where(['shopId'=>$shopId,'status'=>1])->find();
 | 
			
		||||
		// $object['isEct']=0;
 | 
			
		||||
        $object['ectPayRatio'] = db('payments')->where(['payCode'=>'ect'])->value('payRatio');
 | 
			
		||||
    	$object['goodsSn'] = WSTGoodsNo();
 | 
			
		||||
    	$object['productNo'] = WSTGoodsNo();
 | 
			
		||||
    	$object['goodsImg'] = WSTConf('CONF.goodsLogo');
 | 
			
		||||
		$object['ectPay']=0;//db('goods')->alias('g')->join('goods_ectpay ge','ge.goodsId=g.goodsId','left')->value('ectPay');
 | 
			
		||||
        $object['alone'] =0;
 | 
			
		||||
        $object['basicsMoney'] = 0;
 | 
			
		||||
        // $aloneShop = db('alone_shops')->alias('as')->join('__SHOPS__ s','as.shopId=s.shopId')->where(['as.dataFlag'=>'1','as.shopId'=>$shopId])->value('as.shopId');
 | 
			
		||||
        // if($aloneShop){
 | 
			
		||||
        //     $object['alone'] =1;
 | 
			
		||||
        // }
 | 
			
		||||
		//dump($object); 
 | 
			
		||||
    	$data = ['object'=>$object,'src'=>'add'];
 | 
			
		||||
    	return $this->fetch('shops/goods/edit',$data);
 | 
			
		||||
    } 
 | 
			
		||||
    
 | 
			
		||||
    /**
 | 
			
		||||
     * 新增商品
 | 
			
		||||
     */
 | 
			
		||||
    public function toAdd(){
 | 
			
		||||
    	$m = new M();
 | 
			
		||||
    	return $m->add();
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    /**
 | 
			
		||||
     * 跳去编辑页面
 | 
			
		||||
     */
 | 
			
		||||
    public function edit(){
 | 
			
		||||
    	$m = new M();
 | 
			
		||||
    	$object = $m->getById(input('get.id'));
 | 
			
		||||
		$shopId=(int)session('WST_USER.shopId');
 | 
			
		||||
		// $object['pay']=db('shop_pay')->where(['shopId'=>$shopId,'status'=>1])->find();
 | 
			
		||||
		// //$object['pay']=1;
 | 
			
		||||
		// if($object['pay']){
 | 
			
		||||
		// 	$object['isEct']=db('goods_pay')->where('goodsId',$object['goodsId'])->value('ectPay');
 | 
			
		||||
		// 	//$object['isOnline']=db('goods_pay')->where('goodsId',$object['goodsId'])->value('onlinePay');
 | 
			
		||||
		// }
 | 
			
		||||
        $object['ectPayRatio'] = db('payments')->where(['payCode'=>'ect'])->value('payRatio');
 | 
			
		||||
    	if($object['goodsImg']=='')$object['goodsImg'] = WSTConf('CONF.goodsLogo');
 | 
			
		||||
        $object['ectPay']=0;
 | 
			
		||||
        if($object['basicsMoney'] == '') $object['basicsMoney'] = 0;
 | 
			
		||||
        $object['alone'] =0;
 | 
			
		||||
        // $aloneShop = db('alone_shops')->alias('as')->join('__SHOPS__ s','as.shopId=s.shopId')->where(['as.dataFlag'=>'1','as.shopId'=>$shopId])->value('as.shopId');
 | 
			
		||||
        // if($aloneShop){
 | 
			
		||||
        //     $object['alone'] =1;
 | 
			
		||||
        // }
 | 
			
		||||
    	$data = ['object'=>$object,'src'=>input('src')];
 | 
			
		||||
    	return $this->fetch('shops/goods/edit',$data);
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    /**
 | 
			
		||||
     * 编辑商品
 | 
			
		||||
     */
 | 
			
		||||
    public function toEdit(){
 | 
			
		||||
    	$m = new M();
 | 
			
		||||
    	return $m->edit();
 | 
			
		||||
    }
 | 
			
		||||
    /**
 | 
			
		||||
     * 删除商品
 | 
			
		||||
     */
 | 
			
		||||
    public function del(){
 | 
			
		||||
    	$m = new M();
 | 
			
		||||
    	return $m->del();
 | 
			
		||||
    }
 | 
			
		||||
    /**
 | 
			
		||||
     * 获取商品规格属性
 | 
			
		||||
     */
 | 
			
		||||
    public function getSpecAttrs(){
 | 
			
		||||
    	$m = new M();
 | 
			
		||||
    	return $m->getSpecAttrs();
 | 
			
		||||
    }
 | 
			
		||||
    /**
 | 
			
		||||
     * 进行商品搜索
 | 
			
		||||
     */
 | 
			
		||||
    public function search(){
 | 
			
		||||
    	//获取商品记录
 | 
			
		||||
    	$m = new M();
 | 
			
		||||
    	$data = [];
 | 
			
		||||
    	$data['isStock'] = Input('isStock/d');
 | 
			
		||||
    	$data['isNew'] = Input('isNew/d');
 | 
			
		||||
        $data['isFreeShipping'] = input('isFreeShipping/d');
 | 
			
		||||
    	$data['orderBy'] = Input('orderBy/d');
 | 
			
		||||
    	$data['order'] = Input('order/d',1);
 | 
			
		||||
    	$data['keyword'] = input('keyword');
 | 
			
		||||
    	$data['sprice'] = Input('sprice/d');
 | 
			
		||||
    	$data['eprice'] = Input('eprice/d');
 | 
			
		||||
 | 
			
		||||
        $data['areaId'] = (int)Input('areaId');
 | 
			
		||||
        $aModel = model('home/areas');
 | 
			
		||||
 | 
			
		||||
        // 获取地区
 | 
			
		||||
        $data['area1'] = $data['area2'] = $data['area3'] = $aModel->listQuery(); // 省级
 | 
			
		||||
 | 
			
		||||
        // 如果有筛选地区 获取上级地区信息
 | 
			
		||||
        if($data['areaId']!==0){
 | 
			
		||||
            $areaIds = $aModel->getParentIs($data['areaId']);
 | 
			
		||||
            /*
 | 
			
		||||
              2 => int 440000
 | 
			
		||||
              1 => int 440100
 | 
			
		||||
              0 => int 440106
 | 
			
		||||
            */
 | 
			
		||||
            $selectArea = [];
 | 
			
		||||
            $areaName = '';
 | 
			
		||||
            foreach($areaIds as $k=>$v){
 | 
			
		||||
                $a = $aModel->getById($v);
 | 
			
		||||
                $areaName .=$a['areaName'];
 | 
			
		||||
                $selectArea[] = $a;
 | 
			
		||||
            }
 | 
			
		||||
            // 地区完整名称
 | 
			
		||||
            $selectArea['areaName'] = $areaName;
 | 
			
		||||
            // 当前选择的地区
 | 
			
		||||
            $data['areaInfo'] = $selectArea;
 | 
			
		||||
 | 
			
		||||
            $data['area2'] = $aModel->listQuery($areaIds[2]); // 广东的下级
 | 
			
		||||
 
 | 
			
		||||
            $data['area3'] = $aModel->listQuery($areaIds[1]); // 广州的下级
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
    	$data['goodsPage'] = $m->pageQuery();
 | 
			
		||||
    	return $this->fetch("goods_search",$data);
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    /**
 | 
			
		||||
     * 获取商品列表
 | 
			
		||||
     */
 | 
			
		||||
    public function lists(){
 | 
			
		||||
    	$catId = Input('cat/d');
 | 
			
		||||
    	$goodsCatIds = model('GoodsCats')->getParentIs($catId);
 | 
			
		||||
    	reset($goodsCatIds);
 | 
			
		||||
    	//填充参数
 | 
			
		||||
    	$data = [];
 | 
			
		||||
    	$data['catId'] = $catId;
 | 
			
		||||
    	$data['isStock'] = Input('isStock/d');
 | 
			
		||||
    	$data['isNew'] = Input('isNew/d');
 | 
			
		||||
        $data['isFreeShipping'] = input('isFreeShipping/d');
 | 
			
		||||
    	$data['orderBy'] = Input('orderBy/d');
 | 
			
		||||
    	$data['order'] = Input('order/d',1);
 | 
			
		||||
    	$data['sprice'] = Input('sprice');
 | 
			
		||||
    	$data['eprice'] = Input('eprice');
 | 
			
		||||
    	$data['attrs'] = [];
 | 
			
		||||
 | 
			
		||||
        $data['areaId'] = (int)Input('areaId');
 | 
			
		||||
        $aModel = model('home/areas');
 | 
			
		||||
 | 
			
		||||
        // 获取地区
 | 
			
		||||
        $data['area1'] = $data['area2'] = $data['area3'] = $aModel->listQuery(); // 省级
 | 
			
		||||
 | 
			
		||||
        // 如果有筛选地区 获取上级地区信息
 | 
			
		||||
        if($data['areaId']!==0){
 | 
			
		||||
            $areaIds = $aModel->getParentIs($data['areaId']);
 | 
			
		||||
            /*
 | 
			
		||||
              2 => int 440000
 | 
			
		||||
              1 => int 440100
 | 
			
		||||
              0 => int 440106
 | 
			
		||||
            */
 | 
			
		||||
            $selectArea = [];
 | 
			
		||||
            $areaName = '';
 | 
			
		||||
            foreach($areaIds as $k=>$v){
 | 
			
		||||
                $a = $aModel->getById($v);
 | 
			
		||||
                $areaName .=$a['areaName'];
 | 
			
		||||
                $selectArea[] = $a;
 | 
			
		||||
            }
 | 
			
		||||
            // 地区完整名称
 | 
			
		||||
            $selectArea['areaName'] = $areaName;
 | 
			
		||||
            // 当前选择的地区
 | 
			
		||||
            $data['areaInfo'] = $selectArea;
 | 
			
		||||
 | 
			
		||||
            $data['area2'] = $aModel->listQuery($areaIds[2]); // 广东的下级
 | 
			
		||||
 
 | 
			
		||||
            $data['area3'] = $aModel->listQuery($areaIds[1]); // 广州的下级
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
    	$vs = input('vs');
 | 
			
		||||
    	$vs = ($vs!='')?explode(',',$vs):[];
 | 
			
		||||
    	foreach ($vs as $key => $v){
 | 
			
		||||
    		if($v=='' || $v==0)continue;
 | 
			
		||||
    		$v = (int)$v;
 | 
			
		||||
    		$data['attrs']['v_'.$v] = input('v_'.$v);
 | 
			
		||||
    	}
 | 
			
		||||
    	$data['vs'] = $vs;
 | 
			
		||||
 | 
			
		||||
    	$brandIds = Input('brand');
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        $bgIds = [];// 品牌下的商品Id
 | 
			
		||||
        if(!empty($vs)){
 | 
			
		||||
            // 存在筛选条件,取出符合该条件的商品id,根据商品id获取可选品牌
 | 
			
		||||
            $goodsId = model('goods')->filterByAttributes();
 | 
			
		||||
            $data['brandFilter'] = model('Brands')->canChoseBrands($goodsId);
 | 
			
		||||
        }else{
 | 
			
		||||
           // 取出分类下包含商品的品牌
 | 
			
		||||
           $data['brandFilter'] = model('Brands')->goodsListQuery((int)current($goodsCatIds));
 | 
			
		||||
        }
 | 
			
		||||
        if(!empty($brandIds))$bgIds = model('Brands')->getGoodsIds($brandIds);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    	$data['price'] = Input('price');
 | 
			
		||||
    	//封装当前选中的值
 | 
			
		||||
    	$selector = [];
 | 
			
		||||
    	//处理品牌
 | 
			
		||||
        $brandIds = explode(',',$brandIds);
 | 
			
		||||
        $bIds = $brandNames = [];
 | 
			
		||||
        foreach($brandIds as $bId){
 | 
			
		||||
        	if($bId>0){
 | 
			
		||||
        		foreach ($data['brandFilter'] as $key =>$v){
 | 
			
		||||
        			if($v['brandId']==$bId){
 | 
			
		||||
                        array_push($bIds, $v['brandId']);
 | 
			
		||||
                        array_push($brandNames, $v['brandName']);
 | 
			
		||||
                    }
 | 
			
		||||
        		}
 | 
			
		||||
                $selector[] = ['id'=>join(',',$bIds),'type'=>'brand','label'=>"品牌","val"=>join('、',$brandNames)];
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        // 当前是否有品牌筛选
 | 
			
		||||
        if(!empty($selector)){
 | 
			
		||||
            $_s[] = $selector[count($selector)-1];
 | 
			
		||||
            $selector = $_s;
 | 
			
		||||
            unset($data['brandFilter']);
 | 
			
		||||
        }
 | 
			
		||||
        $data['brandId'] = Input('brand');
 | 
			
		||||
 | 
			
		||||
    	//处理价格
 | 
			
		||||
    	if($data['sprice']!='' && $data['eprice']!=''){
 | 
			
		||||
    		$selector[] = ['id'=>0,'type'=>'price','label'=>"价格","val"=>$data['sprice']."-".$data['eprice']];
 | 
			
		||||
    	}
 | 
			
		||||
        if($data['sprice']!='' && $data['eprice']==''){
 | 
			
		||||
        	$selector[] = ['id'=>0,'type'=>'price','label'=>"价格","val"=>$data['sprice']."以上"];
 | 
			
		||||
    	}
 | 
			
		||||
        if($data['sprice']=='' && $data['eprice']!=''){
 | 
			
		||||
        	$selector[] = ['id'=>0,'type'=>'price','label'=>"价格","val"=>"0-".$data['eprice']];
 | 
			
		||||
    	}
 | 
			
		||||
    	//处理已选属性
 | 
			
		||||
    	$goodsFilter = model('Attributes')->listQueryByFilter($catId);
 | 
			
		||||
    	$ngoodsFilter = [];
 | 
			
		||||
        if(!empty($vs)){
 | 
			
		||||
            // 存在筛选条件,取出符合该条件的商品id,根据商品id获取可选属性进行拼凑
 | 
			
		||||
            $goodsId = model('goods')->filterByAttributes();
 | 
			
		||||
                // 如果同时有筛选品牌,则与品牌下的商品Id取交集
 | 
			
		||||
            if(!empty($bgIds))$goodsId = array_intersect($bgIds,$goodsId);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
            $attrs = model('Attributes')->getAttribute($goodsId);
 | 
			
		||||
            // 去除已选择属性
 | 
			
		||||
            foreach ($attrs as $key =>$v){
 | 
			
		||||
                if(!in_array($v['attrId'],$vs))$ngoodsFilter[] = $v;
 | 
			
		||||
            }
 | 
			
		||||
        }else{
 | 
			
		||||
            if(!empty($bgIds))$goodsFilter = model('Attributes')->getAttribute($bgIds);// 存在品牌筛选
 | 
			
		||||
            // 当前无筛选条件,取出分类下所有属性
 | 
			
		||||
        	foreach ($goodsFilter as $key =>$v){
 | 
			
		||||
        		if(!in_array($v['attrId'],$vs))$ngoodsFilter[] = $v;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        if(count($vs)>0){
 | 
			
		||||
            $_vv = [];
 | 
			
		||||
            $_attrArr = [];
 | 
			
		||||
    		foreach ($goodsFilter as $key =>$v){
 | 
			
		||||
    			if(in_array($v['attrId'],$vs)){
 | 
			
		||||
    				foreach ($v['attrVal'] as $key2 =>$vv){
 | 
			
		||||
    					if(strstr(input('v_'.$v['attrId']),$vv)!==false){
 | 
			
		||||
                            array_push($_vv, $vv);
 | 
			
		||||
                            $_attrArr[$v['attrId']]['attrName'] = $v['attrName'];
 | 
			
		||||
                            $_attrArr[$v['attrId']]['val'] = $_vv;
 | 
			
		||||
                        }
 | 
			
		||||
    				}
 | 
			
		||||
                    $_vv = [];
 | 
			
		||||
    			}
 | 
			
		||||
    		}
 | 
			
		||||
            foreach($_attrArr as $k1=>$v1){
 | 
			
		||||
                $selector[] = ['id'=>$k1,'type'=>'v_'.$k1,'label'=>$v1['attrName'],"val"=>join('、',$v1['val'])];
 | 
			
		||||
            }
 | 
			
		||||
    	}
 | 
			
		||||
    	$data['selector'] = $selector;
 | 
			
		||||
    	$data['goodsFilter'] = $ngoodsFilter;
 | 
			
		||||
    	//获取商品记录
 | 
			
		||||
    	$m = new M();
 | 
			
		||||
    	$data['priceGrade'] = $m->getPriceGrade($goodsCatIds);
 | 
			
		||||
    	$data['goodsPage'] = $m->pageQuery($goodsCatIds);
 | 
			
		||||
        $catPaths = model('goodsCats')->getParentNames($catId);
 | 
			
		||||
        $data['catNamePath'] = '全部商品分类';
 | 
			
		||||
        if(!empty($catPaths))$data['catNamePath'] = implode(' - ',$catPaths);
 | 
			
		||||
        // 商品分类下级
 | 
			
		||||
        $where = ['parentId'=>0,'dataFlag'=>1];
 | 
			
		||||
        if($catId!='')$where['parentId']=$catId;
 | 
			
		||||
        $goodsCats = model('goodsCats')->field('catId,catName')->where($where)->select();
 | 
			
		||||
        $this->assign('goodsCats',$goodsCats);
 | 
			
		||||
    	return $this->fetch("goods_list",$data);
 | 
			
		||||
    }
 | 
			
		||||
    /**
 | 
			
		||||
     * 查看商品详情
 | 
			
		||||
     */
 | 
			
		||||
    public function detail(){
 | 
			
		||||
    	$m = new M();
 | 
			
		||||
    	$goods = $m->getBySale(input('id/d',0));
 | 
			
		||||
        $key=input('key');
 | 
			
		||||
    	if(!empty($goods)){
 | 
			
		||||
            //判断是否药品
 | 
			
		||||
            $goods_cat=strpos($goods['goodsCatIdPath'],'389');
 | 
			
		||||
            if($goods_cat!==false && $key==''){
 | 
			
		||||
                return $this->fetch("error_lost");
 | 
			
		||||
            }
 | 
			
		||||
            if((int)session('WST_USER.userId')!=""){
 | 
			
		||||
            $history_data['userId']=(int)session('WST_USER.userId');
 | 
			
		||||
            $history_data['goodsId']=$goods['goodsId'];
 | 
			
		||||
            $history_data['path']='1';
 | 
			
		||||
            $history_data['create_time']=time();
 | 
			
		||||
            $result=db('page_view')->insert($history_data);
 | 
			
		||||
        }
 | 
			
		||||
    	    $history = cookie("history_goods");
 | 
			
		||||
    	    $history = is_array($history)?$history:[];
 | 
			
		||||
            array_unshift($history, (string)$goods['goodsId']);
 | 
			
		||||
            $history = array_values(array_unique($history));
 | 
			
		||||
            
 | 
			
		||||
			if(!empty($history)){
 | 
			
		||||
				cookie("history_goods",$history,25920000);
 | 
			
		||||
			}
 | 
			
		||||
            // 商品详情延迟加载
 | 
			
		||||
            $goods['goodsDesc']=htmlspecialchars_decode($goods['goodsDesc']);
 | 
			
		||||
            //修改匹配规则 适应oss 地址 mark 20180615 by zl
 | 
			
		||||
            // $rule = '/<img src="\/(upload.*?)"/';
 | 
			
		||||
            $rule = '/<img src=".*?\/(upload.*?)"/';
 | 
			
		||||
            preg_match_all($rule, $goods['goodsDesc'], $images);
 | 
			
		||||
            foreach($images[0] as $k=>$v){
 | 
			
		||||
                //mark by cheng商品详情换成远程oss图片20180313
 | 
			
		||||
                //$goods['goodsDesc'] = str_replace($v, "<img class='goodsImg' data-original=\"__ROOT__/".WSTImg($images[1][$k],3)."\"", $goods['goodsDesc']);
 | 
			
		||||
                $goods['goodsDesc'] = str_replace($v, "<img class='goodsImg' data-original=\"__IMGURL__/".WSTImg($images[1][$k],0)."\"", $goods['goodsDesc']);
 | 
			
		||||
 | 
			
		||||
            }
 | 
			
		||||
            hook('afterGetGoods',['params'=>&$goods]);
 | 
			
		||||
            $goods['is_seckilling']=isset($goods['is_seckilling'])?$goods['is_seckilling']:0;
 | 
			
		||||
			$this->assign('goods',$goods);
 | 
			
		||||
            $this->assign('shop',$goods['shop']);
 | 
			
		||||
	    	return $this->fetch("goods_detail");
 | 
			
		||||
    	}else{
 | 
			
		||||
    		return $this->fetch("error_lost");
 | 
			
		||||
    	}
 | 
			
		||||
    }
 | 
			
		||||
    /**
 | 
			
		||||
     * 预警库存
 | 
			
		||||
     */
 | 
			
		||||
    public function stockwarnbypage(){
 | 
			
		||||
    	return $this->fetch("shops/stockwarn/list");
 | 
			
		||||
    }
 | 
			
		||||
    /**
 | 
			
		||||
     * 获取预警库存列表
 | 
			
		||||
     */
 | 
			
		||||
    public function stockByPage(){
 | 
			
		||||
    	$m = new M();
 | 
			
		||||
    	$rs = $m->stockByPage();
 | 
			
		||||
    	$rs['status'] = 1;
 | 
			
		||||
    	return $rs;
 | 
			
		||||
    }
 | 
			
		||||
    /**
 | 
			
		||||
     * 修改预警库存
 | 
			
		||||
     */
 | 
			
		||||
    public function editwarnStock(){
 | 
			
		||||
    	$m = new M();
 | 
			
		||||
    	return $m->editwarnStock();
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
	/**
 | 
			
		||||
	 * 获取商品浏览记录
 | 
			
		||||
	 */
 | 
			
		||||
	public function historyByGoods(){
 | 
			
		||||
		$rs = model('Tags')->historyByGoods(8);
 | 
			
		||||
		return WSTReturn('',1,$rs);
 | 
			
		||||
	}
 | 
			
		||||
	/**
 | 
			
		||||
	 *  记录对比商品
 | 
			
		||||
	 */
 | 
			
		||||
	public function contrastGoods(){
 | 
			
		||||
		$id = (int)input('post.id');
 | 
			
		||||
		$contras = cookie("contras_goods");
 | 
			
		||||
		if($id>0){
 | 
			
		||||
			$m = new M();
 | 
			
		||||
			$goods = $m->getBySale($id);
 | 
			
		||||
			$catId = explode('_',$goods['goodsCatIdPath']);
 | 
			
		||||
			$catId = $catId[0];
 | 
			
		||||
			if(isset($contras['catId']) && $catId!=$contras['catId'])return WSTReturn('请选择同分类对比',-1);
 | 
			
		||||
			if(isset($contras['list']) && count($contras['list'])>3)return WSTReturn('对比栏已满',-1);
 | 
			
		||||
			if(!isset($contras['catId']))$contras['catId'] = $catId;
 | 
			
		||||
			$contras['list'][$id] = $id;
 | 
			
		||||
			cookie("contras_goods",$contras,25920000);
 | 
			
		||||
		}
 | 
			
		||||
		if(isset($contras['list'])){
 | 
			
		||||
			$m = new M();
 | 
			
		||||
			$list = [];
 | 
			
		||||
			foreach($contras['list'] as $k=>$v){
 | 
			
		||||
				$list[] = $m->getBySale($v);
 | 
			
		||||
			}
 | 
			
		||||
			return WSTReturn('',1,$list);
 | 
			
		||||
		}else{
 | 
			
		||||
			return WSTReturn('',1);
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	/**
 | 
			
		||||
	 *  删除对比商品
 | 
			
		||||
	 */
 | 
			
		||||
	public function contrastDel(){
 | 
			
		||||
		$id = (int)input('post.id');
 | 
			
		||||
		$contras = cookie("contras_goods");
 | 
			
		||||
		if($id>0 && isset($contras['list'])){
 | 
			
		||||
			unset($contras['list'][$id]);
 | 
			
		||||
			cookie("contras_goods",$contras,25920000);
 | 
			
		||||
		}else{
 | 
			
		||||
			cookie("contras_goods", null);
 | 
			
		||||
		}
 | 
			
		||||
		return WSTReturn('删除成功',1);
 | 
			
		||||
	}
 | 
			
		||||
	/**
 | 
			
		||||
	 *  商品对比
 | 
			
		||||
	 */
 | 
			
		||||
	public function contrast(){
 | 
			
		||||
		$contras = cookie("contras_goods");
 | 
			
		||||
		$list = [];
 | 
			
		||||
		$list = $lists= $saleSpec = $shop = $score = $brand = $spec = [];
 | 
			
		||||
		if(isset($contras['list'])){
 | 
			
		||||
			$m = new M();
 | 
			
		||||
			foreach($contras['list'] as $key=>$value){
 | 
			
		||||
				$dara = $m->getBySale($value);
 | 
			
		||||
				if(isset($dara['saleSpec'])){
 | 
			
		||||
					foreach($dara['saleSpec'] as $ks=>$vs){
 | 
			
		||||
						if($vs['isDefault']==1){
 | 
			
		||||
							$dara['defaultSpec'] = $vs;
 | 
			
		||||
							$dara['defaultSpec']['ids'] = explode(':',$ks);
 | 
			
		||||
						}
 | 
			
		||||
					}
 | 
			
		||||
					$saleSpec[$value] = $dara['saleSpec'];
 | 
			
		||||
				}
 | 
			
		||||
				$list[] = $dara;
 | 
			
		||||
			}
 | 
			
		||||
			//第一个商品信息
 | 
			
		||||
			$goods = $list[0];
 | 
			
		||||
			//对比处理
 | 
			
		||||
			$shops['identical'] = $scores['identical'] = $brands['identical'] = 1;
 | 
			
		||||
			foreach($list as $k=>$v){
 | 
			
		||||
				$shop[$v['goodsId']] = $v['shop']['shopName'];
 | 
			
		||||
				if($goods['shop']['shopId']!=$v['shop']['shopId'])$shops['identical'] = 0;
 | 
			
		||||
				$score[$v['goodsId']] = $v['scores']['totalScores'];
 | 
			
		||||
				if($goods['scores']['totalScores']!=$v['scores']['totalScores'])$scores['identical'] = 0;
 | 
			
		||||
				$brand[$v['goodsId']] = $v['brandName'];
 | 
			
		||||
				if($goods['brandId']!=$v['brandId'])$brands['identical'] = 0;
 | 
			
		||||
				if(isset($v['spec'])){
 | 
			
		||||
					foreach($v['spec'] as $k2=>$v2){
 | 
			
		||||
						$spec[$k2]['identical'] = 0;
 | 
			
		||||
						$spec[$k2]['type'] = 'spec';
 | 
			
		||||
						$spec[$k2]['name'] = $v2['name'];
 | 
			
		||||
						$spec[$k2]['catId'] = $k2;
 | 
			
		||||
						foreach($v2['list'] as $ks22=>$vs22){
 | 
			
		||||
							$v['spec'][$k2]['list'][$ks22]['isDefault'] = (in_array($vs22['itemId'],$v['defaultSpec']['ids']))?1:0;
 | 
			
		||||
						}
 | 
			
		||||
						$spec[$k2]['info'][$v['goodsId']] = $v['spec'][$k2];
 | 
			
		||||
					}
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
			$shops['name'] = '店铺';
 | 
			
		||||
			$shops['type'] = 'shop';
 | 
			
		||||
			$shops['info'] =  $shop;
 | 
			
		||||
			$lists[] = $shops;
 | 
			
		||||
			$scores['name'] = '商品评分';
 | 
			
		||||
			$scores['type'] = 'score';
 | 
			
		||||
			$scores['info'] =  $score;
 | 
			
		||||
			$lists[] = $scores;
 | 
			
		||||
			$brands['name'] = '品牌';
 | 
			
		||||
			$brands['type'] = 'brand';
 | 
			
		||||
			$brands['info'] =  $brand;
 | 
			
		||||
			$lists[] = $brands;
 | 
			
		||||
			foreach($spec as $k3=>$v3){
 | 
			
		||||
				$lists[] = $v3;
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		$data['list'] = $list;
 | 
			
		||||
		$data['lists'] = $lists;
 | 
			
		||||
		$data['saleSpec'] = $saleSpec;
 | 
			
		||||
		$this->assign('data',$data);
 | 
			
		||||
		return $this->fetch("goods_contrast");
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										18
									
								
								hyhproject/home/controller/Goodscats.php
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										18
									
								
								hyhproject/home/controller/Goodscats.php
									
									
									
									
									
										Executable file
									
								
							@@ -0,0 +1,18 @@
 | 
			
		||||
<?php
 | 
			
		||||
namespace wstmart\home\controller;
 | 
			
		||||
use wstmart\common\model\GoodsCats as M;
 | 
			
		||||
/**
 | 
			
		||||
 * ============================================================================
 | 
			
		||||
 * 商品分类控制器
 | 
			
		||||
 */
 | 
			
		||||
class Goodscats extends Base{
 | 
			
		||||
    /**
 | 
			
		||||
     * 获取列表
 | 
			
		||||
     */
 | 
			
		||||
    public function listQuery(){
 | 
			
		||||
    	$m = new M();
 | 
			
		||||
    	$rs = $m->listQuery(input('parentId/d',0));
 | 
			
		||||
    	return WSTReturn("", 1,$rs);
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										72
									
								
								hyhproject/home/controller/Index.php
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										72
									
								
								hyhproject/home/controller/Index.php
									
									
									
									
									
										Executable file
									
								
							@@ -0,0 +1,72 @@
 | 
			
		||||
<?php
 | 
			
		||||
namespace wstmart\home\controller;
 | 
			
		||||
/**
 | 
			
		||||
 * ============================================================================
 | 
			
		||||
 * 默认控制器
 | 
			
		||||
 */
 | 
			
		||||
class Index extends Base{
 | 
			
		||||
	protected $beforeActionList = [
 | 
			
		||||
          'checkAuth' =>  ['only'=>'getsysmessages']
 | 
			
		||||
    ];
 | 
			
		||||
    public function index(){   
 | 
			
		||||
      $pay['needPay'] =200; 
 | 
			
		||||
      $userId=1;//$this->getUserId()
 | 
			
		||||
      //产品券
 | 
			
		||||
      $buyerMaxProductScale = round(dataConf('buyerMaxProductScale')*0.01,2);
 | 
			
		||||
      $pay['maxProduct'] = $pay['needPay'] * $buyerMaxProductScale;//最大可用产品券
 | 
			
		||||
      $pay['productHandlingFee'] = round(dataConf('useHasProductHandlingFee')*0.01,2);//产品券手续费
 | 
			
		||||
      $pay['productTaxFee'] = round(dataConf('useHasProductTaxFee')*0.01,2);//产品券税费
 | 
			
		||||
      $pay['maxAllProduct'] = $this->getMaxNum($pay['maxProduct'],(1-$pay['productHandlingFee']-$pay['productTaxFee'] ));//加上手续费,税费最多扣除产品券
 | 
			
		||||
 | 
			
		||||
      //优惠券
 | 
			
		||||
      $pay['maxCoupons'] = $pay['needPay'] - $pay['maxProduct'] ;//最大可用其他券,优惠券+旺旺券+现金券
 | 
			
		||||
      $pay['coupousHandlingFee'] = round(dataConf('useHasCoupousHandlingFee')*0.01,2);//优惠券手续费
 | 
			
		||||
      $pay['coupousTaxFee'] = round(dataConf('useHasCoupousTaxFee')*0.01,2);//优惠券税费
 | 
			
		||||
      $pay['maxAllCoupons'] = $this->getMaxNum($pay['maxCoupons'],(1-$pay['coupousHandlingFee']-$pay['coupousTaxFee'] ));//加上手续费,税费最多扣除优惠券
 | 
			
		||||
 | 
			
		||||
      $pay['money']['useMoney'] = 0;
 | 
			
		||||
      $pay['wang']['useWang'] = 0;
 | 
			
		||||
      //实际应用最大的产品券
 | 
			
		||||
      $userInfo = getUserInfo(['userId'=>$userId],'couponsNum,productNum,wangNum');
 | 
			
		||||
      $pay['product']['useProduct'] = $userInfo['productNum'] >= $pay['maxAllProduct'] ? $pay['maxAllProduct'] : $userInfo['productNum'];
 | 
			
		||||
      $pay['product']['useProductHandlingFee'] = $pay['product']['useProduct'] * $pay['productHandlingFee'];//产品券手续费
 | 
			
		||||
      $pay['product']['useProductTaxFee']  = $pay['product']['useProduct'] * $pay['productTaxFee'];
 | 
			
		||||
      $pay['product']['useProductOk'] = $pay['product']['useProduct'] - $pay['product']['useProductHandlingFee'] - $pay['product']['useProductTaxFee'];
 | 
			
		||||
 | 
			
		||||
      //实际应用最大的优惠券
 | 
			
		||||
      $pay['coupons']['useCoupons'] = $userInfo['couponsNum'] >= $pay['maxAllCoupons'] ? $pay['maxAllCoupons'] : $userInfo['couponsNum'];
 | 
			
		||||
      $pay['coupons']['useCouponsHandlingFee'] = round($pay['coupons']['useCoupons'] * $pay['coupousHandlingFee'],2);//产品券手续费
 | 
			
		||||
      $pay['coupons']['useCouponsTaxFee']  = round($pay['coupons']['useCoupons'] * $pay['coupousTaxFee'],2);
 | 
			
		||||
      $pay['coupons']['useCouponsOk'] = $pay['coupons']['useCoupons'] - $pay['coupons']['useCouponsHandlingFee'] - $pay['coupons']['useCouponsTaxFee'];
 | 
			
		||||
      $remNum = $pay['needPay'] - $pay['product']['useProduct'] - $pay['coupons']['useCouponsHandlingFee'];
 | 
			
		||||
      if($remNum > 0 ){
 | 
			
		||||
        //旺旺券
 | 
			
		||||
        $pay['wang']['useWang'] = $userInfo['wangNum'] >= $remNum ? $remNum : $userInfo['wangNum'];
 | 
			
		||||
        $remNum = $pay['needPay'] - $pay['product']['useProduct'] - $pay['coupons']['useCouponsHandlingFee']-$pay['wang']['useWang'];
 | 
			
		||||
        if($remNum > 0 ){
 | 
			
		||||
          $pay['money']['useMoney'] = $remNum;
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      // dump($pay);
 | 
			
		||||
 | 
			
		||||
    	return $this->fetch('index');
 | 
			
		||||
    }
 | 
			
		||||
    /**
 | 
			
		||||
   * 获取除去比例的最大值
 | 
			
		||||
   * @param  [type] $num   [description]
 | 
			
		||||
   * @param  [type] $scale [description]
 | 
			
		||||
   * @return [type]        [description]
 | 
			
		||||
   */
 | 
			
		||||
  private function getMaxNum($num,$scale){
 | 
			
		||||
    return round($num/$scale,2);
 | 
			
		||||
  }
 | 
			
		||||
      /**
 | 
			
		||||
     * 保存目录ID
 | 
			
		||||
     */
 | 
			
		||||
    public function getMenuSession(){
 | 
			
		||||
    	$menuId = input("post.menuId");
 | 
			
		||||
    	$menuType = session('WST_USER.loginTarget');
 | 
			
		||||
    	session('WST_MENUID3'.$menuType,$menuId);
 | 
			
		||||
    } 
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										98
									
								
								hyhproject/home/controller/Shopcats.php
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										98
									
								
								hyhproject/home/controller/Shopcats.php
									
									
									
									
									
										Executable file
									
								
							@@ -0,0 +1,98 @@
 | 
			
		||||
<?php
 | 
			
		||||
namespace wstmart\home\controller;
 | 
			
		||||
use wstmart\common\model\ShopCats as M;
 | 
			
		||||
/**
 | 
			
		||||
 * ============================================================================
 | 
			
		||||
 * 门店分类控制器
 | 
			
		||||
 */
 | 
			
		||||
class Shopcats extends Base{
 | 
			
		||||
    protected $beforeActionList = ['checkShopAuth'];
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * 列表
 | 
			
		||||
	 */
 | 
			
		||||
	public function index(){
 | 
			
		||||
		$m = new M();
 | 
			
		||||
		$list = $m->getCatAndChild(session('WST_USER.shopId'),input('post.parentId/d'));
 | 
			
		||||
        // mark 添加省份 20180518 by zl
 | 
			
		||||
        $areas = $m->getAreas();
 | 
			
		||||
        $this->assign('areas',$areas);
 | 
			
		||||
        // 判断是否是自营 如果是自营就显示省份
 | 
			
		||||
        $shopId = (int)session('WST_USER.shopId');;
 | 
			
		||||
        $this->assign('shopId',$shopId);
 | 
			
		||||
        // end
 | 
			
		||||
		$this->assign('list',$list);
 | 
			
		||||
		return $this->fetch("shops/shopcats/list");
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
    /**
 | 
			
		||||
     * 修改名称
 | 
			
		||||
     */
 | 
			
		||||
    public function editName(){
 | 
			
		||||
    	$m = new M();
 | 
			
		||||
    	$rs = array();
 | 
			
		||||
    	if(input('post.id/d')>0){
 | 
			
		||||
    		$rs = $m->editName();
 | 
			
		||||
    	}
 | 
			
		||||
    	return $rs;
 | 
			
		||||
    }
 | 
			
		||||
    /**
 | 
			
		||||
     * 修改排序
 | 
			
		||||
     */
 | 
			
		||||
    public function editSort(){
 | 
			
		||||
    	$m = new M();
 | 
			
		||||
    	$rs = array();
 | 
			
		||||
    	if(input('post.id/d')>0){
 | 
			
		||||
    		$rs = $m->editSort();
 | 
			
		||||
    	}
 | 
			
		||||
    	return $rs;
 | 
			
		||||
    }
 | 
			
		||||
    /**
 | 
			
		||||
     * 批量保存商品分类
 | 
			
		||||
     */
 | 
			
		||||
    public function batchSaveCats(){
 | 
			
		||||
    	$m = new M();
 | 
			
		||||
    	$rs = $m->batchSaveCats();
 | 
			
		||||
    	return $rs;
 | 
			
		||||
    }
 | 
			
		||||
    /**
 | 
			
		||||
     * 删除操作
 | 
			
		||||
     */
 | 
			
		||||
    public function del(){
 | 
			
		||||
    	$m = new M();
 | 
			
		||||
    	$rs = $m->del();
 | 
			
		||||
    	return $rs;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    /**
 | 
			
		||||
     * 列表查询
 | 
			
		||||
     */
 | 
			
		||||
    public function listQuery(){
 | 
			
		||||
    	$m = new M();
 | 
			
		||||
    	$list = $m->listQuery((int)session('WST_USER.shopId'),input('post.parentId/d'));
 | 
			
		||||
    	$rs = array();
 | 
			
		||||
    	$rs['status'] = 1;
 | 
			
		||||
    	$rs['list'] = $list;
 | 
			
		||||
    	return $rs;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public function changeCatStatus(){
 | 
			
		||||
    	$m = new M();
 | 
			
		||||
    	$rs = $m->changeCatStatus();
 | 
			
		||||
    	return $rs;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 设置分类特产省份 mark 20180515
 | 
			
		||||
     */
 | 
			
		||||
    public function setSpecial(){
 | 
			
		||||
        $m = new M();
 | 
			
		||||
        $rs = $m->setSpecial();
 | 
			
		||||
        return $rs;
 | 
			
		||||
    }
 | 
			
		||||
	
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										31
									
								
								hyhproject/home/controller/Shopconfigs.php
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										31
									
								
								hyhproject/home/controller/Shopconfigs.php
									
									
									
									
									
										Executable file
									
								
							@@ -0,0 +1,31 @@
 | 
			
		||||
<?php
 | 
			
		||||
namespace wstmart\home\controller;
 | 
			
		||||
/**
 | 
			
		||||
 * ============================================================================
 | 
			
		||||
 * 门店配置控制器
 | 
			
		||||
 */
 | 
			
		||||
class Shopconfigs extends Base{
 | 
			
		||||
    protected $beforeActionList = ['checkShopAuth'];
 | 
			
		||||
    /**
 | 
			
		||||
    * 店铺设置
 | 
			
		||||
    */
 | 
			
		||||
    public function toShopCfg(){
 | 
			
		||||
        //获取商品信息
 | 
			
		||||
        $m = model('ShopConfigs');
 | 
			
		||||
        $this->assign('object',$m->getShopCfg((int)session('WST_USER.shopId')));
 | 
			
		||||
        return $this->fetch('shops/shopconfigs/shop_cfg');
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 新增/修改 店铺设置
 | 
			
		||||
     */
 | 
			
		||||
    public function editShopCfg(){
 | 
			
		||||
        $shopId = (int)session('WST_USER.shopId');
 | 
			
		||||
        $m = model('ShopConfigs');
 | 
			
		||||
        if($shopId>0){
 | 
			
		||||
            $rs = $m->editShopCfg($shopId);
 | 
			
		||||
        }
 | 
			
		||||
        return $rs;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										38
									
								
								hyhproject/home/controller/Shopfreights.php
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										38
									
								
								hyhproject/home/controller/Shopfreights.php
									
									
									
									
									
										Executable file
									
								
							@@ -0,0 +1,38 @@
 | 
			
		||||
<?php
 | 
			
		||||
namespace wstmart\home\controller;
 | 
			
		||||
use wstmart\home\model\ShopFreights as M;
 | 
			
		||||
use wstmart\home\model\Areas;
 | 
			
		||||
use wstmart\home\model\Shops;
 | 
			
		||||
/**
 | 
			
		||||
 * ============================================================================
 | 
			
		||||
 * 运费控制器
 | 
			
		||||
 */
 | 
			
		||||
class Shopfreights extends Base{
 | 
			
		||||
	protected $beforeActionList = ['checkShopAuth'];
 | 
			
		||||
    /**
 | 
			
		||||
    * 查看运费设置
 | 
			
		||||
    */
 | 
			
		||||
	public function index(){
 | 
			
		||||
		$shops = new Shops();
 | 
			
		||||
		$shopId = session('WST_USER.shopId');
 | 
			
		||||
		$shFreight =  $shops->getShopsFreight($shopId);
 | 
			
		||||
		$this->assign('shFreight',$shFreight);//默认运费
 | 
			
		||||
		return $this->fetch('shops/freights/list');
 | 
			
		||||
	}
 | 
			
		||||
	/**
 | 
			
		||||
	 * 运费列表
 | 
			
		||||
	 */
 | 
			
		||||
	public function listProvince(){
 | 
			
		||||
		$m = new M();
 | 
			
		||||
		return $m->listProvince();
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 编辑
 | 
			
		||||
     */
 | 
			
		||||
    public function edit(){
 | 
			
		||||
    	$m = new M();
 | 
			
		||||
    	$rs = $m->edit();
 | 
			
		||||
    	return $rs;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										74
									
								
								hyhproject/home/controller/Shoproles.php
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										74
									
								
								hyhproject/home/controller/Shoproles.php
									
									
									
									
									
										Executable file
									
								
							@@ -0,0 +1,74 @@
 | 
			
		||||
<?php
 | 
			
		||||
namespace wstmart\home\controller;
 | 
			
		||||
use wstmart\home\model\ShopRoles as M;
 | 
			
		||||
/**
 | 
			
		||||
 * ============================================================================
 | 
			
		||||
 * 门店角色控制器
 | 
			
		||||
 */
 | 
			
		||||
class Shoproles extends Base{
 | 
			
		||||
    protected $beforeActionList = ['checkShopAuth'];
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * 列表
 | 
			
		||||
	 */
 | 
			
		||||
	public function index(){
 | 
			
		||||
		$m = new M();
 | 
			
		||||
		$list = $m->pageQuery();
 | 
			
		||||
		$this->assign('list',$list);
 | 
			
		||||
		return $this->fetch("shops/shoproles/list");
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
    /**
 | 
			
		||||
    * 查询
 | 
			
		||||
    */
 | 
			
		||||
    public function pageQuery(){
 | 
			
		||||
        $m = new M();
 | 
			
		||||
        return $m->pageQuery();
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    /**
 | 
			
		||||
     * 新增角色
 | 
			
		||||
     */
 | 
			
		||||
    public function add(){
 | 
			
		||||
    	$m = new M();
 | 
			
		||||
    	$object = $m->getEModel('shop_roles');
 | 
			
		||||
		$data = ['object'=>$object];
 | 
			
		||||
    	return $this->fetch('shops/shoproles/edit',$data);
 | 
			
		||||
    }
 | 
			
		||||
	
 | 
			
		||||
	/**
 | 
			
		||||
     * 新增角色
 | 
			
		||||
     */
 | 
			
		||||
    public function toAdd(){
 | 
			
		||||
    	$m = new M();
 | 
			
		||||
    	return $m->add();
 | 
			
		||||
    }
 | 
			
		||||
	
 | 
			
		||||
    /**
 | 
			
		||||
     * 修改角色
 | 
			
		||||
     */
 | 
			
		||||
    public function edit(){
 | 
			
		||||
    	$m = new M();
 | 
			
		||||
    	$object = $m->getById((int)input('get.id'));
 | 
			
		||||
		$data = ['object'=>$object];
 | 
			
		||||
    	return $this->fetch('shops/shoproles/edit',$data);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
     * 修改角色
 | 
			
		||||
     */
 | 
			
		||||
    public function toEdit(){
 | 
			
		||||
    	$m = new M();
 | 
			
		||||
    	return $m->edit();
 | 
			
		||||
    }
 | 
			
		||||
	
 | 
			
		||||
    /**
 | 
			
		||||
     * 删除操作
 | 
			
		||||
     */
 | 
			
		||||
    public function del(){
 | 
			
		||||
    	$m = new M();
 | 
			
		||||
    	$rs = $m->del();
 | 
			
		||||
    	return $rs;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										357
									
								
								hyhproject/home/controller/Shops.php
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										357
									
								
								hyhproject/home/controller/Shops.php
									
									
									
									
									
										Executable file
									
								
							@@ -0,0 +1,357 @@
 | 
			
		||||
<?php
 | 
			
		||||
namespace wstmart\home\controller;
 | 
			
		||||
use wstmart\home\model\Goods;
 | 
			
		||||
use wstmart\common\model\GoodsCats;
 | 
			
		||||
use think\Loader;
 | 
			
		||||
/**
 | 
			
		||||
 * ============================================================================
 | 
			
		||||
 * 门店控制器
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
class Shops extends Base{
 | 
			
		||||
    protected $beforeActionList = [
 | 
			
		||||
          'checkShopAuth' =>  ['only'=>'editinfo,getshopmoney'],
 | 
			
		||||
          'checkAuth'=>['only'=>'join,joinstep1,joinstep2,savestep2,joinstep3,savestep3,joinstep4,savestep4,joinstep5,savestep5,joinsuccess']
 | 
			
		||||
    ];
 | 
			
		||||
    /**
 | 
			
		||||
    * 店铺公告页
 | 
			
		||||
    */
 | 
			
		||||
    public function notice(){
 | 
			
		||||
        $notice = model('shops')->getNotice();
 | 
			
		||||
        $this->assign('notice',$notice);
 | 
			
		||||
        return $this->fetch('shops/shops/notice');
 | 
			
		||||
    }
 | 
			
		||||
    /**
 | 
			
		||||
    * 修改店铺公告
 | 
			
		||||
    */
 | 
			
		||||
    public function editNotice(){
 | 
			
		||||
        $s = model('shops');
 | 
			
		||||
        return $s->editNotice();
 | 
			
		||||
    }
 | 
			
		||||
	/**
 | 
			
		||||
	 * 商家登录
 | 
			
		||||
	 */
 | 
			
		||||
	public function login(){
 | 
			
		||||
		$USER = session('WST_USER');
 | 
			
		||||
		if(!empty($USER) && isset($USER['shopId'])){
 | 
			
		||||
			$this->redirect("shops/index");
 | 
			
		||||
		}
 | 
			
		||||
		$loginName = cookie("loginName");
 | 
			
		||||
		if(!empty($loginName)){
 | 
			
		||||
			$this->assign('loginName',cookie("loginName"));
 | 
			
		||||
		}else{
 | 
			
		||||
			$this->assign('loginName','');
 | 
			
		||||
		}
 | 
			
		||||
		return $this->fetch('shop_login');
 | 
			
		||||
	}
 | 
			
		||||
	/**
 | 
			
		||||
	 * 商家中心
 | 
			
		||||
	 */
 | 
			
		||||
	public function index(){
 | 
			
		||||
		session('WST_MENID1',null);
 | 
			
		||||
		session('WST_MENUID31',null);
 | 
			
		||||
		$s = model('shops');
 | 
			
		||||
		$data = $s->getShopSummary((int)session('WST_USER.shopId'));
 | 
			
		||||
		$this->assign('data',$data);
 | 
			
		||||
		return $this->fetch('shops/index');
 | 
			
		||||
	}
 | 
			
		||||
    /**
 | 
			
		||||
     * 店铺街
 | 
			
		||||
     */
 | 
			
		||||
    public function shopStreet(){
 | 
			
		||||
    	$g = new GoodsCats();
 | 
			
		||||
    	$goodsCats = $g->listQuery(0);
 | 
			
		||||
    	$this->assign('goodscats',$goodsCats);
 | 
			
		||||
    	//店铺街列表
 | 
			
		||||
    	$s = model('shops');
 | 
			
		||||
    	$pagesize = 10;
 | 
			
		||||
    	$selectedId = input("get.id/d");
 | 
			
		||||
    	$this->assign('selectedId',$selectedId);
 | 
			
		||||
    	$list = $s->pageQuery($pagesize);
 | 
			
		||||
    	$this->assign('list',$list);
 | 
			
		||||
    	$this->assign('keyword',input('keyword'));
 | 
			
		||||
    	$this->assign('keytype',1);
 | 
			
		||||
    	return $this->fetch('shop_street');
 | 
			
		||||
    }
 | 
			
		||||
    /**
 | 
			
		||||
     * 店铺详情
 | 
			
		||||
     */
 | 
			
		||||
    public function home(){
 | 
			
		||||
    	$shopId = (int)input("param.shopId/d");
 | 
			
		||||
    	hook("homeBeforeGoShopHome",["shopId"=>$shopId]);
 | 
			
		||||
        hook("goShopAfterAddView",["shopId"=>$shopId,'path'=>1]);
 | 
			
		||||
        $s = model('shops');
 | 
			
		||||
    	$data['shop'] = $s->getShopInfo($shopId);
 | 
			
		||||
        $ct1 = input("param.ct1/d",0);
 | 
			
		||||
        $ct2 = input("param.ct2/d",0);
 | 
			
		||||
        $goodsName = input("param.goodsName");        
 | 
			
		||||
        if(1778 != $shopId && !empty($this->is_icp)) return $this->fetch('error_lost');
 | 
			
		||||
        if(($data['shop']['shopId']==1 || $shopId==0) && $ct1==0 && !isset($goodsName)){
 | 
			
		||||
        	$params = input();
 | 
			
		||||
        	unset($params["shopId"]);
 | 
			
		||||
            $this->redirect(Url('home/shops/selfShop'),$params);
 | 
			
		||||
        }
 | 
			
		||||
    	if(empty($data['shop']))return $this->fetch('error_lost');
 | 
			
		||||
    	$data['shopcats'] = $f = model('ShopCats','model')->getShopCats($shopId);
 | 
			
		||||
    	$g = model('goods');
 | 
			
		||||
    	$data['list'] = $g->shopGoods($shopId);
 | 
			
		||||
        //dump($data['list']);die;
 | 
			
		||||
    	$this->assign('msort',input("param.msort/d",0));//筛选条件
 | 
			
		||||
    	$this->assign('mdesc',input("param.mdesc/d",1));//升降序
 | 
			
		||||
    	$this->assign('sprice',input("param.sprice"));//价格范围
 | 
			
		||||
    	$this->assign('eprice',input("param.eprice"));
 | 
			
		||||
    	$this->assign('ct1',$ct1);//一级分类
 | 
			
		||||
    	$this->assign('ct2',$ct2);//二级分类
 | 
			
		||||
    	$this->assign('goodsName',urldecode($goodsName));//搜索
 | 
			
		||||
    	$this->assign('data',$data);
 | 
			
		||||
 | 
			
		||||
    	return $this->fetch('shop_home');
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    /**
 | 
			
		||||
     * 店铺分类
 | 
			
		||||
     */
 | 
			
		||||
    public function cat(){
 | 
			
		||||
    	$s = model('shops');
 | 
			
		||||
    	$shopId = (int)input("param.shopId/d");
 | 
			
		||||
    	$data['shop'] = $s->getShopInfo($shopId);
 | 
			
		||||
    
 | 
			
		||||
    	$ct1 = input("param.ct1/d",0);
 | 
			
		||||
    	$ct2 = input("param.ct2/d",0);
 | 
			
		||||
    	$goodsName = input("param.goodsName");
 | 
			
		||||
    	if(($data['shop']['shopId']==1 || $shopId==0) && $ct1==0 && !isset($goodsName)){
 | 
			
		||||
	    	 $params = input();
 | 
			
		||||
	    	 unset($params["shopId"]);
 | 
			
		||||
	    	 $this->redirect('shops/selfShop',$params);
 | 
			
		||||
    	}
 | 
			
		||||
    	if(empty($data['shop']))return $this->fetch('error_lost');
 | 
			
		||||
    	$data['shopcats'] = $f = model('ShopCats','model')->getShopCats($shopId);
 | 
			
		||||
    	$g = model('goods');
 | 
			
		||||
    	$data['list'] = $g->shopGoods($shopId);
 | 
			
		||||
    	$this->assign('msort',input("param.msort/d",0));//筛选条件
 | 
			
		||||
    	$this->assign('mdesc',input("param.mdesc/d",1));//升降序
 | 
			
		||||
    	$this->assign('sprice',input("param.sprice"));//价格范围
 | 
			
		||||
    	$this->assign('eprice',input("param.eprice"));
 | 
			
		||||
    	$this->assign('ct1',$ct1);//一级分类
 | 
			
		||||
    	$this->assign('ct2',$ct2);//二级分类
 | 
			
		||||
    	$this->assign('goodsName',urldecode($goodsName));//搜索
 | 
			
		||||
    	$this->assign('data',$data);
 | 
			
		||||
    	return $this->fetch('shop_home');
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    /**
 | 
			
		||||
     * 查看店铺设置
 | 
			
		||||
     */
 | 
			
		||||
    public function info(){
 | 
			
		||||
    	$s = model('shops');
 | 
			
		||||
    	$object = $s->getByView((int)session('WST_USER.shopId'));
 | 
			
		||||
        $bankList= model('banks')->listQuery();
 | 
			
		||||
        $this->assign('bankList',$bankList);
 | 
			
		||||
    	$this->assign('object',$object);
 | 
			
		||||
    	return $this->fetch('shops/shops/view');
 | 
			
		||||
    }
 | 
			
		||||
    /**
 | 
			
		||||
    * 自营店铺
 | 
			
		||||
    */
 | 
			
		||||
    public function selfShop(){
 | 
			
		||||
    	hook("homeBeforeGoSelfShop",["shopId"=>1]);
 | 
			
		||||
        $s = model('shops');
 | 
			
		||||
        $data['shop'] = $s->getShopInfo(1);
 | 
			
		||||
        if(empty($data['shop']))return $this->fetch('error_lost');
 | 
			
		||||
        $this->assign('selfShop',1);
 | 
			
		||||
	    $data['shopcats'] = model('ShopCats')->getShopCats(1);
 | 
			
		||||
	    $this->assign('goodsName',urldecode(input("param.goodsName")));//搜索
 | 
			
		||||
	    // 店长推荐
 | 
			
		||||
	    $data['rec'] = $s->getRecGoods('rec',6);
 | 
			
		||||
	    // 热销商品
 | 
			
		||||
	    $data['hot'] = $s->getRecGoods('hot',6);
 | 
			
		||||
	    $this->assign('data',$data);
 | 
			
		||||
	    return $this->fetch('self_shop');
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 编辑店铺资料
 | 
			
		||||
     */
 | 
			
		||||
    public function editInfo(){
 | 
			
		||||
 | 
			
		||||
        $rs = model('shops')->editInfo();
 | 
			
		||||
        return $rs;
 | 
			
		||||
    }
 | 
			
		||||
   
 | 
			
		||||
    /**
 | 
			
		||||
     * 获取店铺金额
 | 
			
		||||
     */
 | 
			
		||||
    public function getShopMoney(){
 | 
			
		||||
        $rs = model('shops')->getFieldsById((int)session('WST_USER.shopId'),'shopMoney,lockMoney,rechargeMoney');
 | 
			
		||||
        $urs = model('users')->getFieldsById((int)session('WST_USER.userId'),'payPwd');
 | 
			
		||||
        $rs['isSetPayPwd'] = ($urs['payPwd']=='')?0:1;
 | 
			
		||||
        $rs['isDraw'] = ((float)WSTConf('CONF.drawCashShopLimit')<=$rs['shopMoney'])?1:0;
 | 
			
		||||
        unset($urs);
 | 
			
		||||
        return WSTReturn('',1,$rs);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 跳去商家入驻
 | 
			
		||||
     */
 | 
			
		||||
    public function join(){
 | 
			
		||||
        $rs = model('shops')->checkApply();
 | 
			
		||||
        $this->assign('isApply',(!empty($rs) && $rs['applyStatus']>=1)?1:0);
 | 
			
		||||
        $this->assign('applyStep',empty($rs)?1:$rs['applyStep']);
 | 
			
		||||
        $articles = model('Articles')->getArticlesByCat(53);
 | 
			
		||||
        // 防止不存在入驻文章时报错
 | 
			
		||||
        if(!isset($articles['105']))$articles['105']['articleContent'] = '无相关说明,请咨询商城客服~';
 | 
			
		||||
        if(!isset($articles['106']))$articles['106']['articleContent'] = '无相关说明,请咨询商城客服~';
 | 
			
		||||
        if(!isset($articles['107']))$articles['107']['articleContent'] = '无相关说明,请咨询商城客服~';
 | 
			
		||||
        if(!isset($articles['108']))$articles['108']['articleContent'] = '无相关说明,请咨询商城客服~';
 | 
			
		||||
        $this->assign('artiles',$articles);
 | 
			
		||||
        return $this->fetch('shop_join');
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function joinStep1(){
 | 
			
		||||
        session('apply_step',1);
 | 
			
		||||
        $rs = model('shops')->checkApply();
 | 
			
		||||
        $articles = model('Articles')->getArticlesByCat(53);
 | 
			
		||||
        // 防止不存在入驻文章时报错
 | 
			
		||||
        if(!isset($articles['109']))$articles['109']['articleContent'] = '无相关说明,请咨询商城客服~';
 | 
			
		||||
        $this->assign('artiles',$articles);
 | 
			
		||||
        return $this->fetch('shop_join_step1');
 | 
			
		||||
    }
 | 
			
		||||
    public function joinStep2(){
 | 
			
		||||
        $step = (int)session('apply_step');
 | 
			
		||||
        if($step<1){
 | 
			
		||||
            $this->redirect(Url('home/shops/joinStep1'));
 | 
			
		||||
            exit();
 | 
			
		||||
        }
 | 
			
		||||
        session('apply_step',2);
 | 
			
		||||
        $apply = model('shops')->getShopApply();
 | 
			
		||||
        $this->assign('apply',$apply);
 | 
			
		||||
        return $this->fetch('shop_join_step2');
 | 
			
		||||
    }
 | 
			
		||||
    public function saveStep2(){
 | 
			
		||||
        $step = (int)session('apply_step');
 | 
			
		||||
        if($step<2){
 | 
			
		||||
            return WSTReturn('请勿跳过申请步骤');
 | 
			
		||||
        }
 | 
			
		||||
        $data = input('post.');
 | 
			
		||||
        $validate = Loader::validate('Shops');
 | 
			
		||||
        if(!$validate->check($data,[],'applyStep1')){
 | 
			
		||||
            return WSTReturn($validate->getError());
 | 
			
		||||
        }else{
 | 
			
		||||
            return model('shops')->saveStep2($data);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    public function joinStep3(){
 | 
			
		||||
        $step = (int)session('apply_step');
 | 
			
		||||
        if($step<2){
 | 
			
		||||
            $this->redirect(Url('home/shops/joinStep1'));
 | 
			
		||||
            exit();
 | 
			
		||||
        }
 | 
			
		||||
        session('apply_step',3);
 | 
			
		||||
        $areas = model('Areas')->listQuery();
 | 
			
		||||
        $this->assign('areaList',$areas);
 | 
			
		||||
        $apply = model('shops')->getShopApply();
 | 
			
		||||
        $this->assign('apply',$apply);
 | 
			
		||||
        return $this->fetch('shop_join_step3');
 | 
			
		||||
    }
 | 
			
		||||
    public function saveStep3(){
 | 
			
		||||
        $step = (int)session('apply_step');
 | 
			
		||||
        if($step<3){
 | 
			
		||||
            return WSTReturn('请勿跳过申请步骤');
 | 
			
		||||
        }
 | 
			
		||||
        $data = input('post.');
 | 
			
		||||
        $validate = Loader::validate('Shops');
 | 
			
		||||
        if(!$validate->check($data,[],'applyStep2')){
 | 
			
		||||
            return WSTReturn($validate->getError());
 | 
			
		||||
        }else{
 | 
			
		||||
            return model('shops')->saveStep3($data);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    public function joinStep4(){
 | 
			
		||||
        $step = (int)session('apply_step');
 | 
			
		||||
        if($step<3){
 | 
			
		||||
            $this->redirect(Url('home/shops/joinStep4'));
 | 
			
		||||
            exit();
 | 
			
		||||
        }
 | 
			
		||||
        session('apply_step',4);
 | 
			
		||||
        $areas = model('Areas')->listQuery();
 | 
			
		||||
        $this->assign('areaList',$areas);
 | 
			
		||||
        $banks = model('banks')->listQuery();
 | 
			
		||||
        $this->assign('bankList',$banks);
 | 
			
		||||
        $apply = model('shops')->getShopApply();
 | 
			
		||||
        $this->assign('apply',$apply);
 | 
			
		||||
        return $this->fetch('shop_join_step4');
 | 
			
		||||
    }
 | 
			
		||||
    public function saveStep4(){
 | 
			
		||||
        $step = (int)session('apply_step');
 | 
			
		||||
        if($step<4){
 | 
			
		||||
            return WSTReturn('请勿跳过申请步骤');
 | 
			
		||||
        }
 | 
			
		||||
        $data = input('post.');
 | 
			
		||||
        $validate = Loader::validate('Shops');
 | 
			
		||||
        if(!$validate->check($data,[],'applyStep3')){
 | 
			
		||||
            return WSTReturn($validate->getError());
 | 
			
		||||
        }else{
 | 
			
		||||
            return model('shops')->saveStep4($data);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    public function joinStep5(){
 | 
			
		||||
        $step = (int)session('apply_step');
 | 
			
		||||
        if($step<4){
 | 
			
		||||
            $this->redirect(Url('home/shops/joinStep1'));
 | 
			
		||||
            exit();
 | 
			
		||||
        }
 | 
			
		||||
        session('apply_step',5);
 | 
			
		||||
        $shopLicense=db('shop_license')->alias('a')
 | 
			
		||||
        ->join('shops b','b.shopId= a.shopId')
 | 
			
		||||
        ->where('b.userId',(int)session("WST_USER.userId"))->find();
 | 
			
		||||
        $this->assign('shopLicense',$shopLicense);
 | 
			
		||||
        $goodsCatList = model('goodsCats')->listQuery(0);
 | 
			
		||||
        $this->assign('goodsCatList',$goodsCatList);
 | 
			
		||||
        $apply = model('shops')->getShopApply();
 | 
			
		||||
        $this->assign('apply',$apply);
 | 
			
		||||
        return $this->fetch('shop_join_step5');
 | 
			
		||||
    }
 | 
			
		||||
    public function saveStep5(){
 | 
			
		||||
        $step = (int)session('apply_step');
 | 
			
		||||
        if($step<5){
 | 
			
		||||
            return WSTReturn('请勿跳过申请步骤');
 | 
			
		||||
        }
 | 
			
		||||
        $data = input('post.');
 | 
			
		||||
        $validate = Loader::validate('Shops');
 | 
			
		||||
        if(!$validate->check($data,[],'applyStep4')){
 | 
			
		||||
            return WSTReturn($validate->getError());
 | 
			
		||||
        }else{
 | 
			
		||||
            return model('shops')->saveStep5($data);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    public function joinSuccess(){
 | 
			
		||||
        $step = (int)session('apply_step');
 | 
			
		||||
        if($step<5){
 | 
			
		||||
            $this->redirect(Url('home/shops/joinStep1'));
 | 
			
		||||
        }
 | 
			
		||||
        session('apply_step',5);
 | 
			
		||||
        $apply = model('shops')->getShopApply();
 | 
			
		||||
        $this->assign('apply',$apply);
 | 
			
		||||
        return $this->fetch('shop_join_success');
 | 
			
		||||
    }
 | 
			
		||||
    /**
 | 
			
		||||
     * 入驻进度查询
 | 
			
		||||
     */
 | 
			
		||||
    public function checkapplystatus(){
 | 
			
		||||
        $apply = model('shops')->getShopApply();
 | 
			
		||||
        if(empty($apply)){
 | 
			
		||||
            $this->redirect(Url('home/shops/joinStep1'));
 | 
			
		||||
            exit();
 | 
			
		||||
        }else{
 | 
			
		||||
            if($apply['applyStatus']==0){
 | 
			
		||||
                session('apply_step',$apply['applyStep']);
 | 
			
		||||
                $this->redirect(Url('home/shops/joinStep'.$apply['applyStep']));
 | 
			
		||||
                exit();
 | 
			
		||||
            }else{
 | 
			
		||||
                $this->assign('apply',$apply);
 | 
			
		||||
                return $this->fetch('shop_join_success');
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										76
									
								
								hyhproject/home/controller/Shopusers.php
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										76
									
								
								hyhproject/home/controller/Shopusers.php
									
									
									
									
									
										Executable file
									
								
							@@ -0,0 +1,76 @@
 | 
			
		||||
<?php
 | 
			
		||||
namespace wstmart\home\controller;
 | 
			
		||||
use wstmart\home\model\ShopUsers as M;
 | 
			
		||||
/**
 | 
			
		||||
 * ============================================================================
 | 
			
		||||
 * 门店角色控制器
 | 
			
		||||
 */
 | 
			
		||||
class Shopusers extends Base{
 | 
			
		||||
    protected $beforeActionList = ['checkShopAuth'];
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * 列表
 | 
			
		||||
	 */
 | 
			
		||||
	public function index(){
 | 
			
		||||
		$m = new M();
 | 
			
		||||
		$list = $m->pageQuery();
 | 
			
		||||
		$this->assign('list',$list);
 | 
			
		||||
		return $this->fetch("shops/shopusers/list");
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
    /**
 | 
			
		||||
    * 查询
 | 
			
		||||
    */
 | 
			
		||||
    public function pageQuery(){
 | 
			
		||||
        $m = new M();
 | 
			
		||||
        return $m->pageQuery();
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    /**
 | 
			
		||||
     * 新增店铺管理员
 | 
			
		||||
     */
 | 
			
		||||
    public function add(){
 | 
			
		||||
    	$m = new M();
 | 
			
		||||
    	$object = $m->getEModel('shop_roles');
 | 
			
		||||
        $roles = model("ShopRoles")->listQuery();
 | 
			
		||||
		$data = ['object'=>$object,"roles"=>$roles];
 | 
			
		||||
    	return $this->fetch('shops/shopusers/add',$data);
 | 
			
		||||
    }
 | 
			
		||||
	
 | 
			
		||||
	/**
 | 
			
		||||
     * 新增店铺管理员
 | 
			
		||||
     */
 | 
			
		||||
    public function toAdd(){
 | 
			
		||||
    	$m = new M();
 | 
			
		||||
    	return $m->add();
 | 
			
		||||
    }
 | 
			
		||||
	
 | 
			
		||||
    /**
 | 
			
		||||
     * 修改店铺管理员
 | 
			
		||||
     */
 | 
			
		||||
    public function edit(){
 | 
			
		||||
    	$m = new M();
 | 
			
		||||
    	$object = $m->getById(input('get.id'));
 | 
			
		||||
		$roles = model("ShopRoles")->listQuery();
 | 
			
		||||
        $data = ['object'=>$object,"roles"=>$roles];
 | 
			
		||||
    	return $this->fetch('shops/shopusers/edit',$data);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
     * 编辑店铺管理员
 | 
			
		||||
     */
 | 
			
		||||
    public function toEdit(){
 | 
			
		||||
    	$m = new M();
 | 
			
		||||
    	return $m->edit();
 | 
			
		||||
    }
 | 
			
		||||
	
 | 
			
		||||
    /**
 | 
			
		||||
     * 删除操作
 | 
			
		||||
     */
 | 
			
		||||
    public function del(){
 | 
			
		||||
    	$m = new M();
 | 
			
		||||
    	$rs = $m->del();
 | 
			
		||||
    	return $rs;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										974
									
								
								hyhproject/home/controller/Users.php
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										974
									
								
								hyhproject/home/controller/Users.php
									
									
									
									
									
										Executable file
									
								
							@@ -0,0 +1,974 @@
 | 
			
		||||
<?php
 | 
			
		||||
namespace wstmart\home\controller;
 | 
			
		||||
use wstmart\common\model\Users as MUsers;
 | 
			
		||||
use wstmart\common\model\LogSms;
 | 
			
		||||
/**
 | 
			
		||||
 * ============================================================================
 | 
			
		||||
 * 用户控制器
 | 
			
		||||
 */
 | 
			
		||||
class Users extends Base{
 | 
			
		||||
    protected $beforeActionList = [
 | 
			
		||||
          'checkAuth' =>  ['except'=>'getverify,login,logout,regist,toregist,checklogin,getphoneverifycode,checkloginkey,checkemail,checkfindkey,protocol,forgetpass,forgetpasst,resetpass,forgetpasss,forgetpassf,findpass,getfindphone,checkfindphone,getfindemail,tologinbox']
 | 
			
		||||
    ];
 | 
			
		||||
	/**
 | 
			
		||||
     * 去登录
 | 
			
		||||
     */
 | 
			
		||||
	public function login(){
 | 
			
		||||
		$USER = session('WST_USER');
 | 
			
		||||
		//如果已经登录了则直接跳去用户中心
 | 
			
		||||
		if(!empty($USER) && !empty($USER['userId'])){
 | 
			
		||||
			$this->redirect("users/index");
 | 
			
		||||
		}
 | 
			
		||||
		$loginName = cookie("loginName");
 | 
			
		||||
		if(!empty($loginName)){
 | 
			
		||||
			$this->assign('loginName',cookie("loginName"));
 | 
			
		||||
		}else{
 | 
			
		||||
			$this->assign('loginName','');
 | 
			
		||||
		}
 | 
			
		||||
		return $this->fetch('user_login');
 | 
			
		||||
	}
 | 
			
		||||
		    
 | 
			
		||||
    /**
 | 
			
		||||
	 * 用户退出
 | 
			
		||||
	 */
 | 
			
		||||
	public function logout(){
 | 
			
		||||
		session('WST_USER',null);
 | 
			
		||||
		setcookie("loginPwd", null);
 | 
			
		||||
		session('WST_HO_CURRENTURL', null);
 | 
			
		||||
		hook('afterUserLogout');
 | 
			
		||||
		return WSTReturn("退出成功",1);
 | 
			
		||||
		
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	/**
 | 
			
		||||
     * 用户注册
 | 
			
		||||
     * 
 | 
			
		||||
     */
 | 
			
		||||
	public function regist(){
 | 
			
		||||
		$USER = session('WST_USER');
 | 
			
		||||
		//如果已经登录了则直接跳去用户中心
 | 
			
		||||
		if(!empty($USER) && $USER['userId']!=''){
 | 
			
		||||
			$this->redirect("users/index");
 | 
			
		||||
		}
 | 
			
		||||
		$loginName = cookie("loginName");
 | 
			
		||||
		if(!empty($loginName)){
 | 
			
		||||
			$this->assign('loginName',cookie("loginName"));
 | 
			
		||||
		}else{
 | 
			
		||||
			$this->assign('loginName','');
 | 
			
		||||
		}
 | 
			
		||||
		return $this->fetch('regist');
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	
 | 
			
		||||
	/**
 | 
			
		||||
	 * 新用户注册
 | 
			
		||||
	 */
 | 
			
		||||
	public function toRegist(){
 | 
			
		||||
		$m = new MUsers();
 | 
			
		||||
		$rs = $m->regist();
 | 
			
		||||
		$rs['url'] = session('WST_HO_CURRENTURL');
 | 
			
		||||
		return $rs;
 | 
			
		||||
	
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	/**
 | 
			
		||||
	 * 验证登录
 | 
			
		||||
	 *
 | 
			
		||||
	 */
 | 
			
		||||
	public function checkLogin(){
 | 
			
		||||
		$m = new MUsers();
 | 
			
		||||
    	$rs = $m->checkLogin();
 | 
			
		||||
    	$rs['url'] = session('WST_HO_CURRENTURL');
 | 
			
		||||
    	return $rs;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * 获取验证码
 | 
			
		||||
	 */
 | 
			
		||||
	public function getPhoneVerifyCode(){
 | 
			
		||||
		$userPhone = input("post.userPhone");
 | 
			
		||||
		$rs = array();
 | 
			
		||||
		if(!WSTIsPhone($userPhone)){
 | 
			
		||||
			return WSTReturn("手机号格式不正确!");
 | 
			
		||||
			exit();
 | 
			
		||||
		}
 | 
			
		||||
		$m = new MUsers();
 | 
			
		||||
		$rs = $m->checkUserPhone($userPhone,(int)session('WST_USER.userId'));
 | 
			
		||||
		if($rs["status"]!=1){
 | 
			
		||||
			return WSTReturn("手机号已存在!");
 | 
			
		||||
			exit();
 | 
			
		||||
		}
 | 
			
		||||
		$phoneVerify = rand(100000,999999);
 | 
			
		||||
        $rv = ['status'=>-1,'msg'=>'短信发送失败'];
 | 
			
		||||
        $tpl = WSTMsgTemplates('PHONE_USER_REGISTER_VERFIY');
 | 
			
		||||
        if( $tpl['tplContent']!='' && $tpl['status']=='1'){
 | 
			
		||||
            $params = ['tpl'=>$tpl,'params'=>['MALL_NAME'=>WSTConf("CONF.mallName"),'VERFIY_CODE'=>$phoneVerify,'VERFIY_TIME'=>10]];
 | 
			
		||||
            $m = new LogSms();
 | 
			
		||||
            $rv = $m->sendSMS(0,$userPhone,$params,'getPhoneVerify',$phoneVerify);
 | 
			
		||||
        }
 | 
			
		||||
		if($rv['status']==1){
 | 
			
		||||
			session('VerifyCode_userPhone',$phoneVerify);
 | 
			
		||||
			session('VerifyCode_userPhone_Time',time());
 | 
			
		||||
		}
 | 
			
		||||
		return $rv;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	
 | 
			
		||||
	/**
 | 
			
		||||
	 * 判断手机或邮箱是否存在
 | 
			
		||||
	 */
 | 
			
		||||
	public function checkLoginKey(){
 | 
			
		||||
		$m = new MUsers();
 | 
			
		||||
		if(input("post.loginName"))$val=input("post.loginName");
 | 
			
		||||
		if(input("post.userPhone"))$val=input("post.userPhone");
 | 
			
		||||
		if(input("post.userEmail"))$val=input("post.userEmail");
 | 
			
		||||
        $userId = (int)session('WST_USER.userId');
 | 
			
		||||
		$rs = WSTCheckLoginKey($val,$userId);
 | 
			
		||||
		if($rs["status"]==1){
 | 
			
		||||
			return array("ok"=>"");
 | 
			
		||||
		}else{
 | 
			
		||||
			return array("error"=>$rs["msg"]);
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	/**
 | 
			
		||||
	 * 判断邮箱是否存在
 | 
			
		||||
	 */
 | 
			
		||||
	public function checkEmail(){
 | 
			
		||||
		$data = $this->checkLoginKey();
 | 
			
		||||
		if(isset($data['error']))$data['error'] = '对不起,该邮箱已存在';
 | 
			
		||||
		return $data;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	/**
 | 
			
		||||
	 * 判断用户名是否存在/忘记密码
 | 
			
		||||
	 */
 | 
			
		||||
	public function checkFindKey(){
 | 
			
		||||
		$m = new MUsers();
 | 
			
		||||
		$userId = (int)session('WST_USER.userId');
 | 
			
		||||
		$rs = WSTCheckLoginKey(input("post.loginName"),$userId);
 | 
			
		||||
		if($rs["status"]==1){
 | 
			
		||||
			return array("error"=>"该用户不存在!");
 | 
			
		||||
		}else{
 | 
			
		||||
			return array("ok"=>"");
 | 
			
		||||
		}
 | 
			
		||||
	
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	/**
 | 
			
		||||
	 * 跳到用户注册协议
 | 
			
		||||
	 */
 | 
			
		||||
	public function protocol(){
 | 
			
		||||
		return $this->fetch("user_protocol");
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	/**
 | 
			
		||||
	 * 用户中心
 | 
			
		||||
	 */
 | 
			
		||||
	public function index(){
 | 
			
		||||
		session('WST_MENID0',0);
 | 
			
		||||
		session('WST_MENUID30',0);
 | 
			
		||||
        // 待付款 待收货 待评价
 | 
			
		||||
        $info = model('home/Users')->getStatusNum();
 | 
			
		||||
        $this->assign($info);
 | 
			
		||||
        $m = new MUsers();
 | 
			
		||||
        $data = $m->getById((int)session('WST_USER.userId'));
 | 
			
		||||
        $this->assign('data',$data);
 | 
			
		||||
		return $this->fetch('users/index');
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	* 跳去修改个人资料
 | 
			
		||||
	*/
 | 
			
		||||
	public function edit(){
 | 
			
		||||
		$m = new MUsers();
 | 
			
		||||
		//获取用户信息
 | 
			
		||||
		$userId = (int)session('WST_USER.userId');
 | 
			
		||||
        $data = $m->getById($userId);
 | 
			
		||||
        $this->assign('data',$data);
 | 
			
		||||
		return $this->fetch('users/user_edit');
 | 
			
		||||
	}
 | 
			
		||||
	/**
 | 
			
		||||
	* 跳去修改密码页
 | 
			
		||||
	*/
 | 
			
		||||
	public function editPass(){
 | 
			
		||||
		$m = new MUsers();
 | 
			
		||||
		//获取用户信息
 | 
			
		||||
		$userId = (int)session('WST_USER.userId');
 | 
			
		||||
		$data = $m->getById($userId);
 | 
			
		||||
		$this->assign('data',$data);
 | 
			
		||||
		return $this->fetch('users/security/user_pass');
 | 
			
		||||
	}
 | 
			
		||||
	/**
 | 
			
		||||
	* 修改密码
 | 
			
		||||
	*/
 | 
			
		||||
	public function passedit(){
 | 
			
		||||
		$userId = (int)session('WST_USER.userId');
 | 
			
		||||
		$m = new MUsers();
 | 
			
		||||
		$rs = $m->editPass($userId);
 | 
			
		||||
		return $rs;
 | 
			
		||||
	}
 | 
			
		||||
	/**
 | 
			
		||||
    * 修改
 | 
			
		||||
    */
 | 
			
		||||
    public function toEdit(){
 | 
			
		||||
        $m = new MUsers();
 | 
			
		||||
        $rs = $m->edit();
 | 
			
		||||
        return $rs;
 | 
			
		||||
    }
 | 
			
		||||
    /**
 | 
			
		||||
     * 安全设置页
 | 
			
		||||
     */
 | 
			
		||||
    public function security(){
 | 
			
		||||
    	//获取用户信息
 | 
			
		||||
    	$m = new MUsers();
 | 
			
		||||
    	$data = $m->getById((int)session('WST_USER.userId'));
 | 
			
		||||
    	if($data['userPhone']!='')$data['userPhone'] = WSTStrReplace($data['userPhone'],'*',3);
 | 
			
		||||
    	if($data['userEmail']!='')$data['userEmail'] = WSTStrReplace($data['userEmail'],'*',2,'@');
 | 
			
		||||
    	$this->assign('data',$data);
 | 
			
		||||
    	return $this->fetch('users/security/index');
 | 
			
		||||
    }
 | 
			
		||||
    /**
 | 
			
		||||
     * 修改邮箱页
 | 
			
		||||
     */
 | 
			
		||||
    public function editEmail(){
 | 
			
		||||
    	hook('homeControllerUsersEditEmail');
 | 
			
		||||
    	//获取用户信息
 | 
			
		||||
    	$userId = (int)session('WST_USER.userId');
 | 
			
		||||
    	$m = new MUsers();
 | 
			
		||||
    	$data = $m->getById($userId);
 | 
			
		||||
    	if($data['userEmail']!='')$data['userEmail'] = WSTStrReplace($data['userEmail'],'*',2,'@');
 | 
			
		||||
    	$this->assign('data',$data);
 | 
			
		||||
    	$process = 'One';
 | 
			
		||||
    	$this->assign('process',$process);
 | 
			
		||||
    	if($data['userEmail']){
 | 
			
		||||
    		return $this->fetch('users/security/user_edit_email');
 | 
			
		||||
    	}else{
 | 
			
		||||
    		return $this->fetch('users/security/user_email');
 | 
			
		||||
    	}
 | 
			
		||||
    }
 | 
			
		||||
    /**
 | 
			
		||||
     * 发送验证邮件/绑定邮箱
 | 
			
		||||
     */
 | 
			
		||||
    public function getEmailVerify(){
 | 
			
		||||
    	$userEmail = input('post.userEmail');
 | 
			
		||||
    	if(!$userEmail){
 | 
			
		||||
    		return WSTReturn('请输入邮箱!',-1);
 | 
			
		||||
    	}
 | 
			
		||||
    	$code = input("post.verifyCode");
 | 
			
		||||
    	$process = input("post.process");
 | 
			
		||||
    	if(!WSTVerifyCheck($code)){
 | 
			
		||||
    		return WSTReturn('验证码错误!',-1);
 | 
			
		||||
    	}
 | 
			
		||||
    	$rs = WSTCheckLoginKey($userEmail,(int)session('WST_USER.userId'));
 | 
			
		||||
    	if($rs["status"]!=1){
 | 
			
		||||
    		return WSTReturn("邮箱已存在!");
 | 
			
		||||
    		exit();
 | 
			
		||||
    	}
 | 
			
		||||
        $code = rand(0,999999);
 | 
			
		||||
        $sendRs = ['status'=>-1,'msg'=>'邮件发送失败'];
 | 
			
		||||
        $tpl = WSTMsgTemplates('EMAIL_BIND');
 | 
			
		||||
        if( $tpl['tplContent']!='' && $tpl['status']=='1'){
 | 
			
		||||
            $find = ['${LOGIN_NAME}','${SEND_TIME}','${VERFIY_CODE}','${VERFIY_TIME}'];
 | 
			
		||||
            $replace = [session('WST_USER.loginName'),date('Y-m-d H:i:s'),$code,30];
 | 
			
		||||
            $sendRs = WSTSendMail($userEmail,'绑定邮箱',str_replace($find,$replace,$tpl['content']));
 | 
			
		||||
        }
 | 
			
		||||
    	if($sendRs['status']==1){
 | 
			
		||||
            // 绑定的邮箱
 | 
			
		||||
            session('email.val',$userEmail);
 | 
			
		||||
            // 验证码
 | 
			
		||||
            session("email.key", $code);
 | 
			
		||||
            // 发起绑定邮箱的时间;
 | 
			
		||||
            session('email.time',time());
 | 
			
		||||
            return WSTReturn("发送成功",1);
 | 
			
		||||
        }else{
 | 
			
		||||
            return WSTReturn($sendRs['msg'],-1);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    /**
 | 
			
		||||
     * 绑定邮箱
 | 
			
		||||
     */
 | 
			
		||||
    public function emailEdit(){
 | 
			
		||||
    	$USER = session('WST_USER');
 | 
			
		||||
		if(empty($USER) && $USER['userId']==''){
 | 
			
		||||
			$this->redirect("home/users/login");
 | 
			
		||||
		}
 | 
			
		||||
        $bindTime = session('email.time');
 | 
			
		||||
        $code = session('email.key');
 | 
			
		||||
        $bindEmail = session('email.val');
 | 
			
		||||
 | 
			
		||||
    	if(time()>floatval($bindTime)+30*60)$this->error('验证码已失效!');
 | 
			
		||||
    	$rs = WSTCheckLoginKey($bindEmail,(int)session('WST_USER.userId'));
 | 
			
		||||
 | 
			
		||||
    	if($rs["status"]!=1){
 | 
			
		||||
    		$this->error('邮箱已存在!');
 | 
			
		||||
    		exit();
 | 
			
		||||
    	}
 | 
			
		||||
        $secretCode = input('secretCode');
 | 
			
		||||
 | 
			
		||||
        if($code!=$secretCode)return WSTReturn('校验码错误',-1);
 | 
			
		||||
 | 
			
		||||
    	$m = new MUsers();
 | 
			
		||||
    	$rs = $m->editEmail((int)session('WST_USER.userId'),$bindEmail);
 | 
			
		||||
    	if($rs['status'] == 1){
 | 
			
		||||
            // 清空session
 | 
			
		||||
            session('email',null);
 | 
			
		||||
            return WSTReturn('验证通过',1);
 | 
			
		||||
    	}
 | 
			
		||||
    	$this->error('绑定邮箱失败');
 | 
			
		||||
    }
 | 
			
		||||
    /**
 | 
			
		||||
    * 完成邮箱绑定
 | 
			
		||||
    */
 | 
			
		||||
    public function doneEmailBind(){
 | 
			
		||||
        $this->assign('process','Three');
 | 
			
		||||
        return $this->fetch('users/security/user_email');
 | 
			
		||||
    }
 | 
			
		||||
    /**
 | 
			
		||||
     * 发送验证邮件/修改邮箱
 | 
			
		||||
     */
 | 
			
		||||
    public function getEmailVerifyt(){
 | 
			
		||||
    	$m = new MUsers();
 | 
			
		||||
    	$data = $m->getById(session('WST_USER.userId'));
 | 
			
		||||
    	$userEmail = $data['userEmail'];
 | 
			
		||||
    	if(!$userEmail){
 | 
			
		||||
    		return WSTReturn('请输入邮箱!',-1);
 | 
			
		||||
    	}
 | 
			
		||||
    	$code = input("post.verifyCode");
 | 
			
		||||
    	if(!WSTVerifyCheck($code)){
 | 
			
		||||
    		return WSTReturn('验证码错误!',-1);
 | 
			
		||||
    	}
 | 
			
		||||
 | 
			
		||||
    	$code = rand(0,999999);
 | 
			
		||||
        $sendRs = ['status'=>-1,'msg'=>'邮件发送失败'];
 | 
			
		||||
        $tpl = WSTMsgTemplates('EMAIL_EDIT');
 | 
			
		||||
        if( $tpl['tplContent']!='' && $tpl['status']=='1'){
 | 
			
		||||
            $find = ['${LOGIN_NAME}','${SEND_TIME}','${VERFIY_CODE}','${VERFIY_TIME}'];
 | 
			
		||||
            $replace = [session('WST_USER.loginName'),date('Y-m-d H:i:s'),$code,30];
 | 
			
		||||
            $sendRs = WSTSendMail($userEmail,'绑定邮箱',str_replace($find,$replace,$tpl['content']));
 | 
			
		||||
        }
 | 
			
		||||
        if($sendRs['status']==1){
 | 
			
		||||
            // 修改的用户
 | 
			
		||||
            session('email.uId',(int)session('WST_USER.userId'));
 | 
			
		||||
            // 绑定的邮箱
 | 
			
		||||
            session('email.val',$userEmail);
 | 
			
		||||
            // 验证码
 | 
			
		||||
            session("email.key", $code);
 | 
			
		||||
            // 发起绑定邮箱的时间;
 | 
			
		||||
            session('email.time',time());
 | 
			
		||||
            return WSTReturn("发送成功",1);
 | 
			
		||||
        }else{
 | 
			
		||||
            return WSTReturn($sendRs['msg'],-1);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    /**
 | 
			
		||||
     * 修改邮箱
 | 
			
		||||
     */
 | 
			
		||||
    public function emailEditt(){
 | 
			
		||||
    	$USER = session('WST_USER');
 | 
			
		||||
    	if(empty($USER) && $USER['userId']!=''){
 | 
			
		||||
    		$this->redirect("home/users/login");
 | 
			
		||||
    	}
 | 
			
		||||
 | 
			
		||||
        $bindTime = session('email.time');
 | 
			
		||||
        $code = session('email.key');
 | 
			
		||||
        $bindEmail = session('email.val');
 | 
			
		||||
        $uId = (int)session('email.uId');
 | 
			
		||||
 | 
			
		||||
        if(time()>floatval($bindTime)+30*60)$this->error('验证码已失效!');
 | 
			
		||||
        $rs = WSTCheckLoginKey($bindEmail,(int)session('WST_USER.userId'));
 | 
			
		||||
 | 
			
		||||
        if($rs["status"]!=1){
 | 
			
		||||
            $this->error('邮箱已存在!');
 | 
			
		||||
            exit();
 | 
			
		||||
        }
 | 
			
		||||
        $secretCode = input('secretCode');
 | 
			
		||||
 | 
			
		||||
        if($code!=$secretCode)return WSTReturn('校验码错误',-1);
 | 
			
		||||
 | 
			
		||||
    	$m = new MUsers();
 | 
			
		||||
    	$data = $m->getById($uId);
 | 
			
		||||
    	if($data['userId']==session('WST_USER.userId')){
 | 
			
		||||
    		return WSTReturn('验证通过',1);
 | 
			
		||||
    	}
 | 
			
		||||
        $this->error('无效的用户!');
 | 
			
		||||
    }
 | 
			
		||||
    /**
 | 
			
		||||
    * 修改邮箱第二步
 | 
			
		||||
    */
 | 
			
		||||
    public function editEmail2(){
 | 
			
		||||
        $this->assign('process','Two');
 | 
			
		||||
        return $this->fetch('users/security/user_edit_email');
 | 
			
		||||
    }
 | 
			
		||||
    /**
 | 
			
		||||
    * 修改邮箱第三步
 | 
			
		||||
    */
 | 
			
		||||
    public function editEmail3(){
 | 
			
		||||
        $this->assign('process','Three');
 | 
			
		||||
        return $this->fetch('users/security/user_edit_email');
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 修改手机页
 | 
			
		||||
     */
 | 
			
		||||
    public function editPhone(){
 | 
			
		||||
    	//获取用户信息
 | 
			
		||||
    	$userId = (int)session('WST_USER.userId');
 | 
			
		||||
    	$m = new MUsers();
 | 
			
		||||
    	$data = $m->getById($userId);
 | 
			
		||||
    	if($data['userPhone']!='')$data['userPhone'] = WSTStrReplace($data['userPhone'],'*',3);
 | 
			
		||||
    	$this->assign('data',$data);
 | 
			
		||||
    	$process = 'One';
 | 
			
		||||
    	$this->assign('process',$process);
 | 
			
		||||
    	if($data['userPhone']){
 | 
			
		||||
    		return $this->fetch('users/security/user_edit_phone');
 | 
			
		||||
    	}else{
 | 
			
		||||
    		return $this->fetch('users/security/user_phone');
 | 
			
		||||
    	}
 | 
			
		||||
    }
 | 
			
		||||
    /**
 | 
			
		||||
     * 跳到发送手机验证
 | 
			
		||||
     */
 | 
			
		||||
    public function toApply(){
 | 
			
		||||
    	return $this->fetch("user_verify_phone");
 | 
			
		||||
    }
 | 
			
		||||
    /**
 | 
			
		||||
     * 绑定手机/获取验证码
 | 
			
		||||
     */
 | 
			
		||||
    public function getPhoneVerifyo(){
 | 
			
		||||
    	$userPhone = input("post.userPhone");
 | 
			
		||||
    	if(!WSTIsPhone($userPhone)){
 | 
			
		||||
    		return WSTReturn("手机号格式不正确!");
 | 
			
		||||
    		exit();
 | 
			
		||||
    	}
 | 
			
		||||
    	$rs = array();
 | 
			
		||||
    	$m = new MUsers();
 | 
			
		||||
    	$rs = WSTCheckLoginKey($userPhone,(int)session('WST_USER.userId'));
 | 
			
		||||
    	if($rs["status"]!=1){
 | 
			
		||||
    		return WSTReturn("手机号已存在!");
 | 
			
		||||
    		exit();
 | 
			
		||||
    	}
 | 
			
		||||
        $data = $m->getById(session('WST_USER.userId'));
 | 
			
		||||
    	$phoneVerify = rand(100000,999999);
 | 
			
		||||
        $rv = ['status'=>-1,'msg'=>'短信发送失败'];
 | 
			
		||||
        $tpl = WSTMsgTemplates('PHONE_EDIT');
 | 
			
		||||
        if( $tpl['tplContent']!='' && $tpl['status']=='1'){
 | 
			
		||||
            $params = ['tpl'=>$tpl,'params'=>['LOGIN_NAME'=>$data['loginName'],'VERFIY_CODE'=>$phoneVerify,'VERFIY_TIME'=>10]];
 | 
			
		||||
            $m = new LogSms();
 | 
			
		||||
            $rv = $m->sendSMS(0,$userPhone,$params,'getPhoneVerifyo',$phoneVerify);
 | 
			
		||||
        }
 | 
			
		||||
    	if($rv['status']==1){
 | 
			
		||||
    		$USER = [];
 | 
			
		||||
    		$USER['userPhone'] = $userPhone;
 | 
			
		||||
    		$USER['phoneVerify'] = $phoneVerify;
 | 
			
		||||
    		session('Verify_info',$USER);
 | 
			
		||||
    		session('Verify_userPhone_Time',time());
 | 
			
		||||
    		return WSTReturn('短信发送成功!',1);
 | 
			
		||||
    	}
 | 
			
		||||
    	return $rv;
 | 
			
		||||
    }
 | 
			
		||||
    /**
 | 
			
		||||
     * 绑定手机
 | 
			
		||||
     */
 | 
			
		||||
    public function getPhoneVerifyb(){
 | 
			
		||||
        $userPhone = input("post.userPhone");
 | 
			
		||||
        if(!WSTIsPhone($userPhone)){
 | 
			
		||||
            return WSTReturn("手机号格式不正确!");
 | 
			
		||||
            exit();
 | 
			
		||||
        }
 | 
			
		||||
        $rs = array();
 | 
			
		||||
        $m = new MUsers();
 | 
			
		||||
        $rs = WSTCheckLoginKey($userPhone,(int)session('WST_USER.userId'));
 | 
			
		||||
        if($rs["status"]!=1){
 | 
			
		||||
            return WSTReturn("手机号已存在!");
 | 
			
		||||
            exit();
 | 
			
		||||
        }
 | 
			
		||||
        $data = $m->getById(session('WST_USER.userId'));
 | 
			
		||||
        $phoneVerify = rand(100000,999999);
 | 
			
		||||
        $rv = ['status'=>-1,'msg'=>'短信发送失败'];
 | 
			
		||||
        $tpl = WSTMsgTemplates('PHONE_BIND');
 | 
			
		||||
        if( $tpl['tplContent']!='' && $tpl['status']=='1'){
 | 
			
		||||
            $params = ['tpl'=>$tpl,'params'=>['LOGIN_NAME'=>$data['loginName'],'VERFIY_CODE'=>$phoneVerify,'VERFIY_TIME'=>10]];
 | 
			
		||||
            $m = new LogSms();
 | 
			
		||||
            $rv = $m->sendSMS(0,$userPhone,$params,'getPhoneVerifyb',$phoneVerify);
 | 
			
		||||
        }
 | 
			
		||||
        if($rv['status']==1){
 | 
			
		||||
            $USER = [];
 | 
			
		||||
            $USER['userPhone'] = $userPhone;
 | 
			
		||||
            $USER['phoneVerify'] = $phoneVerify;
 | 
			
		||||
            session('Verify_info',$USER);
 | 
			
		||||
            session('Verify_userPhone_Time',time());
 | 
			
		||||
            return WSTReturn('短信发送成功!',1);
 | 
			
		||||
        }
 | 
			
		||||
        return $rv;
 | 
			
		||||
    }
 | 
			
		||||
    /**
 | 
			
		||||
     * 绑定手机
 | 
			
		||||
     */
 | 
			
		||||
    public function phoneEdito(){
 | 
			
		||||
    	$phoneVerify = input("post.Checkcode");
 | 
			
		||||
    	$process = input("post.process");
 | 
			
		||||
    	$timeVerify = session('Verify_userPhone_Time');
 | 
			
		||||
    	if(!session('Verify_info.phoneVerify') || time()>floatval($timeVerify)+10*60){
 | 
			
		||||
    		return WSTReturn("地址已失效,请重新验证身份!");
 | 
			
		||||
    		exit();
 | 
			
		||||
    	}
 | 
			
		||||
   		if($phoneVerify==session('Verify_info.phoneVerify')){
 | 
			
		||||
   			$m = new MUsers();
 | 
			
		||||
   			$rs = $m->editPhone((int)session('WST_USER.userId'),session('Verify_info.userPhone'));
 | 
			
		||||
   			if($process=='Two'){
 | 
			
		||||
   				$rs['process'] = $process;
 | 
			
		||||
   			}else{
 | 
			
		||||
   				$rs['process'] = '0';
 | 
			
		||||
   			}
 | 
			
		||||
   			return $rs;
 | 
			
		||||
   		}
 | 
			
		||||
   		return WSTReturn("校验码不一致,请重新输入!");
 | 
			
		||||
    }
 | 
			
		||||
    public function editPhoneSu(){
 | 
			
		||||
    	$pr = input("get.pr");
 | 
			
		||||
    	$process = 'Three';
 | 
			
		||||
    	$this->assign('process',$process);
 | 
			
		||||
	    if($pr == 'Two'){
 | 
			
		||||
	    	return $this->fetch('users/security/user_edit_phone');
 | 
			
		||||
	    }else{
 | 
			
		||||
	    	return $this->fetch('users/security/user_phone');
 | 
			
		||||
	    }
 | 
			
		||||
    }
 | 
			
		||||
    /**
 | 
			
		||||
     * 修改手机/获取验证码
 | 
			
		||||
     */
 | 
			
		||||
    public function getPhoneVerifyt(){
 | 
			
		||||
    	$m = new MUsers();
 | 
			
		||||
    	$data = $m->getById(session('WST_USER.userId'));
 | 
			
		||||
    	$userPhone = $data['userPhone'];
 | 
			
		||||
    	$phoneVerify = rand(100000,999999);
 | 
			
		||||
        $rv = ['status'=>-1,'msg'=>'短信发送失败'];
 | 
			
		||||
        $tpl = WSTMsgTemplates('PHONE_EDIT');
 | 
			
		||||
        if( $tpl['tplContent']!='' && $tpl['status']=='1'){
 | 
			
		||||
            $params = ['tpl'=>$tpl,'params'=>['LOGIN_NAME'=>$data['loginName'],'VERFIY_CODE'=>$phoneVerify,'VERFIY_TIME'=>10]];
 | 
			
		||||
            $m = new LogSms();
 | 
			
		||||
            $rv = $m->sendSMS(0,$userPhone,$params,'getPhoneVerifyt',$phoneVerify);
 | 
			
		||||
        }
 | 
			
		||||
     	if($rv['status']==1){
 | 
			
		||||
	    	$USER = [];
 | 
			
		||||
	    	$USER['userPhone'] = $userPhone;
 | 
			
		||||
	    	$USER['phoneVerify'] = $phoneVerify;
 | 
			
		||||
	    	session('Verify_info2',$USER);
 | 
			
		||||
	    	session('Verify_userPhone_Time2',time());
 | 
			
		||||
	    	return WSTReturn('短信发送成功!',1);
 | 
			
		||||
    	}
 | 
			
		||||
    	return $rv;
 | 
			
		||||
    }
 | 
			
		||||
    /**
 | 
			
		||||
     * 修改手机
 | 
			
		||||
     */
 | 
			
		||||
    public function phoneEditt(){
 | 
			
		||||
    	$phoneVerify = input("post.Checkcode");
 | 
			
		||||
    	$timeVerify = session('Verify_userPhone_Time2');
 | 
			
		||||
    	if(!session('Verify_info2.phoneVerify') || time()>floatval($timeVerify)+10*60){
 | 
			
		||||
    		return WSTReturn("校验码已失效,请重新发送!");
 | 
			
		||||
    		exit();
 | 
			
		||||
    	}
 | 
			
		||||
    	if($phoneVerify==session('Verify_info2.phoneVerify')){
 | 
			
		||||
    		return WSTReturn("验证成功",1);
 | 
			
		||||
    	}
 | 
			
		||||
    	return WSTReturn("校验码不一致,请重新输入!",-1);
 | 
			
		||||
    }
 | 
			
		||||
    public function editPhoneSut(){
 | 
			
		||||
    	$process = 'Two';
 | 
			
		||||
    	$this->assign('process',$process);
 | 
			
		||||
    	if(session('Verify_info2.phoneVerify')){
 | 
			
		||||
    		return $this->fetch('users/security/user_edit_phone');
 | 
			
		||||
    	}
 | 
			
		||||
        $this->error('地址已失效,请重新验证身份');
 | 
			
		||||
    }
 | 
			
		||||
    /**
 | 
			
		||||
    * 处理图像裁剪
 | 
			
		||||
    */
 | 
			
		||||
    // public function editUserPhoto(){
 | 
			
		||||
    //     $imageSrc = trim(input('post.photoSrc'),'/');
 | 
			
		||||
    //     $image = \image\Image::open($imageSrc);
 | 
			
		||||
    //     $x = (int)input('post.x');
 | 
			
		||||
    //     $y = (int)input('post.y');
 | 
			
		||||
    //     $w = (int)input('post.w',150);
 | 
			
		||||
    //     $h = (int)input('post.h',150);
 | 
			
		||||
    //     $rs = $image->crop($w, $h, $x, $y, 150, 150)->save($imageSrc);
 | 
			
		||||
    //     if($rs){
 | 
			
		||||
    //         return WSTReturn('',1,$imageSrc);
 | 
			
		||||
    //         exit;
 | 
			
		||||
    //     }
 | 
			
		||||
    //     return WSTReturn('发生未知错误.',-1);
 | 
			
		||||
 | 
			
		||||
    // }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
    * 处理图像裁剪 修改适应oss mark 201080612 by zl
 | 
			
		||||
    */
 | 
			
		||||
    public function editUserPhoto(){
 | 
			
		||||
        $imageSrc = trim(input('post.photoSrc'),'/');
 | 
			
		||||
        //判断图片是否缩放了
 | 
			
		||||
        $res = strpos($imageSrc,'?x-oss-process=');
 | 
			
		||||
        $x = (int)input('post.x');
 | 
			
		||||
        $y = (int)input('post.y');
 | 
			
		||||
        $w = (int)input('post.w',150);
 | 
			
		||||
        $h = (int)input('post.h',150);
 | 
			
		||||
        //判断是否缩放 如果缩放了就不加'?x-oss-process='
 | 
			
		||||
        if($res){
 | 
			
		||||
            $imageSrc=$imageSrc.',image/crop,x_'.$x.',y_'.$y.',w_'.$w.',h_'.$h.',image/resize,w_150,h_150';
 | 
			
		||||
        }else{
 | 
			
		||||
            $imageSrc=$imageSrc.'?x-oss-process=image/crop,x_'.$x.',y_'.$y.',w_'.$w.',h_'.$h.',image/resize,w_150,h_150';
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        return WSTReturn('',1,$imageSrc);
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
    /****************************************************** 忘记密码 **********************************************************/
 | 
			
		||||
    /**
 | 
			
		||||
     * 忘记支付密码
 | 
			
		||||
     */
 | 
			
		||||
    public function backPayPass(){
 | 
			
		||||
    	$m = new MUsers();
 | 
			
		||||
    	$userId = (int)session('WST_USER.userId');
 | 
			
		||||
    	$user = $m->getById($userId);
 | 
			
		||||
    	$userPhone = $user['userPhone'];
 | 
			
		||||
    	$user['userPhone'] = WSTStrReplace($user['userPhone'],'*',3);
 | 
			
		||||
    	$user['phoneType'] = empty($userPhone)?0:1;
 | 
			
		||||
    	$backType = (int)session('Type_backPaypwd');
 | 
			
		||||
    	$timeVerify = session('Verify_backPaypwd_Time');
 | 
			
		||||
    	$process = 'One';
 | 
			
		||||
    	$this->assign('data', $user);
 | 
			
		||||
    	$this->assign('process', $process);
 | 
			
		||||
    	return $this->fetch('users/security/user_edit_pay');
 | 
			
		||||
    }
 | 
			
		||||
    /**
 | 
			
		||||
     * 忘记支付密码:发送短信
 | 
			
		||||
     */
 | 
			
		||||
    public function  getphoneverifypay(){
 | 
			
		||||
    	$m = new MUsers();
 | 
			
		||||
    	$data = $m->getById(session('WST_USER.userId'));
 | 
			
		||||
    	$userPhone = $data['userPhone'];
 | 
			
		||||
    	$phoneVerify = rand(100000,999999);
 | 
			
		||||
    	$rv = ['status'=>-1,'msg'=>'短信发送失败'];
 | 
			
		||||
    	$tpl = WSTMsgTemplates('PHONE_FOTGET_PAY');
 | 
			
		||||
    	if( $tpl['tplContent']!='' && $tpl['status']=='1'){
 | 
			
		||||
    		$params = ['tpl'=>$tpl,'params'=>['LOGIN_NAME'=>$data['loginName'],'VERFIY_CODE'=>$phoneVerify,'VERFIY_TIME'=>10]];
 | 
			
		||||
    		$m = new LogSms();
 | 
			
		||||
    		$rv = $m->sendSMS(0,$userPhone,$params,'getPhoneVerifyt',$phoneVerify);
 | 
			
		||||
    	}
 | 
			
		||||
    	if($rv['status']==1){
 | 
			
		||||
    		$USER = [];
 | 
			
		||||
    		$USER['userPhone'] = $userPhone;
 | 
			
		||||
    		$USER['phoneVerify'] = $phoneVerify;
 | 
			
		||||
    		session('Verify_backPaypwd_info',$USER);
 | 
			
		||||
    		session('Verify_backPaypwd_Time',time());
 | 
			
		||||
    		return WSTReturn('短信发送成功!',1);
 | 
			
		||||
    	}
 | 
			
		||||
    	return $rv;
 | 
			
		||||
    }
 | 
			
		||||
    /**
 | 
			
		||||
     * 忘记支付密码:验证
 | 
			
		||||
     */
 | 
			
		||||
    public function payEditt(){
 | 
			
		||||
    	$payVerify = input("post.Checkcode");
 | 
			
		||||
    	$timeVerify = session('Verify_backPaypwd_Time');
 | 
			
		||||
    	if(!session('Verify_backPaypwd_info.phoneVerify') || time()>floatval($timeVerify)+10*60){
 | 
			
		||||
    		return WSTReturn("校验码已失效,请重新发送!");
 | 
			
		||||
    		exit();
 | 
			
		||||
    	}
 | 
			
		||||
    	if($payVerify==session('Verify_backPaypwd_info.phoneVerify')){
 | 
			
		||||
    		return WSTReturn("验证成功",1);
 | 
			
		||||
    	}
 | 
			
		||||
    	return WSTReturn("校验码不一致,请重新输入!",-1);
 | 
			
		||||
    }
 | 
			
		||||
    public function editPaySut(){
 | 
			
		||||
    	$process = 'Two';
 | 
			
		||||
    	$this->assign('process',$process);
 | 
			
		||||
    	if(session('Verify_backPaypwd_info.phoneVerify')){
 | 
			
		||||
    		return $this->fetch('users/security/user_edit_pay');
 | 
			
		||||
    	}
 | 
			
		||||
    	$this->error('地址已失效,请重新验证身份');
 | 
			
		||||
    }
 | 
			
		||||
    /**
 | 
			
		||||
     * 忘记支付密码:设置
 | 
			
		||||
     */
 | 
			
		||||
    public function payEdito(){
 | 
			
		||||
    	$process = input("post.process");
 | 
			
		||||
    	$timeVerify = session('Verify_backPaypwd_Time');
 | 
			
		||||
    	if(!session('Verify_backPaypwd_info.phoneVerify') || time()>floatval($timeVerify)+10*60){
 | 
			
		||||
    		return WSTReturn("地址已失效,请重新验证身份!");
 | 
			
		||||
    		exit();
 | 
			
		||||
    	}
 | 
			
		||||
    	$m = new MUsers();
 | 
			
		||||
    	$rs = $m->resetbackPay();
 | 
			
		||||
    	if($process=='Two'){
 | 
			
		||||
    		$rs['process'] = $process;
 | 
			
		||||
    	}else{
 | 
			
		||||
    		$rs['process'] = '0';
 | 
			
		||||
    	}
 | 
			
		||||
    	return $rs;
 | 
			
		||||
    }
 | 
			
		||||
    /**
 | 
			
		||||
     * 忘记支付密码:完成
 | 
			
		||||
     */
 | 
			
		||||
    public function editPaySu(){
 | 
			
		||||
    	$pr = input("get.pr");
 | 
			
		||||
    	$process = 'Three';
 | 
			
		||||
    	$this->assign('process',$process);
 | 
			
		||||
    	if($pr == 'Two'){
 | 
			
		||||
    		return $this->fetch('users/security/user_edit_pay');
 | 
			
		||||
    	}else{
 | 
			
		||||
    		return $this->fetch('users/security/user_pay_pass');
 | 
			
		||||
    	}
 | 
			
		||||
    }
 | 
			
		||||
    /**
 | 
			
		||||
     * 忘记密码
 | 
			
		||||
     */
 | 
			
		||||
    public function forgetPass(){
 | 
			
		||||
    	return $this->fetch('forget_pass');
 | 
			
		||||
    }
 | 
			
		||||
    public function forgetPasst(){
 | 
			
		||||
    	if(time()<floatval(session('findPass.findTime'))+30*60){
 | 
			
		||||
	    	$userId = session('findPass.userId');
 | 
			
		||||
	    	$m = new MUsers();
 | 
			
		||||
	    	$info = $m->getById($userId);
 | 
			
		||||
	    	if($info['userPhone']!='')$info['userPhone'] = WSTStrReplace($info['userPhone'],'*',3);
 | 
			
		||||
	    	if($info['userEmail']!='')$info['userEmail'] = WSTStrReplace($info['userEmail'],'*',2,'@');
 | 
			
		||||
	    	$this->assign('forgetInfo',$info);
 | 
			
		||||
	    	return $this->fetch('forget_pass2');
 | 
			
		||||
    	}else{
 | 
			
		||||
    		$this->error('页面已过期!');
 | 
			
		||||
    	}
 | 
			
		||||
    }
 | 
			
		||||
    // 重置密码
 | 
			
		||||
    public function resetPass(){
 | 
			
		||||
         if(!session('findPass')){
 | 
			
		||||
            $this->error('连接已失效!',url('home/users/index'));
 | 
			
		||||
         }
 | 
			
		||||
        if(time()>floatval(session('REST_Time'))+30*60)$this->error('连接已失效!');
 | 
			
		||||
        return $this->fetch('forget_pass3');
 | 
			
		||||
    }
 | 
			
		||||
    // 验证校验码
 | 
			
		||||
    public function forgetPasss(){
 | 
			
		||||
        if(!session('findPass')){
 | 
			
		||||
            $this->error('连接已失效!');
 | 
			
		||||
         }
 | 
			
		||||
        if(time()>floatval(session('REST_Time'))+30*60)$this->error('连接已失效!');
 | 
			
		||||
        $USER = session('findPass');
 | 
			
		||||
        if(empty($USER) && $USER['userId']!=''){
 | 
			
		||||
            $this->error('请在同一浏览器操作!');
 | 
			
		||||
        }
 | 
			
		||||
        $USER = session('findPass');
 | 
			
		||||
        if(empty($USER) && $USER['userId']!=''){
 | 
			
		||||
            $this->expire('请在同一浏览器操作!');
 | 
			
		||||
        }
 | 
			
		||||
        $uId = session('findPass.userId');
 | 
			
		||||
        $key = session("findPass.key");
 | 
			
		||||
        // 验证邮箱中的验证码
 | 
			
		||||
        $secretCode = input('secretCode');
 | 
			
		||||
        if($key==$secretCode){
 | 
			
		||||
            session('REST_userId',$uId);
 | 
			
		||||
            session('REST_success','1');
 | 
			
		||||
            return WSTReturn('验证成功',1);
 | 
			
		||||
        }else{
 | 
			
		||||
            return WSTReturn('校验码错误',-1);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
    public function forgetPassf(){
 | 
			
		||||
    	return $this->fetch('forget_pass4');
 | 
			
		||||
    }
 | 
			
		||||
    /**
 | 
			
		||||
     * 找回密码
 | 
			
		||||
     */
 | 
			
		||||
    public function findPass(){
 | 
			
		||||
    	//禁止缓存
 | 
			
		||||
    	header('Cache-Control:no-cache,must-revalidate');
 | 
			
		||||
    	header('Pragma:no-cache');
 | 
			
		||||
    	$code = input("post.verifyCode");
 | 
			
		||||
    	$step = input("post.step/d");
 | 
			
		||||
    	switch ($step) {
 | 
			
		||||
    		case 1:#第一步,验证身份
 | 
			
		||||
    			if(!WSTVerifyCheck($code)){
 | 
			
		||||
    				return WSTReturn('验证码错误!',-1);
 | 
			
		||||
    			}
 | 
			
		||||
    			$loginName = input("post.loginName");
 | 
			
		||||
    			$rs = WSTCheckLoginKey($loginName);
 | 
			
		||||
    			if($rs["status"]==1){
 | 
			
		||||
    				return WSTReturn("用户名不存在!");
 | 
			
		||||
    				exit();
 | 
			
		||||
    			}
 | 
			
		||||
    			$m = new MUsers();
 | 
			
		||||
    			$info = $m->checkAndGetLoginInfo($loginName);
 | 
			
		||||
    			if ($info != false) {
 | 
			
		||||
    				session('findPass',array('userId'=>$info['userId'],'loginName'=>$loginName,'userPhone'=>$info['userPhone'],'userEmail'=>$info['userEmail'],'loginSecret'=>$info['loginSecret'],'findTime'=>time()));
 | 
			
		||||
    				return WSTReturn("操作成功",1);
 | 
			
		||||
    			}else return WSTReturn("用户名不存在!");
 | 
			
		||||
    			break;
 | 
			
		||||
    		case 2:#第二步,验证方式
 | 
			
		||||
    			if (session('findPass.loginName') != null ){
 | 
			
		||||
    				if(input("post.modes")==1){
 | 
			
		||||
    					if ( session('findPass.userPhone') == null) {
 | 
			
		||||
    						return WSTReturn('你没有预留手机号码,请通过邮箱方式找回密码!',-1);
 | 
			
		||||
    					}
 | 
			
		||||
    					$phoneVerify = input("post.Checkcode");
 | 
			
		||||
    					if(!$phoneVerify){
 | 
			
		||||
    						return WSTReturn('校验码不能为空!',-1);
 | 
			
		||||
    					}
 | 
			
		||||
    					return $this->checkfindPhone($phoneVerify);
 | 
			
		||||
    				}else{
 | 
			
		||||
    					if (session('findPass.userEmail')==null) {
 | 
			
		||||
    						return WSTReturn('你没有预留邮箱,请通过手机号码找回密码!',-1);
 | 
			
		||||
    					}
 | 
			
		||||
    					if(!WSTVerifyCheck($code)){
 | 
			
		||||
    						return WSTReturn('验证码错误!',-1);
 | 
			
		||||
    					}
 | 
			
		||||
    					return $this->getfindEmail();
 | 
			
		||||
    				}
 | 
			
		||||
    			}else $this->error('页面已过期!');
 | 
			
		||||
    			break;
 | 
			
		||||
    		case 3:#第三步,设置新密码
 | 
			
		||||
    			$resetPass = session('REST_success');
 | 
			
		||||
    			if($resetPass != 1)$this->error("页面已失效!");
 | 
			
		||||
    			$loginPwd = input("post.loginPwd");
 | 
			
		||||
    			$repassword = input("post.repassword");
 | 
			
		||||
    			$decrypt_data = WSTRSA($loginPwd);
 | 
			
		||||
    			$decrypt_data2 = WSTRSA($repassword);
 | 
			
		||||
    			if($decrypt_data['status']==1 && $decrypt_data2['status']==1){
 | 
			
		||||
    				$loginPwd = $decrypt_data['data'];
 | 
			
		||||
    				$repassword = $decrypt_data2['data'];
 | 
			
		||||
    			}else{
 | 
			
		||||
    				return WSTReturn('设置失败');
 | 
			
		||||
    			}
 | 
			
		||||
    			if ($loginPwd == $repassword) {
 | 
			
		||||
    				$m = new MUsers();
 | 
			
		||||
    				$rs = $m->resetPass();
 | 
			
		||||
    				if($rs['status']==1){
 | 
			
		||||
    					return $rs;
 | 
			
		||||
    				}else{
 | 
			
		||||
    					return $rs;
 | 
			
		||||
    				}
 | 
			
		||||
    			}else return WSTReturn('两次密码不同!',-1);
 | 
			
		||||
    			break;
 | 
			
		||||
    		default:
 | 
			
		||||
    			$this->error('页面已过期!');
 | 
			
		||||
    			break;
 | 
			
		||||
    	}
 | 
			
		||||
    }
 | 
			
		||||
    /**
 | 
			
		||||
     * 手机验证码获取
 | 
			
		||||
     */
 | 
			
		||||
    public function getfindPhone(){
 | 
			
		||||
    	session('WST_USER',session('findPass.userId'));
 | 
			
		||||
        if(session('findPass.userPhone')==''){
 | 
			
		||||
            return WSTReturn('你没有预留手机号码,请通过邮箱方式找回密码!',-1);
 | 
			
		||||
        }
 | 
			
		||||
        $phoneVerify = rand(100000,999999);
 | 
			
		||||
        session('WST_USER',null);
 | 
			
		||||
        $rv = ['status'=>-1,'msg'=>'短信发送失败'];
 | 
			
		||||
        $tpl = WSTMsgTemplates('PHONE_FOTGET');
 | 
			
		||||
        if( $tpl['tplContent']!='' && $tpl['status']=='1'){
 | 
			
		||||
            $params = ['tpl'=>$tpl,'params'=>['VERFIY_CODE'=>$phoneVerify,'VERFIY_TIME'=>10]];
 | 
			
		||||
            $m = new LogSms();
 | 
			
		||||
            $rv = $m->sendSMS(0,session('findPass.userPhone'),$params,'getPhoneVerify',$phoneVerify);
 | 
			
		||||
        }
 | 
			
		||||
        if($rv['status']==1){
 | 
			
		||||
            // 记录发送短信的时间,用于验证是否过期
 | 
			
		||||
            session('REST_Time',time());
 | 
			
		||||
            $USER = [];
 | 
			
		||||
            $USER['phoneVerify'] = $phoneVerify;
 | 
			
		||||
            $USER['time'] = time();
 | 
			
		||||
            session('findPhone',$USER);
 | 
			
		||||
            return WSTReturn('短信发送成功!',1);
 | 
			
		||||
        }
 | 
			
		||||
        return $rv;
 | 
			
		||||
    }
 | 
			
		||||
    /**
 | 
			
		||||
     * 手机验证码检测
 | 
			
		||||
     * -1 错误,1正确
 | 
			
		||||
     */
 | 
			
		||||
    public function checkfindPhone($phoneVerify){
 | 
			
		||||
    	if(!session('findPhone.phoneVerify') || time()>floatval(session('findPhone.time'))+10*60){
 | 
			
		||||
            return WSTReturn("校验码已失效,请重新发送!");
 | 
			
		||||
            exit();
 | 
			
		||||
        }
 | 
			
		||||
        if (session('findPhone.phoneVerify') == $phoneVerify ) {
 | 
			
		||||
            $fuserId = session('findPass.userId');
 | 
			
		||||
            if(!empty($fuserId)){
 | 
			
		||||
                session('REST_userId',$fuserId);
 | 
			
		||||
                session('REST_success','1');
 | 
			
		||||
                $rs['status'] = 1;
 | 
			
		||||
                $rs['url'] = url('home/users/resetPass');
 | 
			
		||||
                return $rs;
 | 
			
		||||
            }
 | 
			
		||||
            return WSTReturn('无效用户',-1);
 | 
			
		||||
        }
 | 
			
		||||
        return WSTReturn('校验码错误!',-1);
 | 
			
		||||
    }
 | 
			
		||||
    /**
 | 
			
		||||
     * 发送验证邮件/找回密码
 | 
			
		||||
     */
 | 
			
		||||
    public function getfindEmail(){
 | 
			
		||||
    	$code = rand(0,999999);
 | 
			
		||||
        $sendRs = ['status'=>-1,'msg'=>'邮件发送失败'];
 | 
			
		||||
        $tpl = WSTMsgTemplates('EMAIL_FOTGET');
 | 
			
		||||
        if( $tpl['tplContent']!='' && $tpl['status']=='1'){
 | 
			
		||||
            $find = ['${LOGIN_NAME}','${SEND_TIME}','${VERFIY_CODE}','${VERFIY_TIME}'];
 | 
			
		||||
            $replace = [session('findPass.loginName'),date('Y-m-d H:i:s'),$code,30];
 | 
			
		||||
            $sendRs = WSTSendMail(session('findPass.userEmail'),'密码重置',str_replace($find,$replace,$tpl['content']));
 | 
			
		||||
        }
 | 
			
		||||
        if($sendRs['status']==1){
 | 
			
		||||
            $uId = session('findPass.userId');
 | 
			
		||||
            session("findPass.key", $code);
 | 
			
		||||
            // 发起重置密码的时间;
 | 
			
		||||
            session('REST_Time',time());
 | 
			
		||||
            return WSTReturn("发送成功",1);
 | 
			
		||||
        }else{
 | 
			
		||||
            return WSTReturn($sendRs['msg'],-1);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    /**
 | 
			
		||||
     * 加载登录小窗口
 | 
			
		||||
     */
 | 
			
		||||
    public function toLoginBox(){
 | 
			
		||||
    	return $this->fetch('box_login');
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
    * 跳去修改支付密码页
 | 
			
		||||
    */
 | 
			
		||||
    public function editPayPass(){
 | 
			
		||||
        $m = new MUsers();
 | 
			
		||||
        //获取用户信息
 | 
			
		||||
        $userId = (int)session('WST_USER.userId');
 | 
			
		||||
        $data = $m->getById($userId);
 | 
			
		||||
        $this->assign('data',$data);
 | 
			
		||||
        return $this->fetch('users/security/user_pay_pass');
 | 
			
		||||
    }
 | 
			
		||||
    /**
 | 
			
		||||
    * 修改支付密码
 | 
			
		||||
    */
 | 
			
		||||
    public function payPassEdit(){
 | 
			
		||||
        $userId = (int)session('WST_USER.userId');
 | 
			
		||||
        $m = new MUsers();
 | 
			
		||||
        $rs = $m->editPayPass($userId);
 | 
			
		||||
        return $rs;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 获取用户金额
 | 
			
		||||
     */
 | 
			
		||||
    public function getUserMoney(){
 | 
			
		||||
        $m = new MUsers();
 | 
			
		||||
        $rs = $m->getFieldsById((int)session('WST_USER.userId'),'userMoney,lockMoney,rechargeMoney,payPwd');
 | 
			
		||||
        $rs['isSetPayPwd'] = ($rs['payPwd']=='')?0:1;
 | 
			
		||||
        $rs['isDraw'] = ((float)WSTConf('CONF.drawCashUserLimit')<=$rs['userMoney'])?1:0;
 | 
			
		||||
        unset($rs['payPwd']);
 | 
			
		||||
        return WSTReturn('',1,$rs);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user