<?php
/**
 * 会员信息管理
 * @Copyright (C) 2016 汉潮 All rights reserved.
 * @License http://www.hanchao9999.com
 * @Author lss <lss@qq.com>
 */
namespace Mobile\Controller;
use Think\Controller;
class ShopInfoController extends ShopBaseController{
    public function _initialize(){
        parent::_initialize();
        if(!checksiteauth('MenDian')){ exit;}
        if (!MID) {
            $this->redirect('Mobile/Login/shop_index');
        }
    }
    /**
     *用户设置页面
     */
    public function shop_account(){
        $this->assign('tplseo_title', '设置' . '_' . C('WEB_SITE_TITLE'));
        $this->assign('page_title', '设置');
        $this->display();
    }

    public function head_portrait(){
        $shops_info = session('shops_info');
        if($shops_info['pid'] == 0){
            $map['id']=$shops_info['shop_id'];
            $shopinfo=M('Shops')->where($map)->field(true)->find();
            $this->assign($shopinfo);
        }else{
            $this->redirect('Mobile/shop_center/index');
        }
        $this->assign('tplseo_title', '修改资料' . '_' . C('WEB_SITE_TITLE'));
        $this->assign('page_title', '修改资料');
        $this->display();
    }
	/**
     *资金明细
     */
    public function money_account(){
		if (!MID) {
            $this->redirect('Mobile/Login/shop_index');
        }
		//变更类型
		$type_status=array();
		$type_status[1]='营业总额';
		$type_status[2]='未结算';
		$type_status[3]='待结算';
		$type_status[4]='冻结';
		$list=D('Shop/Account')->account_list();
		
		$this->assign($list);
		$this->assign('type_status',$type_status);
        $this->assign('tplseo_title', '资金明细' . '_' . C('WEB_SITE_TITLE'));
        $this->assign('page_title', '资金明细');
        $this->display();
    }
	/**
     *门店服务核销
     */
	public function fw_hx(){
		$this->assign('tplseo_title','门店核销'.'_'.C('WEB_SITE_TITLE'));
        $this->assign('page_title','门店核销');
		$this->display();
	}
	public function select_hx(){
		$return['status'] = 0;
		$postdata = I("param.");
		$return = D('Common/Shops')->select_hx($postdata);
		$this->ajaxReturn($return);
	}
	public function service_hx(){
		$return['status'] = 0;
		$postdata = I("param.");
		$return = D('Common/Shops')->service_hx($postdata);
		$this->ajaxReturn($return);
	}
		
	/**
     *门店套餐核销
     */
	public function tc_hx(){
		$this->assign('tplseo_title','门店核销'.'_'.C('WEB_SITE_TITLE'));
        $this->assign('page_title','门店核销');
		$this->display();
	}
	/**
     *门店提货码核销
     */
	public function thm_hx(){
		$this->assign('tplseo_title','门店核销'.'_'.C('WEB_SITE_TITLE'));
        $this->assign('page_title','门店核销');
		$this->display();
	}
	/**
     *门店奖品核销
     */
	public function jp_hx(){
		$this->assign('tplseo_title','门店核销'.'_'.C('WEB_SITE_TITLE'));
        $this->assign('page_title','门店核销');
		$this->display();
	}
    /**
     *优惠券核销
     */
    public function kq_hx(){
        $this->assign('tplseo_title','门店核销'.'_'.C('WEB_SITE_TITLE'));
        $this->assign('page_title','门店核销');
        $this->display();
    }
	/**
     *门店积分兑换
     */
	public function jifen_dh(){
		$this->assign('tplseo_title','积分兑换'.'_'.C('WEB_SITE_TITLE'));
        $this->assign('page_title','积分兑换');
		$this->display();
	}

    /**
     *修改登录密码页面
     */
    public function pass(){
        $this->assign('tplseo_title', '登录密码' . '_' . C('WEB_SITE_TITLE'));
        $this->assign('page_title', '登录密码');
        $this->display();
    }
    /**
      *修改支付密码页面
      */
    public function security(){
        $shop_id = MID;
        if($shop_id){
            $shop_info = M('Shops')->where('id ='.$shop_id)->field(true)->find();
            $this->assign($shop_info);
        }

        $this->assign('tplseo_title', '支付密码' . '_' . C('WEB_SITE_TITLE'));
        $this->assign('page_title', '支付密码');
        $this->display();
    }

    public function feedback(){
        $goods_id = I('get.id');
        $order_id = I('get.order_id');
        $this->assign('goods_id', $goods_id);
        $this->assign('order_id', $order_id);
        $this->assign('tplseo_title', '用户反馈' . '_' . C('WEB_SITE_TITLE'));
        $this->assign('page_title', '用户反馈');
        $this->display();
    }

    /**
     *提交投诉、咨询
     */
    public function submit_service(){
        $postdata = I('post.');
        $data = D('Member')->submit_service($postdata);
        $this->ajaxReturn($data);
    }

    /**
     *修改会员信息，登录密码，支付密码
     */
    public function updateinfo(){
        if (IS_POST) {
            $postdata = I('param.');
            $data = D('Common/Shops')->shop_infor($postdata);
            $this->ajaxReturn($data);
        }
    }

    public function logout(){
        $data = D('Common/ShopLogin')->logout();
		if($data){
			$data['url'] = U('Mobile/Login/shop_index');
		}
        $this->ajaxReturn($data);
    }
	/**
     *查询会员套餐详情
     */
	public function selectpack(){
		$return['status'] = 0;
		$postdata = I("param.");
		$return = D('Common/Shops')->selectpack($postdata);
		$this->ajaxReturn($return);
	}
	//套餐核销
	public function sub_package(){
		$return['status'] = 0;
		$order_true = 1;
		$postdata = I('param.');
		$return = D('Common/Shops')->sub_package($postdata);
		$this->ajaxReturn($return);
	}
    //缺货提醒
  public function quehuo($type=0){
      $param=I('param.page');
      $shops_info = session('shops_info');
      $list = D('Common/Shops')->qh_index($shops_info['id'],$param);
      if($type==1)return $list['data'];
      $this->assign('list',$list['data']);
      $quehuo_list=$this->fetch('quehuo_list');
      $this->assign('quehuo_list',$quehuo_list);
      $this->display();
    }
     public function quehuo_list(){
        $return['status']=0;
        $data=$this->quehuo(1);
        if(empty($data))$this->ajaxReturn($return);
        $return['status']=1;
        $this->assign('list',$data);
        $list_html=$this->fetch('quehuo_list');
        $return['data']=$list_html;
        $this->ajaxReturn($return);
    }


	/**
     * 礼品码查询
     */
    public function select_win_gift(){
        $shops_info = session('shops_info');
        $data['sn_number']=I('sn_number');
        $res=D("Common/Shops")->select_win_gift($data);
        $this->ajaxReturn($res);
    }
    /**
     * 礼品码核销
     */
    public function check_win_gift(){
        // $shops_info = session('shops_info');
        $data['sn_number']=I('sn_number');
        $data['location_id']=I('location_id');
        $data['user_name']=I('user_name');
        $res=D("Common/Shops")->check_win_gift($data);
        $this->ajaxReturn($res);
    }
    /**
     * 优惠券核销
     */
    public function check_kq(){
        $code = I('post.code');
        $Weixin = new \Common\Vendor\WeixinCoupon();
        $query_code = $Weixin->query_code('',$code);
        $this->ajaxReturn($query_code);
    }
	/**
     * 提货码查询
     */
	public function select_thm(){
		$return['status'] = 0;
		$postdata = I("param.");
		$return = D('Common/Shops')->select_thm($postdata);
		$this->ajaxReturn($return);
	}
    /**
     * 提货码核销
     */
    public function check_goods(){
        // $shops_info = session('shops_info');
        $data['location_id']=I('shop_id');
        $data['sn_number']=I('sn_number');
        $res=D("Common/Shops")->check_goods($data);
        $this->ajaxReturn($res);
    }
}