Commit e52579f0 by 冷斌

fix bug

parent 343bced4
...@@ -6,16 +6,17 @@ ...@@ -6,16 +6,17 @@
namespace Admin\Controller; namespace Admin\Controller;
use Common\Controller\AdminbaseController; use Common\Controller\AdminbaseController;
class LuckrateController extends AdminbaseController { class LuckrateController extends AdminbaseController {
var $numslist=['1','10','66','88','100','520','1314']; // var $numslist=['1','10','66','88','100','520','1314'];
protected $numslist = ['1'];
function index(){ function index(){
$giftid=I('giftid'); $giftid=I('giftid');
$map['giftid']=$giftid; $map['giftid']=$giftid;
$giftinfo=M('gift') $giftinfo=M('gift')
->field('giftname') ->field('giftname')
->where("id={$giftid}") ->where("id={$giftid}")
->find(); ->find();
$jackpot=M("luck_rate"); $jackpot=M("luck_rate");
$count=$jackpot->where($map)->count(); $count=$jackpot->where($map)->count();
$page = $this->page($count, 20); $page = $this->page($count, 20);
...@@ -30,82 +31,82 @@ class LuckrateController extends AdminbaseController { ...@@ -30,82 +31,82 @@ class LuckrateController extends AdminbaseController {
$this->assign('giftinfo', $giftinfo); $this->assign('giftinfo', $giftinfo);
$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("luck_rate")->delete($id); $result=M("luck_rate")->delete($id);
if($result){ if($result){
$this->resetcache(); $this->resetcache();
$this->success('删除成功'); $this->success('删除成功');
}else{ }else{
$this->error('删除失败'); $this->error('删除失败');
} }
}else{ }else{
$this->error('数据传入失败!'); $this->error('数据传入失败!');
} }
$this->display(); $this->display();
} }
function add(){ function add(){
$giftid=I('giftid'); $giftid=I('giftid');
$this->assign('giftid', $giftid); $this->assign('giftid', $giftid);
$this->assign('numslist', $this->numslist); $this->assign('numslist', $this->numslist);
$this->display(); $this->display();
} }
function add_post(){ function add_post(){
if(IS_POST){ if(IS_POST){
$jackpot=M("luck_rate"); $jackpot=M("luck_rate");
$jackpot->create(); $jackpot->create();
$giftid=I('giftid'); $giftid=I('giftid');
$nums=I('nums'); $nums=I('nums');
$times=I('times'); $times=I('times');
if($times < 0){ if($times < 0){
$this->error('中奖倍数不能小于0'); $this->error('中奖倍数不能小于0');
} }
$check = $jackpot->where("giftid='{$giftid}' and nums='{$nums}' and times = '{$times}'")->find(); $check = $jackpot->where("giftid='{$giftid}' and nums='{$nums}' and times = '{$times}'")->find();
if($check){ if($check){
$this->error('相同数量、倍数的配置已存在'); $this->error('相同数量、倍数的配置已存在');
} }
$jackpot->addtime=time(); $jackpot->addtime=time();
$result=$jackpot->add(); $result=$jackpot->add();
if($result){ if($result){
$this->resetcache(); $this->resetcache();
$this->success('添加成功'); $this->success('添加成功');
}else{ }else{
$this->error('添加失败'); $this->error('添加失败');
} }
} }
} }
function edit(){ function edit(){
$id=intval($_GET['id']); $id=intval($_GET['id']);
if($id){ if($id){
$data=M("luck_rate")->find($id); $data=M("luck_rate")->find($id);
$this->assign('numslist', $this->numslist); $this->assign('numslist', $this->numslist);
$this->assign('data', $data); $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){
$jackpot=M("luck_rate"); $jackpot=M("luck_rate");
$jackpot->create(); $jackpot->create();
$id=I('id'); $id=I('id');
$giftid=I('giftid'); $giftid=I('giftid');
$nums=I('nums'); $nums=I('nums');
...@@ -114,20 +115,20 @@ class LuckrateController extends AdminbaseController { ...@@ -114,20 +115,20 @@ class LuckrateController extends AdminbaseController {
if($times < 0){ if($times < 0){
$this->error('中奖倍数不能小于0'); $this->error('中奖倍数不能小于0');
} }
$check = $jackpot->where("giftid='{$giftid}' and nums='{$nums}' and times = '{$times}' and id!={$id}")->find(); $check = $jackpot->where("giftid='{$giftid}' and nums='{$nums}' and times = '{$times}' and id!={$id}")->find();
if($check){ if($check){
$this->error('相同数量、倍数的配置已存在'); $this->error('相同数量、倍数的配置已存在');
} }
$result=$jackpot->save(); $result=$jackpot->save();
if($result!==false){ if($result!==false){
$this->resetcache(); $this->resetcache();
$this->success('修改成功'); $this->success('修改成功');
}else{ }else{
$this->error('修改失败'); $this->error('修改失败');
} }
} }
} }
function resetcache(){ function resetcache(){
$key='luck_rate'; $key='luck_rate';
...@@ -136,8 +137,8 @@ class LuckrateController extends AdminbaseController { ...@@ -136,8 +137,8 @@ class LuckrateController extends AdminbaseController {
if($level){ if($level){
setcaches($key,$level); setcaches($key,$level);
} }
return 1; 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