update product service proto

This commit is contained in:
daniel.w 2024-10-25 16:21:12 +08:00
parent e01d14ab90
commit 25b422b907
1 changed files with 130 additions and 105 deletions

View File

@ -112,13 +112,13 @@ message GetOrderResp {
optional string chain_fee_crypto = 32; // 鏈上手續費使用幣別 optional string chain_fee_crypto = 32; // 鏈上手續費使用幣別
optional string memo = 33; // 鏈上備註 optional string memo = 33; // 鏈上備註
optional string order_note = 34; // 訂單交易備註 optional string order_note = 34; // 訂單交易備註
int64 create_time = 35; // 建立時間 int64 create_time = 35; // 建立時間
int64 update_time = 36; // 更新時間 int64 update_time = 36; // 更新時間
} }
message ListOrderReq { message ListOrderReq {
int64 page_index = 1; // required int64 page_index = 1; // required
int64 page_size = 2; // required int64 page_size = 2; // required
string reference_id = 3; string reference_id = 3;
string reference_uid = 4; string reference_uid = 4;
@ -142,7 +142,7 @@ message ListOrderReq {
} }
message ListOrderResp { message ListOrderResp {
repeated GetOrderResp data = 1; // 訂單列表 repeated GetOrderResp data = 1; // 訂單列表
Pager page = 2; Pager page = 2;
} }
@ -165,42 +165,42 @@ service OrderService {
} }
// ========== 錢包服務 =========== // ========== 錢包服務 ===========
message CreateWalletReq{ message CreateWalletReq {
repeated WalletItem item =1; repeated WalletItem item = 1;
} }
message WalletItem { message WalletItem {
string source = 1; // 錢包來源 string source = 1; // 錢包來源
string uid = 2; // 錢包擁有者的 UID string uid = 2; // 錢包擁有者的 UID
string currency_type = 3; // 幣別 string currency_type = 3; // 幣別
string current_balance = 4; // 當前餘額 string current_balance = 4; // 當前餘額
int64 wallet_type = 5; // 錢包金額種類 1. 可用餘額 2. 凍結餘額 3. 限制餘額 int64 wallet_type = 5; // 錢包金額種類 1. 可用餘額 2. 凍結餘額 3. 限制餘額
} }
message WalletTransactionReq{ message WalletTransactionReq {
string uid =1; // 錢包擁有者的 UID string uid = 1; // 錢包擁有者的 UID
optional string order_id =2; // 訂單編號 optional string order_id = 2; // 訂單編號
optional string business_type =3; // 業務種類 optional string business_type = 3; // 業務種類
optional string currency_type = 4; // 幣別 optional string currency_type = 4; // 幣別
optional string amount = 5; // 轉帳金額 optional string amount = 5; // 轉帳金額
optional int64 wallet_type = 6;// 操作金額種類 optional int64 wallet_type = 6; // 操作金額種類
} }
message QueryBalanceByDateReq{ message QueryBalanceByDateReq {
string uid =1; // 錢包擁有者的 UID string uid = 1; // 錢包擁有者的 UID
string currency_type = 2; // 幣別 string currency_type = 2; // 幣別
} }
message QueryBalanceByDateResp { message QueryBalanceByDateResp {
string currency_type = 1; // 幣別 string currency_type = 1; // 幣別
string available = 2; // 可用餘額 string available = 2; // 可用餘額
UnavailableBalance unavailable = 3; // 不可用餘額 UnavailableBalance unavailable = 3; // 不可用餘額
int64 update_time=4; int64 update_time = 4;
} }
message UnavailableBalance{ message UnavailableBalance {
string freeze = 1; // 凍結餘額 string freeze = 1; // 凍結餘額
string unconfirmed = 2; // 限制餘額 string unconfirmed = 2; // 限制餘額
} }
// TODO 未來會新增查詢以及同步的功能 // TODO 未來會新增查詢以及同步的功能
@ -233,36 +233,43 @@ service WalletService {
// ========== 庫存服務 =========== // ========== 庫存服務 ===========
message StockAdjustmentReq { message StockAdjustmentReq {
string product_id = 1; // 商品ID string product_id = 1; // 商品ID
int64 quantity = 2; // 調整的數量 (正數表示增加,負數表示減少) int64 quantity = 2; // 調整的數量 (正數表示增加,負數表示減少)
} }
message StockQueryReq { message StockQueryReq {
string product_id = 1; // 商品ID string product_id = 1; // 商品ID
} }
message StockResp { message StockResp {
string product_id = 1; // 商品ID string product_id = 1; // 商品ID
int64 available_quantity = 2; // 可用庫存 int64 available_quantity = 2; // 可用庫存
int64 reserved_quantity = 3; // 預留庫存 int64 reserved_quantity = 3; // 預留庫存
}
message StockListReq {
int64 page_index = 1; // required
int64 page_size = 2; // required
repeated string product_id = 3; // 一次查多筆
} }
message StockListResp { message StockListResp {
repeated StockResp stock_items = 1; // 所有商品的庫存清單 repeated StockResp stock_items = 1; // 所有商品的庫存清單
Pager page =2; Pager page = 2;
} }
message StockReservationReq { message StockReservationReq {
string product_id = 1; // 商品ID string product_id = 1; // 商品ID
int64 quantity = 2; // 預留的數量 int64 quantity = 2; // 預留的數量
} }
message BatchStockAdjustmentReq { message BatchStockAdjustmentReq {
repeated StockAdjustmentReq adjustments = 1; // 批次調整庫存 repeated StockAdjustmentReq adjustments = 1; // 批次調整庫存
} }
service InventoryService { service InventoryService {
// CreateStock 建立庫存品項
rpc CreateStock(StockAdjustmentReq) returns (OKResp);
// AddStock 增加庫存 // AddStock 增加庫存
rpc AddStock(StockAdjustmentReq) returns (OKResp); rpc AddStock(StockAdjustmentReq) returns (OKResp);
// ReduceStock 減少庫存 // ReduceStock 減少庫存
@ -270,7 +277,7 @@ service InventoryService {
// QueryStock 查詢單一商品的庫存 // QueryStock 查詢單一商品的庫存
rpc QueryStock(StockQueryReq) returns (StockResp); rpc QueryStock(StockQueryReq) returns (StockResp);
// ListAllStock 查詢所有商品的庫存狀況 // ListAllStock 查詢所有商品的庫存狀況
rpc ListAllStock(NoneReq) returns (StockListResp); rpc ListAllStock(StockListReq) returns (StockListResp);
// ReserveStock 預留庫存 (用於未完成的訂單) // ReserveStock 預留庫存 (用於未完成的訂單)
rpc ReserveStock(StockReservationReq) returns (OKResp); rpc ReserveStock(StockReservationReq) returns (OKResp);
// ReleaseReservedStock 釋放預留庫存 (取消或失效的訂單) // ReleaseReservedStock 釋放預留庫存 (取消或失效的訂單)
@ -283,53 +290,78 @@ service InventoryService {
// 商品請求和回應訊息 // 商品請求和回應訊息
message ProductCreateReq { message ProductCreateReq {
string name = 1; // 商品名稱 string name = 1; // 商品名稱
string category = 2; // 商品分類 string description = 2; // 商品簡述
string description = 3; // 商品描述 string content = 3; // 詳細商品內容
double price = 4; // 商品價格 double price = 4; // 商品價格
int64 amount_type = 5; // 1 有限數量 2 無限數量
string currency = 6; // 貨幣類型 (如 USD, TWD)
repeated string brand = 7; // 產品品牌,可以看成channel_id or uid 就是誰得商品,用品牌比較通用
repeated string category = 8; // 商品分類
repeated string tags = 9; // 產品標籤(方便篩選)
string sku = 10; // 庫存單位(Stock Keeping Unit)
repeated string images = 11; // 商品照片網址
optional string coupon_id = 12; // 本商品專屬折扣碼 id
} }
message ProductUpdateReq { message ProductUpdateReq {
string product_id = 1; // 商品ID string product_id = 1; // 商品ID
string name = 2; // 商品名稱 optional string name = 2; // 商品名稱
string category = 3; // 商品分類 optional string description = 3; // 商品簡述
string description = 4; // 商品描述 optional string content = 4; // 詳細商品內容
double price = 5; // 商品價格 optional double price = 5; // 商品價格
optional int64 amount_type = 6; // 1 有限數量 2 無限數量
optional string currency = 7; // 貨幣類型 (如 USD, TWD)
repeated string brand = 8; // 產品品牌,可以看成channel_id or uid 就是誰得商品,用品牌比較通用
repeated string category = 9; // 商品分類
repeated string tags = 10; // 產品標籤(方便篩選)
optional string sku = 11; // 庫存單位(Stock Keeping Unit)
repeated string images = 12; // 商品照片網址
optional string coupon_id = 13; // 本商品專屬折扣碼 id
optional bool is_available = 14; // 是否上架
} }
message ProductDeleteReq { message ProductDeleteReq {
string product_id = 1; // 商品ID string product_id = 1; // 商品ID
} }
message ProductQueryReq { message ProductQueryReq {
string product_id = 1; // 商品ID string product_id = 1; // 商品ID
} }
message ProductResp { message ProductResp {
string product_id = 1; // 商品ID string product_id = 1; // 商品ID
string name = 2; // 商品名稱 string name = 2; // 商品名稱
string category = 3; // 商品分類 string description = 3; // 商品簡述
string description = 4; // 商品描述 string content = 4; // 詳細商品內容
double price = 5; // 商品價格 double price = 5; // 商品價格
bool is_available = 6; // 是否上架 int64 amount_type = 6; // 1 有限數量 2 無限數量
repeated string currency = 7; // 貨幣類型 (如 USD, TWD)
repeated string brand = 8; // 產品品牌,可以看成channel_id or uid 就是誰得商品,用品牌比較通用
string category = 9; // 商品分類
repeated string tags = 10; // 產品標籤(方便篩選)
string sku = 11; // 庫存單位(Stock Keeping Unit)
repeated string images = 12; // 商品照片網址
string coupon_id = 13; // 本商品專屬折扣碼 id
bool is_available = 14; // 是否上架
}
message ProductListReq {
int64 page_index = 1;
int64 page_size = 2;
repeated string product_id = 3; // 商品ID
optional bool is_available = 4; // 是否上架
repeated string tags = 5; // 產品標籤(方便篩選)
optional int64 amount_type = 6; // 1 有限數量 2 無限數量
repeated string currency = 7; // 貨幣類型 (如 USD, TWD)
repeated string brand = 8; // 產品品牌,可以看成channel_id or uid 就是誰得商品,用品牌比較通用
repeated string category = 9; // 商品分類
} }
message ProductListResp { message ProductListResp {
repeated ProductResp products = 1; // 所有商品清單 repeated ProductResp products = 1; // 所有商品清單
} Pager page = 2;
message CategoryQueryReq {
string category = 1; // 商品分類
}
message ProductPriceUpdateReq {
string product_id = 1; // 商品ID
double new_price = 2; // 新價格
}
message ProductStatusUpdateReq {
string product_id = 1; // 商品ID
bool is_available = 2; // 是否上架
} }
service ProductService { service ProductService {
@ -342,71 +374,64 @@ service ProductService {
// QueryProduct 查詢單一商品資訊 // QueryProduct 查詢單一商品資訊
rpc QueryProduct(ProductQueryReq) returns (ProductResp); rpc QueryProduct(ProductQueryReq) returns (ProductResp);
// ListAllProducts 查詢所有商品資訊 // ListAllProducts 查詢所有商品資訊
rpc ListAllProducts(NoneReq) returns (ProductListResp); rpc ListAllProducts(ProductListReq) returns (ProductListResp);
// ListProductsByCategory 根據分類查詢商品
rpc ListProductsByCategory(CategoryQueryReq) returns (ProductListResp);
// UpdateProductPrice 更新商品價格
rpc UpdateProductPrice(ProductPriceUpdateReq) returns (OKResp);
// UpdateProductStatus 更新商品狀態 (上架/下架)
rpc UpdateProductStatus(ProductStatusUpdateReq) returns (OKResp);
} }
// ========== 訂閱服務 =========== // ========== 訂閱服務 ===========
// 訂閱請求和回應訊息 // 訂閱請求和回應訊息
message SubscriptionCreateReq { message SubscriptionCreateReq {
string user_id = 1; // 使用者ID string user_id = 1; // 使用者ID
string plan_id = 2; // 訂閱方案ID string plan_id = 2; // 訂閱方案ID
string start_date = 3; // 訂閱開始日期 string start_date = 3; // 訂閱開始日期
} }
message SubscriptionUpdateReq { message SubscriptionUpdateReq {
string subscription_id = 1; // 訂閱ID string subscription_id = 1; // 訂閱ID
string plan_id = 2; // 訂閱方案ID string plan_id = 2; // 訂閱方案ID
} }
message SubscriptionCancelReq { message SubscriptionCancelReq {
string subscription_id = 1; // 訂閱ID string subscription_id = 1; // 訂閱ID
} }
message SubscriptionQueryReq { message SubscriptionQueryReq {
string subscription_id = 1; // 訂閱ID string subscription_id = 1; // 訂閱ID
} }
message SubscriptionResp { message SubscriptionResp {
string subscription_id = 1; // 訂閱ID string subscription_id = 1; // 訂閱ID
string user_id = 2; // 使用者ID string user_id = 2; // 使用者ID
string plan_id = 3; // 訂閱方案ID string plan_id = 3; // 訂閱方案ID
string start_date = 4; // 訂閱開始日期 string start_date = 4; // 訂閱開始日期
string end_date = 5; // 訂閱結束日期 string end_date = 5; // 訂閱結束日期
string status = 6; // 訂閱狀態 (例如: "active", "expired", "canceled") string status = 6; // 訂閱狀態 (例如: "active", "expired", "canceled")
} }
message ListSubscriptionsReq { message ListSubscriptionsReq {
int64 page_index=1; int64 page_index = 1;
int64 page_size=2; int64 page_size = 2;
optional string uid=3; optional string uid = 3;
} }
message SubscriptionListResp { message SubscriptionListResp {
repeated SubscriptionResp subscriptions = 1; // 訂閱清單 repeated SubscriptionResp subscriptions = 1; // 訂閱清單
Pager page = 2; Pager page = 2;
} }
message SubscriptionRenewReq { message SubscriptionRenewReq {
string subscription_id = 1; // 訂閱ID string subscription_id = 1; // 訂閱ID
string renewal_date = 2; // 續訂日期 string renewal_date = 2; // 續訂日期
} }
message SubscriptionStatusQueryReq { message SubscriptionStatusQueryReq {
string subscription_id = 1; // 訂閱ID string subscription_id = 1; // 訂閱ID
} }
message SubscriptionStatusResp { message SubscriptionStatusResp {
string subscription_id = 1; // 訂閱ID string subscription_id = 1; // 訂閱ID
string status = 2; // 訂閱狀態 string status = 2; // 訂閱狀態
string message = 3; // 狀態訊息 string message = 3; // 狀態訊息
} }
service SubscriptionService { service SubscriptionService {