Commit 247c07ed by 冷斌

add

parent a3da9b5c
......@@ -9,9 +9,9 @@
<form method="post" class="form-horizontal js-ajax-form" action="{:U('Welfare/add_post')}">
<fieldset>
<div class="control-group">
<label class="control-label">数量</label>
<label class="control-label">礼物</label>
<div class="controls">
<select name="nums">
<select name="giftid">
<volist name="gift" id="v">
<option value="{$v['id']}">{$v['giftname']}</option>
</volist>
......
......@@ -10,11 +10,11 @@
<input type="hidden" name="id" value="{$data['id']}">
<fieldset>
<div class="control-group">
<label class="control-label">数量</label>
<label class="control-label">礼物</label>
<div class="controls">
<select name="nums">
<volist name="numslist" id="v">
<option value="{$v}" <if condition="$data['nums'] eq $v">selected</if>>{$v}</option>
<select name="giftid">
<volist name="gift" id="v">
<option value="{$v['id']}" <if condition="$data['giftid'] eq $v['id']">selected</if>>{$v['giftname']}</option>
</volist>
</select>
<span class="form-required"></span>
......@@ -22,15 +22,6 @@
</div>
<div class="control-group">
<label class="control-label">倍数</label>
<div class="controls">
<input type="text" name="times" value="{$data['times']}">
<span class="form-required"></span>
</div>
</div>
<div class="control-group">
<label class="control-label">中奖概率</label>
<div class="controls">
<input type="text" name="rate" value="{$data['rate']}">% 最小支持0.01%
......
......@@ -77,7 +77,7 @@ class WelfareController extends AdminbaseController
function del(){
$id=intval($_GET['id']);
if($id){
$result=M("luck_rate")->delete($id);
$result=M("welfare_rate")->delete($id);
if($result){
$this->resetcache();
$this->success('删除成功');
......@@ -95,24 +95,8 @@ class WelfareController extends AdminbaseController
}
function add_post(){
if(IS_POST){
$jackpot=M("luck_rate");
$jackpot=M("welfare_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('相同数量、倍数的配置已存在');
}
$jackpot->addtime=time();
$result=$jackpot->add();
if($result){
$this->resetcache();
......@@ -125,8 +109,8 @@ class WelfareController extends AdminbaseController
function edit(){
$id=intval($_GET['id']);
if($id){
$data=M("luck_rate")->find($id);
$this->assign('numslist', $this->numslist);
$data=M("welfare_rate")->find($id);
$this->assign('gift', $this->getGift());
$this->assign('data', $data);
}else{
$this->error('数据传入失败!');
......@@ -135,23 +119,8 @@ class WelfareController extends AdminbaseController
}
function edit_post(){
if(IS_POST){
$jackpot=M("luck_rate");
$jackpot=M("welfare_rate");
$jackpot->create();
$id=I('id');
$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}' and id!={$id}")->find();
if($check){
$this->error('相同数量、倍数的配置已存在');
}
$result=$jackpot->save();
if($result!==false){
$this->resetcache();
......@@ -162,9 +131,9 @@ class WelfareController extends AdminbaseController
}
}
function resetcache(){
$key='luck_rate';
$key='welfare_rate';
$level= M("luck_rate")->order("id desc")->select();
$level= M("welfare_rate")->where('id!=1')->order("id rate")->select();
if($level){
setcaches($key,$level);
}
......
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