feat(打卡接口): 调整普通用户打卡逻辑
parent
d102eb2844
commit
a1716ce10a
|
@ -462,13 +462,13 @@ class User extends Base
|
|||
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();
|
||||
}
|
||||
|
||||
$input = input('post.');
|
||||
|
||||
$rules = [
|
||||
'type|打卡类型' => 'require|in:morning_on,morning_off,afternoon_on,afternoon_off',
|
||||
'lat|维度' => 'require',
|
||||
|
@ -541,20 +541,20 @@ class User extends Base
|
|||
* @throws \app\exception\ApiException
|
||||
* @throws \think\db\exception\DbException
|
||||
*/
|
||||
private function normalSign(int $accountId): bool
|
||||
private function normalSign(int $accountId, string $type): bool
|
||||
{
|
||||
$time = time();
|
||||
// $time = $time - 86401 * 3;
|
||||
$now = date('Y-m-d H:i:s', $time);
|
||||
$day = date('Ymd', $time);
|
||||
|
||||
if (ClockLog::checkRate($accountId)) {
|
||||
if (ClockLog::checkRate($accountId, $type)) {
|
||||
throw new ApiException('打卡频率过快!');
|
||||
}
|
||||
|
||||
ClockLog::create([
|
||||
'account_id' => $accountId,
|
||||
'type' => ClockLog::TYPE_NORMAL,
|
||||
'type' => $type,
|
||||
'created_at' => $now,
|
||||
'create_time' => $time,
|
||||
'day' => $day,
|
||||
|
|
Loading…
Reference in New Issue