diff --git a/generate/protobuf/trade.proto b/generate/protobuf/trade.proto index 7f90723..473009f 100644 --- a/generate/protobuf/trade.proto +++ b/generate/protobuf/trade.proto @@ -203,6 +203,8 @@ message UnavailableBalance{ string unconfirmed = 2; // 限制餘額 } +// TODO 未來會新增查詢以及同步的功能 + service WalletService { // CreateWallet 建立錢包 rpc CreateWallet(CreateWalletReq) returns (OKResp); @@ -228,14 +230,122 @@ service WalletService { rpc QueryBalance(QueryBalanceByDateReq) returns (QueryBalanceByDateResp); } - - // 餘額查詢-> 依照日期 - // 查詢目前所擁有的資產 - // 依照日期查詢提現金額 - // ========== 庫存服務 =========== -service InventoryService {} + +message StockAdjustmentReq { + string product_id = 1; // 商品ID + int64 quantity = 2; // 調整的數量 (正數表示增加,負數表示減少) +} + +message StockQueryReq { + string product_id = 1; // 商品ID +} + +message StockResp { + string product_id = 1; // 商品ID + int64 available_quantity = 2; // 可用庫存 + int64 reserved_quantity = 3; // 預留庫存 +} + +message StockListResp { + repeated StockResp stock_items = 1; // 所有商品的庫存清單 + Pager page =2; +} + +message StockReservationReq { + string product_id = 1; // 商品ID + int64 quantity = 2; // 預留的數量 +} + +message BatchStockAdjustmentReq { + repeated StockAdjustmentReq adjustments = 1; // 批次調整庫存 +} + + +service InventoryService { + // AddStock 增加庫存 + rpc AddStock(StockAdjustmentReq) returns (OKResp); + // ReduceStock 減少庫存 + rpc ReduceStock(StockAdjustmentReq) returns (OKResp); + // QueryStock 查詢單一商品的庫存 + rpc QueryStock(StockQueryReq) returns (StockResp); + // ListAllStock 查詢所有商品的庫存狀況 + rpc ListAllStock(NoneReq) returns (StockListResp); + // ReserveStock 預留庫存 (用於未完成的訂單) + rpc ReserveStock(StockReservationReq) returns (OKResp); + // ReleaseReservedStock 釋放預留庫存 (取消或失效的訂單) + rpc ReleaseReservedStock(StockReservationReq) returns (OKResp); + // AdjustStock 調整庫存 (批量修改庫存,用於大批商品更新) + rpc AdjustStock(BatchStockAdjustmentReq) returns (OKResp); +} + // ========== 商品服務 =========== service ProductService {} // ========== 訂閱服務 =========== -service SubscriptionService {} \ No newline at end of file + +// 訂閱請求和回應訊息 +message SubscriptionCreateReq { + string user_id = 1; // 使用者ID + string plan_id = 2; // 訂閱方案ID + string start_date = 3; // 訂閱開始日期 +} + +message SubscriptionUpdateReq { + string subscription_id = 1; // 訂閱ID + string plan_id = 2; // 訂閱方案ID +} + +message SubscriptionCancelReq { + string subscription_id = 1; // 訂閱ID +} + +message SubscriptionQueryReq { + string subscription_id = 1; // 訂閱ID +} + +message SubscriptionResp { + string subscription_id = 1; // 訂閱ID + string user_id = 2; // 使用者ID + string plan_id = 3; // 訂閱方案ID + string start_date = 4; // 訂閱開始日期 + string end_date = 5; // 訂閱結束日期 + string status = 6; // 訂閱狀態 (例如: "active", "expired", "canceled") +} + +message SubscriptionListResp { + repeated SubscriptionResp subscriptions = 1; // 訂閱清單 +} + +message SubscriptionRenewReq { + string subscription_id = 1; // 訂閱ID + string renewal_date = 2; // 續訂日期 +} + +message SubscriptionStatusQueryReq { + string subscription_id = 1; // 訂閱ID +} + +message SubscriptionStatusResp { + string subscription_id = 1; // 訂閱ID + string status = 2; // 訂閱狀態 + string message = 3; // 狀態訊息 +} + +service SubscriptionService { + // CreateSubscription 建立訂閱 + rpc CreateSubscription(SubscriptionCreateReq) returns (SubscriptionResp); + // UpdateSubscription 更新訂閱設定 + rpc UpdateSubscription(SubscriptionUpdateReq) returns (SubscriptionResp); + // CancelSubscription 取消訂閱 + rpc CancelSubscription(SubscriptionCancelReq) returns (OKResp); + // QuerySubscription 查詢單一訂閱資訊 + rpc QuerySubscription(SubscriptionQueryReq) returns (SubscriptionResp); + // ListSubscriptions 查詢所有訂閱 (用於管理和監控) + rpc ListSubscriptions(NoneReq) returns (SubscriptionListResp); + // RenewSubscription 續訂訂閱 + rpc RenewSubscription(SubscriptionRenewReq) returns (SubscriptionResp); + // CheckSubscriptionStatus 查詢訂閱狀態 (啟用/過期/取消) + rpc CheckSubscriptionStatus(SubscriptionStatusQueryReq) returns (SubscriptionStatusResp); + // RefreshSubscriptionStatus cron 改變訂閱的狀態(時間到了要過期),每 5 分鐘執行一次 + rpc RefreshSubscriptionStatus(NoneReq) returns (OKResp); +} \ No newline at end of file