{
  "openapi": "3.0.3",
  "info": {
    "title": "智慧营养健康餐厅 - 订餐核销增量接口",
    "version": "2026-06-15"
  },
  "servers": [
    {
      "url": "http://zhctdev.local"
    }
  ],
  "paths": {
    "/api/consume/bookingVerify": {
      "post": {
        "summary": "订餐核销",
        "description": "本人订餐支持人脸核销，设备只需传 equipment_code + staff_uuid；亲友餐/招待餐支持二维码核销，设备传 equipment_code + qr_token 或 verification_code。服务端会校验当日订餐、当前餐段、退款状态和错峰就餐开始时间。人脸核销没有当日当餐可核销本人订餐时，会按普通消费策略 application_scene=0 生成现场消费订单并扣个人账户。",
        "tags": [
          "消费机/订餐核销"
        ],
        "x-apifox-folder": "消费机/订餐核销",
        "x-apifox-folder-id": "5737553",
        "parameters": [
          {
            "name": "account",
            "in": "header",
            "description": "接口认证账号，来自设备/终端接口认证配置。",
            "required": true,
            "schema": {
              "type": "string"
            },
            "example": "diningdevadmin2025"
          },
          {
            "name": "pwd",
            "in": "header",
            "description": "接口认证密码，来自设备/终端接口认证配置。",
            "required": true,
            "schema": {
              "type": "string"
            },
            "example": "******"
          },
          {
            "name": "key",
            "in": "header",
            "description": "接口认证 key，来自设备/终端接口认证配置。",
            "required": true,
            "schema": {
              "type": "string"
            },
            "example": "******"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/x-www-form-urlencoded": {
              "schema": {
                "type": "object",
                "properties": {
                  "equipment_code": {
                    "type": "string",
                    "description": "设备编号，必填。",
                    "example": "0000009"
                  },
                  "staff_uuid": {
                    "type": "string",
                    "description": "人脸核销人员 UUID；人脸核销必填。",
                    "example": "4FD528A5-3922-D0CB-6365-27110F01C8CE"
                  },
                  "qr_token": {
                    "type": "string",
                    "description": "二维码核销 token；二维码核销必填。",
                    "example": "109385311D8107E3E66DA671B0DC6A0E"
                  },
                  "verification_code": {
                    "type": "string",
                    "description": "qr_token 的兼容别名；qr_token 为空时使用。",
                    "example": "109385311D8107E3E66DA671B0DC6A0E"
                  },
                  "meal_date": {
                    "type": "string",
                    "description": "历史兼容参数；当前人脸核销不依赖设备传入。",
                    "example": "2026-06-15"
                  },
                  "meal_times": {
                    "type": "integer",
                    "description": "历史兼容参数；当前人脸核销不依赖设备传入。1=早餐，2=午餐，3=晚餐，4=夜宵。",
                    "example": 2
                  },
                  "msgid": {
                    "type": "string",
                    "description": "设备消息 ID，当前不参与订单匹配。",
                    "example": "MSG-202606150001"
                  }
                },
                "required": [
                  "equipment_code"
                ],
                "anyOf": [
                  {
                    "required": [
                      "staff_uuid"
                    ]
                  },
                  {
                    "required": [
                      "qr_token"
                    ]
                  },
                  {
                    "required": [
                      "verification_code"
                    ]
                  }
                ]
              },
              "examples": {
                "faceVerify": {
                  "summary": "人脸核销",
                  "value": {
                    "equipment_code": "0000009",
                    "staff_uuid": "4FD528A5-3922-D0CB-6365-27110F01C8CE"
                  }
                },
                "qrVerify": {
                  "summary": "二维码核销",
                  "value": {
                    "equipment_code": "0000009",
                    "qr_token": "109385311D8107E3E66DA671B0DC6A0E"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "接口返回 code=0 表示核销成功，code=1 表示失败。",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "code": {
                      "type": "integer",
                      "example": 0
                    },
                    "message": {
                      "type": "string",
                      "example": "核销成功"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "order_id": {
                          "type": "integer",
                          "example": 123
                        },
                        "order_no": {
                          "type": "string",
                          "example": "260615184398126"
                        },
                        "booking_type": {
                          "type": "integer",
                          "description": "订餐类型：0=非订餐现场消费，1=本人订餐，2=亲友餐，3=招待餐。",
                          "example": 1
                        },
                        "meal_date": {
                          "type": "string",
                          "example": "2026-06-15"
                        },
                        "meal_times": {
                          "type": "integer",
                          "example": 2
                        },
                        "pay_price": {
                          "type": "string",
                          "example": "38.00",
                          "description": "实际支付金额，对应订单 pay_price。"
                        },
                        "verify_status": {
                          "type": "integer",
                          "example": 20,
                          "description": "核销状态；成功时为 20，表示已核销。"
                        },
                        "verify_mode": {
                          "type": "string",
                          "description": "booking=核销已有订餐订单，onsite=人脸无当餐订餐时生成现场消费订单并扣款。",
                          "example": "booking"
                        },
                        "user_name": {
                          "type": "string",
                          "description": "人名，对应订单 user_name。",
                          "example": "兰海军"
                        },
                        "total_price": {
                          "type": "string",
                          "description": "应付金额，对应订单 total_price。",
                          "example": "38.00"
                        },
                        "remain_balance": {
                          "type": "string",
                          "description": "支付后的账户余额，对应订单 remain_balance。",
                          "example": "12.00"
                        }
                      }
                    },
                    "trace_id": {
                      "type": "string",
                      "example": "6a2fe9d3b6705"
                    }
                  }
                },
                "examples": {
                  "success": {
                    "summary": "核销成功",
                    "value": {
                      "code": 0,
                      "message": "核销成功",
                      "data": {
                        "order_id": 123,
                        "order_no": "260615184398126",
                        "user_name": "兰海军",
                        "booking_type": 1,
                        "meal_date": "2026-06-15",
                        "meal_times": 2,
                        "total_price": "38.00",
                        "pay_price": "38.00",
                        "remain_balance": "12.00",
                        "verify_status": 20,
                        "verify_mode": "booking"
                      }
                    }
                  },
                  "onsiteSuccess": {
                    "summary": "人脸无当餐订餐，生成现场消费订单",
                    "value": {
                      "code": 0,
                      "message": "核销成功",
                      "data": {
                        "order_id": 456,
                        "order_no": "260616171000001",
                        "user_name": "兰海军",
                        "booking_type": 0,
                        "meal_date": "2026-06-16",
                        "meal_times": 3,
                        "total_price": "38.00",
                        "pay_price": "9.00",
                        "remain_balance": "-9.00",
                        "verify_status": 20,
                        "verify_mode": "onsite"
                      }
                    }
                  },
                  "notFound": {
                    "summary": "未找到可核销订餐订单",
                    "value": {
                      "code": 1,
                      "message": "未找到可核销订餐订单",
                      "data": []
                    }
                  },
                  "alreadyConsumed": {
                    "summary": "重复现场消费",
                    "value": {
                      "code": 1,
                      "message": "当餐已消费",
                      "data": []
                    }
                  },
                  "refunding": {
                    "summary": "退款中或部分退款",
                    "value": {
                      "code": 1,
                      "message": "订单退款处理中或部分退款，暂不可现场消费",
                      "data": []
                    }
                  },
                  "tooEarly": {
                    "summary": "未到错峰就餐时间",
                    "value": {
                      "code": 1,
                      "message": "未到就餐时间，请于 11:30 后核销",
                      "data": []
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}
