168 行
5.7 KiB
PHP
可执行文件
168 行
5.7 KiB
PHP
可执行文件
<?php
|
||
|
||
namespace Retail\Controller;
|
||
//[1.4.13]
|
||
class FaceClientController extends BaseController
|
||
{
|
||
public function index()
|
||
{
|
||
$arr = array(
|
||
'add'=>'/index.php/Retail/FaceClient/imgAdd',
|
||
'del'=>'/index.php/Retail/FaceClient/delList',
|
||
);
|
||
$authArr = checkFunction($arr);
|
||
$this->assign('authArr',$authArr);
|
||
$this->display();
|
||
}
|
||
/*列表
|
||
*
|
||
*/
|
||
public function imgList()
|
||
{
|
||
|
||
$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'=>1
|
||
);
|
||
$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 imgAdd()
|
||
{
|
||
$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' => 44,
|
||
'localUrl' => 'Store/Face',
|
||
'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)) {
|
||
$msg='编辑背景图片';
|
||
$map['id'] = $editId;
|
||
$success = D('FaceBackGround')->updateOrder($map, $data);
|
||
} else {
|
||
$msg='新增背景图片';
|
||
$data['store_id'] = $store_id;
|
||
$data['merchant_id'] = $merchant_id;
|
||
$data['scene_type'] = 1;
|
||
$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);
|
||
}
|
||
} |