|
@@ -36,7 +36,7 @@ class Active extends Api
|
|
|
$this->success('success',$result);
|
|
|
}
|
|
|
|
|
|
- //收集一个气泡
|
|
|
+ //收集所有气泡
|
|
|
public function open_qipao(){
|
|
|
//我今天的应得气泡数量
|
|
|
$qipao_count = $this->get_qipao_count();
|
|
@@ -44,8 +44,8 @@ class Active extends Api
|
|
|
//我今天打开的气泡数量
|
|
|
$my_count = Db::name('active_user_number')->where('createdate',date('Ymd'))->where('user_id',$this->auth->id)->count();
|
|
|
|
|
|
- if($my_count + 1 > $qipao_count){
|
|
|
- $this->error('可收集气泡不足');
|
|
|
+ if($my_count >= $qipao_count){
|
|
|
+ $this->error('没有气泡可以收集了');
|
|
|
}
|
|
|
|
|
|
$week = [
|
|
@@ -59,17 +59,25 @@ class Active extends Api
|
|
|
];
|
|
|
|
|
|
$today_max = $week[date('N')];
|
|
|
- if($my_count + 1 > $today_max){
|
|
|
+ if($my_count >= $today_max){
|
|
|
$this->error('今天最多能收集'.$today_max.'个气泡,已到上限');
|
|
|
}
|
|
|
|
|
|
- $data = [
|
|
|
- 'user_id' => $this->auth->id,
|
|
|
- 'number' => $this->get_rand_number(),
|
|
|
- 'createtime' => time(),
|
|
|
- 'createdate' => date('Ymd'),
|
|
|
- ];
|
|
|
- Db::name('active_user_number')->insertGetId($data);
|
|
|
+ //一次收集完
|
|
|
+ $count = $qipao_count - $my_count;
|
|
|
+ if($count > $today_max - $my_count){
|
|
|
+ $count = $today_max - $my_count;
|
|
|
+ }
|
|
|
+
|
|
|
+ for($i = 1;$i <= $count;$i++){
|
|
|
+ $data[] = [
|
|
|
+ 'user_id' => $this->auth->id,
|
|
|
+ 'number' => $this->get_rand_number(),
|
|
|
+ 'createtime' => time(),
|
|
|
+ 'createdate' => date('Ymd'),
|
|
|
+ ];
|
|
|
+ }
|
|
|
+ Db::name('active_user_number')->insertAll($data);
|
|
|
|
|
|
$this->success('已收集',$this->get_my_number());
|
|
|
}
|