Skip to content

Commit

Permalink
修复 跨天签到开关不生效的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
liufei-ereach committed Sep 25, 2024
1 parent bd83fbd commit 1c43ea1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
2 changes: 1 addition & 1 deletion locale/zh-Hans.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ mattoid-daily-check-in-history:
max-supplementary-checkin: 最大连续补签数
max-supplementary-checkin-requirement: 允许签到最大连续补签的天数,若中间有已签到的日期则重新计算连续补签天数
span-day-checkin: 允许跨天补签
span-day-checkin-requirement: 开启后,补签日期之后不允许有未签到的日期数据
span-day-checkin-requirement: 开启后,补签日期之后允许有未签到的日期数据
allow-supplementary-check-in: 允许补签
issuance-of-supplementary-cards: 发放补签卡
complimentary-supplementary-card: 赠送补签卡
Expand Down
8 changes: 2 additions & 6 deletions src/Api/Controller/PostCheckinHistoryController.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ public function __construct(SettingsRepositoryInterface $settings, Dispatcher $e
*/
protected function data(ServerRequestInterface $request, Document $document)
{

$actor = RequestUtil::getActor($request);
$userId = Arr::get($actor, 'id');
$checkinDate = Arr::get($request->getParsedBody(), 'date');
Expand Down Expand Up @@ -134,7 +133,7 @@ protected function data(ServerRequestInterface $request, Document $document)
// 需要确认是连续签到,并且补签的前一天和后一天都没有漏签
$tomorrow = date('Y-m-d',strtotime("1 days",strtotime($checkinDate)));
$signedinCount = UserCheckinHistory::query()->where('user_id', $userId)->where('last_checkin_date', '>=', $tomorrow)->count();
if (isset($spanDayCheckin) && !$spanDayCheckin && empty($signedinCount)) {
if (isset($spanDayCheckin) && !$spanDayCheckin && $signedinCount < $diffDay) {
throw new ValidationException(['message' => $this->translator->trans('mattoid-daily-check-in-history.api.error.span-day-checkin', ['date' => $checkinDate])]);
}
$yesterday = date('Y-m-d',strtotime("-1 days",strtotime($checkinDate)));
Expand Down Expand Up @@ -162,10 +161,7 @@ protected function data(ServerRequestInterface $request, Document $document)
$supplementaryCheckinCount ++;
}



$history = $this->events->dispatch(new SupplementaryCheckinEvent($actor, $checkinDate, $totalContinuousCheckinCountHistory, $supplementaryCheckinCount));

return $history;
return reset($history);
}
}

0 comments on commit 1c43ea1

Please sign in to comment.