$params['title'], 'start_time' => strtotime($params['start_time']), 'end_time' => strtotime($params['end_time']), 'labor_time' => (strtotime($params['end_time']) - strtotime($params['start_time'])) / 3600, 'labor_type' => $params['labor_type'], 'cid' => $params['cid'], 'remark' => $params['remark'] ?? '', 'admin_id' => $admin_id ]); Db::commit(); return true; } catch (\Exception $e) { Db::rollback(); self::setError($e->getMessage()); return false; } } /** * @notes 编辑工作记录 * @param array $params * @return bool * @author likeadmin * @date 2024/05/23 14:27 */ public static function edit(array $params): bool { Db::startTrans(); try { OaSchedule::where('id', $params['id'])->update([ 'title' => $params['title'], 'start_time' => strtotime($params['start_time']), 'end_time' => strtotime($params['end_time']), 'labor_time' => (strtotime($params['end_time']) - strtotime($params['start_time'])) / 3600, 'labor_type' => $params['labor_type'], 'cid' => $params['cid'], 'remark' => $params['remark'] ?? '' ]); Db::commit(); return true; } catch (\Exception $e) { Db::rollback(); self::setError($e->getMessage()); return false; } } /** * @notes 删除工作记录 * @param array $params * @return bool * @author likeadmin * @date 2024/05/23 14:27 */ public static function delete(array $params): bool { return OaSchedule::destroy($params['id']); } /** * @notes 获取工作记录详情 * @param $params * @return array * @author likeadmin * @date 2024/05/23 14:27 */ public static function detail($params): array { $data = OaSchedule::findOrEmpty($params['id']); $data['cid_text'] = $data->cid_text; $data['labor_type_text'] = $data->labor_type_text; return $data->toArray(); } /** * @notes 获取工作记录日历 * @param $params * @return array * @author likeadmin * @date 2024/05/23 11:53 */ public static function calendar($params){ $where[] = [ ['admin_id','=',$params['admin_id']], ['start_time','>=',strtotime($params['start_time'])], ['end_time','<=',strtotime($params['end_time'])] ]; $data = OaSchedule::where($where)->select()->toArray(); return $data; } }