完善接口和后台页面
This commit is contained in:
@@ -95,7 +95,7 @@ class Game extends MobileBase
|
||||
if ($response !== null) {
|
||||
return $response;
|
||||
}
|
||||
$limit = $this->intValue($request->get('limit', 30));
|
||||
$limit = $this->intValue($request->input('limit', 30));
|
||||
if ($limit < 1) {
|
||||
$limit = 30;
|
||||
}
|
||||
@@ -133,6 +133,12 @@ class Game extends MobileBase
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 提交下注:入参极简——period_no + numbers + bet_amount(整笔总金额) + idempotency_key。
|
||||
*
|
||||
* 下注判定:开奖号码 ∈ pick_numbers 即算中奖,赔付按整笔 total_amount × odds 计算
|
||||
* (odds 定义见 GameBetSettleService::BASE_ODDS 与 streak_at_bet)。
|
||||
*/
|
||||
public function betPlace(Request $request): Response
|
||||
{
|
||||
$response = $this->initializeMobile($request);
|
||||
@@ -141,11 +147,16 @@ class Game extends MobileBase
|
||||
}
|
||||
$periodNo = trim((string) $request->post('period_no', ''));
|
||||
$numbersRaw = $request->post('numbers', '');
|
||||
$betAmount = (string) $request->post('bet_amount', '');
|
||||
$betAmount = trim((string) $request->post('bet_amount', ''));
|
||||
$idempotencyKey = trim((string) $request->post('idempotency_key', ''));
|
||||
if ($periodNo === '' || $betAmount === '' || $idempotencyKey === '') {
|
||||
return $this->mobileError(1001, 'Missing parameters');
|
||||
}
|
||||
if (!is_numeric($betAmount) || bccomp($betAmount, '0', 4) <= 0) {
|
||||
return $this->mobileError(1003, 'Invalid parameter value');
|
||||
}
|
||||
$totalAmount = bcadd($betAmount, '0', 4);
|
||||
|
||||
$numbers = $this->parseBetNumbersFromRequest($numbersRaw);
|
||||
if ($numbers === []) {
|
||||
return $this->mobileError(1003, 'Invalid parameter value');
|
||||
@@ -164,8 +175,6 @@ class Game extends MobileBase
|
||||
}
|
||||
|
||||
$user = $this->auth->getUser();
|
||||
$pickCount = count($numbers);
|
||||
$totalAmount = bcmul($betAmount, (string) $pickCount, 4);
|
||||
if (bccomp((string) $user->coin, $totalAmount, 4) < 0) {
|
||||
return $this->mobileError(2001, 'Insufficient balance');
|
||||
}
|
||||
@@ -199,8 +208,6 @@ class Game extends MobileBase
|
||||
'user_id' => $user->id,
|
||||
'channel_id' => $user->channel_id,
|
||||
'pick_numbers' => $numbers,
|
||||
'unit_amount' => $betAmount,
|
||||
'pick_count' => $pickCount,
|
||||
'total_amount' => $totalAmount,
|
||||
'streak_at_bet' => $user->current_streak ?? 0,
|
||||
'is_auto' => 0,
|
||||
@@ -231,8 +238,8 @@ class Game extends MobileBase
|
||||
if ($response !== null) {
|
||||
return $response;
|
||||
}
|
||||
$page = $this->intValue($request->get('page', 1));
|
||||
$pageSize = $this->intValue($request->get('page_size', 20));
|
||||
$page = $this->intValue($request->input('page', 1));
|
||||
$pageSize = $this->intValue($request->input('page_size', 20));
|
||||
$paginate = BetOrder::where('user_id', $this->auth->id)->order('id', 'desc')->paginate([
|
||||
'page' => $page,
|
||||
'list_rows' => $pageSize,
|
||||
@@ -244,7 +251,8 @@ class Game extends MobileBase
|
||||
'order_no' => (string) $item->id,
|
||||
'period_no' => $item->period_no,
|
||||
'numbers' => $item->pick_numbers ?? [],
|
||||
'bet_amount' => $item->unit_amount,
|
||||
// 整笔压注金额(与请求 bet_amount 语义一致)
|
||||
'bet_amount' => $item->total_amount,
|
||||
'total_amount' => $item->total_amount,
|
||||
'result_number' => null,
|
||||
'win_amount' => $item->win_amount,
|
||||
|
||||
Reference in New Issue
Block a user