{
  "swagger": "2.0",
  "info": {
    "title": "聚玩订单服务",
    "description": "处理订单业务。ID 字段（int64）以 string 传输",
    "version": "1.0"
  },
  "schemes": [
    "http",
    "https"
  ],
  "consumes": [
    "application/json"
  ],
  "produces": [
    "application/json"
  ],
  "paths": {
    "/api/v1/orders/": {
      "get": {
        "summary": "获取订单列表",
        "operationId": "ListOrders",
        "responses": {
          "200": {
            "description": "A successful response.",
            "schema": {
              "$ref": "#/definitions/OrderListResp"
            }
          }
        },
        "parameters": [
          {
            "name": "offset",
            "in": "query",
            "required": true,
            "type": "integer",
            "format": "int64",
            "default": "0"
          },
          {
            "name": "limit",
            "in": "query",
            "required": true,
            "type": "integer",
            "format": "int64",
            "default": "20"
          },
          {
            "name": "role",
            "description": " consumer, player, owner",
            "in": "query",
            "required": true,
            "type": "string"
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "type": "string"
          }
        ],
        "tags": [
          "order"
        ],
        "consumes": [
          "multipart/form-data"
        ]
      },
      "post": {
        "summary": "创建订单",
        "operationId": "CreateOrder",
        "responses": {
          "200": {
            "description": "A successful response.",
            "schema": {
              "$ref": "#/definitions/CreateOrderResp"
            }
          }
        },
        "parameters": [
          {
            "name": "body",
            "in": "body",
            "required": true,
            "schema": {
              "$ref": "#/definitions/CreateOrderReq"
            }
          }
        ],
        "tags": [
          "order"
        ]
      }
    },
    "/api/v1/orders/paid": {
      "post": {
        "summary": "创建并支付订单",
        "operationId": "CreateAndPayOrder",
        "responses": {
          "200": {
            "description": "A successful response.",
            "schema": {
              "$ref": "#/definitions/CreateOrderResp"
            }
          }
        },
        "parameters": [
          {
            "name": "body",
            "in": "body",
            "required": true,
            "schema": {
              "$ref": "#/definitions/CreateOrderReq"
            }
          }
        ],
        "tags": [
          "order"
        ]
      }
    },
    "/api/v1/orders/{id}": {
      "get": {
        "summary": "获取订单详情",
        "operationId": "GetOrder",
        "responses": {
          "200": {
            "description": "A successful response.",
            "schema": {
              "$ref": "#/definitions/Order"
            }
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "type": "string"
          }
        ],
        "tags": [
          "order"
        ]
      }
    },
    "/api/v1/orders/{id}/accept": {
      "post": {
        "summary": "接单",
        "operationId": "AcceptOrder",
        "responses": {
          "200": {
            "description": "A successful response.",
            "schema": {
              "$ref": "#/definitions/EmptyResp"
            }
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "type": "string"
          },
          {
            "name": "body",
            "in": "body",
            "required": true,
            "schema": {
              "$ref": "#/definitions/PathId"
            }
          }
        ],
        "tags": [
          "order"
        ]
      }
    },
    "/api/v1/orders/{id}/cancel": {
      "post": {
        "summary": "取消订单",
        "operationId": "CancelOrder",
        "responses": {
          "200": {
            "description": "A successful response.",
            "schema": {
              "$ref": "#/definitions/EmptyResp"
            }
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "type": "string"
          },
          {
            "name": "body",
            "in": "body",
            "required": true,
            "schema": {
              "$ref": "#/definitions/PathId"
            }
          }
        ],
        "tags": [
          "order"
        ]
      }
    },
    "/api/v1/orders/{id}/confirm-close": {
      "post": {
        "summary": "确认结算",
        "operationId": "ConfirmCloseOrder",
        "responses": {
          "200": {
            "description": "A successful response.",
            "schema": {
              "$ref": "#/definitions/EmptyResp"
            }
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "type": "string"
          },
          {
            "name": "body",
            "in": "body",
            "required": true,
            "schema": {
              "$ref": "#/definitions/PathId"
            }
          }
        ],
        "tags": [
          "order"
        ]
      }
    },
    "/api/v1/orders/{id}/pay": {
      "post": {
        "summary": "支付订单",
        "operationId": "PayOrder",
        "responses": {
          "200": {
            "description": "A successful response.",
            "schema": {
              "$ref": "#/definitions/EmptyResp"
            }
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "type": "string"
          },
          {
            "name": "body",
            "in": "body",
            "required": true,
            "schema": {
              "$ref": "#/definitions/PathId"
            }
          }
        ],
        "tags": [
          "order"
        ]
      }
    },
    "/api/v1/orders/{id}/reorder": {
      "post": {
        "summary": "再来一单",
        "operationId": "Reorder",
        "responses": {
          "200": {
            "description": "A successful response.",
            "schema": {
              "$ref": "#/definitions/CreateOrderResp"
            }
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "type": "string"
          },
          {
            "name": "body",
            "in": "body",
            "required": true,
            "schema": {
              "$ref": "#/definitions/PathId"
            }
          }
        ],
        "tags": [
          "order"
        ]
      }
    },
    "/api/v1/orders/{id}/request-close": {
      "post": {
        "summary": "申请结算",
        "operationId": "RequestCloseOrder",
        "responses": {
          "200": {
            "description": "A successful response.",
            "schema": {
              "$ref": "#/definitions/EmptyResp"
            }
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "type": "string"
          },
          {
            "name": "body",
            "in": "body",
            "required": true,
            "schema": {
              "$ref": "#/definitions/PathId"
            }
          }
        ],
        "tags": [
          "order"
        ]
      }
    }
  },
  "definitions": {
    "CreateOrderReq": {
      "type": "object",
      "properties": {
        "playerId": {
          "type": "integer",
          "format": "int64"
        },
        "shopId": {
          "type": "integer",
          "format": "int64"
        },
        "serviceId": {
          "type": "integer",
          "format": "int64"
        },
        "quantity": {
          "type": "integer",
          "format": "int32"
        },
        "note": {
          "type": "string"
        }
      },
      "title": "CreateOrderReq",
      "required": [
        "playerId",
        "serviceId",
        "quantity"
      ]
    },
    "CreateOrderResp": {
      "type": "object",
      "properties": {
        "ok": {
          "type": "boolean",
          "format": "boolean"
        },
        "order": {
          "$ref": "#/definitions/Order"
        }
      },
      "title": "CreateOrderResp",
      "required": [
        "ok",
        "order"
      ]
    },
    "EmptyResp": {
      "type": "object",
      "title": "EmptyResp"
    },
    "Order": {
      "type": "object",
      "properties": {
        "id": {
          "type": "integer",
          "format": "int64"
        },
        "consumerId": {
          "type": "integer",
          "format": "int64"
        },
        "playerId": {
          "type": "string"
        },
        "shopId": {
          "type": "integer",
          "format": "int64"
        },
        "service": {
          "$ref": "#/definitions/PlayerService"
        },
        "status": {
          "type": "string"
        },
        "totalPrice": {
          "type": "number",
          "format": "double"
        },
        "note": {
          "type": "string"
        },
        "createdAt": {
          "type": "string"
        },
        "acceptedAt": {
          "type": "string"
        },
        "completedAt": {
          "type": "string"
        }
      },
      "title": "Order",
      "required": [
        "id",
        "consumerId",
        "playerId",
        "service",
        "status",
        "totalPrice",
        "createdAt"
      ]
    },
    "OrderListReq": {
      "type": "object",
      "properties": {
        "offset": {
          "type": "integer",
          "format": "int64",
          "default": "0"
        },
        "limit": {
          "type": "integer",
          "format": "int64",
          "default": "20"
        },
        "role": {
          "type": "string",
          "description": " consumer, player, owner"
        },
        "status": {
          "type": "string"
        }
      },
      "title": "OrderListReq",
      "required": [
        "role"
      ]
    },
    "OrderListResp": {
      "type": "object",
      "properties": {
        "items": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/Order"
          }
        },
        "meta": {
          "$ref": "#/definitions/PageMeta"
        }
      },
      "title": "OrderListResp",
      "required": [
        "items",
        "meta"
      ]
    },
    "PageMeta": {
      "type": "object",
      "properties": {
        "total": {
          "type": "integer",
          "format": "int64"
        },
        "offset": {
          "type": "integer",
          "format": "int64"
        },
        "limit": {
          "type": "integer",
          "format": "int64"
        }
      },
      "title": "PageMeta",
      "required": [
        "total",
        "offset",
        "limit"
      ]
    },
    "PageReq": {
      "type": "object",
      "properties": {
        "offset": {
          "type": "integer",
          "format": "int64",
          "default": "0"
        },
        "limit": {
          "type": "integer",
          "format": "int64",
          "default": "20"
        }
      },
      "title": "PageReq",
      "required": [
        "offset",
        "limit"
      ]
    },
    "PathId": {
      "type": "object",
      "title": "PathId"
    },
    "PlayerService": {
      "type": "object",
      "properties": {
        "id": {
          "type": "integer",
          "format": "int64"
        },
        "playerId": {
          "type": "integer",
          "format": "int64"
        },
        "gameId": {
          "type": "integer",
          "format": "int64"
        },
        "gameName": {
          "type": "string"
        },
        "title": {
          "type": "string"
        },
        "description": {
          "type": "string"
        },
        "price": {
          "type": "number",
          "format": "double"
        },
        "unit": {
          "type": "string"
        },
        "rankRange": {
          "type": "string"
        },
        "availability": {
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      },
      "title": "PlayerService",
      "required": [
        "id",
        "playerId",
        "gameId",
        "gameName",
        "title",
        "description",
        "price",
        "unit",
        "availability"
      ]
    },
    "SimpleUser": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string"
        },
        "nickname": {
          "type": "string"
        },
        "avatar": {
          "type": "string"
        }
      },
      "title": "SimpleUser",
      "required": [
        "id",
        "nickname",
        "avatar"
      ]
    },
    "UserProfile": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string"
        },
        "username": {
          "type": "string"
        },
        "nickname": {
          "type": "string"
        },
        "avatar": {
          "type": "string"
        },
        "role": {
          "type": "string",
          "description": " consumer, player, owner, admin"
        },
        "verifiedRoles": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "verificationStatus": {
          "type": "object"
        },
        "phone": {
          "type": "string"
        },
        "bio": {
          "type": "string"
        },
        "createdAt": {
          "type": "string"
        }
      },
      "title": "UserProfile",
      "required": [
        "id",
        "username",
        "nickname",
        "avatar",
        "role",
        "verifiedRoles",
        "verificationStatus",
        "createdAt"
      ]
    }
  },
  "securityDefinitions": {
    "apiKey": {
      "type": "apiKey",
      "description": "Enter JWT Bearer token **_only_**",
      "name": "Authorization",
      "in": "header"
    }
  }
}
