feat(打卡接口): 调整普通用户打卡逻辑

master
yin5th 2023-01-11 10:41:47 +08:00
parent d102eb2844
commit a1716ce10a
1 changed files with 6 additions and 6 deletions

View File

@ -462,13 +462,13 @@ class User extends Base
return $this->json(6001, '请先登录'); return $this->json(6001, '请先登录');
} }
$input = input('post.');
// 工人打卡 // 工人打卡
if ($customer['role'] == Account::ROLE_NORMAL && $this->normalSign($accountId)) { if ($customer['role'] == Account::ROLE_NORMAL && $this->normalSign($accountId, $input['type'])) {
return $this->json(); return $this->json();
} }
$input = input('post.');
$rules = [ $rules = [
'type|打卡类型' => 'require|in:morning_on,morning_off,afternoon_on,afternoon_off', 'type|打卡类型' => 'require|in:morning_on,morning_off,afternoon_on,afternoon_off',
'lat|维度' => 'require', 'lat|维度' => 'require',
@ -541,20 +541,20 @@ class User extends Base
* @throws \app\exception\ApiException * @throws \app\exception\ApiException
* @throws \think\db\exception\DbException * @throws \think\db\exception\DbException
*/ */
private function normalSign(int $accountId): bool private function normalSign(int $accountId, string $type): bool
{ {
$time = time(); $time = time();
// $time = $time - 86401 * 3; // $time = $time - 86401 * 3;
$now = date('Y-m-d H:i:s', $time); $now = date('Y-m-d H:i:s', $time);
$day = date('Ymd', $time); $day = date('Ymd', $time);
if (ClockLog::checkRate($accountId)) { if (ClockLog::checkRate($accountId, $type)) {
throw new ApiException('打卡频率过快!'); throw new ApiException('打卡频率过快!');
} }
ClockLog::create([ ClockLog::create([
'account_id' => $accountId, 'account_id' => $accountId,
'type' => ClockLog::TYPE_NORMAL, 'type' => $type,
'created_at' => $now, 'created_at' => $now,
'create_time' => $time, 'create_time' => $time,
'day' => $day, 'day' => $day,