Commit 925c6588 by 冷斌

add

parent 3435a9f1
......@@ -4,83 +4,43 @@
<body>
<div class="wrap">
<ul class="nav nav-tabs">
<li class="active"><a >礼物列表</a></li>
<li><a href="{:U('Gift/add')}">礼物添加</a></li>
<li><a href="{:U('Gift/index')}">礼物列表</a></li>
<li class="active"><a >列表</a></li>
<li><a href="{:U('Luckrate/add',array('giftid'=>$giftid))}">添加</a></li>
</ul>
<form method="post" class="js-ajax-form" action="{:U('Gift/listorders')}">
<div class="table-actions">
<button class="btn btn-primary btn-small js-ajax-submit" type="submit">{:L('SORT')}</button>
</div>
<form class="well form-search" name="form1" method="post" action="">
{$giftinfo['giftname']}
</form>
<form method="post" class="js-ajax-form">
<table class="table table-hover table-bordered">
<thead>
<tr>
<th>排序</th>
<th align="center">ID</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>数量</th>
<th>倍数</th>
<th>中奖概率</th>
<th>是否全站通知</th>
<th align="center">{:L('ACTIONS')}</th>
</tr>
</thead>
<tbody>
<foreach name="lists" item="vo">
<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>{$type[$vo['type']]}</td>
<!-- <td>{$gift_sort[$vo['sid']]}</td> -->
<td>{$mark[$vo['mark']]}</td>
<td>{$vo['giftname']}</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>{$vo['nums']}</td>
<td>{$vo['times']}</td>
<td>{$vo['rate']}%</td>
<td><if condition="$vo['isall'] eq 1"><else/></if></td>
<td align="center">
<if condition="$vo['type'] eq 0 && $vo['mark'] eq 3">
<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('Luckrate/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>
</tr>
</foreach>
</tbody>
</table>
<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>
</div>
<script src="__PUBLIC__/js/common.js"></script>
......
......@@ -7,40 +7,38 @@ use Common\Controller\AdminbaseController;
class WelfareController extends AdminbaseController
{
var $type=array("0"=>"普通礼物","1"=>"豪华礼物");
var $mark=array("0"=>"普通","1"=>"热门","2"=>"守护","3"=>"幸运");
var $swftype=array("0"=>"GIF","1"=>"SVGA");
var $numslist=['1','10','66','88','100','520','1314'];
function index(){
$giftid=I('giftid');
$map['giftid']=$giftid;
/* $gift_sort=M("gift_sort")->getField("id,sortname");
$gift_sort[0]="默认分类";
$this->assign('gift_sort', $gift_sort); */
$giftinfo=M('gift')
->field('giftname')
->where("id={$giftid}")
->find();
$gift_model=M("gift");
$count=$gift_model->count();
$jackpot=M("luck_rate");
$count=$jackpot->where($map)->count();
$page = $this->page($count, 20);
$lists = $gift_model
//->where()
->order("orderno, addtime desc")
$lists = $jackpot
->where($map)
->order("id desc")
->limit($page->firstRow . ',' . $page->listRows)
->select();
$this->assign('lists', $lists);
$this->assign('type', $this->type);
$this->assign('mark', $this->mark);
$this->assign('swftype', $this->swftype);
$this->assign('giftid', $giftid);
$this->assign('giftinfo', $giftinfo);
$this->assign("page", $page->show('Admin'));
$this->display();
}
function del(){
$id=intval($_GET['id']);
if($id){
$result=M("gift")->delete($id);
$result=M("luck_rate")->delete($id);
if($result){
$action="删除礼物:{$id}";
setAdminLog($action);
$this->resetcache();
$this->success('删除成功');
}else{
......@@ -51,58 +49,34 @@ class WelfareController extends AdminbaseController
}
$this->display();
}
function add(){
// $gift_sort=M("gift_sort")->getField("id,sortname");
// $this->assign('gift_sort', $gift_sort);
$giftid=I('giftid');
$this->assign('giftid', $giftid);
$this->assign('numslist', $this->numslist);
$this->display();
}
function add_post(){
if(IS_POST){
$gift=M("gift");
$gift->create();
$gift->addtime=time();
$type=I('type');
$swftype=I('swftype');
if($type==1 && $swftype==1){
if($_FILES){
$savepath=date('Ymd').'/';
//上传处理类
$config=array(
'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());
}
}
$jackpot=M("luck_rate");
$jackpot->create();
$giftid=I('giftid');
$nums=I('nums');
$times=I('times');
if($times < 0){
$this->error('中奖倍数不能小于0');
}
$check = $jackpot->where("giftid='{$giftid}' and nums='{$nums}' and times = '{$times}'")->find();
if($check){
$this->error('相同数量、倍数的配置已存在');
}
$result=$gift->add();
$jackpot->addtime=time();
$result=$jackpot->add();
if($result){
$action="添加礼物:{$result}";
setAdminLog($action);
$this->resetcache();
$this->success('添加成功');
}else{
......@@ -113,59 +87,37 @@ class WelfareController extends AdminbaseController
function edit(){
$id=intval($_GET['id']);
if($id){
$gift=M("gift")->find($id);
$this->assign('gift', $gift);
$data=M("luck_rate")->find($id);
$this->assign('numslist', $this->numslist);
$this->assign('data', $data);
}else{
$this->error('数据传入失败!');
}
$this->display();
}
function edit_post(){
if(IS_POST){
$gift=M("gift");
$gift->create();
$type=I('type');
$swftype=I('swftype');
if($type==1 && $swftype==1){
if($_FILES){
$savepath=date('Ymd').'/';
//上传处理类
$config=array(
'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());
}
}
$jackpot=M("luck_rate");
$jackpot->create();
$id=I('id');
$giftid=I('giftid');
$nums=I('nums');
$times=I('times');
if($times < 0){
$this->error('中奖倍数不能小于0');
}
$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){
$action="修改礼物:{$_POST['id']}";
setAdminLog($action);
$this->resetcache();
$this->success('修改成功');
}else{
......@@ -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