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

接口

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