This commit is contained in:
Your Name
2026-04-07 18:13:03 +08:00
parent a780356908
commit fdf714f833
397 changed files with 15086 additions and 1043 deletions
+51
View File
@@ -0,0 +1,51 @@
<?php
declare(strict_types=1);
/**
* 物流轨迹(顺丰 / 京东等)
* 对接快递100「实时查询」: https://api.kuaidi100.com
*
* 规则:同时配置好 CUSTOMER、KEY 即自动走快递100(不必再设 ENABLE=true)。
* 若需临时关闭(保留密钥):LOGISTICS_KUAIDI100_DISABLE = true
*/
$stripQuotes = static function (string $v): string {
$v = trim($v);
if (strlen($v) >= 2 && (($v[0] === '"' && $v[strlen($v) - 1] === '"') || ($v[0] === "'" && $v[strlen($v) - 1] === "'"))) {
return substr($v, 1, -1);
}
return $v;
};
// .env 为 INI 格式:写在某个 [section](如 [trtc])下面的键会变成 trtc.xxx,读不到顶层 LOGISTICS_*
$envKuaidi = static function (string $suffix, $default = '') use ($stripQuotes) {
$top = 'LOGISTICS_KUAIDI100_' . $suffix;
$v = env($top, null);
if ($v !== null && $v !== '') {
return $stripQuotes((string) $v);
}
$nested = env('trtc.' . $top, $default);
return $stripQuotes((string) $nested);
};
$customer = $envKuaidi('CUSTOMER', '');
$key = $envKuaidi('KEY', '');
$hasCreds = $customer !== '' && $key !== '';
$forceDisableRaw = env('LOGISTICS_KUAIDI100_DISABLE', null);
if ($forceDisableRaw === null || $forceDisableRaw === '') {
$forceDisableRaw = env('trtc.LOGISTICS_KUAIDI100_DISABLE', false);
}
$forceDisable = filter_var($forceDisableRaw, FILTER_VALIDATE_BOOLEAN);
// 已填 CUSTOMER+KEY 即启用;需临时关闭时设 LOGISTICS_KUAIDI100_DISABLE=trueLOGISTICS_KUAIDI100_ENABLE 已废弃,可删)
$kuaidiEnabled = ! $forceDisable && $hasCreds;
return [
'kuaidi100' => [
'enable' => $kuaidiEnabled,
'customer' => $customer,
'key' => $key,
'query_url' => $envKuaidi('QUERY_URL', 'https://poll.kuaidi100.com/poll/query.do'),
],
];