Commit 925c6588 by 冷斌

add

parent 3435a9f1
...@@ -4,83 +4,43 @@ ...@@ -4,83 +4,43 @@
<body> <body>
<div class="wrap"> <div class="wrap">
<ul class="nav nav-tabs"> <ul class="nav nav-tabs">
<li class="active"><a >礼物列表</a></li> <li><a href="{:U('Gift/index')}">礼物列表</a></li>
<li><a href="{:U('Gift/add')}">礼物添加</a></li> <li class="active"><a >列表</a></li>
<li><a href="{:U('Luckrate/add',array('giftid'=>$giftid))}">添加</a></li>
</ul> </ul>
<form method="post" class="js-ajax-form" action="{:U('Gift/listorders')}"> <form class="well form-search" name="form1" method="post" action="">
<div class="table-actions"> {$giftinfo['giftname']}
<button class="btn btn-primary btn-small js-ajax-submit" type="submit">{:L('SORT')}</button> </form>
</div> <form method="post" class="js-ajax-form">
<table class="table table-hover table-bordered"> <table class="table table-hover table-bordered">
<thead> <thead>
<tr> <tr>
<th>排序</th>
<th align="center">ID</th> <th align="center">ID</th>
<th>类型</th> <th>数量</th>
<!-- <th>分类</th> --> <th>倍数</th>
<th>标识</th> <th>中奖概率</th>
<th>名称</th> <th>是否全站通知</th>
<th>所需点数</th>
<!-- <th>礼物小图 (25 X 25)</th> -->
<th>图片</th>
<th>动画类型</th>
<th>动画</th>
<th>动画时长</th>
<th>发布时间</th>
<th align="center">{:L('ACTIONS')}</th> <th align="center">{:L('ACTIONS')}</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<foreach name="lists" item="vo"> <foreach name="lists" item="vo">
<tr> <tr>
<td><input name="listorders[{$vo['id']}]" type="text" size="3" value="{$vo['orderno']}" class="input input-order"></td>
<td align="center">{$vo.id}</td> <td align="center">{$vo.id}</td>
<td>{$type[$vo['type']]}</td> <td>{$vo['nums']}</td>
<!-- <td>{$gift_sort[$vo['sid']]}</td> --> <td>{$vo['times']}</td>
<td>{$mark[$vo['mark']]}</td> <td>{$vo['rate']}%</td>
<td>{$vo['giftname']}</td> <td><if condition="$vo['isall'] eq 1"><else/></if></td>
<td>{$vo['needcoin']}</td>
<!-- <td><img width="25" height="25" src="{$vo['gifticon_mini']}" /></td> -->
<td><img width="25" height="25" src="{$vo['gifticon']}" /></td>
<td><if condition="$vo['type'] eq 1">{$swftype[$vo['swftype']]}</if></td>
<td><if condition="$vo['swf']">
<if condition="$vo['swftype'] eq 1">
{$vo['swf']}
<else/>
<img width="100" height="100" src="{$vo['swf']}" />
</if>
</if>
</td>
<td>{$vo['swftime']}</td>
<td>{$vo.addtime|date="Y-m-d H:i:s",###}</td>
<td align="center"> <td align="center">
<if condition="$vo['type'] eq 0 && $vo['mark'] eq 3"> <a href="{:U('Luckrate/edit',array('id'=>$vo['id']))}" >编辑</a>
<a href="{:U('Luckrate/index',array('giftid'=>$vo['id']))}" >中奖设置</a>
|
<a href="{:U('Jackpotrate/index',array('giftid'=>$vo['id']))}" >奖池设置</a>
|
</if>
<if condition="$vo['isjusung'] eq 0 ">
<a href="{:U('Gift/recomm',array('id'=>$vo['id']))}" >推荐周星榜</a> |
<else/>
<a href="{:U('Gift/cancel',array('id'=>$vo['id']))}" >取消周星榜 |
</if>
<a href="{:U('Gift/edit',array('id'=>$vo['id']))}" >编辑</a>
| |
<a href="{:U('Gift/del',array('id'=>$vo['id']))}" class="js-ajax-dialog-btn" data-msg="您确定要删除吗?">删除</a> <a href="{:U('Luckrate/del',array('id'=>$vo['id']))}" class="js-ajax-dialog-btn" data-msg="您确定要删除吗?">删除</a>
</td> </td>
</tr> </tr>
</foreach> </foreach>
</tbody> </tbody>
</table> </table>
<div class="pagination">{$page}</div> <div class="pagination">{$page}</div>
<div class="table-actions">
<button class="btn btn-primary btn-small js-ajax-submit" type="submit">{:L('SORT')}</button>
</div>
</form> </form>
</div> </div>
<script src="__PUBLIC__/js/common.js"></script> <script src="__PUBLIC__/js/common.js"></script>
......
...@@ -7,40 +7,38 @@ use Common\Controller\AdminbaseController; ...@@ -7,40 +7,38 @@ use Common\Controller\AdminbaseController;
class WelfareController extends AdminbaseController class WelfareController extends AdminbaseController
{ {
var $numslist=['1','10','66','88','100','520','1314'];
var $type=array("0"=>"普通礼物","1"=>"豪华礼物");
var $mark=array("0"=>"普通","1"=>"热门","2"=>"守护","3"=>"幸运");
var $swftype=array("0"=>"GIF","1"=>"SVGA");
function index(){ function index(){
$giftid=I('giftid');
$map['giftid']=$giftid;
/* $gift_sort=M("gift_sort")->getField("id,sortname"); $giftinfo=M('gift')
$gift_sort[0]="默认分类"; ->field('giftname')
$this->assign('gift_sort', $gift_sort); */ ->where("id={$giftid}")
->find();
$gift_model=M("gift"); $jackpot=M("luck_rate");
$count=$gift_model->count(); $count=$jackpot->where($map)->count();
$page = $this->page($count, 20); $page = $this->page($count, 20);
$lists = $gift_model $lists = $jackpot
//->where() ->where($map)
->order("orderno, addtime desc") ->order("id desc")
->limit($page->firstRow . ',' . $page->listRows) ->limit($page->firstRow . ',' . $page->listRows)
->select(); ->select();
$this->assign('lists', $lists); $this->assign('lists', $lists);
$this->assign('type', $this->type); $this->assign('giftid', $giftid);
$this->assign('mark', $this->mark); $this->assign('giftinfo', $giftinfo);
$this->assign('swftype', $this->swftype);
$this->assign("page", $page->show('Admin')); $this->assign("page", $page->show('Admin'));
$this->display(); $this->display();
} }
function del(){ function del(){
$id=intval($_GET['id']); $id=intval($_GET['id']);
if($id){ if($id){
$result=M("gift")->delete($id); $result=M("luck_rate")->delete($id);
if($result){ if($result){
$action="删除礼物:{$id}";
setAdminLog($action);
$this->resetcache(); $this->resetcache();
$this->success('删除成功'); $this->success('删除成功');
}else{ }else{
...@@ -51,58 +49,34 @@ class WelfareController extends AdminbaseController ...@@ -51,58 +49,34 @@ class WelfareController extends AdminbaseController
} }
$this->display(); $this->display();
} }
function add(){ function add(){
// $gift_sort=M("gift_sort")->getField("id,sortname"); $giftid=I('giftid');
// $this->assign('gift_sort', $gift_sort); $this->assign('giftid', $giftid);
$this->assign('numslist', $this->numslist);
$this->display(); $this->display();
} }
function add_post(){ function add_post(){
if(IS_POST){ if(IS_POST){
$gift=M("gift"); $jackpot=M("luck_rate");
$gift->create(); $jackpot->create();
$gift->addtime=time();
$type=I('type'); $giftid=I('giftid');
$swftype=I('swftype'); $nums=I('nums');
if($type==1 && $swftype==1){ $times=I('times');
if($_FILES){
$savepath=date('Ymd').'/';
//上传处理类 if($times < 0){
$config=array( $this->error('中奖倍数不能小于0');
'rootPath' => './'.C("UPLOADPATH"), }
'savePath' => $savepath,
'maxSize' => 11048576, $check = $jackpot->where("giftid='{$giftid}' and nums='{$nums}' and times = '{$times}'")->find();
'saveName' => array('uniqid',''), if($check){
'exts' => array('svga'), $this->error('相同数量、倍数的配置已存在');
'autoSub' => false,
);
$upload = new \Think\Upload($config);//
$info=$upload->upload();
//开始上传
if ($info) {
//上传成功
//写入附件数据库信息
$first=array_shift($info);
if(!empty($first['url'])){
$url=$first['url'];
}else{
$url=C("TMPL_PARSE_STRING.__UPLOAD__").$savepath.$first['savename'];
}
$gift->swf=$url;
} else {
//上传失败,返回错误
$this->error($upload->getError());
}
}
} }
$result=$gift->add(); $jackpot->addtime=time();
$result=$jackpot->add();
if($result){ if($result){
$action="添加礼物:{$result}";
setAdminLog($action);
$this->resetcache(); $this->resetcache();
$this->success('添加成功'); $this->success('添加成功');
}else{ }else{
...@@ -113,59 +87,37 @@ class WelfareController extends AdminbaseController ...@@ -113,59 +87,37 @@ class WelfareController extends AdminbaseController
function edit(){ function edit(){
$id=intval($_GET['id']); $id=intval($_GET['id']);
if($id){ if($id){
$gift=M("gift")->find($id); $data=M("luck_rate")->find($id);
$this->assign('gift', $gift);
$this->assign('numslist', $this->numslist);
$this->assign('data', $data);
}else{ }else{
$this->error('数据传入失败!'); $this->error('数据传入失败!');
} }
$this->display(); $this->display();
} }
function edit_post(){ function edit_post(){
if(IS_POST){ if(IS_POST){
$gift=M("gift"); $jackpot=M("luck_rate");
$gift->create(); $jackpot->create();
$type=I('type'); $id=I('id');
$swftype=I('swftype'); $giftid=I('giftid');
if($type==1 && $swftype==1){ $nums=I('nums');
if($_FILES){ $times=I('times');
$savepath=date('Ymd').'/';
//上传处理类 if($times < 0){
$config=array( $this->error('中奖倍数不能小于0');
'rootPath' => './'.C("UPLOADPATH"),
'savePath' => $savepath,
'maxSize' => 11048576,
'saveName' => array('uniqid',''),
'exts' => array('svga'),
'autoSub' => false,
);
$upload = new \Think\Upload($config);//
$info=$upload->upload();
//开始上传
if ($info) {
//上传成功
//写入附件数据库信息
$first=array_shift($info);
if(!empty($first['url'])){
$url=$first['url'];
}else{
$url=C("TMPL_PARSE_STRING.__UPLOAD__").$savepath.$first['savename'];
}
$gift->swf=$url;
} else {
//上传失败,返回错误
$this->error($upload->getError());
}
}
} }
$result=$gift->save(); $check = $jackpot->where("giftid='{$giftid}' and nums='{$nums}' and times = '{$times}' and id!={$id}")->find();
if($check){
$this->error('相同数量、倍数的配置已存在');
}
$result=$jackpot->save();
if($result!==false){ if($result!==false){
$action="修改礼物:{$_POST['id']}";
setAdminLog($action);
$this->resetcache(); $this->resetcache();
$this->success('修改成功'); $this->success('修改成功');
}else{ }else{
...@@ -173,4 +125,14 @@ class WelfareController extends AdminbaseController ...@@ -173,4 +125,14 @@ class WelfareController extends AdminbaseController
} }
} }
} }
function resetcache(){
$key='luck_rate';
$level= M("luck_rate")->order("id desc")->select();
if($level){
setcaches($key,$level);
}
return 1;
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment