display(); // } public function index() { $arr = array( 'model' => '/index.php/Retail/Checkstand/model', 'screen' => '/index.php/Retail/Checkstand/screen', 'self_cash'=>'/index.php/Retail/Checkstand/self_cash' ); $authArr = checkFunction($arr); $this->assign('authArr', $authArr); $this->display(); } // 加载模板(收银机模板) public function model() { $type = I('get.type'); if (empty($type)) { $this->error('访问错误'); } $storeid = session('storeid'); if ($type == 2) { $id = I('get.id'); if (empty($id)) { $this->error('访问错误'); } $cashier = M('retail_cashier')->where(array('storeid' => $storeid, 'id' => $id, 'status' => 1))->find(); if (empty($cashier)) { $this->error('收银员不存在'); } $this->assign('status', $cashier['cash_model']); $this->assign('id', $id); } else { $all = M('retail_cashier')->where(array('storeid' => $storeid, 'status' => 1))->count(); $all1 = M('retail_cashier')->where(array('storeid' => $storeid, 'status' => 1, 'cash_model' => 1))->count(); if ($all && $all == $all1) { $this->assign('status', 1); } else if ($all && $all1 == 0) { $this->assign('status', 2); } } $this->assign('type', $type); $this->display(); } // 设置收银机模板 public function setModel() { $storeid = session('storeid'); $type = I('post.type'); $id = I('post.id'); $status = I('post.status'); if (empty($status) || empty($type)) { $res['status'] = 0; $res['msg'] = '缺少参数'; $this->ajaxReturn($res); } if ($type == 1) { $update = M('retail_cashier')->where(array('storeid' => $storeid, 'status' => 1))->save(array('cash_model' => $status)); } else if ($type == 2) { if (empty($id)) { $res['status'] = 0; $res['msg'] = '缺少参数'; $this->ajaxReturn($res); } $update = M('retail_cashier')->where(array('storeid' => $storeid, 'status' => 1, 'id' => $id))->save(array('cash_model' => $status)); } else { $res['status'] = 0; $res['msg'] = '参数有误'; $this->ajaxReturn($res); } if ($update) { $res['status'] = 1; $res['msg'] = '设置成功'; //操作日志记录 $source = 0;//请求来源: 0pc系统 1小助手 $type = 4;//平台:1合伙人端 2代理商端 3商户端 4门店端 $request_data = json_encode($_POST);//请求参数 json数据 $desc = '统一设置收音机模板';//操作行为描述 action_log($source,$type,$request_data,$desc); //end } else { $res['status'] = 0; $res['msg'] = '设置成功'; } $this->ajaxReturn($res); } // 加载模板(副屏) public function screen() { $storeid = session('storeid'); $storeModel = D("RetailStore"); $checkStand = M('retail_checkstand_screen')->where(array('storeid' => $storeid))->order('id desc')->select(); $checkStand = $checkStand ? $checkStand : array(); $type = $storeModel->getFindField(array($storeModel::ID=>$storeid),$storeModel::SCREEN_TYPE); $this->assign('checkStand', json_encode($checkStand)); $this->assign('type',$type); $this->display(); } //修改显示内容 public function ScreenOperation() { $store_id = session("storeid"); $storeModel = D("RetailStore"); $type = I('post.type'); if(!$store_id){ $res['status'] = 0; $res['msg'] = '登录超时'; $this->ajaxReturn($res); } $success = $storeModel->updateOrder(array($storeModel::ID=>$store_id),array($storeModel::SCREEN_TYPE=>$type)); if($success){ $res['status'] = 1; $res['msg'] = '操作成功'; //操作日志记录 $source = 0;//请求来源: 0pc系统 1小助手 $type = 4;//平台:1合伙人端 2代理商端 3商户端 4门店端 $request_data = json_encode($_POST);//请求参数 json数据 $desc = '统一设置收银机副屏';//操作行为描述 action_log($source,$type,$request_data,$desc); //end }else{ $res['status'] = 0; $res['msg'] = '操作失败'; } $this->ajaxReturn($res); } // 添加轮播图 public function addCheckStand() { $storeid = session('storeid'); $user = session('ls_userinfo'); $videoType = ['video/mp4', 'video/ogg', 'video/flv', 'video/avi', 'video/wmv', 'video/rmvb']; if (!empty($user) && IS_POST && !empty($storeid)) { $image_id = I('post.image_id'); if(!empty($image_id)){ $type = I('post.image_type'); } if (empty($image_id) && (empty($_FILES) || $_FILES['image']['error'] != 0)) { $res['status'] = 0; $res['msg'] = '请选择图片/或视频'; $this->ajaxReturn($res); } if ($_FILES['image']['error'] == 0) { $item = array( 'add_time' => time(), 'from_type_id' => 40, 'localUrl' => 'Store/CheckStand', 'user_type' => 4, 'merchant_id' => $user['merchantid'], 'store_id' => $storeid ); if(in_array($_FILES['image']['type'],$videoType)){ $item['type'] = 2; } $uploads = uploadFiles($item); if (!empty($uploads['image'])) { $image_id = $uploads['image']['id']; $image = $uploads['image']['path']; } else { $res['status'] = 0; $res['msg'] = '图片上传失败'; $this->ajaxReturn($res); } }else{ $image = D('ImageGallery')->getOneField(array('id'=>$image_id),'path'); } $data['storeid'] = $storeid; $data['addtime'] = time(); $data['image_id'] = $image_id; $data['image'] = $image; if($_FILES['image']['error'] == 0 && in_array($_FILES['image']['type'],$videoType)){ $data['type'] = 2; }else if(!empty($type)){ $data['type'] = $type; } $add = M('retail_checkstand_screen')->add($data); if ($add) { $res['status'] = 1; $res['msg'] = '添加成功'; $res['id'] = $add; } else { $res['status'] = 0; $res['msg'] = '添加失败'; } } else { $res['status'] = 0; $res['msg'] = '登录超时'; } $this->ajaxReturn($res); } // 删除图片 public function checkStandDel() { if (IS_POST) { $id = I('post.id'); if (!empty($id)) { $del_art = M('retail_checkstand_screen')->where(array('id' => $id))->delete(); if (!empty($del_art)) { $res['status'] = 1; $res['msg'] = '删除成功'; //操作日志记录 $source = 0;//请求来源: 0pc系统 1小助手 $type = 4;//平台:1合伙人端 2代理商端 3商户端 4门店端 $request_data = json_encode($_POST);//请求参数 json数据 $desc = '统一设置收银机副屏-删除图片';//操作行为描述 action_log($source,$type,$request_data,$desc); //end } else { $res['status'] = 0; $res['msg'] = '删除失败'; } } else { $res['status'] = 0; $res['msg'] = '缺失参数'; } $this->ajaxReturn($res); } } public function self_cash() { $this->display(); } /*列表 * */ public function selfCashImgList() { $store_id = session("storeid"); $data = I("post."); $page = $data['page'].','.$data['limit']; $where = array( 'store_id'=>$store_id, 'status'=>array('in','0,1'), 'scene_type'=>2 ); $list = D('FaceBackGround')->getSelect($where,"*","id desc",$page); if($list){ $count = D('FaceBackGround')->getCount($where); foreach ($list as $key=>&$val){ $val['key'] = $key + 1; $val['img'] = D('ImageGallery')->getFieldPath(array('id' => $val['img_id'])); } } $res['status'] = 1; $res['imgList'] = $list; $res['count'] = $count?$count:0; $this->ajaxReturn($res); } /* * label添加 */ public function selfCashImgAdd() { $merchant_id = session('ls_userinfo')['merchantid']; $store_id = session("storeid"); $editId = json_decode($_POST['editId'], true); $order = json_decode($_POST['order'],true); $label_img_id = I('post.label_img_id'); if (!$label_img_id) { $label_img = $_FILES['label_img']; if ($label_img['error'] == 0) { /* 上传图片 */ $updata = array( 'add_time' => time(), 'from_type_id' => 46, 'localUrl' => 'Store/SelfCash', 'user_type' => 4, 'merchant_id' => $merchant_id, 'store_id' => $store_id ); $uploads = uploadFiles($updata); if ($uploads['label_img']['savePath'] && $uploads['label_img']['id']) { $data['img_id'] = $uploads['label_img']['id']; } else { $res['status'] = 0; $res['msg'] = '图片上传失败,请重试'; $this->ajaxReturn($res); } } else { $res['status'] = 0; $res['msg'] = '请上传图片'; $this->ajaxReturn($res); } } else { $data['img_id'] = $label_img_id; } $data['sort'] = $order; if (!empty($editId)) { $map['id'] = $editId; $msg='编辑轮播图片'; $success = D('FaceBackGround')->updateOrder($map, $data); } else { $msg='新增轮播图片'; $data['store_id'] = $store_id; $data['merchant_id'] = $merchant_id; $data['scene_type'] = 2; $success = D('FaceBackGround')->addOrder($data); } if ($success) { $res['status'] = 1; $res['msg'] = '操作成功'; //操作日志记录 $source = 0;//请求来源: 0pc系统 1小助手 $type = 4;//平台:1合伙人端 2代理商端 3商户端 4门店端 $request_data = json_encode($_POST);//请求参数 json数据 $desc = '自助收银机'.$msg;//操作行为描述 action_log($source,$type,$request_data,$desc); //end } else { $res['status'] = 0; $res['msg'] = '暂无修改'; } $this->ajaxReturn($res); } /*开启关闭 * */ public function changeState() { $data = I("post."); $id = $data['id']; $status = $data['status']; if(!$id || !isset($status)){ $res['status'] = 0; $res['msg'] = '参数缺失'; $this->ajaxReturn($res); } $save = D("FaceBackGround")->updateOrder(array('id'=>$id),array('status'=>$status)); if($save){ $res['status'] = 1; $res['msg'] = '操作成功'; //操作日志记录 $source = 0;//请求来源: 0pc系统 1小助手 $type = 4;//平台:1合伙人端 2代理商端 3商户端 4门店端 $request_data = json_encode($_POST);//请求参数 json数据 $desc = '自助收银机修改轮播图片使用状态';//操作行为描述 action_log($source,$type,$request_data,$desc); //end }else{ $res['status'] = 0; $res['msg'] = '暂无修改'; } $this->ajaxReturn($res); } /*删除 * */ public function delList() { $id = I("post.id"); if(!$id){ $res['status'] = 0; $res['msg'] = '参数缺失'; $this->ajaxReturn($res); } $del = D("FaceBackGround")->updateOrder(array('id'=>$id),array('status'=>2)); if($del){ $res['status'] = 1; $res['msg'] = '操作成功'; //操作日志记录 $source = 0;//请求来源: 0pc系统 1小助手 $type = 4;//平台:1合伙人端 2代理商端 3商户端 4门店端 $request_data = json_encode($_POST);//请求参数 json数据 $desc = '自助收银机删除轮播图片';//操作行为描述 action_log($source,$type,$request_data,$desc); //end }else{ $res['status'] = 0; $res['msg'] = '请勿重复操作'; } $this->ajaxReturn($res); } }