1.优化提现接口/api/finance/withdrawCreate

This commit is contained in:
2026-05-20 12:01:07 +08:00
parent 91229f4477
commit b9e4d806f7
12 changed files with 219 additions and 13 deletions

View File

@@ -402,6 +402,72 @@ final class DepositChannel
return array_values(array_unique($codes));
}
/**
* 当前服务端已对接自动出金的渠道(与 withdrawCreate 校验一致)
*
* @return list<string>
*/
public static function withdrawPayoutChannelCodes(): array
{
return ['ddpay'];
}
/**
* @param list<array{code: string, sort: int, status: int, tier_ids: list<string>}> $effectiveRows
*/
public static function assertChannelEnabled(string $channelCode, array $effectiveRows): bool
{
$row = self::findMergedByCode($effectiveRows, $channelCode);
if ($row === null) {
return false;
}
return ($row['status'] ?? 0) === 1;
}
/**
* 提现页可选支付渠道(仅返回已启用且已对接出金的渠道)
*
* @param list<array{code: string, sort: int, status: int, tier_ids: list<string>}> $effectiveRows
*
* @return list<array{code: string, name: string, sort: int}>
*/
public static function channelsForWithdraw(array $effectiveRows, string $lang): array
{
$registry = self::codeRegistry();
$allowed = self::withdrawPayoutChannelCodes();
$out = [];
foreach ($effectiveRows as $row) {
if (($row['status'] ?? 0) !== 1) {
continue;
}
$code = isset($row['code']) && is_string($row['code']) ? $row['code'] : '';
if ($code === '' || !in_array($code, $allowed, true)) {
continue;
}
if (!isset($registry[$code])) {
continue;
}
$meta = $registry[$code];
$sortRaw = $row['sort'] ?? 0;
$sortVal = is_numeric($sortRaw) ? intval($sortRaw) : 0;
$out[] = [
'code' => $code,
'name' => self::pickLangName($meta, $lang),
'sort' => $sortVal,
];
}
usort($out, static function (array $a, array $b): int {
if ($a['sort'] !== $b['sort']) {
return $a['sort'] <=> $b['sort'];
}
return strcmp($a['code'], $b['code']);
});
return $out;
}
/**
* @param list<array<string, mixed>> $items
*