init: import production code mss.nahaichuan.com (exclude Runtime/Uploads/backups/logs)
这个提交包含在:
@@ -0,0 +1,178 @@
|
||||
<?php
|
||||
|
||||
namespace Retail\Controller;
|
||||
//[1.4.13]
|
||||
class VipShareController extends BaseController
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
$shareinfo = session("ls_userinfo");
|
||||
$info = M('retail_vipshare')->where(array('merchantid' => $shareinfo['merchantid']))->find();
|
||||
if ($info) {
|
||||
$this->assign('state', 1);
|
||||
} else {
|
||||
$this->assign('state', 2);
|
||||
}
|
||||
$arr = array(
|
||||
'addshare' => '/index.php/Retail/VipShare/addshare',
|
||||
'delinfo' => '/index.php/Retail/VipShare/delinfo',
|
||||
);
|
||||
$authArr = checkFunction($arr);
|
||||
$this->assign('authArr', $authArr);
|
||||
$this->display();
|
||||
}
|
||||
|
||||
//信息
|
||||
public function vipshare()
|
||||
{
|
||||
$shareinfo = session("ls_userinfo");
|
||||
$info = M('retail_vipshare')->where(array('merchantid' => $shareinfo['merchantid']))->find();
|
||||
$count = M('retail_vipshare')->where(array('merchantid' => $shareinfo['merchantid']))->count();
|
||||
if ($info) {
|
||||
if (!empty($info['image_id'])) {
|
||||
$info['image'] = D('ImageGallery')->getOneField(array('id' => $info['image_id']), 'path');
|
||||
}
|
||||
$rt['code'] = 0;
|
||||
$rt['msg'] = '';
|
||||
$rt['count'] = $count;
|
||||
$rt['data'] = array($info);
|
||||
} else {
|
||||
$rt['code'] = 0;
|
||||
$rt['msg'] = '';
|
||||
$rt['count'] = 0;
|
||||
$rt['data'] = array();
|
||||
}
|
||||
$this->ajaxReturn($rt);
|
||||
}
|
||||
|
||||
//添加
|
||||
public function addshare()
|
||||
{
|
||||
$id = I('get.id');
|
||||
if ($id) {
|
||||
$info = M('retail_vipshare')->where(array('id' => $id))->find();
|
||||
if (!empty($info['image_id'])) {
|
||||
$info['image'] = D('ImageGallery')->getOneField(array('id' => $info['image_id']), 'path');
|
||||
}
|
||||
$this->assign('info', $info);
|
||||
$this->assign('id', $id);
|
||||
}
|
||||
$this->display();
|
||||
}
|
||||
|
||||
//添加成功
|
||||
public function adds()
|
||||
{
|
||||
$user = session('ls_userinfo');
|
||||
if (IS_POST) {
|
||||
$data = I('post.');
|
||||
$id = $data['id'];
|
||||
$image_id = I('post.image_id');
|
||||
if (!$image_id && empty($_FILES['image']['name'])) {
|
||||
$res['status'] = 0;
|
||||
$res['msg'] = '请上传图片';
|
||||
$this->ajaxReturn($res);
|
||||
}
|
||||
if ($_FILES['image']['error'] == 0) {
|
||||
$item = array(
|
||||
'add_time' => time(),
|
||||
'from_type_id' => 22,
|
||||
'localUrl' => 'Merchant/Grade',
|
||||
'user_type' => 3,
|
||||
'merchant_id' => $user['id']
|
||||
);
|
||||
$uploads = uploadFiles($item);
|
||||
if (!empty($uploads['image']['savePath'])) {
|
||||
$image_id = $uploads['image']['id'];
|
||||
$save['image'] = $uploads['image']['path'];
|
||||
}
|
||||
}else if(!empty($image_id)){
|
||||
$save['image'] = D('ImageGallery')->getOneField(array('id'=>$image_id),'path');
|
||||
}
|
||||
$save['title'] = $data['title'];
|
||||
$save['describe'] = $data['describe'];
|
||||
$save['integral'] = $data['integral'];
|
||||
$save['image_id'] = $image_id ? $image_id : 0;
|
||||
//print_r($save);
|
||||
if ($id) {
|
||||
$add = M('retail_vipshare')->where(array('id' => $id))->save($save);
|
||||
} else {
|
||||
$data['merchantid'] = $user['merchantid'];
|
||||
$data['addtime'] = time();
|
||||
$add = M('retail_vipshare')->add($data);
|
||||
}
|
||||
if ($add) {
|
||||
$res['status'] = 1;
|
||||
$res['msg'] = '设置成功';
|
||||
//操作日志记录
|
||||
if ($id) {
|
||||
$msg='编辑会员卡分享规则';
|
||||
}else{
|
||||
$msg='新增会员卡分享规则';
|
||||
}
|
||||
$source = 0;//请求来源: 0pc系统 1小助手
|
||||
$type = 3;//平台:1合伙人端 2代理商端 3商户端 4门店端
|
||||
$request_data = json_encode($_POST);//请求参数 json数据
|
||||
$desc = $msg;//操作行为描述
|
||||
action_log($source,$type,$request_data,$desc);
|
||||
//end
|
||||
} else {
|
||||
$res['status'] = 1;
|
||||
$res['msg'] = '设置失败';
|
||||
}
|
||||
$this->ajaxReturn($res);
|
||||
}
|
||||
}
|
||||
|
||||
//删除
|
||||
public function delinfo()
|
||||
{
|
||||
if (IS_POST) {
|
||||
$id = I('post.id');
|
||||
$del = M('retail_vipshare')->where(array('id' => $id))->delete();
|
||||
if ($del) {
|
||||
$res['status'] = 1;
|
||||
$res['msg'] = '操作成功';
|
||||
//操作日志记录
|
||||
$source = 0;//请求来源: 0pc系统 1小助手
|
||||
$type = 3;//平台: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 upload()
|
||||
{
|
||||
$upload = new \Think\Upload (); // 实例化上传类
|
||||
$upload->maxSize = 5242880 / 2; // 设置附件上传大小5M/5
|
||||
$upload->exts = array(
|
||||
'jpg',
|
||||
'png',
|
||||
'jpeg',
|
||||
); // 设置附件上传类型
|
||||
$upload->rootPath = 'Uploads'; // 设置附件上传根目录
|
||||
$upload->savePath = '/vipshare/'; // 设置附件上传(子)目录
|
||||
$upload->saveName = array(
|
||||
'uniqid',
|
||||
array('', true)
|
||||
);
|
||||
// 上传文件
|
||||
$info = $upload->upload();
|
||||
if (!empty($info['file']['savename'])) {
|
||||
$path = "/" . $upload->rootPath . $info['file']['savepath'] . $info['file']['savename'];
|
||||
$rt['status'] = 1;
|
||||
$rt['path'] = $path;
|
||||
} else {
|
||||
$rt['status'] = 0;
|
||||
$rt['msg'] = '图片上传失败';
|
||||
}
|
||||
$this->ajaxReturn($rt);
|
||||
}
|
||||
}
|
||||
在新工单中引用
屏蔽一个用户