fix(打卡接口): 今日打卡记录和月度打卡记录完善

master
yin5th 2023-01-13 09:48:15 +08:00
parent fdfac7f0e5
commit c5c5fffb8f
1 changed files with 10 additions and 3 deletions

View File

@ -360,7 +360,11 @@ class User extends Base
*/ */
public function signToday(): Json public function signToday(): Json
{ {
$accountId = $this->request->user['user_id'] ?? 0; $accountId = $this->request->user['user_id'] ?? 0;
$day = input('day/s', '');
$day = $day ?: date('Y-m-d');
$worksiteId = input('worksite_id/d', 0);
$worksiteId = $worksiteId ?: 0;
$list = []; $list = [];
@ -372,9 +376,12 @@ class User extends Base
} }
$where = []; $where = [];
$where[] = ['cl.created_at', '>', date('Y-m-d 00:00:00')]; $where[] = ['cl.created_at', '>', date($day.' 00:00:00')];
$where[] = ['cl.created_at', '<', date('Y-m-d 23:59:59')]; $where[] = ['cl.created_at', '<', date($day.' 23:59:59')];
$where[] = ['cl.account_id', '=', $accountId]; $where[] = ['cl.account_id', '=', $accountId];
if ($worksiteId) {
$where[] = ['cl.worksite_id', '=', $worksiteId];
}
$where[] = ['cl.role', '=', $account['role']]; $where[] = ['cl.role', '=', $account['role']];
$limit = $account['role'] == Account::ROLE_NORMAL ? 4 : 0;//普通用户只展示最新4条 其他不限制 $limit = $account['role'] == Account::ROLE_NORMAL ? 4 : 0;//普通用户只展示最新4条 其他不限制