40 lines
1020 B
PHP
40 lines
1020 B
PHP
|
<?php
|
||
|
|
||
|
namespace app\dao;
|
||
|
|
||
|
use App\model\Signlog;
|
||
|
|
||
|
|
||
|
|
||
|
class SignDao {
|
||
|
/**
|
||
|
* 签到函数
|
||
|
*
|
||
|
*/
|
||
|
public static function Sign($user_id) {
|
||
|
$Signlog=new Signlog();
|
||
|
$Signlog->userid=$user_id;
|
||
|
$Signlog->save();
|
||
|
UserRewardDao::sing($user_id,30);
|
||
|
}
|
||
|
/**
|
||
|
* 查询今天是否签到
|
||
|
* 0没签到1签到
|
||
|
*/
|
||
|
public static function search_Sign_today($user_id){
|
||
|
$today = date('Y-m-d');
|
||
|
$is_sign=Signlog::where('userid',$user_id)->where('created_at', '>=', $today." 00:00:00")->count();
|
||
|
return $is_sign==0?0:1;
|
||
|
}
|
||
|
/**
|
||
|
* 查询当月签到数据
|
||
|
*
|
||
|
*/
|
||
|
public static function search_Sign_tomon($user_id){
|
||
|
$startTime = date('Y-m-01',time());//获取该月份的第一天
|
||
|
$endTime = date('Y-m-t',time());//获取该月份的最后一天
|
||
|
$mon_data=Signlog::whereBetween('created_at', [$startTime." 00:00:00", $endTime." 23:59:59"])->orderBy('created_at','DESC')->get();
|
||
|
|
||
|
}
|
||
|
}
|