文件
mashangyoujiu/Application/Retail/Controller/CardController.class.php

290 行
10 KiB
PHP
可执行文件

此文件含有模棱两可的 Unicode 字符

此文件含有可能会与其他字符混淆的 Unicode 字符。 如果您是想特意这样的,可以安全地忽略该警告。 使用 Escape 按钮显示他们。

<?php
namespace Retail\Controller;
use Think\Controller;
//[1.6.48]
/**
* 会员卡通知、公众号会员卡模板设置
* Class CardController
* @package Retail\Controller
*/
class CardController extends BaseController
{
//-----------------------------------------会员卡通知部分-------------------------------
public function cardNotice()
{
$arr = array(
'add_notice' => '/index.php/Retail/Card/add_notice',
'edit_notice' => '/index.php/Retail/Card/edit_notice',
'doChangeNotice' => '/index.php/Retail/Card/doChangeNotice',
'del_notice' => '/index.php/Retail/Card/del_notice',
);
$authArr = checkFunction($arr);
$this->assign('authArr', $authArr);
$this->display();
}
public function notice_getNotice()
{
$user = session('ls_userinfo');
$map['merchantid'] = $user['id'];
$map['state'] = 1;
$count = M("vipcard_notice")->where($map)->count();
$notice = M('vipcard_notice')->where($map)->page($_POST['page'], $_POST['limit'])->select();
foreach ($notice as $key=>&$val) {
$val['index'] = $key + 1;
$val['addtime'] = date('Y-m-d H:i:s', $val['addtime']);
}
$res['code'] = 0;
$res['msg'] = '';
$res['data'] = $notice;
$res['count'] = $count;
$this->ajaxReturn($res);
}
public function add_notice()
{
$user = session('ls_userinfo');
$plugList = M('plug as p')
->join('ls_plug_merchant as pm on pm.plug_id=p.id AND pm. m_status=1')
->where(array('pm.merchant_id' => $user['id'], 'p.plug_name' => array('in', '红包,大转盘')))
->field('p.id,p.plug_name')
->select();
$this->assign('plugList', $plugList);
$this->display();
}
public function doAddNotice()
{
$user = session('ls_userinfo');
$content = I('post.content');
if (empty($user) || empty($content)) {
$result['status'] = 0;
$result['msg'] = '缺少参数';
$this->ajaxReturn($result);
}
$notice_type = I('post.notice_type');
$item['url'] = I('post.url');
if ($notice_type != 0) {
$map['p.id'] = $notice_type;
$map['pm.merchant_id'] = $user['id'];
$map['pm.m_status'] = 1;
$plug = M('plug as p')
->join('ls_plug_merchant as pm on pm.plug_id=p.id')
->where($map)
->field('p.*')
->find();
$item['url'] = '/index.php/' . $plug['use_url'];
$item['plug_id'] = $plug['id'];
}
$item['merchantid'] = $user['id'];
$item['content'] = $content;
$item['addtime'] = time();
$item['state'] = 1;
$item['status'] = 1;
$add = M('vipcard_notice')->add($item);
if ($add) {
$result['status'] = 1;
$result['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 {
$result['status'] = 0;
$result['msg'] = '添加失败';
}
$this->ajaxReturn($result);
}
public function del_notice()
{
$user = session('ls_userinfo');
$id = I('post.id');
if (empty($user) || empty($id)) {
$result['status'] = 0;
$result['msg'] = '缺少参数';
$this->ajaxReturn($result);
}
$del = M('vipcard_notice')->where(array('id' => $id))->delete();
if ($del) {
$result['status'] = 1;
$result['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 {
$result['status'] = 0;
$result['msg'] = '删除失败';
}
$this->ajaxReturn($result);
}
public function edit_notice()
{
$id = I('get.id');
$user = session('ls_userinfo');
$plugList = M('plug as p')
->join('ls_plug_merchant as pm on pm.plug_id=p.id AND pm. m_status=1')
->where(array('pm.merchant_id' => $user['id'], 'p.plug_name' => array('in', '红包,大转盘')))
->field('p.id,p.plug_name')
->select();
$notice = M('vipcard_notice')->where(array('id' => $id, 'merchantid' => $user['id']))->find();
$this->assign('notice', $notice);
$this->assign('plugList', $plugList);
$this->display();
}
public function doChangeNotice()
{
$user = session('ls_userinfo');
$id = I('post.id');
$status = I('post.status');
if (empty($id) || empty($status)) {
$result['status'] = 0;
$result['msg'] = '缺少参数';
$this->ajaxReturn($result);
}
$map['id'] = $id;
if ($status == 1) {
//去关闭
$update = M('vipcard_notice')->where($map)->save(array('status' => 2));
$value = 2;
} else {
$update = M('vipcard_notice')->where($map)->save(array('status' => 1));
$value = 1;
}
if ($update) {
$result['value'] = $value;
$result['status'] = 1;
$result['msg'] = '修改成功';
//操作日志记录
if($status == 1){
$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 {
$result['value'] = $status;
$result['status'] = 0;
$result['msg'] = '修改失败';
}
$this->ajaxReturn($result);
}
public function editNotice()
{
$user = session('ls_userinfo');
$id = I('post.id');
$content = I('post.content');
if (empty($user) || empty($content) || empty($id)) {
$result['status'] = 0;
$result['msg'] = '缺少参数';
$this->ajaxReturn($result);
}
$notice_type = I('post.notice_type');
$item['url'] = I('post.url');
if ($notice_type != 0) {
$map['p.id'] = $notice_type;
$map['pm.merchant_id'] = $user['id'];
$map['pm.m_status'] = 1;
$plug = M('plug as p')
->join('ls_plug_merchant as pm on pm.plug_id=p.id')
->where($map)
->field('p.*')
->find();
$item['url'] = '/index.php/' . $plug['use_url'];
$item['plug_id'] = $plug['id'];
} else {
$item['plug_id'] = '';
}
$item['merchantid'] = $user['id'];
$item['content'] = $content;
$item['addtime'] = time();
$item['state'] = 1;
$item['status'] = 1;
$add = M('vipcard_notice')->where(array('id' => $id))->save($item);
if ($add) {
$result['status'] = 1;
$result['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 {
$result['status'] = 0;
$result['msg'] = '修改失败';
}
$this->ajaxReturn($result);
}
public function template()
{
$user = session('ls_userinfo');
$config = M('vip_config')->where(array('merchantid' => $user['id']))->find();
$this->assign('status', $config['style_model']?$config['style_model']:1);
$arr = array(
'setVipModel' => '/index.php/Retail/Card/setVipModel',
);
$authArr = checkFunction($arr);
$this->assign('authArr', $authArr);
$this->display();
}
public function setVipModel()
{
$status = I('post.status');
if (empty($status) || ($status != 1 && $status != 2 && $status != 3)) {
$res['status'] = 0;
$res['msg'] = '缺少参数';
}else{
$user = session('ls_userinfo');
$config = M('vip_config')->where(array('merchantid' => $user['id']))->find();
if(empty($config)){
$add['merchantid'] = $user['id'];
$add['style_model'] = $status;
$add['addtime'] = time();
$data = M('vip_config')->add($add);
}else{
$data = M('vip_config')->where(array('merchantid' => $user['id']))
->save(array('style_model'=>$status,'viptemplatesign'=>''));
}
if($data){
$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);
}
}