1.优化充值跳转链接的问题

This commit is contained in:
2026-05-30 11:26:41 +08:00
parent 1f9b2c2663
commit 15b9313c07
6 changed files with 121 additions and 7 deletions

View File

@@ -462,7 +462,7 @@ class Finance extends MobileBase
$remaining = $expireAt > $now ? ($expireAt - $now) : 0;
$canPay = $statusCode === 0 && DepositOrderExpireService::isPendingPaymentValid($row) && $remaining > 0;
return $this->mobileSuccess([
return $this->mobileSuccess($this->attachMockDepositReturnGameUrl([
'order_no' => $orderNo,
'amount' => $this->amountNumber($amount),
'bonus_amount' => $this->amountNumber($bonus),
@@ -475,7 +475,7 @@ class Finance extends MobileBase
'reject_reason' => is_string($row['reject_reason'] ?? null) && trim($row['reject_reason']) !== ''
? trim($row['reject_reason'])
: null,
]);
]));
}
/**
@@ -563,13 +563,13 @@ class Finance extends MobileBase
$status = is_numeric($row['status'] ?? null) ? intval($row['status']) : -1;
if ($status === 1) {
$order = DepositOrder::where('order_no', $orderNo)->find();
$payload = $this->buildDepositResponse($order, null);
$payload = $this->attachMockDepositReturnGameUrl($this->buildDepositResponse($order, null));
$payload['review_required'] = false;
return ['error' => null, 'payload' => $payload];
}
if ($status === MockPay::DEPOSIT_STATUS_PENDING_REVIEW) {
$order = DepositOrder::where('order_no', $orderNo)->find();
$payload = $this->buildDepositResponse($order, null);
$payload = $this->attachMockDepositReturnGameUrl($this->buildDepositResponse($order, null));
$payload['review_required'] = true;
return ['error' => null, 'payload' => $payload];
}
@@ -608,7 +608,7 @@ class Finance extends MobileBase
]);
$order = DepositOrder::where('id', $orderId)->find();
$payload = $this->buildDepositResponse($order, null);
$payload = $this->attachMockDepositReturnGameUrl($this->buildDepositResponse($order, null));
$payload['review_required'] = true;
$payload['mock_pay_success'] = true;
$payload['mock_pay_message'] = 'Payment submitted. Pending admin review.';
@@ -616,6 +616,21 @@ class Finance extends MobileBase
return ['error' => null, 'payload' => $payload];
}
/**
* @param array<string, mixed> $payload
*
* @return array<string, mixed>
*/
private function attachMockDepositReturnGameUrl(array $payload): array
{
$returnGameUrl = MockPay::resolveGameReturnUrl();
if ($returnGameUrl !== '') {
$payload['return_game_url'] = $returnGameUrl;
}
return $payload;
}
/**
* @param \app\common\model\DepositOrder|object $order
*/
@@ -676,6 +691,8 @@ class Finance extends MobileBase
$expireEsc = htmlspecialchars($expireText, ENT_QUOTES, 'UTF-8');
$orderNoJs = json_encode($orderNo, JSON_UNESCAPED_UNICODE);
$confirmUrlJs = json_encode($confirmUrl, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
$returnGameUrl = MockPay::resolveGameReturnUrl();
$returnGameUrlJs = json_encode($returnGameUrl, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
return '<!DOCTYPE html><html lang="zh-CN"><head><meta charset="utf-8"/><meta name="viewport" content="width=device-width,initial-scale=1"/>'
. '<title>模拟充值</title><style>'
@@ -685,6 +702,7 @@ class Finance extends MobileBase
. '.amt{font-size:28px;color:#1677ff;font-weight:700;margin:16px 0;}'
. 'button{width:100%;padding:14px;font-size:16px;border:0;border-radius:8px;background:#1677ff;color:#fff;cursor:pointer;margin-top:12px;}'
. 'button:disabled{background:#ccc;}'
. '.btn-back{display:none;background:#fff;color:#cf1322;border:1px solid #d9d9d9;}'
. '.hint{font-size:13px;color:#999;}'
. '.ok{display:none;margin-top:16px;padding:12px;background:#f6ffed;border:1px solid #b7eb8f;border-radius:8px;color:#389e0d;line-height:1.6;}'
. '</style></head><body>'
@@ -695,11 +713,14 @@ class Finance extends MobileBase
. '<p class="hint">链接有效期至 ' . $expireEsc . '(约 3 分钟,过期后订单将自动失效)</p>'
. '<button type="button" id="btnPay">确认支付</button>'
. '<div class="ok" id="okBox"><strong>支付成功(模拟)</strong><br/>订单已提交,需管理员在后台审核通过后才会入账。</div>'
. '<script>(function(){var confirmUrl=' . $confirmUrlJs . ',orderNo=' . $orderNoJs . ';'
. '<button type="button" class="btn-back" id="btnBackGame">返回游戏</button>'
. '<script>(function(){var confirmUrl=' . $confirmUrlJs . ',orderNo=' . $orderNoJs . ',returnGameUrl=' . $returnGameUrlJs . ';'
. 'function showBackGame(){if(!returnGameUrl){return;}var btn=document.getElementById("btnBackGame");btn.style.display="block";btn.onclick=function(){window.location.href=returnGameUrl;};}'
. 'document.getElementById("btnPay").onclick=function(){var btn=this;btn.disabled=true;btn.textContent="处理中...";'
. 'fetch(confirmUrl,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},'
. 'body:"order_no="+encodeURIComponent(orderNo)}).then(function(r){return r.json();}).then(function(res){'
. 'if(res&&res.code===1){document.getElementById("okBox").style.display="block";btn.style.display="none";}'
. 'if(res&&res.code===1){document.getElementById("okBox").style.display="block";btn.style.display="none";'
. 'if(res.data&&res.data.return_game_url){returnGameUrl=res.data.return_game_url;}showBackGame();}'
. 'else{alert((res&&res.message)||"支付失败");btn.disabled=false;btn.textContent="确认支付";}})'
. '.catch(function(){alert("网络错误,请重试");btn.disabled=false;btn.textContent="确认支付";});};})();</script>'
. '</div></body></html>';