优化每日推送接口/api/v1/playx/daily-push
This commit is contained in:
@@ -14,7 +14,6 @@ use app\common\model\MallPlayxDailyPush;
|
||||
use app\common\model\MallPlayxSession;
|
||||
use app\common\model\MallPlayxOrder;
|
||||
use app\common\model\MallPlayxUserAsset;
|
||||
use app\common\library\PlayxInboundJwt;
|
||||
use support\think\Db;
|
||||
use Webman\Http\Request;
|
||||
use support\Response;
|
||||
@@ -157,14 +156,6 @@ class Playx extends Api
|
||||
return $response;
|
||||
}
|
||||
|
||||
$partnerJwtSecret = strval(config('playx.partner_jwt_secret', ''));
|
||||
if ($partnerJwtSecret !== '') {
|
||||
$authHeader = strval($request->header('authorization', ''));
|
||||
if (!PlayxInboundJwt::verifyBearer($authHeader, $partnerJwtSecret)) {
|
||||
return $this->error(__('Invalid or missing JWT'), null, 0, ['statusCode' => 401]);
|
||||
}
|
||||
}
|
||||
|
||||
$body = $request->post();
|
||||
if (empty($body)) {
|
||||
$raw = $request->rawBody();
|
||||
@@ -179,12 +170,12 @@ class Playx extends Api
|
||||
$ts = $request->header('X-Timestamp', '');
|
||||
$rid = $request->header('X-Request-Id', '');
|
||||
if ($sig === '' || $ts === '' || $rid === '') {
|
||||
return $this->error(__('Invalid signature'), null, 0, ['statusCode' => 401]);
|
||||
return $this->error(__('Daily push signature missing or incomplete'), null, 0, ['statusCode' => 401]);
|
||||
}
|
||||
$canonical = $ts . "\n" . $rid . "\nPOST\n/api/v1/playx/daily-push\n" . hash('sha256', json_encode($body));
|
||||
$expected = hash_hmac('sha256', $canonical, $secret);
|
||||
if (!hash_equals($expected, $sig)) {
|
||||
return $this->error(__('Invalid signature'), null, 0, ['statusCode' => 401]);
|
||||
return $this->error(__('Daily push signature verification failed'), null, 0, ['statusCode' => 401]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -259,7 +250,7 @@ class Playx extends Api
|
||||
|
||||
$asset = $this->ensureAssetForPlayx($playxUserId, $username);
|
||||
if (!$asset) {
|
||||
throw new \RuntimeException(__('Failed to map playx user to mall user'));
|
||||
throw new \RuntimeException(__('Failed to ensure PlayX user asset'));
|
||||
}
|
||||
|
||||
if ($asset->today_limit_date !== $date) {
|
||||
@@ -345,7 +336,7 @@ class Playx extends Api
|
||||
|
||||
$asset = $this->ensureAssetForPlayx($playxUserId, strval($body['username'] ?? ''));
|
||||
if (!$asset) {
|
||||
throw new \RuntimeException(__('Failed to map playx user to mall user'));
|
||||
throw new \RuntimeException(__('Failed to ensure PlayX user asset'));
|
||||
}
|
||||
|
||||
if ($asset->today_limit_date !== $date) {
|
||||
|
||||
@@ -35,6 +35,11 @@ return [
|
||||
'Ok' => 'OK',
|
||||
'Failed to map playx user to mall user' => 'Failed to map PlayX user to mall user',
|
||||
'Missing required fields: request_id, date, user_id' => 'Missing required fields: request_id, date, user_id',
|
||||
'Missing required fields: report_date, member' => 'Missing required fields: report_date, member',
|
||||
'Missing required fields: member_id' => 'Missing required fields: member_id',
|
||||
'Daily push signature missing or incomplete' => 'Daily push signature missing or incomplete',
|
||||
'Daily push signature verification failed' => 'Daily push signature verification failed',
|
||||
'Failed to ensure PlayX user asset' => 'Failed to ensure PlayX user asset',
|
||||
'claim_request_id and user_id/session_id required' => 'claim_request_id and user_id/session_id/token are required',
|
||||
'User asset not found' => 'User asset not found',
|
||||
'No points to claim or limit reached' => 'No points to claim or daily limit reached',
|
||||
|
||||
@@ -67,6 +67,11 @@ return [
|
||||
'Ok' => '成功',
|
||||
'Failed to map playx user to mall user' => '无法将 PlayX 用户关联到商城用户',
|
||||
'Missing required fields: request_id, date, user_id' => '缺少必填字段:request_id、date、user_id',
|
||||
'Missing required fields: report_date, member' => '缺少必填字段:report_date、member',
|
||||
'Missing required fields: member_id' => '缺少必填字段:member_id',
|
||||
'Daily push signature missing or incomplete' => '签名缺失或不完整',
|
||||
'Daily push signature verification failed' => '签名校验失败',
|
||||
'Failed to ensure PlayX user asset' => '创建/映射用户资产失败',
|
||||
'claim_request_id and user_id/session_id required' => '缺少 claim_request_id,或未提供有效的 user_id/session_id/token',
|
||||
'User asset not found' => '未找到用户资产',
|
||||
'No points to claim or limit reached' => '暂无可领取积分或已达今日上限',
|
||||
|
||||
Reference in New Issue
Block a user