{
    "openapi": "3.0.3",
    "info": {
        "title": "中央美术学院 Android 一卡通结算",
        "version": "1.0.0",
        "description": "450称重台匿名取餐，绑盘机按餐盘查询金额并刷一卡通结算。仅在 meal_model=4 时启用匿名餐盘流程。"
    },
    "paths": {
        "/api/oneCardTerminal/syncPersons": {
            "post": {
                "summary": "接口 A：同步人员及卡片",
                "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"
                                }
                            }
                        }
                    }
                },
                "x-apifox-id": 505919155
            }
        },
        "/api/oneCardTerminal/acquireByPlate": {
            "post": {
                "summary": "接口 B：按餐盘查询待结算金额",
                "description": "一个餐盘只关联一个待支付订单。金额单位为分；重复查询返回同一待支付结算单。",
                "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"
                                }
                            }
                        }
                    }
                },
                "x-apifox-id": 505919156
            }
        },
        "/api/oneCardTerminal/report": {
            "post": {
                "summary": "接口 C：反馈一卡通扣款结果",
                "description": "成功时根据结算后卡片的 customerID 绑定人员、完成唯一就餐订单和明细并解绑餐盘；失败时保留待支付订单供重试。不校验结算前后 customerID 是否一致，也不校验反馈扣款金额与订单金额是否一致。三个反馈对象既支持JSON对象，也兼容JSON字符串表单值。",
                "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"
                                }
                            }
                        }
                    }
                },
                "x-apifox-id": 505919157
            }
        }
    },
    "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"
                    }
                }
            }
        }
    },
    "tags": []
}
