|
@@ -80,12 +80,27 @@ class Active extends Api
|
|
|
$this->error('今天已开奖');
|
|
|
}
|
|
|
|
|
|
- //中奖号码。所有号码中随机拿个一,就一定会中奖
|
|
|
- $box = Db::name('active_user_number')->whereTime('createtime','today')->column('number');
|
|
|
- $gift_number = $box[rand(0,count($box)-1)];
|
|
|
+ //中奖号码组。
|
|
|
+ $box_count_config = [
|
|
|
+ 1 => 1,
|
|
|
+ 2 => 1,
|
|
|
+ 3 => 2,
|
|
|
+ 4 => 2,
|
|
|
+ 5 => 3,
|
|
|
+ 6 => 3,
|
|
|
+ 7 => 4,
|
|
|
+ ];
|
|
|
+ $box_count = $box_count_config[date('N')];//今天开N个
|
|
|
+
|
|
|
+ //所有已存在的不重复号码,打乱之后,取前N个
|
|
|
+ $box = Db::name('active_user_number')->whereTime('createtime','today')->group('number')->column('number');
|
|
|
+ shuffle($box);
|
|
|
+ $box_count = $box_count > count($box) ? count($box) : $box_count;
|
|
|
+ $gift_number = array_chunk($box,$box_count)[0]; //中奖数组,不重复
|
|
|
+ $gift_number = implode(',',$gift_number);
|
|
|
|
|
|
//中奖列表
|
|
|
- $list = Db::name('active_user_number')->whereTime('createtime','today')->where('number',$gift_number)->select();
|
|
|
+ $list = Db::name('active_user_number')->whereTime('createtime','today')->where('number','IN',$gift_number)->select();
|
|
|
$log_ids = array_column($list,'id');//id更新快一点
|
|
|
|
|
|
//每股中奖额度
|