112 行
4.4 KiB
PHP
可执行文件
112 行
4.4 KiB
PHP
可执行文件
<?php
|
||
|
||
namespace Retail\Controller;
|
||
//[1.6.46]
|
||
class VipCardMenuBarController extends BaseController
|
||
{
|
||
|
||
public function index()
|
||
{
|
||
//获取用户信息Jurisdiction
|
||
$userinfo = session("ls_userinfo");
|
||
$merchantid = $userinfo['merchantid'];
|
||
$hasaddplugids = M('retail_vipcardmenu_config')
|
||
->where(array('merchantid' => $merchantid,'type'=>2))->getField('plugid',true);
|
||
$hasaddplugids = $hasaddplugids?$hasaddplugids:array(0);
|
||
$map = array();
|
||
$map['type'] = 1;
|
||
$map['status'] = 1;
|
||
$map['templatetype'] = 0;
|
||
$map['plug_name'] = array(array('eq','优惠券'),array('eq','积分商城'),array('eq','次卡'),'OR');
|
||
$plugs = M('plug')
|
||
->where($map)
|
||
->select();
|
||
foreach ($plugs as $k=>$v){
|
||
if(in_array($v['id'],$hasaddplugids)){
|
||
|
||
}else{
|
||
$addData = array(
|
||
'merchantid'=>$merchantid,
|
||
'type'=>2,
|
||
'defaultindex'=>0,
|
||
'menu'=>$v['plug_name'],
|
||
'plugid'=>$v['id']
|
||
);
|
||
M('retail_vipcardmenu_config')->add($addData);
|
||
}
|
||
}
|
||
$defaultarr = array(
|
||
array('merchantid'=>$merchantid,'type'=>1,'defaultindex'=>1,'menu'=>'储值卡中心'),
|
||
array('merchantid'=>$merchantid,'type'=>1,'defaultindex'=>2,'menu'=>'会员卡详情'),
|
||
array('merchantid'=>$merchantid,'type'=>1,'defaultindex'=>3,'menu'=>'每日签到'),
|
||
array('merchantid'=>$merchantid,'type'=>1,'defaultindex'=>4,'menu'=>'分享得积分'),
|
||
array('merchantid'=>$merchantid,'type'=>1,'defaultindex'=>5,'menu'=>'添加到卡包'),
|
||
);
|
||
$hasadddefaultindexs = M('retail_vipcardmenu_config')
|
||
->where(array('merchantid' => $merchantid,'type'=>1))->getField('defaultindex',true);
|
||
foreach ($defaultarr as $k=>$v){
|
||
if(in_array($v['defaultindex'],$hasadddefaultindexs)){
|
||
|
||
}else{
|
||
$addData = array(
|
||
'merchantid'=>$merchantid,
|
||
'type'=>1,
|
||
'defaultindex'=>$v['defaultindex'],
|
||
'menu'=>$v['menu'],
|
||
'plugid'=>0
|
||
);
|
||
M('retail_vipcardmenu_config')->add($addData);
|
||
}
|
||
}
|
||
$info = M('retail_vipcardmenu_config')
|
||
->where(array('merchantid' => $merchantid))->select();
|
||
$arr = array(array(),array());
|
||
foreach ($info as $key=>$value){
|
||
if($value['type'] == 2){
|
||
$value['isopen'] = 2;
|
||
$status = M('plug_merchant')->where(array('merchant_id'=>$merchantid,'plug_id'=>$value['plugid']))->getField('m_status');
|
||
if($status==1){
|
||
$value['isopen'] = 1;
|
||
}
|
||
$arr[0][] = $value;
|
||
}else{
|
||
$value['isopen'] = 1;
|
||
$arr[1][] = $value;
|
||
}
|
||
}
|
||
$this->assign('arr', $arr);
|
||
$arr = array(
|
||
'setVipCardMenuBar' => '/index.php/Retail/VipCardMenuBar/setVipCardMenuBar',
|
||
);
|
||
$authArr = checkFunction($arr);
|
||
$this->assign('authArr', $authArr);
|
||
$this->display();
|
||
}
|
||
|
||
public function setVipCardMenuBar(){
|
||
if(IS_POST){
|
||
$id = I('post.id');
|
||
$userinfo = session("ls_userinfo");
|
||
$merchantid = $userinfo['merchantid'];
|
||
$status = I('post.status');
|
||
$ret = M('retail_vipcardmenu_config')
|
||
->where(array('id'=>$id,'merchantid'=>$merchantid))
|
||
->setField('hide',$status);
|
||
if($ret){
|
||
$rt['status'] = 1;
|
||
$rt['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{
|
||
$rt['status'] = 0;
|
||
$rt['msg'] = '设置失败';
|
||
}
|
||
$this->ajaxReturn($rt);
|
||
}
|
||
}
|
||
} |