$catalog->options($fixture['channels'], $fixture['groups'], $filters); $deposit = $options(['kind' => 'deposit']); $withdraw = $options(['kind' => 'withdraw']); $check(['sanjin', 'jd', 'no', 'zimu'], array_column($deposit['payment_companies'], 'value'), '空商户表也有四家存款公司'); $check(['qianbao', 'jd', 'no', 'zimu'], array_column($withdraw['payment_companies'], 'value'), '提现公司按已实现方向返回'); $check([false, false, false, false], array_column($deposit['payment_companies'], 'disabled'), '实际数据四家均有可选通道'); $check([false, false, false, false], array_column($withdraw['payment_companies'], 'disabled'), '实际数据四家提现均有可选通道'); $check('environment', $deposit['credential_source'], '不把保存配置冒充运行时凭据'); $allChannels = array_column($options()['recharge_channels'], null, 'id'); foreach ([1, 15, 16, 20, 21, 22, 23] as $id) { $check(null, $allChannels[$id]['provider_code'], 'USDT/人工/活动不归入第三方公司 ' . $id); } foreach ([2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14] as $id) { $check('sanjin', $allChannels[$id]['provider_code'], '三斤通道映射 ' . $id); $check([1], $allChannels[$id]['available_group_ids'], '三斤不属于线下组合 ' . $id); } foreach ([24, 25, 26, 27, 28, 29, 30] as $id) { $check([1, 2], $allChannels[$id]['available_group_ids'], 'JD/NO/808支持两个组合 ' . $id); } foreach ([17, 18, 19] as $id) { $check('qianbao', $allChannels[$id]['provider_code'], '钱宝提现映射 ' . $id); $check([1], $allChannels[$id]['available_group_ids'], '钱宝提现不属于线下组合 ' . $id); } $check(false, $allChannels[31]['selectable'], 'ZIMUcash停用不可选'); $check([], $allChannels[31]['available_group_ids'], 'ZIMUcash无所属组合'); $check('0.2000', $allChannels[25]['fee_rate'], 'JD提现原始费率转换为百分比'); $check('9.5000', $allChannels[2]['fee_rate'], '微信费率转换为百分比'); $check(['945', '988', '990'], $allChannels[10]['fixed_amounts'], '固额金额保留'); $filtered = $options(['kind' => 'deposit', 'payment_company' => 'sanjin', 'payment_method' => 'zfbsm']); $check([6, 7, 8, 9], array_column($filtered['recharge_channels'], 'id'), '支付宝扫码保留全部四个额度通道'); $check(7, count($filtered['payment_methods']), '选方式不截断公司方式下拉'); $no = $options(['kind' => 'collection_scan', 'provider_name' => 'no']); $check(['NOpay12', 'NOpay13'], array_column($no['collection_methods'], 'value'), '代收NO方式联动'); $check([26, 27], array_column($no['recharge_channels'], 'id'), '代收NO通道联动'); $check('SHA256', array_column($deposit['payment_companies'], null, 'value')['no']['signature_algorithm'], 'NO不标成MD5'); $check([25], array_column($options(['kind' => 'withdraw', 'payment_company' => 'jd'])['recharge_channels'], 'id'), '同名JD type按充值提现分开'); $check(true, array_column($options(['kind' => 'withdraw', 'payment_company' => 'zimu'])['payment_methods'], null, 'value')['ZIMUcash']['disabled'], '禁用方式仍可见但不能选择'); $empty = $catalog->options([], [], ['kind' => 'deposit']); $check(4, count($empty['payment_companies']), '没有通道时目录仍存在'); $check([true, true, true, true], array_column($empty['payment_companies'], 'disabled'), '没有通道不伪造可用'); $check(['channel_missing', 'channel_missing', 'channel_missing', 'channel_missing'], array_column($empty['payment_companies'], 'disabled_reason_code'), '缺少通道有明确原因'); $legacyGroups = $fixture['groups']; foreach ($legacyGroups as &$group) { $group['recharge_type'] = implode(',', array_diff(explode(',', $group['recharge_type']), ['JDpay', 'NOpay12', 'NOpay13', 'ZIMUpay'])); } unset($group); $missingGroups = $catalog->options($fixture['channels'], $legacyGroups, ['kind' => 'deposit']); $check([false, true, true, true], array_column($missingGroups['payment_companies'], 'disabled'), '只新增通道未更新组合可复现截图'); $check(['', 'group_missing', 'group_missing', 'group_missing'], array_column($missingGroups['payment_companies'], 'disabled_reason_code'), '组合缺失不误报为不支持'); $check('group_missing', array_column($missingGroups['payment_methods'], null, 'value')['JDpay']['disabled_reason_code'], '方式也返回组合缺失原因'); $stoppedChannels = $fixture['channels']; foreach ($stoppedChannels as &$channel) { if (in_array($channel['type'], ['JDpay', 'NOpay12', 'NOpay13', 'ZIMUpay'], true)) $channel['status'] = 0; } unset($channel); $stopped = $catalog->options($stoppedChannels, $fixture['groups'], ['kind' => 'deposit']); $check(['', 'channel_disabled', 'channel_disabled', 'channel_disabled'], array_column($stopped['payment_companies'], 'disabled_reason_code'), '停用和组合缺失区分'); $check(['NOpay12', 'NOpay13'], PaymentProviderCatalog::channelTypesForProvider('no', 1), 'NO存款筛选'); $check(['NOwithdraw'], PaymentProviderCatalog::channelTypesForProvider('no', 2), 'NO提现筛选'); $check([], PaymentProviderCatalog::channelTypesForProvider('sanjin', 2), '三斤无已登记提现方式'); $check([], PaymentProviderCatalog::channelTypesForProvider('no', 3), '活动不属于NO'); $check(['JDpay'], PaymentProviderCatalog::channelTypesForProvider('jd'), '跨方向同名type去重'); $check(['', '', '', ''], array_column($deposit['payment_companies'], 'disabled_reason'), '可选公司无错误提示'); $unknown = $fixture['channels'][0]; $unknown['from'] = 1; $unknown['type'] = 'unimplemented'; $check(null, PaymentProviderCatalog::channelIdentity($unknown), '未知通道不默认发给三斤'); $raw = array_column($fixture['channels'], null, 'id'); PaymentProviderCatalog::validateSelection($raw[2], 'sanjin', 'wxsm', 1); foreach ([[$raw[2], 'jd', 'wxsm', 1], [$raw[2], 'sanjin', 'zfbsm', 1], [$raw[24], 'jd', 'JDpay', 2], [$raw[15], 'sanjin', 'rgcz', 1]] as $args) { $rejected = false; try { PaymentProviderCatalog::validateSelection(...$args); } catch (InvalidArgumentException $e) { $rejected = true; } $check(true, $rejected, '保存拒绝跨公司/跨方向/手填方式/人工充值'); } echo "Payment provider catalog: {$checks} checks passed.\n";