优化游戏实时对局页面
This commit is contained in:
@@ -5,6 +5,7 @@ namespace app\admin\controller\game;
|
||||
use app\common\controller\Backend;
|
||||
use app\common\library\admin\PushChannelConfigHelper;
|
||||
use app\common\service\GameLiveService;
|
||||
use app\common\service\GameRecordService;
|
||||
use support\Response;
|
||||
use Webman\Http\Request as WebmanRequest;
|
||||
|
||||
@@ -102,4 +103,50 @@ class Live extends Backend
|
||||
$okMsg = $res['msg'] ?? '';
|
||||
return $this->success(is_string($okMsg) ? $okMsg : '', $res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 游戏运行开关:关闭时禁止下注、派彩结束后不自动开新期,但当局仍自动开奖并结算;重新开启且无进行中局时立即创建新一期。
|
||||
*/
|
||||
public function runtime(WebmanRequest $request): Response
|
||||
{
|
||||
$response = $this->initializeBackend($request);
|
||||
if ($response !== null) {
|
||||
return $response;
|
||||
}
|
||||
if ($request->method() !== 'POST') {
|
||||
return $this->error(__('Parameter error'));
|
||||
}
|
||||
$raw = $request->post('enabled');
|
||||
$enabled = $raw === true || $raw === '1' || $raw === 1;
|
||||
GameRecordService::setLiveRuntimeEnabled($enabled);
|
||||
if ($enabled) {
|
||||
GameRecordService::bootstrapPeriodWhenRuntimeEnabled();
|
||||
}
|
||||
return $this->success('', GameLiveService::buildSnapshot(null));
|
||||
}
|
||||
|
||||
/**
|
||||
* 作废当前对局(下注/封盘阶段),填写原因后退款待开奖注单并关闭运行开关。
|
||||
*/
|
||||
public function voidPeriod(WebmanRequest $request): Response
|
||||
{
|
||||
$response = $this->initializeBackend($request);
|
||||
if ($response !== null) {
|
||||
return $response;
|
||||
}
|
||||
if ($request->method() !== 'POST') {
|
||||
return $this->error(__('Parameter error'));
|
||||
}
|
||||
$recordIdRaw = $request->post('record_id');
|
||||
$recordId = is_numeric((string) $recordIdRaw) ? (int) $recordIdRaw : null;
|
||||
$voidReason = $request->post('void_reason');
|
||||
$reasonStr = is_string($voidReason) ? $voidReason : '';
|
||||
$res = GameLiveService::voidCurrentPeriod($recordId, $reasonStr);
|
||||
if (!($res['ok'] ?? false)) {
|
||||
$errMsg = $res['msg'] ?? null;
|
||||
return $this->error(is_string($errMsg) ? $errMsg : __('Void failed'));
|
||||
}
|
||||
$okMsg = $res['msg'] ?? '';
|
||||
return $this->success(is_string($okMsg) ? $okMsg : '', GameLiveService::buildSnapshot(null));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user