select(); if (count($users)){ foreach ($users as $user){ $applyRec = \app\common\model\ApplySeller::where('user_id',$user->user_id) ->where('state',1)->find(); if ($applyRec){ $expire = intval(strtotime('+1 year',strtotime($applyRec->update_time))); }else{ $expire = intval(strtotime('+1 year',strtotime($user->create_time))); } User::where('user_id',$user->user_id)->update(['seller_grade'=>1,'seller_expire'=>$expire]); } } } }