新增订单查询接口/api/v1/mall/order
This commit is contained in:
@@ -428,8 +428,8 @@ class Playx extends Api
|
||||
}
|
||||
|
||||
/**
|
||||
* Token 验证 - POST /api/v1/playx/verify-token
|
||||
* 配置 playx.verify_token_local_only=true 时:不向 PlayX 请求,且不校验传入 token(联调占位)。
|
||||
* Token 验证 - POST /api/v1/mall/verifyToken
|
||||
* 配置 playx.verify_token_local_only=true 时:不向 PlayX 请求,按 .env 默认用户签发 session(见 verify_token_local_default_*)。
|
||||
*/
|
||||
public function verifyToken(Request $request): Response
|
||||
{
|
||||
@@ -439,7 +439,7 @@ class Playx extends Api
|
||||
}
|
||||
|
||||
if (config('playx.verify_token_local_only', false)) {
|
||||
return $this->verifyTokenLocalOpen();
|
||||
return $this->verifyTokenLocalOpen($request);
|
||||
}
|
||||
|
||||
$token = strval($request->post('token', $request->post('session', $request->get('token', ''))));
|
||||
@@ -609,14 +609,17 @@ class Playx extends Api
|
||||
}
|
||||
|
||||
/**
|
||||
* 本地联调:不校验 token,按配置默认用户签发新 mall_session(待 PlayX 远程校验就绪后关闭 verify_token_local_only)。
|
||||
* 本地联调:不调用 PlayX verify-token;身份取自 PLAYX_VERIFY_TOKEN_LOCAL_DEFAULT_*,请求 token 仅作占位(有则通过、无则也通过)。
|
||||
*/
|
||||
private function verifyTokenLocalOpen(): Response
|
||||
private function verifyTokenLocalOpen(Request $request): Response
|
||||
{
|
||||
$playxUserId = strval(config('playx.verify_token_local_default_user_id', 'testmyr'));
|
||||
$username = strval(config('playx.verify_token_local_default_username', 'yangyang123'));
|
||||
$playxUserId = trim(strval(config('playx.verify_token_local_default_user_id', '')));
|
||||
$username = trim(strval(config('playx.verify_token_local_default_username', '')));
|
||||
if ($playxUserId === '') {
|
||||
return $this->error(__('PlayX API not configured'));
|
||||
return $this->error(__('PlayX verify token local default user not configured'));
|
||||
}
|
||||
if ($username === '') {
|
||||
$username = $playxUserId;
|
||||
}
|
||||
|
||||
$asset = $this->ensureAssetForPlayx($playxUserId, $username);
|
||||
@@ -878,6 +881,57 @@ class Playx extends Api
|
||||
return $this->success('', ['list' => $arr]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 按订单 ID 查询订单(仅当前登录用户本人的订单)
|
||||
* GET /api/v1/mall/order?order_id=xxx
|
||||
*
|
||||
* 鉴权:token / session_id / user_id(同 assets/orders)
|
||||
*/
|
||||
public function order(Request $request): Response
|
||||
{
|
||||
$response = $this->initializeApi($request);
|
||||
if ($response !== null) {
|
||||
return $response;
|
||||
}
|
||||
|
||||
$assetId = $this->resolvePlayxAssetIdFromRequest($request);
|
||||
if ($assetId === null) {
|
||||
return $this->error(__('Token expiration'), null, 0, ['statusCode' => 401]);
|
||||
}
|
||||
$asset = $this->getAssetById($assetId);
|
||||
if (!$asset || strval($asset->playx_user_id ?? '') === '') {
|
||||
return $this->error(__('Record not found'));
|
||||
}
|
||||
|
||||
$orderId = intval($request->get('order_id', $request->post('order_id', 0)));
|
||||
if ($orderId <= 0) {
|
||||
$orderId = intval($request->get('id', $request->post('id', 0)));
|
||||
}
|
||||
if ($orderId <= 0) {
|
||||
return $this->error(__('Missing required fields'));
|
||||
}
|
||||
|
||||
$playxUserId = strval($asset->playx_user_id);
|
||||
$order = MallOrder::where('id', $orderId)
|
||||
->where('user_id', $playxUserId)
|
||||
->with(['mallItem'])
|
||||
->find();
|
||||
if (!$order) {
|
||||
return $this->error(__('Record not found'));
|
||||
}
|
||||
|
||||
$row = $order->toArray();
|
||||
if (isset($row['mallItem']) && is_array($row['mallItem'])) {
|
||||
$row['mallItem'] = $this->applyMallItemLocaleForApi($row['mallItem']);
|
||||
}
|
||||
|
||||
return $this->success('', [
|
||||
'order_id' => $order->id,
|
||||
'status' => $order->status,
|
||||
'order' => $row,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 积分流水(领取/兑换/退回/管理员调整)
|
||||
* GET /api/v1/mall/pointsLogs
|
||||
|
||||
@@ -61,6 +61,7 @@ return [
|
||||
'nicknameChsDash' => 'Username may only contain letters, numbers, underscores and dashes',
|
||||
'Invalid token' => 'Invalid or expired token',
|
||||
'PlayX API not configured' => 'PlayX API is not configured',
|
||||
'PlayX verify token local default user not configured' => 'Local verify user is not configured; set PLAYX_VERIFY_TOKEN_LOCAL_DEFAULT_USER_ID',
|
||||
'PlayX verify upstream failed' => 'Upstream token verification failed (HTTP %s): %s',
|
||||
'Duplicate input' => 'Duplicate submission',
|
||||
'Ok' => 'OK',
|
||||
|
||||
@@ -62,6 +62,7 @@ return [
|
||||
'nicknameChsDash' => 'Nama pengguna hanya huruf, nombor, garis bawah dan sempang',
|
||||
'Invalid token' => 'Token tidak sah atau tamat tempoh',
|
||||
'PlayX API not configured' => 'API PlayX tidak dikonfigurasi',
|
||||
'PlayX verify token local default user not configured' => 'Pengguna verifikasi tempatan tidak dikonfigurasi; tetapkan PLAYX_VERIFY_TOKEN_LOCAL_DEFAULT_USER_ID',
|
||||
'PlayX verify upstream failed' => 'Pengesahan token hulu gagal (HTTP %s): %s',
|
||||
'Duplicate input' => 'Penghantaran pendua',
|
||||
'Ok' => 'OK',
|
||||
|
||||
@@ -63,6 +63,7 @@ return [
|
||||
// PlayX API v1 /api/v1/*
|
||||
'Invalid token' => '令牌无效或已过期',
|
||||
'PlayX API not configured' => '未配置 PlayX 接口地址',
|
||||
'PlayX verify token local default user not configured' => '未配置本地联调用户,请设置 PLAYX_VERIFY_TOKEN_LOCAL_DEFAULT_USER_ID',
|
||||
'PlayX verify upstream failed' => '上游 Token 校验失败(HTTP %s):%s',
|
||||
'Duplicate input' => '重复提交',
|
||||
'Ok' => '成功',
|
||||
|
||||
Reference in New Issue
Block a user