paths:
  orderRecords:
    get:
      tags: [订单]
      summary: 查询订单记录列表
      description: |
        使用 PocketBase 原生 records list 接口查询 `tbl_order`。
        如需鉴权，请自行在请求头中携带 `Authorization: Bearer <token>`。
      parameters:
        - name: filter
          in: query
          required: false
          schema:
            type: string
          description: PocketBase 原生过滤表达式
          example: order_id="订单业务ID|string"
        - name: page
          in: query
          required: false
          schema:
            type: integer
            minimum: 1
            default: 1
        - name: perPage
          in: query
          required: false
          schema:
            type: integer
            minimum: 1
            default: 20
        - name: sort
          in: query
          required: false
          schema:
            type: string
          example: -order_create
      responses:
        '200':
          description: 查询成功
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PocketBaseOrderListResponse'
        '400':
          description: 查询参数错误
        '401':
          description: token 无效或已过期
        '403':
          description: 无权访问
        '500':
          description: 服务端错误
    post:
      tags: [订单]
      summary: 创建订单记录
      description: |
        使用 PocketBase 原生 records create 接口向 `tbl_order` 新增记录。
        如集合规则要求 `order_owner` 与当前用户一致，请客户端显式提交。
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PocketBaseOrderCreateRequest'
            example:
              order_id: 订单业务ID|string
              order_number: 订单编号|string
              order_owner: 订单所有者openid|string
              order_source: 订单来源|string
              order_status: 订单状态|string
              order_source_id: 来源关联业务ID|string
              order_snap:
                字段名|string: 字段值|string
              order_amount: 订单金额|number
              order_remark: 备注|string
      responses:
        '200':
          description: 创建成功
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PocketBaseOrderRecord'
        '400':
          description: 参数错误或违反集合规则
        '401':
          description: token 无效或已过期
        '403':
          description: 无权访问
        '500':
          description: 服务端错误
  orderRecordById:
    patch:
      tags: [订单]
      summary: 更新订单记录
      description: |
        使用 PocketBase 原生 records update 接口更新 `tbl_order`。
        路径参数使用 PocketBase 原生 `recordId`。
      parameters:
        - name: recordId
          in: path
          required: true
          schema:
            type: string
          example: PocketBase记录主键|string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PocketBaseOrderUpdateRequest'
            example:
              order_number: 订单编号|string
              order_owner: 订单所有者openid|string
              order_source: 订单来源|string
              order_status: 订单状态|string
              order_source_id: 来源关联业务ID|string
              order_snap:
                字段名|string: 字段值|string
              order_amount: 订单金额|number
              order_remark: 备注|string
      responses:
        '200':
          description: 更新成功
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PocketBaseOrderRecord'
        '400':
          description: 参数错误
        '401':
          description: token 无效或已过期
        '404':
          description: 记录不存在
        '500':
          description: 服务端错误
    delete:
      tags: [订单]
      summary: 删除订单记录
      description: |
        使用 PocketBase 原生 records delete 接口删除 `tbl_order`。
        路径参数使用 PocketBase 原生 `recordId`。
      parameters:
        - name: recordId
          in: path
          required: true
          schema:
            type: string
          example: PocketBase记录主键|string
      responses:
        '204':
          description: 删除成功
        '401':
          description: token 无效或已过期
        '404':
          description: 记录不存在
        '500':
          description: 服务端错误
        "400":
          description: 参数错误
          components:
            schemas:
        创建规则：
        - 服务端自动根据当前 token 写入 `order_owner`
        - 服务端自动生成 `order_id`
        - 若未传 `order_number`，服务端会自动生成展示编号
        - `order_source`、`order_source_id`、`order_snap`、`order_amount` 为必填

        目标软删除契约：
                    description: PocketBase错误码
        - 当前仓库导出响应中尚未显式返回 `is_delete` 字段
      security:
                    description: PocketBase错误信息
                    example: PocketBase原生错误信息 | string
      requestBody:
                    description: PocketBase错误数据
        content:
          application/json:
            schema:
              $ref: ../openapi-wx.yaml#/components/schemas/OrderCreateRequest
            example:
              order_number: 可选；未传时服务端自动生成|string
              order_source: 订单来源|string
              order_status: 可选；未传时默认 订单已生成|string
              order_source_id: 来源关联业务 ID|string
              order_snap:
                order_snap字段|string: order_snap值|string
              order_amount: 订单金额|integer
              order_remark: 备注|string
      responses:
        "200":
          description: 创建成功
          content:
            application/json:
              schema:
                $ref: ../openapi-wx.yaml#/components/schemas/OrderRecord
              example:
                pb_id: PocketBase 记录主键 id|string
                created: PocketBase 系统创建时间|string
                updated: PocketBase 系统更新时间|string
                order_id: 订单业务 ID|string
                order_number: 订单编号|string
                order_create: 订单创建时间，由数据库自动生成|string
                order_owner: 订单所有者 openid|string
                order_source: 订单来源|string
                order_status: 订单状态|string
                order_source_id: 来源关联业务 ID|string
                order_snap:
                  order_snap字段|string: order_snap值|string
                order_amount: 订单金额|integer
                order_remark: 备注|string
                is_delete: 软删除标记；目标契约字段，当前 hooks 响应可能尚未显式透出|integer
        "400":
          description: 参数错误或创建失败
          content:
            application/json:
              schema:
                $ref: ../openapi-wx.yaml#/components/schemas/ErrorResponse
              example:
                statusCode: 业务状态码|integer
                errMsg: 业务提示信息|string
                data:
                  业务响应数据字段|string: 业务响应数据值|string
        "401":
          description: token 缺失、无效或已过期
          content:
            application/json:
              schema:
                $ref: ../openapi-wx.yaml#/components/schemas/ErrorResponse
              example:
                statusCode: 业务状态码|integer
                errMsg: 业务提示信息|string
                data:
                  业务响应数据字段|string: 业务响应数据值|string
        "415":
          description: 请求体必须为 application/json
          content:
            application/json:
              schema:
                $ref: ../openapi-wx.yaml#/components/schemas/ErrorResponse
              example:
                statusCode: 业务状态码|integer
                errMsg: 业务提示信息|string
                data:
                  业务响应数据字段|string: 业务响应数据值|string
        "429":
          description: 重复请求过于频繁
          content:
            application/json:
              schema:
                $ref: ../openapi-wx.yaml#/components/schemas/ErrorResponse
              example:
                statusCode: 业务状态码|integer
                errMsg: 业务提示信息|string
                data:
                  业务响应数据字段|string: 业务响应数据值|string
        "500":
          description: 服务端错误
          content:
            application/json:
              schema:
                $ref: ../openapi-wx.yaml#/components/schemas/ErrorResponse
              example:
                statusCode: 业务状态码|integer
                errMsg: 业务提示信息|string
                data:
                  业务响应数据字段|string: 业务响应数据值|string
  orderUpdate:
    post:
      operationId: postOrderUpdate
      tags:
        - 订单
      summary: 修改订单记录
      description: |
        调用自定义 hooks API 按 `order_id` 更新订单记录。

        更新规则：
        - 仅允许修改当前 `Authorization` 对应用户自己的订单记录
        - `order_id` 为必填，用于精确定位目标记录
        - 其余字段均为可选增量更新
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: ../openapi-wx.yaml#/components/schemas/OrderUpdateRequest
            example:
              order_id: 订单业务 ID|string
              order_number: order_number|string
              order_source: order_source|string
              order_status: order_status|string
              order_source_id: order_source_id|string
              order_snap:
                order_snap字段|string: order_snap值|string
              order_amount: order_amount|integer
              order_remark: order_remark|string
      responses:
        "200":
          description: 更新成功
          content:
            application/json:
              schema:
                $ref: ../openapi-wx.yaml#/components/schemas/OrderRecord
              example:
                pb_id: PocketBase 记录主键 id|string
                created: PocketBase 系统创建时间|string
                updated: PocketBase 系统更新时间|string
                order_id: 订单业务 ID|string
                order_number: 订单编号|string
                order_create: 订单创建时间，由数据库自动生成|string
                order_owner: 订单所有者 openid|string
                order_source: 订单来源|string
                order_status: 订单状态|string
                order_source_id: 来源关联业务 ID|string
                order_snap:
                  order_snap字段|string: order_snap值|string
                order_amount: 订单金额|integer
                order_remark: 备注|string
                is_delete: 软删除标记；目标契约字段，当前 hooks 响应可能尚未显式透出|integer
        "400":
          description: 参数错误或更新失败
          content:
            application/json:
              schema:
                $ref: ../openapi-wx.yaml#/components/schemas/ErrorResponse
              example:
                statusCode: 业务状态码|integer
                errMsg: 业务提示信息|string
                data:
                  业务响应数据字段|string: 业务响应数据值|string
        "401":
          description: token 缺失、无效或已过期
          content:
            application/json:
              schema:
                $ref: ../openapi-wx.yaml#/components/schemas/ErrorResponse
              example:
                statusCode: 业务状态码|integer
                errMsg: 业务提示信息|string
                data:
                  业务响应数据字段|string: 业务响应数据值|string
        "403":
          description: 无权访问该订单记录
          content:
            application/json:
              schema:
                $ref: ../openapi-wx.yaml#/components/schemas/ErrorResponse
              example:
                statusCode: 业务状态码|integer
                errMsg: 业务提示信息|string
                data:
                  业务响应数据字段|string: 业务响应数据值|string
        "404":
          description: 未找到待修改的订单记录
          content:
            application/json:
              schema:
                $ref: ../openapi-wx.yaml#/components/schemas/ErrorResponse
              example:
                statusCode: 业务状态码|integer
                errMsg: 业务提示信息|string
                data:
                  业务响应数据字段|string: 业务响应数据值|string
        "415":
          description: 请求体必须为 application/json
          content:
            application/json:
              schema:
                $ref: ../openapi-wx.yaml#/components/schemas/ErrorResponse
              example:
                statusCode: 业务状态码|integer
                errMsg: 业务提示信息|string
                data:
                  业务响应数据字段|string: 业务响应数据值|string
        "429":
          description: 重复请求过于频繁
          content:
            application/json:
              schema:
                $ref: ../openapi-wx.yaml#/components/schemas/ErrorResponse
              example:
                statusCode: 业务状态码|integer
                errMsg: 业务提示信息|string
                data:
                  业务响应数据字段|string: 业务响应数据值|string
        "500":
          description: 服务端错误
          content:
            application/json:
              schema:
                $ref: ../openapi-wx.yaml#/components/schemas/ErrorResponse
              example:
                statusCode: 业务状态码|integer
                errMsg: 业务提示信息|string
                data:
                  业务响应数据字段|string: 业务响应数据值|string
  orderDelete:
    post:
      operationId: postOrderDelete
      tags:
        - 订单
      summary: 软删除订单记录
      description: |
        目标契约：按 `order_id` 软删除订单记录，将 `is_delete` 标记为 `1`，而不是物理删除。

        当前仓库实现差异：
        - 当前 `cartOrderService.deleteOrder()` 仍直接调用 `$app.delete(record)` 做物理删除
        - 因此当前后端实现与本软删除契约不一致
        - 若要严格按本文档执行，需先同步调整后端服务实现，并在列表/详情接口中补充 `is_delete = 0` 过滤
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: ../openapi-wx.yaml#/components/schemas/OrderDeleteRequest
            example:
              order_id: 订单业务 ID|string
      responses:
        "200":
          description: 删除成功
          content:
            application/json:
              schema:
                $ref: ../openapi-wx.yaml#/components/schemas/OrderDeleteResponse
              example:
                order_id: 订单业务 ID|string
                is_delete: 目标软删除标记值；当前实现可能仍返回物理删除结果|integer
        "400":
          description: 参数错误或删除失败
          content:
            application/json:
              schema:
                $ref: ../openapi-wx.yaml#/components/schemas/ErrorResponse
              example:
                statusCode: 业务状态码|integer
                errMsg: 业务提示信息|string
                data:
                  业务响应数据字段|string: 业务响应数据值|string
        "401":
          description: token 缺失、无效或已过期
          content:
            application/json:
              schema:
                $ref: ../openapi-wx.yaml#/components/schemas/ErrorResponse
              example:
                statusCode: 业务状态码|integer
                errMsg: 业务提示信息|string
                data:
                  业务响应数据字段|string: 业务响应数据值|string
        "403":
          description: 无权访问该订单记录
          content:
            application/json:
              schema:
                $ref: ../openapi-wx.yaml#/components/schemas/ErrorResponse
              example:
                statusCode: 业务状态码|integer
                errMsg: 业务提示信息|string
                data:
                  业务响应数据字段|string: 业务响应数据值|string
        "404":
          description: 未找到待删除的订单记录
          content:
            application/json:
              schema:
                $ref: ../openapi-wx.yaml#/components/schemas/ErrorResponse
              example:
                statusCode: 业务状态码|integer
                errMsg: 业务提示信息|string
                data:
                  业务响应数据字段|string: 业务响应数据值|string
        "415":
          description: 请求体必须为 application/json
          content:
            application/json:
              schema:
                $ref: ../openapi-wx.yaml#/components/schemas/ErrorResponse
              example:
                statusCode: 业务状态码|integer
                errMsg: 业务提示信息|string
                data:
                  业务响应数据字段|string: 业务响应数据值|string
        "429":
          description: 重复请求过于频繁
          content:
            application/json:
              schema:
                $ref: ../openapi-wx.yaml#/components/schemas/ErrorResponse
              example:
                statusCode: 业务状态码|integer
                errMsg: 业务提示信息|string
                data:
                  业务响应数据字段|string: 业务响应数据值|string
        "500":
          description: 服务端错误
          content:
            application/json:
              schema:
                $ref: ../openapi-wx.yaml#/components/schemas/ErrorResponse
              example:
                statusCode: 业务状态码|integer
                errMsg: 业务提示信息|string
                data:
                  业务响应数据字段|string: 业务响应数据值|string
  orderRecords:
    get:
      operationId: getPocketBaseOrderRecords
      tags:
        - 订单
      summary: 查询当前用户订单列表或按业务 ID 精确查询
      description: |
        使用 PocketBase 原生 records list 接口查询 `tbl_order`。

        当前线上权限规则：
        - `listRule = @request.auth.id != "" && order_owner = @request.auth.openid && is_delete = 0`
        - 因此调用方只能读到 `order_owner` 等于自己 `openid` 且未软删除的记录

        标准调用方式：
        1. 查询当前登录用户全部订单：
           - 不传 `filter`
           - 可选传 `sort=-order_create`
        2. 按业务 ID 精确查单条：
           - `filter=order_id="ORDER-..."`
           - `perPage=1`
           - `page=1`
      security:
        - BearerAuth: []
      parameters:
        - name: filter
          in: query
          required: false
          schema:
            type: string
          example: order_id="ORDER-1770000000000-abc123"
        - name: page
          in: query
          required: false
          schema:
            type: integer
            minimum: 1
            default: 1
        - name: perPage
          in: query
          required: false
          schema:
            type: integer
            minimum: 1
            default: 20
        - name: sort
          in: query
          required: false
          description: PocketBase 原生排序表达式，推荐 `-order_create`
          schema:
            type: string
          example: -order_create
      responses:
        "200":
          description: 查询成功
          content:
            application/json:
              schema:
                $ref: ../openapi-wx.yaml#/components/schemas/PocketBaseOrderListResponse
              example:
                page: page|integer
                perPage: perPage|integer
                totalItems: totalItems|integer
                totalPages: totalPages|integer
                items:
                  - id: PocketBase 记录主键|string
                    collectionId: collectionId|string
                    collectionName: collectionName|string
                    created: 记录创建时间|string
                    updated: 记录更新时间|string
                    order_id: 订单业务 ID|string
                    order_number: 订单编号|string
                    order_create: 订单创建时间，由数据库自动生成|string
                    order_owner: 订单所有者 openid|string
                    order_source: 订单来源|string
                    order_status: 订单状态|string
                    order_source_id: 来源关联业务 ID|string
                    order_snap:
                      order_snap字段|string: order_snap值|string
                    order_amount: 订单金额|number
                    order_remark: 备注|string
        "400":
          description: 查询参数错误或不满足 listRule
          content:
            application/json:
              schema:
                $ref: ../openapi-wx.yaml#/components/schemas/PocketBaseNativeError
              example:
                code: 业务状态码|integer
                message: message|string
                data:
                  业务响应数据字段|string: 业务响应数据值|string
        "401":
          description: token 缺失、无效或已过期
          content:
            application/json:
              schema:
                $ref: ../openapi-wx.yaml#/components/schemas/PocketBaseNativeError
              example:
                code: 业务状态码|integer
                message: message|string
                data:
                  业务响应数据字段|string: 业务响应数据值|string
        "403":
          description: 集合规则被锁定或服务端权限设置异常
          content:
            application/json:
              schema:
                $ref: ../openapi-wx.yaml#/components/schemas/PocketBaseNativeError
              example:
                code: 业务状态码|integer
                message: message|string
                data:
                  业务响应数据字段|string: 业务响应数据值|string
        "500":
          description: 服务端错误
          content:
            application/json:
              schema:
                $ref: ../openapi-wx.yaml#/components/schemas/PocketBaseNativeError
              example:
                code: 业务状态码|integer
                message: message|string
                data:
                  业务响应数据字段|string: 业务响应数据值|string
    post:
      operationId: postPocketBaseOrderRecord
      tags:
        - 订单
      summary: 创建订单记录
      description: |
        使用 PocketBase 原生 records create 接口向 `tbl_order` 新增记录。

        当前线上权限规则：
        - `createRule = @request.auth.id != "" && @request.body.order_owner = @request.auth.openid`
        - 因此客户端创建时必须显式提交 `order_owner`，并且值必须等于当前 token 对应的 `openid`

        这意味着：
        - 不能依赖服务端自动补 owner
        - 不能省略 `order_owner`
        - 不满足规则时 PocketBase 会直接返回 `400`
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: ../openapi-wx.yaml#/components/schemas/PocketBaseOrderCreateRequest
            example:
              order_id: order_id|string
              order_number: order_number|string
              order_owner: 必须显式提交，且值必须等于当前 token 对应 openid|string
              order_source: order_source|string
              order_status: order_status|string
              order_source_id: order_source_id|string
              order_snap:
                order_snap字段|string: order_snap值|string
              order_amount: order_amount|number
              order_remark: order_remark|string
      responses:
        "200":
          description: 创建成功
          content:
            application/json:
              schema:
                $ref: ../openapi-wx.yaml#/components/schemas/PocketBaseOrderRecord
              example:
                id: PocketBase 记录主键|string
                collectionId: collectionId|string
                collectionName: collectionName|string
                created: 记录创建时间|string
                updated: 记录更新时间|string
                order_id: 订单业务 ID|string
                order_number: 订单编号|string
                order_create: 订单创建时间，由数据库自动生成|string
                order_owner: 订单所有者 openid|string
                order_source: 订单来源|string
                order_status: 订单状态|string
                order_source_id: 来源关联业务 ID|string
                order_snap:
                  order_snap字段|string: order_snap值|string
                order_amount: 订单金额|number
                order_remark: 备注|string
        "400":
          description: 参数错误、违反字段约束或不满足 createRule
          content:
            application/json:
              schema:
                $ref: ../openapi-wx.yaml#/components/schemas/PocketBaseNativeError
              example:
                code: 业务状态码|integer
                message: message|string
                data:
                  业务响应数据字段|string: 业务响应数据值|string
        "401":
          description: token 缺失、无效或已过期
          content:
            application/json:
              schema:
                $ref: ../openapi-wx.yaml#/components/schemas/PocketBaseNativeError
              example:
                code: 业务状态码|integer
                message: message|string
                data:
                  业务响应数据字段|string: 业务响应数据值|string
        "403":
          description: 集合规则被锁定或服务端权限设置异常
          content:
            application/json:
              schema:
                $ref: ../openapi-wx.yaml#/components/schemas/PocketBaseNativeError
              example:
                code: 业务状态码|integer
                message: message|string
                data:
                  业务响应数据字段|string: 业务响应数据值|string
        "500":
          description: 服务端错误
          content:
            application/json:
              schema:
                $ref: ../openapi-wx.yaml#/components/schemas/PocketBaseNativeError
              example:
                code: 业务状态码|integer
                message: message|string
                data:
                  业务响应数据字段|string: 业务响应数据值|string
  orderRecordById:
    patch:
      operationId: patchPocketBaseOrderRecordByRecordId
      tags:
        - 订单
      summary: 更新订单记录
      description: |
        使用 PocketBase 原生 records update 接口更新 `tbl_order`。

        标准调用流程：
        1. 先通过 `GET /pb/api/collections/tbl_order/records?filter=order_id="..."&perPage=1&page=1` 找到原生 `recordId`
        2. 再调用当前 `PATCH /pb/api/collections/tbl_order/records/{recordId}`

        当前线上权限规则：
        - `updateRule = @request.auth.id != "" && order_owner = @request.auth.openid`
        - 调用方只能修改自己的订单记录
      security:
        - BearerAuth: []
      parameters:
        - name: recordId
          in: path
          required: true
          schema:
            type: string
          example: l2r3nq7rqhuob0h
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: ../openapi-wx.yaml#/components/schemas/PocketBaseOrderUpdateRequest
            example:
              order_number: order_number|string
              order_owner: 若提交，必须仍等于当前 token 对应 openid|string
              order_source: order_source|string
              order_status: order_status|string
              order_source_id: order_source_id|string
              order_snap:
                order_snap字段|string: order_snap值|string
              order_amount: order_amount|number
              order_remark: order_remark|string
      responses:
        "200":
          description: 更新成功
          content:
            application/json:
              schema:
                $ref: ../openapi-wx.yaml#/components/schemas/PocketBaseOrderRecord
              example:
                id: PocketBase 记录主键|string
                collectionId: collectionId|string
                collectionName: collectionName|string
                created: 记录创建时间|string
                updated: 记录更新时间|string
                order_id: 订单业务 ID|string
                order_number: 订单编号|string
                order_create: 订单创建时间，由数据库自动生成|string
                order_owner: 订单所有者 openid|string
                order_source: 订单来源|string
                order_status: 订单状态|string
                order_source_id: 来源关联业务 ID|string
                order_snap:
                  order_snap字段|string: order_snap值|string
                order_amount: 订单金额|number
                order_remark: 备注|string
        "400":
          description: 参数错误或违反字段约束
          content:
            application/json:
              schema:
                $ref: ../openapi-wx.yaml#/components/schemas/PocketBaseNativeError
              example:
                code: 业务状态码|integer
                message: message|string
                data:
                  业务响应数据字段|string: 业务响应数据值|string
        "401":
          description: token 缺失、无效或已过期
          content:
            application/json:
              schema:
                $ref: ../openapi-wx.yaml#/components/schemas/PocketBaseNativeError
              example:
                code: 业务状态码|integer
                message: message|string
                data:
                  业务响应数据字段|string: 业务响应数据值|string
        "404":
          description: 记录不存在或不满足 updateRule
          content:
            application/json:
              schema:
                $ref: ../openapi-wx.yaml#/components/schemas/PocketBaseNativeError
              example:
                code: 业务状态码|integer
                message: message|string
                data:
                  业务响应数据字段|string: 业务响应数据值|string
        "500":
          description: 服务端错误
          content:
            application/json:
              schema:
                $ref: ../openapi-wx.yaml#/components/schemas/PocketBaseNativeError
              example:
                code: 业务状态码|integer
                message: message|string
                data:
                  业务响应数据字段|string: 业务响应数据值|string
    delete:
      operationId: deletePocketBaseOrderRecordByRecordId
      tags:
        - 订单
      summary: 删除订单记录
      description: |
        使用 PocketBase 原生 records delete 接口删除 `tbl_order`。

        当前线上权限规则：
        - `deleteRule = @request.auth.id != "" && order_owner = @request.auth.openid`
        - 调用方只能删除自己的订单记录
      security:
        - BearerAuth: []
      parameters:
        - name: recordId
          in: path
          required: true
          schema:
            type: string
          example: l2r3nq7rqhuob0h
      responses:
        "204":
          description: 删除成功
        "401":
          description: token 缺失、无效或已过期
          content:
            application/json:
              schema:
                $ref: ../openapi-wx.yaml#/components/schemas/PocketBaseNativeError
              example:
                code: 业务状态码|integer
                message: message|string
                data:
                  业务响应数据字段|string: 业务响应数据值|string
        "404":
          description: 记录不存在或不满足 deleteRule
          content:
            application/json:
              schema:
                $ref: ../openapi-wx.yaml#/components/schemas/PocketBaseNativeError
              example:
                code: 业务状态码|integer
                message: message|string
                data:
                  业务响应数据字段|string: 业务响应数据值|string
        "500":
          description: 服务端错误
          content:
            application/json:
              schema:
                $ref: ../openapi-wx.yaml#/components/schemas/PocketBaseNativeError
              example:
                code: 业务状态码|integer
                message: message|string
                data:
                  业务响应数据字段|string: 业务响应数据值|string
components:
  schemas:
    ApiResponseBase:
      type: object
      required:
        - statusCode
        - errMsg
        - data
      properties:
        statusCode:
          type:
            - integer
            - string
          description: 业务状态码
          example: 业务状态码 | integer
        errMsg:
          type: string
          description: 业务提示信息
          example: 业务提示信息 | string
        data:
          description: 业务响应数据
          type: object
          additionalProperties: true
      example:
        statusCode: 业务状态码|integer
        errMsg: 业务提示信息|string
        data:
          业务响应数据字段|string: 业务响应数据值|string
    ErrorResponse:
      type: object
      required:
        - statusCode
        - errMsg
        - data
      properties:
        statusCode:
          type:
            - integer
            - string
          description: 业务状态码
          example: 业务状态码 | integer
        errMsg:
          type: string
          description: 业务提示信息
          example: 失败原因提示 | string
        data:
          description: 业务响应数据
          type: object
          additionalProperties: true
      example:
        statusCode: 业务状态码|integer
        errMsg: 业务提示信息|string
        data:
          业务响应数据字段|string: 业务响应数据值|string
    HookRecordBase:
      type: object
      properties:
        pb_id:
          type: string
          description: PocketBase 记录主键 id
          example: l2r3nq7rqhuob0h
        created:
          type: string
          description: PocketBase 系统创建时间
          example: 2026-04-03 15:30:00.000Z
        updated:
          type: string
          description: PocketBase 系统更新时间
          example: 2026-04-03 15:35:00.000Z
      example:
        pb_id: PocketBase 记录主键 id|string
        created: PocketBase 系统创建时间|string
        updated: PocketBase 系统更新时间|string
    PocketBaseNativeError:
      type: object
      properties:
        code:
          type:
            - integer
            - string
          description: 业务状态码
          example: 错误状态码 | integer
        message:
          type: string
          example: PocketBase原生错误信息 | string
        data:
          description: 业务响应数据
          type: object
          additionalProperties: true
      example:
        code: 业务状态码|integer
        message: message|string
        data:
          业务响应数据字段|string: 业务响应数据值|string
    PocketBaseRecordBase:
      type: object
      required:
        - id
        - collectionId
        - collectionName
        - created
        - updated
      properties:
        id:
          type: string
          description: PocketBase 记录主键
          example: PocketBase记录主键 | string
        collectionId:
          type: string
          example: 集合ID | string
        collectionName:
          type: string
          example: 集合名称 | string
        created:
          type: string
          description: 记录创建时间
          example: 记录创建时间 | string
        updated:
          type: string
          description: 记录更新时间
          example: 记录更新时间 | string
      example:
        id: PocketBase 记录主键|string
        collectionId: collectionId|string
        collectionName: collectionName|string
        created: 记录创建时间|string
        updated: 记录更新时间|string
    PocketBaseOrderFields:
      type: object
      properties:
        order_id:
          type: string
          description: 订单业务 ID
          example: ORDER-1770000000000-abc123
        order_number:
          type: string
          description: 订单编号
          example: wx-user-20260403153500
        order_create:
          type: string
          description: 订单创建时间，由数据库自动生成
          example: 2026-04-03 15:35:00.000Z
        order_owner:
          type: string
          description: 订单所有者 openid
          example: wx-openid-user-001
        order_source:
          type: string
          description: 订单来源
          example: 购物车
        order_status:
          type: string
          description: 订单状态
          example: 订单已生成
        order_source_id:
          type: string
          description: 来源关联业务 ID
          example: CART-1770000000000-abc123
        order_snap:
          description: 订单快照 JSON
          oneOf:
            - type: object
              additionalProperties: true
            - type: array
              items:
                type: object
                additionalProperties: true
        order_amount:
          type:
            - number
            - integer
          description: 订单金额
          example: 3998
        order_remark:
          type: string
          description: 备注
          example: 小程序订单示例
      example:
        order_id: 订单业务 ID|string
        order_number: 订单编号|string
        order_create: 订单创建时间，由数据库自动生成|string
        order_owner: 订单所有者 openid|string
        order_source: 订单来源|string
        order_status: 订单状态|string
        order_source_id: 来源关联业务 ID|string
        order_snap:
          order_snap字段|string: order_snap值|string
        order_amount: 订单金额|number
        order_remark: 备注|string
    PocketBaseOrderRecord:
      allOf:
        - $ref: ../openapi-wx.yaml#/components/schemas/PocketBaseRecordBase
        - $ref: ../openapi-wx.yaml#/components/schemas/PocketBaseOrderFields
      example:
        id: PocketBase 记录主键|string
        collectionId: collectionId|string
        collectionName: collectionName|string
        created: 记录创建时间|string
        updated: 记录更新时间|string
        order_id: 订单业务 ID|string
        order_number: 订单编号|string
        order_create: 订单创建时间，由数据库自动生成|string
        order_owner: 订单所有者 openid|string
        order_source: 订单来源|string
        order_status: 订单状态|string
        order_source_id: 来源关联业务 ID|string
        order_snap:
          order_snap字段|string: order_snap值|string
        order_amount: 订单金额|number
        order_remark: 备注|string
    PocketBaseOrderCreateRequest:
      type: object
      required:
        - order_id
        - order_number
        - order_owner
        - order_source
        - order_status
        - order_source_id
        - order_snap
        - order_amount
      properties:
        order_id:
          type: string
        order_number:
          type: string
        order_owner:
          type: string
          description: 必须显式提交，且值必须等于当前 token 对应 openid
        order_source:
          type: string
        order_status:
          type: string
        order_source_id:
          type: string
        order_snap:
          oneOf:
            - type: object
              additionalProperties: true
            - type: array
              items:
                type: object
                additionalProperties: true
        order_amount:
          type:
            - number
            - integer
        order_remark:
          type: string
      example:
        order_id: order_id|string
        order_number: order_number|string
        order_owner: 必须显式提交，且值必须等于当前 token 对应 openid|string
        order_source: order_source|string
        order_status: order_status|string
        order_source_id: order_source_id|string
        order_snap:
          order_snap字段|string: order_snap值|string
        order_amount: order_amount|number
        order_remark: order_remark|string
    PocketBaseOrderUpdateRequest:
      type: object
      properties:
        order_number:
          type: string
        order_owner:
          type: string
          description: 若提交，必须仍等于当前 token 对应 openid
        order_source:
          type: string
        order_status:
          type: string
        order_source_id:
          type: string
        order_snap:
          oneOf:
            - type: object
              additionalProperties: true
            - type: array
              items:
                type: object
                additionalProperties: true
        order_amount:
          type:
            - number
            - integer
        order_remark:
          type: string
      example:
        order_number: order_number|string
        order_owner: 若提交，必须仍等于当前 token 对应 openid|string
        order_source: order_source|string
        order_status: order_status|string
        order_source_id: order_source_id|string
        order_snap:
          order_snap字段|string: order_snap值|string
        order_amount: order_amount|number
        order_remark: order_remark|string
    PocketBaseOrderListResponse:
      type: object
      required:
        - page
        - perPage
        - totalItems
        - totalPages
        - items
      properties:
        page:
          type:
            - integer
            - string
        perPage:
          type:
            - integer
            - string
        totalItems:
          type:
            - integer
            - string
        totalPages:
          type:
            - integer
            - string
        items:
          type: array
          items:
            $ref: ../openapi-wx.yaml#/components/schemas/PocketBaseOrderRecord
      example:
        page: page|integer
        perPage: perPage|integer
        totalItems: totalItems|integer
        totalPages: totalPages|integer
        items:
          - id: PocketBase 记录主键|string
            collectionId: collectionId|string
            collectionName: collectionName|string
            created: 记录创建时间|string
            updated: 记录更新时间|string
            order_id: 订单业务 ID|string
            order_number: 订单编号|string
            order_create: 订单创建时间，由数据库自动生成|string
            order_owner: 订单所有者 openid|string
            order_source: 订单来源|string
            order_status: 订单状态|string
            order_source_id: 来源关联业务 ID|string
            order_snap:
              order_snap字段|string: order_snap值|string
            order_amount: 订单金额|number
            order_remark: 备注|string
