|
@@ -29,7 +29,7 @@ class MaintenanceService
|
|
|
return ['scopes' => $options(Policy::scopes()), 'categories' => $options(Policy::CATEGORIES), 'subcategories' => $subcategories,
|
|
return ['scopes' => $options(Policy::scopes()), 'categories' => $options(Policy::CATEGORIES), 'subcategories' => $subcategories,
|
|
|
'platforms' => $options(['PC' => 'PC', 'H5' => 'H5', 'APP' => 'APP']), 'languages' => $options(Policy::LANGUAGES),
|
|
'platforms' => $options(['PC' => 'PC', 'H5' => 'H5', 'APP' => 'APP']), 'languages' => $options(Policy::LANGUAGES),
|
|
|
'states' => $options(Policy::STATES), 'timezones' => DateTimeZone::listIdentifiers(),
|
|
'states' => $options(Policy::STATES), 'timezones' => DateTimeZone::listIdentifiers(),
|
|
|
- 'defaults' => ['enabled' => 0, 'platforms' => ['PC', 'H5', 'APP'], 'timezone' => 'Asia/Shanghai', 'ends_at' => null],
|
|
|
|
|
|
|
+ 'defaults' => ['enabled' => 0, 'platforms' => ['PC', 'H5', 'APP'], 'timezone' => 'Asia/Shanghai', 'ends_at' => null, 'embeddable' => 1],
|
|
|
'business_codes' => ['site' => Policy::SITE_CODE, 'game' => Policy::GAME_CODE]];
|
|
'business_codes' => ['site' => Policy::SITE_CODE, 'game' => Policy::GAME_CODE]];
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -102,13 +102,18 @@ class MaintenanceService
|
|
|
'enabled' => ['sometimes', 'required', 'integer', 'in:0,1'], 'start_now' => ['sometimes', 'boolean'],
|
|
'enabled' => ['sometimes', 'required', 'integer', 'in:0,1'], 'start_now' => ['sometimes', 'boolean'],
|
|
|
'starts_at' => ['sometimes', 'required', 'date_format:Y-m-d H:i:s'], 'ends_at' => ['nullable', 'date_format:Y-m-d H:i:s'],
|
|
'starts_at' => ['sometimes', 'required', 'date_format:Y-m-d H:i:s'], 'ends_at' => ['nullable', 'date_format:Y-m-d H:i:s'],
|
|
|
'timezone' => ['sometimes', 'required', 'string', Rule::in(DateTimeZone::listIdentifiers())],
|
|
'timezone' => ['sometimes', 'required', 'string', Rule::in(DateTimeZone::listIdentifiers())],
|
|
|
- 'translations' => ['sometimes', 'array'],
|
|
|
|
|
|
|
+ 'translations' => ['sometimes', 'array'], 'embeddable' => ['sometimes', 'required', 'integer', 'in:0,1'],
|
|
|
])->validate();
|
|
])->validate();
|
|
|
return DB::transaction(function () use ($params) {
|
|
return DB::transaction(function () use ($params) {
|
|
|
$id = (int) $params['id'];
|
|
$id = (int) $params['id'];
|
|
|
$found = DB::table('maintenance_settings')->where('id', $id)->lockForUpdate()->first();
|
|
$found = DB::table('maintenance_settings')->where('id', $id)->lockForUpdate()->first();
|
|
|
if (!$found) $this->invalid('id', '维护设置不存在');
|
|
if (!$found) $this->invalid('id', '维护设置不存在');
|
|
|
$before = $this->snapshot($id); $row = (array) $found;
|
|
$before = $this->snapshot($id); $row = (array) $found;
|
|
|
|
|
+ // Whether the platform / lottery / sport opens embedded (iframe) on the member site; independent of maintenance.
|
|
|
|
|
+ if (array_key_exists('embeddable', $params)) {
|
|
|
|
|
+ if (Policy::parentScope($row['scope_code']) === null) $this->invalid('embeddable', '只有子类可以设置是否支持内嵌');
|
|
|
|
|
+ $row['embeddable'] = (int) $params['embeddable'];
|
|
|
|
|
+ }
|
|
|
foreach (['enabled', 'timezone', 'platforms'] as $field) if (array_key_exists($field, $params)) $row[$field] = $params[$field];
|
|
foreach (['enabled', 'timezone', 'platforms'] as $field) if (array_key_exists($field, $params)) $row[$field] = $params[$field];
|
|
|
$row['platforms'] = array_values(array_intersect(['PC', 'H5', 'APP'], Policy::platforms($row)));
|
|
$row['platforms'] = array_values(array_intersect(['PC', 'H5', 'APP'], Policy::platforms($row)));
|
|
|
if (!empty($params['start_now'])) $row['starts_at'] = $this->now()->format('Y-m-d H:i:s');
|
|
if (!empty($params['start_now'])) $row['starts_at'] = $this->now()->format('Y-m-d H:i:s');
|
|
@@ -126,7 +131,7 @@ class MaintenanceService
|
|
|
if (trim((string) ($value['content'] ?? '')) !== '') $texts[$language] = ['content' => $value['content']];
|
|
if (trim((string) ($value['content'] ?? '')) !== '') $texts[$language] = ['content' => $value['content']];
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- $values = array_intersect_key($row, array_flip(['enabled', 'timezone', 'platforms', 'starts_at', 'ends_at']));
|
|
|
|
|
|
|
+ $values = array_intersect_key($row, array_flip(['enabled', 'timezone', 'platforms', 'starts_at', 'ends_at', 'embeddable']));
|
|
|
$values['enabled'] = (int) $values['enabled']; $values['platforms'] = json_encode($values['platforms'], JSON_THROW_ON_ERROR);
|
|
$values['enabled'] = (int) $values['enabled']; $values['platforms'] = json_encode($values['platforms'], JSON_THROW_ON_ERROR);
|
|
|
$values['updated_at'] = $this->now()->format('Y-m-d H:i:s');
|
|
$values['updated_at'] = $this->now()->format('Y-m-d H:i:s');
|
|
|
DB::table('maintenance_settings')->where('id', $id)->update($values);
|
|
DB::table('maintenance_settings')->where('id', $id)->update($values);
|
|
@@ -173,8 +178,8 @@ class MaintenanceService
|
|
|
$parent = Policy::parentScope($row['scope_code']);
|
|
$parent = Policy::parentScope($row['scope_code']);
|
|
|
return ['id' => (int) $row['id'], 'scope_code' => $row['scope_code'], 'scope_name' => $this->names()[$row['scope_code']] ?? $row['scope_code'],
|
|
return ['id' => (int) $row['id'], 'scope_code' => $row['scope_code'], 'scope_name' => $this->names()[$row['scope_code']] ?? $row['scope_code'],
|
|
|
'scope_level' => $row['scope_code'] === 'site' ? 'site' : ($parent === null ? 'category' : 'subcategory'), 'parent_scope' => $parent,
|
|
'scope_level' => $row['scope_code'] === 'site' ? 'site' : ($parent === null ? 'category' : 'subcategory'), 'parent_scope' => $parent,
|
|
|
- 'enabled' => (int) $row['enabled'], 'state' => Policy::state($row, $this->now()->getTimestamp()),
|
|
|
|
|
- 'translations' => (object) $texts] + $public;
|
|
|
|
|
|
|
+ 'enabled' => (int) $row['enabled'], 'embeddable' => $parent === null ? null : (int) ($row['embeddable'] ?? 1),
|
|
|
|
|
+ 'state' => Policy::state($row, $this->now()->getTimestamp()), 'translations' => (object) $texts] + $public;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private function texts(int $id): array
|
|
private function texts(int $id): array
|
|
@@ -188,6 +193,7 @@ class MaintenanceService
|
|
|
{
|
|
{
|
|
|
$row = (array) DB::table('maintenance_settings')->where('id', $id)->first();
|
|
$row = (array) DB::table('maintenance_settings')->where('id', $id)->first();
|
|
|
unset($row['created_at'], $row['updated_at']); $row['enabled'] = (int) $row['enabled']; $row['platforms'] = Policy::platforms($row);
|
|
unset($row['created_at'], $row['updated_at']); $row['enabled'] = (int) $row['enabled']; $row['platforms'] = Policy::platforms($row);
|
|
|
|
|
+ if (Policy::parentScope($row['scope_code']) === null) unset($row['embeddable']); else $row['embeddable'] = (int) ($row['embeddable'] ?? 1);
|
|
|
$row['translations'] = $this->texts($id);
|
|
$row['translations'] = $this->texts($id);
|
|
|
$names = $this->names();
|
|
$names = $this->names();
|
|
|
foreach ($row['translations'] as &$text) $text['title'] = $names[$row['scope_code']] ?? $row['scope_code'];
|
|
foreach ($row['translations'] as &$text) $text['title'] = $names[$row['scope_code']] ?? $row['scope_code'];
|