diff --git a/application/adminapi/controller/Lottery.php b/application/adminapi/controller/Lottery.php index 0308c2af..860292c7 100644 --- a/application/adminapi/controller/Lottery.php +++ b/application/adminapi/controller/Lottery.php @@ -46,31 +46,113 @@ class Lottery extends adminApi * 配置设置 */ public function config_set(){ + $bb_lottery_config = Db::name('bb_lottery_config')->column('value', 'key'); + $small_pool_trigger_times = $bb_lottery_config['small_pool_trigger_times'];//初级开奖的累计次数 + $lottery_rate = $bb_lottery_config['lottery_rate'];//初级最大爆币率 + $small_pool_trigger_times_5 = $bb_lottery_config['small_pool_trigger_times_5'];//中级开奖的累计次数 + $lottery_rate_5 = $bb_lottery_config['lottery_rate_5'];//中级最大爆币率 + $small_pool_trigger_times_10 = $bb_lottery_config['small_pool_trigger_times_10'];//高级最大爆币率 + $lottery_rate_10 = $bb_lottery_config['lottery_rate_10'];//高级最大爆币率 $params = $this->request->post(); + $small_type = 0; + $small_type_5 = 0; + $small_type_10 = 0; + foreach ($params as $k=>$v){ $data = [ 'value'=>$v, ]; db::name("bb_lottery_config")->where(['key'=>$k])->update($data); + + if($k=='small_pool_trigger_times'){ + if($v != $small_pool_trigger_times){ + $small_type = 1; + } + } + if($k=='lottery_rate'){ + if($v != $lottery_rate){ + $small_type = 1; + } + } + + if($k=='small_pool_trigger_times_5'){ + if($v != $small_pool_trigger_times_5){ + $small_type_5 = 1; + } + } + if($k=='lottery_rate_5'){ + if($v != $lottery_rate_5){ + $small_type_5 = 1; + } + } + + if($k=='small_pool_trigger_times_10'){ + if($v != $small_pool_trigger_times_10){ + $small_type_10 = 1; + } + } + if($k=='lottery_rate_10'){ + if($v != $lottery_rate_10){ + $small_type_10 = 1; + } + } } $this->redis = Cache::store('redis')->handler(); - $prize_amount = $this->redis->get('lottery:small_pool:total_gold'); + if($small_type==1){ + $prize_amount = $this->redis->get('lottery:small_pool:total_gold'); + Db::name('bb_lottery_winner_record')->insert([ + 'uid' => 0, + 'prize_type' => 1, + 'prize_amount' => $prize_amount, + 'pool_amount' => $prize_amount, + 'ratio' => 100, + 'release_amount' => $prize_amount, + 'create_time' => time(), + 'status' => 0 // 未发放 + ]); + //修改开启下一轮 + $dd =$this->redis->get('lottery:small_pool:round'); + $this->redis->set('lottery:small_pool:round', $dd+1); + $this->redis->set('lottery:small_pool:total_times',0); + $this->redis->set('lottery:small_pool:total_gold',0); + } + if($small_type_5==1){ + $prize_amount_5 = $this->redis->get('lottery:small_pool:total_gold_5'); + Db::name('bb_lottery_winner_record')->insert([ + 'uid' => 0, + 'prize_type' => 3, + 'prize_amount' => $prize_amount_5, + 'pool_amount' => $prize_amount_5, + 'ratio' => 100, + 'release_amount' => $prize_amount_5, + 'create_time' => time(), + 'status' => 0 // 未发放 + ]); + //修改开启下一轮 + $dd5 =$this->redis->get('lottery:small_pool:round_5'); + $this->redis->set('lottery:small_pool:round_5', $dd5+1); + $this->redis->set('lottery:small_pool:total_times_5',0); + $this->redis->set('lottery:small_pool:total_gold_5',0); + } + if($small_type_10==1){ + $prize_amount_10 = $this->redis->get('lottery:small_pool:total_gold_10'); + Db::name('bb_lottery_winner_record')->insert([ + 'uid' => 0, + 'prize_type' => 4, + 'prize_amount' => $prize_amount_10, + 'pool_amount' => $prize_amount_10, + 'ratio' => 100, + 'release_amount' => $prize_amount_10, + 'create_time' => time(), + 'status' => 0 // 未发放 + ]); + //修改开启下一轮 + $dd_10 =$this->redis->get('lottery:small_pool:round_10'); + $this->redis->set('lottery:small_pool:round_10', $dd_10+1); + $this->redis->set('lottery:small_pool:total_times_10',0); + $this->redis->set('lottery:small_pool:total_gold_10',0); + } - Db::name('bb_lottery_winner_record')->insert([ - 'uid' => 0, - 'prize_type' => 1, - 'prize_amount' => $prize_amount, - 'pool_amount' => $prize_amount, - 'ratio' => 100, - 'release_amount' => $prize_amount, - 'create_time' => time(), - 'status' => 0 // 未发放 - ]); - //修改开启下一轮 - $dd =$this->redis->get('lottery:small_pool:round'); - $this->redis->set('lottery:small_pool:round', $dd+1); - $this->redis->set('lottery:small_pool:total_times',0); - $this->redis->set('lottery:small_pool:total_gold',0); return V(1,"成功"); }