Commit 247c07ed by 冷斌

add

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