返回顶部
s

store-order-query门店订单查询

query store order information from database

作者: admin | 来源: ClawHub
源自
ClawHub
版本
V 1.0.0
安全检测
已通过
243
下载量
免费
免费
0
收藏
概述
安装方式
版本历史

store-order-query

店铺订单查询技能

技能描述

这是一个通过连接MySQL数据库查询店铺订单的技能。当用户询问店铺订单情况时(如查询今天店铺订单、今天的订单怎么样、店铺经营情况),使用此技能连接数据库查询订单数据,并生成分析报告。

使用场景

  • - 用户想查询特定时间段的订单数据
  • 用户想了解店铺经营状况
  • 用户想分析订单中的商品销售情况
  • 用户想查看支付方式分布

工作流程

步骤1. 检查配置文件

首先检查是否存在数据库配置文件 ~/openclaw-skill-data/store-order-query/config.json。

如果配置文件不存在,需要询问用户以下信息:

  • - MySQL数据库主机地址
  • 数据库端口(默认3306)
  • 数据库名称
  • 数据库用户名
  • 数据库密码

然后基于 config.example.json 创建 config.json 文件。

步骤2. 解析用户查询意图

从用户的查询中提取:

  • - 时间范围:今天、昨天、最近7天、最近30天等
  • 查询维度:订单量、金额、商品、支付方式等

如果用户说今天,则查询当天的订单数据。

步骤3. 执行查询脚本

调用以下命令查询订单数据,传递参数:

  • - --date-range:时间范围(today/yesterday/last7days/last30days 或 custom)
  • --start-date:开始日期(YYYY-MM-DD 格式,可选)
  • --end-date:结束日期(YYYY-MM-DD 格式,可选)

node dist/index.js --date-range today

脚本会:

  1. 1. 读取配置文件连接MySQL数据库
  2. 查询Order表获取订单数据
  3. 根据订单号查询OrderItems表获取商品信息
  4. 将数据保存到 ~/openclaw-skill-data/store-order-query/orders_data.json

步骤4. 分析数据并生成报告

调用以下命令分析订单数据并生成报告:

node dist/analyze-orders.js

脚本会:

  1. 1. 读取 ~/openclaw-skill-data/store-order-query/ordersdata.json
  2. 进行数据分析(订单量、总金额、支付方式分布、商品分析等)
  3. 生成 Markdown 格式的报告保存到 ~/openclaw-skill-data/store-order-query/orderreport.md

5. 呈现报告

读取生成的报告文件,向用户展示分析结果。

配置文件格式

~/openclaw-skill-data/store-order-query/config.json 示例:

json
{
database: {
type: mysql,
host: localhost,
port: 3306,
database: shop_db,
user: root,
password: your_password
},
tables: {
orders: Order,
order_items: OrderItems
},
fields: {
orders: {
id: orderSn,
created_at: createdAt,
total_amount: orderActualAmount,
payment_method: payType,
status: orderStatus
},
order_items: {
order_id: orderSn,
product_name: name,
sku: sku,
quantity: counts,
price: actualPrice
}
}
}

数据库表结构

Order 表(订单表)

字段类型说明
orderSnVARCHAR(50)订单号(主键)
createdAt
DATETIME | 创建时间 | | orderActualAmount | DECIMAL(10,2) | 订单实际金额 | | payType | VARCHAR(50) | 支付方式 | | orderStatus | VARCHAR(20) | 订单状态 |

OrderItems 表(订单商品表)

字段类型说明
idINT主键ID
orderSn
VARCHAR(50) | 订单号(外键) | | name | VARCHAR(200) | 商品名称 | | sku | VARCHAR(100) | SKU | | counts | INT | 数量 | | actualPrice | DECIMAL(10,2) | 实际价格 |

注意事项

  1. 1. 确保已在根目录安装依赖:pnpm install
  2. 配置文件包含敏感信息,不要将其提交到公共仓库
  3. 首次使用时需要配置数据库信息
  4. 确保MySQL数据库用户有读取Order和OrderItems表的权限
  5. 生成的报告会保存在 output 目录中,可以重复查看

错误处理

  • - 如果数据库连接失败,提示用户检查配置信息
  • 如果查询结果为空,提示用户该时间段没有订单数据
  • 如果表或字段不存在,提示用户检查配置文件中的字段映射

标签

skill ai

通过对话安装

该技能支持在以下平台通过对话安装:

OpenClaw WorkBuddy QClaw Kimi Claude

方式一:安装 SkillHub 和技能

帮我安装 SkillHub 和 store-order-query-1776053485 技能

方式二:设置 SkillHub 为优先技能安装源

设置 SkillHub 为我的优先技能安装源,然后帮我安装 store-order-query-1776053485 技能

通过命令行安装

skillhub install store-order-query-1776053485

下载

⬇ 下载 store-order-query v1.0.0(免费)

文件大小: 11.79 KB | 发布时间: 2026-4-14 14:29

v1.0.0 最新 2026-4-14 14:29
Initial release of store-order-query skill.

- Allows querying store order information from a MySQL database.
- Supports flexible queries by time range and analysis dimension (order count, revenue, items, payment methods).
- Includes setup workflow for database configuration.
- Generates analytical reports in Markdown format based on order data.
- Handles error cases for missing configuration, database errors, and empty results.

Archiver·手机版·闲社网·闲社论坛·羊毛社区· 多链控股集团有限公司 · 苏ICP备2025199260号-1

Powered by Discuz! X5.0   © 2024-2025 闲社网·线报更新论坛·羊毛分享社区·http://xianshe.com

p2p_official_large
返回顶部