refactor: remove redundant name fields from order service

This commit is contained in:
zetaloop
2026-04-22 22:28:41 +08:00
parent b3db04c9cc
commit 2d45d7e3cb
21 changed files with 179 additions and 1062 deletions
+88 -93
View File
@@ -1,113 +1,108 @@
syntax = "v1"
import "common.api"
info (
title: "聚玩订单服务"
desc: "处理订单业务"
author: "Asadz"
version: "1.0"
title: "聚玩订单服务"
desc: "处理订单业务"
author: "Asadz"
version: "1.0"
)
type (
PathId {
Id int64 `path:"id"`
}
PlayerService {
Id int64 `json:"id"`
PlayerId int64 `json:"playerId"`
GameId int64 `json:"gameId"`
GameName string `json:"gameName"`
Title string `json:"title"`
Description string `json:"description"`
Price float64 `json:"price"`
Unit string `json:"unit"`
RankRange string `json:"rankRange,optional"`
Availability []string `json:"availability"`
}
Order {
Id int64 `json:"id"`
ConsumerId int64 `json:"consumerId"`
ConsumerName string `json:"consumerName"`
PlayerId string `json:"playerId"`
PlayerName string `json:"playerName"`
ShopId int64 `json:"shopId,optional"`
ShopName string `json:"shopName,optional"`
Service PlayerService `json:"service"`
Status string `json:"status"`
TotalPrice float64 `json:"totalPrice"`
Note string `json:"note,optional"`
CreatedAt string `json:"createdAt"`
AcceptedAt string `json:"acceptedAt,optional"`
CompletedAt string `json:"completedAt,optional"`
}
OrderListReq {
PageReq
Role string `form:"role"` // consumer, player, owner
Status string `form:"status,optional"`
}
OrderListResp {
Items []Order `json:"items"`
Meta PageMeta `json:"meta"`
}
CreateOrderReq {
PlayerId int64 `json:"playerId"`
ShopId int64 `json:"shopId,optional"`
ServiceId int64 `json:"serviceId"`
Quantity int `json:"quantity"`
Note string `json:"note,optional"`
}
CreateOrderResp {
Ok bool `json:"ok"`
Order Order `json:"order"`
}
PathId {
Id int64 `path:"id"`
}
PlayerService {
Id int64 `json:"id"`
PlayerId int64 `json:"playerId"`
GameId int64 `json:"gameId"`
GameName string `json:"gameName"`
Title string `json:"title"`
Description string `json:"description"`
Price float64 `json:"price"`
Unit string `json:"unit"`
RankRange string `json:"rankRange,optional"`
Availability []string `json:"availability"`
}
Order {
Id int64 `json:"id"`
ConsumerId int64 `json:"consumerId"`
PlayerId string `json:"playerId"`
ShopId int64 `json:"shopId,optional"`
Service PlayerService `json:"service"`
Status string `json:"status"`
TotalPrice float64 `json:"totalPrice"`
Note string `json:"note,optional"`
CreatedAt string `json:"createdAt"`
AcceptedAt string `json:"acceptedAt,optional"`
CompletedAt string `json:"completedAt,optional"`
}
OrderListReq {
PageReq
Role string `form:"role"` // consumer, player, owner
Status string `form:"status,optional"`
}
OrderListResp {
Items []Order `json:"items"`
Meta PageMeta `json:"meta"`
}
CreateOrderReq {
PlayerId int64 `json:"playerId"`
ShopId int64 `json:"shopId,optional"`
ServiceId int64 `json:"serviceId"`
Quantity int `json:"quantity"`
Note string `json:"note,optional"`
}
CreateOrderResp {
Ok bool `json:"ok"`
Order Order `json:"order"`
}
)
@server(
prefix: api/v1/orders
group: order
@server (
prefix: api/v1/orders
group: order
)
service order-api {
@doc "获取订单列表"
@handler ListOrders
get / (OrderListReq) returns (OrderListResp)
@doc "获取订单列表"
@handler ListOrders
get / (OrderListReq) returns (OrderListResp)
@doc "获取订单详情"
@handler GetOrder
get /:id (PathId) returns (Order)
@doc "获取订单详情"
@handler GetOrder
get /:id (PathId) returns (Order)
@doc "创建订单"
@handler CreateOrder
post / (CreateOrderReq) returns (CreateOrderResp)
@doc "创建订单"
@handler CreateOrder
post / (CreateOrderReq) returns (CreateOrderResp)
@doc "创建并支付订单"
@handler CreateAndPayOrder
post /paid (CreateOrderReq) returns (CreateOrderResp)
@doc "创建并支付订单"
@handler CreateAndPayOrder
post /paid (CreateOrderReq) returns (CreateOrderResp)
@doc "支付订单"
@handler PayOrder
post /:id/pay (PathId) returns (EmptyResp)
@doc "支付订单"
@handler PayOrder
post /:id/pay (PathId) returns (EmptyResp)
@doc "接单"
@handler AcceptOrder
post /:id/accept (PathId) returns (EmptyResp)
@doc "接单"
@handler AcceptOrder
post /:id/accept (PathId) returns (EmptyResp)
@doc "申请结算"
@handler RequestCloseOrder
post /:id/request-close (PathId) returns (EmptyResp)
@doc "申请结算"
@handler RequestCloseOrder
post /:id/request-close (PathId) returns (EmptyResp)
@doc "确认结算"
@handler ConfirmCloseOrder
post /:id/confirm-close (PathId) returns (EmptyResp)
@doc "确认结算"
@handler ConfirmCloseOrder
post /:id/confirm-close (PathId) returns (EmptyResp)
@doc "取消订单"
@handler CancelOrder
post /:id/cancel (PathId) returns (EmptyResp)
@doc "取消订单"
@handler CancelOrder
post /:id/cancel (PathId) returns (EmptyResp)
@doc "再来一单"
@handler Reorder
post /:id/reorder (PathId) returns (CreateOrderResp)
}
@doc "再来一单"
@handler Reorder
post /:id/reorder (PathId) returns (CreateOrderResp)
}
-12
View File
@@ -12,11 +12,8 @@ package pb;
message Orders {
int64 id = 1; //id
int64 consumerId = 2; //consumerId
string consumerName = 3; //consumerName
int64 playerId = 4; //playerId
string playerName = 5; //playerName
optional int64 shopId = 6; //shopId
optional string shopName = 7; //shopName
string serviceSnapshot = 8; //serviceSnapshot
string status = 9; //status
string totalPrice = 10; //totalPrice
@@ -35,11 +32,8 @@ message Orders {
message AddOrdersReq {
int64 id = 1; //id
int64 consumerId = 2; //consumerId
string consumerName = 3; //consumerName
int64 playerId = 4; //playerId
string playerName = 5; //playerName
optional int64 shopId = 6; //shopId
optional string shopName = 7; //shopName
string serviceSnapshot = 8; //serviceSnapshot
optional string status = 9; //status
string totalPrice = 10; //totalPrice
@@ -62,11 +56,8 @@ message AddOrdersResp {
message UpdateOrdersReq {
int64 id = 1; //id
optional int64 consumerId = 2; //consumerId
optional string consumerName = 3; //consumerName
optional int64 playerId = 4; //playerId
optional string playerName = 5; //playerName
optional int64 shopId = 6; //shopId
optional string shopName = 7; //shopName
optional string serviceSnapshot = 8; //serviceSnapshot
optional string status = 9; //status
optional string totalPrice = 10; //totalPrice
@@ -105,11 +96,8 @@ message SearchOrdersReq {
int64 limit = 2; //limit
optional int64 id = 3; //id
optional int64 consumerId = 4; //consumerId
optional string consumerName = 5; //consumerName
optional int64 playerId = 6; //playerId
optional string playerName = 7; //playerName
optional int64 shopId = 8; //shopId
optional string shopName = 9; //shopName
optional string serviceSnapshot = 10; //serviceSnapshot
optional string status = 11; //status
optional string totalPrice = 12; //totalPrice