Conditional Lottery
1. Feature Overview
This module provides live streaming lottery-related functionalities, including initializing a lottery, retrieving lottery information, and participating in a lottery.
2. API Methods
2.1 Initialize Welfare Lottery
Description: Initializes the lottery function, retrieves lottery details, and sets the relevant status.
API Method: initLottery(lotteryId: string): Promise<WelfareLotteryDetail>
Parameter Description:
- lotteryId: Lottery ID, type
string, required.
Return Value Description: Lottery details, type Promise<WelfareLotteryDetail>. Detailed type description is as follows:
| Property Name | Description | Type |
|---|---|---|
lotteryId |
Lottery ID | string |
prizeName |
Prize Name | string |
realPrice |
Discounted Price | number |
price |
Original Price | number |
thumbnail |
Prize Thumbnail | string |
amount |
Number of Winners | number |
lotteryCondition |
Participation Condition | WelfareLotteryCondition |
lotteryRange |
Lottery User Scope | WelfareLotteryRange |
customGroupLotteryType |
Group Lottery Type | WelfareLotteryCustomGroupType |
endTime |
Draw Time, Unit: Timestamp | number |
status |
Lottery Status | WelfareLotteryStatus |
winnerIds |
List of Winning User IDs | string[] |
inviteNum |
Number of Invitations | number |
inviteType |
Invitation Type | WelfareLotteryInviteType |
comment |
Comment Lottery Keyword | string |
duration |
Watch Duration | number |
hiddenWinnerAmount |
Hidden Prize Count | YN |
viewerSize |
Number of Participants | number |
hiddenAttendeeNumber |
Hidden Participant Count | YN |
Example:
// 初始化抽奖
const lotteryDetail = await watchCore.welfareLottery.initLottery('123456');
console.log('抽奖详情', lotteryDetail);
2.2 Get Lottery Details
Description: Retrieves detailed information for a specified lottery activity.
API Method: getLotteryDetail(lotteryId: string): Promise<WelfareLotteryDetail>
Parameter Description:
- lotteryId: Lottery ID, type
string, required.
Return Value Description: Lottery details, type Promise<WelfareLotteryDetail>. Detailed type description is as follows:
| Property Name | Description | Type |
|---|---|---|
lotteryId |
Lottery ID | string |
prizeName |
Prize Name | string |
realPrice |
Discounted Price | number |
price |
Original Price | number |
thumbnail |
Prize Thumbnail | string |
amount |
Number of Winners | number |
lotteryCondition |
Participation Condition | WelfareLotteryCondition |
lotteryRange |
Lottery User Scope | WelfareLotteryRange |
customGroupLotteryType |
Group Lottery Type | WelfareLotteryCustomGroupType |
endTime |
Draw Time, Unit: Timestamp | number |
status |
Lottery Status | WelfareLotteryStatus |
winnerIds |
List of Winning User IDs | string[] |
inviteNum |
Number of Invitations | number |
inviteType |
Invitation Type | WelfareLotteryInviteType |
comment |
Comment Lottery Keyword | string |
duration |
Watch Duration | number |
hiddenWinnerAmount |
Hidden Prize Count | YN |
viewerSize |
Number of Participants | number |
hiddenAttendeeNumber |
Hidden Participant Count | YN |
Example:
// 获取抽奖详情
const detail = await watchCore.welfareLottery.getLotteryDetail('123456');
console.log('抽奖详情', detail);
2.3 Get Lottery Completion Status
Description: Retrieves the user's completion status for participating in a lottery, such as watch duration, whether they commented, etc.
API Method: getLotteryFinishData(lotteryId?: string): Promise<WelfareLotteryFinishData>
Parameter Description:
- lotteryId: undefined, type
string, optional.
Return Value Description: Lottery completion status, type Promise<WelfareLotteryFinishData>. Detailed type description is as follows:
| Property Name | Description | Type |
|---|---|---|
lotteryId |
Lottery ID | string |
viewerSize |
Number of Participants | number |
condition |
Participation Condition | WelfareLotteryCondition |
hasComment |
Has Commented | YN |
duration |
Watch Duration | number |
inviteType |
Invitation Type | WelfareLotteryInviteType |
inviteCount |
Number of Invitations | number |
Example:
// 获取抽奖完成情况
const finishData = await watchCore.welfareLottery.getLotteryFinishData();
console.log('抽奖完成情况', finishData);
2.4 Get Winner List
Description: Retrieves the list of winning users for a lottery activity.
API Method: getLotteryWinners(options: Object): Promise<LotteryWinnersData>
Parameter Description:
- options: Query parameters, type
Object, required. Detailed type description is as follows:
| Parameter Name | Description | Type | Required | Default Value |
|---|---|---|---|---|
pageNumber |
- | number |
No | - |
lotteryId |
Lottery ID | string |
Yes | - |
Return Value Description: Winner list data, type Promise<LotteryWinnersData>. Detailed type description is as follows:
| Property Name | Description | Type |
|---|---|---|
contents |
Winner List | LotteryWinnerItem[] |
pageNumber |
Current Page Number | number |
pageSize |
Items Per Page | number |
totalItems |
Total Items | number |
totalPages |
Total Pages | number |
Example:
// 获取中奖名单
const winners = await watchCore.welfareLottery.getLotteryWinners({
lotteryId: '123456'
});
console.log('中奖名单', winners);
2.5 Complete Comment Lottery
Description: Submits a comment to fulfill the participation condition for a comment-type lottery.
API Method: finishCommentLottery(options: Object): Promise<void>
Parameter Description:
- options: Parameters, type
Object, required. Detailed type description is as follows:
| Parameter Name | Description | Type | Required | Default Value |
|---|---|---|---|---|
comment |
Comment Content | string |
Yes | - |
Example:
// 提交评论参与抽奖
await watchCore.welfareLottery.finishCommentLottery({
comment: '我要参与抽奖'
});
Description: Retrieves detailed prize information for a lottery activity.
API Method: getLotteryPrize(lotteryId: string): Promise<WelfareLotteryPrize>
Parameter Description:
- lotteryId: Lottery ID, type
string, required.
Return Value Description: Lottery prize information, type Promise<WelfareLotteryPrize>. Detailed type description is as follows:
| Property Name | Description | Type |
|---|---|---|
acceptType |
Prize Claim Method | PrizeAcceptType |
channelId |
Channel ID | string |
formList |
Prize Claim Form | PrizeFromItem[] |
hasObtain |
Has Claimed Prize, valid when acceptType is form | boolean |
lotteryId |
Lottery ID | string |
prizeUrl |
Prize Claim URL | string |
recordId |
Winning ID | string |
qrCode |
Prize Claim QR Code | string |
qrCodeTips |
Prize Claim QR Code Prompt | string |
winnerCode |
Winning Code | string |
Example:
// 获取抽奖奖品信息
const prizeInfo = await watchCore.welfareLottery.getLotteryPrize('123456');
console.log('抽奖奖品信息', prizeInfo);
2.6 Get Lottery Records
Description: Retrieves the records of lottery activities the user has participated in.
API Method: getLotteryRecord(options: Object): Promise<LotteryRecordData>
Parameter Description:
- options: Query parameters, type
Object, required. Detailed type description is as follows:
| Parameter Name | Description | Type | Required | Default Value |
|---|---|---|---|---|
pageNumber |
- | number |
No | - |
pageSize |
- | number |
No | - |
Return Value Description: Lottery record data, type Promise<LotteryRecordData>. Detailed type description is as follows:
| Property Name | Description | Type |
|---|---|---|
contents |
Winner List | LotteryRecordItem[] |
pageNumber |
Current Page Number | number |
pageSize |
Items Per Page | number |
totalItems |
Total Items | number |
totalPages |
Total Pages | number |
Example:
// 获取抽奖记录
const records = await watchCore.welfareLottery.getLotteryRecord({
pageNumber: 1,
pageSize: 20
});
console.log('抽奖记录', records);
2.7 Get Prize Claim Form Configuration
Description: Retrieves the prize claim form configuration for a lottery activity, used for filling in claim information after winning.
API Method: getLotteryReceive(options: Object): Promise<LotteryReceiveData>
Parameter Description:
- options: Query parameters, type
Object, required. Detailed type description is as follows:
| Parameter Name | Description | Type | Required | Default Value |
|---|---|---|---|---|
lotteryId |
Lottery ID | string |
Yes | - |
Return Value Description: Prize claim form configuration, type Promise<LotteryReceiveData>. Detailed type description is as follows:
| Property Name | Description | Type |
|---|---|---|
acceptType |
Prize Claim Method | LotteryAcceptType |
formList |
Form List | LotteryReceiveFormItem[] |
hasObtain |
Has Claimed | boolean |
lotteryId |
Lottery ID | string |
prizeUrl |
Prize Claim Address | null | string |
qrCode |
QR Code Address | string |
qrCodeTips |
QR Code Prompt | string |
recordId |
Record ID | string |
winnerCode |
Redemption Code | string |
Example:
// 获取领奖信息表单
const receiveForm = await watchCore.welfareLottery.getLotteryReceive({
lotteryId: '123456'
});
console.log('领奖表单', receiveForm);
2.8 Submit Prize Claimant Information
Description: Submits the prize claimant's information, including name, contact details, etc.
API Method: submitReceive(options: Object): Promise<void>
Parameter Description:
- options: Submission parameters, type
Object, required. Detailed type description is as follows:
| Parameter Name | Description | Type | Required | Default Value |
|---|---|---|---|---|
lotteryId |
Lottery ID | string |
Yes | - |
winnerCode |
Winning Code | string |
Yes | - |
receiveInfo |
Prize Claimant Information Form Data | LotteryReceiveFormItem[] |
Yes | - |
Example:
// 提交领奖信息
await watchCore.welfareLottery.submitReceive({
lotteryId: '123456',
winnerCode: '123456',
receiveInfo: [{
key: 'name',
value: '张三'
}]
});
2.9 Get Lottery Privacy Agreement Content
Description: Retrieves the privacy agreement content for a lottery activity.
API Method: getLotteryPrivacy(): LotteryPrivacyDetail
Return Value Description: Lottery privacy agreement content, type LotteryPrivacyDetail. Detailed type description is as follows:
| Property Name | Description | Type |
|---|---|---|
privacyContent |
Lottery Privacy Agreement Content | undefined | string |
lotteryActivityPrivacyEnabled |
Lottery Activity Privacy Agreement Toggle | YN |
Example:
// 获取抽奖隐私协议内容
const privacy = await watchCore.welfareLottery.getLotteryPrivacy();
console.log('抽奖隐私协议内容', privacy);
2.10 Get Lottery Group Information
Description: Retrieves the group information for a lottery activity.
API Method: getLotteryWinnersGroup(options: Object): Promise<LotteryWinnerGroupItem[]>
Parameter Description:
- options: Query parameters, type
Object, required. Detailed type description is as follows:
| Parameter Name | Description | Type | Required | Default Value |
|---|---|---|---|---|
lotteryId |
Lottery ID | string |
Yes | - |
Return Value Description: List of lottery group information, type Promise<LotteryWinnerGroupItem[]>.
Example:
// 获取抽奖分组信息
const groupInfo = await watchCore.welfareLottery.getLotteryWinnersGroup({
lotteryId: '123456'
});
console.log('抽奖分组信息', groupInfo);
2.11 Get Winner List by Lottery Group
Description: Retrieves the list of winning users in a specific group of a lottery activity.
API Method: getLotteryWinnersByGroup(options: Object): Promise<LotteryWinnersData>
Parameter Description:
- options: Query parameters, type
Object, required. Detailed type description is as follows:
| Parameter Name | Description | Type | Required | Default Value |
|---|---|---|---|---|
pageNumber |
- | number |
No | - |
lotteryId |
Lottery ID | string |
Yes | - |
groupId |
Group ID | number |
Yes | - |
Return Value Description: Winner list data within the group, type Promise<LotteryWinnersData>. Detailed type description is as follows:
| Property Name | Description | Type |
|---|---|---|
contents |
Winner List | LotteryWinnerItem[] |
pageNumber |
Current Page Number | number |
pageSize |
Items Per Page | number |
totalItems |
Total Items | number |
totalPages |
Total Pages | number |
Example:
// 获取特定分组的中奖名单
const groupWinners = await watchCore.welfareLottery.getLotteryWinnersByGroup({
lotteryId: '123456',
groupId: 1
});
console.log('分组中奖名单', groupWinners);
2.12 Get Current Watch Time
Description: Retrieves the current watch time.
API Method: getLotteryWatchTime(): number
Return Value Description: Current watch time.
Example:
const watchTime = watchCore.welfareLottery.getLotteryWatchTime();
console.log('当前观看时间', watchTime);
3. Module Events
3.1 Lottery Start Event
Description: Triggered when a welfare lottery activity starts.
Event: WelfareLotteryEvents.StartLottery
Callback Parameters: __PLV_KEEP
