优化同意订单页面和推送订单到playx的功能

This commit is contained in:
2026-04-03 10:39:40 +08:00
parent 941f0f4a8c
commit 5ab85d1d53
14 changed files with 91 additions and 130 deletions

View File

@@ -47,7 +47,8 @@ class PlayxJobs
$path = strval(config('playx.api.transaction_status_url', '/api/v1/transaction/status'));
$url = rtrim($baseUrl, '/') . $path;
$list = MallOrder::where('grant_status', MallOrder::GRANT_ACCEPTED)
$list = MallOrder::where('type', MallOrder::TYPE_BONUS)
->where('grant_status', MallOrder::GRANT_ACCEPTED)
->where('status', MallOrder::STATUS_PENDING)
->order('id', 'desc')
->limit(50)
@@ -99,12 +100,11 @@ class PlayxJobs
}
$bonusPath = strval(config('playx.api.bonus_grant_url', '/api/v1/bonus/grant'));
$withdrawPath = strval(config('playx.api.balance_credit_url', '/api/v1/balance/credit'));
$bonusUrl = rtrim($baseUrl, '/') . $bonusPath;
$withdrawUrl = rtrim($baseUrl, '/') . $withdrawPath;
$maxRetry = 3;
$list = MallOrder::whereIn('grant_status', [
$list = MallOrder::where('type', MallOrder::TYPE_BONUS)
->whereIn('grant_status', [
MallOrder::GRANT_NOT_SENT,
MallOrder::GRANT_FAILED_RETRYABLE,
])
@@ -124,7 +124,7 @@ class PlayxJobs
$order->retry_count = intval($order->retry_count ?? 0) + 1;
try {
$this->sendGrantByOrder($order, $bonusUrl, $withdrawUrl, $maxRetry);
$this->sendGrantByOrder($order, $bonusUrl, $maxRetry);
} catch (\Throwable $e) {
$order->fail_reason = $e->getMessage();
if (intval($order->retry_count) >= $maxRetry) {
@@ -167,7 +167,7 @@ class PlayxJobs
return false;
}
private function sendGrantByOrder(MallOrder $order, string $bonusUrl, string $withdrawUrl, int $maxRetry): void
private function sendGrantByOrder(MallOrder $order, string $bonusUrl, int $maxRetry): void
{
$item = null;
if ($order->mallItem) {
@@ -221,45 +221,7 @@ class PlayxJobs
return;
}
if ($order->type === MallOrder::TYPE_WITHDRAW) {
$multiplier = intval($order->multiplier ?? 0);
if ($multiplier <= 0) {
$multiplier = 1;
}
$requestId = 'mall_retry_withdraw_' . uniqid();
$res = $this->http->post($withdrawUrl, [
'json' => [
'request_id' => $requestId,
'externalTransactionId' => $order->external_transaction_id,
'user_id' => $order->user_id,
'amount' => $order->amount,
'multiplier' => $multiplier,
],
]);
$data = json_decode(strval($res->getBody()), true) ?? [];
if ($res->getStatusCode() === 200 && ($data['status'] ?? '') === 'accepted') {
$order->grant_status = MallOrder::GRANT_ACCEPTED;
$order->playx_transaction_id = strval($data['playx_transaction_id'] ?? '');
$order->save();
return;
}
$order->fail_reason = strval($data['message'] ?? 'PlayX balance credit not accepted');
if (intval($order->retry_count) >= $maxRetry) {
$order->grant_status = MallOrder::GRANT_FAILED_FINAL;
$order->status = MallOrder::STATUS_REJECTED;
$order->save();
$this->refundPoints($order);
return;
}
$order->grant_status = MallOrder::GRANT_FAILED_RETRYABLE;
$order->save();
return;
}
// PHYSICAL 目前由后台手工发货/驳回,不参与 PlayX 发放重试
// 非 BONUS 订单不参与 PlayX 发放重试(提现/实物由后台流程处理)
}
private function refundPoints(MallOrder $order): void