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 COIN available_amount 账后余额。 int64 balance_after = 7; } // 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; } // 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; } 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; } 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; } 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; } 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; } 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; } 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; } 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; } // WalletService 是内部账务 gRPC 边界,外部 HTTP 入口仍由 gateway-service 承载。 service WalletService { rpc DebitGift(DebitGiftRequest) returns (DebitGiftResponse); rpc GetBalances(GetBalancesRequest) returns (GetBalancesResponse); rpc AdminCreditAsset(AdminCreditAssetRequest) returns (AdminCreditAssetResponse); 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); }