hyapp-server/api/proto/wallet/v1/wallet.proto
2026-05-11 19:26:01 +08:00

846 lines
22 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;
}
// 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;
}
// 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;
}
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 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;
}
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;
}
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;
}
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 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 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;
}
// 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;
}
message ListRechargeProductsRequest {
string request_id = 1;
string app_code = 2;
int64 user_id = 3;
int64 region_id = 4;
}
message ListRechargeProductsResponse {
repeated RechargeProduct products = 1;
repeated string channels = 2;
}
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;
}
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;
}
// 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;
}
// 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 CreateGiftConfig(CreateGiftConfigRequest) returns (GiftConfigResponse);
rpc UpdateGiftConfig(UpdateGiftConfigRequest) returns (GiftConfigResponse);
rpc SetGiftConfigStatus(SetGiftConfigStatusRequest) returns (GiftConfigResponse);
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 ListRechargeBills(ListRechargeBillsRequest) returns (ListRechargeBillsResponse);
rpc GetWalletOverview(GetWalletOverviewRequest) returns (GetWalletOverviewResponse);
rpc GetWalletValueSummary(GetWalletValueSummaryRequest) returns (GetWalletValueSummaryResponse);
rpc ListRechargeProducts(ListRechargeProductsRequest) returns (ListRechargeProductsResponse);
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 CreditTaskReward(CreditTaskRewardRequest) returns (CreditTaskRewardResponse);
}