<?php
namespace Admin\Controller;
class MemberCustomerController extends BaseController
{
	public function _initialize()
    {
        parent::_initialize();
    }
    public function index()
    {
    	$param=I('param.');
    	$map=array();
        if(!empty($param['keyword'])){
            $where=array();
            $where['id|username|mobile']=array('like','%'.$param['keyword'].'%');
            $ids=M('Member')->where($where)->getField('id',true);
            if($ids){
                $map['uid']=array('in',$ids);
            }else{
                $map['uid']=0;
            }
        }
        if(!empty($param['shop_id'])){
            $map['shop_id']=$param['shop_id'];
        }
        if(!empty($param['begin_time']))$map['uptime'][]=array('egt',strtotime($param['begin_time']));
        if(!empty($param['end_time']))$map['uptime'][]=array('elt',strtotime($param['end_time']));
    	if($param['membertype']){
            $map['membertype']=$param['membertype']-1;
            $param['membertype']=$param['membertype']-1;
    	}
    	$list=$this->lists('MemberCustomer',$map,'id desc');
        $map=array();
        $map['status']=1;
        $shop_list=M('Shops')->where($map)->field('id,name,status')->select();
        $this->assign('shop_list',$shop_list);
    	$this->assign('list',$list);
    	$this->assign($param);
    	$this->display();
    }
    // public function edit(){
    //     $id=I('id');
    //     if($id){
    //         $map=array();
    //         $map['id']=$id;
    //         $customer_info=M('MemberCustomer')->where($map)->find();
    //     }else{
    //         $this->error("参数错误");
    //     }
    //     $this->assign($customer_info);
    //     $this->display();
    // }
    // public function update(){
    //     $param=I('param.');
    //     if($param){
    //         $map=array();
    //         $map['id']=$param['id'];
    //         $customer_info=M('MemberCustomer')->where($map)->find();
    //     }else{
    //         $this->error("参数错误");
    //     }
    // }
    //删除顾客
	public function _before_delete(){
		$id=I('id');
		$this->id=$id;
	}
}
?>