正在显示
1 个修改的文件
包含
19 行增加
和
4 行删除
@@ -133,6 +133,16 @@ class SignController extends RestBaseController | @@ -133,6 +133,16 @@ class SignController extends RestBaseController | ||
133 | * @return sleep:睡前打卡记录(null为未进行睡前打卡) | 133 | * @return sleep:睡前打卡记录(null为未进行睡前打卡) |
134 | */ | 134 | */ |
135 | public function daySign(){ | 135 | public function daySign(){ |
136 | + $param=$this->request->param(); | ||
137 | + if ($param['status']==1){ | ||
138 | + $type='morning'; | ||
139 | + }elseif ($param['status']==2){ | ||
140 | + $type='noon'; | ||
141 | + }elseif ($param['status']==3){ | ||
142 | + $type='night'; | ||
143 | + }elseif ($param['status']==4){ | ||
144 | + $type='sleep'; | ||
145 | + } | ||
136 | //用户信息 | 146 | //用户信息 |
137 | $user=Db::name('user')->where('id',$this->getUserId())->find(); | 147 | $user=Db::name('user')->where('id',$this->getUserId())->find(); |
138 | //当天签到记录 | 148 | //当天签到记录 |
@@ -168,13 +178,10 @@ class SignController extends RestBaseController | @@ -168,13 +178,10 @@ class SignController extends RestBaseController | ||
168 | public function daySignPost(){ | 178 | public function daySignPost(){ |
169 | $param=$this->request->param(); | 179 | $param=$this->request->param(); |
170 | $user=Db::name('user')->where('id',$this->getUserId())->find(); | 180 | $user=Db::name('user')->where('id',$this->getUserId())->find(); |
171 | - //是否需要进入每日一签页面 | ||
172 | - $day_sign=0; | 181 | + |
173 | //根据签到种类判断增加积分数 | 182 | //根据签到种类判断增加积分数 |
174 | $score=Db::name('config')->where('id',1)->find(); | 183 | $score=Db::name('config')->where('id',1)->find(); |
175 | if ($param['status']==1){ | 184 | if ($param['status']==1){ |
176 | - //根据星期判断music,image(只有早签到) | ||
177 | - | ||
178 | //早签到积分 | 185 | //早签到积分 |
179 | $score=$score['morning_sign_score']; | 186 | $score=$score['morning_sign_score']; |
180 | $type='morning'; | 187 | $type='morning'; |
@@ -188,6 +195,11 @@ class SignController extends RestBaseController | @@ -188,6 +195,11 @@ class SignController extends RestBaseController | ||
188 | $score=$score['sleep_sign_score']; | 195 | $score=$score['sleep_sign_score']; |
189 | $type='sleep'; | 196 | $type='sleep'; |
190 | } | 197 | } |
198 | + | ||
199 | + if(Db::name('user_sign')->where(['user_id'=>$user['id'],$type=>['neq',null]])->find()){ | ||
200 | + $this->error('当前时间段已签到'); | ||
201 | + } | ||
202 | + | ||
191 | //将签到写入记录 | 203 | //将签到写入记录 |
192 | $beginToday=mktime(0,0,0,date('m'),date('d'),date('Y')); | 204 | $beginToday=mktime(0,0,0,date('m'),date('d'),date('Y')); |
193 | $endToday=mktime(0,0,0,date('m'),date('d')+1,date('Y'))-1; | 205 | $endToday=mktime(0,0,0,date('m'),date('d')+1,date('Y'))-1; |
@@ -195,6 +207,8 @@ class SignController extends RestBaseController | @@ -195,6 +207,8 @@ class SignController extends RestBaseController | ||
195 | //已有记录 | 207 | //已有记录 |
196 | $re=Db::name('user_sign')->where(['user_id'=>$user['id'],'create_time'=>[ 'between time', [$beginToday,$endToday]]])->find(); | 208 | $re=Db::name('user_sign')->where(['user_id'=>$user['id'],'create_time'=>[ 'between time', [$beginToday,$endToday]]])->find(); |
197 | if ($re){ | 209 | if ($re){ |
210 | + //是否需要进入每日一签页面 | ||
211 | + $day_sign=0; | ||
198 | //更新打卡 | 212 | //更新打卡 |
199 | Db::name('user_sign')->where('id',$re['id'])->update(["$type"=>time()]); | 213 | Db::name('user_sign')->where('id',$re['id'])->update(["$type"=>time()]); |
200 | //判断是否打满了4次 | 214 | //判断是否打满了4次 |
@@ -219,6 +233,7 @@ class SignController extends RestBaseController | @@ -219,6 +233,7 @@ class SignController extends RestBaseController | ||
219 | } | 233 | } |
220 | //无记录 | 234 | //无记录 |
221 | else{ | 235 | else{ |
236 | + //是否需要进入每日一签页面 | ||
222 | $day_sign=1; | 237 | $day_sign=1; |
223 | Db::name('user_sign')->insert(['user_id'=>$this->getUserId(),'create_time'=>time(),"$type"=>time()]); | 238 | Db::name('user_sign')->insert(['user_id'=>$this->getUserId(),'create_time'=>time(),"$type"=>time()]); |
224 | } | 239 | } |
-
请 注册 或 登录 后发表评论