hyapp-server/api/proto/wallet/v1/wallet.proto
2026-05-29 19:56:14 +08:00

1453 lines
38 KiB
Protocol Buffer
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

syntax = "proto3";
package hyapp.wallet.v1;
option go_package = "hyapp.local/api/proto/wallet/v1;walletv1";
// DebitGiftRequest 是 room-service 送礼同步扣费的最小账务输入。
message DebitGiftRequest {
string command_id = 1;
string room_id = 2;
int64 sender_user_id = 3;
int64 target_user_id = 4;
string gift_id = 5;
int32 gift_count = 6;
// price_version 为空时使用当前生效价格;非空时必须命中 active 价格版本。
string price_version = 7;
string app_code = 8;
// region_id 来自 room-service 房间 visible_region_id用于校验礼物区域可用性。
int64 region_id = 9;
// target_is_host 由 gateway 根据 user-service active host profile 注入,客户端不能直接声明。
bool target_is_host = 10;
// target_host_region_id 是主播身份所属区域,用于后续按主播区域匹配工资政策。
int64 target_host_region_id = 11;
// target_agency_owner_user_id 是送礼时主播归属 Agency 的 owner用于后续代理工资结算。
int64 target_agency_owner_user_id = 12;
}
// DebitGiftResponse 返回扣费流水、服务端结算值和 sender COIN 账后余额。
message DebitGiftResponse {
string billing_receipt_id = 1;
string transaction_id = 2;
int64 coin_spent = 3;
int64 gift_point_added = 4;
int64 heat_value = 5;
string price_version = 6;
// balance_after 是 sender 被扣费资产 available_amount 账后余额。
int64 balance_after = 7;
string charge_asset_type = 8;
int64 charge_amount = 9;
string gift_type_code = 10;
// host_period_diamond_added 是本次送礼给主播周期钻石账户增加的钻石;非主播为 0。
int64 host_period_diamond_added = 11;
// host_period_cycle_key 是 UTC 月周期,例如 2026-05非主播为空。
string host_period_cycle_key = 12;
}
// AssetBalance 是用户某类资产的余额投影。
message AssetBalance {
string asset_type = 1;
int64 available_amount = 2;
int64 frozen_amount = 3;
int64 version = 4;
string app_code = 5;
}
// GetBalancesRequest 查询用户多资产余额;内部调用方负责鉴权和用户范围控制。
message GetBalancesRequest {
string request_id = 1;
int64 user_id = 2;
repeated string asset_types = 3;
string app_code = 4;
}
message GetBalancesResponse {
repeated AssetBalance balances = 1;
}
// AdminCreditAssetRequest 是后台手动入账/调账的最小审计命令。
message AdminCreditAssetRequest {
string command_id = 1;
int64 target_user_id = 2;
string asset_type = 3;
int64 amount = 4;
int64 operator_user_id = 5;
string reason = 6;
string evidence_ref = 7;
string app_code = 8;
}
message AdminCreditAssetResponse {
string transaction_id = 1;
AssetBalance balance = 2;
}
// AdminCreditCoinSellerStockRequest 是后台给 active 币商专用库存入账的账务命令。
message AdminCreditCoinSellerStockRequest {
string command_id = 1;
int64 seller_user_id = 2;
string stock_type = 3;
int64 coin_amount = 4;
string paid_currency_code = 5;
int64 paid_amount_micro = 6;
string payment_ref = 7;
string evidence_ref = 8;
int64 operator_user_id = 9;
string reason = 10;
string app_code = 11;
}
message AdminCreditCoinSellerStockResponse {
string transaction_id = 1;
int64 seller_user_id = 2;
string stock_type = 3;
int64 coin_amount = 4;
string paid_currency_code = 5;
int64 paid_amount_micro = 6;
bool counts_as_seller_recharge = 7;
int64 balance_after = 8;
int64 created_at_ms = 9;
}
// TransferCoinFromSellerRequest 是币商给玩家转普通金币的内部账务命令。
message TransferCoinFromSellerRequest {
string command_id = 1;
int64 seller_user_id = 2;
int64 target_user_id = 3;
int64 amount = 4;
string reason = 5;
string app_code = 6;
// seller_region_id 和 target_region_id 由 gateway 从 user-service 查询,不接受客户端提交。
int64 seller_region_id = 7;
int64 target_region_id = 8;
}
// TransferCoinFromSellerResponse 同时返回金币到账结果和本次转账对应的充值金额口径。
message TransferCoinFromSellerResponse {
string transaction_id = 1;
int64 seller_balance_after = 2;
int64 target_balance_after = 3;
int64 amount = 4;
int64 recharge_usd_minor = 5;
string recharge_currency_code = 6;
int64 recharge_policy_id = 7;
string recharge_policy_version = 8;
int64 recharge_policy_coin_amount = 9;
int64 recharge_policy_usd_minor_amount = 10;
}
// Resource 是资源库里可配置、可赠送、可被礼物引用的最小资源。
message Resource {
string app_code = 1;
int64 resource_id = 2;
string resource_code = 3;
string resource_type = 4;
string name = 5;
string status = 6;
bool grantable = 7;
string grant_strategy = 8;
string wallet_asset_type = 9;
int64 wallet_asset_amount = 10;
repeated string usage_scopes = 11;
string asset_url = 12;
string preview_url = 13;
string animation_url = 14;
string metadata_json = 15;
int32 sort_order = 16;
int64 created_by_user_id = 17;
int64 updated_by_user_id = 18;
int64 created_at_ms = 19;
int64 updated_at_ms = 20;
bool manager_grant_enabled = 21;
string price_type = 22;
int64 coin_price = 23;
int64 gift_point_amount = 24;
}
message ResourceGroupItem {
int64 group_item_id = 1;
int64 group_id = 2;
int64 resource_id = 3;
Resource resource = 4;
int64 quantity = 5;
int64 duration_ms = 6;
int32 sort_order = 7;
int64 created_at_ms = 8;
int64 updated_at_ms = 9;
string item_type = 10;
string wallet_asset_type = 11;
int64 wallet_asset_amount = 12;
}
message ResourceGroup {
string app_code = 1;
int64 group_id = 2;
string group_code = 3;
string name = 4;
string status = 5;
string description = 6;
int32 sort_order = 7;
repeated ResourceGroupItem items = 8;
int64 created_by_user_id = 9;
int64 updated_by_user_id = 10;
int64 created_at_ms = 11;
int64 updated_at_ms = 12;
}
message GiftConfig {
string app_code = 1;
string gift_id = 2;
int64 resource_id = 3;
Resource resource = 4;
string status = 5;
string name = 6;
int32 sort_order = 7;
string presentation_json = 8;
string price_version = 9;
int64 coin_price = 10;
int64 gift_point_amount = 11;
int64 heat_value = 12;
int64 created_by_user_id = 13;
int64 updated_by_user_id = 14;
int64 created_at_ms = 15;
int64 updated_at_ms = 16;
repeated int64 region_ids = 17;
string gift_type_code = 18;
string charge_asset_type = 19;
int64 effective_from_ms = 20;
int64 effective_to_ms = 21;
repeated string effect_types = 22;
}
message GiftTypeConfig {
string app_code = 1;
string type_code = 2;
string name = 3;
string tab_key = 4;
string status = 5;
int32 sort_order = 6;
int64 created_by_user_id = 7;
int64 updated_by_user_id = 8;
int64 created_at_ms = 9;
int64 updated_at_ms = 10;
}
message ResourceShopItem {
string app_code = 1;
int64 shop_item_id = 2;
int64 resource_id = 3;
Resource resource = 4;
string status = 5;
int32 duration_days = 6;
string price_type = 7;
int64 coin_price = 8;
int64 effective_from_ms = 9;
int64 effective_to_ms = 10;
int32 sort_order = 11;
int64 created_by_user_id = 12;
int64 updated_by_user_id = 13;
int64 created_at_ms = 14;
int64 updated_at_ms = 15;
}
message UserResourceEntitlement {
string app_code = 1;
string entitlement_id = 2;
int64 user_id = 3;
int64 resource_id = 4;
Resource resource = 5;
string status = 6;
int64 quantity = 7;
int64 remaining_quantity = 8;
int64 effective_at_ms = 9;
int64 expires_at_ms = 10;
string source_grant_id = 11;
int64 created_at_ms = 12;
int64 updated_at_ms = 13;
bool equipped = 14;
}
message ResourceGrantItem {
int64 grant_item_id = 1;
string grant_id = 2;
int64 resource_id = 3;
string resource_snapshot_json = 4;
int64 quantity = 5;
int64 duration_ms = 6;
string result_type = 7;
string wallet_transaction_id = 8;
string entitlement_id = 9;
int64 created_at_ms = 10;
}
message ResourceGrant {
string app_code = 1;
string grant_id = 2;
string command_id = 3;
int64 target_user_id = 4;
string grant_source = 5;
string grant_subject_type = 6;
string grant_subject_id = 7;
string status = 8;
string reason = 9;
int64 operator_user_id = 10;
repeated ResourceGrantItem items = 11;
int64 created_at_ms = 12;
int64 updated_at_ms = 13;
}
message ResourceGroupItemInput {
int64 resource_id = 1;
int64 quantity = 2;
int64 duration_ms = 3;
int32 sort_order = 4;
string item_type = 5;
string wallet_asset_type = 6;
int64 wallet_asset_amount = 7;
}
message ListResourcesRequest {
string request_id = 1;
string app_code = 2;
string resource_type = 3;
string status = 4;
string keyword = 5;
int32 page = 6;
int32 page_size = 7;
bool active_only = 8;
bool manager_grant_only = 9;
}
message ListResourcesResponse {
repeated Resource resources = 1;
int64 total = 2;
}
message GetResourceRequest {
string request_id = 1;
string app_code = 2;
int64 resource_id = 3;
}
message GetResourceResponse {
Resource resource = 1;
}
message CreateResourceRequest {
string request_id = 1;
string app_code = 2;
string resource_code = 3;
string resource_type = 4;
string name = 5;
string status = 6;
bool grantable = 7;
string grant_strategy = 8;
string wallet_asset_type = 9;
int64 wallet_asset_amount = 10;
repeated string usage_scopes = 11;
string asset_url = 12;
string preview_url = 13;
string animation_url = 14;
string metadata_json = 15;
int32 sort_order = 16;
int64 operator_user_id = 17;
optional bool manager_grant_enabled = 18;
string price_type = 19;
int64 coin_price = 20;
int64 gift_point_amount = 21;
}
message UpdateResourceRequest {
string request_id = 1;
string app_code = 2;
int64 resource_id = 3;
string resource_code = 4;
string resource_type = 5;
string name = 6;
string status = 7;
bool grantable = 8;
string grant_strategy = 9;
string wallet_asset_type = 10;
int64 wallet_asset_amount = 11;
repeated string usage_scopes = 12;
string asset_url = 13;
string preview_url = 14;
string animation_url = 15;
string metadata_json = 16;
int32 sort_order = 17;
int64 operator_user_id = 18;
optional bool manager_grant_enabled = 19;
string price_type = 20;
int64 coin_price = 21;
int64 gift_point_amount = 22;
}
message SetResourceStatusRequest {
string request_id = 1;
string app_code = 2;
int64 resource_id = 3;
string status = 4;
int64 operator_user_id = 5;
}
message ResourceResponse {
Resource resource = 1;
}
message ListResourceGroupsRequest {
string request_id = 1;
string app_code = 2;
string status = 3;
string keyword = 4;
int32 page = 5;
int32 page_size = 6;
bool active_only = 7;
}
message ListResourceGroupsResponse {
repeated ResourceGroup groups = 1;
int64 total = 2;
}
message GetResourceGroupRequest {
string request_id = 1;
string app_code = 2;
int64 group_id = 3;
}
message GetResourceGroupResponse {
ResourceGroup group = 1;
}
message CreateResourceGroupRequest {
string request_id = 1;
string app_code = 2;
string group_code = 3;
string name = 4;
string status = 5;
string description = 6;
int32 sort_order = 7;
repeated ResourceGroupItemInput items = 8;
int64 operator_user_id = 9;
}
message UpdateResourceGroupRequest {
string request_id = 1;
string app_code = 2;
int64 group_id = 3;
string group_code = 4;
string name = 5;
string status = 6;
string description = 7;
int32 sort_order = 8;
repeated ResourceGroupItemInput items = 9;
int64 operator_user_id = 10;
}
message SetResourceGroupStatusRequest {
string request_id = 1;
string app_code = 2;
int64 group_id = 3;
string status = 4;
int64 operator_user_id = 5;
}
message ResourceGroupResponse {
ResourceGroup group = 1;
}
message ListGiftConfigsRequest {
string request_id = 1;
string app_code = 2;
string status = 3;
string keyword = 4;
int32 page = 5;
int32 page_size = 6;
bool active_only = 7;
int64 region_id = 8;
bool filter_region = 9;
}
message ListGiftConfigsResponse {
repeated GiftConfig gifts = 1;
int64 total = 2;
}
message ListGiftTypeConfigsRequest {
string request_id = 1;
string app_code = 2;
string status = 3;
bool active_only = 4;
}
message ListGiftTypeConfigsResponse {
repeated GiftTypeConfig gift_types = 1;
}
message UpsertGiftTypeConfigRequest {
string request_id = 1;
string app_code = 2;
string type_code = 3;
string name = 4;
string tab_key = 5;
string status = 6;
int32 sort_order = 7;
int64 operator_user_id = 8;
}
message GiftTypeConfigResponse {
GiftTypeConfig gift_type = 1;
}
message CreateGiftConfigRequest {
string request_id = 1;
string app_code = 2;
string gift_id = 3;
int64 resource_id = 4;
string status = 5;
string name = 6;
int32 sort_order = 7;
string presentation_json = 8;
string price_version = 9;
int64 coin_price = 10;
int64 gift_point_amount = 11;
int64 heat_value = 12;
int64 effective_at_ms = 13;
int64 operator_user_id = 14;
repeated int64 region_ids = 15;
string gift_type_code = 16;
string charge_asset_type = 17;
int64 effective_from_ms = 18;
int64 effective_to_ms = 19;
repeated string effect_types = 20;
}
message UpdateGiftConfigRequest {
string request_id = 1;
string app_code = 2;
string gift_id = 3;
int64 resource_id = 4;
string status = 5;
string name = 6;
int32 sort_order = 7;
string presentation_json = 8;
string price_version = 9;
int64 coin_price = 10;
int64 gift_point_amount = 11;
int64 heat_value = 12;
int64 effective_at_ms = 13;
int64 operator_user_id = 14;
repeated int64 region_ids = 15;
string gift_type_code = 16;
string charge_asset_type = 17;
int64 effective_from_ms = 18;
int64 effective_to_ms = 19;
repeated string effect_types = 20;
}
message SetGiftConfigStatusRequest {
string request_id = 1;
string app_code = 2;
string gift_id = 3;
string status = 4;
int64 operator_user_id = 5;
}
message GiftConfigResponse {
GiftConfig gift = 1;
}
message GrantResourceRequest {
string command_id = 1;
string app_code = 2;
int64 target_user_id = 3;
int64 resource_id = 4;
int64 quantity = 5;
int64 duration_ms = 6;
string reason = 7;
int64 operator_user_id = 8;
string grant_source = 9;
}
message GrantResourceGroupRequest {
string command_id = 1;
string app_code = 2;
int64 target_user_id = 3;
int64 group_id = 4;
string reason = 5;
int64 operator_user_id = 6;
string grant_source = 7;
}
message ResourceGrantResponse {
ResourceGrant grant = 1;
}
message ListUserResourcesRequest {
string request_id = 1;
string app_code = 2;
int64 user_id = 3;
string resource_type = 4;
bool active_only = 5;
}
message ListUserResourcesResponse {
repeated UserResourceEntitlement resources = 1;
}
message EquipUserResourceRequest {
string request_id = 1;
string app_code = 2;
int64 user_id = 3;
int64 resource_id = 4;
string entitlement_id = 5;
}
message EquipUserResourceResponse {
UserResourceEntitlement resource = 1;
}
message ListResourceGrantsRequest {
string request_id = 1;
string app_code = 2;
int64 target_user_id = 3;
string status = 4;
int32 page = 5;
int32 page_size = 6;
}
message ListResourceGrantsResponse {
repeated ResourceGrant grants = 1;
int64 total = 2;
}
message ResourceShopItemInput {
int64 shop_item_id = 1;
int64 resource_id = 2;
string status = 3;
int32 duration_days = 4;
int64 effective_from_ms = 5;
int64 effective_to_ms = 6;
int32 sort_order = 7;
}
message ListResourceShopItemsRequest {
string request_id = 1;
string app_code = 2;
string resource_type = 3;
string status = 4;
string keyword = 5;
int32 page = 6;
int32 page_size = 7;
bool active_only = 8;
}
message ListResourceShopItemsResponse {
repeated ResourceShopItem items = 1;
int64 total = 2;
}
message UpsertResourceShopItemsRequest {
string request_id = 1;
string app_code = 2;
repeated ResourceShopItemInput items = 3;
int64 operator_user_id = 4;
}
message UpsertResourceShopItemsResponse {
repeated ResourceShopItem items = 1;
}
message SetResourceShopItemStatusRequest {
string request_id = 1;
string app_code = 2;
int64 shop_item_id = 3;
string status = 4;
int64 operator_user_id = 5;
}
message ResourceShopItemResponse {
ResourceShopItem item = 1;
}
message PurchaseResourceShopItemRequest {
string command_id = 1;
string app_code = 2;
int64 user_id = 3;
int64 shop_item_id = 4;
}
message PurchaseResourceShopItemResponse {
string order_id = 1;
string transaction_id = 2;
string resource_grant_id = 3;
ResourceShopItem shop_item = 4;
UserResourceEntitlement resource = 5;
AssetBalance balance = 6;
int64 coin_spent = 7;
}
message RechargeBill {
string app_code = 1;
string transaction_id = 2;
string command_id = 3;
string recharge_type = 4;
string status = 5;
string external_ref = 6;
int64 user_id = 7;
int64 seller_user_id = 8;
int64 seller_region_id = 9;
int64 target_region_id = 10;
int64 policy_id = 11;
string policy_version = 12;
string currency_code = 13;
int64 coin_amount = 14;
int64 usd_minor_amount = 15;
int64 exchange_coin_amount = 16;
int64 exchange_usd_minor_amount = 17;
int64 created_at_ms = 18;
}
message ListRechargeBillsRequest {
string request_id = 1;
string app_code = 2;
int64 user_id = 3;
int64 seller_user_id = 4;
int64 region_id = 5;
string recharge_type = 6;
string status = 7;
string keyword = 8;
int64 start_at_ms = 9;
int64 end_at_ms = 10;
int32 page = 11;
int32 page_size = 12;
}
message ListRechargeBillsResponse {
repeated RechargeBill bills = 1;
int64 total = 2;
}
// WalletFeatureFlags 是我的页和钱包首页使用的操作开关,来源属于 wallet-service。
message WalletFeatureFlags {
bool recharge_enabled = 1;
bool diamond_exchange_enabled = 2;
bool withdraw_enabled = 3;
}
message GetWalletOverviewRequest {
string request_id = 1;
string app_code = 2;
int64 user_id = 3;
}
message GetWalletOverviewResponse {
repeated AssetBalance balances = 1;
WalletFeatureFlags feature_flags = 2;
}
// WalletValueSummary 是我的页钱包价值展示的轻量投影,只返回首屏展示需要的金币余额。
message WalletValueSummary {
int64 coin_amount = 1;
int64 updated_at_ms = 2;
}
message GetWalletValueSummaryRequest {
string request_id = 1;
string app_code = 2;
int64 user_id = 3;
}
message GetWalletValueSummaryResponse {
WalletValueSummary summary = 1;
}
// GiftWallItem 是用户礼物墙按礼物类型聚合后的当前投影。
message GiftWallItem {
string gift_id = 1;
string gift_name = 2;
int64 resource_id = 3;
Resource resource = 4;
string resource_snapshot_json = 5;
string gift_type_code = 6;
string presentation_json = 7;
int64 gift_count = 8;
int64 total_value = 9;
int64 total_coin_value = 10;
int64 total_diamond_value = 11;
int64 total_gift_point = 12;
int64 total_heat_value = 13;
string charge_asset_type = 14;
string last_price_version = 15;
int64 first_received_at_ms = 16;
int64 last_received_at_ms = 17;
int32 sort_order = 18;
}
message GetUserGiftWallRequest {
string request_id = 1;
string app_code = 2;
int64 user_id = 3;
}
message GetUserGiftWallResponse {
repeated GiftWallItem items = 1;
int64 gift_kind_count = 2;
int64 gift_total_count = 3;
int64 total_value = 4;
int64 total_coin_value = 5;
int64 total_diamond_value = 6;
int64 total_gift_point = 7;
int64 total_heat_value = 8;
}
// RechargeProduct 是 App 充值页可展示的区域化充值档位。
message RechargeProduct {
int64 product_id = 1;
string product_code = 2;
string channel = 3;
string currency_code = 4;
int64 coin_amount = 5;
int64 amount_minor = 6;
string policy_version = 7;
bool enabled = 8;
int32 sort_order = 9;
string product_name = 10;
string description = 11;
string platform = 12;
repeated int64 region_ids = 13;
string resource_asset_type = 14;
int64 amount_micro = 15;
int64 created_by_user_id = 16;
int64 updated_by_user_id = 17;
int64 created_at_ms = 18;
int64 updated_at_ms = 19;
string app_code = 20;
string status = 21;
}
message ListRechargeProductsRequest {
string request_id = 1;
string app_code = 2;
int64 user_id = 3;
int64 region_id = 4;
// platform 来自 gateway 解析的 App 平台请求头;为空时返回该区域全部已上架商品。
string platform = 5;
}
message ListRechargeProductsResponse {
repeated RechargeProduct products = 1;
repeated string channels = 2;
}
message ConfirmGooglePaymentRequest {
string request_id = 1;
string app_code = 2;
string command_id = 3;
int64 user_id = 4;
int64 region_id = 5;
int64 product_id = 6;
string product_code = 7;
string package_name = 8;
string purchase_token = 9;
string order_id = 10;
int64 purchase_time_ms = 11;
}
message ConfirmGooglePaymentResponse {
string payment_order_id = 1;
string transaction_id = 2;
string status = 3;
int64 product_id = 4;
string product_code = 5;
int64 coin_amount = 6;
AssetBalance balance = 7;
bool idempotent_replay = 8;
string consume_state = 9;
}
// ListAdminRechargeProductsRequest 是后台内购配置列表查询,不参与用户充值主链路。
message ListAdminRechargeProductsRequest {
string request_id = 1;
string app_code = 2;
string status = 3;
string platform = 4;
int64 region_id = 5;
string keyword = 6;
int32 page = 7;
int32 page_size = 8;
}
message ListAdminRechargeProductsResponse {
repeated RechargeProduct products = 1;
int64 total = 2;
}
// CreateRechargeProductRequest 配置一个 App 内购商品;首版资源资产固定为 COIN。
message CreateRechargeProductRequest {
string request_id = 1;
string app_code = 2;
int64 amount_micro = 3;
int64 coin_amount = 4;
string product_name = 5;
string description = 6;
string platform = 7;
repeated int64 region_ids = 8;
bool enabled = 9;
int64 operator_user_id = 10;
}
message UpdateRechargeProductRequest {
string request_id = 1;
string app_code = 2;
int64 product_id = 3;
int64 amount_micro = 4;
int64 coin_amount = 5;
string product_name = 6;
string description = 7;
string platform = 8;
repeated int64 region_ids = 9;
bool enabled = 10;
int64 operator_user_id = 11;
}
message DeleteRechargeProductRequest {
string request_id = 1;
string app_code = 2;
int64 product_id = 3;
int64 operator_user_id = 4;
}
message RechargeProductResponse {
RechargeProduct product = 1;
}
message DeleteRechargeProductResponse {
bool deleted = 1;
}
message DiamondExchangeRule {
string exchange_type = 1;
string from_asset_type = 2;
string to_asset_type = 3;
int64 from_amount = 4;
int64 to_amount = 5;
bool enabled = 6;
}
message GetDiamondExchangeConfigRequest {
string request_id = 1;
string app_code = 2;
int64 user_id = 3;
}
message GetDiamondExchangeConfigResponse {
repeated DiamondExchangeRule rules = 1;
}
// WalletTransaction 是用户钱包流水页使用的分录级投影。
message WalletTransaction {
int64 entry_id = 1;
string transaction_id = 2;
string biz_type = 3;
string asset_type = 4;
int64 available_delta = 5;
int64 frozen_delta = 6;
int64 available_after = 7;
int64 frozen_after = 8;
int64 counterparty_user_id = 9;
string room_id = 10;
int64 created_at_ms = 11;
}
message ListWalletTransactionsRequest {
string request_id = 1;
string app_code = 2;
int64 user_id = 3;
string asset_type = 4;
int32 page = 5;
int32 page_size = 6;
}
message ListWalletTransactionsResponse {
repeated WalletTransaction transactions = 1;
int64 total = 2;
}
message WithdrawalRequest {
string withdrawal_id = 1;
int64 user_id = 2;
string asset_type = 3;
int64 amount = 4;
string status = 5;
string payout_account = 6;
string reason = 7;
int64 created_at_ms = 8;
int64 updated_at_ms = 9;
}
message ApplyWithdrawalRequest {
string command_id = 1;
string app_code = 2;
int64 user_id = 3;
int64 amount = 4;
string payout_account = 5;
string reason = 6;
}
message ApplyWithdrawalResponse {
WithdrawalRequest withdrawal = 1;
AssetBalance balance = 2;
}
message VipRewardItem {
int64 resource_id = 1;
string resource_code = 2;
string resource_type = 3;
string name = 4;
int64 quantity = 5;
int64 expires_at_ms = 6;
}
message VipLevel {
int32 level = 1;
string name = 2;
string status = 3;
int64 price_coin = 4;
int64 duration_ms = 5;
int64 reward_resource_group_id = 6;
repeated VipRewardItem reward_items = 7;
bool can_purchase = 8;
int32 sort_order = 9;
bool recharge_gate_required = 10;
int64 required_recharge_coin_amount = 11;
int64 user_recharge_coin_amount = 12;
string purchase_locked_reason = 13;
int64 created_at_ms = 14;
int64 updated_at_ms = 15;
}
message UserVip {
int64 user_id = 1;
int32 level = 2;
string name = 3;
bool active = 4;
int64 started_at_ms = 5;
int64 expires_at_ms = 6;
int64 updated_at_ms = 7;
}
message ListVipPackagesRequest {
string request_id = 1;
string app_code = 2;
int64 user_id = 3;
}
message ListVipPackagesResponse {
UserVip current_vip = 1;
repeated VipLevel packages = 2;
}
message GetMyVipRequest {
string request_id = 1;
string app_code = 2;
int64 user_id = 3;
}
message GetMyVipResponse {
UserVip vip = 1;
}
message PurchaseVipRequest {
string command_id = 1;
string app_code = 2;
int64 user_id = 3;
int32 level = 4;
}
message PurchaseVipResponse {
string order_id = 1;
string transaction_id = 2;
UserVip vip = 3;
int64 coin_spent = 4;
int64 coin_balance_after = 5;
repeated VipRewardItem reward_items = 6;
}
message GrantVipRequest {
string command_id = 1;
string app_code = 2;
int64 target_user_id = 3;
int32 level = 4;
string grant_source = 5;
int64 operator_user_id = 6;
string reason = 7;
}
message GrantVipResponse {
string transaction_id = 1;
UserVip vip = 2;
repeated VipRewardItem reward_items = 3;
int64 server_time_ms = 4;
}
message AdminVipLevelInput {
int32 level = 1;
string name = 2;
string status = 3;
int64 price_coin = 4;
int64 duration_ms = 5;
int64 reward_resource_group_id = 6;
int32 sort_order = 7;
int64 required_recharge_coin_amount = 8;
}
message ListAdminVipLevelsRequest {
string request_id = 1;
string app_code = 2;
}
message ListAdminVipLevelsResponse {
repeated VipLevel levels = 1;
int64 server_time_ms = 2;
}
message UpdateAdminVipLevelsRequest {
string request_id = 1;
string app_code = 2;
repeated AdminVipLevelInput levels = 3;
int64 operator_user_id = 4;
}
message UpdateAdminVipLevelsResponse {
repeated VipLevel levels = 1;
int64 server_time_ms = 2;
}
// CreditTaskRewardRequest 是 activity-service 领取任务奖励时调用的钱包入账命令。
message CreditTaskRewardRequest {
string command_id = 1;
string app_code = 2;
int64 target_user_id = 3;
int64 amount = 4;
string task_type = 5;
string task_id = 6;
string cycle_key = 7;
string reason = 8;
}
// CreditTaskRewardResponse 返回任务奖励入账流水和用户 COIN 账后余额。
message CreditTaskRewardResponse {
string transaction_id = 1;
AssetBalance balance = 2;
int64 amount = 3;
int64 granted_at_ms = 4;
}
// CreditLuckyGiftRewardRequest 是 activity-service 抽奖 outbox 补偿 worker 调用的钱包入账命令。
message CreditLuckyGiftRewardRequest {
string command_id = 1;
string app_code = 2;
int64 target_user_id = 3;
int64 amount = 4;
string draw_id = 5;
string room_id = 6;
string gift_id = 7;
string pool_id = 8;
string reason = 9;
}
// CreditLuckyGiftRewardResponse 返回幸运礼物返奖入账流水和用户 COIN 账后余额。
message CreditLuckyGiftRewardResponse {
string transaction_id = 1;
AssetBalance balance = 2;
int64 amount = 3;
int64 granted_at_ms = 4;
}
// ApplyGameCoinChangeRequest 是 game-service 唯一可以调用的钱包游戏改账入口。
message ApplyGameCoinChangeRequest {
string request_id = 1;
string app_code = 2;
string command_id = 3;
int64 user_id = 4;
string platform_code = 5;
string game_id = 6;
string provider_order_id = 7;
string provider_round_id = 8;
string op_type = 9;
int64 coin_amount = 10;
string room_id = 11;
string request_hash = 12;
}
// ApplyGameCoinChangeResponse 返回游戏改账流水和用户 COIN 账后余额。
message ApplyGameCoinChangeResponse {
string wallet_transaction_id = 1;
int64 balance_after = 2;
bool idempotent_replay = 3;
}
message RedPacketConfig {
string app_code = 1;
bool enabled = 2;
repeated int32 count_tiers = 3;
repeated int64 amount_tiers = 4;
int32 delayed_open_seconds = 5;
int32 expire_seconds = 6;
int32 daily_send_limit = 7;
int64 updated_by_admin_id = 8;
int64 created_at_ms = 9;
int64 updated_at_ms = 10;
string rule_url = 11;
}
message RedPacketClaim {
string app_code = 1;
string claim_id = 2;
string command_id = 3;
string packet_id = 4;
int64 user_id = 5;
int64 amount = 6;
string wallet_transaction_id = 7;
string status = 8;
string failure_reason = 9;
int64 created_at_ms = 10;
int64 updated_at_ms = 11;
}
message RedPacket {
string app_code = 1;
string packet_id = 2;
string command_id = 3;
int64 sender_user_id = 4;
string room_id = 5;
int64 region_id = 6;
string packet_type = 7;
int64 total_amount = 8;
int32 packet_count = 9;
int64 remaining_amount = 10;
int32 remaining_count = 11;
string status = 12;
int64 open_at_ms = 13;
int64 expires_at_ms = 14;
int64 created_at_ms = 15;
int64 updated_at_ms = 16;
bool claimed_by_viewer = 17;
int64 viewer_claim_amount = 18;
repeated RedPacketClaim claims = 19;
int64 refund_amount = 20;
string refund_status = 21;
int64 refunded_at_ms = 22;
}
message GetRedPacketConfigRequest {
string request_id = 1;
string app_code = 2;
}
message GetRedPacketConfigResponse {
RedPacketConfig config = 1;
int64 server_time_ms = 2;
}
message UpdateRedPacketConfigRequest {
string request_id = 1;
string app_code = 2;
bool enabled = 3;
repeated int32 count_tiers = 4;
repeated int64 amount_tiers = 5;
int32 delayed_open_seconds = 6;
int32 expire_seconds = 7;
int32 daily_send_limit = 8;
int64 operator_user_id = 9;
string rule_url = 10;
}
message UpdateRedPacketConfigResponse {
RedPacketConfig config = 1;
int64 server_time_ms = 2;
}
message CreateRedPacketRequest {
string request_id = 1;
string app_code = 2;
string command_id = 3;
int64 sender_user_id = 4;
string room_id = 5;
int64 region_id = 6;
string packet_type = 7;
int64 total_amount = 8;
int32 packet_count = 9;
}
message CreateRedPacketResponse {
RedPacket packet = 1;
int64 balance_after = 2;
int64 server_time_ms = 3;
}
message ClaimRedPacketRequest {
string request_id = 1;
string app_code = 2;
string command_id = 3;
string packet_id = 4;
int64 user_id = 5;
}
message ClaimRedPacketResponse {
RedPacketClaim claim = 1;
int64 balance_after = 2;
int64 server_time_ms = 3;
RedPacket packet = 4;
}
message ListRedPacketsRequest {
string request_id = 1;
string app_code = 2;
string room_id = 3;
int64 sender_user_id = 4;
int64 region_id = 5;
string packet_type = 6;
string status = 7;
int64 viewer_user_id = 8;
int64 start_at_ms = 9;
int64 end_at_ms = 10;
int32 page = 11;
int32 page_size = 12;
}
message ListRedPacketsResponse {
repeated RedPacket packets = 1;
int64 total = 2;
int64 server_time_ms = 3;
}
message GetRedPacketRequest {
string request_id = 1;
string app_code = 2;
string packet_id = 3;
int64 viewer_user_id = 4;
bool include_claims = 5;
}
message GetRedPacketResponse {
RedPacket packet = 1;
int64 server_time_ms = 2;
}
message ExpireRedPacketsRequest {
string request_id = 1;
string app_code = 2;
int32 batch_size = 3;
}
message ExpireRedPacketsResponse {
int32 expired_count = 1;
int64 refunded_amount = 2;
int64 server_time_ms = 3;
}
message RetryRedPacketRefundRequest {
string request_id = 1;
string app_code = 2;
string packet_id = 3;
int64 operator_user_id = 4;
}
message RetryRedPacketRefundResponse {
RedPacket packet = 1;
int64 refunded_amount = 2;
int64 server_time_ms = 3;
}
// CronBatchRequest 是 cron-service 触发 wallet-service 后台批处理的统一请求。
message CronBatchRequest {
string request_id = 1;
string app_code = 2;
string run_id = 3;
string worker_id = 4;
int32 batch_size = 5;
int64 lock_ttl_ms = 6;
}
// CronBatchResponse 返回一个批处理 run 的执行摘要。
message CronBatchResponse {
int32 claimed_count = 1;
int32 processed_count = 2;
int32 success_count = 3;
int32 failure_count = 4;
bool has_more = 5;
}
// WalletCronService 只给 cron-service 调用;账务状态仍由 wallet-service owner 修改。
service WalletCronService {
rpc ProcessHostSalaryDailySettlementBatch(CronBatchRequest) returns (CronBatchResponse);
rpc ProcessHostSalaryHalfMonthSettlementBatch(CronBatchRequest) returns (CronBatchResponse);
rpc ProcessHostSalaryMonthEndBatch(CronBatchRequest) returns (CronBatchResponse);
}
// WalletService 是内部账务 gRPC 边界,外部 HTTP 入口仍由 gateway-service 承载。
service WalletService {
rpc DebitGift(DebitGiftRequest) returns (DebitGiftResponse);
rpc GetBalances(GetBalancesRequest) returns (GetBalancesResponse);
rpc AdminCreditAsset(AdminCreditAssetRequest) returns (AdminCreditAssetResponse);
rpc AdminCreditCoinSellerStock(AdminCreditCoinSellerStockRequest) returns (AdminCreditCoinSellerStockResponse);
rpc TransferCoinFromSeller(TransferCoinFromSellerRequest) returns (TransferCoinFromSellerResponse);
rpc ListResources(ListResourcesRequest) returns (ListResourcesResponse);
rpc GetResource(GetResourceRequest) returns (GetResourceResponse);
rpc CreateResource(CreateResourceRequest) returns (ResourceResponse);
rpc UpdateResource(UpdateResourceRequest) returns (ResourceResponse);
rpc SetResourceStatus(SetResourceStatusRequest) returns (ResourceResponse);
rpc ListResourceGroups(ListResourceGroupsRequest) returns (ListResourceGroupsResponse);
rpc GetResourceGroup(GetResourceGroupRequest) returns (GetResourceGroupResponse);
rpc CreateResourceGroup(CreateResourceGroupRequest) returns (ResourceGroupResponse);
rpc UpdateResourceGroup(UpdateResourceGroupRequest) returns (ResourceGroupResponse);
rpc SetResourceGroupStatus(SetResourceGroupStatusRequest) returns (ResourceGroupResponse);
rpc ListGiftConfigs(ListGiftConfigsRequest) returns (ListGiftConfigsResponse);
rpc ListGiftTypeConfigs(ListGiftTypeConfigsRequest) returns (ListGiftTypeConfigsResponse);
rpc CreateGiftConfig(CreateGiftConfigRequest) returns (GiftConfigResponse);
rpc UpdateGiftConfig(UpdateGiftConfigRequest) returns (GiftConfigResponse);
rpc SetGiftConfigStatus(SetGiftConfigStatusRequest) returns (GiftConfigResponse);
rpc UpsertGiftTypeConfig(UpsertGiftTypeConfigRequest) returns (GiftTypeConfigResponse);
rpc GrantResource(GrantResourceRequest) returns (ResourceGrantResponse);
rpc GrantResourceGroup(GrantResourceGroupRequest) returns (ResourceGrantResponse);
rpc ListUserResources(ListUserResourcesRequest) returns (ListUserResourcesResponse);
rpc EquipUserResource(EquipUserResourceRequest) returns (EquipUserResourceResponse);
rpc ListResourceGrants(ListResourceGrantsRequest) returns (ListResourceGrantsResponse);
rpc ListResourceShopItems(ListResourceShopItemsRequest) returns (ListResourceShopItemsResponse);
rpc UpsertResourceShopItems(UpsertResourceShopItemsRequest) returns (UpsertResourceShopItemsResponse);
rpc SetResourceShopItemStatus(SetResourceShopItemStatusRequest) returns (ResourceShopItemResponse);
rpc PurchaseResourceShopItem(PurchaseResourceShopItemRequest) returns (PurchaseResourceShopItemResponse);
rpc ListRechargeBills(ListRechargeBillsRequest) returns (ListRechargeBillsResponse);
rpc GetWalletOverview(GetWalletOverviewRequest) returns (GetWalletOverviewResponse);
rpc GetWalletValueSummary(GetWalletValueSummaryRequest) returns (GetWalletValueSummaryResponse);
rpc GetUserGiftWall(GetUserGiftWallRequest) returns (GetUserGiftWallResponse);
rpc ListRechargeProducts(ListRechargeProductsRequest) returns (ListRechargeProductsResponse);
rpc ConfirmGooglePayment(ConfirmGooglePaymentRequest) returns (ConfirmGooglePaymentResponse);
rpc ListAdminRechargeProducts(ListAdminRechargeProductsRequest) returns (ListAdminRechargeProductsResponse);
rpc CreateRechargeProduct(CreateRechargeProductRequest) returns (RechargeProductResponse);
rpc UpdateRechargeProduct(UpdateRechargeProductRequest) returns (RechargeProductResponse);
rpc DeleteRechargeProduct(DeleteRechargeProductRequest) returns (DeleteRechargeProductResponse);
rpc GetDiamondExchangeConfig(GetDiamondExchangeConfigRequest) returns (GetDiamondExchangeConfigResponse);
rpc ListWalletTransactions(ListWalletTransactionsRequest) returns (ListWalletTransactionsResponse);
rpc ApplyWithdrawal(ApplyWithdrawalRequest) returns (ApplyWithdrawalResponse);
rpc ListVipPackages(ListVipPackagesRequest) returns (ListVipPackagesResponse);
rpc GetMyVip(GetMyVipRequest) returns (GetMyVipResponse);
rpc PurchaseVip(PurchaseVipRequest) returns (PurchaseVipResponse);
rpc GrantVip(GrantVipRequest) returns (GrantVipResponse);
rpc ListAdminVipLevels(ListAdminVipLevelsRequest) returns (ListAdminVipLevelsResponse);
rpc UpdateAdminVipLevels(UpdateAdminVipLevelsRequest) returns (UpdateAdminVipLevelsResponse);
rpc CreditTaskReward(CreditTaskRewardRequest) returns (CreditTaskRewardResponse);
rpc CreditLuckyGiftReward(CreditLuckyGiftRewardRequest) returns (CreditLuckyGiftRewardResponse);
rpc ApplyGameCoinChange(ApplyGameCoinChangeRequest) returns (ApplyGameCoinChangeResponse);
rpc GetRedPacketConfig(GetRedPacketConfigRequest) returns (GetRedPacketConfigResponse);
rpc UpdateRedPacketConfig(UpdateRedPacketConfigRequest) returns (UpdateRedPacketConfigResponse);
rpc CreateRedPacket(CreateRedPacketRequest) returns (CreateRedPacketResponse);
rpc ClaimRedPacket(ClaimRedPacketRequest) returns (ClaimRedPacketResponse);
rpc ListRedPackets(ListRedPacketsRequest) returns (ListRedPacketsResponse);
rpc GetRedPacket(GetRedPacketRequest) returns (GetRedPacketResponse);
rpc ExpireRedPackets(ExpireRedPacketsRequest) returns (ExpireRedPacketsResponse);
rpc RetryRedPacketRefund(RetryRedPacketRefundRequest) returns (RetryRedPacketRefundResponse);
}