{
  "openapi": "3.0.3",
  "info": {
    "title": "国信订餐接口增量",
    "version": "2026-06-12",
    "description": "国信 H5 订餐、设备核销、PC 订单管理订餐筛选相关接口。"
  },
  "servers": [
    {
      "url": "/",
      "description": "按部署环境域名补齐"
    }
  ],
  "tags": [
    {
      "name": "国信订餐/H5订餐",
      "description": "ai_web 调 ai_api 的 H5 订餐接口"
    },
    {
      "name": "国信订餐/设备核销",
      "description": "消费机/核销设备调 store 的订餐核销接口"
    },
    {
      "name": "国信订餐/PC订单管理",
      "description": "store PC 订单管理订餐字段、筛选与导出"
    }
  ],
  "paths": {
    "/api/mealBooking/config": {
      "post": {
        "tags": [
          "国信订餐/H5订餐"
        ],
        "x-apifox-folder": "国信订餐/H5订餐",
        "summary": "H5订餐配置",
        "description": "返回当前用户、默认档口、档口 book_rules 计算后的可订日期/餐次、每餐价格、订餐类型权限。H5 页面进入订餐页时调用。",
        "operationId": "mealBookingConfig",
        "parameters": [
          {
            "$ref": "#/components/parameters/H5AccessToken"
          },
          {
            "$ref": "#/components/parameters/H5Platform"
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/x-www-form-urlencoded": {
              "schema": {
                "type": "object",
                "properties": {
                  "restaurant_id": {
                    "type": "integer",
                    "description": "档口ID；不传时按当前人员默认档口或可用预定档口取一个",
                    "example": 12
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "查询成功",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BookingConfigResponse"
                },
                "example": {
                  "status": 200,
                  "message": "success",
                  "data": {
                    "current_user": {
                      "name": "张三",
                      "phone": "13800000000",
                      "dept": "测试部门",
                      "is_reception_charge": true
                    },
                    "canteen": {
                      "id": 12,
                      "name": "一层档口"
                    },
                    "dateOptions": [
                      {
                        "label": "06月13日 周六",
                        "value": "2026-06-13"
                      }
                    ],
                    "mealOptions": [
                      {
                        "label": "午餐",
                        "value": 2
                      }
                    ],
                    "pricesByMeal": {
                      "2": {
                        "self": "15.00",
                        "family": "20.00",
                        "official": "30.00"
                      }
                    },
                    "prices": {
                      "self": "15.00",
                      "family": "20.00",
                      "official": "30.00"
                    },
                    "booking_types": [
                      {
                        "value": "self",
                        "label": "本人订餐",
                        "enabled": true
                      },
                      {
                        "value": "family",
                        "label": "亲友餐",
                        "enabled": true
                      },
                      {
                        "value": "official",
                        "label": "招待餐",
                        "enabled": true
                      }
                    ]
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/mealBooking/submit": {
      "post": {
        "tags": [
          "国信订餐/H5订餐"
        ],
        "x-apifox-folder": "国信订餐/H5订餐",
        "summary": "H5提交订餐",
        "description": "本人订餐走 application_scene=1 消费策略；亲友餐走 family_booking_meal_fee 固定价；招待餐走 reception_booking_meal_fee 固定价并扣部门账户。",
        "operationId": "mealBookingSubmit",
        "parameters": [
          {
            "$ref": "#/components/parameters/H5AccessToken"
          },
          {
            "$ref": "#/components/parameters/H5Platform"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/BookingSubmitRequest"
              },
              "examples": {
                "self": {
                  "summary": "本人订餐",
                  "value": {
                    "restaurant_id": 12,
                    "booking_type": "self",
                    "dates": [
                      "2026-06-13"
                    ],
                    "meal_times": [
                      2
                    ],
                    "participant": {
                      "peopleCount": 1
                    }
                  }
                },
                "family": {
                  "summary": "亲友餐",
                  "value": {
                    "restaurant_id": 12,
                    "booking_type": "family",
                    "dates": [
                      "2026-06-13"
                    ],
                    "meal_times": [
                      2
                    ],
                    "participant": {
                      "name": "李四",
                      "phone": "13900000000",
                      "relation": "亲友",
                      "peopleCount": 2
                    }
                  }
                },
                "official": {
                  "summary": "招待餐",
                  "value": {
                    "restaurant_id": 12,
                    "booking_type": "official",
                    "dates": [
                      "2026-06-13"
                    ],
                    "meal_times": [
                      2
                    ],
                    "participant": {
                      "name": "外部接待单位",
                      "phone": "13900000000",
                      "peopleCount": 5,
                      "remark": "项目接待"
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "订餐成功",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BookingSubmitResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/mealBooking/list": {
      "post": {
        "tags": [
          "国信订餐/H5订餐"
        ],
        "x-apifox-folder": "国信订餐/H5订餐",
        "summary": "H5订餐记录列表",
        "description": "查询当前登录用户的订餐订单。支持按年月、订餐类型过滤。",
        "operationId": "mealBookingList",
        "parameters": [
          {
            "$ref": "#/components/parameters/H5AccessToken"
          },
          {
            "$ref": "#/components/parameters/H5Platform"
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/x-www-form-urlencoded": {
              "schema": {
                "type": "object",
                "properties": {
                  "year": {
                    "type": "integer",
                    "example": 2026
                  },
                  "month": {
                    "type": "integer",
                    "example": 6
                  },
                  "booking_type": {
                    "type": "string",
                    "description": "可选：self/family/official；不传查全部",
                    "enum": [
                      "self",
                      "family",
                      "official"
                    ],
                    "example": "self"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "查询成功",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BookingListResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/mealBooking/detail": {
      "post": {
        "tags": [
          "国信订餐/H5订餐"
        ],
        "x-apifox-folder": "国信订餐/H5订餐",
        "summary": "H5订餐详情",
        "description": "查询当前登录用户某一条订餐订单详情，亲友餐/招待餐返回核销二维码 token。",
        "operationId": "mealBookingDetail",
        "parameters": [
          {
            "$ref": "#/components/parameters/H5AccessToken"
          },
          {
            "$ref": "#/components/parameters/H5Platform"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/x-www-form-urlencoded": {
              "schema": {
                "type": "object",
                "required": [
                  "id"
                ],
                "properties": {
                  "id": {
                    "type": "integer",
                    "description": "订单ID",
                    "example": 10001
                  },
                  "order_id": {
                    "type": "integer",
                    "description": "订单ID别名；id/order_id 二选一",
                    "example": 10001
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "查询成功",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BookingDetailResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/mealBooking/cancel": {
      "post": {
        "tags": [
          "国信订餐/H5订餐"
        ],
        "x-apifox-folder": "国信订餐/H5订餐",
        "summary": "H5取消订餐",
        "description": "当前登录用户取消自己的未核销订餐订单；校验取消截止时间，成功后原路退回个人账户或部门账户。",
        "operationId": "mealBookingCancel",
        "parameters": [
          {
            "$ref": "#/components/parameters/H5AccessToken"
          },
          {
            "$ref": "#/components/parameters/H5Platform"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/x-www-form-urlencoded": {
              "schema": {
                "type": "object",
                "required": [
                  "id"
                ],
                "properties": {
                  "id": {
                    "type": "integer",
                    "description": "订单ID",
                    "example": 10001
                  },
                  "order_id": {
                    "type": "integer",
                    "description": "订单ID别名；id/order_id 二选一",
                    "example": 10001
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "取消成功",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BookingCancelResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/consume/bookingVerify": {
      "post": {
        "tags": [
          "国信订餐/设备核销"
        ],
        "x-apifox-folder": "国信订餐/设备核销",
        "summary": "设备订餐核销",
        "description": "store 设备接口。本人订餐使用 staff_uuid 人脸核销；亲友餐/招待餐使用 qr_token 或 verification_code 二维码核销。核销成功后订单变为已完成，booking_verify_status=20。",
        "operationId": "consumeBookingVerify",
        "parameters": [
          {
            "$ref": "#/components/parameters/DeviceAccount"
          },
          {
            "$ref": "#/components/parameters/DevicePwd"
          },
          {
            "$ref": "#/components/parameters/DeviceKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/x-www-form-urlencoded": {
              "schema": {
                "$ref": "#/components/schemas/BookingVerifyRequest"
              },
              "examples": {
                "face": {
                  "summary": "本人订餐人脸核销",
                  "value": {
                    "staff_uuid": "staff-uuid",
                    "equipment_code": "EQ001",
                    "meal_date": "2026-06-13",
                    "meal_times": 2,
                    "msgid": "EQ001-20260613120000001"
                  }
                },
                "qr": {
                  "summary": "亲友/招待二维码核销",
                  "value": {
                    "qr_token": "cb4f6a6c0b8a4e1b8d9a2c5f1a0b2c3d",
                    "equipment_code": "EQ001",
                    "meal_date": "2026-06-13",
                    "meal_times": 2,
                    "msgid": "EQ001-20260613120000002"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "核销结果",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StoreApiResponse"
                },
                "example": {
                  "code": 0,
                  "message": "核销成功",
                  "data": {
                    "order_id": 10001,
                    "order_no": "202606130001",
                    "booking_type": 1,
                    "meal_date": "2026-06-13",
                    "meal_times": 2,
                    "pay_price": "15.00",
                    "verify_status": 20
                  }
                }
              }
            }
          }
        }
      }
    },
    "/p/mealOrder/list": {
      "post": {
        "tags": [
          "国信订餐/PC订单管理"
        ],
        "x-apifox-folder": "国信订餐/PC订单管理",
        "summary": "PC消费订单列表（新增订餐筛选/字段）",
        "description": "既有 store PC 接口，本次新增 is_booking、booking_type 筛选，并在返回列表中增加订餐展示字段。",
        "operationId": "pcMealOrderList",
        "requestBody": {
          "required": false,
          "content": {
            "application/x-www-form-urlencoded": {
              "schema": {
                "$ref": "#/components/schemas/PcMealOrderListRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "查询成功",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PcMealOrderListResponse"
                }
              }
            }
          }
        }
      }
    },
    "/p/mealOrder/export": {
      "post": {
        "tags": [
          "国信订餐/PC订单管理"
        ],
        "x-apifox-folder": "国信订餐/PC订单管理",
        "summary": "PC消费订单导出（新增订餐筛选/字段）",
        "description": "既有 store PC 导出接口，本次新增 is_booking、booking_type 筛选；导出文件增加是否订餐、订餐类型、核销状态、费用归属列。",
        "operationId": "pcMealOrderExport",
        "requestBody": {
          "required": false,
          "content": {
            "application/x-www-form-urlencoded": {
              "schema": {
                "allOf": [
                  {
                    "$ref": "#/components/schemas/PcMealOrderListRequest"
                  },
                  {
                    "type": "object",
                    "properties": {
                      "type": {
                        "type": "integer",
                        "description": "导出类型；消费订单为 1",
                        "example": 1
                      }
                    }
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "导出任务提交结果",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StoreApiResponse"
                },
                "example": {
                  "code": 0,
                  "message": "提交成功，请在导出日志查看进度",
                  "data": []
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "parameters": {
      "H5AccessToken": {
        "name": "Access-Token",
        "in": "header",
        "required": true,
        "description": "ai_api H5 登录 token",
        "schema": {
          "type": "string"
        }
      },
      "H5Platform": {
        "name": "platform",
        "in": "header",
        "required": true,
        "description": "H5 固定传 H5",
        "schema": {
          "type": "string",
          "default": "H5"
        }
      },
      "DeviceAccount": {
        "name": "account",
        "in": "header",
        "required": true,
        "description": "store api_auth 设备接口账号",
        "schema": {
          "type": "string"
        }
      },
      "DevicePwd": {
        "name": "pwd",
        "in": "header",
        "required": true,
        "description": "store api_auth 设备接口密码",
        "schema": {
          "type": "string"
        }
      },
      "DeviceKey": {
        "name": "key",
        "in": "header",
        "required": true,
        "description": "store api_auth 设备接口 key",
        "schema": {
          "type": "string"
        }
      }
    },
    "schemas": {
      "AiApiResponse": {
        "type": "object",
        "properties": {
          "status": {
            "type": "integer",
            "example": 200
          },
          "message": {
            "type": "string",
            "example": "success"
          },
          "data": {
            "type": "object"
          }
        }
      },
      "StoreApiResponse": {
        "type": "object",
        "properties": {
          "code": {
            "type": "integer",
            "example": 0
          },
          "message": {
            "type": "string",
            "example": "查询成功"
          },
          "data": {
            "type": "object"
          }
        }
      },
      "BookingConfigResponse": {
        "allOf": [
          {
            "$ref": "#/components/schemas/AiApiResponse"
          }
        ]
      },
      "BookingSubmitRequest": {
        "type": "object",
        "required": [
          "booking_type",
          "dates",
          "meal_times"
        ],
        "properties": {
          "restaurant_id": {
            "type": "integer",
            "description": "档口ID",
            "example": 12
          },
          "booking_type": {
            "type": "string",
            "description": "self=本人订餐，family=亲友餐，official=招待餐",
            "enum": [
              "self",
              "family",
              "official"
            ],
            "example": "self"
          },
          "dates": {
            "type": "array",
            "description": "订餐日期，按档口 book_rules 可订日期校验",
            "items": {
              "type": "string",
              "format": "date"
            },
            "example": [
              "2026-06-13"
            ]
          },
          "meal_times": {
            "type": "array",
            "description": "餐次：1=早餐，2=午餐，3=晚餐，4=夜宵",
            "items": {
              "type": "integer",
              "enum": [
                1,
                2,
                3,
                4
              ]
            },
            "example": [
              2
            ]
          },
          "participant": {
            "type": "object",
            "description": "亲友餐/招待餐扩展信息",
            "properties": {
              "name": {
                "type": "string",
                "description": "亲友姓名或接待对象"
              },
              "phone": {
                "type": "string",
                "description": "联系电话"
              },
              "relation": {
                "type": "string",
                "description": "亲友关系"
              },
              "peopleCount": {
                "type": "integer",
                "description": "人数；本人订餐固定 1，亲友餐按人数生成多条订单，招待餐一条订单记录总人数",
                "example": 1
              },
              "remark": {
                "type": "string",
                "description": "备注"
              }
            }
          }
        }
      },
      "BookingRecord": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer",
            "example": 10001
          },
          "orderNo": {
            "type": "string",
            "example": "202606130001"
          },
          "type": {
            "type": "string",
            "example": "本人订餐"
          },
          "status": {
            "type": "string",
            "example": "待核销"
          },
          "date": {
            "type": "string",
            "example": "2026-06-13"
          },
          "meal": {
            "type": "string",
            "example": "午餐"
          },
          "canteen": {
            "type": "string",
            "example": "一层档口"
          },
          "amount": {
            "type": "string",
            "example": "15.00"
          },
          "verificationCode": {
            "type": "string",
            "description": "亲友餐/招待餐二维码 token；本人订餐为空",
            "example": "cb4f6a6c0b8a4e1b8d9a2c5f1a0b2c3d"
          },
          "canCancel": {
            "type": "boolean",
            "example": true
          },
          "cancelDeadline": {
            "type": "string",
            "example": "2026-06-13 10:30:00"
          }
        }
      },
      "BookingSubmitResponse": {
        "allOf": [
          {
            "$ref": "#/components/schemas/AiApiResponse"
          },
          {
            "type": "object",
            "properties": {
              "data": {
                "type": "object",
                "properties": {
                  "batch_no": {
                    "type": "string",
                    "example": "BK202606131200000001"
                  },
                  "records": {
                    "type": "array",
                    "items": {
                      "$ref": "#/components/schemas/BookingRecord"
                    }
                  }
                }
              }
            }
          }
        ]
      },
      "BookingListResponse": {
        "allOf": [
          {
            "$ref": "#/components/schemas/AiApiResponse"
          },
          {
            "type": "object",
            "properties": {
              "data": {
                "type": "object",
                "properties": {
                  "list": {
                    "type": "array",
                    "items": {
                      "$ref": "#/components/schemas/BookingRecord"
                    }
                  }
                }
              }
            }
          }
        ]
      },
      "BookingDetailResponse": {
        "allOf": [
          {
            "$ref": "#/components/schemas/AiApiResponse"
          },
          {
            "type": "object",
            "properties": {
              "data": {
                "type": "object",
                "properties": {
                  "detail": {
                    "$ref": "#/components/schemas/BookingRecord"
                  }
                }
              }
            }
          }
        ]
      },
      "BookingCancelResponse": {
        "allOf": [
          {
            "$ref": "#/components/schemas/AiApiResponse"
          },
          {
            "type": "object",
            "properties": {
              "data": {
                "type": "object",
                "properties": {
                  "order_id": {
                    "type": "integer",
                    "example": 10001
                  },
                  "status": {
                    "type": "string",
                    "example": "已取消"
                  }
                }
              }
            }
          }
        ]
      },
      "BookingVerifyRequest": {
        "type": "object",
        "required": [
          "equipment_code"
        ],
        "properties": {
          "staff_uuid": {
            "type": "string",
            "description": "本人订餐人脸核销用；与 qr_token/verification_code 二选一",
            "example": "staff-uuid"
          },
          "qr_token": {
            "type": "string",
            "description": "亲友餐/招待餐二维码 token；与 staff_uuid 二选一",
            "example": "cb4f6a6c0b8a4e1b8d9a2c5f1a0b2c3d"
          },
          "verification_code": {
            "type": "string",
            "description": "qr_token 别名，兼容 H5 展示字段",
            "example": "cb4f6a6c0b8a4e1b8d9a2c5f1a0b2c3d"
          },
          "equipment_code": {
            "type": "string",
            "description": "核销设备编号",
            "example": "EQ001"
          },
          "meal_date": {
            "type": "string",
            "format": "date",
            "description": "就餐日期；不传默认当天",
            "example": "2026-06-13"
          },
          "meal_times": {
            "type": "integer",
            "description": "餐次：1=早餐，2=午餐，3=晚餐，4=夜宵；不传则不按餐次过滤",
            "example": 2
          },
          "msgid": {
            "type": "string",
            "description": "设备请求流水号",
            "example": "EQ001-20260613120000001"
          }
        }
      },
      "PcMealOrderListRequest": {
        "type": "object",
        "properties": {
          "start_date": {
            "type": "string",
            "format": "date",
            "example": "2026-06-01"
          },
          "end_date": {
            "type": "string",
            "format": "date",
            "example": "2026-06-30"
          },
          "source": {
            "type": "integer",
            "description": "订单类型：1=堂食，4=线上订餐/外卖，5=外部订餐，6=闸机，7=点餐机",
            "example": 4
          },
          "is_booking": {
            "type": "integer",
            "description": "是否订餐：0=非订餐，1=订餐；本次新增",
            "enum": [
              0,
              1
            ],
            "example": 1
          },
          "booking_type": {
            "type": "integer",
            "description": "订餐类型：1=本人订餐，2=亲友餐，3=招待餐；本次新增",
            "enum": [
              1,
              2,
              3
            ],
            "example": 1
          },
          "order_unified_status": {
            "type": "integer",
            "description": "订单统一状态：10=待付款，20=已取消，30=已付款，40=已退款，50=退款中，60=部分退款",
            "example": 30
          },
          "pay_type": {
            "type": "integer",
            "description": "支付方式：10=线上，20=刷卡，30=消费码，40=刷脸",
            "example": 10
          },
          "meal_times": {
            "type": "string",
            "description": "餐次，多个逗号分隔",
            "example": "2,3"
          },
          "department_uuids": {
            "type": "string",
            "description": "部门UUID，多个逗号分隔",
            "example": "dept-uuid"
          },
          "restaurantIds": {
            "type": "string",
            "description": "档口ID，多个逗号分隔",
            "example": "12,13"
          },
          "equipment_codes": {
            "type": "string",
            "description": "设备编号，多个逗号分隔",
            "example": "EQ001,EQ002"
          },
          "marketing_strategy_id": {
            "type": "integer",
            "description": "消费策略ID",
            "example": 100
          },
          "mobile": {
            "type": "string",
            "description": "手机号搜索",
            "example": "13800000000"
          },
          "nickname": {
            "type": "string",
            "description": "姓名搜索",
            "example": "张三"
          },
          "card_id": {
            "type": "string",
            "description": "卡号搜索"
          },
          "order_no": {
            "type": "string",
            "description": "订单号搜索"
          },
          "page": {
            "type": "integer",
            "example": 1
          }
        }
      },
      "PcMealOrderListResponse": {
        "allOf": [
          {
            "$ref": "#/components/schemas/StoreApiResponse"
          },
          {
            "type": "object",
            "properties": {
              "data": {
                "type": "object",
                "properties": {
                  "data": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "integer",
                          "example": 10001
                        },
                        "order_no": {
                          "type": "string",
                          "example": "202606130001"
                        },
                        "is_booking": {
                          "type": "integer",
                          "example": 1
                        },
                        "is_booking_text": {
                          "type": "string",
                          "example": "订餐"
                        },
                        "booking_type": {
                          "type": "integer",
                          "example": 1
                        },
                        "booking_type_text": {
                          "type": "string",
                          "example": "本人订餐"
                        },
                        "booking_verify_status": {
                          "type": "integer",
                          "example": 10
                        },
                        "booking_verify_status_text": {
                          "type": "string",
                          "example": "待核销"
                        },
                        "expense_owner_name": {
                          "type": "string",
                          "example": "测试部门账户"
                        }
                      }
                    }
                  },
                  "total": {
                    "type": "integer",
                    "example": 1
                  },
                  "total_price": {
                    "type": "string",
                    "example": "15.00"
                  },
                  "pay_amount": {
                    "type": "string",
                    "example": "15.00"
                  }
                }
              }
            }
          }
        ]
      }
    }
  }
}
