feat(接口): 补卡调整到user 2.暂时关闭打卡时间检查
parent
54c714d79b
commit
137204f0c2
|
@ -593,7 +593,7 @@ class User extends Base
|
||||||
|
|
||||||
// 是否在打卡时间
|
// 是否在打卡时间
|
||||||
if (!Worksite::checkSignTime($input['worksite_id'], $input['type'])) {
|
if (!Worksite::checkSignTime($input['worksite_id'], $input['type'])) {
|
||||||
return $this->json(4002, '不在打卡时间段!');
|
// return $this->json(4002, '不在打卡时间段!');
|
||||||
}
|
}
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
|
@ -631,6 +631,76 @@ class User extends Base
|
||||||
return $this->json();
|
return $this->json();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 提交补卡
|
||||||
|
*/
|
||||||
|
public function replenish(): Json
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$input = input('post.');
|
||||||
|
|
||||||
|
$rules = [
|
||||||
|
'day|补卡日期' => 'require|date',
|
||||||
|
'type|补卡类型' => 'require|in:morning_on,morning_off,afternoon_on,afternoon_off',
|
||||||
|
'worksite_id|工地' => 'require|number',
|
||||||
|
];
|
||||||
|
|
||||||
|
$validate = $this->validateByApi($input, $rules, ['worksite_id.number' => '工地必传', 'type.in' => '补卡类型错误']);
|
||||||
|
|
||||||
|
if ($validate !== true) {
|
||||||
|
return $validate;
|
||||||
|
}
|
||||||
|
|
||||||
|
$accountId = $this->request->user['user_id'] ?? 0;
|
||||||
|
|
||||||
|
if (!$customer = Account::findById($accountId)) {
|
||||||
|
return $this->json(6001, '请先登录');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!in_array($customer['role'], [1, 2])) {
|
||||||
|
return $this->json(4003, '当前身份不能补卡');
|
||||||
|
}
|
||||||
|
|
||||||
|
$time = time();
|
||||||
|
$now = date('Y-m-d H:i:s', $time);
|
||||||
|
$day = date('Ymd', strtotime($input['day']));
|
||||||
|
|
||||||
|
$where = [
|
||||||
|
'account_id' => $accountId,
|
||||||
|
'type' => $input['type'],
|
||||||
|
'worksite_id' => $input['worksite_id'],
|
||||||
|
'day' => $day,
|
||||||
|
'role' => $customer['role'],
|
||||||
|
'indexs' => $accountId.'-'.$input['worksite_id'].'-'.$day,
|
||||||
|
];
|
||||||
|
|
||||||
|
if (ClockLog::where($where)->whereIn('status', [0, 1])->count() > 0) {
|
||||||
|
return $this->json(4001, '记录存在,无需补卡!');
|
||||||
|
}
|
||||||
|
|
||||||
|
$data = [
|
||||||
|
'account_id' => $accountId,
|
||||||
|
'type' => $input['type'],
|
||||||
|
'worksite_id' => $input['worksite_id'],
|
||||||
|
'created_at' => $now,
|
||||||
|
'create_time' => $time,
|
||||||
|
'day' => $day,
|
||||||
|
'role' => $customer['role'],
|
||||||
|
'is_replenish' => ClockLog::COMMON_ON,
|
||||||
|
'indexs' => $accountId.'-'.$input['worksite_id'].'-'.$day,
|
||||||
|
];
|
||||||
|
ClockLog::create($data);
|
||||||
|
|
||||||
|
// 创建当日工资初始记录
|
||||||
|
PayLog::createWhenNotExists($accountId, $input['worksite_id'], $day);
|
||||||
|
} catch (Exception $e) {
|
||||||
|
Log::error('补卡提交失败'.$e->getMessage());
|
||||||
|
return $this->json(5000, '补卡申请失败!');
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->json();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 普通用户打卡
|
* 普通用户打卡
|
||||||
*
|
*
|
||||||
|
|
|
@ -657,74 +657,4 @@ class Worker extends Base
|
||||||
|
|
||||||
return $this->json();
|
return $this->json();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 提交补卡
|
|
||||||
*/
|
|
||||||
public function replenish(): Json
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
$input = input('post.');
|
|
||||||
|
|
||||||
$rules = [
|
|
||||||
'day|补卡日期' => 'require|date',
|
|
||||||
'type|补卡类型' => 'require|in:morning_on,morning_off,afternoon_on,afternoon_off',
|
|
||||||
'worksite_id|工地' => 'require|number',
|
|
||||||
];
|
|
||||||
|
|
||||||
$validate = $this->validateByApi($input, $rules, ['worksite_id.number' => '工地必传', 'type.in' => '补卡类型错误']);
|
|
||||||
|
|
||||||
if ($validate !== true) {
|
|
||||||
return $validate;
|
|
||||||
}
|
|
||||||
|
|
||||||
$accountId = $this->request->user['user_id'] ?? 0;
|
|
||||||
|
|
||||||
if (!$customer = Account::findById($accountId)) {
|
|
||||||
return $this->json(6001, '请先登录');
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($customer['role'] != Account::ROLE_WORKER) {
|
|
||||||
return $this->json(4003, '还不是工人');
|
|
||||||
}
|
|
||||||
|
|
||||||
$time = time();
|
|
||||||
$now = date('Y-m-d H:i:s', $time);
|
|
||||||
$day = date('Ymd', strtotime($input['day']));
|
|
||||||
|
|
||||||
$where = [
|
|
||||||
'account_id' => $accountId,
|
|
||||||
'type' => $input['type'],
|
|
||||||
'worksite_id' => $input['worksite_id'],
|
|
||||||
'day' => $day,
|
|
||||||
'role' => $customer['role'],
|
|
||||||
'indexs' => $accountId.'-'.$input['worksite_id'].'-'.$day,
|
|
||||||
];
|
|
||||||
|
|
||||||
if (ClockLog::where($where)->whereIn('status', [0, 1])->count() > 0) {
|
|
||||||
return $this->json(4001, '记录存在,无需补卡!');
|
|
||||||
}
|
|
||||||
|
|
||||||
$data = [
|
|
||||||
'account_id' => $accountId,
|
|
||||||
'type' => $input['type'],
|
|
||||||
'worksite_id' => $input['worksite_id'],
|
|
||||||
'created_at' => $now,
|
|
||||||
'create_time' => $time,
|
|
||||||
'day' => $day,
|
|
||||||
'role' => $customer['role'],
|
|
||||||
'is_replenish' => ClockLog::COMMON_ON,
|
|
||||||
'indexs' => $accountId.'-'.$input['worksite_id'].'-'.$day,
|
|
||||||
];
|
|
||||||
ClockLog::create($data);
|
|
||||||
|
|
||||||
// 创建当日工资初始记录
|
|
||||||
PayLog::createWhenNotExists($accountId, $input['worksite_id'], $day);
|
|
||||||
} catch (Exception $e) {
|
|
||||||
Log::error('工人补卡提交失败'.$e->getMessage());
|
|
||||||
return $this->json(5000, '补卡申请失败!');
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->json();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue