更新
This commit is contained in:
@@ -393,6 +393,21 @@ class DiagnosisController extends BaseAdminController
|
||||
return $this->data($result);
|
||||
}
|
||||
|
||||
/** @notes 将本机保留录音补转写的完整文字保存到已结束的通话 */
|
||||
public function saveLocalAudioTranscript()
|
||||
{
|
||||
if (!$this->request->isPost()) {
|
||||
return $this->fail('请求方式错误');
|
||||
}
|
||||
$params = $this->request->post('', null, null);
|
||||
$params['admin_id'] = (int)$this->adminId;
|
||||
$result = DiagnosisLogic::saveLocalAudioTranscript($params);
|
||||
if ($result === false) {
|
||||
return $this->fail(DiagnosisLogic::getError());
|
||||
}
|
||||
return $this->data($result);
|
||||
}
|
||||
|
||||
/** @notes 完成当前通话转写并固化对话文字 */
|
||||
public function finishCallTranscription()
|
||||
{
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace app\adminapi\controller\tcm;
|
||||
|
||||
use app\adminapi\controller\BaseAdminController;
|
||||
use app\adminapi\logic\tcm\MobileRecordingLogic;
|
||||
use DomainException;
|
||||
|
||||
/** Authenticated metadata sync; no upload, transcript or arbitrary file URL endpoint. */
|
||||
final class MobileRecordingController extends BaseAdminController
|
||||
{
|
||||
public function bind()
|
||||
{
|
||||
return $this->handle(true, fn (array $params): array => MobileRecordingLogic::bind($params, $this->adminId));
|
||||
}
|
||||
|
||||
public function unbind()
|
||||
{
|
||||
return $this->handle(true, fn (array $params): array => MobileRecordingLogic::unbind($params, $this->adminId));
|
||||
}
|
||||
|
||||
public function deviceLists()
|
||||
{
|
||||
return $this->handle(false, fn (array $params): array => MobileRecordingLogic::deviceLists($params, $this->adminId));
|
||||
}
|
||||
|
||||
public function patientLists()
|
||||
{
|
||||
return $this->handle(false, fn (array $params): array => MobileRecordingLogic::patientLists($params, $this->adminId));
|
||||
}
|
||||
|
||||
private function handle(bool $post, callable $operation)
|
||||
{
|
||||
if ($post ? !$this->request->isPost() : !$this->request->isGet()) {
|
||||
return $this->fail('请求方式错误');
|
||||
}
|
||||
try {
|
||||
// Explicit current page permission, including before any row lookup.
|
||||
MobileRecordingLogic::actor((int) $this->adminId);
|
||||
if ($this->request->file()) {
|
||||
throw new DomainException('手机录音关联不接受文件上传');
|
||||
}
|
||||
$params = $post ? $this->request->post('', null, null) : $this->request->get();
|
||||
return $this->data($operation($params));
|
||||
} catch (DomainException $e) {
|
||||
return $this->fail($e->getMessage());
|
||||
} catch (\Throwable $e) {
|
||||
// Do not expose SQL, identifiers, paths or server configuration on schema/deployment errors.
|
||||
return $this->fail('手机录音关联服务暂不可用,请稍后重试或联系管理员');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -109,6 +109,16 @@ class AuthMiddleware
|
||||
return JsonService::fail('权限不足,无法查看面诊记录');
|
||||
}
|
||||
|
||||
// Full-audio recovery exercises all three realtime write capabilities.
|
||||
// Protect it explicitly before the unregistered-route compatibility branch.
|
||||
if ($accessUri === 'tcm.diagnosis/savelocalaudiotranscript') {
|
||||
$uris = $this->formatUrl($adminAuthCache->getAdminUri() ?? []);
|
||||
$required = ['tcm.diagnosis/startcalltranscription',
|
||||
'tcm.diagnosis/upsertcalltranscriptsegments', 'tcm.diagnosis/finishcalltranscription'];
|
||||
return array_diff($required, $uris) === []
|
||||
? $next($request) : JsonService::fail('权限不足,无法保存录音补转写');
|
||||
}
|
||||
|
||||
// This group must never use the legacy unregistered-route bypass.
|
||||
if (str_starts_with($accessUri, 'tcm.followupaudio/')) {
|
||||
$allowed = ['capabilities', 'uploadsession', 'uploadchunk', 'uploadcomplete',
|
||||
@@ -135,6 +145,16 @@ class AuthMiddleware
|
||||
return JsonService::fail('权限不足,无法访问或操作');
|
||||
}
|
||||
|
||||
// Metadata-only mobile links always share the patient page grant, even before menu registration.
|
||||
if (str_starts_with($accessUri, 'tcm.mobilerecording/')) {
|
||||
$action = substr($accessUri, strlen('tcm.mobilerecording/'));
|
||||
$uris = $this->formatUrl($adminAuthCache->getAdminUri() ?? []);
|
||||
if (in_array($action, ['bind', 'unbind', 'devicelists', 'patientlists'], true)
|
||||
&& in_array('firstvisit.mypatient/lists', $uris, true)) {
|
||||
return $next($request); // Controller re-reads grants; logic enforces the current patient scope.
|
||||
}
|
||||
return JsonService::fail('权限不足,无法访问我的患者录音关联');
|
||||
}
|
||||
// 全部路由
|
||||
$allUri = $this->formatUrl($adminAuthCache->getAllUri());
|
||||
|
||||
|
||||
@@ -2023,6 +2023,20 @@ class DiagnosisLogic extends BaseLogic
|
||||
}
|
||||
}
|
||||
|
||||
/** @notes 本机完整录音补转写;不重新打开实时转写会话 */
|
||||
public static function saveLocalAudioTranscript(array $params)
|
||||
{
|
||||
try {
|
||||
return \app\adminapi\service\LocalAudioTranscriptRecovery::save($params);
|
||||
} catch (\DomainException $e) {
|
||||
self::setError($e->getMessage());
|
||||
return false;
|
||||
} catch (\Throwable $e) {
|
||||
self::setError('录音补转写保存失败,请稍后重试');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 完成实时转写并将最终文字固化在通话记录上
|
||||
* @return array|false
|
||||
@@ -2068,10 +2082,9 @@ class DiagnosisLogic extends BaseLogic
|
||||
$callRecordId = (int)$record['id'];
|
||||
$snapshot = self::buildCallTranscriptSnapshot($callRecordId, $sessionId);
|
||||
$actualCount = (int)$snapshot['segment_count'];
|
||||
$finalStatus = $requestedStatus;
|
||||
if ($requestedStatus === 'completed' && $actualCount < $expectedCount) {
|
||||
$finalStatus = 'partial';
|
||||
}
|
||||
$finalStatus = \app\adminapi\service\LocalAudioTranscriptRecovery::completionStatus(
|
||||
$requestedStatus, $actualCount, $expectedCount, $snapshot['transcript_text']
|
||||
);
|
||||
$now = time();
|
||||
$record->save([
|
||||
'transcription_status' => $finalStatus,
|
||||
|
||||
@@ -0,0 +1,230 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace app\adminapi\logic\tcm;
|
||||
|
||||
use app\adminapi\logic\firstvisit\MyPatientLogic;
|
||||
use app\common\model\tcm\Diagnosis;
|
||||
use DomainException;
|
||||
use think\db\Query;
|
||||
use think\facade\Db;
|
||||
|
||||
/** Metadata only. This service never accepts, reads or uploads a recording or transcript. */
|
||||
final class MobileRecordingLogic
|
||||
{
|
||||
public const PAGE_PERMISSION = 'firstvisit.myPatient/lists';
|
||||
|
||||
/** Re-read the actor and grants; token role/root snapshots are not authorization. */
|
||||
public static function actor(int $adminId, bool $lock = false): array
|
||||
{
|
||||
$row = Db::name('admin')->where('id', $adminId)->whereNull('delete_time')
|
||||
->where('disable', 0)->lock($lock)->find();
|
||||
if ($adminId <= 0 || !$row) {
|
||||
throw new DomainException('账号已停用或登录状态失效');
|
||||
}
|
||||
$roles = Db::name('admin_role')->where('admin_id', $adminId)->column('role_id');
|
||||
$info = ['admin_id' => $adminId, 'id' => $adminId, 'root' => (int) $row['root'], 'role_id' => $roles];
|
||||
if ($info['root'] !== 1) {
|
||||
$menuIds = $roles ? Db::name('system_role_menu')->whereIn('role_id', $roles)->column('menu_id') : [];
|
||||
$allowed = $menuIds && Db::name('system_menu')->whereIn('id', $menuIds)
|
||||
->where('is_disable', 0)->where('perms', self::PAGE_PERMISSION)->count() > 0;
|
||||
if (!$allowed) {
|
||||
throw new DomainException('权限不足,无法访问我的患者录音关联');
|
||||
}
|
||||
}
|
||||
return $info;
|
||||
}
|
||||
|
||||
public static function bind(array $params, int $adminId): array
|
||||
{
|
||||
$p = self::bindingInput($params);
|
||||
return Db::transaction(static function () use ($p, $adminId): array {
|
||||
// Serialize mutations for this actor, including the first INSERT for an absent key.
|
||||
$info = self::actor($adminId, true);
|
||||
$existing = self::ownedQuery($adminId, $p)->lock(true)->find();
|
||||
$ids = array_unique([$p['diagnosis_id'], (int) ($existing['diagnosis_id'] ?? $p['diagnosis_id'])]);
|
||||
sort($ids);
|
||||
$patients = [];
|
||||
foreach ($ids as $id) {
|
||||
$patients[$id] = self::diagnosis($id, $adminId, $info, true);
|
||||
}
|
||||
$now = time();
|
||||
if ($existing) {
|
||||
$id = (int) $existing['id'];
|
||||
self::ownedQuery($adminId, $p)->where('id', $id)->update($p + ['updated_at' => $now]);
|
||||
$row = array_merge($existing, $p, ['updated_at' => $now]);
|
||||
} else {
|
||||
$row = $p + ['admin_id' => $adminId, 'created_at' => $now, 'updated_at' => $now];
|
||||
$row['id'] = (int) Db::name('mobile_recording_binding')->insertGetId($row);
|
||||
}
|
||||
return ['binding' => self::deviceRow($row, $patients[$p['diagnosis_id']])];
|
||||
});
|
||||
}
|
||||
|
||||
public static function unbind(array $params, int $adminId): array
|
||||
{
|
||||
self::only($params, ['installation_id', 'recording_key']);
|
||||
$identity = self::identity($params);
|
||||
return Db::transaction(static function () use ($identity, $adminId): array {
|
||||
$info = self::actor($adminId, true);
|
||||
$row = self::ownedQuery($adminId, $identity)->lock(true)->find();
|
||||
if ($row) {
|
||||
self::diagnosis((int) $row['diagnosis_id'], $adminId, $info, true);
|
||||
self::ownedQuery($adminId, $identity)->where('id', (int) $row['id'])->delete();
|
||||
}
|
||||
return ['unbound' => true];
|
||||
});
|
||||
}
|
||||
|
||||
public static function deviceLists(array $params, int $adminId): array
|
||||
{
|
||||
self::only($params, ['installation_id', 'page_no', 'page_size']);
|
||||
$installationId = self::installation($params['installation_id'] ?? null);
|
||||
[$page, $size] = self::pagination($params, 50);
|
||||
$info = self::actor($adminId);
|
||||
$query = Db::name('mobile_recording_binding')->alias('b')
|
||||
->join([(new Diagnosis())->getTable() => 'd'], 'd.id = b.diagnosis_id')
|
||||
->where('b.admin_id', $adminId)->where('b.installation_id', $installationId)
|
||||
->where('d.status', 1)->whereNull('d.delete_time');
|
||||
MyPatientLogic::applyScope($query, $adminId, $info);
|
||||
$count = (int) (clone $query)->count('b.id');
|
||||
$rows = $query->field('b.*,d.patient_id AS source_patient_id,d.patient_name,d.phone AS patient_phone')
|
||||
->order('b.id', 'desc')->page($page, $size)->select()->toArray();
|
||||
$items = array_map(static fn (array $row): array => self::deviceRow($row, [
|
||||
'id' => $row['diagnosis_id'], 'patient_id' => $row['source_patient_id'],
|
||||
'patient_name' => $row['patient_name'], 'phone' => $row['patient_phone'],
|
||||
]), $rows);
|
||||
return ['lists' => $items, 'count' => $count, 'page_no' => $page, 'page_size' => $size];
|
||||
}
|
||||
|
||||
public static function patientLists(array $params, int $adminId): array
|
||||
{
|
||||
self::only($params, ['diagnosis_id', 'page_no', 'page_size']);
|
||||
$diagnosisId = self::integer($params['diagnosis_id'] ?? null, 1, 4294967295, '诊单标识');
|
||||
[$page, $size] = self::pagination($params, 20);
|
||||
$info = self::actor($adminId);
|
||||
self::diagnosis($diagnosisId, $adminId, $info);
|
||||
$query = Db::name('mobile_recording_binding')->alias('b')->where('b.diagnosis_id', $diagnosisId);
|
||||
$count = (int) (clone $query)->count();
|
||||
$adminTable = Db::name('admin')->getTable();
|
||||
$rows = $query->leftJoin([$adminTable => 'a'], 'a.id = b.admin_id')
|
||||
->field('b.id,b.diagnosis_id,b.source_platform,b.recorded_at,b.duration_ms,b.created_at,b.updated_at,a.name AS bound_by')
|
||||
->order('b.recorded_at', 'desc')->order('b.id', 'desc')->page($page, $size)->select()->toArray();
|
||||
$items = array_map(static function (array $row): array {
|
||||
$dto = self::metadata($row);
|
||||
$dto['bound_by'] = trim((string) ($row['bound_by'] ?? '')) ?: '已停用账号';
|
||||
$dto['playback_location'] = 'original_device';
|
||||
return $dto;
|
||||
}, $rows);
|
||||
return ['lists' => $items, 'count' => $count, 'page_no' => $page, 'page_size' => $size];
|
||||
}
|
||||
|
||||
/** Public for the controller and executable input-contract tests. */
|
||||
public static function bindingInput(array $params): array
|
||||
{
|
||||
self::only($params, ['installation_id', 'recording_key', 'diagnosis_id', 'source_platform', 'recorded_at', 'duration_ms']);
|
||||
if (($params['source_platform'] ?? null) !== 'android_bcr') {
|
||||
throw new DomainException('录音来源无效');
|
||||
}
|
||||
return self::identity($params) + [
|
||||
'diagnosis_id' => self::integer($params['diagnosis_id'] ?? null, 1, 4294967295, '诊单标识'),
|
||||
'source_platform' => 'android_bcr',
|
||||
'recorded_at' => self::integer($params['recorded_at'] ?? null, 0, (time() + 300) * 1000, '录音时间'),
|
||||
'duration_ms' => self::integer($params['duration_ms'] ?? null, 0, 604800000, '录音时长'),
|
||||
];
|
||||
}
|
||||
|
||||
private static function ownedQuery(int $adminId, array $identity): Query
|
||||
{
|
||||
return Db::name('mobile_recording_binding')->where('admin_id', $adminId)
|
||||
->where('installation_id', $identity['installation_id'])->where('recording_key', $identity['recording_key']);
|
||||
}
|
||||
|
||||
private static function diagnosis(int $id, int $adminId, array $info, bool $lock = false): array
|
||||
{
|
||||
$row = Db::name('tcm_diagnosis')->where('id', $id)->whereNull('delete_time')->where('status', 1)
|
||||
->lock($lock)->find();
|
||||
if (!$row || !MyPatientLogic::canAccessDiagnosis($id, $adminId, $info)) {
|
||||
throw new DomainException('患者不存在或无权操作');
|
||||
}
|
||||
return $row;
|
||||
}
|
||||
|
||||
private static function deviceRow(array $row, array $patient): array
|
||||
{
|
||||
return self::metadata($row) + [
|
||||
'installation_id' => (string) $row['installation_id'],
|
||||
'recording_key' => (string) $row['recording_key'],
|
||||
'patient' => [
|
||||
'diagnosis_id' => (int) $patient['id'],
|
||||
'source_patient_id' => (int) ($patient['patient_id'] ?? 0),
|
||||
'patient_name' => (string) ($patient['patient_name'] ?? ''),
|
||||
'phone_masked' => self::maskPhone((string) ($patient['phone'] ?? '')),
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
private static function metadata(array $row): array
|
||||
{
|
||||
$result = ['source_platform' => (string) $row['source_platform']];
|
||||
foreach (['id', 'diagnosis_id', 'recorded_at', 'duration_ms', 'created_at', 'updated_at'] as $field) {
|
||||
$result[$field] = (int) $row[$field];
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
private static function maskPhone(string $phone): string
|
||||
{
|
||||
$digits = preg_replace('/\D+/', '', $phone) ?? '';
|
||||
$length = strlen($digits);
|
||||
if ($length <= 4) {
|
||||
return str_repeat('*', $length);
|
||||
}
|
||||
if ($length < 8) {
|
||||
return substr($digits, 0, 1) . str_repeat('*', $length - 2) . substr($digits, -1);
|
||||
}
|
||||
return substr($digits, 0, 3) . str_repeat('*', $length - 7) . substr($digits, -4);
|
||||
}
|
||||
|
||||
private static function identity(array $params): array
|
||||
{
|
||||
$key = $params['recording_key'] ?? null;
|
||||
if (!is_string($key) || !preg_match('/^[0-9a-f]{64}$/D', $key)) {
|
||||
throw new DomainException('录音标识无效');
|
||||
}
|
||||
return ['installation_id' => self::installation($params['installation_id'] ?? null), 'recording_key' => $key];
|
||||
}
|
||||
|
||||
private static function installation($value): string
|
||||
{
|
||||
if (!is_string($value) || !preg_match('/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/D', $value)) {
|
||||
throw new DomainException('设备标识无效');
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
|
||||
private static function pagination(array $params, int $defaultSize): array
|
||||
{
|
||||
return [
|
||||
self::integer($params['page_no'] ?? 1, 1, 1000000, '页码'),
|
||||
self::integer($params['page_size'] ?? $defaultSize, 1, 100, '每页数量'),
|
||||
];
|
||||
}
|
||||
|
||||
private static function integer($value, int $min, int $max, string $label): int
|
||||
{
|
||||
if (!(is_int($value) || is_string($value)) || !preg_match('/^(0|[1-9][0-9]{0,14})$/D', (string) $value)
|
||||
|| (int) $value < $min || (int) $value > $max) {
|
||||
throw new DomainException($label . '无效');
|
||||
}
|
||||
return (int) $value;
|
||||
}
|
||||
|
||||
private static function only(array $params, array $allowed): void
|
||||
{
|
||||
if (array_diff(array_keys($params), $allowed) !== []) {
|
||||
throw new DomainException('请求包含不支持的字段');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace app\adminapi\service;
|
||||
|
||||
use app\common\model\tcm\CallRecord;
|
||||
use DomainException;
|
||||
use think\facade\Db;
|
||||
|
||||
/** Persist a locally recovered transcript without reopening the realtime session. */
|
||||
final class LocalAudioTranscriptRecovery
|
||||
{
|
||||
public static function save(array $params): array
|
||||
{
|
||||
foreach (['diagnosis_id', 'call_record_id', 'admin_id'] as $key) {
|
||||
$value = $params[$key] ?? null;
|
||||
if ((!is_int($value) && !is_string($value))
|
||||
|| filter_var($value, FILTER_VALIDATE_INT, ['options' => ['min_range' => 1]]) === false) {
|
||||
throw new DomainException('录音补转写身份参数无效');
|
||||
}
|
||||
}
|
||||
foreach (['recovery_id', 'expected_session_id', 'expected_status', 'audio_url', 'transcript_text'] as $key) {
|
||||
if (!isset($params[$key]) || !is_string($params[$key])) {
|
||||
throw new DomainException('录音补转写参数无效');
|
||||
}
|
||||
}
|
||||
if (!preg_match('/\Aaudio-[a-f0-9]{32}\z/D', $params['recovery_id'])
|
||||
|| mb_strlen($params['expected_session_id']) > 128
|
||||
|| !in_array($params['expected_status'], ['', 'pending', 'running', 'partial', 'failed', 'completed'], true)
|
||||
|| trim($params['audio_url']) === '' || strlen($params['audio_url']) > 8192) {
|
||||
throw new DomainException('录音补转写会话参数无效');
|
||||
}
|
||||
$text = trim($params['transcript_text']);
|
||||
if ($text === '' || mb_strlen($params['transcript_text']) > 100000) {
|
||||
throw new DomainException('录音补转写文字必须为1到100000个字符');
|
||||
}
|
||||
|
||||
return Db::transaction(static function () use ($params, $text): array {
|
||||
// The realtime upsert/finish endpoints lock the same row, so a late
|
||||
// old-session write cannot run after this session switch succeeds.
|
||||
$record = CallRecord::where('id', (int) $params['call_record_id'])
|
||||
->where('diagnosis_id', (int) $params['diagnosis_id'])
|
||||
->where('caller_id', (int) $params['admin_id'])
|
||||
->where('caller_type', 'doctor')->lock(true)->find();
|
||||
if (!$record) { throw new DomainException('通话记录不存在或无权操作'); }
|
||||
if ((int) $record['status'] !== 2) { throw new DomainException('通话结束后才能补转写'); }
|
||||
$urls = json_decode((string) ($record['local_audio_urls'] ?? ''), true);
|
||||
if ((int) ($record['local_audio_status'] ?? 0) !== 2 || !is_array($urls)
|
||||
|| !in_array($params['audio_url'], $urls, true)) {
|
||||
throw new DomainException('录音尚未上传或不属于当前通话');
|
||||
}
|
||||
$result = ['call_record_id' => (int) $record['id'], 'transcription_status' => 'completed'];
|
||||
$session = (string) ($record['transcription_session_id'] ?? '');
|
||||
$status = (string) ($record['transcription_status'] ?? '');
|
||||
if ($status === 'completed' && trim((string) ($record['transcript_text'] ?? '')) !== '') {
|
||||
// Lost response retries succeed even with the original CAS values;
|
||||
// a different completed session always wins without being changed.
|
||||
return $session === $params['recovery_id']
|
||||
? $result + ['saved' => true]
|
||||
: $result + ['saved' => false, 'already_complete' => true];
|
||||
}
|
||||
if ($session !== $params['expected_session_id'] || $status !== $params['expected_status']) {
|
||||
throw new DomainException('通话转写状态已变化,请刷新后重试');
|
||||
}
|
||||
|
||||
$now = time();
|
||||
$segments = [];
|
||||
$lines = [];
|
||||
// Recognition supplied no diarization or alignment. Do not invent
|
||||
// doctor/patient attribution or timestamps; preserve source order by id.
|
||||
for ($offset = 0, $index = 0, $length = mb_strlen($text); $offset < $length; $offset += 4000, $index++) {
|
||||
$part = mb_substr($text, $offset, 4000);
|
||||
$segments[] = [
|
||||
'call_record_id' => (int) $record['id'],
|
||||
'transcription_session_id' => $params['recovery_id'],
|
||||
'segment_id' => $params['recovery_id'] . '-' . $index,
|
||||
'speaker_user_id' => '', 'speaker_role' => 'unknown', 'timestamp_ms' => 0,
|
||||
'text' => $part, 'create_time' => $now, 'update_time' => $now,
|
||||
];
|
||||
$lines[] = '未知说话人:' . $part;
|
||||
}
|
||||
// Keep all old-session segments for audit; the current session is the
|
||||
// only one consumed by transcript readers and clinical context builders.
|
||||
Db::name('tcm_call_transcript_segment')->insertAll($segments);
|
||||
$record->save([
|
||||
'transcription_session_id' => $params['recovery_id'],
|
||||
'transcription_status' => 'completed',
|
||||
'transcription_segment_count' => count($segments),
|
||||
'transcript_text' => implode("\n", $lines),
|
||||
'transcription_started_at' => $now, 'transcription_finished_at' => $now,
|
||||
'update_time' => $now,
|
||||
]);
|
||||
return $result + ['saved' => true];
|
||||
});
|
||||
}
|
||||
|
||||
public static function completionStatus(string $requested, int $actual, int $expected, string $text): string
|
||||
{
|
||||
if ($requested !== 'completed') { return $requested; }
|
||||
if ($actual === 0 || trim($text) === '') { return 'failed'; }
|
||||
return $actual < $expected ? 'partial' : 'completed';
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user