{
  "openapi": "3.0.3",
  "info": {
    "title": "中央美术学院 Android 一卡通结算",
    "version": "1.0.0",
    "description": "450称重台匿名取餐，绑盘机按餐盘查询金额并刷一卡通结算。仅在 meal_model=4 时启用匿名餐盘流程。"
  },
  "paths": {
    "/api/oneCardTerminal/syncPersons": {
      "post": {
        "summary": "接口 A：同步人员及卡片",
        "tags": ["智能硬件/安卓/中央美术学院一卡通"],
        "x-apifox-folder": "智能硬件/安卓/中央美术学院一卡通",
        "description": "# 接口 A：同步人员及卡片\n\n## 接口用途\n\n一卡通终端分批向智慧餐厅同步人员及卡片基础信息。接口协议与原同步接口保持不变；单批最多 1000 人。\n\n## 请求说明\n\n- 请求方法：`POST`\n- Content-Type：`application/x-www-form-urlencoded`\n- `one_card_type` 固定传 `新开普`\n- `items` 为人员及卡片数组\n\n## 处理说明\n\n系统以 `customerid` 识别一卡通人员。新人员创建人员及账号，已有人员在数据变化时更新，未变化数据计入 `unchanged`。响应 `code=0` 表示本批请求处理完成，调用方仍需检查 `data.failed`；仅当 `failed=0` 时表示本批全部同步成功。",
        "parameters": [
          {
            "name": "Access-Token",
            "in": "header",
            "required": false,
            "schema": {"type": "string", "default": "{{terminal_token}}"},
            "example": "{{terminal_token}}"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/x-www-form-urlencoded": {
              "schema": {
                "type": "object",
                "required": ["one_card_type", "items"],
                "properties": {
                  "one_card_type": {
                    "type": "string",
                    "enum": ["新开普"],
                    "description": "一卡通类型，固定传新开普",
                    "example": "新开普"
                  },
                  "items": {
                    "type": "array",
                    "maxItems": 1000,
                    "description": "人员及卡片列表，单批最多1000条",
                    "items": {"$ref": "#/components/schemas/SyncPerson"},
                    "example": [{"bm":"020101900000","xh":"1skx273","name":"解航","sex":1,"customerid":29373,"cardno":1705827,"status":1,"cardsn":2}]
                  }
                }
              },
              "example": {
                "one_card_type": "新开普",
                "items": [{"bm":"020101900000","xh":"1skx273","name":"解航","sex":1,"customerid":29373,"cardno":1705827,"status":1,"cardsn":2}]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "同步统计",
            "content": {
              "application/json": {
                "example": {
                  "code": 0,
                  "message": "success",
                  "data": {"total": 1, "created": 1, "updated": 0, "unchanged": 0, "failed": 0},
                  "trace_id": "7f21d8"
                }
              }
            }
          }
        }
      }
    },
    "/p/api/selectPlate": {
      "post": {
        "summary": "450称重台查询并初始化匿名餐盘订单",
        "description": "meal_model=4 且餐盘没有有效绑定时，创建空人员餐盘记录和唯一待支付订单；重复查询复用原订单。其他就餐模式保持原逻辑。",
        "tags": ["智能硬件/安卓/中央美术学院一卡通"],
        "x-apifox-folder": "智能硬件/安卓/中央美术学院一卡通",
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "required": ["plate_code"],
                "properties": {
                  "plate_code": {"type": "string", "example": "008008112"},
                  "equipment_code": {"type": "string", "example": "WEIGHT-450-01"},
                  "dishes_uuids": {"type": "string", "description": "称重台菜品UUID数组JSON", "example": "[]"}
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "空人员信息及当前已取餐金额",
            "content": {
              "application/json": {
                "example": {
                  "code": 0,
                  "message": "查询成功",
                  "data": {
                    "staff": {
                      "uuid": "",
                      "name": "",
                      "reality_price": 0,
                      "balance": "--",
                      "cash_balance": "--",
                      "subsidy_alance": "--"
                    },
                    "nutrition": [],
                    "dishes": []
                  }
                }
              }
            }
          }
        }
      }
    },
    "/p/api/zhctPushMeal": {
      "post": {
        "summary": "450称重台上报匿名餐盘取餐数据",
        "description": "meal_model=4 时根据餐盘找到唯一待支付订单并累加取餐数据。订单进入结算中后拒绝继续取餐。",
        "tags": ["智能硬件/安卓/中央美术学院一卡通"],
        "x-apifox-folder": "智能硬件/安卓/中央美术学院一卡通",
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "required": ["dish_info", "code", "equipment_code"],
                "properties": {
                  "dish_info": {
                    "type": "string",
                    "description": "取餐数据JSON",
                    "example": "{\"create_date\":\"2026-08-24 11:30:00\",\"details\":[{\"uuid\":\"DISH-UUID-001\",\"weight\":100}]}"
                  },
                  "code": {"type": "string", "description": "餐盘码", "example": "008008112"},
                  "equipment_code": {"type": "string", "description": "450称重台编号", "example": "WEIGHT-450-01"}
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "取餐数据接收结果",
            "content": {
              "application/json": {
                "example": {"code": 0, "message": "推送成功", "data": []}
              }
            }
          }
        }
      }
    },
    "/api/oneCardTerminal/acquireByPlate": {
      "post": {
        "summary": "接口 B：按餐盘查询待结算金额",
        "description": "一个餐盘只关联一个待支付订单。金额单位为分；重复查询返回同一待支付结算单。",
        "tags": ["智能硬件/安卓/中央美术学院一卡通"],
        "x-apifox-folder": "智能硬件/安卓/中央美术学院一卡通",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["plate_code", "equipment_code"],
                "properties": {
                  "plate_code": {"type": "string", "example": "008008112"},
                  "equipment_code": {"type": "string", "example": "BIND-ANDROID-01"}
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "结算单号及应扣金额",
            "content": {
              "application/json": {
                "example": {
                  "code": 0,
                  "message": "success",
                  "data": {"order_no": "CAFA20260824113000A1B2C3", "amount": 1234},
                  "trace_id": "7f21d8"
                }
              }
            }
          }
        }
      }
    },
    "/api/oneCardTerminal/report": {
      "post": {
        "summary": "接口 C：反馈一卡通扣款结果",
        "description": "成功时根据结算后卡片的 customerID 绑定人员、完成唯一就餐订单和明细并解绑餐盘；失败时保留待支付订单供重试。不校验结算前后 customerID 是否一致，也不校验反馈扣款金额与订单金额是否一致。三个反馈对象既支持JSON对象，也兼容JSON字符串表单值。",
        "tags": ["智能硬件/安卓/中央美术学院一卡通"],
        "x-apifox-folder": "智能硬件/安卓/中央美术学院一卡通",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["order_no", "settlement_result", "before_card_info", "after_card_info"],
                "properties": {
                  "order_no": {"type": "string", "example": "CAFA20260824113000A1B2C3"},
                  "settlement_result": {"$ref": "#/components/schemas/SettlementResult"},
                  "before_card_info": {"$ref": "#/components/schemas/CardInfo"},
                  "after_card_info": {"$ref": "#/components/schemas/CardInfo"}
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "反馈处理结果",
            "content": {
              "application/json": {
                "example": {"code": 0, "message": "success", "data": [], "trace_id": "7f21d8"}
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "SyncPerson": {
        "type": "object",
        "required": ["bm", "xh", "name", "sex", "customerid", "cardno", "status", "cardsn"],
        "properties": {
          "bm": {"type": "string", "example": "020101900000"},
          "xh": {"type": "string", "example": "20260001"},
          "name": {"type": "string", "example": "测试学生"},
          "sex": {"type": "integer", "enum": [0, 1], "example": 1},
          "customerid": {"type": "integer", "example": 29373},
          "cardno": {"type": "integer", "example": 1705827},
          "status": {"type": "integer", "example": 1},
          "cardsn": {"type": "integer", "example": 2}
        }
      },
      "SettlementResult": {
        "type": "object",
        "required": ["code"],
        "properties": {
          "code": {"type": "integer", "description": "0成功，非0失败", "example": 0},
          "message": {"type": "string", "example": "扣款成功"},
          "amount": {"type": "integer", "description": "一卡通反馈的实际扣款金额，单位分，仅记录不参与订单金额校验", "example": 1234},
          "psamID": {"type": "integer", "example": 166715196755},
          "psamJyNo": {"type": "integer", "example": 6},
          "tac": {"type": "integer", "example": -2015100023}
        },
        "additionalProperties": true
      },
      "CardInfo": {
        "type": "object",
        "required": ["uid", "cardClass", "customerID", "cardNO", "cardSN", "status", "subType", "ze", "ye", "opCount", "subYe", "subCount", "cardASN"],
        "properties": {
          "uid": {"type": "integer", "example": -1845026871},
          "cardClass": {"type": "integer", "example": 8},
          "customerID": {"type": "integer", "example": 29373},
          "cardNO": {"type": "integer", "example": 1705827},
          "cardSN": {"type": "integer", "example": 2},
          "status": {"type": "integer", "example": 241},
          "subType": {"type": "integer", "example": 0},
          "ze": {"type": "integer", "example": 66464},
          "ye": {"type": "integer", "description": "卡余额，单位分", "example": 766},
          "opCount": {"type": "integer", "example": 38},
          "subYe": {"type": "integer", "example": 0},
          "subCount": {"type": "integer", "example": 0},
          "cardASN": {"type": "string", "example": "AA030000026D60992AB9"}
        }
      }
    }
  }
}
