Polyv Help Center

Help Center

redPackService

Updated: 2025-09-11 15:18:09

1. Query Red Packet Distribution Statistics

Description

分页查询频道红包派发数据统计
接口地址(仅做说明使用):https://api.polyv.net/live/v4/channel/red-pack/statistics/list

Call Constraints

  1. The API has a call frequency limit. Click here for details. For common call exceptions, click here.

Unit Test

    @Test
    public void testGetRedPackStats() throws IOException, NoSuchAlgorithmException {
        LiveGetRedPackStatsRequest liveGetRedPackStatsRequest = new LiveGetRedPackStatsRequest();
        LiveGetRedPackStatsResponse liveGetRedPackStatsResponse;
        try {
            String channelId = super.createChannel();
            liveGetRedPackStatsRequest.setChannelId(channelId);
            liveGetRedPackStatsResponse = new ILiveRedPackServiceImpl().getRedPackStats(liveGetRedPackStatsRequest);
            Assert.assertNotNull(liveGetRedPackStatsResponse);
            if (liveGetRedPackStatsResponse != null) {
                //to do something ......
                log.debug("测试查询红包派发数据统计成功 {}", JSON.toJSONString(liveGetRedPackStatsResponse));
            }
        } catch (PloyvSdkException e) {
            //参数校验不合格 或者 请求服务器端500错误,错误信息见PloyvSdkException.getMessage()
            log.error(e.getMessage(), e);
            // 异常返回做B端异常的业务逻辑,记录log 或者 上报到ETL 或者回滚事务
            throw e;
        } catch (Exception e) {
            log.error("SDK调用异常", e);
            throw e;
        }
    }
}

Unit Test Description

  1. If the request is correct, a LiveGetRedPackStatsResponse object is returned, and the B-side processes business logic based on this object.

  2. If the request parameter validation fails, a PloyvSdkException is thrown. The error message can be found in PloyvSdkException.getMessage(), e.g., [ Input parameter [xxx.chat.LivexxxRequest] object validation failed, failed fields [pic cannot be empty / msg cannot be empty] ].

  3. If the server encounters an exception, a PloyvSdkException is thrown. The error message can be found in PloyvSdkException.getMessage(), e.g., [ Polyv request returned data error, request serial number: 66e7ad29fd04425a84c2b2b562d2025b, error reason: invalid signature. ]

Request Parameter Description

Parameter Name Required Type Description
channelId true String Channel ID
sessionId false String Session ID
startTime false Date Start time
endTime false Date End time
currentPage false Integer Page number, default is 1 [Corresponds to the pageNumber field in the API documentation]
pageSize false Integer Number of data items displayed per page, default is 20
appId false String POLYV user APP_ID, required for multi-account calls (i.e., when initMultiAccount() is called to set up multi-account calls). Obtain it by registering on the Polyv official website: Official website -> Login -> Live (Development Settings)
appSecret false String POLYV user APP_SECRET, required for multi-account calls (i.e., when initMultiAccount() is called to set up multi-account calls). Obtain it by registering on the Polyv official website: Official website -> Login -> Live (Development Settings)

Return Object Description

Parameter Name Type Description
contents Array Current page content [See RedPackStats Parameter Description for details]
pageSize Integer Number of data items displayed per page, default is 20
currentPage Integer Current page [Corresponds to the pageNumber field in the API documentation]
totalItems Integer Total number of records
totalPage Integer Total number of pages [Corresponds to the totalPages field in the API documentation]
RedPackStats Parameter Description
Parameter Name Type Description
redPackId String Red packet ID
userId String User WeChat OPENID
channelId String Channel ID
nickName String Nickname
amount Float Red packet amount
balance Float Red packet balance
allotType String Distribution method name: Random distribution red packet, Equal distribution red packet
createdTime Date Creation time, 13-digit millisecond timestamp
status String Status name: In progress, Ended, Refunding, Refunded
redPackType String Red packet type name: Red packet rain, Command red packet, Normal red packet
redPackReceiveList Array List of users who received the red packet [See ReceiveList Parameter Description for details]
ReceiveList Parameter Description
Parameter Name Type Description
redPackId String Red packet ID
userId String User WeChat OPENID
nickName String Nickname
avatar String Avatar
amount Float Amount received (two decimal places)
createdTime Date Time of receipt

联系客服,在线咨询