1.新增获取充值/提现配置接口/api/finance/depositWithdrawConfig

2.优化充值和提现方式
This commit is contained in:
2026-04-23 10:15:01 +08:00
parent 0f28c0fd2a
commit aa1299c018
55 changed files with 901 additions and 750 deletions

View File

@@ -75,7 +75,7 @@ final class DepositSettlement
// 如果已结算,直接返回已有结果(幂等)
if ($status === 1) {
$userId = is_numeric($order['user_id'] ?? null) ? intval($order['user_id']) : 0;
$coinAfter = '0.0000';
$coinAfter = '0.00';
if ($userId > 0) {
$coin = Db::name('user')->where('id', $userId)->value('coin');
$coinAfter = is_string($coin) ? $coin : strval($coin);
@@ -87,7 +87,7 @@ final class DepositSettlement
'order_no' => $orderNo,
'amount' => $amt,
'bonus_amount' => $bns,
'credit' => bcadd($amt, $bns, 4),
'credit' => bcadd($amt, $bns, 2),
'balance_before' => $coinAfter,
'balance_after' => $coinAfter,
'pay_time' => is_numeric($order['pay_time'] ?? null) ? intval($order['pay_time']) : 0,
@@ -100,14 +100,14 @@ final class DepositSettlement
}
$amount = self::amountString($order['amount'] ?? '0');
if (bccomp($amount, '0', 4) <= 0) {
if (bccomp($amount, '0', 2) <= 0) {
throw new RuntimeException('订单金额异常');
}
$bonus = self::amountString($order['bonus_amount'] ?? '0');
if (bccomp($bonus, '0', 4) < 0) {
$bonus = '0.0000';
if (bccomp($bonus, '0', 2) < 0) {
$bonus = '0.00';
}
$credit = bcadd($amount, $bonus, 4);
$credit = bcadd($amount, $bonus, 2);
$userId = is_numeric($order['user_id'] ?? null) ? intval($order['user_id']) : 0;
if ($userId <= 0) {
@@ -121,7 +121,7 @@ final class DepositSettlement
$channelId = is_numeric($order['channel_id'] ?? null) ? intval($order['channel_id']) : null;
$balanceBefore = self::amountString($user['coin'] ?? '0');
$balanceAfter = bcadd($balanceBefore, $credit, 4);
$balanceAfter = bcadd($balanceBefore, $credit, 2);
$now = time();
$baseRemark = is_string($order['remark'] ?? null) ? $order['remark'] : '';
@@ -142,12 +142,10 @@ final class DepositSettlement
->where('id', $orderId)
->where('status', 0)
->update([
'status' => 1,
'pay_time' => $now,
'review_admin_id' => $operatorAdminId,
'review_time' => $operatorAdminId !== null ? $now : null,
'remark' => $finalRemark,
'update_time' => $now,
'status' => 1,
'pay_time' => $now,
'remark' => $finalRemark,
'update_time' => $now,
]);
if ($affected <= 0) {
throw new RuntimeException('订单状态已变更,请刷新后重试');
@@ -199,7 +197,7 @@ final class DepositSettlement
}
/**
* 将任意数值输入格式化为 4 位小数字符串(不做强制类型转换)
* 将任意数值输入格式化为 2 位小数字符串(不做强制类型转换)
*/
private static function amountString($raw): string
{
@@ -208,11 +206,11 @@ final class DepositSettlement
} elseif (is_int($raw) || is_float($raw)) {
$s = strval($raw);
} else {
return '0.0000';
return '0.00';
}
if (!is_numeric($s)) {
return '0.0000';
return '0.00';
}
return bcadd($s, '0', 4);
return bcadd($s, '0', 2);
}
}