fix: 修复 WMS API 请求格式(query string + timestamp 类型)
- base_url 改为 qimen.wms.gztbyc.com - query 参数拼入 URL query string(method/timestamp/app_key/sign) - timestamp 改为整数类型(Unix 秒) - 移除多余 X-* 自定义 Header
This commit is contained in:
parent
c35ac184ae
commit
1f40838320
@ -7,7 +7,7 @@
|
||||
*/
|
||||
return [
|
||||
// WMS 仓库接口基础地址(不含 /warehouse)
|
||||
'base_url' => 'https://wms.wms.gztbyc.com',
|
||||
'base_url' => 'https://qimen.wms.gztbyc.com',
|
||||
|
||||
// 应用 Key(由 WMS 平台分配,联系仓库管理员获取)
|
||||
'app_key' => 'AK2026080314055697eb6c36',
|
||||
|
||||
@ -76,7 +76,7 @@ abstract class Base
|
||||
$body = !empty($body) ? $body : new \stdClass(); // 空 body → {}
|
||||
|
||||
// ---- 构建 query 参数 ----
|
||||
$timestamp = (string) time();
|
||||
$timestamp = time();
|
||||
$nonce = $this->generateNonce(16);
|
||||
$queryParams = array_merge([
|
||||
'app_key' => $this->appKey,
|
||||
@ -90,7 +90,8 @@ abstract class Base
|
||||
$sign = $this->signer->make($queryParams, $body);
|
||||
|
||||
// ---- 发起请求 ----
|
||||
$url = $this->baseUrl . '/warehouse';
|
||||
$queryStr = http_build_query(array_merge($queryParams, ['sign' => $sign]));
|
||||
$url = $this->baseUrl . '/warehouse?' . $queryStr;
|
||||
$bodyJson = json_encode($body, JSON_UNESCAPED_UNICODE);
|
||||
|
||||
\think\Log::info("[WmsFunc] {$method} 请求: " . json_encode([
|
||||
@ -104,10 +105,6 @@ abstract class Base
|
||||
$response = Http::post($url, $bodyJson, [
|
||||
CURLOPT_HTTPHEADER => [
|
||||
'Content-Type: application/json',
|
||||
'X-App-Key: ' . $this->appKey,
|
||||
'X-Timestamp: ' . $timestamp,
|
||||
'X-Nonce: ' . $nonce,
|
||||
'X-Sign: ' . $sign,
|
||||
],
|
||||
CURLOPT_TIMEOUT => $this->timeout,
|
||||
CURLOPT_CONNECTTIMEOUT => $this->connectTimeout,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user