作者 潘浩文
1 个管道 的构建 通过 耗费 0 秒

接口

@@ -173,20 +173,20 @@ class SignController extends RestBaseController @@ -173,20 +173,20 @@ class SignController extends RestBaseController
173 $endToday=mktime(0,0,0,date('m'),date('d')+1,date('Y'))-1; 173 $endToday=mktime(0,0,0,date('m'),date('d')+1,date('Y'))-1;
174 $yesterday = strtotime(date("Y-m-d",strtotime("-1 day"))); 174 $yesterday = strtotime(date("Y-m-d",strtotime("-1 day")));
175 //已有记录 175 //已有记录
176 - $re=Db::name('user_sign')->where(['user_id'=>$this->getUserId(),'create_time'=>[ 'between time', [$beginToday,$endToday]]])->find(); 176 + $re=Db::name('user_sign')->where(['user_id'=>$user['id'],'create_time'=>[ 'between time', [$beginToday,$endToday]]])->find();
177 if ($re){ 177 if ($re){
178 //更新打卡 178 //更新打卡
179 Db::name('user_sign')->where('id',$re['id'])->update(["$type"=>time()]); 179 Db::name('user_sign')->where('id',$re['id'])->update(["$type"=>time()]);
180 //判断是否打满了4次 180 //判断是否打满了4次
181 if (!empty($re['morning'])&&!empty($re['noon'])&&!empty($re['night'])&&!empty($re['sleep'])){ 181 if (!empty($re['morning'])&&!empty($re['noon'])&&!empty($re['night'])&&!empty($re['sleep'])){
182 Db::name('user_sign')->where('id',$re['id'])->update(['status'=>1]); 182 Db::name('user_sign')->where('id',$re['id'])->update(['status'=>1]);
183 - Db::name('user')->where('id',$this->getUserId())->setInc('all_sign_day',1); 183 + Db::name('user')->where('id',$user['id'])->setInc('all_sign_day',1);
184 //判断是否为连续打卡 184 //判断是否为连续打卡
185 $last=Db::name('user_sign')->where(['user_id'=>$this->getUserId(),'status'=>1,'create_time'=>[ 'between time', [$yesterday,$beginToday]]])->find(); 185 $last=Db::name('user_sign')->where(['user_id'=>$this->getUserId(),'status'=>1,'create_time'=>[ 'between time', [$yesterday,$beginToday]]])->find();
186 186
187 if ($user['stay_sign_day']==0||$last) 187 if ($user['stay_sign_day']==0||$last)
188 { 188 {
189 - Db::name('user')->where('id',$this->getUserId())->setInc('all_sign_day',1); 189 + Db::name('user')->where('id',$this->getUserId())->setInc('stay_sign_day',1);
190 //判断最大连续打卡天数 190 //判断最大连续打卡天数
191 if ($user['stay_sign_day']>$user['longest_sign_day']){ 191 if ($user['stay_sign_day']>$user['longest_sign_day']){
192 Db::name('user')->where('id',$this->getUserId())->update(['longest_sign_day'=>$user['stay_sign_day']]); 192 Db::name('user')->where('id',$this->getUserId())->update(['longest_sign_day'=>$user['stay_sign_day']]);