1.新增获取充值/提现配置接口/api/finance/depositWithdrawConfig
2.优化充值和提现方式
This commit is contained in:
@@ -541,7 +541,7 @@ class Channel extends Backend
|
||||
return $this->error('该渠道下暂无管理员,无法配置分配比例');
|
||||
}
|
||||
|
||||
$enabledSum = '0.0000';
|
||||
$enabledSum = '0.00';
|
||||
$insertRows = [];
|
||||
foreach ($rowsRaw as $line) {
|
||||
if (!is_array($line)) {
|
||||
@@ -553,12 +553,12 @@ class Channel extends Backend
|
||||
}
|
||||
$status = ((int) ($line['status'] ?? 1)) === 1 ? 1 : 0;
|
||||
$shareRaw = $line['share_rate'] ?? null;
|
||||
$shareRate = self::normalizeAmountScale($shareRaw === null ? '0' : (string) $shareRaw, 4);
|
||||
if (bccomp($shareRate, '0', 4) < 0 || bccomp($shareRate, '100', 4) > 0) {
|
||||
$shareRate = self::normalizeAmountScale($shareRaw === null ? '0' : (string) $shareRaw, 2);
|
||||
if (bccomp($shareRate, '0', 2) < 0 || bccomp($shareRate, '100', 2) > 0) {
|
||||
return $this->error('分配比例必须在0到100之间');
|
||||
}
|
||||
if ($status === 1) {
|
||||
$enabledSum = bcadd($enabledSum, $shareRate, 4);
|
||||
$enabledSum = bcadd($enabledSum, $shareRate, 2);
|
||||
}
|
||||
$insertRows[] = [
|
||||
'channel_id' => (int) $row['id'],
|
||||
@@ -572,7 +572,7 @@ class Channel extends Backend
|
||||
if ($insertRows === []) {
|
||||
return $this->error('请至少配置一条有效分配记录');
|
||||
}
|
||||
if (bccomp($enabledSum, '100.0000', 4) !== 0) {
|
||||
if (bccomp($enabledSum, '100.00', 2) !== 0) {
|
||||
return $this->error('启用的分配比例总和必须等于100');
|
||||
}
|
||||
|
||||
@@ -696,7 +696,7 @@ class Channel extends Backend
|
||||
$stats = $this->aggregateBetOrderForChannel($channelId, $periodStartTs, $lastEnd !== null, $endTs);
|
||||
$totalBet = $stats['total_bet'];
|
||||
$totalPayout = $stats['total_payout'];
|
||||
$profit = bcsub($totalBet, $totalPayout, 4);
|
||||
$profit = bcsub($totalBet, $totalPayout, 2);
|
||||
|
||||
$mode = (string) ($row['agent_mode'] ?? 'turnover');
|
||||
$commission = $this->computeCommissionAmounts($row, $totalBet, $profit, $mode);
|
||||
@@ -740,7 +740,7 @@ class Channel extends Backend
|
||||
|
||||
$base = $flag . $channelPart . $timePart;
|
||||
for ($i = 0; $i < 8; $i++) {
|
||||
$randPart = strtoupper(substr(bin2hex(random_bytes(4)), 0, 8));
|
||||
$randPart = strtoupper(substr(bin2hex(random_bytes(4)), 0, 2));
|
||||
$no = $base . $randPart;
|
||||
if (!Db::name('agent_settlement_period')->where('settlement_no', $no)->value('id')) {
|
||||
return $no;
|
||||
@@ -784,10 +784,10 @@ class Channel extends Backend
|
||||
}
|
||||
|
||||
$row = $query->field('SUM(total_amount) AS tb, SUM(win_amount) AS tw, SUM(jackpot_extra_amount) AS tj')->find();
|
||||
$tb = $row && $row['tb'] !== null && $row['tb'] !== '' ? (string) $row['tb'] : '0.0000';
|
||||
$tw = $row && $row['tw'] !== null && $row['tw'] !== '' ? (string) $row['tw'] : '0.0000';
|
||||
$tj = $row && $row['tj'] !== null && $row['tj'] !== '' ? (string) $row['tj'] : '0.0000';
|
||||
$totalPayout = bcadd($tw, $tj, 4);
|
||||
$tb = $row && $row['tb'] !== null && $row['tb'] !== '' ? (string) $row['tb'] : '0.00';
|
||||
$tw = $row && $row['tw'] !== null && $row['tw'] !== '' ? (string) $row['tw'] : '0.00';
|
||||
$tj = $row && $row['tj'] !== null && $row['tj'] !== '' ? (string) $row['tj'] : '0.00';
|
||||
$totalPayout = bcadd($tw, $tj, 2);
|
||||
|
||||
return [
|
||||
'total_bet' => number_format((float) $tb, 4, '.', ''),
|
||||
@@ -805,8 +805,8 @@ class Channel extends Backend
|
||||
if ($ratePercent === null || $ratePercent === '') {
|
||||
return '普通返水代理未配置返水分红比例';
|
||||
}
|
||||
$rateDec = bcdiv((string) $ratePercent, '100', 6);
|
||||
$amount = bcmul($totalBet, $rateDec, 4);
|
||||
$rateDec = bcdiv((string) $ratePercent, '100', 2);
|
||||
$amount = bcmul($totalBet, $rateDec, 2);
|
||||
return [
|
||||
'commission_rate' => $rateDec,
|
||||
'calc_base_amount' => $totalBet,
|
||||
@@ -825,27 +825,27 @@ class Channel extends Backend
|
||||
return '联营阶梯规则无效或为空';
|
||||
}
|
||||
|
||||
if (bccomp($platformProfit, '0', 4) <= 0) {
|
||||
if (bccomp($platformProfit, '0', 2) <= 0) {
|
||||
return [
|
||||
'commission_rate' => '0.000000',
|
||||
'calc_base_amount' => '0.0000',
|
||||
'commission_amount' => '0.0000',
|
||||
'commission_rate' => '0.00',
|
||||
'calc_base_amount' => '0.00',
|
||||
'commission_amount' => '0.00',
|
||||
];
|
||||
}
|
||||
|
||||
$afterFee = bcmul($platformProfit, bcsub('1', (string) $fee, 8), 4);
|
||||
if (bccomp($afterFee, '0', 4) <= 0) {
|
||||
$afterFee = bcmul($platformProfit, bcsub('1', (string) $fee, 2), 2);
|
||||
if (bccomp($afterFee, '0', 2) <= 0) {
|
||||
return [
|
||||
'commission_rate' => '0.000000',
|
||||
'calc_base_amount' => '0.0000',
|
||||
'commission_amount' => '0.0000',
|
||||
'commission_rate' => '0.00',
|
||||
'calc_base_amount' => '0.00',
|
||||
'commission_amount' => '0.00',
|
||||
];
|
||||
}
|
||||
|
||||
$playerLoss = $platformProfit;
|
||||
$share = $this->pickAffiliateShareRateFromLadder($rules, $playerLoss);
|
||||
$rateDec = number_format($share, 6, '.', '');
|
||||
$amount = bcmul($afterFee, $rateDec, 4);
|
||||
$amount = bcmul($afterFee, $rateDec, 2);
|
||||
|
||||
return [
|
||||
'commission_rate' => $rateDec,
|
||||
@@ -888,7 +888,7 @@ class Channel extends Backend
|
||||
];
|
||||
}
|
||||
usort($out, function ($a, $b) {
|
||||
return bccomp($a['minLoss'], $b['minLoss'], 4);
|
||||
return bccomp($a['minLoss'], $b['minLoss'], 2);
|
||||
});
|
||||
return $out;
|
||||
}
|
||||
@@ -900,7 +900,7 @@ class Channel extends Backend
|
||||
{
|
||||
$chosen = (float) $rules[0]['shareRate'];
|
||||
foreach ($rules as $rule) {
|
||||
if (bccomp($playerLoss, $rule['minLoss'], 4) >= 0) {
|
||||
if (bccomp($playerLoss, $rule['minLoss'], 2) >= 0) {
|
||||
$chosen = (float) $rule['shareRate'];
|
||||
}
|
||||
}
|
||||
@@ -959,24 +959,24 @@ class Channel extends Backend
|
||||
->select()
|
||||
->toArray();
|
||||
if ($rows !== []) {
|
||||
$sum = '0.0000';
|
||||
$sum = '0.00';
|
||||
$out = [];
|
||||
foreach ($rows as $row) {
|
||||
$adminId = (int) ($row['admin_id'] ?? 0);
|
||||
if ($adminId <= 0) {
|
||||
continue;
|
||||
}
|
||||
$shareRate = self::normalizeAmountScale((string) ($row['share_rate'] ?? '0'), 4);
|
||||
if (bccomp($shareRate, '0', 4) <= 0) {
|
||||
$shareRate = self::normalizeAmountScale((string) ($row['share_rate'] ?? '0'), 2);
|
||||
if (bccomp($shareRate, '0', 2) <= 0) {
|
||||
continue;
|
||||
}
|
||||
$sum = bcadd($sum, $shareRate, 4);
|
||||
$sum = bcadd($sum, $shareRate, 2);
|
||||
$out[] = [
|
||||
'admin_id' => $adminId,
|
||||
'share_rate' => $shareRate,
|
||||
];
|
||||
}
|
||||
if ($out !== [] && bccomp($sum, '100.0000', 4) === 0) {
|
||||
if ($out !== [] && bccomp($sum, '100.00', 2) === 0) {
|
||||
return $out;
|
||||
}
|
||||
}
|
||||
@@ -987,7 +987,7 @@ class Channel extends Backend
|
||||
}
|
||||
return [[
|
||||
'admin_id' => (int) $fallbackAdminId,
|
||||
'share_rate' => '100.0000',
|
||||
'share_rate' => '100.00',
|
||||
]];
|
||||
}
|
||||
|
||||
@@ -1007,19 +1007,19 @@ class Channel extends Backend
|
||||
if ($shareRows === []) {
|
||||
return [];
|
||||
}
|
||||
$sum = '0.0000';
|
||||
$sum = '0.00';
|
||||
$rows = [];
|
||||
$lastIndex = count($shareRows) - 1;
|
||||
foreach ($shareRows as $index => $shareRow) {
|
||||
$shareRate = self::normalizeAmountScale((string) ($shareRow['share_rate'] ?? '0'), 4);
|
||||
$shareDec = bcdiv($shareRate, '100', 8);
|
||||
$shareRate = self::normalizeAmountScale((string) ($shareRow['share_rate'] ?? '0'), 2);
|
||||
$shareDec = bcdiv($shareRate, '100', 2);
|
||||
$amount = $index === $lastIndex
|
||||
? bcsub($commissionTotal, $sum, 4)
|
||||
: bcmul($commissionTotal, $shareDec, 4);
|
||||
? bcsub($commissionTotal, $sum, 2)
|
||||
: bcmul($commissionTotal, $shareDec, 2);
|
||||
if ($index !== $lastIndex) {
|
||||
$sum = bcadd($sum, $amount, 4);
|
||||
$sum = bcadd($sum, $amount, 2);
|
||||
}
|
||||
$effectiveRate = bccomp($calcBaseAmount, '0', 4) <= 0 ? '0.000000' : bcdiv($amount, $calcBaseAmount, 6);
|
||||
$effectiveRate = bccomp($calcBaseAmount, '0', 2) <= 0 ? '0.00' : bcdiv($amount, $calcBaseAmount, 2);
|
||||
$rows[] = [
|
||||
'settlement_period_id' => $periodId,
|
||||
'channel_id' => $channelId,
|
||||
@@ -1052,17 +1052,17 @@ class Channel extends Backend
|
||||
}
|
||||
$adminNames = Db::name('admin')->where('id', 'in', $adminIds)->column('username', 'id');
|
||||
|
||||
$sum = '0.0000';
|
||||
$sum = '0.00';
|
||||
$out = [];
|
||||
$lastIndex = count($shareRows) - 1;
|
||||
foreach ($shareRows as $index => $shareRow) {
|
||||
$shareRate = self::normalizeAmountScale((string) ($shareRow['share_rate'] ?? '0'), 4);
|
||||
$shareDec = bcdiv($shareRate, '100', 8);
|
||||
$shareRate = self::normalizeAmountScale((string) ($shareRow['share_rate'] ?? '0'), 2);
|
||||
$shareDec = bcdiv($shareRate, '100', 2);
|
||||
$amount = $index === $lastIndex
|
||||
? bcsub($commissionTotal, $sum, 4)
|
||||
: bcmul($commissionTotal, $shareDec, 4);
|
||||
? bcsub($commissionTotal, $sum, 2)
|
||||
: bcmul($commissionTotal, $shareDec, 2);
|
||||
if ($index !== $lastIndex) {
|
||||
$sum = bcadd($sum, $amount, 4);
|
||||
$sum = bcadd($sum, $amount, 2);
|
||||
}
|
||||
$adminId = (int) ($shareRow['admin_id'] ?? 0);
|
||||
$out[] = [
|
||||
|
||||
Reference in New Issue
Block a user