<?php
/**
 * 仓库管理
 * @Copyright (C) 2016 汉潮 All rights reserved.
 * @License http://www.hanchao9999.com
 * @Author xiaogg <xiaogg@sina.cn>
 */

namespace Admin\Controller;
class ShopController extends BaseController{

    protected $tableName  = 'shops';
	public function _initialize(){
        parent::_initialize();
        $this->shop_options=array('1'=>'连锁店','2'=>'加盟店');
    }
	/**
     * 仓库列表页
     */
    public function index(){
        $map=array();
        $map['site_id']=C('appid');
        $map['status']=1;
        $site_info=M("SiteInfo")->where($map)->field('end_time,pack_name,package,type_id,type_name,is_try,shop_max_num')->find();
        $this->assign('site_info',$site_info);
		$postdata = I('param.');

		$keyword = $postdata['keyword'];
        $map = array();
        if ($keyword) {
            $whereor['id'] = array('like', '%' . $keyword . '%');
            $whereor['name'] = array('like', '%' . $keyword . '%');
            $whereor['_logic'] = 'or';
            $map['_complex'] = $whereor;
        }

		if($postdata['data_from'])
			$map['updatetime'][] = array('egt',strtotime($postdata['data_from']));
		if($postdata['data_to'])
			$map['updatetime'][] = array('elt',strtotime($postdata['data_to']));

		if($postdata['district']){
            $map['district'] = $postdata['district'];
        }else{
            if($postdata['city_id']){
                $map['city_id'] = $postdata['city_id'];
            }else{
                if($postdata['province']){
                    $map['province'] = $postdata['province'];
                }
            }
        }
        if($postdata['shop_type']){
            $map['shop_type'] = $postdata['shop_type'];
        }
		$postdata['postion'] = $postdata['province'].','.$postdata['city_id'].','.$postdata['district'];

        $list = $this->lists('Shops', $map);
        $this->assign('list', $list);
		$this->assign($postdata);
        $shopslist=M('Shops')->field('id,name')->select();
        $this->assign('shopslist',$shopslist);
        $this->display();
    }
    public function open_child_shops(){
        $map=array();
        $map['status']=1;
        $shops=M('Shops')->where($map)->field('id,name,is_business,send_shop_id,send_price,transfer_type,online_type,extra_discount')->select();
        $shops_type=array('0'=>'仓库','1'=>'普通仓库');
        //jxr start 18.10.10
        // $shops_price=array('1'=>'上次配货价','2'=>'配货仓库进货价','3'=>'配货仓库销售价','4'=>'配货仓库批发价','5'=>'指定仓库进货价');
        $shops_price=array('0'=>'成本价','1'=>'进货价','2'=>'销售价');
        //jxr end 18.10.10
        $transfer_list=array('0'=>'不可编辑数量','1'=>'允许编辑数量，需出货方确认','2'=>'允许编辑数量，直接完成进货');
        // $online_pay=array('0'=>'关闭','1'=>'仅余额支付','2'=>'全部支付方式','3'=>'仅扫码支付','9'=>'仅线下支付');//jxr 18.10.10
        // 
        $online_pay=array('0'=>'关闭','1'=>'仅余额支付','2'=>'全部支付方式','3'=>'仅扫码支付');//19118
        $this->assign('shops_list',$shops);
        $this->assign('shops_type',$shops_type);
        $this->assign('shops_price',$shops_price);
        $this->assign('transfer_list',$transfer_list);
        $this->assign('online_pay',$online_pay);//jxr 18.10.10
        $this->display();
    }
    //jxr start 18.10.10
    public function open_child_shops_user(){
        $map=array();
        $map['status']=1;
        $shops=M('Shops')->where($map)->field('id,name,is_share_user,is_share_money,is_hide_phone')->select();
        $share_user_type=array('0'=>'否','1'=>'是');
        $share_money_type=array('0'=>'不共享使用','1'=>'共享使用');//'2'=>'共享但支付余额手续费'
        $hide_phone_type=array('0'=>'显示','1'=>'隐藏');
        $this->assign('shops_list',$shops);
        $this->assign('share_user_type',$share_user_type);
        $this->assign('share_money_type',$share_money_type);
        $this->assign('hide_phone_type',$hide_phone_type);
        $this->display();
    }
    //jxr end 18.10.10
    public function add_child_shop(){
        $postdata=I('post.');
        foreach($postdata['info']['shops_id'] as $k=>$v){
            $map=array();
            $map['id']=$v;
            $add['is_business']=$postdata['info']['is_business'][$k];
            $add['send_shop_id']=$postdata['info']['send_shop_id'][$k];
            $add['transfer_type']=$postdata['info']['transfer_type'][$k];
            // jxr start 18.10.10
            $add['send_price']=$postdata['info']['send_price'][$k];
            $add['online_type']=$postdata['info']['online_type'][$k];
            $add['is_share_user']=$postdata['info']['is_share_user'][$k];
            $add['extra_discount']=$postdata['info']['extra_discount'][$k];
            $add['is_share_money']=$postdata['info']['is_share_money'][$k];
            $add['is_hide_phone']=$postdata['info']['is_hide_phone'][$k];

            //jxr end 18.10.10
            $add['updatetime']=NOW_TIME;
            $result=M('Shops')->where($map)->save($add);
        }
        if($result){
            $return['status']=1;
            $return['data']=$add;
            $return['msg']='保存仓库设置成功';
        }else{
            $return['status']=0;
            $return['msg']='保存仓库设置失败';
        }
        $this->ajaxReturn($return);
    }
	public function bus_status(){//公共状态
		$mod = D(CONTROLLER_NAME);
		$id     = intval(I('id'));
		$allow_field=array('status','is_business');
		$type=I('type');
		if(!in_array($type,$allow_field))return false;
		$values = $mod->where('id='.$id)->field($type)->find();
        $data[$type]=($values[$type]+1)%2;
        $res=$mod->where('id='.$id)->save($data);
		if(in_array(CONTROLLER_NAME,$this->cache_model)){savecache(CONTROLLER_NAME);}
		$this->ajaxReturn($data[$type]);
	}
	public function first_index(){
        $this->display();
    }
	public function binding_num(){
        $this->display();
    }
	//添加仓库
	public function _before_add(){
        $s_map['status']=1;
        $shop_list=M('Shops')->where($s_map)->getField('id,name');
        $this->assign('shop_list',$shop_list);
		$info = array();
		if(empty($info['business_hours_start'])) $info['business_hours_start'] = '0:00';
		if(empty($info['business_hours_end'])) $info['business_hours_end'] = '23:00';
		$this->assign($info);
	}
	public function first_add(){
		$id = I('id');

		if (IS_POST) {
            $postdata = I('post.');
			$appid = C('appid');

			if(!$postdata['business_hours_start']){
				$postdata['business_hours_start'] = '0:00';
			}
			if(!$postdata['business_hours_end']){
				$postdata['business_hours_end'] = '23:00';
			}
			if(empty($id)){
				$result=D('App/Shops')->add_shops($postdata);
			}else{
				$map = array();$map['shop_id'] = $postdata['id'];$map['pid'] = 0;
				$postdata['sid'] = M('ShopsAccount')->where($map)->getField('id');
				$postdata['shop_id'] = $postdata['id'];
				$result=D('App/Shops')->edit_shops($postdata);
			}
			if($result['status'] == 1){
				if($result['shop_id'] > 0){
					session('shop_num',$shop_num+1);
				}else{
					session('shop_num',$shop_num);
				}
				if($postdata['is_first'] == 1){
					$url = U('Shops/binding_num');
				}else{
					$url = U('Shops/index');
				}
				$this->success($result['msg'],$url);
			}else{
				session('shop_num',$shop_num);
				if($result['status'] == 3){
					$this->error($result['msg']);
				}
			}
		}else{
			/*if (!empty($id)) {
				$model = M("Shops");
				$info = $model->field(true)->find($id);
				$this->assign($info);
				$this->assign('id', $id);
				$this->assign('is_first', 0);
            }*/
			if (!empty($id)) {
				$model = M("Shops");
				$info = $model->field(true)->find($id);

				if(empty($info['business_hours_start'])) $info['business_hours_start'] = '0:00';
				if(empty($info['business_hours_end'])) $info['business_hours_end'] = '23:00';
				$this->assign($info);
				$this->assign('id', $id);
				$this->assign('is_first', 0);
			}else{
				$info = array();
				$info['business_hours_start'] = '0:00';
				$info['business_hours_end'] = '23:00';
				$this->assign($info);
			}
			$this->display();
		}
    }
	/**
     * 会员卡券信息
     */
	private function cardinfo(){
		$map['card_id'] = array('neq','');
		$map['end_timestamp'] = array('gt',NOW_TIME);
		$mcard = M('WxMemberCard')->where($map)->field('card_id,title')->select();
		$ccard = M('Coupons')->where($map)->field('card_id,title')->select();
		$cardinfo = array_merge($mcard,$ccard);
		return $cardinfo;
	}
    /**
     * 判断会员是否存在
     */
    public function check_is_uid($uid){
        $model = M('Member');
        $map['uid'] = $uid;
        $uid = $model->where($map)->count();
        return $uid;
    }
    /**验证会员是否重复
     * @param $uid
     * @return true是重复false是不重复
     */
    public function check_uid($uid, $id){
        $map['uid'] = $uid;
        $shop_id = M('Shops')->where($map)->getField('id');
        if (empty($shop_id) || (!empty($shop_id) && $shop_id == $id)) return false;
        return true;
    }

	//编辑仓库
	public function edit(){
		$model = D (CONTROLLER_NAME);
		$pk=ucfirst($model->getPk ());
		$id = intval(I($model->getPk ()));
		if(empty($id))$this->error(L('do_empty'));
		$do='getBy'.$pk;
		$vo = $model->field(true)->$do($id);
		$list = json_decode($vo['pic_list'],true);
		$vo['pic_list'] = $list['list'];
		$vo['is_weixin'] = 0;
		if($vo['poi_id']){
			$vo['is_weixin'] = 1;
		}
        //11.1 start
        $s_map['status']=1;
        $s_map['id']=array('neq',$id);
        $shop_list=M('Shops')->where($s_map)->getField('id,name');
        $this->assign('shop_list',$shop_list);
        //11.1 end
		$this->assign($vo);
		$this->display();
	}
	//删除仓库
	public function _before_delete(){
		$id=I('id');
		$poi_id = I('poi_id');
		//微信接口删除仓库
		$Weixin = new \Common\Vendor\WeixinShops();
		$add_store = $Weixin->del_store($poi_id);
		if(isset($id)&&is_array($id)){
			foreach($id as $k=>$v){
				$result=check_delete($v,2);
				if(!$result['status'])unset($id[$k]);
			}
			if(empty($id)){$this->error($result['info']);exit;}
		}else{
			$result=check_delete($id,2);
			if(!$result['status']){
                $this->error($result['info']);exit;
            }else{
                $this->delete_acc($id);
            }
		}
		$this->id=$id;
	}
    private function delete_acc($id){
        $d_map['shop_id'] = $id;
        M('ShopsAccount')->where($d_map)->delete();
    }
	/**
     * 验证登陆账号是否存在
     */
    public function checklogin_name(){
		$return['status']=1;
        $post = I('post.');
        $where['shop_id'] = array('neq',$post['shop_id']);
        $where['login_name'] = $post['login_name'];

        $is_login_name = M('ShopsAccount')->where($where)->count();

		$s_where['id'] = array('neq',$post['shop_id']);
        $s_where['login_name'] = $post['login_name'];

        $is_login_name_s = M('Shops')->where($s_where)->count();
        if($is_login_name && $is_login_name_s){
			$return['status']=0;
			$return['data'] = "该登陆账号已存在";
			$this->ajaxReturn($return);
        }
    }
	/**
     * 验证手机号是否存在
     */
    public function check_phone(){
		$return['status']=1;
        $post = I('post.');
        $where['shop_id'] = array('neq',$post['shop_id']);
        $where['mobile'] = $post['phone'];

        $is_login_name = M('ShopsAccount')->where($where)->count();

		$s_where['id'] = array('neq',$post['shop_id']);
        $s_where['contacts_phone'] = $post['phone'];

        $is_login_name_s = M('Shops')->where($s_where)->count();

        if($is_login_name && $is_login_name_s){
			$return['status']=0;
			$return['data'] = "该手机号已存在";
			$this->ajaxReturn($return);
        }
    }
	/**
     * 仓库基础设置
     */
    public function option(){
		/*$list = M('ShopsOption')->field(true)->select();
		$this->assign('list',$list);
        $this->display();*/
    }
	public function edit_option(){
		/*$mod = D('ShopsOption');
		$id     = intval(I('id'));
		$type	= I('type');
		$values = $mod->where('id='.$id)->field($type)->find();
		$data[$type]=($values[$type]+1)%2;
        $res=$mod->where('id='.$id)->save($data);
        S('shops_option',null);
		if(in_array('ShopsOption',$this->cache_model)){savecache('ShopsOption');}
		$this->ajaxReturn($data[$type]);*/
	}
    //管理员进入店铺
    public function login_in(){
        $shop_id=I('param.shop_id');
        $type=I('param.type');
        $admin_info=session('admin_info');
        // define('IS_ROOT', is_administrator(UID));// 是否是超级管理员
        // if(!IS_ROOT){
        if(UID != 1){
            $this->error('提示:无权访问,您可能需要联系管理员为您授权!',U('Admin/index/index'));
        }else{
            $s_map=array();
            $s_map['id']=$shop_id;
            $s_map['status']=1;
            $shopinfo=M('Shops')->where($s_map)->count();
            if(empty($shopinfo)){
                $this->error('提示:此店铺已禁止使用!',U('Admin/index/index'));
            }else{
                $map['shop_id']=$shop_id;
                $shopsinfo['service_switch']=M('Shops')->where('id ='.$shop_id)->getField('service_switch');
                $shopsinfo['package_switch']=M('Shops')->where('id ='.$shop_id)->getField('package_switch');
                $shopsinfo['shop_type']=M('Shops')->where('id ='.$shop_id)->getField('shop_type');
                $shopsinfo['shops_info_auth_sign'] = data_auth_sign($shopsinfo);
                $shopsinfo['shop_id']=$shop_id;
                $shopsinfo['id']=M('ShopsAccount')->where($map)->getField('id');
                $shopsinfo['uid']=UID;
                $shopsinfo['name']= $admin_info['truename'];//员工姓名
                $shopsinfo['login_name']=$admin_info['username'];//登陆账号
                $shopsinfo['password']=$admin_info['password'];//账户密码
                $shopsinfo['salt']=$admin_info['salt']; //干扰码
                $shopsinfo['mobile']=$admin_info['mobile'];//联系电话
                $shopsinfo['qq']=$admin_info['qq'];//qq号
                $shopsinfo['description']='超级管理员';//备注
                $shopsinfo['is_main']=1;//是否为默认管理员
                $shopsinfo['last_ip']=$admin_info['last_login_ip'];//最后一次登录ip
                $shopsinfo['last_login']=$admin_info['last_login_time'];//最后一次登录时间
                $shopsinfo['login_count']=$admin_info['login_count'];//登陆次数
                $shopsinfo['updatetime']=time();//更新时间
                $shopsinfo['status']=1;//状态（0：禁用 1：启用）
                $shopsinfo['is_delete']=0;//是否删除（0：否 1：是）
                $shopsinfo['pid']=0;//父级id
                session('shops_info', $shopsinfo);
                action_log('shop_login', 'Shop','',UID,$shop_id);
            }
        }
        if($type=='shop'){
            redirect(U('Shop/Index/index'));
        }else{
            redirect(U('Shop/cashier/index'));
        }

    }
    public function stocktaking(){
        $map = array();
        $map['type'] = 3;//仓库类型
        if (!empty($postdata['keyword'])) {
            $map['id'] = $postdata['keyword'];
        }
        if($postdata['time_form'] && $postdata['time_to']){
            $map['addtime'] = array(array('EGT',strtotime($postdata['time_form'])),array('ELT',strtotime($postdata['time_to'].' +1 days')));
        }else if($postdata['time_form']){
            $map['addtime'] = array(array('GT',strtotime($postdata['time_form'])),array('LT',strtotime($postdata['time_form'].' +1 days')));
        }else if($postdata['time_to']){
            $map['addtime'] = array(array('GT',strtotime(I('time_to'))),array('LT',strtotime(I('time_to').' +1 days')));
        }
        $list = $this->lists('StocktakingInfo', $map);
        $this->assign($postdata);
        $this->assign('list',$list);
        $this->display();
    }
    //仓库盘点单查看
    public function stocktaking_view(){
        $id = intval(I('get.id'));//订单id
        if(empty($id)){
            $this->error("参数错误");
        }
        $map = array();
        $map['stocktaking_id'] = $id;//盘点单id
        $list = $this->lists('StocktakingGoods', $map);
        $this->assign('list',$list);
        $this->assign('id',$id);
        $this->display();
    }
    public function add_deviceid(){
        $shop_id=I('shop_id');
        $type=I('type');
        if(empty($type)){
            if(!empty($shop_id)){
                $map=array();
                $map['id']=$shop_id;
                $map['status']=1;
                $info=M('Shops')->where($map)->field('id,name')->find();
                $this->assign($info);
            }else{
                $this->error("参数错误");
            }
        }else{
            $map=array();
            $map['status']=1;
            $list=M('Shops')->where($map)->field('id,name')->select();
            $this->assign('list',$list);
        }
        $this->assign('type',$type);
        $this->display();
    }
    /**
     * *添加人脸设备
     */
    public function save_device(){
        $param=I('param.');
        if($param['type']=='all'){
            if($param['device_id']){
                foreach ($param['device_id'] as $key => $value) {
                    if($value){
                        $postdata=array();
                        $postdata['shop_id']=$key;
                        $postdata['device_id']=$value;
                        $this->save_device_pub($postdata);
                    }
                }
            }else{
                $this->error("参数错误");
            }
        }else{
            if(!empty($param['device_id']) && !empty($param['shop_id'])){
                $this->save_device_pub($param);
            }else{
                $this->error("参数错误");
            }
        }
    }
    private function save_device_pub($param){
        if($param){
            $face = new \Common\Vendor\Face();
            $map=array();
            $map['id']=$param['shop_id'];
            $shop_info=idtoname($param['shop_id'],'Shops','id,name,group_id','id',false);
            if(empty($shop_info['group_id']) || $shop_info['group_id']==0){
                $result=$face->queryGroup();
                if($result['stat']['code']==0){
                    if($result['data']){
                        foreach ($result['data'] as $key => $value) {
                            if($shop_info['name']==$value['groupname']){
                                $this->error('已存在该分组名称'.$value['groupname'].',分组名称重复');
                            }
                        }
                    }
                    $result=array();
                    $result=$face->addGroup($shop_info['name']);
                    $stat=$result['stat'];
                    if($result['stat']['code']==0){
                        $groupid=$result['data']['id'];
                        $data=array();
                        $data['group_id']=$groupid;
                        M('Shops')->where($map)->save($data);

                    }else{
                        $this->error($result['result']);
                    }
                }else{
                    $this->error($result['result']);
                }
            }else{
                $groupid=$shop_info['group_id'];
            }
            $temp_device_id=array_filter(explode(',',$param['device_id']));
            foreach ($temp_device_id as $key => $value) {
                $result=array();
                $result=$face ->bindingDevice($value,$groupid);
                if($result['stat']['code']==0){
                    $data=array();
                    $data['device_id']=$value;
                    $data['shop_id']=$param['shop_id'];
                    M('ShopsFacedevice')->where($map)->add($data);
                }else{
                    $this->error($result['result']);
                }
            }
            $this->success('添加成功');
        }else{
            $this->error("参数错误");
        }
    }
    public function face_recognition(){
        $map=array();
        $map['s.status']=1;
        $list=M('ShopsFacedevice')->alias('sf')->join('JOIN __SHOPS__ s ON sf.shop_id=s.id')->field('sf.*,s.name,s.status')->where($map)->select();
        $this->assign('list',$list);
        $this->display();
    }
    public function edit_face_viedo(){
        $id=I('id');
        $map=array();
        $map['id']=$id;
        $info=M('ShopsFacedevice')->where($map)->find();
        $this->assign($info);
        $this->display();
    }
    public function save_face_viedo(){
        $param=I('param.');
        if($param){
            $map=$data=array();
            $data['ip']=$param['ip'];
            $map['id']=$param['id'];
            $result=M('ShopsFacedevice')->where($map)->save($data);
            if($result>0){
                $this->success("修改成功");
            }else{
                $this->error("修改失败");
            }
        }else{
            $this->error("参数错误");
        }
    }
    public function delete_device(){
        $id=I('id.');
        if(!empty($id)){
            $map=array();
            $map['id']=$id;
            $result=M('ShopsFacedevice')->where($id)->delete();
            if($result>0){
                $this->success("删除成功");
            }else{
                $this->error("删除失败");
            }
        }else{
            $this->error("参数错误！");
        }
    }
    public function add_group(){
        $map=array();
        $map['group_id']=array('eq',0);
        $list=M('Shops')->where($map)->field('id,name')->select();
        if($list){
            $face = new \Common\Vendor\Face();
            foreach ($list as $key => $value) {
                $result=$face->addGroup($value['name']);
                if($result['stat']['code']==0){
                    $groupid=$result['data']['id'];
                    $data=$map=array();
                    $data['group_id']=$groupid;
                    $map['id']=$value['id'];
                    $res=M('Shops')->where($map)->save($data);
                }
            }
        }
        $this->success('同步成功');
    }

         /**
    *商家入驻选项
    *  ggw 18/12/13
    */
            // type 1 文本框 2 密码框 3日期 4 单选 5 多选
    public function shop_register_config(){
        $config=idtoname('SHOP_REGISTER_CONFIG','Config','value','name',false);
        $register_config=json_decode($config,true);
        $register_config_name=array('name'=>'公司名称','postion'=>'公司所在地','address'=>'详细地址','phone'=>'公司电话','employee_count'=>'员工总数','registered_capital'=>'注册资金','contacts'=>'联系人姓名','contacts_phone'=>'联系电话','email'=>'邮箱','business_licence_number'=>'营业执照','licence_address'=>'营业执照所在地','licence_start'=>'营业执照有效期','business_sphere'=>'经营范围','cate_id'=>'经营类目','business_licence_img'=>'营业执照');
        $this->assign('register_config_name',$register_config_name);
        // 拿到数组处理
        if(empty($register_config)){
            $register_config=array('name'=>'2','postion'=>'2','address'=>'2','phone'=>'2','employee_count'=>'2','registered_capital'=>'2','contacts'=>'2','contacts_phone'=>'2','email'=>'2','business_licence_number'=>'2','licence_address'=>'2','licence_start'=>'2','business_sphere'=>'2','cate_id'=>'2','business_licence_img'=>'2');
            $where=[];$where['name']='SHOP_REGISTER_CONFIG';
            $data['value']=json_encode($register_config);
            M('Config')->where($where)->save($data);
        }
        $this->assign('register_config',$register_config);
        $this->display();
    }

    /**
    *
    *修改标签名称
    */
    public function src_edit(){
        $data=idtoname('SHOP_REGISTER_CONFIG','Config','value','name',false);
        $register_config_name=array('name'=>'公司名称','postion'=>'公司所在地','address'=>'详细地址','phone'=>'公司电话','employee_count'=>'员工总数','registered_capital'=>'注册资金','contacts'=>'联系人姓名','contacts_phone'=>'联系电话','email'=>'邮箱','business_licence_number'=>'营业执照','licence_address'=>'营业执照所在地','licence_start'=>'营业执照有效期','business_sphere'=>'经营范围','cate_id'=>'经营类目','business_licence_img'=>'营业执照');
        $config=json_decode($data,true);
        $postdata=I('param.');
        if(!$postdata['name']){
            $this->error('参数错误');return false;
        }
        if(IS_POST){
            $save=0;
            if($postdata['is_necessary']==2){
                $config[$postdata['name']]=2;
            }else{
                $config[$postdata['name']]=$postdata['is_show'];
            }
            $s_map=[];$s_map['name']='SHOP_REGISTER_CONFIG';
            $data=[];$data['value']=json_encode($config); 
            $suc=M('Config')->where($s_map)->save($data);
            if($suc){
                $this->success('编辑成功');
            }else{
                $this->error('请重试');
            }

        }else{
           
            $assign['name']=$postdata['name'];
            $assign['s_name']=$register_config_name[$postdata['name']];
            $assign['is_necessary']=$config[$postdata['name']]==2?1:0;
            $assign['is_show']=$config[$postdata['name']]>0?1:0;
            $this->assign($assign);
            $this->display();
        }

    }

    public function shop_register_article(){

        if(IS_POST){
            $suc=false;
            $postdata=I('param.'); 
            foreach($postdata['content'] as $k=>$v){
                if(!in_array($k,[32,33,34,35]))continue;
                $s_v['content']=$v;
                $s_v['updatetime']=time();
                $suc=M('ShopsArticle')->where('id='.$k)->save($s_v);
            };
         if($suc){
            $this->success('保存成功',U('shop_register_config'));
         }else{
            $this->error('保存失败，请重试');
         }   
        }else{
            $map['id']=array('in','32,33,34,35');
            $data=M('ShopsArticle')->where($map)->field(true)->select();
            $this->assign('data',$data);
            $this->display();
        }

    }
}
?>