CRMEB/backend/modules/service/mcp/tools/ExpressListTool.php
sugar1569 3b5bd37bfb feat(mcp): 为内置工具添加分类方法并优化订单列表搜索逻辑
为所有 MCP 内置工具实现 category() 分类方法,支持管理后台按业务分组展示;优化订单列表关键词搜索逻辑,使用闭包显式 OR 条件匹配订单号和商品标题,避免管道字段静默丢弃问题;新增优惠券库存调整原子方法,提升并发安全性;同步更新相关文档和注释,完善分类展示规则说明。
2026-09-24 11:57:27 +08:00

103 lines
2.4 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
declare(strict_types=1);
namespace modules\service\mcp\tools;
use app\dao\shipping\ExpressDao;
use crmeb\interfaces\McpToolInterface;
/**
* MCP 工具:物流公司列表
*
* 返回所有启用的快递公司信息。
*/
class ExpressListTool implements McpToolInterface
{
/**
* 物流公司 DAO
* @var ExpressDao
*/
private ExpressDao $dao;
/**
* 构造函数
* @param ExpressDao $dao 物流公司 DAO
*/
public function __construct(ExpressDao $dao)
{
$this->dao = $dao;
}
/**
* 工具名称
* @return string
*/
public function name(): string
{
return 'crmeb_order_express_list';
}
/**
* 工具描述
* @return string
*/
public function description(): string
{
return '获取物流公司列表';
}
/**
* 工具中文名(管理后台展示)
* @return string
*/
public function label(): string
{
return '物流公司列表';
}
/**
* 工具分类(管理后台分组展示)
* @return string
*/
public function category(): string
{
return '订单';
}
/**
* 入参 Schema
* @return array
*/
public function inputSchema(): array
{
return [
'type' => 'object',
'properties' => new \stdClass(),
];
}
/**
* 执行工具
*
* @param array $args 参数(无)
* @return array 物流公司列表
*/
public function execute(array $args): array
{
$list = $this->dao->search([['is_show', '=', 1]])
->field('id,name,code')
->select()
->toArray();
return ['list' => $list];
}
}