update coupon service proto

This commit is contained in:
daniel.w 2024-10-25 18:11:50 +08:00
parent 25b422b907
commit a575e4fc42
1 changed files with 132 additions and 30 deletions

View File

@ -301,7 +301,7 @@ message ProductCreateReq {
repeated string tags = 9; // 產品標籤(方便篩選) repeated string tags = 9; // 產品標籤(方便篩選)
string sku = 10; // 庫存單位(Stock Keeping Unit) string sku = 10; // 庫存單位(Stock Keeping Unit)
repeated string images = 11; // 商品照片網址 repeated string images = 11; // 商品照片網址
optional string coupon_id = 12; // 本商品專屬折扣碼 id repeated string coupon_id = 12; // 本商品專屬折扣碼 id
} }
message ProductUpdateReq { message ProductUpdateReq {
@ -317,7 +317,7 @@ message ProductUpdateReq {
repeated string tags = 10; // 產品標籤(方便篩選) repeated string tags = 10; // 產品標籤(方便篩選)
optional string sku = 11; // 庫存單位(Stock Keeping Unit) optional string sku = 11; // 庫存單位(Stock Keeping Unit)
repeated string images = 12; // 商品照片網址 repeated string images = 12; // 商品照片網址
optional string coupon_id = 13; // 本商品專屬折扣碼 id repeated string coupon_id = 13; // 本商品專屬折扣碼 id
optional bool is_available = 14; // 是否上架 optional bool is_available = 14; // 是否上架
} }
@ -336,13 +336,13 @@ message ProductResp {
string content = 4; // 詳細商品內容 string content = 4; // 詳細商品內容
double price = 5; // 商品價格 double price = 5; // 商品價格
int64 amount_type = 6; // 1 有限數量 2 無限數量 int64 amount_type = 6; // 1 有限數量 2 無限數量
repeated string currency = 7; // 貨幣類型 (如 USD, TWD) string currency = 7; // 貨幣類型 (如 USD, TWD)
repeated string brand = 8; // 產品品牌,可以看成channel_id or uid 就是誰得商品,用品牌比較通用 repeated string brand = 8; // 產品品牌,可以看成channel_id or uid 就是誰得商品,用品牌比較通用
string category = 9; // 商品分類 repeated string category = 9; // 商品分類
repeated string tags = 10; // 產品標籤(方便篩選) repeated string tags = 10; // 產品標籤(方便篩選)
string sku = 11; // 庫存單位(Stock Keeping Unit) string sku = 11; // 庫存單位(Stock Keeping Unit)
repeated string images = 12; // 商品照片網址 repeated string images = 12; // 商品照片網址
string coupon_id = 13; // 本商品專屬折扣碼 id repeated string coupon_id = 13; // 本商品專屬折扣碼 id
bool is_available = 14; // 是否上架 bool is_available = 14; // 是否上架
} }
@ -379,16 +379,22 @@ service ProductService {
// ========== 訂閱服務 =========== // ========== 訂閱服務 ===========
// 訂閱請求和回應訊息 // 訂閱請求和回應訊息 (訂閱的話,在結束時間結束前,不能再次訂閱,但取消之後可以再次訂閱)
message SubscriptionCreateReq { message SubscriptionCreateReq {
string user_id = 1; // 使用者ID string uid = 1; // 使用者ID
string plan_id = 2; // 訂閱方案ID string plan_id = 2; // 訂閱方案ID
string start_date = 3; // 訂閱開始日期 bool auto_renew = 3; // 是否自動續訂
optional int64 auto_renew_day = 4; // 自動續訂多久
int64 start_date = 5; // 訂閱開始日期
int64 end_date = 6; // 訂閱結束時間
} }
message SubscriptionUpdateReq { message SubscriptionUpdateReq {
string subscription_id = 1; // 訂閱ID string subscription_id = 1; // 訂閱ID
string plan_id = 2; // 訂閱方案ID optional int64 end_date = 2; // 訂閱結束時間(延長要訂閱的時間)
optional bool cancel = 3; // 是否取消訂閱
optional bool auto_renew = 4; // 是否自動續訂
optional int64 auto_renew_day = 5; // 自動續訂多久
} }
message SubscriptionCancelReq { message SubscriptionCancelReq {
@ -401,17 +407,22 @@ message SubscriptionQueryReq {
message SubscriptionResp { message SubscriptionResp {
string subscription_id = 1; // 訂閱ID string subscription_id = 1; // 訂閱ID
string user_id = 2; // 使用者ID string uid = 2; // 使用者ID
string plan_id = 3; // 訂閱方案ID string plan_id = 3; // 訂閱方案ID
string start_date = 4; // 訂閱開始日期 int64 start_date = 4; // 訂閱開始日期
string end_date = 5; // 訂閱結束日期 int64 end_date = 5; // 訂閱結束日期
string status = 6; // 訂閱狀態 (例如: "active", "expired", "canceled") int64 status = 6; // 訂閱狀態 (例如: 1"active", 2"expired", 3"canceled")
bool auto_renew = 7; // 是否自動續訂
int64 auto_renew_day = 8; // 自動續訂多久
} }
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;
repeated string subscription_id = 4;
repeated string plan_id = 5;
int64 status = 6; // 訂閱狀態 (例如: 1"active", 2"expired", 3"canceled")
} }
message SubscriptionListResp { message SubscriptionListResp {
@ -421,7 +432,7 @@ message SubscriptionListResp {
message SubscriptionRenewReq { message SubscriptionRenewReq {
string subscription_id = 1; // 訂閱ID string subscription_id = 1; // 訂閱ID
string renewal_date = 2; // 續訂日期 int64 renewal_date = 2; // 續訂日期
} }
message SubscriptionStatusQueryReq { message SubscriptionStatusQueryReq {
@ -430,8 +441,7 @@ message SubscriptionStatusQueryReq {
message SubscriptionStatusResp { message SubscriptionStatusResp {
string subscription_id = 1; // 訂閱ID string subscription_id = 1; // 訂閱ID
string status = 2; // 訂閱狀態 int64 status = 2; // 訂閱狀態 (例如: 1"active", 2"expired", 3"canceled")
string message = 3; // 狀態訊息
} }
service SubscriptionService { service SubscriptionService {
@ -449,6 +459,98 @@ service SubscriptionService {
rpc RenewSubscription(SubscriptionRenewReq) returns (SubscriptionResp); rpc RenewSubscription(SubscriptionRenewReq) returns (SubscriptionResp);
// CheckSubscriptionStatus 查詢訂閱狀態 (啟用/過期/取消) // CheckSubscriptionStatus 查詢訂閱狀態 (啟用/過期/取消)
rpc CheckSubscriptionStatus(SubscriptionStatusQueryReq) returns (SubscriptionStatusResp); rpc CheckSubscriptionStatus(SubscriptionStatusQueryReq) returns (SubscriptionStatusResp);
// RefreshSubscriptionStatus cron 改變訂閱的狀態(時間到了要過期),每 5 分鐘執行一次 // RefreshSubscriptionStatus cron 改變訂閱的狀態(時間到了要過期,需要續約自動續約),每 5 分鐘執行一次
rpc RefreshSubscriptionStatus(NoneReq) returns (OKResp); rpc RefreshSubscriptionStatus(NoneReq) returns (OKResp);
} }
// ========== 優惠券服務 ===========
message Coupon {
string coupon_id = 1; // 優惠券唯一識別碼
string code = 2; // 優惠碼
double discount = 3; // 折扣 (可以是百分比或固定金額)
string discount_type = 4; // 折扣類型 ("percent" 或 "fixed")
string start_date = 5; // 優惠券生效日期 (格式: YYYY-MM-DD)
string end_date = 6; // 優惠券結束日期 (格式: YYYY-MM-DD)
int32 usage_limit = 7; // 使用次數限制
int32 used_count = 8; // 已使用次數
string status = 9; // 優惠券狀態 ("active", "expired", "inactive")
repeated string applicable_product_ids = 10; // 可以使用此優惠券的產品ID列表
bool is_common = 11; // 是否通用
}
message CreateCouponReq {
string code = 1; // 優惠碼
double discount = 2; // 折扣金額或百分比
string discount_type = 3; // 折扣類型 ("percent" 或 "fixed")
int64 start_date = 4; // 生效日期 (格式: YYYY-MM-DD)
int64 end_date = 5; // 結束日期 (格式: YYYY-MM-DD)
int64 usage_limit = 6; // 使用次數限制
bool is_common = 7; // 是否通用
repeated string applicable_product_ids = 8; // 適用的產品ID列表
}
message UpdateCouponReq {
string coupon_id = 1; // 優惠券ID
string code = 2; // 優惠碼
double discount = 3; // 折扣金額或百分比
string discount_type = 4; // 折扣類型 ("percent" 或 "fixed")
int64 start_date = 5; // 生效日期
int64 end_date = 6; // 結束日期
int64 usage_limit = 7; // 使用次數限制
repeated string applicable_product_ids = 8; // 適用的產品ID列表
optional bool is_common = 9; // 是否通用
}
message CouponQueryReq {
string coupon_id = 1; // 優惠券ID
}
message CouponResp {
Coupon coupon = 1; // 優惠券詳情
}
message CouponListReq {
int64 page_index = 1;
int64 page_size = 2;
repeated string coupon_id = 3;
repeated string code = 4;
int64 start_date = 5; // 生效日期
int64 end_date = 6; // 結束日期
repeated string applicable_product_ids = 7; // 適用的產品ID列表
bool is_use_able = 8; // 是否是還可用的
}
message CouponListResp {
repeated Coupon coupons = 1; // 優惠券列表
Pager page = 2;
}
message ValidateCouponReq {
string product_id = 1; // 使用優惠券的產品ID
double order_amount = 2; // 訂單金額
optional string code = 3; // 優惠碼
optional string coupon_id = 4;
}
message CouponValidationResp {
bool is_valid = 1; // 是否有效
string message = 2; // 驗證結果訊息 (如無效的原因或有效的提示)
double discount_applied = 3; // 允許的折扣金額
string coupon_id = 4; // 驗證成功的優惠券ID
}
service CouponService {
// CreateCoupon 創建優惠券
rpc CreateCoupon(CreateCouponReq) returns (CouponResp);
// UpdateCoupon更新優惠券
rpc UpdateCoupon(UpdateCouponReq) returns (CouponResp);
// QueryCoupon查詢優惠券
rpc QueryCoupon(CouponQueryReq) returns (CouponResp);
// DeleteCoupon 刪除優惠券
rpc DeleteCoupon(CouponQueryReq) returns (OKResp);
// ListCoupons列出所有優惠券
rpc ListCoupons(CouponListReq) returns (CouponListResp);
// ValidateCoupon 驗證優惠券 (在下單或支付時使用)
rpc ValidateCoupon(ValidateCouponReq) returns (CouponValidationResp);
}