diff --git a/application/extra/wms.php b/application/extra/wms.php new file mode 100644 index 0000000..2fa22f1 --- /dev/null +++ b/application/extra/wms.php @@ -0,0 +1,23 @@ + 'https://wms.wms.gztbyc.com', + + // 应用 Key(由 WMS 平台分配,联系仓库管理员获取) + 'app_key' => 'AK2026080314055697eb6c36', + + // 应用 Secret(由 WMS 平台分配) + 'app_secret'=> '5514e6bd12fcf6622606b5eb70981b3a1dcf2d2718aca1100f9a9fc6e60b35e1', + + // API 版本 + 'version' => '1.0', + + // 请求超时(秒) + 'timeout' => 10, +]; diff --git a/application/index/controller/wms/Chat.php b/application/index/controller/wms/Chat.php index 3c92a43..9435e8a 100644 --- a/application/index/controller/wms/Chat.php +++ b/application/index/controller/wms/Chat.php @@ -574,15 +574,18 @@ class Chat extends Frontend $postnums = $this->getPostNums($text);//获取快递号 //消息格式化end - // ── 转发到 WMS 开放接口 ── - // 如果 WMS 返回了处理结果,跳过本地关键词匹配直接返回 - $forward = new Forward(); - $forwardResult = $forward->handle($params, $this->SOURCE, $text); - if ($forwardResult !== null) { - if (!empty($forwardResult['msgs'])) { - $msg_log->save(["result" => json_encode($forwardResult['msgs'])]); + // ── 转发到 WMS 开放接口(不阻塞原有流程)── + try { + $forward = new Forward(); + $forwardResult = $forward->handle($params, $this->SOURCE, $text); + if ($forwardResult !== null) { + if (!empty($forwardResult['msgs'])) { + $msg_log->save(["result" => json_encode($forwardResult['msgs'])]); + } + return $forwardResult; } - return $forwardResult; + } catch (\Throwable $e) { + \think\Log::error('[Forward] 转发异常(已忽略): ' . $e->getMessage()); } switch($roomtype){ diff --git a/application/index/library/new_wms/Forward.php b/application/index/library/new_wms/Forward.php index 77ac9dc..dec85f8 100644 --- a/application/index/library/new_wms/Forward.php +++ b/application/index/library/new_wms/Forward.php @@ -2,13 +2,13 @@ namespace app\index\library\new_wms; -use fast\Http; +use app\index\library\new_wms\func\Inbox; /** * 消息转发处理器 * - * 将群聊消息转发到 WMS 开放接口处理 - * 如果 WMS 返回了有效响应,则跳过 Chat::processMessage 的本地关键词匹配逻辑 + * 收集群聊消息上下文,通过 inbox.push 推送到 WMS 仓库站内信。 + * WMS 异步处理后通过回调/Webhook 返回结果。 * * 调用方式: * $forward = new Forward(); @@ -17,107 +17,77 @@ use fast\Http; */ class Forward { - // ==================== WMS 开放接口配置 ==================== - const WMS_API_BASE_URL = 'https://wms.wms.gztbyc.com/warehouse'; // WMS 开放接口地址 - const WMS_APP_KEY = ''; // 应用 Key(待配置) - const WMS_APP_SECRET = ''; // 应用 Secret(待配置) - const WMS_API_TIMEOUT = 10; // 请求超时(秒) - /** - * 处理消息转发 + * 处理消息转发 → inbox.push * * @param array $params 统一消息结构(与 processMessage 入参一致) * @param string $source 消息来源: 'wx' | 'qiwe' * @param string $text 已提取的消息文本内容 - * @return array|null 返回 null 表示不处理(继续本地逻辑), - * 返回 ["msgs" => ..., "info" => ...] 则跳过本地处理直接返回 + * @return array|null 返回 null 表示继续本地逻辑 */ public function handle($params, $source, $text) { // ---- 配置未就绪时跳过 ---- - if (empty(static::WMS_APP_KEY) || empty(static::WMS_APP_SECRET)) { + if (empty(config('wms.app_key')) || empty(config('wms.app_secret'))) { return null; } - // ---- 构建请求签名 ---- - $timestamp = (string) time(); - $nonce = $this->generateNonce(16); - $sign = $this->buildSign($timestamp, $nonce); + // ---- 收集消息上下文,映射到 inbox.push 参数 ---- + $data = $params['data'] ?? []; + $fromId = $data['fromid'] ?? ''; + $memId = $data['memid'] ?? ''; + $memName = $data['memname'] ?? ''; + $nickName = $data['nickName'] ?? ''; + $msgId = $data['id'] ?? ''; + $msgType = $params['type'] ?? 1; - // ---- 构建请求体 ---- - $postData = [ - 'fromid' => $params['data']['fromid'] ?? '', - 'memid' => $params['data']['memid'] ?? '', - 'memname' => $params['data']['memname'] ?? '', - 'nickName' => $params['data']['nickName'] ?? '', - 'msg' => $text, - 'source' => $source, - 'type' => $params['type'] ?? 1, - 'msgId' => $params['data']['id'] ?? '', + $inboxParams = [ + 'requestId' => $msgId, // 消息 ID → 幂等去重 + 'content' => $text, // 消息正文 + 'groupId' => $fromId, // 群/会话 ID + 'groupName' => '', // 群名称(暂不可用) + 'userId' => $memId, // 发送者 ID + 'userName' => $nickName ?: $memName, // 发送者名称 + 'parentId' => 0, + 'sourceType' => 'im', // 来源: IM + 'targetType' => 'im', + 'extData' => [ + 'source' => $source, // wx / qiwe + 'type' => $msgType, // 消息类型 + 'memName' => $memName, // 原始成员名 + ], + 'flags' => new \stdClass(), ]; - // ---- 发起请求 ---- + // ---- 转发到 WMS ---- try { - $response = Http::post( - static::WMS_API_BASE_URL . '/chat/handle', - json_encode($postData), - [ - CURLOPT_HTTPHEADER => [ - 'Content-Type: application/json', - 'X-App-Key: ' . static::WMS_APP_KEY, - 'X-Timestamp: ' . $timestamp, - 'X-Nonce: ' . $nonce, - 'X-Sign: ' . $sign, - ], - CURLOPT_TIMEOUT => static::WMS_API_TIMEOUT, - CURLOPT_CONNECTTIMEOUT => 5, - ] - ); + $inbox = $this->getInbox(); + $result = $inbox->push($inboxParams); - $result = json_decode($response, true); - - // ---- 校验响应 ---- - if (!$result || empty($result['code'])) { - \think\Log::error('[Forward] WMS 接口返回异常: ' . json_encode($response)); - return null; // 异常时降级到本地处理 + if (!empty($result['data']['ok'])) { + \think\Log::info('[Forward] 已推送站内信: ext_id=' . ($result['data']['ext_id'] ?? '?')); + } else { + \think\Log::error('[Forward] 推送失败: ' . json_encode($result, JSON_UNESCAPED_UNICODE)); } - - // code == 1 表示 WMS 已处理,返回给群聊 - if ((int) $result['code'] === 1 && !empty($result['data'])) { - \think\Log::info('[Forward] WMS 已处理消息: ' . json_encode($result)); - return [ - 'msgs' => $result['data']['msgs'] ?? [], - 'info' => $result['data']['info'] ?? '已转发WMS处理', - ]; - } - - // code == 0 或 data 为空 → 走本地逻辑 - return null; - } catch (\Exception $e) { - \think\Log::error('[Forward] 请求异常: ' . $e->getMessage()); - return null; // 异常时降级到本地处理 + \think\Log::error('[Forward] 推送异常: ' . $e->getMessage()); } + + // inbox.push 是异步的,始终回退到本地逻辑处理 + return null; } /** - * 构建请求签名 + * 获取 Inbox 实例(懒加载) + * @return Inbox */ - private function buildSign($timestamp, $nonce) + private function getInbox() { - return md5(static::WMS_APP_KEY . $timestamp . $nonce . static::WMS_APP_SECRET); - } - - /** - * 生成随机 nonce - */ - private function generateNonce($length = 16) - { - $chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'; - $nonce = ''; - for ($i = 0; $i < $length; $i++) { - $nonce .= $chars[random_int(0, strlen($chars) - 1)]; + static $inbox = null; + if ($inbox === null) { + $inbox = new Inbox(); } - return $nonce; + return $inbox; } } + diff --git a/application/index/library/new_wms/WmsSign.php b/application/index/library/new_wms/WmsSign.php new file mode 100644 index 0000000..1ee4301 --- /dev/null +++ b/application/index/library/new_wms/WmsSign.php @@ -0,0 +1,251 @@ +make($queryParams, $body); + */ +class WmsSign +{ + /** @var string 应用 Secret */ + private $appSecret; + + /** + * @param string $appSecret 应用 Secret + */ + public function __construct($appSecret) + { + $this->appSecret = $appSecret; + } + + // ==================== 公开方法 ==================== + + /** + * 生成签名 + * + * @param array $queryParams 请求 query 参数(关联数组) + * @param mixed $body 请求体(数组、对象等,传 null 表示无请求体) + * @return string 签名结果(小写 MD5 字符串) + */ + public function make(array $queryParams, $body = null) + { + $canonicalQuery = $this->buildCanonicalQuery($queryParams); + $bodySign = $this->buildBodySign($body); + + $signText = $canonicalQuery . $this->appSecret . $bodySign; + + return md5($signText); + } + + // ==================== 内部方法 ==================== + + /** + * 构建 canonicalQuery + * 将 query 参数(排除 sign/signature)按 key 字母序升序排列, + * 拼接为 key1=value1&key2=value2 格式。 + * + * @param array $queryParams + * @return string + */ + private function buildCanonicalQuery(array $queryParams) + { + // 排除签名字段 + $excludeKeys = ['sign', 'signature']; + $filtered = []; + foreach ($queryParams as $key => $value) { + if (in_array($key, $excludeKeys, true)) { + continue; + } + $filtered[$key] = $value; + } + + // 按 key 字母序升序排列 + ksort($filtered, SORT_STRING); + + // 拼接 + $parts = []; + foreach ($filtered as $key => $value) { + $parts[] = $key . '=' . $this->serializeParamValue($value); + } + + return implode('&', $parts); + } + + /** + * 序列化参数值 + * 规则:undefined/null → 空字符串,对象类型 → stableStringify,其他 → String(value) + * + * @param mixed $value + * @return string + */ + private function serializeParamValue($value) + { + if ($value === null) { + return ''; + } + + if (is_array($value) || is_object($value)) { + return $this->stableStringify($value); + } + + return (string) $value; + } + + /** + * 构建 bodySign + * bodySign = md5(stableStringify(请求体)) + * + * @param mixed $body + * @return string + */ + private function buildBodySign($body) + { + if ($body === null) { + return md5(''); + } + + return md5($this->stableStringify($body)); + } + + // ==================== stableStringify ==================== + + /** + * 稳定序列化:递归排序对象 key,保证相同数据始终产出相同字符串。 + * + * 规则: + * - 对普通数组(关联数组/对象),按 key 字母序递归序列化每个字段 + * - 对索引数组(list),按顺序递归序列化每个元素 + * - 对非普通对象(Date 等),使用 JSON.stringify + * - null 返回 "null" + * + * @param mixed $data + * @return string + */ + public function stableStringify($data) + { + return $this->_stringify($data); + } + + /** + * 内部序列化递归 + * + * @param mixed $data + * @return string + */ + private function _stringify($data) + { + // null + if ($data === null) { + return 'null'; + } + + // 标量 + if (is_bool($data)) { + return $data ? 'true' : 'false'; + } + + if (is_int($data) || is_float($data)) { + // 浮点数保留足够精度,避免 1.0 和 1 产生差异 + if (is_float($data)) { + // 用 var_export 保留浮点精度 + return var_export($data, true); + } + return (string) $data; + } + + if (is_string($data)) { + return $this->jsonEncodeString($data); + } + + // 对象 + if (is_object($data)) { + // 非普通对象(如 DateTime 等)→ JSON.stringify + if (!$this->isPlainObject($data)) { + return json_encode($data, JSON_UNESCAPED_UNICODE); + } + // 普通对象 → 提取属性,按 key 排序后序列化为 {...} 格式 + $props = get_object_vars($data); + ksort($props, SORT_STRING); + $parts = []; + foreach ($props as $key => $value) { + $parts[] = $this->jsonEncodeString((string) $key) . ':' . $this->_stringify($value); + } + return '{' . implode(',', $parts) . '}'; + } + + // 数组 + if (is_array($data)) { + // 判断是否为索引数组(list) + if ($this->isArrayList($data)) { + $parts = []; + foreach ($data as $item) { + $parts[] = $this->_stringify($item); + } + return '[' . implode(',', $parts) . ']'; + } + + // 关联数组 → 按 key 字母序排序 + ksort($data, SORT_STRING); + $parts = []; + foreach ($data as $key => $value) { + $parts[] = $this->jsonEncodeString((string) $key) . ':' . $this->_stringify($value); + } + return '{' . implode(',', $parts) . '}'; + } + + // 兜底 + return json_encode($data, JSON_UNESCAPED_UNICODE); + } + + /** + * JSON 编码字符串(带双引号包裹) + * + * @param string $str + * @return string + */ + private function jsonEncodeString($str) + { + return json_encode($str, JSON_UNESCAPED_UNICODE); + } + + /** + * 判断是否为索引数组(list,即键为连续 0..n-1 的整数) + * + * @param array $arr + * @return bool + */ + private function isArrayList(array $arr) + { + if (empty($arr)) { + return true; // 空数组视为 list,输出 [] + } + return array_keys($arr) === range(0, count($arr) - 1); + } + + /** + * 判断是否为普通对象(stdClass 或匿名对象) + * 非普通对象如 DateTime、自定义类实例等 → 用 JSON.stringify + * + * @param object $obj + * @return bool + */ + private function isPlainObject($obj) + { + return $obj instanceof \stdClass; + } +} diff --git a/application/index/library/new_wms/WmsVerify.php b/application/index/library/new_wms/WmsVerify.php new file mode 100644 index 0000000..d821b30 --- /dev/null +++ b/application/index/library/new_wms/WmsVerify.php @@ -0,0 +1,129 @@ +verify($queryParams, $body, $incomingSign); + */ +class WmsVerify +{ + /** @var WmsSign */ + private $signer; + + /** + * @param string $appSecret 应用 Secret + */ + public function __construct($appSecret) + { + $this->signer = new WmsSign($appSecret); + } + + // ==================== 公开方法 ==================== + + /** + * 验证签名 + * + * @param array $queryParams 请求 query 参数(关联数组,应包含 sign 字段) + * @param mixed $body 请求体(数组、对象等,传 null 表示无请求体) + * @param string|null $incomingSign 传入的签名字符串;传 null 则自动从 queryParams 中取出 + * @return bool 验签是否通过 + */ + public function verify(array $queryParams, $body = null, $incomingSign = null) + { + // 获取传入的签名 + if ($incomingSign === null) { + $incomingSign = isset($queryParams['sign']) ? $queryParams['sign'] : ''; + } + + if (empty($incomingSign)) { + return false; + } + + // 重新计算签名 + $expectedSign = $this->signer->make($queryParams, $body); + + // 恒定时间比较(防止时序攻击) + return $this->hashEquals($expectedSign, $incomingSign); + } + + /** + * 从 HTTP 请求中自动提取参数并验签 + * + * 适用于接收 WMS 回调的场景: + * - GET 请求:query 参数从 $_GET 获取,body 为 null + * - POST 请求:query 参数从 $_GET 获取,body 从 php://input 获取 + * + * @param string|null $httpMethod 请求方法(GET/POST),传 null 自动判断 + * @return bool + */ + public function verifyFromRequest($httpMethod = null) + { + if ($httpMethod === null) { + $httpMethod = isset($_SERVER['REQUEST_METHOD']) + ? strtoupper($_SERVER['REQUEST_METHOD']) + : 'GET'; + } + + $queryParams = $_GET; + + $body = null; + if (in_array($httpMethod, ['POST', 'PUT', 'PATCH'], true)) { + $rawBody = file_get_contents('php://input'); + if ($rawBody !== false && $rawBody !== '') { + $body = json_decode($rawBody, true); + // JSON 解析失败则保留原始字符串 + if ($body === null && json_last_error() !== JSON_ERROR_NONE) { + $body = $rawBody; + } + } + } + + return $this->verify($queryParams, $body); + } + + // ==================== 内部方法 ==================== + + /** + * 恒定时间字符串比较(防止时序攻击) + * + * @param string $knownString 已知的正确签名 + * @param string $userString 用户传入的签名 + * @return bool + */ + private function hashEquals($knownString, $userString) + { + if (function_exists('hash_equals')) { + return hash_equals($knownString, $userString); + } + + // fallback: 恒定时间比较 + $knownLen = strlen($knownString); + $userLen = strlen($userString); + + // 先比较长度(非恒定时间,但不会泄露内容) + if ($knownLen !== $userLen) { + // 仍然执行一次比较操作以避免通过时间差异判断长度 + $knownString = $userString; + $result = 0; + } else { + $result = 0; + } + + for ($i = 0; $i < $knownLen; $i++) { + $result |= ord($knownString[$i]) ^ ord($userString[$i]); + } + + return $result === 0; + } +} diff --git a/application/index/library/new_wms/func/Base.php b/application/index/library/new_wms/func/Base.php new file mode 100644 index 0000000..0154dad --- /dev/null +++ b/application/index/library/new_wms/func/Base.php @@ -0,0 +1,157 @@ +ping(); + */ +abstract class Base +{ + /** @var WmsSign */ + protected $signer; + + /** @var string */ + protected $appKey; + + /** @var string */ + protected $baseUrl; + + /** @var string */ + protected $version; + + /** @var int */ + protected $timeout; + + /** @var int */ + protected $connectTimeout = 5; + + public function __construct() + { + $wms = config('wms') ?: []; + + $this->appKey = $wms['app_key'] ?? ''; + $this->signer = new WmsSign($wms['app_secret'] ?? ''); + $this->baseUrl = rtrim($wms['base_url'] ?? '', '/'); + $this->version = $wms['version'] ?? '1.0'; + $this->timeout = (int) ($wms['timeout'] ?? 10); + } + + // ==================== 子类需覆盖 ==================== + + /** + * 返回当前模块名(如 'index'、'store'、'inbox') + * @return string + */ + abstract protected function moduleName(); + + // ==================== 公共调用方法 ==================== + + /** + * 调用 WMS 开放接口 + * + * @param string $methodName 方法名(如 'ping'、'list'、'push') + * @param array $body 请求体(关联数组),空 body 传 [] + * @param array $extraQuery 额外的 query 参数 + * @return array 解析后的响应数组,包含 code / msg / data + */ + protected function call($methodName, array $body = [], array $extraQuery = []) + { + $method = $this->moduleName() . '.' . $methodName; + $body = !empty($body) ? $body : new \stdClass(); // 空 body → {} + + // ---- 构建 query 参数 ---- + $timestamp = (string) time(); + $nonce = $this->generateNonce(16); + $queryParams = array_merge([ + 'app_key' => $this->appKey, + 'method' => $method, + 'timestamp' => $timestamp, + 'v' => $this->version, + 'nonce' => $nonce, + ], $extraQuery); + + // ---- 签名 ---- + $sign = $this->signer->make($queryParams, $body); + + // ---- 发起请求 ---- + $url = $this->baseUrl . '/warehouse'; + $bodyJson = json_encode($body, JSON_UNESCAPED_UNICODE); + + \think\Log::info("[WmsFunc] {$method} 请求: " . json_encode([ + 'url' => $url, + 'query' => $queryParams, + 'body' => $bodyJson, + 'sign' => $sign, + ], JSON_UNESCAPED_UNICODE)); + + try { + $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, + ]); + + $result = json_decode($response, true); + + if ($result === null && json_last_error() !== JSON_ERROR_NONE) { + \think\Log::error("[WmsFunc] {$method} 响应 JSON 解析失败: {$response}"); + return [ + 'code' => -1, + 'msg' => '响应解析失败', + 'data' => null, + ]; + } + + \think\Log::info("[WmsFunc] {$method} 响应: " . json_encode($result, JSON_UNESCAPED_UNICODE)); + + return $result; + + } catch (\Exception $e) { + \think\Log::error("[WmsFunc] {$method} 请求异常: " . $e->getMessage()); + return [ + 'code' => -1, + 'msg' => '请求异常: ' . $e->getMessage(), + 'data' => null, + ]; + } + } + + // ==================== 工具方法 ==================== + + /** + * 生成随机 nonce + * @param int $length + * @return string + */ + protected function generateNonce($length = 16) + { + $chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'; + $nonce = ''; + for ($i = 0; $i < $length; $i++) { + $nonce .= $chars[random_int(0, strlen($chars) - 1)]; + } + return $nonce; + } +} diff --git a/application/index/library/new_wms/func/Inbox.php b/application/index/library/new_wms/func/Inbox.php new file mode 100644 index 0000000..b02daa9 --- /dev/null +++ b/application/index/library/new_wms/func/Inbox.php @@ -0,0 +1,83 @@ +push(['requestId' => 'REQ20240806001']); + * + * // 带完整参数 + * $result = $inbox->push([ + * 'requestId' => 'REQ20240806001', + * 'content' => '入库订单 SO001 已完成', + * 'groupId' => 'GRP001', + * 'groupName' => '仓储业务群', + * 'userId' => 'U001', + * 'userName' => '张三', + * 'parentId' => 0, + * 'sourceType' => 'api', + * 'targetType' => 'im', + * 'extData' => ['orderNo' => 'SO001'], + * 'flags' => new \stdClass(), + * ]); + */ +class Inbox extends Base +{ + /** + * {@inheritDoc} + */ + protected function moduleName() + { + return 'inbox'; + } + + // ==================== API 方法 ==================== + + /** + * inbox.push — 推送站内信 + * + * 外部系统将消息推入仓库站内信。 + * 注意:warehouse_id 由验签后上下文注入,禁止外部传入。 + * + * @param array $params 推送参数(共 11 个字段) + * - requestId string 必填 来源请求唯一 ID,与 appKey 组合为 ext_id(api:{appKey}:{requestId}),用于幂等去重 + * - content string 可选 消息正文/摘要 + * - groupId string 可选 外部群 ID,用于关联群及自动查询货主路由 + * - groupName string 可选 群名称(展示用) + * - userId string 可选 外部用户 ID + * - userName string 可选 用户名称(展示用) + * - parentId number 可选 关联消息 ID(回信时指向原消息,形成对话链) + * - sourceType string 可选 来源类型:im / api / system,默认 api + * - targetType string 可选 目标类型:im / api / webhook,默认 im + * - extData object 可选 外部透传数据,任意 JSON,WMS 不解析,回信时原样返回 + * - flags object 可选 处理标记(预留,当前未消费) + * @return array ['code' => int, 'msg' => string, 'data' => ['ok' => bool, 'id' => int, 'ext_id' => string]] + */ + public function push(array $params) + { + $body = array_merge([ + 'requestId' => '', + 'content' => '', + 'groupId' => '', + 'groupName' => '', + 'userId' => '', + 'userName' => '', + 'parentId' => 0, + 'sourceType' => 'api', + 'targetType' => 'im', + 'extData' => new \stdClass(), + 'flags' => new \stdClass(), + ], $params); + + return $this->call('push', $body); + } +} + + diff --git a/application/index/library/new_wms/func/Index.php b/application/index/library/new_wms/func/Index.php new file mode 100644 index 0000000..461d573 --- /dev/null +++ b/application/index/library/new_wms/func/Index.php @@ -0,0 +1,39 @@ +ping(); + * // $result = ['code' => 1, 'msg' => 'ok', 'data' => [...]] + */ +class Index extends Base +{ + /** + * {@inheritDoc} + */ + protected function moduleName() + { + return 'index'; + } + + // ==================== API 方法 ==================== + + /** + * index.ping — 心跳接口 + * + * 验证仓库 API 应用连通性,返回仓库上下文与应用信息。 + * 无入参,无鉴权,无登录要求。 + * + * @return array ['code' => int, 'msg' => string, 'data' => array] + */ + public function ping() + { + return $this->call('ping'); + } +} diff --git a/application/index/library/new_wms/func/Store.php b/application/index/library/new_wms/func/Store.php new file mode 100644 index 0000000..7849fe5 --- /dev/null +++ b/application/index/library/new_wms/func/Store.php @@ -0,0 +1,47 @@ +list(['page' => 1, 'pageSize' => 20]); + */ +class Store extends Base +{ + /** + * {@inheritDoc} + */ + protected function moduleName() + { + return 'store'; + } + + // ==================== API 方法 ==================== + + /** + * store.list — 查询已授权货主列表 + * + * 返回货主基本信息与授权状态(需 auth_status=2 已通过 + + * store.status=1 启用 + warehouse_use_status=1 可用)。 + * + * @param array $params 查询参数 + * - page int 页码(可选,默认 1) + * - pageSize int 每页条数(可选,默认 20) + * @return array ['code' => int, 'msg' => string, 'data' => array] + */ + public function list(array $params = []) + { + $body = array_merge([ + 'page' => 1, + 'pageSize' => 20, + ], $params); + + return $this->call('list', $body); + } +}