From 37c146a4e0b88ed651104dfdb575f907003fa694 Mon Sep 17 00:00:00 2001 From: yin5th <541304803@qq.com> Date: Wed, 11 Jan 2023 11:21:47 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E6=89=93=E5=8D=A1=E6=8E=A5=E5=8F=A3):=20?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E6=89=93=E5=8D=A1=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controller/api/v1/User.php | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/app/controller/api/v1/User.php b/app/controller/api/v1/User.php index 0531ab7..b52984e 100644 --- a/app/controller/api/v1/User.php +++ b/app/controller/api/v1/User.php @@ -358,19 +358,27 @@ class User extends Base $list = []; if ($accountId > 0) { + if (!$account = Account::findById($accountId)) { + return $this->json(6001, '请先登录'); + } + $where = []; $where[] = ['cl.created_at', '>', date('Y-m-d 00:00:00')]; $where[] = ['cl.created_at', '<', date('Y-m-d 23:59:59')]; $where[] = ['cl.account_id', '=', $accountId]; + + $where[] = ['cl.role', '=', $account['role']]; + $limit = $account['role'] == Account::ROLE_NORMAL ? 4 : 0;//普通用户只展示最新4条 其他不限制 $list = \app\model\ClockLog::alias('cl') ->leftJoin('worksite w', 'w.id = cl.worksite_id') ->field('cl.*,w.name as worksite_name') ->where($where) + ->limit($limit) ->order('cl.id', 'desc') ->select(); $list->each(function ($item) { - $item->type_text = $item->type == 'in' ? '上班' : '下班'; + $item->type_text = ClockLog::typeText()[$item->type]; switch ($item->status) { case 0: $item->status_text = '待确认'; @@ -382,7 +390,7 @@ class User extends Base $item->status_text = '不通过'; break; } - $item->time = date('H:i:s', $item->create_time); + $item->time = date('H:i', $item->create_time); }); $list = $list->toArray(); } @@ -506,6 +514,7 @@ class User extends Base 'created_at' => $now, 'create_time' => $time, 'day' => $day, + 'role' => $customer['role'], 'indexs' => $accountId.'-'.$input['worksite_id'].'-'.$day, ]; @@ -537,6 +546,7 @@ class User extends Base * 普通用户打卡 * * @param int $accountId + * @param string $type * @return bool * @throws \app\exception\ApiException * @throws \think\db\exception\DbException @@ -558,6 +568,7 @@ class User extends Base 'created_at' => $now, 'create_time' => $time, 'day' => $day, + 'status' => ClockLog::COMMON_ON, ]); return true;