fix(接口): 今日打卡记录 完善补卡显示逻辑

master
yin5th 2023-01-14 13:55:56 +08:00
parent 48c060ea08
commit b8ebcd8b5e
1 changed files with 12 additions and 9 deletions

View File

@ -376,9 +376,12 @@ class User extends Base
return $this->json(6001, '请先登录'); return $this->json(6001, '请先登录');
} }
$where = []; $where = [];
$where[] = ['cl.created_at', '>', date($day.' 00:00:00')]; // $where[] = ['cl.created_at', '>', date($day.' 00:00:00')];
$where[] = ['cl.created_at', '<', date($day.' 23:59:59')]; // $where[] = ['cl.created_at', '<', date($day.' 23:59:59')];
$dayInt = str_replace('-', '', $day);
$where[] = ['cl.day', '=', $dayInt];
$where[] = ['cl.account_id', '=', $accountId]; $where[] = ['cl.account_id', '=', $accountId];
if ($worksiteId) { if ($worksiteId) {
$where[] = ['cl.worksite_id', '=', $worksiteId]; $where[] = ['cl.worksite_id', '=', $worksiteId];
@ -662,7 +665,7 @@ class User extends Base
return $this->json(4003, '当前身份不能补卡'); return $this->json(4003, '当前身份不能补卡');
} }
if (strtotime($input['day']) < (time()-86400*3) || strtotime($input['day']) > time()) { if (strtotime($input['day']) < (time() - 86400 * 3) || strtotime($input['day']) > time()) {
return $this->json(4003, '只能补三天以内'); return $this->json(4003, '只能补三天以内');
} }
@ -718,7 +721,7 @@ class User extends Base
public function starList(): Json public function starList(): Json
{ {
$accountId = input('account_id/d', 0); $accountId = input('account_id/d', 0);
$accountId = $accountId ?: 0; $accountId = $accountId ?: 0;
$worksiteId = input('worksite_id/d', 0); $worksiteId = input('worksite_id/d', 0);
$worksiteId = $worksiteId ?: 0; $worksiteId = $worksiteId ?: 0;
@ -747,18 +750,18 @@ class User extends Base
foreach ($list as $val) { foreach ($list as $val) {
$starList[$val['year'].'年'][] = [ $starList[$val['year'].'年'][] = [
'year' => $val['year'], 'year' => $val['year'],
'month' => $val['month'], 'month' => $val['month'],
'star' => $val['star'], 'star' => $val['star'],
]; ];
} }
$firstStar = $list->first()['star'] ?? 0; $firstStar = $list->first()['star'] ?? 0;
$info = [ $info = [
'real_name' => $account['real_name'] ?? '', 'real_name' => $account['real_name'] ?? '',
'worksite_name' => Worksite::where('id', $account['worksite_id'])->value('name'), 'worksite_name' => Worksite::where('id', $account['worksite_id'])->value('name'),
'star' => $firstStar, 'star' => $firstStar,
]; ];
return $this->json(0, 'success', ['info' => $info, 'list' => $starList]); return $this->json(0, 'success', ['info' => $info, 'list' => $starList]);